has_filter() 函式可以判斷一個過濾器是否被某個函式掛載。

用法

1

has_filter($tag,$function_to_check);

引數

$tag

(字串)(必須) 要判斷的過濾器的名字。

預設值:None

$function_to_check

(字串)(可選) 如果設定,並且這個函式被掛載了 $tag 變數指定的過濾器上,則返回優先順序。

預設值:None

返回值

(整數 | 布林) 如果有函式則返回指定函式的優先順序,沒有則返回 False

例子

1

if(!has_filter('the_content','example_alter_the_content'))add_filter('the_content','prefix_alter_the_content');

其它

函式位置:wp-includes/plugin.php

跟此函式相關的文章:https://www.weixiaoduo.com/tag/hook