Only run "woocommerce_admin_shared_settings" filter on admin requests (#51161)

* Only load settings if it's admin

* Add changelog
This commit is contained in:
Chi-Hsuan Huang 2024-09-06 11:44:01 +08:00 committed by GitHub
parent 0ef7d95aff
commit cb2549386a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: performance
Only run woocommerce_admin_shared_settings filter on admin requests

View File

@ -54,6 +54,11 @@ class WCAdminSharedSettings {
* @return void
*/
public function on_woocommerce_blocks_loaded() {
// Ensure we only add admin settings on the admin.
if ( ! is_admin() ) {
return;
}
if ( class_exists( '\Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry' ) ) {
\Automattic\WooCommerce\Blocks\Package::container()->get( \Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry::class )->add(
$this->settings_prefix,
@ -64,4 +69,3 @@ class WCAdminSharedSettings {
}
}
}