<?php if(! defined('ABSPATH')){ return; }
/*
 Name: Sidebar
 Description: Create and display a Sidebar element
 Class: TH_Sidebar
 Category: content
 Level: 3
*/
/**
 * Class TH_Sidebar
 *
 * Create and display a Sidebar element
 *
 * @package  Kallyas
 * @category Page Builder
 * @author   Team Hogash
 * @since    4.0.0
 */
class TH_Sidebar extends ZnElements
{
    public static function getName(){
        return __( "Sidebar", 'zn_framework' );
    }

    /**
     * This method is used to display the output of the element.
     *
     * @return void
     */
    function element()
    {
        $options = $this->data['options'];

        $sidebar_select = $this->opt( 'sidebar_select', 'defaultsidebar' );
        $sidebar_css = $this->opt( 'sidebar_bg', 'yes' ) == 'yes' ? '' : 'no_bg';
        ?>

        <?php
        echo '<div id="sidebar-widget-'.$this->data['uid'].'" class="sidebar ' . $sidebar_css . '">';
            if ( ! function_exists( 'dynamic_sidebar' ) || ! dynamic_sidebar( $sidebar_select ) ) : endif;
        echo '</div>';
        ?>
    <?php
    }

    /**
     * This method is used to retrieve the configurable options of the element.
     * @return array The list of options that compose the element and then passed as the argument for the render() function
     */
    function options()
    {
        return array (
                array (
                    "name"        => __( "Select sidebar", 'zn_framework' ),
                    "description" => __( "Select your desired sidebar to be used on this
                                        post", 'zn_framework' ),
                    "id"          => "sidebar_select",
                    "std"         => "",
                    "type"        => "select",
                    "options"     => WpkZn::getThemeSidebars()
                ),
                array (
                    "name"        => __( "Show background?", 'zn_framework' ),
                    "description" => __( "Select yes if you want to show the default sidebar
                                         background or no to use a transparent background.", 'zn_framework' ),
                    "id"          => "sidebar_bg",
                    "std"         => "yes",
                    "type"        => "select",
                    "options"     => array ( 'yes' => __( 'Yes', 'zn_framework' ), 'no' => __( 'No', 'zn_framework' ) )
                )
        );
    }
}

