GhostManSec
Server: LiteSpeed
System: Linux premium197.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: parhudrw (1725)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //home/parhudrw/www/wp-content/plugins/around-elementor/modules/sidebar/skins/cs-sidebar-skin.php
<?php
namespace AroundElementor\Modules\Sidebar\Skins;

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}

use Elementor;
use Elementor\Skin_Base;
use Elementor\Controls_Manager;
use Elementor\Widget_Base;

class Cs_Sidebar_Skin extends Skin_Base {
    
     public function __construct( Elementor\Widget_Base $parent ) {
        parent::__construct( $parent );
        add_filter( 'elementor/widget/print_template', array( $this, 'skin_print_template' ), 10, 2 );
    }

    public function get_id() {
        return 'cs-sidebar';
    }

    public function get_title() {
        return esc_html__( 'CS Sidebar', 'around-elementor' );
    }

    protected function _register_controls_actions() {
        add_action( 'elementor/element/sidebar/section_sidebar/before_section_end', [ $this, 'add_sidebar_controls' ], 10 );
    }

    public function add_sidebar_controls( Widget_Base $widget ) {
        $this->parent = $widget;

        $this->add_control( 'sidebar_right', [
            'label'       => esc_html__( 'Sidebar Right ?', 'around-elementor' ),
            'type'        => Controls_Manager::SWITCHER,
            'default'     => 'yes',
            'description' => esc_html__( 'Enable to display sidebar in right direction.', 'around-elementor' ),
            'frontend_available' => true,
        ] );


        $this->add_control( 'title', [
            'label'       => esc_html__( 'Sidebar Title', 'around-elementor' ),
            'type'        => Controls_Manager::TEXT,
            'default'     => esc_html__( 'Sidebar', 'around-elementor' ),
            'label_block' => true,
        ] );

        $this->add_control( 'offcanvas-body-class', [
            'label'       => esc_html__( 'Offcanvas Body Class', 'around-elementor' ),
            'type'        => Controls_Manager::TEXT,
            'default'     => 'px-4 pt-3 pt-lg-0 pe-lg-0 ps-lg-2 ps-xl-4',
            'label_block' => true,
        ] );
    }

    public function render() {     
        $widget       = $this->parent;   
        $settings     = $this->parent->get_settings_for_display();
        $sidebar_id   = 'sidebar-' . uniqid();
        
        $this->parent->add_render_attribute( 'offcanvas_body', 'class', [
            'cs-offcanvas-body',
        ] );

        $offcanvas_body_css = $settings[ $this->get_control_id( 'offcanvas-body-class' ) ];
        if ( ! empty( $offcanvas_body_css ) ) {
            $this->parent->add_render_attribute( 'offcanvas_body', 'class', $offcanvas_body_css );
        }

        $this->parent->add_render_attribute( 'offcanvas', 'class', [
            'cs-offcanvas-collapse',
        ] );

        if ( $settings[ $this->get_control_id( 'sidebar_right' ) ] == 'yes' ) {
            $this->parent->add_render_attribute( 'offcanvas', 'class', 'cs-offcanvas-right' );
        }

        if ( ! empty( $settings['_element_id'] ) ) {
            $sidebar_id = trim( $settings['_element_id'] ) . '-widget';
            $this->parent->add_render_attribute( 'offcanvas_id', 'id', $sidebar_id );
        }

        $sidebar = $this->parent->get_settings_for_display( 'sidebar' );

        if ( empty( $sidebar ) ) {
            return;
        }

        ?><div <?php echo $this->parent->get_render_attribute_string( 'offcanvas' ); ?><?php echo $this->parent->get_render_attribute_string( 'offcanvas_id' ); ?>>
            <div class="cs-offcanvas-cap navbar-box-shadow px-4 mb-3">
                <h5 class="mt-1 mb-0"><?php echo esc_html( $settings[ $this->get_control_id( 'title' ) ] ); ?></h5>
                <button class="close lead" type="button" data-toggle="offcanvas" data-offcanvas-id="<?php echo esc_attr( $sidebar_id ); ?>"><span aria-hidden="true">&times;</span></button>
            </div>
            <div <?php echo $this->parent->get_render_attribute_string( 'offcanvas_body' ); ?> data-simplebar>
                <?php dynamic_sidebar( $sidebar ); ?>
            </div>
        </div>
        <button class="btn btn-primary btn-sm cs-sidebar-toggle" type="button" data-toggle="offcanvas" data-offcanvas-id="<?php echo esc_attr( $sidebar_id ); ?>">
            <i class="fe-sidebar font-size-base mr-2"></i>
            <?php echo esc_html( $settings[ $this->get_control_id( 'title' ) ] ); ?>
        </button><?php
    }

    public function skin_print_template( $content, $widget ) {
        if( 'sidebar' == $widget->get_name() ) {
            return '';
        }
        return $content;
    }
}