在以下 WP php 代码中:
function bbp_get_topic_post_count( $topic_id = 0, $integer = false ) {
$topic_id = bbp_get_topic_id( $topic_id );
$replies = (int) get_post_meta( $topic_id, '_bbp_reply_count', true ) + 1;
$filter = ( true === $integer ) ? 'bbp_get_topic_post_count_int' : 'bbp_get_topic_post_count';
return apply_filters( $filter, $replies, $topic_id );
}
我想通过使用过滤器来更改“$replies”。由于上面有“apply_filters”,我认为可以添加“add_filter”。但似乎过滤器名称是“$filter”
function bbp_reply_count_modified( $replies, $topic_id ) {
$topic_id = bbp_get_topic_id( $topic_id );
$replies = (int) get_post_meta( $topic_id, '_bbp_reply_count', true ); // deleted '+ 1'
return $replies;
add_filter( '___________________', 'bbp_reply_count_modified', 10, 2 );
在这种情况下,如何创建“add_filter”函数?
谢谢你的帮助。