WordPress.org

Make WordPress Core

Ticket #16953: symlinked_plugins.diff

File symlinked_plugins.diff, 2.6 KB (added by MikeSchinkel, 5 years ago)

Patch to enable plugin_url() to support symlinked plugins.

  • public_html/wp-includes/plugin.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    787787                return $function[0].$function[1];
    788788        }
    789789}
     790
     791/**
     792 * Stores array of symlinked plugins upon update of 'active_plugins' into 'symlinked_plugins' option.
     793 *
     794 * The array stored for 'symlinked_plugins' will be in the following form assuming that $plugin_virtual_path contained
     795 * an array of full virtual plugin paths where each is in the form WP_PLUGIN_DIR . "/{plugin_slug}":
     796 *
     797 *    array(
     798 *      realpath( $plugin_virtual_path[1] ) => $plugin_virtual_path[1],
     799 *      realpath( $plugin_virtual_path[2] ) => $plugin_virtual_path[2],
     800 *      realpath( $plugin_virtual_path[3] ) => $plugin_virtual_path[3],
     801 *    );
     802 *
     803 * @package WordPress
     804 * @subpackage Plugin
     805 * @access private
     806 * @since 3.6
     807 * @link http://core.trac.wordpress.org/ticket/16953
     808 *
     809 * @param mixed $newvalue The newly changed array of 'active_plugins' being saved.
     810 * @param mixed $oldvalue The previous saved array of 'active_plugins' from wp_options.
     811 * @return mixed Array of full plugin filepaths where key is realpath( $virtual_path ) and value is $virtual_path.
     812 */
     813function _wp_pre_update_option_active_plugins( $newvalue, $oldvalue ) {
     814  $symlinked_plugins = array();
     815  foreach( $newvalue as $plugin_slug ) {
     816    $real_path = realpath( $virtual_path = WP_PLUGIN_DIR . "/{$plugin_slug}" );
     817    if ( $real_path != $virtual_path )
     818      $symlinked_plugins[$real_path] = $virtual_path;
     819  }
     820  update_option( 'symlinked_plugins', $symlinked_plugins );
     821  return $newvalue;
     822}
     823add_filter( 'pre_update_option_active_plugins', '_wp_pre_update_option_active_plugins', 10, 2 );
  • public_html/wp-includes/link-template.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    20602060*/
    20612061function plugins_url($path = '', $plugin = '') {
    20622062
     2063  $symlinked_plugins = get_option( 'symlinked_plugins' );
     2064  if ( isset( $symlinked_plugins[$plugin] ) ) {
     2065    $plugin = $symlinked_plugins[$plugin];
     2066  }
     2067
    20632068        $mu_plugin_dir = WPMU_PLUGIN_DIR;
    20642069        foreach ( array('path', 'plugin', 'mu_plugin_dir') as $var ) {
    20652070                $$var = str_replace('\\' ,'/', $$var); // sanitize for Win32 installs