PHP Class WPCOM_VIP_Plugins_UI, vip-mu-plugins-public

Show file Open project: Automattic/vip-mu-plugins-public Class Usage Examples

Public Properties

Property Type Description
$activation_disabled Whether or not to disable the plugin activation links.
$capability Required capability to access this plugin's features. Use the "wpcom_vip_plugins_ui_capability" filter to change this.
$fpp_plugins List of Featured Partner Program plugins.
$hidden_plugins List of plugins that should be hidden.
$hook_suffix The $hook_suffix value for the menu page.
$parent_menu_slug Parent menu's slug. Use the "wpcom_vip_plugins_ui_parent_menu_slug" filter to change this.
$plugin_folder Path to the extra plugins folder.

Public Methods

Method Description
__clone ( ) A dummy magic method to prevent WPCOM_VIP_Plugins_UI from being cloned
__wakeup ( ) A dummy magic method to prevent WPCOM_VIP_Plugins_UI from being unserialized
action_admin_menu_add_menu_item ( ) Adds the new menu item and registers a few more hook callbacks relating to the menu page.
action_admin_post_plugin_activate ( ) Handles the plugin activation links and activates the requested plugin.
action_admin_post_plugin_deactivate ( ) Handles the plugin deactivation links and deactivates the requested plugin.
action_enqueue_scripts ( string $hook ) : void Load the assets for this plugin on the correct screen only
action_init ( ) Now that we've given the theme time to register its own filters, set up the rest of the plugin's hooks and run some filters.
activate_plugin ( string $plugin ) : boolean | WP_Error Activates a plugin.
add_activate_or_deactive_action_link ( array $actions, string $plugin ) : array Filters an array of action links to add an activation or deactivation link.
cleanup_active_plugins_option ( ) Removes any invalid plugins from the option, i.e. when they're deleted.
community_plugins_menu_columns ( array $columns ) : array Filters the columns of the Community Plugins table.
deactivate_plugin ( string $plugin, $force = false ) : void Deactivates a plugin.
display_menu_page ( ) Outputs the contents of the menu page.
get_active_plugins_option ( ) : array Gets the list of VIP plugins that have been activated via the UI.
get_menu_url ( array $extra_query_args = [] ) : string Generates a link to the plugin's menu page.
get_plugin_activation_link ( string $plugin ) : string Generates the URL to activate a VIP plugin.
get_plugin_deactivation_link ( string $plugin ) : string Generates the URL to deactivate a VIP plugin.
get_plugins ( ) : array Grab list of regular WP plugins
get_shared_plugins ( ) : array Grab list of VIP Shared Plugins
include_active_plugins ( ) Includes any active plugin files that are enabled via the UI/option.
instance ( ) : WPCOM_VIP_Plugins_UI Main WPCOM_VIP_Plugins_UI Instance
is_plugin_active ( string $plugin ) : string | boolean Determines if a given plugin slug is already activated or not.
validate_plugin ( string $plugin ) : boolean Validates a plugin slug.

Private Methods

Method Description
__construct ( ) A dummy constructor to prevent WPCOM_VIP_Plugins_UI from being loaded more than once.
setup_actions ( ) Set up early action hooks for this plugin
setup_globals ( ) Set up the class variables.

Method Details

__clone() public method

A dummy magic method to prevent WPCOM_VIP_Plugins_UI from being cloned
public __clone ( )

__wakeup() public method

A dummy magic method to prevent WPCOM_VIP_Plugins_UI from being unserialized
public __wakeup ( )

action_admin_menu_add_menu_item() public method

Adds the new menu item and registers a few more hook callbacks relating to the menu page.

action_admin_post_plugin_activate() public method

Handles the plugin activation links and activates the requested plugin.

action_admin_post_plugin_deactivate() public method

Handles the plugin deactivation links and deactivates the requested plugin.

action_enqueue_scripts() public method

Load the assets for this plugin on the correct screen only
public action_enqueue_scripts ( string $hook ) : void
$hook string
return void

action_init() public method

Now that we've given the theme time to register its own filters, set up the rest of the plugin's hooks and run some filters.
public action_init ( )

activate_plugin() public method

Activates a plugin.
public activate_plugin ( string $plugin ) : boolean | WP_Error
$plugin string The slug of the plugin to activate.
return boolean | WP_Error True if the plugin was activated, a WP_Error if an error was encountered.

cleanup_active_plugins_option() public method

Removes any invalid plugins from the option, i.e. when they're deleted.

community_plugins_menu_columns() public static method

Filters the columns of the Community Plugins table.
public static community_plugins_menu_columns ( array $columns ) : array
$columns array An array of existing columns.
return array Modified list of columns.

deactivate_plugin() public method

Deactivates a plugin.
public deactivate_plugin ( string $plugin, $force = false ) : void
$plugin string The slug of the plugin to deactivate.
return void deactivate_plugins() returns nothing...so we can't actually know if it succeeded :)

display_menu_page() public method

Outputs the contents of the menu page.
public display_menu_page ( )

get_active_plugins_option() public method

Gets the list of VIP plugins that have been activated via the UI.
public get_active_plugins_option ( ) : array
return array List of active plugin slugs.

get_menu_url() public method

Generates a link to the plugin's menu page.
public get_menu_url ( array $extra_query_args = [] ) : string
$extra_query_args array Optional. Extra arguments to pass to add_query_arg().
return string URL to the plugin's menu page.

get_plugins() public method

Grab list of regular WP plugins
See also: get_plugins()
public get_plugins ( ) : array
return array Array of plugins

get_shared_plugins() public method

Grab list of VIP Shared Plugins
See also: get_plugins()
public get_shared_plugins ( ) : array
return array Array of shared plugins

include_active_plugins() public method

Includes any active plugin files that are enabled via the UI/option.

instance() public static method

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
return WPCOM_VIP_Plugins_UI The one true WPCOM_VIP_Plugins_UI

is_plugin_active() public method

Determines if a given plugin slug is already activated or not.
public is_plugin_active ( string $plugin ) : string | boolean
$plugin string The slug of the VIP plugin to check.
return string | boolean "option" if the plugin was activated via UI, "manual" if activated via code, and false if not activated.

validate_plugin() public method

Validates a plugin slug.
public validate_plugin ( string $plugin ) : boolean
$plugin string The slug of the VIP plugin to validate.
return boolean True if valid, false if not.

Property Details

$activation_disabled public property

Whether or not to disable the plugin activation links.
public $activation_disabled

$capability public property

Required capability to access this plugin's features. Use the "wpcom_vip_plugins_ui_capability" filter to change this.
public $capability

$fpp_plugins public property

List of Featured Partner Program plugins.
public $fpp_plugins

$hidden_plugins public property

List of plugins that should be hidden.
public $hidden_plugins

$hook_suffix public property

The $hook_suffix value for the menu page.
public $hook_suffix

$parent_menu_slug public property

Parent menu's slug. Use the "wpcom_vip_plugins_ui_parent_menu_slug" filter to change this.
public $parent_menu_slug

$plugin_folder public property

Path to the extra plugins folder.
public $plugin_folder