-
Notifications
You must be signed in to change notification settings - Fork 47
Update: Simplify core abilties registration in preparation for core patch. #128
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
Update: Simplify core abilties registration in preparation for core patch. #128
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #128 +/- ##
============================================
- Coverage 90.57% 90.47% -0.10%
+ Complexity 188 177 -11
============================================
Files 20 20
Lines 1485 1470 -15
Branches 120 120
============================================
- Hits 1345 1330 -15
Misses 140 140
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
It looks like we need to land #126 first so CI job running against WP core |
|
This will require a rebase with |
73161fb to
ff2624a
Compare
| if ( function_exists( 'add_action' ) ) { | ||
| add_action( 'wp_abilities_api_categories_init', array( 'WP_Core_Abilities', 'register_category' ) ); | ||
| add_action( 'wp_abilities_api_init', array( 'WP_Core_Abilities', 'register' ) ); | ||
| add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' ); |
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.
It might be possible to simplify all the conditions used with a simple (and remove PHPCS exception):
if ( has_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' ) {The same for another action.
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.
Hi @gziolo, you mean just something like as top level code without any other condition?
if ( ! has_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' ) ) {
add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
}
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.
It's the common pattern used in the Gutenberg plugin. The wrapping:
if ( function_exists( 'has_action' ) ) {
might still be necessary to ensure it doesn't break when loading files too early before WP core, which happens in some scenarios.
| * | ||
| * @return void | ||
| */ | ||
| // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
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 is no longer necessary. I think we could copy the latest version directly from WP 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.
I copied the last version directly from core as suggested 👍
gziolo
left a comment
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.
There is one feedback to consider, but otherwise this looks great. Thank you for taking care of it!
|
Thank you a lot for the review @gziolo, if required I will follow up with enhancements 👍 |
This PR applies feedback provided in #108, by @aaronjorbin as a preparation for the core patch.
Testing
Verify automated testing pass.
Oppenened the editor, and the browser console, made some test requests:
Verified things return as expected.