Make WordPress Core

Ticket #16661: 16661.patch

File 16661.patch, 10.3 KB (added by hakre, 13 years ago)

review of apply_filters_ref_array() calls

  • wp-includes/comment.php

     
    320320                        $where .= $this->get_search_sql( $search, array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) );
    321321
    322322                $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' );
    323                 $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
     323                $clauses = apply_filters( 'comments_clauses', compact( $pieces ), $this );
    324324                foreach ( $pieces as $piece )
    325325                        $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
    326326
     
    330330                        return $wpdb->get_var( $query );
    331331
    332332                $comments = $wpdb->get_results( $query );
    333                 $comments = apply_filters_ref_array( 'the_comments', array( $comments, &$this ) );
     333                $comments = apply_filters( 'the_comments', $comments, $this );
    334334
    335335                wp_cache_add( $cache_key, $comments, 'comment' );
    336336
  • wp-includes/meta.php

     
    442442                $where .= $wpdb->prepare( " AND CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$meta_compare_string}", $meta_value );
    443443        }
    444444
    445         return apply_filters_ref_array( 'get_meta_sql', array( compact( 'join', 'where' ), $meta_query, $meta_type, $primary_table, $primary_id_column, &$context ) );
     445        return apply_filters( 'get_meta_sql', array( compact( 'join', 'where' ), $meta_query, $meta_type, $primary_table, $primary_id_column, $context ) );
    446446}
    447447
    448448/**
  • wp-includes/query.php

     
    21472147                }
    21482148
    21492149                // Allow plugins to contextually add/remove/modify the search section of the database query
    2150                 $search = apply_filters_ref_array('posts_search', array( $search, &$this ) );
     2150                $search = apply_filters( 'posts_search', $search, $this );
    21512151
    21522152                // Taxonomies
    21532153                $this->parse_tax_query( $q );
     
    24512451                // Apply filters on where and join prior to paging so that any
    24522452                // manipulations to them are reflected in the paging by day queries.
    24532453                if ( !$q['suppress_filters'] ) {
    2454                         $where = apply_filters_ref_array('posts_where', array( $where, &$this ) );
    2455                         $join = apply_filters_ref_array('posts_join', array( $join, &$this ) );
     2454                        $where = apply_filters( 'posts_where', $where, $this );
     2455                        $join = apply_filters( 'posts_join', $join, $this );
    24562456                }
    24572457
    24582458                // Paging
     
    24852485                        }
    24862486
    24872487                        if ( !$q['suppress_filters'] ) {
    2488                                 $cjoin = apply_filters_ref_array('comment_feed_join', array( $cjoin, &$this ) );
    2489                                 $cwhere = apply_filters_ref_array('comment_feed_where', array( $cwhere, &$this ) );
    2490                                 $cgroupby = apply_filters_ref_array('comment_feed_groupby', array( $cgroupby, &$this ) );
    2491                                 $corderby = apply_filters_ref_array('comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
    2492                                 $climits = apply_filters_ref_array('comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) );
     2488                                $cjoin = apply_filters('comment_feed_join', $cjoin, $this );
     2489                                $cwhere = apply_filters('comment_feed_where', $cwhere, $this );
     2490                                $cgroupby = apply_filters('comment_feed_groupby', $cgroupby, $this );
     2491                                $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC', $this );
     2492                                $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss'), $this );
    24932493                        }
    24942494                        $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
    24952495                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
     
    25172517                // Apply post-paging filters on where and join.  Only plugins that
    25182518                // manipulate paging queries should use these hooks.
    25192519                if ( !$q['suppress_filters'] ) {
    2520                         $where          = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) );
    2521                         $groupby        = apply_filters_ref_array( 'posts_groupby',             array( $groupby, &$this ) );
    2522                         $join           = apply_filters_ref_array( 'posts_join_paged',  array( $join, &$this ) );
    2523                         $orderby        = apply_filters_ref_array( 'posts_orderby',             array( $orderby, &$this ) );
    2524                         $distinct       = apply_filters_ref_array( 'posts_distinct',    array( $distinct, &$this ) );
    2525                         $limits         = apply_filters_ref_array( 'post_limits',               array( $limits, &$this ) );
    2526                         $fields         = apply_filters_ref_array( 'posts_fields',              array( $fields, &$this ) );
     2520                        $where          = apply_filters( 'posts_where_paged',   $where, $this );
     2521                        $groupby        = apply_filters( 'posts_groupby',               $groupby, $this );
     2522                        $join           = apply_filters( 'posts_join_paged',    $join, $this );
     2523                        $orderby        = apply_filters( 'posts_orderby',               $orderby, $this );
     2524                        $distinct       = apply_filters( 'posts_distinct',              $distinct, $this );
     2525                        $limits         = apply_filters( 'post_limits',                 $limits, $this );
     2526                        $fields         = apply_filters( 'posts_fields',                $fields, $this );
    25272527
    25282528                        // Filter all clauses at once, for convenience
    2529                         $clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $pieces ), &$this ) );
     2529                        $clauses = (array) apply_filters( 'posts_clauses', compact( $pieces ), $this );
    25302530                        foreach ( $pieces as $piece )
    25312531                                $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
    25322532                }
     
    25362536
    25372537                // Filter again for the benefit of caching plugins.  Regular plugins should use the hooks above.
    25382538                if ( !$q['suppress_filters'] ) {
    2539                         $where          = apply_filters_ref_array( 'posts_where_request',               array( $where, &$this ) );
    2540                         $groupby        = apply_filters_ref_array( 'posts_groupby_request',             array( $groupby, &$this ) );
    2541                         $join           = apply_filters_ref_array( 'posts_join_request',                array( $join, &$this ) );
    2542                         $orderby        = apply_filters_ref_array( 'posts_orderby_request',             array( $orderby, &$this ) );
    2543                         $distinct       = apply_filters_ref_array( 'posts_distinct_request',    array( $distinct, &$this ) );
    2544                         $fields         = apply_filters_ref_array( 'posts_fields_request',              array( $fields, &$this ) );
    2545                         $limits         = apply_filters_ref_array( 'post_limits_request',               array( $limits, &$this ) );
     2539                        $where          = apply_filters( 'posts_where_request',         $where, $this );
     2540                        $groupby        = apply_filters( 'posts_groupby_request',       $groupby, $this );
     2541                        $join           = apply_filters( 'posts_join_request',          $join, $this );
     2542                        $orderby        = apply_filters( 'posts_orderby_request',       $orderby, $this );
     2543                        $distinct       = apply_filters( 'posts_distinct_request',      $distinct, $this );
     2544                        $fields         = apply_filters( 'posts_fields_request',        $fields, $this );
     2545                        $limits         = apply_filters( 'post_limits_request',         $limits, $this );
    25462546
    25472547                        // Filter all clauses at once, for convenience
    2548                         $clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( compact( $pieces ), &$this ) );
     2548                        $clauses = (array) apply_filters( 'posts_clauses_request', compact( $pieces ), $this );
    25492549                        foreach ( $pieces as $piece )
    25502550                                $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
    25512551                }
     
    25612561
    25622562                $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
    25632563                if ( !$q['suppress_filters'] )
    2564                         $this->request = apply_filters_ref_array('posts_request', array( $this->request, &$this ) );
     2564                        $this->request = apply_filters('posts_request', $this->request, $this );
    25652565
    25662566                if ( 'ids' == $q['fields'] ) {
    25672567                        $this->posts = $wpdb->get_col($this->request);
     
    25832583
    25842584                // Raw results filter.  Prior to status checks.
    25852585                if ( !$q['suppress_filters'] )
    2586                         $this->posts = apply_filters_ref_array('posts_results', array( $this->posts, &$this ) );
     2586                        $this->posts = apply_filters('posts_results', $this->posts, $this );
    25872587
    25882588                if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
    2589                         $cjoin = apply_filters_ref_array('comment_feed_join', array( '', &$this ) );
    2590                         $cwhere = apply_filters_ref_array('comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
    2591                         $cgroupby = apply_filters_ref_array('comment_feed_groupby', array( '', &$this ) );
     2589                        $cjoin = apply_filters('comment_feed_join', '', $this );
     2590                        $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", $this );
     2591                        $cgroupby = apply_filters('comment_feed_groupby', '', $this );
    25922592                        $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
    2593                         $corderby = apply_filters_ref_array('comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
     2593                        $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC', $this );
    25942594                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
    2595                         $climits = apply_filters_ref_array('comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) );
     2595                        $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss'), $this );
    25962596                        $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits";
    25972597                        $this->comments = $wpdb->get_results($comments_request);
    25982598                        $this->comment_count = count($this->comments);
    25992599                }
    26002600
    26012601                if ( !$q['no_found_rows'] && !empty($limits) ) {
    2602                         $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) );
     2602                        $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()', $this );
    26032603                        $this->found_posts = $wpdb->get_var( $found_posts_query );
    2604                         $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );
     2604                        $this->found_posts = apply_filters( 'found_posts', $this->found_posts, $this );
    26052605                        $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);
    26062606                }
    26072607
     
    26342634                        }
    26352635
    26362636                        if ( $this->is_preview && current_user_can( $edit_cap, $this->posts[0]->ID ) )
    2637                                 $this->posts[0] = apply_filters_ref_array('the_preview', array( $this->posts[0], &$this ));
     2637                                $this->posts[0] = apply_filters('the_preview', $this->posts[0], $this );
    26382638                }
    26392639
    26402640                // Put sticky posts at the top of the posts array
     
    26882688                }
    26892689
    26902690                if ( !$q['suppress_filters'] )
    2691                         $this->posts = apply_filters_ref_array('the_posts', array( $this->posts, &$this ) );
     2691                        $this->posts = apply_filters('the_posts', $this->posts, $this );
    26922692
    26932693                $this->post_count = count($this->posts);
    26942694