Skip to content

Use wp_enqueue for frontend assets; replace hand-printed script tags #10

@nolderoos

Description

@nolderoos

wp.org review round 1, item 2/7.

Reviewer verbatim

Your plugin is not correctly including JS and/or CSS. You should be using the built in functions for this:

When including JavaScript code you can use:
wp_register_script() and wp_enqueue_script() to add JavaScript code from a file.
wp_add_inline_script() to add inline JavaScript code to previous declared scripts.

When including CSS you can use:
wp_register_style() and wp_enqueue_style() to add CSS from a file.
wp_add_inline_style() to add inline CSS to previously declared CSS.

Example(s) from your plugin:
templates/partials/faq.php:69 (raw <script type="application/ld+json"> tag)

Cross-referenced from the "escape output" section, two more sites in scope:

templates/trust-center.php:242 wp_add_inline_script('opentrust-frontend', (string) file_get_contents($ot_js_path));
templates/trust-center.php:105, templates/chat.php:99 (same pattern for CSS).

Plan (Option C, hybrid)

  • Frontend/chat CSS and JS files registered with real plugins_url() $src. wp_print_styles / wp_print_scripts called explicitly inside the templates (NOT wp_head() / wp_footer(), to preserve theme isolation).
  • Per-request inline data stays inline through the asset API: accent-colour CSS variables via wp_add_inline_style, font URL injected as a CSS custom property.
  • frontend.css updated to use var(--ot-font-url) instead of the @@OT_FONT_URL@@ placeholder.
  • Bare <script type="application/ld+json"> in faq.php and the <script id="ot-chat-config" type="application/json"> in chat.php swapped for wp_print_inline_script_tag().

Full pre-flight analysis: wporg-review/02-enqueue-scripts/analysis.md (untracked, local).

Reviewer email: wporg-review/wporg-review-email.txt lines 29-53.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions