Skip to main content
Documentation/Developers/APIs/Hooks Reference/Rendering
Developers

Rendering

The markup Oxygen outputs, from a single element's class list up to the whole rendered
document.

Element output

oxygen_render_show_node

Filter, true, $node. Return false to skip rendering one node and its subtree. This is
the lowest-level "hide this element" hook there is. $node['data']['type'] is the element's
slug, and $node['data']['properties'] its saved settings.

// Hide every PHP Code element for anyone who can't edit posts.
add_filter('oxygen_render_show_node', function ($show, $node) {
    if ($node['data']['type'] === 'OxygenElements\PhpCode') {
        return current_user_can('edit_posts');
    }

    return $show;
}, 10, 2);

oxygen_render_element_html

Filter, $elementHtml, $node. The final HTML of a single element, immediately before
it's placed in the page.

// Append a credit line after every Image element.
add_filter('oxygen_render_element_html', function ($html, $node) {
    if ($node['data']['type'] !== 'OxygenElements\Image') {
        return $html;
    }

    return $html . '<p class="photo-credit">Photo: Redline Studio</p>';
}, 10, 2);

oxygen_element_classnames_for_html_class_attribute

Filter, $classNames, $element, $props. The class list Oxygen puts on an element's
wrapper.

add_filter('oxygen_element_classnames_for_html_class_attribute', function ($classNames) {
    $classNames[] = 'another-class';
    return $classNames;
});

oxygen_frontend_element_attributes

Filter, $atts, $node, $element. The same idea for attributes rather than classes.
$atts is a flat name => value array.

// Make every Container Link safe to open in a new tab.
add_filter('oxygen_frontend_element_attributes', function ($atts, $node, $element) {
    if ($node['data']['type'] === 'OxygenElements\ContainerLink') {
        $atts['rel'] = trim(($atts['rel'] ?? '') . ' noopener');
    }

    return $atts;
}, 10, 3);

Page output

oxygen_should_override_template

Filter, $shouldOverride (bool, true), $fileToInclude (string). Oxygen normally
intercepts WordPress's template choice so its own headers, footers and templates take over.
Return false and WordPress carries on with $fileToInclude, the template file the theme's
hierarchy already picked — useful for handing specific routes to a plugin that ships its own
templates, or for migrating a site section by section.

add_filter('oxygen_should_override_template', function ($shouldOverride, $fileToInclude) {
    if (basename($fileToInclude) === 'single-event.php') {
        return false;
    }

    return $shouldOverride;
}, 10, 2);

It runs during template_include, after the main query, so every conditional tag works. A
few cases are decided before it and can't be reached: the builder's own screens, editing a
header, footer or template, password-protected posts, maintenance mode, and the
broken-permalinks warning. To switch Oxygen off site-wide use the
Tools tab or wp oxygen theme on instead.

oxygen_render_rendered_html

Filter, $html, $postId, $repeaterItemNodeId. The whole rendered tree for a document.
Use it for passes that have to see the finished markup.

// Rewrite any protocol-less asset URLs that slipped into the page.
add_filter('oxygen_render_rendered_html', function ($html, $postId) {
    return str_replace('src="https://', 'src="https://', $html);
}, 10, 2);

oxygen_render_wrap_in_main_tag

Filter, true, $postId, $repeaterItemNodeId. Whether Oxygen wraps rendered output in a
<main> element. Turn it off when your theme already provides the landmark:

add_filter('oxygen_render_wrap_in_main_tag', '__return_false');

oxygen_append_dependencies

Filter, $dependenciesToAppend. The scripts and styles about to be added to the page, as
an array with optional scripts, inlineScripts, styles and inlineStyles keys. Useful
for auditing what an element pulls in, and for removing something you don't want.

// Drop a bundled library you load yourself.
add_filter('oxygen_append_dependencies', function ($dependencies) {
    $dependencies['scripts'] = array_values(array_filter(
        $dependencies['scripts'] ?? [],
        fn($url) => !str_contains($url, 'swiper-bundle')
    ));

    return $dependencies;
});