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/functions.php

    r13529 r13652  
    663663
    664664    if ( bp_is_active( 'groups' ) ) {
    665         $default_args = array_merge( $default_args, array(
    666             'group_front_page'        => 0,
    667             'group_front_boxes'       => 0,
    668             'group_front_description' => 0,
    669             'group_nav_display'       => 0,       // O is default (horizontally). 1 is vertically.
    670             'group_nav_order'         => array(),
    671             'group_nav_tabs'          => 0,
    672             'group_subnav_tabs'       => 0,
    673             'groups_create_tabs'      => 1,
    674             'groups_layout'           => 1,
    675             'members_group_layout'    => 1,
    676             'groups_dir_layout'       => 0,
    677             'groups_dir_tabs'         => 0,
    678         ) );
     665        $default_args = array_merge(
     666            $default_args,
     667            array(
     668                'group_front_page'        => 0,
     669                'group_front_boxes'       => 0,
     670                'group_front_description' => 0,
     671                'group_nav_display'       => 0, // O is default (horizontally). 1 is vertically.
     672                'group_nav_order'         => array(),
     673                'group_nav_tabs'          => 0,
     674                'group_subnav_tabs'       => 0,
     675                'groups_create_tabs'      => 1,
     676                'groups_layout'           => 1,
     677                'members_group_layout'    => 1,
     678                'groups_dir_layout'       => 0,
     679                'groups_dir_tabs'         => 0,
     680            )
     681        );
    679682    }
    680683
    681684    if ( is_multisite() && bp_is_active( 'blogs' ) ) {
    682         $default_args = array_merge( $default_args, array(
    683             'sites_dir_layout' => 0,
    684             'sites_dir_tabs'   => 0,
    685         ) );
     685        $default_args = array_merge(
     686            $default_args,
     687            array(
     688                'sites_dir_layout' => 0,
     689                'sites_dir_tabs'   => 0,
     690            )
     691        );
    686692    }
    687693
     
    691697        'nouveau_appearance_settings'
    692698    );
     699
     700    // Override some settings to better suits block themes.
     701    if ( bp_nouveau()->is_block_theme ) {
     702        $settings['global_alignment'] = 'alignnone';
     703
     704        if ( isset( $settings['groups_create_tabs'] ) ) {
     705            $settings['groups_create_tabs'] = 0;
     706        }
     707    }
    693708
    694709    if ( ! empty( $option ) ) {
     
    16691684    return apply_filters( 'bp_nouveau_get_theme_layout_widths', $layout_widths );
    16701685}
     1686
     1687/**
     1688 * Get the current displayed object for the priority nav.
     1689 *
     1690 * @since 12.0.0
     1691 *
     1692 * @return string The current displayed object (`member` or `group`).
     1693 */
     1694function bp_nouveau_get_current_priority_nav_object() {
     1695    $object = '';
     1696
     1697    if ( bp_is_user() ) {
     1698        $object = 'member';
     1699    } elseif ( bp_is_group() ) {
     1700        $object = 'group';
     1701    }
     1702
     1703    return $object;
     1704}
     1705
     1706/**
     1707 * Checks whether a single item supports priority nav.
     1708 *
     1709 * @since 12.0.0
     1710 *
     1711 * @param string $single_item The single item object name. Possible valuers are 'member' or 'group'.
     1712 * @return bool True if the single item supports priority nav. False otherwise.
     1713 */
     1714function bp_nouveau_single_item_supports_priority_nav( $single_item = '' ) {
     1715    $retval  = false;
     1716    $feature = bp_get_theme_compat_feature( 'priority_item_nav' );
     1717
     1718    if ( isset( $feature->single_items ) && is_array( $feature->single_items ) ) {
     1719        $retval = ! empty( $feature->single_items );
     1720
     1721        if ( $single_item ) {
     1722            $retval = in_array( $single_item, $feature->single_items, true );
     1723        }
     1724    }
     1725
     1726    /**
     1727     * Use this filter to disallow/allow the Priority nav support.
     1728     *
     1729     * @since 12.0.0
     1730     *
     1731     * @param bool   $retval      True if the single item supports priority nav. False otherwise.
     1732     * @param string $single_item The single item object name. Possible valuers are 'member' or 'group'.
     1733     */
     1734    return apply_filters( 'bp_nouveau_single_item_supports_priority_nav', $retval, $single_item );
     1735}
Note: See TracChangeset for help on using the changeset viewer.