PluginProbe
Booking Calendar / 10.11.3
Booking Calendar v10.11.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 / wpbc.php

wpbc.php in Booking Calendar 10.11.3, at core/wpbc.php

600 lines 28.2 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 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 $min_wp_version = version_compare( WP_BK_MIN_WP_VERSION, $wp_version, '<=' ); // FixIn: 7.0.1.6.
19 if ( ( ! class_exists( 'Booking_Calendar' ) ) && ( $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'); //'&#223;<span style="font-size:0.75em;">&#920;&#920;</span>&kgreen;&imath;&eng;'; // __('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 global $menu;
131 if ( current_user_can( ) ) {
132 $menu[] = array( '', 'read', 'separator-wpbc', '', 'wp-menu-separator wpbc' );
133 }
134 debuge($menu);
135 */
136
137 $booking_menu_position = get_bk_option( 'booking_menu_position' );
138 switch ( $booking_menu_position ) {
139 case 'top':
140 $booking_menu_position = '3.3'; // FixIn: 8.7.7.16.
141 break;
142 case 'middle':
143 global $_wp_last_object_menu; // The index of the last top-level menu in the object menu group
144 $_wp_last_object_menu++;
145 $booking_menu_position = $_wp_last_object_menu; // 58.9;
146 break;
147 case 'bottom':
148 $booking_menu_position = '99.999';
149 break;
150 default:
151 $booking_menu_position = '3.3';
152 break;
153 }
154
155 // FixIn: 10.11.3.3.
156
157 // //FixIn: 9.0.1.7 //scale image by this params: viewBox="-2 -1 20 20"
158 // if( 0 ) {
159 // // calendar4-range https://icons.getbootstrap.com/icons/calendar4-range/
160 // $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="" viewBox="-2 -1 20 20">'
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-.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"/>'
162 // . '<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"/>'
163 // . '</svg>';
164 //
165 // //calendar-range https://icons.getbootstrap.com/icons/calendar-range/
166 // $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">'
167 // . '<path d="M9 7a1 1 0 0 1 1-1h5v2h-5a1 1 0 0 1-1-1zM1 9h4a1 1 0 0 1 0 2H1V9z"/>'
168 // . '<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"/>'
169 // . '</svg>';
170 //
171 // //calendar2-range https://icons.getbootstrap.com/icons/calendar2-range/
172 // $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">'
173 // . '<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"/>'
174 // . '<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"/>'
175 // . '</svg>';
176 // }
177 // // calendar3-range https://icons.getbootstrap.com/icons/calendar3-range/
178 // $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">'
179 // . '<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"/>'
180 // . '<path d="M7 10a1 1 0 0 0 0-2H1v2h6zm2-3h6V5H9a1 1 0 0 0 0 2z"/>'
181 // . '</svg>';
182
183 $svg_icon_integarted = wpbc_get_svg_logo( '#aaa', '#aaa', '0.4' ); // '#aaa', '#aaa', '0.2' .
184
185 self::$instance->admin_menu['master'] = new WPBC_Admin_Menus(
186 'wpbc' , array (
187 'in_menu' => 'root'
188 //, 'mune_icon_url' => '/assets/img/icon-16x16.png'
189 , 'mune_icon_url' => $svg_icon_integarted // FixIn: 9.0.1.7.
190 , 'menu_title' => $title
191 , 'menu_title_second' => __('Bookings', 'booking')
192 , 'page_header' => __('Bookings Listing','booking')
193 , 'browser_header' => __('Bookings Listing', 'booking') . ' - ' . __('Booking Calendar', 'booking')
194 , 'user_role' => get_bk_option( 'booking_user_role_booking' )
195 , 'position' => $booking_menu_position // 3.3 - top //( 58.9 ) // - middle
196 /*
197 (Optional). Positions for Core Menu Items
198 2 Dashboard
199 4 Separator
200 5 Posts
201 10 Media
202 15 Links
203 20 Pages
204 25 Comments
205 59 Separator
206 60 Appearance
207 65 Plugins
208 70 Users
209 75 Tools
210 80 Settings
211 99 Separator
212 */
213 )
214 );
215
216 self::$instance->admin_menu['new'] = new WPBC_Admin_Menus(
217 'wpbc-new' , array (
218 'in_menu' => 'wpbc'
219 , 'menu_title' => '+ ' . ucwords( __('Add booking', 'booking') ) // FixIn: 10.9.3.1.
220 , 'page_header' => ucwords( __('Add booking','booking') )
221 , 'browser_header'=> ucwords( __('Add booking', 'booking') ) . ' - ' . __('Booking Calendar', 'booking')
222 , 'user_role' => get_bk_option( 'booking_user_role_addbooking' )
223 )
224 );
225 self::$instance->admin_menu['availability'] = new WPBC_Admin_Menus( // FixIn: 9.3.0.1.
226 'wpbc-availability' , array (
227 'in_menu' => 'wpbc'
228 , 'menu_title' => ucwords( __('Availability', 'booking') )
229 , 'page_header' => ucwords( __('Availability','booking') )
230 , 'browser_header'=> ucwords( __('Availability', 'booking') ) . ' - ' . __('Booking Calendar', 'booking')
231 , 'user_role' => get_bk_option( 'booking_user_role_availability' ) // FixIn: 9.5.2.2.
232 )
233 );
234 //FixIn: 9.8.15.2.4
235 if ( class_exists( 'wpdev_bk_biz_m' ) )
236 self::$instance->admin_menu['prices'] = new WPBC_Admin_Menus(
237 'wpbc-prices' , array (
238 'in_menu' => 'wpbc'
239 , 'menu_title' => __('Prices', 'booking')
240 , 'page_header' => ucwords( __('Booking Prices','booking') )
241 , 'browser_header'=> __('Prices', 'booking') . ' - ' . __('Booking Calendar', 'booking')
242 , 'user_role' => get_bk_option( 'booking_user_role_prices' ) //FixIn: 9.8.15.2.6
243 )
244 );
245 if ( class_exists( 'wpdev_bk_personal' ) ) {
246 self::$instance->admin_menu['resources'] = new WPBC_Admin_Menus(
247 'wpbc-resources' , array (
248 'in_menu' => 'wpbc'
249 , 'menu_title' => __('Resources', 'booking')
250 , 'page_header' => ucwords( __('Booking resources','booking') )
251 , 'browser_header'=> __('Resources', 'booking') . ' - ' . __('Booking Calendar', 'booking')
252 , 'user_role' => get_bk_option( 'booking_user_role_resources' )
253 )
254 );
255 }
256
257
258 if ( ! class_exists( 'wpdev_bk_personal' ) ) { // FixIn: 10.1.3.1.
259 // FixIn: 9.8.15.7.
260 self::$instance->admin_menu['resources'] = new WPBC_Admin_Menus(
261 'wpbc-resources' , array (
262 'in_menu' => 'wpbc'
263 , 'menu_title' => __('Publish', 'booking') // __('Resource', 'booking')
264 , 'page_header' => ucwords( __('Booking resource','booking') )
265 , 'browser_header'=> __('Resource', 'booking') . ' - ' . __('Booking Calendar', 'booking')
266 , 'user_role' => get_bk_option( 'booking_user_role_settings' )
267 )
268 );
269 }
270
271
272 self::$instance->admin_menu['settings'] = new WPBC_Admin_Menus(
273 'wpbc-settings' , array (
274 'in_menu' => 'wpbc'
275 , 'menu_title' => __('Settings', 'booking')
276 , 'page_header' => __('General Settings','booking')
277 , 'browser_header'=> __('Settings', 'booking') . ' - ' . __('Booking Calendar', 'booking')
278 , 'user_role' => get_bk_option( 'booking_user_role_settings' )
279 )
280 );
281
282
283
284
285 if (
286 ( wpbc_is_user_can_access_wizard_page() ) &&
287 ( ! wpbc_setup_wizard_page__is_all_steps_completed() )
288 ){
289
290 $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
291
292 self::$instance->admin_menu['setup'] = new WPBC_Admin_Menus(
293 'wpbc-setup' , array (
294 'in_menu' => 'wpbc'
295 , 'menu_title' => $setup_steps->get_plugin_menu_title__setup_progress()
296 , 'page_header' => ucwords( __('Setup','booking') )
297 , 'browser_header' => ucwords( __('Setup', 'booking') ) . ' - ' . __('Booking Calendar', 'booking')
298 , 'user_role' => get_bk_option( 'booking_user_role_settings' ) //FixIn: 9.8.15.2.6
299 )
300 );
301 }
302
303
304
305 $simulate_user_id = wpbc_mu__is_simulated_login_as_user();
306 if ( ! empty( $simulate_user_id ) ) {
307
308 $custom_user = get_userdata( $simulate_user_id );
309
310 self::$instance->admin_menu['log_off'] = new WPBC_Admin_Menus(
311 'wpbc-log-off' , array (
312 'in_menu' => 'wpbc'
313 //, 'menu_title' => __( 'Log Out Simulated Login as', 'booking' ) . ' "' . $custom_user->display_name . '"'
314 , 'menu_title' => '<span style="color:#fffcdf;font-size: 11px;font-weight: 400;" title="'
315 . esc_attr( __( 'Log out as regular user and login as super booking admin user', 'booking' ) )
316 .'">'
317 .__( 'Back to Super Admin', 'booking' )
318 .'<span>'
319 /* translators: 1: ... */
320 , 'page_header' => ucwords( sprintf( __( 'Need even more functionality? Check %1$s higher versions %2$s', 'booking' ), '', '' ) )
321 , 'browser_header'=> 'Log In as Super Admin'
322 , 'user_role' => get_bk_option( 'booking_user_role_booking' )
323 )
324 );
325 }
326
327
328
329 //FixIn: 8.0.1.6 // FixIn: 10.1.3.1.
330 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
331
332 $is_show_this_menu = get_bk_option('booking_menu_go_pro');
333
334 if ( 'hide' !== $is_show_this_menu )
335 self::$instance->admin_menu['go_pro'] = new WPBC_Admin_Menus(
336 'wpbc-go-pro' , array (
337 'in_menu' => 'wpbc'
338 , 'menu_title' => __('Get Pro', 'booking')
339 /* translators: 1: ... */
340 , 'page_header' => ucwords( sprintf( __( 'Need even more functionality? Check %1$s higher versions %2$s', 'booking' ), '', '' ) )
341 , 'browser_header'=> 'Booking Calendar'
342 , 'user_role' => get_bk_option( 'booking_user_role_booking' )
343 )
344 );
345 }
346
347 }
348
349
350
351 /**
352 * Get Menu Object
353 *
354 * @param type - menu type
355 * @return boolean
356 */
357 public function get_menu_object( $type ) {
358
359 if ( isset( self::$instance->admin_menu[ $type ] ) )
360 return self::$instance->admin_menu[ $type ];
361 else
362 return false;
363 }
364
365
366 // Include Files
367 private function includes() {
368 require_once WPBC_PLUGIN_DIR . '/core/wpbc-include.php' ;
369 }
370
371
372 private function define_version() {
373
374 // GET VERSION NUMBER
375 $plugin_data = wpbc_file__read_header_info( WPBC_FILE , array( 'Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path' ) , 'plugin' );
376 if (!defined('WPDEV_BK_VERSION')) define('WPDEV_BK_VERSION', $plugin_data['Version'] );
377 }
378
379
380 // Cloning instances of the class is forbidden
381 public function __clone() {
382
383 _doing_it_wrong( __FUNCTION__, esc_html__( 'Action is not allowed!', 'booking' ), '1.0' );
384 }
385
386
387 // Unserializing instances of the class is forbidden
388 public function __wakeup() {
389
390 _doing_it_wrong( __FUNCTION__, esc_html__( 'Action is not allowed!', 'booking' ), '1.0' );
391 }
392
393
394 // Initialization
395 private function start(){
396
397 if ( ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ){ // New A J A X R e s p o n d e r
398
399 if ( 1 ) {
400 $wpdev_booking_obj_in_ajax = new wpdev_booking(); // GO
401 } else {
402 if ( class_exists( 'wpdev_bk_personal' ) ) {
403 $wpdev_bk_personal_in_ajax = new wpdev_bk_personal();
404 }
405 }
406
407 require_once WPBC_PLUGIN_DIR . '/core/lib/wpbc-ajax.php'; // Ajax
408
409 return false;
410 } else { // Usual Loading of plugin
411
412 // We are having Response, its executed in other file: wpbc-response.php
413 if ( WP_BK_RESPONSE )
414 return false;
415
416 if( is_admin() ) {
417 // Define Notices System
418 self::$instance->notice = new WPBC_Notices();
419 }
420
421 // Normal Start
422 self::$instance->booking_obj = new wpdev_booking(); // GO
423
424 // Cron Jobs ..... /////////////////////////////////////////////////
425 self::$instance->cron = new WPBC_Cron();
426 ////////////////////////////////////////////////////////////////////
427 }
428 return true;
429 }
430
431 }
432
433 else: // Its seems that some instance of Booking Calendar still activted!!!
434
435 // FixIn: 7.0.1.6.
436 global $wp_version;
437 $min_wp_version = version_compare( WP_BK_MIN_WP_VERSION, $wp_version, '<=' );
438
439 // FixIn: 7.0.1.6.
440 function wpbc_show_min_wp_version_error() {
441
442 $message_type = 'error';
443 $title = __( 'Error' , 'booking') . '!';
444
445
446 $message = 'Booking Calendar ';
447
448 $booking_version_num = get_option( 'booking_version_num');
449 if ( ! empty( $booking_version_num ) )
450 $message .= '<strong>' . $booking_version_num . '</strong> ';
451
452
453 global $wp_version;
454
455 $message .= sprintf( 'require minimum %s . You are using %s. '
456 , ' <strong>' . 'WordPress ' . WP_BK_MIN_WP_VERSION . '</strong>'
457 , ' <strong>' . 'WordPress ' . $wp_version . '</strong>' );
458 if ( current_user_can( 'update_core' ) ){
459 $message .= ' <a href="' . esc_url( self_admin_url( 'update-core.php' ) ) . '">' . 'Return to Dashboard &rarr; Updates' . '</a>';
460 }
461
462
463 $message_content = '';
464
465 $message_content .= '<div class="clear"></div>';
466
467 $message_content .= '<div class="updated wpbc-settings-notice notice-' . $message_type . ' ' . $message_type . '" style="text-align:left;padding:10px;">';
468
469 if ( ! empty( $title ) )
470 $message_content .= '<strong>' . esc_js( $title ) . '</strong> ';
471
472 $message_content .= html_entity_decode( esc_js( $message ) ,ENT_QUOTES) ;
473
474 $message_content .= '</div>';
475
476 $message_content .= '<div class="clear"></div>';
477
478 echo wp_kses_post( $message_content );
479 }
480
481 function wpbc_show_activation_error() {
482
483 $message_type = 'error';
484 $title = __( 'Error' , 'booking') . '!';
485 $message = 'Please deactivate previous old version of' . ' ' . 'Booking Calendar';
486
487 $booking_version_num = get_option( 'booking_version_num');
488 if ( ! empty( $booking_version_num ) )
489 $message .= ' <strong>' . $booking_version_num . '</strong>';
490
491
492 $is_delete_if_deactive = get_bk_option( 'booking_is_delete_if_deactive' ); // check
493
494 if ( $is_delete_if_deactive == 'On' ) {
495
496 $message .= '<br/><br/> <strong>Warning!</strong> ' . 'All plugin data will be deleted when plugin had deactivated.' . ' '
497 . sprintf( 'If you want to save your plugin data, please uncheck the %s"Delete plugin data"%s at the', '<strong>', '</strong>') . ' ' . __( 'Settings' , 'booking' ) . '.';
498 }
499
500 $message_content = '';
501
502 $message_content .= '<div class="clear"></div>';
503
504 $message_content .= '<div class="updated wpbc-settings-notice notice-' . $message_type . ' ' . $message_type . '" style="text-align:left;padding:10px;">';
505
506 if ( ! empty( $title ) )
507 $message_content .= '<strong>' . esc_js( $title ) . '</strong> ';
508
509 $message_content .= html_entity_decode( esc_js( $message ) ,ENT_QUOTES) ;
510
511 $message_content .= '</div>';
512
513 $message_content .= '<div class="clear"></div>';
514
515 echo wp_kses_post( $message_content );
516 }
517
518
519 if ( ! $min_wp_version ) // FixIn: 7.0.1.6.
520 add_action('admin_notices', 'wpbc_show_min_wp_version_error');
521 else
522 add_action('admin_notices', 'wpbc_show_activation_error');
523
524 return; // Exit
525
526 endif;
527
528
529 /**
530 * The main function responsible for returning the one true Instance to functions everywhere.
531 *
532 * Example: <?php $wpbc = WPBC(); ?>
533 */
534 function WPBC() {
535 return Booking_Calendar::init();
536 }
537
538
539
540 // Start
541 WPBC();
542
543
544
545 //if ( ! defined( 'SAVEQUERIES') ) define('SAVEQUERIES', true);
546
547 //add_action( 'admin_footer', 'show_debug_info', 130 );
548 function show_debug_info() {
549
550 $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 */
551 $request_uri = $server_request_uri; //FixIn:5.4.1
552 if ( strpos( $request_uri, 'page=wpbc') === false ) {
553 return;
554 }
555 echo '<div style="width:800px;margin:10px auto;"><style type="text/css"> a:link{background: inherit !important; } pre { white-space: pre-wrap; }</style>';
556 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_phpinfo
557 phpinfo(); echo '</div>'; return;
558
559 ?><div style="width:auto;margin:0 0 0 215px;font-size:11px; "><?php
560
561 // SYSTEM INFO SHOWING ////////////////////////////////////////////////////////
562
563 //Note firstly need to define this in functions.php file: define('SAVEQUERIES', true);
564 global $wpdb;
565 echo '<div class="clear"></div>START SYSTEM<pre>';
566 $qq_kk = 0;
567 $total_time = 0;
568 $total_num = 0;
569 foreach ( $wpdb->queries as $qq_k => $qq ) {
570 if (
571 ( strpos( $qq[0], 'booking') !== false )
572
573 ) {
574 if ( $qq[1] > 0.002 ) { echo '<div style="color:#A77;font-weight:bold;">'; }
575 debuge($qq_kk++, $qq);
576 $total_time += $qq[1];
577 $total_num++;
578 if ( $qq[1] > 0.002 ) { echo '</div>'; }
579 }
580 }
581
582 echo '<div><pre class="prettyprint linenums" style="font-size:18px;">[' . esc_html( $total_num . '/' . $total_time ) . '] WPBC Requests TOTAL TIME</pre></div>';
583
584 echo '<div class="clear"></div>';
585
586 echo '<div><pre class="prettyprint linenums" style="font-size:18px;">' . esc_html( get_num_queries() . '/' . timer_stop( 0, 3 ) ) . 'qps</pre></div>';
587
588 echo '<div class="clear"></div>';
589
590 echo "</pre>";
591 ?><br/><br/><br/><br/><br/><br/><?php
592 echo '<div class="clear"></div>';
593
594 ////////////////////////////////////////////////////////////////////////////////
595 ?></div><?php
596
597 echo '</div>';
598 }
599
600