Make WordPress Core


Ignore:
Timestamp:
01/03/2021 09:45:42 PM (4 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Expose all themes in the themes controller.

Previously, only the active theme was made available. This commit allows for all themes to be queried if the user has the switch_themes or manage_network_themes capabilities.

This commit also no longer exposes the page, per_page, search and context query parameters since they are not supported by this controller.

Props spacedmonkey, lpawlik, TimothyBlynJacobs.
Fixes #50152.

File:
1 edited

Legend:

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

    r49547 r49925  
    960960        $this->assertContains( 'DELETE', $route['methods'] );
    961961        $this->assertArrayHasKey( '_links', $route );
     962
     963        $this->assertArrayHasKey( 'help', $index->get_links() );
     964        $this->assertArrayNotHasKey( 'wp:active-theme', $index->get_links() );
    962965    }
    963966
     
    19972000    }
    19982001
     2002    /**
     2003     * @ticket 50152
     2004     */
     2005    public function test_index_includes_link_to_active_theme_if_authenticated() {
     2006        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     2007
     2008        $index = rest_do_request( '/' );
     2009        $this->assertArrayHasKey( 'https://api.w.org/active-theme', $index->get_links() );
     2010    }
     2011
    19992012    public function _validate_as_integer_123( $value, $request, $key ) {
    20002013        if ( ! is_int( $value ) ) {
Note: See TracChangeset for help on using the changeset viewer.