【问题标题】:wordpress apply_filter on same functionwordpress apply_filter 在同一功能上
【发布时间】:2017-08-18 20:04:40
【问题描述】:
我在我的 wordpress 主题中发现了一个代码 sn-p
function jm_resume_custom_fields_prefix() {
return apply_filters( 'jm_resume_custom_fields_prefix', '_noo_resume_field_' );
}
上面的代码是什么意思?应用过滤器在这种情况下如何工作?
【问题讨论】:
标签:
php
wordpress
wordpress-hook
【解决方案1】:
动作/过滤器标签和函数位于不同的命名空间中。这意味着当函数 jm_resume_custom_fields_prefix() 被执行时,所有绑定到标签 'jm_resume_custom_fields_prefix' 的过滤器(通过 add_filter( 'jm_resume_custom_fields_prefix', ...) 被应用。命名执行操作/过滤器的函数的约定相同因为在 WordPress 中大量使用了 action/filter 标签。