コード例 #1
0
 /**
  * Finds out if a site is using a version control system.
  * @return bool
  **/
 public static function is_version_controlled()
 {
     if (!class_exists('WP_Automatic_Updater')) {
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     }
     $updater = new WP_Automatic_Updater();
     return (bool) strval($updater->is_vcs_checkout($context = ABSPATH));
 }
コード例 #2
0
 /**
  * Finds out if a site is using a version control system.
  * @return string ( '1' | '0' )
  **/
 public static function is_version_controlled()
 {
     if (!class_exists('WP_Automatic_Updater')) {
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     }
     $updater = new WP_Automatic_Updater();
     $is_version_controlled = strval($updater->is_vcs_checkout($context = ABSPATH));
     // transients should not be empty
     if (empty($is_version_controlled)) {
         $is_version_controlled = '0';
     }
     return $is_version_controlled;
 }
コード例 #3
0
 /**
  * Asynchronously upgrades language packs after other upgrades have been made.
  *
  * Hooked to the {@see 'upgrader_process_complete'} action by default.
  *
  * @since 3.7.0
  * @access public
  * @static
  *
  * @param false|WP_Upgrader $upgrader Optional. WP_Upgrader instance or false. If `$upgrader` is
  *                                    a Language_Pack_Upgrader instance, the method will bail to
  *                                    avoid recursion. Otherwise unused. Default false.
  */
 public static function async_upgrade($upgrader = false)
 {
     // Avoid recursion.
     if ($upgrader && $upgrader instanceof Language_Pack_Upgrader) {
         return;
     }
     // Nothing to do?
     $language_updates = wp_get_translation_updates();
     if (!$language_updates) {
         return;
     }
     /*
      * Avoid messing with VCS installs, at least for now.
      * Noted: this is not the ideal way to accomplish this.
      */
     $check_vcs = new WP_Automatic_Updater();
     if ($check_vcs->is_vcs_checkout(WP_CONTENT_DIR)) {
         return;
     }
     foreach ($language_updates as $key => $language_update) {
         $update = !empty($language_update->autoupdate);
         /**
          * Filters whether to asynchronously update translation for core, a plugin, or a theme.
          *
          * @since 4.0.0
          *
          * @param bool   $update          Whether to update.
          * @param object $language_update The update offer.
          */
         $update = apply_filters('async_update_translation', $update, $language_update);
         if (!$update) {
             unset($language_updates[$key]);
         }
     }
     if (empty($language_updates)) {
         return;
     }
     // Re-use the automatic upgrader skin if the parent upgrader is using it.
     if ($upgrader && $upgrader->skin instanceof Automatic_Upgrader_Skin) {
         $skin = $upgrader->skin;
     } else {
         $skin = new Language_Pack_Upgrader_Skin(array('skip_header_footer' => true));
     }
     $lp_upgrader = new Language_Pack_Upgrader($skin);
     $lp_upgrader->bulk_upgrade($language_updates);
 }
コード例 #4
0
 static function get_possible_failures()
 {
     $result = array();
     // Lets check some reasons why it might not be working as expected
     include_once ABSPATH . '/wp-admin/includes/admin.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
     $upgrader = new WP_Automatic_Updater();
     if ($upgrader->is_disabled()) {
         $result[] = 'autoupdates-disabled';
     }
     if (!is_main_site()) {
         $result[] = 'is-not-main-site';
     }
     if (!is_main_network()) {
         $result[] = 'is-not-main-network';
     }
     if ($upgrader->is_vcs_checkout(ABSPATH)) {
         $result[] = 'site-on-vcs';
     }
     if ($upgrader->is_vcs_checkout(WP_PLUGIN_DIR)) {
         $result[] = 'plugin-directory-on-vcs';
     }
     if ($upgrader->is_vcs_checkout(WP_CONTENT_DIR)) {
         $result[] = 'content-directory-on-vcs';
     }
     $lock = get_option('auto_updater.lock');
     if ($lock > time() - HOUR_IN_SECONDS) {
         $result[] = 'lock-is-set';
     }
     $skin = new Automatic_Upgrader_Skin();
     include_once ABSPATH . 'wp-admin/includes/file.php';
     include_once ABSPATH . 'wp-admin/includes/template.php';
     if (!$skin->request_filesystem_credentials(false, ABSPATH, false)) {
         $result[] = 'no-system-write-access';
     }
     if (!$skin->request_filesystem_credentials(false, WP_PLUGIN_DIR, false)) {
         $result[] = 'no-plugin-directory-write-access';
     }
     if (!$skin->request_filesystem_credentials(false, WP_CONTENT_DIR, false)) {
         $result[] = 'no-wp-content-directory-write-access';
     }
     return $result;
 }
コード例 #5
0
ファイル: automatic-updater.php プロジェクト: omodev/hooks
 function plugin_upgrade()
 {
     if (empty($this->options)) {
         // Don't automatically enable core updates in installs coming from a repo
         if (!class_exists('WP_Automatic_Updater')) {
             include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         }
         $wpau = new WP_Automatic_Updater();
         $core_updates_enabled = !$wpau->is_vcs_checkout(ABSPATH);
         $this->options = array('update' => array('core' => array('minor' => $core_updates_enabled, 'major' => false), 'plugins' => false, 'themes' => false), 'svn' => array('core' => false, 'plugins' => array(), 'themes' => array()), 'svn-success-email' => true, 'debug' => 'debug', 'next-development-update' => time(), 'override-email' => '', 'disable-email' => false, 'upgrade-after-3.7' => true);
     }
     // 'debug' option added in version 0.3
     if (!array_key_exists('debug', $this->options)) {
         $this->options['debug'] = false;
     }
     // SVN updates added in version 0.5
     if (!array_key_exists('svn', $this->options)) {
         $this->options['svn'] = false;
     }
     // Development version updates added in version 0.6
     if (!array_key_exists('next-development-update', $this->options)) {
         $this->options['next-development-update'] = time();
     }
     // Override contact email added in version 0.7
     if (!array_key_exists('override-email', $this->options)) {
         $this->options['override-email'] = '';
     }
     // Ability to disable email added in version 0.7
     if (!array_key_exists('disable-email', $this->options)) {
         $this->options['disable-email'] = false;
     }
     // Ability to only send SVN update emails on failure added in 0.8
     if (!array_key_exists('svn-success-email', $this->options)) {
         $this->options['svn-success-email'] = true;
     }
     // SVN support for themes and plugins added in 0.8
     if (!is_array($this->options['svn'])) {
         $this->options['svn'] = array('core' => $this->options['svn'], 'plugins' => array(), 'themes' => array());
     }
     if (!array_key_exists('upgrade-after-3.7', $this->options)) {
         $this->options['upgrade-after-3.7'] = true;
         // Core is handling upgrades now, so we should unschedule our old events
         foreach ($this->options['update'] as $type => $update) {
             $timestamp = wp_next_scheduled("auto_updater_{$type}_event");
             if ($timestamp) {
                 wp_unschedule_event($timestamp, "auto_updater_{$type}_event");
             }
         }
     }
     // Support for different types of core upgrades added in 1.0
     if (!is_array($this->options['update']['core'])) {
         $this->options['update']['core'] = array('major' => $this->options['update']['core'], 'minor' => $this->options['update']['core']);
     }
     // debug option changed to send debug email under varying conditions in 1.0
     if (is_bool($this->options['debug'])) {
         if ($this->options['debug']) {
             $this->options['debug'] = 'always';
         } else {
             $this->options['debug'] = 'debug';
         }
     }
 }
コード例 #6
0
 /**
  * Finds out if a site is using a version control system.
  * We'll store that information as a transient with a 24 expiration.
  * We only need to check once per day.
  *
  * @return string ( '1' | '0' )
  */
 function is_version_controlled()
 {
     $is_version_controlled = get_transient('jetpack_site_is_vcs');
     if (false === $is_version_controlled) {
         include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         $updater = new WP_Automatic_Updater();
         $is_version_controlled = strval($updater->is_vcs_checkout($context = ABSPATH));
         // transients should not be empty
         if (empty($is_version_controlled)) {
             $is_version_controlled = '0';
         }
         set_transient('jetpack_site_is_vcs', $is_version_controlled, DAY_IN_SECONDS);
     }
     return $is_version_controlled;
 }