变更集54155
时间戳: 2022年9月14日上午10:50:26 ( 22个月 (之前) 位置: 大旅行箱 文件夹: -
10已编辑
-
src/wp-includes/块编辑器.php (已修改) ( 1个差异 ) -
src/wp-includes/blocks.php (已修改) ( 8个差异 ) -
src/wp-includes/class-wp-block-type.php (已修改) ( 4个差异 ) -
src/wp-includs/class-wp-block.php文件 (已修改) ( 1个差异 ) -
src/wp-includes/deprecated.php (已修改) ( 1个差异 ) -
src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php (已修改) ( 17个差异 ) -
src/wp-includes/script-loader.php (已修改) ( 1个差异 ) -
tests/phpunit/data/blocks/notice/block.json (已修改) ( 1个差异 ) -
tests/phpunit/tests/blocks/register.php (已修改) ( 8个差异 ) -
tests/phpunit/tests/rest-api/rest-block-type-controller.php (已修改) ( 9个差异 )
图例:
未修改 补充 远离的
-
主干/src/wp-includes/block-editor.php 53419兰特 54155兰特 325 325 326 326 foreach($block_registry->get_all_registered()作为$block_type){ 327 if(!空($block_type->style)){ 328 $style_handles[]=$block_type->style; 329 } 330 331 if(!空($block_type->editor_style)){ 332 $style_handles[]=$block_type->editor_style; 333 } 334 335 if(!空($block_type->script)){ 336 $script_handles[]=$block_type->script; 337 } 327 $style_handles=数组_合并( 328 $style_handles, 329 $block_type->style_handles, 330 $block_type->editor_style_handles 331 ); 332 333 $script_handles=数组合并( 334 $script_handles, 335 $block_type->script_handles 336 ); 338 337 } 339 338 -
trunk/src/wp-includes/blocks.php r54138 54155兰特 36 36 * 37 37 *@自5.5.0起 38 *@自6.1.0以来添加了`$index`参数。 38 39 * 39 40 *@param string$block_name块的名称。 40 41 *@param string$field_name元数据字段的名称。 42 *@param int$index可选。 传递多个项目时的资产索引。 43 *默认值为0。 41 44 *@return string为块字段生成的资产名称。 42 45 */ 43 函数generate_block_asset_handle($block_name,$field_name ) { 46 函数generate_block_asset_handle($block_name,$field_name ,$index=0 ) { 44 47 if(0===strpos($block_name,'core/')){ 45 48 $asset_handle=str_replace('core/','wp-block-',$block_name); … … 49 52 if(0===strpos($field_name,'view')){ 50 53 $asset_handle.='资产句柄- 视图'; 54 } 55 if($index>0){ 56 $asset_handle.=“-”。 ($指数+1); 51 57 } 52 58 返回$asset_handle; … … 60 66 “样式”=>“样式”, 61 67 ); 62 返回 str_replace('/','-',$block_name)。 68 $asset_handle= str_replace('/','-',$block_name)。 63 69 '-' . $ 字段映射[$field_name]; 70 if($index>0){ 71 $asset_handle.=“-”。 ($指数+1); 72 } 73 返回$asset_handle; 64 74 } 65 75 … … 71 81 * 72 82 *@自5.5.0起 83 *@自6.1.0起添加了`$index`参数。 73 84 * 74 85 *@param array$metadata块元数据。 75 86 *@param string$field_name要从元数据中选择的字段名。 87 *@param int$index可选。 传递多个项时要注册的脚本的索引。 88 *默认为0。 76 89 *@return string|false直接提供或通过创建的脚本句柄 77 90 *脚本的注册,或失败时为false。 78 91 */ 79 函数register_block_script_handle($metadata,$field_name ) { 92 函数register_block_script_handle($metadata,$field_name ,$index=0 ) { 80 93 if(空($metadata[$field_name]){ 81 94 返回false; 82 95 } 96 83 97 $script_handle=$metadata[$field_name]; 84 $script_path=删除块路径前缀($metadata[$field_name]); 98 if(is_array($script_handle)){ 99 if(空($scripthandle[$index]){ 100 返回false; 101 } 102 $script_handle=$script_handle[$index]; 103 } 104 105 $script_path=remove_block_asset_path_prefix($script_handle); 85 106 if($script_handle===$script_path){ 86 107 返回$script_handle; 87 108 } 88 109 89 $script_handle=生成块资产句柄($metadata[“名称”],$field_name ); 110 $script_handle=生成块资产句柄($metadata[“名称”],$field_name ,$索引 ); 90 111 $script_asset_path=wp_normalize_path( 91 112 真实路径( … … 146 167 * 147 168 *@自5.5.0起 169 *@自6.1.0起添加了`$index`参数。 148 170 * 149 171 *@param array$metadata块元数据。 150 172 *@param string$field_name要从元数据中选择的字段名。 173 *@param int$index可选。 传递多个项时要注册的样式的索引。 174 *默认值为0。 151 175 *@return string|false直接提供或通过创建的Style句柄 152 176 *样式的注册,或失败时为false。 153 177 */ 154 函数register_block_style_handle($metadata,$field_name ) { 178 函数register_block_style_handle($metadata,$field_name ,$index=0 ) { 155 179 if(空($metadata[$field_name]){ 156 180 返回false; 157 181 } 182 158 183 $wpinc_path_norm=wp_normalize_path(真实路径(ABSPATH.wpinc)); 159 184 $theme_path_norm=wp_normalize_path(get_theme_file_path()); 160 185 $is_core_block=isset($metadata['file'])&&0==strpos($metata['file'],$wpinc_path_norm); 186 //提供捆绑版本时,跳过为每个核心块注册单个样式。 161 187 如果($is_core_block&&!wp_sshould_load_separate_core_block_assets()){ 162 188 返回false; 163 189 } 164 190 191 $style_handle=$metadata[$field_name]; 192 if(is_array($stylehandle)){ 193 if(空($stylehandle[$index]){ 194 返回false; 195 } 196 $style_handle=$style_handle[$index]; 197 } 198 199 $style_path=删除块路径前缀($style_handle); 200 $is_style_handle=$style_handle===$style_path; 201 //只允许传递核心块的样式句柄。 202 if($is_core_block&&!$is_style_handle){ 203 返回false; 204 } 205 //返回样式句柄,除非它是每个需要特殊处理的核心块的第一项。 206 if($is_style_handle&&!($is_core_block&&0==$index)){ 207 return$style_handle; 208 } 209 165 210 //检查样式是否应有“.min”后缀。 166 $后缀=SCRIPT_DEBUG?“:”。 最小值'; 167 168 $style_handle=$metadata[$field_name]; 169 $style_path=删除块路径前缀($metadata[$field_name]); 170 171 if($style_handle===$style_path&&!$is_core_block){ 172 return$style_handle; 173 } 174 211 $后缀=SCRIPT_DEBUG?“:”。 最小值'; 175 212 $style_uri=插件url($style_path,$metadata['file']); 176 213 if($is_core_block){ … … 186 223 } 187 224 188 $style_handle=生成块资产句柄($metadata[“名称”],$field_name ); 225 $style_handle=生成块资产句柄($metadata[“名称”],$field_name ,$索引 ); 189 226 $block_dir=目录名($metadata['file']); 190 $style_file= realpath(“$block_dir/$style_path” ); 227 $style_file= wp_normalize_path(realpath(“$block_dir/$style_path”) ); 191 228 $has_style_file=false!==$ 样式文件; 192 229 $版本=$ is_core_block&&isset($metadata['version'])$ 元数据[“版本”]:false; … … 312 349 } 313 350 314 if(!空($metadata['editorScript']){ 315 $settings['editor_script']=寄存器块脚本句柄( 316 $元数据, 317 '编辑器脚本' 318 ); 319 } 320 321 if(!空($metadata['script']){ 322 $settings['script']=寄存器块脚本句柄( 323 $元数据, 324 '脚本' 325 ); 326 } 327 328 if(!空($metadata['viewScript'])){ 329 $settings['view_script']=寄存器块脚本句柄( 330 $元数据, 331 '查看脚本' 332 ); 333 } 334 335 if(!empty($metadata['editorStyle']){ 336 $settings['editor_style']=寄存器块样式句柄( 337 $元数据, 338 '编辑器样式' 339 ); 340 } 341 342 if(!空($metadata['style']){ 343 $settings['style']=寄存器块样式句柄( 344 $元数据, 345 “样式” 346 ); 351 $script_fields=数组( 352 “editorScript”=>“editor_script_handles”, 353 “script”=>“script_handles”, 354 “viewScript”=>“view_script_handles”, 355 ); 356 foreach($script_fields作为$metadata_field_name=>$settings_field-name){ 357 if(!空($metadata[$metadata_field_name]){ 358 $scripts=$metadata[$metadata_field_name]; 359 $processed_scripts=数组(); 360 if(is_array($scripts)){ 361 for($index=0;$index<count($scripts)$ 索引++){ 362 $result=寄存器块脚本句柄( 363 $元数据, 364 $元数据字段名, 365 $索引 366 ); 367 if($result){ 368 $processed_scripts[]=$result; 369 } 370 } 371 }其他{ 372 $result=寄存器块脚本句柄( 373 $元数据, 374 $元数据字段名 375 ); 376 if($result){ 377 $processed_scripts[]=$result; 378 } 379 } 380 $settings[$settings_field_name]=$processed_scripts; 381 } 382 } 383 384 $style_fields=数组( 385 “editorStyle”=>“editor_style_handles”, 386 “style”=>“style_handles”, 387 ); 388 foreach($style_fields作为$metadata_field_name=>$settings_field-name){ 389 if(!空($metadata[$metadata_field_name]){ 390 $styles=$metadata[$metadata_field_name]; 391 $processed_styles=数组(); 392 if(is_array($styles)){ 393 for($index=0;$index<count($styles)$ 索引++){ 394 $result=寄存器块样式句柄( 395 $元数据, 396 $元数据字段名, 397 $索引 398 ); 399 if($result){ 400 $processed_styles[]=$result; 401 } 402 } 403 }其他{ 404 $result=寄存器块样式句柄( 405 $元数据, 406 $元数据字段名 407 ); 408 if($result){ 409 $processed_styles[]=$result; 410 } 411 } 412 $settings[$settings_field_name]=$processed_styles; 413 } 347 414 } 348 415 … … 1263 1330 1264 1331 /** 1265 *允许多种块样式。 1266 * 1267 *@自5.9.0起 1268 * 1269 *@param array$metadata用于注册块类型的元数据。 1270 *@return array用于注册块类型的元数据。 1271 */ 1272 函数_wp_multiple_block_styles($metadata){ 1273 foreach(数组(“style”,“editorStyle”)作为$key){ 1274 if(!空($metadata[$key])&&isarray($metdata[$key]){ 1275 $default_style=array_shift($metadata[$key]); 1276 foreach($metadata[$key]作为$handle){ 1277 $args=数组('handle'=>$handle); 1278 if(0===strpos($handle,'file:')&&isset($metadata['file'])){ 1279 $style_path=删除块资产路径前缀($handle); 1280 $theme_path_norm=wp_normalize_path(get_theme_file_path()); 1281 $style_path_norm=wp_normalize_path(realpath(目录名($metadata['file']).'/')$ 样式路径); 1282 $is_theme_block=isset($metadata['file'])&&0===strpos($metata['file'],$theme_path_norm); 1283 1284 $style_uri=插件url($style_path,$metadata['file']); 1285 1286 if($is_theme_block){ 1287 $style_uri=获取_theme_file_uri(str_replace($theme_path_norm,'',$style_path_norm)); 1288 } 1289 1290 $args=阵列( 1291 “handle”=>sanitize_key(“{$metadata['name']}-{$style_path}”), 1292 “src”=>$style_uri, 1293 ); 1294 } 1295 1296 wp_enqueue_block_style($metadata['name'],$args); 1297 } 1298 1299 //只返回数组中的第一项。 1300 $metadata[$key]=$default_style; 1301 } 1302 } 1303 返回$metadata; 1304 } 1305 add_filter('block_type_metadata','_wp_multiple_block_styles'); 1306 1307 /** 1308 1332 *Helper函数,从传递的 1309 1333 *块属性。 -
trunk/src/wp-includes/class-wp-block-type.php r54133 54155兰特 167 167 168 168 /** 169 *块类型编辑器专用脚本句柄。 170 * 171 *@自5.0.0起 172 *@var字符串|空 173 */ 174 public$editor_script=null; 175 176 /** 177 *块类型前端和编辑器脚本句柄。 178 * 179 *@自5.0.0起 180 *@var字符串|空 181 */ 182 public$script=null; 183 184 /** 185 *块类型仅前端脚本句柄。 186 * 187 *@自5.9.0起 188 *@var字符串|空 189 */ 190 public$view_script=空; 191 192 /** 193 *块类型编辑器专用样式句柄。 194 * 195 *@自5.0.0起 196 *@var字符串|空 197 */ 198 public$editor_style=null; 199 200 /** 201 *块式前端和编辑器式手柄。 202 * 203 *@自5.0.0起 204 *@var字符串|空 205 */ 206 public$style=null; 169 *仅限块类型编辑器的脚本句柄。 170 * 171 *@自6.1.0起 172 *@var字符串[] 173 */ 174 public$editor_script_handles=array(); 175 176 /** 177 *块类型前端和编辑器脚本句柄。 178 * 179 *@自6.1.0起 180 *@var字符串[] 181 */ 182 public$script_handles=array(); 183 184 /** 185 *块类型仅前端脚本句柄。 186 * 187 *@自6.1.0起 188 *@var字符串[] 189 */ 190 public$view_script_handles=array(); 191 192 /** 193 *仅限块类型编辑器样式句柄。 194 * 195 *@自6.1.0起 196 *@var字符串[] 197 */ 198 public$editor_style_handles=array(); 199 200 /** 201 *块类型前端和编辑器样式手柄。 202 * 203 *@自6.1.0起 204 *@var字符串[] 205 */ 206 public$style_handles=array(); 207 208 /** 209 *脚本和样式句柄的块类型属性已弃用。 210 * 211 *@自6.1.0起 212 *@var字符串[] 213 */ 214 private$deprecated_properties=数组( 215 '编辑脚本', 216 “脚本”, 217 '视图脚本', 218 '编辑器样式', 219 “样式”, 220 ); 207 221 208 222 /** … … 229 243 *@自5.9.0起添加了“view_script”属性。 230 244 *@since 6.0.0添加了“祖先”属性。 245 *@自6.1.0起添加了`editor_script_handles`、`script_handles、`view_script_handles、, 246 *`editor_style_handles`和`style_handles属性。 247 *不推荐使用`editor_script`、`script`、`view_script`和`style`属性。 231 248 * 232 249 *@请参阅register_block_type() … … 237 254 *但是,默认情况下支持以下描述的选项。 默认空数组。 238 255 * 239 *@type字符串$api_version 块API版本。 240 *@type字符串$title 人可读块类型标签。 241 *@type string |空$category 块类型类别分类,用于 242 * 搜索界面以按类别排列块类型。 243 *@type字符串[]| null$parent 设置父级允许块只需要 244 * 嵌套在指定块中时可用。 245 *@type string[]| null$祖先 设置祖先使块仅在指定的 246 * 位于祖先的块子树的任何位置的块类型。 247 *@type string|null$图标 块类型图标。 248 *@type字符串$description 详细的块类型描述。 249 *@type字符串[]$关键字 生成块类型的其他关键字 250 * 搜索界面的结果。 251 *@type string |空$textdomain 翻译文本域。 252 *@type数组[]$styles 替代块样式。 253 *@type数组[]$变体 块变化。 254 *@type array | null$支持 支持的功能。 255 *@type数组|null$示例 块预览的结构化数据。 256 *@type可调用|null$render_callback 块类型渲染回调。 257 *@type数组|null$属性 块类型属性特性模式。 258 *@type字符串[]$uses_context 此类型的块继承的上下文值。 259 *@type string[]|空$provides_context 此类型的块提供的上下文。 260 *@type字符串 |空$editor_script块类型编辑器专用脚本句柄 . 261 *@type字符串 |null$script块类型前端和编辑器脚本句柄 . 262 *@type字符串 |空$view_script块类型仅前端脚本句柄 . 263 *@type字符串 |null$editor_style块类型编辑器仅样式句柄 . 264 *@type字符串 |null$style块类型前端和编辑器样式句柄 . 256 *@类型字符串$api_version 块API版本。 257 *@type字符串$title 人可读块类型标签。 258 *@type字符串|null$category 块类型类别分类,用于 259 * 搜索界面以按类别排列块类型。 260 *@type字符串[]| null$parent 设置父级允许块只需要 261 * 嵌套在指定块中时可用。 262 *@type string[]| null$祖先 设置祖先使块仅在指定的 263 * 在祖先块子树的任何位置的块类型。 264 *@type string|null$图标 块类型图标。 265 *@type字符串$description 详细的块类型描述。 266 *@type字符串[]$关键字 生成块类型的其他关键字 267 * 搜索界面的结果。 268 *@type string |空$textdomain 翻译文本域。 269 *@type数组[]$styles 替代块样式。 270 *@type数组[]$变体 块变化。 271 *@type array | null$支持 支持的功能。 272 *@type数组|null$示例 块预览的结构化数据。 273 *@type可调用|null$render_callback 块类型渲染回调。 274 *@type数组|null$属性 块类型属性特性模式。 275 *@type字符串[]$uses_context 此类型的块继承的上下文值。 276 *@type string[]|空$provides_context 此类型的块提供的上下文。 277 *@类型字符串 []$editor_script_handles块类型编辑器专用脚本句柄 . 278 *@type字符串 []$script_handles块类型前端和编辑器脚本句柄 . 279 *@type字符串 []$view_script_handles块类型仅前端脚本句柄 . 280 *@type字符串 []$editor_style_handles块类型编辑器专用样式句柄 . 281 *@type字符串 []$style_handles块类型前端和编辑器样式句柄 . 265 282 * } 266 283 */ … … 269 286 270 287 $this->set_props($args); 288 } 289 290 /** 291 *代理为脚本和样式句柄获取不推荐使用的属性的值,以实现向后兼容性。 292 *如果提供数组中的第一项,则获取相应新属性的值。 293 * 294 *@自6.1.0起 295 * 296 *@param string$name不推荐属性名。 297 * 298 *@return string | null | void如果提供数组中的第一项,则从新属性中读取的值, 299 *未找到值时为null,提供未知属性名称时为void。 300 */ 301 公共函数__get($name){ 302 if(!in_array($name,$this->deprecated_properties)){ 303 回报; 304 } 305 306 $new_name=$name。”_ 手柄'; 307 返回isset($this->{$new_name}[0])$ this->{$new_name}[0]:空; 308 } 309 310 /** 311 *代理检查脚本和样式句柄的弃用属性,以实现向后兼容性。 312 *检查相应的新属性是否具有提供的数组中的第一项。 313 * 314 *@自6.1.0起 315 * 316 *@param string$name不推荐属性名。 317 * 318 *@return boolean对于新属性,当数组中存在第一个项时返回true, 319 *或其他错误。 320 */ 321 公共函数__isset($name){ 322 if(!in_array($name,$this->deprecated_properties)){ 323 返回false; 324 } 325 326 $new_name=$name。”_ 手柄'; 327 返回isset($this->{$new_name}[0]); 328 } 329 330 /** 331 *代理设置脚本和样式句柄的弃用属性的值,以实现向后兼容性。 332 *将相应新属性的值设置为数组中的第一项。 333 *它还允许设置自定义属性以实现向后兼容性。 334 * 335 *@自6.1.0起 336 * 337 *@param string$name属性名。 338 *@param混合了$value属性值。 339 */ 340 公共函数__set($name,$value){ 341 if(!in_array($name,$this->deprecated_properties)){ 342 $this->{$name}=$value; 343 回报; 344 } 345 346 if(!is_string($value)){ 347 回报; 348 } 349 350 $new_name=$name。”_ 手柄'; 351 $this->{$new_name}[0]=$value; 271 352 } 272 353 -
主干/src/wp-includes/class-wp-block.php r54133 54155兰特 261 261 } 262 262 263 if(!空($this->block_type->script)){ 264 wp_enque_script($this->block_type->script); 265 } 266 267 if(!empty($this->block_type->view_script)&&empty{ 268 wp_enqueue_script($this->block_type->view_script); 269 } 270 271 if(!空($this->block_type->style)){ 272 wp_enque_style($this->block_type->style); 263 if((!empty($this->block_type->script_handles)){ 264 foreach($this->block_type->script_handles作为$script_hannel){ 265 wp_enqueue_script($script_handle); 266 } 267 } 268 269 if(!空($this->block_type->view_script_handles)&&empty($this->block-type->render_callback)){ 270 foreach($this->block_type->view_script_handles作为$view_script_chandle){ 271 wp_enqueue_script($view_script_handle); 272 } 273 } 274 275 if((!empty($this->block_type->stylehandles)){ 276 foreach($this->block_type->style_handles作为$style_hannel){ 277 wp_enqueue_style($style_handle); 278 } 273 279 } 274 280 -
trunk/src/wp-includes/deprecated.php 53874兰特 54155兰特 4443 4443 返回false; 4444 4444 } 4445 4446 /** 4447 *允许多种块样式。 4448 * 4449 *@自5.9.0起 4450 *@不推荐使用的6.1.0 4451 * 4452 *@param array$metadata用于注册块类型的元数据。 4453 *@return array用于注册块类型的元数据。 4454 */ 4455 函数_wp_multiple_block_styles($metadata){ 4456 _deprecated_function(__function__,‘6.1.0’); 4457 返回$metadata; 4458 } -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php 53760兰特 54155兰特 257 257 } 258 258 259 $schema=$this->get_item_schema(); 260 $extra_fields=数组( 261 “api版本”, 262 “名称”, 263 '标题', 264 '描述', 265 “图标”, 266 “类别”, 267 '关键词', 268 “父级”, 269 “祖先”, 270 '提供上下文', 271 “uses_context”, 272 “支架”, 273 “样式”, 274 '文本域', 275 “示例”, 259 $schema=$this->get_item_schema(); 260 //WordPress 6.1中不推荐使用字段,但为了向后兼容,保留在模式中。 261 $deprecated_fields=数组( 276 262 '编辑脚本', 277 263 “脚本”, … … 279 265 '编辑器样式', 280 266 “样式”, 281 “变化”, 267 ); 268 $extra_fields=阵列合并( 269 阵列( 270 “api版本”, 271 “名称”, 272 '标题', 273 '描述', 274 “图标”, 275 “类别”, 276 '关键词', 277 “父级”, 278 “祖先”, 279 '提供上下文', 280 “uses_context”, 281 “支架”, 282 “样式”, 283 '文本域', 284 “示例”, 285 '编辑器脚本句柄', 286 '脚本句柄', 287 '视图脚本句柄', 288 '编辑器样式句柄', 289 “style_handles”, 290 “变化”, 291 ), 292 $deprecated_fields(已弃用字段) 282 293 ); 283 294 foreach($extra_fields作为$extra_field){ … … 438 449 ); 439 450 440 $ 模式=数组( 451 $ 此-> 模式=数组( 441 452 “$schema”=>“ http://json-schema.org/draft-04/schema# ', 442 453 'title'=>'block-type', 443 454 “type”=>“object”, 444 455 “属性”=>数组( 445 'api版本' =>数组( 456 'api版本' =>数组( 446 457 '描述'=>__('区块API版本'), 447 458 “type”=>“integer”, … … 450 461 “只读”=>true, 451 462 ), 452 '标题' =>数组( 463 '标题' =>数组( 453 464 “description”=>__(“块类型标题”), 454 465 “type”=>“string”, … … 457 468 “只读”=>true, 458 469 ), 459 “名称” =>数组( 470 “名称” =>数组( 460 471 “description”=>__(“标识块类型的唯一名称”), 461 472 '类型'=>'字符串', … … 464 475 “只读”=>true, 465 476 ), 466 '说明' =>数组( 477 '说明' =>数组( 467 478 '描述'=>__('块类型描述'), 468 479 “type”=>“string”, … … 471 482 “只读”=>true, 472 483 ), 473 “图标” =>$icon_definition, 474 '属性' =>数组( 484 “图标” =>$icon_definition, 485 '属性' =>数组( 475 486 “description”=>__(“块属性”), 476 487 “type”=>数组(“object”,“null”), … … 483 494 “只读”=>true, 484 495 ), 485 '提供上下文' =>数组( 496 '提供上下文' =>数组( 486 497 “description”=>__(“此类型的块提供的上下文。”), 487 498 “type”=>“object”, … … 494 505 “只读”=>true, 495 506 ), 496 '使用上下文' =>数组( 507 '使用上下文' =>数组( 497 508 “description”=>__(“此类型的块继承的上下文值。”), 498 509 “type”=>“array”, … … 504 515 “只读”=>true, 505 516 ), 506 “支持” =>数组( 517 “支持” =>数组( 507 518 “description”=>__(“块支持”), 508 519 “type”=>“object”, … … 512 523 “只读”=>true, 513 524 ), 514 '类别' =>$category_definition, 515 “is_dynamic” =>数组( 525 '类别' =>$category_definition, 526 “is_dynamic” =>数组( 516 527 “description”=>__(“块是动态渲染的。”), 517 528 “type”=>“boolean”, … … 520 531 “只读”=>true, 521 532 ), 522 'editor_script'=>数组( 523 '描述'=>__('编辑器脚本句柄'), 524 “type”=>数组(“string”,“null”), 525 “默认”=>null, 526 'context'=>数组('embed','view','edit'), 527 “只读”=>true, 528 ), 529 “script”=>数组( 530 “description”=>__(“面向公众的编辑器脚本句柄”), 531 “type”=>数组(“string”,“null”), 532 “默认”=>null, 533 “context”=>数组(“embed”、“view”、“edit”), 534 “只读”=>true, 535 ), 536 “view_script”=>数组( 537 '描述'=>__('面向公众的脚本句柄'), 538 “type”=>数组(“string”,“null”), 539 '默认'=>空, 540 “context”=>数组(“embed”、“view”、“edit”), 541 “只读”=>true, 542 ), 543 “editor_style”=>数组( 544 “description”=>__(“编辑器样式句柄”), 545 “type”=>数组(“string”,“null”), 546 “默认”=>null, 547 “context”=>数组(“embed”、“view”、“edit”), 548 “只读”=>true, 549 ), 550 “style”=>数组( 551 “description”=>__(“面向公众的编辑器样式句柄”), 552 “type”=>数组(“string”,“null”), 553 “默认”=>null, 554 “context”=>数组(“embed”、“view”、“edit”), 555 “只读”=>true, 556 ), 557 “styles”=>数组( 533 “editor_script_handles”=>数组( 534 “description”=>__(“编辑器脚本句柄”), 535 “type”=>数组(“array”), 536 “default”=>数组(), 537 “items”=>数组( 538 “type”=>“string”, 539 ), 540 “context”=>数组(“embed”、“view”、“edit”), 541 “只读”=>true, 542 ), 543 “script_handles”=>数组( 544 “description”=>__(“面向公众的和编辑器脚本句柄。”), 545 “type”=>数组(“array”), 546 “default”=>数组(), 547 “items”=>数组( 548 “type”=>“string”, 549 ), 550 “context”=>数组(“embed”、“view”、“edit”), 551 “只读”=>true, 552 ), 553 “view_script_handles”=>数组( 554 “description”=>__(“面向公众的脚本句柄”), 555 “type”=>数组(“array”), 556 “default”=>数组(), 557 “items”=>数组( 558 “type”=>“string”, 559 ), 560 “context”=>数组(“embed”、“view”、“edit”), 561 “只读”=>true, 562 ), 563 “editor_style_handles”=>数组( 564 “description”=>__(“编辑器样式句柄”), 565 “type”=>数组(“array”), 566 “default”=>数组(), 567 “items”=>数组( 568 “type”=>“string”, 569 ), 570 “context”=>数组(“embed”、“view”、“edit”), 571 “只读”=>true, 572 ), 573 'style_handles'=>数组( 574 “description”=>__(“公共外观和编辑器样式句柄。”), 575 “type”=>数组(“array”), 576 “default”=>数组(), 577 'items'=>数组( 578 “type”=>“string”, 579 ), 580 “context”=>数组(“embed”、“view”、“edit”), 581 “只读”=>true, 582 ), 583 “styles”=>数组( 558 584 “description”=>__(“块样式变化”), 559 585 “type”=>“array”, … … 584 610 “只读”=>true, 585 611 ), 586 “变体” =>数组( 612 “变体” =>数组( 587 613 “description”=>__(“块变量”), 588 614 “type”=>“array”, … … 636 662 “默认”=>null, 637 663 ), 638 '文本域' =>数组( 664 '文本域' =>数组( 639 665 '描述'=>__('公共文本域'), 640 666 “type”=>数组(“string”,“null”), … … 643 669 “只读”=>true, 644 670 ), 645 “父级” =>数组( 671 “父级” =>数组( 646 672 “description”=>__(“父块”), 647 673 “type”=>数组(“array”,“null”), … … 653 679 “只读”=>true, 654 680 ), 655 '祖先' =>数组( 681 '祖先' =>阵列( 656 682 “description”=>__(“祖先块”), 657 683 “type”=>数组(“array”,“null”), … … 668 694 ); 669 695 670 $this->schema=$schema; 696 //WordPress 6.1中不推荐使用属性,但为了向后兼容,保留在模式中。 697 $deprecated_properties=数组( 698 “editor_script”=>数组( 699 “description”=>__(“编辑器脚本句柄。弃用:改用”“Editor_script_handles”“), 700 “type”=>数组(“string”,“null”), 701 “默认”=>null, 702 “context”=>数组(“embed”、“view”、“edit”), 703 “只读”=>true, 704 ), 705 “script”=>数组( 706 'description'=>__('面向公众的编辑器脚本句柄。弃用:改用'script_handles'。'), 707 “type”=>数组(“string”,“null”), 708 “默认”=>null, 709 “context”=>数组(“embed”、“view”、“edit”), 710 “只读”=>true, 711 ), 712 “view_script”=>数组( 713 “description”=>__(“面向公共的脚本句柄。弃用:改用“view_script_handles”), 714 “type”=>数组(“string”,“null”), 715 “默认”=>null, 716 “context”=>数组(“embed”、“view”、“edit”), 717 “只读”=>true, 718 ), 719 “editor_style”=>数组( 720 “description”=>__(“编辑器样式句柄。弃用:改用”“Editor_style_handles”“。”), 721 “type”=>数组(“string”,“null”), 722 “默认”=>null, 723 “context”=>数组(“embed”、“view”、“edit”), 724 “只读”=>true, 725 ), 726 “style”=>数组( 727 'description'=>__('面向公众的编辑器样式句柄。弃用:改用'style_handles'。'), 728 “type”=>数组(“string”,“null”), 729 '默认'=>空, 730 “context”=>数组(“embed”、“view”、“edit”), 731 “只读”=>true, 732 ), 733 ); 734 $this->schema['properties']=array_merge($this->schema['属性'],$deprecated_properties); 671 735 672 736 返回$this->add_additional_fields_schema($this->模式); -
trunk/src/wp-includes/script-loader.php 54118兰特 54155卢比 2532 2532 } 2533 2533 2534 $加载编辑器脚本 =is_admin()&&wp_should_load_block_editor_scripts_and_styles(); 2534 $加载编辑器脚本 _和_样式 =is_admin()&&wp_should_load_block_editor_scripts_and_styles(); 2535 2535 2536 2536 $block_registry=WP_block_Type_registry::get_instance(); 2537 2537 foreach($block_registry->get_all_registered()作为$block_name=>$block_type){ 2538 //前端样式。 2539 if(!空($block_type->style)){ 2540 wp_enqueue_style($block_type->style); 2541 } 2542 2543 //前端脚本。 2544 if(!空($block_type->script)){ 2545 wp_enqueue_script($block_type->script); 2546 } 2547 2548 //编辑器样式。 2549 if($load_editor_scripts&&!空($block_type->editor_style)){ 2550 wp_enqueue_style($block_type->editor_style); 2551 } 2552 2553 //编辑器脚本。 2554 if($load_editor_scripts&&!空($block_type->editor_sscript)){ 2555 wp_enqueue_script($block_type->editor_script); 2538 //Front-end和编辑器样式。 2539 foreach($block_type->style_handles作为$style_hannel){ 2540 wp_enqueue_style($style_handle); 2541 } 2542 2543 //Front-end和编辑器脚本。 2544 foreach($block_type->script_handles作为$script_handle){ 2545 wp_enqueue_script($script_handle); 2546 } 2547 2548 if($load_editor_scripts_and_styles){ 2549 //编辑器样式。 2550 foreach($block_type->editor_style_handles作为$editor_syle_handle){ 2551 wp_enqueue_style($editor_style_handle); 2552 } 2553 2554 //编辑器脚本。 2555 foreach($block_type->editor_script_handles作为$editor_sscript_handle){ 2556 wp_enqueue_script($editor_script_handle); 2557 } 2556 2558 } 2557 2559 } -
trunk/tests/phpunit/data/blocks/notice/block.json r54132 54155兰特 58 58 “editorScript”:“测试通知编辑器脚本”, 59 59 “script”:“tests-notice-script”, 60 “viewScript”: “tests-notice-view-script” , 60 “视图脚本”: [“tests-notice-view-script”,“tests-notice-view-script-2”] , 61 61 “editorStyle”:“tests-notice-editor-style”, 62 “风格”: “测试-通知-样式” , 62 “风格”: [“tests-notice-style”,“tests-notice-sstyle-2”] , 63 63 “render”:“file:./render.php” 64 64 } -
trunk/tests/phpunit/tests/blocks/register.php r54132 54155兰特 149 149 $this->资产相同( 150 150 '单元测试-my-block-script', 151 generate_block_asset_handle($block_name,'脚本' ) 152 ); 153 $this->资产相同( 154 '单元测试-my-block-view-script ', 155 generate_block_asset_handle($block_name,'viewScript' ) 156 ); 157 $this->资产相同( 158 '单元测试-my-block-editor样式 ', 159 generate_block_asset_handle($block_name,'editorStyle' ) 151 generate_block_asset_handle($block_name,'脚本' , 0 ) 152 ); 153 $this->资产相同( 154 '单元测试-my-block-view-script -100 ', 155 generate_block_asset_handle($block_name,'viewScript' , 99 ) 156 ); 157 $this->资产相同( 158 '单元测试-my-block-editor样式 -2 ', 159 generate_block_asset_handle($block_name,'editorStyle' , 1 ) 160 160 ); 161 161 $this->资产相同( … … 177 177 $this->资产相同( 178 178 “wp-block-pargraph”, 179 generate_block_asset_handle($block_name,'脚本' ) 180 ); 181 $this->资产相同( 182 'wp-block-pargraph-view(wp-block图形视图) ', 183 generate_block_asset_handle($block_name,'viewScript' ) 184 ); 185 $this->资产相同( 186 'wp-block-pargraph-editor(wp-block图形编辑器) ', 187 generate_block_asset_handle($block_name,'editorStyle' ) 179 generate_block_asset_handle($block_name,'脚本' , 0 ) 180 ); 181 $this->资产相同( 182 'wp-block-pargraph-view(wp-block图形视图) -100 ', 183 generate_block_asset_handle($block_name,'viewScript' , 99 ) 184 ); 185 $this->资产相同( 186 'wp-block-pargraph-editor(wp-block图形编辑器) -2 ', 187 generate_block_asset_handle($block_name,'editorStyle' , 1 ) 188 188 ); 189 189 $this->资产相同( … … 205 205 *@票号50263 206 206 */ 207 公共功能测试_空_ 价值 _寄存器块脚本句柄(){ 207 公共功能测试_空_ 字符串_值_否 _寄存器块脚本句柄(){ 208 208 $metadata=数组(“脚本”=>“”); 209 209 $result=register_block_script_handle($metadata,'script'); 210 211 $this->assertFalse($result); 212 } 213 214 公共函数test_empty_array_value_do_not_register_block_script_handle(){ 215 $metadata=数组('script'=>array()); 216 $result=register_block_script_handle($metadata,'script'); 217 218 $this->assertFalse($result); 219 } 220 221 公共函数test_wrong_array_index_do_not_register_block_script_handle(){ 222 $metadata=数组(“script”=>数组(“test-script-handle”)); 223 $result=register_block_script_handle($metadata,'script',1); 210 224 211 225 $this->assertFalse($result); … … 232 246 公共函数test_handle_passed_register_block_script_handle(){ 233 247 $metadata=数组( 234 ' 编辑S script'=>'测试脚本handle', 235 ); 236 $result=寄存器块脚本句柄($metadata,' 编辑S 脚本'); 248 ' 秒 script'=>'测试脚本handle', 249 ); 250 $result=寄存器块脚本句柄($metadata,' 秒 脚本'); 237 251 238 252 $this->assertSame(“test-script-handle”,$result); 253 } 254 255 公共函数test_handles_passed_register_block_script_handles(){ 256 $metadata=数组( 257 “script”=>数组(“test-script-handle”,“test-script-handle-2”), 258 ); 259 260 $result=register_block_script_handle($metadata,'script'); 261 $this->assertSame(“test-script-handle”,$result); 262 263 $result=register_block_script_handle($metadata,'script',1); 264 $this->assertSame(“test-script-handle-2”,$result,1); 239 265 } 240 266 … … 282 308 *@票号50263 283 309 */ 284 公共功能测试_空_ 找到的值 _寄存器块样式句柄(){ 310 公共功能测试_空_ 字符串_值_否 _寄存器块样式句柄(){ 285 311 $metadata=数组(“style”=>“”); 286 312 $result=register_block_style_handle($metadata,'style'); … … 289 315 } 290 316 317 公共函数test_empty_array_value_do_not_register_block_style_handle(){ 318 $metadata=数组(“style”=>数组()); 319 $result=register_block_style_handle($metadata,'style'); 320 321 $this->assertFalse($result); 322 } 323 324 公共函数test_wrong_array_index_do_not_register_block_style_handle(){ 325 $metadata=数组(“style”=>数组(“test style handle”)); 326 $result=register_block_style_handle($metadata,'style',1); 327 328 $this->assertFalse($result); 329 } 330 291 331 /** 292 332 *@车票50263 … … 299 339 300 340 $this->assertSame(“test-style-handle”,$result); 341 } 342 343 公共函数test_handles_passed_register_block_style_handles(){ 344 $metadata=数组( 345 “style”=>数组(“test-style-handle”,“test-tyle-handle-2”), 346 ); 347 348 $result=register_block_style_handle($metadata,'style'); 349 $this->assertSame(“test-style-handle”,$result); 350 351 $result=register_block_style_handle($metadata,'style',1); 352 $this->assertSame('test-style-handle-2',$result,1); 301 353 } 302 354 … … 443 495 $result->示例 444 496 ); 445 $this->assertSame('tests-notice-editor-script',$result->editor_script); 446 $this->assertSame(“tests-notice-script”,$result->script); 447 $this->assertSame('tests-notice-view-script',$result->view_script); 448 $this->assertSame('测试通知编辑器样式',$result->editor_style); 449 $this->assertSame('tests-notice-style',$result->style); 497 $this->资产SameSet( 498 数组(“tests-notice-editor-script”), 499 $result->editor_script_handles 500 ); 501 $this->资产SameSet( 502 数组(“tests-notice-script”), 503 $result->script_handles 504 ); 505 $this->资产SameSet( 506 数组(“tests-notice-view-script”,“tests-notice-view-script-2”), 507 $result->view_script_handles 508 ); 509 $this->资产SameSet( 510 数组(“tests-notice-editor-style”), 511 $result->editor_style_handles 512 ); 513 $this->资产SameSet( 514 数组(“tests-notice-style”,“tests-notice-sstyle-2”), 515 $result->style_handles 516 ); 450 517 451 518 //@门票50328 -
trunk/tests/phpunit/tests/rest-api/rest-block-type-controller.php 54058兰特 54155兰特 238 238 $this->assertSame('1',$data['description']); 239 239 $this->assertNull($data['icon']); 240 $this->断言 空($data['editor_script '] ); 241 $this->断言 空($data['script '] ); 242 $this->断言 空($data['view_script '] ); 243 $this->断言 空($data['editor_style '] ); 244 $this->断言 空($data['style '] ); 240 $this->断言 SameSet(数组(),$data['editor_script_handles '] ); 241 $this->断言 SameSet(数组(),$data['script_handles '] ); 242 $this->断言 SameSet(数组(),$data['view_script_handles '] ); 243 $this->断言 SameSet(数组(),$data['editor_style_handles '] ); 244 $this->断言 SameSet(数组(),$data['style_handles '] ); 245 245 $this->assertSameSet(数组(),$data['provides_context']); 246 246 $this->资产SameSetsWithIndex( … … 261 261 $this->assertFalse($data['is_dynamic']); 262 262 $this->assertSameSet(数组(array()),$data['variations']); 263 //不推荐的属性。 264 $this->assertNull($data['editor_script']); 265 $this->assertNull($data['script']); 266 $this->assertNull($data['view_script']); 267 $this->assertNull($data['editor_style']); 268 $this->assertNull($data['style']); 269 263 270 } 264 271 … … 300 307 $this->assertSame(“”,$data['description']); 301 308 $this->assertNull($data['icon']); 302 $this->断言 空($data['editor_script '] ); 303 $this->断言 空($data['script '] ); 304 $this->断言 空($data['view_script '] ); 305 $this->断言 空($data['editor_style '] ); 306 $this->断言 空($data['style '] ); 309 $this->断言 SameSet(数组(),$data['editor_script_handles '] ); 310 $this->断言 SameSet(数组(),$data['script_handles '] ); 311 $this->断言 SameSet(数组(),$data['view_script_handles '] ); 312 $this->断言 SameSet(数组(),$data['editor_style_handles '] ); 313 $this->断言 SameSet(数组(),$data['style_handles '] ); 307 314 $this->资产SameSetsWithIndex( 308 315 阵列( … … 324 331 $this->assertFalse($data['is_dynamic']); 325 332 $this->assertSameSet(数组(),$data['variations']); 333 //不推荐的属性。 334 $this->assertNull($data['editor_script']); 335 $this->assertNull($data['script']); 336 $this->assertNull($data['view_script']); 337 $this->assertNull($data['editor_style']); 338 $this->assertNull($data[“样式”]); 326 339 } 327 340 … … 393 406 $data=$response->get_data(); 394 407 $properties=$data['schema']['properties']; 395 $this->assertCount(2 三 ,$properties); 408 $this->assertCount(2 8 ,$properties); 396 409 $this->assertArrayHasKey('api_version',$properties); 397 410 $this->assertArrayHasKey('title',$properties); … … 406 419 $this->assertArrayHasKey(“类别”,$properties); 407 420 $this->assertArrayHasKey(“is_dynamic”,$properties); 408 $this->assertArrayHasKey('editor_script ',$properties); 409 $this->assertArrayHasKey('脚本 ',$properties); 410 $this->assertArrayHasKey('view_script ',$properties); 411 $this->assertArrayHasKey('编辑器样式 ',$properties); 412 $this->assertArrayHasKey('样式 ',$properties); 421 $this->assertArrayHasKey('editor_script _把手 ',$properties); 422 $this->assertArrayHasKey('脚本 _手柄 ',$properties); 423 $this->assertArrayHasKey('view_script _把手 ',$properties); 424 $this->assertArrayHasKey('编辑器样式 _把手 ',$properties); 425 $this->assertArrayHasKey('样式 _把手 ',$properties); 413 426 $this->assertArrayHasKey(“父级”,$properties); 414 427 $this->assertArrayHasKey(“示例”,$properties); … … 417 430 $this->assertArrayHasKey(“变体”,$properties); 418 431 $this->assertArrayHasKey(“祖先”,$properties); 432 //不推荐的属性。 433 $this->assertArrayHasKey('editor_script',$properties); 434 $this->assertArrayHasKey(“脚本”,$properties); 435 $this->assertArrayHasKey('view_script',$properties); 436 $this->assertArrayHasKey('editor_style',$properties); 437 $this->assertArrayHasKey(“样式”,$properties); 438 419 439 } 420 440 … … 519 539 “名称”, 520 540 “类别”, 521 '编辑器脚本 ', 522 '脚本 ', 523 '视图脚本 ', 524 '编辑器样式 ', 525 '样式 ', 541 '编辑器脚本 _把手 ', 542 '脚本 _把手 ', 543 '视图脚本 _把手 ', 544 '编辑_样式 _把手 ', 545 '样式 _把手 ', 526 546 '标题', 527 547 “图标”, … … 535 555 '文本域', 536 556 “示例”, 557 //不推荐的字段。 558 '编辑脚本', 559 “脚本”, 560 '视图脚本', 561 '编辑器样式', 562 “样式”, 537 563 ); 538 564