Developer reference: hooks, filters and REST routes in Xtra Addons
Every action and filter in Xtra Addons for Elementor 1.0.0, with arguments and examples, plus the Library REST routes, data storage and CSS variables.
This page lists the hooks that exist in the free plugin, version 1.0.0, all prefixed with xtra_. Each one was taken from the plugin source, so you can rely on the names and arguments below. Put your code in a small custom plugin or your child theme's functions.php.
Note: Hooks may gain new arguments in future releases. Always check the version in the changelog when you upgrade.
#Quick reference
| Hook | Type | Arguments | Purpose |
|---|---|---|---|
xtra_template_saved |
Action | int $post_id, string $type |
A template was saved to Xtra Library. |
xtra_template_updated |
Action | int $post_id |
A saved template was updated. |
xtra_library_categories |
Filter | array $categories |
Add or change section categories. |
xtra_library_kits |
Filter | array $kits |
Add or change website kits. |
xtra_library_items |
Filter | array $items |
Add or change library templates. |
xtra_library_item_content |
Filter | array|WP_Error|null $data, array $item |
Provide the content of a non-bundled template. |
xtra_library_asset_roots |
Filter | array $roots |
Add folders for xtra-asset:// images. |
xtra_business_hours_current_time |
Filter | int $timestamp |
Override "now" in the Business Hours widget. |
xtra_pro_license_valid |
Filter | bool $valid |
Report Pro license status to the free plugin. |
xtra_pro_widget_slugs |
Filter | array $slugs |
Mark widgets with a PRO badge in the Elementor panel. |
#Actions
#xtra_template_saved
Fires after Save to Xtra Library stores a new template.
add_action( 'xtra_template_saved', function ( $post_id, $type ) {
// $type is 'page', 'section' or 'block'.
error_log( sprintf( 'Xtra template %d saved as %s', $post_id, $type ) );
}, 10, 2 );
#xtra_template_updated
Fires after a saved template is changed.
add_action( 'xtra_template_updated', function ( $post_id ) {
clean_post_cache( $post_id );
} );
#Filters for Xtra Library
These filters let you add your own categories, kits and templates to the Xtra Library window.
#xtra_library_categories and xtra_library_kits
Both receive a list of array( 'slug' => '…', 'title' => '…' ) entries.
add_filter( 'xtra_library_categories', function ( $categories ) {
$categories[] = array(
'slug' => 'my-blocks',
'title' => 'My blocks',
);
return $categories;
} );
#xtra_library_items
Receives the list of templates. Each item uses this shape:
| Key | Meaning |
|---|---|
slug |
Unique ID (lowercase letters, numbers, dashes). |
type |
section or page. |
title |
Name shown on the card. |
category |
A category slug (for sections). |
kit |
A kit slug (for pages). |
tags |
Array of search tags. |
widgets |
Array of widget names used. |
is_pro |
true to show a Pro badge and require a license. |
thumb, preview |
Absolute image URLs. |
palette |
null, or an array with primary, accent, dark, text hex colors used by Match my site colors. |
source |
Free-form label, such as custom. |
#xtra_library_item_content
Called when someone inserts a template. Return null to let Xtra handle it, an array with a content key (the Elementor element tree) and an optional page_settings key to supply your own, or a WP_Error to refuse (for example, when a license is missing).
add_filter( 'xtra_library_items', function ( $items ) {
$items[] = array(
'slug' => 'my-hero',
'type' => 'section',
'title' => 'My hero',
'category' => 'my-blocks',
'kit' => '',
'tags' => array( 'hero' ),
'widgets' => array(),
'is_pro' => false,
'thumb' => 'https://example.com/my-hero.webp',
'preview' => 'https://example.com/my-hero.webp',
'palette' => null,
'source' => 'custom',
);
return $items;
} );
add_filter( 'xtra_library_item_content', function ( $data, $item ) {
if ( 'my-hero' !== $item['slug'] ) {
return $data;
}
return array(
'content' => json_decode( file_get_contents( __DIR__ . '/my-hero.json' ), true ),
);
}, 10, 2 );
Element IDs are regenerated for you on every insert.
#xtra_library_asset_roots
Images inside templates are written as xtra-asset://images/file.webp. Xtra looks for them in templates/ inside the plugin. Add your own roots like this:
add_filter( 'xtra_library_asset_roots', function ( $roots ) {
$roots[] = array(
'path' => WP_CONTENT_DIR . '/my-assets/templates/',
'url' => content_url( 'my-assets/templates/' ),
);
return $roots;
} );
Files must live in an images/ subfolder of the root.
#Other filters
#xtra_business_hours_current_time
Lets you override the time the Business Hours widget treats as "now", for example to test open and closed states. Return a Unix timestamp.
add_filter( 'xtra_business_hours_current_time', function ( $now ) {
return strtotime( 'next friday 10:00' );
} );
#xtra_pro_license_valid
The free plugin never contacts a license server. The separate Pro plugin answers this filter. In your code, call the helper instead of the filter:
if ( function_exists( 'xtra_is_license_valid' ) && xtra_is_license_valid() ) {
// A valid Xtra Addons Pro license is active.
}
Without Pro installed it always returns false.
#xtra_pro_widget_slugs
Pro uses this to add a PRO badge to its widgets in the Elementor panel. Return an array of widget names such as xtra-chart.
#REST routes
Xtra Library talks to your own site through these routes in the xtra/v1 namespace. They use the normal WordPress cookie and X-WP-Nonce authentication. They exist for the Library window, so treat them as internal and subject to change.
| Route | Method | Needs capability |
|---|---|---|
/library/catalog |
GET | edit_posts |
/library/import |
POST | edit_posts |
/library/create-page |
POST | edit_pages |
/library/saved |
GET, POST | edit_posts |
/library/saved/{id} |
GET, PUT, DELETE | edit_posts |
/library/saved/{id}/duplicate |
POST | edit_posts |
#Data storage
- Settings: the option
xtra_settings, with the keysenabled_widgets,known_widgetsandextensions. - Saved templates: the non-public post type
xtra_templatewith meta keys starting with_xtra_template_. - Imported images: attachments carrying the meta key
_xtra_library_asset.
See Uninstall and your data for what is removed on delete.
#Constants
XTRA_VERSION, XTRA_FILE, XTRA_PATH, XTRA_URL, XTRA_ASSETS, XTRA_INC and XTRA_WIDGETS are defined when the plugin loads. Use defined( 'XTRA_VERSION' ) to detect Xtra Addons.
#Xtra Motion: CSS classes and variables
Xtra Motion is driven by prefix classes and CSS custom properties, so you can fine-tune it with custom CSS.
- Classes:
xtra-enter-<effect>,xtra-hover-<effect>,xtra-parallax-yes,xtra-stagger-yes,xtra-replay-yes. - Variables:
--xtra-m-dur,--xtra-m-delay,--xtra-m-dist,--xtra-m-ease,--xtra-m-step,--xtra-m-hs(strength),--xtra-m-gc(glow color) and--xtra-m-parallax.
Elementor writes the variables on each element, so a custom rule needs !important to win. Give the element a class in Advanced → CSS Classes, then:
/* Slow down the entrance of elements with the class "my-hero". */
.my-hero {
--xtra-m-dur: 900ms !important;
}
#Related
Last updated November 17, 2026 · Need help?