Make WordPress Core

Changeset 43985 for trunk


Ignore:
Timestamp:
12/12/2018 03:32:21 AM (5 years ago)
Author:
jeremyfelt
Message:

REST API: Introduce themes endpoint to expose theme-supports values for the active theme.

In order to correctly render parts of its UI, the new editor needs to be aware of the active theme's post-formats and post-thumbnails support. This data is exposed by querying for the active theme on a new /wp/v2/themes endpoint for sufficiently privileged users.

Merges [43734], [43735] to trunk.

props desrosj.
Fixes #45016.

Location:
trunk
Files:
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/rest-api.php

    r43979 r43985  
    233233    // Settings.
    234234    $controller = new WP_REST_Settings_Controller;
     235    $controller->register_routes();
     236
     237    // Themes.
     238    $controller = new WP_REST_Themes_Controller;
    235239    $controller->register_routes();
    236240}
  • trunk/src/wp-settings.php

    r43009 r43985  
    236236require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-comments-controller.php' );
    237237require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-settings-controller.php' );
     238require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-themes-controller.php' );
    238239require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-meta-fields.php' );
    239240require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-comment-meta-fields.php' );
  • trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r43571 r43985  
    112112            '/wp/v2/comments/(?P<id>[\\d]+)',
    113113            '/wp/v2/settings',
     114            '/wp/v2/themes',
    114115        );
    115116
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r43973 r43985  
    35253525            "_links": {
    35263526                "self": "http://example.org/index.php?rest_route=/wp/v2/settings"
     3527            }
     3528        },
     3529        "/wp/v2/themes": {
     3530            "namespace": "wp/v2",
     3531            "methods": [
     3532                "GET"
     3533            ],
     3534            "endpoints": [
     3535                {
     3536                    "methods": [
     3537                        "GET"
     3538                    ],
     3539                    "args": {
     3540                        "context": {
     3541                            "required": false,
     3542                            "description": "Scope under which the request is made; determines fields present in response.",
     3543                            "type": "string"
     3544                        },
     3545                        "page": {
     3546                            "required": false,
     3547                            "default": 1,
     3548                            "description": "Current page of the collection.",
     3549                            "type": "integer"
     3550                        },
     3551                        "per_page": {
     3552                            "required": false,
     3553                            "default": 10,
     3554                            "description": "Maximum number of items to be returned in result set.",
     3555                            "type": "integer"
     3556                        },
     3557                        "search": {
     3558                            "required": false,
     3559                            "description": "Limit results to those matching a string.",
     3560                            "type": "string"
     3561                        },
     3562                        "status": {
     3563                            "required": true,
     3564                            "description": "Limit result set to themes assigned one or more statuses.",
     3565                            "type": "array",
     3566                            "items": {
     3567                                "enum": [
     3568                                    "active"
     3569                                ],
     3570                                "type": "string"
     3571                            }
     3572                        }
     3573                    }
     3574                }
     3575            ],
     3576            "_links": {
     3577                "self": "http://example.org/index.php?rest_route=/wp/v2/themes"
    35273578            }
    35283579        }
Note: See TracChangeset for help on using the changeset viewer.