|
23 | 23 | break; |
24 | 24 | } |
25 | 25 | } |
| 26 | + |
| 27 | +// Teams for WooCommerce Memberships. |
| 28 | +$is_teams_area_page = false; |
| 29 | +$team = null; |
| 30 | +$teams_area_sections = []; |
| 31 | +if ( function_exists( 'wc_memberships_for_teams' ) ) { |
| 32 | + $teams_area = wc_memberships_for_teams()->get_frontend_instance()->get_teams_area_instance(); |
| 33 | + $is_teams_area_page = $teams_area->is_teams_area(); |
| 34 | + $team = $teams_area->get_teams_area_team(); |
| 35 | + $teams_area_sections = $teams_area->get_teams_area_navigation_items( $team ); |
| 36 | +} |
26 | 37 | ?> |
27 | 38 |
|
28 | 39 | <div class="newspack-my-account__navigation-topbar"> |
|
44 | 55 | </a> |
45 | 56 | <?php endif; ?> |
46 | 57 |
|
47 | | - <a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="newspack-my-account__home-link newspack-ui__button newspack-ui__button--small newspack-ui__button--ghost-light"> |
48 | | - <?php Newspack_UI_Icons::print_svg( 'chevronLeft' ); ?> |
49 | | - <?php _e( 'Back to Homepage', 'newspack-plugin' ); ?> |
50 | | - </a> |
51 | | - |
52 | | - <ul> |
53 | | - <?php |
54 | | - // Check if viewing a single subscription page. |
55 | | - $is_viewing_single_subscription = false; |
56 | | - if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'view-subscription' ) ) { |
57 | | - $is_viewing_single_subscription = true; |
58 | | - } |
| 58 | + <?php |
| 59 | + if ( $team ) : |
| 60 | + $back_section = array_shift( $teams_area_sections ); |
59 | 61 | ?> |
60 | | - <?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?> |
| 62 | + <a href="<?php echo esc_url( $back_section['url'] ); ?>" class="newspack-my-account__home-link newspack-ui__button newspack-ui__button--small newspack-ui__button--ghost-light"> |
| 63 | + <?php Newspack_UI_Icons::print_svg( 'chevronLeft' ); ?> |
| 64 | + <?php echo esc_html( $back_section['label'] ); ?> |
| 65 | + </a> |
| 66 | + <ul> |
61 | 67 | <?php |
62 | | - // Highlight subscriptions menu item if viewing a single subscription. |
63 | | - $is_current_item = wc_is_current_account_menu_item( $endpoint ) || ( $is_viewing_single_subscription && 'subscriptions' === $endpoint ); |
| 68 | + foreach ( $teams_area_sections as $section_id => $section_data ) : |
| 69 | + $classes = wc_get_account_menu_item_classes( $section_id ) . ' ' . $section_data['class']; |
| 70 | + $is_current_item = strpos( $classes, 'is-active' ) !== false; |
| 71 | + ?> |
| 72 | + <li class="<?php echo esc_attr( $classes ); ?>"> |
| 73 | + <a href="<?php echo esc_url( $section_data['url'] ); ?>" class="newspack-ui__button newspack-ui__button--small <?php echo $is_current_item ? 'newspack-ui__button--accent' : 'newspack-ui__button--ghost'; ?>"> |
| 74 | + <?php echo esc_html( $section_data['label'] ); ?> |
| 75 | + </a> |
| 76 | + </li> |
| 77 | + <?php endforeach; ?> |
| 78 | + </ul> |
| 79 | + <?php else : ?> |
| 80 | + <a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="newspack-my-account__home-link newspack-ui__button newspack-ui__button--small newspack-ui__button--ghost-light"> |
| 81 | + <?php Newspack_UI_Icons::print_svg( 'chevronLeft' ); ?> |
| 82 | + <?php _e( 'Back to Homepage', 'newspack-plugin' ); ?> |
| 83 | + </a> |
| 84 | + <ul> |
| 85 | + <?php |
| 86 | + // Check if viewing a single subscription page. |
| 87 | + $is_viewing_single_subscription = false; |
| 88 | + if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'view-subscription' ) ) { |
| 89 | + $is_viewing_single_subscription = true; |
| 90 | + } |
64 | 91 | ?> |
65 | | - <li class="<?php echo esc_attr( wc_get_account_menu_item_classes( $endpoint ) ); ?>"> |
66 | | - <a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>" <?php echo $is_current_item ? 'aria-current="page"' : ''; ?> class="newspack-ui__button newspack-ui__button--small <?php echo $is_current_item ? 'newspack-ui__button--accent' : 'newspack-ui__button--ghost'; ?>"> |
67 | | - <?php echo esc_html( $label ); ?> |
68 | | - </a> |
69 | | - </li> |
70 | | - <?php endforeach; ?> |
71 | | - </ul> |
| 92 | + <?php foreach ( $account_menu_items as $endpoint => $label ) : ?> |
| 93 | + <?php |
| 94 | + // Highlight subscriptions menu item if viewing a single subscription. |
| 95 | + $is_current_item = wc_is_current_account_menu_item( $endpoint ) || ( $is_viewing_single_subscription && 'subscriptions' === $endpoint ); |
| 96 | + ?> |
| 97 | + <li class="<?php echo esc_attr( wc_get_account_menu_item_classes( $endpoint ) ); ?>"> |
| 98 | + <a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>" <?php echo $is_current_item ? 'aria-current="page"' : ''; ?> class="newspack-ui__button newspack-ui__button--small <?php echo $is_current_item ? 'newspack-ui__button--accent' : 'newspack-ui__button--ghost'; ?>"> |
| 99 | + <?php echo esc_html( $label ); ?> |
| 100 | + </a> |
| 101 | + </li> |
| 102 | + <?php endforeach; ?> |
| 103 | + </ul> |
| 104 | + <?php endif; ?> |
72 | 105 | </div> |
73 | 106 |
|
74 | 107 | <div class="newspack-my-account__navigation-footer"> |
|
0 commit comments