808 * |
808 * |
809 * @since 2.1.3 |
809 * @since 2.1.3 |
810 * @uses $post Gets the ID of the current post for the token |
810 * @uses $post Gets the ID of the current post for the token |
811 */ |
811 */ |
812 function wp_comment_form_unfiltered_html_nonce() { |
812 function wp_comment_form_unfiltered_html_nonce() { |
813 global $post; |
813 $post = get_post(); |
814 |
814 $post_id = $post ? $post->ID : 0; |
815 $post_id = 0; |
|
816 if ( !empty($post) ) |
|
817 $post_id = $post->ID; |
|
818 |
815 |
819 if ( current_user_can( 'unfiltered_html' ) ) { |
816 if ( current_user_can( 'unfiltered_html' ) ) { |
820 wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false ); |
817 wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false ); |
821 echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n"; |
818 echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n"; |
822 } |
819 } |
895 $comments = &$wp_query->comments; |
892 $comments = &$wp_query->comments; |
896 $wp_query->comment_count = count($wp_query->comments); |
893 $wp_query->comment_count = count($wp_query->comments); |
897 update_comment_cache($wp_query->comments); |
894 update_comment_cache($wp_query->comments); |
898 |
895 |
899 if ( $separate_comments ) { |
896 if ( $separate_comments ) { |
900 $wp_query->comments_by_type = &separate_comments($comments); |
897 $wp_query->comments_by_type = separate_comments($comments); |
901 $comments_by_type = &$wp_query->comments_by_type; |
898 $comments_by_type = &$wp_query->comments_by_type; |
902 } |
899 } |
903 |
900 |
904 $overridden_cpage = false; |
901 $overridden_cpage = false; |
905 if ( '' == get_query_var('cpage') && get_option('page_comments') ) { |
902 if ( '' == get_query_var('cpage') && get_option('page_comments') ) { |
906 set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); |
903 set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); |
907 $overridden_cpage = true; |
904 $overridden_cpage = true; |
908 } |
905 } |
909 |
906 |
910 if ( !defined('COMMENTS_TEMPLATE') || !COMMENTS_TEMPLATE) |
907 if ( !defined('COMMENTS_TEMPLATE') ) |
911 define('COMMENTS_TEMPLATE', true); |
908 define('COMMENTS_TEMPLATE', true); |
912 |
909 |
913 $include = apply_filters('comments_template', STYLESHEETPATH . $file ); |
910 $include = apply_filters('comments_template', STYLESHEETPATH . $file ); |
914 if ( file_exists( $include ) ) |
911 if ( file_exists( $include ) ) |
915 require( $include ); |
912 require( $include ); |
1329 * @param array $args |
1326 * @param array $args |
1330 */ |
1327 */ |
1331 function start_el( &$output, $comment, $depth, $args, $id = 0 ) { |
1328 function start_el( &$output, $comment, $depth, $args, $id = 0 ) { |
1332 $depth++; |
1329 $depth++; |
1333 $GLOBALS['comment_depth'] = $depth; |
1330 $GLOBALS['comment_depth'] = $depth; |
|
1331 $GLOBALS['comment'] = $comment; |
1334 |
1332 |
1335 if ( !empty($args['callback']) ) { |
1333 if ( !empty($args['callback']) ) { |
1336 call_user_func($args['callback'], $comment, $args, $depth); |
1334 call_user_func($args['callback'], $comment, $args, $depth); |
1337 return; |
1335 return; |
1338 } |
1336 } |
1339 |
1337 |
1340 $GLOBALS['comment'] = $comment; |
|
1341 extract($args, EXTR_SKIP); |
1338 extract($args, EXTR_SKIP); |
1342 |
1339 |
1343 if ( 'div' == $args['style'] ) { |
1340 if ( 'div' == $args['style'] ) { |
1344 $tag = 'div'; |
1341 $tag = 'div'; |
1345 $add_below = 'comment'; |
1342 $add_below = 'comment'; |
1429 if ( null !== $comments ) { |
1426 if ( null !== $comments ) { |
1430 $comments = (array) $comments; |
1427 $comments = (array) $comments; |
1431 if ( empty($comments) ) |
1428 if ( empty($comments) ) |
1432 return; |
1429 return; |
1433 if ( 'all' != $r['type'] ) { |
1430 if ( 'all' != $r['type'] ) { |
1434 $comments_by_type = &separate_comments($comments); |
1431 $comments_by_type = separate_comments($comments); |
1435 if ( empty($comments_by_type[$r['type']]) ) |
1432 if ( empty($comments_by_type[$r['type']]) ) |
1436 return; |
1433 return; |
1437 $_comments = $comments_by_type[$r['type']]; |
1434 $_comments = $comments_by_type[$r['type']]; |
1438 } else { |
1435 } else { |
1439 $_comments = $comments; |
1436 $_comments = $comments; |
1522 $user_identity = $user->exists() ? $user->display_name : ''; |
1519 $user_identity = $user->exists() ? $user->display_name : ''; |
1523 |
1520 |
1524 $req = get_option( 'require_name_email' ); |
1521 $req = get_option( 'require_name_email' ); |
1525 $aria_req = ( $req ? " aria-required='true'" : '' ); |
1522 $aria_req = ( $req ? " aria-required='true'" : '' ); |
1526 $fields = array( |
1523 $fields = array( |
1527 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . |
1524 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
1528 '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>', |
1525 '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>', |
1529 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . |
1526 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
1530 '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>', |
1527 '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>', |
1531 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' . |
1528 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' . |
1532 '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', |
1529 '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', |
1533 ); |
1530 ); |
1534 |
1531 |
1535 $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); |
1532 $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); |
1536 $defaults = array( |
1533 $defaults = array( |
1537 'fields' => apply_filters( 'comment_form_default_fields', $fields ), |
1534 'fields' => apply_filters( 'comment_form_default_fields', $fields ), |
1538 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', |
1535 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', |
1539 'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', |
1536 'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', |
1540 'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', |
1537 'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', |
1541 'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>', |
1538 'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>', |
1542 'comment_notes_after' => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>', |
1539 'comment_notes_after' => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>', |
1543 'id_form' => 'commentform', |
1540 'id_form' => 'commentform', |
1544 'id_submit' => 'submit', |
1541 'id_submit' => 'submit', |
1545 'title_reply' => __( 'Leave a Reply' ), |
1542 'title_reply' => __( 'Leave a Reply' ), |