PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.4
Elementor Website Builder – more than just a page builder v4.0.4
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / modules / atomic-widgets / elements / atomic-svg / atomic-svg.php

atomic-svg.php in Elementor Website Builder – more than just a page builder 4.0.4, at modules/atomic-widgets/elements/atomic-svg/atomic-svg.php

110 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Svg;
3
4 use Elementor\Modules\AtomicWidgets\Controls\Section;
5 use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control;
6 use Elementor\Modules\AtomicWidgets\Controls\Types\Svg_Control;
7 use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
8 use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base;
9 use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template;
10 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
11 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
12 use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
13 use Elementor\Modules\AtomicWidgets\PropTypes\Svg_Src_Prop_Type;
14 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
15 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
16 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
17 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
18 use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit; // Exit if accessed directly.
22 }
23
24 class Atomic_Svg extends Atomic_Widget_Base {
25 use Has_Template;
26
27 const BASE_STYLE_KEY = 'base';
28 const DEFAULT_SVG = 'images/default-svg.svg';
29 const DEFAULT_SVG_PATH = ELEMENTOR_ASSETS_PATH . self::DEFAULT_SVG;
30 const DEFAULT_SVG_URL = ELEMENTOR_ASSETS_URL . self::DEFAULT_SVG;
31
32 public static $widget_description = 'Display an SVG image with customizable styles and link options.';
33
34 public static function get_element_type(): string {
35 return 'e-svg';
36 }
37
38 public function get_title() {
39 return esc_html__( 'SVG', 'elementor' );
40 }
41
42 public function get_keywords() {
43 return [ 'ato', 'atom', 'atoms', 'atomic' ];
44 }
45
46 public function get_icon() {
47 return 'eicon-svg';
48 }
49
50 protected static function define_props_schema(): array {
51 return [
52 'classes' => Classes_Prop_Type::make()->default( [] ),
53 'svg' => Svg_Src_Prop_Type::make()->default_url( static::DEFAULT_SVG_URL ),
54 'link' => Link_Prop_Type::make(),
55 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
56 ];
57 }
58
59 protected function define_atomic_controls(): array {
60 return [
61 Section::make()
62 ->set_label( esc_html__( 'Content', 'elementor' ) )
63 ->set_items( [
64 Svg_Control::bind_to( 'svg' )
65 ->set_label( __( 'SVG', 'elementor' ) ),
66 ] ),
67 Section::make()
68 ->set_label( __( 'Settings', 'elementor' ) )
69 ->set_id( 'settings' )
70 ->set_items( $this->get_settings_controls() ),
71 ];
72 }
73
74 protected function get_settings_controls(): array {
75 return [
76 Link_Control::bind_to( 'link' )
77 ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) )
78 ->set_label( __( 'Link', 'elementor' ) ),
79 Text_Control::bind_to( '_cssid' )
80 ->set_label( __( 'ID', 'elementor' ) )
81 ->set_meta( $this->get_css_id_control_meta() ),
82 ];
83 }
84
85 protected function define_base_styles(): array {
86 $display_value = String_Prop_Type::generate( 'inline-block' );
87
88 $size = Size_Prop_Type::generate( [
89 'size' => 65,
90 'unit' => 'px',
91 ] );
92
93 return [
94 self::BASE_STYLE_KEY => Style_Definition::make()
95 ->add_variant(
96 Style_Variant::make()
97 ->add_prop( 'display', $display_value )
98 ->add_prop( 'width', $size )
99 ->add_prop( 'height', $size )
100 ),
101 ];
102 }
103
104 protected function get_templates(): array {
105 return [
106 'elementor/elements/atomic-svg' => __DIR__ . '/atomic-svg.html.twig',
107 ];
108 }
109 }
110