Make WordPress Core

Ticket #22802: wp-load-plugin.patch

File wp-load-plugin.patch, 3.7 KB (added by MikeSchinkel, 12 years ago)

Adding wp_load_plugin() function and appropriate calls.

  • public_html/wp-admin/plugins.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    144144                        @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
    145145                        // Go back to "sandbox" scope so we get the same errors as before
    146146                        function plugin_sandbox_scrape( $plugin ) {
    147                                 include( WP_PLUGIN_DIR . '/' . $plugin );
     147                                wp_load_plugin( WP_PLUGIN_DIR . '/' . $plugin );
    148148                        }
    149149                        plugin_sandbox_scrape( $plugin );
    150150                        do_action('activate_' . $plugin);
  • public_html/wp-settings.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    156156
    157157// Load must-use plugins.
    158158foreach ( wp_get_mu_plugins() as $mu_plugin ) {
    159         include_once( $mu_plugin );
     159  wp_load_plugin( $mu_plugin, 'mu-plugin' );
    160160}
    161161unset( $mu_plugin );
    162162
    163163// Load network activated plugins.
    164164if ( is_multisite() ) {
    165165        foreach( wp_get_active_network_plugins() as $network_plugin ) {
    166                 include_once( $network_plugin );
     166    wp_load_plugin( $network_plugin, 'network-plugin' );
    167167        }
    168168        unset( $network_plugin );
    169169}
     
    192192
    193193// Load active plugins.
    194194foreach ( wp_get_active_and_valid_plugins() as $plugin )
    195         include_once( $plugin );
     195  wp_load_plugin( $plugin );
    196196unset( $plugin );
    197197
    198198// Load pluggable functions.
  • public_html/wp-admin/includes/plugin.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    859859                update_option('uninstall_plugins', $uninstallable_plugins);
    860860                unset($uninstallable_plugins);
    861861
    862                 include WP_PLUGIN_DIR . '/' . $file;
     862    wp_load_plugin( WP_PLUGIN_DIR . '/' . $file );
    863863
    864864                add_action( 'uninstall_' . $file, $callable );
    865865                do_action( 'uninstall_' . $file );
  • public_html/wp-includes/load.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    759759
    760760        $wp_locale = new WP_Locale();
    761761}
     762
     763/**
     764 * Load plugin while setting $wp_plugin_file during the loading of the plugin
     765 *
     766 * @global string $wp_plugin_file Full filename for the currently loading plugin.
     767 * @global string $wp_plugin_type One of 'plugin', 'mu-plugin' or 'network-plugin'
     768 * @global string $wp_plugin_slug The 'slug' WordPress will store to identify this plugin
     769 *
     770 * @since 3.6
     771 *
     772 * @param string $plugin_file Full path and filename of plugin's entry point file.
     773 * @param string $plugin_type Type of plugin loaded; plugin, mu-plugin or network-plugin.
     774 */
     775function wp_load_plugin( $plugin_file, $plugin_type = 'plugin' ) {
     776  global $wp_plugin_file, $wp_plugin_type, $wp_plugin_slug;
     777  $wp_plugin_type = $plugin_type;
     778  /*
     779   * @todo: Verify next 2 lines is correct logic for plugin slug for 100% of use-cases.
     780   */
     781  $dir = preg_quote( 'mu-plugin' == $plugin_type ? WPMU_PLUGIN_DIR : WP_PLUGIN_DIR );
     782  $wp_plugin_slug = preg_replace( "#^{$dir}/(.+)$#", '$1', str_replace( '\\', '/', $plugin_file ) );
     783  include_once( $wp_plugin_file = $plugin_file );
     784  unset( $wp_plugin_file, $wp_plugin_type, $wp_plugin_slug );
     785}
     786