Skip to content
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

PayPal js files loaded on non PayPal pages (3341) #2411

Merged

Conversation

stracker-phil
Copy link
Collaborator

Problem:

Some plugin assets (JS files) were loaded on WooCommerce settings pages that did not require them.

Checks

  • cart-paylater-block-inserter.js
    • Reported to load on any "WooCommerce → Settings" tab, but not reproducible
    • Only loaded on (admin) pages that also have the Block Editor, via enqueue_block_editor_assets
  • settings.js ← optimized
    • Previously loaded on the "WooCommerce → Settings → Payments" tab
    • Now only loaded on "WooCommerce → Settings → Payments → PayPal" (and related, like "Advanced Card Processing")
    • Addressed in line 171 of the commit
  • Besides the plugin settings tabs ("WooCommerce → Settings → Payments → PayPal"), only two other pages correctly enqueue plugin scripts:
    • Two assets are loaded on the "Order details" page
    • Some assets are loaded in Block Editor, when editing a page/post

Further Cleanup:

This PR also does minor cleanup of the relevant PHP class

  1. Remove unnecessary trailingslashit() calls in the register() method
  2. Change return type of the enqueue() method from bool to void - it's only used as an action callback

@Dinamiko Dinamiko merged commit b069705 into trunk Jul 23, 2024
8 checks passed
@Dinamiko Dinamiko deleted the PCP-3341-pay-pal-js-files-loaded-on-non-pay-pal-pages branch July 23, 2024 10:56
@Dinamiko Dinamiko added the bug Something isn't working label Aug 7, 2024
@Dinamiko Dinamiko added this to the 2.8.3 milestone Aug 7, 2024
@Dinamiko Dinamiko mentioned this pull request Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants