Skip to content

Refactor tracking script-injection to use wp_enqueue_script()#12

Merged
Woldbye merged 2 commits intomainfrom
fix-script-injection
Feb 4, 2026
Merged

Refactor tracking script-injection to use wp_enqueue_script()#12
Woldbye merged 2 commits intomainfrom
fix-script-injection

Conversation

@Woldbye
Copy link
Copy Markdown
Collaborator

@Woldbye Woldbye commented Feb 4, 2026

Refactors tracking script injection to comply with WordPress.org plugin guidelines by replacing direct <script> tag output with proper wp_enqueue_script() and wp_add_inline_script() APIs.

This followed the suggestion from the latest Wordpress Plugin Review.

Changes

  • Use wp_enqueue_script() with WP 6.3+ async strategy for the external tracking script
  • Use wp_add_inline_script() for the event queue buffer and queued events output
  • Add script_loader_tag filter for custom data-* attributes
  • Update hooks from wp_head/wp_footer to wp_enqueue_scripts
  • Bump minimum WordPress version to 6.3 (This is required to use the wp_enqueue_script() feature they suggest)

@Woldbye Woldbye self-assigned this Feb 4, 2026
@Woldbye Woldbye changed the title Resolve script-injection problem Refactor tracking script-injection to use wp_enqueue_script() Feb 4, 2026
@Woldbye Woldbye changed the title Refactor tracking script-injection to use wp_enqueue_script() Refactor tracking script-injection to use wp_enqueue_script() Feb 4, 2026
- Add validation to script URL
- Add PHPCS ignore for null version
@Woldbye Woldbye merged commit 7febc73 into main Feb 4, 2026
3 checks passed
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.

1 participant