PluginProbe
Booking Calendar / 10.11
Booking Calendar v10.11
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 / old-admin-page-structure.php

old-admin-page-structure.php in Booking Calendar 10.11, at core/any/old-admin-page-structure.php

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