@@ 667-682 (lines=16) @@ | ||
664 | * |
|
665 | * @since 3.1.0 |
|
666 | */ |
|
667 | function wp_ajax_delete_link() { |
|
668 | $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
669 | ||
670 | check_ajax_referer( "delete-bookmark_$id" ); |
|
671 | if ( !current_user_can( 'manage_links' ) ) |
|
672 | wp_die( -1 ); |
|
673 | ||
674 | $link = get_bookmark( $id ); |
|
675 | if ( !$link || is_wp_error( $link ) ) |
|
676 | wp_die( 1 ); |
|
677 | ||
678 | if ( wp_delete_link( $id ) ) |
|
679 | wp_die( 1 ); |
|
680 | else |
|
681 | wp_die( 0 ); |
|
682 | } |
|
683 | ||
684 | /** |
|
685 | * Ajax handler for deleting meta. |
|
@@ 710-726 (lines=17) @@ | ||
707 | * |
|
708 | * @param string $action Action to perform. |
|
709 | */ |
|
710 | function wp_ajax_delete_post( $action ) { |
|
711 | if ( empty( $action ) ) |
|
712 | $action = 'delete-post'; |
|
713 | $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
714 | ||
715 | check_ajax_referer( "{$action}_$id" ); |
|
716 | if ( !current_user_can( 'delete_post', $id ) ) |
|
717 | wp_die( -1 ); |
|
718 | ||
719 | if ( !get_post( $id ) ) |
|
720 | wp_die( 1 ); |
|
721 | ||
722 | if ( wp_delete_post( $id ) ) |
|
723 | wp_die( 1 ); |
|
724 | else |
|
725 | wp_die( 0 ); |
|
726 | } |
|
727 | ||
728 | /** |
|
729 | * Ajax handler for sending a post to the trash. |
|
@@ 776-792 (lines=17) @@ | ||
773 | * |
|
774 | * @param string $action |
|
775 | */ |
|
776 | function wp_ajax_delete_page( $action ) { |
|
777 | if ( empty( $action ) ) |
|
778 | $action = 'delete-page'; |
|
779 | $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
780 | ||
781 | check_ajax_referer( "{$action}_$id" ); |
|
782 | if ( !current_user_can( 'delete_page', $id ) ) |
|
783 | wp_die( -1 ); |
|
784 | ||
785 | if ( ! get_post( $id ) ) |
|
786 | wp_die( 1 ); |
|
787 | ||
788 | if ( wp_delete_post( $id ) ) |
|
789 | wp_die( 1 ); |
|
790 | else |
|
791 | wp_die( 0 ); |
|
792 | } |
|
793 | ||
794 | /** |
|
795 | * Ajax handler to dim a comment. |