instance() public static méthode

Insures that only one instance of WPCOM_VIP_Plugins_UI exists in memory at any one time. Also prevents needing to define globals all over the place.
See also: WPCOM_VIP_Plugins_UI()
public static instance ( ) : WPCOM_VIP_Plugins_UI
Résultat WPCOM_VIP_Plugins_UI The one true WPCOM_VIP_Plugins_UI
 /**
  * Main WPCOM_VIP_Plugins_UI Instance
  *
  * Insures that only one instance of WPCOM_VIP_Plugins_UI exists in memory at any one time.
  * Also prevents needing to define globals all over the place.
  *
  * @staticvar array $instance
  * @uses WPCOM_VIP_Plugins_UI::setup_globals() Setup the globals needed
  * @uses WPCOM_VIP_Plugins_UI::setup_actions() Setup the hooks and actions
  * @see WPCOM_VIP_Plugins_UI()
  * @return WPCOM_VIP_Plugins_UI The one true WPCOM_VIP_Plugins_UI
  */
 public static function instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new WPCOM_VIP_Plugins_UI();
         self::$instance->setup_globals();
         self::$instance->setup_actions();
     }
     return self::$instance;
 }
 /**
  * Fetch the list of VIP plugins to display in the list table.
  */
 public function prepare_items()
 {
     $active = $inactive = array();
     $vip_plugins = WPCOM_VIP_Plugins_UI::instance();
     $shared_plugins = $vip_plugins->get_shared_plugins();
     foreach ($shared_plugins as $plugin_file => $plugin_data) {
         $plugin_folder = basename(dirname($plugin_file));
         if (isset(WPCOM_VIP_Plugins_UI()->fpp_plugins[$plugin_folder])) {
             continue;
         }
         $plugin_file = WPCOM_VIP_Plugins_UI::SHARED_PLUGINS_RELATIVE_PATH . '/' . $plugin_file;
         $status = WPCOM_VIP_Plugins_UI()->is_plugin_active($plugin_folder) ? 'active' : 'inactive';
         if ('inactive' === $status && in_array($plugin_folder, WPCOM_VIP_Plugins_UI()->hidden_plugins, true)) {
             continue;
         }
         ${$status}[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
     }
     $this->items = array_merge($active, $inactive);
 }
 /**
  * Fetch the list of VIP plugins to display in the list table.
  */
 public function prepare_items()
 {
     $active = $inactive = array();
     $vip_plugins = WPCOM_VIP_Plugins_UI::instance();
     $shared_plugins = $vip_plugins->get_shared_plugins();
     // The path has to be
     foreach ($shared_plugins as $plugin_file => $plugin_data) {
         $plugin_folder = basename(dirname($plugin_file));
         // FPP is listed separately
         if (isset(WPCOM_VIP_Plugins_UI()->fpp_plugins[$plugin_folder])) {
             continue;
         }
         $plugin_file = WPCOM_VIP_Plugins_UI::SHARED_PLUGINS_RELATIVE_PATH . '/' . $plugin_file;
         $status = WPCOM_VIP_Plugins_UI()->is_plugin_active($plugin_folder) ? 'active' : 'inactive';
         // Don't want some plugins showing up in the list
         if ('inactive' == $status && in_array($plugin_folder, WPCOM_VIP_Plugins_UI()->hidden_plugins)) {
             continue;
         }
         // Translate, Don't Apply Markup, Sanitize HTML
         ${$status}[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
     }
     $this->items = array_merge($active, $inactive);
 }
/**
 * The main function responsible for returning the one true WPCOM_VIP_Plugins_UI instance to functions everywhere.
 *
 * Use this function like you would a global variable, except without needing to declare the global.
 * Example: <?php $WPCOM_VIP_Plugins_UI = WPCOM_VIP_Plugins_UI(); ?>
 *
 * @return WPCOM_VIP_Plugins_UI The one true WPCOM_VIP_Plugins_UI Instance
 */
function WPCOM_VIP_Plugins_UI()
{
    return WPCOM_VIP_Plugins_UI::instance();
}