Changeset 27158 for trunk/src/wp-includes/plugin.php
- Timestamp:
- 02/10/2014 10:59:40 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/plugin.php
r26868 r27158 593 593 * @uses WP_PLUGIN_DIR 594 594 */ 595 function plugin_basename($file) { 596 $file = str_replace('\\','/',$file); // sanitize for Win32 installs 597 $file = preg_replace('|/+|','/', $file); // remove any duplicate slash 598 $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs 599 $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash 600 $mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs 601 $mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash 595 function plugin_basename( $file ) { 596 global $wp_plugin_paths; 597 598 foreach ( $wp_plugin_paths as $dir => $realdir ) { 599 if ( strpos( $file, $realdir ) === 0 ) { 600 $file = $dir . substr( $file, strlen( $realdir ) ); 601 } 602 } 603 604 $file = wp_normalize_path( $file ); 605 $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); 606 $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); 607 602 608 $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir 603 609 $file = trim($file, '/'); 604 610 return $file; 611 } 612 613 /** 614 * Register a plugin's real path. 615 * 616 * This is used in {@see plugin_basename()} to resolve symlinked paths. 617 * 618 * @param string $file Known path to the file. 619 */ 620 function wp_register_plugin_realpath( $file ) { 621 global $wp_plugin_paths; 622 623 $plugin_path = wp_normalize_path( dirname( $file ) ); 624 $plugin_realpath = wp_normalize_path( dirname( realpath( $file ) ) ); 625 626 if ( $plugin_path !== $plugin_realpath ) { 627 $wp_plugin_paths[ $plugin_path ] = $plugin_realpath; 628 } 605 629 } 606 630
Note: See TracChangeset
for help on using the changeset viewer.