| 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 |
class WPBC_Notices { |
| 19 |
|
| 20 |
private $messages = array(); |
| 21 |
|
| 22 |
/** |
| 23 |
* Constructor. |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
|
| 27 |
$this->hooks(); |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
/** |
| 32 |
* Hooks. |
| 33 |
* |
| 34 |
* @return void |
| 35 |
*/ |
| 36 |
private function hooks() { |
| 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 |
|
| 68 |
if (! empty($this->messages['updated_paid_to_free'])){ |
| 69 |
|
| 70 |
?><div class="wpbc_admin_system_message wpbc_page_<?php echo esc_attr( $my_page ); ?>"><?php |
| 71 |
|
| 72 |
/** Static messages - user need to click for closing these messages */ |
| 73 |
|
| 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 |
} |
| 78 |
|
| 79 |
?></div><?php |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
|
| 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> ', // ×. |
| 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 |
|
| 131 |
return $notice; |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
|