PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 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 All 205 releases
← All changes | includes/_functions/versions.php +113 -40 11.4.1 → 11.9 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * @version 1.0
4 4 * @package Booking Calendar
@@ -17,43 +17,39 @@
17 17 // =====================================================================================================================
18 18 // == Versions ==
19 19 // =====================================================================================================================
20 20
21 -/**
22 - * Check if this demo website
23 - *
24 - * @return bool
25 - */
26 -function wpbc_is_this_demo() {
21 +/**
22 + * Check whether the site is a managed public Booking Calendar live demo.
23 + *
24 + * This compatibility helper delegates to the shared environment policy so
25 + * legacy consumers and newer capability checks cannot classify the same host
26 + * differently.
27 + *
28 + * @return bool True for a managed public live demo.
29 + */
30 +function wpbc_is_this_demo() {
31 + return WPBC_Environment_Policy::is_live_demo();
32 +}
27 33
28 -// return true; //.
29 34
30 - if ( ! class_exists( 'wpdev_bk_personal' ) ) {
31 - return false; // If this is Booking Calendar Free version, then it's not the demo.
32 - }
35 +/**
36 + * Determine whether the current request uses the local beta hostname.
37 + *
38 + * The comparison intentionally ignores a port and one trailing DNS dot. It
39 + * does not classify beta subdomains or path names as the trusted beta host.
40 + *
41 + * @return bool True only for an HTTP Host whose normalized hostname is `beta`.
42 + */
43 +function wpbc_is_this_beta() {
44 + $http_host = isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : '';
45 + $http_host = wp_parse_url( 'http://' . ltrim( strtolower( $http_host ), '/' ), PHP_URL_HOST );
46 + $is_beta = is_string( $http_host ) && ( 'beta' === rtrim( $http_host, '.' ) );
47 +
48 + return $is_beta;
49 +}
33 50
34 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
35 - if ( ( ( isset( $_SERVER['SCRIPT_FILENAME'] ) ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'wpbookingcalendar.com' ) !== false ) ) || ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( strpos( $_SERVER['HTTP_HOST'], 'wpbookingcalendar.com' ) !== false ) ) ) {
36 - return true;
37 - } else {
38 - return false;
39 - }
40 -}
41 51
42 -
43 -/**
44 - * Check if this Beta Demo website
45 - *
46 - * @return bool
47 - */
48 -function wpbc_is_this_beta() {
49 -
50 - $is_beta = ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( 'beta' === $_SERVER['HTTP_HOST'] ) );
51 -
52 - return $is_beta;
53 -}
54 -
55 -
56 52 /** Get Warning Text for Demo websites */
57 53 function wpbc_get_warning_text_in_demo_mode() {
58 54 // 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 55 return '<div class="wpbc-settings-notice notice-warning"><strong>Warning!</strong> Demo test version does not allow changes to these items.</div>';
@@ -59,9 +55,9 @@
59 55 return '<div class="wpbc-settings-notice notice-warning"><strong>Warning!</strong> Demo test version does not allow changes to these items.</div>';
60 56 }
61 57
62 58
63 -function wpbc_get_wpbc_versions_numbers() {
59 +function wpbc_get_wpbc_versions_numbers() {
64 60
65 61 $version_numbers = array();
66 62
67 63 if ( defined( 'WP_BK_VERSION_NUM' ) ) {
@@ -77,10 +73,71 @@
77 73 }
78 74
79 75 $version_numbers_str = implode( ' | ', $version_numbers );
80 76
81 - return $version_numbers_str;
82 -}
77 + return $version_numbers_str;
78 +}
79 +
80 +
81 +/**
82 + * Prevent the legacy Pro Simple booking form branch from requiring a removed Free file.
83 + *
84 + * Pro versions before 11.4 require `page-form-simple.php` only when the legacy
85 + * `booking_is_use_simple_booking_form` option is enabled. Newer Free versions no longer contain that file. Because the
86 + * Pro loader runs on `wpbc_loaded_php_files`, this check must happen immediately before that action is fired; waiting
87 + * until `plugins_loaded` is too late and can result in a fatal `require_once` error. Other legacy Pro configurations
88 + * remain loadable for the mixed-version compatibility layer.
89 + *
90 + * @return bool True when an incompatible Pro loader was removed, otherwise false.
91 + */
92 +function wpbc_prevent_incompatible_pro_version_loading() {
93 +
94 + $pro_loader_priority = has_action( 'wpbc_loaded_php_files', 'wpbc_pro_load_php_files' );
95 +
96 + if ( false === $pro_loader_priority ) {
97 + return false;
98 + }
99 +
100 + $is_legacy_pro_version = (
101 + ! defined( 'WPBC_PRO_VERSION_NUM' )
102 + || version_compare( WPBC_PRO_VERSION_NUM, WP_BK_PRO_BFB_ONLY_VERSION, '<' )
103 + );
104 + $is_legacy_simple_form_enabled = ( 'On' === get_bk_option( 'booking_is_use_simple_booking_form' ) );
105 + $is_legacy_simple_form_missing = ! file_exists( WPBC_PLUGIN_DIR . '/includes/page-form-simple/page-form-simple.php' );
106 +
107 + if ( ! $is_legacy_pro_version || ! $is_legacy_simple_form_enabled || ! $is_legacy_simple_form_missing ) {
108 + return false;
109 + }
110 +
111 + remove_action( 'wpbc_loaded_php_files', 'wpbc_pro_load_php_files', $pro_loader_priority );
112 +
113 + if ( is_admin() ) {
114 + add_action( 'admin_notices', 'wpbc_show_error__legacy_simple_form_pro_version' );
115 + }
116 +
117 + return true;
118 +}
119 +
120 +
121 +/**
122 + * Show an actionable notice after the legacy Simple booking form Pro loader has been disabled.
123 + *
124 + * @return void
125 + */
126 +function wpbc_show_error__legacy_simple_form_pro_version() {
127 +
128 + $pro_version = defined( 'WPBC_PRO_VERSION_NUM' ) ? WPBC_PRO_VERSION_NUM : __( 'unknown', 'booking' );
129 +
130 + $message = sprintf(
131 + /* translators: 1: Installed Pro version, 2: Installed Free version, 3: First Pro version without legacy form pages. */
132 + __( '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' ),
133 + '<strong>' . esc_html( $pro_version ) . '</strong>',
134 + '<strong>' . esc_html( WP_BK_VERSION_NUM ) . '</strong>',
135 + '<strong>' . esc_html( WP_BK_PRO_BFB_ONLY_VERSION ) . '</strong>'
136 + );
137 +
138 + echo '<div class="notice notice-error"><p>' . wp_kses_post( $message ) . '</p></div>';
139 +}
83 140
84 141
85 142 function wpbc_get_version_type__and_mu(){
86 143 $version = 'free';
@@ -182,9 +239,9 @@
182 239 * Is show upgrade link.
183 240 *
184 241 * @return bool
185 242 */
186 -function wpbc_is_show_up() {
243 +function wpbc_is_show_up() {
187 244
188 245 // $is_show_up = get_bk_option( 'booking_wpdev_copyright_adminpanel' );
189 246 // $is_show_up = ( ( 'Off' !== $is_show_up ) && ( ! class_exists( 'wpdev_bk_multiuser' ) ) );
190 247 // return $is_show_up;
@@ -190,13 +247,29 @@
190 247 // return $is_show_up;
191 248
192 249 $is_show_up = ( ( 'hide' !== get_bk_option( 'booking_menu_go_pro' ) ) && ( ! class_exists( 'wpdev_bk_multiuser' ) ) );
193 250
194 - return $is_show_up;
195 -}
196 -
197 -
198 -/**
251 + return $is_show_up;
252 +}
253 +
254 +
255 +/**
256 + * Check whether Free-edition upgrade navigation may be shown.
257 + *
258 + * This combines the existing administrator preference and MultiUser policy
259 + * with the product-edition check used by Free-only upgrade actions.
260 + *
261 + * @since 11.8.0
262 + *
263 + * @return bool True when Free-edition upgrade navigation may be rendered.
264 + */
265 +function wpbc_is_show_free_upgrade() {
266 +
267 + return wpbc_is_show_up() && ! class_exists( 'wpdev_bk_personal' );
268 +}
269 +
270 +
271 +/**
199 272 * Get Up link.
200 273 *
201 274 * @return string
202 275 */