| 1 |
<?php |
| 2 |
/** |
| 3 |
* @version 1.0 |
| 4 |
* @package Booking Calendar |
| 5 |
* @subpackage Versions Functions |
| 6 |
* @category Functions |
| 7 |
* |
| 8 |
* @author wpdevelop |
| 9 |
* @link https://wpbookingcalendar.com/ |
| 10 |
* @email info@wpbookingcalendar.com |
| 11 |
* |
| 12 |
* @modified 2024-09-03 |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 16 |
|
| 17 |
// ===================================================================================================================== |
| 18 |
// == Versions == |
| 19 |
// ===================================================================================================================== |
| 20 |
|
| 21 |
/** |
| 22 |
* Check if this demo website |
| 23 |
* |
| 24 |
* @return bool |
| 25 |
*/ |
| 26 |
function wpbc_is_this_demo() { |
| 27 |
|
| 28 |
// return true; //. |
| 29 |
|
| 30 |
if ( ! class_exists( 'wpdev_bk_personal' ) ) { |
| 31 |
return false; // If this is Booking Calendar Free version, then it's not the demo. |
| 32 |
} |
| 33 |
|
| 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 |
|
| 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 |
/** Get Warning Text for Demo websites */ |
| 57 |
function wpbc_get_warning_text_in_demo_mode() { |
| 58 |
// 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 |
return '<div class="wpbc-settings-notice notice-warning"><strong>Warning!</strong> Demo test version does not allow changes to these items.</div>'; |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
function wpbc_get_wpbc_versions_numbers() { |
| 64 |
|
| 65 |
$version_numbers = array(); |
| 66 |
|
| 67 |
if ( defined( 'WP_BK_VERSION_NUM' ) ) { |
| 68 |
$version_numbers [] = WP_BK_VERSION_NUM; |
| 69 |
} else { |
| 70 |
$version_numbers [] = ( defined( 'WPDEV_BK_VERSION' ) ) ? WPDEV_BK_VERSION : 'N/A'; |
| 71 |
} |
| 72 |
|
| 73 |
if ( defined( 'WPBC_PRO_VERSION_NUM' ) ) { |
| 74 |
if ( ( count( $version_numbers ) > 0 ) && ( $version_numbers[0] !== WPBC_PRO_VERSION_NUM ) ) { |
| 75 |
$version_numbers [] = WPBC_PRO_VERSION_NUM; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
$version_numbers_str = implode( ' | ', $version_numbers ); |
| 80 |
|
| 81 |
return $version_numbers_str; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
function wpbc_get_version_type__and_mu(){ |
| 86 |
$version = 'free'; |
| 87 |
if ( class_exists( 'wpdev_bk_personal' ) ) $version = 'personal'; |
| 88 |
if ( class_exists( 'wpdev_bk_biz_s' ) ) $version = 'biz_s'; |
| 89 |
if ( class_exists( 'wpdev_bk_biz_m' ) ) $version = 'biz_m'; |
| 90 |
if ( class_exists( 'wpdev_bk_biz_l' ) ) $version = 'biz_l'; |
| 91 |
if ( class_exists('wpdev_bk_multiuser') ) $version = 'multiuser'; |
| 92 |
return $version; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
function wpbc_get_plugin_version_type(){ |
| 97 |
$version = 'free'; |
| 98 |
if ( class_exists( 'wpdev_bk_personal' ) ) $version = 'personal'; |
| 99 |
if ( class_exists( 'wpdev_bk_biz_s' ) ) $version = 'biz_s'; |
| 100 |
if ( class_exists( 'wpdev_bk_biz_m' ) ) $version = 'biz_m'; |
| 101 |
if ( class_exists( 'wpdev_bk_biz_l' ) ) $version = 'biz_l'; |
| 102 |
return $version; |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
/** |
| 107 |
* Get Title of the version type. |
| 108 |
* |
| 109 |
* @return string |
| 110 |
*/ |
| 111 |
function wpbc_get_plugin_version_title() { |
| 112 |
$title = 'Free'; |
| 113 |
$version_type = wpbc_get_version_type__and_mu(); |
| 114 |
switch ( $version_type ) { |
| 115 |
case 'personal': |
| 116 |
$title = 'Personal'; |
| 117 |
break; |
| 118 |
case 'biz_s': |
| 119 |
$title = 'Business Small'; |
| 120 |
break; |
| 121 |
case 'biz_m': |
| 122 |
$title = 'Business Medium'; |
| 123 |
break; |
| 124 |
case 'biz_l': |
| 125 |
$title = 'Business Large'; |
| 126 |
break; |
| 127 |
case 'multiuser': |
| 128 |
$title = 'MultiUser'; |
| 129 |
break; |
| 130 |
default: |
| 131 |
$title = 'Free'; |
| 132 |
} |
| 133 |
|
| 134 |
return $title; |
| 135 |
} |
| 136 |
|
| 137 |
|
| 138 |
/** |
| 139 |
* Check if user accidentially update Booking Calendar Paid version to Free |
| 140 |
* |
| 141 |
* @return bool |
| 142 |
*/ |
| 143 |
function wpbc_is_updated_paid_to_free() { |
| 144 |
|
| 145 |
if ( ( wpbc_is_table_exists('bookingtypes') ) && ( ! class_exists('wpdev_bk_personal') ) ) |
| 146 |
return true; |
| 147 |
else |
| 148 |
return false; |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
function wpbc_get_ver_sufix() { |
| 153 |
if ( strpos( strtolower( WPDEV_BK_VERSION ), 'multisite' ) !== false ) { |
| 154 |
$v_type = '-multi'; |
| 155 |
} else if ( strpos( strtolower( WPDEV_BK_VERSION ), 'develop' ) !== false ) { |
| 156 |
$v_type = '-dev'; |
| 157 |
} else { |
| 158 |
$v_type = ''; |
| 159 |
} |
| 160 |
$v = ''; |
| 161 |
if ( class_exists( 'wpdev_bk_personal' ) ) { |
| 162 |
$v = 'ps' . $v_type; |
| 163 |
} |
| 164 |
if ( class_exists( 'wpdev_bk_biz_s' ) ) { |
| 165 |
$v = 'bs' . $v_type; |
| 166 |
} |
| 167 |
if ( class_exists( 'wpdev_bk_biz_m' ) ) { |
| 168 |
$v = 'bm' . $v_type; |
| 169 |
} |
| 170 |
if ( class_exists( 'wpdev_bk_biz_l' ) ) { |
| 171 |
$v = 'bl' . $v_type; |
| 172 |
} |
| 173 |
if ( class_exists( 'wpdev_bk_multiuser' ) ) { |
| 174 |
$v = ''; |
| 175 |
} |
| 176 |
|
| 177 |
return $v; |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
/** |
| 182 |
* Is show upgrade link. |
| 183 |
* |
| 184 |
* @return bool |
| 185 |
*/ |
| 186 |
function wpbc_is_show_up() { |
| 187 |
|
| 188 |
// $is_show_up = get_bk_option( 'booking_wpdev_copyright_adminpanel' ); |
| 189 |
// $is_show_up = ( ( 'Off' !== $is_show_up ) && ( ! class_exists( 'wpdev_bk_multiuser' ) ) ); |
| 190 |
// return $is_show_up; |
| 191 |
|
| 192 |
$is_show_up = ( ( 'hide' !== get_bk_option( 'booking_menu_go_pro' ) ) && ( ! class_exists( 'wpdev_bk_multiuser' ) ) ); |
| 193 |
|
| 194 |
return $is_show_up; |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
/** |
| 199 |
* Get Up link. |
| 200 |
* |
| 201 |
* @return string |
| 202 |
*/ |
| 203 |
function wpbc_up_link() { |
| 204 |
|
| 205 |
if ( ! wpbc_is_this_demo() ) { |
| 206 |
$v = wpbc_get_ver_sufix(); |
| 207 |
} else { |
| 208 |
$v = ''; |
| 209 |
} |
| 210 |
|
| 211 |
if ( empty( $v ) ) { |
| 212 |
$v = 'features/'; |
| 213 |
} else { |
| 214 |
$v = 'upgrade-' . $v . '/'; |
| 215 |
} |
| 216 |
|
| 217 |
return 'https://wpbookingcalendar.com/' . $v; |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
/** |
| 222 |
* Check if "Booking Manager" installed/activated and return version number |
| 223 |
* |
| 224 |
* @return string - 0 if not installed, otherwise version num |
| 225 |
*/ |
| 226 |
function wpbc_get_wpbm_version() { |
| 227 |
|
| 228 |
if ( ! defined( 'WPBM_VERSION_NUM' ) ) { |
| 229 |
return 0; |
| 230 |
} else { |
| 231 |
return WPBM_VERSION_NUM; |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
/** |
| 237 |
* Get header info from this file, just for compatibility with WordPress 2.8 and older versions |
| 238 |
* |
| 239 |
* @param $file = WPBC_FILE |
| 240 |
* @param $default_headers = array( 'Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path' ) |
| 241 |
* @param $context = 'plugin' |
| 242 |
* |
| 243 |
* @return array |
| 244 |
* |
| 245 |
* Example: |
| 246 |
* $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' ); |
| 247 |
*/ |
| 248 |
function wpbc_file__read_header_info( $file, $default_headers, $context = '' ) { |
| 249 |
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen |
| 250 |
$fp = fopen( $file, 'r' ); // We don't need to write to the file, so just open for reading. |
| 251 |
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fread |
| 252 |
$file_data = fread( $fp, 8192 ); // Pull only the first 8kiB of the file in. |
| 253 |
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose |
| 254 |
fclose( $fp ); // PHP will close file handle, but we are good citizens. |
| 255 |
|
| 256 |
if ( $context != '' ) { |
| 257 |
$extra_headers = array(); //apply_filters( "extra_$context".'_headers', array() ); |
| 258 |
|
| 259 |
$extra_headers = array_flip( $extra_headers ); |
| 260 |
foreach ( $extra_headers as $key => $value ) { |
| 261 |
$extra_headers[ $key ] = $key; |
| 262 |
} |
| 263 |
$all_headers = array_merge( $extra_headers, $default_headers ); |
| 264 |
} else { |
| 265 |
$all_headers = $default_headers; |
| 266 |
} |
| 267 |
|
| 268 |
foreach ( $all_headers as $field => $regex ) { |
| 269 |
preg_match( '/' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field}); |
| 270 |
if ( !empty( ${$field} ) ) |
| 271 |
${$field} = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', ${$field}[1] )); |
| 272 |
else |
| 273 |
${$field} = ''; |
| 274 |
} |
| 275 |
|
| 276 |
$file_data = compact( array_keys( $all_headers ) ); |
| 277 |
|
| 278 |
return $file_data; |
| 279 |
} |
| 280 |
|
| 281 |
|
| 282 |
function wpbc_get_json_property_from_meta( $property_key ) { |
| 283 |
|
| 284 |
if ( ! defined( 'WPBC_PRO_FILE' ) ) { |
| 285 |
return null; |
| 286 |
} |
| 287 |
|
| 288 |
$meta_file_path = plugin_dir_path( WPBC_PRO_FILE ) . 'meta.json'; |
| 289 |
|
| 290 |
if ( ( ! is_file( $meta_file_path ) ) || ( ! is_readable( $meta_file_path ) ) ) { |
| 291 |
return null; |
| 292 |
} |
| 293 |
|
| 294 |
// Read the local plugin metadata directly, so hosts with FTP-based WP_Filesystem settings cannot fatal here. |
| 295 |
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents |
| 296 |
$json_contents = file_get_contents( $meta_file_path ); |
| 297 |
|
| 298 |
if ( false === $json_contents || '' === trim( $json_contents ) ) { |
| 299 |
return null; |
| 300 |
} |
| 301 |
|
| 302 |
$data = json_decode( $json_contents, true ); |
| 303 |
|
| 304 |
if ( ( json_last_error() !== JSON_ERROR_NONE ) || ( ! is_array( $data ) ) ) { |
| 305 |
return null; |
| 306 |
} |
| 307 |
|
| 308 |
return array_key_exists( $property_key, $data ) ? $data[ $property_key ] : null; |
| 309 |
} |
| 310 |
|
| 311 |
/** |
| 312 |
* Check if we need BLUR this section -- add CSS Class for specific versions |
| 313 |
* |
| 314 |
* Example: $is_blured = wpbc_is_blured( array( 'free', 'ps' ) ); // true in Free and Personal versions. |
| 315 |
* |
| 316 |
* @param $versions_arr |
| 317 |
* |
| 318 |
* @return void |
| 319 |
*/ |
| 320 |
function wpbc_is_blured( $versions_arr ){ |
| 321 |
|
| 322 |
$ver = wpbc_get_version_type__and_mu(); |
| 323 |
|
| 324 |
$is_blured = false; |
| 325 |
|
| 326 |
switch ( $ver ) { |
| 327 |
case 'free': |
| 328 |
$is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'f', $versions_arr ) ) ) ? true : $is_blured; |
| 329 |
break; |
| 330 |
case 'personal': |
| 331 |
$is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'ps', $versions_arr ) ) ) ? true : $is_blured; |
| 332 |
break; |
| 333 |
case 'biz_s': |
| 334 |
$is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'bs', $versions_arr ) ) ) ? true : $is_blured; |
| 335 |
break; |
| 336 |
case 'biz_m': |
| 337 |
$is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'bm', $versions_arr ) ) ) ? true : $is_blured; |
| 338 |
break; |
| 339 |
case 'biz_l': |
| 340 |
$is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'bl', $versions_arr ) ) ) ? true : $is_blured; |
| 341 |
break; |
| 342 |
case 'multiuser': |
| 343 |
$is_blured = ( ( in_array( $ver, $versions_arr ) ) || ( in_array( 'mu', $versions_arr ) ) ) ? true : $is_blured; |
| 344 |
break; |
| 345 |
default: |
| 346 |
// Default |
| 347 |
} |
| 348 |
return $is_blured; |
| 349 |
} |
| 350 |
|
| 351 |
|
| 352 |
/** |
| 353 |
* Echo Blur CSS Class for specific versions |
| 354 |
* |
| 355 |
* Example: wpbc_echo_blur(array('free','ps')); // Echo blur in Free and Personal versions. |
| 356 |
* |
| 357 |
* @param $versions_arr |
| 358 |
* |
| 359 |
* @return void |
| 360 |
*/ |
| 361 |
function wpbc_echo_blur( $versions_arr ){ |
| 362 |
|
| 363 |
$is_blured = wpbc_is_blured( $versions_arr ); |
| 364 |
|
| 365 |
if ( $is_blured ) { |
| 366 |
echo 'wpbc_blur'; |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
|
| 371 |
/** |
| 372 |
* Show Upgrade Widget |
| 373 |
* |
| 374 |
* @param $id |
| 375 |
* @param $params |
| 376 |
* |
| 377 |
* @return string if upgrade panel hided than returned '' |
| 378 |
* |
| 379 |
* |
| 380 |
* Example: |
| 381 |
* wpbc_get_up_notice('booking_weekdays_conditions', array( |
| 382 |
* 'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#capacity' ), |
| 383 |
* 'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ), |
| 384 |
* 'versions' => 'Business Large, MultiUser versions', |
| 385 |
* 'css' => 'transform: translate(0) translateY(120px);' |
| 386 |
* )); |
| 387 |
*/ |
| 388 |
function wpbc_get__upgrade_notice__html_content( $id, $params ){ |
| 389 |
|
| 390 |
$defaults = array( |
| 391 |
'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#capacity' ), |
| 392 |
'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ), |
| 393 |
'versions' => 'Business Large, MultiUser versions', |
| 394 |
'css' => 'transform: translate(0) translateY(120px);', |
| 395 |
'dismiss_css_class' => '', |
| 396 |
'html_dismiss_btn' => '' |
| 397 |
); |
| 398 |
$params = wp_parse_args( $params, $defaults ); |
| 399 |
|
| 400 |
ob_start(); |
| 401 |
|
| 402 |
?><div id="upgrade_notice_<?php echo esc_attr( $id ); ?>" |
| 403 |
class="wpbc_widget_content wpbc_upgrade_widget <?php echo esc_attr( str_replace( array('.','#'), '', $params['dismiss_css_class'] ) ); ?>" |
| 404 |
style="<?php echo esc_attr( $params['css'] ); ?>"> |
| 405 |
<div class="ui_container ui_container_toolbar ui_container_small wpbc_upgrade_widget_container"> |
| 406 |
<div class="ui_group ui_group__upgrade"> |
| 407 |
<div class="wpbc_upgrade_note wpbc_upgrade_theme_green"> |
| 408 |
<div> |
| 409 |
<?php |
| 410 |
echo wp_kses_post( sprintf( 'This %s is available in the %s. %s' |
| 411 |
, '<a target="_blank" href="https://wpbookingcalendar.com/' . $params['feature_link']['relative_url'] . '">' . $params['feature_link']['title'] . '</a>' |
| 412 |
, '<strong>' . $params['versions'] . '</strong>' |
| 413 |
, '<a target="_blank" href="https://wpbookingcalendar.com/' . $params['upgrade_link']['relative_url'] . '">' . $params['upgrade_link']['title'] . '</a>' |
| 414 |
) ); |
| 415 |
?> |
| 416 |
</div> |
| 417 |
<?php |
| 418 |
// Dismiss button |
| 419 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 420 |
echo $params['html_dismiss_btn']; |
| 421 |
?> |
| 422 |
</div> |
| 423 |
</div> |
| 424 |
</div> |
| 425 |
</div><?php |
| 426 |
|
| 427 |
$html = ob_get_clean(); |
| 428 |
|
| 429 |
return $html ; |
| 430 |
} |
| 431 |
|
| 432 |
|
| 433 |
/** |
| 434 |
* Get for showing Upgrade Widget Content and CSS class if needed to blur real content. If |
| 435 |
* |
| 436 |
* @param $params = array( |
| 437 |
* 'id' => $id . '_' . 'weekdays_conditions', |
| 438 |
* 'dismiss_css_class' => '.wpbc_dismiss_weekdays_conditions', |
| 439 |
* 'blured_in_versions' => array( 'free', 'ps', 'bs', 'mu' ), |
| 440 |
* 'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#advanced-days-selection' ), |
| 441 |
* 'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ), |
| 442 |
* 'versions' => 'Business Medium / Large, MultiUser versions', |
| 443 |
* 'css' => 'transform: translate(0) translateY(120px);' |
| 444 |
* ) |
| 445 |
* |
| 446 |
* @return array( |
| 447 |
* 'content' => $upgrade_panel_html, |
| 448 |
* 'maybe_blur_css_class' => $blur_css_class |
| 449 |
* ) |
| 450 |
* |
| 451 |
* Example of usage: |
| 452 |
* |
| 453 |
* $upgrade_content_arr = wpbc_get_upgrade_widget( array( |
| 454 |
* 'id' => $id . '_' . 'weekdays_conditions', |
| 455 |
* 'dismiss_css_class' => '.wpbc_dismiss_weekdays_conditions', |
| 456 |
* 'blured_in_versions' => array( 'free', 'ps', 'bs', 'mu' ), |
| 457 |
* 'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#advanced-days-selection' ), |
| 458 |
* 'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ), |
| 459 |
* 'versions' => 'Business Medium / Large, MultiUser versions', |
| 460 |
* 'css' => 'transform: translate(0) translateY(120px);' |
| 461 |
* ) ); |
| 462 |
* |
| 463 |
* echo $upgrade_content_arr['content']; |
| 464 |
* |
| 465 |
* // ... In real content ... |
| 466 |
* <div class=" wpbc_dismiss_weekdays_conditions <?php echo esc_attr( $upgrade_content_arr['maybe_blur_css_class'] ); ?>"> |
| 467 |
* ... |
| 468 |
* </div> |
| 469 |
*/ |
| 470 |
function wpbc_get_upgrade_widget( $params ) { |
| 471 |
|
| 472 |
$defaults = array( |
| 473 |
'id' => 'wpbc_random_' . round( microtime( true ) * 1000 ), //$id . '_' . 'weekdays_conditions', |
| 474 |
'blured_in_versions' => array( 'free', 'ps', 'bs', 'bm', 'bl', 'mu' ), |
| 475 |
'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#capacity' ), |
| 476 |
'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ), |
| 477 |
'versions' => 'Business Large, MultiUser versions', |
| 478 |
'css' => 'transform: translate(0) translateY(120px);', |
| 479 |
'dismiss_css_class' => '', //'.wpbc_random_' . round( microtime( true ) * 1000 ), //'.'.$id . '_' . 'weekdays_conditions' |
| 480 |
'no_dismiss' => false |
| 481 |
); |
| 482 |
$params = wp_parse_args( $params, $defaults ); |
| 483 |
$up_id = $params['id']; |
| 484 |
|
| 485 |
|
| 486 |
$is_blured = wpbc_is_blured( $params['blured_in_versions'] ); |
| 487 |
|
| 488 |
$upgrade_panel_html = ''; |
| 489 |
$blur_css_class = ''; |
| 490 |
|
| 491 |
if ( $is_blured ) { |
| 492 |
|
| 493 |
if ( $params['no_dismiss'] ) { |
| 494 |
$is_upgrade_panel_visible = true; |
| 495 |
$html_dismiss_btn = ''; |
| 496 |
} else { |
| 497 |
// --------------------------------------------------------------------------------------------------------- |
| 498 |
// Is dismissed ? |
| 499 |
// --------------------------------------------------------------------------------------------------------- |
| 500 |
ob_start(); |
| 501 |
$is_upgrade_panel_visible = wpbc_is_dismissed( $up_id , array( |
| 502 |
'title' => '<span aria-hidden="true" style="font-size: 28px;">×</span>', |
| 503 |
'hint' => __( 'Dismiss', 'booking' ), |
| 504 |
'class' => 'wpbc_panel_get_started_dismiss', |
| 505 |
'css' => '', |
| 506 |
'dismiss_css_class' => $params['dismiss_css_class'] |
| 507 |
) ); |
| 508 |
$html_dismiss_btn = ob_get_clean(); |
| 509 |
} |
| 510 |
|
| 511 |
// --------------------------------------------------------------------------------------------------------- |
| 512 |
// Upgrade Widget |
| 513 |
// --------------------------------------------------------------------------------------------------------- |
| 514 |
if ( $is_upgrade_panel_visible ) { |
| 515 |
|
| 516 |
$upgrade_panel_html = wpbc_get__upgrade_notice__html_content( $up_id, array( |
| 517 |
'feature_link' => $params['feature_link'], |
| 518 |
'upgrade_link' => $params['upgrade_link'], |
| 519 |
'versions' => $params['versions'], |
| 520 |
'css' => $params['css'], |
| 521 |
'dismiss_css_class' => $params['dismiss_css_class'], |
| 522 |
'html_dismiss_btn'=> $html_dismiss_btn |
| 523 |
) ); |
| 524 |
$blur_css_class = 'wpbc_blur'; |
| 525 |
} else { |
| 526 |
|
| 527 |
ob_start(); |
| 528 |
|
| 529 |
?><script type="text/javascript"> |
| 530 |
jQuery(document).ready(function(){ |
| 531 |
setTimeout(function(){ |
| 532 |
jQuery( '<?php echo esc_attr( $params['dismiss_css_class'] ); ?>' ).hide() ; |
| 533 |
}, 100); |
| 534 |
}); |
| 535 |
</script><?php |
| 536 |
|
| 537 |
$upgrade_panel_html = ob_get_clean(); |
| 538 |
} |
| 539 |
} |
| 540 |
|
| 541 |
$upgrade_content_arr = array( |
| 542 |
'content' => $upgrade_panel_html, |
| 543 |
'maybe_blur_css_class' => $blur_css_class |
| 544 |
); |
| 545 |
|
| 546 |
return $upgrade_content_arr; |
| 547 |
|
| 548 |
} |
| 549 |
|
| 550 |
|
| 551 |
/** |
| 552 |
* How old ago was installed plugin, based on first booking |
| 553 |
* |
| 554 |
* @return int if -1, then no bookings! |
| 555 |
*/ |
| 556 |
function wpbc_how_old_in_days() { |
| 557 |
|
| 558 |
$how_old = wpbc_get_info__about_how_old(); |
| 559 |
|
| 560 |
if ( ! empty( $how_old ) ) { |
| 561 |
return intval( $how_old['days'] ); |
| 562 |
} else { |
| 563 |
// Unknown. Maybe no bookings |
| 564 |
return -1; |
| 565 |
} |
| 566 |
} |
| 567 |
|
| 568 |
/** |
| 569 |
* Get date info about first booking. |
| 570 |
* @return array|false |
| 571 |
*/ |
| 572 |
function wpbc_get_info__about_how_old() { |
| 573 |
global $wpdb; |
| 574 |
|
| 575 |
$sql = "SELECT modification_date FROM {$wpdb->prefix}booking as bk ORDER by booking_id LIMIT 0,1"; |
| 576 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter |
| 577 |
$res = $wpdb->get_results( $sql ); |
| 578 |
|
| 579 |
if ( ! empty( $res ) ) { |
| 580 |
|
| 581 |
$first_booking_date = wpbc_datetime_localized( gmdate( 'Y-m-d H:i:s', strtotime( $res[0]->modification_date ) ), 'Y-m-d H:i:s' ); |
| 582 |
|
| 583 |
$dif_days = wpbc_get_difference_in_days( gmdate( 'Y-m-d 00:00:00', strtotime( 'now' ) ), gmdate( 'Y-m-d 00:00:00', strtotime( $res[0]->modification_date ) ) ); |
| 584 |
|
| 585 |
return array( |
| 586 |
'date_ymd_his' => $res[0]->modification_date, |
| 587 |
'date_echo' => $first_booking_date, |
| 588 |
'days' => $dif_days |
| 589 |
); |
| 590 |
} |
| 591 |
|
| 592 |
return false; |
| 593 |
} |
| 594 |
|