PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.18
UiCore Elements – Free widgets and templates for Elementor v1.3.18
1.3.18 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 All 42 releases
← All changes | includes/widgets/theme-builder/page-description.php +311 -297 1.0.10 → 1.3.18 View file →
@@ -1,297 +1,311 @@
1 -<?php
2 -namespace UiCoreElements\ThemeBuilder\Widgets;
3 -
4 -use Elementor\Widget_Base;
5 -use Elementor\Controls_Manager;
6 -use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
7 -use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
8 -use Elementor\Group_Control_Typography;
9 -use Elementor\Group_Control_Text_Shadow;
10 -use Elementor\Group_Control_Text_Stroke;
11 -use Elementor\Utils;
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 - * Get widget name.
25 - *
26 - * Retrieve heading widget name.
27 - *
28 - * @since 1.0.0
29 - * @access public
30 - *
31 - * @return string Widget name.
32 - */
33 - public function get_name() {
34 - return 'uicore-page-description';
35 - }
36 -
37 - /**
38 - * Get widget title.
39 - *
40 - * Retrieve heading widget title.
41 - *
42 - * @since 1.0.0
43 - * @access public
44 - *
45 - * @return string Widget title.
46 - */
47 - public function get_title() {
48 - return esc_html__( 'Page Description', 'uicore-elements' );
49 - }
50 -
51 - /**
52 - * Get widget icon.
53 - *
54 - * Retrieve heading widget icon.
55 - *
56 - * @since 1.0.0
57 - * @access public
58 - *
59 - * @return string Widget icon.
60 - */
61 - public function get_icon() {
62 - return 'eicon-text ui-e-widget';
63 - }
64 -
65 - /**
66 - * Get widget categories.
67 - *
68 - * Retrieve the list of categories the heading widget belongs to.
69 - *
70 - * Used to determine where to display the widget in the editor.
71 - *
72 - * @since 2.0.0
73 - * @access public
74 - *
75 - * @return array Widget categories.
76 - */
77 - public function get_categories() {
78 - return ['uicore', 'uicore-theme-builder' ];
79 - }
80 -
81 - /**
82 - * Get widget keywords.
83 - *
84 - * Retrieve the list of keywords the widget belongs to.
85 - *
86 - * @since 2.1.0
87 - * @access public
88 - *
89 - * @return array Widget keywords.
90 - */
91 - public function get_keywords() {
92 - return [ 'description', 'page', 'text' ];
93 - }
94 -
95 - /**
96 - * Register heading widget controls.
97 - *
98 - * Adds different input fields to allow the user to change and customize the widget settings.
99 - *
100 - * @since 3.1.0
101 - * @access protected
102 - */
103 - protected function register_controls() {
104 - $this->start_controls_section(
105 - 'section_title',
106 - [
107 - 'label' => esc_html__( 'Content', 'uicore-elements' ),
108 - ]
109 - );
110 -
111 - $this->add_control(
112 - 'header_size',
113 - [
114 - 'label' => esc_html__( 'HTML Tag', 'uicore-elements' ),
115 - 'type' => Controls_Manager::SELECT,
116 - 'options' => [
117 - 'h1' => 'H1',
118 - 'h2' => 'H2',
119 - 'h3' => 'H3',
120 - 'h4' => 'H4',
121 - 'h5' => 'H5',
122 - 'h6' => 'H6',
123 - 'div' => 'div',
124 - 'span' => 'span',
125 - 'p' => 'p',
126 - ],
127 - 'default' => 'p',
128 - ]
129 - );
130 -
131 - $this->add_responsive_control(
132 - 'align',
133 - [
134 - 'label' => esc_html__( 'Alignment', 'uicore-elements' ),
135 - 'type' => Controls_Manager::CHOOSE,
136 - 'options' => [
137 - 'left' => [
138 - 'title' => esc_html__( 'Left', 'uicore-elements' ),
139 - 'icon' => 'eicon-text-align-left',
140 - ],
141 - 'center' => [
142 - 'title' => esc_html__( 'Center', 'uicore-elements' ),
143 - 'icon' => 'eicon-text-align-center',
144 - ],
145 - 'right' => [
146 - 'title' => esc_html__( 'Right', 'uicore-elements' ),
147 - 'icon' => 'eicon-text-align-right',
148 - ],
149 - 'justify' => [
150 - 'title' => esc_html__( 'Justified', 'uicore-elements' ),
151 - 'icon' => 'eicon-text-align-justify',
152 - ],
153 - ],
154 - 'default' => '',
155 - 'selectors' => [
156 - '{{WRAPPER}}' => 'text-align: {{VALUE}};',
157 - ],
158 - ]
159 - );
160 - $this->add_control(
161 - 'fallabck_text',
162 - [
163 - 'label' => __( 'Fallback text', 'uicore-elements' ),
164 - 'description' => esc_html__('If is empty and page does not have any description nothing will be displayed.', 'uicore-elements'),
165 - 'type' => Controls_Manager::TEXT,
166 - ]
167 - );
168 -
169 - $this->end_controls_section();
170 -
171 - $this->start_controls_section(
172 - 'section_title_style',
173 - [
174 - 'label' => esc_html__( 'Content', 'uicore-elements' ),
175 - 'tab' => Controls_Manager::TAB_STYLE,
176 - ]
177 - );
178 -
179 - $this->add_control(
180 - 'title_color',
181 - [
182 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
183 - 'type' => Controls_Manager::COLOR,
184 - 'global' => [
185 - 'default' => Global_Colors::COLOR_PRIMARY,
186 - ],
187 - 'selectors' => [
188 - '{{WRAPPER}} .ui-e-page-description' => 'color: {{VALUE}};',
189 - ],
190 - ]
191 - );
192 -
193 - $this->add_group_control(
194 - Group_Control_Typography::get_type(),
195 - [
196 - 'name' => 'typography',
197 - 'global' => [
198 - 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
199 - ],
200 - 'selector' => '{{WRAPPER}} .ui-e-page-description',
201 - ]
202 - );
203 -
204 - $this->add_group_control(
205 - Group_Control_Text_Stroke::get_type(),
206 - [
207 - 'name' => 'text_stroke',
208 - 'selector' => '{{WRAPPER}} .ui-e-page-description',
209 - ]
210 - );
211 -
212 - $this->add_group_control(
213 - Group_Control_Text_Shadow::get_type(),
214 - [
215 - 'name' => 'text_shadow',
216 - 'selector' => '{{WRAPPER}} .ui-e-page-description',
217 - ]
218 - );
219 -
220 - $this->add_control(
221 - 'blend_mode',
222 - [
223 - 'label' => esc_html__( 'Blend Mode', 'uicore-elements' ),
224 - 'type' => Controls_Manager::SELECT,
225 - 'options' => [
226 - '' => esc_html__( 'Normal', 'uicore-elements' ),
227 - 'multiply' => 'Multiply',
228 - 'screen' => 'Screen',
229 - 'overlay' => 'Overlay',
230 - 'darken' => 'Darken',
231 - 'lighten' => 'Lighten',
232 - 'color-dodge' => 'Color Dodge',
233 - 'saturation' => 'Saturation',
234 - 'color' => 'Color',
235 - 'difference' => 'Difference',
236 - 'exclusion' => 'Exclusion',
237 - 'hue' => 'Hue',
238 - 'luminosity' => 'Luminosity',
239 - ],
240 - 'selectors' => [
241 - '{{WRAPPER}} .ui-e-page-description' => 'mix-blend-mode: {{VALUE}}',
242 - ],
243 - 'separator' => 'none',
244 - ]
245 - );
246 -
247 - $this->end_controls_section();
248 - }
249 -
250 - /**
251 - * Render heading widget output on the frontend.
252 - *
253 - * Written in PHP and used to generate the final HTML.
254 - *
255 - * @since 1.0.0
256 - * @access protected
257 - */
258 - protected function render() {
259 - $settings = $this->get_settings_for_display();
260 - $this->add_render_attribute( 'title', 'class', 'ui-e-page-description' );
261 -
262 - if( !\Elementor\Plugin::$instance->editor->is_edit_mode() ) {
263 -
264 - $post_id = Helper::get_current_meta_id();
265 - $title = get_post_meta($post_id, 'page_description', true);
266 -
267 - }else{
268 - if($settings['fallabck_text']){
269 - $title = $settings['fallabck_text'];
270 - }else{
271 - $title = 'This is the page description. You can change this text by editing the page using the default WordPress editor.';
272 - }
273 - }
274 - if(!$title && $settings['fallabck_text']){
275 - $title = $settings['fallabck_text'];
276 - }
277 -
278 - $title_html = sprintf( '<%1$s %2$s>%3$s</%1$s>', Utils::validate_html_tag($settings['header_size']), $this->get_render_attribute_string( 'title' ), \esc_html($title) );
279 -
280 - // PHPCS - the variable $title_html holds safe data.
281 - echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
282 -
283 -
284 - }
285 -
286 - /**
287 - * Render heading widget output in the editor.
288 - *
289 - * Written as a Backbone JavaScript template and used to generate the live preview.
290 - *
291 - * @since 2.9.0
292 - * @access protected
293 - */
294 - protected function content_template() {
295 - }
296 -}
297 -\Elementor\Plugin::instance()->widgets_manager->register(new PageDescription());
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());