Ticket #16953: 16953.9.diff
File 16953.9.diff, 5.2 KB (added by , 11 years ago) |
---|
-
src/wp-admin/includes/plugin.php
537 537 if ( !empty($redirect) ) 538 538 wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error 539 539 ob_start(); 540 include_once(WP_PLUGIN_DIR . '/' . $plugin); 540 wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); 541 include_once( WP_PLUGIN_DIR . '/' . $plugin ); 541 542 542 543 if ( ! $silent ) { 543 544 /** … … 921 922 unset($uninstallable_plugins); 922 923 923 924 define('WP_UNINSTALL_PLUGIN', $file); 925 wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . dirname( $file ) ); 924 926 include WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php'; 925 927 926 928 return true; … … 932 934 update_option('uninstall_plugins', $uninstallable_plugins); 933 935 unset($uninstallable_plugins); 934 936 937 wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); 935 938 include WP_PLUGIN_DIR . '/' . $file; 936 939 937 940 add_action( 'uninstall_' . $file, $callable ); -
src/wp-includes/functions.php
1434 1434 } 1435 1435 1436 1436 /** 1437 * Normalize a filesystem path. 1438 * 1439 * Replaces backslashes with forward slashes for Windows systems, 1440 * and ensures no duplicate slashes exist. 1441 * 1442 * @param string $path Path to normalize. 1443 * @return string Normalized path. 1444 */ 1445 function wp_normalize_path( $path ) { 1446 $path = str_replace( '\\', '/', $path ); 1447 $path = preg_replace( '|/+|','/', $path ); 1448 return $path; 1449 } 1450 1451 /** 1437 1452 * Determines a writable directory for temporary files. 1438 1453 * Function's preference is the return value of <code>sys_get_temp_dir()</code>, 1439 1454 * followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR, -
src/wp-includes/plugin.php
583 583 * @uses WP_PLUGIN_DIR 584 584 */ 585 585 function plugin_basename($file) { 586 $file = str_replace('\\','/',$file); // sanitize for Win32 installs 587 $file = preg_replace('|/+|','/', $file); // remove any duplicate slash 588 $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs 589 $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash 590 $mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs 591 $mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash 586 global $wp_plugin_paths; 587 $original_file = $file; 588 589 foreach ($wp_plugin_paths as $dir => $realdir) { 590 if (strpos($file, $realdir) === 0) { 591 $file = $dir . substr( $file, strlen( $realdir ) ); 592 } 593 } 594 595 $file = wp_normalize_path($file); 596 $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); 597 $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); 598 592 599 $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir 593 600 $file = trim($file, '/'); 594 return $file; 601 602 /** 603 * Filter the plugin's basename. 604 * 605 * @since 3.7.0 606 * 607 * @param string $file Resolved basename. 608 * @param string $original_file Filename passed into the function. 609 */ 610 return apply_filters( 'plugin_basename', $file, $original_file ); 595 611 } 596 612 597 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 } 629 } 630 631 /** 598 632 * Gets the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in 599 633 * @package WordPress 600 634 * @subpackage Plugin -
src/wp-settings.php
164 164 // Define must-use plugin directory constants, which may be overridden in the sunrise.php drop-in. 165 165 wp_plugin_directory_constants(); 166 166 167 $GLOBALS['wp_plugin_paths'] = array(); 168 167 169 // Load must-use plugins. 168 170 foreach ( wp_get_mu_plugins() as $mu_plugin ) { 169 171 include_once( $mu_plugin ); … … 173 175 // Load network activated plugins. 174 176 if ( is_multisite() ) { 175 177 foreach( wp_get_active_network_plugins() as $network_plugin ) { 178 wp_register_plugin_realpath( $network_plugin ); 179 176 180 include_once( $network_plugin ); 177 181 } 178 182 unset( $network_plugin ); … … 206 210 register_theme_directory( get_theme_root() ); 207 211 208 212 // Load active plugins. 209 foreach ( wp_get_active_and_valid_plugins() as $plugin ) 213 foreach ( wp_get_active_and_valid_plugins() as $plugin ) { 214 wp_register_plugin_realpath( $plugin ); 215 210 216 include_once( $plugin ); 217 } 211 218 unset( $plugin ); 212 219 213 220 // Load pluggable functions.