Make WordPress Core

Ticket #16953: 16953.7.diff

File 16953.7.diff, 4.0 KB (added by rmccue, 10 years ago)

Check on activation as well

  • wp-admin/includes/plugin.php

    diff --git wp-admin/includes/plugin.php wp-admin/includes/plugin.php
    index c931783..6709a1e 100644
    function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen 
    537537                if ( !empty($redirect) )
    538538                        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
    539539                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 );
    541542
    542543                if ( ! $silent ) {
    543544                        /**
  • wp-includes/functions.php

    diff --git wp-includes/functions.php wp-includes/functions.php
    index c4dc1e7..c9f45f3 100644
    function path_join( $base, $path ) { 
    14291429}
    14301430
    14311431/**
     1432 * Normalize a filesystem path.
     1433 *
     1434 * Replaces backslashes with forward slashes for Windows systems,
     1435 * and ensures no duplicate slashes exist.
     1436 *
     1437 * @param string $path Path to normalize.
     1438 * @return string Normalized path.
     1439 */
     1440function wp_normalize_path( $path ) {
     1441        $path = str_replace( '\\', '/', $path );
     1442        $path = preg_replace( '|/+|','/', $path );
     1443        return $path;
     1444}
     1445
     1446/**
    14321447 * Determines a writable directory for temporary files.
    14331448 * Function's preference is the return value of <code>sys_get_temp_dir()</code>,
    14341449 * followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR,
  • wp-includes/plugin.php

    diff --git wp-includes/plugin.php wp-includes/plugin.php
    index 03c4ac3..6b6ae49 100644
    function remove_all_actions($tag, $priority = false) { 
    574574 * @uses WP_PLUGIN_DIR
    575575 */
    576576function plugin_basename($file) {
    577         $file = str_replace('\\','/',$file); // sanitize for Win32 installs
    578         $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
    579         $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
    580         $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
    581         $mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs
    582         $mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
     577        global $wp_plugin_paths;
     578        $original_file = $file;
     579
     580        foreach ($wp_plugin_paths as $dir => $realdir) {
     581                if (strpos($file, $realdir) === 0) {
     582                        $file = $dir . substr( $file, strlen( $realdir ) );
     583                }
     584        }
     585
     586        $file = wp_normalize_path($file);
     587        $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
     588        $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
     589
    583590        $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
    584591        $file = trim($file, '/');
    585         return $file;
     592
     593        /**
     594         * Filter the plugin's basename.
     595         *
     596         * @since 3.7.0
     597         *
     598         * @param string $file Resolved basename.
     599         * @param string $original_file Filename passed into the function.
     600         */
     601        return apply_filters( 'plugin_basename', $file, $original_file );
     602}
     603
     604/**
     605 * Register a plugin's real path.
     606 *
     607 * This is used in {@see plugin_basename()} to resolve symlinked paths.
     608 *
     609 * @param string $file Known path to the file.
     610 */
     611function wp_register_plugin_realpath( $file ) {
     612        global $wp_plugin_paths;
     613
     614        $plugin_path = wp_normalize_path( dirname( $file ) );
     615        $plugin_realpath = wp_normalize_path( dirname( realpath( $file ) ) );
     616
     617        if ( $plugin_path !== $plugin_realpath ) {
     618                $wp_plugin_paths[ $plugin_path ] = $plugin_realpath;
     619        }
    586620}
    587621
    588622/**
  • wp-settings.php

    diff --git wp-settings.php wp-settings.php
    index 24aee93..46e4e74 100644
    create_initial_post_types(); 
    194194register_theme_directory( get_theme_root() );
    195195
    196196// Load active plugins.
    197 foreach ( wp_get_active_and_valid_plugins() as $plugin )
     197$GLOBALS['wp_plugin_paths'] = array();
     198foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
     199        wp_register_plugin_realpath($plugin);
     200
    198201        include_once( $plugin );
     202}
    199203unset( $plugin );
    200204
    201205// Load pluggable functions.