Changeset 53715 for trunk/src/wp-includes/comment-template.php
- Timestamp:
- 07/18/2022 05:35:51 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-template.php
r53576 r53715 427 427 * Default empty. 428 428 * @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment. 429 * @param int|WP_Post $post _idPost ID or WP_Post object. Default current post.429 * @param int|WP_Post $post Post ID or WP_Post object. Default current post. 430 430 * @param bool $display Optional. Whether to print or return the output. 431 431 * Default true. 432 432 * @return void|string Void if `$display` argument is true, comment classes if `$display` is false. 433 433 */ 434 function comment_class( $css_class = '', $comment = null, $post _id= null, $display = true ) {434 function comment_class( $css_class = '', $comment = null, $post = null, $display = true ) { 435 435 // Separates classes with a single space, collates classes for comment DIV. 436 $css_class = 'class="' . implode( ' ', get_comment_class( $css_class, $comment, $post _id) ) . '"';436 $css_class = 'class="' . implode( ' ', get_comment_class( $css_class, $comment, $post ) ) . '"'; 437 437 438 438 if ( $display ) { … … 455 455 * @param string|string[] $css_class Optional. One or more classes to add to the class list. Default empty. 456 456 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment. 457 * @param int|WP_Post $post _idPost ID or WP_Post object. Default current post.457 * @param int|WP_Post $post Post ID or WP_Post object. Default current post. 458 458 * @return string[] An array of classes. 459 459 */ 460 function get_comment_class( $css_class = '', $comment_id = null, $post _id= null ) {460 function get_comment_class( $css_class = '', $comment_id = null, $post = null ) { 461 461 global $comment_alt, $comment_depth, $comment_thread_alt; 462 462 … … 477 477 $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); 478 478 // For comment authors who are the author of the post. 479 $ post = get_post( $post_id);480 if ( $ post ) {481 if ( $comment->user_id === $ post->post_author ) {479 $_post = get_post( $post ); 480 if ( $_post ) { 481 if ( $comment->user_id === $_post->post_author ) { 482 482 $classes[] = 'bypostauthor'; 483 483 } … … 535 535 * @param string $comment_id The comment ID as a numeric string. 536 536 * @param WP_Comment $comment The comment object. 537 * @param int|WP_Post $post _idThe post ID or WP_Post object.538 */ 539 return apply_filters( 'comment_class', $classes, $css_class, $comment->comment_ID, $comment, $post _id);537 * @param int|WP_Post $post The post ID or WP_Post object. 538 */ 539 return apply_filters( 'comment_class', $classes, $css_class, $comment->comment_ID, $comment, $post ); 540 540 } 541 541 … … 809 809 * @since 1.5.0 810 810 * 811 * @param int|WP_Post $post _idOptional. Post ID or WP_Post object. Default is global $post.811 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 812 812 * @return string The link to the comments. 813 813 */ 814 function get_comments_link( $post _id= 0 ) {815 $hash = get_comments_number( $post _id) ? '#comments' : '#respond';816 $comments_link = get_permalink( $post _id) . $hash;814 function get_comments_link( $post = 0 ) { 815 $hash = get_comments_number( $post ) ? '#comments' : '#respond'; 816 $comments_link = get_permalink( $post ) . $hash; 817 817 818 818 /** … … 822 822 * 823 823 * @param string $comments_link Post comments permalink with '#comments' appended. 824 * @param int|WP_Post $post _idPost ID or WP_Post object.825 */ 826 return apply_filters( 'get_comments_link', $comments_link, $post _id);824 * @param int|WP_Post $post Post ID or WP_Post object. 825 */ 826 return apply_filters( 'get_comments_link', $comments_link, $post ); 827 827 } 828 828 … … 850 850 * @since 1.5.0 851 851 * 852 * @param int|WP_Post $post _idOptional. Post ID or WP_Post object. Default is the global `$post`.852 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`. 853 853 * @return string|int If the post exists, a numeric string representing the number of comments 854 854 * the post has, otherwise 0. 855 855 */ 856 function get_comments_number( $post_id = 0 ) { 857 $post = get_post( $post_id ); 858 859 if ( ! $post ) { 860 $count = 0; 861 } else { 862 $count = $post->comment_count; 863 $post_id = $post->ID; 864 } 856 function get_comments_number( $post = 0 ) { 857 $post = get_post( $post ); 858 859 $count = $post ? $post->comment_count : 0; 860 $post_id = $post ? $post->ID : 0; 865 861 866 862 /** … … 879 875 * 880 876 * @since 0.71 881 * @since 5.4.0 The `$deprecated` parameter was changed to `$post _id`.882 * 883 * @param string|false $zero 884 * @param string|false $one 885 * @param string|false $more 886 * @param int|WP_Post $post _idOptional. Post ID or WP_Post object. Default is the global `$post`.887 */ 888 function comments_number( $zero = false, $one = false, $more = false, $post _id= 0 ) {889 echo get_comments_number_text( $zero, $one, $more, $post _id);877 * @since 5.4.0 The `$deprecated` parameter was changed to `$post`. 878 * 879 * @param string|false $zero Optional. Text for no comments. Default false. 880 * @param string|false $one Optional. Text for one comment. Default false. 881 * @param string|false $more Optional. Text for more than one comment. Default false. 882 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`. 883 */ 884 function comments_number( $zero = false, $one = false, $more = false, $post = 0 ) { 885 echo get_comments_number_text( $zero, $one, $more, $post ); 890 886 } 891 887 … … 894 890 * 895 891 * @since 4.0.0 896 * @since 5.4.0 Added the `$post _id` parameter to allow using the function outside of the loop.897 * 898 * @param string $zero 899 * @param string $one 900 * @param string $more 901 * @param int|WP_Post $post _idOptional. Post ID or WP_Post object. Default is the global `$post`.892 * @since 5.4.0 Added the `$post` parameter to allow using the function outside of the loop. 893 * 894 * @param string $zero Optional. Text for no comments. Default false. 895 * @param string $one Optional. Text for one comment. Default false. 896 * @param string $more Optional. Text for more than one comment. Default false. 897 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`. 902 898 * @return string Language string for the number of comments a post has. 903 899 */ 904 function get_comments_number_text( $zero = false, $one = false, $more = false, $post _id= 0 ) {905 $number = get_comments_number( $post _id);900 function get_comments_number_text( $zero = false, $one = false, $more = false, $post = 0 ) { 901 $number = get_comments_number( $post ); 906 902 907 903 if ( $number > 1 ) { … … 1236 1232 * @since 1.5.0 1237 1233 * 1238 * @param int|WP_Post $post _idPost ID or WP_Post object. Default current post.1234 * @param int|WP_Post $post Post ID or WP_Post object. Default current post. 1239 1235 * @return bool True if the comments are open. 1240 1236 */ 1241 function comments_open( $post_id = null ) { 1242 1243 $_post = get_post( $post_id ); 1237 function comments_open( $post = null ) { 1238 $_post = get_post( $post ); 1244 1239 1245 1240 $post_id = $_post ? $_post->ID : 0; … … 1266 1261 * @since 1.5.0 1267 1262 * 1268 * @param int|WP_Post $post _idPost ID or WP_Post object. Default current post.1263 * @param int|WP_Post $post Post ID or WP_Post object. Default current post. 1269 1264 * @return bool True if pings are accepted 1270 1265 */ 1271 function pings_open( $post_id = null ) { 1272 1273 $_post = get_post( $post_id ); 1266 function pings_open( $post = null ) { 1267 $_post = get_post( $post ); 1274 1268 1275 1269 $post_id = $_post ? $_post->ID : 0; … … 1516 1510 * 1517 1511 * @param array $comments Array of comments supplied to the comments template. 1518 * @param int $post_ IDPost ID.1512 * @param int $post_id Post ID. 1519 1513 */ 1520 1514 $wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID ); … … 2325 2319 * @type string $format The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'. 2326 2320 * } 2327 * @param int|WP_Post $post _idPost ID or WP_Post object to generate the form for. Default current post.2328 */ 2329 function comment_form( $args = array(), $post _id= null ) {2330 if ( null === $post_id ) {2331 $post_id = get_the_ID(); 2332 }2321 * @param int|WP_Post $post Post ID or WP_Post object to generate the form for. Default current post. 2322 */ 2323 function comment_form( $args = array(), $post = null ) { 2324 $post = get_post( $post ); 2325 2326 $post_id = $post ? $post->ID : get_the_ID(); 2333 2327 2334 2328 // Exit the function when comments for the post are closed.
Note: See TracChangeset
for help on using the changeset viewer.