[wp-trac] [WordPress Trac] #53304: Missing constant causes admin page not to load styles

WordPress Trac noreply at wordpress.org
Mon May 31 02:42:46 UTC 2021


#53304: Missing constant causes admin page not to load styles
----------------------------+-----------------------------
 Reporter:  HFigarella      |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:
 Severity:  critical        |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 **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
 <?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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53304>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list