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

Add a front end JQuery enqueue check #423

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

adamsilverstein
Copy link
Member

Addresses #402

*
* @return array Error message.
*/
public function getError() {
Copy link
Member Author

Choose a reason for hiding this comment

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

copied this bit from other classes, so i'm assuming it is required?

@adamsilverstein adamsilverstein requested a review from aristath May 23, 2022 14:07

checkcount();

if ( ! preg_match( '/wp_enqueue_script\(\s?("|\')jquery("|\')/i', $php ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

This will catch enqueueing jQuery successfully. However, it will not catch cases where jQuery is a dependency of another script - in which case it also gets loaded.
Most themes don't enqueue jQuery directly, it is simply used as a dependency for their own scripts, so we should check for that scenario as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants