| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Menu Structure in Admin Panel |
| 4 | 4 | * |
| @@ -62,12 +62,24 @@ | ||
| 62 | 62 | |
| 63 | 63 | // Defining Name of parameter in GET request - $_GET[ 'subtab' ] == 'paypal'. |
| 64 | 64 | $this->tags['subtab'] = 'subtab'; |
| 65 | 65 | |
| 66 | + // FixIn: 10.14.1.2. | |
| 66 | 67 | // This Hook fire after creation menu in class WPBC_Admin_Menus. |
| 67 | - add_action( 'wpbc_define_nav_tabs', array( $this, 'wpbc_create_plugin_menu_structure_arr' ) ); | |
| 68 | + add_action( 'wpbc_define_nav_tabs', array( $this, 'wpbc_create_plugin_menu_structure_arr' ), 10, 1 ); | |
| 69 | + | |
| 70 | + // Such calls requires for ability to use methods, such as $this->is_use_option__in_subtabs_or_tabs('...'), which can be run only after_tabs_defined ! | |
| 71 | + // We set here priority 11, to load this function, after 'wpbc_create_plugin_menu_structure_arr', where defined all tabs. | |
| 72 | + add_action( 'wpbc_define_nav_tabs', array( $this, 'after_tabs_defined' ), 11, 1 ); | |
| 73 | + | |
| 74 | + // Right Vertical Sidebar. // FixIn: 10.14.1.3. | |
| 75 | + add_action( 'wpbc_ui__right_vertical_sidebar_content', array( $this, 'maybe_show_right_sidebar_content' ) ); | |
| 76 | + | |
| 77 | + // Right Vertical Sidebar - Compact. // FixIn: 10.14.1.3. | |
| 78 | + add_action( 'wpbc_ui__right_vertical_sidebar_compact_content', array( $this, 'maybe_show_right_sidebar_compact_content' ) ); | |
| 68 | 79 | } |
| 69 | 80 | |
| 81 | + | |
| 70 | 82 | // ----------------------------------------------------------------------------------------------------------------- |
| 71 | 83 | // Abstract Methods |
| 72 | 84 | // ----------------------------------------------------------------------------------------------------------------- |
| 73 | 85 | |
| @@ -191,15 +203,121 @@ | ||
| 191 | 203 | */ |
| 192 | 204 | abstract public function content(); |
| 193 | 205 | |
| 194 | 206 | |
| 207 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 208 | + // Right Vertical Sidebar. // FixIn: 10.14.1.3. | |
| 209 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 210 | + | |
| 211 | + /** | |
| 212 | + * Show content of right sidebar. Overide it in child classes ! | |
| 213 | + * | |
| 214 | + * @return void | |
| 215 | + */ | |
| 216 | + abstract public function right_sidebar_content(); | |
| 217 | + | |
| 218 | + | |
| 219 | + /** | |
| 220 | + * Helper method to show 'right sidebar' only if it is enabled page! | |
| 221 | + * | |
| 222 | + * @return void | |
| 223 | + */ | |
| 224 | + public function maybe_show_right_sidebar_content(){ | |
| 225 | + | |
| 226 | + if ( ! $this->is_page_activated() ) { | |
| 227 | + return false; | |
| 228 | + } | |
| 229 | + | |
| 230 | + $this->right_sidebar_content(); | |
| 231 | + } | |
| 232 | + | |
| 233 | + /** | |
| 234 | + * Show content of right sidebar - Compact. Overide it in child classes ! | |
| 235 | + * | |
| 236 | + * @return void | |
| 237 | + */ | |
| 238 | + abstract public function right_sidebar_compact_content(); | |
| 239 | + | |
| 240 | + | |
| 241 | + /** | |
| 242 | + * Helper method to show 'right sidebar' - Compact only if it is enabled page! | |
| 243 | + * | |
| 244 | + * @return void | |
| 245 | + */ | |
| 246 | + public function maybe_show_right_sidebar_compact_content(){ | |
| 247 | + | |
| 248 | + if ( ! $this->is_page_activated() ) { | |
| 249 | + return false; | |
| 250 | + } | |
| 251 | + | |
| 252 | + $this->right_sidebar_compact_content(); | |
| 253 | + } | |
| 254 | + | |
| 255 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 256 | + // Methods After 'Tabs' defined. // FixIn: 10.14.1.2. | |
| 257 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 258 | + | |
| 259 | + /** | |
| 260 | + * We already prepeared all tabs and can use function such as $this->is_page_activated(); | |
| 261 | + * // FixIn: 10.14.1.2. | |
| 262 | + * | |
| 263 | + * @return void | |
| 264 | + */ | |
| 265 | + public function after_tabs_defined() { | |
| 266 | + | |
| 267 | + // This call -> Initiate definition of all parameters for current page. | |
| 268 | + $is_page_activated = $this->is_page_activated(); | |
| 269 | + | |
| 270 | + if ( $is_page_activated ) { | |
| 271 | + add_filter( 'admin_body_class', array( $this, 'admin_body_class__add_loading_classes' ) ); | |
| 272 | + } | |
| 273 | + } | |
| 274 | + | |
| 275 | + | |
| 276 | + /** | |
| 277 | + * Check if this page have to load in default Full Screen mode, | |
| 278 | + * because of parameter 'is_default_full_screen' => false in ->tabs(...) method. | |
| 279 | + * If yes, then we add css class 'wpbc_admin_full_screen' to the body of the page. | |
| 280 | + * // FixIn: 10.14.1.2. | |
| 281 | + * | |
| 282 | + * @param string $classes - CSS classes. | |
| 283 | + * | |
| 284 | + * @return mixed|string | |
| 285 | + */ | |
| 286 | + public function admin_body_class__add_loading_classes( $classes ) { | |
| 287 | + | |
| 288 | + // Such methods can be loaded only after_tabs_defined(). | |
| 289 | + if ( ( method_exists( $this, 'is_full_screen_mode_enabled' ) ) && ( $this->is_full_screen_mode_enabled() ) ) { | |
| 290 | + $classes .= ' wpbc_admin_full_screen'; | |
| 291 | + } | |
| 292 | + | |
| 293 | + return $classes; | |
| 294 | + } | |
| 295 | + | |
| 296 | + | |
| 297 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 298 | + // Getters | |
| 299 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 300 | + | |
| 195 | 301 | public function get_current_page_params() { |
| 196 | 302 | return $this->current_page_params; |
| 197 | 303 | } |
| 198 | 304 | |
| 199 | - public function get_nav_tabs() { | |
| 200 | - return self::$nav_tabs; | |
| 201 | - } | |
| 305 | + public function get_nav_tabs() { | |
| 306 | + if ( function_exists( 'wpbc_booking_modes_v3_capture_navigation_source' ) ) { | |
| 307 | + return wpbc_booking_modes_v3_capture_navigation_source( self::$nav_tabs ); | |
| 308 | + } | |
| 309 | + | |
| 310 | + if ( | |
| 311 | + function_exists( 'wpbc_booking_modes_is_navigation_boundary_enabled' ) | |
| 312 | + && wpbc_booking_modes_is_navigation_boundary_enabled() | |
| 313 | + && function_exists( 'wpbc_booking_modes_resolve_navigation' ) | |
| 314 | + ) { | |
| 315 | + return wpbc_booking_modes_resolve_navigation( self::$nav_tabs ); | |
| 316 | + } | |
| 317 | + | |
| 318 | + return self::$nav_tabs; | |
| 319 | + } | |
| 202 | 320 | |
| 203 | 321 | // ----------------------------------------------------------------------------------------------------------------- |
| 204 | 322 | // Active Page Parameters |
| 205 | 323 | // ----------------------------------------------------------------------------------------------------------------- |
| @@ -229,10 +347,18 @@ | ||
| 229 | 347 | : null; |
| 230 | 348 | |
| 231 | 349 | foreach ( $this_page_arr as $this_page ) { |
| 232 | 350 | |
| 233 | - foreach ( $this->tabs() as $this_tab_tag => $this_tab ) { // Get First Tab Element, which MUST be subtab element, all other tabs, can be links, not really showing content!!! | |
| 234 | - break; | |
| 351 | + foreach ( $this->tabs() as $this_tab_tag => $this_tab ) { | |
| 352 | + | |
| 353 | + // FixIn: 10.11.3.5.1. | |
| 354 | + $not_skip_type_arr = array( 'tab', 'subtab' ); | |
| 355 | + | |
| 356 | + if ( ( empty( $this_tab['type'] ) ) || ( in_array( $this_tab['type'], $not_skip_type_arr, true ) ) ) { | |
| 357 | + // Probably it is not the separator, and we have no content here ! | |
| 358 | + // Get First Tab Element, which MUST be subtab element, all other tabs, can be links, not really showing content!!! | |
| 359 | + break; | |
| 360 | + } | |
| 235 | 361 | } |
| 236 | 362 | |
| 237 | 363 | if ( empty( $this_tab ) ) { |
| 238 | 364 | return $this_page; // this page empty - tabs is empty array, probabaly its was redefined in child CLASS to $tabs = array(); for not ability to open this page. |
| @@ -237,18 +363,34 @@ | ||
| 237 | 363 | if ( empty( $this_tab ) ) { |
| 238 | 364 | return $this_page; // this page empty - tabs is empty array, probabaly its was redefined in child CLASS to $tabs = array(); for not ability to open this page. |
| 239 | 365 | } |
| 240 | 366 | |
| 241 | - $this_subtab_tag = 0; | |
| 242 | - $this_subtab = array( 'default' => false ); | |
| 243 | - | |
| 244 | - if ( isset( $this_tab['subtabs'] ) ) { | |
| 245 | - foreach ( $this_tab['subtabs'] as $temp_this_subtab_tag => $temp_this_subtab ) { | |
| 246 | - | |
| 247 | - // Get First Subtab element from subtabs array. | |
| 248 | - if ( 'subtab' === $temp_this_subtab['type'] ) { | |
| 249 | - $this_subtab_tag = $temp_this_subtab_tag; | |
| 250 | - $this_subtab = $temp_this_subtab; | |
| 367 | + $this_subtab_tag = 0; | |
| 368 | + $this_subtab = array( 'default' => false ); | |
| 369 | + | |
| 370 | + if ( | |
| 371 | + isset( $request_arr['subtab'] ) | |
| 372 | + && isset( $this_tab['subtabs'] ) | |
| 373 | + && is_array( $this_tab['subtabs'] ) | |
| 374 | + && isset( $this_tab['subtabs'][ $request_arr['subtab'] ] ) | |
| 375 | + && is_array( $this_tab['subtabs'][ $request_arr['subtab'] ] ) | |
| 376 | + && isset( $this_tab['subtabs'][ $request_arr['subtab'] ]['type'] ) | |
| 377 | + && 'subtab' === $this_tab['subtabs'][ $request_arr['subtab'] ]['type'] | |
| 378 | + ) { | |
| 379 | + // Resolve the explicitly requested subtab, even when it is not the first one declared by this page class. | |
| 380 | + $this_subtab_tag = $request_arr['subtab']; | |
| 381 | + $this_subtab = $this_tab['subtabs'][ $request_arr['subtab'] ]; | |
| 382 | + } elseif ( isset( $this_tab['subtabs'] ) && is_array( $this_tab['subtabs'] ) ) { | |
| 383 | + foreach ( $this_tab['subtabs'] as $temp_this_subtab_tag => $temp_this_subtab ) { | |
| 384 | + | |
| 385 | + // Get First Subtab element from subtabs array. | |
| 386 | + if ( | |
| 387 | + is_array( $temp_this_subtab ) | |
| 388 | + && isset( $temp_this_subtab['type'] ) | |
| 389 | + && 'subtab' === $temp_this_subtab['type'] | |
| 390 | + ) { | |
| 391 | + $this_subtab_tag = $temp_this_subtab_tag; | |
| 392 | + $this_subtab = $temp_this_subtab; | |
| 251 | 393 | break; |
| 252 | 394 | } |
| 253 | 395 | } |
| 254 | 396 | } |
| @@ -303,13 +445,23 @@ | ||
| 303 | 445 | * @return void |
| 304 | 446 | */ |
| 305 | 447 | protected function define_current_page_parameters( $this_tab_tag, $this_tab, $this_subtab_tag, $this_subtab ) { |
| 306 | 448 | |
| 307 | - $this->current_page_params = array( | |
| 308 | - 'tab' => array_merge( $this_tab, array( 'tag' => $this_tab_tag ) ), | |
| 309 | - 'subtab' => array_merge( $this_subtab, array( 'tag' => $this_subtab_tag ) ), | |
| 310 | - ); | |
| 311 | - } | |
| 449 | + $this->current_page_params = array( | |
| 450 | + 'tab' => array_merge( $this_tab, array( 'tag' => $this_tab_tag ) ), | |
| 451 | + 'subtab' => array_merge( $this_subtab, array( 'tag' => $this_subtab_tag ) ), | |
| 452 | + ); | |
| 453 | + | |
| 454 | + if ( function_exists( 'wpbc_booking_modes_v3_apply_current_page_options' ) ) { | |
| 455 | + $context = wpbc_booking_modes_get_context(); | |
| 456 | + $this->current_page_params = wpbc_booking_modes_v3_apply_current_page_options( | |
| 457 | + $this->current_page_params, | |
| 458 | + $context['page'], | |
| 459 | + $this_tab_tag, | |
| 460 | + $this_subtab_tag | |
| 461 | + ); | |
| 462 | + } | |
| 463 | + } | |
| 312 | 464 | |
| 313 | 465 | |
| 314 | 466 | /** |
| 315 | 467 | * Get all SubTabs of current opened page Tab |
| @@ -470,19 +622,27 @@ | ||
| 470 | 622 | |
| 471 | 623 | foreach ( $local_top_main_menu_arr as $tab_tag => $tab_array ) { |
| 472 | 624 | |
| 473 | 625 | if ( ! isset( self::$nav_tabs[ $this_page ][ $tab_tag ] ) ) { // If this tab ( for exmaple "payment") declared previously, then does not do anything. |
| 626 | + self::$nav_tabs[ $this_page ][ $tab_tag ] = array(); | |
| 627 | + } | |
| 474 | 628 | |
| 475 | - self::$nav_tabs[ $this_page ][ $tab_tag ] = $local_top_main_menu_arr[ $tab_tag ]; | |
| 629 | + foreach ( $local_top_main_menu_arr[ $tab_tag ] as $page_prop_name => $page_prop_value ) { | |
| 630 | + if ( 'subtabs' !== $page_prop_name ) { | |
| 631 | + self::$nav_tabs[ $this_page ][ $tab_tag ][ $page_prop_name ] = $page_prop_value; | |
| 632 | + } | |
| 633 | + } | |
| 634 | + | |
| 635 | + if ( ! isset( self::$nav_tabs[ $this_page ][ $tab_tag ]['subtabs'] ) ) { | |
| 476 | 636 | self::$nav_tabs[ $this_page ][ $tab_tag ]['subtabs'] = array(); |
| 477 | 637 | } |
| 638 | + // Merge subtabs (Ex: PayPal and Sage) and attach to current tab: (Ex: payment). | |
| 639 | + self::$nav_tabs[ $this_page ][ $tab_tag ]['subtabs'] = array_merge( self::$nav_tabs[ $this_page ][ $tab_tag ]['subtabs'], $local_vert_left_menu_arr[ $tab_tag ] ); | |
| 478 | 640 | |
| 479 | - if ( isset( self::$nav_tabs[ $this_page ] ) ) { | |
| 480 | - // Merge subtabs (Ex: PayPal and Sage) and attach to current tab: (Ex: payment). | |
| 481 | - self::$nav_tabs[ $this_page ][ $tab_tag ]['subtabs'] = array_merge( self::$nav_tabs[ $this_page ][ $tab_tag ]['subtabs'], $local_vert_left_menu_arr[ $tab_tag ] ); | |
| 482 | - } | |
| 483 | 641 | } |
| 484 | 642 | } |
| 643 | + | |
| 644 | + self::$nav_tabs = apply_filters( 'wpbc_plugin_menu_structure_arr', self::$nav_tabs, $this_page ); | |
| 485 | 645 | } |
| 486 | 646 | |
| 487 | 647 | |
| 488 | 648 | /** |