| 1 |
<?php |
| 2 |
/* |
| 3 |
* |
| 4 |
* Elementor Addons |
| 5 |
* |
| 6 |
*/ |
| 7 |
class gBoxEWidget extends \Elementor\Widget_Base |
| 8 |
{ |
| 9 |
|
| 10 |
/** |
| 11 |
* Get widget name. |
| 12 |
* |
| 13 |
* Retrieve Blank widget name. |
| 14 |
* |
| 15 |
* @return string Widget name. |
| 16 |
* @since 1.0.0 |
| 17 |
* @access public |
| 18 |
* |
| 19 |
*/ |
| 20 |
public function get_name() |
| 21 |
{ |
| 22 |
return 'gbox_shortcode'; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Get widget title. |
| 27 |
* |
| 28 |
* Retrieve Blank widget title. |
| 29 |
* |
| 30 |
* @return string Widget title. |
| 31 |
* @since 1.0.0 |
| 32 |
* @access public |
| 33 |
* |
| 34 |
*/ |
| 35 |
public function get_title() |
| 36 |
{ |
| 37 |
return __('Gallery Box', 'gallery-box'); |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Get widget icon. |
| 42 |
* |
| 43 |
* Retrieve Blank widget icon. |
| 44 |
* |
| 45 |
* @return string Widget icon. |
| 46 |
* @since 1.0.0 |
| 47 |
* @access public |
| 48 |
* |
| 49 |
*/ |
| 50 |
public function get_icon() |
| 51 |
{ |
| 52 |
return 'eicon-gallery-grid'; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Get widget categories. |
| 57 |
* |
| 58 |
* Retrieve the list of categories the Blank widget belongs to. |
| 59 |
* |
| 60 |
* @return array Widget categories. |
| 61 |
* @since 1.0.0 |
| 62 |
* @access public |
| 63 |
* |
| 64 |
*/ |
| 65 |
public function get_categories() |
| 66 |
{ |
| 67 |
return ['general']; |
| 68 |
} |
| 69 |
/** |
| 70 |
* Get widget keywords. |
| 71 |
* |
| 72 |
* Retrieve the list of keywords the widget belongs to. |
| 73 |
* |
| 74 |
* @since 2.1.0 |
| 75 |
* @access public |
| 76 |
* |
| 77 |
* @return array Widget keywords. |
| 78 |
*/ |
| 79 |
public function get_keywords() |
| 80 |
{ |
| 81 |
return ['shortcode', 'gallery', 'image', 'video', 'lightbox']; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Whether the reload preview is required or not. |
| 86 |
* |
| 87 |
* Used to determine whether the reload preview is required. |
| 88 |
* |
| 89 |
* @since 1.0.0 |
| 90 |
* @access public |
| 91 |
* |
| 92 |
* @return bool Whether the reload preview is required. |
| 93 |
*/ |
| 94 |
public function is_reload_preview_required() |
| 95 |
{ |
| 96 |
return true; |
| 97 |
} |
| 98 |
/** |
| 99 |
* Register Blank widget controls. |
| 100 |
* |
| 101 |
* Adds different input fields to allow the user to change and customize the widget settings. |
| 102 |
* |
| 103 |
* @since 1.0.0 |
| 104 |
* @access protected |
| 105 |
*/ |
| 106 |
protected function register_controls() |
| 107 |
{ |
| 108 |
$this->register_content_controls(); |
| 109 |
} |
| 110 |
|
| 111 |
/** |
| 112 |
* Register Blank widget content ontrols. |
| 113 |
* |
| 114 |
* Adds different input fields to allow the user to change and customize the widget settings. |
| 115 |
* |
| 116 |
* @since 1.0.0 |
| 117 |
* @access protected |
| 118 |
*/ |
| 119 |
function register_content_controls() |
| 120 |
{ |
| 121 |
|
| 122 |
$this->start_controls_section( |
| 123 |
'mgpl_query', |
| 124 |
[ |
| 125 |
'label' => esc_html__('Gallery Box', 'gallery-box'), |
| 126 |
] |
| 127 |
); |
| 128 |
|
| 129 |
|
| 130 |
$this->add_control( |
| 131 |
'gbox_id', |
| 132 |
[ |
| 133 |
'label' => __('Select Gallery Box Gallery', 'gallery-box'), |
| 134 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 135 |
'label_block' => true, |
| 136 |
'multiple' => false, |
| 137 |
'default' => '0', |
| 138 |
'options' => gbox_gallery_list(), |
| 139 |
|
| 140 |
] |
| 141 |
); |
| 142 |
|
| 143 |
$this->end_controls_section(); |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
/** |
| 149 |
* Render Blank widget output on the frontend. |
| 150 |
* |
| 151 |
* Written in PHP and used to generate the final HTML. |
| 152 |
* |
| 153 |
* @since 1.0.0 |
| 154 |
* @access protected |
| 155 |
*/ |
| 156 |
protected function render() |
| 157 |
{ |
| 158 |
|
| 159 |
$settings = $this->get_settings_for_display(); |
| 160 |
$gbox_id = isset($settings['gbox_id']) ? intval($settings['gbox_id']) : 0; |
| 161 |
|
| 162 |
echo do_shortcode('[gallerybox id="' . $gbox_id . '"]'); |
| 163 |
} |
| 164 |
} |
| 165 |
|