PluginProbe
Booking Calendar / 10.1.3
Booking Calendar v10.1.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.1.3, at core/wpbc.php

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