Skip to content

Use wp_script_attributes to add attributes to the BA script#14

Merged
Woldbye merged 9 commits intomainfrom
tracker-script-attributes
Feb 20, 2026
Merged

Use wp_script_attributes to add attributes to the BA script#14
Woldbye merged 9 commits intomainfrom
tracker-script-attributes

Conversation

@Woldbye
Copy link
Copy Markdown
Collaborator

@Woldbye Woldbye commented Feb 13, 2026

Use the wp_script_attributes filter (WP 5.7+) to add data attributes to the tracking script tag, replacing the previous script_loader_tag + str_replace approach. This operates on the attributes array before HTML generation, as recommended by the WordPress plugin reviewer.

Changes

  • Replace script_loader_tag filter with wp_script_attributes filter for adding data-* attributes to the tracker script
  • Refactor add_tracker_script_attributes() from HTML string manipulation to array-based attribute injection
  • Update all attribute-related tests to use array input/output instead of HTML string assertions

@Woldbye Woldbye requested a review from flopper123 February 13, 2026 10:47
@Woldbye Woldbye merged commit edb9447 into main Feb 20, 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.

2 participants