Code Duplication    Length = 16-17 lines in 3 locations

wp-admin/includes/ajax-actions.php 3 locations

@@ 620-635 (lines=16) @@
617
 *
618
 * @since 3.1.0
619
 */
620
function wp_ajax_delete_link() {
621
	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
622
623
	check_ajax_referer( "delete-bookmark_$id" );
624
	if ( !current_user_can( 'manage_links' ) )
625
		wp_die( -1 );
626
627
	$link = get_bookmark( $id );
628
	if ( !$link || is_wp_error( $link ) )
629
		wp_die( 1 );
630
631
	if ( wp_delete_link( $id ) )
632
		wp_die( 1 );
633
	else
634
		wp_die( 0 );
635
}
636
637
/**
638
 * Ajax handler for deleting meta.
@@ 663-679 (lines=17) @@
660
 *
661
 * @param string $action Action to perform.
662
 */
663
function wp_ajax_delete_post( $action ) {
664
	if ( empty( $action ) )
665
		$action = 'delete-post';
666
	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
667
668
	check_ajax_referer( "{$action}_$id" );
669
	if ( !current_user_can( 'delete_post', $id ) )
670
		wp_die( -1 );
671
672
	if ( !get_post( $id ) )
673
		wp_die( 1 );
674
675
	if ( wp_delete_post( $id ) )
676
		wp_die( 1 );
677
	else
678
		wp_die( 0 );
679
}
680
681
/**
682
 * Ajax handler for sending a post to the trash.
@@ 729-745 (lines=17) @@
726
 *
727
 * @param string $action
728
 */
729
function wp_ajax_delete_page( $action ) {
730
	if ( empty( $action ) )
731
		$action = 'delete-page';
732
	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
733
734
	check_ajax_referer( "{$action}_$id" );
735
	if ( !current_user_can( 'delete_page', $id ) )
736
		wp_die( -1 );
737
738
	if ( ! get_post( $id ) )
739
		wp_die( 1 );
740
741
	if ( wp_delete_post( $id ) )
742
		wp_die( 1 );
743
	else
744
		wp_die( 0 );
745
}
746
747
/**
748
 * Ajax handler to dim a comment.