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

298 lines 6.8 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 /**
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());
298