Always pass back the custom classes `get_post_class()` was called with, even if the post was not found.
props F J Kaiser, Bueltge. fixes #22271. Built from https://develop.svn.wordpress.org/trunk@31408 git-svn-id: http://core.svn.wordpress.org/trunk@31389 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3cd585a457
commit
97698eb127
|
@ -404,12 +404,20 @@ function post_class( $class = '', $post_id = null ) {
|
||||||
* @return array Array of classes.
|
* @return array Array of classes.
|
||||||
*/
|
*/
|
||||||
function get_post_class( $class = '', $post_id = null ) {
|
function get_post_class( $class = '', $post_id = null ) {
|
||||||
$post = get_post($post_id);
|
$post = get_post( $post_id );
|
||||||
|
|
||||||
$classes = array();
|
$classes = array();
|
||||||
|
|
||||||
if ( empty($post) )
|
if ( $class ) {
|
||||||
|
if ( ! is_array( $class ) ) {
|
||||||
|
$class = preg_split( '#\s+#', $class );
|
||||||
|
}
|
||||||
|
$classes = array_map( 'esc_attr', $class );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $post ) {
|
||||||
return $classes;
|
return $classes;
|
||||||
|
}
|
||||||
|
|
||||||
$classes[] = 'post-' . $post->ID;
|
$classes[] = 'post-' . $post->ID;
|
||||||
if ( ! is_admin() )
|
if ( ! is_admin() )
|
||||||
|
@ -466,13 +474,7 @@ function get_post_class( $class = '', $post_id = null ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($class) ) {
|
$classes = array_map( 'esc_attr', $classes );
|
||||||
if ( !is_array( $class ) )
|
|
||||||
$class = preg_split('#\s+#', $class);
|
|
||||||
$classes = array_merge($classes, $class);
|
|
||||||
}
|
|
||||||
|
|
||||||
$classes = array_map('esc_attr', $classes);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the list of CSS classes for the current post.
|
* Filter the list of CSS classes for the current post.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-alpha-31407';
|
$wp_version = '4.2-alpha-31408';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
|
Loading…
Reference in New Issue