Make WordPress Core

Ticket #16953: 16953.8.diff

File 16953.8.diff, 8.2 KB (added by MikeSchinkel, 11 years ago)

Added wp_register_plugin_realpath() in uninstall_plugin() to 16953.7.diff

  • trunk/wp-includes/plugin.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    583583 * @uses WP_PLUGIN_DIR
    584584 */
    585585function 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
    592599        $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
    593600        $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 );
     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 */
     620function 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        }
    595629}
    596630
    597631/**
  • trunk/wp-includes/functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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,
  • trunk/wp-admin/includes/plugin.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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                        /**
    544545                         * Fires before a plugin is activated in activate_plugin() when the $silent parameter is false.
    545                          * 
     546                         *
    546547                         * @since 2.9.0
    547548                         *
    548549                         * @param string $plugin       Plugin path to main plugin file with plugin data.
     
    553554
    554555                        /**
    555556                         * Fires before a plugin is activated in activate_plugin() when the $silent parameter is false.
    556                          * 
     557                         *
    557558                         * The action concatenates the 'activate_' prefix with the $plugin value passed to
    558559                         * activate_plugin() to create a dynamically-named action.
    559                          * 
     560                         *
    560561                         * @since 2.0.0
    561562                         *
    562563                         * @param bool $network_wide Whether to enable the plugin for all sites in the network
     
    577578                if ( ! $silent ) {
    578579                        /**
    579580                         * Fires after a plugin has been activated in activate_plugin() when the $silent parameter is false.
    580                          * 
     581                         *
    581582                         * @since 2.9.0
    582583                         *
    583584                         * @param string $plugin       Plugin path to main plugin file with plugin data.
     
    627628                        /**
    628629                         * Fires for each plugin being deactivated in deactivate_plugins(), before deactivation
    629630                         * and when the $silent parameter is false.
    630                          * 
     631                         *
    631632                         * @since 2.9.0
    632633                         *
    633634                         * @param string $plugin               Plugin path to main plugin file with plugin data.
    634                          * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network 
     635                         * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
    635636                         *                                     or just the current site. Multisite only. Default is false.
    636637                         */
    637638                        do_action( 'deactivate_plugin', $plugin, $network_deactivating );
     
    657658                        /**
    658659                         * Fires for each plugin being deactivated in deactivate_plugins(), after deactivation
    659660                         * and when the $silent parameter is false.
    660                          * 
     661                         *
    661662                         * The action concatenates the 'deactivate_' prefix with the plugin's basename
    662663                         * to create a dynamically-named action.
    663                          * 
     664                         *
    664665                         * @since 2.0.0
    665666                         *
    666                          * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network 
     667                         * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
    667668                         *                                   or just the current site. Multisite only. Default is false.
    668669                         */
    669670                        do_action( 'deactivate_' . $plugin, $network_deactivating );
     
    671672                        /**
    672673                         * Fires for each plugin being deactivated in deactivate_plugins(), after deactivation
    673674                         * and when the $silent parameter is false.
    674                          * 
     675                         *
    675676                         * @since 2.9.0
    676677                         *
    677678                         * @param string $plugin               Plugin path to main plugin file with plugin data.
    678                          * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network 
     679                         * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
    679680                         *                                     or just the current site. Multisite only. Default is false.
    680681                         */
    681682                        do_action( 'deactivated_plugin', $plugin, $network_deactivating );
     
    914915                unset($uninstallable_plugins);
    915916
    916917                define('WP_UNINSTALL_PLUGIN', $file);
     918                wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . dirname( $file ) );
    917919                include WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php';
    918920
    919921                return true;
     
    925927                update_option('uninstall_plugins', $uninstallable_plugins);
    926928                unset($uninstallable_plugins);
    927929
     930                wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
    928931                include WP_PLUGIN_DIR . '/' . $file;
    929932
    930933                add_action( 'uninstall_' . $file, $callable );
    931934
    932935                /**
    933936                 * Fires in uninstall_plugin() once the plugin has been uninstalled.
    934                  * 
     937                 *
    935938                 * The action concatenates the 'uninstall_' prefix with the basename of the
    936939                 * plugin passed to {@see uninstall_plugin()} to create a dynamically-named action.
    937940                 *
  • trunk/wp-settings.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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.