PluginProbe
Booking Calendar / 11.9.1
Booking Calendar v11.9.1
11.9.1 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 All 206 releases
booking / core / class / wpbc-class-welcome.php

wpbc-class-welcome.php in Booking Calendar 11.9.1, at core/class/wpbc-class-welcome.php

512 lines 16.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 if ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() ) {
246 return;
247 }
248
249 $legacy_redirect = get_transient( '_booking_activation_redirect' );
250 $redirect_intent = class_exists( 'WPBC_Setup_Wizard_First_Install_State' )
251 ? get_transient( WPBC_Setup_Wizard_First_Install_State::ACTIVATION_INTENT_TRANSIENT )
252 : false;
253 $is_whats_new_intent = class_exists( 'WPBC_Setup_Wizard_First_Install_State' )
254 && WPBC_Setup_Wizard_First_Install_State::is_whats_new_redirect_intent( $redirect_intent );
255
256 // A genuine first-install intent belongs exclusively to the earlier Setup Wizard redirect handler.
257 if (
258 class_exists( 'WPBC_Setup_Wizard_First_Install_State' )
259 && WPBC_Setup_Wizard_First_Install_State::is_first_install_redirect_intent( $redirect_intent )
260 ) {
261 return;
262 }
263
264 // Bail if neither the released boolean nor a current structured intent is set.
265 if ( ! $legacy_redirect && ! $is_whats_new_intent ) { // $.
266 return;
267 }
268 if (
269 $is_whats_new_intent
270 && ! WPBC_Setup_Wizard_First_Install_State::is_redirect_intent_for_current_user( $redirect_intent )
271 ) {
272 return;
273 }
274
275 // Delete the redirect transient
276 delete_transient( '_booking_activation_redirect' );
277 if ( class_exists( 'WPBC_Setup_Wizard_First_Install_State' ) ) {
278 delete_transient( WPBC_Setup_Wizard_First_Install_State::ACTIVATION_INTENT_TRANSIENT );
279 }
280
281 // Bail for environments where automatic activation navigation is disabled.
282 $is_redirect_restricted = class_exists( 'WPBC_Setup_Wizard_First_Install_State' )
283 ? WPBC_Setup_Wizard_First_Install_State::is_automatic_onboarding_restricted()
284 : (
285 wpbc_is_this_demo()
286 || ( defined( 'WPBC_IS_PLAYGROUND' ) && true === WPBC_IS_PLAYGROUND )
287 || is_network_admin()
288 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only activation context detection.
289 || isset( $_GET['activate-multi'] )
290 || defined( 'IFRAME_REQUEST' )
291 );
292 if ( $is_redirect_restricted ) {
293 return;
294 }
295
296 // Set mark, that we already redirected to About screen //FixIn: 5.4.5
297 $redirect_for_version = get_bk_option( 'booking_activation_redirect_for_version' );
298 if ( $redirect_for_version == WP_BK_VERSION_NUM )
299 return;
300 else
301 update_bk_option( 'booking_activation_redirect_for_version', WP_BK_VERSION_NUM );
302
303 wp_safe_redirect( admin_url( 'index.php?page=wpbc-about' ) );
304 exit;
305 }
306
307
308 // CONTENT /////////////////////////////////////////////////////////////////
309
310 public function show_go_links() {
311 ?>
312 <div style="display: flex;flex-flow: row wrap;justify-content: center;gap: 2em;margin: 3em 0 1em;">
313 <a class="button button-primary"
314 href="<?php
315 echo esc_url( wpbc_get_bookings_url() . '&tab=vm_booking_listing' ); ?>"
316 style="font-size: 20px;padding: 0 1em;height: 44px;line-height: 40px;"><?php
317 esc_html_e( 'Go to Booking Admin Panel', 'booking' ); ?></a>
318 <?php
319 $wpbc_starter_pages = function_exists( 'wpbc_get_published_activation_booking_pages' ) ? wpbc_get_published_activation_booking_pages() : array();
320 if ( ! empty( $wpbc_starter_pages ) ) {
321 foreach ( $wpbc_starter_pages as $wpbc_starter_page ) {
322 ?>
323 <a class="button button-secondary"
324 style="font-size: 20px;padding: 0 1em;height: 44px;line-height: 40px;"
325 href="<?php
326 echo esc_url( $wpbc_starter_page['url'] ); ?>"
327 ><?php
328 echo esc_html( $wpbc_starter_page['button_title'] ); ?></a>
329 <?php
330 }
331 } else {
332 $wp_post_booking_absolute = false;
333 if ( ! empty( $wp_post_booking_absolute ) ) {
334 ?>
335 <a class="button button-secondary"
336 style="font-size: 20px;padding: 0 1em;height: 44px;line-height: 40px;"
337 href="<?php
338 echo esc_url( $wp_post_booking_absolute ); ?>"
339 ><?php
340 esc_html_e( 'Go to page with booking form', 'booking' ); ?></a>
341 <?php
342 }
343 } ?>
344 </div>
345 <?php
346 }
347
348 public function content_whats_new() {
349
350 echo '<div class="wrap about-wrap wpbc-welcome-page">';
351
352 $this->title_section();
353
354 $this->show_go_links();
355
356 $this->maintence_section();
357
358 $this->section_9_8_css();
359
360 if ( ( defined( 'WPBC_ENABLE_12_0_TIMELINE' ) ) && ( WPBC_ENABLE_12_0_TIMELINE ) ) {
361 wpbc_welcome_section_12_0( $this );
362 }
363 wpbc_welcome_section_11_9( $this );
364 wpbc_welcome_section_11_8_1( $this );
365 wpbc_welcome_section_11_8( $this );
366 wpbc_welcome_section_11_7( $this );
367 wpbc_welcome_section_11_6( $this );
368 wpbc_welcome_section_11_5( $this );
369 wpbc_welcome_section_11_4( $this );
370 wpbc_welcome_section_11_3( $this );
371 wpbc_welcome_section_11_2( $this );
372 wpbc_welcome_section_11_1( $this );
373 wpbc_welcome_section_11_0( $this );
374 wpbc_welcome_section_10_15( $this );
375 wpbc_welcome_section_10_14( $this );
376 wpbc_welcome_section_10_13( $this );
377
378 $this->show_go_links();
379
380 echo '<div';
381 }
382
383
384 function expand_section_start( $section_param_arr ) {
385
386 ?>
387 <div class="clear" style="margin-top:20px;"></div><?php
388
389 if ( $section_param_arr['show_expand'] ) {
390
391 ?><a id="wpbc_show_advanced_section_link_show"
392 class="wpbc_expand_section_link"
393 href="javascript:void(0)"
394 onclick="javascript:jQuery( '.version_update_<?php
395 echo esc_attr( str_replace( array(
396 '.', ' ',
397 ), '_', $section_param_arr['version_num'] ) ); ?>' ).toggle();"
398 >+ Show changes in version update <span
399 style="font-size: 1.35em;font-weight: 600;color: #079;font-family: Consolas,Monaco,monospace;padding-left:12px;"><?php
400 echo esc_html( $section_param_arr['version_num'] ); ?></span>
401 </a>
402 <div class="version_update_<?php
403 echo esc_attr( str_replace( array(
404 '.', ' ',
405 ), '_', $section_param_arr['version_num'] ) ); ?>" style="display:none;">
406 <?php
407
408 }
409
410 ?><h2 style='font-size: 1.9em;text-align:left;'>What's New in Booking Calendar <span
411 style="font-size: 1.1em;font-weight: 600;font-family: Consolas,Monaco,monospace;padding-left: 10px;color: #5F5F5F;"
412 ><?php
413 echo esc_html( $section_param_arr['version_num'] ); ?></span></h2><?php
414
415 }
416
417
418 function expand_section_end( $section_param_arr ) {
419 if ( $section_param_arr['show_expand'] ) {
420 ?></div><?php
421 }
422 }
423
424
425 function section_img_url( $relative_path_to_img ) {
426
427 return esc_url( $this->asset_path . $relative_path_to_img );
428 }
429
430
431 function section_9_8_css(){
432
433 ?><style type="text/css">
434 .about-wrap.wpbc-welcome-page {
435 position: relative;
436 margin: 25px 40px 0 20px;
437 max-width: 1050px;
438 font-size: 15px;
439 clear: both;
440 }
441 .wpbc_wn_container{
442 margin: 24px auto;
443 overflow: hidden;
444 }
445 .wpbc_wn_section{
446 display: flex;
447 flex-flow: row wrap;
448 justify-content: space-between;
449 align-content: flex-start;
450 align-items: flex-start;
451 font-size: 1.05em;
452 line-height: 2rem;
453 margin: 1em 0;
454 }
455 .wpbc_wn_col{
456 flex: 1 1 50%;
457 padding: 1.5em 2em;
458 box-sizing: border-box;
459 }
460 @media screen and (max-width: 782px) {
461 .wpbc_wn_col{
462 flex: 1 1 100%;
463 }
464 }
465 .wpbc_wn_separator{
466 flex: 1 1 100%;
467 }
468 .wpbc_wn_col * {
469 margin: 0;
470 line-height: 2.2em;
471 }
472 .wpbc_wn_section > h2,
473 .wpbc_wn_section > h3{
474 margin: 0 0 0.25em;
475 font-size: 2em;
476 line-height: 2.16em;
477 font-weight: 600;
478 flex: 1 1 100%;
479 text-align: center;
480 padding:0 1.5em;
481 }
482 .wpbc_wn_section h3 {
483 font-size: 1.25em;
484 text-align: left;
485 margin: 0.25em 0 0.5em;
486 }
487 .wpbc_wn_section img{
488 border-radius: 2px;
489 box-shadow: none;
490 width: 99%;
491 margin: 0.5em 0 auto;
492 padding: 3px;
493 background: #fff;
494 border: 1px solid #ccc;
495 }
496 .wpbc_wn_container .wpbc_hr_dots {
497 height: 1px;
498 border:none;
499 border-bottom: 0.5rem dotted #a9a9a9;
500 width: 3rem;
501 margin:0 auto;
502 clear: both:;
503 display: block;
504 position: relative;
505 }
506 </style>
507 <?php
508 }
509 }
510
511 $wpbc_welcome = new WPBC_Welcome();
512