Extending Velum with code
These pages are for developers who change Velum with their own PHP or JavaScript. Most changes need neither: layouts, colours, fonts and animations are set in Elementor and Site Settings. Reach for code when a setting doesn't exist for what you need.
The hooks, events and template paths on these pages are the supported way in, and they stay stable between updates. Everything else in the theme's and the plugins' code can change in any update, so don't build on a function or a class name you found by reading the source.
Where your code goes
Put PHP in the child theme's functions.php and your scripts and styles in its folder, so a theme update never overwrites them. See Using the child theme.
Some hooks belong to the bundled plugins: Velum Elementor and Velum AJAX Transitions. A site can run without either of them, so code that calls a plugin's class checks first that it exists:
php
if ( class_exists( '\Velum\Elementor\Plugin' ) ) {
// Code that needs Velum Elementor.
}A filter or an action needs no check: if the plugin is inactive, the hook simply never runs.
Loading a script that works with Velum
Velum's frontend runs from one script, registered as velum-elementor-app. It starts the widgets on every page and plays their animations. Name it as a dependency and your script runs right after it, before the page has finished loading, so it can use Velum's hooks from the very start, as described in JavaScript hooks and events:
php
add_action( 'wp_enqueue_scripts', 'velum_child_enqueue_scripts' );
function velum_child_enqueue_scripts() {
wp_enqueue_script(
'velum-child-script',
get_stylesheet_directory_uri() . '/js/script.js',
array( 'velum-elementor-app' ),
wp_get_theme()->get( 'Version' ),
array(
'in_footer' => false,
'strategy' => 'defer',
)
);
}WordPress prints no script whose dependency is missing, so this one stays out while Velum Elementor is inactive. A script that doesn't need Velum should leave the dependency out.
Not the page transitions script
Don't make your script depend on velum-ajax-transitions-app. Velum loads that script after the page has loaded, and naming it as a dependency would load it at once. To follow page transitions, listen to their events instead: see JavaScript hooks and events.
Next: PHP hooks and filters.