balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

sidebar.php (2978B)


      1 <?php
      2 namespace Elementor;
      3 
      4 if ( ! defined( 'ABSPATH' ) ) {
      5 	exit; // Exit if accessed directly.
      6 }
      7 
      8 /**
      9  * Elementor sidebar widget.
     10  *
     11  * Elementor widget that insert any sidebar into the page.
     12  *
     13  * @since 1.0.0
     14  */
     15 class Widget_Sidebar extends Widget_Base {
     16 
     17 	/**
     18 	 * Get widget name.
     19 	 *
     20 	 * Retrieve sidebar widget name.
     21 	 *
     22 	 * @since 1.0.0
     23 	 * @access public
     24 	 *
     25 	 * @return string Widget name.
     26 	 */
     27 	public function get_name() {
     28 		return 'sidebar';
     29 	}
     30 
     31 	/**
     32 	 * Get widget title.
     33 	 *
     34 	 * Retrieve sidebar widget title.
     35 	 *
     36 	 * @since 1.0.0
     37 	 * @access public
     38 	 *
     39 	 * @return string Widget title.
     40 	 */
     41 	public function get_title() {
     42 		return esc_html__( 'Sidebar', 'elementor' );
     43 	}
     44 
     45 	/**
     46 	 * Get widget icon.
     47 	 *
     48 	 * Retrieve sidebar widget icon.
     49 	 *
     50 	 * @since 1.0.0
     51 	 * @access public
     52 	 *
     53 	 * @return string Widget icon.
     54 	 */
     55 	public function get_icon() {
     56 		return 'eicon-sidebar';
     57 	}
     58 
     59 	/**
     60 	 * Get widget keywords.
     61 	 *
     62 	 * Retrieve the list of keywords the widget belongs to.
     63 	 *
     64 	 * @since 2.1.0
     65 	 * @access public
     66 	 *
     67 	 * @return array Widget keywords.
     68 	 */
     69 	public function get_keywords() {
     70 		return [ 'sidebar', 'widget' ];
     71 	}
     72 
     73 	/**
     74 	 * Register sidebar widget controls.
     75 	 *
     76 	 * Adds different input fields to allow the user to change and customize the widget settings.
     77 	 *
     78 	 * @since 3.1.0
     79 	 * @access protected
     80 	 */
     81 	protected function register_controls() {
     82 		global $wp_registered_sidebars;
     83 
     84 		$options = [];
     85 
     86 		if ( ! $wp_registered_sidebars ) {
     87 			$options[''] = esc_html__( 'No sidebars were found', 'elementor' );
     88 		} else {
     89 			$options[''] = esc_html__( 'Choose Sidebar', 'elementor' );
     90 
     91 			foreach ( $wp_registered_sidebars as $sidebar_id => $sidebar ) {
     92 				$options[ $sidebar_id ] = $sidebar['name'];
     93 			}
     94 		}
     95 
     96 		$default_key = array_keys( $options );
     97 		$default_key = array_shift( $default_key );
     98 
     99 		$this->start_controls_section(
    100 			'section_sidebar',
    101 			[
    102 				'label' => esc_html__( 'Sidebar', 'elementor' ),
    103 			]
    104 		);
    105 
    106 		$this->add_control(
    107 			'sidebar',
    108 			[
    109 				'label' => esc_html__( 'Choose Sidebar', 'elementor' ),
    110 				'type' => Controls_Manager::SELECT,
    111 				'default' => $default_key,
    112 				'options' => $options,
    113 			]
    114 		);
    115 
    116 		$this->end_controls_section();
    117 	}
    118 
    119 	/**
    120 	 * Render sidebar widget output on the frontend.
    121 	 *
    122 	 * Written in PHP and used to generate the final HTML.
    123 	 *
    124 	 * @since 1.0.0
    125 	 * @access protected
    126 	 */
    127 	protected function render() {
    128 		$sidebar = $this->get_settings_for_display( 'sidebar' );
    129 
    130 		if ( empty( $sidebar ) ) {
    131 			return;
    132 		}
    133 
    134 		dynamic_sidebar( $sidebar );
    135 	}
    136 
    137 	/**
    138 	 * Render sidebar widget output in the editor.
    139 	 *
    140 	 * Written as a Backbone JavaScript template and used to generate the live preview.
    141 	 *
    142 	 * @since 2.9.0
    143 	 * @access protected
    144 	 */
    145 	protected function content_template() {}
    146 
    147 	/**
    148 	 * Render sidebar widget as plain content.
    149 	 *
    150 	 * Override the default render behavior, don't render sidebar content.
    151 	 *
    152 	 * @since 1.0.0
    153 	 * @access public
    154 	 */
    155 	public function render_plain_content() {}
    156 }