Make WordPress Core


Ignore:
Timestamp:
11/23/2016 02:46:42 AM (7 years ago)
Author:
joehoyle
Message:

REST API: Allow unsetting of page templates in update requests.

Sending a request to update a page with the template property set to an empty string resulted in an error because “” was not a valid value in the enum.

Props lucasstark, swissspidy.
Fixes #38877.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php

    r39289 r39343  
    2828        $this->has_setup_template = false;
    2929        add_filter( 'theme_page_templates', array( $this, 'filter_theme_page_templates' ) );
     30        // reregister the route as we now have a template available.
     31        $GLOBALS['wp_rest_server']->override_by_default = true;
     32        $controller = new WP_REST_Posts_Controller( 'page' );
     33        $controller->register_routes();
     34        $GLOBALS['wp_rest_server']->override_by_default = false;
    3035    }
    3136
Note: See TracChangeset for help on using the changeset viewer.