PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.3
Elementor Website Builder – more than just a page builder v4.0.3
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 4.0.7 All 451 releases
elementor / modules / atomic-widgets / elements / atomic-paragraph / atomic-paragraph.php

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

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