WordPress.org

Make WordPress Core

Changeset 12848


Ignore:
Timestamp:
01/26/2010 06:39:12 PM (10 years ago)
Author:
ryan
Message:

Remove fix_actve_plugins(). Props hakre. fixes #11750

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin.php

    r12825 r12848  
    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
     
    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);
     
    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');
    327 
    328     if ( !is_array($plugins) )
    329         $plugins = array($plugins);
    330 
    331     foreach ( $plugins as $plugin ) {
     325function deactivate_plugins( $plugins, $silent = false ) {
     326    $current = get_option( 'active_plugins', array() );
     327
     328    foreach ( (array) $plugins as $plugin ) {
    332329        $plugin = plugin_basename($plugin);
    333330        if ( ! is_plugin_active($plugin) )
     
    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') );
    480 
    481     // Sanity check.  If the active plugin list is not an array, make it an
    482     // empty array.
    483     if ( !is_array($check_plugins) ) {
     485    $plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) );
     486
     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    }
  • trunk/wp-admin/plugin-editor.php

    r12546 r12848  
    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 } ?>
  • trunk/wp-admin/plugins.php

    r12832 r12848  
    114114            require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
    115115            require_once( 'admin-header.php' );
    116            
     116
    117117            $url = 'plugins.php?action=upgrade-selected&amp;plugins=' . urlencode( join( ',', $plugins ) );
    118118            $title = __( 'Upgrade Plugins' );
     
    284284if ( is_multisite() && is_super_admin() ) {
    285285    $menu_perms = get_site_option('menu_items', array());
    286     if ( !$menu_perms['plugins'] ) {
     286    if ( empty($menu_perms['plugins']) )
    287287        add_action( 'admin_notices', '_admin_notice_multisite_activate_plugins_page' );
    288     }
     288    unset($menu_perms);
    289289}
    290290
  • trunk/wp-includes/load.php

    r12762 r12848  
    405405            $plugins[] = ABSPATH . 'my-hacks.php';
    406406
    407     $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
     407    $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) );
    408408    if ( !is_array( $active_plugins ) || defined( 'WP_INSTALLING' ) )
    409409        return $plugins;
  • trunk/wp-includes/ms-deprecated.php

    r12839 r12848  
    111111}
    112112
     113/**
     114 * @deprecated 3.0
     115 */
     116function clear_global_post_cache( $post_id ) {
     117    _deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache' );
     118}
     119
    113120?>
  • trunk/wp-includes/ms-functions.php

    r12840 r12848  
    726726}
    727727
    728 // deprecated, see clean_post_cache()
    729 function clear_global_post_cache( $post_id ) {
    730     return;
    731 }
    732 
    733728function add_user_to_blog( $blog_id, $user_id, $role ) {
    734729    switch_to_blog($blog_id);
     
    19871982}
    19881983
    1989 function fix_active_plugins( $value ) {
    1990     if ( false == is_array( $value ) )
    1991         $value = array();
    1992     return $value;
    1993 }
    1994 add_filter( "option_active_plugins", "fix_active_plugins" );
    1995 
    19961984if ( !function_exists('rss_gc') ) :
    19971985function rss_gc() {
  • trunk/wp-includes/update.php

    r12673 r12848  
    113113
    114114    $plugins = get_plugins();
    115     $active  = get_option( 'active_plugins' );
     115    $active  = get_option( 'active_plugins', array() );
    116116    $current = get_site_transient( 'update_plugins' );
    117117    if ( ! is_object($current) )
     
    148148    set_site_transient( 'update_plugins', $current );
    149149
    150     $to_send = (object)compact('plugins', 'active');
     150    $to_send = (object) compact('plugins', 'active');
    151151
    152152    $options = array(
Note: See TracChangeset for help on using the changeset viewer.