81
81
return new WP_Error('fs_error', $this->strings['fs_error'], $wp_filesystem->errors);
83
83
foreach ( (array)$directories as $dir ) {
84
if ( ABSPATH == $dir && ! $wp_filesystem->abspath() )
85
return new WP_Error('fs_no_root_dir', $this->strings['fs_no_root_dir']);
87
elseif ( WP_CONTENT_DIR == $dir && ! $wp_filesystem->wp_content_dir() )
88
return new WP_Error('fs_no_content_dir', $this->strings['fs_no_content_dir']);
90
elseif ( WP_PLUGIN_DIR == $dir && ! $wp_filesystem->wp_plugins_dir() )
91
return new WP_Error('fs_no_plugins_dir', $this->strings['fs_no_plugins_dir']);
93
elseif ( WP_CONTENT_DIR . '/themes' == $dir && ! $wp_filesystem->find_folder(WP_CONTENT_DIR . '/themes') )
94
return new WP_Error('fs_no_themes_dir', $this->strings['fs_no_themes_dir']);
96
elseif ( ! $wp_filesystem->find_folder($dir) )
97
return new WP_Error('fs_no_folder', sprintf($strings['fs_no_folder'], $dir));
86
if ( ! $wp_filesystem->abspath() )
87
return new WP_Error('fs_no_root_dir', $this->strings['fs_no_root_dir']);
90
if ( ! $wp_filesystem->wp_content_dir() )
91
return new WP_Error('fs_no_content_dir', $this->strings['fs_no_content_dir']);
94
if ( ! $wp_filesystem->wp_plugins_dir() )
95
return new WP_Error('fs_no_plugins_dir', $this->strings['fs_no_plugins_dir']);
97
case WP_CONTENT_DIR . '/themes':
98
if ( ! $wp_filesystem->find_folder(WP_CONTENT_DIR . '/themes') )
99
return new WP_Error('fs_no_themes_dir', $this->strings['fs_no_themes_dir']);
102
if ( ! $wp_filesystem->find_folder($dir) )
103
return new WP_Error('fs_no_folder', sprintf($this->strings['fs_no_folder'], $dir));
100
108
} //end fs_connect();
202
210
$destination = trailingslashit($destination) . trailingslashit(basename($source));
205
//If we're not clearing the destination folder, and something exists there allready, Bail.
206
if ( ! $clear_destination && $wp_filesystem->exists($remote_destination) ) {
207
$wp_filesystem->delete($remote_source, true); //Clear out the source files.
208
return new WP_Error('folder_exists', $this->strings['folder_exists'], $remote_destination );
209
} else if ( $clear_destination ) {
210
//We're going to clear the destination if theres something there
211
$this->skin->feedback('remove_old');
214
if ( $wp_filesystem->exists($remote_destination) )
213
if ( $wp_filesystem->exists($remote_destination) ) {
214
if ( $clear_destination ) {
215
//We're going to clear the destination if theres something there
216
$this->skin->feedback('remove_old');
215
217
$removed = $wp_filesystem->delete($remote_destination, true);
217
$removed = apply_filters('upgrader_clear_destination', $removed, $local_destination, $remote_destination, $hook_extra);
219
if ( is_wp_error($removed) )
221
else if ( ! $removed )
222
return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
218
$removed = apply_filters('upgrader_clear_destination', $removed, $local_destination, $remote_destination, $hook_extra);
220
if ( is_wp_error($removed) )
222
else if ( ! $removed )
223
return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
225
//If we're not clearing the destination folder and something exists there allready, Bail.
226
//But first check to see if there are actually any files in the folder.
227
$_files = $wp_filesystem->dirlist($remote_destination);
228
if ( ! empty($_files) ) {
229
$wp_filesystem->delete($remote_source, true); //Clear out the source files.
230
return new WP_Error('folder_exists', $this->strings['folder_exists'], $remote_destination );
225
235
//Create destination if needed
261
271
'destination' => '', //And this
262
272
'clear_destination' => false,
263
273
'clear_working' => true,
264
275
'hook_extra' => array() //Pass any extra $hook_extra args here, this will be passed to any hooked filters.
417
//Cleanup our hooks, incase something else does a upgrade on this connection.
435
// Cleanup our hooks, incase something else does a upgrade on this connection.
418
436
remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));
419
437
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
425
443
delete_transient('update_plugins');
446
function bulk_upgrade($plugins) {
450
$this->upgrade_strings();
452
$current = get_transient( 'update_plugins' );
454
add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
456
$this->skin->header();
458
// Connect to the Filesystem first.
459
$res = $this->fs_connect( array(WP_CONTENT_DIR, WP_PLUGIN_DIR) );
461
$this->skin->footer();
465
$this->maintenance_mode(true);
467
$all = count($plugins);
469
foreach ( $plugins as $plugin ) {
471
$this->show_before = sprintf( '<h4>' . __('Updating plugin %1$d of %2$d...') . '</h4>', $i, $all );
474
if ( !isset( $current->response[ $plugin ] ) ) {
475
$this->skin->set_result(false);
476
$this->skin->error('up_to_date');
477
$this->skin->after();
478
$results[$plugin] = false;
482
// Get the URL to the zip file
483
$r = $current->response[ $plugin ];
485
$this->skin->plugin_active = is_plugin_active($plugin);
487
$result = $this->run(array(
488
'package' => $r->package,
489
'destination' => WP_PLUGIN_DIR,
490
'clear_destination' => true,
491
'clear_working' => true,
493
'hook_extra' => array(
498
$results[$plugin] = $this->result;
500
// Prevent credentials auth screen from displaying multiple times
501
if ( false === $result )
504
$this->maintenance_mode(false);
505
$this->skin->footer();
507
// Cleanup our hooks, incase something else does a upgrade on this connection.
508
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
510
// Force refresh of plugin update information
511
delete_transient('update_plugins');
428
516
//return plugin info.
429
517
function plugin_info() {
430
518
if ( ! is_array($this->result) )
822
910
function after() {
911
if ( $this->upgrader->bulk )
823
914
$this->plugin = $this->upgrader->plugin_info();
824
915
if( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
825
916
show_message(__('Attempting reactivation of the plugin'));
826
917
echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>';
828
920
$update_actions = array(
829
921
'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
830
922
'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . esc_attr__('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
838
930
if ( ! empty($update_actions) )
839
931
$this->feedback('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$update_actions));
935
if ( $this->upgrader->show_before ) {
936
echo $this->upgrader->show_before;
937
$this->upgrader->show_before = '';
996
1095
$name = $theme_info['Name'];
997
1096
$stylesheet = $this->upgrader->result['destination_name'];
998
1097
$template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet;
1000
1099
$preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) );
1001
1100
$activate_link = wp_nonce_url("themes.php?action=activate&template=" . urlencode($template) . "&stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template);
1003
1102
$update_actions = array(
1004
1103
'preview' => '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview “%s”'), $name)) . '">' . __('Preview') . '</a>',
1005
1104
'activate' => '<a href="' . $activate_link . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>',