-
+ 024EB09A7A1A5CA5F6B74D2B79C670A866817A4D3433C6D6FC3C439D91F4DF5BC1B0DE26C63B6DCA5D7FC91FC6F2868DB42451AF38778FFDD0943974A025EAD2mp-wp/wp-includes/comment-template.php(0 . 0)(1 . 1378)
83537 <?php
83538 /**
83539 * Comment template functions
83540 *
83541 * These functions are meant to live inside of the WordPress loop.
83542 *
83543 * @package WordPress
83544 * @subpackage Template
83545 */
83546
83547 /**
83548 * Retrieve the author of the current comment.
83549 *
83550 * If the comment has an empty comment_author field, then 'Anonymous' person is
83551 * assumed.
83552 *
83553 * @since 1.5.0
83554 * @uses apply_filters() Calls 'get_comment_author' hook on the comment author
83555 *
83556 * @return string The comment author
83557 */
83558 function get_comment_author() {
83559 global $comment;
83560 if ( empty($comment->comment_author) ) {
83561 if (!empty($comment->user_id)){
83562 $user=get_userdata($comment->user_id);
83563 $author=$user->user_login;
83564 } else {
83565 $author = __('Anonymous');
83566 }
83567 } else {
83568 $author = $comment->comment_author;
83569 }
83570 return apply_filters('get_comment_author', $author);
83571 }
83572
83573 /**
83574 * Displays the author of the current comment.
83575 *
83576 * @since 0.71
83577 * @uses apply_filters() Calls 'comment_author' on comment author before displaying
83578 */
83579 function comment_author() {
83580 $author = apply_filters('comment_author', get_comment_author() );
83581 echo $author;
83582 }
83583
83584 /**
83585 * Retrieve the email of the author of the current comment.
83586 *
83587 * @since 1.5.0
83588 * @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email
83589 * @uses $comment
83590 *
83591 * @return string The current comment author's email
83592 */
83593 function get_comment_author_email() {
83594 global $comment;
83595 return apply_filters('get_comment_author_email', $comment->comment_author_email);
83596 }
83597
83598 /**
83599 * Display the email of the author of the current global $comment.
83600 *
83601 * Care should be taken to protect the email address and assure that email
83602 * harvesters do not capture your commentors' email address. Most assume that
83603 * their email address will not appear in raw form on the blog. Doing so will
83604 * enable anyone, including those that people don't want to get the email
83605 * address and use it for their own means good and bad.
83606 *
83607 * @since 0.71
83608 * @uses apply_filters() Calls 'author_email' hook on the author email
83609 */
83610 function comment_author_email() {
83611 echo apply_filters('author_email', get_comment_author_email() );
83612 }
83613
83614 /**
83615 * Display the html email link to the author of the current comment.
83616 *
83617 * Care should be taken to protect the email address and assure that email
83618 * harvesters do not capture your commentors' email address. Most assume that
83619 * their email address will not appear in raw form on the blog. Doing so will
83620 * enable anyone, including those that people don't want to get the email
83621 * address and use it for their own means good and bad.
83622 *
83623 * @since 0.71
83624 * @uses apply_filters() Calls 'comment_email' hook for the display of the comment author's email
83625 * @uses get_comment_author_email_link() For generating the link
83626 * @global object $comment The current Comment row object
83627 *
83628 * @param string $linktext The text to display instead of the comment author's email address
83629 * @param string $before The text or HTML to display before the email link.
83630 * @param string $after The text or HTML to display after the email link.
83631 */
83632 function comment_author_email_link($linktext='', $before='', $after='') {
83633 if ( $link = get_comment_author_email_link( $linktext, $before, $after ) )
83634 echo $link;
83635 }
83636
83637 /**
83638 * Return the html email link to the author of the current comment.
83639 *
83640 * Care should be taken to protect the email address and assure that email
83641 * harvesters do not capture your commentors' email address. Most assume that
83642 * their email address will not appear in raw form on the blog. Doing so will
83643 * enable anyone, including those that people don't want to get the email
83644 * address and use it for their own means good and bad.
83645 *
83646 * @since 2.7
83647 * @uses apply_filters() Calls 'comment_email' hook for the display of the comment author's email
83648 * @global object $comment The current Comment row object
83649 *
83650 * @param string $linktext The text to display instead of the comment author's email address
83651 * @param string $before The text or HTML to display before the email link.
83652 * @param string $after The text or HTML to display after the email link.
83653 */
83654 function get_comment_author_email_link($linktext='', $before='', $after='') {
83655 global $comment;
83656 $email = apply_filters('comment_email', $comment->comment_author_email);
83657 if ((!empty($email)) && ($email != '@')) {
83658 $display = ($linktext != '') ? $linktext : $email;
83659 $return = $before;
83660 $return .= "<a href='mailto:$email'>$display</a>";
83661 $return .= $after;
83662 return $return;
83663 } else {
83664 return '';
83665 }
83666 }
83667
83668 /**
83669 * Retrieve the html link to the url of the author of the current comment.
83670 *
83671 * @since 1.5.0
83672 * @uses apply_filters() Calls 'get_comment_author_link' hook on the complete link HTML or author
83673 *
83674 * @return string Comment Author name or HTML link for author's URL
83675 */
83676 function get_comment_author_link() {
83677 /** @todo Only call these functions when they are needed. Include in if... else blocks */
83678 $url = get_comment_author_url();
83679 $author = get_comment_author();
83680
83681 if ( empty( $url ) || 'http://' == $url )
83682 $return = $author;
83683 else
83684 // Removed rel='external nofollow' from here
83685 $return = "<a href='$url' class='url'>$author</a>";
83686 return apply_filters('get_comment_author_link', $return);
83687 }
83688
83689 /**
83690 * Display the html link to the url of the author of the current comment.
83691 *
83692 * @since 0.71
83693 * @see get_comment_author_link() Echos result
83694 */
83695 function comment_author_link() {
83696 echo get_comment_author_link();
83697 }
83698
83699 /**
83700 * Retrieve the IP address of the author of the current comment.
83701 *
83702 * @since 1.5.0
83703 * @uses $comment
83704 * @uses apply_filters()
83705 *
83706 * @return unknown
83707 */
83708 function get_comment_author_IP() {
83709 global $comment;
83710 return apply_filters('get_comment_author_IP', $comment->comment_author_IP);
83711 }
83712
83713 /**
83714 * Display the IP address of the author of the current comment.
83715 *
83716 * @since 0.71
83717 * @see get_comment_author_IP() Echos Result
83718 */
83719 function comment_author_IP() {
83720 echo get_comment_author_IP();
83721 }
83722
83723 /**
83724 * Retrieve the url of the author of the current comment.
83725 *
83726 * @since 1.5.0
83727 * @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL
83728 *
83729 * @return string
83730 */
83731 function get_comment_author_url() {
83732 global $comment;
83733 return apply_filters('get_comment_author_url', $comment->comment_author_url);
83734 }
83735
83736 /**
83737 * Display the url of the author of the current comment.
83738 *
83739 * @since 0.71
83740 * @uses apply_filters()
83741 * @uses get_comment_author_url() Retrieves the comment author's URL
83742 */
83743 function comment_author_url() {
83744 echo apply_filters('comment_url', get_comment_author_url());
83745 }
83746
83747 /**
83748 * Retrieves the HTML link of the url of the author of the current comment.
83749 *
83750 * $linktext parameter is only used if the URL does not exist for the comment
83751 * author. If the URL does exist then the URL will be used and the $linktext
83752 * will be ignored.
83753 *
83754 * Encapsulate the HTML link between the $before and $after. So it will appear
83755 * in the order of $before, link, and finally $after.
83756 *
83757 * @since 1.5.0
83758 * @uses apply_filters() Calls the 'get_comment_author_url_link' on the complete HTML before returning.
83759 *
83760 * @param string $linktext The text to display instead of the comment author's email address
83761 * @param string $before The text or HTML to display before the email link.
83762 * @param string $after The text or HTML to display after the email link.
83763 * @return string The HTML link between the $before and $after parameters
83764 */
83765 function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
83766 $url = get_comment_author_url();
83767 $display = ($linktext != '') ? $linktext : $url;
83768 $display = str_replace( 'http://www.', '', $display );
83769 $display = str_replace( 'http://', '', $display );
83770 if ( '/' == substr($display, -1) )
83771 $display = substr($display, 0, -1);
83772 $return = "$before<a href='$url' rel='external'>$display</a>$after";
83773 return apply_filters('get_comment_author_url_link', $return);
83774 }
83775
83776 /**
83777 * Displays the HTML link of the url of the author of the current comment.
83778 *
83779 * @since 0.71
83780 * @see get_comment_author_url_link() Echos result
83781 *
83782 * @param string $linktext The text to display instead of the comment author's email address
83783 * @param string $before The text or HTML to display before the email link.
83784 * @param string $after The text or HTML to display after the email link.
83785 */
83786 function comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
83787 echo get_comment_author_url_link( $linktext, $before, $after );
83788 }
83789
83790 /**
83791 * Generates semantic classes for each comment element
83792 *
83793 * @since 2.7.0
83794 *
83795 * @param string|array $class One or more classes to add to the class list
83796 * @param int $comment_id An optional comment ID
83797 * @param int $post_id An optional post ID
83798 * @param bool $echo Whether comment_class should echo or return
83799 */
83800 function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) {
83801 // Separates classes with a single space, collates classes for comment DIV
83802 $class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"';
83803 if ( $echo)
83804 echo $class;
83805 else
83806 return $class;
83807 }
83808
83809 /**
83810 * Returns the classes for the comment div as an array
83811 *
83812 * @since 2.7.0
83813 *
83814 * @param string|array $class One or more classes to add to the class list
83815 * @param int $comment_id An optional comment ID
83816 * @param int $post_id An optional post ID
83817 * @return array Array of classes
83818 */
83819 function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
83820 global $comment_alt, $comment_depth, $comment_thread_alt;
83821
83822 $comment = get_comment($comment_id);
83823
83824 $classes = array();
83825
83826 // Get the comment type (comment, trackback),
83827 $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
83828
83829 // If the comment author has an id (registered), then print the log in name
83830 if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
83831 // For all registered users, 'byuser'
83832 $classes[] = 'byuser comment-author-' . $user->user_nicename;
83833 // For comment authors who are the author of the post
83834 if ( $post = get_post($post_id) ) {
83835 if ( $comment->user_id === $post->post_author )
83836 $classes[] = 'bypostauthor';
83837 }
83838 }
83839
83840 if ( empty($comment_alt) )
83841 $comment_alt = 0;
83842 if ( empty($comment_depth) )
83843 $comment_depth = 1;
83844 if ( empty($comment_thread_alt) )
83845 $comment_thread_alt = 0;
83846
83847 if ( $comment_alt % 2 ) {
83848 $classes[] = 'odd';
83849 $classes[] = 'alt';
83850 } else {
83851 $classes[] = 'even';
83852 }
83853
83854 $comment_alt++;
83855
83856 // Alt for top-level comments
83857 if ( 1 == $comment_depth ) {
83858 if ( $comment_thread_alt % 2 ) {
83859 $classes[] = 'thread-odd';
83860 $classes[] = 'thread-alt';
83861 } else {
83862 $classes[] = 'thread-even';
83863 }
83864 $comment_thread_alt++;
83865 }
83866
83867 $classes[] = "depth-$comment_depth";
83868
83869 if ( !empty($class) ) {
83870 if ( !is_array( $class ) )
83871 $class = preg_split('#\s+#', $class);
83872 $classes = array_merge($classes, $class);
83873 }
83874
83875 return apply_filters('comment_class', $classes, $class, $comment_id, $post_id);
83876 }
83877
83878 /**
83879 * Retrieve the comment date of the current comment.
83880 *
83881 * @since 1.5.0
83882 * @uses apply_filters() Calls 'get_comment_date' hook with the formated date and the $d parameter respectively
83883 * @uses $comment
83884 *
83885 * @param string $d The format of the date (defaults to user's config)
83886 * @return string The comment's date
83887 */
83888 function get_comment_date( $d = '' ) {
83889 global $comment;
83890 if ( '' == $d )
83891 $date = mysql2date( get_option('date_format'), $comment->comment_date);
83892 else
83893 $date = mysql2date($d, $comment->comment_date);
83894 return apply_filters('get_comment_date', $date, $d);
83895 }
83896
83897 /**
83898 * Display the comment date of the current comment.
83899 *
83900 * @since 0.71
83901 *
83902 * @param string $d The format of the date (defaults to user's config)
83903 */
83904 function comment_date( $d = '' ) {
83905 echo get_comment_date( $d );
83906 }
83907
83908 /**
83909 * Retrieve the excerpt of the current comment.
83910 *
83911 * Will cut each word and only output the first 20 words with '...' at the end.
83912 * If the word count is less than 20, then no truncating is done and no '...'
83913 * will appear.
83914 *
83915 * @since 1.5.0
83916 * @uses $comment
83917 * @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment
83918 *
83919 * @return string The maybe truncated comment with 20 words or less
83920 */
83921 function get_comment_excerpt() {
83922 global $comment;
83923 $comment_text = strip_tags($comment->comment_content);
83924 $blah = explode(' ', $comment_text);
83925 if (count($blah) > 20) {
83926 $k = 20;
83927 $use_dotdotdot = 1;
83928 } else {
83929 $k = count($blah);
83930 $use_dotdotdot = 0;
83931 }
83932 $excerpt = '';
83933 for ($i=0; $i<$k; $i++) {
83934 $excerpt .= $blah[$i] . ' ';
83935 }
83936 $excerpt .= ($use_dotdotdot) ? '...' : '';
83937 return apply_filters('get_comment_excerpt', $excerpt);
83938 }
83939
83940 /**
83941 * Display the excerpt of the current comment.
83942 *
83943 * @since 1.2.0
83944 * @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt
83945 */
83946 function comment_excerpt() {
83947 echo apply_filters('comment_excerpt', get_comment_excerpt() );
83948 }
83949
83950 /**
83951 * Retrieve the comment id of the current comment.
83952 *
83953 * @since 1.5.0
83954 * @uses $comment
83955 * @uses apply_filters() Calls the 'get_comment_ID' hook for the comment ID
83956 *
83957 * @return int The comment ID
83958 */
83959 function get_comment_ID() {
83960 global $comment;
83961 return apply_filters('get_comment_ID', $comment->comment_ID);
83962 }
83963
83964 /**
83965 * Displays the comment id of the current comment.
83966 *
83967 * @since 0.71
83968 * @see get_comment_ID() Echos Result
83969 */
83970 function comment_ID() {
83971 echo get_comment_ID();
83972 }
83973
83974 /**
83975 * Retrieve the link to a given comment.
83976 *
83977 * @since 1.5.0
83978 * @uses $comment
83979 *
83980 * @param object|string|int $comment Comment to retrieve.
83981 * @param array $args Optional args.
83982 * @return string The permalink to the current comment
83983 */
83984 function get_comment_link( $comment = null, $args = array() ) {
83985 global $wp_rewrite, $in_comment_loop;
83986
83987 $comment = get_comment($comment);
83988
83989 // Backwards compat
83990 if ( !is_array($args) ) {
83991 $page = $args;
83992 $args = array();
83993 $args['page'] = $page;
83994 }
83995
83996 $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
83997 $args = wp_parse_args( $args, $defaults );
83998
83999 if ( '' === $args['per_page'] && get_option('page_comments') )
84000 $args['per_page'] = get_option('comments_per_page');
84001
84002 if ( empty($args['per_page']) ) {
84003 $args['per_page'] = 0;
84004 $args['page'] = 0;
84005 }
84006
84007 if ( $args['per_page'] ) {
84008 if ( '' == $args['page'] )
84009 $args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args );
84010
84011 if ( $wp_rewrite->using_permalinks() )
84012 return user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' ) . '#comment-' . $comment->comment_ID;
84013 else
84014 return add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ) . '#comment-' . $comment->comment_ID;
84015 } else {
84016 return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID;
84017 }
84018 }
84019
84020 /**
84021 * Retrieves the link to the current post comments.
84022 *
84023 * @since 1.5.0
84024 *
84025 * @return string The link to the comments
84026 */
84027 function get_comments_link() {
84028 return get_permalink() . '#comments';
84029 }
84030
84031 /**
84032 * Displays the link to the current post comments.
84033 *
84034 * @since 0.71
84035 *
84036 * @param string $deprecated Not Used
84037 * @param bool $deprecated Not Used
84038 */
84039 function comments_link( $deprecated = '', $deprecated = '' ) {
84040 echo get_comments_link();
84041 }
84042
84043 /**
84044 * Retrieve the amount of comments a post has.
84045 *
84046 * @since 1.5.0
84047 * @uses apply_filters() Calls the 'get_comments_number' hook on the number of comments
84048 *
84049 * @param int $post_id The Post ID
84050 * @return int The number of comments a post has
84051 */
84052 function get_comments_number( $post_id = 0 ) {
84053 global $id;
84054 $post_id = (int) $post_id;
84055
84056 if ( !$post_id )
84057 $post_id = (int) $id;
84058
84059 $post = get_post($post_id);
84060 if ( ! isset($post->comment_count) )
84061 $count = 0;
84062 else
84063 $count = $post->comment_count;
84064
84065 return apply_filters('get_comments_number', $count);
84066 }
84067
84068 /**
84069 * Display the language string for the number of comments the current post has.
84070 *
84071 * @since 0.71
84072 * @uses $id
84073 * @uses apply_filters() Calls the 'comments_number' hook on the output and number of comments respectively.
84074 *
84075 * @param string $zero Text for no comments
84076 * @param string $one Text for one comment
84077 * @param string $more Text for more than one comment
84078 * @param string $deprecated Not used.
84079 */
84080 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
84081 global $id;
84082 $number = get_comments_number($id);
84083
84084 if ( $number > 1 )
84085 $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);
84086 elseif ( $number == 0 )
84087 $output = ( false === $zero ) ? __('No Comments') : $zero;
84088 else // must be one
84089 $output = ( false === $one ) ? __('1 Comment') : $one;
84090
84091 echo apply_filters('comments_number', $output, $number);
84092 }
84093
84094 /**
84095 * Retrieve the text of the current comment.
84096 *
84097 * @since 1.5.0
84098 * @uses $comment
84099 *
84100 * @return string The comment content
84101 */
84102 function get_comment_text() {
84103 global $comment;
84104 return apply_filters('get_comment_text', $comment->comment_content);
84105 }
84106
84107 /**
84108 * Displays the text of the current comment.
84109 *
84110 * @since 0.71
84111 * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display
84112 * @uses get_comment_text() Gets the comment content
84113
84114 hacked for pgp.
84115 */
84116 function comment_text() {
84117
84118 $comment_content = get_comment_text();
84119
84120 $dead = array("\n", ' ');
84121 $live = array('<br />', ' ');
84122
84123 if (strpos($comment_content,"----BEGIN PGP ")>0)
84124 echo str_replace($dead, $live, str_replace("\r\n","\n",strip_tags($comment_content)));
84125 else echo apply_filters('comment_text', $comment_content);
84126 }
84127
84128 /**
84129 * Retrieve the comment time of the current comment.
84130 *
84131 * @since 1.5.0
84132 * @uses $comment
84133 * @uses apply_filter() Calls 'get_comment_time' hook with the formatted time, the $d parameter, and $gmt parameter passed.
84134 *
84135 * @param string $d Optional. The format of the time (defaults to user's config)
84136 * @param bool $gmt Whether to use the GMT date
84137 * @return string The formatted time
84138 */
84139 function get_comment_time( $d = '', $gmt = false ) {
84140 global $comment;
84141 $comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date;
84142 if ( '' == $d )
84143 $date = mysql2date(get_option('time_format'), $comment_date);
84144 else
84145 $date = mysql2date($d, $comment_date);
84146 return apply_filters('get_comment_time', $date, $d, $gmt);
84147 }
84148
84149 /**
84150 * Display the comment time of the current comment.
84151 *
84152 * @since 0.71
84153 *
84154 * @param string $d Optional. The format of the time (defaults to user's config)
84155 */
84156 function comment_time( $d = '' ) {
84157 echo get_comment_time($d);
84158 }
84159
84160 /**
84161 * Retrieve the comment type of the current comment.
84162 *
84163 * @since 1.5.0
84164 * @uses $comment
84165 * @uses apply_filters() Calls the 'get_comment_type' hook on the comment type
84166 *
84167 * @return string The comment type
84168 */
84169 function get_comment_type() {
84170 global $comment;
84171
84172 if ( '' == $comment->comment_type )
84173 $comment->comment_type = 'comment';
84174
84175 return apply_filters('get_comment_type', $comment->comment_type);
84176 }
84177
84178 /**
84179 * Display the comment type of the current comment.
84180 *
84181 * @since 0.71
84182 *
84183 * @param string $commenttxt The string to display for comment type
84184 * @param string $trackbacktxt The string to display for trackback type
84185 * @param string $pingbacktxt The string to display for pingback type
84186 */
84187 function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') {
84188 $type = get_comment_type();
84189 switch( $type ) {
84190 case 'trackback' :
84191 echo $trackbacktxt;
84192 break;
84193 case 'pingback' :
84194 echo $pingbacktxt;
84195 break;
84196 default :
84197 echo $commenttxt;
84198 }
84199 }
84200
84201 /**
84202 * Retrieve The current post's trackback URL.
84203 *
84204 * There is a check to see if permalink's have been enabled and if so, will
84205 * retrieve the pretty path. If permalinks weren't enabled, the ID of the
84206 * current post is used and appended to the correct page to go to.
84207 *
84208 * @since 1.5.0
84209 * @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL
84210 * @uses $id
84211 *
84212 * @return string The trackback URL after being filtered
84213 */
84214 function get_trackback_url() {
84215 global $id;
84216 if ( '' != get_option('permalink_structure') ) {
84217 $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
84218 } else {
84219 $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . $id;
84220 }
84221 return apply_filters('trackback_url', $tb_url);
84222 }
84223
84224 /**
84225 * Displays the current post's trackback URL.
84226 *
84227 * @since 0.71
84228 * @uses get_trackback_url() Gets the trackback url for the current post
84229 *
84230 * @param bool $deprecated Remove backwards compat in 2.5
84231 * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() for the result instead.
84232 */
84233 function trackback_url($deprecated = true) {
84234 if ($deprecated) echo get_trackback_url();
84235 else return get_trackback_url();
84236 }
84237
84238 /**
84239 * Generates and displays the RDF for the trackback information of current post.
84240 *
84241 * @since 0.71
84242 *
84243 * @param int $deprecated Not used (Was $timezone = 0)
84244 */
84245 function trackback_rdf($deprecated = '') {
84246 if (stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') === false) {
84247 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
84248 xmlns:dc="http://purl.org/dc/elements/1.1/"
84249 xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
84250 <rdf:Description rdf:about="';
84251 the_permalink();
84252 echo '"'."\n";
84253 echo ' dc:identifier="';
84254 the_permalink();
84255 echo '"'."\n";
84256 echo ' dc:title="'.str_replace('--', '--', wptexturize(strip_tags(get_the_title()))).'"'."\n";
84257 echo ' trackback:ping="'.get_trackback_url().'"'." />\n";
84258 echo '</rdf:RDF>';
84259 }
84260 }
84261
84262 /**
84263 * Whether the current post is open for comments.
84264 *
84265 * @since 1.5.0
84266 * @uses $post
84267 *
84268 * @param int $post_id An optional post ID to check instead of the current post.
84269 * @return bool True if the comments are open
84270 */
84271 function comments_open( $post_id=NULL ) {
84272
84273 $_post = get_post($post_id);
84274
84275 $open = ( 'open' == $_post->comment_status );
84276 return apply_filters( 'comments_open', $open, $post_id );
84277 }
84278
84279 /**
84280 * Whether the current post is open for pings.
84281 *
84282 * @since 1.5.0
84283 * @uses $post
84284 *
84285 * @param int $post_id An optional post ID to check instead of the current post.
84286 * @return bool True if pings are accepted
84287 */
84288 function pings_open( $post_id = NULL ) {
84289
84290 $_post = get_post($post_id);
84291
84292 $open = ( 'open' == $_post->ping_status );
84293 return apply_filters( 'pings_open', $open, $post_id );
84294 }
84295
84296 /**
84297 * Displays form token for unfiltered comments.
84298 *
84299 * Will only display nonce token if the current user has permissions for
84300 * unfiltered html. Won't display the token for other users.
84301 *
84302 * The function was backported to 2.0.10 and was added to versions 2.1.3 and
84303 * above. Does not exist in versions prior to 2.0.10 in the 2.0 branch and in
84304 * the 2.1 branch, prior to 2.1.3. Technically added in 2.2.0.
84305 *
84306 * Backported to 2.0.10.
84307 *
84308 * @since 2.1.3
84309 * @uses $post Gets the ID of the current post for the token
84310 */
84311 function wp_comment_form_unfiltered_html_nonce() {
84312 global $post;
84313
84314 $post_id = 0;
84315 if ( !empty($post) )
84316 $post_id = $post->ID;
84317
84318 if ( current_user_can('unfiltered_html') )
84319 wp_nonce_field('unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment', false);
84320 }
84321
84322 /**
84323 * Loads the comment template specified in $file.
84324 *
84325 * Will not display the comments template if not on single post or page, or if
84326 * the post does not have comments.
84327 *
84328 * Uses the WordPress database object to query for the comments. The comments
84329 * are passed through the 'comments_array' filter hook with the list of comments
84330 * and the post ID respectively.
84331 *
84332 * The $file path is passed through a filter hook called, 'comments_template'
84333 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
84334 * first and if it fails it will require the default comment themplate from the
84335 * default theme. If either does not exist, then the WordPress process will be
84336 * halted. It is advised for that reason, that the default theme is not deleted.
84337 *
84338 * @since 1.5.0
84339 * @global array $comment List of comment objects for the current post
84340 * @uses $wpdb
84341 * @uses $id
84342 * @uses $post
84343 * @uses $withcomments Will not try to get the comments if the post has none.
84344 *
84345 * @param string $file Optional, default '/comments.php'. The file to load
84346 * @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false.
84347 * @return null Returns null if no comments appear
84348 */
84349 function comments_template( $file = '/comments.php', $separate_comments = false ) {
84350 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
84351
84352 if ( ! (is_single() || is_page() || $withcomments) )
84353 return;
84354
84355 if ( empty($file) )
84356 $file = '/comments.php';
84357
84358 $req = get_option('require_name_email');
84359 $commenter = wp_get_current_commenter();
84360 extract($commenter, EXTR_SKIP);
84361
84362 /** @todo Use API instead of SELECTs. */
84363 if ( $user_ID) {
84364 $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", $post->ID, $user_ID));
84365 } else if ( empty($comment_author) ) {
84366 $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post->ID));
84367 } else {
84368 $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", $post->ID, $comment_author, $comment_author_email));
84369 }
84370
84371 // keep $comments for legacy's sake
84372 $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
84373 $comments = &$wp_query->comments;
84374 $wp_query->comment_count = count($wp_query->comments);
84375 update_comment_cache($wp_query->comments);
84376
84377 if ( $separate_comments ) {
84378 $wp_query->comments_by_type = &separate_comments($comments);
84379 $comments_by_type = &$wp_query->comments_by_type;
84380 }
84381
84382 $overridden_cpage = FALSE;
84383 if ( '' == get_query_var('cpage') && get_option('page_comments') && 'newest' == get_option('default_comments_page') ) {
84384 set_query_var( 'cpage', get_comment_pages_count() );
84385 $overridden_cpage = TRUE;
84386 }
84387
84388 define('COMMENTS_TEMPLATE', true);
84389
84390 $include = apply_filters('comments_template', STYLESHEETPATH . $file );
84391 if ( file_exists( $include ) )
84392 require( $include );
84393 elseif ( file_exists( TEMPLATEPATH . $file ) )
84394 require( TEMPLATEPATH . $file );
84395 else
84396 require( get_theme_root() . '/default/comments.php');
84397 }
84398
84399 /**
84400 * Displays the JS popup script to show a comment.
84401 *
84402 * If the $file parameter is empty, then the home page is assumed. The defaults
84403 * for the window are 400px by 400px.
84404 *
84405 * For the comment link popup to work, this function has to be called or the
84406 * normal comment link will be assumed.
84407 *
84408 * @since 0.71
84409 * @global string $wpcommentspopupfile The URL to use for the popup window
84410 * @global int $wpcommentsjavascript Whether to use JavaScript or not. Set when function is called
84411 *
84412 * @param int $width Optional. The width of the popup window
84413 * @param int $height Optional. The height of the popup window
84414 * @param string $file Optional. Sets the location of the popup window
84415 */
84416 function comments_popup_script($width=400, $height=400, $file='') {
84417 global $wpcommentspopupfile, $wpcommentsjavascript;
84418
84419 if (empty ($file)) {
84420 $wpcommentspopupfile = ''; // Use the index.
84421 } else {
84422 $wpcommentspopupfile = $file;
84423 }
84424
84425 $wpcommentsjavascript = 1;
84426 $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";
84427 echo $javascript;
84428 }
84429
84430 /**
84431 * Displays the link to the comments popup window for the current post ID.
84432 *
84433 * Is not meant to be displayed on single posts and pages. Should be used on the
84434 * lists of posts
84435 *
84436 * @since 0.71
84437 * @uses $id
84438 * @uses $wpcommentspopupfile
84439 * @uses $wpcommentsjavascript
84440 * @uses $post
84441 *
84442 * @param string $zero The string to display when no comments
84443 * @param string $one The string to display when only one comment is available
84444 * @param string $more The string to display when there are more than one comment
84445 * @param string $css_class The CSS class to use for comments
84446 * @param string $none The string to display when comments have been turned off
84447 * @return null Returns null on single posts and pages.
84448 */
84449 function comments_popup_link( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $css_class = '', $none = 'Comments Off' ) {
84450 global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post;
84451
84452 if ( is_single() || is_page() )
84453 return;
84454
84455 $number = get_comments_number( $id );
84456
84457 if ( 0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status ) {
84458 echo '<span' . ((!empty($css_class)) ? ' class="' . $css_class . '"' : '') . '>' . $none . '</span>';
84459 return;
84460 }
84461
84462 if ( post_password_required() ) {
84463 echo __('Enter your password to view comments');
84464 return;
84465 }
84466
84467 echo '<a href="';
84468 if ( $wpcommentsjavascript ) {
84469 if ( empty( $wpcommentspopupfile ) )
84470 $home = get_option('home');
84471 else
84472 $home = get_option('siteurl');
84473 echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
84474 echo '" onclick="wpopen(this.href); return false"';
84475 } else { // if comments_popup_script() is not in the template, display simple comment link
84476 if ( 0 == $number )
84477 echo get_permalink() . '#respond';
84478 else
84479 comments_link();
84480 echo '"';
84481 }
84482
84483 if ( !empty( $css_class ) ) {
84484 echo ' class="'.$css_class.'" ';
84485 }
84486 $title = attribute_escape( get_the_title() );
84487
84488 echo apply_filters( 'comments_popup_link_attributes', '' );
84489
84490 echo ' title="' . sprintf( __('Comment on %s'), $title ) . '">';
84491 comments_number( $zero, $one, $more, $number );
84492 echo '</a>';
84493 }
84494
84495 /**
84496 * Retrieve HTML content for reply to comment link.
84497 *
84498 * The default arguments that can be override are 'add_below', 'respond_id',
84499 * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
84500 * used, if the user must log in or register first before posting a comment. The
84501 * 'reply_text' will be used, if they can post a reply. The 'add_below' and
84502 * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
84503 * parameters.
84504 *
84505 * @since 2.7.0
84506 *
84507 * @param array $args Optional. Override default options.
84508 * @param int $comment Optional. Comment being replied to.
84509 * @param int $post Optional. Post that the comment is going to be displayed on.
84510 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
84511 */
84512 function get_comment_reply_link($args = array(), $comment = null, $post = null) {
84513 global $user_ID;
84514
84515 $defaults = array('add_below' => 'comment', 'respond_id' => 'respond', 'reply_text' => __('Reply'),
84516 'login_text' => __('Log in to Reply'), 'depth' => 0, 'before' => '', 'after' => '');
84517
84518 $args = wp_parse_args($args, $defaults);
84519
84520 if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] )
84521 return;
84522
84523 extract($args, EXTR_SKIP);
84524
84525 $comment = get_comment($comment);
84526 $post = get_post($post);
84527
84528 if ( 'open' != $post->comment_status )
84529 return false;
84530
84531 $link = '';
84532
84533 if ( get_option('comment_registration') && !$user_ID )
84534 // Removed rel="nofollow" from here
84535 $link = '<a href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
84536 else
84537 // Removed rel="nofollow" from here
84538 $link = "<a href='" . wp_specialchars( 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>";
84539 return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post);
84540 }
84541
84542 /**
84543 * Displays the HTML content for reply to comment link.
84544 *
84545 * @since 2.7.0
84546 * @see get_comment_reply_link() Echoes result
84547 *
84548 * @param array $args Optional. Override default options.
84549 * @param int $comment Optional. Comment being replied to.
84550 * @param int $post Optional. Post that the comment is going to be displayed on.
84551 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
84552 */
84553 function comment_reply_link($args = array(), $comment = null, $post = null) {
84554 echo get_comment_reply_link($args, $comment, $post);
84555 }
84556
84557 /**
84558 * Retrieve HTML content for reply to post link.
84559 *
84560 * The default arguments that can be override are 'add_below', 'respond_id',
84561 * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
84562 * used, if the user must log in or register first before posting a comment. The
84563 * 'reply_text' will be used, if they can post a reply. The 'add_below' and
84564 * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
84565 * parameters.
84566 *
84567 * @since 2.7.0
84568 *
84569 * @param array $args Optional. Override default options.
84570 * @param int|object $post Optional. Post that the comment is going to be displayed on. Defaults to current post.
84571 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
84572 */
84573 function get_post_reply_link($args = array(), $post = null) {
84574 global $user_ID;
84575
84576 $defaults = array('add_below' => 'post', 'respond_id' => 'respond', 'reply_text' => __('Leave a Comment'),
84577 'login_text' => __('Log in to leave a Comment'), 'before' => '', 'after' => '');
84578
84579 $args = wp_parse_args($args, $defaults);
84580 extract($args, EXTR_SKIP);
84581 $post = get_post($post);
84582
84583 if ( !comments_open($post->ID) )
84584 return false;
84585
84586 if ( get_option('comment_registration') && !$user_ID ) {
84587 // Removed rel="nofollow" from here
84588 $link = '<a href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
84589 } else {
84590 // Removed rel="nofollow" from here
84591 $link = "<a href='" . get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
84592 }
84593 return apply_filters('post_comments_link', $before . $link . $after, $post);
84594 }
84595
84596 /**
84597 * Displays the HTML content for reply to post link.
84598 * @since 2.7.0
84599 * @see get_post_reply_link()
84600 *
84601 * @param array $args Optional. Override default options.
84602 * @param int|object $post Optional. Post that the comment is going to be displayed on.
84603 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
84604 */
84605 function post_reply_link($args = array(), $post = null) {
84606 echo get_post_reply_link($args, $post);
84607 }
84608
84609 /**
84610 * Retrieve HTML content for cancel comment reply link.
84611 *
84612 * @since 2.7.0
84613 *
84614 * @param string $text Optional. Text to display for cancel reply link.
84615 */
84616 function get_cancel_comment_reply_link($text = '') {
84617 if ( empty($text) )
84618 $text = __('Click here to cancel reply.');
84619
84620 $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
84621 $link = wp_specialchars( remove_query_arg('replytocom') ) . '#respond';
84622 // Removed rel="nofollow" from here
84623 return apply_filters('cancel_comment_reply_link', '<a id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>', $link, $text);
84624 }
84625
84626 /**
84627 * Display HTML content for cancel comment reply link.
84628 *
84629 * @since 2.7.0
84630 *
84631 * @param string $text Optional. Text to display for cancel reply link.
84632 */
84633 function cancel_comment_reply_link($text = '') {
84634 echo get_cancel_comment_reply_link($text);
84635 }
84636
84637 /**
84638 * Output hidden input HTML for replying to comments.
84639 *
84640 * @since 2.7.0
84641 */
84642 function comment_id_fields() {
84643 global $id;
84644
84645 $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
84646 echo "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
84647 echo "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
84648 }
84649
84650 /**
84651 * Display text based on comment reply status. Only affects users with Javascript disabled.
84652 *
84653 * @since 2.7.0
84654 *
84655 * @param string $noreplytext Optional. Text to display when not replying to a comment.
84656 * @param string $replytext Optional. Text to display when replying to a comment. Accepts "%s" for the author of the comment being replied to.
84657 * @param string $linktoparent Optional. Boolean to control making the author's name a link to their comment.
84658 */
84659 function comment_form_title( $noreplytext = 'Leave a Reply', $replytext = 'Leave a Reply to %s', $linktoparent = TRUE ) {
84660 global $comment;
84661
84662 $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
84663
84664 if ( 0 == $replytoid )
84665 echo $noreplytext;
84666 else {
84667 $comment = get_comment($replytoid);
84668 $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author();
84669 printf( $replytext, $author );
84670 }
84671 }
84672
84673 /**
84674 * HTML comment list class.
84675 *
84676 * @package WordPress
84677 * @uses Walker
84678 * @since unknown
84679 */
84680 class Walker_Comment extends Walker {
84681 /**
84682 * @see Walker::$tree_type
84683 * @since unknown
84684 * @var string
84685 */
84686 var $tree_type = 'comment';
84687
84688 /**
84689 * @see Walker::$db_fields
84690 * @since unknown
84691 * @var array
84692 */
84693 var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
84694
84695 /**
84696 * @see Walker::start_lvl()
84697 * @since unknown
84698 *
84699 * @param string $output Passed by reference. Used to append additional content.
84700 * @param int $depth Depth of comment.
84701 * @param array $args Uses 'style' argument for type of HTML list.
84702 */
84703 function start_lvl(&$output, $depth, $args) {
84704 $GLOBALS['comment_depth'] = $depth + 1;
84705
84706 switch ( $args['style'] ) {
84707 case 'div':
84708 break;
84709 case 'ol':
84710 echo "<ol class='children'>\n";
84711 break;
84712 default:
84713 case 'ul':
84714 echo "<ul class='children'>\n";
84715 break;
84716 }
84717 }
84718
84719 /**
84720 * @see Walker::end_lvl()
84721 * @since unknown
84722 *
84723 * @param string $output Passed by reference. Used to append additional content.
84724 * @param int $depth Depth of comment.
84725 * @param array $args Will only append content if style argument value is 'ol' or 'ul'.
84726 */
84727 function end_lvl(&$output, $depth, $args) {
84728 $GLOBALS['comment_depth'] = $depth + 1;
84729
84730 switch ( $args['style'] ) {
84731 case 'div':
84732 break;
84733 case 'ol':
84734 echo "</ol>\n";
84735 break;
84736 default:
84737 case 'ul':
84738 echo "</ul>\n";
84739 break;
84740 }
84741 }
84742
84743 /**
84744 * @see Walker::start_el()
84745 * @since unknown
84746 *
84747 * @param string $output Passed by reference. Used to append additional content.
84748 * @param object $comment Comment data object.
84749 * @param int $depth Depth of comment in reference to parents.
84750 * @param array $args
84751 */
84752 function start_el(&$output, $comment, $depth, $args) {
84753 $depth++;
84754 $GLOBALS['comment_depth'] = $depth;
84755
84756 if ( !empty($args['callback']) ) {
84757 call_user_func($args['callback'], $comment, $args, $depth);
84758 return;
84759 }
84760
84761 $GLOBALS['comment'] = $comment;
84762 extract($args, EXTR_SKIP);
84763
84764 if ( 'div' == $args['style'] ) {
84765 $tag = 'div';
84766 $add_below = 'comment';
84767 } else {
84768 $tag = 'li';
84769 $add_below = 'div-comment';
84770 }
84771 ?>
84772 <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
84773 <?php if ( 'ul' == $args['style'] ) : ?>
84774 <div id="div-comment-<?php comment_ID() ?>">
84775 <?php endif; ?>
84776 <div class="comment-author vcard">
84777 <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
84778 <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
84779 </div>
84780 <?php if ($comment->comment_approved == '0') : ?>
84781 <em><?php _e('Your comment is awaiting moderation.') ?></em>
84782 <br />
84783 <?php endif; ?>
84784
84785 <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>
84786
84787 <?php comment_text() ?>
84788
84789 <div class="reply">
84790 <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
84791 </div>
84792 <?php if ( 'ul' == $args['style'] ) : ?>
84793 </div>
84794 <?php endif; ?>
84795 <?php
84796 }
84797
84798 /**
84799 * @see Walker::end_el()
84800 * @since unknown
84801 *
84802 * @param string $output Passed by reference. Used to append additional content.
84803 * @param object $comment
84804 * @param int $depth Depth of comment.
84805 * @param array $args
84806 */
84807 function end_el(&$output, $comment, $depth, $args) {
84808 if ( !empty($args['end-callback']) ) {
84809 call_user_func($args['end-callback'], $comment, $args, $depth);
84810 return;
84811 }
84812 if ( 'div' == $args['style'] )
84813 echo "</div>\n";
84814 else
84815 echo "</li>\n";
84816 }
84817
84818 }
84819
84820 /**
84821 * List comments
84822 *
84823 * Used in the comments.php template to list comments for a particular post
84824 *
84825 * @since 2.7.0
84826 * @uses Walker_Comment
84827 *
84828 * @param string|array $args Formatting options
84829 * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
84830 */
84831 function wp_list_comments($args = array(), $comments = null ) {
84832 global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
84833
84834 $in_comment_loop = true;
84835
84836 $comment_alt = $comment_thread_alt = 0;
84837 $comment_depth = 1;
84838
84839 $defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
84840 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
84841
84842 $r = wp_parse_args( $args, $defaults );
84843
84844 // Figure out what comments we'll be looping through ($_comments)
84845 if ( null !== $comments ) {
84846 $comments = (array) $comments;
84847 if ( empty($comments) )
84848 return;
84849 if ( 'all' != $r['type'] ) {
84850 $comments_by_type = &separate_comments($comments);
84851 if ( empty($comments_by_type[$r['type']]) )
84852 return;
84853 $_comments = $comments_by_type[$r['type']];
84854 } else {
84855 $_comments = $comments;
84856 }
84857 } else {
84858 if ( empty($wp_query->comments) )
84859 return;
84860 if ( 'all' != $r['type'] ) {
84861 if ( empty($wp_query->comments_by_type) )
84862 $wp_query->comments_by_type = &separate_comments($wp_query->comments);
84863 if ( empty($wp_query->comments_by_type[$r['type']]) )
84864 return;
84865 $_comments = $wp_query->comments_by_type[$r['type']];
84866 } else {
84867 $_comments = $wp_query->comments;
84868 }
84869 }
84870
84871 if ( '' === $r['per_page'] && get_option('page_comments') )
84872 $r['per_page'] = get_query_var('comments_per_page');
84873
84874 if ( empty($r['per_page']) ) {
84875 $r['per_page'] = 0;
84876 $r['page'] = 0;
84877 }
84878
84879 if ( '' === $r['max_depth'] ) {
84880 if ( get_option('thread_comments') )
84881 $r['max_depth'] = get_option('thread_comments_depth');
84882 else
84883 $r['max_depth'] = -1;
84884 }
84885
84886 if ( '' === $r['page'] ) {
84887 if ( empty($overridden_cpage) ) {
84888 $r['page'] = get_query_var('cpage');
84889 } else {
84890 $threaded = ( -1 == $r['max_depth'] ) ? false : true;
84891 $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1;
84892 set_query_var( 'cpage', $r['page'] );
84893 }
84894 }
84895 // Validation check
84896 $r['page'] = intval($r['page']);
84897 if ( 0 == $r['page'] && 0 != $r['per_page'] )
84898 $r['page'] = 1;
84899
84900 if ( null === $r['reverse_top_level'] )
84901 $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ) ? TRUE : FALSE;
84902
84903 extract( $r, EXTR_SKIP );
84904
84905 if ( empty($walker) )
84906 $walker = new Walker_Comment;
84907
84908 $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
84909 $wp_query->max_num_comment_pages = $walker->max_pages;
84910
84911 $in_comment_loop = false;
84912 }
84913
84914 ?>