使WordPress成为核心

变更集55951


忽略:
时间戳:
2023年6月20日晚上10:15:57(12个月(之前)
作者:
audrasjb公司
消息:

REST API:指示主题何时支持主题REST API响应中的站点编辑器。

此变更集添加了是块主题属性中的每个主题wp/v2/主题API响应,使用WP_主题::is_block_Theme确定是否
主题是否为块主题。

Props grantmkin,iron程序员,祖奈德321,azaozz,spacedmonkey,audrasjb,costdev。
修复#58123

位置:
大旅行箱
文件夹:
2已编辑

图例:

未修改
补充
远离的
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php

    53760兰特 人民币55951元  
    327327        }
    328328
     329if(rest_is_field_included('is_block_theme',$fields)){
     330$data['is_block_theme']=$theme->is_block _theme();
     331}
     332
    329333$data=$this->add_additional_fields_to_object($data,$request);
    330334
     
    495499                    ),
    496500                ),
     501“is_block_theme”=>数组(
     502“description”=>__(“主题是否是基于块的主题。”),
     503“type”=>“boolean”,
     504“只读”=>true,
     505                ),
    497506“name”=>数组(
    498507'description'=>__('主题的名称。'),
  • trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php

    55822兰特 55951兰特  
    173173“author_uri”,
    174174'说明',
     175'是块主题',
    175176“名称”,
    176177'需要_php',
     
    186187“版本”,
    187188        );
     189$this->assertIsArray($data);
     190$this->assertNotEmpty($data);
    188191$this->assertSameSet($fields,array_keys($data[0]));
    189192    }
     
    209212“author_uri”,
    210213'说明',
     214'是块主题',
    211215'名称',
    212216'需要_php',
     
    221225“版本”,
    222226        );
     227$this->assertIsArray($data);
     228$this->assertNotEmpty($data);
    223229$this->assertSameSet($fields,array_keys($data[0]));
    224230
     
    344350$data=$response->get_data();
    345351$properties=$data['schema']['properties'];
    346 $this->assertCount(15,$properties);
     352$this->assertCount(16,$properties);
    347353
    348354$this->assertArrayHasKey(“作者”,$properties);
     
    357363$this->assertArrayHasKey(“原始”,$properties['description']['properties']);
    358364$this->assertArrayHasKey('rendered',$properties['description']['properties']);
     365
     366$this->assertArrayHasKey('is_block_theme',$properties);
    359367
    360368$this->assertArrayHasKey(“名称”,$properties);
     
    473481
    474482    /**
     483*@票58123
     484*@covers WP_REST_Themes_Controller::prepare_item_for_response
     485     */
     486公共函数test_theme_is_block_theme(){
     487//测试经典主题,在测试设置中激活。
     488$response=自身::perform_active_theme_request();
     489$result=$response->get_data();
     490
     491$this->assertArrayHasKey('is_block_theme',$result[0]);
     492$this->assertFalse($result[0]['is_block_theme']);
     493
     494//测试块主题。
     495switch_theme(“区块主题”);
     496$response=自身::perform_active_theme_request();
     497$result=$response->get_data();
     498
     499$this->assertArrayHasKey('is_block_theme',$result[0]);
     500$this->assertTrue($result[0]['is_block_theme']);
     501    }
     502
     503    /**
    475504*@票49906
    476505     */
     
    12351264“author_uri”,
    12361265'说明',
     1266'is_block_theme',
    12371267“名称”,
    12381268'需要_php',
注:请参见TracChangeset(跟踪变更集)获取有关使用变更集查看器的帮助。