PluginProbe
Booking Calendar / 11.8
Booking Calendar v11.8
11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 10.11.3 All 202 releases
booking / includes / _functions / is_dismissed.php

is_dismissed.php in Booking Calendar 11.8, at includes/_functions/is_dismissed.php

188 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Booking Calendar
5 * @subpackage Is Dismissed
6 * @category Functions
7 *
8 * @author wpdevelop
9 * @link https://wpbookingcalendar.com/
10 * @email info@wpbookingcalendar.com
11 *
12 * @modified 2024-09-03
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17
18 // =====================================================================================================================
19 // == Is Dismissed ==
20 // =====================================================================================================================
21
22
23 /**
24 * Only check if Dismised or visible this section
25 *
26 * @param $element_html_id
27 *
28 * @return bool
29 */
30 function wpbc_is_dismissed_panel_visible( $element_html_id ) {
31 return ( '1' != get_user_option( 'booking_win_' . $element_html_id ) );
32
33 }
34
35 /**
36 * Show dismiss close button for specific HTML section
37 *
38 * @param string $element_html_id - ID of HTML selection to dismiss
39 * @param array $params - array( 'title' => 'Dismiss', 'is_apply_in_demo' => false ) )
40 *
41 * @return bool
42 *
43 * Examples:
44 * $is_dismissed = wpbc_is_dismissed( 'wpbc_dashboard_section_video_f' );
45 *
46 * $is_dismissed = wpbc_is_dismissed( 'html_id', array( 'is_apply_in_demo' => $is_apply_in_demo ) );
47 *
48 * $is_panel_visible = wpbc_is_dismissed( 'wpbc-panel-get-started', array(
49 * 'title' => '<i class="menu_icon icon-1x wpbc_icn_close"></i> ',
50 * 'hint' => __( 'Dismiss', 'booking' ),
51 * 'class' => 'wpbc_panel_get_started_dismiss',
52 * 'css' => ''
53 * ));
54 */
55 function wpbc_is_dismissed( $element_html_id, $params = array() ){ // FixIn: 8.1.3.10.
56
57 $defaults = array(
58 'title' => '&times;'
59 , 'hint' => __( 'Dismiss' ,'booking')
60 , 'is_apply_in_demo' => ! wpbc_is_this_demo()
61 , 'class' => 'wpbc_x_dismiss_btn' // CSS class of close X element
62 , 'css' => '' // Style class of close X element
63 , 'dismiss_css_class' => '' //'.'.$id . '_' . 'weekdays_conditions'
64 );
65 $params = wp_parse_args( $params, $defaults );
66
67
68 $params['css'] = 'text-decoration: none;font-weight: 600;float:right;' . $params['css']; // Append CSS instead of replace it
69
70 if ( ( class_exists( 'WPBC_Dismiss' )) && ( $params[ 'is_apply_in_demo' ] ) ) {
71
72 global $wpbc_Dismiss;
73
74 $is_panel_visible = $wpbc_Dismiss->render( array(
75 'id' => $element_html_id,
76 'title' => $params['title'],
77 'hint' => $params['hint'],
78 'class' => $params['class'],
79 'css' => $params['css'],
80 'dismiss_css_class' => $params['dismiss_css_class']
81 ) );
82 } else {
83 $is_panel_visible = false;
84 }
85
86 return $is_panel_visible;
87 }
88
89
90 class WPBC_Dismiss {
91
92 public $element_id;
93 public $title;
94 public $hint;
95 public $html_class;
96 public $css;
97 public $dismiss_css_class;
98
99 public function __construct( ) {
100
101 }
102
103 public function render( $params = array() ){
104 if (isset($params['id']))
105 $this->element_id = $params['id'];
106 else return false; // Exit, because we do not have ID of element
107
108 if (isset($params['title']))
109 $this->title = $params['title'];
110 else $this->title = __( 'Dismiss' ,'booking');
111
112 if (isset($params['hint']))
113 $this->hint = $params['hint'];
114 else $this->hint = __( 'Dismiss' ,'booking');
115
116 if (isset($params['class']))
117 $this->html_class = $params['class'];
118 else $this->html_class = 'wpbc-panel-dismiss';
119
120 if (isset($params['css']))
121 $this->css = $params['css'];
122 else $this->css = 'text-decoration: none;font-weight: 600;';
123
124 if (isset($params['dismiss_css_class']))
125 $this->dismiss_css_class = $params['dismiss_css_class'];
126 else $this->dismiss_css_class = '';
127
128 return $this->show();
129 }
130
131 public function show() {
132
133 // Check if this window is already Hided or not
134 if ( '1' == get_user_option( 'booking_win_' . $this->element_id ) ){ // Panel Hided
135
136 echo '<script type="text/javascript"> jQuery(document).ready(function(){ ';
137 if ( ! empty( $this->element_id ) ) {
138 echo ' jQuery( "#' . esc_attr( $this->element_id ) . '" ).hide(); ';
139 }
140 if ( ! empty( $this->dismiss_css_class ) ) {
141 echo ' jQuery( "' . esc_attr( $this->dismiss_css_class ) . '" ).hide(); ';
142 }
143 echo ' }); </script>';
144
145 return false;
146
147 } else { // Show Panel
148 echo '<script type="text/javascript"> jQuery(document).ready(function(){ ';
149
150 if ( ! empty( $this->element_id ) ) {
151 echo ' jQuery( "#' . esc_attr( $this->element_id ) . '" ).show(); ';
152 }
153 if ( ! empty( $this->dismiss_css_class ) ) {
154 echo ' jQuery( "' . esc_attr( $this->dismiss_css_class ) . '" ).show(); ';
155 }
156 echo ' }); </script>';
157 }
158
159 wp_nonce_field('wpbc_ajax_admin_nonce', "wpbc_admin_panel_dismiss_window_nonce" , true , true );
160 // Show Hide link
161 ?><a class="<?php echo esc_attr( $this->html_class ); ?>" style="<?php echo esc_attr( $this->css ); ?>"
162 title="<?php echo esc_attr( $this->hint ); ?>"
163 href="javascript:void(0)"
164 onclick="javascript: if ( typeof( wpbc_hide_window ) == 'function' ) {
165 wpbc_hide_window('<?php echo esc_attr( $this->element_id ); ?>');
166 wpbc_dismiss_window(<?php echo esc_attr( wpbc_get_current_user_id() ); ?>, '<?php echo esc_attr( $this->element_id ); ?>');
167 jQuery( this ).hide(); <?php
168 if ( ! empty( $this->dismiss_css_class ) ) {
169 echo "jQuery('" . esc_attr($this->dismiss_css_class) . "').slideUp(500);";
170 }
171 ?>
172 } else { <?php
173 echo "jQuery('#" . esc_attr( $this->element_id ) . "').slideUp(500);";
174 if ( ! empty( $this->dismiss_css_class ) ) {
175 echo "jQuery('" . esc_attr($this->dismiss_css_class) . "').slideUp(500);";
176 }
177 ?> }"
178 ><?php
179 echo wp_kses_post( $this->title ); ?></a><?php
180
181 return true;
182 }
183 }
184
185 if( is_admin() ) {
186 global $wpbc_Dismiss;
187 $wpbc_Dismiss = new WPBC_Dismiss();
188 }