Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/27/2023 10:55:27 PM (2 years ago)
Author:
imath
Message:

Introduce a new Theme Compat feature firstly designed for Block Themes

NB : this feature is also only available in the BP Nouveau template pack.

The Priority Navigations theme compat feature is used to make sure BP Single items primary and secondary navigations are displayed on a single row/line no matter how many items these navigations are containing.
When there's not enough space to display all the items on this row/line, an ellipsis is inserted and hovering on it shows the remaining nav items into a dropdown menu.

This commit also make sure the BP Customizer sections are neutralized so that the Customizer is not loaded on front-end when a Block Theme is active to start complying with the fact these kind of themes are not using the Customizer.

See #9030
See https://github.com/buddypress/buddypress/pull/197

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/template-tags.php

    r13529 r13652  
    15731573        $component  = bp_current_component();
    15741574        $bp_nouveau = bp_nouveau();
     1575        $object     = '';
    15751576
    15761577        // @todo wasn't able to get $customizer_option to pass a string to get_settings
    15771578        // this is a temp workaround but differs from earlier dir approach- bad!
    15781579        if ( bp_is_group() ) {
     1580            $object   = 'group';
    15791581            $nav_tabs = (int) bp_nouveau_get_temporary_setting( 'group_nav_tabs', bp_nouveau_get_appearance_settings( 'group_nav_tabs' ) );
    15801582
    15811583        } elseif ( bp_is_user() ) {
     1584            $object   = 'member';
    15821585            $nav_tabs = (int) bp_nouveau_get_temporary_setting( 'user_nav_tabs', bp_nouveau_get_appearance_settings( 'user_nav_tabs' ) );
     1586        }
     1587
     1588        if ( $object && bp_nouveau_single_item_supports_priority_nav( $object ) ) {
     1589            $classes[] = 'bp-priority-nav';
    15831590        }
    15841591
     
    16481655        // Set user or group class string
    16491656        if ( bp_is_user() ) {
     1657            $object    = 'member';
    16501658            $classes[] = 'user-subnav';
    16511659        }
    16521660
    16531661        if ( bp_is_group() ) {
     1662            $object    = 'group';
    16541663            $classes[] = 'group-subnav';
     1664        }
     1665
     1666        if ( $object && bp_nouveau_single_item_supports_priority_nav( $object ) ) {
     1667            $classes[] = 'bp-priority-nav';
    16551668        }
    16561669
     
    27372750    return $retval;
    27382751}
     2752
     2753/**
     2754 * Displays an ellipsis to show hidden primary nav items.
     2755 *
     2756 * @since 12.0.0
     2757 */
     2758function bp_nouveau_hidden_primary_nav() {
     2759    $object = bp_nouveau_get_current_priority_nav_object();
     2760
     2761    if ( ! $object || ! bp_nouveau_single_item_supports_priority_nav( $object ) ) {
     2762        return '';
     2763    }
     2764?>
     2765    <div class="primary-nav-more">
     2766        <ul class="bp-priority-object-nav-nav-items">
     2767            <li class="primary-nav-item primary-nav-item-has-children">
     2768                <button class="submenu-expand bp-priority-nav-more-toggle is-empty" tabindex="-1" aria-label="<?php esc_attr_e( 'More', 'buddypress' ); ?>" aria-haspopup="true" aria-expanded="false">
     2769                    <span class="dashicons dashicons-ellipsis"></span>
     2770                </button>
     2771                <ul class="sub-menu hidden-items"></ul>
     2772            </li>
     2773        </ul>
     2774    </div>
     2775<?php
     2776}
     2777
     2778/**
     2779 * Displays an ellipsis to show hidden secondary nav items.
     2780 *
     2781 * @since 12.0.0
     2782 */
     2783function bp_nouveau_hidden_secondary_nav() {
     2784    $object = bp_nouveau_get_current_priority_nav_object();
     2785
     2786    if ( ! $object || ! bp_nouveau_single_item_supports_priority_nav( $object ) ) {
     2787        return '';
     2788    }
     2789?>
     2790    <div class="secondary-nav-more">
     2791        <ul class="bp-priority-subnav-nav-items">
     2792            <li class="secondary-nav-item secondary-nav-item-has-children">
     2793                <button class="submenu-expand bp-priority-nav-more-toggle is-empty" tabindex="-1" aria-label="<?php esc_attr_e( 'More', 'buddypress' ); ?>" aria-haspopup="true" aria-expanded="false">
     2794                    <span class="dashicons dashicons-ellipsis"></span>
     2795                </button>
     2796                <ul class="sub-menu hidden-items"></ul>
     2797            </li>
     2798        </ul>
     2799    </div>
     2800<?php
     2801}
Note: See TracChangeset for help on using the changeset viewer.