| 1 |
<?php |
| 2 |
/** |
| 3 |
* Welcome Page Class |
| 4 |
* Shows a feature overview for the new version (major). |
| 5 |
* Adapted from code in EDD (Copyright (c) 2012, Pippin Williamson) and WP. |
| 6 |
* @version 2.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
// Exit if accessed directly. |
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
require_once WPBC_PLUGIN_DIR . '/core/class/welcome_current.php'; |
| 15 |
|
| 16 |
class WPBC_Welcome { |
| 17 |
|
| 18 |
/** |
| 19 |
* Minimum capability, such as 'read' or 'manage_options' |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
public $minimum_capability = 'read'; |
| 23 |
|
| 24 |
/** |
| 25 |
* Path to images. |
| 26 |
* @var string |
| 27 |
*/ |
| 28 |
public $asset_path = ( true ) ? 'https://wpbookingcalendar.com/assets/' : 'http://beta/assets/'; |
| 29 |
|
| 30 |
/** |
| 31 |
* Constructor |
| 32 |
*/ |
| 33 |
public function __construct() { |
| 34 |
|
| 35 |
add_action( 'admin_menu', array( $this, 'admin_menus' ) ); |
| 36 |
|
| 37 |
add_action( 'admin_init', array( $this, 'welcome' ) ); |
| 38 |
|
| 39 |
add_action( 'load-dashboard_page_wpbc-about', array( $this, 'wpbc_define_page_title_about' ) ); |
| 40 |
} |
| 41 |
|
| 42 |
public function wpbc_define_page_title_about() { // FixIn: 9.6.2.12. |
| 43 |
global $title; |
| 44 |
if ( ! isset( $title ) ) { |
| 45 |
$title = 'Welcome to Booking Calendar'; |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
public function show_separator() { |
| 50 |
echo '<div class="clear" style="height:1px;border-bottom:1px solid #DFDFDF;"></div>'; |
| 51 |
} |
| 52 |
|
| 53 |
public function show_header( $text = '', $header_type = 'h3', $style = '' ) { |
| 54 |
echo '<', esc_attr( $header_type ); |
| 55 |
if ( ! empty( $style ) ) { |
| 56 |
echo " style='" . esc_attr( $style ) . "'"; |
| 57 |
} |
| 58 |
echo '>'; |
| 59 |
echo wp_kses_post( wpbc_replace_to_strong_symbols( $text ) ); |
| 60 |
echo '</', esc_attr( $header_type ), '>'; |
| 61 |
} |
| 62 |
|
| 63 |
public function show_col_section( $sections_array = array() ) { |
| 64 |
|
| 65 |
$columns_num = count( $sections_array ); |
| 66 |
|
| 67 |
if ( isset( $sections_array['h3'] ) ) { |
| 68 |
$columns_num --; |
| 69 |
} |
| 70 |
if ( isset( $sections_array['h2'] ) ) { |
| 71 |
$columns_num --; |
| 72 |
} |
| 73 |
?> |
| 74 |
<div class="changelog"><?php |
| 75 |
|
| 76 |
if ( isset( $sections_array['h3'] ) ) { |
| 77 |
echo "<h3>" . wp_kses_post( wpbc_replace_to_strong_symbols( $sections_array['h3'] ) ) . "</h3>"; |
| 78 |
unset( $sections_array['h3'] ); |
| 79 |
} |
| 80 |
if ( isset( $sections_array['h2'] ) ) { |
| 81 |
echo "<h2>" . wp_kses_post( wpbc_replace_to_strong_symbols( $sections_array['h2'] ) ) . "</h2>"; |
| 82 |
unset( $sections_array['h2'] ); |
| 83 |
} |
| 84 |
|
| 85 |
?> |
| 86 |
<div class="feature-section <?php |
| 87 |
if ( $columns_num == 2 ) { |
| 88 |
echo ' two-col'; |
| 89 |
} |
| 90 |
if ( $columns_num == 3 ) { |
| 91 |
echo ' three-col'; |
| 92 |
} ?>"> |
| 93 |
<?php |
| 94 |
foreach ( $sections_array as $section_key => $section ) { |
| 95 |
$col_num = ( $section_key + 1 ); |
| 96 |
if ( $columns_num == $col_num ) { |
| 97 |
$is_last_feature = ' last-feature '; |
| 98 |
} else { |
| 99 |
$is_last_feature = ''; |
| 100 |
} |
| 101 |
|
| 102 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 103 |
echo "<div class='col col-{$col_num}{$is_last_feature}'>"; |
| 104 |
|
| 105 |
if ( isset( $section['header'] ) ) { |
| 106 |
echo "<h4>" . wp_kses_post( wpbc_replace_to_strong_symbols( $section['header'] ) ) . "</h4>"; |
| 107 |
} |
| 108 |
if ( isset( $section['h4'] ) ) { |
| 109 |
echo "<h4>" . wp_kses_post( wpbc_replace_to_strong_symbols( $section['h4'] ) ) . "</h4>"; |
| 110 |
} |
| 111 |
if ( isset( $section['h3'] ) ) { |
| 112 |
echo "<h3>" . wp_kses_post( wpbc_replace_to_strong_symbols( $section['h3'] ) ) . "</h3>"; |
| 113 |
} |
| 114 |
if ( isset( $section['h2'] ) ) { |
| 115 |
echo "<h2>" . wp_kses_post( wpbc_replace_to_strong_symbols( $section['h2'] ) ) . "</h2>"; |
| 116 |
} |
| 117 |
if ( isset( $section['text'] ) ) { |
| 118 |
echo wp_kses_post( wpbc_replace_to_strong_symbols( $section['text'] ) ); |
| 119 |
} |
| 120 |
if ( isset( $section['img'] ) ) { |
| 121 |
|
| 122 |
$is_full_link = strpos( $section['img'], 'http' ); |
| 123 |
if ( false === $is_full_link ) { |
| 124 |
// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage |
| 125 |
echo '<img src="' . esc_url( $this->asset_path . $section['img'] ) . '" '; |
| 126 |
} else { |
| 127 |
// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage |
| 128 |
echo '<img src="' . esc_url( $section['img'] ) . '" '; |
| 129 |
} |
| 130 |
if ( isset( $section['img_style'] ) ) { |
| 131 |
echo ' style="' . esc_attr( $section['img_style'] ) . '" '; |
| 132 |
} |
| 133 |
echo ' class="wpbc-section-image" />'; |
| 134 |
} |
| 135 |
|
| 136 |
echo "</div>"; |
| 137 |
} |
| 138 |
?> |
| 139 |
</div> |
| 140 |
</div> |
| 141 |
<?php |
| 142 |
} |
| 143 |
|
| 144 |
public function get_img( $img, $img_style = '' ) { |
| 145 |
|
| 146 |
$is_full_link = strpos( $img, 'http' ); |
| 147 |
if ( false === $is_full_link ) { |
| 148 |
// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage |
| 149 |
$img_result = '<img src="' . esc_url( $this->asset_path . $img ) . '" '; |
| 150 |
} else { |
| 151 |
// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage |
| 152 |
$img_result = '<img src="' . esc_url( $img ) . '" '; |
| 153 |
} |
| 154 |
|
| 155 |
if ( ! empty( $img_style ) ) { |
| 156 |
$img_result .= ' style="' . esc_attr( $img_style ) . '" '; |
| 157 |
} |
| 158 |
$img_result .= ' class="wpbc-section-image" />'; |
| 159 |
|
| 160 |
return $img_result; |
| 161 |
} |
| 162 |
|
| 163 |
// ----------------------------------------------------------------------------------------------------------------- |
| 164 |
// Menu |
| 165 |
public function admin_menus() { |
| 166 |
// What's New. |
| 167 |
add_dashboard_page( sprintf( 'Welcome to Booking Calendar' ), sprintf( 'What\'s New' ), $this->minimum_capability, 'wpbc-about', array( $this, 'content_whats_new' ) ); |
| 168 |
remove_submenu_page( 'index.php', 'wpbc-about' ); |
| 169 |
} |
| 170 |
|
| 171 |
// Head. |
| 172 |
public function admin_head() { |
| 173 |
remove_submenu_page( 'index.php', 'wpbc-about' ); |
| 174 |
} |
| 175 |
|
| 176 |
// Title |
| 177 |
public function title_section() { |
| 178 |
|
| 179 |
list( $display_version ) = explode( '-', WPDEV_BK_VERSION ); |
| 180 |
//$display_version = WP_BK_VERSION_NUM; |
| 181 |
?> |
| 182 |
<h1><?php echo wp_kses_post( sprintf( 'Welcome to Booking Calendar %s', $display_version ) ); ?></h1> |
| 183 |
<div class="about-text"><?php |
| 184 |
echo ( 'Booking Calendar is ready to receive and manage bookings from your visitors!' ); |
| 185 |
?></div> |
| 186 |
|
| 187 |
|
| 188 |
<h2 class="nav-tab-wrapper"> |
| 189 |
<?php |
| 190 |
$is_about_tab_active = $is_about_premium_tab_active = $is_getting_started_tab_active = ''; |
| 191 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 192 |
if ( ( isset( $_GET[ 'page' ] ) ) && ( $_GET[ 'page' ] == 'wpbc-about' ) ) |
| 193 |
$is_about_tab_active = ' nav-tab-active '; |
| 194 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 195 |
if ( ( isset( $_GET[ 'page' ] ) ) && ( $_GET[ 'page' ] == 'wpbc-about-premium' ) ) |
| 196 |
$is_about_premium_tab_active = ' nav-tab-active '; |
| 197 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 198 |
if ( ( isset( $_GET[ 'page' ] ) ) && ( $_GET[ 'page' ] == 'wpbc-getting-started' ) ) |
| 199 |
$is_getting_started_tab_active = ' nav-tab-active '; |
| 200 |
?> |
| 201 |
<a class="nav-tab<?php echo esc_attr( $is_about_tab_active ); ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( |
| 202 |
'page' => 'wpbc-about' ), 'index.php' ) ) ); ?>"> |
| 203 |
<?php echo( "What's New" ); ?> |
| 204 |
<a class="nav-tab<?php echo esc_attr( $is_getting_started_tab_active ); ?>" href="https://wpbookingcalendar.com/faq/#using"> |
| 205 |
<?php echo( "Get Started" ); ?> |
| 206 |
</a><a class="nav-tab<?php echo esc_attr( $is_about_premium_tab_active ); ?>" href="https://wpbookingcalendar.com/features/"> |
| 207 |
<?php echo( "Get even more functionality" ); // echo( "Even more Premium Features" ); ?> |
| 208 |
</a> |
| 209 |
</h2> |
| 210 |
<?php |
| 211 |
} |
| 212 |
|
| 213 |
/** |
| 214 |
* Maintenance section |
| 215 |
*/ |
| 216 |
public function maintence_section() { |
| 217 |
|
| 218 |
if ( ! ( ( defined( 'WP_BK_MINOR_UPDATE' ) ) && ( WP_BK_MINOR_UPDATE ) ) ) { |
| 219 |
return; |
| 220 |
} |
| 221 |
|
| 222 |
list( $display_version ) = explode( '-', WPDEV_BK_VERSION ); |
| 223 |
?> |
| 224 |
<div class="changelog point-releases" style="margin: 40px 0 50px;"> |
| 225 |
<h3><?php |
| 226 |
echo( "Maintenance Release" ); ?></h3> |
| 227 |
<p><strong><?php |
| 228 |
echo wp_kses_post( sprintf( 'Version %s', $display_version ) ); ?></strong> <?php |
| 229 |
echo 'addressed some minor issues and improvement in functionality'; ?>. |
| 230 |
<?php |
| 231 |
echo wp_kses_post( sprintf( 'For more information, see %sthe release notes%s', '<a href="https://wpbookingcalendar.com/changelog/" target="_blank">', '</a>' ) ); ?> |
| 232 |
. |
| 233 |
</p> |
| 234 |
</div> |
| 235 |
<?php |
| 236 |
} |
| 237 |
|
| 238 |
// Start |
| 239 |
public function welcome() { |
| 240 |
|
| 241 |
$booking_activation_process = get_bk_option( 'booking_activation_process' ); |
| 242 |
if ( $booking_activation_process == 'On' ) |
| 243 |
return; |
| 244 |
|
| 245 |
// Bail if no activation redirect transient is set |
| 246 |
if ( ! get_transient( '_booking_activation_redirect' ) ) { // $. |
| 247 |
return; |
| 248 |
} |
| 249 |
|
| 250 |
// Delete the redirect transient |
| 251 |
delete_transient( '_booking_activation_redirect' ); |
| 252 |
|
| 253 |
// Bail if DEMO or activating from network, or bulk, or within an iFrame. |
| 254 |
|
| 255 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 256 |
if ( wpbc_is_this_demo() || is_network_admin() || isset( $_GET[ 'activate-multi' ] ) || defined( 'IFRAME_REQUEST' ) ) |
| 257 |
return; |
| 258 |
|
| 259 |
// Set mark, that we already redirected to About screen //FixIn: 5.4.5 |
| 260 |
$redirect_for_version = get_bk_option( 'booking_activation_redirect_for_version' ); |
| 261 |
if ( $redirect_for_version == WP_BK_VERSION_NUM ) |
| 262 |
return; |
| 263 |
else |
| 264 |
update_bk_option( 'booking_activation_redirect_for_version', WP_BK_VERSION_NUM ); |
| 265 |
|
| 266 |
wp_safe_redirect( admin_url( 'index.php?page=wpbc-about' ) ); |
| 267 |
exit; |
| 268 |
} |
| 269 |
|
| 270 |
|
| 271 |
// CONTENT ///////////////////////////////////////////////////////////////// |
| 272 |
|
| 273 |
public function show_go_links() { |
| 274 |
?> |
| 275 |
<div style="display: flex;flex-flow: row wrap;justify-content: center;gap: 2em;margin: 3em 0 1em;"> |
| 276 |
<a class="button button-primary" |
| 277 |
href="<?php |
| 278 |
echo esc_url( wpbc_get_bookings_url() . '&tab=vm_booking_listing' ); ?>" |
| 279 |
style="font-size: 20px;padding: 0 1em;height: 44px;line-height: 40px;"><?php |
| 280 |
esc_html_e( 'Go to Booking Admin Panel', 'booking' ); ?></a> |
| 281 |
<?php |
| 282 |
$wpbc_starter_pages = function_exists( 'wpbc_get_published_activation_booking_pages' ) ? wpbc_get_published_activation_booking_pages() : array(); |
| 283 |
if ( ! empty( $wpbc_starter_pages ) ) { |
| 284 |
foreach ( $wpbc_starter_pages as $wpbc_starter_page ) { |
| 285 |
?> |
| 286 |
<a class="button button-secondary" |
| 287 |
style="font-size: 20px;padding: 0 1em;height: 44px;line-height: 40px;" |
| 288 |
href="<?php |
| 289 |
echo esc_url( $wpbc_starter_page['url'] ); ?>" |
| 290 |
><?php |
| 291 |
echo esc_html( $wpbc_starter_page['button_title'] ); ?></a> |
| 292 |
<?php |
| 293 |
} |
| 294 |
} else { |
| 295 |
$wp_post_booking_absolute = false; |
| 296 |
if ( ! empty( $wp_post_booking_absolute ) ) { |
| 297 |
?> |
| 298 |
<a class="button button-secondary" |
| 299 |
style="font-size: 20px;padding: 0 1em;height: 44px;line-height: 40px;" |
| 300 |
href="<?php |
| 301 |
echo esc_url( $wp_post_booking_absolute ); ?>" |
| 302 |
><?php |
| 303 |
esc_html_e( 'Go to page with booking form', 'booking' ); ?></a> |
| 304 |
<?php |
| 305 |
} |
| 306 |
} ?> |
| 307 |
</div> |
| 308 |
<?php |
| 309 |
} |
| 310 |
|
| 311 |
public function content_whats_new() { |
| 312 |
|
| 313 |
echo '<div class="wrap about-wrap wpbc-welcome-page">'; |
| 314 |
|
| 315 |
$this->title_section(); |
| 316 |
|
| 317 |
$this->show_go_links(); |
| 318 |
|
| 319 |
$this->maintence_section(); |
| 320 |
|
| 321 |
$this->section_9_8_css(); |
| 322 |
|
| 323 |
wpbc_welcome_section_11_8_1( $this ); |
| 324 |
wpbc_welcome_section_11_8( $this ); |
| 325 |
wpbc_welcome_section_11_7( $this ); |
| 326 |
wpbc_welcome_section_11_6( $this ); |
| 327 |
wpbc_welcome_section_11_5( $this ); |
| 328 |
wpbc_welcome_section_11_4( $this ); |
| 329 |
wpbc_welcome_section_11_3( $this ); |
| 330 |
wpbc_welcome_section_11_2( $this ); |
| 331 |
wpbc_welcome_section_11_1( $this ); |
| 332 |
wpbc_welcome_section_11_0( $this ); |
| 333 |
wpbc_welcome_section_10_15( $this ); |
| 334 |
wpbc_welcome_section_10_14( $this ); |
| 335 |
wpbc_welcome_section_10_13( $this ); |
| 336 |
|
| 337 |
$this->show_go_links(); |
| 338 |
|
| 339 |
echo '<div'; |
| 340 |
} |
| 341 |
|
| 342 |
|
| 343 |
function expand_section_start( $section_param_arr ) { |
| 344 |
|
| 345 |
?> |
| 346 |
<div class="clear" style="margin-top:20px;"></div><?php |
| 347 |
|
| 348 |
if ( $section_param_arr['show_expand'] ) { |
| 349 |
|
| 350 |
?><a id="wpbc_show_advanced_section_link_show" |
| 351 |
class="wpbc_expand_section_link" |
| 352 |
href="javascript:void(0)" |
| 353 |
onclick="javascript:jQuery( '.version_update_<?php |
| 354 |
echo esc_attr( str_replace( array( |
| 355 |
'.', ' ', |
| 356 |
), '_', $section_param_arr['version_num'] ) ); ?>' ).toggle();" |
| 357 |
>+ Show changes in version update <span |
| 358 |
style="font-size: 1.35em;font-weight: 600;color: #079;font-family: Consolas,Monaco,monospace;padding-left:12px;"><?php |
| 359 |
echo esc_html( $section_param_arr['version_num'] ); ?></span> |
| 360 |
</a> |
| 361 |
<div class="version_update_<?php |
| 362 |
echo esc_attr( str_replace( array( |
| 363 |
'.', ' ', |
| 364 |
), '_', $section_param_arr['version_num'] ) ); ?>" style="display:none;"> |
| 365 |
<?php |
| 366 |
|
| 367 |
} |
| 368 |
|
| 369 |
?><h2 style='font-size: 1.9em;text-align:left;'>What's New in Booking Calendar <span |
| 370 |
style="font-size: 1.1em;font-weight: 600;font-family: Consolas,Monaco,monospace;padding-left: 10px;color: #5F5F5F;" |
| 371 |
><?php |
| 372 |
echo esc_html( $section_param_arr['version_num'] ); ?></span></h2><?php |
| 373 |
|
| 374 |
} |
| 375 |
|
| 376 |
|
| 377 |
function expand_section_end( $section_param_arr ) { |
| 378 |
if ( $section_param_arr['show_expand'] ) { |
| 379 |
?></div><?php |
| 380 |
} |
| 381 |
} |
| 382 |
|
| 383 |
|
| 384 |
function section_img_url( $relative_path_to_img ) { |
| 385 |
|
| 386 |
return esc_url( $this->asset_path . $relative_path_to_img ); |
| 387 |
} |
| 388 |
|
| 389 |
|
| 390 |
function section_9_8_css(){ |
| 391 |
|
| 392 |
?><style type="text/css"> |
| 393 |
.about-wrap.wpbc-welcome-page { |
| 394 |
position: relative; |
| 395 |
margin: 25px 40px 0 20px; |
| 396 |
max-width: 1050px; |
| 397 |
font-size: 15px; |
| 398 |
clear: both; |
| 399 |
} |
| 400 |
.wpbc_wn_container{ |
| 401 |
margin: 24px auto; |
| 402 |
overflow: hidden; |
| 403 |
} |
| 404 |
.wpbc_wn_section{ |
| 405 |
display: flex; |
| 406 |
flex-flow: row wrap; |
| 407 |
justify-content: space-between; |
| 408 |
align-content: flex-start; |
| 409 |
align-items: flex-start; |
| 410 |
font-size: 1.05em; |
| 411 |
line-height: 2rem; |
| 412 |
margin: 1em 0; |
| 413 |
} |
| 414 |
.wpbc_wn_col{ |
| 415 |
flex: 1 1 50%; |
| 416 |
padding: 1.5em 2em; |
| 417 |
box-sizing: border-box; |
| 418 |
} |
| 419 |
@media screen and (max-width: 782px) { |
| 420 |
.wpbc_wn_col{ |
| 421 |
flex: 1 1 100%; |
| 422 |
} |
| 423 |
} |
| 424 |
.wpbc_wn_separator{ |
| 425 |
flex: 1 1 100%; |
| 426 |
} |
| 427 |
.wpbc_wn_col * { |
| 428 |
margin: 0; |
| 429 |
line-height: 2.2em; |
| 430 |
} |
| 431 |
.wpbc_wn_section > h2, |
| 432 |
.wpbc_wn_section > h3{ |
| 433 |
margin: 0 0 0.25em; |
| 434 |
font-size: 2em; |
| 435 |
line-height: 2.16em; |
| 436 |
font-weight: 600; |
| 437 |
flex: 1 1 100%; |
| 438 |
text-align: center; |
| 439 |
padding:0 1.5em; |
| 440 |
} |
| 441 |
.wpbc_wn_section h3 { |
| 442 |
font-size: 1.25em; |
| 443 |
text-align: left; |
| 444 |
margin: 0.25em 0 0.5em; |
| 445 |
} |
| 446 |
.wpbc_wn_section img{ |
| 447 |
border-radius: 2px; |
| 448 |
box-shadow: none; |
| 449 |
width: 99%; |
| 450 |
margin: 0.5em 0 auto; |
| 451 |
padding: 3px; |
| 452 |
background: #fff; |
| 453 |
border: 1px solid #ccc; |
| 454 |
} |
| 455 |
.wpbc_wn_container .wpbc_hr_dots { |
| 456 |
height: 1px; |
| 457 |
border:none; |
| 458 |
border-bottom: 0.5rem dotted #a9a9a9; |
| 459 |
width: 3rem; |
| 460 |
margin:0 auto; |
| 461 |
clear: both:; |
| 462 |
display: block; |
| 463 |
position: relative; |
| 464 |
} |
| 465 |
</style> |
| 466 |
<?php |
| 467 |
} |
| 468 |
} |
| 469 |
|
| 470 |
$wpbc_welcome = new WPBC_Welcome(); |
| 471 |
|