Changeset 44183 for branches/5.0/src/wp-includes/blocks/latest-comments.php
- Timestamp:
- 12/14/2018 12:19:57 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0/src/wp-includes/blocks/latest-comments.php
r43951 r44183 6 6 */ 7 7 8 if ( ! function_exists( 'wp_latest_comments_draft_or_post_title' ) ) { 9 /** 10 * Get the post title. 11 * 12 * The post title is fetched and if it is blank then a default string is 13 * returned. 14 * 15 * Copied from `wp-admin/includes/template.php`, but we can't include that 16 * file because: 17 * 18 * 1. It causes bugs with test fixture generation and strange Docker 255 error 19 * codes. 20 * 2. It's in the admin; ideally we *shouldn't* be including files from the 21 * admin for a block's output. It's a very small/simple function as well, 22 * so duplicating it isn't too terrible. 23 * 24 * @since 3.3.0 25 * 26 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 27 * @return string The post title if set; "(no title)" if no title is set. 28 */ 29 function wp_latest_comments_draft_or_post_title( $post = 0 ) { 30 $title = get_the_title( $post ); 31 if ( empty( $title ) ) { 32 $title = __( '(no title)' ); 33 } 34 return esc_html( $title ); 8 /** 9 * Get the post title. 10 * 11 * The post title is fetched and if it is blank then a default string is 12 * returned. 13 * 14 * Copied from `wp-admin/includes/template.php`, but we can't include that 15 * file because: 16 * 17 * 1. It causes bugs with test fixture generation and strange Docker 255 error 18 * codes. 19 * 2. It's in the admin; ideally we *shouldn't* be including files from the 20 * admin for a block's output. It's a very small/simple function as well, 21 * so duplicating it isn't too terrible. 22 * 23 * @since 3.3.0 24 * 25 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 26 * @return string The post title if set; "(no title)" if no title is set. 27 */ 28 function wp_latest_comments_draft_or_post_title( $post = 0 ) { 29 $title = get_the_title( $post ); 30 if ( empty( $title ) ) { 31 $title = __( '(no title)' ); 35 32 } 33 return esc_html( $title ); 36 34 } 37 35
Note: See TracChangeset
for help on using the changeset viewer.