<?php

class TC_Divi_Shortcode_Builder {

    function __construct() {

        // Add filter and action for DIVI Builder
        if ( isset( $_GET[ 'et_fb' ] ) && $_GET[ 'et_fb' ] ) {
            add_action( 'et_fb_enqueue_assets', array( $this, 'divi_builder_enqueue_styles_scripts' ), 999 );
            add_action( 'et_after_main_content', array( $this, 'show_shortcodes' ) );
        }
    }

    /**
     * Add css and js for frontend builder
     */
    function divi_builder_enqueue_styles_scripts() {
        global $tc;
        wp_enqueue_style( $tc->name . '-divi', $tc->plugin_url . 'css/builders/divi-sc-front.css', false, $tc->version );
        wp_enqueue_script( $tc->name . '-shortcode-builders-script', $tc->plugin_url . 'js/builders/shortcode-builder.js', array( $tc->name . '-colorbox' ), $tc->version, true );
        wp_enqueue_script( $tc->name . '-divi', $tc->plugin_url . 'js/builders/divi.js', [], $tc->version, true );
    }

    function show_shortcodes() {
        $shortcode_builder = new TC_Shortcode_Builder( false );
        echo $shortcode_builder->form();
    }
}

$divi_shortcode_builder = new TC_Divi_Shortcode_Builder();
