UsePluginHelpers
Table of Contents
- activate_plugin_by_slug() : false|null|WP_Error
- Activate a plugin by its slug.
- deactivate_plugin_by_slug() : bool
- Deactivate a plugin by its slug.
- delete_plugin_by_slug() : bool|WP_Error
- Deactivate and delete a plugin by its slug.
- is_plugin_dir() : bool
- Check if a plugin with the specified slug is installed.
Methods
activate_plugin_by_slug()
Activate a plugin by its slug.
public
activate_plugin_by_slug(string $slug) : false|null|WP_Error
Searches for the plugin with the specified slug in the installed plugins and activates it.
Parameters
- $slug : string
-
The slug of the plugin to activate.
Return values
false|null|WP_Error — Null on success, WP_Error on invalid file, false if not found.deactivate_plugin_by_slug()
Deactivate a plugin by its slug.
public
deactivate_plugin_by_slug(string $slug) : bool
Searches for the plugin with the specified slug in the installed plugins and deactivates it.
Parameters
- $slug : string
-
The slug of the plugin to deactivate.
Return values
bool — True if the plugin was deactivated, false otherwise.delete_plugin_by_slug()
Deactivate and delete a plugin by its slug.
public
delete_plugin_by_slug(string $slug) : bool|WP_Error
Searches for the plugin with the specified slug in the installed plugins, deactivates it if active, and then deletes it.
Parameters
- $slug : string
-
The slug of the plugin to delete.
Return values
bool|WP_Error — True if the plugin was deleted, false otherwise.is_plugin_dir()
Check if a plugin with the specified slug is installed.
public
is_plugin_dir(string $slug) : bool
Parameters
- $slug : string
-
The slug of the plugin to check.