[wp-trac] [WordPress Trac] #40467: Hardcoding Template and Stylesheet paths inside the wp-config.php leads to "constant already defined in default-constants.php"

WordPress Trac noreply at wordpress.org
Thu Sep 23 17:40:03 UTC 2021


#40467: Hardcoding Template and Stylesheet paths inside the wp-config.php leads to
"constant already defined in default-constants.php"
-----------------------------------------+---------------------------------
 Reporter:  rkoller                      |       Owner:  (none)
     Type:  defect (bug)                 |      Status:  closed
 Priority:  normal                       |   Milestone:
Component:  Themes                       |     Version:
 Severity:  normal                       |  Resolution:  invalid
 Keywords:  has-patch reporter-feedback  |     Focuses:  template,
                                         |  performance
-----------------------------------------+---------------------------------
Changes (by hellofromTonya):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 Hello @rkoller,

 Welcome back to WordPress Core Trac!

 The notices you're seeing are because these two constants are defined in
 `wp-includes/default-constants.php`. The fatal error is because those
 functions have not yet been loaded into memory.

 The constants are defined and populated during the initialization of
 WordPress.

 WordPress automatically populates those constants using the activated
 theme. See the docs for
 [https://developer.wordpress.org/reference/functions/get_stylesheet_directory/
 `get_stylesheet_directory()`] and
 [https://developer.wordpress.org/reference/functions/get_template_directory/
 `get_template_directory()`].

 Why hardcode the absolute path to the current theme rather than activating
 the theme and letting WordPress automatically detect and set the absolute
 path? Is there a compelling reason?

 As it's been over 4 years with no activity and the errors are doing it
 wrong, closing this ticket.

 @rkoller if there's a compelling reason to hardcode the constants, please
 reopen and share the why and reasoning for further discussion and
 consideration.

 Note: please don't be offended by the
 [https://make.wordpress.org/core/handbook/contribute/trac/ close reason of
 `invalid`], as this keyword means it's not a bug.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/40467#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list