Skip to content

Actions and filters

Language: 7 hooks.

Every hook here has a description in the source.

3 actions4 filters

action

davo_language_provider_conflict

Fires when more than one multilingual plugin is active.

Parameters of davo_language_provider_conflict
ParameterTypeDescription
$idsstring[]Provider IDs, in priority order. The first one is used.
add_action
add_action( 'davo_language_provider_conflict', 'my_action_callback', 10, 1 );

/**
 * @param string[] $ids
 */
function my_action_callback( $ids ) {
	// Your code here.
}

src/domains/language/registry.php:98

filter

davo_language_providers

Filters the multilingual adapters, highest priority first.

Parameters of davo_language_providers
ParameterTypeDescription
$providersLanguage_Provider[]Adapters. Entries that are not providers are ignored.
add_filter
add_filter( 'davo_language_providers', 'my_filter_callback', 10, 1 );

/**
 * @param Language_Provider[] $providers
 */
function my_filter_callback( $providers ) {
	// Change $providers as needed, then return it.
	return $providers;
}

src/domains/language/registry.php:65

action

davo_language_register_strings

Fires when the active multilingual plugin collects strings for translation.

Parameters of davo_language_register_strings
ParameterTypeDescription
$stringsLanguage_StringsService to register strings with.
add_action
add_action( 'davo_language_register_strings', 'my_action_callback', 10, 1 );

/**
 * @param Language_Strings $strings
 */
function my_action_callback( $strings ) {
	// Your code here.
}

src/domains/language/strings.php:120

filter

davo_language_scope_query

Filters whether a query run during a language-scoped REST request is restricted to that language.

Parameters of davo_language_scope_query
ParameterTypeDescription
$scopeboolWhether to scope. Default true.
$queryWP_QueryThe query.
$codestringLanguage code of the request.
add_filter
add_filter( 'davo_language_scope_query', 'my_filter_callback', 10, 3 );

/**
 * @param bool $scope
 * @param WP_Query $query
 * @param string $code
 */
function my_filter_callback( $scope, $query, $code ) {
	// Change $scope as needed, then return it.
	return $scope;
}

src/domains/language/query-scope.php:143

filter

davo_language_state

Filters the language switcher view model.

Parameters of davo_language_state
ParameterTypeDescription
$statearray<string, mixed>View model.
$providerLanguage_ProviderAdapter that produced it.
add_filter
add_filter( 'davo_language_state', 'my_filter_callback', 10, 2 );

/**
 * @param array<string, mixed> $state
 * @param Language_Provider $provider
 */
function my_filter_callback( $state, $provider ) {
	// Change $state as needed, then return it.
	return $state;
}

src/domains/language/repository.php:198

filter

davo_language_untranslated_policy

Filters what the switcher does with a language that has no translation of the current page.

link goes to whatever URL the plugin offers (usually that language's home page), disable shows the language but does not link it, and hide leaves it out.

Parameters of davo_language_untranslated_policy
ParameterTypeDescription
$policystringlink, disable or hide.
add_filter
add_filter( 'davo_language_untranslated_policy', 'my_filter_callback', 10, 1 );

/**
 * @param string $policy
 */
function my_filter_callback( $policy ) {
	// Change $policy as needed, then return it.
	return $policy;
}

src/domains/language/repository.php:74

action

davo_search_schedule_reindex

Fires when the search index should be rebuilt in full.

The Search domain queues a background reindex of every source.

add_action
add_action( 'davo_search_schedule_reindex', 'my_action_callback', 10, 1 );

function my_action_callback( $arg1 ) {
	// Your code here.
}

src/domains/language/search.php:134

Note. Generated from the plugin source. Descriptions and parameters are the ones written in the code. The starter code uses the parameter names from those comments, or generic names where there are none, so check them against your use.

See it on your own site.

Davo is a WordPress theme and plugin by Exorex.

  • Runs on your own WordPress
  • Guided setup wizard
  • AI is off until you switch it on
  • Read the licence on the marketplace first