PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 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 All 205 releases
← All changes | includes/ui_settings/parts/ui__nav_horis.php +110 -44 10.15.7 → 11.9 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * Admin Panel UI - Parts
4 4 *
@@ -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,27 +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 - 'wpbc-new' => __( 'Add Booking', 'booking' ),
44 54 'wpbc-availability' => __( 'Availability', 'booking' ),
45 55 'wpbc-prices' => __( 'Prices', 'booking' ),
46 56 'wpbc-resources' => __( 'Resources', 'booking' ),
47 57 '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!
58 + 'wpbc-setup' => __( 'Setup', 'booking' ),
59 + );
60 + // Ability to click on panel, only if there 'min' class - panel minimized!
53 61 echo '<div class="wpbc_ui_el__horis_top_bar__wrapper">';
54 62
55 63 echo ' <div class="wpbc_ui_el__horis_top_bar__content">';
56 64
@@ -63,15 +71,32 @@
63 71 // Show only active page settings list.
64 72 if ( $main_page_slug !== $active_page_arr['active_page'] ) {
65 73 continue;
66 74 }
67 - $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 + }
68 88
69 - 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
70 98
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 ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
73 -
74 99 wpbc_ui__horis_menu__item_main( $main_menu_slug, $menu_item_arr );
75 100
76 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
77 102 }
@@ -84,10 +109,34 @@
84 109 echo '</div><!-- wpbc_ui_el__horis_top_bar__wrapper -->';
85 110 }
86 111
87 112
88 -/**
89 - * Show Horisontal - "Menu Item".
113 +/**
114 + * Remove New labels from titles rendered in the top horizontal navigation.
115 + *
116 + * @param string $title Horizontal navigation title.
117 + *
118 + * @return string
119 + */
120 +function wpbc_ui__horis_menu__item_main__remove_new_label( $title ) {
121 +
122 + if ( ! is_string( $title ) || '' === $title ) {
123 + return $title;
124 + }
125 +
126 + $filtered_title = preg_replace(
127 + '/<span\b[^>]*\bclass\s*=\s*(["\'])[^"\']*\bwpbc_new_label\b[^"\']*\1[^>]*>.*?<\/span>(?:\s|&nbsp;)*/is',
128 + '',
129 + $title
130 + );
131 +
132 + return ( null === $filtered_title ) ? $title : $filtered_title;
133 +}
134 +add_filter( 'wpbc_ui__horis_menu__item_main__title', 'wpbc_ui__horis_menu__item_main__remove_new_label', PHP_INT_MAX );
135 +
136 +
137 +/**
138 + * Show Horisontal - "Menu Item".
90 139 *
91 140 * @param string $menu_slug - 'calendar_appearance'.
92 141 * @param array $menu_item_arr - [ [title] => Skin
93 142 * [page_title] => Calendar General Settings 3
@@ -93,15 +142,17 @@
93 142 * [page_title] => Calendar General Settings 3
94 143 * [hint] => Calendar General Settings 2
95 144 * [link] =>
96 145 * [position] =>
97 - * [css_classes] =>
98 - * [icon] =>
146 + * [css_classes] =>
147 + * [folder_style] => order:93;
148 + * [icon] =>
99 149 * [font_icon] => wpbc-bi-calendar2-range
100 150 * [default] =>
101 - * [disabled] =>
102 - * [hided] =>
103 - * [is_active] => 1
151 + * [disabled] =>
152 + * [hided] =>
153 + * [top_navigation_hidden] =>
154 + * [is_active] => 1
104 155 * [url] => http://beta/wp-admin/admin.php?page=wpbc-settings&#038;tab=calendar_appearance
105 156 * [subtabs] => [....]
106 157 * ]
107 158 *
@@ -109,26 +160,39 @@
109 160 */
110 161 function wpbc_ui__horis_menu__item_main( $menu_slug, $menu_item_arr ) {
111 162
112 163 $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 ' : ''; ?>">
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(),
180 + );
181 + $menu_item_arr = wp_parse_args( $menu_item_arr, $defaults );
182 + $folder_style = ( ! empty( $menu_item_arr['folder_style'] ) ) ? esc_attr( $menu_item_arr['folder_style'] ) : ''; // FixIn: 11.4.2.
183 +
184 + /**
185 + * Filter the title displayed in the top horizontal navigation.
186 + *
187 + * @param string $title Horizontal navigation title.
188 + * @param string $menu_slug Menu item slug.
189 + * @param array $menu_item_arr Complete menu item configuration.
190 + */
191 + $menu_item_arr['title'] = apply_filters( 'wpbc_ui__horis_menu__item_main__title', $menu_item_arr['title'], $menu_slug, $menu_item_arr );
192 +
193 + ?><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 ' : ''; ?>"
194 + style="<?php echo esc_attr( $folder_style ); ?>">
131 195 <?php
132 196 // Single Item.
133 197 ?>
134 198 <a href="<?php echo esc_url( $menu_item_arr['url'] ); ?>"
@@ -136,9 +200,11 @@
136 200 <?php if ( ! empty( $menu_item_arr['font_icon'] ) ) { ?>
137 201 <i class="wpbc_ui_el__horis_nav_icon tooltip_top menu_icon icon-1x <?php echo esc_attr( $menu_item_arr['font_icon'] ); ?>"
138 202 data-original-title="<?php echo esc_attr( $menu_item_arr['title'] ); ?>"></i>
139 203 <?php } ?>
140 - <span class="wpbc_ui_el__horis_nav_title"><?php echo wp_kses_post( $menu_item_arr['title'] ); ?></span>
204 + <span class="wpbc_ui_el__horis_nav_title"><?php
205 + echo wp_kses_post( $menu_item_arr['title'] );
206 + ?></span>
141 207 </a>
142 208 </div>
143 209 <?php
144 210 }