PluginProbe
Elementor Website Builder – more than just a page builder / 3.17.2
Elementor Website Builder – more than just a page builder v3.17.2
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | includes/widgets/progress.php +62 -207 4.1.23.17.2 View file →
@@ -72,31 +72,9 @@
72 72 public function get_keywords() {
73 73 return [ 'progress', 'bar' ];
74 74 }
75 75
76 - protected function is_dynamic_content(): bool {
77 - return false;
78 - }
79 -
80 76 /**
81 - * Get style dependencies.
82 - *
83 - * Retrieve the list of style dependencies the widget requires.
84 - *
85 - * @since 3.24.0
86 - * @access public
87 - *
88 - * @return array Widget style dependencies.
89 - */
90 - public function get_style_depends(): array {
91 - return [ 'widget-progress' ];
92 - }
93 -
94 - public function has_widget_inner_wrapper(): bool {
95 - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
96 - }
97 -
98 - /**
99 77 * Register progress widget controls.
100 78 *
101 79 * Adds different input fields to allow the user to change and customize the widget settings.
102 80 *
@@ -148,26 +126,13 @@
148 126 ]
149 127 );
150 128
151 129 $this->add_control(
152 - 'title_display',
153 - [
154 - 'label' => esc_html__( 'Display Title', 'elementor' ),
155 - 'type' => Controls_Manager::SWITCHER,
156 - 'label_on' => esc_html__( 'Show', 'elementor' ),
157 - 'label_off' => esc_html__( 'Hide', 'elementor' ),
158 - 'default' => 'yes',
159 - 'condition' => [
160 - 'title!' => '',
161 - ],
162 - ]
163 - );
164 -
165 - $this->add_control(
166 130 'progress_type',
167 131 [
168 132 'label' => esc_html__( 'Type', 'elementor' ),
169 133 'type' => Controls_Manager::SELECT,
134 + 'default' => '',
170 135 'options' => [
171 136 '' => esc_html__( 'Default', 'elementor' ),
172 137 'info' => esc_html__( 'Info', 'elementor' ),
173 138 'success' => esc_html__( 'Success', 'elementor' ),
@@ -173,12 +138,8 @@
173 138 'success' => esc_html__( 'Success', 'elementor' ),
174 139 'warning' => esc_html__( 'Warning', 'elementor' ),
175 140 'danger' => esc_html__( 'Danger', 'elementor' ),
176 141 ],
177 - 'default' => '',
178 - 'condition' => [
179 - 'progress_type!' => '', // a workaround to hide the control, unless it's in use (not default).
180 - ],
181 142 'separator' => 'before',
182 143 ]
183 144 );
184 145
@@ -193,9 +154,8 @@
193 154 ],
194 155 'dynamic' => [
195 156 'active' => true,
196 157 ],
197 - 'separator' => 'before',
198 158 ]
199 159 );
200 160
201 161 $this->add_control(
@@ -206,11 +166,8 @@
206 166 'label_on' => esc_html__( 'Show', 'elementor' ),
207 167 'label_off' => esc_html__( 'Hide', 'elementor' ),
208 168 'return_value' => 'show',
209 169 'default' => 'show',
210 - 'condition' => [
211 - 'percent!' => '',
212 - ],
213 170 ]
214 171 );
215 172
216 173 $this->add_control(
@@ -223,12 +180,20 @@
223 180 ],
224 181 'placeholder' => esc_html__( 'e.g. Web Designer', 'elementor' ),
225 182 'default' => esc_html__( 'Web Designer', 'elementor' ),
226 183 'label_block' => true,
227 - 'separator' => 'before',
228 184 ]
229 185 );
230 186
187 + $this->add_control(
188 + 'view',
189 + [
190 + 'label' => esc_html__( 'View', 'elementor' ),
191 + 'type' => Controls_Manager::HIDDEN,
192 + 'default' => 'traditional',
193 + ]
194 + );
195 +
231 196 $this->end_controls_section();
232 197
233 198 $this->start_controls_section(
234 199 'section_progress_style',
@@ -238,70 +203,8 @@
238 203 ]
239 204 );
240 205
241 206 $this->add_control(
242 - 'title_heading',
243 - [
244 - 'label' => esc_html__( 'Title', 'elementor' ),
245 - 'type' => Controls_Manager::HEADING,
246 - 'condition' => [
247 - 'title!' => '',
248 - ],
249 - ]
250 - );
251 -
252 - $this->add_control(
253 - 'title_color',
254 - [
255 - 'label' => esc_html__( 'Text Color', 'elementor' ),
256 - 'type' => Controls_Manager::COLOR,
257 - 'selectors' => [
258 - '{{WRAPPER}} .elementor-title' => 'color: {{VALUE}};',
259 - ],
260 - 'global' => [
261 - 'default' => Global_Colors::COLOR_PRIMARY,
262 - ],
263 - 'condition' => [
264 - 'title!' => '',
265 - ],
266 - ]
267 - );
268 -
269 - $this->add_group_control(
270 - Group_Control_Typography::get_type(),
271 - [
272 - 'name' => 'typography',
273 - 'selector' => '{{WRAPPER}} .elementor-title',
274 - 'global' => [
275 - 'default' => Global_Typography::TYPOGRAPHY_TEXT,
276 - ],
277 - 'condition' => [
278 - 'title!' => '',
279 - ],
280 - ]
281 - );
282 -
283 - $this->add_group_control(
284 - Group_Control_Text_Shadow::get_type(),
285 - [
286 - 'name' => 'title_shadow',
287 - 'selector' => '{{WRAPPER}} .elementor-title',
288 - 'condition' => [
289 - 'title!' => '',
290 - ],
291 - ]
292 - );
293 -
294 - $this->add_control(
295 - 'percentage_heading',
296 - [
297 - 'label' => esc_html__( 'Percentage', 'elementor' ),
298 - 'type' => Controls_Manager::HEADING,
299 - 'separator' => 'before',
300 - ]
301 - );
302 -
303 - $this->add_control(
304 207 'bar_color',
305 208 [
306 209 'label' => esc_html__( 'Color', 'elementor' ),
307 210 'type' => Controls_Manager::COLOR,
@@ -329,9 +232,8 @@
329 232 'bar_height',
330 233 [
331 234 'label' => esc_html__( 'Height', 'elementor' ),
332 235 'type' => Controls_Manager::SLIDER,
333 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
334 236 'selectors' => [
335 237 '{{WRAPPER}} .elementor-progress-bar' => 'height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
336 238 ],
337 239 ]
@@ -354,11 +256,8 @@
354 256 [
355 257 'label' => esc_html__( 'Inner Text', 'elementor' ),
356 258 'type' => Controls_Manager::HEADING,
357 259 'separator' => 'before',
358 - 'condition' => [
359 - 'inner_text!' => '',
360 - ],
361 260 ]
362 261 );
363 262
364 263 $this->add_control(
@@ -368,11 +267,8 @@
368 267 'type' => Controls_Manager::COLOR,
369 268 'selectors' => [
370 269 '{{WRAPPER}} .elementor-progress-bar' => 'color: {{VALUE}};',
371 270 ],
372 - 'condition' => [
373 - 'inner_text!' => '',
374 - ],
375 271 ]
376 272 );
377 273
378 274 $this->add_group_control(
@@ -382,11 +278,8 @@
382 278 'selector' => '{{WRAPPER}} .elementor-progress-bar',
383 279 'exclude' => [
384 280 'line_height',
385 281 ],
386 - 'condition' => [
387 - 'inner_text!' => '',
388 - ],
389 282 ]
390 283 );
391 284
392 285 $this->add_group_control(
@@ -393,14 +286,54 @@
393 286 Group_Control_Text_Shadow::get_type(),
394 287 [
395 288 'name' => 'bar_inner_shadow',
396 289 'selector' => '{{WRAPPER}} .elementor-progress-bar',
397 - 'condition' => [
398 - 'inner_text!' => '',
290 + ]
291 + );
292 +
293 + $this->end_controls_section();
294 +
295 + $this->start_controls_section(
296 + 'section_title',
297 + [
298 + 'label' => esc_html__( 'Title Style', 'elementor' ),
299 + 'tab' => Controls_Manager::TAB_STYLE,
300 + ]
301 + );
302 +
303 + $this->add_control(
304 + 'title_color',
305 + [
306 + 'label' => esc_html__( 'Text Color', 'elementor' ),
307 + 'type' => Controls_Manager::COLOR,
308 + 'selectors' => [
309 + '{{WRAPPER}} .elementor-title' => 'color: {{VALUE}};',
399 310 ],
311 + 'global' => [
312 + 'default' => Global_Colors::COLOR_PRIMARY,
313 + ],
400 314 ]
401 315 );
402 316
317 + $this->add_group_control(
318 + Group_Control_Typography::get_type(),
319 + [
320 + 'name' => 'typography',
321 + 'selector' => '{{WRAPPER}} .elementor-title',
322 + 'global' => [
323 + 'default' => Global_Typography::TYPOGRAPHY_TEXT,
324 + ],
325 + ]
326 + );
327 +
328 + $this->add_group_control(
329 + Group_Control_Text_Shadow::get_type(),
330 + [
331 + 'name' => 'title_shadow',
332 + 'selector' => '{{WRAPPER}} .elementor-title',
333 + ]
334 + );
335 +
403 336 $this->end_controls_section();
404 337 }
405 338
406 339 /**
@@ -414,42 +347,17 @@
414 347 */
415 348 protected function render() {
416 349 $settings = $this->get_settings_for_display();
417 350
418 - if ( empty( $settings['title'] ) && empty( $settings['percent']['size'] ) ) {
419 - return;
420 - }
421 -
422 - $progressbar_id = 'elementor-progress-bar-' . $this->get_id();
423 -
424 351 $progress_percentage = is_numeric( $settings['percent']['size'] ) ? $settings['percent']['size'] : '0';
425 352 if ( 100 < $progress_percentage ) {
426 353 $progress_percentage = 100;
427 354 }
428 355
429 - if ( ! Utils::is_empty( $settings['title'] ) ) {
356 + $this->add_render_attribute( 'title', 'class', 'elementor-title' );
430 357
431 - if ( 'yes' === $settings['title_display'] ) {
358 + $this->add_inline_editing_attributes( 'title' );
432 359
433 - $this->add_render_attribute(
434 - 'title',
435 - [
436 - 'class' => 'elementor-title',
437 - 'id' => $progressbar_id,
438 - ]
439 - );
440 -
441 - $this->add_inline_editing_attributes( 'title' );
442 -
443 - $this->add_render_attribute( 'wrapper', 'aria-labelledby', $progressbar_id );
444 -
445 - } else {
446 -
447 - $this->add_render_attribute( 'wrapper', 'aria-label', $settings['title'] );
448 -
449 - }
450 - }
451 -
452 360 $this->add_render_attribute(
453 361 'wrapper',
454 362 [
455 363 'class' => 'elementor-progress-wrapper',
@@ -479,17 +387,17 @@
479 387 $this->add_render_attribute( 'inner_text', 'class', 'elementor-progress-text' );
480 388
481 389 $this->add_inline_editing_attributes( 'inner_text' );
482 390
483 - if ( ! Utils::is_empty( $settings['title'] ) && 'yes' === $settings['title_display'] ) { ?>
391 + if ( ! Utils::is_empty( $settings['title'] ) ) { ?>
484 392 <<?php Utils::print_validated_html_tag( $settings['title_tag'] ); ?> <?php $this->print_render_attribute_string( 'title' ); ?>>
485 - <?php echo wp_kses_post( $settings['title'] ); ?>
393 + <?php $this->print_unescaped_setting( 'title' ); ?>
486 394 </<?php Utils::print_validated_html_tag( $settings['title_tag'] ); ?>>
487 395 <?php } ?>
488 396
489 397 <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
490 398 <div <?php $this->print_render_attribute_string( 'progress-bar' ); ?>>
491 - <span <?php $this->print_render_attribute_string( 'inner_text' ); ?>><?php echo wp_kses_post( $settings['inner_text'] ); ?></span>
399 + <span <?php $this->print_render_attribute_string( 'inner_text' ); ?>><?php $this->print_unescaped_setting( 'inner_text' ); ?></span>
492 400 <?php if ( 'show' === $settings['display_percentage'] ) { ?>
493 401 <span class="elementor-progress-percentage"><?php echo $progress_percentage; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>%</span>
494 402 <?php } ?>
495 403 </div>
@@ -507,14 +415,9 @@
507 415 */
508 416 protected function content_template() {
509 417 ?>
510 418 <#
511 - if ( '' === settings.title && '' === settings.percent.size ) {
512 - return;
513 - }
514 -
515 419 const title_tag = elementor.helpers.validateHTMLTag( settings.title_tag );
516 - const progressbar_id = 'elementor-progress-bar-<?php echo esc_attr( $this->get_id() ); ?>';
517 420
518 421 let progress_percentage = 0;
519 422 if ( ! isNaN( settings.percent.size ) ) {
520 423 progress_percentage = 100 < settings.percent.size ? 100 : settings.percent.size;
@@ -519,31 +422,12 @@
519 422 if ( ! isNaN( settings.percent.size ) ) {
520 423 progress_percentage = 100 < settings.percent.size ? 100 : settings.percent.size;
521 424 }
522 425
523 - if ( settings.title ) {
426 + view.addRenderAttribute( 'title', 'class', 'elementor-title' );
524 427
525 - if ( 'yes' === settings.title_display ) {
428 + view.addInlineEditingAttributes( 'title' );
526 429
527 - view.addRenderAttribute(
528 - 'title',
529 - {
530 - 'class': 'elementor-title',
531 - 'id': progressbar_id,
532 - }
533 - );
534 -
535 - view.addInlineEditingAttributes( 'title' );
536 -
537 - view.addRenderAttribute( 'progressWrapper', 'aria-labelledby', progressbar_id );
538 -
539 - } else {
540 -
541 - view.addRenderAttribute( 'progressWrapper', 'aria-label', settings.title );
542 -
543 - }
544 - }
545 -
546 430 view.addRenderAttribute(
547 431 'progressWrapper',
548 432 {
549 433 'class': [ 'elementor-progress-wrapper', 'progress-' + settings.progress_type ],
@@ -561,14 +445,14 @@
561 445 view.addRenderAttribute( 'inner_text', 'class', 'elementor-progress-text' );
562 446
563 447 view.addInlineEditingAttributes( 'inner_text' );
564 448 #>
565 - <# if ( settings.title && 'yes' === settings.title_display ) { #>
566 - <{{ title_tag }} {{{ view.getRenderAttributeString( 'title' ) }}}>{{ settings.title }}</{{ title_tag }}>
449 + <# if ( settings.title ) { #>
450 + <{{ title_tag }} {{{ view.getRenderAttributeString( 'title' ) }}}>{{{ settings.title }}}</{{ title_tag }}>
567 451 <# } #>
568 452 <div {{{ view.getRenderAttributeString( 'progressWrapper' ) }}}>
569 453 <div class="elementor-progress-bar" data-max="{{ progress_percentage }}">
570 - <span {{{ view.getRenderAttributeString( 'inner_text' ) }}}>{{ settings.inner_text }}</span>
454 + <span {{{ view.getRenderAttributeString( 'inner_text' ) }}}>{{{ settings.inner_text }}}</span>
571 455 <# if ( 'show' === settings.display_percentage ) { #>
572 456 <span class="elementor-progress-percentage">{{{ progress_percentage }}}%</span>
573 457 <# } #>
574 458 </div>
@@ -573,35 +457,6 @@
573 457 <# } #>
574 458 </div>
575 459 </div>
576 460 <?php
577 - }
578 -
579 - public function render_markdown(): string {
580 - $settings = $this->get_settings_for_display();
581 - $title = Utils::html_to_plain_text( $settings['title'] ?? '' );
582 - $inner_text = Utils::html_to_plain_text( $settings['inner_text'] ?? '' );
583 - $percent = $settings['percent']['size'] ?? ( $settings['percent'] ?? '' );
584 -
585 - $parts = [];
586 -
587 - if ( ! empty( $title ) ) {
588 - $parts[] = $title;
589 - }
590 -
591 - if ( ! empty( $inner_text ) ) {
592 - $parts[] = $inner_text;
593 - }
594 -
595 - if ( empty( $parts ) && empty( $percent ) ) {
596 - return '';
597 - }
598 -
599 - $label = implode( ' - ', $parts );
600 -
601 - if ( ! empty( $percent ) ) {
602 - return ! empty( $label ) ? $label . ': ' . $percent . '%' : $percent . '%';
603 - }
604 -
605 - return $label;
606 461 }
607 462 }