PluginProbe
Booking Calendar / 10.10
Booking Calendar v10.10
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 / core / class / wpbc-class-notices.php

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

149 lines 6.0 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 $this->hooks();
25 }
26
27
28 private function hooks(){
29 add_action( 'init', array( $this, 'set_messages' ) ); // FixIn: 10.6.5.1.
30
31 add_action('wpbc_hook_booking_page_header', array( $this, 'show_system_messages') );
32 add_action('wpbc_hook_add_booking_page_header', array( $this, 'show_system_messages') );
33
34 add_action('wpbc_hook_settings_page_header', array( $this, 'show_system_messages') );
35 }
36
37 // FixIn: 10.6.5.1.
38 public function set_messages(){
39
40 $this->messages['updated_paid_to_free'] = '<strong>' . esc_html__('Warning!' ,'booking') . '</strong> '
41 /* translators: 1: ... */
42 . 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 %1$sthis page%2$s.', 'booking')
43 , '<a href="https://wpbookingcalendar.com/request-update/" target="_blank">', '</a>' );
44 }
45
46
47 /**
48 * Define secion for the system messages at the admin panel and show System Messages.
49 *
50 * @param type $my_page
51 */
52 public function show_system_messages($my_page) {
53
54
55 if (! empty($this->messages['updated_paid_to_free'])){
56 ?><div class="wpbc_admin_system_message wpbc_page_<?php echo esc_attr( $my_page ); ?>"><?php
57
58 /** Static messages - user need to click for closing these messages */
59
60 if ( wpbc_is_updated_paid_to_free() ) {
61 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
62 echo $this->get_formated_message( $this->messages['updated_paid_to_free'], 'updated error' );
63 }
64
65 ?></div><?php
66 }
67 /** Dynamic messages - auto-hide, after specific number of seconds */
68
69 // if ( wpbc_is_updated_paid_to_free() )
70 // $this->show_message( $this->messages['updated_paid_to_free'] , 20 );
71
72 }
73
74
75 /**
76 * Show System Message(s) at the top of the admin page.
77 *
78 * @param string $message
79 * @param int $time_to_show -in seconds if 0 then do not hide message
80 * @param string $message_type : 'updated' | 'error'
81 */
82 public function show_message ( $message, $time_to_show , $message_type = 'updated') {
83
84 // Generate unique HTML ID for the message
85 $inner_message_id = intval( time() * wp_rand(10, 100) );
86
87 // Get formated HTML message
88 $notice = $this->get_formated_message( $message, $message_type, $inner_message_id );
89
90 // Get the time of message showing
91 $time_to_show = intval($time_to_show)*1000;
92
93 // Show this Message
94 ?> <script type="text/javascript">
95 if ( jQuery('.wpbc_admin_message').length ) {
96 jQuery('.wpbc_admin_message').append( '<?php
97 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
98 echo $notice ; ?>' );
99 <?php if ( $time_to_show > 0 ) { ?>
100 jQuery('#wpbc_inner_message_<?php echo esc_attr( $inner_message_id ); ?>').animate({opacity: 1},<?php echo esc_attr( $time_to_show ); ?>).fadeOut( 2000 );
101 <?php } ?>
102 }
103 </script> <?php
104 }
105
106
107 private function get_formated_message ( $message, $message_type = 'updated', $inner_message_id = '') {
108
109
110 // Recheck for any "lang" shortcodes for replacing to correct language
111 $message = wpbc_lang( $message );
112
113 // Escape any JavaScript from message
114 $notice = html_entity_decode( esc_js( $message ) ,ENT_QUOTES) ;
115
116 $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>';
117
118 // $my_close_open_alert_id = 'wpbc_system_message_id_';
119 // $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>';
120 if (! empty( $inner_message_id ))
121 $inner_message_id = 'id="wpbc_inner_message_'. $inner_message_id .'"';
122
123 $notice = '<div '.$inner_message_id.' class="wpbc_inner_message '. $message_type . '">' . $notice . '</div>';
124
125 return $notice;
126 }
127
128 /*
129 function show_alert($message) {
130
131 $alert_head = __('Note' ,'booking');
132
133 $my_close_open_alert_id = 'bk_alert_settings_form_in_free';
134
135 ?>
136 <div class="alert alert-warning alert-block alert-info <?php if ( '1' == get_user_option( 'booking_win_' . $my_close_open_alert_id ) ) echo 'closed'; ?>"
137 id="<?php echo esc_attr( $my_close_open_alert_id ); ?>">
138 <a class="close tooltip_left" rel="tooltip" title="<?php esc_attr_e("Don't show the message anymore" ,'booking');?>" data-dismiss="alert"
139 href="javascript:void(0)"
140 onclick="javascript:wpbc_verify_window_opening(<?php echo esc_attr( wpbc_get_current_user_id() ); ?>, '<?php echo esc_attr( $my_close_open_alert_id ); ?>');"
141 >&times;</a>
142 <strong class="alert-heading"><?php echo esc_html( $alert_head ); ?></strong><?php echo esc_attr( $message ); ?>
143 </div>
144 <?php
145 }*/
146
147 }
148
149