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 / core / any / class-admin-page-structure.php

class-admin-page-structure.php in Booking Calendar 10.10, at core/any/class-admin-page-structure.php

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