PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.3
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.3
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 3.5.0 All 201 releases
betterdocs / includes / Editors / Elementor / Widget / Title.php

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

286 lines 6.6 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 'selectors' => [
156 '{{WRAPPER}} .betterdocs-entry-title, .betterdocs-entry-title a' => 'color: {{VALUE}};'
157 ]
158 ]
159 );
160
161 $this->add_group_control(
162 Group_Control_Typography::get_type(),
163 [
164 'name' => 'typography',
165 'selector' => '{{WRAPPER}} .betterdocs-entry-title, .betterdocs-entry-title a'
166 ]
167 );
168
169 $this->add_group_control(
170 Group_Control_Text_Shadow::get_type(),
171 [
172 'name' => 'text_shadow',
173 'selector' => '{{WRAPPER}} .betterdocs-entry-title'
174 ]
175 );
176
177 $this->add_control(
178 'blend_mode',
179 [
180 'label' => __( 'Blend Mode', 'betterdocs' ),
181 'type' => Controls_Manager::SELECT,
182 'options' => [
183 '' => __( 'Normal', 'betterdocs' ),
184 'multiply' => 'Multiply',
185 'screen' => 'Screen',
186 'overlay' => 'Overlay',
187 'darken' => 'Darken',
188 'lighten' => 'Lighten',
189 'color-dodge' => 'Color Dodge',
190 'saturation' => 'Saturation',
191 'color' => 'Color',
192 'difference' => 'Difference',
193 'exclusion' => 'Exclusion',
194 'hue' => 'Hue',
195 'luminosity' => 'Luminosity'
196 ],
197 'selectors' => [
198 '{{WRAPPER}} .betterdocs-entry-title' => 'mix-blend-mode: {{VALUE}}'
199 ],
200 'separator' => 'none'
201 ]
202 );
203
204 $this->add_responsive_control(
205 'title_padding',
206 [
207 'label' => esc_html__( 'Title Padding', 'betterdocs' ),
208 'type' => Controls_Manager::DIMENSIONS,
209 'size_units' => [ 'px', 'em', '%' ],
210 'default' => [
211 'top' => '0',
212 'right' => '0',
213 'bottom' => '0',
214 'left' => '0',
215 'isLinked' => false
216 ],
217 'selectors' => [
218 '{{WRAPPER}} .betterdocs-entry-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
219 ]
220 ]
221 );
222
223 $this->add_responsive_control(
224 'title_margin',
225 [
226 'label' => esc_html__( 'Title Margin', 'betterdocs' ),
227 'type' => Controls_Manager::DIMENSIONS,
228 'size_units' => [ 'px', 'em', '%' ],
229 'default' => [
230 'top' => '0',
231 'right' => '0',
232 'bottom' => '0',
233 'left' => '0',
234 'isLinked' => false
235 ],
236 'selectors' => [
237 '{{WRAPPER}} .betterdocs-entry-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
238 ]
239 ]
240 );
241
242 $this->end_controls_section();
243
244 $this->update_control(
245 'title',
246 [
247 'dynamic' => [
248 'default' => Plugin::elementor()->dynamic_tags->tag_data_to_tag_text( null, 'betterdocs-title-tag' )
249 ]
250 ],
251 [
252 'recursive' => true
253 ]
254 );
255
256 $this->update_control(
257 'header_size',
258 [
259 'default' => 'h1'
260 ]
261 );
262 }
263
264 public function render_callback() {
265 $this->views( 'widgets/title' );
266 }
267
268 public function view_params() {
269 $this->add_inline_editing_attributes( 'title' );
270 $title = $this->attributes['title'];
271
272 if ( ! empty( $this->attributes['link']['url'] ) ) {
273 $this->add_link_attributes( 'url', $this->attributes['link'] );
274 $title = sprintf( '<a %1$s>%2$s</a>', $this->get_render_attribute_string( 'url' ), $title );
275 }
276
277 return [
278 'tag' => $this->attributes['header_size'],
279 'title' => $title,
280 'wrapper_attr' => $this->get_render_attributes( 'title' )
281 ];
282 }
283
284 public function render_plain_content() {}
285 }
286