wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



resume_plugin › WordPress Function

Da5.2.0
Deprecaton/a
resume_plugin ( $plugin, $redirect = '' )
Parametri: (2)
  • (string) $plugin Single plugin to resume.
    Richiesto:
  • (string) $redirect Optional. URL to redirect to. Default empty string.
    Richiesto: No
    Default: (vuoto)
Ritorna:
  • (true|WP_Error) True on success, false if `$plugin` was not paused, `WP_Error` on failure.
Definito a:
Codex:

Tries to resume a single plugin.

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.


Sorgenti

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;
}