예제 #1
0
 /**
  * @todo   TEST IF IT WORKS!!!
  *
  * Include plugins for automatic updates based on stored settings.
  *
  * @see    http://wordpress.stackexchange.com/questions/131394/how-do-i-exclude-plugins-from-getting-automatically-updated/131404#131404
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.4
  *
  * @param bool   $update Whether to update (not used for plugins)
  * @param object $item   The plugin's info
  *
  * @return bool
  */
 static function _include_plugins_in_auto_update($update, $item)
 {
     // Before version 3.8.2 the $item was the file name of the plugin,
     // while in 3.8.2 statistics were added (https://core.trac.wordpress.org/changeset/27905).
     $by_slug = (int) str_replace('.', '', get_bloginfo('version')) >= 382;
     if (!isset(self::$_auto_updated_plugins)) {
         $plugins = self::$_accounts->get_option('plugins', array());
         $identifiers = array();
         foreach ($plugins as $p) {
             /**
              * @var FS_Plugin $p
              */
             if (isset($p->auto_update) && $p->auto_update) {
                 $identifiers[] = $by_slug ? $p->slug : plugin_basename($p->file);
             }
         }
         self::$_auto_updated_plugins = $identifiers;
     }
     if (in_array($by_slug ? $item->slug : $item, self::$_auto_updated_plugins)) {
         return true;
     }
     // Pass update decision to next filters
     return $update;
 }