PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
uicore-elements / includes / widgets / theme-builder / the-title.php

the-title.php in UiCore Elements – Free widgets and templates for Elementor 1.3.17, at includes/widgets/theme-builder/the-title.php

308 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UiCoreElements\ThemeBuilder\Widgets;
4
5 use Elementor\Widget_Base;
6 use Elementor\Controls_Manager;
7 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
8 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
9 use Elementor\Group_Control_Typography;
10 use Elementor\Group_Control_Text_Shadow;
11 use Elementor\Group_Control_Text_Stroke;
12 use UiCoreElements\Helper;
13
14 defined('ABSPATH') || exit();
15
16 /**
17 * The Title widget.
18 *
19 * @since 4.0.0
20 */
21 class TheTitle extends Widget_Base
22 {
23
24 /**
25 * Get widget name.
26 *
27 * Retrieve heading widget name.
28 *
29 * @since 1.0.0
30 * @access public
31 *
32 * @return string Widget name.
33 */
34 public function get_name()
35 {
36 return 'uicore-the-title';
37 }
38
39 /**
40 * Get widget title.
41 *
42 * Retrieve heading widget title.
43 *
44 * @since 1.0.0
45 * @access public
46 *
47 * @return string Widget title.
48 */
49 public function get_title()
50 {
51 return esc_html__('The Title', 'uicore-elements');
52 }
53
54 /**
55 * Get widget icon.
56 *
57 * Retrieve heading widget icon.
58 *
59 * @since 1.0.0
60 * @access public
61 *
62 * @return string Widget icon.
63 */
64 public function get_icon()
65 {
66 return 'eicon-t-letter ui-e-widget';
67 }
68
69 /**
70 * Get widget categories.
71 *
72 * Retrieve the list of categories the heading widget belongs to.
73 *
74 * Used to determine where to display the widget in the editor.
75 *
76 * @since 2.0.0
77 * @access public
78 *
79 * @return array Widget categories.
80 */
81 public function get_categories()
82 {
83 return ['uicore', 'uicore-theme-builder'];
84 }
85
86 /**
87 * Get widget keywords.
88 *
89 * Retrieve the list of keywords the widget belongs to.
90 *
91 * @since 2.1.0
92 * @access public
93 *
94 * @return array Widget keywords.
95 */
96 public function get_keywords()
97 {
98 return ['heading', 'title', 'text'];
99 }
100
101 public function has_widget_inner_wrapper(): bool
102 {
103 // TODO: remove after Optmized Markup experiment is merged to the core
104 return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
105 }
106
107 /**
108 * Register heading widget controls.
109 *
110 * Adds different input fields to allow the user to change and customize the widget settings.
111 *
112 * @since 3.1.0
113 * @access protected
114 */
115 protected function register_controls()
116 {
117 $this->start_controls_section(
118 'section_title',
119 [
120 'label' => esc_html__('Title', 'uicore-elements'),
121 ]
122 );
123
124 $this->add_control(
125 'header_size',
126 [
127 'label' => esc_html__('HTML Tag', 'uicore-elements'),
128 'type' => Controls_Manager::SELECT,
129 'options' => [
130 'h1' => 'H1',
131 'h2' => 'H2',
132 'h3' => 'H3',
133 'h4' => 'H4',
134 'h5' => 'H5',
135 'h6' => 'H6',
136 'div' => 'div',
137 'span' => 'span',
138 'p' => 'p',
139 ],
140 'default' => 'h2',
141 ]
142 );
143
144 $this->add_responsive_control(
145 'align',
146 [
147 'label' => esc_html__('Alignment', 'uicore-elements'),
148 'type' => Controls_Manager::CHOOSE,
149 'options' => [
150 'left' => [
151 'title' => esc_html__('Left', 'uicore-elements'),
152 'icon' => 'eicon-text-align-left',
153 ],
154 'center' => [
155 'title' => esc_html__('Center', 'uicore-elements'),
156 'icon' => 'eicon-text-align-center',
157 ],
158 'right' => [
159 'title' => esc_html__('Right', 'uicore-elements'),
160 'icon' => 'eicon-text-align-right',
161 ],
162 'justify' => [
163 'title' => esc_html__('Justified', 'uicore-elements'),
164 'icon' => 'eicon-text-align-justify',
165 ],
166 ],
167 'default' => '',
168 'selectors' => [
169 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
170 ],
171 ]
172 );
173
174 $this->add_control(
175 'view',
176 [
177 'label' => esc_html__('View', 'uicore-elements'),
178 'type' => Controls_Manager::HIDDEN,
179 'default' => 'traditional',
180 ]
181 );
182
183 $this->end_controls_section();
184
185 $this->start_controls_section(
186 'section_title_style',
187 [
188 'label' => esc_html__('Title', 'uicore-elements'),
189 'tab' => Controls_Manager::TAB_STYLE,
190 ]
191 );
192
193 $this->add_control(
194 'title_color',
195 [
196 'label' => esc_html__('Text Color', 'uicore-elements'),
197 'type' => Controls_Manager::COLOR,
198 'default' => 'var(--e-global-color-uicore_primary)',
199
200 'selectors' => [
201 '{{WRAPPER}} .elementor-heading-title' => 'color: {{VALUE}};',
202 ],
203 ]
204 );
205
206 $this->add_group_control(
207 Group_Control_Typography::get_type(),
208 [
209 'name' => 'typography',
210 'global' => [
211 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
212 ],
213 'selector' => '{{WRAPPER}} .elementor-heading-title',
214 ]
215 );
216
217 $this->add_group_control(
218 Group_Control_Text_Stroke::get_type(),
219 [
220 'name' => 'text_stroke',
221 'selector' => '{{WRAPPER}} .elementor-heading-title',
222 ]
223 );
224
225 $this->add_group_control(
226 Group_Control_Text_Shadow::get_type(),
227 [
228 'name' => 'text_shadow',
229 'selector' => '{{WRAPPER}} .elementor-heading-title',
230 ]
231 );
232
233 $this->add_control(
234 'blend_mode',
235 [
236 'label' => esc_html__('Blend Mode', 'uicore-elements'),
237 'type' => Controls_Manager::SELECT,
238 'options' => [
239 '' => esc_html__('Normal', 'uicore-elements'),
240 'multiply' => 'Multiply',
241 'screen' => 'Screen',
242 'overlay' => 'Overlay',
243 'darken' => 'Darken',
244 'lighten' => 'Lighten',
245 'color-dodge' => 'Color Dodge',
246 'saturation' => 'Saturation',
247 'color' => 'Color',
248 'difference' => 'Difference',
249 'exclusion' => 'Exclusion',
250 'hue' => 'Hue',
251 'luminosity' => 'Luminosity',
252 ],
253 'selectors' => [
254 '{{WRAPPER}} .elementor-heading-title' => 'mix-blend-mode: {{VALUE}}',
255 ],
256 'separator' => 'none',
257 ]
258 );
259
260 $this->end_controls_section();
261 }
262
263 /**
264 * Render heading widget output on the frontend.
265 *
266 * Written in PHP and used to generate the final HTML.
267 *
268 * @since 1.0.0
269 * @access protected
270 */
271 protected function render()
272 {
273 $settings = $this->get_settings_for_display();
274
275 $this->add_render_attribute('title', 'class', 'elementor-heading-title');
276
277 if (!\Elementor\Plugin::$instance->editor->is_edit_mode()) {
278
279 // If there is a post.
280 if (is_single() || (is_home() && ! is_front_page()) || (is_page() && ! is_front_page())) {
281 $title = single_post_title('', false);
282 } else {
283 $title = wp_title(null, false);
284 }
285
286 $title = $title ? $title : get_bloginfo('name');
287 } else {
288 $title = __('This is a dummy title.', 'uicore-elements');
289 }
290
291 $title_html = sprintf('<%1$s %2$s>%3$s</%1$s>', Helper::esc_tag($settings['header_size']), $this->get_render_attribute_string('title'), \esc_html($title));
292
293 // PHPCS - the variable $title_html holds safe data.
294 echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
295 }
296
297 /**
298 * Render heading widget output in the editor.
299 *
300 * Written as a Backbone JavaScript template and used to generate the live preview.
301 *
302 * @since 2.9.0
303 * @access protected
304 */
305 protected function content_template() {}
306 }
307 \Elementor\Plugin::instance()->widgets_manager->register(new TheTitle());
308