Skip to content

Conversation

@chihsuan
Copy link
Member

@chihsuan chihsuan commented Apr 10, 2025

Submission Review Guidelines:

Changes proposed in this Pull Request:

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.

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

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

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.
@chihsuan chihsuan self-assigned this Apr 10, 2025
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Apr 10, 2025
@chihsuan chihsuan requested review from a team and louwie17 April 10, 2025 05:09
@github-actions
Copy link
Contributor

Testing Guidelines

Hi @louwie17 @woocommerce/flux,

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

@albarin albarin left a comment

Choose a reason for hiding this comment

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

Changes look good to me.
Confirmed wcsettings-deprecation is only loaded in WC admin pages.

@chihsuan chihsuan merged commit baba087 into trunk Apr 10, 2025
41 of 43 checks passed
@chihsuan chihsuan deleted the wooplug-3876-woocommerce-loading-clientadmin-scripts-on-unrelated-wp branch April 10, 2025 07:52
@github-actions github-actions bot added this to the 9.9.0 milestone Apr 10, 2025
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Apr 10, 2025
louwie17 pushed a commit that referenced this pull request Apr 11, 2025
* 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
jorgeatorres pushed a commit that referenced this pull request Apr 14, 2025
…57186)

Fix loading wc admin scripts on unrelated WP admin pages (#57150)

* 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

Co-authored-by: Chi-Hsuan Huang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: analysis Indicates if the PR requires a PR testing scrub session. plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants