Make WordPress Core

Ticket #17787: filters-and-minor-tweaks.patch

File filters-and-minor-tweaks.patch, 5.5 KB (added by 5ubliminal, 15 years ago)

Fixes for mentioned improvements.

  • wp-admin/includes/plugin.php

     
    255255
    256256        if ( empty($plugin_files) )
    257257                return $wp_plugins;
     258               
     259        /**
     260         * @author 5ubliminal
     261         */
     262        $plugin_files = apply_filters('get_plugins_files', $plugin_files); // [HACK]
    258263
    259264        foreach ( $plugin_files as $plugin_file ) {
    260265                if ( !is_readable( "$plugin_root/$plugin_file" ) )
     
    273278        $cache_plugins[ $plugin_folder ] = $wp_plugins;
    274279        wp_cache_set('plugins', $cache_plugins, 'plugins');
    275280
    276         return $wp_plugins;
     281        /**
     282         * @author 5ubliminal
     283         */
     284        return apply_filters('get_plugins', $wp_plugins);
    277285}
    278286
    279287/**
  • wp-includes/load.php

     
    455455        closedir( $dh );
    456456        sort( $mu_plugins );
    457457
    458         return $mu_plugins;
     458        /**
     459         * @author 5ubliminal
     460         */
     461        return apply_filters('get_mu_plugins', $mu_plugins);
    459462}
    460463
    461464/**
     
    484487
    485488        $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
    486489
     490        /**
     491         * @author 5ubliminal
     492         */
     493        $active_plugins = apply_filters('active_and_valid_plugins', $plugins);
     494       
    487495        foreach ( $active_plugins as $plugin ) {
    488496                if ( ! validate_file( $plugin ) // $plugin must validate as file
    489497                        && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
     
    493501                        )
    494502                $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
    495503        }
    496         return $plugins;
     504        /**
     505         * @author 5ubliminal
     506         */
     507        return apply_filters('get_active_and_valid_plugins', $plugins);
    497508}
    498509
    499510/**
  • wp-includes/ms-load.php

     
    4545        $active_plugins = array_keys( $active_plugins );
    4646        sort( $active_plugins );
    4747
     48        /**
     49         * @author 5ubliminal
     50         */
     51        $active_plugins = apply_filters('active_network_plugins', $active_plugins);
     52       
    4853        foreach ( $active_plugins as $plugin ) {
    4954                if ( ! validate_file( $plugin ) // $plugin must validate as file
    5055                        && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
     
    5257                        )
    5358                $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
    5459        }
    55         return $plugins;
     60
     61        /**
     62         * @author 5ubliminal
     63         */
     64        return apply_filters('get_active_network_plugins', $plugins);
    5665}
    5766
    5867/**
  • wp-includes/plugin.php

     
    6565function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
    6666        global $wp_filter, $merged_filters;
    6767
     68        /**
     69         * No longer violently unset($wp_filter); in wp-settings.php line #38-some.
     70         * We empty this on first call or if we find it's not an array().
     71         * This function is the only one that should add data to it so it has every right to reset it on first run.
     72         *
     73         * And we count calls by using a static variable.
     74         */
     75        static $hits = 0;
     76        if(!$hits or !is_array($wp_filter)) $wp_filter = array(); // Reset filters on first run or on type mismatch
     77        $hits++; // Increment hit count
     78       
    6879        $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority);
    6980        $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
    7081        unset( $merged_filters[ $tag ] );
  • wp-includes/theme.php

     
    745745        if ( empty( $templates ) )
    746746                $templates = array("{$type}.php");
    747747
     748        /**
     749         * Allow the use of one major filter named 'query_template'.
     750         * Only if the returned value is an array() will it be used to replace previous array().
     751         * This is to prevent accidental returns of NULLs or such.
     752         * @author 5ubliminal
     753         */
     754        is_array( $new_templates = apply_filters( "query_template", $templates, $type ) ) and
     755                !empty( $new_templates ) and ( $templates = $new_templates );
     756       
    748757        return apply_filters( "{$type}_template", locate_template( $templates ) );
    749758}
    750759
  • wp-login.php

     
    367367        setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
    368368
    369369// allow plugins to override the default actions, and to add extra actions if they want
    370 do_action( 'login_init' );
     370/**
     371 * We should also get the action name here.
     372 * @author 5ubliminal
     373 */
     374do_action( 'login_init', $action );
    371375do_action( 'login_form_' . $action );
    372376
    373377$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
  • wp-settings.php

     
    3535wp_unregister_GLOBALS();
    3636
    3737// Ensure these global variables do not exist so they do not interfere with WordPress.
    38 unset( $wp_filter, $cache_lastcommentmodified );
     38/**
     39 * We now reset $wp_filter directly in the add_filter() function,
     40 * the only function that should legally alter it.
     41 * @author 5ubliminal
     42 */
     43unset($cache_lastcommentmodified); // unset( $wp_filter, $cache_lastcommentmodified );
    3944
    4045// Standardize $_SERVER variables across setups.
    4146wp_fix_server_vars();