PluginProbe
Vimeography: Vimeo Video Gallery WordPress Plugin / 0.6.7
Vimeography: Vimeo Video Gallery WordPress Plugin v0.6.7
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.7, at vimeography.php

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