Skip to content

Updated theme mod keys for WPML compatibility - #4715

Open
girishpanchal30 wants to merge 2 commits into
developmentfrom
bugfix/4699
Open

girishpanchal30 wants to merge 2 commits into
developmentfrom
bugfix/4699

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

Summary

Improved WPML compatibility by updating wpml-config.xml to register only relevant theme modification keys for translation. Added comprehensive tests to ensure all free-text theme mods used by the theme are included while unused or deprecated keys are excluded.

Will affect visual aspect of the product

NO

Check before Pull Request is ready:

Closes #4699

@pirate-bot

pirate-bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Plugin build for 3af5328 is ready 🛎️!

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟢 Approved

This approves the change; the note asks for a check that translated header and footer texts show on translated pages.

Questions for the author

  • A child theme may still hold an older copied wpml-config.xml, as the #4283 workaround suggested. Does the translation plugin then apply the parent's new keys?
  • The color validator change in globals/sanitize-functions.php is not in the PR body or #4699. Is it meant to ship in this PR?
Validation details
  • Files reviewed: 4/4 changed files. Open history question: "Keys missing from wpml-config file to make theme fully compatible with WPML".
  • All eight added keys match the setting IDs the theme reads (source trace).
  • PHP 8.3, WordPress 7.1.5, PHPUnit 9.6: the changed test classes pass at HEAD set -o pipefail; cd /var/www/html/wp-content/themes/neve-base && timeout 900 phpunit --do-not-cache-result --testdox --f… (run R11, exit 0).
  • With base source files, the four new or changed tests fail set -o pipefail; cd /var/www/html/wp-content/themes/neve-base && timeout 900 phpunit --do-not-cache-result --testdox --f… (run R11, exit 0).
  • Accepted colors give the same output as base `cat > /workspace/checks/C1/probe/TableProbeTest.php <<'EOF'
Untested areas - WPML was not installed, so String Translation was not exercised. - History question "Keys missing from wpml-config file to make theme fully compatible with WPML" was left unchecked for that reason. - The variant pass did not settle these places, where the fixed cause may still reach: - `/repo/inc/customizer/options/layout_blog.php:648-675` — unverified: Both JSON metadata repeaters are absent from /repo/wpml-config.xml:11-30. Free controls expose only hide_on_mobile and disallow new items; their stored title supplies the Customize… - `/repo/inc/customizer/options/layout_single_post.php:595-613` — unverified: Both JSON metadata repeaters are absent from /repo/wpml-config.xml:11-30. Free controls expose only hide_on_mobile and disallow new items; their stored title supplies the Customize…
🤖 Automated review · run code-review-agent_6b05309908c228.75526632. --- **🤖 Review agent** — review posted ✅ on `e3ad0ccf` · [approved · 0 findings](https://github.com//pull/4715#pullrequestreview-6034874156) · 13 min Run `code-review-agent_6b05309908c228.75526632` · [trail](https://agents.vertistudio.com/admin/trails/github-pr/Codeinwp-neve-4715)

Comment thread wpml-config.xml
Comment on lines +23 to +30
<key name="custom_html_content"/>
<key name="footer_copyright_content"/>
<key name="button_base_text_setting"/>
<key name="button_base_link_setting"/>
<key name="header_search_placeholder"/>
<key name="header_search_responsive_placeholder"/>
<key name="neve_single_post_metadata_separator"/>
<key name="neve_scroll_to_top_label"/>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

note The Custom HTML text is read through the cached Mods::get(). The copyright text calls get_theme_mod() directly. If the cache fills before WPML filters theme_mods_neve, a translated page can still show the default-language HTML. Translate both texts in WPML String Translation on a free-only site. If both show translated on the second-language page, the change is safe. If Custom HTML stays in the default language, the cached read bypasses the translation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The concern is unfounded. custom_html_content is retrieved only during template rendering through component_setting( CustomHtml::CONTENT_ID ) in component-html.php#L15. This happens well after WPML registers its option_theme_mods_neve filter during plugins_loaded. Since there are no earlier reads during theme initialization, Mods::$_cached is still empty when the component renders. Therefore, Mods::get() calls get_theme_mod(), which correctly passes through WPML’s active translation filter.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You are right, and I withdraw this note. Mods::get() caches per key, not the whole theme-mods array (inc/core/settings/mods.php:51-56). The only read of custom_html_content is at template render (component-html.php:15). An earlier call on after_setup_theme reads the custom colors key (inc/core/front_end.php:151-174). Other keys read earlier cannot prefill the Custom HTML value.

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟡 Changes requested

Register neve_top_bar_content too, because migrated sites still print it as the Custom HTML text without translation.

Validation details
  • Files reviewed: 2/2 changed files.
  • Eight added keys match setting IDs the free theme reads (source trace).
  • The removed keys neve_footer_text and neve_read_more_text have no PHP reader in the theme.
  • The new tests fail on the base config by source: it lacks custom_html_content and still lists the removed keys.
  • header_search_responsive_button_text is not needed: the free responsive search shows no text button.
Untested areas
  • WPML was not installed, so String Translation was not exercised. No code was run in this review.
  • Post meta format strings, the WooCommerce cart label fragment and custom SVG title text were not settled. No free-only source of these texts was found.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • /repo/inc/compatibility/woocommerce.php:928-935 — unverified: cart fragments print unregistered header_cart_icon_cart_label without a Pro check; a producer allowing free-only users to configure that label was not established. Initial renderin…
    • /repo/inc/views/partials/post_meta.php:140-193 — unverified: unregistered neve_blog_post_meta_fields and neve_single_post_meta_fields can carry printed format strings through /repo/inc/views/template_parts.php:415-425 and /repo/inc/views/pos…
    • /repo/header-footer-grid/Core/Components/Utility/SearchIconButton.php:184-206 — unverified: custom SVG accepts strings, including allowed title content (/repo/globals/utilities.php:306), and reaches output (:223-242). Free-only registration of these controls was not estab…

🤖 Automated review · run code-review-agent_6b055ebf0fd489.45105045.


🤖 Review agent — review posted ✅ on e56e17db · changes requested · 1 finding · 16 min

Run code-review-agent_6b055ebf0fd489.45105045 · trail

Comment thread wpml-config.xml Resolved

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟢 Approved

The PR passes: neve_top_bar_content is now registered for translation, which fixes the earlier finding.

Validation details
  • Files reviewed: 2/2 changed files.
  • The new key sits under theme_mods_neve, the node the test reads (source check).
  • The test now expects neve_top_bar_content. The previous config lacks it, so the test fails there (source check, not executed).
  • Earlier checks of the other keys are reused from run code-review-agent_6b055ebf0fd489.45105045, not rerun.
Untested areas
  • WPML was not installed. String Translation was not exercised. No code was run.
  • The variant pass was not run again. The earlier run left the cart label fragment, post meta format strings and custom search icon title text unsettled.

🤖 Automated review · run code-review-agent_6b056a5940ffd1.04566741.


🤖 Review agent — review posted ✅ on 3af5328d · approved · 0 findings · 3 min

Run code-review-agent_6b056a5940ffd1.04566741 · trail

This branch has not been deployed

No deployments
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