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;
 }
 /**
  * Checks if upgrade is required or not
  **/
 function runUpgradeRequiredCheck()
 {
     global $wp_version;
     //if this function does not exist, it means upgrade is definitely required
     if (!function_exists('wp_version_check')) {
         return true;
     } else {
         //run the core check
         if ($wp_version >= 2.7) {
             $update_array = get_core_updates();
             if (is_array($update_array)) {
                 if ('upgrade' == $update_array[0]->response) {
                     return true;
                 }
             }
         } else {
             wp_version_check();
             $cur = get_option('update_core');
             if (isset($cur->response) || 'upgrade' == $cur->response) {
                 return true;
             }
         }
     }
     return false;
 }
Example #3
0
 /**
  * @slowThreshold 1000
  */
 public function test_tested_up_to()
 {
     if (!($readme_data = $this->get_readme())) {
         $this->markTestSkipped('There is no readme file');
         return;
     }
     wp_version_check();
     $cur = get_preferred_from_update_core();
     if (false === $cur) {
         $this->markTestSkipped('There is no internet connection');
         return;
     }
     if (isset($cur->current)) {
         list($display_version) = explode('-', $cur->current);
         $this->assertTrue(version_compare($readme_data['tested_up_to'], $display_version, '>='), sprintf('%s >= %s', $readme_data['tested_up_to'], $display_version));
     }
 }
Example #4
0
 /**
  * Check if there is an update to the WordPress core.
  *
  * @return $this
  */
 public function checkCoreUpdates()
 {
     $this->needs_core_update = false;
     if (!function_exists('wp_version_check')) {
         require_once ABSPATH . WPINC . '/update.php';
     }
     if (!function_exists('get_preferred_from_update_core')) {
         require_once ABSPATH . 'wp-admin/includes/update.php';
     }
     wp_version_check();
     // Check for Core updates
     $update = get_preferred_from_update_core();
     if (isset($update->response) && $update->response == 'upgrade') {
         $this->needs_core_update = true;
         $this->core_update_version = $update->current;
     }
     return $this;
 }
 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;
 }
Example #6
0
 /**
  * Update the WordPress core
  *
  * @param array $args
  */
 function update($args)
 {
     wp_version_check();
     $from_api = get_site_transient('update_core');
     if (empty($from_api->updates)) {
         $update = false;
     } else {
         list($update) = $from_api->updates;
     }
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     $upgrader = WP_CLI::get_upgrader('Core_Upgrader');
     $result = $upgrader->upgrade($update);
     if (is_wp_error($result)) {
         $msg = WP_CLI::errorToString($result);
         if ('up_to_date' != $result->get_error_code()) {
             WP_CLI::error($msg);
         } else {
             WP_CLI::success($msg);
         }
     } else {
         WP_CLI::success('WordPress updated successfully.');
     }
 }
Example #7
0
 function refresh_updates()
 {
     if (rand(1, 3) == '2') {
         require_once ABSPATH . WPINC . '/update.php';
         wp_update_plugins();
         wp_update_themes();
         wp_version_check();
     }
 }
Example #8
0
 /**
  * Update WordPress.
  *
  * ## OPTIONS
  *
  * [<zip>]
  * : Path to zip file to use, instead of downloading from wordpress.org.
  *
  * [--version=<version>]
  * : Update to this version, instead of to the latest version.
  *
  * [--force]
  * : Update even when installed WP version is greater than the requested version.
  *
  * [--locale=<locale>]
  * : Select which language you want to download.
  *
  * ## EXAMPLES
  *
  *     wp core update
  *
  *     wp core update --version=3.8 ../latest.zip
  *
  *     wp core update --version=3.1 --force
  *
  * @alias upgrade
  */
 function update($args, $assoc_args)
 {
     global $wp_version;
     $update = $from_api = null;
     $upgrader = 'WP_CLI\\CoreUpgrader';
     if (!empty($args[0])) {
         $upgrader = 'WP_CLI\\NonDestructiveCoreUpgrader';
         $version = !empty($assoc_args['version']) ? $assoc_args['version'] : null;
         $update = (object) array('response' => 'upgrade', 'current' => $version, 'download' => $args[0], 'packages' => (object) array('partial' => null, 'new_bundled' => null, 'no_content' => null, 'full' => $args[0]), 'version' => $version, 'locale' => null);
     } else {
         if (empty($assoc_args['version'])) {
             wp_version_check();
             $from_api = get_site_transient('update_core');
             if (empty($from_api->updates)) {
                 $update = false;
             } else {
                 list($update) = $from_api->updates;
             }
         } else {
             if (version_compare($wp_version, $assoc_args['version'], '<') || isset($assoc_args['force'])) {
                 $version = $assoc_args['version'];
                 $locale = isset($assoc_args['locale']) ? $assoc_args['locale'] : get_locale();
                 $new_package = $this->get_download_url($version, $locale);
                 $update = (object) array('response' => 'upgrade', 'current' => $assoc_args['version'], 'download' => $new_package, 'packages' => (object) array('partial' => null, 'new_bundled' => null, 'no_content' => null, 'full' => $new_package), 'version' => $version, 'locale' => $locale);
             } else {
                 WP_CLI::success('WordPress is up to date.');
                 return;
             }
         }
     }
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     if ($update->version) {
         WP_CLI::log("Updating to version {$update->version} ({$update->locale})...");
     } else {
         WP_CLI::log("Starting update...");
     }
     $GLOBALS['wp_cli_update_obj'] = $update;
     $result = Utils\get_upgrader($upgrader)->upgrade($update);
     unset($GLOBALS['wp_cli_update_obj']);
     if (is_wp_error($result)) {
         $msg = WP_CLI::error_to_string($result);
         if ('up_to_date' != $result->get_error_code()) {
             WP_CLI::error($msg);
         } else {
             WP_CLI::success($msg);
         }
     } else {
         WP_CLI::success('WordPress updated successfully.');
     }
 }
 /**
  * Kicks off the background update process, looping through all pending updates.
  *
  * @since 3.7.0
  */
 public function run()
 {
     global $wpdb, $wp_version;
     if ($this->is_disabled()) {
         return;
     }
     if (!is_main_network() || !is_main_site()) {
         return;
     }
     $lock_name = 'auto_updater.lock';
     // Try to lock
     $lock_result = $wpdb->query($wpdb->prepare("INSERT IGNORE INTO `{$wpdb->options}` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time()));
     if (!$lock_result) {
         $lock_result = get_option($lock_name);
         // If we couldn't create a lock, and there isn't a lock, bail
         if (!$lock_result) {
             return;
         }
         // Check to see if the lock is still valid
         if ($lock_result > time() - HOUR_IN_SECONDS) {
             return;
         }
     }
     // Update the lock, as by this point we've definitely got a lock, just need to fire the actions
     update_option($lock_name, time());
     // Don't automatically run these thins, as we'll handle it ourselves
     remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
     remove_action('upgrader_process_complete', 'wp_version_check');
     remove_action('upgrader_process_complete', 'wp_update_plugins');
     remove_action('upgrader_process_complete', 'wp_update_themes');
     // Next, Plugins
     wp_update_plugins();
     // Check for Plugin updates
     $plugin_updates = get_site_transient('update_plugins');
     if ($plugin_updates && !empty($plugin_updates->response)) {
         foreach ($plugin_updates->response as $plugin) {
             $this->update('plugin', $plugin);
         }
         // Force refresh of plugin update information
         wp_clean_plugins_cache();
     }
     // Next, those themes we all love
     wp_update_themes();
     // Check for Theme updates
     $theme_updates = get_site_transient('update_themes');
     if ($theme_updates && !empty($theme_updates->response)) {
         foreach ($theme_updates->response as $theme) {
             $this->update('theme', (object) $theme);
         }
         // Force refresh of theme update information
         wp_clean_themes_cache();
     }
     // Next, Process any core update
     wp_version_check();
     // Check for Core updates
     $core_update = find_core_auto_update();
     if ($core_update) {
         $this->update('core', $core_update);
     }
     // Clean up, and check for any pending translations
     // (Core_Upgrader checks for core updates)
     $theme_stats = array();
     if (isset($this->update_results['theme'])) {
         foreach ($this->update_results['theme'] as $upgrade) {
             $theme_stats[$upgrade->item->theme] = true === $upgrade->result;
         }
     }
     wp_update_themes($theme_stats);
     // Check for Theme updates
     $plugin_stats = array();
     if (isset($this->update_results['plugin'])) {
         foreach ($this->update_results['plugin'] as $upgrade) {
             $plugin_stats[$upgrade->item->plugin] = true === $upgrade->result;
         }
     }
     wp_update_plugins($plugin_stats);
     // Check for Plugin updates
     // Finally, Process any new translations
     $language_updates = wp_get_translation_updates();
     if ($language_updates) {
         foreach ($language_updates as $update) {
             $this->update('translation', $update);
         }
         // Clear existing caches
         wp_clean_update_cache();
         wp_version_check();
         // check for Core updates
         wp_update_themes();
         // Check for Theme updates
         wp_update_plugins();
         // Check for Plugin updates
     }
     // Send debugging email to all development installs.
     if (!empty($this->update_results)) {
         $development_version = false !== strpos($wp_version, '-');
         /**
          * Filter whether to send a debugging email for each automatic background update.
          *
          * @since 3.7.0
          *
          * @param bool $development_version By default, emails are sent if the
          *                                  install is a development version.
          *                                  Return false to avoid the email.
          */
         if (apply_filters('automatic_updates_send_debug_email', $development_version)) {
             $this->send_debug_email();
         }
         if (!empty($this->update_results['core'])) {
             $this->after_core_update($this->update_results['core'][0]);
         }
         /**
          * Fires after all automatic updates have run.
          *
          * @since 3.8.0
          *
          * @param array $update_results The results of all attempted updates.
          */
         do_action('automatic_updates_complete', $this->update_results);
     }
     // Clear the lock
     delete_option($lock_name);
 }
 function _get_preferred_from_update_core()
 {
     if (!function_exists('get_preferred_from_update_core')) {
         require_once ABSPATH . 'wp-admin/includes/update.php';
     }
     //Validate that we have api data and if not get the normal data so we always have it.
     $preferred = get_preferred_from_update_core();
     if (false === $preferred) {
         wp_version_check();
         $preferred = get_preferred_from_update_core();
     }
     return $preferred;
 }
Example #11
0
function _maybe_update_core()
{
    global $wp_version;
    $current = get_transient('update_core');
    if (isset($current->last_checked) && 43200 > time() - $current->last_checked && isset($current->version_checked) && $current->version_checked == $wp_version) {
        return;
    }
    wp_version_check();
}
Example #12
0
 public function doCoreUpdateCheck()
 {
     global $wp_current_filter;
     $wp_current_filter[] = 'load-update-core.php';
     if (function_exists('wp_clean_update_cache')) {
         wp_clean_update_cache();
     }
     wp_version_check();
     array_pop($wp_current_filter);
     do_action('load-plugins.php');
 }
Example #13
0
 /**
  * Update WordPress.
  *
  * ## OPTIONS
  *
  * [<zip>]
  * : Path to zip file to use, instead of downloading from wordpress.org.
  *
  * [--minor]
  * : Only perform updates for minor releases (e.g. update from WP 4.3 to 4.3.3 instead of 4.4.2).
  *
  * [--version=<version>]
  * : Update to a specific version, instead of to the latest version.
  *
  * [--force]
  * : Update even when installed WP version is greater than the requested version.
  *
  * [--locale=<locale>]
  * : Select which language you want to download.
  *
  * ## EXAMPLES
  *
  *     wp core update
  *
  *     wp core update --version=3.8 ../latest.zip
  *
  *     wp core update --version=3.1 --force
  *
  * @alias upgrade
  */
 function update($args, $assoc_args)
 {
     global $wp_version;
     $update = $from_api = null;
     $upgrader = 'WP_CLI\\CoreUpgrader';
     if (empty($args[0]) && empty($assoc_args['version']) && \WP_CLI\Utils\get_flag_value($assoc_args, 'minor')) {
         $updates = $this->get_updates(array('minor' => true));
         if (!empty($updates)) {
             $assoc_args['version'] = $updates[0]['version'];
         } else {
             WP_CLI::success('WordPress is at the latest minor release.');
             return;
         }
     }
     if (!empty($args[0])) {
         $upgrader = 'WP_CLI\\NonDestructiveCoreUpgrader';
         $version = \WP_CLI\Utils\get_flag_value($assoc_args, 'version');
         $update = (object) array('response' => 'upgrade', 'current' => $version, 'download' => $args[0], 'packages' => (object) array('partial' => null, 'new_bundled' => null, 'no_content' => null, 'full' => $args[0]), 'version' => $version, 'locale' => null);
     } else {
         if (empty($assoc_args['version'])) {
             wp_version_check();
             $from_api = get_site_transient('update_core');
             if (!empty($from_api->updates)) {
                 list($update) = $from_api->updates;
             }
         } else {
             if (\WP_CLI\Utils\wp_version_compare($assoc_args['version'], '<') || \WP_CLI\Utils\get_flag_value($assoc_args, 'force')) {
                 $version = $assoc_args['version'];
                 $locale = \WP_CLI\Utils\get_flag_value($assoc_args, 'locale', get_locale());
                 $new_package = $this->get_download_url($version, $locale);
                 $update = (object) array('response' => 'upgrade', 'current' => $assoc_args['version'], 'download' => $new_package, 'packages' => (object) array('partial' => null, 'new_bundled' => null, 'no_content' => null, 'full' => $new_package), 'version' => $version, 'locale' => $locale);
             }
         }
     }
     if (!empty($update) && ($update->version != $wp_version || \WP_CLI\Utils\get_flag_value($assoc_args, 'force'))) {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         if ($update->version) {
             WP_CLI::log("Updating to version {$update->version} ({$update->locale})...");
         } else {
             WP_CLI::log("Starting update...");
         }
         $from_version = $wp_version;
         $GLOBALS['wp_cli_update_obj'] = $update;
         $result = Utils\get_upgrader($upgrader)->upgrade($update);
         unset($GLOBALS['wp_cli_update_obj']);
         if (is_wp_error($result)) {
             $msg = WP_CLI::error_to_string($result);
             if ('up_to_date' != $result->get_error_code()) {
                 WP_CLI::error($msg);
             } else {
                 WP_CLI::success($msg);
             }
         } else {
             if (file_exists(ABSPATH . 'wp-includes/version.php')) {
                 include ABSPATH . 'wp-includes/version.php';
                 $to_version = $wp_version;
             }
             $locale = \WP_CLI\Utils\get_flag_value($assoc_args, 'locale', get_locale());
             $this->cleanup_extra_files($from_version, $to_version, $locale);
             WP_CLI::success('WordPress updated successfully.');
         }
     } else {
         WP_CLI::success('WordPress is up to date.');
     }
 }
Example #14
0
 /**
  * Returns update information
  */
 private function get_updates($assoc_args)
 {
     wp_version_check();
     $from_api = get_site_transient('update_core');
     if (!$from_api) {
         return array();
     }
     $compare_version = str_replace('-src', '', $GLOBALS['wp_version']);
     $updates = array('major' => false, 'minor' => false);
     foreach ($from_api->updates as $offer) {
         $update_type = Utils\get_named_sem_ver($offer->version, $compare_version);
         if (!$update_type) {
             continue;
         }
         // WordPress follow its own versioning which is roughly equivalent to semver
         if ('minor' === $update_type) {
             $update_type = 'major';
         } else {
             if ('patch' === $update_type) {
                 $update_type = 'minor';
             }
         }
         if (!empty($updates[$update_type]) && !Comparator::greaterThan($offer->version, $updates[$update_type]['version'])) {
             continue;
         }
         $updates[$update_type] = array('version' => $offer->version, 'update_type' => $update_type, 'package_url' => !empty($offer->packages->partial) ? $offer->packages->partial : $offer->packages->full);
     }
     foreach ($updates as $type => $value) {
         if (empty($value)) {
             unset($updates[$type]);
         }
     }
     foreach (array('major', 'minor') as $type) {
         if (true === \WP_CLI\Utils\get_flag_value($assoc_args, $type)) {
             return !empty($updates[$type]) ? array($updates[$type]) : false;
         }
     }
     return array_values($updates);
 }
Example #15
0
File: core.php Project: nb/wp-cli
 /**
  * Update WordPress.
  *
  * ## OPTIONS
  *
  * [<zip>]
  * : Path to zip file to use, instead of downloading from wordpress.org.
  *
  * [--version=<version>]
  * : Update to this version, instead of to the latest version.
  *
  * [--force]
  * : Will update even when current WP version < passed version. Use with
  * caution.
  *
  * ## EXAMPLES
  *
  *     wp core update
  *
  *     wp core update --version=3.4 ../latest.zip
  *
  *     wp core update --version=3.1 --force
  *
  * @alias upgrade
  */
 function update($args, $assoc_args)
 {
     global $wp_version;
     $update = $from_api = null;
     $upgrader = 'Core_Upgrader';
     if (empty($assoc_args['version'])) {
         wp_version_check();
         $from_api = get_site_transient('update_core');
         if (empty($from_api->updates)) {
             $update = false;
         } else {
             list($update) = $from_api->updates;
         }
     } else {
         if (version_compare($wp_version, $assoc_args['version'], '<') || isset($assoc_args['force'])) {
             $new_package = null;
             if (empty($args[0])) {
                 $new_package = 'https://wordpress.org/wordpress-' . $assoc_args['version'] . '.zip';
                 WP_CLI::log(sprintf('Downloading WordPress %s (%s)...', $assoc_args['version'], 'en_US'));
             } else {
                 $new_package = $args[0];
                 $upgrader = 'WP_CLI\\NonDestructiveCoreUpgrader';
             }
             $update = (object) array('response' => 'upgrade', 'current' => $assoc_args['version'], 'download' => $new_package, 'packages' => (object) array('partial' => null, 'new_bundled' => null, 'no_content' => null, 'full' => $new_package));
         } else {
             WP_CLI::success('WordPress is up to date.');
             return;
         }
     }
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     $result = Utils\get_upgrader($upgrader)->upgrade($update);
     if (is_wp_error($result)) {
         $msg = WP_CLI::error_to_string($result);
         if ('up_to_date' != $result->get_error_code()) {
             WP_CLI::error($msg);
         } else {
             WP_CLI::success($msg);
         }
     } else {
         WP_CLI::success('WordPress updated successfully.');
     }
 }
Example #16
0
 public static function refresh_core_updates()
 {
     require_once ABSPATH . 'wp-includes/update.php';
     if (is_callable('wp_version_check')) {
         return wp_version_check(array(), true);
     }
     return false;
 }
 /**
  * Upgrade WordPress core.
  *
  * @since 2.8.0
  * @access public
  *
  * @global WP_Filesystem_Base $wp_filesystem Subclass
  * @global callable           $_wp_filesystem_direct_method
  *
  * @param object $current Response object for whether WordPress is current.
  * @param array  $args {
  *        Optional. Arguments for upgrading WordPress core. Default empty array.
  *
  *        @type bool $pre_check_md5    Whether to check the file checksums before
  *                                     attempting the upgrade. Default true.
  *        @type bool $attempt_rollback Whether to attempt to rollback the chances if
  *                                     there is a problem. Default false.
  *        @type bool $do_rollback      Whether to perform this "upgrade" as a rollback.
  *                                     Default false.
  * }
  * @return null|false|WP_Error False or WP_Error on failure, null on success.
  */
 public function upgrade($current, $args = array())
 {
     global $wp_filesystem;
     include ABSPATH . WPINC . '/version.php';
     // $wp_version;
     $start_time = time();
     $defaults = array('pre_check_md5' => true, 'attempt_rollback' => false, 'do_rollback' => false, 'allow_relaxed_file_ownership' => false);
     $parsed_args = wp_parse_args($args, $defaults);
     $this->init();
     $this->upgrade_strings();
     // Is an update available?
     if (!isset($current->response) || $current->response == 'latest') {
         return new WP_Error('up_to_date', $this->strings['up_to_date']);
     }
     $res = $this->fs_connect(array(ABSPATH, WP_CONTENT_DIR), $parsed_args['allow_relaxed_file_ownership']);
     if (!$res || is_wp_error($res)) {
         return $res;
     }
     $wp_dir = trailingslashit($wp_filesystem->abspath());
     $partial = true;
     if ($parsed_args['do_rollback']) {
         $partial = false;
     } elseif ($parsed_args['pre_check_md5'] && !$this->check_files()) {
         $partial = false;
     }
     /*
      * If partial update is returned from the API, use that, unless we're doing
      * a reinstall. If we cross the new_bundled version number, then use
      * the new_bundled zip. Don't though if the constant is set to skip bundled items.
      * If the API returns a no_content zip, go with it. Finally, default to the full zip.
      */
     if ($parsed_args['do_rollback'] && $current->packages->rollback) {
         $to_download = 'rollback';
     } elseif ($current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial) {
         $to_download = 'partial';
     } elseif ($current->packages->new_bundled && version_compare($wp_version, $current->new_bundled, '<') && (!defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || !CORE_UPGRADE_SKIP_NEW_BUNDLED)) {
         $to_download = 'new_bundled';
     } elseif ($current->packages->no_content) {
         $to_download = 'no_content';
     } else {
         $to_download = 'full';
     }
     // Lock to prevent multiple Core Updates occuring
     $lock = WP_Upgrader::create_lock('core_updater', 15 * MINUTE_IN_SECONDS);
     if (!$lock) {
         return new WP_Error('locked', $this->strings['locked']);
     }
     $download = $this->download_package($current->packages->{$to_download});
     if (is_wp_error($download)) {
         WP_Upgrader::release_lock('core_updater');
         return $download;
     }
     $working_dir = $this->unpack_package($download);
     if (is_wp_error($working_dir)) {
         WP_Upgrader::release_lock('core_updater');
         return $working_dir;
     }
     // Copy update-core.php from the new version into place.
     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);
         WP_Upgrader::release_lock('core_updater');
         return new WP_Error('copy_failed_for_update_core_file', __('The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.'), 'wp-admin/includes/update-core.php');
     }
     $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
     require_once ABSPATH . 'wp-admin/includes/update-core.php';
     if (!function_exists('update_core')) {
         WP_Upgrader::release_lock('core_updater');
         return new WP_Error('copy_failed_space', $this->strings['copy_failed_space']);
     }
     $result = update_core($working_dir, $wp_dir);
     // In the event of an issue, we may be able to roll back.
     if ($parsed_args['attempt_rollback'] && $current->packages->rollback && !$parsed_args['do_rollback']) {
         $try_rollback = false;
         if (is_wp_error($result)) {
             $error_code = $result->get_error_code();
             /*
              * Not all errors are equal. These codes are critical: copy_failed__copy_dir,
              * mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full.
              * do_rollback allows for update_core() to trigger a rollback if needed.
              */
             if (false !== strpos($error_code, 'do_rollback')) {
                 $try_rollback = true;
             } elseif (false !== strpos($error_code, '__copy_dir')) {
                 $try_rollback = true;
             } elseif ('disk_full' === $error_code) {
                 $try_rollback = true;
             }
         }
         if ($try_rollback) {
             /** This filter is documented in wp-admin/includes/update-core.php */
             apply_filters('update_feedback', $result);
             /** This filter is documented in wp-admin/includes/update-core.php */
             apply_filters('update_feedback', $this->strings['start_rollback']);
             $rollback_result = $this->upgrade($current, array_merge($parsed_args, array('do_rollback' => true)));
             $original_result = $result;
             $result = new WP_Error('rollback_was_required', $this->strings['rollback_was_required'], (object) array('update' => $original_result, 'rollback' => $rollback_result));
         }
     }
     /** This action is documented in wp-admin/includes/class-wp-upgrader.php */
     do_action('upgrader_process_complete', $this, array('action' => 'update', 'type' => 'core'));
     // Clear the current updates
     delete_site_transient('update_core');
     if (!$parsed_args['do_rollback']) {
         $stats = array('update_type' => $current->response, 'success' => true, 'fs_method' => $wp_filesystem->method, 'fs_method_forced' => defined('FS_METHOD') || has_filter('filesystem_method'), 'fs_method_direct' => !empty($GLOBALS['_wp_filesystem_direct_method']) ? $GLOBALS['_wp_filesystem_direct_method'] : '', 'time_taken' => time() - $start_time, 'reported' => $wp_version, 'attempted' => $current->version);
         if (is_wp_error($result)) {
             $stats['success'] = false;
             // Did a rollback occur?
             if (!empty($try_rollback)) {
                 $stats['error_code'] = $original_result->get_error_code();
                 $stats['error_data'] = $original_result->get_error_data();
                 // Was the rollback successful? If not, collect its error too.
                 $stats['rollback'] = !is_wp_error($rollback_result);
                 if (is_wp_error($rollback_result)) {
                     $stats['rollback_code'] = $rollback_result->get_error_code();
                     $stats['rollback_data'] = $rollback_result->get_error_data();
                 }
             } else {
                 $stats['error_code'] = $result->get_error_code();
                 $stats['error_data'] = $result->get_error_data();
             }
         }
         wp_version_check($stats);
     }
     WP_Upgrader::release_lock('core_updater');
     return $result;
 }
Example #18
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');
     }
 }
 function getSiteStats($information = array(), $exit = true)
 {
     global $wp_version;
     if ($exit) {
         $this->updateExternalSettings();
     }
     MainWP_Helper::update_option('mainwp_child_branding_disconnected', '', 'yes');
     if (isset($_POST['server'])) {
         MainWP_Helper::update_option('mainwp_child_server', $_POST['server']);
     }
     if (isset($_POST['numberdaysOutdatePluginTheme']) && !empty($_POST['numberdaysOutdatePluginTheme'])) {
         $days_outdate = get_option('mainwp_child_plugintheme_days_outdate', 365);
         if ($days_outdate !== $_POST['numberdaysOutdatePluginTheme']) {
             $days_outdate = $_POST['numberdaysOutdatePluginTheme'];
             MainWP_Helper::update_option('mainwp_child_plugintheme_days_outdate', $days_outdate);
             MainWP_Child_Plugins_Check::Instance()->cleanup_deactivation(false);
             MainWP_Child_Themes_Check::Instance()->cleanup_deactivation(false);
         }
     }
     $information['version'] = self::$version;
     $information['wpversion'] = $wp_version;
     $information['siteurl'] = get_option('siteurl');
     $information['nossl'] = '1' === get_option('mainwp_child_nossl') ? 1 : 0;
     include_once ABSPATH . '/wp-admin/includes/update.php';
     $timeout = 3 * 60 * 60;
     // 3minutes
     @set_time_limit($timeout);
     @ini_set('max_execution_time', $timeout);
     //Check for new versions
     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);
     }
     @wp_version_check();
     $core_updates = get_core_updates();
     if (count($core_updates) > 0) {
         foreach ($core_updates as $core_update) {
             if ('latest' === $core_update->response) {
                 break;
             }
             if ('upgrade' === $core_update->response && version_compare($wp_version, $core_update->current, '<=')) {
                 $information['wp_updates'] = $core_update->current;
             }
         }
     }
     if (!isset($information['wp_updates'])) {
         $information['wp_updates'] = null;
     }
     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);
     }
     add_filter('default_option_active_plugins', array(&$this, 'default_option_active_plugins'));
     add_filter('option_active_plugins', array(&$this, 'default_option_active_plugins'));
     //First check for new premium updates
     $update_check = apply_filters('mwp_premium_update_check', array());
     if (!empty($update_check)) {
         foreach ($update_check as $updateFeedback) {
             if (is_array($updateFeedback['callback']) && isset($updateFeedback['callback'][0]) && isset($updateFeedback['callback'][1])) {
                 @call_user_func(array($updateFeedback['callback'][0], $updateFeedback['callback'][1]));
             } else {
                 if (is_string($updateFeedback['callback'])) {
                     @call_user_func($updateFeedback['callback']);
                 }
             }
         }
     }
     $informationPremiumUpdates = apply_filters('mwp_premium_update_notification', array());
     $premiumPlugins = array();
     $premiumThemes = array();
     if (is_array($informationPremiumUpdates)) {
         $premiumUpdates = array();
         $information['premium_updates'] = array();
         $informationPremiumUpdatesLength = count($informationPremiumUpdates);
         for ($i = 0; $i < $informationPremiumUpdatesLength; $i++) {
             if (!isset($informationPremiumUpdates[$i]['new_version'])) {
                 continue;
             }
             $slug = isset($informationPremiumUpdates[$i]['slug']) ? $informationPremiumUpdates[$i]['slug'] : $informationPremiumUpdates[$i]['Name'];
             if ('plugin' === $informationPremiumUpdates[$i]['type']) {
                 $premiumPlugins[] = $slug;
             } else {
                 if ('theme' === $informationPremiumUpdates[$i]['type']) {
                     $premiumThemes[] = $slug;
                 }
             }
             $new_version = $informationPremiumUpdates[$i]['new_version'];
             unset($informationPremiumUpdates[$i]['old_version']);
             unset($informationPremiumUpdates[$i]['new_version']);
             $information['premium_updates'][$slug] = $informationPremiumUpdates[$i];
             $information['premium_updates'][$slug]['update'] = (object) array('new_version' => $new_version, 'premium' => true, 'slug' => $slug);
             if (!in_array($slug, $premiumUpdates)) {
                 $premiumUpdates[] = $slug;
             }
         }
         MainWP_Helper::update_option('mainwp_premium_updates', $premiumUpdates);
     }
     remove_filter('default_option_active_plugins', array(&$this, 'default_option_active_plugins'));
     remove_filter('option_active_plugins', array(&$this, 'default_option_active_plugins'));
     if (null !== $this->filterFunction) {
         add_filter('pre_site_transient_update_plugins', $this->filterFunction, 99);
     }
     global $wp_current_filter;
     $wp_current_filter[] = 'load-plugins.php';
     @wp_update_plugins();
     include_once ABSPATH . '/wp-admin/includes/plugin.php';
     $plugin_updates = get_plugin_updates();
     if (is_array($plugin_updates)) {
         $information['plugin_updates'] = array();
         foreach ($plugin_updates as $slug => $plugin_update) {
             if (in_array($plugin_update->Name, $premiumPlugins)) {
                 continue;
             }
             $information['plugin_updates'][$slug] = $plugin_update;
         }
     }
     if (null !== $this->filterFunction) {
         remove_filter('pre_site_transient_update_plugins', $this->filterFunction, 99);
     }
     if (null !== $this->filterFunction) {
         add_filter('pre_site_transient_update_themes', $this->filterFunction, 99);
     }
     @wp_update_themes();
     include_once ABSPATH . '/wp-admin/includes/theme.php';
     $theme_updates = $this->upgrade_get_theme_updates();
     if (is_array($theme_updates)) {
         $information['theme_updates'] = array();
         foreach ($theme_updates as $slug => $theme_update) {
             $name = is_array($theme_update) ? $theme_update['Name'] : $theme_update->Name;
             if (in_array($name, $premiumThemes)) {
                 continue;
             }
             $information['theme_updates'][$slug] = $theme_update;
         }
     }
     if (null !== $this->filterFunction) {
         remove_filter('pre_site_transient_update_themes', $this->filterFunction, 99);
     }
     $information['recent_comments'] = $this->get_recent_comments(array('approve', 'hold'), 5);
     $information['recent_posts'] = $this->get_recent_posts(array('publish', 'draft', 'pending', 'trash'), 5);
     $information['recent_pages'] = $this->get_recent_posts(array('publish', 'draft', 'pending', 'trash'), 5, 'page');
     $securityIssuess = 0;
     if (!MainWP_Security::prevent_listing_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_wp_version_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_rsd_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_wlw_ok()) {
         $securityIssuess++;
     }
     //        if (!MainWP_Security::remove_core_update_ok()) $securityIssuess++;
     //        if (!MainWP_Security::remove_plugin_update_ok()) $securityIssuess++;
     //        if (!MainWP_Security::remove_theme_update_ok()) $securityIssuess++;
     //        if (!MainWP_Security::fix_file_permissions_ok()) $securityIssuess++;
     if (!MainWP_Security::remove_database_reporting_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_php_reporting_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_scripts_version_ok() || !MainWP_Security::remove_styles_version_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::admin_user_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_readme_ok()) {
         $securityIssuess++;
     }
     $information['securityIssues'] = $securityIssuess;
     //Directory listings!
     $information['directories'] = $this->scanDir(ABSPATH, 3);
     $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => true));
     $categories = array();
     foreach ($cats as $cat) {
         $categories[] = $cat->name;
     }
     $information['categories'] = $categories;
     $information['totalsize'] = $this->getTotalFileSize();
     $information['dbsize'] = MainWP_Child_DB::get_size();
     $auths = get_option('mainwp_child_auth');
     $information['extauth'] = $auths && isset($auths[$this->maxHistory]) ? $auths[$this->maxHistory] : null;
     $plugins = $this->get_all_plugins_int(false);
     $themes = $this->get_all_themes_int(false);
     $information['plugins'] = $plugins;
     $information['themes'] = $themes;
     if (isset($_POST['optimize']) && '1' === $_POST['optimize']) {
         $information['users'] = $this->get_all_users_int();
     }
     if (isset($_POST['pluginConflicts']) && '' !== $_POST['pluginConflicts']) {
         $pluginConflicts = json_decode(stripslashes($_POST['pluginConflicts']), true);
         $conflicts = array();
         if (count($pluginConflicts) > 0) {
             if (!$plugins) {
                 $plugins = $this->get_all_plugins_int(false);
             }
             if (is_array($plugins) && is_array($pluginConflicts)) {
                 foreach ($plugins as $plugin) {
                     foreach ($pluginConflicts as $pluginConflict) {
                         if ('1' === $plugin['active'] && ($plugin['name'] === $pluginConflict || $plugin['slug'] === $pluginConflict)) {
                             $conflicts[] = $plugin['name'];
                         }
                     }
                 }
             }
         }
         if (count($conflicts) > 0) {
             $information['pluginConflicts'] = $conflicts;
         }
     }
     if (isset($_POST['themeConflicts']) && '' !== $_POST['themeConflicts']) {
         $themeConflicts = json_decode(stripslashes($_POST['themeConflicts']), true);
         $conflicts = array();
         if (is_array($themeConflicts) && count($themeConflicts) > 0) {
             $theme = wp_get_theme()->get('Name');
             foreach ($themeConflicts as $themeConflict) {
                 if ($theme === $themeConflict) {
                     $conflicts[] = $theme;
                 }
             }
         }
         if (count($conflicts) > 0) {
             $information['themeConflicts'] = $conflicts;
         }
     }
     if (isset($_POST['othersData'])) {
         $othersData = json_decode(stripslashes($_POST['othersData']), true);
         if (!is_array($othersData)) {
             $othersData = array();
         }
         $information = apply_filters('mainwp-site-sync-others-data', $information, $othersData);
         if (version_compare(phpversion(), '5.3', '>=')) {
             if (isset($othersData['syncBackUpWordPress']) && $othersData['syncBackUpWordPress']) {
                 if (MainWP_Child_Back_Up_Wordpress::isActivated()) {
                     $information['syncBackUpWordPress'] = MainWP_Child_Back_Up_Wordpress::Instance()->syncData();
                 }
             }
         }
         if (isset($othersData['syncWPRocketData']) && 'yes' === $othersData['syncWPRocketData']) {
             $data = array();
             if (MainWP_Child_WP_Rocket::isActivated()) {
                 $boxes = get_user_meta($GLOBALS['current_user']->ID, 'rocket_boxes', true);
                 $data['rocket_boxes'] = $boxes;
             }
             $information['syncWPRocketData'] = $data;
         }
     }
     $information['faviIcon'] = $this->get_favicon();
     $last_post = wp_get_recent_posts(array('numberposts' => absint('1')));
     if (isset($last_post[0])) {
         $last_post = $last_post[0];
     }
     if (isset($last_post) && isset($last_post['post_modified_gmt'])) {
         $information['last_post_gmt'] = strtotime($last_post['post_modified_gmt']);
     }
     $information['mainwpdir'] = MainWP_Helper::validateMainWPDir() ? 1 : -1;
     $information['uniqueId'] = get_option('mainwp_child_uniqueId', '');
     $information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
     $information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
     if ($exit) {
         MainWP_Helper::write($information);
     }
     return $information;
 }
Example #20
0
 /**
  * Updates the active translation of core, plugins, and themes.
  *
  * [--dry-run]
  * : Preview which translations would be updated.
  *
  * @subcommand update
  */
 public function update($args, $assoc_args)
 {
     // Ignore updates for the default locale.
     if ('en_US' == get_locale()) {
         \WP_CLI::success("Translations updates are not needed for the 'English (US)' locale.");
         return;
     }
     $this->wp_clean_update_cache();
     // Clear existing update caches.
     wp_version_check();
     // Check for Core translation updates.
     wp_update_themes();
     // Check for Theme translation updates.
     wp_update_plugins();
     // Check for Plugin translation updates.
     $updates = wp_get_translation_updates();
     // Retrieves a list of all translations updates available.
     if (empty($updates)) {
         \WP_CLI::success('Translations are up to date.');
         return;
     }
     // Gets a list of all languages.
     $all_languages = $this->get_all_languages();
     // Formats the updates list.
     foreach ($updates as $update) {
         if ('plugin' == $update->type) {
             $plugin_data = array_shift(get_plugins('/' . $update->slug));
             $name = $plugin_data['Name'];
         } elseif ('theme' == $update->type) {
             $theme_data = wp_get_theme($update->slug);
             $name = $theme_data['Name'];
         } else {
             // Core
             $name = 'WordPress';
         }
         // Gets the translation data.
         $translation = (object) reset(wp_list_filter($all_languages, array('language' => $update->language)));
         $update->Type = ucfirst($update->type);
         $update->Name = $name;
         $update->Version = $update->version;
         $update->Language = $translation->english_name;
     }
     // Only preview which translations would be updated.
     if (\WP_CLI\Utils\get_flag_value($assoc_args, 'dry-run')) {
         \WP_CLI::line(sprintf('Available %d translations updates:', count($updates)));
         \WP_CLI\Utils\format_items('table', $updates, array('Type', 'Name', 'Version', 'Language'));
         return;
     }
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     $upgrader = new \Language_Pack_Upgrader(new \Automatic_Upgrader_Skin());
     $results = array();
     // Update translations.
     foreach ($updates as $update) {
         \WP_CLI::line("Updating '{$update->Language}' translation for {$update->Name} {$update->Version}...");
         \WP_CLI::line("Downloading translation from {$update->package}...");
         $result = $upgrader->upgrade($update);
         if ($result) {
             \WP_CLI::line('Translation updated successfully.');
         } else {
             \WP_CLI::line('Translation update failed.');
         }
         $results[] = $result;
     }
     $num_to_update = count($updates);
     $num_updated = count(array_filter($results));
     $line = "Updated {$num_updated}/{$num_to_update} translations.";
     if ($num_to_update == $num_updated) {
         \WP_CLI::success($line);
     } else {
         if ($num_updated > 0) {
             \WP_CLI::warning($line);
         } else {
             \WP_CLI::error($line);
         }
     }
 }
/**
 * @global string $wp_version
 */
function _maybe_update_core()
{
    global $wp_version;
    include ABSPATH . WPINC . '/version.php';
    // include an unmodified $wp_version
    $current = get_site_transient('update_core');
    if (isset($current->last_checked, $current->version_checked) && 12 * HOUR_IN_SECONDS > time() - $current->last_checked && $current->version_checked == $wp_version) {
        return;
    }
    wp_version_check();
}
Example #22
0
<?php

//only admins can get this
if (!function_exists("current_user_can") || !current_user_can("manage_options") && !current_user_can("pmpro_addons")) {
    die(__("You do not have permissions to perform this action.", "pmpro"));
}
global $wpdb, $msg, $msgt, $pmpro_addons;
wp_enqueue_script('plugin-install');
add_thickbox();
wp_enqueue_script('updates');
require_once dirname(__FILE__) . "/admin_header.php";
//force a check of plugin versions?
if (!empty($_REQUEST['force-check'])) {
    wp_version_check(array(), true);
    wp_update_plugins();
    $pmpro_license_key = get_option("pmpro_license_key", "");
    pmpro_license_isValid($pmpro_license_key, NULL, true);
}
//some vars
$addons = pmpro_getAddons();
$addons_timestamp = get_option("pmpro_addons_timestamp", false);
$plugin_info = get_site_transient('update_plugins');
$pmpro_license_key = get_option("pmpro_license_key", "");
//get plugin status for filters
if (!empty($_REQUEST['plugin_status'])) {
    $status = $_REQUEST['plugin_status'];
}
//make sure we have an approved status
$approved_statuses = array('all', 'active', 'inactive', 'update', 'uninstalled');
if (empty($status) || !in_array($status, $approved_statuses)) {
    $status = "all";
Example #23
0
$title = __('WordPress Updates');
$parent_file = 'index.php';
$updates_overview = '<p>' . __('On this screen, you can update to the latest version of WordPress, as well as update your themes, plugins, and translations from the WordPress.org repositories.') . '</p>';
$updates_overview .= '<p>' . __('If an update is available, you&#8127;ll see a notification appear in the Toolbar and navigation menu.') . ' ' . __('Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.') . '</p>';
get_current_screen()->add_help_tab(array('id' => 'overview', 'title' => __('Overview'), 'content' => $updates_overview));
$updates_howto = '<p>' . __('<strong>WordPress</strong> &mdash; Updating your WordPress installation is a simple one-click procedure: just <strong>click on the &#8220;Update Now&#8221; button</strong> when you are notified that a new version is available.') . ' ' . __('In most cases, WordPress will automatically apply maintenance and security updates in the background for you.') . '</p>';
$updates_howto .= '<p>' . __('<strong>Themes and Plugins</strong> &mdash; To update individual themes or plugins from this screen, use the checkboxes to make your selection, then <strong>click on the appropriate &#8220;Update&#8221; button</strong>. To update all of your themes or plugins at once, you can check the box at the top of the section to select all before clicking the update button.') . '</p>';
if ('en_US' != get_locale()) {
    $updates_howto .= '<p>' . __('<strong>Translations</strong> &mdash; The files translating WordPress into your language are updated for you whenever any other updates occur. But if these files are out of date, you can <strong>click the &#8220;Update Translations&#8221;</strong> button.') . '</p>';
}
get_current_screen()->add_help_tab(array('id' => 'how-to-update', 'title' => __('How to Update'), 'content' => $updates_howto));
get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="https://codex.wordpress.org/Dashboard_Updates_Screen" target="_blank">Documentation on Updating WordPress</a>') . '</p>' . '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>');
if ('upgrade-core' == $action) {
    // Force a update check when requested
    $force_check = !empty($_GET['force-check']);
    wp_version_check(array(), $force_check);
    require_once ABSPATH . 'wp-admin/admin-header.php';
    ?>
	<div class="wrap">
	<h1><?php 
    _e('WordPress Updates');
    ?>
</h1>
	<?php 
    if ($upgrade_error) {
        echo '<div class="error"><p>';
        if ($upgrade_error == 'themes') {
            _e('Please select one or more themes to update.');
        } else {
            _e('Please select one or more plugins to update.');
        }
 /**
  * Kicks off the background update process, looping through all pending updates.
  *
  * @since 3.7.0
  * @access public
  *
  * @global wpdb   $wpdb
  * @global string $wp_version
  */
 public function run()
 {
     global $wpdb, $wp_version;
     if ($this->is_disabled()) {
         return;
     }
     if (!is_main_network() || !is_main_site()) {
         return;
     }
     if (!$this->create_lock('auto_updater')) {
         return;
     }
     // Don't automatically run these thins, as we'll handle it ourselves
     remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
     remove_action('upgrader_process_complete', 'wp_version_check');
     remove_action('upgrader_process_complete', 'wp_update_plugins');
     remove_action('upgrader_process_complete', 'wp_update_themes');
     // Next, Plugins
     wp_update_plugins();
     // Check for Plugin updates
     $plugin_updates = get_site_transient('update_plugins');
     if ($plugin_updates && !empty($plugin_updates->response)) {
         foreach ($plugin_updates->response as $plugin) {
             $this->update('plugin', $plugin);
         }
         // Force refresh of plugin update information
         wp_clean_plugins_cache();
     }
     // Next, those themes we all love
     wp_update_themes();
     // Check for Theme updates
     $theme_updates = get_site_transient('update_themes');
     if ($theme_updates && !empty($theme_updates->response)) {
         foreach ($theme_updates->response as $theme) {
             $this->update('theme', (object) $theme);
         }
         // Force refresh of theme update information
         wp_clean_themes_cache();
     }
     // Next, Process any core update
     wp_version_check();
     // Check for Core updates
     $core_update = find_core_auto_update();
     if ($core_update) {
         $this->update('core', $core_update);
     }
     // Clean up, and check for any pending translations
     // (Core_Upgrader checks for core updates)
     $theme_stats = array();
     if (isset($this->update_results['theme'])) {
         foreach ($this->update_results['theme'] as $upgrade) {
             $theme_stats[$upgrade->item->theme] = true === $upgrade->result;
         }
     }
     wp_update_themes($theme_stats);
     // Check for Theme updates
     $plugin_stats = array();
     if (isset($this->update_results['plugin'])) {
         foreach ($this->update_results['plugin'] as $upgrade) {
             $plugin_stats[$upgrade->item->plugin] = true === $upgrade->result;
         }
     }
     wp_update_plugins($plugin_stats);
     // Check for Plugin updates
     // Finally, Process any new translations
     $language_updates = wp_get_translation_updates();
     if ($language_updates) {
         foreach ($language_updates as $update) {
             $this->update('translation', $update);
         }
         // Clear existing caches
         wp_clean_update_cache();
         wp_version_check();
         // check for Core updates
         wp_update_themes();
         // Check for Theme updates
         wp_update_plugins();
         // Check for Plugin updates
     }
     // Send debugging email to all development installs.
     if (!empty($this->update_results)) {
         $development_version = false !== strpos($wp_version, '-');
         /**
          * Filter whether to send a debugging email for each automatic background update.
          *
          * @since 3.7.0
          *
          * @param bool $development_version By default, emails are sent if the
          *                                  install is a development version.
          *                                  Return false to avoid the email.
          */
         if (apply_filters('automatic_updates_send_debug_email', $development_version)) {
             $this->send_debug_email();
         }
         if (!empty($this->update_results['core'])) {
             $this->after_core_update($this->update_results['core'][0]);
         }
         /**
          * Fires after all automatic updates have run.
          *
          * @since 3.8.0
          *
          * @param array $update_results The results of all attempted updates.
          */
         do_action('automatic_updates_complete', $this->update_results);
     }
     $this->release_lock('auto_updater');
 }
Example #25
0
function _maybe_update_core()
{
    include ABSPATH . WPINC . '/version.php';
    // include an unmodified $wp_version
    $current = get_site_transient('update_core');
    if (isset($current->last_checked) && 43200 > time() - $current->last_checked && isset($current->version_checked) && $current->version_checked == $wp_version) {
        return;
    }
    wp_version_check();
}
 public function get_updates($options)
 {
     if (!current_user_can('update_plugins') && !current_user_can('update_themes') && !current_user_can('update_core')) {
         return $this->_generic_error_response('updates_permission_denied');
     }
     $this->_admin_include('plugin.php', 'update.php', 'file.php', 'template.php');
     $this->_frontend_include('update.php');
     if (!is_array($options)) {
         $options = array();
     }
     // Normalise it
     $plugin_updates = array();
     if (current_user_can('update_plugins')) {
         // Detect if refresh needed
         $transient = get_site_transient('update_plugins');
         if (!empty($options['force_refresh']) || false === $transient) {
             delete_site_transient('update_plugins');
             wp_update_plugins();
         }
         $get_plugin_updates = get_plugin_updates();
         if (is_array($get_plugin_updates)) {
             foreach ($get_plugin_updates as $update) {
                 $plugin_updates[] = array('name' => $update->Name, 'plugin_uri' => $update->PluginURI, 'version' => $update->Version, 'description' => $update->Description, 'author' => $update->Author, 'author_uri' => $update->AuthorURI, 'title' => $update->Title, 'author_name' => $update->AuthorName, 'update' => array('plugin' => $update->update->plugin, 'slug' => $update->update->slug, 'new_version' => $update->update->new_version, 'package' => $update->update->package, 'tested' => isset($update->update->tested) ? $update->update->tested : null, 'compatibility' => isset($update->update->compatibility) ? (array) $update->update->compatibility : null, 'sections' => isset($update->update->sections) ? (array) $update->update->sections : null));
             }
         }
     }
     $theme_updates = array();
     if (current_user_can('update_themes')) {
         // Detect if refresh needed
         $transient = get_site_transient('update_themes');
         if (!empty($options['force_refresh']) || false === $transient) {
             delete_site_transient('update_themes');
             wp_update_themes();
         }
         $get_theme_updates = get_theme_updates();
         if (is_array($get_theme_updates)) {
             foreach ($get_theme_updates as $update) {
                 $theme_updates[] = array('name' => @$update->Name, 'theme_uri' => @$update->ThemeURI, 'version' => @$update->Version, 'description' => @$update->Description, 'author' => @$update->Author, 'author_uri' => @$update->AuthorURI, 'update' => array('theme' => @$update->update['theme'], 'new_version' => @$update->update['new_version'], 'package' => @$update->update['package'], 'url' => @$update->update['url']));
             }
         }
     }
     $core_updates = array();
     if (current_user_can('update_core')) {
         // Detect if refresh needed
         $transient = get_site_transient('update_core');
         if (!empty($options['force_refresh']) || false === $transient) {
             // The next line is only needed for older WP versions - otherwise, the parameter to wp_version_check forces a check.
             delete_site_transient('update_core');
             wp_version_check(array(), true);
         }
         $get_core_updates = get_core_updates();
         if (is_array($get_core_updates)) {
             $core_update_key = false;
             $core_update_latest_version = false;
             @(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) {
                 $update = $get_core_updates[$core_update_key];
                 global $wpdb;
                 $mysql_version = $wpdb->db_version();
                 $is_mysql = file_exists(WP_CONTENT_DIR . '/db.php') && empty($wpdb->is_mysql) ? false : true;
                 $core_updates[] = array('download' => $update->download, 'version' => $update->version, 'php_version' => $update->php_version, 'mysql_version' => $update->mysql_version, 'installed' => array('version' => $wp_version, 'mysql' => $mysql_version, 'php' => PHP_VERSION, 'is_mysql' => $is_mysql), 'sufficient' => array('mysql' => version_compare($mysql_version, $update->mysql_version, '>='), 'php' => version_compare(PHP_VERSION, $update->php_version, '>=')));
             }
         }
     }
     // Do we need to ask the user for filesystem credentials?
     $request_filesystem_credentials = array();
     $check_fs = array('plugins' => WP_PLUGIN_DIR, 'themes' => WP_CONTENT_DIR . '/themes', 'core' => untrailingslashit(ABSPATH));
     foreach ($check_fs as $entity => $dir) {
         $filesystem_method = get_filesystem_method(array(), $dir);
         ob_start();
         $filesystem_credentials_are_stored = request_filesystem_credentials(site_url());
         $filesystem_form = strip_tags(ob_get_contents(), '<div><h2><p><input><label><fieldset><legend><span><em>');
         ob_end_clean();
         $request_filesystem_credentials[$entity] = $filesystem_method != 'direct' && !$filesystem_credentials_are_stored;
     }
     $automatic_backups = class_exists('UpdraftPlus_Options') && class_exists('UpdraftPlus_Addon_Autobackup') && UpdraftPlus_Options::get_updraft_option('updraft_autobackup_default', true) ? true : false;
     return $this->_response(array('plugins' => $plugin_updates, 'themes' => $theme_updates, 'core' => $core_updates, 'meta' => array('request_filesystem_credentials' => $request_filesystem_credentials, 'filesystem_form' => $filesystem_form, 'automatic_backups' => $automatic_backups)));
 }
Example #27
0
 public function check_notifications()
 {
     global $wp_version;
     $mwp_notifications = get_option('mwp_notifications', true);
     $args = array();
     $updates = array();
     $send = 0;
     if (is_array($mwp_notifications) && $mwp_notifications != false) {
         include_once ABSPATH . 'wp-includes/update.php';
         include_once ABSPATH . '/wp-admin/includes/update.php';
         extract($mwp_notifications);
         //Check wordpress core updates
         if ($wp) {
             @wp_version_check();
             if (function_exists('get_core_updates')) {
                 $wp_updates = get_core_updates();
                 if (!empty($wp_updates)) {
                     $current_transient = $wp_updates[0];
                     if ($current_transient->response == "development" || version_compare($wp_version, $current_transient->current, '<')) {
                         $current_transient->current_version = $wp_version;
                         $updates['core_updates'] = $current_transient;
                     } else {
                         $updates['core_updates'] = array();
                     }
                 } else {
                     $updates['core_updates'] = array();
                 }
             }
         }
         //Check plugin updates
         if ($plugins) {
             @wp_update_plugins();
             $this->get_installer_instance();
             $updates['upgradable_plugins'] = $this->installer_instance->get_upgradable_plugins();
         }
         //Check theme updates
         if ($themes) {
             @wp_update_themes();
             $this->get_installer_instance();
             $updates['upgradable_themes'] = $this->installer_instance->get_upgradable_themes();
         }
         if ($backups) {
             $this->get_backup_instance();
             $backups = $this->backup_instance->get_backup_stats();
             $updates['backups'] = $backups;
             foreach ($backups as $task_name => $backup_results) {
                 foreach ($backup_results as $k => $backup) {
                     if (isset($backups[$task_name][$k]['server']['file_path'])) {
                         unset($backups[$task_name][$k]['server']['file_path']);
                     }
                 }
             }
             $updates['backups'] = $backups;
         }
         if (!empty($updates)) {
             $args['body']['updates'] = $updates;
             $args['body']['notification_key'] = $notification_key;
             $send = 1;
         }
     }
     $alert_data = get_option('mwp_pageview_alerts', true);
     if (is_array($alert_data) && $alert_data['alert']) {
         $pageviews = get_option('user_hit_count');
         $args['body']['alerts']['pageviews'] = $pageviews;
         $args['body']['alerts']['site_id'] = $alert_data['site_id'];
         if (!isset($url)) {
             $url = $alert_data['url'];
         }
         $send = 1;
     }
     if ($send) {
         if (!class_exists('WP_Http')) {
             include_once ABSPATH . WPINC . '/class-http.php';
         }
         $result = wp_remote_post($url, $args);
         if (is_array($result) && $result['body'] == 'mwp_delete_alert') {
             delete_option('mwp_pageview_alerts');
         }
     }
 }
Example #28
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');
     }
 }
}

function do_undismiss_core_update() {
	$version = isset( $_POST['version'] )? $_POST['version'] : false;
	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
	$update = find_core_update( $version, $locale );
	if ( !$update )
		return;
	undismiss_core_update( $version, $locale );
	wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
}

$action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';

if ( 'upgrade-core' == $action ) {
	wp_version_check();
	$title = __('Upgrade WordPress');
	$parent_file = 'tools.php';
	require_once('admin-header.php');
	core_upgrade_preamble();
	include('admin-footer.php');
} elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
	check_admin_referer('upgrade-core');
	$title = __('Upgrade WordPress');
	$parent_file = 'tools.php';
	// do the (un)dismiss actions before headers,
	// so that they can redirect
	if ( isset( $_POST['dismiss'] ) )
		do_dismiss_core_update();
	elseif ( isset( $_POST['undismiss'] ) )
	do_undismiss_core_update();
 /**
  * Kicks off a upgrade request for each item in the upgrade "queue"
  */
 static function perform_auto_updates()
 {
     $lock_name = 'auto_upgrader.lock';
     if (get_site_option($lock_name)) {
         // Test to see if it was set more than an hour ago, if so, cleanup.
         if (get_site_option($lock_name) < time() - HOUR_IN_SECONDS) {
             delete_site_option($lock_name);
         } else {
             // The process is already locked
             return;
         }
     }
     // Lock upgrades for us for half an hour
     if (!add_site_option($lock_name, microtime(true), HOUR_IN_SECONDS / 2)) {
         return;
     }
     // Don't automatically run these thins, as we'll handle it ourselves
     remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20, 3);
     remove_action('upgrader_process_complete', 'wp_version_check');
     remove_action('upgrader_process_complete', 'wp_update_plugins');
     remove_action('upgrader_process_complete', 'wp_update_themes');
     // Next, Plugins
     wp_update_plugins();
     // Check for Plugin updates
     $plugin_updates = get_site_transient('update_plugins');
     if ($plugin_updates && !empty($plugin_updates->response)) {
         foreach (array_keys($plugin_updates->response) as $plugin) {
             self::upgrade('plugin', $plugin);
         }
         // Force refresh of plugin update information
         wp_clean_plugins_cache();
     }
     // Next, those themes we all love
     wp_update_themes();
     // Check for Theme updates
     $theme_updates = get_site_transient('update_themes');
     if ($theme_updates && !empty($theme_updates->response)) {
         foreach (array_keys($theme_updates->response) as $theme) {
             self::upgrade('theme', $theme);
         }
         // Force refresh of theme update information
         wp_clean_themes_cache();
     }
     // Next, Process any core upgrade
     wp_version_check();
     // Check for Core updates
     $core_update = find_core_auto_update();
     if ($core_update) {
         self::upgrade('core', $core_update);
         delete_site_transient('update_core');
     }
     // Cleanup, and check for any pending translations
     wp_version_check();
     // check for Core updates
     wp_update_themes();
     // Check for Theme updates
     wp_update_plugins();
     // Check for Plugin updates
     // Finally, Process any new translations
     $language_updates = wp_get_translation_updates();
     if ($language_updates) {
         foreach ($language_updates as $update) {
             self::upgrade('language', $update);
         }
         // Clear existing caches
         wp_clean_plugins_cache();
         wp_clean_themes_cache();
         delete_site_transient('update_core');
         wp_version_check();
         // check for Core updates
         wp_update_themes();
         // Check for Theme updates
         wp_update_plugins();
         // Check for Plugin updates
     }
     /**
      * Filter whether to email an update summary to the site administrator.
      *
      * @since 3.7.0
      *
      * @param bool                         Whether or not email should be sent to administrator. Default true.
      * @param bool|array $core_update      An array of core update data, false otherwise.
      * @param object     $theme_updates    Object containing theme update properties.
      * @param object     $plugin_updates   Object containing plugin update properties.
      * @param array      $language_updates Array containing the Language updates available.
      * @param array      $upgrade_results  Array of the upgrade results keyed by upgrade type, and plugin/theme slug.
      */
     if (apply_filters('enable_auto_upgrade_email', true, $core_update, $theme_updates, $plugin_updates, $language_updates, self::$upgrade_results)) {
         self::send_email();
     }
     // Clear the lock
     delete_site_option($lock_name);
 }