[wp-trac] [WordPress Trac] #34358: plugin_dir_url( __FILE__ ) returns plugins directory when plugin symlinked to mu-plugins

WordPress Trac noreply at wordpress.org
Fri Apr 22 15:45:52 UTC 2016


#34358: plugin_dir_url( __FILE__ ) returns plugins directory when plugin symlinked
to mu-plugins
-------------------------------------------------+-------------------------
 Reporter:  scamartist26                         |       Owner:
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Plugins                              |  Review
 Severity:  normal                               |     Version:  4.3.1
 Keywords:  has-patch needs-unit-tests needs-    |  Resolution:
  refresh                                        |     Focuses:
-------------------------------------------------+-------------------------

Comment (by mattmckenny):

 Thanks for the suggestion @rmccue

 We are in fact using a loader file in the mu-plugins directory to load
 plugin files which reside in subdirectories of mu-plugins. I just tried
 your recommendation to properly load a symlinked plugin by registering
 through `wp_register_plugin_path()` first. My loader file has a few lines
 thas look something like this:
 {{{#!php

 $symlinked_plugin = dirname(__FILE__) . '/symlinked-plugin/symlinked-
 plugin.php';

 wp_register_plugin_realpath( $symlinked_plugin );

 include_once( $symlinked_plugin );

 }}}



 and then printing out the `$wp_plugin_paths` global gives me this:


 {{{
 Array
 (
     [/Users/matt/Sites/example-site/wp-content/mu-plugins/symlinked-
 plugin] => /Users/matt/Sites/_plugins/symlinked-plugin
 )

 }}}

 The plugin works for the most part, with the exception of our "assets".
 The symlinked plugin is enqueueing a CSS file, let's call is
 symlinked.css. When I view the source of the rendered page, I see that the
 file has been loaded but it's loading it through the 'plugins' directory,
 not the 'mu-plugins' directory. The loaded CSS file looks like this:

 {{{

 <link rel='stylesheet' id='symlinked-css'  href='https://www.example.com
 /wp-content/plugins/symlinked-plugin/symlinked.css?ver=4.4.2'
 type='text/css' media='all' />

 }}}

 As you can imagine, this doesn't work since the CSS is actually in the
 'mu-plugins' subdirectory.

 Again, thank you for your help. Please let me know if I've missing
 something in my setup and approach.

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


More information about the wp-trac mailing list