Make WordPress Core

Opened 8 years ago

Last modified 5 years ago

#39414 new enhancement

New param in plugin_dir_path

Reported by: sebastianpisula's profile sebastian.pisula Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Plugins Keywords:
Focuses: Cc:

Description

New param - path. Function with this param return full path to file. Examples:

<?php
var_dump(plugin_dir_path(__FILE__));
var_dump(plugin_dir_path(__FILE__, 'assets/test.png'));
string(26) "\wp-content\plugins\myplugin/"
string(41) "\wp-content\plugins\myplugin/assets/test.png"

Attachments (1)

39414.patch (989 bytes) - added by sebastian.pisula 8 years ago.

Download all attachments as: .zip

Change History (3)

#1 @swissspidy
8 years ago

What is the advantage of plugin_dir_path( __FILE__ , 'assets/test.png' ) over simply using plugin_dir_path( __FILE__ ) . 'assets/test.png' )? I don't really see a benefit of using a second param for that when you can simply concatenate the strings on your own. Developers would probably not use it because of back compat. Also, plugin_dir_path() says it returns the path to a directory, not a file.

#2 @ocean90
8 years ago

Related: [38578] for themes

Note: See TracTickets for help on using tickets.