-
Notifications
You must be signed in to change notification settings - Fork 839
refactor: Improve the editor assets endpoint #45714
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
base: trunk
Are you sure you want to change the base?
Conversation
Simplify existing logic with helpful utilities.
Extract various work to simplify the primary function.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 1 file.
|
| array_keys( WP_Block_Type_Registry::get_instance()->get_all_registered() ), | ||
| function ( $block_name ) { | ||
| return strpos( $block_name, 'core/' ) === 0; | ||
| return str_starts_with( $block_name, 'core/' ); |
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.
This and similar changes merely change generic string utilities to more explicit ones to better communicate intent.
| } finally { | ||
| // Always restore original asset state, even if an exception occurred | ||
| $wp_styles = $current_wp_styles; | ||
| $wp_scripts = $current_wp_scripts; | ||
| } |
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.
This try/finally block as added to ensure global state is restored in the event of an error. It will likely have no impact, but felt worthwhile nonetheless.
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.
These changes solely relocate existing code, aside from the inline comments noting otherwise.
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
Tip
I recommend reviewing each commit individually to simplify code review.
Important
#45715 builds upon this, so any manual testing should be performed on that branch.
Refactor existing code to use appropriate string methods, improve organization, and ensure restored global state. The majority of the changes are relocating existing code. The only new code is a
try/finalblock and string utility usage.Proposed changes:
str_containsandstr_starts_withoverstrpos.get_items()complexity by extracting disparate functions.try/finalto ensure global state restoration.Other information:
Jetpack product discussion
N/A
Does this pull request change what data or activity we track or use?
No
Testing instructions:
curl.