theme-elements
6 months ago
accordion.php
6 months ago
audio.php
6 months ago
before-after.php
6 months ago
button.php
6 months ago
carousel-navigation.php
6 months ago
circle-chart.php
6 months ago
contact-box.php
6 months ago
contact-form.php
6 months ago
custom-list.php
6 months ago
divider.php
6 months ago
gallery.php
6 months ago
gmap.php
3 days ago
heading-modern.php
5 months ago
icon.php
6 months ago
image.php
6 months ago
mailchimp.php
6 months ago
modern-button.php
6 months ago
products-grid.php
6 months ago
quote.php
6 months ago
recent-comments.php
6 months ago
recent-posts-grid-carousel.php
1 month ago
recent-posts-land-style.php
6 months ago
recent-posts-masonry.php
6 months ago
recent-posts-tiles-carousel.php
6 months ago
recent-posts-tiles.php
6 months ago
recent-posts-timeline.php
6 months ago
recent-products.php
6 months ago
responsive-table.php
6 months ago
search.php
6 months ago
staff.php
6 months ago
svg.php
6 months ago
tabs.php
6 months ago
testimonial.php
6 months ago
text.php
6 months ago
touch-slider.php
6 months ago
video.php
6 months ago
svg.php
453 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements; |
| 3 | |
| 4 | use Elementor\Plugin; |
| 5 | use Elementor\Widget_Base; |
| 6 | use Elementor\Controls_Manager; |
| 7 | use Elementor\Group_Control_Image_Size; |
| 8 | use Elementor\Utils; |
| 9 | use Elementor\Group_Control_Border; |
| 10 | use Elementor\Group_Control_Background; |
| 11 | use Elementor\Group_Control_Box_Shadow; |
| 12 | |
| 13 | |
| 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | exit; // Exit if accessed directly. |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Elementor 'Simple_SVG' widget. |
| 20 | * |
| 21 | * Elementor widget that displays an 'Simple_SVG' with lightbox. |
| 22 | * |
| 23 | * @since 1.0.0 |
| 24 | */ |
| 25 | class Simple__SVG extends Widget_Base { |
| 26 | |
| 27 | /** |
| 28 | * Get widget name. |
| 29 | * |
| 30 | * Retrieve 'Simple_SVG' widget name. |
| 31 | * |
| 32 | * @since 1.0.0 |
| 33 | * @access public |
| 34 | * |
| 35 | * @return string Widget name. |
| 36 | */ |
| 37 | public function get_name() { |
| 38 | return 'aux_simple_svg'; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get widget title. |
| 43 | * |
| 44 | * Retrieve 'Simple_SVG' widget title. |
| 45 | * |
| 46 | * @since 1.0.0 |
| 47 | * @access public |
| 48 | * |
| 49 | * @return string Widget title. |
| 50 | */ |
| 51 | public function get_title() { |
| 52 | return __('Simple SVG', 'auxin-elements' ); |
| 53 | } |
| 54 | |
| 55 | public function has_widget_inner_wrapper(): bool { |
| 56 | return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 57 | } |
| 58 | |
| 59 | |
| 60 | /** |
| 61 | * Get widget icon. |
| 62 | * |
| 63 | * Retrieve 'Simple_SVG' widget icon. |
| 64 | * |
| 65 | * @since 1.0.0 |
| 66 | * @access public |
| 67 | * |
| 68 | * @return string Widget icon. |
| 69 | */ |
| 70 | public function get_icon() { |
| 71 | return 'eicon-integration auxin-badge-pro'; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Get widget categories. |
| 76 | * |
| 77 | * Retrieve 'Simple_SVG' widget icon. |
| 78 | * |
| 79 | * @since 1.0.0 |
| 80 | * @access public |
| 81 | * |
| 82 | * @return string Widget icon. |
| 83 | */ |
| 84 | public function get_categories() { |
| 85 | return array( 'auxin-pro' ); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Register 'Simple_SVG' widget controls. |
| 90 | * |
| 91 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 92 | * |
| 93 | * @since 1.0.0 |
| 94 | * @access protected |
| 95 | */ |
| 96 | protected function register_controls() { |
| 97 | |
| 98 | /*-----------------------------------------------------------------------------------*/ |
| 99 | /* Content Tab |
| 100 | /*-----------------------------------------------------------------------------------*/ |
| 101 | |
| 102 | $this->start_controls_section( |
| 103 | 'svg_image_section', |
| 104 | array( |
| 105 | 'label' => __( 'SVG', 'auxin-elements' ) |
| 106 | ) |
| 107 | ); |
| 108 | |
| 109 | $this->add_control( |
| 110 | 'type', |
| 111 | array( |
| 112 | 'label' => __( 'Type', 'auxin-elements' ), |
| 113 | 'type' => Controls_Manager::SELECT, |
| 114 | 'options' => array( |
| 115 | 'image' => __( 'Image', 'auxin-elements' ), |
| 116 | 'inline' => __( 'Inline', 'auxin-elements' ) |
| 117 | ), |
| 118 | 'default' => 'image' |
| 119 | ) |
| 120 | ); |
| 121 | |
| 122 | $this->add_control( |
| 123 | 'image', |
| 124 | array( |
| 125 | 'label' => __( 'Choose Image', 'auxin-elements' ), |
| 126 | 'type' => Controls_Manager::MEDIA, |
| 127 | 'default' => array( |
| 128 | 'url' => Utils::get_placeholder_image_src(), |
| 129 | ), |
| 130 | 'condition' => array( |
| 131 | 'type' => 'image' |
| 132 | ) |
| 133 | ) |
| 134 | ); |
| 135 | |
| 136 | $this->add_control( |
| 137 | 'inline', |
| 138 | array( |
| 139 | 'label' => '', |
| 140 | 'type' => Controls_Manager::CODE, |
| 141 | 'default' => '', |
| 142 | 'placeholder' => __( 'Enter inline SVG content here', 'auxin-elements' ), |
| 143 | 'show_label' => false, |
| 144 | 'condition' => array( |
| 145 | 'type' => 'inline' |
| 146 | ) |
| 147 | ) |
| 148 | ); |
| 149 | |
| 150 | $this->end_controls_section(); |
| 151 | |
| 152 | /*-----------------------------------------------------------------------------------*/ |
| 153 | /* Style Tab |
| 154 | /*-----------------------------------------------------------------------------------*/ |
| 155 | |
| 156 | $this->start_controls_section( |
| 157 | 'svg_style_section', |
| 158 | array( |
| 159 | 'label' => __( 'Style', 'auxin-elements' ), |
| 160 | 'tab' => Controls_Manager::TAB_STYLE |
| 161 | ) |
| 162 | ); |
| 163 | |
| 164 | $this->add_responsive_control( |
| 165 | '_width', |
| 166 | array( |
| 167 | 'label' => __('Width','auxin-elements' ), |
| 168 | 'type' => Controls_Manager::SLIDER, |
| 169 | 'size_units' => array('px', 'em', '%'), |
| 170 | 'range' => array( |
| 171 | '%' => array( |
| 172 | 'min' => 1, |
| 173 | 'max' => 100, |
| 174 | 'step' => 1 |
| 175 | ), |
| 176 | 'px' => array( |
| 177 | 'min' => 0, |
| 178 | 'max' => 1600, |
| 179 | 'step' => 1 |
| 180 | ), |
| 181 | 'em' => array( |
| 182 | 'min' => 0, |
| 183 | 'step' => 1 |
| 184 | ) |
| 185 | ), |
| 186 | 'desktop_default' => array( |
| 187 | 'size' => 300, |
| 188 | 'unit' => 'px' |
| 189 | ), |
| 190 | 'selectors' => array( |
| 191 | '{{WRAPPER}} .aux-the-svg' => 'width:{{SIZE}}{{UNIT}};' |
| 192 | ) |
| 193 | ) |
| 194 | ); |
| 195 | |
| 196 | $this->add_responsive_control( |
| 197 | '_height', |
| 198 | array( |
| 199 | 'label' => __( 'Height','auxin-elements' ), |
| 200 | 'type' => Controls_Manager::SLIDER, |
| 201 | 'size_units' => array('px', 'em', '%'), |
| 202 | 'range' => array( |
| 203 | '%' => array( |
| 204 | 'min' => 1, |
| 205 | 'max' => 100, |
| 206 | 'step' => 1 |
| 207 | ), |
| 208 | 'px' => array( |
| 209 | 'min' => 0, |
| 210 | 'max' => 1600, |
| 211 | 'step' => 1 |
| 212 | ), |
| 213 | 'em' => array( |
| 214 | 'min' => 0, |
| 215 | 'step' => 1 |
| 216 | ) |
| 217 | ), |
| 218 | 'selectors' => array( |
| 219 | '{{WRAPPER}} .aux-the-svg' => 'height:{{SIZE}}{{UNIT}};' |
| 220 | ) |
| 221 | ) |
| 222 | ); |
| 223 | |
| 224 | $this->add_responsive_control( |
| 225 | '_max_width', |
| 226 | array( |
| 227 | 'label' => __('Max Width','auxin-elements' ), |
| 228 | 'type' => Controls_Manager::SLIDER, |
| 229 | 'size_units' => array('px', 'em', '%'), |
| 230 | 'range' => array( |
| 231 | '%' => array( |
| 232 | 'min' => 1, |
| 233 | 'max' => 100, |
| 234 | 'step' => 1 |
| 235 | ), |
| 236 | 'px' => array( |
| 237 | 'min' => 0, |
| 238 | 'max' => 1600, |
| 239 | 'step' => 1 |
| 240 | ), |
| 241 | 'em' => array( |
| 242 | 'min' => 0, |
| 243 | 'step' => 1 |
| 244 | ) |
| 245 | ), |
| 246 | 'selectors' => array( |
| 247 | '{{WRAPPER}} .aux-widget-container-inner' => 'max-width:{{SIZE}}{{UNIT}};' |
| 248 | ) |
| 249 | ) |
| 250 | ); |
| 251 | |
| 252 | $this->add_responsive_control( |
| 253 | '_max_height', |
| 254 | array( |
| 255 | 'label' => __('Max Height','auxin-elements' ), |
| 256 | 'type' => Controls_Manager::SLIDER, |
| 257 | 'size_units' => array('px', 'em','%'), |
| 258 | 'range' => array( |
| 259 | '%' => array( |
| 260 | 'min' => 1, |
| 261 | 'max' => 100, |
| 262 | 'step' => 1 |
| 263 | ), |
| 264 | 'px' => array( |
| 265 | 'min' => 0, |
| 266 | 'max' => 2000, |
| 267 | 'step' => 10 |
| 268 | ), |
| 269 | 'em' => array( |
| 270 | 'min' => 0, |
| 271 | 'step' => 1 |
| 272 | ) |
| 273 | ), |
| 274 | 'selectors' => array( |
| 275 | '{{WRAPPER}} .aux-widget-container-inner' => 'max-height:{{SIZE}}{{UNIT}};' |
| 276 | ), |
| 277 | 'separator' => 'after' |
| 278 | ) |
| 279 | ); |
| 280 | |
| 281 | $this->add_responsive_control( |
| 282 | 'alignment', |
| 283 | array( |
| 284 | 'label' => __('Alignment', 'auxin-elements'), |
| 285 | 'type' => Controls_Manager::CHOOSE, |
| 286 | 'default' => 'center', |
| 287 | 'options' => array( |
| 288 | 'left' => array( |
| 289 | 'title' => __( 'Left', 'auxin-elements' ), |
| 290 | 'icon' => 'eicon-text-align-left', |
| 291 | ), |
| 292 | 'center' => array( |
| 293 | 'title' => __( 'Center', 'auxin-elements' ), |
| 294 | 'icon' => 'eicon-text-align-center', |
| 295 | ), |
| 296 | 'right' => array( |
| 297 | 'title' => __( 'Right', 'auxin-elements' ), |
| 298 | 'icon' => 'eicon-text-align-right', |
| 299 | ) |
| 300 | ), |
| 301 | 'selectors' => array( |
| 302 | '{{WRAPPER}} .aux-widget-container' => 'text-align: {{VALUE}};' |
| 303 | ) |
| 304 | ) |
| 305 | ); |
| 306 | |
| 307 | $this->add_responsive_control( |
| 308 | 'svg_border_radius', |
| 309 | array( |
| 310 | 'label' => __( 'Border radius', 'auxin-elements' ), |
| 311 | 'type' => Controls_Manager::DIMENSIONS, |
| 312 | 'size_units' => array( 'px', 'em', '%' ), |
| 313 | 'selectors' => array( |
| 314 | '{{WRAPPER}} .aux-the-svg > *' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 315 | ), |
| 316 | 'separator' => 'after' |
| 317 | ) |
| 318 | ); |
| 319 | |
| 320 | $this->start_controls_tabs( 'svg_style_tabs' ); |
| 321 | |
| 322 | $this->start_controls_tab( |
| 323 | 'svg_status_normal', |
| 324 | array( |
| 325 | 'label' => __( 'Normal' , 'auxin-elements' ) |
| 326 | ) |
| 327 | ); |
| 328 | |
| 329 | $this->add_group_control( |
| 330 | Group_Control_Box_Shadow::get_type(), |
| 331 | array( |
| 332 | 'name' => 'svg_box_shadow', |
| 333 | 'selector' => '{{WRAPPER}} .aux-the-svg > *', |
| 334 | 'separator' => 'none' |
| 335 | ) |
| 336 | ); |
| 337 | |
| 338 | $this->add_group_control( |
| 339 | Group_Control_Border::get_type(), |
| 340 | array( |
| 341 | 'name' => 'svg_border', |
| 342 | 'selector' => '{{WRAPPER}} .aux-the-svg > *', |
| 343 | 'separator' => 'none' |
| 344 | ) |
| 345 | ); |
| 346 | |
| 347 | $this->add_group_control( |
| 348 | Group_Control_Background::get_type(), |
| 349 | array( |
| 350 | 'name' => 'svg_background', |
| 351 | 'selector' => '{{WRAPPER}} .aux-the-svg > *', |
| 352 | 'separator' => 'none' |
| 353 | ) |
| 354 | ); |
| 355 | |
| 356 | $this->end_controls_tab(); |
| 357 | |
| 358 | |
| 359 | $this->start_controls_tab( |
| 360 | 'svg_status_hover', |
| 361 | array( |
| 362 | 'label' => __( 'Hover' , 'auxin-elements' ) |
| 363 | ) |
| 364 | ); |
| 365 | |
| 366 | $this->add_group_control( |
| 367 | Group_Control_Box_Shadow::get_type(), |
| 368 | array( |
| 369 | 'name' => 'svg_box_shadow_hover', |
| 370 | 'selector' => '{{WRAPPER}} .aux-the-svg:hover > *', |
| 371 | 'separator' => 'none' |
| 372 | ) |
| 373 | ); |
| 374 | |
| 375 | $this->add_group_control( |
| 376 | Group_Control_Border::get_type(), |
| 377 | array( |
| 378 | 'name' => 'svg_border_hover', |
| 379 | 'selector' => '{{WRAPPER}} .aux-the-svg:hover > *', |
| 380 | 'separator' => 'none' |
| 381 | ) |
| 382 | ); |
| 383 | |
| 384 | $this->add_group_control( |
| 385 | Group_Control_Background::get_type(), |
| 386 | array( |
| 387 | 'name' => 'svg_background_hover', |
| 388 | 'selector' => '{{WRAPPER}} .aux-the-svg:hover > *', |
| 389 | 'separator' => 'none' |
| 390 | ) |
| 391 | ); |
| 392 | |
| 393 | $this->end_controls_tab(); |
| 394 | |
| 395 | $this->end_controls_tabs(); |
| 396 | |
| 397 | $this->end_controls_section(); |
| 398 | |
| 399 | } |
| 400 | |
| 401 | |
| 402 | /** |
| 403 | * Render the widget output on the frontend. |
| 404 | * |
| 405 | * Written in PHP and used to generate the final HTML. |
| 406 | * |
| 407 | */ |
| 408 | protected function render() { |
| 409 | $settings = $this->get_settings_for_display(); |
| 410 | |
| 411 | if( 'image' == $settings['type'] ){ |
| 412 | $content = Group_Control_Image_Size::get_attachment_image_html( $settings ); |
| 413 | } else { |
| 414 | $content = $this->get_settings_for_display( 'inline' ); |
| 415 | } |
| 416 | ?> |
| 417 | <div class="aux-widget-container aux-simple-svg-container"> |
| 418 | <div class="aux-widget-container-inner"> |
| 419 | <div class="aux-the-svg"><?php echo wp_kses_post( $content ); ?></div> |
| 420 | </div> |
| 421 | </div> |
| 422 | <?php |
| 423 | } |
| 424 | |
| 425 | |
| 426 | /** |
| 427 | * Render the widget output in the editor. |
| 428 | * |
| 429 | * Written as a Backbone JavaScript template and used to generate the live preview. |
| 430 | * |
| 431 | */ |
| 432 | protected function content_template() { |
| 433 | ?> |
| 434 | <div class="aux-widget-container aux-simple-svg-container"> |
| 435 | <div class="aux-widget-container-inner"> |
| 436 | <div class="aux-the-svg"> |
| 437 | <# if( settings.type == 'image' ){ |
| 438 | |
| 439 | if ( settings.image.url ) { |
| 440 | #><img src="{{ settings.image.url }}" /><# |
| 441 | } |
| 442 | |
| 443 | } else { #> |
| 444 | {{{ settings.inline }}} |
| 445 | <# } #> |
| 446 | </div> |
| 447 | </div> |
| 448 | </div> |
| 449 | <?php |
| 450 | } |
| 451 | |
| 452 | } |
| 453 |