Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing array of styles causes PHP Warnings and Notices #43086

Closed
sanzeeb3 opened this issue Aug 9, 2022 · 3 comments
Closed

Passing array of styles causes PHP Warnings and Notices #43086

sanzeeb3 opened this issue Aug 9, 2022 · 3 comments
Assignees
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.

Comments

@sanzeeb3
Copy link
Contributor

sanzeeb3 commented Aug 9, 2022

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

@Mamaduka Mamaduka added the [Feature] Block API API that allows to express the block paradigm. label Aug 9, 2022
@gziolo gziolo added the [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked. label Aug 12, 2022
@gziolo
Copy link
Member

gziolo commented Aug 12, 2022

Passing an array of styles works when passed through block.json file. It doesn't work today when using the 2nd param from register_block_type. There is a proposal to address that: WordPress/wordpress-develop#2853. I hope to see it included in WordPress 6.1.

@gziolo
Copy link
Member

gziolo commented Aug 18, 2022

I have an alternative proposal that should resolve the issue in WordPress core for all style and script types: WordPress/wordpress-develop#3108.

@t-hamano
Copy link
Contributor

A similar problem was reported in #44687. And these issues have been fixed in Changeset 54670 and appear to be included in WordPress 6.1.

Therefore, this issue may be closed.

@gziolo gziolo closed this as completed Nov 26, 2022
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.
Projects
None yet
Development

No branches or pull requests

5 participants