TGMPA_VERSION
TGMPA_VERSION
TGMPA version number.
Automatic plugin installation and activation library.
Creates a way to automatically install and activate plugins from within themes. The plugins can be either bundled, downloaded from the WordPress Plugin Repository or downloaded from another external source.
$instance : \TGM_Plugin_Activation
Holds a copy of itself, so it can be referenced by the class name.
admin_init() : null
Handles calls to show plugin information via links in the notices.
We get the links in the admin notices to point to the TGMPA page, rather than the typical plugin-install.php file, so we can prepare everything beforehand.
WP does not make it easy to show the plugin information in the thickbox - here we have to require a file that includes a function that does the main work of displaying it, enqueue some styles, set up some globals and finally call that function before exiting.
Down right easy once you know how...
Returns early if not the TGMPA page.
Returns early if not the TGMPA page.
thickbox()
Enqueue thickbox scripts/styles for plugin info.
Thickbox is not automatically included on all admin pages, so we must manually enqueue it for those pages.
Thickbox is only loaded if the user has not dismissed the admin notice or if there are any plugins left to install and activate.
admin_menu() : null
Adds submenu page if there are plugin actions to take.
This method adds the submenu page letting users know that a required plugin needs to be installed.
This page disappears once the plugin has been installed and activated.
Return early if user lacks capability to install a plugin.
install_plugins_page() : null
Echoes plugin installation form.
This method is the callback for the admin_menu method function. This displays the admin page and form area where the user can select to install and activate the plugin. Aborts early if we're processing a plugin installation action.
Aborts early if we're processing a plugin installation action.
maybe_adjust_source_dir(string $source, string $remote_source, \WP_Upgrader $upgrader) : string
Adjust the plugin directory name if necessary.
The final destination directory of a plugin is based on the subdirectory name found in the (un)zipped source. In some cases - most notably GitHub repository plugin downloads -, this subdirectory name is not the same as the expected slug and the plugin will not be recognized as installed. This is fixed by adjusting the temporary unzipped source subdirectory name to the expected plugin slug.
| string | $source | Path to upgrade/zip-file-name.tmp/subdirectory/. |
| string | $remote_source | Path to upgrade/zip-file-name.tmp. |
| \WP_Upgrader | $upgrader | Instance of the upgrader which installs the plugin. |
$source
notices() : null
Echoes required plugin notice.
Outputs a message telling users that a specific plugin is required for their theme. If appropriate, it includes a link to the form page where users can install and activate the plugin.
Returns early if we're on the Install page.
Returns early if we're on the Install page.
register(array|null $plugin) : null
Add individual plugin to our collection of plugins.
If the required keys are not set or the plugin has already been registered, the plugin is not added.
| array|null | $plugin | Array of plugin arguments or null if invalid argument. |
Return early if incorrect argument.
sanitize_key(string $key) : string
Sanitizes a string key.
Near duplicate of WP Core sanitize_key(). The difference is that uppercase characters are
allowed, so as not to break upgrade paths from non-standard bundled plugins using uppercase
characters in the plugin directory path/slug. Silly them.
| string | $key | String key. |
Sanitized key
_get_plugin_data_from_name(string $name, string $data) : string|boolean
Retrieve plugin data, given the plugin name.
Loops through the registered plugins looking for $name. If it finds it, it returns the $data from that plugin. Otherwise, returns false.
| string | $name | Name of the plugin, as it was registered. |
| string | $data | Optional. Array key of plugin data to return. Default is slug. |
Plugin slug if found, false otherwise.
get_tgmpa_url() : string
Retrieve the URL to the TGMPA Install page.
I.e. depending on the config settings passed something along the lines of: http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins
Properly encoded URL (not escaped).
get_tgmpa_status_url(string $status) : string
Retrieve the URL to the TGMPA Install page for a specific plugin status (view).
I.e. depending on the config settings passed something along the lines of: http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins&plugin_status=install
| string | $status | Plugin status - either 'install', 'update' or 'activate'. |
Properly encoded URL (not escaped).
can_plugin_update(string $slug) : bool
Check if a plugin can be updated, i.e. if we have information on the minimum WP version required available, check whether the current install meets them.
| string | $slug | Plugin slug. |
True if OK to update, false otherwise.
get_installed_version(string $slug) : string
Retrieve the version number of an installed plugin.
| string | $slug | Plugin slug. |
Version number as string or an empty string if the plugin is not installed
or version unknown (plugins which don't comply with the plugin header standard).
force_activation()
Forces plugin activation if the parameter 'force_activation' is set to true.
This allows theme authors to specify certain plugins that must be active at all times while using the current theme.
Please take special care when using this parameter as it has the potential to be harmful if not used correctly. Setting this parameter to true will not allow the specified plugin to be deactivated unless the user switches themes.
force_deactivation()
Forces plugin deactivation if the parameter 'force_deactivation' is set to true.
This allows theme authors to specify certain plugins that must be deactivated upon switching from the current theme to another.
Please take special care when using this parameter as it has the potential to be harmful if not used correctly.
do_plugin_install() : boolean
Installs, updates or activates a plugin depending on the action link clicked by the user.
Checks the $_GET variable to see which actions have been passed and responds with the appropriate method.
Uses WP_Filesystem to process and handle the plugin installation method.
True on success, false on failure.
activate_single_plugin(string $file_path, string $slug, bool $automatic) : bool
Activate a single plugin and send feedback about the result to the screen.
| string | $file_path | Path within wp-plugins/ to main plugin file. |
| string | $slug | Plugin slug. |
| bool | $automatic | Whether this is an automatic activation after an install. Defaults to false. |
False if an error was encountered, true otherwise.
get_plugin_source_type(string $source) : string
Determine what type of source the plugin comes from.
| string | $source | The source of the plugin as provided, either empty (= WP repo), a file path |
'repo', 'external', or 'bundled'
_get_plugin_basename_from_slug(string $slug) : string
Helper function to extract the file path of the plugin file from the plugin slug, if the plugin is installed.
| string | $slug | Plugin slug (typically folder name) as provided by the developer. |
Either file path for plugin if installed, or just the plugin slug.