[44] | 1 | <?php
|
---|
| 2 | /**
|
---|
| 3 | * Comment template functions
|
---|
| 4 | *
|
---|
| 5 | * These functions are meant to live inside of the WordPress loop.
|
---|
| 6 | *
|
---|
| 7 | * @package WordPress
|
---|
| 8 | * @subpackage Template
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | /**
|
---|
| 12 | * Retrieve the author of the current comment.
|
---|
| 13 | *
|
---|
| 14 | * If the comment has an empty comment_author field, then 'Anonymous' person is
|
---|
| 15 | * assumed.
|
---|
| 16 | *
|
---|
| 17 | * @since 1.5.0
|
---|
| 18 | * @uses apply_filters() Calls 'get_comment_author' hook on the comment author
|
---|
| 19 | *
|
---|
| 20 | * @return string The comment author
|
---|
| 21 | */
|
---|
| 22 | function get_comment_author() {
|
---|
| 23 | global $comment;
|
---|
| 24 | if ( empty($comment->comment_author) ) {
|
---|
| 25 | if (!empty($comment->user_id)){
|
---|
| 26 | $user=get_userdata($comment->user_id);
|
---|
| 27 | $author=$user->user_login;
|
---|
| 28 | } else {
|
---|
| 29 | $author = __('Anonymous');
|
---|
| 30 | }
|
---|
| 31 | } else {
|
---|
| 32 | $author = $comment->comment_author;
|
---|
| 33 | }
|
---|
| 34 | return apply_filters('get_comment_author', $author);
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | * Displays the author of the current comment.
|
---|
| 39 | *
|
---|
| 40 | * @since 0.71
|
---|
| 41 | * @uses apply_filters() Calls 'comment_author' on comment author before displaying
|
---|
| 42 | */
|
---|
| 43 | function comment_author() {
|
---|
| 44 | $author = apply_filters('comment_author', get_comment_author() );
|
---|
| 45 | echo $author;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | /**
|
---|
| 49 | * Retrieve the email of the author of the current comment.
|
---|
| 50 | *
|
---|
| 51 | * @since 1.5.0
|
---|
| 52 | * @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email
|
---|
| 53 | * @uses $comment
|
---|
| 54 | *
|
---|
| 55 | * @return string The current comment author's email
|
---|
| 56 | */
|
---|
| 57 | function get_comment_author_email() {
|
---|
| 58 | global $comment;
|
---|
| 59 | return apply_filters('get_comment_author_email', $comment->comment_author_email);
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | /**
|
---|
| 63 | * Display the email of the author of the current global $comment.
|
---|
| 64 | *
|
---|
| 65 | * Care should be taken to protect the email address and assure that email
|
---|
| 66 | * harvesters do not capture your commentors' email address. Most assume that
|
---|
| 67 | * their email address will not appear in raw form on the blog. Doing so will
|
---|
| 68 | * enable anyone, including those that people don't want to get the email
|
---|
| 69 | * address and use it for their own means good and bad.
|
---|
| 70 | *
|
---|
| 71 | * @since 0.71
|
---|
| 72 | * @uses apply_filters() Calls 'author_email' hook on the author email
|
---|
| 73 | */
|
---|
| 74 | function comment_author_email() {
|
---|
| 75 | echo apply_filters('author_email', get_comment_author_email() );
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | /**
|
---|
| 79 | * Display the html email link to the author of the current comment.
|
---|
| 80 | *
|
---|
| 81 | * Care should be taken to protect the email address and assure that email
|
---|
| 82 | * harvesters do not capture your commentors' email address. Most assume that
|
---|
| 83 | * their email address will not appear in raw form on the blog. Doing so will
|
---|
| 84 | * enable anyone, including those that people don't want to get the email
|
---|
| 85 | * address and use it for their own means good and bad.
|
---|
| 86 | *
|
---|
| 87 | * @since 0.71
|
---|
| 88 | * @uses apply_filters() Calls 'comment_email' hook for the display of the comment author's email
|
---|
| 89 | * @uses get_comment_author_email_link() For generating the link
|
---|
| 90 | * @global object $comment The current Comment row object
|
---|
| 91 | *
|
---|
| 92 | * @param string $linktext The text to display instead of the comment author's email address
|
---|
| 93 | * @param string $before The text or HTML to display before the email link.
|
---|
| 94 | * @param string $after The text or HTML to display after the email link.
|
---|
| 95 | */
|
---|
| 96 | function comment_author_email_link($linktext='', $before='', $after='') {
|
---|
| 97 | if ( $link = get_comment_author_email_link( $linktext, $before, $after ) )
|
---|
| 98 | echo $link;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | /**
|
---|
| 102 | * Return the html email link to the author of the current comment.
|
---|
| 103 | *
|
---|
| 104 | * Care should be taken to protect the email address and assure that email
|
---|
| 105 | * harvesters do not capture your commentors' email address. Most assume that
|
---|
| 106 | * their email address will not appear in raw form on the blog. Doing so will
|
---|
| 107 | * enable anyone, including those that people don't want to get the email
|
---|
| 108 | * address and use it for their own means good and bad.
|
---|
| 109 | *
|
---|
| 110 | * @since 2.7
|
---|
| 111 | * @uses apply_filters() Calls 'comment_email' hook for the display of the comment author's email
|
---|
| 112 | * @global object $comment The current Comment row object
|
---|
| 113 | *
|
---|
| 114 | * @param string $linktext The text to display instead of the comment author's email address
|
---|
| 115 | * @param string $before The text or HTML to display before the email link.
|
---|
| 116 | * @param string $after The text or HTML to display after the email link.
|
---|
| 117 | */
|
---|
| 118 | function get_comment_author_email_link($linktext='', $before='', $after='') {
|
---|
| 119 | global $comment;
|
---|
| 120 | $email = apply_filters('comment_email', $comment->comment_author_email);
|
---|
| 121 | if ((!empty($email)) && ($email != '@')) {
|
---|
| 122 | $display = ($linktext != '') ? $linktext : $email;
|
---|
| 123 | $return = $before;
|
---|
| 124 | $return .= "<a href='mailto:$email'>$display</a>";
|
---|
| 125 | $return .= $after;
|
---|
| 126 | return $return;
|
---|
| 127 | } else {
|
---|
| 128 | return '';
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | /**
|
---|
| 133 | * Retrieve the html link to the url of the author of the current comment.
|
---|
| 134 | *
|
---|
| 135 | * @since 1.5.0
|
---|
| 136 | * @uses apply_filters() Calls 'get_comment_author_link' hook on the complete link HTML or author
|
---|
| 137 | *
|
---|
| 138 | * @return string Comment Author name or HTML link for author's URL
|
---|
| 139 | */
|
---|
| 140 | function get_comment_author_link() {
|
---|
| 141 | /** @todo Only call these functions when they are needed. Include in if... else blocks */
|
---|
| 142 | $url = get_comment_author_url();
|
---|
| 143 | $author = get_comment_author();
|
---|
| 144 |
|
---|
| 145 | if ( empty( $url ) || 'http://' == $url )
|
---|
| 146 | $return = $author;
|
---|
| 147 | else
|
---|
| 148 | $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
|
---|
| 149 | return apply_filters('get_comment_author_link', $return);
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | /**
|
---|
| 153 | * Display the html link to the url of the author of the current comment.
|
---|
| 154 | *
|
---|
| 155 | * @since 0.71
|
---|
| 156 | * @see get_comment_author_link() Echos result
|
---|
| 157 | */
|
---|
| 158 | function comment_author_link() {
|
---|
| 159 | echo get_comment_author_link();
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | /**
|
---|
| 163 | * Retrieve the IP address of the author of the current comment.
|
---|
| 164 | *
|
---|
| 165 | * @since 1.5.0
|
---|
| 166 | * @uses $comment
|
---|
| 167 | * @uses apply_filters()
|
---|
| 168 | *
|
---|
| 169 | * @return unknown
|
---|
| 170 | */
|
---|
| 171 | function get_comment_author_IP() {
|
---|
| 172 | global $comment;
|
---|
| 173 | return apply_filters('get_comment_author_IP', $comment->comment_author_IP);
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | /**
|
---|
| 177 | * Display the IP address of the author of the current comment.
|
---|
| 178 | *
|
---|
| 179 | * @since 0.71
|
---|
| 180 | * @see get_comment_author_IP() Echos Result
|
---|
| 181 | */
|
---|
| 182 | function comment_author_IP() {
|
---|
| 183 | echo get_comment_author_IP();
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | /**
|
---|
| 187 | * Retrieve the url of the author of the current comment.
|
---|
| 188 | *
|
---|
| 189 | * @since 1.5.0
|
---|
| 190 | * @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL
|
---|
| 191 | *
|
---|
| 192 | * @return string
|
---|
| 193 | */
|
---|
| 194 | function get_comment_author_url() {
|
---|
| 195 | global $comment;
|
---|
| 196 | $url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
|
---|
| 197 | return apply_filters('get_comment_author_url', $url);
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 | /**
|
---|
| 201 | * Display the url of the author of the current comment.
|
---|
| 202 | *
|
---|
| 203 | * @since 0.71
|
---|
| 204 | * @uses apply_filters()
|
---|
| 205 | * @uses get_comment_author_url() Retrieves the comment author's URL
|
---|
| 206 | */
|
---|
| 207 | function comment_author_url() {
|
---|
| 208 | echo apply_filters('comment_url', get_comment_author_url());
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | /**
|
---|
| 212 | * Retrieves the HTML link of the url of the author of the current comment.
|
---|
| 213 | *
|
---|
| 214 | * $linktext parameter is only used if the URL does not exist for the comment
|
---|
| 215 | * author. If the URL does exist then the URL will be used and the $linktext
|
---|
| 216 | * will be ignored.
|
---|
| 217 | *
|
---|
| 218 | * Encapsulate the HTML link between the $before and $after. So it will appear
|
---|
| 219 | * in the order of $before, link, and finally $after.
|
---|
| 220 | *
|
---|
| 221 | * @since 1.5.0
|
---|
| 222 | * @uses apply_filters() Calls the 'get_comment_author_url_link' on the complete HTML before returning.
|
---|
| 223 | *
|
---|
| 224 | * @param string $linktext The text to display instead of the comment author's email address
|
---|
| 225 | * @param string $before The text or HTML to display before the email link.
|
---|
| 226 | * @param string $after The text or HTML to display after the email link.
|
---|
| 227 | * @return string The HTML link between the $before and $after parameters
|
---|
| 228 | */
|
---|
| 229 | function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
|
---|
| 230 | $url = get_comment_author_url();
|
---|
| 231 | $display = ($linktext != '') ? $linktext : $url;
|
---|
| 232 | $display = str_replace( 'http://www.', '', $display );
|
---|
| 233 | $display = str_replace( 'http://', '', $display );
|
---|
| 234 | if ( '/' == substr($display, -1) )
|
---|
| 235 | $display = substr($display, 0, -1);
|
---|
| 236 | $return = "$before<a href='$url' rel='external'>$display</a>$after";
|
---|
| 237 | return apply_filters('get_comment_author_url_link', $return);
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | /**
|
---|
| 241 | * Displays the HTML link of the url of the author of the current comment.
|
---|
| 242 | *
|
---|
| 243 | * @since 0.71
|
---|
| 244 | * @see get_comment_author_url_link() Echos result
|
---|
| 245 | *
|
---|
| 246 | * @param string $linktext The text to display instead of the comment author's email address
|
---|
| 247 | * @param string $before The text or HTML to display before the email link.
|
---|
| 248 | * @param string $after The text or HTML to display after the email link.
|
---|
| 249 | */
|
---|
| 250 | function comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
|
---|
| 251 | echo get_comment_author_url_link( $linktext, $before, $after );
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | /**
|
---|
| 255 | * Generates semantic classes for each comment element
|
---|
| 256 | *
|
---|
| 257 | * @since 2.7.0
|
---|
| 258 | *
|
---|
| 259 | * @param string|array $class One or more classes to add to the class list
|
---|
| 260 | * @param int $comment_id An optional comment ID
|
---|
| 261 | * @param int $post_id An optional post ID
|
---|
| 262 | * @param bool $echo Whether comment_class should echo or return
|
---|
| 263 | */
|
---|
| 264 | function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) {
|
---|
| 265 | // Separates classes with a single space, collates classes for comment DIV
|
---|
| 266 | $class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"';
|
---|
| 267 | if ( $echo)
|
---|
| 268 | echo $class;
|
---|
| 269 | else
|
---|
| 270 | return $class;
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | /**
|
---|
| 274 | * Returns the classes for the comment div as an array
|
---|
| 275 | *
|
---|
| 276 | * @since 2.7.0
|
---|
| 277 | *
|
---|
| 278 | * @param string|array $class One or more classes to add to the class list
|
---|
| 279 | * @param int $comment_id An optional comment ID
|
---|
| 280 | * @param int $post_id An optional post ID
|
---|
| 281 | * @return array Array of classes
|
---|
| 282 | */
|
---|
| 283 | function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
|
---|
| 284 | global $comment_alt, $comment_depth, $comment_thread_alt;
|
---|
| 285 |
|
---|
| 286 | $comment = get_comment($comment_id);
|
---|
| 287 |
|
---|
| 288 | $classes = array();
|
---|
| 289 |
|
---|
| 290 | // Get the comment type (comment, trackback),
|
---|
| 291 | $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
|
---|
| 292 |
|
---|
| 293 | // If the comment author has an id (registered), then print the log in name
|
---|
| 294 | if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
|
---|
| 295 | // For all registered users, 'byuser'
|
---|
| 296 | $classes[] = 'byuser';
|
---|
| 297 | $classes[] = 'comment-author-' . sanitize_html_class($user->user_nicename, $comment->user_id);
|
---|
| 298 | // For comment authors who are the author of the post
|
---|
| 299 | if ( $post = get_post($post_id) ) {
|
---|
| 300 | if ( $comment->user_id === $post->post_author )
|
---|
| 301 | $classes[] = 'bypostauthor';
|
---|
| 302 | }
|
---|
| 303 | }
|
---|
| 304 |
|
---|
| 305 | if ( empty($comment_alt) )
|
---|
| 306 | $comment_alt = 0;
|
---|
| 307 | if ( empty($comment_depth) )
|
---|
| 308 | $comment_depth = 1;
|
---|
| 309 | if ( empty($comment_thread_alt) )
|
---|
| 310 | $comment_thread_alt = 0;
|
---|
| 311 |
|
---|
| 312 | if ( $comment_alt % 2 ) {
|
---|
| 313 | $classes[] = 'odd';
|
---|
| 314 | $classes[] = 'alt';
|
---|
| 315 | } else {
|
---|
| 316 | $classes[] = 'even';
|
---|
| 317 | }
|
---|
| 318 |
|
---|
| 319 | $comment_alt++;
|
---|
| 320 |
|
---|
| 321 | // Alt for top-level comments
|
---|
| 322 | if ( 1 == $comment_depth ) {
|
---|
| 323 | if ( $comment_thread_alt % 2 ) {
|
---|
| 324 | $classes[] = 'thread-odd';
|
---|
| 325 | $classes[] = 'thread-alt';
|
---|
| 326 | } else {
|
---|
| 327 | $classes[] = 'thread-even';
|
---|
| 328 | }
|
---|
| 329 | $comment_thread_alt++;
|
---|
| 330 | }
|
---|
| 331 |
|
---|
| 332 | $classes[] = "depth-$comment_depth";
|
---|
| 333 |
|
---|
| 334 | if ( !empty($class) ) {
|
---|
| 335 | if ( !is_array( $class ) )
|
---|
| 336 | $class = preg_split('#\s+#', $class);
|
---|
| 337 | $classes = array_merge($classes, $class);
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | return apply_filters('comment_class', $classes, $class, $comment_id, $post_id);
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | /**
|
---|
| 344 | * Retrieve the comment date of the current comment.
|
---|
| 345 | *
|
---|
| 346 | * @since 1.5.0
|
---|
| 347 | * @uses apply_filters() Calls 'get_comment_date' hook with the formated date and the $d parameter respectively
|
---|
| 348 | * @uses $comment
|
---|
| 349 | *
|
---|
| 350 | * @param string $d The format of the date (defaults to user's config)
|
---|
| 351 | * @return string The comment's date
|
---|
| 352 | */
|
---|
| 353 | function get_comment_date( $d = '' ) {
|
---|
| 354 | global $comment;
|
---|
| 355 | if ( '' == $d )
|
---|
| 356 | $date = mysql2date(get_option('date_format'), $comment->comment_date);
|
---|
| 357 | else
|
---|
| 358 | $date = mysql2date($d, $comment->comment_date);
|
---|
| 359 | return apply_filters('get_comment_date', $date, $d);
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | /**
|
---|
| 363 | * Display the comment date of the current comment.
|
---|
| 364 | *
|
---|
| 365 | * @since 0.71
|
---|
| 366 | *
|
---|
| 367 | * @param string $d The format of the date (defaults to user's config)
|
---|
| 368 | */
|
---|
| 369 | function comment_date( $d = '' ) {
|
---|
| 370 | echo get_comment_date( $d );
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | /**
|
---|
| 374 | * Retrieve the excerpt of the current comment.
|
---|
| 375 | *
|
---|
| 376 | * Will cut each word and only output the first 20 words with '...' at the end.
|
---|
| 377 | * If the word count is less than 20, then no truncating is done and no '...'
|
---|
| 378 | * will appear.
|
---|
| 379 | *
|
---|
| 380 | * @since 1.5.0
|
---|
| 381 | * @uses $comment
|
---|
| 382 | * @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment
|
---|
| 383 | *
|
---|
| 384 | * @return string The maybe truncated comment with 20 words or less
|
---|
| 385 | */
|
---|
| 386 | function get_comment_excerpt() {
|
---|
| 387 | global $comment;
|
---|
| 388 | $comment_text = strip_tags($comment->comment_content);
|
---|
| 389 | $blah = explode(' ', $comment_text);
|
---|
| 390 | if (count($blah) > 20) {
|
---|
| 391 | $k = 20;
|
---|
| 392 | $use_dotdotdot = 1;
|
---|
| 393 | } else {
|
---|
| 394 | $k = count($blah);
|
---|
| 395 | $use_dotdotdot = 0;
|
---|
| 396 | }
|
---|
| 397 | $excerpt = '';
|
---|
| 398 | for ($i=0; $i<$k; $i++) {
|
---|
| 399 | $excerpt .= $blah[$i] . ' ';
|
---|
| 400 | }
|
---|
| 401 | $excerpt .= ($use_dotdotdot) ? '...' : '';
|
---|
| 402 | return apply_filters('get_comment_excerpt', $excerpt);
|
---|
| 403 | }
|
---|
| 404 |
|
---|
| 405 | /**
|
---|
| 406 | * Display the excerpt of the current comment.
|
---|
| 407 | *
|
---|
| 408 | * @since 1.2.0
|
---|
| 409 | * @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt
|
---|
| 410 | */
|
---|
| 411 | function comment_excerpt() {
|
---|
| 412 | echo apply_filters('comment_excerpt', get_comment_excerpt() );
|
---|
| 413 | }
|
---|
| 414 |
|
---|
| 415 | /**
|
---|
| 416 | * Retrieve the comment id of the current comment.
|
---|
| 417 | *
|
---|
| 418 | * @since 1.5.0
|
---|
| 419 | * @uses $comment
|
---|
| 420 | * @uses apply_filters() Calls the 'get_comment_ID' hook for the comment ID
|
---|
| 421 | *
|
---|
| 422 | * @return int The comment ID
|
---|
| 423 | */
|
---|
| 424 | function get_comment_ID() {
|
---|
| 425 | global $comment;
|
---|
| 426 | return apply_filters('get_comment_ID', $comment->comment_ID);
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | /**
|
---|
| 430 | * Displays the comment id of the current comment.
|
---|
| 431 | *
|
---|
| 432 | * @since 0.71
|
---|
| 433 | * @see get_comment_ID() Echos Result
|
---|
| 434 | */
|
---|
| 435 | function comment_ID() {
|
---|
| 436 | echo get_comment_ID();
|
---|
| 437 | }
|
---|
| 438 |
|
---|
| 439 | /**
|
---|
| 440 | * Retrieve the link to a given comment.
|
---|
| 441 | *
|
---|
| 442 | * @since 1.5.0
|
---|
| 443 | * @uses $comment
|
---|
| 444 | *
|
---|
| 445 | * @param object|string|int $comment Comment to retrieve.
|
---|
| 446 | * @param array $args Optional args.
|
---|
| 447 | * @return string The permalink to the given comment.
|
---|
| 448 | */
|
---|
| 449 | function get_comment_link( $comment = null, $args = array() ) {
|
---|
| 450 | global $wp_rewrite, $in_comment_loop;
|
---|
| 451 |
|
---|
| 452 | $comment = get_comment($comment);
|
---|
| 453 |
|
---|
| 454 | // Backwards compat
|
---|
| 455 | if ( !is_array($args) ) {
|
---|
| 456 | $page = $args;
|
---|
| 457 | $args = array();
|
---|
| 458 | $args['page'] = $page;
|
---|
| 459 | }
|
---|
| 460 |
|
---|
| 461 | $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
|
---|
| 462 | $args = wp_parse_args( $args, $defaults );
|
---|
| 463 |
|
---|
| 464 | if ( '' === $args['per_page'] && get_option('page_comments') )
|
---|
| 465 | $args['per_page'] = get_option('comments_per_page');
|
---|
| 466 |
|
---|
| 467 | if ( empty($args['per_page']) ) {
|
---|
| 468 | $args['per_page'] = 0;
|
---|
| 469 | $args['page'] = 0;
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | if ( $args['per_page'] ) {
|
---|
| 473 | if ( '' == $args['page'] )
|
---|
| 474 | $args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args );
|
---|
| 475 |
|
---|
| 476 | if ( $wp_rewrite->using_permalinks() )
|
---|
| 477 | $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' );
|
---|
| 478 | else
|
---|
| 479 | $link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) );
|
---|
| 480 | } else {
|
---|
| 481 | $link = get_permalink( $comment->comment_post_ID );
|
---|
| 482 | }
|
---|
| 483 |
|
---|
| 484 | return apply_filters( 'get_comment_link', $link . '#comment-' . $comment->comment_ID, $comment, $args );
|
---|
| 485 | }
|
---|
| 486 |
|
---|
| 487 | /**
|
---|
| 488 | * Retrieves the link to the current post comments.
|
---|
| 489 | *
|
---|
| 490 | * @since 1.5.0
|
---|
| 491 | *
|
---|
| 492 | * @return string The link to the comments
|
---|
| 493 | */
|
---|
| 494 | function get_comments_link() {
|
---|
| 495 | return get_permalink() . '#comments';
|
---|
| 496 | }
|
---|
| 497 |
|
---|
| 498 | /**
|
---|
| 499 | * Displays the link to the current post comments.
|
---|
| 500 | *
|
---|
| 501 | * @since 0.71
|
---|
| 502 | *
|
---|
| 503 | * @param string $deprecated Not Used
|
---|
| 504 | * @param bool $deprecated Not Used
|
---|
| 505 | */
|
---|
| 506 | function comments_link( $deprecated = '', $deprecated = '' ) {
|
---|
| 507 | echo get_comments_link();
|
---|
| 508 | }
|
---|
| 509 |
|
---|
| 510 | /**
|
---|
| 511 | * Retrieve the amount of comments a post has.
|
---|
| 512 | *
|
---|
| 513 | * @since 1.5.0
|
---|
| 514 | * @uses apply_filters() Calls the 'get_comments_number' hook on the number of comments
|
---|
| 515 | *
|
---|
| 516 | * @param int $post_id The Post ID
|
---|
| 517 | * @return int The number of comments a post has
|
---|
| 518 | */
|
---|
| 519 | function get_comments_number( $post_id = 0 ) {
|
---|
| 520 | global $id;
|
---|
| 521 | $post_id = (int) $post_id;
|
---|
| 522 |
|
---|
| 523 | if ( !$post_id )
|
---|
| 524 | $post_id = (int) $id;
|
---|
| 525 |
|
---|
| 526 | $post = get_post($post_id);
|
---|
| 527 | if ( ! isset($post->comment_count) )
|
---|
| 528 | $count = 0;
|
---|
| 529 | else
|
---|
| 530 | $count = $post->comment_count;
|
---|
| 531 |
|
---|
| 532 | return apply_filters('get_comments_number', $count);
|
---|
| 533 | }
|
---|
| 534 |
|
---|
| 535 | /**
|
---|
| 536 | * Display the language string for the number of comments the current post has.
|
---|
| 537 | *
|
---|
| 538 | * @since 0.71
|
---|
| 539 | * @uses $id
|
---|
| 540 | * @uses apply_filters() Calls the 'comments_number' hook on the output and number of comments respectively.
|
---|
| 541 | *
|
---|
| 542 | * @param string $zero Text for no comments
|
---|
| 543 | * @param string $one Text for one comment
|
---|
| 544 | * @param string $more Text for more than one comment
|
---|
| 545 | * @param string $deprecated Not used.
|
---|
| 546 | */
|
---|
| 547 | function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
|
---|
| 548 | global $id;
|
---|
| 549 | $number = get_comments_number($id);
|
---|
| 550 |
|
---|
| 551 | if ( $number > 1 )
|
---|
| 552 | $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);
|
---|
| 553 | elseif ( $number == 0 )
|
---|
| 554 | $output = ( false === $zero ) ? __('No Comments') : $zero;
|
---|
| 555 | else // must be one
|
---|
| 556 | $output = ( false === $one ) ? __('1 Comment') : $one;
|
---|
| 557 |
|
---|
| 558 | echo apply_filters('comments_number', $output, $number);
|
---|
| 559 | }
|
---|
| 560 |
|
---|
| 561 | /**
|
---|
| 562 | * Retrieve the text of the current comment.
|
---|
| 563 | *
|
---|
| 564 | * @since 1.5.0
|
---|
| 565 | * @uses $comment
|
---|
| 566 | *
|
---|
| 567 | * @return string The comment content
|
---|
| 568 | */
|
---|
| 569 | function get_comment_text() {
|
---|
| 570 | global $comment;
|
---|
| 571 | return apply_filters('get_comment_text', $comment->comment_content);
|
---|
| 572 | }
|
---|
| 573 |
|
---|
| 574 | /**
|
---|
| 575 | * Displays the text of the current comment.
|
---|
| 576 | *
|
---|
| 577 | * @since 0.71
|
---|
| 578 | * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display
|
---|
| 579 | * @uses get_comment_text() Gets the comment content
|
---|
| 580 | */
|
---|
| 581 | function comment_text() {
|
---|
| 582 | echo apply_filters('comment_text', get_comment_text() );
|
---|
| 583 | }
|
---|
| 584 |
|
---|
| 585 | /**
|
---|
| 586 | * Retrieve the comment time of the current comment.
|
---|
| 587 | *
|
---|
| 588 | * @since 1.5.0
|
---|
| 589 | * @uses $comment
|
---|
| 590 | * @uses apply_filter() Calls 'get_comment_time' hook with the formatted time, the $d parameter, and $gmt parameter passed.
|
---|
| 591 | *
|
---|
| 592 | * @param string $d Optional. The format of the time (defaults to user's config)
|
---|
| 593 | * @param bool $gmt Whether to use the GMT date
|
---|
| 594 | * @param bool $translate Whether to translate the time (for use in feeds)
|
---|
| 595 | * @return string The formatted time
|
---|
| 596 | */
|
---|
| 597 | function get_comment_time( $d = '', $gmt = false, $translate = true ) {
|
---|
| 598 | global $comment;
|
---|
| 599 | $comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date;
|
---|
| 600 | if ( '' == $d )
|
---|
| 601 | $date = mysql2date(get_option('time_format'), $comment_date, $translate);
|
---|
| 602 | else
|
---|
| 603 | $date = mysql2date($d, $comment_date, $translate);
|
---|
| 604 | return apply_filters('get_comment_time', $date, $d, $gmt);
|
---|
| 605 | }
|
---|
| 606 |
|
---|
| 607 | /**
|
---|
| 608 | * Display the comment time of the current comment.
|
---|
| 609 | *
|
---|
| 610 | * @since 0.71
|
---|
| 611 | *
|
---|
| 612 | * @param string $d Optional. The format of the time (defaults to user's config)
|
---|
| 613 | */
|
---|
| 614 | function comment_time( $d = '' ) {
|
---|
| 615 | echo get_comment_time($d);
|
---|
| 616 | }
|
---|
| 617 |
|
---|
| 618 | /**
|
---|
| 619 | * Retrieve the comment type of the current comment.
|
---|
| 620 | *
|
---|
| 621 | * @since 1.5.0
|
---|
| 622 | * @uses $comment
|
---|
| 623 | * @uses apply_filters() Calls the 'get_comment_type' hook on the comment type
|
---|
| 624 | *
|
---|
| 625 | * @return string The comment type
|
---|
| 626 | */
|
---|
| 627 | function get_comment_type() {
|
---|
| 628 | global $comment;
|
---|
| 629 |
|
---|
| 630 | if ( '' == $comment->comment_type )
|
---|
| 631 | $comment->comment_type = 'comment';
|
---|
| 632 |
|
---|
| 633 | return apply_filters('get_comment_type', $comment->comment_type);
|
---|
| 634 | }
|
---|
| 635 |
|
---|
| 636 | /**
|
---|
| 637 | * Display the comment type of the current comment.
|
---|
| 638 | *
|
---|
| 639 | * @since 0.71
|
---|
| 640 | *
|
---|
| 641 | * @param string $commenttxt The string to display for comment type
|
---|
| 642 | * @param string $trackbacktxt The string to display for trackback type
|
---|
| 643 | * @param string $pingbacktxt The string to display for pingback type
|
---|
| 644 | */
|
---|
| 645 | function comment_type($commenttxt = false, $trackbacktxt = false, $pingbacktxt = false) {
|
---|
| 646 | if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' );
|
---|
| 647 | if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' );
|
---|
| 648 | if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' );
|
---|
| 649 | $type = get_comment_type();
|
---|
| 650 | switch( $type ) {
|
---|
| 651 | case 'trackback' :
|
---|
| 652 | echo $trackbacktxt;
|
---|
| 653 | break;
|
---|
| 654 | case 'pingback' :
|
---|
| 655 | echo $pingbacktxt;
|
---|
| 656 | break;
|
---|
| 657 | default :
|
---|
| 658 | echo $commenttxt;
|
---|
| 659 | }
|
---|
| 660 | }
|
---|
| 661 |
|
---|
| 662 | /**
|
---|
| 663 | * Retrieve The current post's trackback URL.
|
---|
| 664 | *
|
---|
| 665 | * There is a check to see if permalink's have been enabled and if so, will
|
---|
| 666 | * retrieve the pretty path. If permalinks weren't enabled, the ID of the
|
---|
| 667 | * current post is used and appended to the correct page to go to.
|
---|
| 668 | *
|
---|
| 669 | * @since 1.5.0
|
---|
| 670 | * @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL
|
---|
| 671 | * @uses $id
|
---|
| 672 | *
|
---|
| 673 | * @return string The trackback URL after being filtered
|
---|
| 674 | */
|
---|
| 675 | function get_trackback_url() {
|
---|
| 676 | global $id;
|
---|
| 677 | if ( '' != get_option('permalink_structure') ) {
|
---|
| 678 | $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
|
---|
| 679 | } else {
|
---|
| 680 | $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . $id;
|
---|
| 681 | }
|
---|
| 682 | return apply_filters('trackback_url', $tb_url);
|
---|
| 683 | }
|
---|
| 684 |
|
---|
| 685 | /**
|
---|
| 686 | * Displays the current post's trackback URL.
|
---|
| 687 | *
|
---|
| 688 | * @since 0.71
|
---|
| 689 | * @uses get_trackback_url() Gets the trackback url for the current post
|
---|
| 690 | *
|
---|
| 691 | * @param bool $deprecated Remove backwards compat in 2.5
|
---|
| 692 | * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() for the result instead.
|
---|
| 693 | */
|
---|
| 694 | function trackback_url($deprecated = true) {
|
---|
| 695 | if ($deprecated) echo get_trackback_url();
|
---|
| 696 | else return get_trackback_url();
|
---|
| 697 | }
|
---|
| 698 |
|
---|
| 699 | /**
|
---|
| 700 | * Generates and displays the RDF for the trackback information of current post.
|
---|
| 701 | *
|
---|
| 702 | * @since 0.71
|
---|
| 703 | *
|
---|
| 704 | * @param int $deprecated Not used (Was $timezone = 0)
|
---|
| 705 | */
|
---|
| 706 | function trackback_rdf($deprecated = '') {
|
---|
| 707 | if (stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') === false) {
|
---|
| 708 | echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
---|
| 709 | xmlns:dc="http://purl.org/dc/elements/1.1/"
|
---|
| 710 | xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
|
---|
| 711 | <rdf:Description rdf:about="';
|
---|
| 712 | the_permalink();
|
---|
| 713 | echo '"'."\n";
|
---|
| 714 | echo ' dc:identifier="';
|
---|
| 715 | the_permalink();
|
---|
| 716 | echo '"'."\n";
|
---|
| 717 | echo ' dc:title="'.str_replace('--', '--', wptexturize(strip_tags(get_the_title()))).'"'."\n";
|
---|
| 718 | echo ' trackback:ping="'.get_trackback_url().'"'." />\n";
|
---|
| 719 | echo '</rdf:RDF>';
|
---|
| 720 | }
|
---|
| 721 | }
|
---|
| 722 |
|
---|
| 723 | /**
|
---|
| 724 | * Whether the current post is open for comments.
|
---|
| 725 | *
|
---|
| 726 | * @since 1.5.0
|
---|
| 727 | * @uses $post
|
---|
| 728 | *
|
---|
| 729 | * @param int $post_id An optional post ID to check instead of the current post.
|
---|
| 730 | * @return bool True if the comments are open
|
---|
| 731 | */
|
---|
| 732 | function comments_open( $post_id=NULL ) {
|
---|
| 733 |
|
---|
| 734 | $_post = get_post($post_id);
|
---|
| 735 |
|
---|
| 736 | $open = ( 'open' == $_post->comment_status );
|
---|
| 737 | return apply_filters( 'comments_open', $open, $post_id );
|
---|
| 738 | }
|
---|
| 739 |
|
---|
| 740 | /**
|
---|
| 741 | * Whether the current post is open for pings.
|
---|
| 742 | *
|
---|
| 743 | * @since 1.5.0
|
---|
| 744 | * @uses $post
|
---|
| 745 | *
|
---|
| 746 | * @param int $post_id An optional post ID to check instead of the current post.
|
---|
| 747 | * @return bool True if pings are accepted
|
---|
| 748 | */
|
---|
| 749 | function pings_open( $post_id = NULL ) {
|
---|
| 750 |
|
---|
| 751 | $_post = get_post($post_id);
|
---|
| 752 |
|
---|
| 753 | $open = ( 'open' == $_post->ping_status );
|
---|
| 754 | return apply_filters( 'pings_open', $open, $post_id );
|
---|
| 755 | }
|
---|
| 756 |
|
---|
| 757 | /**
|
---|
| 758 | * Displays form token for unfiltered comments.
|
---|
| 759 | *
|
---|
| 760 | * Will only display nonce token if the current user has permissions for
|
---|
| 761 | * unfiltered html. Won't display the token for other users.
|
---|
| 762 | *
|
---|
| 763 | * The function was backported to 2.0.10 and was added to versions 2.1.3 and
|
---|
| 764 | * above. Does not exist in versions prior to 2.0.10 in the 2.0 branch and in
|
---|
| 765 | * the 2.1 branch, prior to 2.1.3. Technically added in 2.2.0.
|
---|
| 766 | *
|
---|
| 767 | * Backported to 2.0.10.
|
---|
| 768 | *
|
---|
| 769 | * @since 2.1.3
|
---|
| 770 | * @uses $post Gets the ID of the current post for the token
|
---|
| 771 | */
|
---|
| 772 | function wp_comment_form_unfiltered_html_nonce() {
|
---|
| 773 | global $post;
|
---|
| 774 |
|
---|
| 775 | $post_id = 0;
|
---|
| 776 | if ( !empty($post) )
|
---|
| 777 | $post_id = $post->ID;
|
---|
| 778 |
|
---|
| 779 | if ( current_user_can('unfiltered_html') )
|
---|
| 780 | wp_nonce_field('unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment', false);
|
---|
| 781 | }
|
---|
| 782 |
|
---|
| 783 | /**
|
---|
| 784 | * Loads the comment template specified in $file.
|
---|
| 785 | *
|
---|
| 786 | * Will not display the comments template if not on single post or page, or if
|
---|
| 787 | * the post does not have comments.
|
---|
| 788 | *
|
---|
| 789 | * Uses the WordPress database object to query for the comments. The comments
|
---|
| 790 | * are passed through the 'comments_array' filter hook with the list of comments
|
---|
| 791 | * and the post ID respectively.
|
---|
| 792 | *
|
---|
| 793 | * The $file path is passed through a filter hook called, 'comments_template'
|
---|
| 794 | * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
|
---|
| 795 | * first and if it fails it will require the default comment themplate from the
|
---|
| 796 | * default theme. If either does not exist, then the WordPress process will be
|
---|
| 797 | * halted. It is advised for that reason, that the default theme is not deleted.
|
---|
| 798 | *
|
---|
| 799 | * @since 1.5.0
|
---|
| 800 | * @global array $comment List of comment objects for the current post
|
---|
| 801 | * @uses $wpdb
|
---|
| 802 | * @uses $id
|
---|
| 803 | * @uses $post
|
---|
| 804 | * @uses $withcomments Will not try to get the comments if the post has none.
|
---|
| 805 | *
|
---|
| 806 | * @param string $file Optional, default '/comments.php'. The file to load
|
---|
| 807 | * @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false.
|
---|
| 808 | * @return null Returns null if no comments appear
|
---|
| 809 | */
|
---|
| 810 | function comments_template( $file = '/comments.php', $separate_comments = false ) {
|
---|
| 811 | global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
|
---|
| 812 |
|
---|
| 813 | if ( ! (is_single() || is_page() || $withcomments) )
|
---|
| 814 | return;
|
---|
| 815 |
|
---|
| 816 | if ( empty($file) )
|
---|
| 817 | $file = '/comments.php';
|
---|
| 818 |
|
---|
| 819 | $req = get_option('require_name_email');
|
---|
| 820 | $commenter = wp_get_current_commenter();
|
---|
| 821 | extract($commenter, EXTR_SKIP);
|
---|
| 822 |
|
---|
| 823 | /** @todo Use API instead of SELECTs. */
|
---|
| 824 | if ( $user_ID) {
|
---|
| 825 | $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID));
|
---|
| 826 | } else if ( empty($comment_author) ) {
|
---|
| 827 | $comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') );
|
---|
| 828 | } else {
|
---|
| 829 | $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES), $comment_author_email));
|
---|
| 830 | }
|
---|
| 831 |
|
---|
| 832 | // keep $comments for legacy's sake
|
---|
| 833 | $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
|
---|
| 834 | $comments = &$wp_query->comments;
|
---|
| 835 | $wp_query->comment_count = count($wp_query->comments);
|
---|
| 836 | update_comment_cache($wp_query->comments);
|
---|
| 837 |
|
---|
| 838 | if ( $separate_comments ) {
|
---|
| 839 | $wp_query->comments_by_type = &separate_comments($comments);
|
---|
| 840 | $comments_by_type = &$wp_query->comments_by_type;
|
---|
| 841 | }
|
---|
| 842 |
|
---|
| 843 | $overridden_cpage = FALSE;
|
---|
| 844 | if ( '' == get_query_var('cpage') && get_option('page_comments') ) {
|
---|
| 845 | set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 );
|
---|
| 846 | $overridden_cpage = TRUE;
|
---|
| 847 | }
|
---|
| 848 |
|
---|
| 849 | if ( !defined('COMMENTS_TEMPLATE') || !COMMENTS_TEMPLATE)
|
---|
| 850 | define('COMMENTS_TEMPLATE', true);
|
---|
| 851 |
|
---|
| 852 | $include = apply_filters('comments_template', STYLESHEETPATH . $file );
|
---|
| 853 | if ( file_exists( $include ) )
|
---|
| 854 | require( $include );
|
---|
| 855 | elseif ( file_exists( TEMPLATEPATH . $file ) )
|
---|
| 856 | require( TEMPLATEPATH . $file );
|
---|
| 857 | else
|
---|
| 858 | require( get_theme_root() . '/default/comments.php');
|
---|
| 859 | }
|
---|
| 860 |
|
---|
| 861 | /**
|
---|
| 862 | * Displays the JS popup script to show a comment.
|
---|
| 863 | *
|
---|
| 864 | * If the $file parameter is empty, then the home page is assumed. The defaults
|
---|
| 865 | * for the window are 400px by 400px.
|
---|
| 866 | *
|
---|
| 867 | * For the comment link popup to work, this function has to be called or the
|
---|
| 868 | * normal comment link will be assumed.
|
---|
| 869 | *
|
---|
| 870 | * @since 0.71
|
---|
| 871 | * @global string $wpcommentspopupfile The URL to use for the popup window
|
---|
| 872 | * @global int $wpcommentsjavascript Whether to use JavaScript or not. Set when function is called
|
---|
| 873 | *
|
---|
| 874 | * @param int $width Optional. The width of the popup window
|
---|
| 875 | * @param int $height Optional. The height of the popup window
|
---|
| 876 | * @param string $file Optional. Sets the location of the popup window
|
---|
| 877 | */
|
---|
| 878 | function comments_popup_script($width=400, $height=400, $file='') {
|
---|
| 879 | global $wpcommentspopupfile, $wpcommentsjavascript;
|
---|
| 880 |
|
---|
| 881 | if (empty ($file)) {
|
---|
| 882 | $wpcommentspopupfile = ''; // Use the index.
|
---|
| 883 | } else {
|
---|
| 884 | $wpcommentspopupfile = $file;
|
---|
| 885 | }
|
---|
| 886 |
|
---|
| 887 | $wpcommentsjavascript = 1;
|
---|
| 888 | $javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";
|
---|
| 889 | echo $javascript;
|
---|
| 890 | }
|
---|
| 891 |
|
---|
| 892 | /**
|
---|
| 893 | * Displays the link to the comments popup window for the current post ID.
|
---|
| 894 | *
|
---|
| 895 | * Is not meant to be displayed on single posts and pages. Should be used on the
|
---|
| 896 | * lists of posts
|
---|
| 897 | *
|
---|
| 898 | * @since 0.71
|
---|
| 899 | * @uses $id
|
---|
| 900 | * @uses $wpcommentspopupfile
|
---|
| 901 | * @uses $wpcommentsjavascript
|
---|
| 902 | * @uses $post
|
---|
| 903 | *
|
---|
| 904 | * @param string $zero The string to display when no comments
|
---|
| 905 | * @param string $one The string to display when only one comment is available
|
---|
| 906 | * @param string $more The string to display when there are more than one comment
|
---|
| 907 | * @param string $css_class The CSS class to use for comments
|
---|
| 908 | * @param string $none The string to display when comments have been turned off
|
---|
| 909 | * @return null Returns null on single posts and pages.
|
---|
| 910 | */
|
---|
| 911 | function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
|
---|
| 912 | global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post;
|
---|
| 913 |
|
---|
| 914 | if ( false === $zero ) $zero = __( 'No Comments' );
|
---|
| 915 | if ( false === $one ) $one = __( '1 Comment' );
|
---|
| 916 | if ( false === $more ) $more = __( '% Comments' );
|
---|
| 917 | if ( false === $none ) $none = __( 'Comments Off' );
|
---|
| 918 |
|
---|
| 919 | $number = get_comments_number( $id );
|
---|
| 920 |
|
---|
| 921 | if ( 0 == $number && !comments_open() && !pings_open() ) {
|
---|
| 922 | echo '<span' . ((!empty($css_class)) ? ' class="' . $css_class . '"' : '') . '>' . $none . '</span>';
|
---|
| 923 | return;
|
---|
| 924 | }
|
---|
| 925 |
|
---|
| 926 | if ( post_password_required() ) {
|
---|
| 927 | echo __('Enter your password to view comments');
|
---|
| 928 | return;
|
---|
| 929 | }
|
---|
| 930 |
|
---|
| 931 | echo '<a href="';
|
---|
| 932 | if ( $wpcommentsjavascript ) {
|
---|
| 933 | if ( empty( $wpcommentspopupfile ) )
|
---|
| 934 | $home = get_option('home');
|
---|
| 935 | else
|
---|
| 936 | $home = get_option('siteurl');
|
---|
| 937 | echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
|
---|
| 938 | echo '" onclick="wpopen(this.href); return false"';
|
---|
| 939 | } else { // if comments_popup_script() is not in the template, display simple comment link
|
---|
| 940 | if ( 0 == $number )
|
---|
| 941 | echo get_permalink() . '#respond';
|
---|
| 942 | else
|
---|
| 943 | comments_link();
|
---|
| 944 | echo '"';
|
---|
| 945 | }
|
---|
| 946 |
|
---|
| 947 | if ( !empty( $css_class ) ) {
|
---|
| 948 | echo ' class="'.$css_class.'" ';
|
---|
| 949 | }
|
---|
| 950 | $title = esc_attr( get_the_title() );
|
---|
| 951 |
|
---|
| 952 | echo apply_filters( 'comments_popup_link_attributes', '' );
|
---|
| 953 |
|
---|
| 954 | echo ' title="' . sprintf( __('Comment on %s'), $title ) . '">';
|
---|
| 955 | comments_number( $zero, $one, $more, $number );
|
---|
| 956 | echo '</a>';
|
---|
| 957 | }
|
---|
| 958 |
|
---|
| 959 | /**
|
---|
| 960 | * Retrieve HTML content for reply to comment link.
|
---|
| 961 | *
|
---|
| 962 | * The default arguments that can be override are 'add_below', 'respond_id',
|
---|
| 963 | * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
|
---|
| 964 | * used, if the user must log in or register first before posting a comment. The
|
---|
| 965 | * 'reply_text' will be used, if they can post a reply. The 'add_below' and
|
---|
| 966 | * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
|
---|
| 967 | * parameters.
|
---|
| 968 | *
|
---|
| 969 | * @since 2.7.0
|
---|
| 970 | *
|
---|
| 971 | * @param array $args Optional. Override default options.
|
---|
| 972 | * @param int $comment Optional. Comment being replied to.
|
---|
| 973 | * @param int $post Optional. Post that the comment is going to be displayed on.
|
---|
| 974 | * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
|
---|
| 975 | */
|
---|
| 976 | function get_comment_reply_link($args = array(), $comment = null, $post = null) {
|
---|
| 977 | global $user_ID;
|
---|
| 978 |
|
---|
| 979 | $defaults = array('add_below' => 'comment', 'respond_id' => 'respond', 'reply_text' => __('Reply'),
|
---|
| 980 | 'login_text' => __('Log in to Reply'), 'depth' => 0, 'before' => '', 'after' => '');
|
---|
| 981 |
|
---|
| 982 | $args = wp_parse_args($args, $defaults);
|
---|
| 983 |
|
---|
| 984 | if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] )
|
---|
| 985 | return;
|
---|
| 986 |
|
---|
| 987 | extract($args, EXTR_SKIP);
|
---|
| 988 |
|
---|
| 989 | $comment = get_comment($comment);
|
---|
| 990 | $post = get_post($post);
|
---|
| 991 |
|
---|
| 992 | if ( !comments_open($post->ID) )
|
---|
| 993 | return false;
|
---|
| 994 |
|
---|
| 995 | $link = '';
|
---|
| 996 |
|
---|
| 997 | if ( get_option('comment_registration') && !$user_ID )
|
---|
| 998 | $link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $login_text . '</a>';
|
---|
| 999 | else
|
---|
| 1000 | $link = "<a rel='nofollow' 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>";
|
---|
| 1001 | return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post);
|
---|
| 1002 | }
|
---|
| 1003 |
|
---|
| 1004 | /**
|
---|
| 1005 | * Displays the HTML content for reply to comment link.
|
---|
| 1006 | *
|
---|
| 1007 | * @since 2.7.0
|
---|
| 1008 | * @see get_comment_reply_link() Echoes result
|
---|
| 1009 | *
|
---|
| 1010 | * @param array $args Optional. Override default options.
|
---|
| 1011 | * @param int $comment Optional. Comment being replied to.
|
---|
| 1012 | * @param int $post Optional. Post that the comment is going to be displayed on.
|
---|
| 1013 | * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
|
---|
| 1014 | */
|
---|
| 1015 | function comment_reply_link($args = array(), $comment = null, $post = null) {
|
---|
| 1016 | echo get_comment_reply_link($args, $comment, $post);
|
---|
| 1017 | }
|
---|
| 1018 |
|
---|
| 1019 | /**
|
---|
| 1020 | * Retrieve HTML content for reply to post link.
|
---|
| 1021 | *
|
---|
| 1022 | * The default arguments that can be override are 'add_below', 'respond_id',
|
---|
| 1023 | * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
|
---|
| 1024 | * used, if the user must log in or register first before posting a comment. The
|
---|
| 1025 | * 'reply_text' will be used, if they can post a reply. The 'add_below' and
|
---|
| 1026 | * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
|
---|
| 1027 | * parameters.
|
---|
| 1028 | *
|
---|
| 1029 | * @since 2.7.0
|
---|
| 1030 | *
|
---|
| 1031 | * @param array $args Optional. Override default options.
|
---|
| 1032 | * @param int|object $post Optional. Post that the comment is going to be displayed on. Defaults to current post.
|
---|
| 1033 | * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
|
---|
| 1034 | */
|
---|
| 1035 | function get_post_reply_link($args = array(), $post = null) {
|
---|
| 1036 | global $user_ID;
|
---|
| 1037 |
|
---|
| 1038 | $defaults = array('add_below' => 'post', 'respond_id' => 'respond', 'reply_text' => __('Leave a Comment'),
|
---|
| 1039 | 'login_text' => __('Log in to leave a Comment'), 'before' => '', 'after' => '');
|
---|
| 1040 |
|
---|
| 1041 | $args = wp_parse_args($args, $defaults);
|
---|
| 1042 | extract($args, EXTR_SKIP);
|
---|
| 1043 | $post = get_post($post);
|
---|
| 1044 |
|
---|
| 1045 | if ( !comments_open($post->ID) )
|
---|
| 1046 | return false;
|
---|
| 1047 |
|
---|
| 1048 | if ( get_option('comment_registration') && !$user_ID ) {
|
---|
| 1049 | $link = '<a rel="nofollow" href="' . wp_login_url( get_permalink() ) . '">' . $login_text . '</a>';
|
---|
| 1050 | } else {
|
---|
| 1051 | $link = "<a rel='nofollow' class='comment-reply-link' href='" . get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
|
---|
| 1052 | }
|
---|
| 1053 | return apply_filters('post_comments_link', $before . $link . $after, $post);
|
---|
| 1054 | }
|
---|
| 1055 |
|
---|
| 1056 | /**
|
---|
| 1057 | * Displays the HTML content for reply to post link.
|
---|
| 1058 | * @since 2.7.0
|
---|
| 1059 | * @see get_post_reply_link()
|
---|
| 1060 | *
|
---|
| 1061 | * @param array $args Optional. Override default options.
|
---|
| 1062 | * @param int|object $post Optional. Post that the comment is going to be displayed on.
|
---|
| 1063 | * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
|
---|
| 1064 | */
|
---|
| 1065 | function post_reply_link($args = array(), $post = null) {
|
---|
| 1066 | echo get_post_reply_link($args, $post);
|
---|
| 1067 | }
|
---|
| 1068 |
|
---|
| 1069 | /**
|
---|
| 1070 | * Retrieve HTML content for cancel comment reply link.
|
---|
| 1071 | *
|
---|
| 1072 | * @since 2.7.0
|
---|
| 1073 | *
|
---|
| 1074 | * @param string $text Optional. Text to display for cancel reply link.
|
---|
| 1075 | */
|
---|
| 1076 | function get_cancel_comment_reply_link($text = '') {
|
---|
| 1077 | if ( empty($text) )
|
---|
| 1078 | $text = __('Click here to cancel reply.');
|
---|
| 1079 |
|
---|
| 1080 | $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
|
---|
| 1081 | $link = esc_html( remove_query_arg('replytocom') ) . '#respond';
|
---|
| 1082 | return apply_filters('cancel_comment_reply_link', '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>', $link, $text);
|
---|
| 1083 | }
|
---|
| 1084 |
|
---|
| 1085 | /**
|
---|
| 1086 | * Display HTML content for cancel comment reply link.
|
---|
| 1087 | *
|
---|
| 1088 | * @since 2.7.0
|
---|
| 1089 | *
|
---|
| 1090 | * @param string $text Optional. Text to display for cancel reply link.
|
---|
| 1091 | */
|
---|
| 1092 | function cancel_comment_reply_link($text = '') {
|
---|
| 1093 | echo get_cancel_comment_reply_link($text);
|
---|
| 1094 | }
|
---|
| 1095 |
|
---|
| 1096 | /**
|
---|
| 1097 | * Output hidden input HTML for replying to comments.
|
---|
| 1098 | *
|
---|
| 1099 | * @since 2.7.0
|
---|
| 1100 | */
|
---|
| 1101 | function comment_id_fields() {
|
---|
| 1102 | global $id;
|
---|
| 1103 |
|
---|
| 1104 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
|
---|
| 1105 | echo "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
|
---|
| 1106 | echo "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
|
---|
| 1107 | }
|
---|
| 1108 |
|
---|
| 1109 | /**
|
---|
| 1110 | * Display text based on comment reply status. Only affects users with Javascript disabled.
|
---|
| 1111 | *
|
---|
| 1112 | * @since 2.7.0
|
---|
| 1113 | *
|
---|
| 1114 | * @param string $noreplytext Optional. Text to display when not replying to a comment.
|
---|
| 1115 | * @param string $replytext Optional. Text to display when replying to a comment. Accepts "%s" for the author of the comment being replied to.
|
---|
| 1116 | * @param string $linktoparent Optional. Boolean to control making the author's name a link to their comment.
|
---|
| 1117 | */
|
---|
| 1118 | function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = TRUE ) {
|
---|
| 1119 | global $comment;
|
---|
| 1120 |
|
---|
| 1121 | if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' );
|
---|
| 1122 | if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' );
|
---|
| 1123 |
|
---|
| 1124 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
|
---|
| 1125 |
|
---|
| 1126 | if ( 0 == $replytoid )
|
---|
| 1127 | echo $noreplytext;
|
---|
| 1128 | else {
|
---|
| 1129 | $comment = get_comment($replytoid);
|
---|
| 1130 | $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author();
|
---|
| 1131 | printf( $replytext, $author );
|
---|
| 1132 | }
|
---|
| 1133 | }
|
---|
| 1134 |
|
---|
| 1135 | /**
|
---|
| 1136 | * HTML comment list class.
|
---|
| 1137 | *
|
---|
| 1138 | * @package WordPress
|
---|
| 1139 | * @uses Walker
|
---|
| 1140 | * @since unknown
|
---|
| 1141 | */
|
---|
| 1142 | class Walker_Comment extends Walker {
|
---|
| 1143 | /**
|
---|
| 1144 | * @see Walker::$tree_type
|
---|
| 1145 | * @since unknown
|
---|
| 1146 | * @var string
|
---|
| 1147 | */
|
---|
| 1148 | var $tree_type = 'comment';
|
---|
| 1149 |
|
---|
| 1150 | /**
|
---|
| 1151 | * @see Walker::$db_fields
|
---|
| 1152 | * @since unknown
|
---|
| 1153 | * @var array
|
---|
| 1154 | */
|
---|
| 1155 | var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
|
---|
| 1156 |
|
---|
| 1157 | /**
|
---|
| 1158 | * @see Walker::start_lvl()
|
---|
| 1159 | * @since unknown
|
---|
| 1160 | *
|
---|
| 1161 | * @param string $output Passed by reference. Used to append additional content.
|
---|
| 1162 | * @param int $depth Depth of comment.
|
---|
| 1163 | * @param array $args Uses 'style' argument for type of HTML list.
|
---|
| 1164 | */
|
---|
| 1165 | function start_lvl(&$output, $depth, $args) {
|
---|
| 1166 | $GLOBALS['comment_depth'] = $depth + 1;
|
---|
| 1167 |
|
---|
| 1168 | switch ( $args['style'] ) {
|
---|
| 1169 | case 'div':
|
---|
| 1170 | break;
|
---|
| 1171 | case 'ol':
|
---|
| 1172 | echo "<ol class='children'>\n";
|
---|
| 1173 | break;
|
---|
| 1174 | default:
|
---|
| 1175 | case 'ul':
|
---|
| 1176 | echo "<ul class='children'>\n";
|
---|
| 1177 | break;
|
---|
| 1178 | }
|
---|
| 1179 | }
|
---|
| 1180 |
|
---|
| 1181 | /**
|
---|
| 1182 | * @see Walker::end_lvl()
|
---|
| 1183 | * @since unknown
|
---|
| 1184 | *
|
---|
| 1185 | * @param string $output Passed by reference. Used to append additional content.
|
---|
| 1186 | * @param int $depth Depth of comment.
|
---|
| 1187 | * @param array $args Will only append content if style argument value is 'ol' or 'ul'.
|
---|
| 1188 | */
|
---|
| 1189 | function end_lvl(&$output, $depth, $args) {
|
---|
| 1190 | $GLOBALS['comment_depth'] = $depth + 1;
|
---|
| 1191 |
|
---|
| 1192 | switch ( $args['style'] ) {
|
---|
| 1193 | case 'div':
|
---|
| 1194 | break;
|
---|
| 1195 | case 'ol':
|
---|
| 1196 | echo "</ol>\n";
|
---|
| 1197 | break;
|
---|
| 1198 | default:
|
---|
| 1199 | case 'ul':
|
---|
| 1200 | echo "</ul>\n";
|
---|
| 1201 | break;
|
---|
| 1202 | }
|
---|
| 1203 | }
|
---|
| 1204 |
|
---|
| 1205 | /**
|
---|
| 1206 | * @see Walker::start_el()
|
---|
| 1207 | * @since unknown
|
---|
| 1208 | *
|
---|
| 1209 | * @param string $output Passed by reference. Used to append additional content.
|
---|
| 1210 | * @param object $comment Comment data object.
|
---|
| 1211 | * @param int $depth Depth of comment in reference to parents.
|
---|
| 1212 | * @param array $args
|
---|
| 1213 | */
|
---|
| 1214 | function start_el(&$output, $comment, $depth, $args) {
|
---|
| 1215 | $depth++;
|
---|
| 1216 | $GLOBALS['comment_depth'] = $depth;
|
---|
| 1217 |
|
---|
| 1218 | if ( !empty($args['callback']) ) {
|
---|
| 1219 | call_user_func($args['callback'], $comment, $args, $depth);
|
---|
| 1220 | return;
|
---|
| 1221 | }
|
---|
| 1222 |
|
---|
| 1223 | $GLOBALS['comment'] = $comment;
|
---|
| 1224 | extract($args, EXTR_SKIP);
|
---|
| 1225 |
|
---|
| 1226 | if ( 'div' == $args['style'] ) {
|
---|
| 1227 | $tag = 'div';
|
---|
| 1228 | $add_below = 'comment';
|
---|
| 1229 | } else {
|
---|
| 1230 | $tag = 'li';
|
---|
| 1231 | $add_below = 'div-comment';
|
---|
| 1232 | }
|
---|
| 1233 | ?>
|
---|
| 1234 | <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
|
---|
| 1235 | <?php if ( 'ul' == $args['style'] ) : ?>
|
---|
| 1236 | <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
|
---|
| 1237 | <?php endif; ?>
|
---|
| 1238 | <div class="comment-author vcard">
|
---|
| 1239 | <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
|
---|
| 1240 | <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
|
---|
| 1241 | </div>
|
---|
| 1242 | <?php if ($comment->comment_approved == '0') : ?>
|
---|
| 1243 | <em><?php _e('Your comment is awaiting moderation.') ?></em>
|
---|
| 1244 | <br />
|
---|
| 1245 | <?php endif; ?>
|
---|
| 1246 |
|
---|
| 1247 | <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','') ?></div>
|
---|
| 1248 |
|
---|
| 1249 | <?php comment_text() ?>
|
---|
| 1250 |
|
---|
| 1251 | <div class="reply">
|
---|
| 1252 | <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
|
---|
| 1253 | </div>
|
---|
| 1254 | <?php if ( 'ul' == $args['style'] ) : ?>
|
---|
| 1255 | </div>
|
---|
| 1256 | <?php endif; ?>
|
---|
| 1257 | <?php
|
---|
| 1258 | }
|
---|
| 1259 |
|
---|
| 1260 | /**
|
---|
| 1261 | * @see Walker::end_el()
|
---|
| 1262 | * @since unknown
|
---|
| 1263 | *
|
---|
| 1264 | * @param string $output Passed by reference. Used to append additional content.
|
---|
| 1265 | * @param object $comment
|
---|
| 1266 | * @param int $depth Depth of comment.
|
---|
| 1267 | * @param array $args
|
---|
| 1268 | */
|
---|
| 1269 | function end_el(&$output, $comment, $depth, $args) {
|
---|
| 1270 | if ( !empty($args['end-callback']) ) {
|
---|
| 1271 | call_user_func($args['end-callback'], $comment, $args, $depth);
|
---|
| 1272 | return;
|
---|
| 1273 | }
|
---|
| 1274 | if ( 'div' == $args['style'] )
|
---|
| 1275 | echo "</div>\n";
|
---|
| 1276 | else
|
---|
| 1277 | echo "</li>\n";
|
---|
| 1278 | }
|
---|
| 1279 |
|
---|
| 1280 | }
|
---|
| 1281 |
|
---|
| 1282 | /**
|
---|
| 1283 | * List comments
|
---|
| 1284 | *
|
---|
| 1285 | * Used in the comments.php template to list comments for a particular post
|
---|
| 1286 | *
|
---|
| 1287 | * @since 2.7.0
|
---|
| 1288 | * @uses Walker_Comment
|
---|
| 1289 | *
|
---|
| 1290 | * @param string|array $args Formatting options
|
---|
| 1291 | * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
|
---|
| 1292 | */
|
---|
| 1293 | function wp_list_comments($args = array(), $comments = null ) {
|
---|
| 1294 | global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
|
---|
| 1295 |
|
---|
| 1296 | $in_comment_loop = true;
|
---|
| 1297 |
|
---|
| 1298 | $comment_alt = $comment_thread_alt = 0;
|
---|
| 1299 | $comment_depth = 1;
|
---|
| 1300 |
|
---|
| 1301 | $defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
|
---|
| 1302 | 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
|
---|
| 1303 |
|
---|
| 1304 | $r = wp_parse_args( $args, $defaults );
|
---|
| 1305 |
|
---|
| 1306 | // Figure out what comments we'll be looping through ($_comments)
|
---|
| 1307 | if ( null !== $comments ) {
|
---|
| 1308 | $comments = (array) $comments;
|
---|
| 1309 | if ( empty($comments) )
|
---|
| 1310 | return;
|
---|
| 1311 | if ( 'all' != $r['type'] ) {
|
---|
| 1312 | $comments_by_type = &separate_comments($comments);
|
---|
| 1313 | if ( empty($comments_by_type[$r['type']]) )
|
---|
| 1314 | return;
|
---|
| 1315 | $_comments = $comments_by_type[$r['type']];
|
---|
| 1316 | } else {
|
---|
| 1317 | $_comments = $comments;
|
---|
| 1318 | }
|
---|
| 1319 | } else {
|
---|
| 1320 | if ( empty($wp_query->comments) )
|
---|
| 1321 | return;
|
---|
| 1322 | if ( 'all' != $r['type'] ) {
|
---|
| 1323 | if ( empty($wp_query->comments_by_type) )
|
---|
| 1324 | $wp_query->comments_by_type = &separate_comments($wp_query->comments);
|
---|
| 1325 | if ( empty($wp_query->comments_by_type[$r['type']]) )
|
---|
| 1326 | return;
|
---|
| 1327 | $_comments = $wp_query->comments_by_type[$r['type']];
|
---|
| 1328 | } else {
|
---|
| 1329 | $_comments = $wp_query->comments;
|
---|
| 1330 | }
|
---|
| 1331 | }
|
---|
| 1332 |
|
---|
| 1333 | if ( '' === $r['per_page'] && get_option('page_comments') )
|
---|
| 1334 | $r['per_page'] = get_query_var('comments_per_page');
|
---|
| 1335 |
|
---|
| 1336 | if ( empty($r['per_page']) ) {
|
---|
| 1337 | $r['per_page'] = 0;
|
---|
| 1338 | $r['page'] = 0;
|
---|
| 1339 | }
|
---|
| 1340 |
|
---|
| 1341 | if ( '' === $r['max_depth'] ) {
|
---|
| 1342 | if ( get_option('thread_comments') )
|
---|
| 1343 | $r['max_depth'] = get_option('thread_comments_depth');
|
---|
| 1344 | else
|
---|
| 1345 | $r['max_depth'] = -1;
|
---|
| 1346 | }
|
---|
| 1347 |
|
---|
| 1348 | if ( '' === $r['page'] ) {
|
---|
| 1349 | if ( empty($overridden_cpage) ) {
|
---|
| 1350 | $r['page'] = get_query_var('cpage');
|
---|
| 1351 | } else {
|
---|
| 1352 | $threaded = ( -1 == $r['max_depth'] ) ? false : true;
|
---|
| 1353 | $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1;
|
---|
| 1354 | set_query_var( 'cpage', $r['page'] );
|
---|
| 1355 | }
|
---|
| 1356 | }
|
---|
| 1357 | // Validation check
|
---|
| 1358 | $r['page'] = intval($r['page']);
|
---|
| 1359 | if ( 0 == $r['page'] && 0 != $r['per_page'] )
|
---|
| 1360 | $r['page'] = 1;
|
---|
| 1361 |
|
---|
| 1362 | if ( null === $r['reverse_top_level'] )
|
---|
| 1363 | $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ) ? TRUE : FALSE;
|
---|
| 1364 |
|
---|
| 1365 | extract( $r, EXTR_SKIP );
|
---|
| 1366 |
|
---|
| 1367 | if ( empty($walker) )
|
---|
| 1368 | $walker = new Walker_Comment;
|
---|
| 1369 |
|
---|
| 1370 | $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
|
---|
| 1371 | $wp_query->max_num_comment_pages = $walker->max_pages;
|
---|
| 1372 |
|
---|
| 1373 | $in_comment_loop = false;
|
---|
| 1374 | }
|
---|
| 1375 |
|
---|
| 1376 | ?>
|
---|