Skip to content

Conversation

@louwie17
Copy link
Contributor

  • Fix admin script loading condition in WCAdminSharedSettings

Updated the admin script enqueue logic to check if the current page is an admin or embed page before loading the deprecation scripts. This improves performance by preventing unnecessary script loading on non-relevant pages.

  • Add changelog

Submission Review Guidelines:

Changes proposed in this Pull Request:

Note: this is already merged to trunk, but the issue also exists in the 9.8 release, see this issue for example: #57183

WC 9.8 (PR: #55707) introduced a bug where the settings-deprecation script is loaded on all admin pages without any condition, so all its dependencies are also loaded.

This PR adds a condition to check if the current page is an admin or embed page before loading deprecation scripts to ensure we only load the script on relevant pages.

Screenshots or screen recordings:

Before After

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Navigate to any non WooCommerce page in WordPress (e.g., Settings > General)
  2. Check browser's network tab
  3. Verify that /woocommerce/assets/client/admin scripts not being loaded
  4. Go to WooCommerce admin pages
  5. Verify that wcsettings-deprecation.js is still being loaded correctly
  6. Install and activate the Speed Optimizer by Siteground plugin
  7. Go to Speed Optimizer > Dashboard
  8. Open your console and make sure there are no JS errors

Testing that has already taken place:

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

* Fix admin script loading condition in WCAdminSharedSettings

Updated the admin script enqueue logic to check if the current page is an admin or embed page before loading the deprecation scripts. This improves performance by preventing unnecessary script loading on non-relevant pages.

* Add changelog
@louwie17 louwie17 self-assigned this Apr 11, 2025
@louwie17 louwie17 requested a review from Aljullu April 11, 2025 13:48
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Apr 11, 2025
@github-actions
Copy link
Contributor

Testing Guidelines

Hi @Aljullu ,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

@github-actions
Copy link
Contributor

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

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.

Thanks for working on this, @louwie17! Code changes look good to me. I tested with the Speed Controller by SiteGround plugin and confirmed the error is gone:

Before After
imatge imatge
Testing environment
  • WordPress 6.8-RC3 local dev environment
  • Plugins: WooCommerce, WooCommerce Beta Tester, WordPress Beta Tester and Speed Controller by SiteGround
  • Theme: Twenty Twenty-Five
  • Store creation: April 6th 2025
  • Store size: small

@jorgeatorres jorgeatorres merged commit 889e01b into release/9.8 Apr 14, 2025
34 checks passed
@jorgeatorres jorgeatorres deleted the fix/wooplug-3876-woocommerce-loading-clientadmin-scripts-on-unrelated-wp branch April 14, 2025 07:29
@github-actions github-actions bot added cherry pick to trunk Dev only - Part of CFE, PRR flows cherry pick to frozen release Dev only - Part of PRR flow labels Apr 14, 2025
@jorgeatorres jorgeatorres mentioned this pull request Apr 14, 2025
6 tasks
@jorgeatorres jorgeatorres changed the title Fix loading wc admin scripts on unrelated WP admin pages (#57150) Fix loading wc admin scripts on unrelated WP admin pages Apr 17, 2025
@ysc711
Copy link

ysc711 commented Apr 20, 2025

WooCommerce 9.8.1 breaks compatibility with WPCodeBox 2, and we cannot access it now as shown in the attached photo. The support of WPCodeBox 2 said it is waiting for WooCommerce to rollout the fix at #57186 in order to resolve the issues. May we know when the new fixes will be rolled out ? Thank you.

image

@Aljullu
Copy link
Contributor

Aljullu commented Apr 22, 2025

Hi there, @ysc711. WooCommerce 9.8.2 has just been released including this fix.

@ysc711
Copy link

ysc711 commented Apr 22, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry pick to frozen release Dev only - Part of PRR flow cherry pick to trunk Dev only - Part of CFE, PRR flows plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants