| 1 |
<?php |
| 2 |
/** |
| 3 |
* @version 1.0 |
| 4 |
* @package Booking Calendar |
| 5 |
* @subpackage Core |
| 6 |
* @category Bookings |
| 7 |
* |
| 8 |
* @author wpdevelop |
| 9 |
* @link https://wpbookingcalendar.com/ |
| 10 |
* @email info@wpbookingcalendar.com |
| 11 |
* |
| 12 |
* @modified 2014.07.29 |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 16 |
|
| 17 |
global $wp_version; |
| 18 |
$wpbc_min_wp_version = version_compare( WP_BK_MIN_WP_VERSION, $wp_version, '<=' ); // FixIn: 7.0.1.6. |
| 19 |
if ( ( ! class_exists( 'Booking_Calendar' ) ) && ( $wpbc_min_wp_version ) ) : |
| 20 |
|
| 21 |
|
| 22 |
// General Init Class |
| 23 |
final class Booking_Calendar { |
| 24 |
|
| 25 |
static private $instance = NULL; |
| 26 |
|
| 27 |
public $cron; |
| 28 |
public $notice; |
| 29 |
public $booking_obj; |
| 30 |
|
| 31 |
public $admin_menu; |
| 32 |
public $js; |
| 33 |
public $css; |
| 34 |
|
| 35 |
private $is_wp_inited = false; |
| 36 |
|
| 37 |
/** Get Single Instance of this Class and Init Plugin */ |
| 38 |
public static function init() { |
| 39 |
|
| 40 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Booking_Calendar ) ) { |
| 41 |
|
| 42 |
self::$instance = new Booking_Calendar; |
| 43 |
self::$instance->includes(); |
| 44 |
self::$instance->define_version(); |
| 45 |
|
| 46 |
add_action( 'init', array( self::$instance, 'wp_inited' ) ); |
| 47 |
|
| 48 |
if ( class_exists( 'WPBC_BookingInstall' ) ) { // Check if we need to run Install / Uninstal process. |
| 49 |
new WPBC_BookingInstall(); |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Make Ajax, Response, in this case $is_continue_at_frontend = false |
| 54 |
* or |
| 55 |
* define Booking Class for front-end side, then $is_continue_at_frontend = true |
| 56 |
*/ |
| 57 |
$is_continue_at_frontend = self::$instance->start(); |
| 58 |
|
| 59 |
make_bk_action('wpbc_booking_calendar_started'); |
| 60 |
|
| 61 |
if ( $is_continue_at_frontend ) { // Possible Load Admin or Front-End page |
| 62 |
|
| 63 |
self::$instance->js = new WPBC_JS; |
| 64 |
self::$instance->css = new WPBC_CSS; |
| 65 |
|
| 66 |
if( is_admin() ) { |
| 67 |
|
| 68 |
// Define Menu |
| 69 |
add_action( '_admin_menu', array( self::$instance, 'define_admin_menu') ); // _admin_menu - Fires before the administration menu loads in the admin. |
| 70 |
|
| 71 |
add_action( 'admin_footer', 'wpbc_print_js', 50 ); // Load my Queued JavaScript Code at the footer of the Admin Panel page. Executed in ALL Admin Menu Pages |
| 72 |
|
| 73 |
} else { |
| 74 |
|
| 75 |
if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache |
| 76 |
|
| 77 |
add_action( 'wp_enqueue_scripts', array(self::$instance->css, 'load'), 1000000001 ); // Load CSS at front-end side // Enqueue Scripts to All Client pages |
| 78 |
add_action( 'wp_enqueue_scripts', array(self::$instance->js, 'load'), 1000000001 ); // Load JavaScript files and define JS varibales at forn-end side |
| 79 |
add_action( 'wp_footer', 'wpbc_print_js', 50 ); // Load my Queued JavaScript Code at the footer of the page, if executed "wp_footer" hook at the Theme. |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
} |
| 84 |
return self::$instance; |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Set WordPress was inited |
| 89 |
* |
| 90 |
* @return void |
| 91 |
*/ |
| 92 |
public function wp_inited(){ |
| 93 |
self::$instance->is_wp_inited = true; |
| 94 |
} |
| 95 |
|
| 96 |
/** |
| 97 |
* Check if WP was inited |
| 98 |
* @return mixed |
| 99 |
*/ |
| 100 |
public function is_wp_inited(){ |
| 101 |
return self::$instance->is_wp_inited; |
| 102 |
} |
| 103 |
|
| 104 |
/** Define Admin Menu items */ |
| 105 |
public function define_admin_menu(){ |
| 106 |
|
| 107 |
$update_count = wpbc_db_get_number_new_bookings(); |
| 108 |
// FixIn: 9.1.3.3. |
| 109 |
$title = 'WPBC ';//__('Booking', 'booking'); //'ß<span style="font-size:0.75em;">ΘΘ</span>ĸıŋ'; // __('Booking', 'booking') |
| 110 |
$is_user_activated = apply_bk_filter('multiuser_is_current_user_active', true ); // FixIn: 6.0.1.17. |
| 111 |
|
| 112 |
if ( ( $update_count > 0 ) && ( $is_user_activated ) ) { |
| 113 |
$update_count_title = "<span class='update-plugins count-$update_count' title=''><span class='update-count bk-update-count'>" . number_format_i18n($update_count) . "</span></span>" ; |
| 114 |
$title .= $update_count_title; |
| 115 |
} |
| 116 |
|
| 117 |
$title = '<div class="name_container" style="display: flex;flex-flow: row nowrap;justify-content: flex-start;align-items: center;min-height: 16px;">' |
| 118 |
. ' <div class="name_item" style="font-size: 6px;font-weight: 600;margin-left: -4px;margin-top: 12px;margin-right: 0px;word-wrap: normal;white-space: nowrap;position: absolute;">WP</div>' |
| 119 |
. ' <div class="name_item" style="font-size: 11px;margin-left: -5px;margin-top: -7px;white-space: nowrap;margin-right: 4px;">Booking Calendar</div>'; |
| 120 |
if ( ( $update_count > 0 ) && ( $is_user_activated ) ) { |
| 121 |
$badge_style= ''; |
| 122 |
} else { |
| 123 |
$badge_style = 'display:none;'; |
| 124 |
} |
| 125 |
|
| 126 |
$title .= '<span style="margin-top:-2px;'.$badge_style.'" class="wpbc_badge_count name_item update-plugins count-'.$update_count.'" title=""><span class="update-count bk-update-count" style="white-space: nowrap;word-wrap: normal;">' . number_format_i18n( $update_count ) . '</span></span>'; |
| 127 |
$title .= '</div>'; |
| 128 |
|
| 129 |
|
| 130 |
$booking_menu_position = get_bk_option( 'booking_menu_position' ); |
| 131 |
switch ( $booking_menu_position ) { |
| 132 |
case 'top': |
| 133 |
$booking_menu_position = '3.3'; // FixIn: 8.7.7.16. |
| 134 |
break; |
| 135 |
case 'middle': |
| 136 |
global $_wp_last_object_menu; // The index of the last top-level menu in the object menu group |
| 137 |
$_wp_last_object_menu++; |
| 138 |
$booking_menu_position = $_wp_last_object_menu; // 58.9; |
| 139 |
break; |
| 140 |
case 'bottom': |
| 141 |
$booking_menu_position = '99.999'; |
| 142 |
break; |
| 143 |
default: |
| 144 |
$booking_menu_position = '3.3'; |
| 145 |
break; |
| 146 |
} |
| 147 |
|
| 148 |
// FixIn: 10.11.3.3. |
| 149 |
|
| 150 |
// //FixIn: 9.0.1.7 //scale image by this params: viewBox="-2 -1 20 20" |
| 151 |
// if( 0 ) { |
| 152 |
// // calendar4-range https://icons.getbootstrap.com/icons/calendar4-range/ |
| 153 |
// $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="" viewBox="-2 -1 20 20">' |
| 154 |
// . '<path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM2 2a1 1 0 0 0-1 1v1h14V3a1 1 0 0 0-1-1H2zm13 3H1v9a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V5z"/>' |
| 155 |
// . '<path d="M9 7.5a.5.5 0 0 1 .5-.5H15v2H9.5a.5.5 0 0 1-.5-.5v-1zm-2 3v1a.5.5 0 0 1-.5.5H1v-2h5.5a.5.5 0 0 1 .5.5z"/>' |
| 156 |
// . '</svg>'; |
| 157 |
// |
| 158 |
// //calendar-range https://icons.getbootstrap.com/icons/calendar-range/ |
| 159 |
// $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-calendar-range" viewBox="-2 -1 20 20">' |
| 160 |
// . '<path d="M9 7a1 1 0 0 1 1-1h5v2h-5a1 1 0 0 1-1-1zM1 9h4a1 1 0 0 1 0 2H1V9z"/>' |
| 161 |
// . '<path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/>' |
| 162 |
// . '</svg>'; |
| 163 |
// |
| 164 |
// //calendar2-range https://icons.getbootstrap.com/icons/calendar2-range/ |
| 165 |
// $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-calendar2-range" viewBox="-2 -1 20 20">' |
| 166 |
// . '<path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM2 2a1 1 0 0 0-1 1v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1H2z"/>' |
| 167 |
// . '<path d="M2.5 4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5H3a.5.5 0 0 1-.5-.5V4zM9 8a1 1 0 0 1 1-1h5v2h-5a1 1 0 0 1-1-1zm-8 2h4a1 1 0 1 1 0 2H1v-2z"/>' |
| 168 |
// . '</svg>'; |
| 169 |
// } |
| 170 |
// // calendar3-range https://icons.getbootstrap.com/icons/calendar3-range/ |
| 171 |
// $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-calendar3-range" viewBox="-2 -1 20 20">' |
| 172 |
// . '<path d="M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z"/>' |
| 173 |
// . '<path d="M7 10a1 1 0 0 0 0-2H1v2h6zm2-3h6V5H9a1 1 0 0 0 0 2z"/>' |
| 174 |
// . '</svg>'; |
| 175 |
|
| 176 |
$svg_icon_integarted = wpbc_get_svg_logo( '#aaa', '#aaa', '0.4' ); // '#aaa', '#aaa', '0.2' . |
| 177 |
|
| 178 |
self::$instance->admin_menu['master'] = new WPBC_Admin_Menus( |
| 179 |
'wpbc' , array ( |
| 180 |
'in_menu' => 'root' |
| 181 |
//, 'mune_icon_url' => '/assets/img/icon-16x16.png' |
| 182 |
, 'mune_icon_url' => $svg_icon_integarted // FixIn: 9.0.1.7. |
| 183 |
, 'menu_title' => $title |
| 184 |
, 'menu_title_second' => __('Bookings', 'booking') |
| 185 |
, 'page_header' => __('Bookings Listing','booking') |
| 186 |
, 'browser_header' => __('Bookings Listing', 'booking') . ' - ' . __('Booking Calendar', 'booking') |
| 187 |
, 'user_role' => get_bk_option( 'booking_user_role_booking' ) |
| 188 |
, 'position' => $booking_menu_position // 3.3 - top //( 58.9 ) // - middle |
| 189 |
/* |
| 190 |
(Optional). Positions for Core Menu Items |
| 191 |
2 Dashboard |
| 192 |
4 Separator |
| 193 |
5 Posts |
| 194 |
10 Media |
| 195 |
15 Links |
| 196 |
20 Pages |
| 197 |
25 Comments |
| 198 |
59 Separator |
| 199 |
60 Appearance |
| 200 |
65 Plugins |
| 201 |
70 Users |
| 202 |
75 Tools |
| 203 |
80 Settings |
| 204 |
99 Separator |
| 205 |
*/ |
| 206 |
) |
| 207 |
); |
| 208 |
|
| 209 |
self::$instance->admin_menu['new'] = new WPBC_Admin_Menus( |
| 210 |
'wpbc-new', |
| 211 |
array( |
| 212 |
'in_menu' => 'wpbc', |
| 213 |
'menu_title' => '+ ' . ucwords( __( 'Add booking', 'booking' ) ), // FixIn: 10.9.3.1. |
| 214 |
'page_header' => ucwords( __( 'Add booking', 'booking' ) ), |
| 215 |
'browser_header' => ucwords( __( 'Add booking', 'booking' ) ) . ' - ' . __( 'Booking Calendar', 'booking' ), |
| 216 |
'user_role' => get_bk_option( 'booking_user_role_addbooking' ), |
| 217 |
) |
| 218 |
); |
| 219 |
|
| 220 |
self::$instance->admin_menu['availability'] = new WPBC_Admin_Menus( // FixIn: 9.3.0.1. |
| 221 |
'wpbc-availability' , array ( |
| 222 |
'in_menu' => 'wpbc' |
| 223 |
, 'menu_title' => ucwords( __('Availability', 'booking') ) |
| 224 |
, 'page_header' => ucwords( __('Availability','booking') ) |
| 225 |
, 'browser_header'=> ucwords( __('Availability', 'booking') ) . ' - ' . __('Booking Calendar', 'booking') |
| 226 |
, 'user_role' => get_bk_option( 'booking_user_role_availability' ) // FixIn: 9.5.2.2. |
| 227 |
) |
| 228 |
); |
| 229 |
//FixIn: 9.8.15.2.4 |
| 230 |
if ( class_exists( 'wpdev_bk_biz_m' ) ) |
| 231 |
self::$instance->admin_menu['prices'] = new WPBC_Admin_Menus( |
| 232 |
'wpbc-prices' , array ( |
| 233 |
'in_menu' => 'wpbc' |
| 234 |
, 'menu_title' => __('Prices', 'booking') |
| 235 |
, 'page_header' => ucwords( __('Booking Prices','booking') ) |
| 236 |
, 'browser_header'=> __('Prices', 'booking') . ' - ' . __('Booking Calendar', 'booking') |
| 237 |
, 'user_role' => get_bk_option( 'booking_user_role_prices' ) //FixIn: 9.8.15.2.6 |
| 238 |
) |
| 239 |
); |
| 240 |
if ( class_exists( 'wpdev_bk_personal' ) ) { |
| 241 |
self::$instance->admin_menu['resources'] = new WPBC_Admin_Menus( |
| 242 |
'wpbc-resources' , array ( |
| 243 |
'in_menu' => 'wpbc' |
| 244 |
, 'menu_title' => __('Resources', 'booking') |
| 245 |
, 'page_header' => ucwords( __('Booking resources','booking') ) |
| 246 |
, 'browser_header'=> __('Resources', 'booking') . ' - ' . __('Booking Calendar', 'booking') |
| 247 |
, 'user_role' => get_bk_option( 'booking_user_role_resources' ) |
| 248 |
) |
| 249 |
); |
| 250 |
} |
| 251 |
|
| 252 |
|
| 253 |
if ( ! class_exists( 'wpdev_bk_personal' ) ) { // FixIn: 10.1.3.1. |
| 254 |
// FixIn: 9.8.15.7. |
| 255 |
self::$instance->admin_menu['resources'] = new WPBC_Admin_Menus( |
| 256 |
'wpbc-resources' , array ( |
| 257 |
'in_menu' => 'wpbc' |
| 258 |
, 'menu_title' => __('Publish', 'booking') // __('Resource', 'booking') |
| 259 |
, 'page_header' => ucwords( __('Booking resource','booking') ) |
| 260 |
, 'browser_header'=> __('Resource', 'booking') . ' - ' . __('Booking Calendar', 'booking') |
| 261 |
, 'user_role' => get_bk_option( 'booking_user_role_settings' ) |
| 262 |
) |
| 263 |
); |
| 264 |
} |
| 265 |
|
| 266 |
|
| 267 |
self::$instance->admin_menu['settings'] = new WPBC_Admin_Menus( |
| 268 |
'wpbc-settings' , array ( |
| 269 |
'in_menu' => 'wpbc' |
| 270 |
, 'menu_title' => __('Settings', 'booking') |
| 271 |
, 'page_header' => __('General Settings','booking') |
| 272 |
, 'browser_header'=> __('Settings', 'booking') . ' - ' . __('Booking Calendar', 'booking') |
| 273 |
, 'user_role' => get_bk_option( 'booking_user_role_settings' ) |
| 274 |
) |
| 275 |
); |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
if ( |
| 281 |
( wpbc_is_user_can_access_wizard_page() ) && |
| 282 |
( ! wpbc_setup_wizard_page__is_all_steps_completed() ) |
| 283 |
){ |
| 284 |
|
| 285 |
$setup_steps = new WPBC_SETUP_WIZARD_STEPS(); |
| 286 |
|
| 287 |
self::$instance->admin_menu['setup'] = new WPBC_Admin_Menus( |
| 288 |
'wpbc-setup' , array ( |
| 289 |
'in_menu' => 'wpbc' |
| 290 |
, 'menu_title' => $setup_steps->get_plugin_menu_title__setup_progress() |
| 291 |
, 'page_header' => ucwords( __('Setup','booking') ) |
| 292 |
, 'browser_header' => ucwords( __('Setup', 'booking') ) . ' - ' . __('Booking Calendar', 'booking') |
| 293 |
, 'user_role' => get_bk_option( 'booking_user_role_settings' ) //FixIn: 9.8.15.2.6 |
| 294 |
) |
| 295 |
); |
| 296 |
} |
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
$simulate_user_id = wpbc_mu__is_simulated_login_as_user(); |
| 301 |
if ( ! empty( $simulate_user_id ) ) { |
| 302 |
|
| 303 |
$custom_user = get_userdata( $simulate_user_id ); |
| 304 |
|
| 305 |
self::$instance->admin_menu['log_off'] = new WPBC_Admin_Menus( |
| 306 |
'wpbc-log-off' , array ( |
| 307 |
'in_menu' => 'wpbc' |
| 308 |
//, 'menu_title' => __( 'Log Out Simulated Login as', 'booking' ) . ' "' . $custom_user->display_name . '"' |
| 309 |
, 'menu_title' => '<span style="color:#fffcdf;font-size: 11px;font-weight: 400;" title="' |
| 310 |
. esc_attr( __( 'Log out as regular user and login as super booking admin user', 'booking' ) ) |
| 311 |
.'">' |
| 312 |
.__( 'Back to Super Admin', 'booking' ) |
| 313 |
.'<span>' |
| 314 |
/* translators: 1: ... */ |
| 315 |
, 'page_header' => ucwords( sprintf( __( 'Need even more functionality? Check %1$s higher versions %2$s', 'booking' ), '', '' ) ) |
| 316 |
, 'browser_header'=> 'Log In as Super Admin' |
| 317 |
, 'user_role' => get_bk_option( 'booking_user_role_booking' ) |
| 318 |
) |
| 319 |
); |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
/** |
| 326 |
* Get Menu Object |
| 327 |
* |
| 328 |
* @param type - menu type |
| 329 |
* @return boolean |
| 330 |
*/ |
| 331 |
public function get_menu_object( $type ) { |
| 332 |
|
| 333 |
if ( isset( self::$instance->admin_menu[ $type ] ) ) |
| 334 |
return self::$instance->admin_menu[ $type ]; |
| 335 |
else |
| 336 |
return false; |
| 337 |
} |
| 338 |
|
| 339 |
|
| 340 |
// Include Files |
| 341 |
private function includes() { |
| 342 |
require_once WPBC_PLUGIN_DIR . '/includes/wpbc-include.php' ; |
| 343 |
} |
| 344 |
|
| 345 |
|
| 346 |
private function define_version() { |
| 347 |
|
| 348 |
// GET VERSION NUMBER |
| 349 |
$plugin_data = wpbc_file__read_header_info( WPBC_FILE, array( |
| 350 |
'Name' => 'Plugin Name', |
| 351 |
'PluginURI' => 'Plugin URI', |
| 352 |
'Version' => 'Version', |
| 353 |
'Description' => 'Description', |
| 354 |
'Author' => 'Author', |
| 355 |
'AuthorURI' => 'Author URI', |
| 356 |
'TextDomain' => 'Text Domain', |
| 357 |
'DomainPath' => 'Domain Path', |
| 358 |
), 'plugin' ); |
| 359 |
if ( ! defined( 'WPDEV_BK_VERSION' ) ) { |
| 360 |
define( 'WPDEV_BK_VERSION', $plugin_data['Version'] ); |
| 361 |
} |
| 362 |
} |
| 363 |
|
| 364 |
|
| 365 |
// Cloning instances of the class is forbidden |
| 366 |
public function __clone() { |
| 367 |
|
| 368 |
_doing_it_wrong( __FUNCTION__, esc_html__( 'Action is not allowed!', 'booking' ), '1.0' ); |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
// Unserializing instances of the class is forbidden |
| 373 |
public function __wakeup() { |
| 374 |
|
| 375 |
_doing_it_wrong( __FUNCTION__, esc_html__( 'Action is not allowed!', 'booking' ), '1.0' ); |
| 376 |
} |
| 377 |
|
| 378 |
|
| 379 |
// Initialization |
| 380 |
private function start(){ |
| 381 |
|
| 382 |
if ( ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ){ // New A J A X R e s p o n d e r |
| 383 |
|
| 384 |
if ( 1 ) { |
| 385 |
$wpdev_booking_obj_in_ajax = new wpdev_booking(); // GO |
| 386 |
} else { |
| 387 |
if ( class_exists( 'wpdev_bk_personal' ) ) { |
| 388 |
$wpdev_bk_personal_in_ajax = new wpdev_bk_personal(); |
| 389 |
} |
| 390 |
} |
| 391 |
|
| 392 |
require_once WPBC_PLUGIN_DIR . '/core/lib/wpbc-ajax.php'; // Ajax |
| 393 |
|
| 394 |
return false; |
| 395 |
} else { // Usual Loading of plugin |
| 396 |
|
| 397 |
// We are having Response, its executed in other file: wpbc-response.php |
| 398 |
if ( WP_BK_RESPONSE ) |
| 399 |
return false; |
| 400 |
|
| 401 |
if( is_admin() ) { |
| 402 |
// Define Notices System |
| 403 |
self::$instance->notice = new WPBC_Notices(); |
| 404 |
} |
| 405 |
|
| 406 |
// Normal Start |
| 407 |
self::$instance->booking_obj = new wpdev_booking(); // GO |
| 408 |
|
| 409 |
// Cron Jobs ..... ///////////////////////////////////////////////// |
| 410 |
self::$instance->cron = new WPBC_Cron(); |
| 411 |
//////////////////////////////////////////////////////////////////// |
| 412 |
} |
| 413 |
return true; |
| 414 |
} |
| 415 |
|
| 416 |
} |
| 417 |
|
| 418 |
else: // Its seems that some instance of Booking Calendar still activted!!! |
| 419 |
|
| 420 |
// FixIn: 7.0.1.6. |
| 421 |
global $wp_version; |
| 422 |
$wpbc_min_wp_version = version_compare( WP_BK_MIN_WP_VERSION, $wp_version, '<=' ); |
| 423 |
|
| 424 |
// FixIn: 7.0.1.6. |
| 425 |
function wpbc_show_min_wp_version_error() { |
| 426 |
|
| 427 |
$message_type = 'error'; |
| 428 |
$title = __( 'Error' , 'booking') . '!'; |
| 429 |
|
| 430 |
|
| 431 |
$message = 'Booking Calendar '; |
| 432 |
|
| 433 |
$booking_version_num = get_option( 'booking_version_num'); |
| 434 |
if ( ! empty( $booking_version_num ) ) |
| 435 |
$message .= '<strong>' . $booking_version_num . '</strong> '; |
| 436 |
|
| 437 |
|
| 438 |
global $wp_version; |
| 439 |
|
| 440 |
$message .= sprintf( 'require minimum %s . You are using %s. ' |
| 441 |
, ' <strong>' . 'WordPress ' . WP_BK_MIN_WP_VERSION . '</strong>' |
| 442 |
, ' <strong>' . 'WordPress ' . $wp_version . '</strong>' ); |
| 443 |
if ( current_user_can( 'update_core' ) ){ |
| 444 |
$message .= ' <a href="' . esc_url( self_admin_url( 'update-core.php' ) ) . '">' . 'Return to Dashboard → Updates' . '</a>'; |
| 445 |
} |
| 446 |
|
| 447 |
|
| 448 |
$message_content = ''; |
| 449 |
|
| 450 |
$message_content .= '<div class="clear"></div>'; |
| 451 |
|
| 452 |
$message_content .= '<div class="updated wpbc-settings-notice notice-' . $message_type . ' ' . $message_type . '" style="text-align:left;padding:10px;">'; |
| 453 |
|
| 454 |
if ( ! empty( $title ) ) |
| 455 |
$message_content .= '<strong>' . esc_js( $title ) . '</strong> '; |
| 456 |
|
| 457 |
$message_content .= html_entity_decode( esc_js( $message ) ,ENT_QUOTES) ; |
| 458 |
|
| 459 |
$message_content .= '</div>'; |
| 460 |
|
| 461 |
$message_content .= '<div class="clear"></div>'; |
| 462 |
|
| 463 |
echo wp_kses_post( $message_content ); |
| 464 |
} |
| 465 |
|
| 466 |
function wpbc_show_activation_error() { |
| 467 |
|
| 468 |
$message_type = 'error'; |
| 469 |
$title = __( 'Error' , 'booking') . '!'; |
| 470 |
$message = 'Please deactivate previous old version of' . ' ' . 'Booking Calendar'; |
| 471 |
|
| 472 |
$booking_version_num = get_option( 'booking_version_num'); |
| 473 |
if ( ! empty( $booking_version_num ) ) |
| 474 |
$message .= ' <strong>' . $booking_version_num . '</strong>'; |
| 475 |
|
| 476 |
|
| 477 |
$is_delete_if_deactive = get_bk_option( 'booking_is_delete_if_deactive' ); // check |
| 478 |
|
| 479 |
if ( $is_delete_if_deactive == 'On' ) { |
| 480 |
|
| 481 |
$message .= '<br/><br/> <strong>Warning!</strong> ' . 'All plugin data will be deleted when plugin had deactivated.' . ' ' |
| 482 |
. sprintf( 'If you want to save your plugin data, please uncheck the %s"Delete plugin data"%s at the', '<strong>', '</strong>') . ' ' . __( 'Settings' , 'booking' ) . '.'; |
| 483 |
} |
| 484 |
|
| 485 |
$message_content = ''; |
| 486 |
|
| 487 |
$message_content .= '<div class="clear"></div>'; |
| 488 |
|
| 489 |
$message_content .= '<div class="updated wpbc-settings-notice notice-' . $message_type . ' ' . $message_type . '" style="text-align:left;padding:10px;">'; |
| 490 |
|
| 491 |
if ( ! empty( $title ) ) |
| 492 |
$message_content .= '<strong>' . esc_js( $title ) . '</strong> '; |
| 493 |
|
| 494 |
$message_content .= html_entity_decode( esc_js( $message ) ,ENT_QUOTES) ; |
| 495 |
|
| 496 |
$message_content .= '</div>'; |
| 497 |
|
| 498 |
$message_content .= '<div class="clear"></div>'; |
| 499 |
|
| 500 |
echo wp_kses_post( $message_content ); |
| 501 |
} |
| 502 |
|
| 503 |
|
| 504 |
if ( ! $wpbc_min_wp_version ) // FixIn: 7.0.1.6. |
| 505 |
add_action('admin_notices', 'wpbc_show_min_wp_version_error'); |
| 506 |
else |
| 507 |
add_action('admin_notices', 'wpbc_show_activation_error'); |
| 508 |
|
| 509 |
return; // Exit |
| 510 |
|
| 511 |
endif; |
| 512 |
|
| 513 |
|
| 514 |
/** |
| 515 |
* The main function responsible for returning the one true Instance to functions everywhere. |
| 516 |
* |
| 517 |
* Example: <?php $wpbc = WPBC(); ?> |
| 518 |
*/ |
| 519 |
function WPBC() { |
| 520 |
return Booking_Calendar::init(); |
| 521 |
} |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
// Start |
| 526 |
WPBC(); |
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
//if ( ! defined( 'SAVEQUERIES') ) define('SAVEQUERIES', true); |
| 531 |
|
| 532 |
//add_action( 'admin_footer', 'wpbc_show_debug_info', 130 ); |
| 533 |
function wpbc_show_debug_info() { |
| 534 |
|
| 535 |
$server_request_uri = ( ( isset( $_SERVER['REQUEST_URI'] ) ) ? sanitize_text_field( $_SERVER['REQUEST_URI'] ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash */ /* FixIn: sanitize_unslash */ |
| 536 |
$request_uri = $server_request_uri; //FixIn:5.4.1 |
| 537 |
if ( strpos( $request_uri, 'page=wpbc') === false ) { |
| 538 |
return; |
| 539 |
} |
| 540 |
echo '<div style="width:800px;margin:10px auto;"><style type="text/css"> a:link{background: inherit !important; } pre { white-space: pre-wrap; }</style>'; |
| 541 |
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_phpinfo |
| 542 |
phpinfo(); echo '</div>'; return; |
| 543 |
|
| 544 |
?><div style="width:auto;margin:0 0 0 215px;font-size:11px; "><?php |
| 545 |
|
| 546 |
// SYSTEM INFO SHOWING //////////////////////////////////////////////////////// |
| 547 |
|
| 548 |
//Note firstly need to define this in functions.php file: define('SAVEQUERIES', true); |
| 549 |
global $wpdb; |
| 550 |
echo '<div class="clear"></div>START SYSTEM<pre>'; |
| 551 |
$qq_kk = 0; |
| 552 |
$total_time = 0; |
| 553 |
$total_num = 0; |
| 554 |
foreach ( $wpdb->queries as $qq_k => $qq ) { |
| 555 |
if ( |
| 556 |
( strpos( $qq[0], 'booking') !== false ) |
| 557 |
|
| 558 |
) { |
| 559 |
if ( $qq[1] > 0.002 ) { echo '<div style="color:#A77;font-weight:bold;">'; } |
| 560 |
debuge($qq_kk++, $qq); |
| 561 |
$total_time += $qq[1]; |
| 562 |
$total_num++; |
| 563 |
if ( $qq[1] > 0.002 ) { echo '</div>'; } |
| 564 |
} |
| 565 |
} |
| 566 |
|
| 567 |
echo '<div><pre class="prettyprint linenums" style="font-size:18px;">[' . esc_html( $total_num . '/' . $total_time ) . '] WPBC Requests TOTAL TIME</pre></div>'; |
| 568 |
|
| 569 |
echo '<div class="clear"></div>'; |
| 570 |
|
| 571 |
echo '<div><pre class="prettyprint linenums" style="font-size:18px;">' . esc_html( get_num_queries() . '/' . timer_stop( 0, 3 ) ) . 'qps</pre></div>'; |
| 572 |
|
| 573 |
echo '<div class="clear"></div>'; |
| 574 |
|
| 575 |
echo "</pre>"; |
| 576 |
?><br/><br/><br/><br/><br/><br/><?php |
| 577 |
echo '<div class="clear"></div>'; |
| 578 |
|
| 579 |
//////////////////////////////////////////////////////////////////////////////// |
| 580 |
?></div><?php |
| 581 |
|
| 582 |
echo '</div>'; |
| 583 |
} |
| 584 |
|