Changeset 45667 for trunk/src/wp-includes/post.php
- Timestamp:
- 07/25/2019 12:47:53 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r45652 r45667 614 614 ); 615 615 616 $ r= wp_parse_args( $args, $defaults );617 618 $children = get_posts( $ r);616 $parsed_args = wp_parse_args( $args, $defaults ); 617 618 $children = get_posts( $parsed_args ); 619 619 620 620 if ( ! $children ) { … … 622 622 } 623 623 624 if ( ! empty( $ r['fields'] ) ) {624 if ( ! empty( $parsed_args['fields'] ) ) { 625 625 return $children; 626 626 } … … 1955 1955 ); 1956 1956 1957 $ r= wp_parse_args( $args, $defaults );1958 if ( empty( $ r['post_status'] ) ) {1959 $ r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';1960 } 1961 if ( ! empty( $ r['numberposts'] ) && empty( $r['posts_per_page'] ) ) {1962 $ r['posts_per_page'] = $r['numberposts'];1963 } 1964 if ( ! empty( $ r['category'] ) ) {1965 $ r['cat'] = $r['category'];1966 } 1967 if ( ! empty( $ r['include'] ) ) {1968 $incposts = wp_parse_id_list( $r['include'] );1969 $ r['posts_per_page'] = count( $incposts ); // only the number of posts included1970 $ r['post__in'] = $incposts;1971 } elseif ( ! empty( $ r['exclude'] ) ) {1972 $ r['post__not_in'] = wp_parse_id_list( $r['exclude'] );1973 } 1974 1975 $ r['ignore_sticky_posts'] = true;1976 $ r['no_found_rows'] = true;1957 $parsed_args = wp_parse_args( $args, $defaults ); 1958 if ( empty( $parsed_args['post_status'] ) ) { 1959 $parsed_args['post_status'] = ( 'attachment' == $parsed_args['post_type'] ) ? 'inherit' : 'publish'; 1960 } 1961 if ( ! empty( $parsed_args['numberposts'] ) && empty( $parsed_args['posts_per_page'] ) ) { 1962 $parsed_args['posts_per_page'] = $parsed_args['numberposts']; 1963 } 1964 if ( ! empty( $parsed_args['category'] ) ) { 1965 $parsed_args['cat'] = $parsed_args['category']; 1966 } 1967 if ( ! empty( $parsed_args['include'] ) ) { 1968 $incposts = wp_parse_id_list( $parsed_args['include'] ); 1969 $parsed_args['posts_per_page'] = count( $incposts ); // only the number of posts included 1970 $parsed_args['post__in'] = $incposts; 1971 } elseif ( ! empty( $parsed_args['exclude'] ) ) { 1972 $parsed_args['post__not_in'] = wp_parse_id_list( $parsed_args['exclude'] ); 1973 } 1974 1975 $parsed_args['ignore_sticky_posts'] = true; 1976 $parsed_args['no_found_rows'] = true; 1977 1977 1978 1978 $get_posts = new WP_Query; 1979 return $get_posts->query( $ r);1979 return $get_posts->query( $parsed_args ); 1980 1980 1981 1981 } … … 3382 3382 ); 3383 3383 3384 $ r= wp_parse_args( $args, $defaults );3385 3386 $results = get_posts( $ r);3384 $parsed_args = wp_parse_args( $args, $defaults ); 3385 3386 $results = get_posts( $parsed_args ); 3387 3387 3388 3388 // Backward compatibility. Prior to 3.1 expected posts to be returned in array. … … 5112 5112 ); 5113 5113 5114 $ r= wp_parse_args( $args, $defaults );5115 5116 $number = (int) $ r['number'];5117 $offset = (int) $ r['offset'];5118 $child_of = (int) $ r['child_of'];5119 $hierarchical = $ r['hierarchical'];5120 $exclude = $ r['exclude'];5121 $meta_key = $ r['meta_key'];5122 $meta_value = $ r['meta_value'];5123 $parent = $ r['parent'];5124 $post_status = $ r['post_status'];5114 $parsed_args = wp_parse_args( $args, $defaults ); 5115 5116 $number = (int) $parsed_args['number']; 5117 $offset = (int) $parsed_args['offset']; 5118 $child_of = (int) $parsed_args['child_of']; 5119 $hierarchical = $parsed_args['hierarchical']; 5120 $exclude = $parsed_args['exclude']; 5121 $meta_key = $parsed_args['meta_key']; 5122 $meta_value = $parsed_args['meta_value']; 5123 $parent = $parsed_args['parent']; 5124 $post_status = $parsed_args['post_status']; 5125 5125 5126 5126 // Make sure the post type is hierarchical. 5127 5127 $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); 5128 if ( ! in_array( $ r['post_type'], $hierarchical_post_types ) ) {5128 if ( ! in_array( $parsed_args['post_type'], $hierarchical_post_types ) ) { 5129 5129 return false; 5130 5130 } … … 5143 5143 5144 5144 // $args can be whatever, only use the args defined in defaults to compute the key. 5145 $key = md5( serialize( wp_array_slice_assoc( $ r, array_keys( $defaults ) ) ) );5145 $key = md5( serialize( wp_array_slice_assoc( $parsed_args, array_keys( $defaults ) ) ) ); 5146 5146 $last_changed = wp_cache_get_last_changed( 'posts' ); 5147 5147 … … 5152 5152 $pages = array_map( 'get_post', $cache ); 5153 5153 /** This filter is documented in wp-includes/post.php */ 5154 $pages = apply_filters( 'get_pages', $pages, $ r);5154 $pages = apply_filters( 'get_pages', $pages, $parsed_args ); 5155 5155 return $pages; 5156 5156 } 5157 5157 5158 5158 $inclusions = ''; 5159 if ( ! empty( $ r['include'] ) ) {5159 if ( ! empty( $parsed_args['include'] ) ) { 5160 5160 $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include 5161 5161 $parent = -1; … … 5164 5164 $meta_value = ''; 5165 5165 $hierarchical = false; 5166 $incpages = wp_parse_id_list( $ r['include'] );5166 $incpages = wp_parse_id_list( $parsed_args['include'] ); 5167 5167 if ( ! empty( $incpages ) ) { 5168 5168 $inclusions = ' AND ID IN (' . implode( ',', $incpages ) . ')'; … … 5179 5179 5180 5180 $author_query = ''; 5181 if ( ! empty( $ r['authors'] ) ) {5182 $post_authors = wp_parse_list( $ r['authors'] );5181 if ( ! empty( $parsed_args['authors'] ) ) { 5182 $post_authors = wp_parse_list( $parsed_args['authors'] ); 5183 5183 5184 5184 if ( ! empty( $post_authors ) ) { … … 5234 5234 5235 5235 if ( 1 == count( $post_status ) ) { 5236 $where_post_type = $wpdb->prepare( 'post_type = %s AND post_status = %s', $ r['post_type'], reset( $post_status ) );5236 $where_post_type = $wpdb->prepare( 'post_type = %s AND post_status = %s', $parsed_args['post_type'], reset( $post_status ) ); 5237 5237 } else { 5238 5238 $post_status = implode( "', '", $post_status ); 5239 $where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $ r['post_type'] );5239 $where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $parsed_args['post_type'] ); 5240 5240 } 5241 5241 … … 5262 5262 ); 5263 5263 5264 foreach ( explode( ',', $ r['sort_column'] ) as $orderby ) {5264 foreach ( explode( ',', $parsed_args['sort_column'] ) as $orderby ) { 5265 5265 $orderby = trim( $orderby ); 5266 5266 if ( ! in_array( $orderby, $allowed_keys ) ) { … … 5293 5293 $sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title"; 5294 5294 5295 $sort_order = strtoupper( $ r['sort_order'] );5295 $sort_order = strtoupper( $parsed_args['sort_order'] ); 5296 5296 if ( '' !== $sort_order && ! in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) { 5297 5297 $sort_order = 'ASC'; … … 5312 5312 5313 5313 /** This filter is documented in wp-includes/post.php */ 5314 $pages = apply_filters( 'get_pages', array(), $ r);5314 $pages = apply_filters( 'get_pages', array(), $parsed_args ); 5315 5315 return $pages; 5316 5316 } … … 5329 5329 } 5330 5330 5331 if ( ! empty( $ r['exclude_tree'] ) ) {5332 $exclude = wp_parse_id_list( $ r['exclude_tree'] );5331 if ( ! empty( $parsed_args['exclude_tree'] ) ) { 5332 $exclude = wp_parse_id_list( $parsed_args['exclude_tree'] ); 5333 5333 foreach ( $exclude as $id ) { 5334 5334 $children = get_page_children( $id, $pages ); … … 5362 5362 * 5363 5363 * @param array $pages List of pages to retrieve. 5364 * @param array $ rArray of get_pages() arguments.5364 * @param array $parsed_args Array of get_pages() arguments. 5365 5365 */ 5366 return apply_filters( 'get_pages', $pages, $ r);5366 return apply_filters( 'get_pages', $pages, $parsed_args ); 5367 5367 } 5368 5368
Note: See TracChangeset
for help on using the changeset viewer.