Skip to content

Hooks & Filters Reference

Omnalingo registers all its WordPress hooks through subscriber classes, each declaring its hooks in a static method. This page lists the hooks most relevant to external developers: the public filters and actions you can use to extend or modify plugin behavior, followed by a priority reference for the hooks Omnalingo registers on standard WordPress hooks.


These filters are intended for use by companion plugins and custom code.

Returns a read-only wrapper around the plugin’s service container. Use this to access any registered service.

add_action('init', function () {
$container = apply_filters('omnalingo/container', null);
if ($container && $container->has(\Omnalingo\Service\SlugService::class)) {
$slugService = $container->get(\Omnalingo\Service\SlugService::class);
}
});

The container is populated during plugins_loaded. Access it on init or later.


Register a new top-level tab in the Omnalingo settings UI. Each tab receives its own mount point where you can render custom Vue components or plain HTML.

add_filter('omnalingo/settings/tabs', function (array $tabs): array {
$tabs[] = [
'slug' => 'my-feature',
'label' => __('My Feature', 'my-plugin'),
'order' => 35, // General=10, Languages=15, Glossary=20, AI Context=25, Exclusion Rules=30, Advanced=40, License=50
];
return $tabs;
}, 10, 1);

See Extending Omnalingo for the full tab registration and UI mounting workflow.


Inject a settings section inside an existing core settings tab.

add_filter('omnalingo/settings/groups', function (array $groups): array {
$groups['general'][] = [
'id' => 'my-seo',
'order' => 15, // after "languages" (10), before "content" (20)
'type' => 'extension',
];
return $groups;
}, 10, 1);

Available tab IDs: general, glossary, ai-context, exclusion-rules, advanced, license.


Override the maximum number of active target languages. The default is 1. Pro hooks this to apply the plan’s language limit.

add_filter('omnalingo/settings/max_languages', function (int $max): int {
return 5;
}, 10, 1);

Add arbitrary data to the window.omnalingoData JavaScript object available in the admin UI.

add_filter('omnalingo/admin/hydration_data', function (array $data): array {
$data['myPluginConfig'] = [
'apiUrl' => MY_PLUGIN_API_URL,
'options' => get_option('my_plugin_options', []),
];
return $data;
}, 10, 1);

Access in JavaScript as window.omnalingoData.myPluginConfig.


Override the table prefix used for all Omnalingo database tables. Applied once when the database service is initialized.

add_filter('omnalingo/db/table_prefix', function (string $prefix): string {
return 'custom_prefix_';
}, 10, 1);

Fired for every URL that needs language-prefix rewriting. Use this to apply per-slug translations on top of the language prefix. This is the hook the Pro plugin uses to turn /de/about/ into /de/ueber-uns/.

add_filter('omnalingo/slug/translate_url', function (string $url, string $langCode, ?int $postId, ?int $termId): string {
// Return a modified URL with a translated slug
return $url;
}, 10, 4);

Reverse map a translated slug path back to its original. Called during request routing to map incoming /de/ueber-uns/ back to /about/ so WordPress routes correctly.

add_filter('omnalingo/slug/resolve_path', function (string $path, string $langCode): string {
return $path;
}, 10, 2);

Modify which HTML <meta> tag name values are considered translatable during scanning.

add_filter('omnalingo/scan/translatable_meta_tags', function (array $allowedMetaTags): array {
$allowedMetaTags[] = 'my-custom-meta';
return $allowedMetaTags;
}, 10, 1);

Sanitize and validate settings submitted by your extension before they are saved. Replace {id} with the slug from your tab registration or the id from your group registration.

add_filter('omnalingo_validate_extension_my-feature', function (array $data): array {
return [
'enabled' => !empty($data['enabled']),
'option_a' => sanitize_text_field($data['option_a'] ?? ''),
];
}, 10, 1);

These do_action() calls are fired by Omnalingo at specific lifecycle moments. Hook into them to react to plugin events.

ActionArgumentsFired when
omnalingo/db/resetnoneFactory reset completes (all data wiped).
omnalingo/scan/gathering_completestring $triggerContent gathering finishes. $trigger: 'manual', 'activation', 'reset', or 'settings'.
omnalingo/editor/title_translatedint $contentId, string $objectTypeA page or post title translation is saved in the editor.
omnalingo/slug/original_changedint $objectId, string $objectType, string $newSlugA post or term’s original slug changes.
omnalingo/slug/object_deletedint $objectId, string $objectTypeA post or term is permanently deleted.

Priority Reference for Standard WordPress Hooks

Section titled “Priority Reference for Standard WordPress Hooks”

When you need to run code before or after Omnalingo on a shared WordPress hook, use this table to position your priority correctly.

HookOmnalingo’s priorityTo run beforeTo run after
plugins_loaded (language detection)1Not recommended2+
init (URI stripping)1Not applicable2+
locale0Not applicable1+
post_link / page_link / term_link / home_url20< 2021+
template_redirect (scanner)10< 1011+
template_redirect (translation output buffer)15< 1516+
gettext / ngettext / gettext_with_context / ngettext_with_context999< 9991000+
gettext_with_context (RTL text direction)10< 1011+
save_post / edit_term / created_term20< 2021+
deactivated_plugin / after_switch_theme10< 1011+
admin_menu (access restriction)999< 999Not recommended

Hooks Registered on Standard WordPress Hooks (Full List)

Section titled “Hooks Registered on Standard WordPress Hooks (Full List)”

For completeness, here are all the standard WordPress hooks Omnalingo registers callbacks on.

HookPriorityWhat it does
plugins_loaded1Language detection from the request URI (active languages)
init0Language detection for inactive languages (requires auth context)
init1Strips the language prefix from the request URI
init2Resolves translated slugs back to originals
init10Registers the [omnalingo-switcher] shortcode
locale0Returns the locale for the detected language
redirect_canonical10Prevents WordPress canonical redirects for translated URLs
post_link20Adds language prefix to post permalinks
post_type_link20Adds language prefix to custom post type permalinks
page_link20Adds language prefix to page permalinks
term_link20Adds language prefix to taxonomy term links
home_url20Adds language prefix to home_url() calls
nav_menu_link_attributes10Rewrites href on nav menu items
wp_head10Outputs <link rel="alternate" hreflang="..."> tags
template_redirect10Activates scan mode for ?omnalingo_scan=1 requests
template_redirect15Starts the output buffer for translation replacement
gettext_with_context10RTL detection: returns 'rtl' for RTL languages
HookPriorityWhat it does
plugins_loaded10Initializes gettext marker system, preloads translations
gettext999Processes __() and _e() output
gettext_with_context999Processes _x() output
ngettext999Processes _n() output
ngettext_with_context999Processes _nx() output
clean_url1Safety net: strips leaked gettext markers from URLs
sanitize_title1Safety net: strips gettext markers before title sanitization
http_request_args999Safety net: strips markers from outgoing HTTP request bodies
HookPriorityWhat it does
save_post20Syncs URL record on post save, schedules rescan
before_delete_post10Removes URL record when a post is deleted
edit_terms10Captures old term slug before DB update
edit_term10Syncs URL record, detects slug changes
created_term10Adds URL record for a new term
pre_delete_term10Removes URL record when a term is deleted
updated_option10Syncs translation tables when language settings change
admin_init10Processes scheduled structural cleanup if due
admin_menu10Registers the Omnalingo admin menu page
admin_menu999Restricts admin menus for the Translator role
admin_enqueue_scripts10Enqueues the Vue admin SPA bundle
deactivated_plugin10Flags gettext strings for deactivated plugins
after_switch_theme10Flags gettext strings for the previous theme
wp_footer10Outputs the floating language switcher widget
wp_head10Outputs switcher CSS variables