Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/27/2023 10:55:27 PM (3 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/buddypress-functions.php

    r13493 r13652  
    8181                }
    8282
    83                 $this->includes_dir  = trailingslashit( $this->dir ) . 'includes/';
    84                 $this->directory_nav = new BP_Core_Nav( bp_get_root_blog_id() );
     83                $this->includes_dir   = trailingslashit( $this->dir ) . 'includes/';
     84                $this->directory_nav  = new BP_Core_Nav( bp_get_root_blog_id() );
     85                $this->is_block_theme = false;
     86
     87                if ( bp_is_running_wp( '5.9.0', '>=' ) ) {
     88                        $this->is_block_theme = wp_is_block_theme();
     89                }
    8590        }
    8691
     
    108113                }
    109114
    110                 add_action( 'bp_customize_register', function() {
    111                         if ( bp_is_root_blog() && current_user_can( 'customize' ) ) {
    112                                 require bp_nouveau()->includes_dir . 'customizer.php';
    113                         }
    114                 }, 0 );
     115                // The customizer is only used by classic themes.
     116                if ( ! $this->is_block_theme ) {
     117                        add_action(
     118                                'bp_customize_register',
     119                                function() {
     120                                        if ( bp_is_root_blog() && current_user_can( 'customize' ) ) {
     121                                                require bp_nouveau()->includes_dir . 'customizer.php';
     122                                        }
     123                                },
     124                                0
     125                        );
     126                } elseif ( wp_using_themes() && ! isset( $_GET['bp_customizer'] ) ) {
     127                        remove_action( 'customize_register', 'bp_customize_register', 20 );
     128                }
    115129
    116130                foreach ( bp_core_get_packaged_component_ids() as $component ) {
     
    150164                }
    151165
    152                 bp_set_theme_compat_feature( $this->id, array(
    153                         'name'     => 'cover_image',
    154                         'settings' => array(
    155                                 'components'   => array( 'members', 'groups' ),
    156                                 'width'        => $width,
    157                                 'height'       => $top_offset + round( $avatar_height / 2 ),
    158                                 'callback'     => 'bp_nouveau_theme_cover_image',
    159                                 'theme_handle' => 'bp-nouveau',
    160                         ),
    161                 ) );
     166                if ( $this->is_block_theme ) {
     167                        $width = (int) wp_get_global_settings( array( 'layout', 'contentSize' ) );
     168                }
     169
     170                bp_set_theme_compat_feature(
     171                        $this->id,
     172                        array(
     173                                'name'     => 'cover_image',
     174                                'settings' => array(
     175                                        'components'   => array( 'members', 'groups' ),
     176                                        'width'        => $width,
     177                                        'height'       => $top_offset + round( $avatar_height / 2 ),
     178                                        'callback'     => 'bp_nouveau_theme_cover_image',
     179                                        'theme_handle' => 'bp-nouveau',
     180                                ),
     181                        )
     182                );
     183
     184                bp_set_theme_compat_feature(
     185                        $this->id,
     186                        array(
     187                                'name'     => 'priority_item_nav',
     188                                'settings' => array(
     189                                        'single_items' => $this->is_block_theme ? array( 'member', 'group' ) : array(),
     190                                ),
     191                        )
     192                );
    162193        }
    163194
     
    253284                        'bp-nouveau' => array(
    254285                                'file' => 'css/buddypress%1$s%2$s.css', 'dependencies' => $css_dependencies, 'version' => $this->version,
     286                        ),
     287                        'bp-nouveau-priority-nav' => array(
     288                                'file' => 'css/priority-nav%1$s%2$s.css', 'dependencies' => array( 'dashicons' ), 'version' => $this->version,
    255289                        ),
    256290                ) );
     
    354388                                        'footer'       => true,
    355389                                ),
     390                                'bp-nouveau-priority-menu' => array(
     391                                        'file'         => 'js/buddypress-priority-menu%s.js',
     392                                        'dependencies' => array(),
     393                                        'version'      => $this->version,
     394                                        'footer'       => true,
     395                                )
    356396                        )
    357397                );
Note: See TracChangeset for help on using the changeset viewer.