PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.5.3
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.5.3
4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 All 202 releases
betterdocs / includes / Editors / Elementor / Widget / Title.php

Title.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.5.3, at includes/Editors/Elementor/Widget/Title.php

291 lines 9.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WPDeveloper\BetterDocs\Editors\Elementor\Widget;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly
6 }
7
8 use ElementorPro\Plugin;
9 use Elementor\Core\Schemes;
10 use Elementor\Controls_Manager;
11 use Elementor\Group_Control_Typography;
12 use Elementor\Group_Control_Text_Shadow;
13 use WPDeveloper\BetterDocs\Editors\Elementor\BaseWidget;
14 use ElementorPro\Base\Base_Widget_Trait as BaseWidgetTrait;
15
16 class Title extends BaseWidget {
17 use BaseWidgetTrait;
18
19 public $view_wrapper = 'betterdocs-entry-title';
20
21 public function get_name() {
22 return 'betterdocs-title';
23 }
24
25 public function get_title() {
26 return __( 'Doc Title', 'betterdocs' );
27 }
28
29 public function get_icon() {
30 return 'betterdocs-icon-title';
31 }
32
33 public function get_categories() {
34 return ['betterdocs-elements-single'];
35 }
36
37 public function get_keywords() {
38 return ['betterdocs-elements', 'title', 'heading', 'betterdocs', 'docs'];
39 }
40
41 public function get_custom_help_url() {
42 return 'https://betterdocs.co/docs/single-doc-in-elementor';
43 }
44
45 protected function register_controls() {
46 $this->start_controls_section(
47 'section_title',
48 [
49 'label' => __( 'Title', 'betterdocs' )
50 ]
51 );
52
53 $this->add_control(
54 'title',
55 [
56 'label' => __( 'Title', 'betterdocs' ),
57 'type' => Controls_Manager::TEXTAREA,
58 'dynamic' => [
59 'active' => true
60 ],
61 'placeholder' => __( 'Enter your title', 'betterdocs' ),
62 'default' => __( 'Add Your Heading Text Here', 'betterdocs' )
63 ]
64 );
65
66 $this->add_control(
67 'link',
68 [
69 'label' => __( 'Link', 'betterdocs' ),
70 'type' => Controls_Manager::URL,
71 'dynamic' => [
72 'active' => true
73 ],
74 'default' => [
75 'url' => ''
76 ],
77 'separator' => 'before'
78 ]
79 );
80
81 $this->add_control(
82 'header_size',
83 [
84 'label' => __( 'HTML Tag', 'betterdocs' ),
85 'type' => Controls_Manager::SELECT,
86 'options' => [
87 'h1' => 'H1',
88 'h2' => 'H2',
89 'h3' => 'H3',
90 'h4' => 'H4',
91 'h5' => 'H5',
92 'h6' => 'H6',
93 'div' => 'div',
94 'span' => 'span',
95 'p' => 'p'
96 ],
97 'default' => 'h2'
98 ]
99 );
100
101 $this->add_responsive_control(
102 'align',
103 [
104 'label' => __( 'Alignment', 'betterdocs' ),
105 'type' => Controls_Manager::CHOOSE,
106 'options' => [
107 'left' => [
108 'title' => __( 'Left', 'betterdocs' ),
109 'icon' => 'eicon-text-align-left'
110 ],
111 'center' => [
112 'title' => __( 'Center', 'betterdocs' ),
113 'icon' => 'eicon-text-align-center'
114 ],
115 'right' => [
116 'title' => __( 'Right', 'betterdocs' ),
117 'icon' => 'eicon-text-align-right'
118 ],
119 'justify' => [
120 'title' => __( 'Justified', 'betterdocs' ),
121 'icon' => 'eicon-text-align-justify'
122 ]
123 ],
124 'default' => '',
125 'selectors' => [
126 '{{WRAPPER}}' => 'text-align: {{VALUE}};'
127 ]
128 ]
129 );
130
131 $this->add_control(
132 'view',
133 [
134 'label' => __( 'View', 'betterdocs' ),
135 'type' => Controls_Manager::HIDDEN,
136 'default' => 'traditional'
137 ]
138 );
139
140 $this->end_controls_section();
141
142 $this->start_controls_section(
143 'section_title_style',
144 [
145 'label' => __( 'Title', 'betterdocs' ),
146 'tab' => Controls_Manager::TAB_STYLE
147 ]
148 );
149
150 $this->add_control(
151 'title_color',
152 [
153 'label' => __( 'Text Color', 'betterdocs' ),
154 'type' => Controls_Manager::COLOR,
155 'scheme' => [
156 'type' => Schemes\Color::get_type(),
157 'value' => Schemes\Color::COLOR_1
158 ],
159 'selectors' => [
160 '{{WRAPPER}} .betterdocs-entry-title, .betterdocs-entry-title a' => 'color: {{VALUE}};'
161 ]
162 ]
163 );
164
165 $this->add_group_control(
166 Group_Control_Typography::get_type(),
167 [
168 'name' => 'typography',
169 'scheme' => Schemes\Typography::TYPOGRAPHY_1,
170 'selector' => '{{WRAPPER}} .betterdocs-entry-title, .betterdocs-entry-title a'
171 ]
172 );
173
174 $this->add_group_control(
175 Group_Control_Text_Shadow::get_type(),
176 [
177 'name' => 'text_shadow',
178 'selector' => '{{WRAPPER}} .betterdocs-entry-title'
179 ]
180 );
181
182 $this->add_control(
183 'blend_mode',
184 [
185 'label' => __( 'Blend Mode', 'betterdocs' ),
186 'type' => Controls_Manager::SELECT,
187 'options' => [
188 '' => __( 'Normal', 'betterdocs' ),
189 'multiply' => 'Multiply',
190 'screen' => 'Screen',
191 'overlay' => 'Overlay',
192 'darken' => 'Darken',
193 'lighten' => 'Lighten',
194 'color-dodge' => 'Color Dodge',
195 'saturation' => 'Saturation',
196 'color' => 'Color',
197 'difference' => 'Difference',
198 'exclusion' => 'Exclusion',
199 'hue' => 'Hue',
200 'luminosity' => 'Luminosity'
201 ],
202 'selectors' => [
203 '{{WRAPPER}} .betterdocs-entry-title' => 'mix-blend-mode: {{VALUE}}'
204 ],
205 'separator' => 'none'
206 ]
207 );
208
209 $this->add_responsive_control(
210 'title_padding',
211 [
212 'label' => esc_html__( 'Title Padding', 'betterdocs' ),
213 'type' => Controls_Manager::DIMENSIONS,
214 'size_units' => ['px', 'em', '%'],
215 'default' => [
216 "top" => '0',
217 "right" => '0',
218 "bottom" => '0',
219 "left" => '0',
220 "isLinked" => false
221 ],
222 'selectors' => [
223 '{{WRAPPER}} .betterdocs-entry-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
224 ]
225 ]
226 );
227
228 $this->add_responsive_control(
229 'title_margin',
230 [
231 'label' => esc_html__( 'Title Margin', 'betterdocs' ),
232 'type' => Controls_Manager::DIMENSIONS,
233 'size_units' => ['px', 'em', '%'],
234 'default' => [
235 "top" => '0',
236 "right" => '0',
237 "bottom" => '0',
238 "left" => '0',
239 "isLinked" => false
240 ],
241 'selectors' => [
242 '{{WRAPPER}} .betterdocs-entry-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
243 ]
244 ]
245 );
246
247 $this->end_controls_section();
248
249 $this->update_control(
250 'title',
251 [
252 'dynamic' => [
253 'default' => Plugin::elementor()->dynamic_tags->tag_data_to_tag_text( null, 'betterdocs-title-tag' )
254 ]
255 ],
256 [
257 'recursive' => true
258 ]
259 );
260
261 $this->update_control(
262 'header_size',
263 [
264 'default' => 'h1'
265 ]
266 );
267 }
268
269 public function render_callback() {
270 $this->views( 'widgets/title' );
271 }
272
273 public function view_params() {
274 $this->add_inline_editing_attributes( 'title' );
275 $title = $this->attributes['title'];
276
277 if ( ! empty( $this->attributes['link']['url'] ) ) {
278 $this->add_link_attributes( 'url', $this->attributes['link'] );
279 $title = sprintf( '<a %1$s>%2$s</a>', $this->get_render_attribute_string( 'url' ), $title );
280 }
281
282 return [
283 'tag' => $this->attributes['header_size'],
284 'title' => $title,
285 'wrapper_attr' => $this->get_render_attributes( 'title' )
286 ];
287 }
288
289 public function render_plain_content() {}
290 }
291