PluginProbe
Booking Calendar / 11.1
Booking Calendar v11.1
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 10.11.2 All 203 releases
booking / includes / ui_settings / parts / ui__nav_top.php

ui__nav_top.php in Booking Calendar 11.1, at includes/ui_settings/parts/ui__nav_top.php

323 lines 10.8 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-02-15
14 */
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit, if accessed directly.
18 }
19
20 /**
21 * Show Top Nav bar
22 *
23 * @param array $args - parameters.
24 *
25 * @return void
26 */
27 function wpbc_ui__top_nav( $args = array() ) {
28
29 $defaults = array(
30 'attr' => array(),
31 );
32 $params = wp_parse_args( $args, $defaults );
33
34 echo '<div class="wpbc_ui_el wpbc_ui_el__top_nav">';
35
36 wpbc_ui__vert_left_bar__do_toggle();
37 wpbc_ui_el__divider_vertical( array( 'class' => 'wpbc_ui_el__vertical_line wpbc_ui__top_nav__btn_show_left_vertical_nav_divider' ) );
38
39 wpbc_ui__top_nav__dropdown__wpbc();
40
41 do_action( 'wpbc_ui_el__top_nav__content_start', $params['page_tag'], $params['active_page_tab'], $params['active_page_subtab'] );
42
43
44 ?><div class="wpbc_ui_el__make_space"></div><?php // Spacer.
45
46 do_action( 'wpbc_ui_el__top_nav__content_center', $params['page_tag'], $params['active_page_tab'], $params['active_page_subtab'] );
47
48 // Load Top News Message and "Search by ID" fields.
49 echo '<style type="text/css"> .wpbc_message_wrapper { margin-left: 0px !important; } </style>';
50 make_bk_action( 'wpbc_h1_header_content_end', $params['page_tag'], $params['active_page_tab'], $params['active_page_subtab'] );
51
52 ?><div class="wpbc_ui_el__make_space"></div><?php // Spacer.
53
54 do_action( 'wpbc_ui_el__top_nav__content_end', $params['page_tag'], $params['active_page_tab'], $params['active_page_subtab'] );
55
56 wpbc_ui_el__divider_vertical();
57
58 // Right sidebar toggle button.
59 wpbc_ui__vert_right_bar__do_toggle();
60 wpbc_ui_el__divider_vertical( array( 'class' => 'wpbc_ui_el__vertical_line wpbc_ui__top_nav__btn_show_right_vertical_nav_divider' ) );
61
62
63 // Full Screen Buttons.
64 wpbc_ui__top_nav__btn_full_screen();
65 wpbc_ui__top_nav__btn_normal_screen();
66
67 echo '</div>';
68 }
69
70
71
72 /**
73 * Show element - "WPBC - Main Dropdown"
74 *
75 * @return void
76 */
77 function wpbc_ui__top_nav__dropdown__wpbc() {
78
79 $svg_size = '22px';
80 $svg_icon_style = 'margin:5px 5px 0 0;'; // 'background-position: 0 0;background-size: ' . $svg_size . ' ' . $svg_size . ';width: ' . $svg_size . ';height: ' . $svg_size . ';'; //.
81 $svg_icon = wpbc_get_svg_logo_for_background( '#555', '#e5e5e5', '1.0' );
82
83 $wpbc_starter_pages = function_exists( 'wpbc_get_published_activation_booking_pages' ) ? wpbc_get_published_activation_booking_pages() : array();
84 $wp_post_booking_absolute = false;
85
86 if (
87 empty( $wpbc_starter_pages ) &&
88 function_exists( 'wpbc_stp_wiz__is_exist_published_page_with_booking_form' )
89 ) {
90 $wp_post_booking_absolute = wpbc_stp_wiz__is_exist_published_page_with_booking_form();
91 }
92
93 $el_arr = array(
94 // 'title' => 'Booking Calendar',
95 // 'font_icon' => 'wpbc-bi-calendar2-range',
96 'title_html' => '<span class="nav-tab-text" style="margin: -3px 0 0 5px;font-size: 16px;padding: 0;"><span style="position: absolute;font-size: 7px;margin-top: 13px;margin-left: 1px;">WP</span>Booking Calendar</span>',
97 'svg_icon' => $svg_icon,
98 'svg_icon_style' => $svg_icon_style,
99 'style' => 'display: flex;flex-flow:row nowrap;align-items: center;justify-content: flex-start; ',
100 'container_style' => 'padding: 0 15px 0 10px;',
101 'position' => 'left',
102 'has_down_arrow' => true,
103 'items' => array(),
104 );
105
106 if ( ! empty( $wpbc_starter_pages ) && is_array( $wpbc_starter_pages ) ) {
107 $el_arr['items'][] = array(
108 'type' => 'header',
109 'title' => __( 'Visit Booking Pages', 'booking' ),
110 );
111 $el_arr['items'][] = array(
112 'type' => 'link',
113 'title' => __( 'Visit Home Page', 'booking' ),
114 'url' => esc_url( home_url( '/' ) ),
115 );
116
117 foreach ( $wpbc_starter_pages as $wpbc_starter_page ) {
118 if ( empty( $wpbc_starter_page['url'] ) ) {
119 continue;
120 }
121
122 $wpbc_starter_page_title = __( 'Go to page with booking form', 'booking' );
123 if ( ! empty( $wpbc_starter_page['button_title'] ) ) {
124 $wpbc_starter_page_title = $wpbc_starter_page['button_title'];
125 } elseif ( ! empty( $wpbc_starter_page['page_title'] ) ) {
126 $wpbc_starter_page_title = $wpbc_starter_page['page_title'];
127 }
128
129 $el_arr['items'][] = array(
130 'type' => 'link',
131 'title' => $wpbc_starter_page_title,
132 'url' => esc_url( $wpbc_starter_page['url'] ),
133 );
134 }
135 } elseif ( ! empty( $wp_post_booking_absolute ) ) {
136 $el_arr['items'][] = array(
137 'type' => 'header',
138 'title' => __( 'Visit Booking Page', 'booking' ),
139 );
140 $el_arr['items'][] = array(
141 'type' => 'link',
142 'title' => __( 'Visit Home Page', 'booking' ),
143 'url' => esc_url( home_url( '/' ) ),
144 );
145 $el_arr['items'][] = array(
146 'type' => 'link',
147 'title' => __( 'Go to page with booking form', 'booking' ),
148 'url' => esc_url( $wp_post_booking_absolute ),
149 );
150 }
151 $el_arr['items'][] = array(
152 'type' => 'header',
153 'title' => __( 'Help', 'booking' ),
154 );
155 $el_arr['items'][] = array(
156 'type' => 'link',
157 'title' => __( 'FAQ', 'booking' ),
158 'url' => 'https://wpbookingcalendar.com/faq/',
159 );
160 $el_arr['items'][] = array(
161 'type' => 'header',
162 'title' => __( 'Support', 'booking' ),
163 );
164 $el_arr['items'][] = array(
165 'type' => 'link',
166 'title' => __( 'Support Forum', 'booking' ),
167 'url' => 'https://wpbookingcalendar.com/support/',
168 );
169 $el_arr['items'][] = array(
170 'type' => 'link',
171 'title' => __( 'Contact Support', 'booking' ),
172 'url' => 'mailto:support@wpbookingcalendar.com',
173 'attr' => array( 'style' => 'font-weight: 600;' ),
174 );
175 $el_arr['items'][] = array( 'type' => 'divider' );
176 $el_arr['items'][] = array(
177 'type' => 'link',
178 'title' => __( 'Release History', 'booking' ),
179 'url' => 'https://wpbookingcalendar.com/wn/',
180 );
181 $el_arr['items'][] = array(
182 'type' => 'link',
183 'title' => __( 'What\'s New', 'booking' ) . ' <span style="float:right">' . esc_attr( WP_BK_VERSION_NUM ) . '</span>',
184 'url' => esc_url( admin_url( add_query_arg( array( 'page' => 'wpbc-about' ), 'index.php' ) ) ),
185 );
186 // $el_arr['items'][] = array(
187 // 'type' => 'link',
188 // 'title' => __( 'About', 'booking' ),
189 // 'url' => 'https://wpbookingcalendar.com/',
190 // );
191
192
193 $is_show_up = wpbc_is_show_up();
194
195 if ( $is_show_up ) {
196 $el_arr['items'][] = array( 'type' => 'divider' );
197 $el_arr['items'][] = array(
198 'type' => 'link',
199 'title' => ( class_exists( 'wpdev_bk_personal' ) )
200 ? __( 'View Upgrade Options', 'booking' )
201 : __( 'Upgrade to Pro', 'booking' ),
202 'url' => wpbc_up_link(),
203 'attr' => array(
204 'class' => 'wpbc_ui_el_upgrade_button wpbc_button_light wpbc_button_green',
205 'style' => 'color:#fff;font-weight: 600;',
206 ),
207 );
208 }
209
210 wpbc_ui_el__dropdown_menu( $el_arr );
211 }
212
213
214 /**
215 * Show element - "Full Screen"
216 *
217 * @return void
218 */
219 function wpbc_ui__top_nav__btn_full_screen() {
220
221 $el_arr = array();
222
223 $el_arr['onclick'] = "jQuery( '.wpbc_ui__top_nav__btn_full_screen,.wpbc_ui__top_nav__btn_normal_screen' ).toggleClass( 'wpbc_ui__hide' );";
224 $el_arr['onclick'] .= "jQuery('body').toggleClass('wpbc_admin_full_screen');wpbc_check_full_screen_mode();";
225
226 $el_arr['font_icon'] = 'wpbc-bi-arrows-fullscreen';
227 $el_arr['hint'] = array(
228 'title' => __( 'Full Screen', 'booking' ),
229 'position' => 'top',
230 );
231
232 $el_arr['container_class'] = 'wpbc_ui__top_nav__btn_full_screen';
233
234 if ( ! wpbc_is_setup_wizard_page() ) {
235
236 // Params for saving user option.
237 $user_cust_option = 'is_full_screen';
238 $nonce_action = $user_cust_option . '_nonce_act';
239
240 $el_arr['attr'] = array(
241 'data-wpbc-u-save-name' => $user_cust_option,
242 'data-wpbc-u-save-value' => 'On',
243 'data-wpbc-u-save-nonce' => wp_create_nonce( $nonce_action ), // do not need to make escaping the values because: wpbc_get_custom_attr() should handle escaping.
244 'data-wpbc-u-save-user-id' => wpbc_get_current_user_id(),
245 'data-wpbc-u-save-action' => $nonce_action,
246 );
247 $el_arr['onclick'] .= 'wpbc_save_custom_user_data_from_element(this);';
248
249 ?><script type="text/javascript"><?php
250
251 $is_full_screen = WPBC_User_Custom_Data_Saver::get_user_data_value( wpbc_get_current_user_id(), $user_cust_option );
252 $is_full_screen = ( 'On' === $is_full_screen );
253
254 echo wpbc_jq_ready_start(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
255
256 if ( $is_full_screen ) {
257 echo " jQuery( '.wpbc_ui__top_nav__btn_full_screen,.wpbc_ui__top_nav__btn_normal_screen' ).toggleClass( 'wpbc_ui__hide' ); ";
258 }
259 echo ' wpbc_check_full_screen_mode(); ';
260 echo wpbc_jq_ready_end(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
261
262 ?></script><?php
263 }
264 wpbc_ui_el__a( $el_arr );
265 }
266
267
268 /**
269 * Show element - "Normal Screen"
270 *
271 * @return void
272 */
273 function wpbc_ui__top_nav__btn_normal_screen() {
274
275 $el_arr = array();
276
277 $el_arr['onclick'] = "jQuery( '.wpbc_ui__top_nav__btn_full_screen,.wpbc_ui__top_nav__btn_normal_screen' ).toggleClass( 'wpbc_ui__hide' );";
278 $el_arr['onclick'] .= "jQuery('body').toggleClass('wpbc_admin_full_screen');wpbc_check_full_screen_mode();";
279
280 $el_arr['title'] = '';
281 $el_arr['font_icon'] = 'wpbc-bi-arrows-angle-contract';
282 $el_arr['hint'] = array(
283 'title' => __( 'Exit Full Screen', 'booking' ),
284 'position' => 'top',
285 );
286 $el_arr['container_class'] = 'wpbc_ui__top_nav__btn_normal_screen wpbc_ui__hide';
287
288 // Params for saving user option.
289 $user_cust_option = 'is_full_screen';
290 $nonce_action = $user_cust_option . '_nonce_act';
291 $el_arr['attr'] = array(
292 'data-wpbc-u-save-name' => $user_cust_option,
293 'data-wpbc-u-save-value' => 'Off',
294 'data-wpbc-u-save-nonce' => wp_create_nonce( $nonce_action ), // do not need to make escaping the values because: wpbc_get_custom_attr() should handle escaping.
295 'data-wpbc-u-save-user-id' => wpbc_get_current_user_id(),
296 'data-wpbc-u-save-action' => $nonce_action,
297 );
298 $el_arr['onclick'] .= 'wpbc_save_custom_user_data_from_element(this);';
299
300 wpbc_ui_el__a( $el_arr );
301 }
302
303
304 /**
305 * Set the admin full screen class
306 *
307 * @param bool $classes Body classes.
308 *
309 * @return array
310 */
311 function wpbc_check_full_screen_mode_on_loading( $classes ) {
312
313 $is_full_screen = WPBC_User_Custom_Data_Saver::get_user_data_value( wpbc_get_current_user_id(), 'is_full_screen' );
314 $is_full_screen = ( 'On' === $is_full_screen );
315
316 if ( ( wpbc_is_this_plugin_page() ) && ( $is_full_screen ) && ( ! wpbc_is_setup_wizard_page() ) ) {
317 $classes .= ' wpbc_admin_full_screen';
318 }
319
320 return $classes;
321 }
322 add_filter( 'admin_body_class', 'wpbc_check_full_screen_mode_on_loading' );
323