[wp-trac] [WordPress Trac] #37357: PHPDoc for wp_register_plugin_realpath is wrong
WordPress Trac
noreply at wordpress.org
Wed Jul 13 18:57:18 UTC 2016
#37357: PHPDoc for wp_register_plugin_realpath is wrong
--------------------------+-----------------------------
Reporter: Zuige | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: 3.9
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
{{{
/**
* Register a plugin's real path.
*
* This is used in plugin_basename() to resolve symlinked paths.
*
* @since 3.9.0
*
* @see plugin_basename()
*
* @global array $wp_plugin_paths
*
* @staticvar string $wp_plugin_path
* @staticvar string $wpmu_plugin_path
*
* @param string $file Known path to the file.
* @return bool Whether the path was able to be registered.
*/
}}}
But `plugin_basename()` doesn't use the method at all
{{{
function plugin_basename( $file ) {
global $wp_plugin_paths;
// $wp_plugin_paths contains normalized paths.
$file = wp_normalize_path( $file );
arsort( $wp_plugin_paths );
foreach ( $wp_plugin_paths as $dir => $realdir ) {
if ( strpos( $file, $realdir ) === 0 ) {
$file = $dir . substr( $file, strlen( $realdir ) );
}
}
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
$mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
$file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' .
preg_quote($mu_plugin_dir, '#') . '/#','',$file); /
$file = trim($file, '/');
return $file;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37357>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list