return-to-shop.php
320 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | use ShopEngine\Widgets\Products; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | class ShopEngine_Return_To_Shop extends \ShopEngine\Base\Widget |
| 10 | { |
| 11 | |
| 12 | public function config() { |
| 13 | return new ShopEngine_Return_To_Shop_Config(); |
| 14 | } |
| 15 | |
| 16 | |
| 17 | protected function register_controls() { |
| 18 | $this->start_controls_section( |
| 19 | 'shopengine_settings_section', |
| 20 | [ |
| 21 | 'label' => esc_html__('Button', 'shopengine'), |
| 22 | 'tab' => Controls_Manager::TAB_STYLE, |
| 23 | ] |
| 24 | ); |
| 25 | |
| 26 | $this->add_control( |
| 27 | 'shopengine_button_align', |
| 28 | [ |
| 29 | 'label' => esc_html__('Button Alignment', 'shopengine'), |
| 30 | 'type' => Controls_Manager::CHOOSE, |
| 31 | 'options' => [ |
| 32 | 'left' => [ |
| 33 | 'title' => esc_html__('Left', 'shopengine'), |
| 34 | 'icon' => 'eicon-text-align-left', |
| 35 | ], |
| 36 | 'center' => [ |
| 37 | 'title' => esc_html__('Center', 'shopengine'), |
| 38 | 'icon' => 'eicon-text-align-center', |
| 39 | ], |
| 40 | 'right' => [ |
| 41 | 'title' => esc_html__('Right', 'shopengine'), |
| 42 | 'icon' => 'eicon-text-align-right', |
| 43 | ], |
| 44 | ], |
| 45 | 'selectors' => [ |
| 46 | '{{WRAPPER}} .shopengine-return-to-shop .return-to-shop' => 'text-align: {{VALUE}};', |
| 47 | '.rtl {{WRAPPER}}.elementor-align-left .shopengine-return-to-shop .return-to-shop' => 'text-align:right;', |
| 48 | '.rtl {{WRAPPER}}.elementor-align-right .shopengine-return-to-shop .return-to-shop' => 'text-align:left;', |
| 49 | ], |
| 50 | 'prefix_class' => 'elementor-align-', |
| 51 | ] |
| 52 | ); |
| 53 | |
| 54 | $this->add_group_control( |
| 55 | Group_Control_Typography::get_type(), |
| 56 | [ |
| 57 | 'name' => 'shopengine_typography_primary', |
| 58 | 'label' => esc_html__('Typography', 'shopengine'), |
| 59 | 'exclude' => ['letter_spacing','font_style', 'text_style', 'text_decoration'], |
| 60 | 'fields_options' => [ |
| 61 | 'typography' => [ |
| 62 | 'default' => 'custom', |
| 63 | ], |
| 64 | 'font_weight' => [ |
| 65 | 'default' => '600', |
| 66 | ], |
| 67 | 'font_size' => [ |
| 68 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 69 | 'size_units' => ['px'], |
| 70 | 'default' => [ |
| 71 | 'size' => '15', |
| 72 | 'unit' => 'px', |
| 73 | ], |
| 74 | ], |
| 75 | 'line_height' => [ |
| 76 | 'size_units' => ['px'], |
| 77 | 'label' => 'Line Height (px)', |
| 78 | 'responsive' => false, |
| 79 | ] |
| 80 | ], |
| 81 | 'selector' => '{{WRAPPER}} .shopengine-return-to-shop .button', |
| 82 | ] |
| 83 | ); |
| 84 | |
| 85 | $this->start_controls_tabs('shopengine_button_tabs_style'); |
| 86 | |
| 87 | $this->start_controls_tab( |
| 88 | 'shopengine_button_tabnormal', |
| 89 | [ |
| 90 | 'label' => esc_html__('Normal', 'shopengine'), |
| 91 | ] |
| 92 | ); |
| 93 | |
| 94 | $this->add_control( |
| 95 | 'shopengine_button_text_color', |
| 96 | [ |
| 97 | 'label' => esc_html__('Text Color', 'shopengine'), |
| 98 | 'type' => Controls_Manager::COLOR, |
| 99 | 'alpha' => false, |
| 100 | 'default' => '#ffffff', |
| 101 | 'selectors' => [ |
| 102 | '{{WRAPPER}} .shopengine-return-to-shop .button' => 'color: {{VALUE}} !important;', |
| 103 | ], |
| 104 | ] |
| 105 | ); |
| 106 | |
| 107 | $this->add_control( |
| 108 | 'shopengine_button_text_bg_color', |
| 109 | [ |
| 110 | 'label' => esc_html__('Background Color', 'shopengine'), |
| 111 | 'type' => Controls_Manager::COLOR, |
| 112 | 'alpha' => false, |
| 113 | 'default' => '#101010', |
| 114 | 'selectors' => [ |
| 115 | '{{WRAPPER}} .shopengine-return-to-shop .button' => 'background-color: {{VALUE}} !important;', |
| 116 | ], |
| 117 | ] |
| 118 | ); |
| 119 | |
| 120 | |
| 121 | $this->add_group_control( |
| 122 | Group_Control_Border::get_type(), |
| 123 | [ |
| 124 | 'name' => 'shopengine_input_border', |
| 125 | 'label' => esc_html__('Border', 'shopengine'), |
| 126 | 'fields_options' => [ |
| 127 | 'border' => [ |
| 128 | 'default' => 'solid', |
| 129 | 'responsive' => false, |
| 130 | 'selectors' => [ |
| 131 | '{{WRAPPER}} .shopengine-return-to-shop .button' => 'border-style: {{VALUE}} !important;', |
| 132 | ], |
| 133 | ], |
| 134 | |
| 135 | 'width' => [ |
| 136 | 'label' => esc_html__('Border Width', 'shopengine'), |
| 137 | 'default' => [ |
| 138 | 'top' => '1', |
| 139 | 'right' => '1', |
| 140 | 'bottom' => '1', |
| 141 | 'left' => '1', |
| 142 | 'unit' => 'px', |
| 143 | ], |
| 144 | 'selectors' => [ |
| 145 | '{{WRAPPER}} .shopengine-return-to-shop .button' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', |
| 146 | '.rtl {{WRAPPER}} .shopengine-return-to-shop .button' => 'border-width: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}} !important;', |
| 147 | ], |
| 148 | 'responsive' => false, |
| 149 | ], |
| 150 | |
| 151 | 'color' => [ |
| 152 | 'label' => esc_html__('Border Color', 'shopengine'), |
| 153 | 'alpha' => false, |
| 154 | 'responsive' => false, |
| 155 | 'selectors' => [ |
| 156 | '{{WRAPPER}} .shopengine-return-to-shop .button' => 'border-color: {{VALUE}} !important;', |
| 157 | ], |
| 158 | ], |
| 159 | |
| 160 | ], |
| 161 | ] |
| 162 | ); |
| 163 | |
| 164 | $this->end_controls_tab(); |
| 165 | |
| 166 | $this->start_controls_tab( |
| 167 | 'shopengine_button_tab_button_hover', |
| 168 | [ |
| 169 | 'label' => esc_html__('Hover', 'shopengine'), |
| 170 | ] |
| 171 | ); |
| 172 | |
| 173 | $this->add_control( |
| 174 | 'shopengine_button_hover_color', |
| 175 | [ |
| 176 | 'label' => esc_html__('Text Color', 'shopengine'), |
| 177 | 'type' => Controls_Manager::COLOR, |
| 178 | 'default' => '#ffffff', |
| 179 | 'alpha' => false, |
| 180 | 'selectors' => [ |
| 181 | '{{WRAPPER}} .shopengine-return-to-shop .button:hover' => 'color: {{VALUE}} !important;', |
| 182 | ], |
| 183 | ] |
| 184 | ); |
| 185 | |
| 186 | |
| 187 | $this->add_control( |
| 188 | 'shopengine_button_hover_bg_color', |
| 189 | [ |
| 190 | 'label' => esc_html__('Background Color', 'shopengine'), |
| 191 | 'type' => Controls_Manager::COLOR, |
| 192 | 'default' => '#000000', |
| 193 | 'alpha' => false, |
| 194 | 'selectors' => [ |
| 195 | '{{WRAPPER}} .shopengine-return-to-shop .button:hover' => 'background-color: {{VALUE}} !important;', |
| 196 | ], |
| 197 | ] |
| 198 | ); |
| 199 | |
| 200 | |
| 201 | $this->add_group_control( |
| 202 | Group_Control_Border::get_type(), |
| 203 | [ |
| 204 | 'name' => 'shopengine_input_border_hover', |
| 205 | 'label' => esc_html__('Border', 'shopengine'), |
| 206 | 'fields_options' => [ |
| 207 | 'border' => [ |
| 208 | 'default' => 'solid', |
| 209 | 'responsive' => false, |
| 210 | 'selectors' => [ |
| 211 | '{{WRAPPER}} .shopengine-return-to-shop .button:hover' => 'border-style: {{VALUE}} !important;', |
| 212 | ], |
| 213 | ], |
| 214 | |
| 215 | 'width' => [ |
| 216 | 'label' => esc_html__('Border Width', 'shopengine'), |
| 217 | 'default' => [ |
| 218 | 'top' => '1', |
| 219 | 'right' => '1', |
| 220 | 'bottom' => '1', |
| 221 | 'left' => '1', |
| 222 | 'unit' => 'px', |
| 223 | ], |
| 224 | 'selectors' => [ |
| 225 | '{{WRAPPER}} .shopengine-return-to-shop .button:hover' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', |
| 226 | '.rtl {{WRAPPER}} .shopengine-return-to-shop .button:hover' => 'border-width: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}} !important;', |
| 227 | ], |
| 228 | 'responsive' => false, |
| 229 | ], |
| 230 | |
| 231 | 'color' => [ |
| 232 | 'label' => esc_html__('Border Color', 'shopengine'), |
| 233 | 'alpha' => false, |
| 234 | 'responsive' => false, |
| 235 | 'selectors' => [ |
| 236 | '{{WRAPPER}} .shopengine-return-to-shop .button:hover' => 'border-color: {{VALUE}} !important;', |
| 237 | ], |
| 238 | ], |
| 239 | |
| 240 | ], |
| 241 | ] |
| 242 | ); |
| 243 | |
| 244 | $this->end_controls_tab(); |
| 245 | $this->end_controls_tabs(); |
| 246 | |
| 247 | $this->add_control( |
| 248 | 'shopengine_button_border_radius', |
| 249 | [ |
| 250 | 'label' => esc_html__('Border Radius', 'shopengine'), |
| 251 | 'type' => Controls_Manager::DIMENSIONS, |
| 252 | 'size_units' => ['px'], |
| 253 | 'default' => [ |
| 254 | 'unit' => 'px', |
| 255 | 'top' => 3, |
| 256 | 'right' => 3, |
| 257 | 'bottom' => 3, |
| 258 | 'left' => 3, |
| 259 | 'isLinked' => true |
| 260 | ], |
| 261 | 'separator' => 'before', |
| 262 | 'selectors' => [ |
| 263 | '{{WRAPPER}} .shopengine-return-to-shop .button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', |
| 264 | '.rtl {{WRAPPER}} .shopengine-return-to-shop .button' => 'border-radius: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}} !important;', |
| 265 | ], |
| 266 | ] |
| 267 | ); |
| 268 | |
| 269 | $this->add_control( |
| 270 | 'shopengine_button_text_padding', |
| 271 | [ |
| 272 | 'label' => esc_html__('Padding', 'shopengine'), |
| 273 | 'type' => Controls_Manager::DIMENSIONS, |
| 274 | 'size_units' => ['px'], |
| 275 | 'default' => [ |
| 276 | 'top' => '15', |
| 277 | 'right' => '20', |
| 278 | 'bottom' => '16', |
| 279 | 'left' => '20', |
| 280 | 'unit' => 'px', |
| 281 | 'isLinked' => false, |
| 282 | ], |
| 283 | 'selectors' => [ |
| 284 | '{{WRAPPER}} .shopengine-return-to-shop .button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 285 | '.rtl {{WRAPPER}} .shopengine-return-to-shop .button' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};', |
| 286 | ], |
| 287 | ] |
| 288 | ); |
| 289 | |
| 290 | // |
| 291 | |
| 292 | $this->add_group_control( |
| 293 | Group_Control_Box_Shadow::get_type(), |
| 294 | [ |
| 295 | 'name' => 'shopengine_button_box_shadow_group', |
| 296 | 'selector' => '{{WRAPPER}} .shopengine-return-to-shop .button', |
| 297 | ] |
| 298 | ); |
| 299 | |
| 300 | $this->end_controls_section(); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * Render widget output on the frontend. |
| 305 | * |
| 306 | * Written in PHP and used to generate the final HTML. |
| 307 | * |
| 308 | * @since 1.0.0 |
| 309 | * @access protected |
| 310 | */ |
| 311 | protected function screen() { |
| 312 | |
| 313 | if(wc_get_page_id('shop') > 0) { |
| 314 | |
| 315 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 316 | |
| 317 | include $tpl; |
| 318 | } |
| 319 | } |
| 320 | } |