Make WordPress Core


Ignore:
Timestamp:
01/15/2010 04:58:36 PM (15 years ago)
Author:
ryan
Message:

Merge edit-pages.php into edit.php. see #9674

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit.php

    r12719 r12728  
    2121}
    2222
    23 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) )
     23if ( 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 ) ) ) ) )
    2424    $post_type = $_GET['post_type'];
    2525else
     
    2828
    2929$post_type_object = get_post_type_object($post_type);
     30$post_type_cap = $post_type_object->capability_type;
    3031
    3132if ( 'post' != $post_type ) {
     
    3839    $post_new_file = 'post-new.php';
    3940}
     41
     42$pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;
     43if ( empty($pagenum) )
     44    $pagenum = 1;
     45$per_page = 'edit_' . $post_type . '_per_page';
     46$per_page = (int) get_user_option( $per_page );
     47if ( 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 );
    4051
    4152// Handle bulk actions
     
    6273            $trashed = 0;
    6374            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 post to 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.') );
    6677
    6778                if ( !wp_trash_post($post_id) )
     
    7586            $untrashed = 0;
    7687            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 post from 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.') );
    7990
    8091                if ( !wp_untrash_post($post_id) )
     
    90101                $post_del = & get_post($post_id);
    91102
    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.') );
    94105
    95106                if ( $post_del->post_type == 'attachment' ) {
     
    131142
    132143$user_posts = false;
    133 if ( !current_user_can('edit_others_posts') ) {
     144if ( !current_user_can('edit_others_' . $post_type_cap . 's') ) {
    134145    $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) );
    135146    $user_posts = true;
     
    140151$avail_post_stati = wp_edit_posts_query();
    141152
     153if ( $post_type_object->hierarchical )
     154    $num_pages = ceil($wp_query->post_count / $per_page);
     155else
     156    $num_pages = $wp_query->max_num_pages;
     157
    142158require_once('admin-header.php');
    143 
    144 if ( !isset( $_GET['paged'] ) )
    145     $_GET['paged'] = 1;
    146159
    147160if ( empty($_GET['mode']) )
     
    159172<?php
    160173if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
    161 <div id="message" class="updated"><p><strong><?php _e('Your post 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>
     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>
    162175<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
    163176endif; ?>
     
    174187
    175188if ( 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'] ) );
    177190    unset($_GET['locked']);
    178191}
    179192
    180193if ( 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'] ) );
    182195    unset($_GET['deleted']);
    183196}
    184197
    185198if ( 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'] ) );
    187200    $ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
    188201    echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />';
     
    191204
    192205if ( 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'] ) );
    194207    unset($_GET['undeleted']);
    195208}
     
    213226    if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user->ID ) )
    214227        $class = ' class="current"';
    215     $status_links[] = "<li><a href='edit.php?author=$current_user->ID'$class>" . sprintf( _nx( 'My 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>';
    216229    $allposts = '?all_posts=1';
    217230}
     
    262275    'prev_text' => __('&laquo;'),
    263276    'next_text' => __('&raquo;'),
    264     'total' => $wp_query->max_num_pages,
    265     'current' => $_GET['paged']
     277    'total' => $num_pages,
     278    'current' => $pagenum
    266279));
    267280
     
    319332
    320333<?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');
     334if ( 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}
    325340?>
    326341<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
    327342<?php }
    328343
    329 if ( $is_trash && current_user_can('edit_others_posts') ) { ?>
     344if ( $is_trash && current_user_can('edit_others_' . $post_type_cap .'s') ) { ?>
    330345<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    331346<?php } ?>
     
    334349<?php if ( $page_links ) { ?>
    335350<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%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 ) ),
    338353    number_format_i18n( $wp_query->found_posts ),
    339354    $page_links
     
    374389</select>
    375390<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') ) { ?>
    377392<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    378393<?php } ?>
     
    394409</form>
    395410
    396 <?php inline_edit_row( 'post' ); ?>
     411<?php inline_edit_row( $current_screen ); ?>
    397412
    398413<div id="ajax-response"></div>
Note: See TracChangeset for help on using the changeset viewer.