PluginProbe
Booking Calendar / 10.1.3
Booking Calendar v10.1.3
11.8.3 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 All 203 releases
booking / core / class / wpbc-class-notices.php

wpbc-class-notices.php in Booking Calendar 10.1.3, at core/class/wpbc-class-notices.php

140 lines 5.6 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 Notices
6 * @category Alerts
7 *
8 * @author wpdevelop
9 * @link https://wpbookingcalendar.com/
10 * @email info@wpbookingcalendar.com
11 *
12 * @modified 2014.10.17
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17
18
19 class WPBC_Notices {
20
21 private $messages = array();
22
23 function __construct() {
24
25 $this->messages['updated_paid_to_free'] = '<strong>'. __('Warning!' ,'booking') . '</strong> '
26 . sprintf( __('Probably you updated your paid version of Booking Calendar by free version or update process failed. You can request the new update of your paid version at %1sthis page%2s.')
27 , '<a href="https://wpbookingcalendar.com/request-update/" target="_blank">', '</a>' );
28 //$this->messages['updated_paid_to_free'] = ''; // TODO: 2023-11-06 comment this
29 $this->hooks();
30 }
31
32
33 private function hooks(){
34
35 add_action('wpbc_hook_booking_page_header', array( $this, 'show_system_messages') );
36 add_action('wpbc_hook_add_booking_page_header', array( $this, 'show_system_messages') );
37
38 add_action('wpbc_hook_settings_page_header', array( $this, 'show_system_messages') );
39 }
40
41
42 /**
43 * Define secion for the system messages at the admin panel and show System Messages.
44 *
45 * @param type $my_page
46 */
47 public function show_system_messages($my_page) {
48
49
50 if (! empty($this->messages['updated_paid_to_free'])){
51 ?><div class="wpbc_admin_system_message wpbc_page_<?php echo $my_page; ?>"><?php
52
53 /** Static messages - user need to click for closing these messages */
54
55 if ( wpbc_is_updated_paid_to_free() )
56 echo $this->get_formated_message( $this->messages['updated_paid_to_free'] , 'updated error' );
57
58 ?></div><?php
59 }
60 /** Dynamic messages - auto-hide, after specific number of seconds */
61
62 // if ( wpbc_is_updated_paid_to_free() )
63 // $this->show_message( $this->messages['updated_paid_to_free'] , 20 );
64
65 }
66
67
68 /**
69 * Show System Message(s) at the top of the admin page.
70 *
71 * @param string $message
72 * @param int $time_to_show -in seconds if 0 then do not hide message
73 * @param string $message_type : 'updated' | 'error'
74 */
75 public function show_message ( $message, $time_to_show , $message_type = 'updated') {
76
77 // Generate unique HTML ID for the message
78 $inner_message_id = intval( time() * rand(10, 100) );
79
80 // Get formated HTML message
81 $notice = $this->get_formated_message( $message, $message_type, $inner_message_id );
82
83 // Get the time of message showing
84 $time_to_show = intval($time_to_show)*1000;
85
86 // Show this Message
87 ?> <script type="text/javascript">
88 if ( jQuery('.wpbc_admin_message').length ) {
89 jQuery('.wpbc_admin_message').append( '<?php echo $notice; ?>' );
90 <?php if ( $time_to_show > 0 ) { ?>
91 jQuery('#wpbc_inner_message_<?php echo $inner_message_id; ?>').animate({opacity: 1},<?php echo $time_to_show; ?>).fadeOut( 2000 );
92 <?php } ?>
93 }
94 </script> <?php
95 }
96
97
98 private function get_formated_message ( $message, $message_type = 'updated', $inner_message_id = '') {
99
100
101 // Recheck for any "lang" shortcodes for replacing to correct language
102 $message = wpbc_lang( $message );
103
104 // Escape any JavaScript from message
105 $notice = html_entity_decode( esc_js( $message ) ,ENT_QUOTES) ;
106
107 $notice .= '<a class="close tooltip_left" rel="tooltip" title="'. esc_js(__("Hide" ,'booking')). '" data-dismiss="alert" href="javascript:void(0)" onclick="javascript:jQuery(this).parent().hide();">&times;</a>';
108
109 // $my_close_open_alert_id = 'wpbc_system_message_id_';
110 // $notice .= '<a class="close tooltip_left" rel="tooltip" title="'. esc_js(__("Don't show the message anymore" ,'booking')). '" data-dismiss="alert" href="javascript:void(0)" onclick="javascript:wpbc_verify_window_opening('. wpbc_get_current_user_id() .', \''. $my_close_open_alert_id .'\');">&times;</a>';
111 if (! empty( $inner_message_id ))
112 $inner_message_id = 'id="wpbc_inner_message_'. $inner_message_id .'"';
113
114 $notice = '<div '.$inner_message_id.' class="wpbc_inner_message '. $message_type . '">' . $notice . '</div>';
115
116 return $notice;
117 }
118
119 /*
120 function show_alert($message) {
121
122 $alert_head = __('Note' ,'booking');
123
124 $my_close_open_alert_id = 'bk_alert_settings_form_in_free';
125
126 ?>
127 <div class="alert alert-warning alert-block alert-info <?php if ( '1' == get_user_option( 'booking_win_' . $my_close_open_alert_id ) ) echo 'closed'; ?>"
128 id="<?php echo $my_close_open_alert_id; ?>">
129 <a class="close tooltip_left" rel="tooltip" title="<?php _e("Don't show the message anymore" ,'booking');?>" data-dismiss="alert"
130 href="javascript:void(0)"
131 onclick="javascript:wpbc_verify_window_opening(<?php echo wpbc_get_current_user_id(); ?>, '<?php echo $my_close_open_alert_id; ?>');"
132 >&times;</a>
133 <strong class="alert-heading"><?php echo $alert_head; ?></strong><?php echo $message; ?>
134 </div>
135 <?php
136 }*/
137
138 }
139
140