From decf135295b7ab998a6978c45370fd476cfdeb86 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 21 Jan 2010 06:53:33 +0000 Subject: [PATCH] Update trash and right now links for pages. fixes #11958 git-svn-id: http://svn.automattic.com/wordpress/trunk@12783 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-header.php | 2 +- wp-admin/edit.php | 6 ++--- wp-admin/includes/dashboard.php | 4 ++-- wp-admin/includes/template.php | 5 +++-- wp-includes/link-template.php | 40 ++++++++++----------------------- wp-includes/post.php | 2 ++ 6 files changed, 23 insertions(+), 36 deletions(-) diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 652b33b4d6..d6f73bea8d 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -40,7 +40,7 @@ var ajaxurl = '', pagenow = ' ' . __('Undo') . '
'; + echo ' ' . __('Undo') . '
'; unset($_GET['trashed']); } diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index b05172c21a..74f6d9ec9f 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -252,8 +252,8 @@ function wp_dashboard_right_now() { $num = number_format_i18n( $num_pages->publish ); $text = _n( 'Page', 'Pages', $num_pages->publish ); if ( current_user_can( 'edit_pages' ) ) { - $num = "$num"; - $text = "$text"; + $num = "$num"; + $text = "$text"; } echo '' . $num . ''; echo '' . $text . ''; diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index f13a994705..fbc63fe38a 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1605,6 +1605,7 @@ function display_page_row( $page, $level = 0 ) { $posts_columns = get_column_headers( $current_screen ); $hidden = get_hidden_columns( $current_screen ); $title = _draft_or_post_title(); + $post_type = $page->post_type; ?> $column_display_name) { } if ( current_user_can('delete_page', $page->ID) ) { if ( $post->post_status == 'trash' ) - $actions['untrash'] = "ID) . "'>" . __('Restore') . ""; + $actions['untrash'] = "ID) . "'>" . __('Restore') . ""; elseif ( EMPTY_TRASH_DAYS ) $actions['trash'] = "" . __('Trash') . ""; if ( $post->post_status == 'trash' || !EMPTY_TRASH_DAYS ) - $actions['delete'] = "ID) . "'>" . __('Delete Permanently') . ""; + $actions['delete'] = "ID) . "'>" . __('Delete Permanently') . ""; } if ( in_array($post->post_status, array('pending', 'draft')) ) { if ( current_user_can('edit_page', $page->ID) ) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 9fd303da44..923a9728e4 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -737,35 +737,19 @@ function get_delete_post_link($id = 0, $context = 'display') { else $action = 'action=trash&'; - switch ( $post->post_type ) : - case 'page' : - if ( !current_user_can( 'delete_page', $post->ID ) ) - return; - $file = 'page'; - $var = 'post'; - break; - case 'attachment' : - if ( !current_user_can( 'delete_post', $post->ID ) ) - return; - $file = 'media'; - $var = 'attachment_id'; - break; - case 'revision' : - if ( !current_user_can( 'delete_post', $post->ID ) ) - return; - $file = 'revision'; - $var = 'revision'; - $action = ''; - break; - default : - if ( !current_user_can( 'edit_post', $post->ID ) ) - return apply_filters( 'get_delete_post_link', '', $post->ID, $context ); - $file = 'post'; - $var = 'post'; - break; - endswitch; + if ( 'display' == $context ) + $action = '&action=trash'; + else + $action = '&action=trash'; - return apply_filters( 'get_delete_post_link', wp_nonce_url( admin_url("$file.php?{$action}$var=$post->ID"), "trash-{$file}_" . $post->ID ), $context ); + $post_type_object = get_post_type_object( $post->post_type ); + if ( !$post_type_object ) + return; + + if ( !current_user_can( $post_type_object->delete_cap, $post->ID ) ) + return; + + return apply_filters( 'get_delete_post_link', wp_nonce_url( admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), "trash-{$post->post_type}_" . $post->ID), $post->ID, $context ); } /** diff --git a/wp-includes/post.php b/wp-includes/post.php index c168f36c73..73d5fbedae 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -720,9 +720,11 @@ function register_post_type($post_type, $args = array()) { if ( empty($args->capability_type) ) { $args->edit_cap = ''; $args->read_cap = ''; + $args->delete_cap = ''; } else { $args->edit_cap = 'edit_' . $args->capability_type; $args->read_cap = 'read_' . $args->capability_type; + $args->delete_cap = 'delete_' . $args->capability_type; } if ( !$args->_builtin && $args->public )