Move inline settings javascript to ppec-settings.js
#676
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When the PPEC gateway is initialized it loads file
includes/settings/settings-ppec.php
, which returns the set of configuration settings for the gateway.This file also enqueues some inline javascript in order to handle the hiding and showing of certain settings on the settings screen (for example: to hide Live credential fields when the "Sandbox" environment is selected, and viceversa).
Because it is unconditionally enqueued inline, this JS gets added to WC pages on the frontend (and even to all pages if using things like the mini-cart widget). Because the CSS IDs targeted by the code are very specific, this is probably fine most of the time, but it's unnecessary nevertheless. We also have an admin-side settings JS file (
ppec-settings.js
) which is not only not loaded on the frontend but also seems like a more appropriate location for this code.This PR moves the inline JS to
ppec-settings.js
.Note: I couldn't find a reason for this JS to be enqueued on the frontend, but I might've missed something. If that's the case, feel free to comment and/or close the PR.
Steps to test
master
or1.7_dev
.no_inline_settings_js
.