我有一个评论插件,可以覆盖特定帖子类型中的评论表单。现在,我试图将评论和评论分开。
我的第一步是删除修改当前评论模板的过滤器,并在第二个评论表单中使用该过滤器。
插件使用此代码(简体)
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)
如果有人可以使我正确地找到解决方法的方向,那将对我有很大帮助。
我通常这样编码:
$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(). 在我的示例中使用它的最有效方法是什么?