WP Residence Help WP Residence Help

  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / 30. WPResidence Translate Plugin / Settings Page — Developer Reference

Settings Page — Developer Reference

2 views 0

This article documents the internals of the wpresidence-translate Settings screen: how it is registered, how its form fields map to the wpr_translate_settings option, and how the sanitizer validates each key. It pairs with the user-facing Settings walkthrough and the multi-language real estate website product page.

Page Registration

The Settings submenu is registered in includes/admin/menu.php by wpr_translate_admin_register_menus():

add_submenu_page(
    'wpr-translate-overview',
    __( 'Translation Settings', 'wpr-translate' ),
    __( 'Settings', 'wpr-translate' ),
    'manage_options',
    'wpr-translate-settings',
    'wpr_translate_admin_render_settings_page'
);

Capability is manage_options. The render callback loads the view file includes/admin/views/settings.php, which in turn includes the settings-delete-translations.php partial.

Settings API Bindings

wpr_translate_admin_register_settings() binds four option groups via register_setting():

register_setting( 'wpr_translate_languages',         'wpr_translate_languages',         'wpr_translate_admin_sanitize_languages' );
register_setting( 'wpr_translate_settings',           'wpr_translate_settings',           'wpr_translate_admin_sanitize_settings' );
register_setting( 'wpr_translate_glossary',           'wpr_translate_glossary',           'wpr_translate_admin_sanitize_glossary' );
register_setting( 'wpr_translate_auto_translation',   'wpr_translate_auto_translation',   'wpr_translate_admin_sanitize_auto_translation_settings' );

The Settings screen form uses settings_fields( 'wpr_translate_settings' ) and posts to options.php, so all validation goes through wpr_translate_admin_sanitize_settings().

Shape of wpr_translate_settings

After sanitization the option stores the following associative array:

Key Type Default Notes
default_language string site locale Language code (e.g. en, fr).
url_strategy string subdirectory Sanitizer forces this value regardless of input.
sync_media bool true Clone attachments metadata when duplicating content.
elementor_compatibility bool true Enables Elementor widget and WPResidence shortcode ID remapping.
taxonomy_modes array<string,string> [] Per-taxonomy translate or not_translatable. Written by the Taxonomy Translation page, surfaced here as hidden fields.
taxonomy_auto_duplicate array<string,bool> [] Per-taxonomy auto-duplicate flag. Hidden fields.
menu_language_switcher array<string,string> [] Maps registered menu location to before or after.

Keys written by the activator (enable_url_prefix, detect_browser_language, language_switcher_style) survive alongside the UI-managed keys because the sanitizer does not prune unknown keys.

Sanitizer Behavior

wpr_translate_admin_sanitize_settings() in includes/admin/settings-helpers.php:

  1. wp_parse_args() merges the submitted payload with the defaults shown above.
  2. default_language is passed through sanitize_text_field() — non-Latin language codes are preserved.
  3. url_strategy is always overwritten to subdirectory — other values are silently dropped.
  4. sync_media and elementor_compatibility are cast to bool.
  5. auto_update_glossary is explicitly unset() (it was a previous-release key).
  6. taxonomy_modes keys are run through sanitize_key(); values must be translate or not_translatable, otherwise they default to translate.
  7. taxonomy_auto_duplicate values are cast to bool.
  8. menu_language_switcher entries are filtered against get_registered_nav_menus() — unregistered locations are dropped. Positions must be before or after.

Screenshot: Browser devtools network tab showing options.php POST with wpr_translate_settings payload

Form Fields in settings.php

Every visible field maps 1:1 to a sanitizer key:

Control Field name
Default language <select> wpr_translate_settings[default_language]
URL strategy <input type="radio"> wpr_translate_settings[url_strategy]
Media sync <input type="checkbox"> wpr_translate_settings[sync_media]
Elementor compat <input type="checkbox"> wpr_translate_settings[elementor_compatibility]
Menu switcher <select> per location wpr_translate_settings[menu_language_switcher][{location}]
Taxonomy modes (hidden) wpr_translate_settings[taxonomy_modes][{taxonomy}]
Taxonomy auto-duplicate (hidden) wpr_translate_settings[taxonomy_auto_duplicate][{taxonomy}]

The taxonomy inputs render as hidden fields so the values written by the Taxonomy Translation screen are preserved on Save.

Auxiliary Forms on the Same Page

Two additional forms render below the main settings form:

  1. Reset form — posts back to admin.php?page=wpr-translate-settings with nonce action wpr_translate_reset_settings. Handled by wpr_translate_admin_handle_reset_settings() on admin_init, which calls wpr_translate_admin_reset_plugin_data().
  2. Delete Translations card — purely AJAX. Uses the nonce action wpr_translate_delete_translations and hits wp_ajax_wpr_translate_count_translations and wp_ajax_wpr_translate_delete_translations (see includes/admin/delete-translations.php).

Reading Settings From Code

When you need the plugin’s current configuration inside other code, read the option directly:

$settings = get_option( 'wpr_translate_settings', array() );
$default  = isset( $settings['default_language'] ) ? $settings['default_language'] : 'en';
$sync     = ! empty( $settings['sync_media'] );

There is no dedicated getter helper — the option is intentionally a plain array so it is easy to inspect.

Related Options

Option Shape Written by
wpr_translate_languages indexed array of language payloads Languages page sanitizer.
wpr_translate_language_catalog predefined language list Activator; merged with stored overrides on the Languages page.
wpr_translate_auto_translation provider config Automatic Translation page sanitizer.
wpr_translate_glossary array of glossary entries Glossary storage.

Gotchas

  • The url_strategy radio group is cosmetic — the sanitizer hard-codes subdirectory. Do not build features that branch on other values until the plugin exposes them.
  • The sanitizer does not prune unknown keys left over from the activator (enable_url_prefix, detect_browser_language, language_switcher_style). They coexist with UI-managed keys.
  • Saving the Languages page also calls flush_rewrite_rules() — saving the Settings page does not. If your code changes URL behavior, flush rewrites yourself.
  • Menu-switcher locations that are no longer registered are silently dropped. Re-saving the form is enough to prune stale entries.

Extension Points

  • Add additional keys to the option by extending the submitted form, then re-implementing the sanitizer — overriding wpr_translate_admin_sanitize_settings() from a mu-plugin is the cleanest path.
  • Use the wpr_translate_auto_translation_excluded_post_types filter (defined in settings-helpers.php) to exclude additional post types from automatic translation flows.

Screenshot: settings-helpers.php open in an IDE showing the wpr_translate_admin_sanitize_settings function

Further Reading

  • Installation, Activation & Uninstall (Developer) — how the defaults in wpr_translate_settings are seeded.
  • Cache Purge & Reset Tools (Developer) — the reset, delete, and cache-purge endpoints.
  • URL Structure & Permalinks — how the subdirectory strategy is implemented.

For the product framing around these options, see the multi-language real estate website page.

30. WPResidence Translate Plugin

Related Articles

  • String Scanner — Developer Guide
  • The String Scanner
  • Gettext Pipeline & MO Files — Developer Guide
  • Gettext & MO Files — Making Translations Appear on the Front End

WP Residence Documentation

  • 01. Getting Started
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 02. Installation & Setup
  • 03. Installation FAQ
  • 06. Search & Filtering
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 09. Agent, Agency & Developers
  • 08. Property Pages & Layouts
  • 07. Property Lists, Categories & Archive
  • 13. WPResidence Elementor Studio
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • 04. Theme Options & Global Settings
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • 20. Translations & Languages
  • 26. FAQ
  • 10. Pages
  • 11. Header
  • 12. Footer
  • 05. Maps & Location Settings
  • 18. Payments & Monetization
  • Plugins
    • 19. Included Plugins
    • 22. Third Party Plugins – IDX Compatibility
    • 21. Third-Party Plugins – Multi-Language
    • 23. Third party Plugins – Other
  • Technical
    • 24. Technical how to | Custom Code Required
    • 25. Technical: Child Theme

Join Us On

Powered by WP Estate - All Rights Reserved
  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API