-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Move _doing_it_wrong() to wp_is_block_theme().
#8526
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
This moves the location of the `_doing_it_wrong()` call added to `WP_Theme::is_block_theme()` in [59968] to `wp_is_block_theme()` in order to inform developers that calling this function too early can result in broken parent/child theme relationships. Ticket: https://core.trac.wordpress.org/ticket/63086.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Doesn’t |
|
Good question, @afragen! Returning early ensures that (Edit: also, FWIW, I checked the Core Rollback plugin, and that plugin is calling |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
@joemcgill I didn't think there was an issue in Core Rollback, but it is an example of use in a plugin. I've added your changes in 2 of my test sites running 6.8-beta2. I think there might still be an issue somewhere in The Events Calendar plugin. |
Thanks for testing, @afragen! You're right, this will get triggered on TEC, because they are calling |
|
The changes have been running on 2 of my test servers and only reported errors are from The Events Calendar and Events Calendar Pro. It’s looking much better. |
src/wp-includes/theme.php
Outdated
| */ | ||
| function wp_is_block_theme() { | ||
| if ( ! did_action( 'setup_theme' ) ) { | ||
| _doing_it_wrong( __FUNCTION__, __( 'This function should not be called before themes are set up.' ), '6.8.0' ); |
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.
| _doing_it_wrong( __FUNCTION__, __( 'This function should not be called before themes are set up.' ), '6.8.0' ); | |
| _doing_it_wrong( __FUNCTION__, __( 'This function should not be called before theme directories are set up.' ), '6.8.0' ); |
Or
This function should not be called before register_theme_directory() is called.
Co-authored-by: Joe McGill <801097+joemcgill@users.noreply.github.com>
|
I've merged in Joe's suggestion of switching to test for the definition of theme directories. No error is thrown in the customizer during my testing. Using a modified version of @SirLouen's testing plugin while running @fabiankaegy's MVP block child theme attached to Core-63062, I've been able to confirm child theme are working as expected. Without the early return prior to the the directories being set up, the child theme continues to result in a fatal error when the function is called on Coincidently, I've got some client work to do this-afternoon on a site running WooCommerce, so I will check for notices in that once I have switched tasks. |
|
Replying to @peterwilsoncc
I got this error yesterday in the morning and this is why I started researching further in the idea proposed by dinhtungdu. But I was testing against the Not the current PS: I've noted that the convention to check for the global $wp_theme_directories is using this format: global $wp_theme_directories;
if ( empty( $wp_theme_directories ) ) {
_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before themes are set up.' ), '6.8.0' );
return false;
}Instead of |

This moves the location of the
_doing_it_wrong()call added toWP_Theme::is_block_theme()in [59968] towp_is_block_theme()in order to inform developers that calling this function too early can result in broken parent/child theme relationships.Trac ticket: https://core.trac.wordpress.org/ticket/63086
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.