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 / page-description.php

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

312 lines 9.1 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 PageDescription 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-page-description';
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__('Page Description', '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-text 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 ['description', 'page', '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__('Content', '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' => 'p',
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 $this->add_control(
174 'fallabck_text',
175 [
176 'label' => __('Fallback text', 'uicore-elements'),
177 'description' => esc_html__('If is empty and page does not have any description nothing will be displayed.', 'uicore-elements'),
178 'type' => Controls_Manager::TEXT,
179 ]
180 );
181
182 $this->end_controls_section();
183
184 $this->start_controls_section(
185 'section_title_style',
186 [
187 'label' => esc_html__('Content', 'uicore-elements'),
188 'tab' => Controls_Manager::TAB_STYLE,
189 ]
190 );
191
192 $this->add_control(
193 'title_color',
194 [
195 'label' => esc_html__('Text Color', 'uicore-elements'),
196 'type' => Controls_Manager::COLOR,
197 'default' => 'var(--e-global-color-uicore_primary)',
198
199 'selectors' => [
200 '{{WRAPPER}} .ui-e-page-description' => 'color: {{VALUE}};',
201 ],
202 ]
203 );
204
205 $this->add_group_control(
206 Group_Control_Typography::get_type(),
207 [
208 'name' => 'typography',
209 'global' => [
210 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
211 ],
212 'selector' => '{{WRAPPER}} .ui-e-page-description',
213 ]
214 );
215
216 $this->add_group_control(
217 Group_Control_Text_Stroke::get_type(),
218 [
219 'name' => 'text_stroke',
220 'selector' => '{{WRAPPER}} .ui-e-page-description',
221 ]
222 );
223
224 $this->add_group_control(
225 Group_Control_Text_Shadow::get_type(),
226 [
227 'name' => 'text_shadow',
228 'selector' => '{{WRAPPER}} .ui-e-page-description',
229 ]
230 );
231
232 $this->add_control(
233 'blend_mode',
234 [
235 'label' => esc_html__('Blend Mode', 'uicore-elements'),
236 'type' => Controls_Manager::SELECT,
237 'options' => [
238 '' => esc_html__('Normal', 'uicore-elements'),
239 'multiply' => 'Multiply',
240 'screen' => 'Screen',
241 'overlay' => 'Overlay',
242 'darken' => 'Darken',
243 'lighten' => 'Lighten',
244 'color-dodge' => 'Color Dodge',
245 'saturation' => 'Saturation',
246 'color' => 'Color',
247 'difference' => 'Difference',
248 'exclusion' => 'Exclusion',
249 'hue' => 'Hue',
250 'luminosity' => 'Luminosity',
251 ],
252 'selectors' => [
253 '{{WRAPPER}} .ui-e-page-description' => 'mix-blend-mode: {{VALUE}}',
254 ],
255 'separator' => 'none',
256 ]
257 );
258
259 $this->end_controls_section();
260 }
261
262 /**
263 * Render heading widget output on the frontend.
264 *
265 * Written in PHP and used to generate the final HTML.
266 *
267 * @since 1.0.0
268 * @access protected
269 */
270 protected function render()
271 {
272 $settings = $this->get_settings_for_display();
273 $this->add_render_attribute('title', 'class', 'ui-e-page-description');
274
275 if (!\Elementor\Plugin::$instance->editor->is_edit_mode()) {
276
277 $post_id = Helper::get_current_meta_id();
278 $title = get_post_meta($post_id, 'page_description', true);
279 } else {
280 if ($settings['fallabck_text']) {
281 $title = $settings['fallabck_text'];
282 } else {
283 $title = __('This is the page description. You can change this text by editing the page using the default WordPress editor.', 'uicore-elements');
284 }
285 }
286 if (!$title && $settings['fallabck_text']) {
287 $title = $settings['fallabck_text'];
288 }
289
290 $title_html = sprintf(
291 '<%1$s %2$s>%3$s</%1$s>',
292 Helper::esc_tag($settings['header_size']),
293 $this->get_render_attribute_string('title'),
294 Helper::esc_string($title) //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
295 );
296
297 // PHPCS - the variable $title_html holds safe data.
298 echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
299 }
300
301 /**
302 * Render heading widget output in the editor.
303 *
304 * Written as a Backbone JavaScript template and used to generate the live preview.
305 *
306 * @since 2.9.0
307 * @access protected
308 */
309 protected function content_template() {}
310 }
311 \Elementor\Plugin::instance()->widgets_manager->register(new PageDescription());
312