get_comment_link example

/* translators: %s: Comment text. */
                $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
                $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
                /* translators: Comment notification email subject. 1: Site title, 2: Post title. */
                $subject = sprintf( __( '[%1$s] Comment: "%2$s"' )$blogname$post->post_title );
                break;
        }

        $notify_message .= get_permalink( $comment->comment_post_ID ) . "#comments\r\n\r\n";
        /* translators: %s: Comment URL. */
        $notify_message .= sprintf( __( 'Permalink: %s' )get_comment_link( $comment ) ) . "\r\n";

        if ( user_can( $post->post_author, 'edit_comment', $comment->comment_ID ) ) {
            if ( EMPTY_TRASH_DAYS ) {
                /* translators: Comment moderation. %s: Comment action URL. */
                $notify_message .= sprintf( __( 'Trash it: %s' )admin_url( "comment.php?action=trash&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
            } else {
                /* translators: Comment moderation. %s: Comment action URL. */
                $notify_message .= sprintf( __( 'Delete it: %s' )admin_url( "comment.php?action=delete&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
            }
            /* translators: Comment moderation. %s: Comment action URL. */
            $notify_message .= sprintf( __( 'Spam it: %s' )admin_url( "comment.php?action=spam&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
        }


        if ( in_array( 'content', $fields, true ) ) {
            $data['content'] = array(
                /** This filter is documented in wp-includes/comment-template.php */
                'rendered' => apply_filters( 'comment_text', $comment->comment_content, $comment ),
                'raw'      => $comment->comment_content,
            );
        }

        if ( in_array( 'link', $fields, true ) ) {
            $data['link'] = get_comment_link( $comment );
        }

        if ( in_array( 'status', $fields, true ) ) {
            $data['status'] = $this->prepare_status_response( $comment->comment_approved );
        }

        if ( in_array( 'type', $fields, true ) ) {
            $data['type'] = get_comment_type( $comment->comment_ID );
        }

        if ( in_array( 'author_avatar_urls', $fields, true ) ) {
            


            $author_markup = '';
            if ( $author_url ) {
                $author_markup .= '<a class="wp-block-latest-comments__comment-author" href="' . esc_url( $author_url ) . '">' . get_comment_author( $comment ) . '</a>';
            } else {
                $author_markup .= '<span class="wp-block-latest-comments__comment-author">' . get_comment_author( $comment ) . '</span>';
            }

            // `_draft_or_post_title` calls `esc_html()` so we don't need to wrap that call in             // `esc_html`.             $post_title = '<a class="wp-block-latest-comments__comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '">' . wp_latest_comments_draft_or_post_title( $comment->comment_post_ID ) . '</a>';

            $list_items_markup .= sprintf(
                /* translators: 1: author name (inside <a> or <span> tag, based on if they have a URL), 2: post title related to this comment */
                __( '%1$s on %2$s' ),
                $author_markup,
                $post_title
            );

            if ( $attributes['displayDate'] ) {
                $list_items_markup .= sprintf(
                    '<time datetime="%1$s" class="wp-block-latest-comments__comment-date">%2$s</time>',
                    
            ?> <thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> <?php         else : // This comment is in reply to another comment.             $parent_comment = get_comment( $comment->comment_parent );
            /* * The rel attribute below and the id tag above should be GUIDs, * but WP doesn't create them for comments (unlike posts). * Either way, it's more important that they both use the same system. */
            ?> <thr:in-reply-to ref="<?php comment_guid( $parent_comment ); ?>" href="<?php echo get_comment_link( $parent_comment ); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> <?php         endif;

        /** * Fires at the end of each Atom comment feed item. * * @since 2.2.0 * * @param int $comment_id ID of the current comment. * @param int $comment_post_id ID of the post the current comment is connected to. */
        
if ( empty( $comment ) ) {
        return '';
    }

    $classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';

    $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
    $formatted_date     = get_comment_date(
        isset( $attributes['format'] ) ? $attributes['format'] : '',
        $comment
    );
    $link               = get_comment_link( $comment );

    if ( ! empty( $attributes['isLink'] ) ) {
        $formatted_date = sprintf( '<a href="%1s">%2s</a>', esc_url( $link )$formatted_date );
    }

    return sprintf(
        '<div %1$s><time datetime="%2$s">%3$s</time></div>',
        $wrapper_attributes,
        esc_attr( get_comment_date( 'c', $comment ) ),
        $formatted_date
    );
}
$comment_status = 'approve';
        } else {
            $comment_status = $comment->comment_approved;
        }
        $_comment = array(
            'date_created_gmt' => $comment_date_gmt,
            'user_id'          => $comment->user_id,
            'comment_id'       => $comment->comment_ID,
            'parent'           => $comment->comment_parent,
            'status'           => $comment_status,
            'content'          => $comment->comment_content,
            'link'             => get_comment_link( $comment ),
            'post_id'          => $comment->comment_post_ID,
            'post_title'       => get_the_title( $comment->comment_post_ID ),
            'author'           => $comment->comment_author,
            'author_url'       => $comment->comment_author_url,
            'author_email'     => $comment->comment_author_email,
            'author_ip'        => $comment->comment_author_IP,
            'type'             => $comment->comment_type,
        );

        /** * Filters XML-RPC-prepared data for the given comment. * * @since 3.4.0 * * @param array $_comment An array of prepared comment data. * @param WP_Comment $comment Comment object. */

    public function column_comment( $comment ) {
        echo '<div class="comment-author">';
            $this->column_author( $comment );
        echo '</div>';

        if ( $comment->comment_parent ) {
            $parent = get_comment( $comment->comment_parent );

            if ( $parent ) {
                $parent_link = esc_url( get_comment_link( $parent ) );
                $name        = get_comment_author( $parent );
                printf(
                    /* translators: %s: Comment link. */
                    __( 'In reply to %s.' ),
                    '<a href="' . $parent_link . '">' . $name . '</a>'
                );
            }
        }

        comment_text( $comment );

        
<?php _e( 'Edit Comment' ); ?></h1> <div id="poststuff"> <input type="hidden" name="action" value="editedcomment" /> <input type="hidden" name="comment_ID" value="<?php echo esc_attr( $comment->comment_ID ); ?>" /> <input type="hidden" name="comment_post_ID" value="<?php echo esc_attr( $comment->comment_post_ID ); ?>" /> <div id="post-body" class="metabox-holder columns-2"> <div id="post-body-content" class="edit-form-section edit-comment-section"> <?php if ( 'approved' === wp_get_comment_status( $comment ) && $comment->comment_post_ID > 0 ) :
    $comment_link = get_comment_link( $comment );
    ?> <div class="inside"> <div id="comment-link-box"> <strong><?php _ex( 'Permalink:', 'comment' ); ?></strong> <span id="sample-permalink"> <a href="<?php echo esc_url( $comment_link ); ?>"> <?php echo esc_html( $comment_link ); ?> </a> </span> </div> </div>
case 'comment_author_IP':
                case 'comment_agent':
                case 'comment_date':
                    $value = $comment->{$key};
                    break;

                case 'comment_content':
                    $value = get_comment_text( $comment->comment_ID );
                    break;

                case 'comment_link':
                    $value = get_comment_link( $comment->comment_ID );
                    $value = sprintf(
                        '<a href="%s" target="_blank" rel="noopener">%s</a>',
                        esc_url( $value ),
                        esc_html( $value )
                    );
                    break;
            }

            if ( ! empty( $value ) ) {
                $comment_data_to_export[] = array(
                    'name'  => $name,
                    
        $post_id = $comment->comment_post_ID;
        if ( current_user_can( 'edit_post', $post_id ) ) {
            $post_link  = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>";
            $post_link .= esc_html( get_the_title( $post_id ) ) . '</a>';
        } else {
            $post_link = esc_html( get_the_title( $post_id ) );
        }
        echo $post_link;

        if ( $comment->comment_parent ) {
            $parent      = get_comment( $comment->comment_parent );
            $parent_link = esc_url( get_comment_link( $parent ) );
            $name        = get_comment_author( $parent );
            printf(
                /* translators: %s: Comment link. */
                ' | ' . __( 'In reply to %s.' ),
                '<a href="' . $parent_link . '">' . $name . '</a>'
            );
        }
        ?> </td> </tr> <tr> <th scope="row">
$actions['trash'] = sprintf(
                '<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
                $trash_url,
                "delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
                esc_attr__( 'Move this comment to the Trash' ),
                _x( 'Trash', 'verb' )
            );
        }

        $actions['view'] = sprintf(
            '<a class="comment-link" href="%s" aria-label="%s">%s</a>',
            esc_url( get_comment_link( $comment ) ),
            esc_attr__( 'View this comment' ),
            __( 'View' )
        );

        /** * Filters the action links displayed for each comment in the 'Recent Comments' * dashboard widget. * * @since 2.6.0 * * @param string[] $actions An array of comment actions. Default actions include: * 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam', * 'Delete', and 'Trash'. * @param WP_Comment $comment The comment object. */
?> </div> <?php if ( '0' == $comment->comment_approved ) : ?> <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em> <br /> <?php endif; ?> <div class="comment-meta commentmetadata"> <?php             printf(
                '<a href="%s">%s</a>',
                esc_url( get_comment_link( $comment$args ) ),
                sprintf(
                    /* translators: 1: Comment date, 2: Comment time. */
                    __( '%1$s at %2$s' ),
                    get_comment_date( '', $comment ),
                    get_comment_time()
                )
            );

            edit_comment_link( __( '(Edit)' ), ' &nbsp;&nbsp;', '' );
            ?> </div>

do_action( 'set_comment_cookies', $comment$user$cookies_consent );

$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID;

// If user didn't consent to cookies, add specific query arguments to display the awaiting moderation message. if ( ! $cookies_consent && 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) {
    $location = add_query_arg(
        array(
            'unapproved'      => $comment->comment_ID,
            'moderation-hash' => wp_hash( $comment->comment_date_gmt ),
        ),
        $location
    );
}


function get_comment_text( $comment_id = 0, $args = array() ) {
    $comment = get_comment( $comment_id );

    $comment_text = $comment->comment_content;

    if ( is_comment_feed() && $comment->comment_parent ) {
        $parent = get_comment( $comment->comment_parent );
        if ( $parent ) {
            $parent_link = esc_url( get_comment_link( $parent ) );
            $name        = get_comment_author( $parent );

            $comment_text = sprintf(
                /* translators: %s: Comment link. */
                ent2ncr( __( 'In reply to %s.' ) ),
                '<a href="' . $parent_link . '">' . $name . '</a>'
            ) . "\n\n" . $comment_text;
        }
    }

    /** * Filters the text of a comment. * * @since 1.5.0 * * @see Walker_Comment::comment() * * @param string $comment_text Text of the comment. * @param WP_Comment $comment The comment object. * @param array $args An array of arguments. */
    if ( ! $total || ! $per_page || ! $page || ! $url ) {
        $time           = time();
        $comment        = get_comment( $comment_id );
        $comment_status = '';
        $comment_link   = '';

        if ( $comment ) {
            $comment_status = $comment->comment_approved;
        }

        if ( 1 === (int) $comment_status ) {
            $comment_link = get_comment_link( $comment );
        }

        $counts = wp_count_comments();

        $x = new WP_Ajax_Response(
            array(
                'what'         => 'comment',
                // Here for completeness - not used.                 'id'           => $comment_id,
                'supplemental' => array(
                    'status'               => $comment_status,
                    
Home | Imprint | This part of the site doesn't use cookies.