PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.2.3
UiCore Elements – Free widgets and templates for Elementor v1.2.3
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.2.3, at includes/widgets/theme-builder/page-description.php

306 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 public function has_widget_inner_wrapper(): bool {
96 // TODO: remove after 3.30, when the full deprecation of widget innet wrapper is ready
97 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
98 }
99
100 /**
101 * Register heading widget controls.
102 *
103 * Adds different input fields to allow the user to change and customize the widget settings.
104 *
105 * @since 3.1.0
106 * @access protected
107 */
108 protected function register_controls() {
109 $this->start_controls_section(
110 'section_title',
111 [
112 'label' => esc_html__( 'Content', 'uicore-elements' ),
113 ]
114 );
115
116 $this->add_control(
117 'header_size',
118 [
119 'label' => esc_html__( 'HTML Tag', 'uicore-elements' ),
120 'type' => Controls_Manager::SELECT,
121 'options' => [
122 'h1' => 'H1',
123 'h2' => 'H2',
124 'h3' => 'H3',
125 'h4' => 'H4',
126 'h5' => 'H5',
127 'h6' => 'H6',
128 'div' => 'div',
129 'span' => 'span',
130 'p' => 'p',
131 ],
132 'default' => 'p',
133 ]
134 );
135
136 $this->add_responsive_control(
137 'align',
138 [
139 'label' => esc_html__( 'Alignment', 'uicore-elements' ),
140 'type' => Controls_Manager::CHOOSE,
141 'options' => [
142 'left' => [
143 'title' => esc_html__( 'Left', 'uicore-elements' ),
144 'icon' => 'eicon-text-align-left',
145 ],
146 'center' => [
147 'title' => esc_html__( 'Center', 'uicore-elements' ),
148 'icon' => 'eicon-text-align-center',
149 ],
150 'right' => [
151 'title' => esc_html__( 'Right', 'uicore-elements' ),
152 'icon' => 'eicon-text-align-right',
153 ],
154 'justify' => [
155 'title' => esc_html__( 'Justified', 'uicore-elements' ),
156 'icon' => 'eicon-text-align-justify',
157 ],
158 ],
159 'default' => '',
160 'selectors' => [
161 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
162 ],
163 ]
164 );
165 $this->add_control(
166 'fallabck_text',
167 [
168 'label' => __( 'Fallback text', 'uicore-elements' ),
169 'description' => esc_html__('If is empty and page does not have any description nothing will be displayed.', 'uicore-elements'),
170 'type' => Controls_Manager::TEXT,
171 ]
172 );
173
174 $this->end_controls_section();
175
176 $this->start_controls_section(
177 'section_title_style',
178 [
179 'label' => esc_html__( 'Content', 'uicore-elements' ),
180 'tab' => Controls_Manager::TAB_STYLE,
181 ]
182 );
183
184 $this->add_control(
185 'title_color',
186 [
187 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
188 'type' => Controls_Manager::COLOR,
189 'global' => [
190 'default' => Global_Colors::COLOR_PRIMARY,
191 ],
192 'selectors' => [
193 '{{WRAPPER}} .ui-e-page-description' => 'color: {{VALUE}};',
194 ],
195 ]
196 );
197
198 $this->add_group_control(
199 Group_Control_Typography::get_type(),
200 [
201 'name' => 'typography',
202 'global' => [
203 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
204 ],
205 'selector' => '{{WRAPPER}} .ui-e-page-description',
206 ]
207 );
208
209 $this->add_group_control(
210 Group_Control_Text_Stroke::get_type(),
211 [
212 'name' => 'text_stroke',
213 'selector' => '{{WRAPPER}} .ui-e-page-description',
214 ]
215 );
216
217 $this->add_group_control(
218 Group_Control_Text_Shadow::get_type(),
219 [
220 'name' => 'text_shadow',
221 'selector' => '{{WRAPPER}} .ui-e-page-description',
222 ]
223 );
224
225 $this->add_control(
226 'blend_mode',
227 [
228 'label' => esc_html__( 'Blend Mode', 'uicore-elements' ),
229 'type' => Controls_Manager::SELECT,
230 'options' => [
231 '' => esc_html__( 'Normal', 'uicore-elements' ),
232 'multiply' => 'Multiply',
233 'screen' => 'Screen',
234 'overlay' => 'Overlay',
235 'darken' => 'Darken',
236 'lighten' => 'Lighten',
237 'color-dodge' => 'Color Dodge',
238 'saturation' => 'Saturation',
239 'color' => 'Color',
240 'difference' => 'Difference',
241 'exclusion' => 'Exclusion',
242 'hue' => 'Hue',
243 'luminosity' => 'Luminosity',
244 ],
245 'selectors' => [
246 '{{WRAPPER}} .ui-e-page-description' => 'mix-blend-mode: {{VALUE}}',
247 ],
248 'separator' => 'none',
249 ]
250 );
251
252 $this->end_controls_section();
253 }
254
255 /**
256 * Render heading widget output on the frontend.
257 *
258 * Written in PHP and used to generate the final HTML.
259 *
260 * @since 1.0.0
261 * @access protected
262 */
263 protected function render() {
264 $settings = $this->get_settings_for_display();
265 $this->add_render_attribute( 'title', 'class', 'ui-e-page-description' );
266
267 if( !\Elementor\Plugin::$instance->editor->is_edit_mode() ) {
268
269 $post_id = Helper::get_current_meta_id();
270 $title = get_post_meta($post_id, 'page_description', true);
271
272 }else{
273 if($settings['fallabck_text']){
274 $title = $settings['fallabck_text'];
275 }else{
276 $title = __('This is the page description. You can change this text by editing the page using the default WordPress editor.', 'uicore-elements');
277 }
278 }
279 if(!$title && $settings['fallabck_text']){
280 $title = $settings['fallabck_text'];
281 }
282
283 $title_html = sprintf(
284 '<%1$s %2$s>%3$s</%1$s>',
285 Utils::validate_html_tag($settings['header_size']),
286 $this->get_render_attribute_string( 'title' ),
287 Helper::esc_string($title) //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
288 );
289
290 // PHPCS - the variable $title_html holds safe data.
291 echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
292 }
293
294 /**
295 * Render heading widget output in the editor.
296 *
297 * Written as a Backbone JavaScript template and used to generate the live preview.
298 *
299 * @since 2.9.0
300 * @access protected
301 */
302 protected function content_template() {
303 }
304 }
305 \Elementor\Plugin::instance()->widgets_manager->register(new PageDescription());
306