PluginProbe
Vimeography: Vimeo Video Gallery WordPress Plugin / 0.6.1
Vimeography: Vimeo Video Gallery WordPress Plugin v0.6.1
2.4.9 2.4.8 trunk 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 0.6 0.6.1 0.6.2 0.6.3 0.6.4 0.6.5 0.6.6 0.6.7 0.6.8 0.6.8.1 0.6.9 0.6.9.1 0.6.9.2 0.7 0.8 All 103 releases
vimeography / vimeography.php

vimeography.php in Vimeography: Vimeo Video Gallery WordPress Plugin 0.6.1, at vimeography.php

594 lines 21.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Vimeography
4 Plugin URI: http://vimeography.com
5 Description: Vimeography is the easiest way to set up a custom Vimeo gallery on your site.
6 Version: 0.6.1
7 Author: Dave Kiss
8 Author URI: http://davekiss.com
9 License: MIT
10 */
11
12 if (!function_exists('json_decode'))
13 wp_die('Vimeography needs the JSON PHP extension.');
14
15 global $wpdb;
16 $wp_upload_dir = wp_upload_dir();
17
18 // Define constants
19 define( 'VIMEOGRAPHY_URL', plugin_dir_url(__FILE__) );
20 define( 'VIMEOGRAPHY_PATH', plugin_dir_path(__FILE__) );
21 define( 'VIMEOGRAPHY_THEME_URL', $wp_upload_dir['baseurl'].'/vimeography-themes/' );
22 define( 'VIMEOGRAPHY_THEME_PATH', $wp_upload_dir['basedir'].'/vimeography-themes/' );
23 define( 'VIMEOGRAPHY_ASSETS_URL', $wp_upload_dir['baseurl'].'/vimeography-assets/' );
24 define( 'VIMEOGRAPHY_ASSETS_PATH', $wp_upload_dir['basedir'].'/vimeography-assets/' );
25 define( 'VIMEOGRAPHY_BASENAME', plugin_basename( __FILE__ ) );
26 define( 'VIMEOGRAPHY_VERSION', '0.6.1');
27 define( 'VIMEOGRAPHY_GALLERY_TABLE', $wpdb->prefix . "vimeography_gallery");
28 define( 'VIMEOGRAPHY_GALLERY_META_TABLE', $wpdb->prefix . "vimeography_gallery_meta");
29 define( 'VIMEOGRAPHY_CURRENT_PAGE', basename($_SERVER['PHP_SELF']));
30
31 require_once(VIMEOGRAPHY_PATH . '/vendor/mustache/Mustache.php');
32
33 class Vimeography
34 {
35 public function __construct()
36 {
37 add_action( 'init', array(&$this, 'vimeography_init') );
38 add_action( 'admin_init', array(&$this, 'vimeography_requires_wordpress_version') );
39 add_action( 'admin_init', array(&$this, 'vimeography_check_if_db_exists') );
40 add_action( 'plugins_loaded', array(&$this, 'vimeography_update_db_to_0_6') );
41 add_action( 'plugins_loaded', array(&$this, 'vimeography_update_db_version') );
42 add_action( 'admin_menu', array(&$this, 'vimeography_add_menu') );
43
44 register_activation_hook( VIMEOGRAPHY_BASENAME, array(&$this, 'vimeography_update_tables') );
45
46 add_filter( 'plugin_action_links', array(&$this, 'vimeography_filter_plugin_actions'), 10, 2 );
47 add_shortcode( 'vimeography', array(&$this, 'vimeography_shortcode') );
48
49 // Add shortcode support for widgets
50 add_filter( 'widget_text', 'do_shortcode' );
51 }
52
53 public function vimeography_init()
54 {
55 if(in_array(VIMEOGRAPHY_CURRENT_PAGE, array('post.php', 'page.php', 'page-new.php', 'post-new.php'))){
56 add_action('admin_footer', array(&$this, 'vimeography_add_mce_popup'));
57 }
58
59 if ( get_user_option('rich_editing') == 'true' ) {
60 add_filter( 'mce_external_plugins', array(&$this, 'vimeography_add_editor_plugin' ));
61 add_filter( 'mce_buttons', array(&$this, 'vimeography_register_editor_button') );
62 }
63
64 }
65
66 public function vimeography_register_editor_button($buttons)
67 {
68 array_push( $buttons, "|", "vimeography" );
69 return $buttons;
70 }
71
72 public function vimeography_add_editor_plugin( $plugin_array ) {
73 $plugin_array['vimeography'] = VIMEOGRAPHY_URL . 'media/js/mce.js';
74 return $plugin_array;
75 }
76
77 /**
78 * Check the wordpress version is compatible, and disable plugin if not.
79 *
80 * @access public
81 * @return void
82 */
83 public function vimeography_requires_wordpress_version() {
84 global $wp_version;
85 $plugin = plugin_basename( __FILE__ );
86 $plugin_data = get_plugin_data( __FILE__, false );
87
88 if ( version_compare($wp_version, "3.3", "<" ) ) {
89 if( is_plugin_active($plugin) ) {
90 deactivate_plugins( $plugin );
91 wp_die( "'".$plugin_data['Name']."' requires WordPress 3.3 or higher, and has been deactivated! Please upgrade WordPress and try again.<br /><br />Back to <a href='".admin_url()."'>WordPress admin</a>." );
92 }
93 }
94 }
95
96 public function vimeography_check_if_db_exists()
97 {
98 if (get_option('vimeography_db_version') == FALSE)
99 $this->vimeography_update_db_version();
100 }
101
102 /**
103 * Check if the Vimeography database structure needs updated to version 0.6 based on the stored db version.
104 *
105 * @access public
106 * @return void
107 */
108 public function vimeography_update_db_to_0_6()
109 {
110 if (get_option('vimeography_db_version') < 0.6)
111 {
112 global $wpdb;
113 $old_galleries = $wpdb->get_results('SELECT * FROM '.VIMEOGRAPHY_GALLERY_META_TABLE.' AS meta JOIN '.VIMEOGRAPHY_GALLERY_TABLE.' AS gallery ON meta.gallery_id = gallery.id;');
114 $new_galleries = array();
115
116 if (is_array($old_galleries))
117 {
118 foreach ($old_galleries as $old_gallery)
119 {
120 $new_gallery = array();
121
122 $new_gallery['gallery_id'] = $old_gallery->gallery_id;
123 $new_gallery['video_limit'] = $old_gallery->video_count;
124 $new_gallery['featured_video'] = $old_gallery->featured_video;
125 $new_gallery['cache_timeout'] = $old_gallery->cache_timeout;
126 $new_gallery['theme_name'] = $old_gallery->theme_name;
127 switch ($old_gallery->source_type)
128 {
129 case 'user':
130 $new_gallery['source_url'] = 'https://vimeo.com/'.$old_gallery->source_name;
131 break;
132 case 'album':
133 $new_gallery['source_url'] = 'https://vimeo.com/album/'.$old_gallery->source_name;
134 break;
135 case 'group':
136 $new_gallery['source_url'] = 'https://vimeo.com/groups/'.$old_gallery->source_name;
137 break;
138 case 'channel':
139 $new_gallery['source_url'] = 'https://vimeo.com/channels/'.$old_gallery->source_name;
140 break;
141 }
142 $new_galleries[] = $new_gallery;
143 }
144 }
145 $wpdb->query('DROP TABLE '.VIMEOGRAPHY_GALLERY_META_TABLE.';');
146
147 $this->vimeography_update_tables();
148
149 foreach ($new_galleries as $new_gallery)
150 {
151 $wpdb->insert(
152 VIMEOGRAPHY_GALLERY_META_TABLE,
153 $new_gallery
154 );
155 }
156 }
157 }
158
159 /**
160 * Updates the Vimeography version stored in the database.
161 *
162 * @access public
163 * @return void
164 */
165 public function vimeography_update_db_version()
166 {
167 update_option('vimeography_db_version', VIMEOGRAPHY_VERSION);
168 }
169
170 /**
171 * Add Settings link to "installed plugins" admin page.
172 *
173 * @access public
174 * @param mixed $links
175 * @param mixed $file
176 * @return void
177 */
178 public function vimeography_filter_plugin_actions($links, $file)
179 {
180 if ( $file == VIMEOGRAPHY_BASENAME )
181 {
182 $settings_link = '<a href="admin.php?page=vimeography-edit-galleries">' . __('Settings') . '</a>';
183 if (!in_array($settings_link, $links))
184 array_unshift( $links, $settings_link ); // before other links
185 }
186 return $links;
187 }
188
189 /**
190 * Action target that displays the popup to insert a form to a post/page.
191 *
192 * @access public
193 * @return void
194 */
195 public function vimeography_add_mce_popup(){
196 require_once(VIMEOGRAPHY_PATH . 'lib/admin/view/vimeography/mce.php');
197 $mustache = new Vimeography_MCE();
198 $template = $this->_load_template('vimeography/mce');
199 echo $mustache->render($template);
200 }
201
202 /**
203 * Adds a new top level menu to the admin menu.
204 *
205 * @access public
206 * @return void
207 */
208 public function vimeography_add_menu()
209 {
210
211 global $submenu;
212
213 add_menu_page( 'Vimeography Page Title', 'Vimeography', 'manage_options', 'vimeography-edit-galleries', '', VIMEOGRAPHY_URL.'media/img/vimeography-icon.png' );
214 add_submenu_page( 'vimeography-edit-galleries', 'Edit Galleries', 'Edit Galleries', 'manage_options', 'vimeography-edit-galleries', array(&$this, 'vimeography_render_template' ));
215 add_submenu_page( 'vimeography-edit-galleries', 'New Gallery', 'New Gallery', 'manage_options', 'vimeography-new-gallery', array(&$this, 'vimeography_render_template' ));
216 add_submenu_page( 'vimeography-edit-galleries', 'My Themes', 'My Themes', 'manage_options', 'vimeography-my-themes', array(&$this, 'vimeography_render_template' ));
217 $submenu['vimeography-edit-galleries'][500] = array( 'Buy Themes', 'manage_options' , 'http://vimeography.com/themes' );
218 add_submenu_page( 'vimeography-edit-galleries', 'Vimeography Pro', 'Vimeography Pro', 'manage_options', 'vimeography-pro', array(&$this, 'vimeography_render_template' ));
219 add_submenu_page( 'vimeography-edit-galleries', 'Help', 'Help', 'manage_options', 'vimeography-help', array(&$this, 'vimeography_render_template' ));
220
221 }
222
223 public function vimeography_render_template()
224 {
225 if ( !current_user_can( 'manage_options' ) ) {
226 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
227 }
228
229 wp_register_style( 'bootstrap_css', VIMEOGRAPHY_URL.'media/css/bootstrap.min.css');
230 wp_register_style( 'bootstrap_responsive_css', VIMEOGRAPHY_URL.'media/css/bootstrap-responsive.min.css');
231 wp_register_style( 'vimeography-admin.css', VIMEOGRAPHY_URL.'media/css/admin.css');
232 wp_register_script( 'bootstrap_tab_js', VIMEOGRAPHY_URL.'media/js/bootstrap-tab.js');
233 wp_register_script( 'bootstrap_alert_js', VIMEOGRAPHY_URL.'media/js/bootstrap-alert.js');
234 wp_register_script( 'vimeography-admin.js', VIMEOGRAPHY_URL.'media/js/admin.js', 'jquery');
235
236 wp_enqueue_style( 'bootstrap_css');
237 wp_enqueue_style( 'bootstrap_responsive_css');
238 wp_enqueue_style( 'vimeography-admin.css');
239 wp_enqueue_script( 'jquery');
240 wp_enqueue_script( 'bootstrap_tab_js');
241 wp_enqueue_script( 'bootstrap_alert_js');
242 wp_enqueue_script( 'vimeography-admin.js');
243
244 switch(current_filter())
245 {
246 case 'vimeography_page_vimeography-new-gallery':
247 require_once(VIMEOGRAPHY_PATH . 'lib/admin/view/gallery/new.php');
248 $mustache = new Vimeography_Gallery_New();
249 $template = $this->_load_template('gallery/new');
250 break;
251 case 'toplevel_page_vimeography-edit-galleries':
252 if (isset($_GET['id']))
253 {
254 require_once(VIMEOGRAPHY_PATH . 'lib/admin/view/gallery/edit.php');
255 $mustache = new Vimeography_Gallery_Edit();
256 $template = $this->_load_template('gallery/edit');
257 }
258 else
259 {
260 require_once(VIMEOGRAPHY_PATH . 'lib/admin/view/gallery/list.php');
261 $mustache = new Vimeography_Gallery_List();
262 $template = $this->_load_template('gallery/list');
263 }
264 break;
265 case 'vimeography_page_vimeography-my-themes':
266 require_once(VIMEOGRAPHY_PATH . 'lib/admin/view/theme/list.php');
267 $mustache = new Vimeography_Theme_List();
268 $template = $this->_load_template('theme/list');
269 break;
270 case 'vimeography_page_vimeography-pro':
271 require_once(VIMEOGRAPHY_PATH . 'lib/admin/view/vimeography/pro.php');
272 $mustache = new Vimeography_Pro();
273 $template = $this->_load_template('vimeography/pro');
274 break;
275 case 'vimeography_page_vimeography-help':
276 require_once(VIMEOGRAPHY_PATH . 'lib/admin/view/vimeography/help.php');
277 $mustache = new Vimeography_Help();
278 $template = $this->_load_template('vimeography/help');
279 break;
280 default:
281 wp_die( __('The admin template for "'.current_filter().'" cannot be found.') );
282 break;
283 }
284 echo $mustache->render($template);
285 }
286
287 protected function _load_template($name)
288 {
289 $path = VIMEOGRAPHY_PATH . 'lib/admin/templates/' . $name .'.mustache';
290 if (! $result = @file_get_contents($path))
291 wp_die('The admin template "'.$name.'" cannot be found.');
292 return $result;
293 }
294
295 /**
296 * Create tables and define defaults when plugin is activated.
297 *
298 * @access public
299 * @return void
300 */
301 public function vimeography_update_tables() {
302 global $wpdb;
303
304 delete_option('vimeography_default_settings');
305 delete_option('vimeography_advanced_settings');
306
307 add_option('vimeography_advanced_settings', array(
308 'active' => FALSE,
309 'client_id' => '',
310 'client_secret' => '',
311 'access_token' => '',
312 'access_token_secret' => '',
313 ));
314
315 add_option('vimeography_default_settings', array(
316 'source_url' => 'https://vimeo.com/channels/staffpicks/',
317 'video_limit' => 20,
318 'featured_video' => '',
319 'cache_timeout' => 3600,
320 'theme_name' => 'bugsauce',
321 ));
322
323 $sql = 'CREATE TABLE '.VIMEOGRAPHY_GALLERY_TABLE.' (
324 id mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
325 title varchar(150) NOT NULL,
326 date_created datetime NOT NULL,
327 is_active tinyint(1) NOT NULL,
328 PRIMARY KEY (id)
329 );
330 CREATE TABLE '.VIMEOGRAPHY_GALLERY_META_TABLE.' (
331 id mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
332 gallery_id mediumint(8) unsigned NOT NULL,
333 source_url varchar(100) NOT NULL,
334 video_limit mediumint(7) NOT NULL,
335 featured_video int(9) unsigned DEFAULT NULL,
336 cache_timeout mediumint(7) NOT NULL,
337 theme_name varchar(50) NOT NULL,
338 PRIMARY KEY (id)
339 );
340 ';
341
342 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
343 dbDelta($sql);
344
345 // Let's also move the bugsauce folder to the vimeography_theme_path (wp-content/uploads)
346 $this->_move_theme(array('source' => VIMEOGRAPHY_PATH . 'bugsauce/', 'destination' => VIMEOGRAPHY_THEME_PATH.'bugsauce/', 'clear_destination' => true, 'clear_working' => true));
347 $this->_move_theme(array('source' => VIMEOGRAPHY_PATH . 'theme-assets/', 'destination' => VIMEOGRAPHY_ASSETS_PATH, 'clear_destination' => true, 'clear_working' => true));
348
349 }
350
351 /**
352 * Read the shortcode and return the output.
353 * example:
354 * [vimeography from='user' named='davekiss' theme='apple']
355 *
356 * @access public
357 * @param mixed $atts
358 * @return void
359 */
360 public function vimeography_shortcode($atts)
361 {
362
363 // Let's get the data for this gallery from the db
364 if (intval($atts['id']))
365 {
366 global $wpdb;
367 $gallery_info = $wpdb->get_results('SELECT * from '.VIMEOGRAPHY_GALLERY_META_TABLE.' AS meta JOIN '.VIMEOGRAPHY_GALLERY_TABLE.' AS gallery ON meta.gallery_id = gallery.id WHERE meta.gallery_id = '.$atts['id'].' LIMIT 1;');
368 }
369
370 // Get admin panel options
371 $default_settings = get_option('vimeography_default_settings');
372
373 $gallery_settings['theme'] = isset($gallery_info[0]->theme_name) ? $gallery_info[0]->theme_name : $default_settings['theme_name'];
374 $gallery_settings['featured'] = isset($gallery_info[0]->featured_video) ? $gallery_info[0]->featured_video : $default_settings['featured_video'];
375 $gallery_settings['source'] = isset($gallery_info[0]->source_url) ? $gallery_info[0]->source_url : $default_settings['source_url'];
376 $gallery_settings['limit'] = isset($gallery_info[0]->video_limit) ? $gallery_info[0]->video_limit : $default_settings['video_limit'];
377 $gallery_settings['cache'] = isset($gallery_info[0]->cache_timeout) ? $gallery_info[0]->cache_timeout : $default_settings['cache_timeout'];
378
379 // Get shortcode attributes
380 $settings = shortcode_atts( array(
381 'id' => '',
382 'theme' => $gallery_settings['theme'],
383 'featured' => $gallery_settings['featured'],
384 'source' => $gallery_settings['source'],
385 'limit' => $gallery_settings['limit'],
386 'cache' => $gallery_settings['cache'],
387 ), $atts );
388
389 try
390 {
391 require_once(VIMEOGRAPHY_PATH . 'lib/core.php');
392 $vimeography = Vimeography_Core::factory('videos', $settings);
393
394 $settings_check = $settings;
395 $unused_id = array_shift($settings_check);
396
397 // If the shortcode settings are equal to the DB settings, the
398 // gallery isn't being overloaded by shortcode, so proceed to render
399 // the standard cache.
400
401 if ($settings_check == $gallery_settings)
402 {
403 // if cache is set, render it. otherwise, get the json, set the
404 // cache, and render it
405
406 if (($vimeography_data = $this->get_vimeography_cache($settings['id'])) === FALSE)
407 {
408 // cache not set, let's do a new request to the vimeo API
409 // and cache it
410 $vimeography_data = $vimeography->get('videos');
411 $transient = $this->set_vimeography_cache($settings['id'], $vimeography_data, $settings['cache']);
412 }
413 }
414 // Otherwise, let's see if a cache exists for these particular
415 // shortcode settings, and if not, we'll create one using an
416 // alternate cache name generated using an md5 of the serialized
417 // shortcode combines with the gallery id.
418
419 else
420 {
421 $cache_hash = $settings['id'].'_'.md5(serialize($gallery_settings));
422
423 // if cache is set, render it. otherwise, get the json, set the
424 // cache, and render it
425 if (($vimeography_data = $this->get_vimeography_cache($cache_hash)) === FALSE)
426 {
427 // cache not set, let's do a new request to the vimeo API
428 // and cache it
429 $vimeography_data = $vimeography->get('videos');
430 $transient = $this->set_vimeography_cache($cache_hash, $vimeography_data, $settings['cache']);
431 }
432 }
433 return $vimeography->render($vimeography_data);
434 }
435 catch (Vimeography_Exception $e)
436 {
437 return "Vimeography error: ".$e->getMessage();
438 }
439 }
440
441 /**
442 * Get the JSON data stored in the Vimeography cache for the provided gallery id.
443 *
444 * @access public
445 * @static
446 * @param mixed $id
447 * @return void
448 */
449 public static function get_vimeography_cache($id)
450 {
451 return FALSE === ( $vimeography_cache_results = get_transient( 'vimeography_cache_'.$id ) ) ? FALSE : $vimeography_cache_results;
452 }
453
454 /**
455 * Set the JSON data to the Vimeography cache for the provided gallery id.
456 *
457 * @access public
458 * @static
459 * @param mixed $id
460 * @param mixed $data
461 * @param mixed $cache_limit
462 * @return void
463 */
464 public static function set_vimeography_cache($id, $data, $cache_limit)
465 {
466 return set_transient( 'vimeography_cache_'.$id, $data, $cache_limit );
467 }
468
469 /**
470 * Clear the Vimeography cache for the provided gallery id.
471 *
472 * @access public
473 * @static
474 * @param mixed $id
475 * @return void
476 */
477 public static function delete_vimeography_cache($id)
478 {
479 return delete_transient('vimeography_cache_'.$id);
480 }
481
482 /**
483 * Moves the given folder to the given destination.
484 *
485 * @access private
486 * @param array $args (default: array())
487 * @return void
488 */
489 private function _move_theme($args = array())
490 {
491 // Replaces simple `WP_Filesystem();` call to prevent any extraction issues
492 // @link http://wpquestions.com/question/show/id/2685
493 if (! function_exists('__return_direct'))
494 {
495 function __return_direct() { return 'direct'; }
496 }
497
498 add_filter( 'filesystem_method', '__return_direct' );
499 WP_Filesystem();
500 remove_filter( 'filesystem_method', '__return_direct' );
501
502 global $wp_filesystem;
503 $defaults = array( 'source' => '', 'destination' => '', //Please always pass these
504 'clear_destination' => false, 'clear_working' => false,
505 'hook_extra' => array());
506
507 $args = wp_parse_args($args, $defaults);
508 extract($args);
509
510 @set_time_limit( 300 );
511
512 if ( empty($source) || empty($destination) )
513 return new WP_Error('bad_request', 'bad request.');
514
515 // $this->skin->feedback('installing_package');
516
517 //Retain the Original source and destinations
518 $remote_source = $source;
519 $local_destination = $destination;
520
521 if (! $wp_filesystem->dirlist($remote_source)) return FALSE;
522
523 $source_files = array_keys( $wp_filesystem->dirlist($remote_source) );
524 $remote_destination = $wp_filesystem->find_folder($local_destination);
525
526 //Locate which directory to copy to the new folder, This is based on the actual folder holding the files.
527 if ( 1 == count($source_files) && $wp_filesystem->is_dir( trailingslashit($source) . $source_files[0] . '/') ) //Only one folder? Then we want its contents.
528 $source = trailingslashit($source) . trailingslashit($source_files[0]);
529 elseif ( count($source_files) == 0 )
530 return new WP_Error( 'incompatible_archive', 'incompatible archive string', __( 'The plugin contains no files.' ) ); //There are no files?
531 else //Its only a single file, The upgrader will use the foldername of this file as the destination folder. foldername is based on zip filename.
532 $source = trailingslashit($source);
533
534 //Has the source location changed? If so, we need a new source_files list.
535 if ( $source !== $remote_source )
536 $source_files = array_keys( $wp_filesystem->dirlist($source) );
537
538 if ( $clear_destination ) {
539 //We're going to clear the destination if there's something there
540 //$this->skin->feedback('remove_old');
541 $removed = true;
542 if ( $wp_filesystem->exists($remote_destination) )
543 $removed = $wp_filesystem->delete($remote_destination, true);
544 if ( is_wp_error($removed) )
545 return $removed;
546 else if ( ! $removed )
547 return new WP_Error('remove_old_failed', 'couldnt remove old');
548 } elseif ( $wp_filesystem->exists($remote_destination) ) {
549 //If we're not clearing the destination folder and something exists there already, Bail.
550 //But first check to see if there are actually any files in the folder.
551 $_files = $wp_filesystem->dirlist($remote_destination);
552 if ( ! empty($_files) ) {
553 $wp_filesystem->delete($remote_source, true); //Clear out the source files.
554 return new WP_Error('folder_exists', 'folder exists string', $remote_destination );
555 }
556 }
557
558 //Create themes folder, if needed
559 if ( !$wp_filesystem->exists(VIMEOGRAPHY_THEME_PATH) )
560 if ( !$wp_filesystem->mkdir(VIMEOGRAPHY_THEME_PATH, FS_CHMOD_DIR) )
561 return new WP_Error('mkdir_failed', 'mkdir failer string', $remote_destination);
562
563 //Create destination if needed
564 if ( !$wp_filesystem->exists($remote_destination) )
565 if ( !$wp_filesystem->mkdir($remote_destination, FS_CHMOD_DIR) )
566 return new WP_Error('mkdir_failed', 'mkdir failer string', $remote_destination);
567
568 // Copy new version of item into place.
569 $result = copy_dir($source, $remote_destination);
570
571 if ( is_wp_error($result) ) {
572 if ( $clear_working )
573 $wp_filesystem->delete($remote_source, true);
574 return $result;
575 }
576
577 //Clear the Working folder?
578 if ( $clear_working )
579 $wp_filesystem->delete($remote_source, true);
580
581 $destination_name = basename( str_replace($local_destination, '', $destination) );
582 if ( '.' == $destination_name )
583 $destination_name = '';
584
585 $result = compact('local_source', 'source', 'source_name', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination', 'delete_source_dir');
586
587 //Bombard the calling function will all the info which we've just used.
588 return $result;
589
590 }
591
592 }
593
594 new Vimeography;