WordPress.org

Make WordPress Core

Changeset 8660


Ignore:
Timestamp:
08/17/2008 11:15:38 AM (10 years ago)
Author:
westi
Message:

remove_all_{actions|filters}. Fixes #7216 props filosofo and santosj.

File:
1 edited

Legend:

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

    r8587 r8660  
    207207}
    208208
     209/**
     210 * Remove all of the hooks from a filter.
     211 *
     212 * @since 2.7
     213 *
     214 * @param string $tag The filter to remove hooks from.
     215 * @param int $priority The priority number to remove.
     216 * @return bool True when finished.
     217 */
     218function remove_all_filters($tag, $priority = false) {
     219    global $wp_filter, $merge_filters;
     220
     221    if( isset($wp_filter[$tag]) ) {
     222        if( false !== $priority && isset($$wp_filter[$tag][$priority]) )
     223            unset($wp_filter[$tag][$priority]);
     224        else
     225            unset($wp_filter[$tag]);
     226    }
     227
     228    if( isset($merged_filters[$tag]) )
     229        unset($merged_filters[$tag]);
     230
     231    return true;
     232}
    209233
    210234/**
     
    426450function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
    427451    return remove_filter($tag, $function_to_remove, $priority, $accepted_args);
     452}
     453
     454/**
     455 * Remove all of the hooks from an action.
     456 *
     457 * @since 2.7
     458 *
     459 * @param string $tag The action to remove hooks from.
     460 * @param int $priority The priority number to remove them from.
     461 * @return bool True when finished.
     462 */
     463function remove_all_actions($tag, $priority = false) {
     464    return remove_all_filters($tag, $priority);
    428465}
    429466
Note: See TracChangeset for help on using the changeset viewer.