| @@ -19,9 +19,11 @@ | ||
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Show Top Horisontal Navigation Bar |
| 22 | 22 | * |
| 23 | - * @param array $args - parameters. | |
| 23 | + * @param array $args Navigation parameters. An active tab can set | |
| 24 | + * top_navigation_use_subtabs to render its subtabs in this | |
| 25 | + * bar instead of every top-level tab on the page. | |
| 24 | 26 | * |
| 25 | 27 | * @return void |
| 26 | 28 | */ |
| 27 | 29 | function wpbc_ui__top_horisontal_nav( $args =array() ) { |
| @@ -30,26 +32,33 @@ | ||
| 30 | 32 | 'attr' => array(), |
| 31 | 33 | ); |
| 32 | 34 | $params = wp_parse_args( $args, $defaults ); |
| 33 | 35 | |
| 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 | - ); | |
| 36 | + $active_page_arr = array( | |
| 37 | + 'active_page' => $args['active_page'], // wpbc-settings. | |
| 38 | + 'active_tab' => $args ['active_tab'], // calendar_appearance. | |
| 39 | + 'active_subtab' => $args['active_subtab'], // calendar_appearance_skin. | |
| 40 | + ); | |
| 41 | + | |
| 42 | + if ( function_exists( 'wpbc_booking_modes_v3_compile_horizontal_navigation' ) ) { | |
| 43 | + $args['page_nav_tabs'] = wpbc_booking_modes_v3_compile_horizontal_navigation( | |
| 44 | + $args['page_nav_tabs'], | |
| 45 | + $active_page_arr['active_page'], | |
| 46 | + $active_page_arr['active_tab'], | |
| 47 | + $active_page_arr['active_subtab'] | |
| 48 | + ); | |
| 49 | + } | |
| 39 | 50 | |
| 40 | 51 | // Available Main Menu - slug => titles. |
| 41 | - $show_these_pages_arr = array( | |
| 52 | + $show_these_pages_arr = array( | |
| 42 | 53 | 'wpbc' => __( 'Bookings', 'booking' ), |
| 43 | 54 | 'wpbc-availability' => __( 'Availability', 'booking' ), |
| 44 | 55 | 'wpbc-prices' => __( 'Prices', 'booking' ), |
| 45 | 56 | 'wpbc-resources' => __( 'Resources', 'booking' ), |
| 46 | 57 | 'wpbc-settings' => __( 'Settings', 'booking' ), |
| 47 | - 'wpbc-setup' => __( 'Setup', 'booking' ), | |
| 48 | - ); | |
| 49 | - | |
| 50 | - | |
| 51 | - // Ability to click on panel, only if there 'min' class - panel minimized! | |
| 58 | + 'wpbc-setup' => __( 'Setup', 'booking' ), | |
| 59 | + ); | |
| 60 | + // Ability to click on panel, only if there 'min' class - panel minimized! | |
| 52 | 61 | echo '<div class="wpbc_ui_el__horis_top_bar__wrapper">'; |
| 53 | 62 | |
| 54 | 63 | echo ' <div class="wpbc_ui_el__horis_top_bar__content">'; |
| 55 | 64 | |
| @@ -62,15 +71,32 @@ | ||
| 62 | 71 | // Show only active page settings list. |
| 63 | 72 | if ( $main_page_slug !== $active_page_arr['active_page'] ) { |
| 64 | 73 | continue; |
| 65 | 74 | } |
| 66 | - $page_item_arr = $args['page_nav_tabs'][ $main_page_slug ]; | |
| 75 | + $page_item_arr = $args['page_nav_tabs'][ $main_page_slug ]; | |
| 76 | + $active_tab = isset( $page_item_arr[ $active_page_arr['active_tab'] ] ) && is_array( $page_item_arr[ $active_page_arr['active_tab'] ] ) | |
| 77 | + ? $page_item_arr[ $active_page_arr['active_tab'] ] | |
| 78 | + : array(); | |
| 79 | + | |
| 80 | + // Some focused settings pages use their subtabs as the horizontal page-level navigation. | |
| 81 | + if ( | |
| 82 | + ! empty( $active_tab['top_navigation_use_subtabs'] ) | |
| 83 | + && ! empty( $active_tab['subtabs'] ) | |
| 84 | + && is_array( $active_tab['subtabs'] ) | |
| 85 | + ) { | |
| 86 | + $page_item_arr = $active_tab['subtabs']; | |
| 87 | + } | |
| 67 | 88 | |
| 68 | - do_action( 'hook__wpbc_ui__top_horisontal_nav__start', $active_page_arr['active_page'], $active_page_arr['active_tab'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 89 | + do_action( 'hook__wpbc_ui__top_horisontal_nav__start', $active_page_arr['active_page'], $active_page_arr['active_tab'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 90 | + | |
| 91 | + foreach ( $page_item_arr as $main_menu_slug => $menu_item_arr ) { | |
| 92 | + // Legacy hided/disabled flags control other navigation surfaces; the top bar uses its own explicit flag. | |
| 93 | + if ( ! empty( $menu_item_arr['top_navigation_hidden'] ) ) { | |
| 94 | + continue; | |
| 95 | + } | |
| 96 | + | |
| 97 | + do_action( 'hook__wpbc_ui__top_horisontal_nav__item_start', $active_page_arr['active_page'], $active_page_arr['active_tab'], $main_menu_slug ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 69 | 98 | |
| 70 | - foreach ( $page_item_arr as $main_menu_slug => $menu_item_arr ) { | |
| 71 | - do_action( 'hook__wpbc_ui__top_horisontal_nav__item_start', $active_page_arr['active_page'], $active_page_arr['active_tab'], $main_menu_slug ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 72 | - | |
| 73 | 99 | wpbc_ui__horis_menu__item_main( $main_menu_slug, $menu_item_arr ); |
| 74 | 100 | |
| 75 | 101 | do_action( 'hook__wpbc_ui__top_horisontal_nav__item_end', $active_page_arr['active_page'], $active_page_arr['active_tab'], $main_menu_slug ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound |
| 76 | 102 | } |
| @@ -121,11 +147,12 @@ | ||
| 121 | 147 | * [folder_style] => order:93; |
| 122 | 148 | * [icon] => |
| 123 | 149 | * [font_icon] => wpbc-bi-calendar2-range |
| 124 | 150 | * [default] => |
| 125 | - * [disabled] => | |
| 126 | - * [hided] => | |
| 127 | - * [is_active] => 1 | |
| 151 | + * [disabled] => | |
| 152 | + * [hided] => | |
| 153 | + * [top_navigation_hidden] => | |
| 154 | + * [is_active] => 1 | |
| 128 | 155 | * [url] => http://beta/wp-admin/admin.php?page=wpbc-settings&tab=calendar_appearance |
| 129 | 156 | * [subtabs] => [....] |
| 130 | 157 | * ] |
| 131 | 158 | * |
| @@ -133,23 +160,24 @@ | ||
| 133 | 160 | */ |
| 134 | 161 | function wpbc_ui__horis_menu__item_main( $menu_slug, $menu_item_arr ) { |
| 135 | 162 | |
| 136 | 163 | $defaults = array( |
| 137 | - 'title' => '', | |
| 138 | - 'page_title' => '', | |
| 139 | - 'hint' => '', | |
| 140 | - 'link' => '', | |
| 141 | - 'position' => '', | |
| 142 | - 'css_classes' => '', | |
| 143 | - 'folder_style' => '', | |
| 144 | - 'icon' => '', | |
| 145 | - 'font_icon' => '', | |
| 146 | - 'default' => false, | |
| 147 | - 'disabled' => false, | |
| 148 | - 'hided' => false, | |
| 149 | - 'is_active' => 0, | |
| 150 | - 'url' => '', | |
| 151 | - 'subtabs' => array(), | |
| 164 | + 'title' => '', | |
| 165 | + 'page_title' => '', | |
| 166 | + 'hint' => '', | |
| 167 | + 'link' => '', | |
| 168 | + 'position' => '', | |
| 169 | + 'css_classes' => '', | |
| 170 | + 'folder_style' => '', | |
| 171 | + 'icon' => '', | |
| 172 | + 'font_icon' => '', | |
| 173 | + 'default' => false, | |
| 174 | + 'disabled' => false, | |
| 175 | + 'hided' => false, | |
| 176 | + 'top_navigation_hidden' => false, | |
| 177 | + 'is_active' => 0, | |
| 178 | + 'url' => '', | |
| 179 | + 'subtabs' => array(), | |
| 152 | 180 | ); |
| 153 | 181 | $menu_item_arr = wp_parse_args( $menu_item_arr, $defaults ); |
| 154 | 182 | $folder_style = ( ! empty( $menu_item_arr['folder_style'] ) ) ? esc_attr( $menu_item_arr['folder_style'] ) : ''; // FixIn: 11.4.2. |
| 155 | 183 | |