PluginProbe
Booking Calendar / 11.8.4
Booking Calendar v11.8.4
11.8.4 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 All 204 releases
← All changes | core/class/wpbc-class-notices.php +97 -102 10.1.311.8.4 View file →
@@ -14,126 +14,121 @@
14 14
15 15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16 16
17 17
18 +class WPBC_Notices {
18 19
19 -class WPBC_Notices {
20 + private $messages = array();
20 21
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 - }
22 + /**
23 + * Constructor.
24 + */
25 + public function __construct() {
31 26
32 -
33 - private function hooks(){
27 + $this->hooks();
28 + }
34 29
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 30
31 + /**
32 + * Hooks.
33 + *
34 + * @return void
35 + */
36 + private function hooks() {
49 37
38 + // Define Messages.
39 + add_action( 'init', array( $this, 'set_messages' ) );
40 +
41 + // Where to show messages ?
42 + add_action( 'wpbc_hook_booking_page_header', array( $this, 'show_system_messages' ) );
43 + add_action( 'wpbc_hook_add_booking_page_header', array( $this, 'show_system_messages' ) );
44 + add_action( 'wpbc_hook_settings_page_header', array( $this, 'show_system_messages' ) );
45 + }
46 +
47 +
48 + /**
49 + * Define messageas.
50 + *
51 + * @return void
52 + */
53 + public function set_messages() {
54 +
55 + $this->messages['updated_paid_to_free'] = '<strong>' . esc_html__( 'Warning!', 'booking' ) . '</strong> ' .
56 + /* translators: 1: ... */
57 + 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' ), '<a href="https://wpbookingcalendar.com/request-update/" target="_blank">', '</a>' );
58 + }
59 +
60 +
61 + /**
62 + * Define secion for the system messages at the admin panel and show System Messages.
63 + *
64 + * @param string $my_page - tag of the page.
65 + */
66 + public function show_system_messages( $my_page ) {
67 +
50 68 if (! empty($this->messages['updated_paid_to_free'])){
51 - ?><div class="wpbc_admin_system_message wpbc_page_<?php echo $my_page; ?>"><?php
52 69
70 + ?><div class="wpbc_admin_system_message wpbc_page_<?php echo esc_attr( $my_page ); ?>"><?php
71 +
53 72 /** Static messages - user need to click for closing these messages */
54 73
55 - if ( wpbc_is_updated_paid_to_free() )
56 - echo $this->get_formated_message( $this->messages['updated_paid_to_free'] , 'updated error' );
74 + if ( wpbc_is_updated_paid_to_free() ) {
75 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
76 + echo $this->get_formated_message( $this->messages['updated_paid_to_free'], 'updated error' );
77 + }
57 78
58 79 ?></div><?php
59 80 }
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 81 }
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 82
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 83
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 -
84 +
85 + private function get_formated_message( $message, $message_type = 'updated', $inner_message_id = '' ) {
86 +
87 +
88 + // Recheck for any "lang" shortcodes for replacing to correct language.
89 + $message = wpbc_lang( $message );
90 +
91 + // Escape any JavaScript from message.
92 + $notice = html_entity_decode( esc_js( $message ), ENT_QUOTES );
93 +
94 + if ( ! empty( $inner_message_id ) ) {
95 + $inner_message_id_attr = 'id="wpbc_inner_message_' . $inner_message_id . '"';
96 + } else {
97 + $inner_message_id_attr = '';
98 + }
99 +
100 +
101 + $notice_hide = '<a style="border-radius: 7px;margin: 10px 0 0 30px;float: right;font-weight: 600;text-decoration: underline;" title="' . esc_js( __( "Hide", 'booking' ) ) . '" href="javascript:void(0)" onclick="javascript:jQuery(this).parent().parent().fadeOut( 500 );">' . esc_html( __( 'Hide', 'booking' ) ) . '</a>';
102 + $wpbc_metabox_id = 'wpbc_message_update_free_to_paid';
103 +
104 + ob_start();
105 + $is_panel_visible = wpbc_is_dismissed( $wpbc_metabox_id, array(
106 + 'title' => __( 'Dismiss', 'booking' ), // ' <i class="menu_icon icon-1x wpbc_icn_close"></i> ', // &times;.
107 + 'hint' => __( 'Dismiss Forever', 'booking' ),
108 + 'class' => 'wpbc_message_update_free_to_paid',
109 + 'css' => 'border-radius: 7px;margin: 10px 0 0 30px;text-decoration: underline;',
110 + ) );
111 + ?>
112 + <script type="text/javascript">
113 + jQuery( '#<?php echo esc_js( $wpbc_metabox_id ); ?> .wpbc_message_update_free_to_paid' ).on( 'click', function (event) {
114 + jQuery( '#<?php echo esc_attr( $wpbc_metabox_id ); ?>' ).parent().fadeOut(500);
115 + } );
116 + </script>
117 + <?php
118 + $dismiss_button_content = ob_get_clean();
119 +
120 + if ( $is_panel_visible ) {
121 +
122 + $notice = '<div ' . $inner_message_id_attr . ' class="wpbc_inner_message ' . $message_type . '"><div id="' . esc_attr( $wpbc_metabox_id ) . '">' .
123 + $dismiss_button_content .
124 + $notice_hide .
125 + $notice .
126 + '</div></div>';
127 + } else {
128 + $notice = '';
129 + }
130 +
116 131 return $notice;
117 132 }
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 133 }
139 134