[wp-trac] [WordPress Trac] #38800: add WP_ADMIN_URL and WP_INCLUDES_URL constants

WordPress Trac noreply at wordpress.org
Tue Nov 15 17:20:26 UTC 2016


#38800: add WP_ADMIN_URL and WP_INCLUDES_URL constants
---------------------------+-----------------------------
 Reporter:  petersplugins  |      Owner:
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Script Loader  |    Version:
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 If WP is installed in a sub directory we can use a subdomain pointing to
 wp-content directory and set the {{{WP_CONTENT_URL}}} in wp-config.php to
 hide the path WP is installed in.

 But the HTML code still yields information about the path because the WP
 default scripts and styles are loaded from wp-includes resp. wp-admin
 directory. Of course those URLs can be changed using the
 {{{script_loader_src}}} filter.

 But to obviate the need for using this filter and to remove this lack of
 consistency it should be possible to define {{{WP_ADMIN_URL}}} and
 {{{WP_INCLUDES_URL}}} in wp-config.php

 '''Sample Code'''

 For testing I've added two functions

 {{{#!php
 function wp_get_admin_url() {
   if ( defined( 'WP_ADMIN_URL' ) ) {
     return trailingslashit( WP_ADMIN_URL );
   }
   return '/wp-admin/';
 }

 function wp_get_includes_url() {
   if ( defined( 'WP_INCLUDES_URL' ) ) {
     return trailingslashit( WP_INCLUDES_URL );
   }
   return '/wp-includes/';
 }
 }}}

 Also I've made changes to wp-includes/script-loader.php. I've added the
 following lines to functions {{{wp_default_scripts()}}} and
 {{{wp_default_styles()}}}

 {{{#!php
 $admin_src = wp_get_admin_url();
 $includes_src = wp_get_includes_url();
 }}}

 Then I've changed every occurrence of {{{$scripts->add()}}} and
 {{{$styles->add()}}} to use those variables instead of the fixed path.

 This works as expected to hide the directory WP is installed in from the
 WP default scripts and styles.

 I'm pretty sure there's a lot more to change but I wanted to bring this up
 for discussion first and I'm eagerly waiting for feedback.

 Notes: I'm a newbie here so please excuse if I did't follow the usual
 procedure and let me know how to do better. And second please be bear with
 me that I'm not a native english speaker.

 Peter

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


More information about the wp-trac mailing list