PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.3
Elementor Website Builder – more than just a page builder v3.0.3
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
elementor / includes / base / widget-base.php

widget-base.php in Elementor Website Builder – more than just a page builder 3.0.3, at includes/base/widget-base.php

889 lines 22.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor widget base.
10 *
11 * An abstract class to register new Elementor widgets. It extended the
12 * `Element_Base` class to inherit its properties.
13 *
14 * This abstract class must be extended in order to register new widgets.
15 *
16 * @since 1.0.0
17 * @abstract
18 */
19 abstract class Widget_Base extends Element_Base {
20
21 /**
22 * Whether the widget has content.
23 *
24 * Used in cases where the widget has no content. When widgets uses only
25 * skins to display dynamic content generated on the server. For example the
26 * posts widget in Elementor Pro. Default is true, the widget has content
27 * template.
28 *
29 * @access protected
30 *
31 * @var bool
32 */
33 protected $_has_template_content = true;
34
35 /**
36 * Get element type.
37 *
38 * Retrieve the element type, in this case `widget`.
39 *
40 * @since 1.0.0
41 * @access public
42 * @static
43 *
44 * @return string The type.
45 */
46 public static function get_type() {
47 return 'widget';
48 }
49
50 /**
51 * Get widget icon.
52 *
53 * Retrieve the widget icon.
54 *
55 * @since 1.0.0
56 * @access public
57 *
58 * @return string Widget icon.
59 */
60 public function get_icon() {
61 return 'eicon-apps';
62 }
63
64 /**
65 * Get widget keywords.
66 *
67 * Retrieve the widget keywords.
68 *
69 * @since 1.0.10
70 * @access public
71 *
72 * @return array Widget keywords.
73 */
74 public function get_keywords() {
75 return [];
76 }
77
78 /**
79 * Get widget categories.
80 *
81 * Retrieve the widget categories.
82 *
83 * @since 1.0.10
84 * @access public
85 *
86 * @return array Widget categories.
87 */
88 public function get_categories() {
89 return [ 'general' ];
90 }
91
92 /**
93 * Widget base constructor.
94 *
95 * Initializing the widget base class.
96 *
97 * @since 1.0.0
98 * @access public
99 *
100 * @throws \Exception If arguments are missing when initializing a full widget
101 * instance.
102 *
103 * @param array $data Widget data. Default is an empty array.
104 * @param array|null $args Optional. Widget default arguments. Default is null.
105 */
106 public function __construct( $data = [], $args = null ) {
107 parent::__construct( $data, $args );
108
109 $is_type_instance = $this->is_type_instance();
110
111 if ( ! $is_type_instance && null === $args ) {
112 throw new \Exception( '`$args` argument is required when initializing a full widget instance.' );
113 }
114
115 if ( $is_type_instance ) {
116 $this->_register_skins();
117
118 $widget_name = $this->get_name();
119
120 /**
121 * Widget skin init.
122 *
123 * Fires when Elementor widget is being initialized.
124 *
125 * The dynamic portion of the hook name, `$widget_name`, refers to the widget name.
126 *
127 * @since 1.0.0
128 *
129 * @param Widget_Base $this The current widget.
130 */
131 do_action( "elementor/widget/{$widget_name}/skins_init", $this );
132 }
133 }
134
135 /**
136 * Get stack.
137 *
138 * Retrieve the widget stack of controls.
139 *
140 * @since 1.9.2
141 * @access public
142 *
143 * @param bool $with_common_controls Optional. Whether to include the common controls. Default is true.
144 *
145 * @return array Widget stack of controls.
146 */
147 public function get_stack( $with_common_controls = true ) {
148 $stack = parent::get_stack();
149
150 if ( $with_common_controls && 'common' !== $this->get_unique_name() ) {
151 /** @var Widget_Common $common_widget */
152 $common_widget = Plugin::$instance->widgets_manager->get_widget_types( 'common' );
153
154 $stack['controls'] = array_merge( $stack['controls'], $common_widget->get_controls() );
155
156 $stack['tabs'] = array_merge( $stack['tabs'], $common_widget->get_tabs_controls() );
157 }
158
159 return $stack;
160 }
161
162 /**
163 * Get widget controls pointer index.
164 *
165 * Retrieve widget pointer index where the next control should be added.
166 *
167 * While using injection point, it will return the injection point index. Otherwise index of the last control of the
168 * current widget itself without the common controls, plus one.
169 *
170 * @since 1.9.2
171 * @access public
172 *
173 * @return int Widget controls pointer index.
174 */
175 public function get_pointer_index() {
176 $injection_point = $this->get_injection_point();
177
178 if ( null !== $injection_point ) {
179 return $injection_point['index'];
180 }
181
182 return count( $this->get_stack( false )['controls'] );
183 }
184
185 /**
186 * Show in panel.
187 *
188 * Whether to show the widget in the panel or not. By default returns true.
189 *
190 * @since 1.0.0
191 * @access public
192 *
193 * @return bool Whether to show the widget in the panel or not.
194 */
195 public function show_in_panel() {
196 return true;
197 }
198
199 /**
200 * Start widget controls section.
201 *
202 * Used to add a new section of controls to the widget. Regular controls and
203 * skin controls.
204 *
205 * Note that when you add new controls to widgets they must be wrapped by
206 * `start_controls_section()` and `end_controls_section()`.
207 *
208 * @since 1.0.0
209 * @access public
210 *
211 * @param string $section_id Section ID.
212 * @param array $args Section arguments Optional.
213 */
214 public function start_controls_section( $section_id, array $args = [] ) {
215 parent::start_controls_section( $section_id, $args );
216
217 static $is_first_section = true;
218
219 if ( $is_first_section ) {
220 $this->register_skin_control();
221
222 $is_first_section = false;
223 }
224 }
225
226 /**
227 * Register the Skin Control if the widget has skins.
228 *
229 * An internal method that is used to add a skin control to the widget.
230 * Added at the top of the controls section.
231 *
232 * @since 2.0.0
233 * @access private
234 */
235 private function register_skin_control() {
236 $skins = $this->get_skins();
237 if ( ! empty( $skins ) ) {
238 $skin_options = [];
239
240 if ( $this->_has_template_content ) {
241 $skin_options[''] = __( 'Default', 'elementor' );
242 }
243
244 foreach ( $skins as $skin_id => $skin ) {
245 $skin_options[ $skin_id ] = $skin->get_title();
246 }
247
248 // Get the first item for default value
249 $default_value = array_keys( $skin_options );
250 $default_value = array_shift( $default_value );
251
252 if ( 1 >= count( $skin_options ) ) {
253 $this->add_control(
254 '_skin',
255 [
256 'label' => __( 'Skin', 'elementor' ),
257 'type' => Controls_Manager::HIDDEN,
258 'default' => $default_value,
259 ]
260 );
261 } else {
262 $this->add_control(
263 '_skin',
264 [
265 'label' => __( 'Skin', 'elementor' ),
266 'type' => Controls_Manager::SELECT,
267 'default' => $default_value,
268 'options' => $skin_options,
269 ]
270 );
271 }
272 }
273 }
274
275 /**
276 * Register widget skins.
277 *
278 * This method is activated while initializing the widget base class. It is
279 * used to assign skins to widgets with `add_skin()` method.
280 *
281 * Usage:
282 *
283 * protected function _register_skins() {
284 * $this->add_skin( new Skin_Classic( $this ) );
285 * }
286 *
287 * @since 1.7.12
288 * @access protected
289 */
290 protected function _register_skins() {}
291
292 /**
293 * Get initial config.
294 *
295 * Retrieve the current widget initial configuration.
296 *
297 * Adds more configuration on top of the controls list, the tabs assigned to
298 * the control, element name, type, icon and more. This method also adds
299 * widget type, keywords and categories.
300 *
301 * @since 2.9.0
302 * @access protected
303 *
304 * @return array The initial widget config.
305 */
306 protected function get_initial_config() {
307 $config = [
308 'widget_type' => $this->get_name(),
309 'keywords' => $this->get_keywords(),
310 'categories' => $this->get_categories(),
311 'html_wrapper_class' => $this->get_html_wrapper_class(),
312 'show_in_panel' => $this->show_in_panel(),
313 ];
314
315 $stack = Plugin::$instance->controls_manager->get_element_stack( $this );
316
317 if ( $stack ) {
318 $config['controls'] = $this->get_stack( false )['controls'];
319 $config['tabs_controls'] = $this->get_tabs_controls();
320 }
321
322 return array_merge( parent::get_initial_config(), $config );
323 }
324
325 /**
326 * @since 2.3.1
327 * @access protected
328 */
329 protected function should_print_empty() {
330 return false;
331 }
332
333 /**
334 * Print widget content template.
335 *
336 * Used to generate the widget content template on the editor, using a
337 * Backbone JavaScript template.
338 *
339 * @since 2.0.0
340 * @access protected
341 *
342 * @param string $template_content Template content.
343 */
344 protected function print_template_content( $template_content ) {
345 ?>
346 <div class="elementor-widget-container">
347 <?php
348 echo $template_content; // XSS ok.
349 ?>
350 </div>
351 <?php
352 }
353
354 /**
355 * Parse text editor.
356 *
357 * Parses the content from rich text editor with shortcodes, oEmbed and
358 * filtered data.
359 *
360 * @since 1.0.0
361 * @access protected
362 *
363 * @param string $content Text editor content.
364 *
365 * @return string Parsed content.
366 */
367 protected function parse_text_editor( $content ) {
368 /** This filter is documented in wp-includes/widgets/class-wp-widget-text.php */
369 $content = apply_filters( 'widget_text', $content, $this->get_settings() );
370
371 $content = shortcode_unautop( $content );
372 $content = do_shortcode( $content );
373 $content = wptexturize( $content );
374
375 if ( $GLOBALS['wp_embed'] instanceof \WP_Embed ) {
376 $content = $GLOBALS['wp_embed']->autoembed( $content );
377 }
378
379 return $content;
380 }
381
382 /**
383 * Get HTML wrapper class.
384 *
385 * Retrieve the widget container class. Can be used to override the
386 * container class for specific widgets.
387 *
388 * @since 2.0.9
389 * @access protected
390 */
391 protected function get_html_wrapper_class() {
392 return 'elementor-widget-' . $this->get_name();
393 }
394
395 /**
396 * Add widget render attributes.
397 *
398 * Used to add attributes to the current widget wrapper HTML tag.
399 *
400 * @since 1.0.0
401 * @access protected
402 */
403 protected function _add_render_attributes() {
404 parent::_add_render_attributes();
405
406 $this->add_render_attribute(
407 '_wrapper', 'class', [
408 'elementor-widget',
409 $this->get_html_wrapper_class(),
410 ]
411 );
412
413 $settings = $this->get_settings();
414
415 $this->add_render_attribute( '_wrapper', 'data-widget_type', $this->get_name() . '.' . ( ! empty( $settings['_skin'] ) ? $settings['_skin'] : 'default' ) );
416 }
417
418 /**
419 * Add lightbox data to image link.
420 *
421 * Used to add lightbox data attributes to image link HTML.
422 *
423 * @since 2.9.1
424 * @access public
425 *
426 * @param string $link_html Image link HTML.
427 * @param string $id Attachment id.
428 *
429 * @return string Image link HTML with lightbox data attributes.
430 */
431 public function add_lightbox_data_to_image_link( $link_html, $id ) {
432 $settings = $this->get_settings_for_display();
433 $open_lightbox = isset( $settings['open_lightbox'] ) ? $settings['open_lightbox'] : null;
434
435 if ( Plugin::$instance->editor->is_edit_mode() ) {
436 $this->add_render_attribute( 'link', 'class', 'elementor-clickable', true );
437 }
438
439 $this->add_lightbox_data_attributes( 'link', $id, $open_lightbox, $this->get_id(), true );
440 return preg_replace( '/^<a/', '<a ' . $this->get_render_attribute_string( 'link' ), $link_html );
441 }
442
443 /**
444 * Add Light-Box attributes.
445 *
446 * Used to add Light-Box-related data attributes to links that open media files.
447 *
448 * @param array|string $element The link HTML element.
449 * @param int $id The ID of the image
450 * @param string $lightbox_setting_key The setting key that dictates weather to open the image in a lightbox
451 * @param string $group_id Unique ID for a group of lightbox images
452 * @param bool $overwrite Optional. Whether to overwrite existing
453 * attribute. Default is false, not to overwrite.
454 *
455 * @return Widget_Base Current instance of the widget.
456 * @since 2.9.0
457 * @access public
458 *
459 */
460 public function add_lightbox_data_attributes( $element, $id = null, $lightbox_setting_key = null, $group_id = null, $overwrite = false ) {
461 $kit = Plugin::$instance->kits_manager->get_active_kit();
462
463 $is_global_image_lightbox_enabled = 'yes' === $kit->get_settings( 'global_image_lightbox' );
464
465 if ( 'no' === $lightbox_setting_key ) {
466 if ( $is_global_image_lightbox_enabled ) {
467 $this->add_render_attribute( $element, 'data-elementor-open-lightbox', 'no' );
468 }
469
470 return $this;
471 }
472
473 if ( 'yes' !== $lightbox_setting_key && ! $is_global_image_lightbox_enabled ) {
474 return $this;
475 }
476
477 $attributes['data-elementor-open-lightbox'] = 'yes';
478
479 if ( $group_id ) {
480 $attributes['data-elementor-lightbox-slideshow'] = $group_id;
481 }
482
483 if ( $id ) {
484 $lightbox_image_attributes = Plugin::$instance->images_manager->get_lightbox_image_attributes( $id );
485
486 if ( isset( $lightbox_image_attributes['title'] ) ) {
487 $attributes['data-elementor-lightbox-title'] = $lightbox_image_attributes['title'];
488 }
489
490 if ( isset( $lightbox_image_attributes['description'] ) ) {
491 $attributes['data-elementor-lightbox-description'] = $lightbox_image_attributes['description'];
492 }
493 }
494
495 $this->add_render_attribute( $element, $attributes, null, $overwrite );
496
497 return $this;
498 }
499
500 /**
501 * Render widget output on the frontend.
502 *
503 * Used to generate the final HTML displayed on the frontend.
504 *
505 * Note that if skin is selected, it will be rendered by the skin itself,
506 * not the widget.
507 *
508 * @since 1.0.0
509 * @access public
510 */
511 public function render_content() {
512 /**
513 * Before widget render content.
514 *
515 * Fires before Elementor widget is being rendered.
516 *
517 * @since 1.0.0
518 *
519 * @param Widget_Base $this The current widget.
520 */
521 do_action( 'elementor/widget/before_render_content', $this );
522
523 ob_start();
524
525 $skin = $this->get_current_skin();
526 if ( $skin ) {
527 $skin->set_parent( $this );
528 $skin->render();
529 } else {
530 $this->render();
531 }
532
533 $widget_content = ob_get_clean();
534
535 if ( empty( $widget_content ) ) {
536 return;
537 }
538 ?>
539 <div class="elementor-widget-container">
540 <?php
541
542 /**
543 * Render widget content.
544 *
545 * Filters the widget content before it's rendered.
546 *
547 * @since 1.0.0
548 *
549 * @param string $widget_content The content of the widget.
550 * @param Widget_Base $this The widget.
551 */
552 $widget_content = apply_filters( 'elementor/widget/render_content', $widget_content, $this );
553
554 echo $widget_content; // XSS ok.
555 ?>
556 </div>
557 <?php
558 }
559
560 /**
561 * Render widget plain content.
562 *
563 * Elementor saves the page content in a unique way, but it's not the way
564 * WordPress saves data. This method is used to save generated HTML to the
565 * database as plain content the WordPress way.
566 *
567 * When rendering plain content, it allows other WordPress plugins to
568 * interact with the content - to search, check SEO and other purposes. It
569 * also allows the site to keep working even if Elementor is deactivated.
570 *
571 * Note that if the widget uses shortcodes to display the data, the best
572 * practice is to return the shortcode itself.
573 *
574 * Also note that if the widget don't display any content it should return
575 * an empty string. For example Elementor Pro Form Widget uses this method
576 * to return an empty string because there is no content to return. This way
577 * if Elementor Pro will be deactivated there won't be any form to display.
578 *
579 * @since 1.0.0
580 * @access public
581 */
582 public function render_plain_content() {
583 $this->render_content();
584 }
585
586 /**
587 * Before widget rendering.
588 *
589 * Used to add stuff before the widget `_wrapper` element.
590 *
591 * @since 1.0.0
592 * @access public
593 */
594 public function before_render() {
595 ?>
596 <div <?php $this->print_render_attribute_string( '_wrapper' ); ?>>
597 <?php
598 }
599
600 /**
601 * After widget rendering.
602 *
603 * Used to add stuff after the widget `_wrapper` element.
604 *
605 * @since 1.0.0
606 * @access public
607 */
608 public function after_render() {
609 ?>
610 </div>
611 <?php
612 }
613
614 /**
615 * Get the element raw data.
616 *
617 * Retrieve the raw element data, including the id, type, settings, child
618 * elements and whether it is an inner element.
619 *
620 * The data with the HTML used always to display the data, but the Elementor
621 * editor uses the raw data without the HTML in order not to render the data
622 * again.
623 *
624 * @since 1.0.0
625 * @access public
626 *
627 * @param bool $with_html_content Optional. Whether to return the data with
628 * HTML content or without. Used for caching.
629 * Default is false, without HTML.
630 *
631 * @return array Element raw data.
632 */
633 public function get_raw_data( $with_html_content = false ) {
634 $data = parent::get_raw_data( $with_html_content );
635
636 unset( $data['isInner'] );
637
638 $data['widgetType'] = $this->get_data( 'widgetType' );
639
640 if ( $with_html_content ) {
641 ob_start();
642
643 $this->render_content();
644
645 $data['htmlCache'] = ob_get_clean();
646 }
647
648 return $data;
649 }
650
651 /**
652 * Print widget content.
653 *
654 * Output the widget final HTML on the frontend.
655 *
656 * @since 1.0.0
657 * @access protected
658 */
659 protected function _print_content() {
660 $this->render_content();
661 }
662
663 /**
664 * Get default data.
665 *
666 * Retrieve the default widget data. Used to reset the data on initialization.
667 *
668 * @since 1.0.0
669 * @access protected
670 *
671 * @return array Default data.
672 */
673 protected function get_default_data() {
674 $data = parent::get_default_data();
675
676 $data['widgetType'] = '';
677
678 return $data;
679 }
680
681 /**
682 * Get default child type.
683 *
684 * Retrieve the widget child type based on element data.
685 *
686 * @since 1.0.0
687 * @access protected
688 *
689 * @param array $element_data Widget ID.
690 *
691 * @return array|false Child type or false if it's not a valid widget.
692 */
693 protected function _get_default_child_type( array $element_data ) {
694 return Plugin::$instance->elements_manager->get_element_types( 'section' );
695 }
696
697 /**
698 * Get repeater setting key.
699 *
700 * Retrieve the unique setting key for the current repeater item. Used to connect the current element in the
701 * repeater to it's settings model and it's control in the panel.
702 *
703 * PHP usage (inside `Widget_Base::render()` method):
704 *
705 * $tabs = $this->get_settings( 'tabs' );
706 * foreach ( $tabs as $index => $item ) {
707 * $tab_title_setting_key = $this->get_repeater_setting_key( 'tab_title', 'tabs', $index );
708 * $this->add_inline_editing_attributes( $tab_title_setting_key, 'none' );
709 * echo '<div ' . $this->get_render_attribute_string( $tab_title_setting_key ) . '>' . $item['tab_title'] . '</div>';
710 * }
711 *
712 * @since 1.8.0
713 * @access protected
714 *
715 * @param string $setting_key The current setting key inside the repeater item (e.g. `tab_title`).
716 * @param string $repeater_key The repeater key containing the array of all the items in the repeater (e.g. `tabs`).
717 * @param int $repeater_item_index The current item index in the repeater array (e.g. `3`).
718 *
719 * @return string The repeater setting key (e.g. `tabs.3.tab_title`).
720 */
721 protected function get_repeater_setting_key( $setting_key, $repeater_key, $repeater_item_index ) {
722 return implode( '.', [ $repeater_key, $repeater_item_index, $setting_key ] );
723 }
724
725 /**
726 * Add inline editing attributes.
727 *
728 * Define specific area in the element to be editable inline. The element can have several areas, with this method
729 * you can set the area inside the element that can be edited inline. You can also define the type of toolbar the
730 * user will see, whether it will be a basic toolbar or an advanced one.
731 *
732 * Note: When you use wysiwyg control use the advanced toolbar, with textarea control use the basic toolbar. Text
733 * control should not have toolbar.
734 *
735 * PHP usage (inside `Widget_Base::render()` method):
736 *
737 * $this->add_inline_editing_attributes( 'text', 'advanced' );
738 * echo '<div ' . $this->get_render_attribute_string( 'text' ) . '>' . $this->get_settings( 'text' ) . '</div>';
739 *
740 * @since 1.8.0
741 * @access protected
742 *
743 * @param string $key Element key.
744 * @param string $toolbar Optional. Toolbar type. Accepted values are `advanced`, `basic` or `none`. Default is
745 * `basic`.
746 */
747 protected function add_inline_editing_attributes( $key, $toolbar = 'basic' ) {
748 if ( ! Plugin::$instance->editor->is_edit_mode() ) {
749 return;
750 }
751
752 $this->add_render_attribute( $key, [
753 'class' => 'elementor-inline-editing',
754 'data-elementor-setting-key' => $key,
755 ] );
756
757 if ( 'basic' !== $toolbar ) {
758 $this->add_render_attribute( $key, [
759 'data-elementor-inline-editing-toolbar' => $toolbar,
760 ] );
761 }
762 }
763
764 /**
765 * Add new skin.
766 *
767 * Register new widget skin to allow the user to set custom designs. Must be
768 * called inside the `_register_skins()` method.
769 *
770 * @since 1.0.0
771 * @access public
772 *
773 * @param Skin_Base $skin Skin instance.
774 */
775 public function add_skin( Skin_Base $skin ) {
776 Plugin::$instance->skins_manager->add_skin( $this, $skin );
777 }
778
779 /**
780 * Get single skin.
781 *
782 * Retrieve a single skin based on skin ID, from all the skin assigned to
783 * the widget. If the skin does not exist or not assigned to the widget,
784 * return false.
785 *
786 * @since 1.0.0
787 * @access public
788 *
789 * @param string $skin_id Skin ID.
790 *
791 * @return string|false Single skin, or false.
792 */
793 public function get_skin( $skin_id ) {
794 $skins = $this->get_skins();
795 if ( isset( $skins[ $skin_id ] ) ) {
796 return $skins[ $skin_id ];
797 }
798
799 return false;
800 }
801
802 /**
803 * Get current skin ID.
804 *
805 * Retrieve the ID of the current skin.
806 *
807 * @since 1.0.0
808 * @access public
809 *
810 * @return string Current skin.
811 */
812 public function get_current_skin_id() {
813 return $this->get_settings( '_skin' );
814 }
815
816 /**
817 * Get current skin.
818 *
819 * Retrieve the current skin, or if non exist return false.
820 *
821 * @since 1.0.0
822 * @access public
823 *
824 * @return Skin_Base|false Current skin or false.
825 */
826 public function get_current_skin() {
827 return $this->get_skin( $this->get_current_skin_id() );
828 }
829
830 /**
831 * Remove widget skin.
832 *
833 * Unregister an existing skin and remove it from the widget.
834 *
835 * @since 1.0.0
836 * @access public
837 *
838 * @param string $skin_id Skin ID.
839 *
840 * @return \WP_Error|true Whether the skin was removed successfully from the widget.
841 */
842 public function remove_skin( $skin_id ) {
843 return Plugin::$instance->skins_manager->remove_skin( $this, $skin_id );
844 }
845
846 /**
847 * Get widget skins.
848 *
849 * Retrieve all the skin assigned to the widget.
850 *
851 * @since 1.0.0
852 * @access public
853 *
854 * @return Skin_Base[]
855 */
856 public function get_skins() {
857 return Plugin::$instance->skins_manager->get_skins( $this );
858 }
859
860 /**
861 * @param string $plugin_title Plugin's title
862 * @param string $since Plugin version widget was deprecated
863 * @param string $last Plugin version in which the widget will be removed
864 * @param string $replacement Widget replacement
865 */
866 protected function deprecated_notice( $plugin_title, $since, $last = '', $replacement = '' ) {
867 $this->start_controls_section( 'Deprecated',
868 [
869 'label' => __( 'Deprecated', 'elementor' ),
870 ]
871 );
872
873 $this->add_control(
874 'deprecated_notice',
875 [
876 'type' => Controls_Manager::DEPRECATED_NOTICE,
877 'widget' => $this->get_title(),
878 'since' => $since,
879 'last' => $last,
880 'plugin' => $plugin_title,
881 'replacement' => $replacement,
882 ]
883 );
884
885 $this->end_controls_section();
886
887 }
888 }
889