Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_ajax_delete_comment [ WordPress Function ]

wp_ajax_delete_comment ( No parameters )
Defined at:



No description yet.

Source


<?php
function wp_ajax_delete_comment() {
    
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;

    if ( !
$comment get_comment$id ) )
        
wp_dietime() );
    if ( ! 
current_user_can'edit_comment'$comment->comment_ID ) )
        
wp_die( -);

    
check_ajax_referer"delete-comment_$id);
    
$status wp_get_comment_status$comment->comment_ID );

    
$delta = -1;
    if ( isset(
$_POST['trash']) && == $_POST['trash'] ) {
        if ( 
'trash' == $status )
            
wp_dietime() );
        
$r wp_trash_comment$comment->comment_ID );
    } elseif ( isset(
$_POST['untrash']) && == $_POST['untrash'] ) {
        if ( 
'trash' != $status )
            
wp_dietime() );
        
$r wp_untrash_comment$comment->comment_ID );
        if ( ! isset( 
$_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' // undo trash, not in trash
            
$delta 1;
    } elseif ( isset(
$_POST['spam']) && == $_POST['spam'] ) {
        if ( 
'spam' == $status )
            
wp_dietime() );
        
$r wp_spam_comment$comment->comment_ID );
    } elseif ( isset(
$_POST['unspam']) && == $_POST['unspam'] ) {
        if ( 
'spam' != $status )
            
wp_dietime() );
        
$r wp_unspam_comment$comment->comment_ID );
        if ( ! isset( 
$_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' // undo spam, not in spam
            
$delta 1;
    } elseif ( isset(
$_POST['delete']) && == $_POST['delete'] ) {
        
$r wp_delete_comment$comment->comment_ID );
    } else {
        
wp_die( -);
    }

    if ( 
$r // Decide if we need to send back '1' or a more complicated response including page links and comment counts
        
_wp_ajax_delete_comment_response$comment->comment_ID$delta );
    
wp_die);
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics