WordPress.org

Make WordPress Core

Ticket #15019: wp-includes-comment-filters.patch

File wp-includes-comment-filters.patch, 1.9 KB (added by sc0ttkclark, 4 years ago)

Initial Patch including the new filters / actions

  • comment.php

     
    209209        ); 
    210210 
    211211        $args = wp_parse_args( $args, $defaults ); 
     212 
     213        $args = apply_filters('pre_get_comments', $args); 
     214 
    212215        extract( $args, EXTR_SKIP ); 
    213216 
    214217        // $args can be whatever, only use the args defined in defaults to compute the key 
     
    297300        if ( '' !== $search ) 
    298301                $post_where .= _wp_search_sql($search, array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content')); 
    299302 
     303        // Apply post-paging filters on where and join.  Only plugins that 
     304        // manipulate paging queries should use these hooks. 
     305        $post_where     = apply_filters( 'comments_post_where', $post_where, $args); 
     306        $orderby        = apply_filters( 'comments_orderby',    $orderby, $args); 
     307        $order          = apply_filters( 'comments_order',              $order, $args); 
     308        $limit          = apply_filters( 'comments_limit',              $limit, $args); 
     309 
     310        // Announce current selection parameters.  For use by caching plugins. 
     311        do_action( 'comments_selection', $post_where . $orderby . $order . $limit ); 
     312 
     313        // Filter again for the benefit of caching plugins.  Regular plugins should use the hooks above. 
     314        $post_where     = apply_filters( 'comments_post_where_request', $post_where, $args); 
     315        $orderby        = apply_filters( 'comments_orderby_request',    $orderby, $args); 
     316        $order          = apply_filters( 'comments_order_request',              $order, $args); 
     317        $limit          = apply_filters( 'comments_limit_request',              $limit, $args); 
     318 
    300319        if ( $count ) 
    301320                return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments $post_where ORDER BY $orderby $order $limit" ); 
    302321 
    303322        $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments $post_where ORDER BY $orderby $order $limit" ); 
    304323 
     324        $comments = apply_filters('the_comments', $comments, $args); 
     325 
    305326        wp_cache_add( $cache_key, $comments, 'comment' ); 
    306327 
    307328        return $comments;