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.
Public Filters
Section titled “Public Filters”These filters are intended for use by companion plugins and custom code.
omnalingo/container
Section titled “omnalingo/container”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.
omnalingo/settings/tabs
Section titled “omnalingo/settings/tabs”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.
omnalingo/settings/groups
Section titled “omnalingo/settings/groups”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.
omnalingo/settings/max_languages
Section titled “omnalingo/settings/max_languages”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);omnalingo/admin/hydration_data
Section titled “omnalingo/admin/hydration_data”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.
omnalingo/db/table_prefix
Section titled “omnalingo/db/table_prefix”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);omnalingo/slug/translate_url
Section titled “omnalingo/slug/translate_url”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);omnalingo/slug/resolve_path
Section titled “omnalingo/slug/resolve_path”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);omnalingo/scan/translatable_meta_tags
Section titled “omnalingo/scan/translatable_meta_tags”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);omnalingo_validate_extension_{id}
Section titled “omnalingo_validate_extension_{id}”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);Custom Actions
Section titled “Custom Actions”These do_action() calls are fired by Omnalingo at specific lifecycle moments. Hook into them to react to plugin events.
| Action | Arguments | Fired when |
|---|---|---|
omnalingo/db/reset | none | Factory reset completes (all data wiped). |
omnalingo/scan/gathering_complete | string $trigger | Content gathering finishes. $trigger: 'manual', 'activation', 'reset', or 'settings'. |
omnalingo/editor/title_translated | int $contentId, string $objectType | A page or post title translation is saved in the editor. |
omnalingo/slug/original_changed | int $objectId, string $objectType, string $newSlug | A post or term’s original slug changes. |
omnalingo/slug/object_deleted | int $objectId, string $objectType | A 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.
| Hook | Omnalingo’s priority | To run before | To run after |
|---|---|---|---|
plugins_loaded (language detection) | 1 | Not recommended | 2+ |
init (URI stripping) | 1 | Not applicable | 2+ |
locale | 0 | Not applicable | 1+ |
post_link / page_link / term_link / home_url | 20 | < 20 | 21+ |
template_redirect (scanner) | 10 | < 10 | 11+ |
template_redirect (translation output buffer) | 15 | < 15 | 16+ |
gettext / ngettext / gettext_with_context / ngettext_with_context | 999 | < 999 | 1000+ |
gettext_with_context (RTL text direction) | 10 | < 10 | 11+ |
save_post / edit_term / created_term | 20 | < 20 | 21+ |
deactivated_plugin / after_switch_theme | 10 | < 10 | 11+ |
admin_menu (access restriction) | 999 | < 999 | Not 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.
URL and locale layer
Section titled “URL and locale layer”| Hook | Priority | What it does |
|---|---|---|
plugins_loaded | 1 | Language detection from the request URI (active languages) |
init | 0 | Language detection for inactive languages (requires auth context) |
init | 1 | Strips the language prefix from the request URI |
init | 2 | Resolves translated slugs back to originals |
init | 10 | Registers the [omnalingo-switcher] shortcode |
locale | 0 | Returns the locale for the detected language |
redirect_canonical | 10 | Prevents WordPress canonical redirects for translated URLs |
post_link | 20 | Adds language prefix to post permalinks |
post_type_link | 20 | Adds language prefix to custom post type permalinks |
page_link | 20 | Adds language prefix to page permalinks |
term_link | 20 | Adds language prefix to taxonomy term links |
home_url | 20 | Adds language prefix to home_url() calls |
nav_menu_link_attributes | 10 | Rewrites href on nav menu items |
wp_head | 10 | Outputs <link rel="alternate" hreflang="..."> tags |
template_redirect | 10 | Activates scan mode for ?omnalingo_scan=1 requests |
template_redirect | 15 | Starts the output buffer for translation replacement |
gettext_with_context | 10 | RTL detection: returns 'rtl' for RTL languages |
Gettext layer
Section titled “Gettext layer”| Hook | Priority | What it does |
|---|---|---|
plugins_loaded | 10 | Initializes gettext marker system, preloads translations |
gettext | 999 | Processes __() and _e() output |
gettext_with_context | 999 | Processes _x() output |
ngettext | 999 | Processes _n() output |
ngettext_with_context | 999 | Processes _nx() output |
clean_url | 1 | Safety net: strips leaked gettext markers from URLs |
sanitize_title | 1 | Safety net: strips gettext markers before title sanitization |
http_request_args | 999 | Safety net: strips markers from outgoing HTTP request bodies |
Content sync and admin
Section titled “Content sync and admin”| Hook | Priority | What it does |
|---|---|---|
save_post | 20 | Syncs URL record on post save, schedules rescan |
before_delete_post | 10 | Removes URL record when a post is deleted |
edit_terms | 10 | Captures old term slug before DB update |
edit_term | 10 | Syncs URL record, detects slug changes |
created_term | 10 | Adds URL record for a new term |
pre_delete_term | 10 | Removes URL record when a term is deleted |
updated_option | 10 | Syncs translation tables when language settings change |
admin_init | 10 | Processes scheduled structural cleanup if due |
admin_menu | 10 | Registers the Omnalingo admin menu page |
admin_menu | 999 | Restricts admin menus for the Translator role |
admin_enqueue_scripts | 10 | Enqueues the Vue admin SPA bundle |
deactivated_plugin | 10 | Flags gettext strings for deactivated plugins |
after_switch_theme | 10 | Flags gettext strings for the previous theme |
wp_footer | 10 | Outputs the floating language switcher widget |
wp_head | 10 | Outputs switcher CSS variables |