Template: Don't output an empty `<ul>` in `the_meta()` when a post only has protected metas.

Props campusboy1987, birgire.
Fixes #42629.

Built from https://develop.svn.wordpress.org/trunk@42225


git-svn-id: http://core.svn.wordpress.org/trunk@42054 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2017-11-24 05:21:51 +00:00
parent 4073743527
commit 5342b33a0b
2 changed files with 7 additions and 4 deletions

View File

@ -1016,7 +1016,7 @@ function post_custom( $key = '' ) {
*/ */
function the_meta() { function the_meta() {
if ( $keys = get_post_custom_keys() ) { if ( $keys = get_post_custom_keys() ) {
echo "<ul class='post-meta'>\n"; $li_html = '';
foreach ( (array) $keys as $key ) { foreach ( (array) $keys as $key ) {
$keyt = trim( $key ); $keyt = trim( $key );
if ( is_protected_meta( $keyt, 'post' ) ) { if ( is_protected_meta( $keyt, 'post' ) ) {
@ -1041,9 +1041,12 @@ function the_meta() {
* @param string $key Meta key. * @param string $key Meta key.
* @param string $value Meta value. * @param string $value Meta value.
*/ */
echo apply_filters( 'the_meta_key', $html, $key, $value ); $li_html .= apply_filters( 'the_meta_key', $html, $key, $value );
}
if ( $li_html ) {
echo "<ul class='post-meta'>\n{$li_html}</ul>\n";
} }
echo "</ul>\n";
} }
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.0-alpha-42224'; $wp_version = '5.0-alpha-42225';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.