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