Make WordPress Core

Ticket #34358: urls_for_symlinked_mu_plugins.34358.diff

File urls_for_symlinked_mu_plugins.34358.diff, 2.2 KB (added by mattmckenny, 8 years ago)

Proposed fix for 34358

  • src/wp-includes/link-template.php

    diff --git src/wp-includes/link-template.php src/wp-includes/link-template.php
    index dfd80f4..31373dc 100644
    function content_url($path = '') { 
    31583158*/
    31593159function plugins_url( $path = '', $plugin = '' ) {
    31603160
     3161        $plugin = wp_get_plugin_realpath( $plugin );
     3162
    31613163        $path = wp_normalize_path( $path );
    31623164        $plugin = wp_normalize_path( $plugin );
    31633165        $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
  • src/wp-includes/plugin.php

    diff --git src/wp-includes/plugin.php src/wp-includes/plugin.php
    index 1ec2497..815d582 100644
    function remove_all_actions($tag, $priority = false) { 
    667667 *
    668668 * @since 1.5.0
    669669 *
    670  * @global array $wp_plugin_paths
    671  *
    672670 * @param string $file The filename of plugin.
    673671 * @return string The name of a plugin.
    674672 */
    675673function plugin_basename( $file ) {
    676         global $wp_plugin_paths;
    677 
    678         foreach ( $wp_plugin_paths as $dir => $realdir ) {
    679                 if ( strpos( $file, $realdir ) === 0 ) {
    680                         $file = $dir . substr( $file, strlen( $realdir ) );
    681                 }
    682         }
    683674
     675        $file = wp_get_plugin_realpath( $file );
    684676        $file = wp_normalize_path( $file );
    685677        $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
    686678        $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
    function plugin_basename( $file ) { 
    690682        return $file;
    691683}
    692684
     685
    693686/**
    694687 * Register a plugin's real path.
    695688 *
    function wp_register_plugin_realpath( $file ) { 
    732725}
    733726
    734727/**
     728 *  Get the path of a symlinked plugin.
     729 *
     730 * This is used to return the target of a symlinked plugin that has been registered using wp_register_plugin_realpath.
     731 *
     732 * @since 4.3.1
     733 *
     734 * @see plugin_basename()
     735 *
     736 * @global array $wp_plugin_paths
     737 *
     738 * @param string $file Known path to the file, typically passed in as __FILE__
     739 * @return string Returns the target filesystem path of a symlinked file
     740 */
     741function wp_get_plugin_realpath( $file ) {
     742
     743        global $wp_plugin_paths;
     744
     745        foreach ( $wp_plugin_paths as $dir => $realdir ) {
     746                if ( 0 === strpos( $file, $realdir ) ) {
     747                        $file = $dir . substr( $file, strlen( $realdir ) );
     748                }
     749        }
     750
     751        return $file;
     752
     753}
     754
     755/**
    735756 * Get the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in.
    736757 *
    737758 * @since 2.8.0