Skip to content

Passing array of styles causes PHP Warnings and Notices #43086

@sanzeeb3

Description

@sanzeeb3

Description

In the documentation: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style

Note: An option to pass also an array of styles exists since WordPress 5.9.0.

passing an array of styles is possible since 5.9.0. However, I'm on WordPress 6.1 and there are some errors and notices:

[09-Aug-2022 11:04:58 UTC] PHP Notice: Array to string conversion in C:\laragon\www\dev\wp-includes\block-editor.php on line 340
[09-Aug-2022 11:04:58 UTC] PHP Warning: explode() expects parameter 2 to be string, array given in C:\laragon\www\dev\wp-includes\class.wp-dependencies.php on line 186
[09-Aug-2022 11:04:58 UTC] PHP Notice: Trying to access array offset on value of type null in C:\laragon\www\dev\wp-includes\class.wp-dependencies.php on line 187

Both the styles are enqueued, though.

Step-by-step reproduction instructions

  1. Register a block with an array of styles. E.g.
register_block_type(
	'wpfda/block',
       [
                'style' => [ 'wpfda-style', 'wpfda-editor-style' ]
       ]
  1. Go to new post page.
  2. See the error.

Screenshots, screen recording, code snippet

No response

Environment info

Gutenberg is not installed.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

Metadata

Metadata

Assignees

Labels

[Feature] Block APIAPI that allows to express the block paradigm.[Type] WP Core TicketRequires an upstream change from WordPress. Core Trac ticket should be linked.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions