Make WordPress Core

Ticket #5231: has_filter.diff

File has_filter.diff, 2.7 KB (added by ryan, 17 years ago)
  • wp-includes/plugin.php

     
    7979}
    8080
    8181/**
     82 * Check if a filter has been registered for a hook
     83 * @package WordPress
     84 * @subpackage Plugin
     85 * @since 2.4
     86 * @global array $wp_filter Stores all of the filters
     87 *
     88 * @param string $tag The name of the filter hook.
     89 * @return boolean
     90 */
     91function has_filter($tag) {
     92        global $wp_filter;
     93
     94        return isset($wp_filter[$tag]);
     95}
     96
     97/**
    8298 * Call the functions added to a filter hook.
    8399 *
    84100 * The callback functions attached to filter hook <tt>$tag</tt> are invoked by
     
    377393}
    378394
    379395/**
     396 * Check if an action has been registered for a hook
     397 * @package WordPress
     398 * @subpackage Plugin
     399 * @since 2.4
     400 * @global array $wp_action Stores all of the actions
     401 *
     402 * @param string $tag The name of the action hook.
     403 * @return boolean
     404 */
     405function has_action($tag) {
     406        global $wp_action;
     407
     408        return isset($wp_action[$tag]);
     409}
     410
     411/**
    380412 * Removes a function from a specified action hook.
    381413 *
    382414 * This function removes a function attached to a specified action hook. This
  • wp-includes/classes.php

     
    238238                }
    239239
    240240                // query_string filter deprecated.  Use request filter instead.
    241                 global $wp_filter;
    242                 if ( isset($wp_filter['query_string']) ) {  // Don't bother filtering and parsing if no plugins are hooked in.
     241                if ( has_filter('query_string') ) {  // Don't bother filtering and parsing if no plugins are hooked in.
    243242                        $this->query_string = apply_filters('query_string', $this->query_string);
    244243                        parse_str($this->query_string, $this->query_vars);
    245244                }
  • wp-settings.php

     
    2020
    2121wp_unregister_GLOBALS();
    2222
    23 unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate );
     23unset( $wp_filter, $wp_action, $cache_lastcommentmodified, $cache_lastpostdate );
    2424
    2525if ( ! isset($blog_id) )
    2626        $blog_id = 1;
  • wp-admin/includes/plugin.php

     
    329329}
    330330
    331331function get_plugin_page_hook( $plugin_page, $parent_page ) {
    332         global $wp_filter;
    333 
    334332        $hook = get_plugin_page_hookname( $plugin_page, $parent_page );
    335         if ( isset( $wp_filter[$hook] ))
     333        if ( has_action($hook) )
    336334                return $hook;
    337335        else
    338336                return null;