PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev1
Elementor Website Builder – more than just a page builder v3.35.0-dev1
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-paragraph / atomic-paragraph.php

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

153 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Paragraph;
4
5 use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base;
6 use Elementor\Modules\AtomicWidgets\Controls\Section;
7 use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control;
8 use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control;
9 use Elementor\Modules\AtomicWidgets\Controls\Types\Textarea_Control;
10 use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template;
11 use Elementor\Modules\AtomicWidgets\Module as Atomic_Widgets_Module;
12 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
13 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
14 use Elementor\Modules\AtomicWidgets\PropTypes\Html_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\Styles\Style_Definition;
19 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
20 use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
21 use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control;
22 use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
23 use Elementor\Plugin;
24
25 if ( ! defined( 'ABSPATH' ) ) {
26 exit;
27 }
28
29 class Atomic_Paragraph extends Atomic_Widget_Base {
30 use Has_Template;
31
32 const LINK_BASE_STYLE_KEY = 'link-base';
33
34 public static $widget_description = 'Display a paragraph with customizable tag, styles, and link options.';
35
36 public static function get_element_type(): string {
37 return 'e-paragraph';
38 }
39
40 public function get_title() {
41 return esc_html__( 'Paragraph', 'elementor' );
42 }
43
44 public function get_keywords() {
45 return [ 'ato', 'atom', 'atoms', 'atomic' ];
46 }
47
48 public function get_icon() {
49 return 'eicon-paragraph';
50 }
51
52 protected static function define_props_schema(): array {
53 $is_feature_active = Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_INLINE_EDITING );
54
55 $paragraph_prop = $is_feature_active
56 ? Html_Prop_Type::make()->default( __( 'Type your paragraph here', 'elementor' ) )
57 : String_Prop_Type::make()->default( __( 'Type your paragraph here', 'elementor' ) );
58
59 $props = [
60 'classes' => Classes_Prop_Type::make()
61 ->default( [] ),
62
63 'paragraph' => $paragraph_prop
64 ->description( 'The text content of the paragraph.' ),
65
66 'tag' => String_Prop_Type::make()
67 ->enum( [ 'p', 'span' ] )
68 ->default( 'p' ),
69
70 'link' => Link_Prop_Type::make(),
71
72 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
73 ];
74
75 return $props;
76 }
77
78 protected function define_atomic_controls(): array {
79 $is_feature_active = Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_INLINE_EDITING );
80
81 $control = $is_feature_active
82 ? Inline_Editing_Control::bind_to( 'paragraph' )
83 ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) )
84 ->set_label( __( 'Paragraph', 'elementor' ) )
85 : Textarea_Control::bind_to( 'paragraph' )
86 ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) )
87 ->set_label( __( 'Paragraph', 'elementor' ) );
88
89 return [
90 Section::make()
91 ->set_label( __( 'Content', 'elementor' ) )
92 ->set_items( [ $control ] ),
93 Section::make()
94 ->set_label( __( 'Settings', 'elementor' ) )
95 ->set_id( 'settings' )
96 ->set_items( $this->get_settings_controls() ),
97 ];
98 }
99
100 protected function get_settings_controls(): array {
101 return [
102 Select_Control::bind_to( 'tag' )
103 ->set_options([
104 [
105 'value' => 'p',
106 'label' => 'p',
107 ],
108 [
109 'value' => 'span',
110 'label' => 'span',
111 ],
112 ])
113 ->set_label( __( 'Tag', 'elementor' ) ),
114 Link_Control::bind_to( 'link' )
115 ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) )
116 ->set_label( __( 'Link', 'elementor' ) )
117 ->set_meta( [
118 'topDivider' => true,
119 ] ),
120 Text_Control::bind_to( '_cssid' )
121 ->set_label( __( 'ID', 'elementor' ) )
122 ->set_meta( $this->get_css_id_control_meta() ),
123 ];
124 }
125
126 protected function define_base_styles(): array {
127 $margin_value = Size_Prop_Type::generate( [
128 'unit' => 'px',
129 'size' => 0 ,
130 ] );
131
132 return [
133 'base' => Style_Definition::make()
134 ->add_variant(
135 Style_Variant::make()
136 ->add_prop( 'margin', $margin_value )
137 ),
138 self::LINK_BASE_STYLE_KEY => Style_Definition::make()
139 ->add_variant(
140 Style_Variant::make()
141 ->add_prop( 'all', 'unset' )
142 ->add_prop( 'cursor', 'pointer' )
143 ),
144 ];
145 }
146
147 protected function get_templates(): array {
148 return [
149 'elementor/elements/atomic-paragraph' => __DIR__ . '/atomic-paragraph.html.twig',
150 ];
151 }
152 }
153