Ticket #4711: 4711.diff
File 4711.diff, 4.1 KB (added by , 18 years ago) |
---|
-
wp-includes/post.php
41 41 } 42 42 43 43 $defaults = array( 44 'numberposts' => -1, 'post_type' => '', 44 'numberposts' => -1, 'post_type' => '', 45 45 'post_status' => '', 'post_parent' => 0 46 46 ); 47 47 … … 194 194 global $wpdb; 195 195 196 196 $defaults = array( 197 'numberposts' => 5, 'offset' => 0, 198 'category' => 0, 'orderby' => 'post_date', 199 'order' => 'DESC', 'include' => '', 200 'exclude' => '', 'meta_key' => '', 201 'meta_value' =>'', 'post_type' => 'post', 202 'post_ status' => 'publish', 'post_parent' => 0197 'numberposts' => 5, 'offset' => 0, 198 'category' => 0, 'orderby' => 'post_date', 199 'order' => 'DESC', 'include' => '', 200 'exclude' => '', 'meta_key' => '', 201 'meta_value' =>'', 'post_type' => 'post', 202 'post_parent' => 0 203 203 ); 204 204 205 205 $r = wp_parse_args( $args, $defaults ); … … 248 248 $exclusions .= ')'; 249 249 250 250 $query = "SELECT DISTINCT * FROM $wpdb->posts "; 251 $query .= empty( $category ) ? '' : ", $wpdb->term_relationships, $wpdb->term_taxonomy "; 251 $query .= empty( $category ) ? '' : ", $wpdb->term_relationships, $wpdb->term_taxonomy "; 252 252 $query .= empty( $meta_key ) ? '' : ", $wpdb->postmeta "; 253 253 $query .= " WHERE 1=1 "; 254 254 $query .= empty( $post_type ) ? '' : "AND post_type = '$post_type' "; 255 $query .= empty( $post_status ) ? '' : "AND post_status = '$post_status' ";255 $query .= 'AND '.get_private_posts_cap_sql('post').' '; 256 256 $query .= "$exclusions $inclusions " ; 257 257 $query .= empty( $category ) ? '' : "AND ($wpdb->posts.ID = $wpdb->term_relationships.object_id AND $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = " . $category. ") "; 258 258 $query .= empty( $post_parent ) ? '' : "AND $wpdb->posts.post_parent = '$post_parent' "; … … 428 428 if ( $do_object ) 429 429 $post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context); 430 430 else 431 $post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context); 431 $post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context); 432 432 } 433 433 434 434 return $post; … … 1100 1100 global $wpdb; 1101 1101 1102 1102 $defaults = array( 1103 'child_of' => 0, 'sort_order' => 'ASC', 1104 'sort_column' => 'post_title', 'hierarchical' => 1, 1105 'exclude' => '', 'include' => '', 1106 'meta_key' => '', 'meta_value' => '', 1103 'child_of' => 0, 'sort_order' => 'ASC', 1104 'sort_column' => 'post_title', 'hierarchical' => 1, 1105 'exclude' => '', 'include' => '', 1106 'meta_key' => '', 'meta_value' => '', 1107 1107 'authors' => '' 1108 1108 ); 1109 1109 … … 1117 1117 1118 1118 $inclusions = ''; 1119 1119 if ( !empty($include) ) { 1120 $child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include 1120 $child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include 1121 1121 $exclude = ''; 1122 1122 $meta_key = ''; 1123 1123 $meta_value = ''; … … 1146 1146 } 1147 1147 } 1148 1148 } 1149 if (!empty($exclusions)) 1149 if (!empty($exclusions)) 1150 1150 $exclusions .= ')'; 1151 1151 1152 1152 $author_query = ''; … … 1176 1176 } 1177 1177 1178 1178 $query = "SELECT * FROM $wpdb->posts " ; 1179 $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " ) ; 1180 $query .= " WHERE (post_type = 'page' AND post_status = 'publish') $exclusions $inclusions " ;1179 $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " ) ; 1180 $query .= " WHERE (post_type = 'page' AND ".get_private_posts_cap_sql('page').") $exclusions $inclusions " ; 1181 1181 $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" ) ; 1182 1182 $query .= $author_query; 1183 1183 $query .= " ORDER BY " . $sort_column . " " . $sort_order ; … … 1606 1606 * SQL code that can be added to a WHERE clause; this SQL is constructed 1607 1607 * to allow all published posts, and all private posts to which the user 1608 1608 * has access. 1609 * 1609 * 1610 1610 * @param string $post_type currently only supports 'post' or 'page'. 1611 1611 * @return string SQL code that can be added to a where clause. 1612 1612 */