Changeset 11956 for trunk/wp-includes/link-template.php
- Timestamp:
- 09/21/2009 09:33:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.