[wp-trac] [WordPress Trac] #61755: Use WPINC constant in script-loader.php

WordPress Trac noreply at wordpress.org
Thu Aug 14 06:11:18 UTC 2025


#61755: Use WPINC constant in script-loader.php
---------------------------+------------------------------
 Reporter:  kkmuffme       |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Script Loader  |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  close          |     Focuses:
---------------------------+------------------------------
Changes (by jonsurrell):

 * keywords:   => close


Comment:

 It does seem that `WPINC` is always defined to be `wp-includes`. It seems
 like the convention is to use `WPINC` for file paths but not URLs. That
 leads to patterns like this:

 {{{#!php
 <?php
 foreach ( $development_scripts as $script_name ) {
         $assets = include ABSPATH . WPINC . '/assets/script-loader-' .
 $script_name . '.php';
         if ( ! is_array( $assets ) ) {
                 return;
         }
         $scripts->add(
                 'wp-' . $script_name,
                 '/wp-includes/js/dist/development/' . $script_name .
 '.js',
                 $assets['dependencies'],
                 $assets['version']
         );
 }
 }}}

 I think you're suggesting it should be used for URLs as well:

 {{{
 '/wp-includes/js/dist/development/' . $script_name . '.js'
 }}}

 becomes

 {{{
 '/' . WPINC . '/js/dist/development/' . $script_name . '.js'
 }}}

 Is that what you recommend? Would that provide any benefits other than
 consistency?

 I see that the usage does have some consistency, where the full path is
 written our for asset URLs. The form that uses concatenation with `WPINC`
 seems to trade the risk of typing `/wp-includes` correctly for the risk of
 concatenating `WPINC` incorrectly. There's also the inherent risk that a
 change has vs. the existing implementation that has seen real world usage.

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


More information about the wp-trac mailing list