PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0
Elementor Website Builder – more than just a page builder v4.3.0
4.3.1 4.3.0 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 All 454 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.3.0, at modules/atomic-widgets/elements/atomic-svg/atomic-svg.php

126 lines 4.0 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\Module as Atomic_Widgets_Module;
11 use Elementor\Modules\AtomicWidgets\Elements\Base\Html_Tag_Computer;
12 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
13 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
14 use Elementor\Modules\AtomicWidgets\PropTypes\Icon_Prop_Type;
15 use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
16 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
17 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
18 use Elementor\Modules\AtomicWidgets\PropTypes\Svg_Src_Prop_Type;
19 use Elementor\Modules\AtomicWidgets\PropTypes\Union_Prop_Type;
20 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
21 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
22 use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
23
24 if ( ! defined( 'ABSPATH' ) ) {
25 exit; // Exit if accessed directly.
26 }
27
28 class Atomic_Svg extends Atomic_Widget_Base {
29 use Has_Template;
30
31 const BASE_STYLE_KEY = 'base';
32 const DEFAULT_SVG = 'images/default-svg.svg';
33 const DEFAULT_SVG_PATH = ELEMENTOR_ASSETS_PATH . self::DEFAULT_SVG;
34 const DEFAULT_SVG_URL = ELEMENTOR_ASSETS_URL . self::DEFAULT_SVG;
35
36 public static $widget_description = 'Display an SVG image with customizable styles and link options.';
37
38 public static function get_element_type(): string {
39 return 'e-svg';
40 }
41
42 public function get_title() {
43 return esc_html__( 'SVG', 'elementor' );
44 }
45
46 public function get_keywords() {
47 return [ 'ato', 'atom', 'atoms', 'atomic', 'svg', 'icon', 'vector' ];
48 }
49
50 public function get_icon() {
51 return 'eicon-svg';
52 }
53
54 public static function get_computed_html_tag( array $settings ): string {
55 return Html_Tag_Computer::compute( $settings, 'div' );
56 }
57
58 protected static function define_props_schema(): array {
59 return [
60 'classes' => Classes_Prop_Type::make()->default( [] ),
61 'svg' => Union_Prop_Type::create_from(
62 Svg_Src_Prop_Type::make()->default_url( static::DEFAULT_SVG_URL )
63 )->add_prop_type( Icon_Prop_Type::make() ),
64 'link' => Link_Prop_Type::make(),
65 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
66 ];
67 }
68
69 protected function define_atomic_controls(): array {
70 return [
71 Section::make()
72 ->set_label( esc_html__( 'Content', 'elementor' ) )
73 ->set_id( 'content' )
74 ->set_items( [
75 Svg_Control::bind_to( 'svg' )
76 ->set_label( __( 'SVG', 'elementor' ) )
77 ->set_show_icon_library( Atomic_Widgets_Module::is_svg_library_active() ),
78 ] ),
79 Section::make()
80 ->set_label( __( 'Settings', 'elementor' ) )
81 ->set_id( 'settings' )
82 ->set_items( $this->get_settings_controls() ),
83 ];
84 }
85
86 protected function get_settings_controls(): array {
87 return [
88 Link_Control::bind_to( 'link' )
89 ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) )
90 ->set_label( __( 'Link', 'elementor' ) ),
91 Text_Control::bind_to( '_cssid' )
92 ->set_label( __( 'ID', 'elementor' ) )
93 ->set_meta( $this->get_css_id_control_meta() ),
94 ];
95 }
96
97 protected function define_base_styles(): array {
98 $display_value = String_Prop_Type::generate( 'inline-block' );
99
100 $size = Size_Prop_Type::generate( [
101 'size' => 65,
102 'unit' => 'px',
103 ] );
104
105 return [
106 self::BASE_STYLE_KEY => Style_Definition::make()
107 ->add_variant(
108 Style_Variant::make()
109 ->add_prop( 'display', $display_value )
110 ->add_prop( 'width', $size )
111 ->add_prop( 'height', $size )
112 ),
113 ];
114 }
115
116 protected function get_templates(): array {
117 return [
118 'elementor/elements/atomic-svg' => __DIR__ . '/atomic-svg.html.twig',
119 ];
120 }
121
122 public function render_markdown(): string {
123 return '';
124 }
125 }
126