diff --git a/src/wp-admin/admin-header.php b/src/wp-admin/admin-header.php
index 3306c9125b..ab648dec49 100644
--- a/src/wp-admin/admin-header.php
+++ b/src/wp-admin/admin-header.php
@@ -212,12 +212,25 @@ if ( $current_screen->is_block_editor() ) {
 $error_get_last = 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' )
-	// 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_get_last['type'] || 'wp-config.php' !== wp_basename( $error_get_last['file'] ) )
-) {
-	$admin_body_class .= ' php-error';
+if ( $error_get_last && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' ) ) {
+	/**
+	 * Filters whether to preempt printing the CSS class to make PHP errors visible.
+	 *
+	 * Returning false will NOT print the CSS class.
+	 *
+	 * @param bool  $print Whether to print the CSS class. Default true.
+	 * @param array $error {
+	 *     Error information returned by `error_get_last()`.
+	 *
+	 *     @type int    $type    The error type.
+	 *     @type string $file    The name of the file in which the error occurred.
+	 *     @type int    $line    The line number in which the error occurred.
+	 *     @type string $message The error message.
+	 * }
+	 */
+	if ( apply_filters( 'pre_admin_php_error_class', true, $error_get_last ) ) {
+		$admin_body_class .= ' php-error';
+	}
 }
 
 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/src/wp-admin/includes/admin-filters.php
+++ b/src/wp-admin/includes/admin-filters.php
@@ -51,6 +51,7 @@ add_action( 'admin_head', 'wp_site_icon' );
 add_action( 'admin_head', 'wp_admin_viewport_meta' );
 add_action( 'customize_controls_head', 'wp_admin_viewport_meta' );
 add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' );
+add_filter( 'pre_admin_php_error_class', '_pre_admin_php_error_class', 1, 2 );
 
 // Prerendering.
 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/src/wp-admin/includes/misc.php
+++ b/src/wp-admin/includes/misc.php
@@ -1626,3 +1626,27 @@ function wp_check_php_version() {
 
 	return $response;
 }
+
+/**
+ * Checks if the PHP error should be visible.
+ *
+ * Does not print the CSS 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.
+ *
+ * @access private
+ *
+ * @param bool  $print Whether to print the CSS class.
+ * @param array $error {
+ *     Error information returned by `error_get_last()`.
+ *
+ *     @type int    $type    The error type.
+ *     @type string $file    The name of the file in which the error occurred.
+ *     @type int    $line    The line number in which the error occurred.
+ *     @type string $message The error message.
+ * }
+ * @return bool Array of PHP version data. False on failure.
+ */
+function _pre_admin_php_error_class( $print, $error ) {
+	return ( E_NOTICE !== $error['type'] || 'wp-config.php' !== wp_basename( $error['file'] ) );
+}
