Make WordPress Core


Ignore:
Timestamp:
11/02/2016 03:36:40 AM (8 years ago)
Author:
rmccue
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r39055 r39084  
    19241924
    19251925                case 'post-formats':
     1926                    $supports_formats = get_theme_support( 'post-formats' );
    19261927                    $schema['properties']['format'] = array(
    19271928                        'description' => __( 'The format for the object.' ),
    19281929                        'type'        => 'string',
    1929                         'enum'        => array_values( get_post_format_slugs() ),
     1930                        'enum'        => $supports_formats ? array_values( $supports_formats[0] ) : array(),
    19301931                        'context'     => array( 'view', 'edit' ),
    19311932                    );
Note: See TracChangeset for help on using the changeset viewer.