Changes in branches/3.1/wp-includes/post.php [18368:18023]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/wp-includes/post.php
r18368 r18023 2411 2411 2412 2412 $postarr = wp_parse_args($postarr, $defaults); 2413 2414 unset( $postarr[ 'filter' ] );2415 2416 2413 $postarr = sanitize_post($postarr, 'db'); 2417 2414 … … 3425 3422 $where_post_type = $wpdb->prepare( "post_type = '%s' AND post_status = '%s'", $post_type, $post_status ); 3426 3423 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 else3452 $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 3464 3424 $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where "; 3465 3425 $query .= $author_query; … … 3587 3547 if ( !empty($parent) ) 3588 3548 $object['post_parent'] = $parent; 3589 3590 unset( $object[ 'filter' ] );3591 3549 3592 3550 $object = sanitize_post($object, 'db');
Note: See TracChangeset
for help on using the changeset viewer.