remove_all_filters

The timeline below displays how wordpress function remove_all_filters has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.8

/**
 * Removes all of the callback functions from a filter hook.
 *
 * @since 2.7.0
 *
 * @global WP_Hook[] $wp_filter Stores all of the filters and actions.
 *
 * @param string    $hook_name The filter to remove callbacks from.
 * @param int|false $priority  Optional. The priority number to remove them from.
 *                             Default false.
 * @return true Always returns true.
 */
function remove_all_filters($hook_name, $priority = false)
{
    global $wp_filter;
    if (isset($wp_filter[$hook_name])) {
        $wp_filter[$hook_name]->remove_all_filters($priority);
        if (!$wp_filter[$hook_name]->has_filters()) {
            unset($wp_filter[$hook_name]);
        }
    }
    return true;
}

WordPress Version: 5.7

/**
 * Remove all of the hooks from a filter.
 *
 * @since 2.7.0
 *
 * @global WP_Hook[] $wp_filter Stores all of the filters and actions.
 *
 * @param string    $tag      The filter to remove hooks from.
 * @param int|false $priority Optional. The priority number to remove. Default false.
 * @return true True when finished.
 */
function remove_all_filters($tag, $priority = false)
{
    global $wp_filter;
    if (isset($wp_filter[$tag])) {
        $wp_filter[$tag]->remove_all_filters($priority);
        if (!$wp_filter[$tag]->has_filters()) {
            unset($wp_filter[$tag]);
        }
    }
    return true;
}

WordPress Version: 5.6

/**
 * Remove all of the hooks from a filter.
 *
 * @since 2.7.0
 *
 * @global WP_Hook[] $wp_filter Stores all of the filters and actions.
 *
 * @param string   $tag      The filter to remove hooks from.
 * @param int|bool $priority Optional. The priority number to remove. Default false.
 * @return true True when finished.
 */
function remove_all_filters($tag, $priority = false)
{
    global $wp_filter;
    if (isset($wp_filter[$tag])) {
        $wp_filter[$tag]->remove_all_filters($priority);
        if (!$wp_filter[$tag]->has_filters()) {
            unset($wp_filter[$tag]);
        }
    }
    return true;
}

WordPress Version: 5.4

/**
 * Remove all of the hooks from a filter.
 *
 * @since 2.7.0
 *
 * @global array $wp_filter Stores all of the filters and actions.
 *
 * @param string   $tag      The filter to remove hooks from.
 * @param int|bool $priority Optional. The priority number to remove. Default false.
 * @return true True when finished.
 */
function remove_all_filters($tag, $priority = false)
{
    global $wp_filter;
    if (isset($wp_filter[$tag])) {
        $wp_filter[$tag]->remove_all_filters($priority);
        if (!$wp_filter[$tag]->has_filters()) {
            unset($wp_filter[$tag]);
        }
    }
    return true;
}

WordPress Version: 4.7

/**
 * Remove all of the hooks from a filter.
 *
 * @since 2.7.0
 *
 * @global array $wp_filter  Stores all of the filters
 *
 * @param string   $tag      The filter to remove hooks from.
 * @param int|bool $priority Optional. The priority number to remove. Default false.
 * @return true True when finished.
 */
function remove_all_filters($tag, $priority = false)
{
    global $wp_filter;
    if (isset($wp_filter[$tag])) {
        $wp_filter[$tag]->remove_all_filters($priority);
        if (!$wp_filter[$tag]->has_filters()) {
            unset($wp_filter[$tag]);
        }
    }
    return true;
}

WordPress Version: 4.3

/**
 * Remove all of the hooks from a filter.
 *
 * @since 2.7.0
 *
 * @global array $wp_filter         Stores all of the filters
 * @global array $merged_filters    Merges the filter hooks using this function.
 *
 * @param string   $tag      The filter to remove hooks from.
 * @param int|bool $priority Optional. The priority number to remove. Default false.
 * @return true True when finished.
 */
function remove_all_filters($tag, $priority = false)
{
    global $wp_filter, $merged_filters;
    if (isset($wp_filter[$tag])) {
        if (false === $priority) {
            $wp_filter[$tag] = array();
        } elseif (isset($wp_filter[$tag][$priority])) {
            $wp_filter[$tag][$priority] = array();
        }
    }
    unset($merged_filters[$tag]);
    return true;
}

WordPress Version: 4.2

/**
 * Remove all of the hooks from a filter.
 *
 * @since 2.7.0
 *
 * @param string   $tag      The filter to remove hooks from.
 * @param int|bool $priority Optional. The priority number to remove. Default false.
 * @return bool True when finished.
 */
function remove_all_filters($tag, $priority = false)
{
    global $wp_filter, $merged_filters;
    if (isset($wp_filter[$tag])) {
        if (false === $priority) {
            $wp_filter[$tag] = array();
        } elseif (isset($wp_filter[$tag][$priority])) {
            $wp_filter[$tag][$priority] = array();
        }
    }
    if (isset($merged_filters[$tag])) {
        unset($merged_filters[$tag]);
    }
    return true;
}

WordPress Version: 4.0

/**
 * Remove all of the hooks from a filter.
 *
 * @since 2.7.0
 *
 * @param string   $tag      The filter to remove hooks from.
 * @param int|bool $priority Optional. The priority number to remove. Default false.
 * @return bool True when finished.
 */
function remove_all_filters($tag, $priority = false)
{
    global $wp_filter, $merged_filters;
    if (isset($wp_filter[$tag])) {
        if (false !== $priority && isset($wp_filter[$tag][$priority])) {
            $wp_filter[$tag][$priority] = array();
        } else {
            $wp_filter[$tag] = array();
        }
    }
    if (isset($merged_filters[$tag])) {
        unset($merged_filters[$tag]);
    }
    return true;
}

WordPress Version: 3.9

/**
 * Remove all of the hooks from a filter.
 *
 * @since 2.7.0
 *
 * @param string $tag The filter to remove hooks from.
 * @param int $priority The priority number to remove.
 * @return bool True when finished.
 */
function remove_all_filters($tag, $priority = false)
{
    global $wp_filter, $merged_filters;
    if (isset($wp_filter[$tag])) {
        if (false !== $priority && isset($wp_filter[$tag][$priority])) {
            unset($wp_filter[$tag][$priority]);
        } else {
            unset($wp_filter[$tag]);
        }
    }
    if (isset($merged_filters[$tag])) {
        unset($merged_filters[$tag]);
    }
    return true;
}

WordPress Version: 3.7

/**
 * Remove all of the hooks from a filter.
 *
 * @since 2.7
 *
 * @param string $tag The filter to remove hooks from.
 * @param int $priority The priority number to remove.
 * @return bool True when finished.
 */
function remove_all_filters($tag, $priority = false)
{
    global $wp_filter, $merged_filters;
    if (isset($wp_filter[$tag])) {
        if (false !== $priority && isset($wp_filter[$tag][$priority])) {
            unset($wp_filter[$tag][$priority]);
        } else {
            unset($wp_filter[$tag]);
        }
    }
    if (isset($merged_filters[$tag])) {
        unset($merged_filters[$tag]);
    }
    return true;
}