[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
Sun Apr 16 14:56:13 UTC 2017


#40467: Hardcoding Template and Stylesheet paths inside the wp-config.php leads to
"constant already defined in default-constants.php"
-----------------------------------+-----------------------------
 Reporter:  rkoller                |      Owner:
     Type:  defect (bug)           |     Status:  new
 Priority:  normal                 |  Milestone:  Awaiting Review
Component:  Themes                 |    Version:  4.7.3
 Severity:  normal                 |   Keywords:
  Focuses:  template, performance  |
-----------------------------------+-----------------------------
 I've tried to hardcode the Template and Stylesheet directory inside the
 wp-config with:

 {{{#!php
 <?php
 define('TEMPLATEPATH', '/app/public/wp-content/themes/twentyseventeen');
 define('STYLESHEETPATH', '/app/public/wp-content/themes/twentyseventeen');
 }}}

 The paths I've got from

 {{{
 get_template_directory()
 }}}

 and

 {{{
 get_stylesheet_directory()
 }}}

 I've tried with WP 4.7.3  on Local from Flywheel with Twentyseventeen as
 theme. But as soon as I save the two defines I get:


 {{{
 Notice: Constant TEMPLATEPATH already defined in /app/public/wp-includes
 /default-constants.php on line 343

 Notice: Constant STYLESHEETPATH already defined in /app/public/wp-includes
 /default-constants.php on line 349
 }}}



 I've also tried with :

 {{{#!php
 <?php
 define( ‘TEMPLATEPATH’, get_template_directory() );
 define( ‘STYLESHEETPATH’, get_stylesheet_directory() );
 }}}


 liked listed in the codex:

 [https://codex.wordpress.org/Editing_wp-config.php]

 But that resulted in


 {{{
 Fatal error: Call to undefined function get_template_directory() in
 /app/public/wp-config.php on line 75
 }}}


 But it could be easily fixed by adding if statements inside the default-
 constants.php function for TEMPLATEPATH and STYLESHEETPATH I suppose

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


More information about the wp-trac mailing list