PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.0
Elementor Website Builder – more than just a page builder v4.1.0
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 / controls / notice.php

notice.php in Elementor Website Builder – more than just a page builder 4.1.0, at includes/controls/notice.php

116 lines 4.1 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 Notice control.
10 *
11 * A base control specific for creating Notices in the Editor panels.
12 *
13 * @since 3.19.0
14 */
15 class Control_Notice extends Base_UI_Control {
16
17 /**
18 * Get notice control type.
19 *
20 * Retrieve the control type, in this case `notice`.
21 *
22 * @since 3.19.0
23 * @access public
24 *
25 * @return string Control type.
26 */
27 public function get_type() {
28 return 'notice';
29 }
30
31 /**
32 * Render notice control output in the editor.
33 *
34 * Used to generate the control HTML in the editor using Underscore JS
35 * template. The variables for the class are available using `data` JS
36 * object.
37 *
38 * @since 3.19.0
39 * @access public
40 */
41 public function content_template() {
42 ?>
43 <#
44 if ( ! data.shouldRenderNotice ) {
45 return;
46 }
47
48 const validNoticeTypes = [ 'info', 'success', 'warning', 'danger' ];
49 const showIcon = validNoticeTypes.includes( data.notice_type );
50 data.content = elementor.compileTemplate( data.content, { view } );
51 #>
52 <div class="elementor-control-notice elementor-control-notice-type-{{ data.notice_type }}">
53 <# if ( showIcon && data.icon ) { #>
54 <div class="elementor-control-notice-icon">
55 <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
56 <path d="M2.25 9H3M9 2.25V3M15 9H15.75M4.2 4.2L4.725 4.725M13.8 4.2L13.275 4.725M7.27496 12.75H10.725M6.75 12C6.12035 11.5278 5.65525 10.8694 5.42057 10.1181C5.1859 9.36687 5.19355 8.56082 5.44244 7.81415C5.69133 7.06748 6.16884 6.41804 6.80734 5.95784C7.44583 5.49764 8.21294 5.25 9 5.25C9.78706 5.25 10.5542 5.49764 11.1927 5.95784C11.8312 6.41804 12.3087 7.06748 12.5576 7.81415C12.8065 8.56082 12.8141 9.36687 12.5794 10.1181C12.3448 10.8694 11.8796 11.5278 11.25 12C10.9572 12.2899 10.7367 12.6446 10.6064 13.0355C10.4761 13.4264 10.4397 13.8424 10.5 14.25C10.5 14.6478 10.342 15.0294 10.0607 15.3107C9.77936 15.592 9.39782 15.75 9 15.75C8.60218 15.75 8.22064 15.592 7.93934 15.3107C7.65804 15.0294 7.5 14.6478 7.5 14.25C7.56034 13.8424 7.52389 13.4264 7.3936 13.0355C7.2633 12.6446 7.04282 12.2899 6.75 12Z" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
57 </svg>
58 </div>
59 <# } #>
60 <div class="elementor-control-notice-main">
61 <# if ( data.heading ) { #>
62 <div class="elementor-control-notice-main-heading">{{{ data.heading }}}</div>
63 <# } #>
64 <# if ( data.content ) { #>
65 <div class="elementor-control-notice-main-content">{{{ data.content }}}</div>
66 <# } #>
67 <# if ( data.button_text || data.button_text2 ) { #>
68 <div class="elementor-control-notice-main-actions">
69 <# if ( data.button_text || data.button_event ) { #>
70 <button type="button" class="e-btn e-{{{ data.notice_type }}} e-btn-1" data-event="{{{ data.button_event }}}">
71 {{{ data.button_text }}}
72 </button>
73 <# } #>
74 <# if ( data.button_text2 || data.button_event2 ) { #>
75 <button type="button" class="e-btn e-{{{ data.notice_type }}} e-btn-2" data-event="{{{ data.button_event2 }}}">
76 {{{ data.button_text2 }}}
77 </button>
78 <# } #>
79 </div>
80 <# } #>
81 </div>
82 <# if ( data.dismissible ) { #>
83 <button class="elementor-control-notice-dismiss tooltip-target" data-tooltip="<?php echo esc_attr__( 'Don’t show again.', 'elementor' ); ?>" aria-label="<?php echo esc_attr__( 'Don’t show again.', 'elementor' ); ?>">
84 <i class="eicon eicon-close" aria-hidden="true"></i>
85 </button>
86 <# } #>
87 </div>
88 <?php
89 }
90
91 /**
92 * Get notice control default settings.
93 *
94 * Retrieve the default settings of the notice control. Used to return the
95 * default settings while initializing the notice control.
96 *
97 * @since 3.19.0
98 * @access protected
99 *
100 * @return array Control default settings.
101 */
102 protected function get_default_settings() {
103 return [
104 'notice_type' => '', // info, success, warning, danger
105 'icon' => true,
106 'dismissible' => false,
107 'heading' => '',
108 'content' => '',
109 'button_text' => '',
110 'button_event' => '',
111 'button_text2' => '',
112 'button_event2' => '',
113 ];
114 }
115 }
116