X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f5fcdc7994bb67cce809bc4777944ae8b7fad4a4..53f4633144ed68c8b8fb5861f992b5489894a940:/wp-includes/query.php diff --git a/wp-includes/query.php b/wp-includes/query.php index 6cfdd2ee..7cbac9db 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -14,9 +14,9 @@ /** * Retrieve variable in the WP_Query class. * - * @see WP_Query::get() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @param string $var The variable key to retrieve. * @param mixed $default Value to return if the query variable is not set. Default ''. @@ -24,18 +24,17 @@ */ function get_query_var( $var, $default = '' ) { global $wp_query; - return $wp_query->get( $var, $default ); } /** * Retrieve the currently-queried object. Wrapper for $wp_query->get_queried_object() * - * @uses WP_Query::get_queried_object - * * @since 3.1.0 * @access public * + * @global WP_Query $wp_query + * * @return object */ function get_queried_object() { @@ -46,11 +45,11 @@ function get_queried_object() { /** * Retrieve ID of the current queried object. Wrapper for $wp_query->get_queried_object_id() * - * @uses WP_Query::get_queried_object_id() - * * @since 3.1.0 * @access public * + * @global WP_Query $wp_query + * * @return int */ function get_queried_object_id() { @@ -61,18 +60,16 @@ function get_queried_object_id() { /** * Set query variable. * - * @see WP_Query::set() * @since 2.2.0 - * @uses $wp_query * - * @param string $var Query variable key. - * @param mixed $value - * @return null + * @global WP_Query $wp_query + * + * @param string $var Query variable key. + * @param mixed $value */ -function set_query_var($var, $value) { +function set_query_var( $var, $value ) { global $wp_query; - - return $wp_query->set($var, $value); + $wp_query->set( $var, $value ); } /** @@ -82,7 +79,8 @@ function set_query_var($var, $value) { * once. This must not be used within the WordPress Loop. * * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @param string $query * @return array List of posts @@ -100,7 +98,9 @@ function query_posts($query) { * wp_query object is not destroyed properly before another is set up. * * @since 2.3.0 - * @uses $wp_query + * + * @global WP_Query $wp_query + * @global WP_Query $wp_the_query */ function wp_reset_query() { $GLOBALS['wp_query'] = $GLOBALS['wp_the_query']; @@ -112,7 +112,8 @@ function wp_reset_query() { * the $post global to the current post in the main query. * * @since 3.0.0 - * @uses $wp_query + * + * @global WP_Query $wp_query */ function wp_reset_postdata() { global $wp_query; @@ -131,9 +132,9 @@ function wp_reset_postdata() { * * Month, Year, Category, Author, Post Type archive... * - * @see WP_Query::is_archive() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -151,11 +152,11 @@ function is_archive() { /** * Is the query for an existing post type archive page? * - * @see WP_Query::is_post_type_archive() * @since 3.1.0 - * @uses $wp_query * - * @param mixed $post_types Optional. Post type or array of posts types to check against. + * @global WP_Query $wp_query + * + * @param string|array $post_types Optional. Post type or array of posts types to check against. * @return bool */ function is_post_type_archive( $post_types = '' ) { @@ -172,9 +173,9 @@ function is_post_type_archive( $post_types = '' ) { /** * Is the query for an existing attachment page? * - * @see WP_Query::is_attachment() * @since 2.0.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @param int|string|array|object $attachment Attachment ID, title, slug, or array of such. * @return bool @@ -196,9 +197,9 @@ function is_attachment( $attachment = '' ) { * If the $author parameter is specified, this function will additionally * check if the query is for one of the authors specified. * - * @see WP_Query::is_author() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames * @return bool @@ -220,9 +221,9 @@ function is_author( $author = '' ) { * If the $category parameter is specified, this function will additionally * check if the query is for one of the categories specified. * - * @see WP_Query::is_category() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs. * @return bool @@ -244,9 +245,9 @@ function is_category( $category = '' ) { * If the $tag parameter is specified, this function will additionally * check if the query is for one of the tags specified. * - * @see WP_Query::is_tag() * @since 2.3.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs. * @return bool @@ -272,12 +273,12 @@ function is_tag( $tag = '' ) { * this function will additionally check if the query is for one of the terms * specified. * - * @see WP_Query::is_tax() * @since 2.5.0 - * @uses $wp_query * - * @param string|array $taxonomy Optional. Taxonomy slug or slugs. - * @param int|string|array $term Optional. Term ID, name, slug or array of Term IDs, names, and slugs. + * @global WP_Query $wp_query + * + * @param string|array $taxonomy Optional. Taxonomy slug or slugs. + * @param int|string|array $term Optional. Term ID, name, slug or array of Term IDs, names, and slugs. * @return bool */ function is_tax( $taxonomy = '', $term = '' ) { @@ -294,9 +295,9 @@ function is_tax( $taxonomy = '', $term = '' ) { /** * Whether the current URL is within the comments popup window. * - * @see WP_Query::is_comments_popup() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -314,9 +315,9 @@ function is_comments_popup() { /** * Is the query for an existing date archive? * - * @see WP_Query::is_date() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -334,9 +335,9 @@ function is_date() { /** * Is the query for an existing day archive? * - * @see WP_Query::is_day() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -354,9 +355,9 @@ function is_day() { /** * Is the query for a feed? * - * @see WP_Query::is_feed() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @param string|array $feeds Optional feed types to check. * @return bool @@ -375,9 +376,9 @@ function is_feed( $feeds = '' ) { /** * Is the query for a comments feed? * - * @see WP_Query::is_comments_feed() * @since 3.0.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -404,9 +405,10 @@ function is_comment_feed() { * * Otherwise the same as @see is_home() * - * @see WP_Query::is_front_page() * @since 2.5.0 * + * @global WP_Query $wp_query + * * @return bool True, if front of site. */ function is_front_page() { @@ -432,9 +434,9 @@ function is_front_page() { * * @see is_front_page() * - * @see WP_Query::is_home() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool True if blog view homepage. */ @@ -452,9 +454,9 @@ function is_home() { /** * Is the query for an existing month archive? * - * @see WP_Query::is_month() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -478,9 +480,9 @@ function is_month() { * @see is_single() * @see is_singular() * - * @see WP_Query::is_page() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @param mixed $page Page ID, title, slug, or array of such. * @return bool @@ -499,9 +501,9 @@ function is_page( $page = '' ) { /** * Is the query for paged result and not for the first page? * - * @see WP_Query::is_paged() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -519,9 +521,9 @@ function is_paged() { /** * Is the query for a post or page preview? * - * @see WP_Query::is_preview() * @since 2.0.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -539,9 +541,9 @@ function is_preview() { /** * Is the query for the robots file? * - * @see WP_Query::is_robots() * @since 2.1.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -559,9 +561,9 @@ function is_robots() { /** * Is the query for a search? * - * @see WP_Query::is_search() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -587,9 +589,9 @@ function is_search() { * @see is_page() * @see is_singular() * - * @see WP_Query::is_single() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @param mixed $post Post ID, title, slug, or array of such. * @return bool @@ -614,9 +616,9 @@ function is_single( $post = '' ) { * @see is_page() * @see is_single() * - * @see WP_Query::is_singular() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @param mixed $post_types Optional. Post Type or array of Post Types * @return bool @@ -635,9 +637,9 @@ function is_singular( $post_types = '' ) { /** * Is the query for a specific time? * - * @see WP_Query::is_time() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -655,9 +657,9 @@ function is_time() { /** * Is the query for a trackback endpoint call? * - * @see WP_Query::is_trackback() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -675,9 +677,9 @@ function is_trackback() { /** * Is the query for an existing year archive? * - * @see WP_Query::is_year() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -695,9 +697,9 @@ function is_year() { /** * Is the query a 404 (returns no results)? * - * @see WP_Query::is_404() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -717,6 +719,8 @@ function is_404() { * * @since 3.3.0 * + * @global WP_Query $wp_query + * * @return bool */ function is_main_query() { @@ -737,15 +741,14 @@ function is_main_query() { /** * Whether current WordPress query has results to loop over. * - * @see WP_Query::have_posts() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ function have_posts() { global $wp_query; - return $wp_query->have_posts(); } @@ -753,41 +756,37 @@ function have_posts() { * Whether the caller is in the Loop. * * @since 2.0.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool True if caller is within loop, false if loop hasn't started or ended. */ function in_the_loop() { global $wp_query; - return $wp_query->in_the_loop; } /** * Rewind the loop posts. * - * @see WP_Query::rewind_posts() * @since 1.5.0 - * @uses $wp_query * - * @return null + * @global WP_Query $wp_query */ function rewind_posts() { global $wp_query; - - return $wp_query->rewind_posts(); + $wp_query->rewind_posts(); } /** * Iterate the post index in the loop. * - * @see WP_Query::the_post() * @since 1.5.0 - * @uses $wp_query + * + * @global WP_Query $wp_query */ function the_post() { global $wp_query; - $wp_query->the_post(); } @@ -798,9 +797,9 @@ function the_post() { /** * Whether there are comments to loop over. * - * @see WP_Query::have_comments() * @since 2.2.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return bool */ @@ -812,9 +811,9 @@ function have_comments() { /** * Iterate comment index in the comment loop. * - * @see WP_Query::the_comment() * @since 2.2.0 - * @uses $wp_query + * + * @global WP_Query $wp_query * * @return object */ @@ -1868,6 +1867,10 @@ class WP_Query { $term = $q[$t->query_var]; + if ( is_array( $term ) ) { + $term = implode( ',', $term ); + } + if ( strpos($term, '+') !== false ) { $terms = preg_split( '/[+]+/', $term ); foreach ( $terms as $term ) { @@ -2179,6 +2182,7 @@ class WP_Query { * Generate SQL for the ORDER BY condition based on passed search terms. * * @global wpdb $wpdb + * * @param array $q Query variables. * @return string ORDER BY clause. */ @@ -2224,7 +2228,7 @@ class WP_Query { * @global wpdb $wpdb WordPress database abstraction object. * * @param string $orderby Alias for the field to order by. - * @return string|bool Table-prefixed value to used in the ORDER clause. False otherwise. + * @return string|false Table-prefixed value to used in the ORDER clause. False otherwise. */ protected function parse_orderby( $orderby ) { global $wpdb; @@ -2360,7 +2364,7 @@ class WP_Query { * @access public * * @param string $query_var Query variable key. - * @param mixed $value Query variable value. + * @param mixed $value Query variable value. */ public function set($query_var, $value) { $this->query_vars[$query_var] = $value; @@ -2375,6 +2379,8 @@ class WP_Query { * @since 1.5.0 * @access public * + * @global wpdb $wpdb + * * @return array List of posts. */ public function get_posts() { @@ -3656,6 +3662,8 @@ class WP_Query { * * @since 3.5.0 * @access private + * + * @global wpdb $wpdb */ private function set_found_posts( $q, $limits ) { global $wpdb; @@ -3717,6 +3725,8 @@ class WP_Query { * * @since 1.5.0 * @access public + * + * @global WP_Post $post */ public function the_post() { global $post; @@ -4014,7 +4024,7 @@ class WP_Query { * * @param callable $name Method to call. * @param array $arguments Arguments to pass when calling. - * @return mixed|bool Return value of the callback, false otherwise. + * @return mixed|false Return value of the callback, false otherwise. */ public function __call( $name, $arguments ) { if ( in_array( $name, $this->compat_methods ) ) { @@ -4195,6 +4205,8 @@ class WP_Query { * * @since 3.1.0 * + * @global array $wp_taxonomies + * * @param mixed $taxonomy Optional. Taxonomy slug or slugs. * @param mixed $term Optional. Term ID, name, slug or array of Term IDs, names, and slugs. * @return bool @@ -4556,6 +4568,8 @@ class WP_Query { * * @since 3.3.0 * + * @global WP_Query $wp_query + * * @return bool */ public function is_main_query() { @@ -4568,8 +4582,18 @@ class WP_Query { * * @since 4.1.0 * + * @global int $id + * @global WP_User $authordata + * @global string|int|bool $currentday + * @global string|int|bool $currentmonth + * @global int $page + * @global array $pages + * @global int $multipage + * @global int $more + * @global int $numpages + * * @param WP_Post $post Post data. - * @return bool True when finished. + * @return true True when finished. */ public function setup_postdata( $post ) { global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages; @@ -4636,6 +4660,8 @@ class WP_Query { * restores the $post global to the current post in this query. * * @since 3.7.0 + * + * @global WP_Post $post */ public function reset_postdata() { if ( ! empty( $this->post ) ) { @@ -4652,10 +4678,8 @@ class WP_Query { * * @since 2.1.0 * - * @uses $wp_query - * @global wpdb $wpdb WordPress database abstraction object. - * - * @return null If no link is found, null is returned. + * @global WP_Query $wp_query + * @global wpdb $wpdb WordPress database abstraction object. */ function wp_old_slug_redirect() { global $wp_query; @@ -4711,6 +4735,8 @@ function wp_old_slug_redirect() { * * @since 1.5.0 * + * @global WP_Query $wp_query + * * @param object $post Post data. * @return bool True when finished. */