Changeset 12728 for trunk/wp-admin/edit.php
- Timestamp:
- 01/15/2010 04:58:36 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit.php
r12719 r12728 21 21 } 22 22 23 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) )23 if ( isset($_GET['post_type']) && ( in_array( $_GET['post_type'], get_post_types( array('_show' => true ) ) ) || in_array( $_GET['post_type'], get_post_types( array('_builtin' => true ) ) ) ) ) 24 24 $post_type = $_GET['post_type']; 25 25 else … … 28 28 29 29 $post_type_object = get_post_type_object($post_type); 30 $post_type_cap = $post_type_object->capability_type; 30 31 31 32 if ( 'post' != $post_type ) { … … 38 39 $post_new_file = 'post-new.php'; 39 40 } 41 42 $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0; 43 if ( empty($pagenum) ) 44 $pagenum = 1; 45 $per_page = 'edit_' . $post_type . '_per_page'; 46 $per_page = (int) get_user_option( $per_page ); 47 if ( empty( $per_page ) || $per_page < 1 ) 48 $per_page = 15; 49 // @todo filter based on type 50 $per_page = apply_filters( 'edit_posts_per_page', $per_page ); 40 51 41 52 // Handle bulk actions … … 62 73 $trashed = 0; 63 74 foreach( (array) $post_ids as $post_id ) { 64 if ( !current_user_can('delete_ post', $post_id) )65 wp_die( __('You are not allowed to move this postto the trash.') );75 if ( !current_user_can('delete_' . $post_type_cap, $post_id) ) 76 wp_die( __('You are not allowed to move this item to the trash.') ); 66 77 67 78 if ( !wp_trash_post($post_id) ) … … 75 86 $untrashed = 0; 76 87 foreach( (array) $post_ids as $post_id ) { 77 if ( !current_user_can('delete_ post', $post_id) )78 wp_die( __('You are not allowed to restore this postfrom the trash.') );88 if ( !current_user_can('delete_' . $post_type_cap, $post_id) ) 89 wp_die( __('You are not allowed to restore this item from the trash.') ); 79 90 80 91 if ( !wp_untrash_post($post_id) ) … … 90 101 $post_del = & get_post($post_id); 91 102 92 if ( !current_user_can('delete_ post', $post_id) )93 wp_die( __('You are not allowed to delete this post.') );103 if ( !current_user_can('delete_' . $post_type_cap, $post_id) ) 104 wp_die( __('You are not allowed to delete this item.') ); 94 105 95 106 if ( $post_del->post_type == 'attachment' ) { … … 131 142 132 143 $user_posts = false; 133 if ( !current_user_can('edit_others_ posts') ) {144 if ( !current_user_can('edit_others_' . $post_type_cap . 's') ) { 134 145 $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status != 'trash' AND post_author = %d", $post_type, $current_user->ID) ); 135 146 $user_posts = true; … … 140 151 $avail_post_stati = wp_edit_posts_query(); 141 152 153 if ( $post_type_object->hierarchical ) 154 $num_pages = ceil($wp_query->post_count / $per_page); 155 else 156 $num_pages = $wp_query->max_num_pages; 157 142 158 require_once('admin-header.php'); 143 144 if ( !isset( $_GET['paged'] ) )145 $_GET['paged'] = 1;146 159 147 160 if ( empty($_GET['mode']) ) … … 159 172 <?php 160 173 if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> 161 <div id="message" class="updated"><p><strong><?php _e(' Your posthas been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div>174 <div id="message" class="updated"><p><strong><?php _e('This has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div> 162 175 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); 163 176 endif; ?> … … 174 187 175 188 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) { 176 printf( _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );189 printf( _n( '%s item not updated, somebody is editing it.', '%s items not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) ); 177 190 unset($_GET['locked']); 178 191 } 179 192 180 193 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) { 181 printf( _n( ' Post permanently deleted.', '%s posts permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );194 printf( _n( 'Item permanently deleted.', '%s items permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ); 182 195 unset($_GET['deleted']); 183 196 } 184 197 185 198 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) { 186 printf( _n( ' Post moved to the trash.', '%s posts moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );199 printf( _n( 'Item moved to the trash.', '%s items moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) ); 187 200 $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; 188 201 echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />'; … … 191 204 192 205 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) { 193 printf( _n( ' Post restored from the trash.', '%s posts restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );206 printf( _n( 'Item restored from the trash.', '%s items restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); 194 207 unset($_GET['undeleted']); 195 208 } … … 213 226 if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user->ID ) ) 214 227 $class = ' class="current"'; 215 $status_links[] = "<li><a href='edit.php?author=$current_user->ID'$class>" . sprintf( _nx( 'M y Posts <span class="count">(%s)</span>', 'My Posts<span class="count">(%s)</span>', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . '</a>';228 $status_links[] = "<li><a href='edit.php?author=$current_user->ID'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . '</a>'; 216 229 $allposts = '?all_posts=1'; 217 230 } … … 262 275 'prev_text' => __('«'), 263 276 'next_text' => __('»'), 264 'total' => $ wp_query->max_num_pages,265 'current' => $ _GET['paged']277 'total' => $num_pages, 278 'current' => $pagenum 266 279 )); 267 280 … … 319 332 320 333 <?php 321 $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1, 322 'show_count' => 0, 'orderby' => 'name', 'selected' => $cat); 323 wp_dropdown_categories($dropdown_options); 324 do_action('restrict_manage_posts'); 334 if ( is_object_in_taxonomy($post_type, 'category') ) { 335 $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1, 336 'show_count' => 0, 'orderby' => 'name', 'selected' => $cat); 337 wp_dropdown_categories($dropdown_options); 338 do_action('restrict_manage_posts'); 339 } 325 340 ?> 326 341 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" /> 327 342 <?php } 328 343 329 if ( $is_trash && current_user_can('edit_others_ posts') ) { ?>344 if ( $is_trash && current_user_can('edit_others_' . $post_type_cap .'s') ) { ?> 330 345 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 331 346 <?php } ?> … … 334 349 <?php if ( $page_links ) { ?> 335 350 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 336 number_format_i18n( ( $ _GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page']+ 1 ),337 number_format_i18n( min( $ _GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),351 number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), 352 number_format_i18n( min( $pagenum * $per_page, $wp_query->found_posts ) ), 338 353 number_format_i18n( $wp_query->found_posts ), 339 354 $page_links … … 374 389 </select> 375 390 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 376 <?php if ( $is_trash && current_user_can('edit_others_ posts') ) { ?>391 <?php if ( $is_trash && current_user_can('edit_others_' . $post_type_cap . 's') ) { ?> 377 392 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 378 393 <?php } ?> … … 394 409 </form> 395 410 396 <?php inline_edit_row( 'post'); ?>411 <?php inline_edit_row( $current_screen ); ?> 397 412 398 413 <div id="ajax-response"></div>
Note: See TracChangeset
for help on using the changeset viewer.