| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin Panel UI - Parts |
| 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 2025-03-20 |
| 14 |
*/ |
| 15 |
|
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit; // Exit, if accessed directly. |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Show Top Horisontal Navigation Bar |
| 22 |
* |
| 23 |
* @param array $args - parameters. |
| 24 |
* |
| 25 |
* @return void |
| 26 |
*/ |
| 27 |
function wpbc_ui__top_horisontal_nav( $args =array() ) { |
| 28 |
|
| 29 |
$defaults = array( |
| 30 |
'attr' => array(), |
| 31 |
); |
| 32 |
$params = wp_parse_args( $args, $defaults ); |
| 33 |
|
| 34 |
$active_page_arr = array( |
| 35 |
'active_page' => $args['active_page'], // wpbc-settings. |
| 36 |
'active_tab' => $args ['active_tab'], // calendar_appearance. |
| 37 |
'active_subtab' => $args['active_subtab'], // calendar_appearance_skin. |
| 38 |
); |
| 39 |
|
| 40 |
// Available Main Menu - slug => titles. |
| 41 |
$show_these_pages_arr = array( |
| 42 |
'wpbc' => __( 'Bookings', 'booking' ), |
| 43 |
'wpbc-new' => __( 'Add Booking', 'booking' ), |
| 44 |
'wpbc-availability' => __( 'Availability', 'booking' ), |
| 45 |
'wpbc-prices' => __( 'Prices', 'booking' ), |
| 46 |
'wpbc-resources' => __( 'Resources', 'booking' ), |
| 47 |
'wpbc-settings' => __( 'Settings', 'booking' ), |
| 48 |
'wpbc-setup' => __( 'Setup', 'booking' ), |
| 49 |
); |
| 50 |
|
| 51 |
|
| 52 |
// Ability to click on panel, only if there 'min' class - panel minimized! |
| 53 |
echo '<div class="wpbc_ui_el__horis_top_bar__wrapper">'; |
| 54 |
|
| 55 |
echo ' <div class="wpbc_ui_el__horis_top_bar__content">'; |
| 56 |
|
| 57 |
$main_page_slug = $active_page_arr['active_page']; |
| 58 |
$page_title = $show_these_pages_arr[ $main_page_slug ]; |
| 59 |
|
| 60 |
// Loop to show all main sections in horisontal menu. |
| 61 |
foreach ( $show_these_pages_arr as $main_page_slug => $page_title ) { |
| 62 |
|
| 63 |
// Show only active page settings list. |
| 64 |
if ( $main_page_slug !== $active_page_arr['active_page'] ) { |
| 65 |
continue; |
| 66 |
} |
| 67 |
$page_item_arr = $args['page_nav_tabs'][ $main_page_slug ]; |
| 68 |
|
| 69 |
do_action( 'hook__wpbc_ui__top_horisontal_nav__start', $active_page_arr['active_page'], $active_page_arr['active_tab'] ); |
| 70 |
|
| 71 |
foreach ( $page_item_arr as $main_menu_slug => $menu_item_arr ) { |
| 72 |
do_action( 'hook__wpbc_ui__top_horisontal_nav__item_start', $active_page_arr['active_page'], $active_page_arr['active_tab'], $main_menu_slug ); |
| 73 |
|
| 74 |
wpbc_ui__horis_menu__item_main( $main_menu_slug, $menu_item_arr ); |
| 75 |
|
| 76 |
do_action( 'hook__wpbc_ui__top_horisontal_nav__item_end', $active_page_arr['active_page'], $active_page_arr['active_tab'], $main_menu_slug ); |
| 77 |
} |
| 78 |
do_action( 'hook__wpbc_ui__top_horisontal_nav__end', $active_page_arr['active_page'], $active_page_arr['active_tab'] ); |
| 79 |
|
| 80 |
// wpbc_ui_el__divider_vertical(); |
| 81 |
} // Loop to show all main sections in horisontal menu. |
| 82 |
echo ' </div><!-- wpbc_ui_el__horis_top_bar__content -->'; |
| 83 |
|
| 84 |
echo '</div><!-- wpbc_ui_el__horis_top_bar__wrapper -->'; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
/** |
| 89 |
* Show Horisontal - "Menu Item". |
| 90 |
* |
| 91 |
* @param string $menu_slug - 'calendar_appearance'. |
| 92 |
* @param array $menu_item_arr - [ [title] => Skin |
| 93 |
* [page_title] => Calendar General Settings 3 |
| 94 |
* [hint] => Calendar General Settings 2 |
| 95 |
* [link] => |
| 96 |
* [position] => |
| 97 |
* [css_classes] => |
| 98 |
* [icon] => |
| 99 |
* [font_icon] => wpbc-bi-calendar2-range |
| 100 |
* [default] => |
| 101 |
* [disabled] => |
| 102 |
* [hided] => |
| 103 |
* [is_active] => 1 |
| 104 |
* [url] => http://beta/wp-admin/admin.php?page=wpbc-settings&tab=calendar_appearance |
| 105 |
* [subtabs] => [....] |
| 106 |
* ] |
| 107 |
* |
| 108 |
* @return void |
| 109 |
*/ |
| 110 |
function wpbc_ui__horis_menu__item_main( $menu_slug, $menu_item_arr ) { |
| 111 |
|
| 112 |
$defaults = array( |
| 113 |
'title' => '', |
| 114 |
'page_title' => '', |
| 115 |
'hint' => '', |
| 116 |
'link' => '', |
| 117 |
'position' => '', |
| 118 |
'css_classes' => '', |
| 119 |
'icon' => '', |
| 120 |
'font_icon' => '', |
| 121 |
'default' => false, |
| 122 |
'disabled' => false, |
| 123 |
'hided' => false, |
| 124 |
'is_active' => 0, |
| 125 |
'url' => '', |
| 126 |
'subtabs' => array(), |
| 127 |
); |
| 128 |
$menu_item_arr = wp_parse_args( $menu_item_arr, $defaults ); |
| 129 |
|
| 130 |
?><div class="wpbc_ui_el__horis_nav_item wpbc_ui_el__horis_nav_item__<?php echo esc_attr( $menu_slug ); ?> <?php echo ( ! empty( $menu_item_arr['is_active'] ) ) ? ' active ' : ''; ?>"> |
| 131 |
<?php |
| 132 |
// Single Item. |
| 133 |
?> |
| 134 |
<a href="<?php echo esc_url( $menu_item_arr['url'] ); ?>" |
| 135 |
class="wpbc_ui_el__horis_nav_item__a wpbc_ui_el__horis_nav_item__single"> |
| 136 |
<?php if ( ! empty( $menu_item_arr['font_icon'] ) ) { ?> |
| 137 |
<i class="wpbc_ui_el__horis_nav_icon tooltip_top menu_icon icon-1x <?php echo esc_attr( $menu_item_arr['font_icon'] ); ?>" |
| 138 |
data-original-title="<?php echo esc_attr( $menu_item_arr['title'] ); ?>"></i> |
| 139 |
<?php } ?> |
| 140 |
<span class="wpbc_ui_el__horis_nav_title"><?php echo wp_kses_post( $menu_item_arr['title'] ); ?></span> |
| 141 |
</a> |
| 142 |
</div> |
| 143 |
<?php |
| 144 |
} |
| 145 |
|