Changeset 31408
- Timestamp:
- 02/11/2015 03:59:06 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post-template.php
r31356 r31408 405 405 */ 406 406 function get_post_class( $class = '', $post_id = null ) { 407 $post = get_post( $post_id);407 $post = get_post( $post_id ); 408 408 409 409 $classes = array(); 410 410 411 if ( empty($post) ) 411 if ( $class ) { 412 if ( ! is_array( $class ) ) { 413 $class = preg_split( '#\s+#', $class ); 414 } 415 $classes = array_map( 'esc_attr', $class ); 416 } 417 418 if ( ! $post ) { 412 419 return $classes; 420 } 413 421 414 422 $classes[] = 'post-' . $post->ID; … … 467 475 } 468 476 469 if ( !empty($class) ) { 470 if ( !is_array( $class ) ) 471 $class = preg_split('#\s+#', $class); 472 $classes = array_merge($classes, $class); 473 } 474 475 $classes = array_map('esc_attr', $classes); 477 $classes = array_map( 'esc_attr', $classes ); 476 478 477 479 /** -
trunk/tests/phpunit/tests/post/getPostClass.php
r31280 r31408 46 46 47 47 /** 48 * @ticket 22271 49 */ 50 public function test_with_custom_classes_and_no_post() { 51 $this->assertEquals( array(), get_post_class( '', null ) ); 52 $this->assertEquals( array( 'foo' ), get_post_class( 'foo', null ) ); 53 $this->assertEquals( array( 'foo', 'bar' ), get_post_class( array( 'foo', 'bar' ), null ) ); 54 } 55 56 /** 48 57 * @group cache 49 58 */
Note: See TracChangeset
for help on using the changeset viewer.