本文整理汇总了PHP中Core_Upgrader类的典型用法代码示例。如果您正苦于以下问题:PHP Core_Upgrader类的具体用法?PHP Core_Upgrader怎么用?PHP Core_Upgrader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Core_Upgrader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
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: update
/**
* 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.');
}
}
示例3: update
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: upgrade_core
/**
* 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));
}
//.........这里部分代码省略.........
示例5: do_core_upgrade
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;
}
示例6: _update_core
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;
}
}
}
示例7: wp_update_core
/**
* 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);
}
示例8: wp_update_core
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);
}
示例9: do_core_upgrade
/**
* 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
}
示例10: bruteprotect_update_core
/**
* 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;
}
示例11: _wprp_upgrade_core
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;
}
示例12: wp_oracle_get_core_upgrade
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));
}
示例13: should_auto_update
/**
* 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;
}
示例14: upgrade_screen
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";
//.........这里部分代码省略.........
示例15: upgradeWP
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);
}