| 479 | | function wp_edit_posts_query( $q = false ) { |
|---|
| 480 | | global $wpdb; |
|---|
| 481 | | if ( false === $q ) |
|---|
| 482 | | $q = $_GET; |
|---|
| 483 | | $q['m'] = (int) $q['m']; |
|---|
| 484 | | $q['cat'] = (int) $q['cat']; |
|---|
| 485 | | $post_stati = array( // array( adj, noun ) |
|---|
| 486 | | 'draft' => array(__('Draft'), _c('Drafts|manage posts header')), |
|---|
| 487 | | 'future' => array(__('Scheduled'), __('Scheduled posts')), |
|---|
| 488 | | 'pending' => array(__('Pending Review'), __('Pending posts')), |
|---|
| 489 | | 'private' => array(__('Private'), __('Private posts')), |
|---|
| 490 | | 'publish' => array(__('Published'), __('Published posts')) |
|---|
| 491 | | ); |
|---|
| 492 | | |
|---|
| 493 | | $avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'"); |
|---|
| 494 | | |
|---|
| 495 | | $post_status_q = ''; |
|---|
| 496 | | $post_status_label = _c('Posts|manage posts header'); |
|---|
| 497 | | if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) { |
|---|
| 498 | | $post_status_label = $post_stati[$q['post_status']][1]; |
|---|
| 499 | | $post_status_q = '&post_status=' . $q['post_status']; |
|---|
| 500 | | } |
|---|
| 501 | | |
|---|
| 502 | | if ( 'pending' === $q['post_status'] ) { |
|---|
| 503 | | $order = 'ASC'; |
|---|
| 504 | | $orderby = 'modified'; |
|---|
| 505 | | } elseif ( 'draft' === $q['post_status'] ) { |
|---|
| 506 | | $order = 'DESC'; |
|---|
| 507 | | $orderby = 'modified'; |
|---|
| 508 | | } else { |
|---|
| 509 | | $order = 'DESC'; |
|---|
| 510 | | $orderby = 'date'; |
|---|
| 511 | | } |
|---|
| 512 | | |
|---|
| 513 | | wp("what_to_show=posts$post_status_q&posts_per_page=20&order=$order&orderby=$orderby"); |
|---|
| 514 | | |
|---|
| 515 | | return array($post_stati, $avail_post_stati); |
|---|
| 516 | | } |
|---|
| 517 | | |
|---|