[wp-hackers] Access files inside a plugin directory?

John Blackbourn johnbillion+wp at gmail.com
Tue Mar 23 16:15:28 UTC 2010


Just thinking out loud here. If you use hardlinks instead of symlinks,
__FILE__ should still work, no?

On Tue, Mar 23, 2010 at 3:47 PM, Dougal Campbell <dougal at gunters.org> wrote:
> On Mar 23 2010 10:18 AM, Jeremy Clarke wrote:
>>
>> On Mon, Mar 22, 2010 at 7:38 PM, scribu<scribu at gmail.com>  wrote:
>>
>>>
>>> URL: plugins_url('file_name', __FILE__);
>>>
>>> PATH: dirname(__FILE__) . '/file_name';
>>>
>>
>> Is using __FILE__ an accepted practice in WP-land? I have many
>> installs where I use symlinks ( ln -s ) to share plugin/theme
>> directories between multiple installations, and any use of __file__
>> completely screws up file includes in that setup. Most plugins manage
>> to avoid it but the ones that use it need to be modified by hand.
>>
>> Isn't it presumptive or something? Seems dangerous to have as a best
>> practice.
>>
>
> Well, it presumes that you won't be doing something way-out-of-the-norm,
> like symlinking stuff between multiple installs ;)
>
> That said, yeah, using __FILE__ is definitely a pretty common practice. I
> suppose we really should all be using something more like:
>
>  // Get just the parent directory name of the current file. Path is stripped
> away.
>  $my_plugin_dir_slug = '/' . basename( dirname( __FILE__ ) );
>  $my_plugin_dir = WP_PLUGIN_DIR . $my_plugin_dir_slug;
>  $my_plugin_url = WP_PLUGIN_URL . $my_plugin_dir_slug;
>
> --
> Dougal Campbell <dougal at gunters.org>
> http://dougal.gunters.org/
> http://twitter.com/dougal
> http://twitual.com/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list