diff --git src/wp-includes/post.php src/wp-includes/post.php
index 59506f8..2ff3133 100644
|
|
|
function post_type_supports( $post_type, $feature ) { |
| 1552 | 1552 | } |
| 1553 | 1553 | |
| 1554 | 1554 | /** |
| | 1555 | * Get a list of post type names that support a specific feature. |
| | 1556 | * |
| | 1557 | * @since 4.5.0 |
| | 1558 | * |
| | 1559 | * @param array|string $args Single feature or an array of features the post types should support. |
| | 1560 | * @return array A list of post type names. |
| | 1561 | */ |
| | 1562 | function get_post_types_by_support( $args ) { |
| | 1563 | global $_wp_post_type_features; |
| | 1564 | |
| | 1565 | $features = array_fill_keys( (array) $args, true ); |
| | 1566 | |
| | 1567 | return array_keys( wp_filter_object_list( $_wp_post_type_features, $features ) ); |
| | 1568 | } |
| | 1569 | |
| | 1570 | /** |
| 1555 | 1571 | * Update the post type for the post ID. |
| 1556 | 1572 | * |
| 1557 | 1573 | * The page or post cache will be cleaned for the post ID. |
diff --git tests/phpunit/tests/post/types.php tests/phpunit/tests/post/types.php
index 02d4590..d8154d6 100644
|
|
|
class Tests_Post_Types extends WP_UnitTestCase { |
| 159 | 159 | |
| 160 | 160 | _unregister_post_type( 'foo' ); |
| 161 | 161 | } |
| | 162 | |
| | 163 | /** |
| | 164 | * @ticket 34010 |
| | 165 | */ |
| | 166 | public function test_get_post_types_by_support_single_feature() { |
| | 167 | $this->assertSame( array( |
| | 168 | 'post', |
| | 169 | 'page', |
| | 170 | 'attachment', |
| | 171 | 'nav_menu_item', |
| | 172 | ), get_post_types_by_support( 'title' ) ); |
| | 173 | } |
| | 174 | |
| | 175 | /** |
| | 176 | * @ticket 34010 |
| | 177 | */ |
| | 178 | public function test_get_post_types_by_support_multiple_features() { |
| | 179 | $this->assertSame( array( 'post', 'page' ), get_post_types_by_support( array( 'thumbnail', 'author' ) ) ); |
| | 180 | } |
| | 181 | |
| | 182 | /** |
| | 183 | * @ticket 34010 |
| | 184 | */ |
| | 185 | public function test_get_post_types_by_support_excluding_features() { |
| | 186 | $this->assertSame( array(), get_post_types_by_support( array( 'post-formats', 'page-attributes' ) ) ); |
| | 187 | } |
| | 188 | |
| | 189 | /** |
| | 190 | * @ticket 34010 |
| | 191 | */ |
| | 192 | public function test_get_post_types_by_support_non_existant_feature() { |
| | 193 | $this->assertSame( array(), get_post_types_by_support( 'somefeature' ) ); |
| | 194 | } |
| 162 | 195 | } |