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 +101 -20 11.411.8.2 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * @version 1.0
4 4 * @package Booking Calendar
@@ -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,9 +63,9 @@
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
63 -function wpbc_get_wpbc_versions_numbers() {
67 +function wpbc_get_wpbc_versions_numbers() {
64 68
65 69 $version_numbers = array();
66 70
67 71 if ( defined( 'WP_BK_VERSION_NUM' ) ) {
@@ -77,10 +81,71 @@
77 81 }
78 82
79 83 $version_numbers_str = implode( ' | ', $version_numbers );
80 84
81 - return $version_numbers_str;
82 -}
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 +}
83 148
84 149
85 150 function wpbc_get_version_type__and_mu(){
86 151 $version = 'free';
@@ -182,9 +247,9 @@
182 247 * Is show upgrade link.
183 248 *
184 249 * @return bool
185 250 */
186 -function wpbc_is_show_up() {
251 +function wpbc_is_show_up() {
187 252
188 253 // $is_show_up = get_bk_option( 'booking_wpdev_copyright_adminpanel' );
189 254 // $is_show_up = ( ( 'Off' !== $is_show_up ) && ( ! class_exists( 'wpdev_bk_multiuser' ) ) );
190 255 // return $is_show_up;
@@ -190,13 +255,29 @@
190 255 // return $is_show_up;
191 256
192 257 $is_show_up = ( ( 'hide' !== get_bk_option( 'booking_menu_go_pro' ) ) && ( ! class_exists( 'wpdev_bk_multiuser' ) ) );
193 258
194 - return $is_show_up;
195 -}
196 -
197 -
198 -/**
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 +/**
199 280 * Get Up link.
200 281 *
201 282 * @return string
202 283 */