Skip to content

Developer Reference

Filters

dms_wpml_translatable_datastore_terms

Controls which option keys are treated as translatable, grouped by the kind of object they belong to. Add a key here and its value is registered with WPML on scan, and translated on output.

add_filter( 'dms_wpml_translatable_datastore_terms', function ( array $terms ): array {
  $terms['type'][ 'my_custom_label' ] = 'my_custom_label';

  return $terms;
} );

The array has five groups: option, type, category, term, and badge.

The resolved list is cached

The assembled list is stored in the dms_wpml_translatable_datastore_terms transient for a week. A newly added key won't take effect until that transient expires or is deleted:

delete_transient( 'dms_wpml_translatable_datastore_terms' );

dms_wpml_max_scan_amount

Number of terms processed per scan request. Defaults to 50. Lower it if a scan on a large category times out on your server.

add_filter( 'dms_wpml_max_scan_amount', fn() => 20 );

Actions

dms_wpml_init

Fires once WPML is confirmed active and the extension has loaded. Use it to attach your own WPML-dependent code without checking for WPML yourself.

add_action( 'dms_wpml_init', function (): void {
  // Safe to call WPML APIs here.
} );

dms_wpml_preload_translatable_terms

Fires while the translatable option list is being assembled, before a scan runs. Use it to register translatable keys for custom data that DMS doesn't know about.

How strings are registered

Each value is registered with WPML using wpml_register_string, in a package built from the object it belongs to:

Package field Value
kind dms-Type for anything under a listing type, dms-Global for global options
name The listing type ID, or options for global options
title The string's own value

The resulting String Translation domain is dms-type-{type id} or dms-global-options. String names follow the patterns documented in Translating.

Output is translated by filtering the DMS option getters — dms_get_type_option_{option}, dms_get_category_option_{option}, dms_get_term_option_{option}, and dms_get_option_{option} — so any code reading values through the DMS API gets translated text with no changes.

Lifecycle

Registration is kept in sync with DMS data through these hooks:

Event Behavior
Type, category, term, or badge added Its strings are registered immediately
One of them renamed Strings for changed fields only are unregistered, then re-registered with the new value
One of them deleted Its strings are unregistered

Because only changed fields are unregistered on update, editing one field on a category doesn't discard translations for its other fields.