Opened 4 years ago
Closed 4 years ago
#53304 closed defect (bug) (duplicate)
Missing constant causes admin page not to load styles
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | critical | Version: | |
Component: | Themes | Keywords: | |
Focuses: | administration | Cc: |
Description
BUG
In the last alpha versions for the past week including 5.8-alpha-51047
...\wp-includes\theme.php is triggering this error reported by PHP 8.0.6
PHP Fatal error: Uncaught Error: Undefined constant "WP_CONTENT_DIR" in \wp-includes\theme.php:593
Consequently, none of the css files are loaded in the admin page
My solution
Problem is solved by defining the missing constant before line 593 ($theme_root = WP_CONTENT_DIR . $theme_root)
<?php function get_theme_root( $stylesheet_or_template = '' ) { global $wp_theme_directories; // Added by Horacio. Solves error of missing constant when upgrading to WP 5.8 PHP Fatal error: Uncaught Error: Undefined constant "WP_CONTENT_DIR" in \wp-includes\theme.php:599 if ( ! defined( 'WP_CONTENT_DIR' ) ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); $theme_root = ''; if ( $stylesheet_or_template ) { $theme_root = get_raw_theme_root( $stylesheet_or_template ); if ( $theme_root ) { // Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory. // This gives relative theme roots the benefit of the doubt when things go haywire. if ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) ) { $theme_root = WP_CONTENT_DIR . $theme_root; } } } if ( ! $theme_root ) { $theme_root = WP_CONTENT_DIR . '/themes'; }
Alternative solution is to install WordPress 5.7.2 or any 5.8 alpha version but the ones from last week.
Change History (1)
Note: See
TracTickets for help on using
tickets.
Hi there, welcome to WordPress Trac!
Thanks for the report, we're already tracking this issue in #53175, starting with comment:34:ticket:53175.