remove_all_filters()删除一个过滤器的所有钩子

目录

描述

Remove all of the hooks from a filter.

remove_all_filters() 描述

用法

<?php remove_all_filters$tag$priority ); ?>

remove_all_filters() 用法

参数

$tag

(string) (必填) The filter to remove hooks from.

默认值: None

$priority

(integer) (可选) The priority number to remove.

默认值: false

remove_all_filters() 参数

返回值

(boolean) 

True when finished.

remove_all_filters() 返回值

注意

  • 使用到 global: (unknown type) $wp_filter
  • 使用到 global: (unknown type) $merged_filters

remove_all_filters() 注意

历史

添加于 版本: 2.7

remove_all_filters() 历史

源文件

remove_all_filters() 函数的代码位于 wp-includes/plugin.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * 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;
}

remove_all_filters() 源文件

相关