Wordpress 4.2.1 pre_get_comments这在更新后不起作用

时间:2015-04-29 08:03:58

标签: wordpress-plugin wordpress

我有这段代码一直工作,但在更新到Wordpress 4.2.1后,这不起作用。

// return just the missing replies in the comment table
add_action( 'pre_get_comments', array( $this, 'return_missing_list' ) );
public function return_missing_list( $comments = array() ) {

    // bail on anything not admin
    if ( ! is_admin() )
        return;

    // only run this on the comments table
    $current_screen = get_current_screen();

    if( 'edit-comments' !== $current_screen->base )
        return;

    // check for query param
    if ( ! isset( $_GET['missing_reply'] ) )
        return;

    // now run action to show missing
    $comments->query_vars['meta_key']   = '_cnrt_missing';
    $comments->query_vars['meta_value'] = '1';
    $comments->query_vars['date_query'] = array(
                'after' => '10 months ago'
            );

    // Because at this point, the meta query has already been parsed,
    // we need to re-parse it to incorporate our changes
    $comments->meta_query->parse_query_vars( $comments->query_vars );
} // end missing_reply_list

0 个答案:

没有答案