diff --git a/src/wp-admin/admin-header.php b/src/wp-admin/admin-header.php
index 3306c9125b..ab648dec49 100644
a
|
b
|
if ( $current_screen->is_block_editor() ) { |
212 | 212 | $error_get_last = error_get_last(); |
213 | 213 | |
214 | 214 | // Print a CSS class to make PHP errors visible. |
215 | | if ( $error_get_last && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' ) |
216 | | // Don't print the class for PHP notices in wp-config.php, as they happen before WP_DEBUG takes effect, |
217 | | // and should not be displayed with the `error_reporting` level previously set in wp-load.php. |
218 | | && ( E_NOTICE !== $error_get_last['type'] || 'wp-config.php' !== wp_basename( $error_get_last['file'] ) ) |
219 | | ) { |
220 | | $admin_body_class .= ' php-error'; |
| 215 | if ( $error_get_last && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' ) ) { |
| 216 | /** |
| 217 | * Filters whether to preempt printing the CSS class to make PHP errors visible. |
| 218 | * |
| 219 | * Returning false will NOT print the CSS class. |
| 220 | * |
| 221 | * @param bool $print Whether to print the CSS class. Default true. |
| 222 | * @param array $error { |
| 223 | * Error information returned by `error_get_last()`. |
| 224 | * |
| 225 | * @type int $type The error type. |
| 226 | * @type string $file The name of the file in which the error occurred. |
| 227 | * @type int $line The line number in which the error occurred. |
| 228 | * @type string $message The error message. |
| 229 | * } |
| 230 | */ |
| 231 | if ( apply_filters( 'pre_admin_php_error_class', true, $error_get_last ) ) { |
| 232 | $admin_body_class .= ' php-error'; |
| 233 | } |
221 | 234 | } |
222 | 235 | |
223 | 236 | unset( $error_get_last ); |
diff --git a/src/wp-admin/includes/admin-filters.php b/src/wp-admin/includes/admin-filters.php
index 33354cb073..30ecd0483f 100644
a
|
b
|
add_action( 'admin_head', 'wp_site_icon' ); |
51 | 51 | add_action( 'admin_head', 'wp_admin_viewport_meta' ); |
52 | 52 | add_action( 'customize_controls_head', 'wp_admin_viewport_meta' ); |
53 | 53 | add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' ); |
| 54 | add_filter( 'pre_admin_php_error_class', '_pre_admin_php_error_class', 1, 2 ); |
54 | 55 | |
55 | 56 | // Prerendering. |
56 | 57 | if ( ! is_customize_preview() ) { |
diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php
index 78c1aab1c8..27e2534baa 100644
a
|
b
|
function wp_check_php_version() { |
1626 | 1626 | |
1627 | 1627 | return $response; |
1628 | 1628 | } |
| 1629 | |
| 1630 | /** |
| 1631 | * Checks if the PHP error should be visible. |
| 1632 | * |
| 1633 | * Does not print the CSS class for PHP notices in wp-config.php, as they happen |
| 1634 | * before WP_DEBUG takes effect, and should not be displayed with the `error_reporting` |
| 1635 | * level previously set in wp-load.php. |
| 1636 | * |
| 1637 | * @access private |
| 1638 | * |
| 1639 | * @param bool $print Whether to print the CSS class. |
| 1640 | * @param array $error { |
| 1641 | * Error information returned by `error_get_last()`. |
| 1642 | * |
| 1643 | * @type int $type The error type. |
| 1644 | * @type string $file The name of the file in which the error occurred. |
| 1645 | * @type int $line The line number in which the error occurred. |
| 1646 | * @type string $message The error message. |
| 1647 | * } |
| 1648 | * @return bool Array of PHP version data. False on failure. |
| 1649 | */ |
| 1650 | function _pre_admin_php_error_class( $print, $error ) { |
| 1651 | return ( E_NOTICE !== $error['type'] || 'wp-config.php' !== wp_basename( $error['file'] ) ); |
| 1652 | } |