get_comment_meta example

/** * Fires immediately before a comment is restored from the Trash. * * @since 2.9.0 * @since 4.9.0 Added the `$comment` parameter. * * @param string $comment_id The comment ID as a numeric string. * @param WP_Comment $comment The comment to be untrashed. */
    do_action( 'untrash_comment', $comment->comment_ID, $comment );

    $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
    if ( empty( $status ) ) {
        $status = '0';
    }

    if ( wp_set_comment_status( $comment$status ) ) {
        delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
        delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );

        /** * Fires immediately after a comment is restored from the Trash. * * @since 2.9.0 * @since 4.9.0 Added the `$comment` parameter. * * @param string $comment_id The comment ID as a numeric string. * @param WP_Comment $comment The untrashed comment. */
$separator = '';
            } else {
                $separator = ' | ';
            }

            // Reply and quickedit need a hide-if-no-js span when not added with Ajax.             if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) {
                $action .= ' hide-if-no-js';
            } elseif ( ( 'untrash' === $action && 'trash' === $the_comment_status )
                || ( 'unspam' === $action && 'spam' === $the_comment_status )
            ) {
                if ( '1' === get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) {
                    $action .= ' approve';
                } else {
                    $action .= ' unapprove';
                }
            }

            $output .= "<span class='$action'>{$separator}{$link}</span>";
        }

        $output .= '</div>';

        


        if ( ! empty( $comment_author_email ) ) {
            return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_author_email = %s AND comment_author = %s AND comment_author_url = %s AND comment_approved = 1" . $comment_type_where$comment_author_email$comment_author$comment_author_url ) );
        }

        return 0;
    }

    // get the full comment history for a given comment, as an array in reverse chronological order     public static function get_comment_history( $comment_id ) {
        $history = get_comment_meta( $comment_id, 'akismet_history', false );
        if ( empty( $history ) || empty( $history[ 0 ] ) ) {
            return false;
        }
        
        /* // To see all variants when testing. $history[] = array( 'time' => 445856401, 'message' => 'Old versions of Akismet stored the message as a literal string in the commentmeta.', 'event' => null ); $history[] = array( 'time' => 445856402, 'event' => 'recheck-spam' ); $history[] = array( 'time' => 445856403, 'event' => 'check-spam' ); $history[] = array( 'time' => 445856404, 'event' => 'recheck-ham' ); $history[] = array( 'time' => 445856405, 'event' => 'check-ham' ); $history[] = array( 'time' => 445856406, 'event' => 'wp-blacklisted' ); $history[] = array( 'time' => 445856406, 'event' => 'wp-disallowed' ); $history[] = array( 'time' => 445856407, 'event' => 'report-spam' ); $history[] = array( 'time' => 445856408, 'event' => 'report-spam', 'user' => 'sam' ); $history[] = array( 'message' => 'sam reported this comment as spam (hardcoded message).', 'time' => 445856400, 'event' => 'report-spam', 'user' => 'sam' ); $history[] = array( 'time' => 445856409, 'event' => 'report-ham', 'user' => 'sam' ); $history[] = array( 'message' => 'sam reported this comment as ham (hardcoded message).', 'time' => 445856400, 'event' => 'report-ham', 'user' => 'sam' ); // $history[] = array( 'time' => 445856410, 'event' => 'cron-retry-spam' ); $history[] = array( 'time' => 445856411, 'event' => 'cron-retry-ham' ); $history[] = array( 'time' => 445856412, 'event' => 'check-error' ); // $history[] = array( 'time' => 445856413, 'event' => 'check-error', 'meta' => array( 'response' => 'The server was taking a nap.' ) ); $history[] = array( 'time' => 445856414, 'event' => 'recheck-error' ); // Should not generate a message. $history[] = array( 'time' => 445856415, 'event' => 'recheck-error', 'meta' => array( 'response' => 'The server was taking a nap.' ) ); $history[] = array( 'time' => 445856416, 'event' => 'status-changedtrash' ); $history[] = array( 'time' => 445856417, 'event' => 'status-changedspam' ); $history[] = array( 'time' => 445856418, 'event' => 'status-changedhold' ); $history[] = array( 'time' => 445856419, 'event' => 'status-changedapprove' ); $history[] = array( 'time' => 445856420, 'event' => 'status-changed-trash' ); $history[] = array( 'time' => 445856421, 'event' => 'status-changed-spam' ); $history[] = array( 'time' => 445856422, 'event' => 'status-changed-hold' ); $history[] = array( 'time' => 445856423, 'event' => 'status-changed-approve' ); $history[] = array( 'time' => 445856424, 'event' => 'status-trash', 'user' => 'sam' ); $history[] = array( 'time' => 445856425, 'event' => 'status-spam', 'user' => 'sam' ); $history[] = array( 'time' => 445856426, 'event' => 'status-hold', 'user' => 'sam' ); $history[] = array( 'time' => 445856427, 'event' => 'status-approve', 'user' => 'sam' ); */
$comment = get_comment( $comment_id, ARRAY_A );
            if ( $comment && current_user_can( 'edit_comment', $comment['comment_ID'] ) ) {
                $comment['comment_author_url'] = esc_url( $_POST['url'] );
                do_action( 'comment_add_author_url' );
                print( wp_update_comment( $comment ) );
                die();
            }
        }
    }

    public static function comment_row_action( $a$comment ) {
        $akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
        $akismet_error  = get_comment_meta( $comment->comment_ID, 'akismet_error', true );
        $user_result    = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
        $comment_status = wp_get_comment_status( $comment->comment_ID );
        $desc = null;
        if ( $akismet_error ) {
            $desc = __( 'Awaiting spam check' , 'akismet');
        } elseif ( !$user_result || $user_result == $akismet_result ) {
            // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same             if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
                $desc = __( 'Flagged as spam by Akismet' , 'akismet');
            elseif ( $akismet_result == 'false' && $comment_status == 'spam' )
                
Home | Imprint | This part of the site doesn't use cookies.