Make WordPress Core

Ticket #7216: 7216.r8534.diff

File 7216.r8534.diff, 1.4 KB (added by santosj, 17 years ago)

remove_all_filters() and remove_all_actions() based off of r8534

  • plugin.php

     
    206206        return $r;
    207207}
    208208
     209/**
     210 * Remove all of the hooks from a filter.
     211 *
     212 * @since {@internal Version Unknown}}
     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;
    209220
     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}
     233
    210234/**
    211235 * current_filter() - Return the name of the current filter or action.
    212236 *
     
    427451        return remove_filter($tag, $function_to_remove, $priority, $accepted_args);
    428452}
    429453
     454/**
     455 * Remove all of the hooks from an action.
     456 *
     457 * @since {@internal Version Unknown}}
     458 *
     459 * @param string $tag The action to remove hooks from.
     460 * @param int $priority The priority number to remove.
     461 * @return bool True when finished.
     462 */
     463function remove_all_actions($tag, $priority = false) {
     464        return remove_all_filters($tag, $priority);
     465}
     466
    430467//
    431468// Functions for handling plugins.
    432469//