wp_untrash_comment example

$spammed++;
                break;
            case 'unspam':
                wp_unspam_comment( $comment_id );
                $unspammed++;
                break;
            case 'trash':
                wp_trash_comment( $comment_id );
                $trashed++;
                break;
            case 'untrash':
                wp_untrash_comment( $comment_id );
                $untrashed++;
                break;
            case 'delete':
                wp_delete_comment( $comment_id );
                $deleted++;
                break;
        }
    }

    if ( ! in_array( $doaction, array( 'approve', 'unapprove', 'spam', 'unspam', 'trash', 'delete' ), true ) ) {
        $screen = get_current_screen()->id;

        
case 'trashcomment':
                wp_trash_comment( $comment );
                $redir = add_query_arg(
                    array(
                        'trashed' => '1',
                        'ids'     => $comment_id,
                    ),
                    $redir
                );
                break;
            case 'untrashcomment':
                wp_untrash_comment( $comment );
                $redir = add_query_arg( array( 'untrashed' => '1' )$redir );
                break;
            case 'spamcomment':
                wp_spam_comment( $comment );
                $redir = add_query_arg(
                    array(
                        'spammed' => '1',
                        'ids'     => $comment_id,
                    ),
                    $redir
                );
                
break;
            case 'spam':
                $changed = wp_spam_comment( $comment_id );
                break;
            case 'unspam':
                $changed = wp_unspam_comment( $comment_id );
                break;
            case 'trash':
                $changed = wp_trash_comment( $comment_id );
                break;
            case 'untrash':
                $changed = wp_untrash_comment( $comment_id );
                break;
            default:
                $changed = false;
                break;
        }

        return $changed;
    }

    /** * Checks if the post can be read. * * Correctly handles posts with the inherit status. * * @since 4.7.0 * * @param WP_Post $post Post object. * @param WP_REST_Request $request Request data to check. * @return bool Whether post can be read. */
if ( isset( $_POST['trash'] ) && 1 == $_POST['trash'] ) {
        if ( 'trash' === $status ) {
            wp_die( time() );
        }

        $r = wp_trash_comment( $comment );
    } elseif ( isset( $_POST['untrash'] ) && 1 == $_POST['untrash'] ) {
        if ( 'trash' !== $status ) {
            wp_die( time() );
        }

        $r = wp_untrash_comment( $comment );

        // Undo trash, not in Trash.         if ( ! isset( $_POST['comment_status'] ) || 'trash' !== $_POST['comment_status'] ) {
            $delta = 1;
        }
    } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) {
        if ( 'spam' === $status ) {
            wp_die( time() );
        }

        $r = wp_spam_comment( $comment );
    }
Home | Imprint | This part of the site doesn't use cookies.