Skip to:
Content

BuddyPress.org

Ticket #8474: 8474.patch

File 8474.patch, 7.8 KB (added by imath, 2 years ago)
  • src/bp-core/bp-core-template-loader.php

    diff --git src/bp-core/bp-core-template-loader.php src/bp-core/bp-core-template-loader.php
    index eed2d9df5..b270d49f8 100644
    function bp_get_query_template( $type, $templates = array() ) { 
    453453         */
    454454        $templates = apply_filters( "bp_get_{$type}_template", $templates );
    455455
    456         // Filter possible templates, try to match one, and set any BuddyPress theme
    457         // compat properties so they can be cross-checked later.
     456        /*
     457         * Filter possible templates, try to match one, and set any BuddyPress theme
     458         * compat properties so they can be cross-checked later.
     459         */
    458460        $templates = bp_set_theme_compat_templates( $templates );
    459461        $template  = bp_locate_template( $templates );
    460         $template  = bp_set_theme_compat_template( $template );
     462
     463        /*
     464         * The current theme is using the WordPress Full Site Editing feature.
     465         * BuddyPress then needs to use the WordPress template canvas to retrieve the community content.
     466         */
     467        if ( current_theme_supports( 'block-templates' ) && $template === get_theme_file_path( 'index.php' ) ) {
     468                $template = ABSPATH . WPINC . '/template-canvas.php';
     469        }
     470
     471        $template = bp_set_theme_compat_template( $template );
    461472
    462473        /**
    463474         * Filters the path to a template file.
  • src/bp-templates/bp-nouveau/buddypress-functions.php

    diff --git src/bp-templates/bp-nouveau/buddypress-functions.php src/bp-templates/bp-nouveau/buddypress-functions.php
    index bffb1ce40..98e086513 100644
    class BP_Nouveau extends BP_Theme_Compat { 
    176176                // We need to neutralize the BuddyPress core "bp_core_render_message()" once it has been added.
    177177                add_action( 'bp_actions', array( $this, 'neutralize_core_template_notices' ), 6 );
    178178
    179                 // Scripts.
    180                 add_action( 'bp_enqueue_scripts', array( $this, 'register_scripts' ), 2 ); // Register theme JS.
     179                // Scripts & Styles.
     180                $registration_params = array(
     181                        'hook'     => 'bp_enqueue_scripts',
     182                        'priority' => 2,
     183                );
     184
     185                /*
     186                 * The WordPress Full Site Editing feature needs Scripts
     187                 * and Styles to be registered earlier.
     188                 */
     189                if ( current_theme_supports( 'block-templates' ) ) {
     190                        $registration_params['hook']     = 'bp_init';
     191                        $registration_params['priority'] = 20;
     192                }
     193
     194                // Register theme JS.
     195                add_action( $registration_params['hook'], array( $this, 'register_scripts' ), $registration_params['priority'] );
     196
     197                // Enqueue theme CSS.
     198                add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
     199
     200                // Enqueue theme JS.
     201                add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
     202
     203                // Enqueue theme script localization.
     204                add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) );
    181205                remove_action( 'bp_enqueue_scripts', 'bp_core_confirmation_js' );
    182                 add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS.
    183                 add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS.
    184                 add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization.
    185206
    186207                // Body no-js class.
    187208                add_filter( 'body_class', array( $this, 'add_nojs_body_class' ), 20, 1 );
  • src/bp-templates/bp-nouveau/includes/customizer.php

    diff --git src/bp-templates/bp-nouveau/includes/customizer.php src/bp-templates/bp-nouveau/includes/customizer.php
    index 7a5bcd9d0..4b675ab9f 100644
     
    33 * Code to hook into the WP Customizer
    44 *
    55 * @since 3.0.0
    6  * @version 3.1.0
     6 * @version 10.0.0
    77 */
    88
    99/**
    function bp_nouveau_customize_register( WP_Customize_Manager $wp_customize ) { 
    2121        require_once( trailingslashit( bp_nouveau()->includes_dir ) . 'customizer-controls.php' );
    2222        $wp_customize->register_control_type( 'BP_Nouveau_Nav_Customize_Control' );
    2323        $bp_nouveau_options = bp_nouveau_get_appearance_settings();
     24        $layout_widths      = bp_nouveau_get_theme_layout_widths();
    2425
    2526        $wp_customize->add_panel( 'bp_nouveau_panel', array(
    2627                'description' => __( 'Customize the appearance of BuddyPress Nouveau Template pack.', 'buddypress' ),
    function bp_nouveau_customize_register( WP_Customize_Manager $wp_customize ) { 
    202203                ),
    203204        ) );
    204205
    205         if ( current_theme_supports( 'align-wide' ) ) {
     206        if ( $layout_widths ) {
    206207                $settings['bp_nouveau_appearance[global_alignment]'] = array(
    207208                        'index'             => 'global_alignment',
    208209                        'capability'        => 'bp_moderate',
    function bp_nouveau_customize_register( WP_Customize_Manager $wp_customize ) { 
    306307         */
    307308        $controls = apply_filters( 'bp_nouveau_customizer_controls', $controls );
    308309
    309         if ( current_theme_supports( 'align-wide' ) ) {
     310        if ( $layout_widths ) {
    310311                $controls['global_alignment'] = array(
    311312                        'label'      => __( 'Select the BuddyPress container width for your site.', 'buddypress' ),
    312313                        'section'    => 'bp_nouveau_general_settings',
    313314                        'settings'   => 'bp_nouveau_appearance[global_alignment]',
    314315                        'type'       => 'select',
    315                         'choices'    => array(
    316                                 'alignnone' => __( 'Default width', 'buddypress' ),
    317                                 'alignwide' => __( 'Wide width', 'buddypress' ),
    318                                 'alignfull' => __( 'Full width', 'buddypress' ),
    319                         ),
     316                        'choices'    => $layout_widths,
    320317                );
    321318        }
    322319
  • src/bp-templates/bp-nouveau/includes/functions.php

    diff --git src/bp-templates/bp-nouveau/includes/functions.php src/bp-templates/bp-nouveau/includes/functions.php
    index a761586ae..479163ccd 100644
     
    33 * Common functions
    44 *
    55 * @since 3.0.0
    6  * @version 9.0.0
     6 * @version 10.0.0
    77 */
    88
    99// Exit if accessed directly.
    function bp_nouveau_render_primary_nav_block( $attributes = array() ) { 
    16391639
    16401640        return $widget_content;
    16411641}
     1642
     1643/**
     1644 * Retuns the theme layout available widths.
     1645 *
     1646 * @since 10.0.0
     1647 *
     1648 * @return array The available theme layout widths.
     1649 */
     1650function bp_nouveau_get_theme_layout_widths() {
     1651        $layout_widths = array();
     1652
     1653        if ( current_theme_supports( 'align-wide' ) ) {
     1654                $layout_widths = array(
     1655                        'alignnone' => __( 'Default width', 'buddypress' ),
     1656                        'alignwide' => __( 'Wide width', 'buddypress' ),
     1657                        'alignfull' => __( 'Full width', 'buddypress' ),
     1658                );
     1659        }
     1660
     1661        if ( bp_is_running_wp( '5.9-alpha-20211112.120915' ) ) {
     1662                $theme_layouts = wp_get_global_settings( array( 'layout' ) );
     1663
     1664                if ( isset( $theme_layouts['wideSize'] ) && $theme_layouts['wideSize'] ) {
     1665                        $layout_widths = array(
     1666                                'alignnone' => __( 'Content width', 'buddypress' ),
     1667                                'alignwide' => __( 'Wide width', 'buddypress' ),
     1668                        );
     1669                }
     1670        }
     1671
     1672        /**
     1673         * Filter here to edit the available theme layout widths.
     1674         *
     1675         * @since 10.0.0
     1676         *
     1677         * @param array $layout_widths The available theme layout widths.
     1678         */
     1679        return apply_filters( 'bp_nouveau_get_theme_layout_widths', $layout_widths );
     1680}
  • src/bp-templates/bp-nouveau/includes/template-tags.php

    diff --git src/bp-templates/bp-nouveau/includes/template-tags.php src/bp-templates/bp-nouveau/includes/template-tags.php
    index ef5ad0075..7b804a082 100644
     
    33 * Common template tags
    44 *
    55 * @since 3.0.0
    6  * @version 8.0.0
     6 * @version 10.0.0
    77 */
    88
    99// Exit if accessed directly.
    function bp_nouveau_container_classes() { 
    15291529                        }
    15301530                }
    15311531
    1532                 $global_alignment = bp_nouveau_get_temporary_setting( 'global_alignment', bp_nouveau_get_appearance_settings( 'global_alignment' ) );
    1533                 if ( $global_alignment && 'alignnone' !== $global_alignment && current_theme_supports( 'align-wide' ) ) {
     1532                $global_alignment  = bp_nouveau_get_temporary_setting( 'global_alignment', bp_nouveau_get_appearance_settings( 'global_alignment' ) );
     1533                $layout_widths     = bp_nouveau_get_theme_layout_widths();
     1534
     1535                if ( $global_alignment && 'alignnone' !== $global_alignment && $layout_widths ) {
    15341536                        $classes[] = $global_alignment;
    15351537                }
    15361538