wp_is_fatal_error_handler_enabled

函式
wp_is_fatal_error_handler_enabled ( No parameters )
返回值
  • (bool) True if the fatal error handler is enabled, false otherwise.
定義位置
相關方法
wp_register_fatal_error_handlerwp_is_ini_value_changeablewp_revisions_enabledwp_import_handle_uploadwp_embed_handler_audio
引入
5.2.0
棄用
-

wp_is_fatal_error_handler_enabled: 這個函式用來檢查WordPress網站是否啟用了一個自定義的致命錯誤處理程式。致命錯誤處理程式用於處理無法恢復的錯誤,如記憶體錯誤或語法錯誤。

檢查是否啟用了致命錯誤處理程式。

可以在`wp-config.php`中設定常量`WP_DISABLE_FATAL_ERROR_HANDLER`來禁用它,或者可以使用{@see ‘wp_fatal_error_handler_enabled’}過濾器來修改返回值。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_is_fatal_error_handler_enabled() {
$enabled = ! defined( 'WP_DISABLE_FATAL_ERROR_HANDLER' ) || ! WP_DISABLE_FATAL_ERROR_HANDLER;
/**
* Filters whether the fatal error handler is enabled.
*
* **Important:** This filter runs before it can be used by plugins. It cannot
* be used by plugins, mu-plugins, or themes. To use this filter you must define
* a `$wp_filter` global before WordPress loads, usually in `wp-config.php`.
*
* Example:
*
* $GLOBALS['wp_filter'] = array(
* 'wp_fatal_error_handler_enabled' => array(
* 10 => array(
* array(
* 'accepted_args' => 0,
* 'function' => function() {
* return false;
* },
* ),
* ),
* ),
* );
*
* Alternatively you can use the `WP_DISABLE_FATAL_ERROR_HANDLER` constant.
*
* @since 5.2.0
*
* @param bool $enabled True if the fatal error handler is enabled, false otherwise.
*/
return apply_filters( 'wp_fatal_error_handler_enabled', $enabled );
}
function wp_is_fatal_error_handler_enabled() { $enabled = ! defined( 'WP_DISABLE_FATAL_ERROR_HANDLER' ) || ! WP_DISABLE_FATAL_ERROR_HANDLER; /** * Filters whether the fatal error handler is enabled. * * **Important:** This filter runs before it can be used by plugins. It cannot * be used by plugins, mu-plugins, or themes. To use this filter you must define * a `$wp_filter` global before WordPress loads, usually in `wp-config.php`. * * Example: * * $GLOBALS['wp_filter'] = array( * 'wp_fatal_error_handler_enabled' => array( * 10 => array( * array( * 'accepted_args' => 0, * 'function' => function() { * return false; * }, * ), * ), * ), * ); * * Alternatively you can use the `WP_DISABLE_FATAL_ERROR_HANDLER` constant. * * @since 5.2.0 * * @param bool $enabled True if the fatal error handler is enabled, false otherwise. */ return apply_filters( 'wp_fatal_error_handler_enabled', $enabled ); }
function wp_is_fatal_error_handler_enabled() {
	$enabled = ! defined( 'WP_DISABLE_FATAL_ERROR_HANDLER' ) || ! WP_DISABLE_FATAL_ERROR_HANDLER;

	/**
	 * Filters whether the fatal error handler is enabled.
	 *
	 * **Important:** This filter runs before it can be used by plugins. It cannot
	 * be used by plugins, mu-plugins, or themes. To use this filter you must define
	 * a `$wp_filter` global before WordPress loads, usually in `wp-config.php`.
	 *
	 * Example:
	 *
	 *     $GLOBALS['wp_filter'] = array(
	 *         'wp_fatal_error_handler_enabled' => array(
	 *             10 => array(
	 *                 array(
	 *                     'accepted_args' => 0,
	 *                     'function'      => function() {
	 *                         return false;
	 *                     },
	 *                 ),
	 *             ),
	 *         ),
	 *     );
	 *
	 * Alternatively you can use the `WP_DISABLE_FATAL_ERROR_HANDLER` constant.
	 *
	 * @since 5.2.0
	 *
	 * @param bool $enabled True if the fatal error handler is enabled, false otherwise.
	 */
	return apply_filters( 'wp_fatal_error_handler_enabled', $enabled );
}

常見問題

FAQs
檢視更多 >