Commit 56c434cd authored by Sergey Biryukov's avatar Sergey Biryukov
Browse files

Administration: Don't print the `.php-error` class in the admin header for PHP...

Administration: Don't print the `.php-error` class in the admin header for PHP notices in `wp-config.php`.

Any notices in that file happen before `WP_DEBUG` takes effect, and should not be displayed with the `error_reporting` level previously set in `wp-load.php`.

Adding the class when there is no notice displayed results in extra padding under the admin bar, which should be avoided.

Follow-up to [20102], [21025], [26620], [47745].

Props akissz, tw2113, laxman-prajapati, sabernhardt, johnbillion, SergeyBiryukov.
Merges [48850] to the 5.5 branch.
Fixes #51073.
Built from https://develop.svn.wordpress.org/branches/5.5@48851


git-svn-id: https://core.svn.wordpress.org/branches/5.5@48613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
parent 558d9b80
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -198,11 +198,19 @@ if ( $current_screen->is_block_editor() ) {
	}
}

$error = error_get_last();

// Print a CSS class to make PHP errors visible.
if ( error_get_last() && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' ) ) {
if ( $error && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' )
	// Don't print the class for PHP notices in wp-config.php, as they happen before WP_DEBUG takes effect,
	// and should not be displayed with the `error_reporting` level previously set in wp-load.php.
	&& ( E_NOTICE !== $error['type'] || 'wp-config.php' !== wp_basename( $error['file'] ) )
) {
	$admin_body_class .= ' php-error';
}

unset( $error );

?>
</head>
<?php
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
 *
 * @global string $wp_version
 */
$wp_version = '5.5.1-alpha-48849';
$wp_version = '5.5.1-alpha-48851';

/**
 * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.