Custom element for Flatsome theme (UX Builder) in Wordpress

293 Views Asked by At

Please help with the following attempt to create a custom element in UX Builder (Wordpress theme Flatsome).

Custom plugin:

    // [...]

    function custom_slider_render() {
        ob_start();
        include plugin_dir_path( __FILE__ ).'/templates/slider.php';
        return ob_get_clean();
    }

    // make custom slider
    add_ux_builder_shortcode('custom_slider', array(
        'type' => 'container',
        'name' => __('Custom Slider'),
        'category' => __('Custom'),
        'allow' => array( 'custom_image_carousel'), // 'ux_banner','ux_image','section','row','ux_banner_grid','logo'
        'wrap' => false,
        'template' => custom_slider_render(),
        'children' => array(
            'inline' => true,
            'addable_spots' => array( 'left', 'right' )
        ),
        'toolbar' => array(
            'show_children_selector' => true,
            'show_on_child_active' => true,
        ),
        'options' => array(
            'text_color' => array(
                'type' => 'colorpicker',
                'heading' => __('Couleur de texte'),
                'format' => 'rgb',
                'default' => 'rgb(0, 0, 0)',
                'position' => 'bottom right',
            ),
            'outerglow_color' => array(
                'type' => 'colorpicker',
                'heading' => __('Couleur de lueur externe'),
                'format' => 'rgb',
                'default' => 'rgb(225, 255, 255)',
                'position' => 'bottom right',
            ),
        ),
    ));

    // [...]

Template (slider.php)

    <div class="swiper">
        <div class="swiper-wrapper" style="color: {{shortcode.options.text_color}}">
            <?php if ($is_frontend) { ?>
                <?php echo do_shortcode($content); ?>
            <?php } else { ?>
                <content />
            <?php } ?>
        </div>
    </div>

I'm not sure how to get the value for shortcode.options.text_color in the template.

Please advise.

Any help is appreciated.

0

There are 0 best solutions below