From 889c790eb63af927630979a02015cf32b29f4d22 Mon Sep 17 00:00:00 2001 From: James Nylen Date: Fri, 24 Feb 2017 23:30:44 +0000 Subject: [PATCH] REST API: Allow setting post formats even if they are not supported by the theme. A `post_format` not used by the current theme, but supported by core is not a wrong/broken piece of information. It's just not used at this point in time. Therefore we should allow setting and retrieving any of the standard post formats supported in core, even if the current theme doesn't use them. After this commit, a post's `format` value can survive a round trip through the API, which is a good general design principle for an API. Props JPry, iseulde, davidakennedy, Drivingralle. Fixes #39232. Built from https://develop.svn.wordpress.org/trunk@40120 git-svn-id: http://core.svn.wordpress.org/trunk@40057 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../endpoints/class-wp-rest-posts-controller.php | 10 +++------- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 8 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 5b6cafdbc4..30651d0538 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 @@ -1989,17 +1989,13 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { break; case 'post-formats': - $supports_formats = get_theme_support( 'post-formats' ); - - // Force to an array. Supports formats can return true even if empty in some cases. - $supports_formats = is_array( $supports_formats ) ? array_values( $supports_formats[0] ) : array(); - - $supported_formats = array_merge( array( 'standard' ), $supports_formats ); + // Get the native post formats and remove the array keys. + $formats = array_values( get_post_format_slugs() ); $schema['properties']['format'] = array( 'description' => __( 'The format for the object.' ), 'type' => 'string', - 'enum' => $supported_formats, + 'enum' => $formats, 'context' => array( 'view', 'edit' ), ); break; diff --git a/wp-includes/version.php b/wp-includes/version.php index ba6480c10d..637aaf5e92 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-40118'; +$wp_version = '4.8-alpha-40120'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.