mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
REST API: Only expose formats supported by the current theme.
While it's valid to save any format to the database, and WordPress is totally fine with that, we should only include the formats specified by the theme in the schema. Props danielbachhuber. Fixes #38610. git-svn-id: https://develop.svn.wordpress.org/trunk@39084 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1923,10 +1923,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
break;
|
||||
|
||||
case 'post-formats':
|
||||
$supports_formats = get_theme_support( 'post-formats' );
|
||||
$schema['properties']['format'] = array(
|
||||
'description' => __( 'The format for the object.' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_values( get_post_format_slugs() ),
|
||||
'enum' => $supports_formats ? array_values( $supports_formats[0] ) : array(),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user