Oxygen Content Shortcode

Display Oxygen content within a shortcode.

After installation, you can use this shortcode anywhere on a WordPress website.

[oxygen-content id="123"]

snippet Code

<?php
/**
* Displays Oxygen Content in a shortcode elsewhere on a WordPress site.
* 
* @param $atts['id'] - the ID of the Oxygen Content (Template, Reusable Post, or Oxyberg Block) you'd like to display
*/
add_shortcode('oxygen-content', 'bitt_oxygen_content_shortcode');

if (!function_exists('bitt_oxygen_content_shortcode')) {
    function bitt_oxygen_content_shortcode($atts)
    {
        if (!class_exists('OxygenElement')) {
            return '';
        } else {

            $json = get_post_meta($atts['id'], "ct_builder_json", true);

            if ($json) {
                global $oxygen_doing_oxygen_elements;
                $oxygen_doing_oxygen_elements = true;
                return do_oxygen_elements(json_decode($json, true));
            } else {
                $shortcodes = get_post_meta($atts['id'], "ct_builder_shortcodes", true);
                return do_shortcode($shortcodes);
            }
        }

    }
}
?>
Leave a Reply

Your email address will not be published. Required fields are marked *

    Table Of Contents

    Related Content

    © 2020-2024 Luxibay
    Name(Required)
    Please let us know what's on your mind. Have a question for us? Ask away.
    This field is for validation purposes and should be left unchanged.