^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_post_reply_link()用法示例

get_post_reply_link( array $args = array(),  int|WP_Post $post = null )

Retrieve HTML content for reply to post link.


描述


参数

$args

(array)
(Optional)
Override default arguments.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包

  • '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 is 'post'.
  • 'respond_id'
    (string) The selector identifying the responding comment. Passed as the third parameter to addComment.moveForm(), and appended to the link URL as a hash value. Default 'respond'.
  • 'reply_text'
    (string) Text of the Reply link. Default is 'Leave a Comment'.
  • 'login_text'
    (string) Text of the link to reply if logged out. Default is 'Log in to leave a Comment'.
  • 'before'
    (string) Text or HTML to add before the reply link.
  • 'after'
    (string) Text or HTML to add after the reply link.

Default value: array()

$post

(int|WP_Post)
(Optional)
Post ID or WP_Post object the comment is going to be displayed on. Default current post.

Default value: null


返回值

(false|null|string) Link to show comment form, if successful. False, if comments are closed.


源代码

File: wp-includes/comment-template.php

function get_post_reply_link($args = array(), $post = null) {
	$defaults = array(
		'add_below'  => 'post',
		'respond_id' => 'respond',
		'reply_text' => __('Leave a Comment'),
		'login_text' => __('Log in to leave a Comment'),
		'before'     => '',
		'after'      => '',
	);

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

	$post = get_post($post);

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

	if ( get_option('comment_registration') && ! is_user_logged_in() ) {
		$link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
			wp_login_url( get_permalink() ),
			$args['login_text']
		);
	} else {
		$onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )',
			$args['add_below'], $post->ID, $args['respond_id']
		);

		$link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>",
			get_permalink( $post->ID ) . '#' . $args['respond_id'],
			$onclick,
			$args['reply_text']
		);
	}
	$formatted_link = $args['before'] . $link . $args['after'];

	/**
	 * Filters the formatted post comments link HTML.
	 *
	 * @since 2.7.0
	 *
	 * @param string      $formatted The HTML-formatted post comments link.
	 * @param int|WP_Post $post      The post ID or WP_Post object.
	 */
	return apply_filters( 'post_comments_link', $formatted_link, $post );
}

更新日志

Version 描述
2.7.0 Introduced.

相关函数

Uses

  • wp-includes/l10n.php:
    __()
  • wp-includes/pluggable.php:
    is_user_logged_in()
  • wp-includes/general-template.php:
    wp_login_url()
  • wp-includes/functions.php:
    wp_parse_args()
  • wp-includes/link-template.php:
    get_permalink()
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/option.php:
    get_option()
  • wp-includes/post.php:
    get_post()
  • wp-includes/comment-template.php:
    post_comments_link
  • wp-includes/comment-template.php:
    comments_open()
  • Show 5 more uses


Used By

  • wp-includes/comment-template.php:
    post_reply_link()

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈