Changes in branches/3.1/wp-includes/post.php [18023:18368]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/wp-includes/post.php
r18023 r18368 2411 2411 2412 2412 $postarr = wp_parse_args($postarr, $defaults); 2413 2414 unset( $postarr[ 'filter' ] ); 2415 2413 2416 $postarr = sanitize_post($postarr, 'db'); 2414 2417 … … 3422 3425 $where_post_type = $wpdb->prepare( "post_type = '%s' AND post_status = '%s'", $post_type, $post_status ); 3423 3426 3427 $orderby_array = array(); 3428 $allowed_keys = array('author', 'post_author', 'date', 'post_date', 'title', 'post_title', 'modified', 3429 'post_modified', 'modified_gmt', 'post_modified_gmt', 'menu_order', 'parent', 'post_parent', 3430 'ID', 'rand', 'comment_count'); 3431 foreach ( explode( ',', $sort_column ) as $orderby ) { 3432 $orderby = trim( $orderby ); 3433 if ( !in_array( $orderby, $allowed_keys ) ) 3434 continue; 3435 3436 switch ( $orderby ) { 3437 case 'menu_order': 3438 break; 3439 case 'ID': 3440 $orderby = "$wpdb->posts.ID"; 3441 break; 3442 case 'rand': 3443 $orderby = 'RAND()'; 3444 break; 3445 case 'comment_count': 3446 $orderby = "$wpdb->posts.comment_count"; 3447 break; 3448 default: 3449 if ( 0 === strpos( $orderby, 'post_' ) ) 3450 $orderby = "$wpdb->posts." . $orderby; 3451 else 3452 $orderby = "$wpdb->posts.post_" . $orderby; 3453 } 3454 3455 $orderby_array[] = $orderby; 3456 3457 } 3458 $sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title"; 3459 3460 $sort_order = strtoupper( $sort_order ); 3461 if ( '' !== $sort_order && !in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) 3462 $sort_order = 'ASC'; 3463 3424 3464 $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where "; 3425 3465 $query .= $author_query; … … 3547 3587 if ( !empty($parent) ) 3548 3588 $object['post_parent'] = $parent; 3589 3590 unset( $object[ 'filter' ] ); 3549 3591 3550 3592 $object = sanitize_post($object, 'db');
Note: See TracChangeset
for help on using the changeset viewer.