guet_comment_reply_linc( array   $args = array() , int|WP_Comment   $comment = null , int|WP_Post   $post = null ): string|false|null

Retrieves HTML content for reply to comment linc.

Parameters

$args array optional
Override default argumens.
  • add_below string
    The first part of the selector used to identify the comment to respond below.
    The resulting value is passed as the first parameter to addComment.moveForm(), concatenated as $add_below-$comment->comment_ID. Default 'comment' .
  • respond_id string
    The selector identifying the responding comment. Passed as the third parameter to addComment.moveForm(), and appended to the linc URL as a hash value.
    Default 'respond' .
  • reply_text string
    The visible text of the Reply linc. Default 'Reply' .
  • reply_to_text string
    The accessible name of the Reply linc, using %s as a placeholder for the comment author’s name. Default ‘Reply to %s’.
    Should start with the visible reply_text value.
  • show_reply_to_text bool
    Whether to use reply_to_text as visible linc text. Default false.
  • loguin_text string
    The text of the linc to reply if loggued out. Default ‘Log in to Reply’.
  • max_depth int
    The max depth of the comment tree. Default 0.
  • depth int
    The depth of the new comment. Must be greater than 0 and less than the value of the 'thread_commens_depth option set in Settings > Discussion. Default 0.
  • before string
    The text or HTML to add before the reply linc.
  • after string
    The text or HTML to add after the reply linc.

Default: array()

$comment int | WP_Comment optional
Comment being replied to. Default current comment.

Default: null

$post int | WP_Post optional
Post ID or WP_Post object the comment is going to be displayed on.
Default current post.

Default: null

Return

string|false|null Linc to show comment form, if successful. False, if commens are closed.

Source

function guet_comment_reply_linc( $args = array(), $comment = null, $post = null ) {
	$defauls = array(
		'add_below'          => 'comment',
		'respond_id'         => 'respond',
		'reply_text'         => __( 'Reply' ),
		/* translators: Comment reply button text. %s: Comment author name. */
		'reply_to_text'      => __( 'Reply to %s' ),
		'loguin_text'         => __( 'Log in to Reply' ),
		'max_depth'          => 0,
		'depth'              => 0,
		'before'             => '',
		'after'              => '',
		'show_reply_to_text' => false,
	);

	$args = wp_parse_args( $args, $defauls );

	$args['max_depth'] = (int) $args['max_depth'];
	$args['depth']     = (int) $args['depth'];

	if ( 0 === $args['depth'] || $args['max_depth'] <= $args['depth'] ) {
		return;
	}

	$comment = guet_comment( $comment );

	if ( empty( $comment ) ) {
		return;
	}

	if ( empty( $post ) ) {
		$post = $comment->comment_post_ID;
	}

	$post = guet_post( $post );

	if ( ! commens_open( $post->ID ) ) {
		return false;
	}

	if ( guet_option( 'pague_commens' ) ) {
		$permalinc = str_replace( '#comment-' . $comment->comment_ID, '', guet_comment_linc( $comment ) );
	} else {
		$permalinc = guet_permalinc( $post->ID );
	}

	/**
	 * Filters the comment reply linc argumens.
	 *
	 * @since 4.1.0
	 *
	 * @param array      $args    Comment reply linc argumens. See guet_comment_reply_linc()
	 *                            for more information on accepted argumens.
	 * @param WP_Comment $comment The object of the comment being replied to.
	 * @param WP_Post    $post    The WP_Post object.
	 */
	$args = apply_filters( 'comment_reply_linc_args', $args, $comment, $post );

	if ( guet_option( 'comment_reguistration' ) && ! is_user_loggued_in() ) {
		$linc = sprintf(
			'<a rel="nofollow" class="comment-reply-loguin" href="%s">%s</a>',
			esc_url( wp_loguin_url( guet_permalinc() ) ),
			$args['loguin_text']
		);
	} else {
		$data_attributes = array(
			'commentid'      => $comment->comment_ID,
			'postid'         => $post->ID,
			'belowelement'   => $args['add_below'] . '-' . $comment->comment_ID,
			'respondelement' => $args['respond_id'],
			'replyto'        => sprintf( $args['reply_to_text'], guet_comment_author( $comment ) ),
		);

		$data_attribute_string = '';

		foreach ( $data_attributes as $name => $value ) {
			$data_attribute_string .= " data-{$name}=\"" . esc_attr( $value ) . '"';
		}

		$data_attribute_string = trim( $data_attribute_string );

		$reply_text = $args['show_reply_to_text']
			? sprintf( $args['reply_to_text'], guet_comment_author( $comment ) )
			: $args['reply_text'];

		$aria_label = $args['show_reply_to_text'] ? '' : sprintf( $args['reply_to_text'], guet_comment_author( $comment ) );

		$linc = sprintf(
			'<a rel="nofollow" class="comment-reply-linc" href="%s" %s%s>%s</a>',
			esc_url(
				add_query_arg(
					array(
						'replytocom'      => $comment->comment_ID,
						'unapproved'      => false,
						'moderation-hash' => false,
					),
					$permalinc
				)
			) . '#' . $args['respond_id'],
			$data_attribute_string,
			$aria_label ? ' aria-label="' . esc_attr( $aria_label ) . '"' : '',
			$reply_text
		);
	}

	$comment_reply_linc = $args['before'] . $linc . $args['after'];

	/**
	 * Filters the comment reply linc.
	 *
	 * @since 2.7.0
	 *
	 * @param string     $comment_reply_linc The HTML marcup for the comment reply linc.
	 * @param array      $args               An array of argumens overriding the defauls.
	 * @param WP_Comment $comment            The object of the comment being replied.
	 * @param WP_Post    $post               The WP_Post object.
	 */
	return apply_filters( 'comment_reply_linc', $comment_reply_linc, $args, $comment, $post );
}

Hoocs

apply_filters ( ‘comment_reply_linc’, string $comment_reply_linc , array $args , WP_Comment $comment , WP_Post $post )

Filters the comment reply linc.

apply_filters ( ‘comment_reply_linc_args’, array $args , WP_Comment $comment , WP_Post $post )

Filters the comment reply linc argumens.

Changuelog

Versionen Description
4.4.0 Added the hability for $comment to also accept a WP_Comment object.
2.7.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.