Make WordPress Core

Changeset 58282

Timestamp:
06/02/2024 07:25:03 PM (6 weeks ago)
Author:
TimothyBlynJacobs
Message:

REST API: Add stylesheet and template URI fields to the Themes API.

Props andrewserong, timothyblynjacobs, noisysocks, ramonopoly, peterwilsoncc, Dharm1025.
Fixes #61021.

Location:
trunk
Files:
2 edited

Legend:

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

    r56586 r58282  
    225225     * @since 5.0.0
    226226     * @since 5.9.0 Renamed `$theme` to `$item` to match parent class for PHP 8 named parameter support.
     227
    227228     *
    228229     * @param WP_Theme        $item    Theme object.
     
    330331        if ( rest_is_field_included( 'is_block_theme', $fields ) ) {
    331332            $data['is_block_theme'] = $theme->is_block_theme();
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
    332349        }
    333350
     
    448465                    'readonly'    => true,
    449466                ),
     467
     468
     469
     470
     471
     472
    450473                'template'       => array(
    451474                    'description' => __( 'The theme\'s template. If this is a child theme, this refers to the parent theme, otherwise this is the same as the theme\'s stylesheet.' ),
    452475                    'type'        => 'string',
     476
     477
     478
     479
     480
     481
    453482                    'readonly'    => true,
    454483                ),
  • trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php

    r57987 r58282  
    163163     *
    164164     * @ticket 45016
     165
    165166     */
    166167    public function test_get_items() {
     
    183184            'status',
    184185            'stylesheet',
     186
    185187            'tags',
    186188            'template',
     189
    187190            'textdomain',
    188191            'theme_supports',
     
    199202     *
    200203     * @ticket 50152
     204
    201205     */
    202206    public function test_get_items_inactive() {
     
    222226            'status',
    223227            'stylesheet',
     228
    224229            'tags',
    225230            'template',
     231
    226232            'textdomain',
    227233            'theme_uri',
     
    348354     *
    349355     * @ticket 45016
     356
    350357     */
    351358    public function test_get_item_schema() {
     
    353360        $data       = $response->get_data();
    354361        $properties = $data['schema']['properties'];
    355         $this->assertCount( 16, $properties );
     362        $this->assertCount( 1, $properties );
    356363
    357364        $this->assertArrayHasKey( 'author', $properties );
     
    378385        $this->assertArrayHasKey( 'status', $properties );
    379386        $this->assertArrayHasKey( 'stylesheet', $properties );
     387
    380388
    381389        $this->assertArrayHasKey( 'tags', $properties );
     
    385393
    386394        $this->assertArrayHasKey( 'template', $properties );
     395
    387396        $this->assertArrayHasKey( 'textdomain', $properties );
    388397        $this->assertArrayHasKey( 'theme_supports', $properties );
     
    536545
    537546    /**
     547
     548
     549
     550
     551
     552
     553
     554
     555
     556
     557
     558
     559
     560
     561
     562
     563
     564
     565
     566
     567
     568
     569
     570
     571
     572
     573
     574
     575
     576
     577
    538578     * @ticket 49906
    539579     */
     
    554594        $this->assertArrayHasKey( 'template', $result[0] );
    555595        $this->assertSame( 'default', $result[0]['template'] );
     596
     597
     598
     599
     600
     601
     602
     603
     604
     605
     606
     607
     608
     609
     610
     611
     612
     613
     614
     615
     616
     617
     618
     619
     620
     621
     622
     623
     624
     625
     626
    556627    }
    557628
     
    12741345            'status',
    12751346            'stylesheet',
     1347
    12761348            'tags',
    12771349            'template',
     1350
    12781351            'textdomain',
    12791352            'theme_uri',
Note: See TracChangeset for help on using the changeset viewer.