Make WordPress Core


Ignore:
Timestamp:
02/20/2014 05:33:16 PM (11 years ago)
Author:
DrewAPicture
Message:

Inline documentation for various SQL clause hooks in wp-includes/query.php.

Covers documentation for general SQL clause hooks, including:

  • posts_where
  • posts_join
  • posts_where_paged
  • posts_groupby
  • posts_join_paged
  • posts_orderby
  • posts_distinct
  • post_limits
  • posts_fields
  • posts_clauses

Props dougwollison, DrewAPicture.
See #25514.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r27067 r27206  
    27602760            if ( ! empty( $where_status ) ) {
    27612761                $where .= " AND ($where_status)";
    2762             } 
     2762            }
    27632763        } elseif ( !$this->is_singular ) {
    27642764            $where .= " AND ($wpdb->posts.post_status = 'publish'";
     
    27952795        }
    27962796
    2797         // Apply filters on where and join prior to paging so that any
    2798         // manipulations to them are reflected in the paging by day queries.
     2797        /*
     2798         * Apply filters on where and join prior to paging so that any
     2799         * manipulations to them are reflected in the paging by day queries.
     2800         */
    27992801        if ( !$q['suppress_filters'] ) {
    2800             $where = apply_filters_ref_array('posts_where', array( $where, &$this ) );
    2801             $join = apply_filters_ref_array('posts_join', array( $join, &$this ) );
     2802            /**
     2803             * Filter the WHERE clause of the query.
     2804             *
     2805             * @since 1.5.0
     2806             *
     2807             * @param string   $where The WHERE clause of the query.
     2808             * @param WP_Query &$this The WP_Query instance (passed by reference).
     2809             */
     2810            $where = apply_filters_ref_array( 'posts_where', array( $where, &$this ) );
     2811
     2812            /**
     2813             * Filter the JOIN clause of the query.
     2814             *
     2815             * @since 1.5.0
     2816             *
     2817             * @param string   $where The JOIN clause of the query.
     2818             * @param WP_Query &$this The WP_Query instance (passed by reference).
     2819             */
     2820            $join = apply_filters_ref_array( 'posts_join', array( $join, &$this ) );
    28022821        }
    28032822
     
    28572876        $pieces = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' );
    28582877
    2859         // Apply post-paging filters on where and join. Only plugins that
    2860         // manipulate paging queries should use these hooks.
     2878        /*
     2879         * Apply post-paging filters on where and join. Only plugins that
     2880         * manipulate paging queries should use these hooks.
     2881         */
    28612882        if ( !$q['suppress_filters'] ) {
     2883            /**
     2884             * Filter the WHERE clause of the query.
     2885             *
     2886             * Specifically for manipulating paging queries.
     2887             *
     2888             * @since 1.5.0
     2889             *
     2890             * @param string   $where The WHERE clause of the query.
     2891             * @param WP_Query &$this The WP_Query instance (passed by reference).
     2892             */
    28622893            $where      = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) );
     2894
     2895            /**
     2896             * Filter the GROUP BY clause of the query.
     2897             *
     2898             * @since 2.0.0
     2899             *
     2900             * @param string   $groupby The GROUP BY clause of the query.
     2901             * @param WP_Query &$this   The WP_Query instance (passed by reference).
     2902             */
    28632903            $groupby    = apply_filters_ref_array( 'posts_groupby',     array( $groupby, &$this ) );
     2904
     2905            /**
     2906             * Filter the JOIN clause of the query.
     2907             *
     2908             * Specifically for manipulating paging queries.
     2909             *
     2910             * @since 1.5.0
     2911             *
     2912             * @param string   $join  The JOIN clause of the query.
     2913             * @param WP_Query &$this The WP_Query instance (passed by reference).
     2914             */
    28642915            $join       = apply_filters_ref_array( 'posts_join_paged',  array( $join, &$this ) );
     2916
     2917            /**
     2918             * Filter the ORDER BY clause of the query.
     2919             *
     2920             * @since 1.5.1
     2921             *
     2922             * @param string   $orderby The ORDER BY clause of the query.
     2923             * @param WP_Query &$this   The WP_Query instance (passed by reference).
     2924             */
    28652925            $orderby    = apply_filters_ref_array( 'posts_orderby',     array( $orderby, &$this ) );
     2926
     2927            /**
     2928             * Filter the DISTINCT clause of the query.
     2929             *
     2930             * @since 2.1.0
     2931             *
     2932             * @param string   $distinct The DISTINCT clause of the query.
     2933             * @param WP_Query &$this    The WP_Query instance (passed by reference).
     2934             */
    28662935            $distinct   = apply_filters_ref_array( 'posts_distinct',    array( $distinct, &$this ) );
     2936
     2937            /**
     2938             * Filter the LIMIT clause of the query.
     2939             *
     2940             * @since 2.1.0
     2941             *
     2942             * @param string   $limits The LIMIT clause of the query.
     2943             * @param WP_Query &$this  The WP_Query instance (passed by reference).
     2944             */
    28672945            $limits     = apply_filters_ref_array( 'post_limits',       array( $limits, &$this ) );
     2946
     2947            /**
     2948             * Filter the SELECT clause of the query.
     2949             *
     2950             * @since 2.1.0
     2951             *
     2952             * @param string   $fields The SELECT clause of the query.
     2953             * @param WP_Query &$this  The WP_Query instance (passed by reference).
     2954             */
    28682955            $fields     = apply_filters_ref_array( 'posts_fields',      array( $fields, &$this ) );
    28692956
    2870             // Filter all clauses at once, for convenience
     2957            /**
     2958             * Filter all query clauses at once, for convenience.
     2959             *
     2960             * Covers the WHERE, GROUP BY, JOIN, ORDER BY, DISTINCT,
     2961             * fields (SELECT), and LIMITS clauses.
     2962             *
     2963             * @since 3.1.0
     2964             *
     2965             * @param array    $clauses The list of clauses for the query.
     2966             * @param WP_Query &$this   The WP_Query instance (passed by reference).
     2967             */
    28712968            $clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $pieces ), &$this ) );
    2872             foreach ( $pieces as $piece )
     2969
     2970            foreach ( $pieces as $piece ) {
    28732971                $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
     2972            }
    28742973        }
    28752974
Note: See TracChangeset for help on using the changeset viewer.