PluginProbe
Booking Calendar / 10.10
Booking Calendar v10.10
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
booking / includes / class_page_structure / class_page_structure.php

class_page_structure.php in Booking Calendar 10.10, at includes/class_page_structure/class_page_structure.php

1,010 lines 40.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Page Structure in Admin Panel
4 *
5 * @version 1.2
6 * @package Any
7 * @category Page Structure in Admin Panel
8 * @author wpdevelop
9 *
10 * @web-site https://wpbookingcalendar.com/
11 * @email info@wpbookingcalendar.com
12 *
13 * @modified 2024-12-23, 2015-11-02
14 */
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit, if accessed directly.
18 }
19
20 // FixIn: 11.0.0.1.
21
22 /**
23 * Define Settings Page Structure
24 */
25 abstract class WPBC_Page_Structure {
26
27 /**
28 * Tabs array, same for all objects.
29 *
30 * @var array
31 */
32 protected static $nav_tabs;
33 /**
34 * Parameters for current page, if this page selected, otherwise its = empty array()
35 *
36 * @var array
37 */
38 private $current_page_params;
39 /**
40 * Is show icons
41 *
42 * @var bool
43 */
44 private $is_only_icons = false;
45 protected $is_use_left_navigation = false;
46 protected $is_use_left_navigation_custom = false;
47 protected $is_use_navigation_path = false;
48 /**
49 * Defining Name of parameter in GET request for Navigation TOP and BOTTOM tabs: - $_GET[ 'tab' ] == 'payment' - $_GET[ 'subtab' ] == 'paypal'.
50 *
51 * @var array
52 */
53 protected $tags;
54
55
56 /**
57 * Constructor
58 */
59 public function __construct() {
60
61 self::$nav_tabs = array();
62
63 $this->current_page_params = array();
64
65 $this->tags = array();
66
67 // Defining Name of parameter in GET request - $_GET[ 'tab' ] == 'payment'.
68 $this->tags['tab'] = 'tab';
69
70 // Defining Name of parameter in GET request - $_GET[ 'subtab' ] == 'paypal'.
71 $this->tags['subtab'] = 'subtab';
72
73 // This Hook fire after creation menu in class WPBC_Admin_Menus.
74 add_action( 'wpbc_define_nav_tabs', array( $this, 'wpbc_create_plugin_menu_structure_arr' ) );
75
76 // This Hook fire in the class WPBC_Admin_Menus for showing page content of specific menu.
77 add_action( 'wpbc_page_structure_show', array( $this, 'content_structure' ) );
78 }
79
80 // -----------------------------------------------------------------------------------------------------------------
81 // Abstract Methods
82 // -----------------------------------------------------------------------------------------------------------------
83
84 /**
85 * Define slug in what menu to show this page. // Parameter relative: $_GET['page'].
86 *
87 * @return string
88 *
89 * Example:
90
91 return 'wpbc-settings';
92
93 */
94 abstract public function in_page();
95
96 /**
97 * Define Tabs and Subtabs of this Admin Page
98 *
99 * @return array();
100
101 * Example:
102
103 $tabs = array();
104 $tabs[ 'form' ] = array(
105 'title' => __('Form','booking') // Title of TAB
106 , 'hint' => __('Customization of Form Fields', 'booking') // Hint
107 , 'page_title' =>ucwords( __('Form fields', 'booking') ) // Title of Page
108 //, 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
109 //, 'position' => '' // 'left' || 'right' || ''
110 //, 'css_classes' => '' // CSS class(es)
111 //, 'icon' => '' // Icon - link to the real PNG img
112 , 'font_icon' => 'wpbc_icn_draw' // CSS definition of forn Icon
113 , 'default' => false // Is this tab activated by default or not: true || false.
114 , 'disabled' => false // Is this tab disbaled: true || false.
115 , 'hided' => false // Is this tab hided: true || false.
116 , 'subtabs' => array()
117
118 );
119 $tabs[ 'upgrade' ] = array(
120 'title' => __('Upgrade','booking') // Title of TAB
121 , 'hint' => __('Upgrade to higher version', 'booking') // Hint
122 //, 'page_title' => __('Upgrade', 'booking') // Title of Page
123 , 'link' => 'http://server.com/' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
124 , 'position' => 'right' // 'left' || 'right' || ''
125 //, 'css_classes' => '' // CSS class(es)
126 //, 'icon' => '' // Icon - link to the real PNG img
127 , 'font_icon' => 'wpbc_icn_auto_graph'// CSS definition of forn Icon
128 //, 'default' => false // Is this tab activated by default or not: true || false.
129 //, 'subtabs' => array()
130
131 );
132
133 $subtabs = array();
134
135 $subtabs['fields'] = array(
136 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
137 , 'title' => __('Form','booking') // Title of TAB
138 , 'page_title' => __('Form Settings', 'booking') // Title of Page
139 , 'hint' => __('Customization of Form Settings', 'booking') // Hint
140 , 'link' => '' // link
141 , 'position' => '' // 'left' || 'right' || ''
142 , 'css_classes' => '' // CSS class(es)
143 //, 'icon' => 'https://www.paypalobjects.com/webstatic/icon/pp258.png' // Icon - link to the real PNG img
144 //, 'font_icon' => 'wpbc_icn_payment' // CSS definition of Font Icon
145 , 'default' => true // Is this sub tab activated by default or not: true || false.
146 , 'disabled' => false // Is this sub tab deactivated: true || false.
147 , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' )
148 , 'content' => 'content' // Function to load as conten of this TAB
149 );
150
151 $subtabs['form-separator'] = array(
152 'type' => 'separator' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
153 );
154 $subtabs['form-goto'] = array(
155 'type' => 'goto-link' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
156 , 'title' =>ucwords( __('Form fields', 'booking') ) // Title of TAB
157 , 'hint' => '' // Hint
158 , 'show_section' => 'id_of_show_section' // ID of HTML element, for scroll to.
159 );
160
161 ob_start();
162 ...
163 $html_element_data = ob_get_clean();
164
165 $subtabs['form-selection'] = array(
166 'type' => 'html' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
167 , 'html' => $html_element_data
168 );
169
170 $subtabs['form-save'] = array(
171 'type' => 'button' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
172 , 'title' => __('Save Changes','booking') // Title of TAB
173 , 'form' => 'wpbc_form' // Required for 'button'! Name of Form to submit
174 );
175
176 $tabs[ 'form' ][ 'subtabs' ] = $subtabs;
177
178 return $tabs;
179 */
180 abstract public function tabs();
181
182 /**
183 * Show Content of this page - Main function.
184 *
185 * In top of this function have to be checking ubout Update (saving POST request).
186 *
187 * Exmaple:
188
189 // S u b m i t ///////////////////////////////////////////////////////
190
191 $this_submit_form = 'wpbc_emails_toolbar'; // Define form name
192
193 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
194 if ( isset( $_POST['is_form_sbmitted_'. $this_submit_form ] ) ) {
195
196 // Check N o n c e
197 check_admin_referer( 'wpbc_settings_page_' . $this_submit_form ); // Its stop show anything on submiting, if its not refear to the original page
198
199 // Make Update of settings
200 $edit_field_data = $this->update_wpbc_emails_toolbar( $menu_slug );
201 }
202 ////////////////////////////////////////////////////////////////////////
203 */
204 abstract public function content();
205
206 /**
207 * This function can be overridden by child classes for auto update / save options in main form
208 *
209 * @return void
210 */
211 public function maybe_update() {
212
213 }
214
215
216 // -----------------------------------------------------------------------------------------------------------------
217 // C O N T E N T
218 // -----------------------------------------------------------------------------------------------------------------
219
220 /**
221 * General Page Structure
222 *
223 * @param string $page_tag - its the same that return $this->in_page ()
224 */
225 public function content_structure( $page_tag ) {
226
227 if ( ! $this->is_page_activated() ) {
228 return false;
229 }
230
231 $this->maybe_update();
232
233 $active_page_tab = $active_page_subtab = '';
234
235 if ( ( isset( $this->current_page_params['tab'] ) ) && ( ! empty( $this->current_page_params['tab']['tag'] ) ) ) {
236 $active_page_tab = $this->current_page_params['tab']['tag'];
237 }
238 if ( ( isset( $this->current_page_params['subtab'] ) ) && ( ! empty( $this->current_page_params['subtab']['tag'] ) ) ) {
239 $active_page_subtab = $this->current_page_params['subtab']['tag'];
240 }
241
242 // Fires Before showing settings Content page
243 $is_show_this_page = apply_filters( 'wpbc_before_showing_settings_page_is_show_page', true, $page_tag, $active_page_tab, $active_page_subtab );
244
245 if ( $is_show_this_page === false ) {
246 return false;
247 }
248
249 // Fires Before showing settings Content page
250 do_action( 'wpbc_before_settings_content', $page_tag, $active_page_tab, $active_page_subtab );
251
252
253 ?><div class="wpbc_page_top__header_tabs"><?php
254 ?><div id="<?php echo esc_attr( $page_tag ); ?>-admin-page-top"
255 class="wrap wpbc_page_top <?php
256 echo ' wpbc_page_tab__' . esc_attr( $active_page_tab );
257 echo ' wpbc_page_subtab__' . esc_attr( $active_page_subtab );
258 ?>"
259 ><?php
260 ?><h1 class="wpbc_header wpdvlp-top-tabs"><?php
261 ?><div class="wpbc_header_menu_tabs"><?php
262 if ( ! empty( $this->is_use_navigation_path ) ) {
263 $this->show_top_path( $page_tag ); // Show Top Path // FixIn: 10.4.0.2.
264 } else {
265 $this->show_tabs_line( $page_tag ); // T O P T A B S in Header
266 }
267 ?></div><?php
268 make_bk_action( 'wpbc_h1_header_content_end', $page_tag, $active_page_tab, $active_page_subtab ); // FixIn: 9.9.0.10.
269 ?></h1><?php
270 ?></div><?php
271 ?></div><?php
272
273 do_action( 'wpbc_after_wpbc_page_top__header_tabs', $page_tag, $active_page_tab, $active_page_subtab ); // Fires Before showing settings Content page.
274
275 ?><div id="<?php echo esc_attr( $page_tag ); ?>-admin-page"
276 class="wrap wpbc_page wpbc_page_tab__<?php echo esc_attr( $active_page_tab ); ?> wpbc_page_subtab__<?php echo esc_attr( $active_page_subtab ); ?>" >
277 <div class="wpbc_admin_message"></div>
278 <div class="wpbc_admin_page">
279 <div id="ajax_working"></div>
280 <div class="clear wpbc_header_margin"></div>
281 <div id="ajax_respond" class="ajax_respond" style="display:none;"></div><?php
282
283 if ( $this->is_use_left_navigation ) {
284
285 ?><div class="clear" style="margin-bottom:10px;"></div>
286 <div class="wpbc_settings_flex_container">
287 <div class="wpbc_settings_flex_container_left">
288 <div class="wpbc_settings_navigation_column">
289 <?php
290
291 $this->show_tabs_structure( $page_tag );
292
293 ?>
294 </div>
295 </div>
296 <div class="wpbc_settings_flex_container_right">
297 <?php
298 } else {
299 $this->show_tabs_structure( $page_tag ); // T A B S.
300 }
301
302 wp_nonce_field( 'wpbc_ajax_admin_nonce', 'wpbc_admin_panel_nonce', true, true );
303
304 // C o n t e n t
305 if ( ( isset( $this->current_page_params['subtab'] ) ) && ( isset( $this->current_page_params['subtab']['content'] ) ) ) {
306
307 call_user_func( array( $this, $this->current_page_params['subtab']['content'] ) );
308
309 } else if ( ( isset( $this->current_page_params['tab'] ) ) && ( isset( $this->current_page_params['tab']['content'] ) ) ) {
310 call_user_func( array( $this, $this->current_page_params['tab']['content'] ) );
311
312 } else {
313 $this->content();
314 }
315
316 do_action('wpbc_show_settings_content' , $page_tag, $active_page_tab, $active_page_subtab );
317
318 if ( $this->is_use_left_navigation ) { ?>
319 </div><!-- wpbc_settings_flex_container_right -->
320 </div><!-- wpbc_settings_flex_container --><?php
321 }
322
323 ?></div><!-- wpbc_admin_page -->
324 </div><!-- ...-admin-page --><?php
325
326 do_action( 'wpbc_after_settings_content', $page_tag, $active_page_tab, $active_page_subtab ); // Fires After showing settings Content page
327 }
328
329
330
331 // -----------------------------------------------------------------------------------------------------------------
332 // Active Page Parameters
333 // -----------------------------------------------------------------------------------------------------------------
334
335 /**
336 * Check if this page selected (active), depend from the GET parameter
337 * If selected, then define Current Page Parameters.
338 *
339 * @return boolean
340 */
341 private function is_page_activated() {
342
343 $is_page_selected = false;
344
345 $this_page = $this->in_page();
346 $this_page_arr = ( is_array( $this_page ) ) ? $this_page : array( $this_page );
347
348 foreach ( $this_page_arr as $this_page ) {
349
350 foreach ( $this->tabs() as $this_tab_tag => $this_tab ) { // Get First Tab Element, which MUST be subtab element, all other tabs, can be links, not really showing content!!!
351 break;
352 }
353
354 if ( empty( $this_tab ) ) {
355 return $this_page; // this page empty - tabs is empty array, probabaly its was redefined in child CLASS to $tabs = array(); for not ability to open this page.
356 }
357
358 $this_subtab_tag = 0;
359 $this_subtab = array( 'default' => false );
360
361 if ( isset( $this_tab['subtabs'] ) )
362 foreach ( $this_tab['subtabs'] as $temp_this_subtab_tag => $temp_this_subtab ) {
363
364 if ( $temp_this_subtab['type'] == 'subtab' ) { // Get First Subtab element from subtabs array
365 $this_subtab_tag = $temp_this_subtab_tag;
366 $this_subtab = $temp_this_subtab;
367 break;
368 }
369 }
370
371 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
372 if ( ( isset( $_REQUEST['page'] ) ) && ( $this_page == $_REQUEST['page'] ) ) { // We are inside of this page. Menu item selected.
373
374 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
375 if ( ( ! isset( $_REQUEST[ $this->tags['tab'] ] ) ) // TAB NOT selected && Default.
376 // && ( ! isset( $_REQUEST[ $this->tags['subtab'] ] ) ) // SubTab NOT selected.
377 && ( isset( $this_tab['default'] ) ) && ( $this_tab['default'] )
378 ) {
379 $is_page_selected = true;
380 }
381 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
382 if ( ( isset( $_REQUEST[ $this->tags['tab'] ] ) ) // TAB Selected.
383 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
384 && ( ! isset( $_REQUEST[ $this->tags['subtab'] ] ) ) // SubTab NOT selected && ! exist || Default.
385 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
386 && ( $_REQUEST[ $this->tags['tab'] ] === $this_tab_tag )
387 && ( ( 0 === $this_subtab_tag ) || ( $this_subtab['default'] ) )
388 ) {
389 $is_page_selected = true;
390 }
391 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
392 if ( ( isset( $_REQUEST[ $this->tags['tab'] ] ) ) // TAB Selected.
393 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
394 && ( isset( $_REQUEST[ $this->tags['subtab'] ] ) ) // SubTab Selected.
395 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
396 && ( $_REQUEST[ $this->tags['tab'] ] === $this_tab_tag )
397 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
398 && ( $_REQUEST[ $this->tags['subtab'] ] === $this_subtab_tag )
399 ) {
400 $is_page_selected = true;
401 }
402 }
403
404 // If this page activated, then define Current Page parameters.
405 if ( $is_page_selected ) {
406 $this->define_current_page_parameters( $this_tab_tag, $this_tab, $this_subtab_tag, $this_subtab );
407 }
408
409 if ( $is_page_selected ) {
410 break;
411 }
412 }
413
414 return $is_page_selected;
415 }
416
417
418 /**
419 * Define parameters for current selected page
420 *
421 * @param type $paramas
422 */
423 private function define_current_page_parameters( $this_tab_tag, $this_tab, $this_subtab_tag, $this_subtab ) {
424
425 $this->current_page_params = array(
426 'tab' => array_merge( $this_tab, array( 'tag' => $this_tab_tag ) )
427 , 'subtab' => array_merge( $this_subtab, array( 'tag' => $this_subtab_tag ) )
428 );
429
430 if ( ( ! empty( $this_subtab ) ) && ( ! empty( $this_subtab['is_use_left_navigation'] ) ) && ( true === $this_subtab['is_use_left_navigation'] ) ) {
431 $this->is_use_left_navigation = true;
432 }
433
434 if ( ( ! empty( $this_subtab ) ) && ( ! empty( $this_subtab['is_use_left_navigation_custom'] ) ) && ( true === $this_subtab['is_use_left_navigation_custom'] ) ) {
435 $this->is_use_left_navigation_custom = true;
436 }
437
438 // Use Top line as Path and nt the menu // FixIn: 10.4.0.2.
439 if ( ( ! empty( $this_subtab ) ) && ( ! empty( $this_subtab['is_use_navigation_path'] ) ) ) {
440 $this->is_use_navigation_path = $this_subtab['is_use_navigation_path'];
441 }
442 }
443
444
445
446 /**
447 * Get all SubTabs of current opened page Tab
448 *
449 * @param string $menu_in_page_tag - Optional. Menu Tag, the same as $this->in_page ();
450 * @return array
451 */
452 private function get_all_sub_tabs_of_selected_tab( $menu_in_page_tag = false ) {
453
454 if ( $menu_in_page_tag === false ) {
455
456 //FixIn: 9.8.15.2.3
457 $this_page = $this->in_page();
458 $this_page_arr = ( is_array( $this_page ) ) ? $this_page : array( $this_page );
459
460 $menu_in_page_tag = $this_page_arr[0];
461 }
462
463 $all_sub_tabs_of_selected_tab = self::$nav_tabs[ $menu_in_page_tag ][ $this->current_page_params['tab']['tag'] ]['subtabs'];
464
465 return $all_sub_tabs_of_selected_tab;
466 }
467
468
469
470 // -----------------------------------------------------------------------------------------------------------------
471 // T A B s
472 // -----------------------------------------------------------------------------------------------------------------
473
474 // Define ------------------------------------------------------------------
475
476 /**
477 * Define TABS structure.
478 * General structure of tabs for every plugin menu page.
479 */
480 public function wpbc_create_plugin_menu_structure_arr() { // Function executed after creation menu in class WPBC_Admin_Menus
481 /*
482 Array (
483 [wpbc-resources] => Array ()
484 [wpbc-settings] => Array
485 (
486 [general] => Array
487 (
488 [title] => General
489 [page_title] => General Settings
490 ...
491 [subtabs] => Array ()
492 )
493 [help] => Array
494 (
495 [title] => Help
496 [page_title] =>
497 ...
498 [subtabs] => Array ()
499 )
500 [form] => Array
501 (
502 [title] => Form
503 [hint] => Customization of Form Fields
504 [page_title] => Form Fields
505 ...
506 [subtabs] => Array
507 (
508 [goto-form] => Array
509 (
510 [type] => goto-link
511 [title] => Booking Form Fields
512 ...
513 [content] => content
514 [update] => update
515 )
516
517 [goto-content-data] => Array
518 (
519 [type] => button
520 [title] => Save Changes
521 [form] => wpbc_form
522 ...
523 )
524
525 )
526
527 )
528 [payment] => Array
529 (
530 [title] => Payments
531 [hint] => Customization of Payment
532 [page_title] => Payment Gateways
533 ...
534 [subtabs] => Array
535 (
536 [paypal] => Array
537 (
538 [type] => subtab
539 [title] => PayPal
540 ...
541 )
542
543 [sage] => Array
544 (
545 [type] => subtab
546 [title] => Sage
547 ...
548 )
549
550 )
551
552 )
553
554 )
555
556 )
557 */
558
559 /**
560 * self::$nav_tabs =
561 *
562 * WP Left Menu | Top Horiz Menu | Vert Left Menu or top submenu
563 * ? page =wpbc-settings & tab=email & subtab=new-admin
564 *
565 * [
566 * wpbc-settings = [
567 * general = [...]
568 * form = [...]
569 * email = [...,
570 * subtabs = [
571 * new-admin = [
572 * type = "subtab"
573 * , ...
574 */
575
576 $this_page = $this->in_page(); // e.g. 'wpbc-settings'
577 $this_page_arr = ( is_array( $this_page ) ) ? $this_page : array( $this_page ); // [ 'wpbc-settings' ]
578
579 // Menu Structure
580 foreach ( $this_page_arr as $this_page ) {
581
582 // WP Left Menu
583 if ( ! isset( self::$nav_tabs[ $this_page ] ) ) {
584 self::$nav_tabs[ $this_page ] = array();
585 }
586
587 // Top Horiz Menu - e.g. [ 'calendar_appearance' ] => [ ... ] ]
588 $local_top_main_menu_arr = $this->tabs();
589
590 // Vert Left Menu - or top submenu
591 $local_vert_left_menu_arr = array();
592
593 foreach ( $local_top_main_menu_arr as $tab_tag => $tab_array ) {
594
595 if ( isset( $tab_array[ 'subtabs' ] ) ) {
596 $local_vert_left_menu_arr[ $tab_tag ] = $tab_array[ 'subtabs' ]; // Create new Subtabs array
597
598 unset( $local_top_main_menu_arr[ $tab_tag ][ 'subtabs' ] ); // Detach Subtabs array from Tab array. It's required for do not overwrite subtabs with already exist subtabs in previlosly defined tab.
599 } else {
600 $local_vert_left_menu_arr[ $tab_tag ] = array();
601 }
602 }
603
604
605 foreach ( $local_top_main_menu_arr as $tab_tag => $tab_array ) {
606
607 if ( ! isset( self::$nav_tabs[ $this_page ][ $tab_tag ] ) ) { // If this tab ( for exmaple "payment") declared previously, then does not do anything
608
609 self::$nav_tabs[ $this_page ][ $tab_tag ] = $local_top_main_menu_arr[ $tab_tag ];
610 self::$nav_tabs[ $this_page ][ $tab_tag ][ 'subtabs' ] = array();
611 }
612
613 if ( isset(self::$nav_tabs[ $this_page ] ) ) {
614 // Merge subtabs (Ex: PayPal and Sage) and attach to current tab: (Ex: payment)
615 self::$nav_tabs[ $this_page ][ $tab_tag ][ 'subtabs' ] = array_merge(
616 self::$nav_tabs[ $this_page ][ $tab_tag ][ 'subtabs' ]
617 , $local_vert_left_menu_arr[ $tab_tag ]
618 );
619 }
620 }
621
622 }
623 }
624
625
626 /**
627 * Get array of visible TABs
628 * Tabs that do not hided or disbaled
629 *
630 * @param string $menu_in_page_tag - Menu Tag, the same as $this->in_page ();
631 * @return type
632 */
633 private function get_visible_tabs( $menu_in_page_tag ) {
634
635 $visible_tabs = array();
636
637 foreach ( self::$nav_tabs[ $menu_in_page_tag ] as $tab_tag => $tab ) {
638
639 if ( empty( $tab['disabled'] )
640 && empty( $tab['hided'] )
641 ) {
642 $visible_tabs[$tab_tag] = $tab;
643 }
644 }
645
646 return $visible_tabs;
647 }
648
649 // Showing -----------------------------------------------------------------
650
651 /**
652 *
653 * @param string $menu_in_page_tag - Menu Tag, the same as $this->in_page ();
654 * @return boolean - true if nav tabs exist and false if does not exist
655 */
656 public function show_tabs_structure( $menu_in_page_tag ) {
657
658 // Exit if no Tabs in this page.
659 if ( empty( self::$nav_tabs[ $menu_in_page_tag ] ) ) {
660 return false;
661 }
662
663
664 // If custom Left Nav.
665 if ( $this->is_use_left_navigation_custom ) {
666
667 do_action( 'wpbc_page_show_left_navigation_custom', $menu_in_page_tag );
668
669 return false;
670 }
671
672
673 // Exit if tabs hided or disabled
674 $visible_tabs = $this->get_visible_tabs( $menu_in_page_tag );
675 if ( empty( $visible_tabs ) ) {
676 return false;
677 }
678
679 if ( ! $this->is_use_left_navigation ) {
680 ?><span class="wpdevelop wpdvlp-nav-tabs-container wpbc_top_tabs_sub_menu">
681 <div class="clear"></div><?php
682 }
683
684 // FixIn: 9.8.15.2.
685 do_action( 'wpbc_toolbar_top_tabs_insert', $menu_in_page_tag );
686
687 $bottom_tabs = $this->get_all_sub_tabs_of_selected_tab( $menu_in_page_tag );
688
689 if ( ! empty( $bottom_tabs ) ) { // S U B T A B S
690 if ( ! $this->is_use_left_navigation ) {
691 wpbc_bs_toolbar_sub_html_container_start();
692
693 $this->show_subtabs_line( $bottom_tabs, $menu_in_page_tag );
694
695 wpbc_bs_toolbar_sub_html_container_end();
696 } else {
697 $this->show_subtabs_line( $bottom_tabs, $menu_in_page_tag );
698 }
699
700 } // Bottom Tabs
701
702 if ( ! $this->is_use_left_navigation ) {
703 ?></span><?php
704 }
705
706 return true;
707 }
708
709
710 // FixIn: 10.4.0.2.
711 /**
712 * Show Top Path
713 *
714 * @param $menu_in_page_tag
715 *
716 * @param string $menu_in_page_tag - Menu Tag, the same as $this->in_page ();
717 */
718 function show_top_path( $menu_in_page_tag ) {
719
720 $navigation_path_arr = $this->is_use_navigation_path;
721
722 if (! empty( $navigation_path_arr ) ) {
723 if ( ! empty( $navigation_path_arr['path'] ) ) {
724 foreach ( $navigation_path_arr['path'] as $el_id => $el_arr ) {
725
726 $defaults = array(
727 'tag' => 'a',
728 'title' => '',
729 'hint' => '',
730 'class' => '',
731 'icon' => false,
732 'url' => '',
733 'attr' => array(),
734 'html' => '',
735 );
736 $el_arr = wp_parse_args( $el_arr, $defaults );
737
738 $tag = 'span';
739 if ( in_array( $el_arr['tag'], array( 'a', 'span', 'div', '>', '|' ) ) ) {
740 $tag = $el_arr['tag'];
741 }
742
743 // Shortcut for 'Next' breadcrumb
744 if ( '>' === $tag ) {
745 $tag = 'span';
746 $el_arr['html'] = '<i class="menu_icon icon-1x wpbc_icn_navigate_next"></i>';
747 $el_arr['attr'] = array( 'style' => 'padding-left: 0;padding-right: 0;' );
748 }
749 if ( '|' === $tag ) {
750 $tag = 'div';
751 $el_arr['html'] = '<div style="border-left: 2px solid #00000012;width: 0;height: 100%;margin: 0 10px;">&nbsp;</div>';
752 $el_arr['attr'] = array( 'style' => 'padding-left: 0;padding-right: 0;' );
753 }
754
755
756 echo '<' . esc_attr( $tag );
757
758 if ( ! empty( $el_arr['action'] ) ) {
759 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
760 echo ' onclick="javascript:' . $el_arr['action'] . '" ';
761
762 // URL .
763 echo ' href="javascript:void(0);" ';
764
765 } elseif ( ! empty( $el_arr['url'] ) ) {
766 // URL .
767 echo ' href="' . esc_url( $el_arr['url'] ) . '" ';
768 }
769
770 // Hints .
771 if ( ! empty( $el_arr['hint'] ) ) {
772 echo ' data-original-title="' . esc_attr( $el_arr['hint'] ) . '" ';
773 }
774
775 // CSS Class .
776 echo ' class="nav-tab ' .
777 ( ( ! empty( $el_arr['class'] ) ) ? esc_attr( $el_arr['class'] ) : '' ) .
778 ( ( ! empty( $el_arr['hint'] ) ) ? ' tooltip_top ' : '' ) .
779 '" ';
780
781
782 // Other attr .
783 if ( ! empty( $el_arr['attr'] ) ) {
784 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
785 echo ' ' . WPBC_Settings_API::get_custom_attr_static( array( 'attr' => $el_arr['attr'] ) ) . ' ';
786 }
787
788 echo '>';
789
790 // In case if we insert ANY html .
791 if ( ! empty( $el_arr['html'] ) ) {
792 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
793 echo $el_arr['html'];
794 }
795 // Icon .
796 if ( ! empty( $el_arr['icon'] ) ) {
797 echo '<i class="menu_icon icon-1x ' . esc_attr( $el_arr['icon'] ) . '"></i>';
798 }
799
800 // Title .
801 if ( ! empty( $el_arr['title'] ) ) {
802 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
803 echo '<span class="nav-tab-text">' . ( ( ! empty( $el_arr['icon'] ) ) ? '&nbsp;&nbsp;' : '' ) . $el_arr['title'] . '</span>';
804 }
805 echo '</' . esc_attr( $tag ) . '>';
806 }
807 }
808 }
809 }
810
811
812
813 /**
814 * Show Top nav TABs line
815 *
816 * @param string $menu_in_page_tag - Menu Tag, the same as $this->in_page ();
817 */
818 public function show_tabs_line( $menu_in_page_tag ) {
819
820 foreach ( self::$nav_tabs[ $menu_in_page_tag ] as $tab_tag => $tab ) {
821
822 $css_classes = ( ( isset( $tab['css_classes'] ) ) ? $tab['css_classes'] : '' );
823
824 if ( ( isset( $this->current_page_params['tab'] ) ) && ( $this->current_page_params['tab']['tag'] === $tab_tag ) ) {
825 $css_classes .= ' nav-tab-active';
826 }
827 if ( ! empty( $tab['position'] ) ) {
828 $css_classes .= ' nav-tab-position-' . $tab['position'];
829 }
830 if ( ! empty( $tab['hided'] ) ) {
831 $css_classes .= ' hide';
832 }
833 if ( ( isset( $tab['disabled'] ) ) && ( $tab['disabled'] ) ) {
834 $css_classes .= ' wpdevelop-tab-disabled';
835 }
836 $tab['css_classes'] = $css_classes;
837
838 $tab['link'] = ( ! empty( $tab['link'] ) ? $tab['link'] : $this->get_tab_url( $menu_in_page_tag, $tab_tag ) );
839
840 // Recheck active status of default TAB.
841 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
842 if ( ( isset( $_REQUEST[ $this->tags['tab'] ] ) ) // Some Tab selected.
843 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
844 && ( $_REQUEST[ $this->tags['tab'] ] !== $tab_tag ) // This tag not in URL.
845 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
846 && ( isset( $tab['default'] ) && ( $tab['default'] ) ) // This tab default, need to set it as not defaultm for not showing it selected.
847 ) {
848 $tab['default'] = false;
849 }
850
851 wpbc_bs_display_tab( $tab );
852
853 }
854 }
855
856
857 /**
858 * Show Sub Menu Lines at the Settings page for Active Tab
859 *
860 * @param array $bottom_tabs
861 * @param string $menu_in_page_tag - Menu Tag, the same as $this->in_page ();
862 */
863 public function show_subtabs_line( $bottom_tabs, $menu_in_page_tag ) {
864
865 if ( ! empty( $bottom_tabs ) )
866 foreach ( $bottom_tabs as $tab_tag => $tab ) {
867
868 switch ( $tab['type'] ) {
869 case 'separator': // Separator
870 ?><span class="wpdevelop-submenu-tab-separator-vertical"></span><?php
871 break;
872
873 case 'button': // Button
874 ?><div class="clear-for-mobile"></div><input
875 type="button"
876 class="button button-primary wpbc_submit_button"
877 value="<?php
878 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
879 echo $tab['title']; ?>"
880 onclick="if (typeof document.forms['<?php echo esc_attr( $tab['form'] ); ?>'] !== 'undefined'){ document.forms['<?php echo esc_attr( $tab['form'] ); ?>'].submit(); } else { wpbc_admin_show_message( '<?php echo ' <strong>Error!</strong> Form <strong>' , esc_attr($tab['form']) , '</strong> does not exist.'; ?>', 'error', 10000 ); }" <?php //FixIn: 7.0.1.56 ?>
881 /><?php
882 break;
883
884 case 'html': // HTML.
885 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
886 echo $tab['html'];
887 break;
888
889 case 'goto-link':
890 ?><a class="nav-tab wpdevelop-submenu-tab go-to-link"
891 original-title="<?php
892 echo( empty( $tab['hint'] ) ? '' : esc_attr( $tab['hint'] ) ); ?>"
893 onclick="javascript:wpbc_scroll_to('#<?php
894 echo esc_js( $tab['show_section'] ); ?>' );"
895 href="javascript:void(0);"><span><?php
896 echo esc_html( $tab['title'] ); ?></span></a><?php
897 break;
898
899 default: // Link
900
901 $css_classes = ( ( isset( $tab['css_classes'] ) ) ? $tab['css_classes'] : '' );
902 $tab['link'] = ( ! empty( $tab['link'] ) ? $tab['link'] : $this->get_tab_url( $menu_in_page_tag, $this->current_page_params['tab']['tag'], $tab_tag ) );
903
904 if ( $this->is_use_left_navigation ) {
905
906 if ( $tab_tag == $this->current_page_params['subtab']['tag'] ) {
907 $css_classes .= ' wpbc_settings_navigation_item_active';
908 }
909
910 $hint_title = '';
911 $hint_css_classes = '';
912 if ( ( ! empty( $tab['hint'] ) ) && ( is_array( $tab['hint'] ) ) ) {
913 if ( ! empty( $tab['hint']['title'] ) ) {
914 $hint_title = $tab['hint']['title'];
915 }
916 if ( ! empty( $tab['hint']['position'] ) ){
917 $hint_css_classes .= ' tooltip_' . $tab['hint']['position'];
918 }
919 }
920 $html_tag = 'a';
921
922 if ( $tab['disabled'] ) {
923 $tab['link'] = 'javascript:void(0)';
924 $html_tag = 'span';
925 }
926
927 ?><div id="wpbc_settings_left_nav_tab_<?php echo esc_attr( $tab_tag ); ?>"
928 class="wpbc_settings_navigation_item <?php echo esc_attr( $css_classes ); ?>">
929 <<?php echo esc_attr( $html_tag ); ?> class="<?php echo esc_attr( $hint_css_classes ); ?>"
930 title="<?php echo esc_attr( $hint_title ); ?>"
931 <?php
932 if ( $html_tag == 'a' ) { // Parameters for A tag
933 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
934 echo ' href="', $tab['link'], '" ';
935
936 if ( ! empty( $tab['onclick'] ) ) {
937 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
938 echo ' onclick="javascript:', $tab['onclick'], '" ';
939 }
940 }
941
942 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
943 echo wpbc_get_custom_attr( $tab );
944 ?>
945 >
946 <?php echo wp_kses_post( $tab['title'] ); ?>
947 <?php if ( ( ! empty( $tab['show_checked_icon'] ) ) && ( ! empty( $tab['checked_data'] ) ) ) {
948 $is_checked_data = get_bk_option( $tab['checked_data'] );
949 if (
950 ( ( ! empty( $is_checked_data ) ) && ( isset( $is_checked_data['enabled'] ) ) && ( $is_checked_data['enabled'] == 'On' ) )
951 || ( ( ! empty( $is_checked_data ) ) && ( $is_checked_data === 'On' ) )
952 ){
953 echo '<i class="menu_icon icon-1x wpbc-bi-toggle2-on wpbc_icn_radio_button_checked0" style="margin-left: auto;margin-top: 3px;color: #036aab;"></i>';
954 } else{
955 echo '<i class="menu_icon icon-1x wpbc-bi-toggle2-off wpbc_icn_radio_button_unchecked0" style="margin-left: auto;margin-top: 3px;"></i>';
956 }
957
958 }?>
959 </<?php echo esc_attr( $html_tag ); ?>>
960 </div><?php
961
962 } else {
963
964
965 if ( ! empty( $tab['position'] ) ) {
966 $css_classes .= ' nav-tab-position-' . $tab['position'];
967 }
968 if ( $tab_tag == $this->current_page_params['subtab']['tag'] ) {
969 $css_classes .= ' wpdevelop-submenu-tab-selected';
970 }
971 if ( $tab['disabled'] ) {
972 $css_classes .= ' wpdevelop-submenu-tab-disabled';
973 }
974
975 $tab['css_classes'] = $css_classes;
976
977
978
979 $tab['top'] = false;
980 wpbc_bs_display_tab( $tab );
981 }
982
983 break;
984
985 } // End Switch
986 } // End Bottom Tabs Loop
987
988 }
989
990
991 // -----------------------------------------------------------------------------------------------------------------
992 // Support
993 // -----------------------------------------------------------------------------------------------------------------
994
995 /**
996 * Get URL of settings page, based on Page Slug and Tab Slug
997 *
998 * @param string $page_tag
999 * @param string $tab_name
1000 * @param string $subtab_name ( Optional )
1001 * @return string - Escaped URL to plugin page.
1002 */
1003 private function get_tab_url( $page_tag, $tab_name, $subtab_name = false ){
1004 if ( $subtab_name === false )
1005 return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $this->tags['tab'] => $tab_name ), 'admin.php' ) ) );
1006 else
1007 return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $this->tags['tab'] => $tab_name, $this->tags['subtab'] => $subtab_name ), 'admin.php' ) ) );
1008 }
1009
1010 }