1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WordPress6.1からregister_block_typeのパラメータの書き方変わりました

Last updated at Posted at 2023-02-05

register_block_typeの第2引数の連想配列においてeditor_scripteditor_styleなどがeditor_script_handleseditor_style_handlesなど_handlesが付いた形に変わり複数同時に指定できるようになりました。

そして、旧来のeditor_scripteditor_styleの指定がDeprecatedになってます。

まだ動きますが、Deprecatedってことはいつか動かなくなるかもしれないってことなので、要対応ですね。

register_block_type('myblocks/myblock',[
	'editor_script'=>'editor-script-handle',
	'editor_style'=>'editor-style-handle'
]);



register_block_type('myblocks/myblock',[
	'editor_script_handles'=>['editor-script-handle'],
	'editor_style_handles'=>['editor-style-handle']
]);


参考:https://core.trac.wordpress.org/browser/tags/6.1/src/wp-includes/class-wp-block-type.php#L245

@since 6.1.0 Added the `editor_script_handles`, `script_handles`, `view_script_handles`,
`editor_style_handles`, and `style_handles` properties.
Deprecated the `editor_script`, `script`, `view_script`, `editor_style`, and `style` properties.
1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?