Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Deprecate the woocommerce_shared_settings hook #4092

Merged
merged 2 commits into from Apr 26, 2021

Conversation

mikejolley
Copy link
Member

@mikejolley mikejolley commented Apr 22, 2021

This is pulled from #3864 and closes #3748

This deprecates woocommerce_shared_settings with a notice. Tests have been updated to ignore warnings - we cannot test for the notice yet because WP tests do not support PHPUnit 9.x.

How to test the changes in this Pull Request:

Add a filter somewhere, for example, main plugin file.

add_filter( 'woocommerce_shared_settings', function( $settings ) { return $settings; } );

Visit the store.

Check the debug log:

Screenshot 2021-04-22 at 15 53 30

Dev Note

Blocks surfaced a hook named woocommerce_shared_settings which could be used to change, add, or remove settings that are passed from the server to the client. This is now considered deprecated—a warning will be logged to the browser error console if used.

We recommend instead using the Asset Data Registry directly, so for example:

use Automattic\WooCommerce\Blocks\Package;
use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry;

Package::container()->get( AssetDataRegistry::class )->add( $key, $value )

Doing this lessons the risk of conflicting or overwriting data, since the filter allows any setting to be modified which could lead to unintentional side effects.

Changelog

Replaced usage of the woocommerce_shared_settings hook. This will be deprecated.

@mikejolley mikejolley added status: needs review needs: dev note PR that has some text that needs to be included in the release notes. labels Apr 22, 2021
@mikejolley mikejolley requested a review from a team as a code owner April 22, 2021 14:54
@mikejolley mikejolley requested review from Aljullu and removed request for a team April 22, 2021 14:54
@mikejolley mikejolley self-assigned this Apr 22, 2021
@github-actions
Copy link
Contributor

Size Change: 0 B

Total Size: 1.15 MB

ℹ️ View Unchanged
Filename Size Change
build/active-filters-frontend.js 8.1 kB 0 B
build/active-filters.js 7.65 kB 0 B
build/all-products-frontend.js 35 kB 0 B
build/all-products.js 36.2 kB 0 B
build/all-reviews.js 9.29 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 1.8 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 1.95 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 336 B 0 B
build/atomic-block-components/add-to-cart-frontend.js 8.75 kB 0 B
build/atomic-block-components/add-to-cart.js 7.83 kB 0 B
build/atomic-block-components/button-frontend.js 1.73 kB 0 B
build/atomic-block-components/button.js 843 B 0 B
build/atomic-block-components/category-list-frontend.js 469 B 0 B
build/atomic-block-components/category-list.js 478 B 0 B
build/atomic-block-components/image-frontend.js 1.84 kB 0 B
build/atomic-block-components/image.js 1.31 kB 0 B
build/atomic-block-components/price-frontend.js 1.98 kB 0 B
build/atomic-block-components/price.js 2 kB 0 B
build/atomic-block-components/rating-frontend.js 520 B 0 B
build/atomic-block-components/rating.js 526 B 0 B
build/atomic-block-components/sale-badge-frontend.js 860 B 0 B
build/atomic-block-components/sale-badge.js 870 B 0 B
build/atomic-block-components/sku-frontend.js 389 B 0 B
build/atomic-block-components/sku.js 394 B 0 B
build/atomic-block-components/stock-indicator-frontend.js 568 B 0 B
build/atomic-block-components/stock-indicator.js 572 B 0 B
build/atomic-block-components/summary-frontend.js 908 B 0 B
build/atomic-block-components/summary.js 914 B 0 B
build/atomic-block-components/tag-list-frontend.js 465 B 0 B
build/atomic-block-components/tag-list.js 472 B 0 B
build/atomic-block-components/title-frontend.js 1.41 kB 0 B
build/atomic-block-components/title.js 1.26 kB 0 B
build/attribute-filter-frontend.js 17.8 kB 0 B
build/attribute-filter.js 11.5 kB 0 B
build/blocks-checkout.js 13.2 kB 0 B
build/blocks.js 3.49 kB 0 B
build/cart-frontend.js 77.4 kB 0 B
build/cart.js 43.1 kB 0 B
build/checkout-frontend.js 81.7 kB 0 B
build/checkout.js 45.4 kB 0 B
build/editor-rtl.css 14.9 kB 0 B
build/editor.css 14.9 kB 0 B
build/featured-category.js 7.23 kB 0 B
build/featured-product.js 9.46 kB 0 B
build/handpicked-products.js 5.88 kB 0 B
build/price-filter-frontend.js 14.3 kB 0 B
build/price-filter.js 9.34 kB 0 B
build/price-format.js 1.46 kB 0 B
build/product-best-sellers.js 6.05 kB 0 B
build/product-categories.js 3.23 kB 0 B
build/product-category.js 7.03 kB 0 B
build/product-new.js 6.21 kB 0 B
build/product-on-sale.js 6.64 kB 0 B
build/product-search.js 2.55 kB 0 B
build/product-tag.js 6.09 kB 0 B
build/product-top-rated.js 6.18 kB 0 B
build/products-by-attribute.js 6.97 kB 0 B
build/reviews-by-category.js 11.4 kB 0 B
build/reviews-by-product.js 12.9 kB 0 B
build/reviews-frontend.js 9.1 kB 0 B
build/single-product-frontend.js 38.1 kB 0 B
build/single-product.js 9.71 kB 0 B
build/style-rtl.css 18.8 kB 0 B
build/style.css 18.8 kB 0 B
build/vendors--atomic-block-components/price-frontend.js 6.54 kB 0 B
build/vendors-style-rtl.css 1.05 kB 0 B
build/vendors-style.css 1.05 kB 0 B
build/vendors.js 419 kB 0 B
build/wc-blocks-data.js 10.6 kB 0 B
build/wc-blocks-google-analytics.js 1.99 kB 0 B
build/wc-blocks-middleware.js 1.48 kB 0 B
build/wc-blocks-registry.js 2.74 kB 0 B
build/wc-payment-method-bacs.js 812 B 0 B
build/wc-payment-method-cheque.js 807 B 0 B
build/wc-payment-method-cod.js 903 B 0 B
build/wc-payment-method-paypal.js 844 B 0 B
build/wc-payment-method-stripe.js 12.3 kB 0 B
build/wc-settings.js 2.93 kB 0 B
build/wc-shared-context.js 1.54 kB 0 B
build/wc-shared-hocs.js 1.72 kB 0 B

compressed-size-action

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mikejolley mikejolley merged commit e853849 into trunk Apr 26, 2021
@mikejolley mikejolley deleted the update/deprecate-woocommerce_shared_settings branch April 26, 2021 09:36
@mikejolley mikejolley added this to the 5.0.0 milestone Apr 28, 2021
@mikejolley mikejolley added type: refactor The issue/PR is related to refactoring. type: technical debt This issue/PR represents/solves the technical debt of the project. labels Apr 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: dev note PR that has some text that needs to be included in the release notes. type: refactor The issue/PR is related to refactoring. type: technical debt This issue/PR represents/solves the technical debt of the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't load wc_blocks_data on every route unnecessarily.
2 participants