Changeset 39620
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r39595 r39620 1924 1924 case 'post-formats': 1925 1925 $supports_formats = get_theme_support( 'post-formats' ); 1926 1927 // Force to an array. Supports formats can return true even if empty in some cases. 1928 $supports_formats = is_array( $supports_formats ) ? array_values( $supports_formats[0] ) : array(); 1929 1930 $supported_formats = array_merge( array( 'standard' ), $supports_formats ); 1931 1926 1932 $schema['properties']['format'] = array( 1927 1933 'description' => __( 'The format for the object.' ), 1928 1934 'type' => 'string', 1929 'enum' => array_merge( array( 'standard' ), $supports_formats ? array_values( $supports_formats[0] ) : array() ),1935 'enum' => $supported_formats, 1930 1936 'context' => array( 'view', 'edit' ), 1931 1937 ); -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r39595 r39620 857 857 $this->assertCount( 1, $data ); 858 858 $this->assertEquals( $post2, $data[0]['id'] ); 859 } 860 861 public function test_get_items_no_supported_post_formats() { 862 // This causes get_theme_support( 'post-formats' ) to return `true` (not an array) 863 add_theme_support( 'post-formats' ); 864 865 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' ); 866 $response = $this->server->dispatch( $request ); 867 $data = $response->get_data(); 868 869 // Set the expected state back for the rest of the tests. 870 global $_wp_theme_features; 871 unset( $_wp_theme_features['post-formats'] ); 872 add_theme_support( 'post-formats', array( 'post', 'gallery' ) ); 873 874 $formats = array( 'standard' ); 875 876 $this->assertEquals( $formats, $data['schema']['properties']['format']['enum'] ); 859 877 } 860 878
Note: See TracChangeset
for help on using the changeset viewer.