is_wp_error

函式
is_wp_error ( $thing )
引數
  • (mixed) $thing The variable to check.
    Required:
返回值
  • (bool) Whether the variable is an instance of WP_Error.
定義位置
相關方法
is_erroris_server_erroris_client_error_wp_cronwp_generator
引入
2.1.0
棄用
-

is_wp_error: 這是WordPress的一個函式,用來檢查一個變數是否是WP_Error物件。WP_Error物件在WordPress中用來表示錯誤和錯誤資訊: 這個函式可以用來檢查一個變數是否是WP_Error的一個例項。

檢查給定的變數是否是WordPress錯誤。

返回`$thing`是否是`WP_Error`類的一個例項。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function is_wp_error( $thing ) {
$is_wp_error = ( $thing instanceof WP_Error );
if ( $is_wp_error ) {
/**
* Fires when `is_wp_error()` is called and its parameter is an instance of `WP_Error`.
*
* @since 5.6.0
*
* @param WP_Error $thing The error object passed to `is_wp_error()`.
*/
do_action( 'is_wp_error_instance', $thing );
}
return $is_wp_error;
}
function is_wp_error( $thing ) { $is_wp_error = ( $thing instanceof WP_Error ); if ( $is_wp_error ) { /** * Fires when `is_wp_error()` is called and its parameter is an instance of `WP_Error`. * * @since 5.6.0 * * @param WP_Error $thing The error object passed to `is_wp_error()`. */ do_action( 'is_wp_error_instance', $thing ); } return $is_wp_error; }
function is_wp_error( $thing ) {
	$is_wp_error = ( $thing instanceof WP_Error );

	if ( $is_wp_error ) {
		/**
		 * Fires when `is_wp_error()` is called and its parameter is an instance of `WP_Error`.
		 *
		 * @since 5.6.0
		 *
		 * @param WP_Error $thing The error object passed to `is_wp_error()`.
		 */
		do_action( 'is_wp_error_instance', $thing );
	}

	return $is_wp_error;
}

常見問題

FAQs
檢視更多 >