-
Notifications
You must be signed in to change notification settings - Fork 3k
Theme JSON: Fix notice when unknown elements are specified #3026
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
Conversation
If I'm following correctly. |
Hey @scruffian, 👋 Your code doesn't solve the gutenberg issue rather it contains another error. Please Test the code U write before creating PR. Thanks. 🙂 |
'path' => array( 'styles', 'elements', $element ), | ||
'selector' => static::ELEMENTS[ $element ], | ||
); | ||
if ( array_key_exists( $element, static::ELEMENTS ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @scruffian ,
This line containing the if check should be below the foreach check.
Currently the test is failing because the $element is undefined.
Kindly check please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry about the typo.
I meant the foreach loop
.
To be more clear:
line 1480 should be at line 1479
and
line 1479 should be at line 1480
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good now. Thanks @scruffian
I made a patch for this on trac: https://core.trac.wordpress.org/ticket/56291 |
May be adding the trac link in the 'description of this PR' will auto link this PR in the trac. |
This was solved in a different way |
If a theme.json file specifies an unknown element then we'll get a notice from line 1482 in this file. This adds an
array_key_exists
check before we get the value of the array at that key, to avoid the notice.Gutenberg issue: WordPress/gutenberg#42649
Trac issue: https://core.trac.wordpress.org/ticket/56291
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.