wp/wp-includes/comment-template.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    27 	if ( ! empty( $comment->comment_ID ) ) {
    27 	if ( ! empty( $comment->comment_ID ) ) {
    28 		$comment_id = $comment->comment_ID;
    28 		$comment_id = $comment->comment_ID;
    29 	} elseif ( is_scalar( $comment_id ) ) {
    29 	} elseif ( is_scalar( $comment_id ) ) {
    30 		$comment_id = (string) $comment_id;
    30 		$comment_id = (string) $comment_id;
    31 	} else {
    31 	} else {
    32 		$comment_id = '';
    32 		$comment_id = '0';
    33 	}
    33 	}
    34 
    34 
    35 	if ( empty( $comment->comment_author ) ) {
    35 	if ( empty( $comment->comment_author ) ) {
    36 		$user = ! empty( $comment->user_id ) ? get_userdata( $comment->user_id ) : false;
    36 		$user = ! empty( $comment->user_id ) ? get_userdata( $comment->user_id ) : false;
    37 		if ( $user ) {
    37 		if ( $user ) {
   231  * @return string The comment author name or HTML link for author's URL.
   231  * @return string The comment author name or HTML link for author's URL.
   232  */
   232  */
   233 function get_comment_author_link( $comment_id = 0 ) {
   233 function get_comment_author_link( $comment_id = 0 ) {
   234 	$comment = get_comment( $comment_id );
   234 	$comment = get_comment( $comment_id );
   235 
   235 
   236 	$comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
   236 	if ( ! empty( $comment->comment_ID ) ) {
       
   237 		$comment_id = $comment->comment_ID;
       
   238 	} elseif ( is_scalar( $comment_id ) ) {
       
   239 		$comment_id = (string) $comment_id;
       
   240 	} else {
       
   241 		$comment_id = '0';
       
   242 	}
   237 
   243 
   238 	$comment_author_url = get_comment_author_url( $comment );
   244 	$comment_author_url = get_comment_author_url( $comment );
   239 	$comment_author     = get_comment_author( $comment );
   245 	$comment_author     = get_comment_author( $comment );
   240 
   246 
   241 	if ( empty( $comment_author_url ) || 'http://' === $comment_author_url ) {
   247 	if ( empty( $comment_author_url ) || 'http://' === $comment_author_url ) {
   556 	}
   562 	}
   557 
   563 
   558 	++$comment_alt;
   564 	++$comment_alt;
   559 
   565 
   560 	// Alt for top-level comments.
   566 	// Alt for top-level comments.
   561 	if ( 1 == $comment_depth ) {
   567 	if ( 1 === $comment_depth ) {
   562 		if ( $comment_thread_alt % 2 ) {
   568 		if ( $comment_thread_alt % 2 ) {
   563 			$classes[] = 'thread-odd';
   569 			$classes[] = 'thread-odd';
   564 			$classes[] = 'thread-alt';
   570 			$classes[] = 'thread-alt';
   565 		} else {
   571 		} else {
   566 			$classes[] = 'thread-even';
   572 			$classes[] = 'thread-even';
   806 			$args['page']     = 0;
   812 			$args['page']     = 0;
   807 		}
   813 		}
   808 
   814 
   809 		$cpage = $args['page'];
   815 		$cpage = $args['page'];
   810 
   816 
   811 		if ( '' == $cpage ) {
   817 		if ( '' === $cpage ) {
   812 			if ( ! empty( $in_comment_loop ) ) {
   818 			if ( ! empty( $in_comment_loop ) ) {
   813 				$cpage = get_query_var( 'cpage' );
   819 				$cpage = (int) get_query_var( 'cpage' );
   814 			} else {
   820 			} else {
   815 				// Requires a database hit, so we only do it when we can't figure out from context.
   821 				// Requires a database hit, so we only do it when we can't figure out from context.
   816 				$cpage = get_page_of_comment( $comment->comment_ID, $args );
   822 				$cpage = get_page_of_comment( $comment->comment_ID, $args );
   817 			}
   823 			}
   818 		}
   824 		}
   953  * @param string      $more Optional. Text for more than one comment. Default false.
   959  * @param string      $more Optional. Text for more than one comment. Default false.
   954  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`.
   960  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`.
   955  * @return string Language string for the number of comments a post has.
   961  * @return string Language string for the number of comments a post has.
   956  */
   962  */
   957 function get_comments_number_text( $zero = false, $one = false, $more = false, $post = 0 ) {
   963 function get_comments_number_text( $zero = false, $one = false, $more = false, $post = 0 ) {
   958 	$comments_number = get_comments_number( $post );
   964 	$comments_number = (int) get_comments_number( $post );
   959 
   965 
   960 	if ( $comments_number > 1 ) {
   966 	if ( $comments_number > 1 ) {
   961 		if ( false === $more ) {
   967 		if ( false === $more ) {
   962 			$comments_number_text = sprintf(
   968 			$comments_number_text = sprintf(
   963 				/* translators: %s: Number of comments. */
   969 				/* translators: %s: Number of comments. */
   988 				}
   994 				}
   989 			}
   995 			}
   990 
   996 
   991 			$comments_number_text = str_replace( '%', number_format_i18n( $comments_number ), $more );
   997 			$comments_number_text = str_replace( '%', number_format_i18n( $comments_number ), $more );
   992 		}
   998 		}
   993 	} elseif ( 0 == $comments_number ) {
   999 	} elseif ( 0 === $comments_number ) {
   994 		$comments_number_text = ( false === $zero ) ? __( 'No Comments' ) : $zero;
  1000 		$comments_number_text = ( false === $zero ) ? __( 'No Comments' ) : $zero;
   995 	} else { // Must be one.
  1001 	} else { // Must be one.
   996 		$comments_number_text = ( false === $one ) ? __( '1 Comment' ) : $one;
  1002 		$comments_number_text = ( false === $one ) ? __( '1 Comment' ) : $one;
   997 	}
  1003 	}
   998 
  1004 
  1597 		$wp_query->comments_by_type = array();
  1603 		$wp_query->comments_by_type = array();
  1598 	}
  1604 	}
  1599 
  1605 
  1600 	$overridden_cpage = false;
  1606 	$overridden_cpage = false;
  1601 
  1607 
  1602 	if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) {
  1608 	if ( '' === get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) {
  1603 		set_query_var( 'cpage', 'newest' === get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 );
  1609 		set_query_var( 'cpage', 'newest' === get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 );
  1604 		$overridden_cpage = true;
  1610 		$overridden_cpage = true;
  1605 	}
  1611 	}
  1606 
  1612 
  1607 	if ( ! defined( 'COMMENTS_TEMPLATE' ) ) {
  1613 	if ( ! defined( 'COMMENTS_TEMPLATE' ) ) {
  1640  * @param false|string $none      Optional. String to display when comments have been turned off. Default false.
  1646  * @param false|string $none      Optional. String to display when comments have been turned off. Default false.
  1641  */
  1647  */
  1642 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
  1648 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
  1643 	$post_id         = get_the_ID();
  1649 	$post_id         = get_the_ID();
  1644 	$post_title      = get_the_title();
  1650 	$post_title      = get_the_title();
  1645 	$comments_number = get_comments_number( $post_id );
  1651 	$comments_number = (int) get_comments_number( $post_id );
  1646 
  1652 
  1647 	if ( false === $zero ) {
  1653 	if ( false === $zero ) {
  1648 		/* translators: %s: Post title. */
  1654 		/* translators: %s: Post title. */
  1649 		$zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $post_title );
  1655 		$zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $post_title );
  1650 	}
  1656 	}
  1667 	if ( false === $none ) {
  1673 	if ( false === $none ) {
  1668 		/* translators: %s: Post title. */
  1674 		/* translators: %s: Post title. */
  1669 		$none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $post_title );
  1675 		$none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $post_title );
  1670 	}
  1676 	}
  1671 
  1677 
  1672 	if ( 0 == $comments_number && ! comments_open() && ! pings_open() ) {
  1678 	if ( 0 === $comments_number && ! comments_open() && ! pings_open() ) {
  1673 		printf(
  1679 		printf(
  1674 			'<span%1$s>%2$s</span>',
  1680 			'<span%1$s>%2$s</span>',
  1675 			! empty( $css_class ) ? ' class="' . esc_attr( $css_class ) . '"' : '',
  1681 			! empty( $css_class ) ? ' class="' . esc_attr( $css_class ) . '"' : '',
  1676 			$none
  1682 			$none
  1677 		);
  1683 		);
  1681 	if ( post_password_required() ) {
  1687 	if ( post_password_required() ) {
  1682 		_e( 'Enter your password to view comments.' );
  1688 		_e( 'Enter your password to view comments.' );
  1683 		return;
  1689 		return;
  1684 	}
  1690 	}
  1685 
  1691 
  1686 	if ( 0 == $comments_number ) {
  1692 	if ( 0 === $comments_number ) {
  1687 		$respond_link = get_permalink() . '#respond';
  1693 		$respond_link = get_permalink() . '#respond';
  1688 		/**
  1694 		/**
  1689 		 * Filters the respond link when a post has no comments.
  1695 		 * Filters the respond link when a post has no comments.
  1690 		 *
  1696 		 *
  1691 		 * @since 4.4.0
  1697 		 * @since 4.4.0
  1725  * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
  1731  * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
  1726  *
  1732  *
  1727  * @param array          $args {
  1733  * @param array          $args {
  1728  *     Optional. Override default arguments.
  1734  *     Optional. Override default arguments.
  1729  *
  1735  *
  1730  *     @type string $add_below  The first part of the selector used to identify the comment to respond below.
  1736  *     @type string $add_below          The first part of the selector used to identify the comment to respond below.
  1731  *                              The resulting value is passed as the first parameter to addComment.moveForm(),
  1737  *                                      The resulting value is passed as the first parameter to addComment.moveForm(),
  1732  *                              concatenated as $add_below-$comment->comment_ID. Default 'comment'.
  1738  *                                      concatenated as $add_below-$comment->comment_ID. Default 'comment'.
  1733  *     @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
  1739  *     @type string $respond_id         The selector identifying the responding comment. Passed as the third parameter
  1734  *                              to addComment.moveForm(), and appended to the link URL as a hash value.
  1740  *                                      to addComment.moveForm(), and appended to the link URL as a hash value.
  1735  *                              Default 'respond'.
  1741  *                                      Default 'respond'.
  1736  *     @type string $reply_text The text of the Reply link. Default 'Reply'.
  1742  *     @type string $reply_text         The visible text of the Reply link. Default 'Reply'.
  1737  *     @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
  1743  *     @type string $reply_to_text      The accessible name of the Reply link, using `%s` as a placeholder
  1738  *     @type int    $max_depth  The max depth of the comment tree. Default 0.
  1744  *                                      for the comment author's name. Default 'Reply to %s'.
  1739  *     @type int    $depth      The depth of the new comment. Must be greater than 0 and less than the value
  1745  *                                      Should start with the visible `reply_text` value.
  1740  *                              of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
  1746  *     @type bool   $show_reply_to_text Whether to use `reply_to_text` as visible link text. Default false.
  1741  *     @type string $before     The text or HTML to add before the reply link. Default empty.
  1747  *     @type string $login_text         The text of the link to reply if logged out. Default 'Log in to Reply'.
  1742  *     @type string $after      The text or HTML to add after the reply link. Default empty.
  1748  *     @type int    $max_depth          The max depth of the comment tree. Default 0.
       
  1749  *     @type int    $depth              The depth of the new comment. Must be greater than 0 and less than the value
       
  1750  *                                      of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
       
  1751  *     @type string $before             The text or HTML to add before the reply link. Default empty.
       
  1752  *     @type string $after              The text or HTML to add after the reply link. Default empty.
  1743  * }
  1753  * }
  1744  * @param int|WP_Comment $comment Optional. Comment being replied to. Default current comment.
  1754  * @param int|WP_Comment $comment Optional. Comment being replied to. Default current comment.
  1745  * @param int|WP_Post    $post    Optional. Post ID or WP_Post object the comment is going to be displayed on.
  1755  * @param int|WP_Post    $post    Optional. Post ID or WP_Post object the comment is going to be displayed on.
  1746  *                                Default current post.
  1756  *                                Default current post.
  1747  * @return string|false|null Link to show comment form, if successful. False, if comments are closed.
  1757  * @return string|false|null Link to show comment form, if successful. False, if comments are closed.
  1748  */
  1758  */
  1749 function get_comment_reply_link( $args = array(), $comment = null, $post = null ) {
  1759 function get_comment_reply_link( $args = array(), $comment = null, $post = null ) {
  1750 	$defaults = array(
  1760 	$defaults = array(
  1751 		'add_below'     => 'comment',
  1761 		'add_below'          => 'comment',
  1752 		'respond_id'    => 'respond',
  1762 		'respond_id'         => 'respond',
  1753 		'reply_text'    => __( 'Reply' ),
  1763 		'reply_text'         => __( 'Reply' ),
  1754 		/* translators: Comment reply button text. %s: Comment author name. */
  1764 		/* translators: Comment reply button text. %s: Comment author name. */
  1755 		'reply_to_text' => __( 'Reply to %s' ),
  1765 		'reply_to_text'      => __( 'Reply to %s' ),
  1756 		'login_text'    => __( 'Log in to Reply' ),
  1766 		'login_text'         => __( 'Log in to Reply' ),
  1757 		'max_depth'     => 0,
  1767 		'max_depth'          => 0,
  1758 		'depth'         => 0,
  1768 		'depth'              => 0,
  1759 		'before'        => '',
  1769 		'before'             => '',
  1760 		'after'         => '',
  1770 		'after'              => '',
       
  1771 		'show_reply_to_text' => false,
  1761 	);
  1772 	);
  1762 
  1773 
  1763 	$args = wp_parse_args( $args, $defaults );
  1774 	$args = wp_parse_args( $args, $defaults );
  1764 
  1775 
  1765 	if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) {
  1776 	$args['max_depth'] = (int) $args['max_depth'];
       
  1777 	$args['depth']     = (int) $args['depth'];
       
  1778 
       
  1779 	if ( 0 === $args['depth'] || $args['max_depth'] <= $args['depth'] ) {
  1766 		return;
  1780 		return;
  1767 	}
  1781 	}
  1768 
  1782 
  1769 	$comment = get_comment( $comment );
  1783 	$comment = get_comment( $comment );
  1770 
  1784 
  1821 			$data_attribute_string .= " data-{$name}=\"" . esc_attr( $value ) . '"';
  1835 			$data_attribute_string .= " data-{$name}=\"" . esc_attr( $value ) . '"';
  1822 		}
  1836 		}
  1823 
  1837 
  1824 		$data_attribute_string = trim( $data_attribute_string );
  1838 		$data_attribute_string = trim( $data_attribute_string );
  1825 
  1839 
       
  1840 		$reply_text = $args['show_reply_to_text']
       
  1841 			? sprintf( $args['reply_to_text'], get_comment_author( $comment ) )
       
  1842 			: $args['reply_text'];
       
  1843 
       
  1844 		$aria_label = $args['show_reply_to_text'] ? '' : sprintf( $args['reply_to_text'], get_comment_author( $comment ) );
       
  1845 
  1826 		$link = sprintf(
  1846 		$link = sprintf(
  1827 			"<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>",
  1847 			'<a rel="nofollow" class="comment-reply-link" href="%s" %s%s>%s</a>',
  1828 			esc_url(
  1848 			esc_url(
  1829 				add_query_arg(
  1849 				add_query_arg(
  1830 					array(
  1850 					array(
  1831 						'replytocom'      => $comment->comment_ID,
  1851 						'replytocom'      => $comment->comment_ID,
  1832 						'unapproved'      => false,
  1852 						'unapproved'      => false,
  1834 					),
  1854 					),
  1835 					$permalink
  1855 					$permalink
  1836 				)
  1856 				)
  1837 			) . '#' . $args['respond_id'],
  1857 			) . '#' . $args['respond_id'],
  1838 			$data_attribute_string,
  1858 			$data_attribute_string,
  1839 			esc_attr( sprintf( $args['reply_to_text'], get_comment_author( $comment ) ) ),
  1859 			$aria_label ? ' aria-label="' . esc_attr( $aria_label ) . '"' : '',
  1840 			$args['reply_text']
  1860 			$reply_text
  1841 		);
  1861 		);
  1842 	}
  1862 	}
  1843 
  1863 
  1844 	$comment_reply_link = $args['before'] . $link . $args['after'];
  1864 	$comment_reply_link = $args['before'] . $link . $args['after'];
  1845 
  1865 
  2081  * @since 2.7.0
  2101  * @since 2.7.0
  2082  * @since 6.2.0 Added the `$post` parameter.
  2102  * @since 6.2.0 Added the `$post` parameter.
  2083  *
  2103  *
  2084  * @global WP_Comment $comment Global comment object.
  2104  * @global WP_Comment $comment Global comment object.
  2085  *
  2105  *
  2086  * @param string|false      $no_reply_text  Optional. Text to display when not replying to a comment.
  2106  * @param string|false     $no_reply_text  Optional. Text to display when not replying to a comment.
  2087  *                                          Default false.
  2107  *                                         Default false.
  2088  * @param string|false      $reply_text     Optional. Text to display when replying to a comment.
  2108  * @param string|false     $reply_text     Optional. Text to display when replying to a comment.
  2089  *                                          Default false. Accepts "%s" for the author of the comment
  2109  *                                         Default false. Accepts "%s" for the author of the comment
  2090  *                                          being replied to.
  2110  *                                         being replied to.
  2091  * @param bool              $link_to_parent Optional. Boolean to control making the author's name a link
  2111  * @param bool             $link_to_parent Optional. Boolean to control making the author's name a link
  2092  *                                          to their comment. Default true.
  2112  *                                         to their comment. Default true.
  2093  * @param int|WP_Post|null  $post           Optional. The post that the comment form is being displayed for.
  2113  * @param int|WP_Post|null $post           Optional. The post that the comment form is being displayed for.
  2094  *                                          Defaults to the current global post.
  2114  *                                         Defaults to the current global post.
  2095  */
  2115  */
  2096 function comment_form_title( $no_reply_text = false, $reply_text = false, $link_to_parent = true, $post = null ) {
  2116 function comment_form_title( $no_reply_text = false, $reply_text = false, $link_to_parent = true, $post = null ) {
  2097 	global $comment;
  2117 	global $comment;
  2098 
  2118 
  2099 	if ( false === $no_reply_text ) {
  2119 	if ( false === $no_reply_text ) {
  2272 		/*
  2292 		/*
  2273 		 * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
  2293 		 * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
  2274 		 * perform a separate comment query and allow Walker_Comment to paginate.
  2294 		 * perform a separate comment query and allow Walker_Comment to paginate.
  2275 		 */
  2295 		 */
  2276 		if ( $parsed_args['page'] || $parsed_args['per_page'] ) {
  2296 		if ( $parsed_args['page'] || $parsed_args['per_page'] ) {
  2277 			$current_cpage = get_query_var( 'cpage' );
  2297 			$current_cpage = (int) get_query_var( 'cpage' );
  2278 			if ( ! $current_cpage ) {
  2298 			if ( ! $current_cpage ) {
  2279 				$current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
  2299 				$current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
  2280 			}
  2300 			}
  2281 
  2301 
  2282 			$current_per_page = get_query_var( 'comments_per_page' );
  2302 			$current_per_page = (int) get_query_var( 'comments_per_page' );
  2283 			if ( $parsed_args['page'] != $current_cpage || $parsed_args['per_page'] != $current_per_page ) {
  2303 			if ( (int) $parsed_args['page'] !== $current_cpage || (int) $parsed_args['per_page'] !== $current_per_page ) {
  2284 				$comment_args = array(
  2304 				$comment_args = array(
  2285 					'post_id' => get_the_ID(),
  2305 					'post_id' => get_the_ID(),
  2286 					'orderby' => 'comment_date_gmt',
  2306 					'orderby' => 'comment_date_gmt',
  2287 					'order'   => 'ASC',
  2307 					'order'   => 'ASC',
  2288 					'status'  => 'approve',
  2308 					'status'  => 'approve',
  2329 				$_comments = $wp_query->comments;
  2349 				$_comments = $wp_query->comments;
  2330 			}
  2350 			}
  2331 
  2351 
  2332 			if ( $wp_query->max_num_comment_pages ) {
  2352 			if ( $wp_query->max_num_comment_pages ) {
  2333 				$default_comments_page = get_option( 'default_comments_page' );
  2353 				$default_comments_page = get_option( 'default_comments_page' );
  2334 				$cpage                 = get_query_var( 'cpage' );
  2354 				$cpage                 = (int) get_query_var( 'cpage' );
       
  2355 
  2335 				if ( 'newest' === $default_comments_page ) {
  2356 				if ( 'newest' === $default_comments_page ) {
  2336 					$parsed_args['cpage'] = $cpage;
  2357 					$parsed_args['cpage'] = $cpage;
  2337 
  2358 				} elseif ( 1 === $cpage ) {
  2338 					/*
  2359 					/*
  2339 					* When first page shows oldest comments, post permalink is the same as
  2360 					 * When the first page shows the oldest comments,
  2340 					* the comment permalink.
  2361 					 * post permalink is the same as the comment permalink.
  2341 					*/
  2362 					 */
  2342 				} elseif ( 1 == $cpage ) {
       
  2343 					$parsed_args['cpage'] = '';
  2363 					$parsed_args['cpage'] = '';
  2344 				} else {
  2364 				} else {
  2345 					$parsed_args['cpage'] = $cpage;
  2365 					$parsed_args['cpage'] = $cpage;
  2346 				}
  2366 				}
  2347 
  2367 
  2370 
  2390 
  2371 	if ( '' === $parsed_args['page'] ) {
  2391 	if ( '' === $parsed_args['page'] ) {
  2372 		if ( empty( $overridden_cpage ) ) {
  2392 		if ( empty( $overridden_cpage ) ) {
  2373 			$parsed_args['page'] = get_query_var( 'cpage' );
  2393 			$parsed_args['page'] = get_query_var( 'cpage' );
  2374 		} else {
  2394 		} else {
  2375 			$threaded            = ( -1 != $parsed_args['max_depth'] );
  2395 			$threaded            = ( -1 !== (int) $parsed_args['max_depth'] );
  2376 			$parsed_args['page'] = ( 'newest' === get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $parsed_args['per_page'], $threaded ) : 1;
  2396 			$parsed_args['page'] = ( 'newest' === get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $parsed_args['per_page'], $threaded ) : 1;
  2377 			set_query_var( 'cpage', $parsed_args['page'] );
  2397 			set_query_var( 'cpage', $parsed_args['page'] );
  2378 		}
  2398 		}
  2379 	}
  2399 	}
       
  2400 
  2380 	// Validation check.
  2401 	// Validation check.
  2381 	$parsed_args['page'] = (int) $parsed_args['page'];
  2402 	$parsed_args['page']     = (int) $parsed_args['page'];
  2382 	if ( 0 == $parsed_args['page'] && 0 != $parsed_args['per_page'] ) {
  2403 	$parsed_args['per_page'] = (int) $parsed_args['per_page'];
       
  2404 	if ( 0 === $parsed_args['page'] && 0 !== $parsed_args['per_page'] ) {
  2383 		$parsed_args['page'] = 1;
  2405 		$parsed_args['page'] = 1;
  2384 	}
  2406 	}
  2385 
  2407 
  2386 	if ( null === $parsed_args['reverse_top_level'] ) {
  2408 	if ( null === $parsed_args['reverse_top_level'] ) {
  2387 		$parsed_args['reverse_top_level'] = ( 'desc' === get_option( 'comment_order' ) );
  2409 		$parsed_args['reverse_top_level'] = ( 'desc' === get_option( 'comment_order' ) );
  2422  * @since 4.5.0 The 'author', 'email', and 'url' form fields are limited to 245, 100,
  2444  * @since 4.5.0 The 'author', 'email', and 'url' form fields are limited to 245, 100,
  2423  *              and 200 characters, respectively.
  2445  *              and 200 characters, respectively.
  2424  * @since 4.6.0 Introduced the 'action' argument.
  2446  * @since 4.6.0 Introduced the 'action' argument.
  2425  * @since 4.9.6 Introduced the 'cookies' default comment field.
  2447  * @since 4.9.6 Introduced the 'cookies' default comment field.
  2426  * @since 5.5.0 Introduced the 'class_container' argument.
  2448  * @since 5.5.0 Introduced the 'class_container' argument.
       
  2449  * @since 6.8.2 Introduced the 'novalidate' argument.
  2427  *
  2450  *
  2428  * @param array       $args {
  2451  * @param array       $args {
  2429  *     Optional. Default arguments and form fields to override.
  2452  *     Optional. Default arguments and form fields to override.
  2430  *
  2453  *
  2431  *     @type array $fields {
  2454  *     @type array $fields {
  2443  *     @type string $comment_notes_before HTML element for a message displayed before the comment fields
  2466  *     @type string $comment_notes_before HTML element for a message displayed before the comment fields
  2444  *                                        if the user is not logged in.
  2467  *                                        if the user is not logged in.
  2445  *                                        Default 'Your email address will not be published.'.
  2468  *                                        Default 'Your email address will not be published.'.
  2446  *     @type string $comment_notes_after  HTML element for a message displayed after the textarea field.
  2469  *     @type string $comment_notes_after  HTML element for a message displayed after the textarea field.
  2447  *     @type string $action               The comment form element action attribute. Default '/wp-comments-post.php'.
  2470  *     @type string $action               The comment form element action attribute. Default '/wp-comments-post.php'.
       
  2471  *     @type bool   $novalidate           Whether the novalidate attribute is added to the comment form. Default false.
  2448  *     @type string $id_form              The comment form element id attribute. Default 'commentform'.
  2472  *     @type string $id_form              The comment form element id attribute. Default 'commentform'.
  2449  *     @type string $id_submit            The comment submit element id attribute. Default 'submit'.
  2473  *     @type string $id_submit            The comment submit element id attribute. Default 'submit'.
  2450  *     @type string $class_container      The comment form container class attribute. Default 'comment-respond'.
  2474  *     @type string $class_container      The comment form container class attribute. Default 'comment-respond'.
  2451  *     @type string $class_form           The comment form element class attribute. Default 'comment-form'.
  2475  *     @type string $class_form           The comment form element class attribute. Default 'comment-form'.
  2452  *     @type string $class_submit         The comment submit element class attribute. Default 'submit'.
  2476  *     @type string $class_submit         The comment submit element class attribute. Default 'submit'.
  2622 			),
  2646 			),
  2623 			$required_text
  2647 			$required_text
  2624 		),
  2648 		),
  2625 		'comment_notes_after'  => '',
  2649 		'comment_notes_after'  => '',
  2626 		'action'               => site_url( '/wp-comments-post.php' ),
  2650 		'action'               => site_url( '/wp-comments-post.php' ),
       
  2651 		'novalidate'           => false,
  2627 		'id_form'              => 'commentform',
  2652 		'id_form'              => 'commentform',
  2628 		'id_submit'            => 'submit',
  2653 		'id_submit'            => 'submit',
  2629 		'class_container'      => 'comment-respond',
  2654 		'class_container'      => 'comment-respond',
  2630 		'class_form'           => 'comment-form',
  2655 		'class_form'           => 'comment-form',
  2631 		'class_submit'         => 'submit',
  2656 		'class_submit'         => 'submit',
  2705 			printf(
  2730 			printf(
  2706 				'<form action="%s" method="post" id="%s" class="%s"%s>',
  2731 				'<form action="%s" method="post" id="%s" class="%s"%s>',
  2707 				esc_url( $args['action'] ),
  2732 				esc_url( $args['action'] ),
  2708 				esc_attr( $args['id_form'] ),
  2733 				esc_attr( $args['id_form'] ),
  2709 				esc_attr( $args['class_form'] ),
  2734 				esc_attr( $args['class_form'] ),
  2710 				( $html5 ? ' novalidate' : '' )
  2735 				( $args['novalidate'] ? ' novalidate' : '' )
  2711 			);
  2736 			);
  2712 
  2737 
  2713 			/**
  2738 			/**
  2714 			 * Fires at the top of the comment form, inside the form tag.
  2739 			 * Fires at the top of the comment form, inside the form tag.
  2715 			 *
  2740 			 *