resume_plugin

函式
resume_plugin ( $plugin, $redirect = '' )
引數
  • (string) $plugin Single plugin to resume.
    Required:
  • (string) $redirect Optional. URL to redirect to. Default empty string.
    Required:
    Default: (empty)
返回值
  • (bool|WP_Error) True on success, false if `$plugin` was not paused, `WP_Error` on failure.
定義位置
相關方法
delete_pluginsget_pluginsget_mu_pluginswp_update_pluginwp_update_plugins
引入
5.2.0
棄用
-

resume_plugin: 這是一個WordPress動作,當一個外掛被停用後恢復時被觸發: 當一個外掛被停用時,它的功能不會被執行: 當該外掛被重新啟用時,resume_plugin被呼叫,允許該外掛恢復其功能。

嘗試恢復一個外掛。

如果提供了一個重定向,我們首先確保該外掛不再丟擲致命的錯誤。

它的工作方式是,在嘗試包含外掛檔案之前,將重定向設定為錯誤。如果該外掛失敗了,那麼重定向將不會 被成功資訊覆蓋,並且該外掛不會被恢復。”

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >