PluginProbe
Booking Calendar / 11.8.2
Booking Calendar v11.8.2
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 10.11.3 All 202 releases
← All changes | includes/_functions/versions.php +251 -38 10.1011.8.2 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * @version 1.0
4 4 * @package Booking Calendar
@@ -24,9 +24,9 @@
24 24 * @return bool
25 25 */
26 26 function wpbc_is_this_demo() {
27 27
28 - // return false; //.
28 +// return true; //.
29 29
30 30 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
31 31 return false; // If this is Booking Calendar Free version, then it's not the demo.
32 32 }
@@ -39,21 +39,25 @@
39 39 }
40 40 }
41 41
42 42
43 -/**
44 - * Check if this Beta Demo website
45 - *
46 - * @return bool
47 - */
48 -function wpbc_is_this_beta() {
43 +/**
44 + * Determine whether the current request uses the local beta hostname.
45 + *
46 + * The comparison intentionally ignores a port and one trailing DNS dot. It
47 + * does not classify beta subdomains or path names as the trusted beta host.
48 + *
49 + * @return bool True only for an HTTP Host whose normalized hostname is `beta`.
50 + */
51 +function wpbc_is_this_beta() {
52 + $http_host = isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : '';
53 + $http_host = wp_parse_url( 'http://' . ltrim( strtolower( $http_host ), '/' ), PHP_URL_HOST );
54 + $is_beta = is_string( $http_host ) && ( 'beta' === rtrim( $http_host, '.' ) );
55 +
56 + return $is_beta;
57 +}
49 58
50 - $is_beta = ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( 'beta' === $_SERVER['HTTP_HOST'] ) );
51 59
52 - return $is_beta;
53 -}
54 -
55 -
56 60 /** Get Warning Text for Demo websites */
57 61 function wpbc_get_warning_text_in_demo_mode() {
58 62 // return '<div class="wpbc-error-message wpbc_demo_test_version_warning"><strong>Warning!</strong> Demo test version does not allow changes to these items.</div>'; //Old Style
59 63 return '<div class="wpbc-settings-notice notice-warning"><strong>Warning!</strong> Demo test version does not allow changes to these items.</div>';
@@ -59,8 +63,91 @@
59 63 return '<div class="wpbc-settings-notice notice-warning"><strong>Warning!</strong> Demo test version does not allow changes to these items.</div>';
60 64 }
61 65
62 66
67 +function wpbc_get_wpbc_versions_numbers() {
68 +
69 + $version_numbers = array();
70 +
71 + if ( defined( 'WP_BK_VERSION_NUM' ) ) {
72 + $version_numbers [] = WP_BK_VERSION_NUM;
73 + } else {
74 + $version_numbers [] = ( defined( 'WPDEV_BK_VERSION' ) ) ? WPDEV_BK_VERSION : 'N/A';
75 + }
76 +
77 + if ( defined( 'WPBC_PRO_VERSION_NUM' ) ) {
78 + if ( ( count( $version_numbers ) > 0 ) && ( $version_numbers[0] !== WPBC_PRO_VERSION_NUM ) ) {
79 + $version_numbers [] = WPBC_PRO_VERSION_NUM;
80 + }
81 + }
82 +
83 + $version_numbers_str = implode( ' | ', $version_numbers );
84 +
85 + return $version_numbers_str;
86 +}
87 +
88 +
89 +/**
90 + * Prevent the legacy Pro Simple booking form branch from requiring a removed Free file.
91 + *
92 + * Pro versions before 11.4 require `page-form-simple.php` only when the legacy
93 + * `booking_is_use_simple_booking_form` option is enabled. Newer Free versions no longer contain that file. Because the
94 + * Pro loader runs on `wpbc_loaded_php_files`, this check must happen immediately before that action is fired; waiting
95 + * until `plugins_loaded` is too late and can result in a fatal `require_once` error. Other legacy Pro configurations
96 + * remain loadable for the mixed-version compatibility layer.
97 + *
98 + * @return bool True when an incompatible Pro loader was removed, otherwise false.
99 + */
100 +function wpbc_prevent_incompatible_pro_version_loading() {
101 +
102 + $pro_loader_priority = has_action( 'wpbc_loaded_php_files', 'wpbc_pro_load_php_files' );
103 +
104 + if ( false === $pro_loader_priority ) {
105 + return false;
106 + }
107 +
108 + $is_legacy_pro_version = (
109 + ! defined( 'WPBC_PRO_VERSION_NUM' )
110 + || version_compare( WPBC_PRO_VERSION_NUM, WP_BK_PRO_BFB_ONLY_VERSION, '<' )
111 + );
112 + $is_legacy_simple_form_enabled = ( 'On' === get_bk_option( 'booking_is_use_simple_booking_form' ) );
113 + $is_legacy_simple_form_missing = ! file_exists( WPBC_PLUGIN_DIR . '/includes/page-form-simple/page-form-simple.php' );
114 +
115 + if ( ! $is_legacy_pro_version || ! $is_legacy_simple_form_enabled || ! $is_legacy_simple_form_missing ) {
116 + return false;
117 + }
118 +
119 + remove_action( 'wpbc_loaded_php_files', 'wpbc_pro_load_php_files', $pro_loader_priority );
120 +
121 + if ( is_admin() ) {
122 + add_action( 'admin_notices', 'wpbc_show_error__legacy_simple_form_pro_version' );
123 + }
124 +
125 + return true;
126 +}
127 +
128 +
129 +/**
130 + * Show an actionable notice after the legacy Simple booking form Pro loader has been disabled.
131 + *
132 + * @return void
133 + */
134 +function wpbc_show_error__legacy_simple_form_pro_version() {
135 +
136 + $pro_version = defined( 'WPBC_PRO_VERSION_NUM' ) ? WPBC_PRO_VERSION_NUM : __( 'unknown', 'booking' );
137 +
138 + $message = sprintf(
139 + /* translators: 1: Installed Pro version, 2: Installed Free version, 3: First Pro version without legacy form pages. */
140 + __( 'Booking Calendar Pro %1$s cannot load because its legacy Simple booking form option is enabled, but Booking Calendar %2$s no longer contains that legacy settings module. Pro loading was stopped to prevent a fatal error. Update Booking Calendar Pro to version %3$s or newer; using matching Free and Pro versions is recommended.', 'booking' ),
141 + '<strong>' . esc_html( $pro_version ) . '</strong>',
142 + '<strong>' . esc_html( WP_BK_VERSION_NUM ) . '</strong>',
143 + '<strong>' . esc_html( WP_BK_PRO_BFB_ONLY_VERSION ) . '</strong>'
144 + );
145 +
146 + echo '<div class="notice notice-error"><p>' . wp_kses_post( $message ) . '</p></div>';
147 +}
148 +
149 +
63 150 function wpbc_get_version_type__and_mu(){
64 151 $version = 'free';
65 152 if ( class_exists( 'wpdev_bk_personal' ) ) $version = 'personal';
66 153 if ( class_exists( 'wpdev_bk_biz_s' ) ) $version = 'biz_s';
@@ -81,8 +168,40 @@
81 168 }
82 169
83 170
84 171 /**
172 + * Get Title of the version type.
173 + *
174 + * @return string
175 + */
176 +function wpbc_get_plugin_version_title() {
177 + $title = 'Free';
178 + $version_type = wpbc_get_version_type__and_mu();
179 + switch ( $version_type ) {
180 + case 'personal':
181 + $title = 'Personal';
182 + break;
183 + case 'biz_s':
184 + $title = 'Business Small';
185 + break;
186 + case 'biz_m':
187 + $title = 'Business Medium';
188 + break;
189 + case 'biz_l':
190 + $title = 'Business Large';
191 + break;
192 + case 'multiuser':
193 + $title = 'MultiUser';
194 + break;
195 + default:
196 + $title = 'Free';
197 + }
198 +
199 + return $title;
200 +}
201 +
202 +
203 +/**
85 204 * Check if user accidentially update Booking Calendar Paid version to Free
86 205 *
87 206 * @return bool
88 207 */
@@ -95,30 +214,89 @@
95 214 }
96 215
97 216
98 217 function wpbc_get_ver_sufix() {
99 - if( strpos( strtolower(WPDEV_BK_VERSION) , 'multisite') !== false ) {
218 + if ( strpos( strtolower( WPDEV_BK_VERSION ), 'multisite' ) !== false ) {
100 219 $v_type = '-multi';
101 - } else if( strpos( strtolower(WPDEV_BK_VERSION) , 'develop') !== false ) {
220 + } else if ( strpos( strtolower( WPDEV_BK_VERSION ), 'develop' ) !== false ) {
102 221 $v_type = '-dev';
103 222 } else {
104 223 $v_type = '';
105 224 }
106 225 $v = '';
107 - if (class_exists('wpdev_bk_personal')) $v = 'ps'. $v_type;
108 - if (class_exists('wpdev_bk_biz_s')) $v = 'bs'. $v_type;
109 - if (class_exists('wpdev_bk_biz_m')) $v = 'bm'. $v_type;
110 - if (class_exists('wpdev_bk_biz_l')) $v = 'bl'. $v_type;
111 - if (class_exists('wpdev_bk_multiuser')) $v = '';
112 - return $v ;
226 + if ( class_exists( 'wpdev_bk_personal' ) ) {
227 + $v = 'ps' . $v_type;
228 + }
229 + if ( class_exists( 'wpdev_bk_biz_s' ) ) {
230 + $v = 'bs' . $v_type;
231 + }
232 + if ( class_exists( 'wpdev_bk_biz_m' ) ) {
233 + $v = 'bm' . $v_type;
234 + }
235 + if ( class_exists( 'wpdev_bk_biz_l' ) ) {
236 + $v = 'bl' . $v_type;
237 + }
238 + if ( class_exists( 'wpdev_bk_multiuser' ) ) {
239 + $v = '';
240 + }
241 +
242 + return $v;
113 243 }
114 244
115 245
246 +/**
247 + * Is show upgrade link.
248 + *
249 + * @return bool
250 + */
251 +function wpbc_is_show_up() {
252 +
253 + // $is_show_up = get_bk_option( 'booking_wpdev_copyright_adminpanel' );
254 + // $is_show_up = ( ( 'Off' !== $is_show_up ) && ( ! class_exists( 'wpdev_bk_multiuser' ) ) );
255 + // return $is_show_up;
256 +
257 + $is_show_up = ( ( 'hide' !== get_bk_option( 'booking_menu_go_pro' ) ) && ( ! class_exists( 'wpdev_bk_multiuser' ) ) );
258 +
259 + return $is_show_up;
260 +}
261 +
262 +
263 +/**
264 + * Check whether Free-edition upgrade navigation may be shown.
265 + *
266 + * This combines the existing administrator preference and MultiUser policy
267 + * with the product-edition check used by Free-only upgrade actions.
268 + *
269 + * @since 11.8.0
270 + *
271 + * @return bool True when Free-edition upgrade navigation may be rendered.
272 + */
273 +function wpbc_is_show_free_upgrade() {
274 +
275 + return wpbc_is_show_up() && ! class_exists( 'wpdev_bk_personal' );
276 +}
277 +
278 +
279 +/**
280 + * Get Up link.
281 + *
282 + * @return string
283 + */
116 284 function wpbc_up_link() {
117 - if ( ! wpbc_is_this_demo() )
118 - $v = wpbc_get_ver_sufix();
119 - else $v = '';
120 - return 'https://wpbookingcalendar.com/' . ( ( empty($v) ) ? '' : 'upgrade-' . $v . '/' ) ;
285 +
286 + if ( ! wpbc_is_this_demo() ) {
287 + $v = wpbc_get_ver_sufix();
288 + } else {
289 + $v = '';
290 + }
291 +
292 + if ( empty( $v ) ) {
293 + $v = 'features/';
294 + } else {
295 + $v = 'upgrade-' . $v . '/';
296 + }
297 +
298 + return 'https://wpbookingcalendar.com/' . $v;
121 299 }
122 300
123 301
124 302 /**
@@ -181,8 +359,37 @@
181 359 return $file_data;
182 360 }
183 361
184 362
363 +function wpbc_get_json_property_from_meta( $property_key ) {
364 +
365 + if ( ! defined( 'WPBC_PRO_FILE' ) ) {
366 + return null;
367 + }
368 +
369 + $meta_file_path = plugin_dir_path( WPBC_PRO_FILE ) . 'meta.json';
370 +
371 + if ( ( ! is_file( $meta_file_path ) ) || ( ! is_readable( $meta_file_path ) ) ) {
372 + return null;
373 + }
374 +
375 + // Read the local plugin metadata directly, so hosts with FTP-based WP_Filesystem settings cannot fatal here.
376 + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
377 + $json_contents = file_get_contents( $meta_file_path );
378 +
379 + if ( false === $json_contents || '' === trim( $json_contents ) ) {
380 + return null;
381 + }
382 +
383 + $data = json_decode( $json_contents, true );
384 +
385 + if ( ( json_last_error() !== JSON_ERROR_NONE ) || ( ! is_array( $data ) ) ) {
386 + return null;
387 + }
388 +
389 + return array_key_exists( $property_key, $data ) ? $data[ $property_key ] : null;
390 +}
391 +
185 392 /**
186 393 * Check if we need BLUR this section -- add CSS Class for specific versions
187 394 *
188 395 * Example: $is_blured = wpbc_is_blured( array( 'free', 'ps' ) ); // true in Free and Personal versions.
@@ -349,9 +556,10 @@
349 556 'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#capacity' ),
350 557 'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ),
351 558 'versions' => 'Business Large, MultiUser versions',
352 559 'css' => 'transform: translate(0) translateY(120px);',
353 - 'dismiss_css_class' => '' //'.wpbc_random_' . round( microtime( true ) * 1000 ), //'.'.$id . '_' . 'weekdays_conditions'
560 + 'dismiss_css_class' => '', //'.wpbc_random_' . round( microtime( true ) * 1000 ), //'.'.$id . '_' . 'weekdays_conditions'
561 + 'no_dismiss' => false
354 562 );
355 563 $params = wp_parse_args( $params, $defaults );
356 564 $up_id = $params['id'];
357 565
@@ -362,20 +570,25 @@
362 570 $blur_css_class = '';
363 571
364 572 if ( $is_blured ) {
365 573
366 - // ---------------------------------------------------------------------------------------------------------
367 - // Is dismissed ?
368 - // ---------------------------------------------------------------------------------------------------------
369 - ob_start();
370 - $is_upgrade_panel_visible = wpbc_is_dismissed( $up_id , array(
371 - 'title' => '<span aria-hidden="true" style="font-size: 28px;">&times;</span>',
372 - 'hint' => __( 'Dismiss', 'booking' ),
373 - 'class' => 'wpbc_panel_get_started_dismiss',
374 - 'css' => '',
375 - 'dismiss_css_class' => $params['dismiss_css_class']
376 - ) );
377 - $html_dismiss_btn = ob_get_clean();
574 + if ( $params['no_dismiss'] ) {
575 + $is_upgrade_panel_visible = true;
576 + $html_dismiss_btn = '';
577 + } else {
578 + // ---------------------------------------------------------------------------------------------------------
579 + // Is dismissed ?
580 + // ---------------------------------------------------------------------------------------------------------
581 + ob_start();
582 + $is_upgrade_panel_visible = wpbc_is_dismissed( $up_id , array(
583 + 'title' => '<span aria-hidden="true" style="font-size: 28px;">&times;</span>',
584 + 'hint' => __( 'Dismiss', 'booking' ),
585 + 'class' => 'wpbc_panel_get_started_dismiss',
586 + 'css' => '',
587 + 'dismiss_css_class' => $params['dismiss_css_class']
588 + ) );
589 + $html_dismiss_btn = ob_get_clean();
590 + }
378 591
379 592 // ---------------------------------------------------------------------------------------------------------
380 593 // Upgrade Widget
381 594 // ---------------------------------------------------------------------------------------------------------
@@ -440,9 +653,9 @@
440 653 function wpbc_get_info__about_how_old() {
441 654 global $wpdb;
442 655
443 656 $sql = "SELECT modification_date FROM {$wpdb->prefix}booking as bk ORDER by booking_id LIMIT 0,1";
444 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
657 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
445 658 $res = $wpdb->get_results( $sql );
446 659
447 660 if ( ! empty( $res ) ) {
448 661