-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Add the WooCommerce features engine, take 2 #34727
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
Merged
Konamiman
merged 12 commits into
trunk
from
add/features-controller-with-plugin-compatibility-declaration-take-2
Sep 27, 2022
Merged
Add the WooCommerce features engine, take 2 #34727
Konamiman
merged 12 commits into
trunk
from
add/features-controller-with-plugin-compatibility-declaration-take-2
Sep 27, 2022
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add the FeaturesController and FeaturesUtil classes - Remove the old code to handle Admin related feature toggling - Modify CustomOrdersTableController to handle the COT feature using the new features controller - Add the StringUtil::plugin_name_from_plugin_file method - Add wc_doing_it_wrong in show/hide_feature for COT
Contributor
Test Results SummaryCommit SHA: 7b8b11e
To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
5 tasks
…bility-declaration-take-2
…bility-declaration-take-2
* Initial commit * Implement APMs toggle button - Add valid links to each APM - Add valid link to the marketplace * Implement APMs toggle button - Add valid links to each APM - Add valid link to the marketplace * Refactor the code to be more explicit * Delete the apm on toggle off if it's local state * Implement FAQ simple block - Style a notice about APM is enabled - Add noreferrer and target=_blank to external links * Add todo comments * FAQ simple styling fix (improve padding) * Fixes after inner review * Add changelog item * Address PR review comments * Remove Affirm as it's not in the store * Style fixes, proper internationalization and put valid link * Styling fixes, translators comment, rename ApmsProps component to ApmListProps * Two more styling fixes * Styling fix * Styling fix * Remove text-decoration: none to match the design
* Add shipping class section and dropdown * Add comment suggestions * Add a Spinner during shipping classes resolution
Delete changelog files for 34807 Co-authored-by: WooCommerce Bot <[email protected]>
…#34793) (HPOS/COT) prevent user from paging beyond available range (admin list table for orders).
138eadc to
057595b
Compare
…bility-declaration-take-2
vedanshujain
approved these changes
Sep 27, 2022
Contributor
vedanshujain
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.
LGTM!
Contributor
|
Hi @Konamiman, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:
|
rodrigoprimo
added a commit
to mailpoet/mailpoet
that referenced
this pull request
Oct 3, 2022
The latest version development build of WooCommerce contains a change that modified the method that should be called to enable Woo Custom Orders Tables (see this Woo PR for more information: woocommerce/woocommerce#34727. This commit update the plugin that we use in the acceptance and integration tests to reflect this change. [MAILPOET-4691]
costasovo
pushed a commit
to mailpoet/mailpoet
that referenced
this pull request
Oct 4, 2022
The latest version development build of WooCommerce contains a change that modified the method that should be called to enable Woo Custom Orders Tables (see this Woo PR for more information: woocommerce/woocommerce#34727. This commit update the plugin that we use in the acceptance and integration tests to reflect this change. [MAILPOET-4691]
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
This is a remake of #34616, which was reverted due to failing tests
Background
In this context we define a feature as a major piece of the WooCommerce functionality that can be turned on or off via code API or via admin UI. Each feature has a unique alphanumeric identifier and a standardized name for the option that turns it on or off:
woocommerce_feature_{id}_enabled(the value of the option is eitheryesornolike any other settings related option).A feature can be mature or experimental, the later means that the feature either is still in development or is part of an experiment that could end up being successful or not; so the idea is that ultimately all the features that at one point are marked experimental eventually either become mature or are removed.
WooCommerce plugins may declare positive compatibility or negative compatibility with any of the existing features. Positive means that to the best of the plugin authors knowledge, the plugin will continue to work as expected when the feature is enabled. Negative means that there are known issues that will arise when the plugin is used with the feature enabled.
WooCommerce had already two "features" that were provided by the Admin code: enable analytics, and enable the new navigation. In this pull request these have been repurposed as part of the new "features engine"; as an exceptional case, the old enabling option name is used for those, instead of
woocommerce_feature_{id}_enabled.New classes
This pull request introduces two new classes:
An internal
FeaturesControllerclass. This class has methods to:A public
FeaturesUtilclass with static methods that are proxies toFeaturesController.FeaturesControlleris to be retrieved via the dependency injection container as usual,FeaturesUtilcan be used directly.Declaring feature compatibility
Both
FeaturesControllerandFeaturesUtilhave adeclare_compatibilitymethod that accepts a feature id, a plugin identifier and a boolean indicating positive or negative compatibility. It's mandatory to invoke these methods from inside thebefore_woocommerce_initaction, so that by the timewoocommerce_initis fired any plugin willing to declare feature compatibility has done so already. Plugins must use the method fromFeaturesUtiland not the method fromFeaturesController.The plugin identifier to be passed to
FeaturesUtil::declare_compatibilitymust be the path of the main plugin file, this will be converted todirectory/file.phpwhich is the format used by the keys in the array returned by the WordPressget_pluginsfunction. TheFeaturesController::declare_compatibilitymethod assumes that the plugin identifier it receives is already in this format.Thus this is the snippet that a plugin can use to declare compatibility with a feature (assuming it runs from the main plugin file):
The feature settings UI
This is how the settings page for the features looks now:
At first sight it might look like the only change is the addition of the "Experimental" section, but actually the changes are deeper: now the entire settings page is rendered by the
FeaturesControllerclass, and additionally, all the rendered settings are tied to options with the formatwoocommerce_feature_{id}_enabled. The analytics and new navigation options were previously rendered by Admin code (they keep their old names for the enabling options).This new settings page is still compatible with the
woocommerce_settings_featuresfilter. Any settings added there will be rendered in the "mature" settings section, right after the built-in WooCommerce settings.Compatibility with the
woocommerce_admin_disabledfilter is also maintained. This is how the settings page will render if this filter returnstrue:Enabling the custom orders table feature
Previously the custom orders table feature had to be enabled via the
CustomOrdersTableController::show_featuremethod. This is no longer the case (the new features engine is used instead), and to make this extra clear, thatshow_featuremethod will throw an exception. This method (and the companion,hide_feature) will eventually be removed once the custom orders table feature becomes mature.Compatibility with the old Admin settings
The
FeaturesControllerclass still uses the old option names for enabling/disabling the legacy features:woocommerce_analytics_enabledfor enabling analyticswoocommerce_navigation_enabledfor enabling the new navigationThe Admin code related to the features settings page rendering has been modified: the hookings to
woocommerce_get_sections_advancedandwoocommerce_get_settings_advancedhave been removed, and the methods that were the target of those have been turned into no-ops and marked as deprecated.The feature enabled changed action
Last but not least, a new
woocommerce_feature_enabled_changedaction is introduced. This is fired whenever the enabled status for a feature changes and provides the feature id and whether it has been enabled or disabled.What's missing
Apart from the revamped settings page there are no UI changes. An indication of which plugins are compatible with which features will be introduced in a separate pull request.
Closes #34419.
How to test the changes in this Pull Request:
Compatibility with the old settings and the custom order tables feature
Go to WooCommerce - Settings - Advanced - Features and verify that enabling and disabling "Analytics" and "New navigation" continues to work as expected.
Also verify that the custom orders table feature is properly enabled and disabled from that page (a quite immediate indication is that the "Custom data stores" section appears or disappears from the same settings page).
Declaring compatibility
Create a dummy plugin and add compatibility (positive or negative) with the custom orders table, as in the snippet shown above in "Declaring feature compatibility".
From the command line, verify that you can check compatibility either by plugin name...
...or by feature id:
Others
woocommerce_settings_featuresfilter are still rendered, e.g. add the following to your dummy plugin:woocommerce_admin_disabledfilter:Other information:
pnpm changelog add --filter=<project>?FOR PR REVIEWER ONLY: