Changeset 33776
- Timestamp:
- 08/28/2015 03:38:26 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post-functions.php
r33759 r33776 1338 1338 $post_type = $post_type_object->name; 1339 1339 1340 $default_labels = clone $labels; 1341 1340 1342 /** 1341 1343 * Filter the labels of a specific post type. … … 1350 1352 * @param object $labels Object with labels for the post type as member variables. 1351 1353 */ 1352 return apply_filters( "post_type_labels_{$post_type}", $labels ); 1354 $labels = apply_filters( "post_type_labels_{$post_type}", $labels ); 1355 1356 // Ensure that the filtered labels contain all required default values. 1357 $labels = (object) array_merge( (array) $default_labels, (array) $labels ); 1358 1359 return $labels; 1353 1360 } 1354 1361 -
trunk/tests/phpunit/tests/post/types.php
r31457 r33776 102 102 _unregister_post_type( 'foo' ); 103 103 } 104 105 /** 106 * @ticket 33543 107 */ 108 function test_get_post_type_labels_should_fall_back_on_defaults_when_filtered_labels_do_not_contain_the_keys() { 109 add_filter( 'post_type_labels_foo', array( $this, 'filter_post_type_labels' ) ); 110 register_post_type( 'foo' ); 111 112 $this->assertObjectHasAttribute( 'featured_image', get_post_type_object( 'foo' )->labels ); 113 $this->assertObjectHasAttribute( 'set_featured_image', get_post_type_object( 'foo' )->labels ); 114 115 _unregister_post_type( 'foo' ); 116 remove_filter( 'post_type_labels_foo', array( $this, 'filter_post_type_labels' ) ); 117 } 118 119 public function filter_post_type_labels( $labels ) { 120 unset( $labels->featured_image ); 121 unset( $labels->set_featured_image ); 122 return $labels; 123 } 124 104 125 }
Note: See TracChangeset
for help on using the changeset viewer.