X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/41578db67d72562346e4dbb2a14889b23d522813..refs/tags/wordpress-4.4:/wp-admin/edit.php?ds=sidebyside diff --git a/wp-admin/edit.php b/wp-admin/edit.php index a062b091..62c70e2b 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -12,14 +12,35 @@ require_once( dirname( __FILE__ ) . '/admin.php' ); if ( ! $typenow ) wp_die( __( 'Invalid post type' ) ); +if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ) ) ) { + wp_die( __( 'You are not allowed to edit posts in this post type.' ) ); +} + +if ( 'attachment' === $typenow ) { + if ( wp_redirect( admin_url( 'upload.php' ) ) ) { + exit; + } +} + +/** + * @global string $post_type + * @global object $post_type_object + */ +global $post_type, $post_type_object; + $post_type = $typenow; $post_type_object = get_post_type_object( $post_type ); if ( ! $post_type_object ) wp_die( __( 'Invalid post type' ) ); -if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) - wp_die( __( 'Cheatin’ uh?' ) ); +if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) { + wp_die( + '

' . __( 'Cheatin’ uh?' ) . '

' . + '

' . __( 'You are not allowed to edit posts in this post type.' ) . '

', + 403 + ); +} $wp_list_table = _get_list_table('WP_Posts_List_Table'); $pagenum = $wp_list_table->get_pagenum(); @@ -56,9 +77,12 @@ if ( $doaction ) { $sendback = admin_url($post_new_file); if ( 'delete_all' == $doaction ) { + // Prepare for deletion of all posts with a specified post status (i.e. Empty trash). $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']); - if ( get_post_status_object($post_status) ) // Check the post status exists first + // Validate the post status exists. + if ( get_post_status_object( $post_status ) ) { $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) ); + } $doaction = 'delete'; } elseif ( isset( $_REQUEST['media'] ) ) { $post_ids = $_REQUEST['media']; @@ -77,7 +101,7 @@ if ( $doaction ) { case 'trash': $trashed = $locked = 0; - foreach( (array) $post_ids as $post_id ) { + foreach ( (array) $post_ids as $post_id ) { if ( !current_user_can( 'delete_post', $post_id) ) wp_die( __('You are not allowed to move this item to the Trash.') ); @@ -96,7 +120,7 @@ if ( $doaction ) { break; case 'untrash': $untrashed = 0; - foreach( (array) $post_ids as $post_id ) { + foreach ( (array) $post_ids as $post_id ) { if ( !current_user_can( 'delete_post', $post_id) ) wp_die( __('You are not allowed to restore this item from the Trash.') ); @@ -109,7 +133,7 @@ if ( $doaction ) { break; case 'delete': $deleted = 0; - foreach( (array) $post_ids as $post_id ) { + foreach ( (array) $post_ids as $post_id ) { $post_del = get_post($post_id); if ( !current_user_can( 'delete_post', $post_id ) ) @@ -152,6 +176,7 @@ if ( $doaction ) { $wp_list_table->prepare_items(); wp_enqueue_script('inline-edit-post'); +wp_enqueue_script('heartbeat'); $title = $post_type_object->labels->name; @@ -170,7 +195,7 @@ if ( 'post' == $post_type ) { '' ) ); @@ -196,7 +221,7 @@ if ( 'post' == $post_type ) { get_current_screen()->set_help_sidebar( '

' . __('For more information:') . '

' . - '

' . __('Documentation on Managing Posts') . '

' . + '

' . __('Documentation on Managing Posts') . '

' . '

' . __('Support Forums') . '

' ); @@ -217,12 +242,19 @@ if ( 'post' == $post_type ) { get_current_screen()->set_help_sidebar( '

' . __('For more information:') . '

' . - '

' . __('Documentation on Managing Pages') . '

' . + '

' . __('Documentation on Managing Pages') . '

' . '

' . __('Support Forums') . '

' ); + } -add_screen_option( 'per_page', array( 'label' => $title, 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) ); +get_current_screen()->set_screen_reader_content( array( + 'heading_views' => $post_type_object->labels->filter_items_list, + 'heading_pagination' => $post_type_object->labels->items_list_navigation, + 'heading_list' => $post_type_object->labels->items_list, +) ); + +add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) ); $bulk_counts = array( 'updated' => isset( $_REQUEST['updated'] ) ? absint( $_REQUEST['updated'] ) : 0, @@ -235,14 +267,16 @@ $bulk_counts = array( $bulk_messages = array(); $bulk_messages['post'] = array( 'updated' => _n( '%s post updated.', '%s posts updated.', $bulk_counts['updated'] ), - 'locked' => _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $bulk_counts['locked'] ), + 'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 post not updated, somebody is editing it.' ) : + _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $bulk_counts['locked'] ), 'deleted' => _n( '%s post permanently deleted.', '%s posts permanently deleted.', $bulk_counts['deleted'] ), 'trashed' => _n( '%s post moved to the Trash.', '%s posts moved to the Trash.', $bulk_counts['trashed'] ), 'untrashed' => _n( '%s post restored from the Trash.', '%s posts restored from the Trash.', $bulk_counts['untrashed'] ), ); $bulk_messages['page'] = array( 'updated' => _n( '%s page updated.', '%s pages updated.', $bulk_counts['updated'] ), - 'locked' => _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $bulk_counts['locked'] ), + 'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 page not updated, somebody is editing it.' ) : + _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $bulk_counts['locked'] ), 'deleted' => _n( '%s page permanently deleted.', '%s pages permanently deleted.', $bulk_counts['deleted'] ), 'trashed' => _n( '%s page moved to the Trash.', '%s pages moved to the Trash.', $bulk_counts['trashed'] ), 'untrashed' => _n( '%s page restored from the Trash.', '%s pages restored from the Trash.', $bulk_counts['untrashed'] ), @@ -265,13 +299,13 @@ $bulk_counts = array_filter( $bulk_counts ); require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?>
-

labels->name ); if ( current_user_can( $post_type_object->cap->create_posts ) ) - echo ' ' . esc_html( $post_type_object->labels->add_new ) . ''; + echo ' ' . esc_html( $post_type_object->labels->add_new ) . ''; if ( ! empty( $_REQUEST['s'] ) ) printf( ' ' . __('Search results for “%s”') . '', get_search_query() ); -?>

+?> $count ) { } if ( $messages ) - echo '

' . join( ' ', $messages ) . '

'; + echo '

' . join( ' ', $messages ) . '

'; unset( $messages ); $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] ); @@ -297,7 +331,7 @@ $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated views(); ?> -
+ search_box( $post_type_object->labels->search_items, 'post' ); ?>