Changeset 25428
- Timestamp:
- 09/13/2013 07:19:45 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-template.php
r25151 r25428 1019 1019 * Retrieve HTML content for reply to comment link. 1020 1020 * 1021 * @since 2.7.0 1022 * 1023 * @param array $args { 1024 * Override default options. 1025 * 1026 * @type string 'add_below' 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. 1027 * Default is 'comment'. 1028 * @type string 'respond_id' The selector identifying the responding comment. Passed as the third parameter to addComment.moveForm(), and appended to the link URL as a hash value. 1029 * Default is 'respond'. 1030 * @type string 'reply_text' The text of the Reply link. 1031 * Default is 'Reply'. 1032 * @type string 'login_text' The text of the link to reply if logged out. 1033 * Default is 'Log in to Reply'. 1034 * @type int 'depth' The depth of the new comment. Must be greater than 0 and less than the value of the 'thread_comments_depth' option set in Settings > Discussion. 1035 * Default is 0. 1036 * @type string 'before' The text or HTML to add before the reply link. 1037 * Default empty string. 1038 * @type string 'after' The text or HTML to add after the reply link. 1039 * Default empty string. 1040 * } 1041 * @param int $comment Optional. Comment being replied to. 1042 * @param int $post Optional. Post that the comment is going to be displayed on. 1043 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed. 1044 */ 1045 function get_comment_reply_link($args = array(), $comment = null, $post = null) { 1046 global $user_ID; 1047 1048 $defaults = array( 1049 'add_below' => 'comment', 1050 'respond_id' => 'respond', 1051 'reply_text' => __('Reply'), 1052 'login_text' => __('Log in to Reply'), 1053 'depth' => 0, 1054 'before' => '', 1055 'after' => '' 1056 ); 1057 1058 $args = wp_parse_args($args, $defaults); 1059 1060 if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) 1061 return; 1062 1063 extract($args, EXTR_SKIP); 1064 1065 $comment = get_comment($comment); 1066 if ( empty($post) ) 1067 $post = $comment->comment_post_ID; 1068 $post = get_post($post); 1069 1070 if ( !comments_open($post->ID) ) 1071 return false; 1072 1073 $link = ''; 1074 1075 if ( get_option('comment_registration') && !$user_ID ) 1076 $link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $login_text . '</a>'; 1077 else 1078 $link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>"; 1079 1080 /** 1081 * Filter the comment reply link. 1082 * 1083 * @since 2.7.0 1084 * 1085 * @param string $before Text or HTML displayed before the reply link. 1086 * @param string $link The HTML markup for the comment reply link. 1087 * @param string $after Text or HTML displayed after the reply link. 1088 * @param array $args An array of arguments overriding the defaults. 1089 * @param object $comment The object of the comment being replied. 1090 * @param WP_Post $post The WP_Post object. 1091 */ 1092 return apply_filters( 'comment_reply_link', $before . $link . $after, $args, $comment, $post ); 1093 } 1094 1095 /** 1096 * Displays the HTML content for reply to comment link. 1097 * 1098 * @since 2.7.0 1099 * @see get_comment_reply_link() Echoes result 1100 * 1101 * @param array $args Optional. Override default options, @see get_comment_reply_link(). 1102 * @param int $comment Optional. Comment being replied to. 1103 * @param int $post Optional. Post that the comment is going to be displayed on. 1104 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed. 1105 */ 1106 function comment_reply_link($args = array(), $comment = null, $post = null) { 1107 echo get_comment_reply_link($args, $comment, $post); 1108 } 1109 1110 /** 1111 * Retrieve HTML content for reply to post link. 1112 * 1021 1113 * The default arguments that can be override are 'add_below', 'respond_id', 1022 1114 * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be … … 1026 1118 * parameters. 1027 1119 * 1028 * @since 2.7.0 1029 * 1030 * @param array $args Optional. Override default options. 1031 * @param int $comment Optional. Comment being replied to. 1032 * @param int $post Optional. Post that the comment is going to be displayed on. 1033 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed. 1034 */ 1035 function get_comment_reply_link($args = array(), $comment = null, $post = null) { 1036 global $user_ID; 1037 1038 $defaults = array('add_below' => 'comment', 'respond_id' => 'respond', 'reply_text' => __('Reply'), 1039 'login_text' => __('Log in to Reply'), 'depth' => 0, 'before' => '', 'after' => ''); 1040 1041 $args = wp_parse_args($args, $defaults); 1042 1043 if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) 1044 return; 1045 1046 extract($args, EXTR_SKIP); 1047 1048 $comment = get_comment($comment); 1049 if ( empty($post) ) 1050 $post = $comment->comment_post_ID; 1051 $post = get_post($post); 1052 1053 if ( !comments_open($post->ID) ) 1054 return false; 1055 1056 $link = ''; 1057 1058 if ( get_option('comment_registration') && !$user_ID ) 1059 $link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $login_text . '</a>'; 1060 else 1061 $link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>"; 1062 return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post); 1063 } 1064 1065 /** 1066 * Displays the HTML content for reply to comment link. 1067 * 1068 * @since 2.7.0 1069 * @see get_comment_reply_link() Echoes result 1070 * 1071 * @param array $args Optional. Override default options. 1072 * @param int $comment Optional. Comment being replied to. 1073 * @param int $post Optional. Post that the comment is going to be displayed on. 1074 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed. 1075 */ 1076 function comment_reply_link($args = array(), $comment = null, $post = null) { 1077 echo get_comment_reply_link($args, $comment, $post); 1078 } 1079 1080 /** 1081 * Retrieve HTML content for reply to post link. 1082 * 1083 * The default arguments that can be override are 'add_below', 'respond_id', 1084 * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be 1085 * used, if the user must log in or register first before posting a comment. The 1086 * 'reply_text' will be used, if they can post a reply. The 'add_below' and 1087 * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function 1088 * parameters. 1120 * @todo See get_comment_reply_link() for a template of the args docblock. 1089 1121 * 1090 1122 * @since 2.7.0 … … 1117 1149 /** 1118 1150 * Displays the HTML content for reply to post link. 1151 * 1119 1152 * @since 2.7.0 1120 * @see get_post_reply_link() 1121 * 1122 * @param array $args Optional. Override default options. 1153 * 1154 * @param array $args Optional. Override default options, @see get_post_reply_link(). 1123 1155 * @param int|object $post Optional. Post that the comment is going to be displayed on. 1124 1156 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
Note: See TracChangeset
for help on using the changeset viewer.