protected function update($version, $locale)
 {
     $args = $this->input();
     $version = isset($args['version']) ? $args['version'] : false;
     $locale = isset($args['locale']) ? $args['locale'] : get_locale();
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     delete_site_transient('update_core');
     wp_version_check(array(), true);
     if ($version) {
         $update = find_core_update($version, $locale);
     } else {
         $update = $this->find_latest_update_offer();
     }
     /**
      * Pre-upgrade action
      * 
      * @since 3.9.3
      * 
      * @param object|array $update as returned by find_core_update() or find_core_auto_update()
      */
     do_action('jetpack_pre_core_upgrade', $update);
     $skin = new Automatic_Upgrader_Skin();
     $upgrader = new Core_Upgrader($skin);
     $this->new_version = $upgrader->upgrade($update);
     $this->log = $upgrader->skin->get_upgrade_messages();
     if (is_wp_error($this->new_version)) {
         return $this->new_version;
     }
     return $this->new_version;
 }
Пример #2
0
 /**
  * Update the WordPress core
  *
  * @param array $args
  */
 function update($args)
 {
     WP_CLI::line('Updating the WordPress core.');
     if (!class_exists('Core_Upgrader')) {
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     }
     ob_start();
     $upgrader = new Core_Upgrader(new CLI_Upgrader_Skin());
     $result = $upgrader->upgrade($current);
     $feedback = ob_get_clean();
     // Borrowed verbatim from wp-admin/update-core.php
     if (is_wp_error($result)) {
         if ('up_to_date' != $result->get_error_code()) {
             WP_CLI::error('Installation failed (' . WP_CLI::errorToString($result) . ').');
         } else {
             WP_CLI::success(WP_CLI::errorToString($result));
         }
     } else {
         WP_CLI::success('WordPress upgraded successfully.');
     }
 }
 private function update($version, $locale)
 {
     $args = $this->input();
     $version = isset($args['version']) ? $args['version'] : false;
     $locale = isset($args['locale']) ? $args['locale'] : get_locale();
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     delete_site_transient('update_core');
     wp_version_check(array(), true);
     if ($version) {
         $update = find_core_update($version, $locale);
     } else {
         $update = $this->find_latest_update_offer();
     }
     $skin = new Automatic_Upgrader_Skin();
     $upgrader = new Core_Upgrader($skin);
     $this->new_version = $upgrader->upgrade($update);
     $this->log = $upgrader->skin->get_upgrade_messages();
     if (is_wp_error($this->new_version)) {
         return $this->new_version;
     }
     return $this->new_version;
 }
Пример #4
0
 /**
  * Upgrades WordPress locally
  */
 public function upgrade_core($current)
 {
     ob_start();
     if (file_exists(ABSPATH . '/wp-admin/includes/update.php')) {
         include_once ABSPATH . '/wp-admin/includes/update.php';
     }
     @wp_version_check();
     $current_update = false;
     ob_end_flush();
     ob_end_clean();
     $core = $this->mmb_get_transient('update_core');
     if (isset($core->updates) && !empty($core->updates)) {
         $updates = $core->updates[0];
         $updated = $core->updates[0];
         if (!isset($updated->response) || $updated->response == 'latest') {
             return array('upgraded' => ' updated');
         }
         if ($updated->response == "development" && $current['response'] == "upgrade") {
             return array('error' => '<font color="#900">Unexpected error. Please upgrade manually.</font>');
         } else {
             if ($updated->response == $current['response'] || $updated->response == "upgrade" && $current['response'] == "development") {
                 if ($updated->locale != $current['locale']) {
                     foreach ($updates as $update) {
                         if ($update->locale == $current['locale']) {
                             $current_update = $update;
                             break;
                         }
                     }
                     if ($current_update == false) {
                         return array('error' => ' Localization mismatch. Try again.');
                     }
                 } else {
                     $current_update = $updated;
                 }
             } else {
                 return array('error' => ' Transient mismatch. Try again.');
             }
         }
     } else {
         return array('error' => ' Refresh transient failed. Try again.');
     }
     if ($current_update != false) {
         global $wp_filesystem, $wp_version;
         if (version_compare($wp_version, '3.1.9', '>')) {
             if (!class_exists('Core_Upgrader')) {
                 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
             }
             /** @handled class */
             $core = new Core_Upgrader(mwp_container()->getUpdaterSkin());
             $result = $core->upgrade($current_update);
             $this->mmb_maintenance_mode(false);
             if (is_wp_error($result)) {
                 return array('error' => $this->mmb_get_error($result));
             } else {
                 return array('upgraded' => ' updated');
             }
         } else {
             if (!class_exists('WP_Upgrader')) {
                 include_once ABSPATH . 'wp-admin/includes/update.php';
                 if (function_exists('wp_update_core')) {
                     $result = wp_update_core($current_update);
                     if (is_wp_error($result)) {
                         return array('error' => $this->mmb_get_error($result));
                     } else {
                         return array('upgraded' => ' updated');
                     }
                 }
             }
             if (class_exists('WP_Upgrader')) {
                 /** @handled class */
                 $upgrader_skin = new WP_Upgrader_Skin();
                 $upgrader_skin->done_header = true;
                 /** @handled class */
                 $upgrader = new WP_Upgrader($upgrader_skin);
                 // Is an update available?
                 if (!isset($current_update->response) || $current_update->response == 'latest') {
                     return array('upgraded' => ' updated');
                 }
                 $res = $upgrader->fs_connect(array(ABSPATH, WP_CONTENT_DIR));
                 if (is_wp_error($res)) {
                     return array('error' => $this->mmb_get_error($res));
                 }
                 $wp_dir = trailingslashit($wp_filesystem->abspath());
                 $core_package = false;
                 if (isset($current_update->package) && !empty($current_update->package)) {
                     $core_package = $current_update->package;
                 } elseif (isset($current_update->packages->full) && !empty($current_update->packages->full)) {
                     $core_package = $current_update->packages->full;
                 }
                 $download = $upgrader->download_package($core_package);
                 if (is_wp_error($download)) {
                     return array('error' => $this->mmb_get_error($download));
                 }
                 $working_dir = $upgrader->unpack_package($download);
                 if (is_wp_error($working_dir)) {
                     return array('error' => $this->mmb_get_error($working_dir));
                 }
                 if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
                     $wp_filesystem->delete($working_dir, true);
                     return array('error' => 'Unable to move update files.');
                 }
                 $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
                 require ABSPATH . 'wp-admin/includes/update-core.php';
                 $update_core = update_core($working_dir, $wp_dir);
                 ob_end_clean();
                 $this->mmb_maintenance_mode(false);
                 if (is_wp_error($update_core)) {
                     return array('error' => $this->mmb_get_error($update_core));
                 }
                 ob_end_flush();
                 return array('upgraded' => 'updated');
             } else {
                 return array('error' => 'failed');
             }
         }
     } else {
         return array('error' => 'failed');
     }
 }
Пример #5
0
 public function do_core_upgrade($params)
 {
     $required_fields = array('upgrade_id', 'locale', 'version');
     $errors = array();
     foreach ($required_fields as $field) {
         if (!isset($params[$field])) {
             $errors[] = "The '{$field}' field is missing.";
         }
     }
     if (empty($errors)) {
         require_once $GLOBALS['ithemes_updater_path'] . '/functions.php';
         $updates = Ithemes_Sync_Functions::get_update_details(array('verbose' => true, 'force_refresh' => array('core')));
         if (empty($updates['core'])) {
             $errors[] = 'No core updates are currently available.';
         } else {
             if (empty($updates['core'][$params['upgrade_id']])) {
                 $errors[] = 'Unable to find an availble upgrade matching the requested upgrade_id.';
             } else {
                 if ($params['locale'] != $updates['core'][$params['upgrade_id']]->locale) {
                     $errors[] = 'The requested upgrade does not match the requested locale.';
                 } else {
                     if (isset($updates['core'][$params['upgrade_id']]->version) && $params['version'] != $updates['core'][$params['upgrade_id']]->version) {
                         $errors[] = 'The requested upgrade does not match the requested version.';
                     } else {
                         if (isset($updates['core'][$params['upgrade_id']]->current) && $params['version'] != $updates['core'][$params['upgrade_id']]->current) {
                             $errors[] = 'The requested upgrade does not match the requested version.';
                         }
                     }
                 }
             }
         }
     }
     if (!empty($errors)) {
         return array('errors' => $errors);
     }
     Ithemes_Sync_Functions::set_time_limit(300);
     $original_version = Ithemes_Sync_Functions::get_wordpress_version();
     require_once ABSPATH . 'wp-admin/includes/file.php';
     require_once ABSPATH . 'wp-admin/includes/update.php';
     require_once ABSPATH . 'wp-admin/includes/misc.php';
     $upgrader = new Core_Upgrader($this->skin);
     $result = $upgrader->upgrade($updates['core'][$params['upgrade_id']]);
     Ithemes_Sync_Functions::refresh_core_updates();
     if (is_wp_error($result)) {
         return array('errors' => array($result->get_error_code() => $result->get_error_message()));
     }
     $current_version = Ithemes_Sync_Functions::get_wordpress_version();
     $current_updates = Ithemes_Sync_Functions::get_update_details(array('force_refresh' => array('core')));
     $current_update_version = false;
     foreach ($current_updates['core'] as $index => $update) {
         if (version_compare($update->version, $current_update_version, '>')) {
             $current_update_version = $update->version;
         }
     }
     $response = array('wordpress_response' => $result, 'original_version' => $original_version, 'current_version' => $current_version, 'current_update_version' => $current_update_version, 'original_update_version' => $updates['core'][$params['upgrade_id']]->version);
     if (is_multisite()) {
         // Based on the upgrade action of wp-admin/network/upgrade.php
         $wp_db_version = Ithemes_Sync_Functions::get_wordpress_db_version();
         update_site_option('wpmu_upgrade_site', $wp_db_version);
         global $wpdb;
         $blogs = $wpdb->get_results("SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0'", ARRAY_A);
         $response['network_upgrade'] = true;
         foreach ((array) $blogs as $details) {
             switch_to_blog($details['blog_id']);
             $siteurl = site_url();
             $upgrade_url = admin_url('upgrade.php?step=upgrade_db');
             restore_current_blog();
             $result = wp_remote_get($upgrade_url, array('timeout' => 120, 'httpversion' => '1.1'));
             if (is_wp_error($result)) {
                 $response['network_upgrade'] = false;
                 $response['errors'][] = 'Unable to successfully upgrade the network. You may need to visit the network admin dashboard to manually upgrade the network.';
                 break;
             }
             do_action('after_mu_upgrade', $result);
             do_action('wpmu_upgrade_site', $details['blog_id']);
         }
     }
     if ($current_version == $params['version']) {
         $response['success'] = true;
     }
     return $response;
 }
 function unpack_package($package, $delete_package = false)
 {
     return parent::unpack_package($package, $delete_package);
 }
Пример #7
0
 private function _update_core($core)
 {
     global $wp_filesystem;
     $status = array('update' => 'core', 'core' => $core, 'oldVersion' => '', 'newVersion' => '');
     include ABSPATH . WPINC . '/version.php';
     $status['oldVersion'] = $wp_version;
     if (!current_user_can('update_core')) {
         $status['error'] = 'updates_permission_denied';
         return $status;
     }
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     wp_version_check();
     $locale = get_locale();
     $core_update_key = false;
     $core_update_latest_version = false;
     $get_core_updates = get_core_updates();
     @(include ABSPATH . WPINC . '/version.php');
     foreach ($get_core_updates as $k => $core_update) {
         if (isset($core_update->version) && version_compare($core_update->version, $wp_version, '>') && version_compare($core_update->version, $core_update_latest_version, '>')) {
             $core_update_latest_version = $core_update->version;
             $core_update_key = $k;
         }
     }
     if ($core_update_key === false) {
         $status['error'] = 'no_update_found';
         return $status;
     }
     $update = $get_core_updates[$core_update_key];
     // WP < 3.7
     if (!class_exists('Automatic_Upgrader_Skin')) {
         require_once UPDRAFTPLUS_DIR . '/central/classes/class-automatic-upgrader-skin.php';
     }
     $skin = new Automatic_Upgrader_Skin();
     $upgrader = new Core_Upgrader($skin);
     $result = $upgrader->upgrade($update);
     $status['messages'] = $upgrader->skin->get_upgrade_messages();
     if (is_wp_error($result)) {
         $status['error'] = $result->get_error_code();
         $status['error_message'] = $result->get_error_message();
         return $status;
     } else {
         if (is_bool($result) && !$result) {
             $status['error'] = 'unable_to_connect_to_filesystem';
             // Pass through the error from WP_Filesystem if one was raised
             if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
                 $status['error'] = $wp_filesystem->errors->get_error_code();
                 $status['error_message'] = $wp_filesystem->errors->get_error_message();
             }
             return $status;
         } elseif (preg_match('/^[0-9]/', $result)) {
             $status['newVersion'] = $result;
             return $status;
         } else {
             // An unhandled error occured
             $status['error'] = 'update_failed';
             return $status;
         }
     }
 }
Пример #8
0
/**
 * This was once used to kick-off the Core Updater.
 *
 * Deprecated in favor of instantating a Core_Upgrader instance directly,
 * and calling the 'upgrade' method.
 *
 * @since 2.7.0
 * @deprecated 3.7.0 Use Core_Upgrader
 * @see Core_Upgrader
 */
function wp_update_core($current, $feedback = '')
{
    _deprecated_function(__FUNCTION__, '3.7.0', 'new Core_Upgrader();');
    if (!empty($feedback)) {
        add_filter('update_feedback', $feedback);
    }
    $upgrader = new Core_Upgrader();
    return $upgrader->upgrade($current);
}
Пример #9
0
function wp_update_core($current, $feedback = '')
{
    if (!empty($feedback)) {
        add_filter('update_feedback', $feedback);
    }
    include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $upgrader = new Core_Upgrader();
    return $upgrader->upgrade($current);
}
Пример #10
0
/**
 * Upgrade WordPress core display.
 *
 * @since 2.7.0
 *
 * @global WP_Filesystem_Base $wp_filesystem Subclass
 *
 * @param bool $reinstall
 */
function do_core_upgrade($reinstall = false)
{
    global $wp_filesystem;
    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    if ($reinstall) {
        $url = 'update-core.php?action=do-core-reinstall';
    } else {
        $url = 'update-core.php?action=do-core-upgrade';
    }
    $url = wp_nonce_url($url, 'upgrade-core');
    $version = isset($_POST['version']) ? $_POST['version'] : false;
    $locale = isset($_POST['locale']) ? $_POST['locale'] : 'en_US';
    $update = find_core_update($version, $locale);
    if (!$update) {
        return;
    }
    // Allow relaxed file ownership writes for User-initiated upgrades when the API specifies
    // that it's safe to do so. This only happens when there are no new files to create.
    $allow_relaxed_file_ownership = !$reinstall && isset($update->new_files) && !$update->new_files;
    ?>
	<div class="wrap">
	<h1><?php 
    _e('Update WordPress');
    ?>
</h1>
<?php 
    if (false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH, array('version', 'locale'), $allow_relaxed_file_ownership))) {
        echo '</div>';
        return;
    }
    if (!WP_Filesystem($credentials, ABSPATH, $allow_relaxed_file_ownership)) {
        // Failed to connect, Error and request again
        request_filesystem_credentials($url, '', true, ABSPATH, array('version', 'locale'), $allow_relaxed_file_ownership);
        echo '</div>';
        return;
    }
    if ($wp_filesystem->errors->get_error_code()) {
        foreach ($wp_filesystem->errors->get_error_messages() as $message) {
            show_message($message);
        }
        echo '</div>';
        return;
    }
    if ($reinstall) {
        $update->response = 'reinstall';
    }
    add_filter('update_feedback', 'show_message');
    $upgrader = new Core_Upgrader();
    $result = $upgrader->upgrade($update, array('allow_relaxed_file_ownership' => $allow_relaxed_file_ownership));
    if (is_wp_error($result)) {
        show_message($result);
        if ('up_to_date' != $result->get_error_code()) {
            show_message(__('Installation Failed'));
        }
        echo '</div>';
        return;
    }
    show_message(__('WordPress updated successfully'));
    show_message('<span class="hide-if-no-js">' . sprintf(__('Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.'), $result, esc_url(self_admin_url('about.php?updated'))) . '</span>');
    show_message('<span class="hide-if-js">' . sprintf(__('Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.'), $result, esc_url(self_admin_url('about.php?updated'))) . '</span>');
    ?>
	</div>
	<script type="text/javascript">
	window.location = '<?php 
    echo self_admin_url('about.php?updated');
    ?>
';
	</script>
	<?php 
}
Пример #11
0
/**
 * Updates wordpress core to the given version.
 *
 * Returns the new version on success, and a Wp_error object on failure
 * 
 * @param string $version
 * @return string|object
 */
function bruteprotect_update_core($version)
{
    $locale = get_locale();
    $update = find_core_update($version, $locale);
    $skin = new Automatic_Upgrader_Skin();
    $upgrader = new Core_Upgrader($skin);
    $results = $upgrader->upgrade($update);
    return $results;
}
Пример #12
0
function _wprp_upgrade_core()
{
    if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
        return new WP_Error('disallow-file-mods', __("File modification is disabled with the DISALLOW_FILE_MODS constant.", 'wpremote'));
    }
    include_once ABSPATH . 'wp-admin/includes/admin.php';
    include_once ABSPATH . 'wp-admin/includes/upgrade.php';
    include_once ABSPATH . 'wp-includes/update.php';
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    require_once WPRP_PLUGIN_PATH . 'inc/class-wprp-core-upgrader-skin.php';
    // check for filesystem access
    if (!_wpr_check_filesystem_access()) {
        return new WP_Error('filesystem-not-writable', __('The filesystem is not writable with the supplied credentials', 'wpremote'));
    }
    // force refresh
    wp_version_check();
    $updates = get_core_updates();
    if (is_wp_error($updates) || !$updates) {
        return new WP_Error('no-update-available');
    }
    $update = reset($updates);
    if (!$update) {
        return new WP_Error('no-update-available');
    }
    $skin = new WPRP_Core_Upgrader_Skin();
    $upgrader = new Core_Upgrader($skin);
    $result = $upgrader->upgrade($update);
    if (is_wp_error($result)) {
        return $result;
    }
    global $wp_current_db_version, $wp_db_version;
    // we have to include version.php so $wp_db_version
    // will take the version of the updated version of wordpress
    require ABSPATH . WPINC . '/version.php';
    wp_upgrade();
    return true;
}
 public function wp_oracle_get_core_upgrade()
 {
     include_once ABSPATH . 'wp-admin/includes/admin.php';
     include_once ABSPATH . 'wp-admin/includes/upgrade.php';
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     require_once ABSPATH . 'wp-admin/includes/update.php';
     require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-wordpress-oracle-core-upgrader-skin.php';
     // force refresh
     wp_version_check();
     $updates = get_core_updates();
     $update = reset($updates);
     $skin = new Wordpress_Oracle_Core_Upgrader_Skin();
     $upgrader = new Core_Upgrader($skin);
     $result = $upgrader->upgrade($update, array('allow_relaxed_file_ownership' => true));
     if (is_wp_error($result)) {
         return $result;
     }
     global $wp_current_db_version, $wp_db_version;
     // we have to include version.php so $wp_db_version
     // will take the version of the updated version of wordpress
     require ABSPATH . WPINC . '/version.php';
     wp_upgrade();
     return array('blog' => array('core_version' => $result));
 }
 /**
  * Tests to see if we should upgrade a specific item, does not test to see if we CAN update the item.
  */
 static function should_auto_update($type, $item, $context)
 {
     if (self::upgrader_disabled()) {
         return false;
     }
     if (self::is_vcs_checkout($context)) {
         return false;
     }
     // Next up, do we actually have it enabled for this type of update?
     switch ($type) {
         case 'language':
             $upgrade = true;
             break;
         case 'core':
             $upgrade = Core_Upgrader::should_upgrade_to_version($item->current);
             break;
         default:
         case 'plugin':
         case 'theme':
             $upgrade = false;
             break;
     }
     // And does the user / plugins want it?
     // Plugins may filter on 'auto_upgrade_plugin', and check the 2nd param, $item, to only enable it for certain Plugins/Themes
     if (!apply_filters('auto_upgrade_' . $type, $upgrade, $item)) {
         return false;
     }
     // If it's a core update, are we actually compatible with it's requirements?
     if ('core' == $type) {
         global $wpdb;
         $php_compat = version_compare(phpversion(), $item->php_version, '>=');
         if (file_exists(WP_CONTENT_DIR . '/db.php') && empty($wpdb->is_mysql)) {
             $mysql_compat = true;
         } else {
             $mysql_compat = version_compare($wpdb->db_version(), $item->mysql_version, '>=');
         }
         if (!$php_compat || !$mysql_compat) {
             return false;
         }
     }
     return true;
 }
Пример #15
0
    function upgrade_screen()
    {
        $html = ob_get_clean();
        if (!$this->check_user_permission() && !$this->can_update_core()) {
            $html = preg_replace('~<form[^>]*?>~', '<!--form opening tag removed by BusinessPres-->', $html);
            $html = str_replace('</form>', '<!--form closing tag removed by BusinessPres-->', $html);
        }
        if (!$this->check_user_permission() && (empty($this->aOptions['cap_update']) || !$this->aOptions['cap_update'])) {
            $html = preg_replace('~<input[^>]*?type=["\']checkbox["\'][^>]*?>~', '', $html);
            $html = preg_replace('~<thead[\\s\\S]*?</thead>~', '', $html);
            $html = preg_replace('~<tfoot[\\s\\S]*?</tfoot>~', '', $html);
            $html = preg_replace('~<input[^>]*?upgrade-plugins[^>]*?>~', '', $html);
            $html = preg_replace('~<input[^>]*?upgrade-themes[^>]*?>~', '', $html);
        }
        global $wp_version;
        $new_html = '';
        if (!$this->check_user_permission() && !$this->can_update_core()) {
            $new_html .= "<div class='error'><p>" . $this->talk_no_permissions('upgrade WordPress core') . "</p></div>";
        }
        $new_html .= "<h4>WordPress " . $wp_version . " installed<br />";
        global $wp_version;
        $sStatus = false;
        $iTTL = 0;
        $aVersions = $this->cache_core_version_info();
        if ($aVersions && isset($aVersions['data']) && count($aVersions['data']) > 0) {
            if ($this->get_version_branch() && isset($aVersions['data'][$this->get_version_branch()])) {
                $iDate = strtotime($aVersions['data'][$this->get_version_branch()]);
                $iTTL = $iDate + 3600 * 24 * 30 * 30;
                //  the current version is good has time to live set to 30 months
                if ($iTTL - time() < 0) {
                    $sStatus = "Not Secure - Major Upgrade Required";
                } else {
                    if ($iTTL - time() < 3600 * 24 * 30 * 3) {
                        //  if the current version is older than 23 monts, warn the user
                        $sStatus = "Update Recommended Soon";
                    } else {
                        $sStatus = "Secure";
                    }
                }
            }
            if ($this->get_branch_latest() != $wp_version && strtotime($aVersions['data'][$this->get_branch_latest()]) + 3600 * 24 * 5 < time()) {
                $sStatus = "Not Secure - Minor Upgrade Required";
            }
        }
        $new_html .= "Last updated: " . date('j F Y', strtotime($aVersions['data'][$this->get_branch_latest()])) . "<br />";
        $new_html .= "Status: " . $sStatus . "<br />";
        $iRemaining = floor(($iTTL - time()) / (3600 * 24) / 30);
        if ($iRemaining > 0) {
            $new_html .= "Projected security updates: " . $iRemaining . " months.";
        } else {
            $new_html .= "Projected security updates: Negative " . abs($iRemaining) . " months. Expired or expiration imminent.";
        }
        $new_html .= "</h4>\n";
        if (!class_exists('Core_Upgrader')) {
            include_once ABSPATH . '/wp-admin/includes/admin.php';
            include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
        }
        if (class_exists('Core_Upgrader')) {
            $new_html .= "<p>Core auto-updates status: ";
            $bDisabled = false;
            if (class_exists('Core_Upgrader')) {
                $objUpdater = new WP_Automatic_Updater();
                if ($objUpdater->is_disabled()) {
                    $new_html .= "disabled";
                    $bDisabled = true;
                }
            }
            if (!$bDisabled) {
                if (Core_Upgrader::should_update_to_version('100.1.2.3')) {
                    $new_html .= "<strong>Major version updates enabled</strong>";
                } else {
                    if (Core_Upgrader::should_update_to_version(get_bloginfo('version') . '.0.1')) {
                        $new_html .= "only Minor version updates enabled";
                    }
                }
            }
            $new_html .= "</p>";
        }
        $aBlockedUpdates = get_site_option('businesspress_core_update_delay');
        $bFound = false;
        if ($aBlockedUpdates) {
            foreach ($aBlockedUpdates as $key => $value) {
                if (stripos($key, '.next.minor') === false) {
                    $bFound = true;
                }
            }
        }
        if ($bFound && $aBlockedUpdates) {
            ksort($aBlockedUpdates);
            $aBlockedUpdates = array_reverse($aBlockedUpdates);
            $new_html .= "<p>Recently blocked updates:</p>";
            $new_html .= "<ul>\n";
            foreach ($aBlockedUpdates as $key => $value) {
                if (stripos($key, '.next.minor') !== false) {
                    $new_html .= "<li>WP core internal autoupdate check " . human_time_diff(time(), $value) . " ago</li>\n";
                    continue;
                }
                $new_html .= "<li><a href='https://codex.wordpress.org/Version_" . $key . "' target='_blank'>" . $key . "</a> " . human_time_diff(time(), $value) . " ago</li>\n";
            }
            $new_html .= "</ul>\n";
            $new_html .= "<p><a href='" . site_url('wp-admin/options-general.php?page=businesspress') . "'>BusinessPress</a> delays these updates 5 days to make sure you are not affected by any bugs in them.</p>";
        } else {
            //$new_html .= "<p>No recent actions, be careful with your upgrades!</p>";
        }
        /*if( stripos($html,'update-core.php?action=do-core-upgrade') !== false ) {
        
              preg_match( '~<input name="version" value="4.5"~', $html, $aVersion );
              $new_html .= "<p>Alternatively you can download 4.4.2 and upload it via FTP.</p><p>While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.</p>";
            }*/
        //  this bit if from update-core.php
        ob_start();
        global $wp_version, $required_php_version, $required_mysql_version;
        $aShowed = array();
        if ($this->check_user_permission() || $this->can_update_core()) {
            $aUpdates = get_site_transient('update_core');
            if (!$aUpdates) {
                $aUpdates = get_option('_site_transient_update_core');
            }
            if ($aUpdates && count($aUpdates->updates)) {
                foreach ($aUpdates->updates as $update) {
                    if (stripos($update->version, $this->get_version_branch()) === 0) {
                        if ($update->version == $wp_version) {
                            echo "<strong>You have the latest version of WordPress.</strong>";
                            continue;
                        }
                        if (isset($aShowed[$update->version])) {
                            continue;
                        }
                        $aShowed[$update->version] = true;
                        echo '<ul class="core-updates-businespress">';
                        echo '<strong class="response">';
                        _e('There is a security update of WordPress available.', 'businesspress');
                        echo '</strong>';
                        echo '<li>';
                        $this->list_core_update($update, false);
                        echo '</li>';
                        echo '</ul>';
                    }
                }
            }
        }
        $updates = get_core_updates();
        $bMajorUpdate = false;
        foreach ((array) $updates as $update) {
            if (stripos($update->version, $this->get_version_branch()) === false) {
                $bMajorUpdate = true;
            }
        }
        if (!isset($updates[0]->response) || 'latest' == $updates[0]->response) {
            /*echo '<h2>';
                  _e('You have the latest version of WordPress.');
              
                  if ( wp_http_supports( array( 'ssl' ) ) ) {
                    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
                    $upgrader = new WP_Automatic_Updater;
                    $future_minor_update = (object) array(
                      'current'       => $wp_version . '.1.next.minor',
                      'version'       => $wp_version . '.1.next.minor',
                      'php_version'   => $required_php_version,
                      'mysql_version' => $required_mysql_version,
                    );
                    $should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH );
                    if ( $should_auto_update )
                      echo ' ' . __( 'Future security updates will be applied automatically.' );
                  }
                  echo '</h2>';*/
        } else {
            if ($bMajorUpdate) {
                echo '<strong class="response">';
                _e('There is a core upgrade version of WordPress available.', 'businesspress');
                echo '</strong>';
                if ($this->check_user_permission() || $this->can_update_core()) {
                    echo '<p>';
                    _e('Be very careful before you upgrade: in addition to causing your site to fail to load, core upgrades can corrupt your database or cause plugins important to your business to fail, such as membership and ecommerce solutions. <strong>Please be sure to upgrade all your plugins to their most recent version before a major version upgrade.</strong>', 'businesspress');
                    echo '</p>';
                }
            }
        }
        if (isset($updates[0]) && $updates[0]->response == 'development') {
            /*require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
              $upgrader = new WP_Automatic_Updater;
              if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) ) {
                echo '<div class="updated inline"><p>';
                echo '<strong>' . __( 'BETA TESTERS:' ) . '</strong> ' . __( 'This site is set up to install updates of future beta versions automatically.' );
                echo '</p></div>';
              }*/
        }
        if ($bMajorUpdate && ($this->check_user_permission() || $this->can_update_core())) {
            echo '<ul class="core-updates-businespress">';
            foreach ((array) $updates as $update) {
                if (stripos($update->version, $this->get_version_branch()) === 0) {
                    continue;
                    //  don't show the minor updates here!
                }
                echo '<li>';
                if (!isset($update->response) || 'latest' == $update->response) {
                    list_core_update($update);
                } else {
                    $this->list_core_update($update);
                }
                echo '</li>';
            }
            echo '</ul>';
            // Don't show the maintenance mode notice when we are only showing a single re-install option.
            if ($updates && (count($updates) > 1 || $updates[0]->response != 'latest')) {
                echo '<p>' . __('While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.') . '</p>';
            } elseif (!$updates) {
                list($normalized_version) = explode('-', $wp_version);
                echo '<p>' . sprintf(__('<a href="%s">Learn more about WordPress %s</a>.'), esc_url(self_admin_url('about.php')), $normalized_version) . '</p>';
            }
        }
        $new_html .= ob_get_clean();
        if (preg_match('~<h\\d[^>]*?>Plugins</h\\d>~', $html)) {
            $html = preg_replace('~(<div class="wrap">)([\\s\\S]*?)(<h\\d[^>]*?>Plugins</h\\d>)~', '$1' . $new_html . '$3', $html);
        } else {
            $html = preg_replace('~(<div class="wrap">)([\\s\\S]*?)$~', '$1' . $new_html, $html);
        }
        echo $html;
        ?>
    <script>
    jQuery(function($){
      $('form').submit( function(e) {
        var form = $(this);
        
        if( form.find('.check-1').prop('checked') && form.find('.check-2').prop('checked') && form.find('.check-3').prop('checked') ) {

        } else {
          e.preventDefault();
          alert("Please confirm your site is ready for a core upgrade by checking the boxes above.");
        }
        
      });
    });
    </script>
    <?php 
    }
Пример #16
0
 function upgradeWP()
 {
     global $wp_version;
     $wp_filesystem = $this->getWPFilesystem();
     $information = array();
     include_once ABSPATH . '/wp-admin/includes/update.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
     //        if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php');
     if (file_exists(ABSPATH . '/wp-admin/includes/screen.php')) {
         include_once ABSPATH . '/wp-admin/includes/screen.php';
     }
     if (file_exists(ABSPATH . '/wp-admin/includes/template.php')) {
         include_once ABSPATH . '/wp-admin/includes/template.php';
     }
     include_once ABSPATH . '/wp-admin/includes/file.php';
     include_once ABSPATH . '/wp-admin/includes/misc.php';
     if (null !== $this->filterFunction) {
         add_filter('pre_site_transient_update_core', $this->filterFunction, 99);
     }
     if (null !== $this->filterFunction) {
         add_filter('pre_transient_update_core', $this->filterFunction, 99);
     }
     //Check for new versions
     @wp_version_check();
     $core_updates = get_core_updates();
     if (count($core_updates) > 0) {
         foreach ($core_updates as $core_update) {
             if ('latest' === $core_update->response) {
                 $information['upgrade'] = 'SUCCESS';
             } else {
                 if ('upgrade' === $core_update->response && $core_update->locale === get_locale() && version_compare($wp_version, $core_update->current, '<=')) {
                     //Upgrade!
                     $upgrade = false;
                     if (class_exists('Core_Upgrader')) {
                         $core = new Core_Upgrader();
                         $upgrade = $core->upgrade($core_update);
                     }
                     //If this does not work - add code from /wp-admin/includes/class-wp-upgrader.php in the newer versions
                     //So users can upgrade older versions too.
                     //3rd option: 'wp_update_core'
                     if (!is_wp_error($upgrade)) {
                         $information['upgrade'] = 'SUCCESS';
                     } else {
                         $information['upgrade'] = 'WPERROR';
                     }
                     break;
                 }
             }
         }
         if (!isset($information['upgrade'])) {
             foreach ($core_updates as $core_update) {
                 if ('upgrade' === $core_update->response && version_compare($wp_version, $core_update->current, '<=')) {
                     //Upgrade!
                     $upgrade = false;
                     if (class_exists('Core_Upgrader')) {
                         $core = new Core_Upgrader();
                         $upgrade = $core->upgrade($core_update);
                     }
                     //If this does not work - add code from /wp-admin/includes/class-wp-upgrader.php in the newer versions
                     //So users can upgrade older versions too.
                     //3rd option: 'wp_update_core'
                     if (!is_wp_error($upgrade)) {
                         $information['upgrade'] = 'SUCCESS';
                     } else {
                         $information['upgrade'] = 'WPERROR';
                     }
                     break;
                 }
             }
         }
     } else {
         $information['upgrade'] = 'NORESPONSE';
     }
     if (null !== $this->filterFunction) {
         remove_filter('pre_site_transient_update_core', $this->filterFunction, 99);
     }
     if (null !== $this->filterFunction) {
         remove_filter('pre_transient_update_core', $this->filterFunction, 99);
     }
     MainWP_Helper::write($information);
 }
/**
 * Upgrade WordPress core display.
 *
 * @since 2.7
 *
 * @return null
 */
function do_core_upgrade( $reinstall = false ) {
	global $wp_filesystem;

	include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';

	if ( $reinstall )
		$url = 'update-core.php?action=do-core-reinstall';
	else
		$url = 'update-core.php?action=do-core-upgrade';
	$url = wp_nonce_url($url, 'upgrade-core');

	$version = isset( $_POST['version'] )? $_POST['version'] : false;
	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
	$update = find_core_update( $version, $locale );
	if ( !$update )
		return;

?>
	<div class="wrap">
	<?php screen_icon('tools'); ?>
	<h2><?php _e('Update WordPress'); ?></h2>
<?php

	if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH ) ) ) {
		echo '</div>';
		return;
	}

	if ( ! WP_Filesystem( $credentials, ABSPATH ) ) {
		// Failed to connect, Error and request again
		request_filesystem_credentials( $url, '', true, ABSPATH );
		echo '</div>';
		return;
	}

	if ( $wp_filesystem->errors->get_error_code() ) {
		foreach ( $wp_filesystem->errors->get_error_messages() as $message )
			show_message($message);
		echo '</div>';
		return;
	}

	if ( $reinstall )
		$update->response = 'reinstall';

	add_filter( 'update_feedback', 'show_message' );

	$upgrader = new Core_Upgrader();
	$result = $upgrader->upgrade( $update );

	if ( is_wp_error($result) ) {
		show_message($result);
		if ('up_to_date' != $result->get_error_code() )
			show_message( __('Installation Failed') );
		echo '</div>';
		return;
	}

	show_message( __('WordPress updated successfully') );
	show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
	show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
	?>
	</div>
	<script type="text/javascript">
	window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
	</script>
	<?php
}
Пример #18
0
 /**
  * Tests to see if we can and should update a specific item.
  *
  * @since 3.7.0
  *
  * @param string $type    The type of update being checked: 'core', 'theme',
  *                        'plugin', 'translation'.
  * @param object $item    The update offer.
  * @param string $context The filesystem context (a path) against which filesystem
  *                        access and status should be checked.
  */
 public function should_update($type, $item, $context)
 {
     // Used to see if WP_Filesystem is set up to allow unattended updates.
     $skin = new Automatic_Upgrader_Skin();
     if ($this->is_disabled()) {
         return false;
     }
     // Only relax the filesystem checks when the update doesn't include new files
     $allow_relaxed_file_ownership = false;
     if ('core' == $type && isset($item->new_files) && !$item->new_files) {
         $allow_relaxed_file_ownership = true;
     }
     // If we can't do an auto core update, we may still be able to email the user.
     if (!$skin->request_filesystem_credentials(false, $context, $allow_relaxed_file_ownership) || $this->is_vcs_checkout($context)) {
         if ('core' == $type) {
             $this->send_core_update_notification_email($item);
         }
         return false;
     }
     // Next up, is this an item we can update?
     if ('core' == $type) {
         $update = Core_Upgrader::should_update_to_version($item->current);
     } else {
         $update = !empty($item->autoupdate);
     }
     /**
      * Filter whether to automatically update core, a plugin, a theme, or a language.
      *
      * The dynamic portion of the hook name, `$type`, refers to the type of update
      * being checked. Can be 'core', 'theme', 'plugin', or 'translation'.
      *
      * Generally speaking, plugins, themes, and major core versions are not updated
      * by default, while translations and minor and development versions for core
      * are updated by default.
      *
      * See the {@see 'allow_dev_auto_core_updates', {@see 'allow_minor_auto_core_updates'},
      * and {@see 'allow_major_auto_core_updates'} filters for a more straightforward way to
      * adjust core updates.
      *
      * @since 3.7.0
      *
      * @param bool   $update Whether to update.
      * @param object $item   The update offer.
      */
     $update = apply_filters('auto_update_' . $type, $update, $item);
     if (!$update) {
         if ('core' == $type) {
             $this->send_core_update_notification_email($item);
         }
         return false;
     }
     // If it's a core update, are we actually compatible with its requirements?
     if ('core' == $type) {
         global $wpdb;
         $php_compat = version_compare(phpversion(), $item->php_version, '>=');
         if (file_exists(WP_CONTENT_DIR . '/db.php') && empty($wpdb->is_mysql)) {
             $mysql_compat = true;
         } else {
             $mysql_compat = version_compare($wpdb->db_version(), $item->mysql_version, '>=');
         }
         if (!$php_compat || !$mysql_compat) {
             return false;
         }
     }
     return true;
 }
Пример #19
0
 function upgrade_core($current, $userid)
 {
     global $iwp_activities_log_post_type, $iwp_mmb_activities_log;
     ob_start();
     if (!function_exists('wp_version_check') || !function_exists('get_core_checksums')) {
         include_once ABSPATH . '/wp-admin/includes/update.php';
     }
     @wp_version_check();
     $current_update = false;
     ob_end_flush();
     ob_end_clean();
     $core = $this->iwp_mmb_get_transient('update_core');
     if (isset($core->updates) && !empty($core->updates)) {
         $updates = $core->updates[0];
         $updated = $core->updates[0];
         if (!isset($updated->response) || $updated->response == 'latest') {
             return array('upgraded' => 'updated');
         }
         if ($updated->response == "development" && $current->response == "upgrade") {
             return array('error' => '<font color="#900">Unexpected error. Please upgrade manually.</font>', 'error_code' => 'unexpected_error_please_upgrade_manually');
         } else {
             if ($updated->response == $current->response || $updated->response == "upgrade" && $current->response == "development") {
                 if ($updated->locale != $current->locale) {
                     foreach ($updates as $update) {
                         if ($update->locale == $current->locale) {
                             $current_update = $update;
                             break;
                         }
                     }
                     if ($current_update == false) {
                         return array('error' => ' Localization mismatch. Try again.', 'error_code' => 'localization_mismatch');
                     }
                 } else {
                     $current_update = $updated;
                 }
             } else {
                 return array('error' => ' Transient mismatch. Try again.', 'error_code' => 'transient_mismatch');
             }
         }
     } else {
         return array('error' => ' Refresh transient failed. Try again.', 'error_code' => 'refresh_transient_failed');
     }
     if ($current_update != false) {
         global $iwp_mmb_wp_version, $wp_filesystem, $wp_version;
         if (version_compare($wp_version, '3.1.9', '>')) {
             if (!class_exists('Core_Upgrader')) {
                 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
             }
             $core = new Core_Upgrader();
             $result = $core->upgrade($current_update);
             $this->iwp_mmb_maintenance_mode(false);
             if (is_wp_error($result)) {
                 return array('error' => $this->iwp_mmb_get_error($result), 'error_code' => 'maintenance_mode_upgrade_core');
             } else {
                 $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('core', 'update', $iwp_activities_log_post_type, $current, $userid);
                 return array('upgraded' => 'updated');
             }
         } else {
             if (!class_exists('WP_Upgrader')) {
                 include_once ABSPATH . 'wp-admin/includes/update.php';
                 if (function_exists('wp_update_core')) {
                     $result = wp_update_core($current_update);
                     if (is_wp_error($result)) {
                         return array('error' => $this->iwp_mmb_get_error($result), 'error_code' => 'wp_update_core_upgrade_core');
                     } else {
                         $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('core', 'update', $iwp_activities_log_post_type, $current, $userid);
                         return array('upgraded' => 'updated');
                     }
                 }
             }
             if (class_exists('WP_Upgrader')) {
                 $upgrader_skin = new WP_Upgrader_Skin();
                 $upgrader_skin->done_header = true;
                 $upgrader = new WP_Upgrader($upgrader_skin);
                 // Is an update available?
                 if (!isset($current_update->response) || $current_update->response == 'latest') {
                     return array('upgraded' => 'updated');
                 }
                 $res = $upgrader->fs_connect(array(ABSPATH, WP_CONTENT_DIR));
                 if (is_wp_error($res)) {
                     return array('error' => $this->iwp_mmb_get_error($res), 'error_code' => 'upgrade_core_wp_error_res');
                 }
                 $wp_dir = trailingslashit($wp_filesystem->abspath());
                 $core_package = false;
                 if (isset($current_update->package) && !empty($current_update->package)) {
                     $core_package = $current_update->package;
                 } elseif (isset($current_update->packages->full) && !empty($current_update->packages->full)) {
                     $core_package = $current_update->packages->full;
                 }
                 $download = $upgrader->download_package($core_package);
                 if (is_wp_error($download)) {
                     return array('error' => $this->iwp_mmb_get_error($download), 'error_code' => 'download_upgrade_core');
                 }
                 $working_dir = $upgrader->unpack_package($download);
                 if (is_wp_error($working_dir)) {
                     return array('error' => $this->iwp_mmb_get_error($working_dir), 'error_code' => 'working_dir_upgrade_core');
                 }
                 if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
                     $wp_filesystem->delete($working_dir, true);
                     return array('error' => 'Unable to move update files.', 'error_code' => 'unable_to_move_update_files');
                 }
                 $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
                 require ABSPATH . 'wp-admin/includes/update-core.php';
                 $update_core = update_core($working_dir, $wp_dir);
                 ob_end_clean();
                 $this->iwp_mmb_maintenance_mode(false);
                 if (is_wp_error($update_core)) {
                     return array('error' => $this->iwp_mmb_get_error($update_core), 'error_code' => 'upgrade_core_wp_error');
                 }
                 ob_end_flush();
                 $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('core', 'update', $iwp_activities_log_post_type, $current, $userid);
                 return array('upgraded' => 'updated');
             } else {
                 return array('error' => 'failed', 'error_code' => 'failed_WP_Upgrader_class_not_exists');
             }
         }
     } else {
         return array('error' => 'failed', 'error_code' => 'failed_current_update_false');
     }
 }
Пример #20
0
/**
 * This was once used to kick-off the Core Updater.
 *
 * Deprecated in favor of instantating a Core_Upgrader instance directly,
 * and calling the 'upgrade' method.
 *
 * @since 2.7.0
 * @deprecated 3.7.0
 * @see Core_Upgrader
 */
function wp_update_core($current, $feedback = '')
{
    _deprecated_function(__FUNCTION__, '3.7', 'new Core_Upgrader();');
    if (!empty($feedback)) {
        add_filter('update_feedback', $feedback);
    }
    include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $upgrader = new Core_Upgrader();
    return $upgrader->upgrade($current);
}
 /**
  * [doInstallUpdate description]
  * @param  [type] $update_id   [description]
  * @param  [type] $build_url   [description]
  * @param  [type] $package_url [description]
  * @return [type]              [description]
  */
 public function doInstallUpdate($update_row)
 {
     global $wp_filesystem;
     /*
     // Parse Update ID
       $update_keys = array('type', 'element', 'version', 'locale');
       $update_vals = explode( ':', $update_row->update_id );
       $update_rule = new wbSiteManager_Params( array_combine(array_intersect_key($update_keys, $update_vals), array_intersect_key($update_vals, $update_keys)) );
       if( empty($update_rule->type) ){
         $this->out('Invalid Update ID: ' . $update_id);
         return false;
       }
       $this->out('Processing Update ID: '. $update_id);
     */
     // Switch Type
     $this->out('Processing Update ID: ' . $update_row->update_id);
     switch ($update_row->type) {
         case 'core':
             // Load Update Record
             $remoteUrl = 'update-core.php?action=do-core-upgrade';
             $reinstall = false;
             if ($update_row->version == $update_row->installed_version) {
                 $reinstall = true;
                 $remoteUrl = 'update-core.php?action=do-core-reinstall';
             }
             $update = find_core_update($update_row->version, $update_row->get('locale', 'en_US'));
             if (!$update) {
                 $this->out(' - Failed to Load Update');
                 return false;
             }
             if ($reinstall) {
                 $update->response = 'reinstall';
             }
             // Confirm Write Access
             $allow_relaxed_file_ownership = isset($update->new_files) && !$update->new_files;
             if (false === ($credentials = request_filesystem_credentials($remoteUrl, '', false, ABSPATH, array('version', 'locale'), $allow_relaxed_file_ownership))) {
                 $this->out(' - Invalid File Permission');
                 return false;
             }
             if (!WP_Filesystem($credentials, ABSPATH, $allow_relaxed_file_ownership)) {
                 $this->out(' - Failed to load File Permissions');
                 return false;
             }
             if ($wp_filesystem->errors->get_error_code()) {
                 foreach ($wp_filesystem->errors->get_error_messages() as $message) {
                     $this->out(' - File Error: ' . $message);
                 }
                 return false;
             }
             // Run Update
             $upgrader_skin = new wbSiteManager_WP_Upgrader_Skin(array(), $this);
             $upgrader = new Core_Upgrader($upgrader_skin);
             $result = $upgrader->upgrade($update, array('allow_relaxed_file_ownership' => $allow_relaxed_file_ownership));
             $response_html = explode("\n", strip_tags(ob_get_clean()));
             ob_end_clean();
             if (is_wp_error($result)) {
                 if ($result->get_error_data() && is_string($result->get_error_data())) {
                     $message = $result->get_error_message() . ': ' . $result->get_error_data();
                 } else {
                     $message = $result->get_error_message();
                 }
                 $this->out(' - Update Error: ' . $message);
                 if ('up_to_date' != $result->get_error_code()) {
                     $this->out(' - Insallation Failed');
                 }
                 return false;
             }
             // Clear Cache
             set_site_transient('update_core', null);
             break;
         case 'plugin':
             // Install vs Upgrade
             if ($install) {
                 // Get Plugins API
                 $plugin_api = plugins_api('plugin_information', array('slug' => $update_row->extension_id, 'fields' => array('short_description' => false, 'sections' => false, 'requires' => false, 'rating' => false, 'ratings' => false, 'downloaded' => false, 'last_updated' => false, 'added' => false, 'tags' => false, 'compatibility' => false, 'homepage' => false, 'donate_link' => false)));
                 // Load Plugin Updater
                 $upgrader = new Plugin_Upgrader(new wbSiteManager_Plugin_Upgrader_Skin(array('title' => 'Install Plugin: ' . $update_row->extension_id . ' v' . $update_row->version, 'nonce' => 'install-plugin_' . $update_row->extension_id, 'url' => 'update.php?action=install-plugin&plugin=' . urlencode($update_row->extension_id), 'plugin' => $update_row->extension_id, 'api' => $api), $this));
                 $upgrader->install($plugin_api->download_link);
             } else {
                 // Load Plugin Updater
                 $upgrader = new Plugin_Upgrader(new wbSiteManager_Plugin_Upgrader_Skin(array('title' => 'Upgrade Plugin: ' . $update_row->extension_id . ' v' . $update_row->version, 'nonce' => 'upgrade-plugin_' . $update_row->extension_id, 'url' => 'update.php?action=upgrade-plugin&plugin=' . urlencode($update_row->extension_id), 'plugin' => $update_row->extension_id), $this));
                 $upgrader->upgrade($update_row->extension_id);
             }
             // Process Result
             if (empty($upgrader->result)) {
                 $this->out(' - Installation Failed');
                 return false;
             }
             // Clear Cache
             // set_site_transient( 'update_core', null );
             break;
         case 'theme':
             // Install vs Upgrade
             if ($install) {
                 // Load API
                 $api = themes_api('theme_information', array('slug' => $update_row->extension_id, 'fields' => array('sections' => false, 'tags' => false)));
                 // Load Theme Updater
                 $upgrader = new Theme_Upgrader(new wbSiteManager_Theme_Upgrader_Skin(array('title' => 'Install Theme: ' . $update_row->extension_id, 'nonce' => 'install-theme_' . $update_row->extension_id, 'url' => 'update.php?action=install-theme&theme=' . urlencode($update_row->extension_id), 'theme' => $update_row->extension_id, 'api' => $api), $this));
                 $upgrader->install($api->download_link);
             } else {
                 // Load Theme Updater
                 $upgrader = new Theme_Upgrader(new wbSiteManager_Theme_Upgrader_Skin(array('title' => 'Upgrade Theme: ' . $update_row->extension_id, 'nonce' => 'upgrade-theme_' . $update_row->extension_id, 'url' => 'update.php?action=upgrade-theme&theme=' . urlencode($update_row->extension_id), 'theme' => $update_row->extension_id), $this));
                 $upgrader->upgrade($update_row->extension_id);
             }
             // Process Result
             if (empty($upgrader->result)) {
                 $this->out(' - Installation Failed');
                 return false;
             }
             // Clear Cache
             // set_site_transient( 'update_core', null );
             break;
     }
     // Complete
     $this->out(' - Update Success');
     return true;
 }