Changeset 11956
- Timestamp:
- 09/21/2009 09:33:00 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r11954 r11956 1451 1451 } 1452 1452 if ( current_user_can('delete_post', $post->ID) ) { 1453 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-post_' .$post->ID) . "'>" . __('Trash') . "</a>";1453 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>"; 1454 1454 } 1455 1455 if ( in_array($post->post_status, array('pending', 'draft')) ) { … … 1671 1671 } 1672 1672 if ( current_user_can('delete_page', $page->ID) ) { 1673 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . wp_nonce_url("page.php?action=trash&post=$page->ID", 'trash-page_' .$page->ID) . "'>" . __('Trash') . "</a>";1673 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . get_delete_post_link($page->ID) . "'>" . __('Trash') . "</a>"; 1674 1674 } 1675 1675 if ( in_array($post->post_status, array('pending', 'draft')) ) { -
trunk/wp-includes/link-template.php
r11930 r11956 733 733 734 734 /** 735 * Retrieve delete posts link for post. 736 * 737 * Can be used within the WordPress loop or outside of it. Can be used with 738 * pages, posts, attachments, and revisions. 739 * 740 * @since 2.9.0 741 * 742 * @param int $id Optional. Post ID. 743 * @param string $context Optional, default to display. How to write the '&', defaults to '&'. 744 * @return string 745 */ 746 function get_delete_post_link($id = 0, $context = 'display') { 747 if ( !$post = &get_post( $id ) ) 748 return; 749 750 if ( 'display' == $context ) 751 $action = 'action=trash&'; 752 else 753 $action = 'action=trash&'; 754 755 switch ( $post->post_type ) : 756 case 'page' : 757 if ( !current_user_can( 'delete_page', $post->ID ) ) 758 return; 759 $file = 'page'; 760 $var = 'post'; 761 break; 762 case 'attachment' : 763 if ( !current_user_can( 'delete_post', $post->ID ) ) 764 return; 765 $file = 'media'; 766 $var = 'attachment_id'; 767 break; 768 case 'revision' : 769 if ( !current_user_can( 'delete_post', $post->ID ) ) 770 return; 771 $file = 'revision'; 772 $var = 'revision'; 773 $action = ''; 774 break; 775 default : 776 if ( !current_user_can( 'edit_post', $post->ID ) ) 777 return apply_filters( 'get_delete_post_link', '', $post->ID, $context );; 778 $file = 'post'; 779 $var = 'post'; 780 break; 781 endswitch; 782 783 return apply_filters( 'get_delete_post_link', wp_nonce_url( admin_url("$file.php?{$action}$var=$post->ID"), "trash-{$file}_" . $post->ID ), $context ); 784 } 785 786 /** 735 787 * Retrieve edit comment link. 736 788 *
Note: See TracChangeset
for help on using the changeset viewer.