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
This commit is contained in:
ryan 2010-01-21 06:53:33 +00:00
parent 74a86506f6
commit decf135295
6 changed files with 23 additions and 36 deletions

View File

@ -40,7 +40,7 @@ var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php ech
</script> </script>
<?php <?php
if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php') ) ) { if ( in_array( $pagenow, array('post.php', 'post-new.php') ) ) {
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 ); add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
wp_enqueue_script('quicktags'); wp_enqueue_script('quicktags');
} }

View File

@ -65,7 +65,7 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
$post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']); $post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']);
$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2']; $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
} else { } else {
wp_redirect( admin_url('edit.php') ); wp_redirect( admin_url("edit.php?post_type=$post_type") );
} }
switch ( $doaction ) { switch ( $doaction ) {
@ -127,7 +127,7 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
} }
if ( isset($_GET['action']) ) if ( isset($_GET['action']) )
$sendback = remove_query_arg( array('action', 'action2', 'cat', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view', 'post_type'), $sendback ); $sendback = remove_query_arg( array('action', 'action2', 'cat', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
wp_redirect($sendback); wp_redirect($sendback);
exit(); exit();
@ -198,7 +198,7 @@ if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) { if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
printf( _n( 'Item moved to the trash.', '%s items moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) ); printf( _n( 'Item moved to the trash.', '%s items moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
$ids = isset($_GET['ids']) ? $_GET['ids'] : 0; $ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />'; echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />';
unset($_GET['trashed']); unset($_GET['trashed']);
} }

View File

@ -252,8 +252,8 @@ function wp_dashboard_right_now() {
$num = number_format_i18n( $num_pages->publish ); $num = number_format_i18n( $num_pages->publish );
$text = _n( 'Page', 'Pages', $num_pages->publish ); $text = _n( 'Page', 'Pages', $num_pages->publish );
if ( current_user_can( 'edit_pages' ) ) { if ( current_user_can( 'edit_pages' ) ) {
$num = "<a href='edit-pages.php'>$num</a>"; $num = "<a href='edit.php?post_type=page'>$num</a>";
$text = "<a href='edit-pages.php'>$text</a>"; $text = "<a href='edit.php?post_type=page'>$text</a>";
} }
echo '<td class="first b b_pages">' . $num . '</td>'; echo '<td class="first b b_pages">' . $num . '</td>';
echo '<td class="t pages">' . $text . '</td>'; echo '<td class="t pages">' . $text . '</td>';

View File

@ -1605,6 +1605,7 @@ function display_page_row( $page, $level = 0 ) {
$posts_columns = get_column_headers( $current_screen ); $posts_columns = get_column_headers( $current_screen );
$hidden = get_hidden_columns( $current_screen ); $hidden = get_hidden_columns( $current_screen );
$title = _draft_or_post_title(); $title = _draft_or_post_title();
$post_type = $page->post_type;
?> ?>
<tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit"> <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
<?php <?php
@ -1669,11 +1670,11 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
} }
if ( current_user_can('delete_page', $page->ID) ) { if ( current_user_can('delete_page', $page->ID) ) {
if ( $post->post_status == 'trash' ) if ( $post->post_status == 'trash' )
$actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("page.php?action=untrash&amp;post=$page->ID", 'untrash-page_' . $page->ID) . "'>" . __('Restore') . "</a>"; $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&amp;action=untrash&amp;post=$page->ID", 'untrash-page_' . $page->ID) . "'>" . __('Restore') . "</a>";
elseif ( EMPTY_TRASH_DAYS ) elseif ( EMPTY_TRASH_DAYS )
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . get_delete_post_link($page->ID) . "'>" . __('Trash') . "</a>"; $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . get_delete_post_link($page->ID) . "'>" . __('Trash') . "</a>";
if ( $post->post_status == 'trash' || !EMPTY_TRASH_DAYS ) if ( $post->post_status == 'trash' || !EMPTY_TRASH_DAYS )
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("page.php?action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>"; $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&amp;action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>";
} }
if ( in_array($post->post_status, array('pending', 'draft')) ) { if ( in_array($post->post_status, array('pending', 'draft')) ) {
if ( current_user_can('edit_page', $page->ID) ) if ( current_user_can('edit_page', $page->ID) )

View File

@ -737,35 +737,19 @@ function get_delete_post_link($id = 0, $context = 'display') {
else else
$action = 'action=trash&'; $action = 'action=trash&';
switch ( $post->post_type ) : if ( 'display' == $context )
case 'page' : $action = '&amp;action=trash';
if ( !current_user_can( 'delete_page', $post->ID ) ) else
return; $action = '&action=trash';
$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;
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 );
} }
/** /**

View File

@ -720,9 +720,11 @@ function register_post_type($post_type, $args = array()) {
if ( empty($args->capability_type) ) { if ( empty($args->capability_type) ) {
$args->edit_cap = ''; $args->edit_cap = '';
$args->read_cap = ''; $args->read_cap = '';
$args->delete_cap = '';
} else { } else {
$args->edit_cap = 'edit_' . $args->capability_type; $args->edit_cap = 'edit_' . $args->capability_type;
$args->read_cap = 'read_' . $args->capability_type; $args->read_cap = 'read_' . $args->capability_type;
$args->delete_cap = 'delete_' . $args->capability_type;
} }
if ( !$args->_builtin && $args->public ) if ( !$args->_builtin && $args->public )