
WP-CLI v2 – 通过终端管理WordPress
resume_plugin ( $plugin, $redirect = '' )
resume_plugin: 这是一个WordPress动作,当一个插件被停用后恢复时被触发: 当一个插件被停用时,它的功能不会被执行: 当该插件被重新激活时,resume_plugin被调用,允许该插件恢复其功能。
尝试恢复一个插件。
如果提供了一个重定向,我们首先确保该插件不再抛出致命的错误。
它的工作方式是,在尝试包含插件文件之前,将重定向设置为错误。如果该插件失败了,那么重定向将不会 被成功信息覆盖,并且该插件不会被恢复。”
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; }