小编kia*_*shi的帖子

删除插件过滤器

我有一个评论插件,可以覆盖特定帖子类型中的评论表单。现在,我试图将评论和评论分开。

我的第一步是删除修改当前评论模板的过滤器,并在第二个评论表单中使用该过滤器。

插件使用此代码(简体)

final class DM_Reviews {

    public function hooks() {
        do_action_ref_array( 'dm_reviews_before_setup_actions', array( &$this ) );

        add_filter( 'comment_form_defaults', array( $this, 'reviews_form'       ) );        

        do_action_ref_array( 'dm_reviews_after_setup_actions', array( &$this ) );
    }

    public function review_form( $args ) {    

            $form = 'plugin code to modify form';   

        return wp_parse_args( $form, $args );
    }

}
Run Code Online (Sandbox Code Playgroud)

在我的孩子主题的function.php文件中,我尝试使用它,但是没有用。

global $DM_Reviews;
remove_filter( 'comment_form_defaults', array($DM_Reviews, 'reviews_form'),1 );
Run Code Online (Sandbox Code Playgroud)

WP法典

如果有人可以使我正确地找到解决方法的方向,那将对我有很大帮助。

php wordpress filter

5
推荐指数
1
解决办法
2338
查看次数

ob_start() 和 ob_get_clean() 的使用

我通常这样编码:

$output .= 'custom code';
    $output .= 'another line of custom code';
$output .= 'more code';     

return $output;
Run Code Online (Sandbox Code Playgroud)

现在我想使用ob_start(),ob_get_contents()ob_get_clean(). 在我的示例中使用它的最有效方法是什么?

wordpress buffer

3
推荐指数
1
解决办法
9723
查看次数

标签 统计

wordpress ×2

buffer ×1

filter ×1

php ×1