Make WordPress Core

Ticket #11750: 11750.patch

File 11750.patch, 6.1 KB (added by hakre, 15 years ago)
  • wp-admin/includes/plugin.php

    ### Eclipse Workspace Patch 1.0
    #P wordpress-trunk
     
    258258 * @param string $plugin Base plugin path from plugins directory.
    259259 * @return bool True, if in the active plugins list. False, not in the list.
    260260 */
    261 function is_plugin_active($plugin) {
    262         return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) );
     261function is_plugin_active( $plugin ) {
     262        return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ) );
    263263}
    264264
    265265/**
     
    286286 * @param string $redirect Optional. URL to redirect to.
    287287 * @return WP_Error|null WP_Error on invalid file or null on success.
    288288 */
    289 function activate_plugin($plugin, $redirect = '') {
    290         $current = get_option('active_plugins');
    291         $plugin = plugin_basename(trim($plugin));
     289function activate_plugin( $plugin, $redirect = '' ) {
     290        $current = get_option( 'active_plugins', array() );
     291        $plugin  = plugin_basename( trim( $plugin ) );
    292292
    293293        $valid = validate_plugin($plugin);
    294294        if ( is_wp_error($valid) )
     
    322322 * @param string|array $plugins Single plugin or list of plugins to deactivate.
    323323 * @param bool $silent Optional, default is false. Prevent calling deactivate hook.
    324324 */
    325 function deactivate_plugins($plugins, $silent= false) {
    326         $current = get_option('active_plugins');
     325function deactivate_plugins( $plugins, $silent = false ) {
     326        $current = get_option( 'active_plugins', array() );
    327327
    328         if ( !is_array($plugins) )
    329                 $plugins = array($plugins);
    330 
    331         foreach ( $plugins as $plugin ) {
     328        foreach ( (array) $plugins as $plugin ) {
    332329                $plugin = plugin_basename($plugin);
    333330                if( ! is_plugin_active($plugin) )
    334331                        continue;
     
    475472        return true;
    476473}
    477474
     475/**
     476 * validate active plugins
     477 *
     478 * validate all active plugins, deactivates invalid and
     479 * returns an array of deactived ones.
     480 *
     481 * @since unknown
     482 * @return array invalid plugins, plugin as key, error as value
     483 */
    478484function validate_active_plugins() {
    479         $check_plugins = apply_filters( 'active_plugins', get_option('active_plugins') );
     485        $plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) );
    480486
    481         // Sanity check.  If the active plugin list is not an array, make it an
    482         // empty array.
    483         if ( !is_array($check_plugins) ) {
     487        // validate vartype: array
     488        if ( !is_array( $plugins ) ) {
    484489                update_option('active_plugins', array());
    485490                return;
    486491        }
    487492
    488         //Invalid is any plugin that is deactivated due to error.
    489493        $invalid = array();
    490494
    491         // If a plugin file does not exist, remove it from the list of active
    492         // plugins.
    493         foreach ( $check_plugins as $check_plugin ) {
    494                 $result = validate_plugin($check_plugin);
     495        // invalid plugins get deactivated
     496        foreach ( $plugins as $plugin ) {
     497                $result = validate_plugin( $plugin );
    495498                if ( is_wp_error( $result ) ) {
    496                         $invalid[$check_plugin] = $result;
    497                         deactivate_plugins( $check_plugin, true);
     499                        $invalid[$plugin] = $result;
     500                        deactivate_plugins( $plugin, true );
    498501                }
    499502        }
    500503        return $invalid;
  • wp-settings.php

     
    581581                require(ABSPATH . 'my-hacks.php');
    582582}
    583583
    584 $current_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
     584$current_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) );
    585585if ( is_array($current_plugins) && !defined('WP_INSTALLING') ) {
    586586        foreach ( $current_plugins as $plugin ) {
    587587                // check the $plugin filename
  • wp-admin/plugin-editor.php

     
    208208                <div id="documentation"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&amp;locale=<?php echo urlencode( get_locale() ) ?>&amp;version=<?php echo urlencode( $wp_version ) ?>&amp;redirect=true'); }" /></div>
    209209                <?php endif; ?>
    210210<?php if ( is_writeable($real_file) ) : ?>
    211         <?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?>
     211        <?php if ( in_array( $file, (array) get_option( 'active_plugins', array() ) ) ) { ?>
    212212                <p><?php _e('<strong>Warning:</strong> Making changes to active plugins is not recommended.  If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?></p>
    213213        <?php } ?>
    214214        <p class="submit">
  • wp-includes/update.php

     
    112112                require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    113113
    114114        $plugins = get_plugins();
    115         $active  = get_option( 'active_plugins' );
     115        $active  = get_option( 'active_plugins', array() );
    116116        $current = get_transient( 'update_plugins' );
    117117        if ( ! is_object($current) )
    118118                $current = new stdClass;
     
    147147        $current->last_checked = time();
    148148        set_transient( 'update_plugins', $current );
    149149
    150         $to_send = (object)compact('plugins', 'active');
     150        $to_send = (object) compact('plugins', 'active');
    151151
    152152        $options = array(
    153153                'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
  • wp-includes/ms-functions.php

     
    22322232        return false;
    22332233}
    22342234
    2235 function fix_active_plugins( $value ) {
    2236         if( false == is_array( $value ) )
    2237                 $value = array();
    2238         return $value;
    2239 }
    2240 add_filter( "option_active_plugins", "fix_active_plugins" );
    2241 
    22422235if ( !function_exists('rss_gc') ) :
    22432236function rss_gc() {
    22442237        global $wpdb;