PluginProbe
Booking Calendar / 11.5
Booking Calendar v11.5
11.8.4 11.8.3 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 All 204 releases
booking / includes / ui_settings / parts / ui__nav_horis.php

ui__nav_horis.php in Booking Calendar 11.5, at includes/ui_settings/parts/ui__nav_horis.php

204 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 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.
26 *
27 * @return void
28 */
29 function wpbc_ui__top_horisontal_nav( $args =array() ) {
30
31 $defaults = array(
32 'attr' => array(),
33 );
34 $params = wp_parse_args( $args, $defaults );
35
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 // Available Main Menu - slug => titles.
43 $show_these_pages_arr = array(
44 'wpbc' => __( 'Bookings', 'booking' ),
45 'wpbc-availability' => __( 'Availability', 'booking' ),
46 'wpbc-prices' => __( 'Prices', 'booking' ),
47 'wpbc-resources' => __( 'Resources', 'booking' ),
48 'wpbc-settings' => __( 'Settings', 'booking' ),
49 'wpbc-setup' => __( 'Setup', 'booking' ),
50 );
51
52
53 // Ability to click on panel, only if there 'min' class - panel minimized!
54 echo '<div class="wpbc_ui_el__horis_top_bar__wrapper">';
55
56 echo ' <div class="wpbc_ui_el__horis_top_bar__content">';
57
58 $main_page_slug = $active_page_arr['active_page'];
59 $page_title = $show_these_pages_arr[ $main_page_slug ];
60
61 // Loop to show all main sections in horisontal menu.
62 foreach ( $show_these_pages_arr as $main_page_slug => $page_title ) {
63
64 // Show only active page settings list.
65 if ( $main_page_slug !== $active_page_arr['active_page'] ) {
66 continue;
67 }
68 $page_item_arr = $args['page_nav_tabs'][ $main_page_slug ];
69 $active_tab = isset( $page_item_arr[ $active_page_arr['active_tab'] ] ) && is_array( $page_item_arr[ $active_page_arr['active_tab'] ] )
70 ? $page_item_arr[ $active_page_arr['active_tab'] ]
71 : array();
72
73 // Some focused settings pages use their subtabs as the horizontal page-level navigation.
74 if (
75 ! empty( $active_tab['top_navigation_use_subtabs'] )
76 && ! empty( $active_tab['subtabs'] )
77 && is_array( $active_tab['subtabs'] )
78 ) {
79 $page_item_arr = $active_tab['subtabs'];
80 }
81
82 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
83
84 foreach ( $page_item_arr as $main_menu_slug => $menu_item_arr ) {
85 // Legacy hided/disabled flags control other navigation surfaces; the top bar uses its own explicit flag.
86 if ( ! empty( $menu_item_arr['top_navigation_hidden'] ) ) {
87 continue;
88 }
89
90 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
91
92 wpbc_ui__horis_menu__item_main( $main_menu_slug, $menu_item_arr );
93
94 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
95 }
96 do_action( 'hook__wpbc_ui__top_horisontal_nav__end', $active_page_arr['active_page'], $active_page_arr['active_tab'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
97
98 // wpbc_ui_el__divider_vertical();
99 } // Loop to show all main sections in horisontal menu.
100 echo ' </div><!-- wpbc_ui_el__horis_top_bar__content -->';
101
102 echo '</div><!-- wpbc_ui_el__horis_top_bar__wrapper -->';
103 }
104
105
106 /**
107 * Remove New labels from titles rendered in the top horizontal navigation.
108 *
109 * @param string $title Horizontal navigation title.
110 *
111 * @return string
112 */
113 function wpbc_ui__horis_menu__item_main__remove_new_label( $title ) {
114
115 if ( ! is_string( $title ) || '' === $title ) {
116 return $title;
117 }
118
119 $filtered_title = preg_replace(
120 '/<span\b[^>]*\bclass\s*=\s*(["\'])[^"\']*\bwpbc_new_label\b[^"\']*\1[^>]*>.*?<\/span>(?:\s|&nbsp;)*/is',
121 '',
122 $title
123 );
124
125 return ( null === $filtered_title ) ? $title : $filtered_title;
126 }
127 add_filter( 'wpbc_ui__horis_menu__item_main__title', 'wpbc_ui__horis_menu__item_main__remove_new_label', PHP_INT_MAX );
128
129
130 /**
131 * Show Horisontal - "Menu Item".
132 *
133 * @param string $menu_slug - 'calendar_appearance'.
134 * @param array $menu_item_arr - [ [title] => Skin
135 * [page_title] => Calendar General Settings 3
136 * [hint] => Calendar General Settings 2
137 * [link] =>
138 * [position] =>
139 * [css_classes] =>
140 * [folder_style] => order:93;
141 * [icon] =>
142 * [font_icon] => wpbc-bi-calendar2-range
143 * [default] =>
144 * [disabled] =>
145 * [hided] =>
146 * [top_navigation_hidden] =>
147 * [is_active] => 1
148 * [url] => http://beta/wp-admin/admin.php?page=wpbc-settings&#038;tab=calendar_appearance
149 * [subtabs] => [....]
150 * ]
151 *
152 * @return void
153 */
154 function wpbc_ui__horis_menu__item_main( $menu_slug, $menu_item_arr ) {
155
156 $defaults = array(
157 'title' => '',
158 'page_title' => '',
159 'hint' => '',
160 'link' => '',
161 'position' => '',
162 'css_classes' => '',
163 'folder_style' => '',
164 'icon' => '',
165 'font_icon' => '',
166 'default' => false,
167 'disabled' => false,
168 'hided' => false,
169 'top_navigation_hidden' => false,
170 'is_active' => 0,
171 'url' => '',
172 'subtabs' => array(),
173 );
174 $menu_item_arr = wp_parse_args( $menu_item_arr, $defaults );
175 $folder_style = ( ! empty( $menu_item_arr['folder_style'] ) ) ? esc_attr( $menu_item_arr['folder_style'] ) : ''; // FixIn: 11.4.2.
176
177 /**
178 * Filter the title displayed in the top horizontal navigation.
179 *
180 * @param string $title Horizontal navigation title.
181 * @param string $menu_slug Menu item slug.
182 * @param array $menu_item_arr Complete menu item configuration.
183 */
184 $menu_item_arr['title'] = apply_filters( 'wpbc_ui__horis_menu__item_main__title', $menu_item_arr['title'], $menu_slug, $menu_item_arr );
185
186 ?><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 ' : ''; ?>"
187 style="<?php echo esc_attr( $folder_style ); ?>">
188 <?php
189 // Single Item.
190 ?>
191 <a href="<?php echo esc_url( $menu_item_arr['url'] ); ?>"
192 class="wpbc_ui_el__horis_nav_item__a wpbc_ui_el__horis_nav_item__single">
193 <?php if ( ! empty( $menu_item_arr['font_icon'] ) ) { ?>
194 <i class="wpbc_ui_el__horis_nav_icon tooltip_top menu_icon icon-1x <?php echo esc_attr( $menu_item_arr['font_icon'] ); ?>"
195 data-original-title="<?php echo esc_attr( $menu_item_arr['title'] ); ?>"></i>
196 <?php } ?>
197 <span class="wpbc_ui_el__horis_nav_title"><?php
198 echo wp_kses_post( $menu_item_arr['title'] );
199 ?></span>
200 </a>
201 </div>
202 <?php
203 }
204