Ticket #9582: edit_posts_links.patch
| File edit_posts_links.patch, 10.4 KB (added by , 17 years ago) |
|---|
-
home/cristi/svn/wp/wp-admin/includes/post.php
789 789 $q = $_GET; 790 790 $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; 791 791 $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; 792 $post_stat i= array( // array( adj, noun )793 'publish' => array(_x('Published', 'post'), __('Published posts'), _n_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>')),794 'future' => array(_x('Scheduled', 'post'), __('Scheduled posts'), _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>')),795 'pending' => array(_x('Pending Review', 'post'), __('Pending posts'), _n_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>')),796 'draft' => array(_x('Draft', 'post'), _x('Drafts', 'manage posts header'), _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')),797 'private' => array(_x('Private', 'post'), __('Private posts'), _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>')),798 );792 $post_statuses = array( // array( adj, noun ) 793 'publish' => array(_x('Published', 'post'), __('Published posts')), 794 'future' => array(_x('Scheduled', 'post'), __('Scheduled posts')), 795 'pending' => array(_x('Pending Review', 'post'), __('Pending posts')), 796 'draft' => array(_x('Draft', 'post'), _x('Drafts', 'manage posts header')), 797 'private' => array(_x('Private', 'post'), __('Private posts')), 798 ); 799 799 800 $post_stat i = apply_filters('post_stati', $post_stati);800 $post_statuses = apply_filters('post_statuses', $post_statuses); 801 801 802 $avail_post_stat i= get_available_post_statuses('post');802 $avail_post_statuses = get_available_post_statuses('post'); 803 803 804 804 $post_status_q = ''; 805 if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stat i) ) ) {805 if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_statuses) ) ) { 806 806 $post_status_q = '&post_status=' . $q['post_status']; 807 807 $post_status_q .= '&perm=readable'; 808 808 } … … 825 825 826 826 wp("post_type=post&what_to_show=posts$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby"); 827 827 828 return array($post_stat i, $avail_post_stati);828 return array($post_statuses, $avail_post_statuses); 829 829 } 830 830 831 831 /** -
home/cristi/svn/wp/wp-admin/includes/template.php
3715 3715 <?php 3716 3716 } 3717 3717 3718 /** 3719 * Generates filter links for various admin pages. 3720 * 3721 * @since 2.8.0 3722 */ 3723 function wp_filter_links($links) { 3724 $tmp = array(); 3725 3726 foreach ( $links as $link => $link_format ) { 3727 $class = $link_format['cond'] ? 'class="current"' : ''; 3728 3729 if ( isset($link_format['count']) ) 3730 $count = sprintf(" <span class='count'>(%s)</span>", number_format_i18n($link_format['count']) ); 3731 else 3732 $count = ''; 3733 3734 $tmp[] = sprintf("<li><a href='$link' $class>%s</a>", $link_format['title'] . $count ); 3735 } 3736 3737 return implode( " |</li>\n", $tmp ) . '</li>'; 3738 } 3739 3718 3740 ?> -
home/cristi/svn/wp/wp-admin/edit.php
82 82 $parent_file = 'edit.php'; 83 83 wp_enqueue_script('inline-edit-post'); 84 84 85 list($post_stati, $avail_post_stati) = wp_edit_posts_query();86 87 85 require_once('admin-header.php'); 88 86 89 87 if ( !isset( $_GET['paged'] ) ) … … 137 135 <ul class="subsubsub"> 138 136 <?php 139 137 if ( empty($locked_post_status) ) : 140 $ status_links = array();138 $edit_posts_links = array(); 141 139 $num_posts = wp_count_posts( 'post', 'readable' ); 142 $total_posts = array_sum( (array) $num_posts ); 143 $class = empty( $_GET['post_status'] ) ? ' class="current"' : ''; 144 $status_links[] = "<li><a href='edit.php' $class>" . sprintf( _n( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts ), number_format_i18n( $total_posts ) ) . '</a>'; 140 $edit_posts_links['edit.php'] = array( 141 'title' => __( 'All' ), 142 'count' => array_sum( (array) $num_posts ), 143 'cond' => ( count( $_GET ) <= 1 ) 144 ); 145 145 146 global $user_ID, $wpdb; 147 $my_posts_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_author = $user_ID"); 148 $edit_posts_links["edit.php?author=$user_ID"] = array( 149 'title' => __('My posts'), 150 'count' => $my_posts_count, 151 'cond' => ( isset($_GET['author']) && $user_ID == $_GET['author'] ) 152 ); 146 153 147 foreach ( $post_stati as $status => $label ) { 148 $class = ''; 154 list($post_statuses, $avail_post_statuses) = wp_edit_posts_query(); 149 155 150 if ( !in_array( $status, $avail_post_stati ) ) 156 foreach ( $post_statuses as $status => $label ) { 157 if ( !in_array( $status, $avail_post_statuses ) ) 151 158 continue; 152 159 153 160 if ( empty( $num_posts->$status ) ) 154 161 continue; 155 if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )156 $class = ' class="current"';157 162 158 $status_links[] = "<li><a href='edit.php?post_status=$status' $class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>'; 163 $edit_posts_links["edit.php?post_status=$status"] = array( 164 'title' => $label[0], 165 'count' => $num_posts->$status, 166 'cond' => ( isset($_GET['post_status']) && $status == $_GET['post_status'] ) 167 ); 159 168 } 160 echo implode( " |</li>\n", $status_links ) . '</li>'; 161 unset( $status_links ); 169 170 $edit_posts_links = apply_filters('edit_posts_links', $edit_posts_links); 171 172 echo wp_filter_links($edit_posts_links); 173 162 174 endif; 163 175 ?> 164 176 </ul> -
home/cristi/svn/wp/wp-admin/edit-pages.php
74 74 $parent_file = 'edit-pages.php'; 75 75 wp_enqueue_script('inline-edit-post'); 76 76 77 $post_stat i= array( // array( adj, noun )78 'publish' => array(_x('Published', 'page'), __('Published pages'), _nx_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>', 'page')),79 'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')),80 'pending' => array(_x('Pending Review', 'page'), __('Pending pages'), _nx_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>', 'page')),81 'draft' => array(_x('Draft', 'page'), _x('Drafts', 'manage posts header'), _nx_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'page')),82 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page'))83 );77 $post_statuses = array( // array( adj, noun ) 78 'publish' => array(_x('Published', 'page'), __('Published pages')), 79 'future' => array(_x('Scheduled', 'page'), __('Scheduled pages')), 80 'pending' => array(_x('Pending Review', 'page'), __('Pending pages')), 81 'draft' => array(_x('Draft', 'page'), _x('Drafts', 'manage posts header')), 82 'private' => array(_x('Private', 'page'), __('Private pages')) 83 ); 84 84 85 $post_statuses = apply_filters('page_statuses', $post_statuses); 86 85 87 $query = array('post_type' => 'page', 'orderby' => 'menu_order title', 'what_to_show' => 'posts', 86 88 'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc'); 87 89 88 90 $post_status_label = __('Pages'); 89 if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stat i) ) ) {90 $post_status_label = $post_stat i[$_GET['post_status']][1];91 if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_statuses) ) ) { 92 $post_status_label = $post_statuses[$_GET['post_status']][1]; 91 93 $query['post_status'] = $_GET['post_status']; 92 94 $query['perm'] = 'readable'; 93 95 } … … 141 143 endif; ?> 142 144 143 145 <form id="posts-filter" action="" method="get"> 146 144 147 <ul class="subsubsub"> 145 148 <?php 146 147 $avail_post_stati = get_available_post_statuses('page');148 149 if ( empty($locked_post_status) ) : 149 $ status_links = array();150 $num_posts = wp_count_posts( 'page', 'readable');151 $ total_posts = array_sum( (array) $num_posts );152 $class = empty($_GET['post_status']) ? ' class="current"' : ''; 153 $status_links[] = "<li><a href='edit-pages.php'$class>" . sprintf( _n( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts ), number_format_i18n( $total_posts ) ) . '</a>'; 154 foreach ( $post_stati as $status => $label ) { 155 $class = '';150 $edit_posts_links = array(); 151 $num_posts = wp_count_posts( 'page', 'readable' ); 152 $edit_posts_links['edit-pages.php'] = array( 153 'title' => __( 'All' ), 154 'count' => array_sum( (array) $num_posts ), 155 'cond' => ( count( $_GET ) == 0 ) 156 ); 156 157 157 if ( !in_array($status, $avail_post_stati) ) 158 global $user_ID, $wpdb; 159 $my_posts_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'page' AND post_author = $user_ID"); 160 $edit_posts_links["edit-pages.php?author=$user_ID"] = array( 161 'title' => __('My pages'), 162 'count' => $my_posts_count, 163 'cond' => ( isset($_GET['author']) && $user_ID == $_GET['author'] ) 164 ); 165 166 $avail_post_statuses = get_available_post_statuses('page'); 167 168 foreach ( $post_statuses as $status => $label ) { 169 if ( !in_array( $status, $avail_post_statuses ) ) 158 170 continue; 159 171 160 if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'])161 $class = ' class="current"';172 if ( empty( $num_posts->$status ) ) 173 continue; 162 174 163 $status_links[] = "<li><a href='edit-pages.php?post_status=$status'$class>" . sprintf( _nx( $label[2][0], $label[2][1], $num_posts->$status, $label[2][2] ), number_format_i18n( $num_posts->$status ) ) . '</a>'; 175 $edit_posts_links["edit-pages.php?post_status=$status"] = array( 176 'title' => $label[0], 177 'count' => $num_posts->$status, 178 'cond' => ( isset($_GET['post_status']) && $status == $_GET['post_status'] ) 179 ); 164 180 } 165 echo implode( " |</li>\n", $status_links ) . '</li>'; 166 unset($status_links); 181 182 $edit_posts_links = apply_filters('edit_posts_links', $edit_posts_links); 183 184 echo wp_filter_links($edit_posts_links); 185 167 186 endif; 168 187 ?> 169 188 </ul>