Changeset 54956 for trunk/src/wp-includes/post-template.php
- Timestamp:
- 12/11/2022 01:40:18 PM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post-template.php
r54891 r54956 35 35 * @since 0.71 36 36 * 37 * @param string $before Optional. Markup to prepend to the title. Default empty.38 * @param string $after Optional. Markup to append to the title. Default empty.39 * @param bool $ echoOptional. Whether to echo or return the title. Default true for echo.40 * @return void|string Void if `$ echo` argument is true, current post title if `$echo` is false.41 */ 42 function the_title( $before = '', $after = '', $ echo= true ) {37 * @param string $before Optional. Markup to prepend to the title. Default empty. 38 * @param string $after Optional. Markup to append to the title. Default empty. 39 * @param bool $display Optional. Whether to echo or return the title. Default true for echo. 40 * @return void|string Void if `$display` argument is true, current post title if `$display` is false. 41 */ 42 function the_title( $before = '', $after = '', $display = true ) { 43 43 $title = get_the_title(); 44 44 … … 49 49 $title = $before . $title . $after; 50 50 51 if ( $ echo) {51 if ( $display ) { 52 52 echo $title; 53 53 } else { … … 454 454 * @since 2.7.0 455 455 * 456 * @param string|string[] $class One or more classes to add to the class list. 457 * @param int|WP_Post $post Optional. Post ID or post object. Defaults to the global `$post`. 458 */ 459 function post_class( $class = '', $post = null ) { 456 * @param string|string[] $css_class Optional. One or more classes to add to the class list. 457 * Default empty. 458 * @param int|WP_Post $post Optional. Post ID or post object. Defaults to the global `$post`. 459 */ 460 function post_class( $css_class = '', $post = null ) { 460 461 // Separates classes with a single space, collates classes for post DIV. 461 echo 'class="' . esc_attr( implode( ' ', get_post_class( $c lass, $post ) ) ) . '"';462 echo 'class="' . esc_attr( implode( ' ', get_post_class( $css_class, $post ) ) ) . '"'; 462 463 } 463 464 … … 474 475 * case; the class has the 'tag-' prefix instead of 'post_tag-'. All class names are 475 476 * passed through the filter, {@see 'post_class'}, with the list of class names, followed by 476 * $c lass parameter value, with the post ID as the last parameter.477 * $css_class parameter value, with the post ID as the last parameter. 477 478 * 478 479 * @since 2.7.0 479 480 * @since 4.2.0 Custom taxonomy class names were added. 480 481 * 481 * @param string|string[] $class Space-separated string or array of class names to add to the class list. 482 * @param int|WP_Post $post Optional. Post ID or post object. 482 * @param string|string[] $css_class Optional. Space-separated string or array of class names 483 * to add to the class list. Default empty. 484 * @param int|WP_Post $post Optional. Post ID or post object. 483 485 * @return string[] Array of class names. 484 486 */ 485 function get_post_class( $c lass = '', $post = null ) {487 function get_post_class( $css_class = '', $post = null ) { 486 488 $post = get_post( $post ); 487 489 488 490 $classes = array(); 489 491 490 if ( $c lass ) {491 if ( ! is_array( $c lass ) ) {492 $c lass = preg_split( '#\s+#', $class );493 } 494 $classes = array_map( 'esc_attr', $c lass );492 if ( $css_class ) { 493 if ( ! is_array( $css_class ) ) { 494 $css_class = preg_split( '#\s+#', $css_class ); 495 } 496 $classes = array_map( 'esc_attr', $css_class ); 495 497 } else { 496 498 // Ensure that we always coerce class to being an array. 497 $c lass = array();499 $css_class = array(); 498 500 } 499 501 … … 559 561 * @param int $post_id The post ID. 560 562 * @param string[] $classes An array of post class names. 561 * @param string[] $c lassAn array of additional class names added to the post.563 * @param string[] $css_class An array of additional class names added to the post. 562 564 */ 563 $taxonomies = apply_filters( 'post_class_taxonomies', $taxonomies, $post->ID, $classes, $c lass );565 $taxonomies = apply_filters( 'post_class_taxonomies', $taxonomies, $post->ID, $classes, $css_class ); 564 566 565 567 foreach ( (array) $taxonomies as $taxonomy ) { … … 592 594 * @since 2.7.0 593 595 * 594 * @param string[] $classes An array of post class names.595 * @param string[] $c lassAn array of additional class names added to the post.596 * @param int $post_id The post ID.596 * @param string[] $classes An array of post class names. 597 * @param string[] $css_class An array of additional class names added to the post. 598 * @param int $post_id The post ID. 597 599 */ 598 $classes = apply_filters( 'post_class', $classes, $c lass, $post->ID );600 $classes = apply_filters( 'post_class', $classes, $css_class, $post->ID ); 599 601 600 602 return array_unique( $classes ); … … 606 608 * @since 2.8.0 607 609 * 608 * @param string|string[] $class Space-separated string or array of class names to add to the class list. 609 */ 610 function body_class( $class = '' ) { 610 * @param string|string[] $css_class Optional. Space-separated string or array of class names 611 * to add to the class list. Default empty. 612 */ 613 function body_class( $css_class = '' ) { 611 614 // Separates class names with a single space, collates class names for body element. 612 echo 'class="' . esc_attr( implode( ' ', get_body_class( $c lass ) ) ) . '"';615 echo 'class="' . esc_attr( implode( ' ', get_body_class( $css_class ) ) ) . '"'; 613 616 } 614 617 … … 620 623 * @global WP_Query $wp_query WordPress Query object. 621 624 * 622 * @param string|string[] $class Space-separated string or array of class names to add to the class list. 625 * @param string|string[] $css_class Optional. Space-separated string or array of class names 626 * to add to the class list. Default empty. 623 627 * @return string[] Array of class names. 624 628 */ 625 function get_body_class( $c lass = '' ) {629 function get_body_class( $css_class = '' ) { 626 630 global $wp_query; 627 631 … … 831 835 } 832 836 833 if ( ! empty( $c lass ) ) {834 if ( ! is_array( $c lass ) ) {835 $c lass = preg_split( '#\s+#', $class );836 } 837 $classes = array_merge( $classes, $c lass );837 if ( ! empty( $css_class ) ) { 838 if ( ! is_array( $css_class ) ) { 839 $css_class = preg_split( '#\s+#', $css_class ); 840 } 841 $classes = array_merge( $classes, $css_class ); 838 842 } else { 839 843 // Ensure that we always coerce class to being an array. 840 $c lass = array();844 $css_class = array(); 841 845 } 842 846 … … 848 852 * @since 2.8.0 849 853 * 850 * @param string[] $classes An array of body class names.851 * @param string[] $c lassAn array of additional class names added to the body.854 * @param string[] $classes An array of body class names. 855 * @param string[] $css_class An array of additional class names added to the body. 852 856 */ 853 $classes = apply_filters( 'body_class', $classes, $c lass );857 $classes = apply_filters( 'body_class', $classes, $css_class ); 854 858 855 859 return array_unique( $classes );
Note: See TracChangeset
for help on using the changeset viewer.