resume_plugin( string $plugin, string $redirect = '' ): true|WP_Error
- Since
- 5.2.0
- Source
wp-admin/includes/plugin.php:2514
Description
If a redirect was provided, we first ensure the plugin does not throw fatal errors anymore.
The way it works is by setting the redirection to the error before trying to include the plugin file. If the plugin fails, then the redirection will not be overwritten with the success message and the plugin will not be resumed.
Compatibility
- WordPress
- since 5.2.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$pluginstring- Single plugin to resume.
$redirectstringoptional- URL to redirect to. Default empty string.Default:
''
Return value
true|WP_Error- True on success, false if
$pluginwas not paused,WP_Erroron failure.
Performance profile
How much work a call to resume_plugin() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Constant
- Instructions
- 18–44
- Plugin surface
- None
- Called by
- 0
Reaches the database via ->delete().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 45.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- sqldatabase query
->delete()called directly - hookthird-party callbacks
apply_filters()one call below resume_plugin()
Further down the call graph this can also reach option, cache, serialize, transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost resume_plugin() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
empty($redirect) | 18 | explode(), wp_paused_plugins(), ->delete() |
empty($redirect) | 25 | explode(), wp_paused_plugins(), ->delete(), __() |
!empty($redirect) | 37 | wp_create_nonce(), add_query_arg(), wp_redirect(), ob_start(), plugin_sandbox_scrape(), ob_clean(), explode(), wp_paused_plugins(), ->delete() |
!empty($redirect) | 44 | wp_create_nonce(), add_query_arg(), wp_redirect(), ob_start(), plugin_sandbox_scrape(), ob_clean(), explode(), wp_paused_plugins(), ->delete(), __() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 45 instructions, 18–44 executed per call, 2 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 8
- wp_redirect()Redirects to another page.
- add_query_arg()Retrieves a modified URL query string.
- wp_create_nonce()Creates a cryptographic token tied to a specific action, user, user session, and window of time.
- plugin_sandbox_scrape()Loads a given plugin attempt to generate errors.
- wp_paused_plugins()Get the instance for storing paused plugins.
- __()Retrieves the translation of $text.
- wp_paused_plugins()::delete()
- WP_Error::__construct()Initializes the error.
Source code
function resume_plugin( $plugin, $redirect = '' ) { /* * We'll override this later if the plugin could be resumed without * creating a fatal error. */ if ( ! empty( $redirect ) ) { wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-resume-error_' . $plugin ), $redirect ) ); // Load the plugin to test whether it throws a fatal error. ob_start(); plugin_sandbox_scrape( $plugin ); ob_clean(); } list( $extension ) = explode( '/', $plugin ); $result = wp_paused_plugins()->delete( $extension ); if ( ! $result ) { return new WP_Error( 'could_not_resume_plugin', __( 'Could not resume the plugin.' ) ); } return true;}Changelog
Introduced in 5.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-admin/includes/plugin.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.