From 08ea66490b157698bb564fa844a5a44f949353b0 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Wed, 2 Nov 2016 03:37:32 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@39084 git-svn-id: http://core.svn.wordpress.org/trunk@39026 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../rest-api/endpoints/class-wp-rest-posts-controller.php | 3 ++- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index e5d623705b..7c801a4c44 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -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; diff --git a/wp-includes/version.php b/wp-includes/version.php index 76ad941eec..06d60685e8 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-beta1-39083'; +$wp_version = '4.7-beta1-39084'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.