Skip to:
Content

BuddyPress.org

Ticket #8133: 8133.2.patch

File 8133.2.patch, 11.8 KB (added by imath, 5 years ago)
  • src/bp-core/bp-core-functions.php

    diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
    index 592f5b155..3563f5f5a 100644
    function bp_core_get_component_search_query_arg( $component = null ) {  
    949949        return apply_filters( 'bp_core_get_component_search_query_arg', $query_arg, $component );
    950950}
    951951
     952/**
     953 * Get a list of all active component objects.
     954 *
     955 * @since 8.0.0
     956 *
     957 * @param array $args {
     958 *     Optional. An array of key => value arguments to match against the component objects.
     959 *     Default empty array.
     960 *
     961 *     @type string $name          Translatable name for the component.
     962 *     @type string $id            Unique ID for the component.
     963 *     @type string $slug          Unique slug for the component, for use in query strings and URLs.
     964 *     @type bool   $has_directory True if the component has a top-level directory. False otherwise.
     965 *     @type string $root_slug     Slug used by the component's directory page.
     966 * }
     967 * @param string $output   Optional. The type of output to return. Accepts 'ids'
     968 *                         or 'objects'. Default 'ids'.
     969 * @param string $operator Optional. The logical operation to perform. 'or' means only one
     970 *                         element from the array needs to match; 'and' means all elements
     971 *                         must match. Accepts 'or' or 'and'. Default 'and'.
     972 * @return array A list of component ids or objects.
     973 */
     974function bp_core_get_active_components( $args = array(), $output = 'ids', $operator = 'and' ) {
     975        $bp = buddypress();
     976
     977        $active_components = array_keys( $bp->active_components );
     978
     979        $xprofile_id = array_search( 'xprofile', $active_components, true );
     980        if ( false !== $xprofile_id ) {
     981                $active_components[ $xprofile_id ] = 'profile';
     982        }
     983
     984        $components = array();
     985        foreach ( $active_components as $id ) {
     986                if ( isset( $bp->{$id} ) && $bp->{$id} instanceof BP_Component ) {
     987                        $components[ $id ] = $bp->{$id};
     988                }
     989        }
     990
     991        $components = wp_filter_object_list( $components, $args, $operator );
     992
     993        if ( 'ids' === $output ) {
     994                $components = wp_list_pluck( $components, 'id' );
     995        }
     996
     997        return $components;
     998}
     999
    9521000/**
    9531001 * Determine whether BuddyPress should register the bp-themes directory.
    9541002 *
  • src/bp-members/bp-members-adminbar.php

    diff --git src/bp-members/bp-members-adminbar.php src/bp-members/bp-members-adminbar.php
    index 28b6f54c3..10f784d09 100644
    function bp_members_admin_bar_user_admin_menu() {  
    102102                        'parent' => $bp->user_admin_menu_id,
    103103                        'id'     => $bp->user_admin_menu_id . '-edit-profile',
    104104                        'title'  => __( "Edit Profile", 'buddypress' ),
    105                         'href'   => bp_get_members_component_link( 'profile', 'edit' )
     105                        'href'   => bp_get_members_component_link( $bp->profile->id, 'edit' )
    106106                ) );
    107107
    108108                // User Admin > Edit this user's avatar.
    function bp_members_admin_bar_user_admin_menu() {  
    111111                                'parent' => $bp->user_admin_menu_id,
    112112                                'id'     => $bp->user_admin_menu_id . '-change-avatar',
    113113                                'title'  => __( "Edit Profile Photo", 'buddypress' ),
    114                                 'href'   => bp_get_members_component_link( 'profile', 'change-avatar' )
     114                                'href'   => bp_get_members_component_link( $bp->profile->id, 'change-avatar' )
    115115                        ) );
    116116                }
    117117
    function bp_members_admin_bar_user_admin_menu() {  
    121121                                'parent' => $bp->user_admin_menu_id,
    122122                                'id'     => $bp->user_admin_menu_id . '-change-cover-image',
    123123                                'title'  => __( 'Edit Cover Image', 'buddypress' ),
    124                                 'href'   => bp_get_members_component_link( 'profile', 'change-cover-image' )
     124                                'href'   => bp_get_members_component_link( $bp->profile->id, 'change-cover-image' )
    125125                        ) );
    126126                }
    127127
  • src/bp-members/bp-members-template.php

    diff --git src/bp-members/bp-members-template.php src/bp-members/bp-members-template.php
    index 5ceda3078..541b27479 100644
    function bp_members_component_link( $component, $action = '', $query_args = '',  
    28002800         * @return string
    28012801         */
    28022802        function bp_get_members_component_link( $component, $action = '', $query_args = '', $nonce = false ) {
    2803 
    28042803                // Must be displayed user.
    2805                 if ( !bp_displayed_user_id() )
     2804                if ( ! bp_displayed_user_id() ) {
    28062805                        return;
     2806                }
    28072807
    28082808                $bp = buddypress();
    28092809
     2810                if ( 'xprofile' === $component ) {
     2811                        $component = 'profile';
     2812                }
     2813
    28102814                // Append $action to $url if there is no $type.
    2811                 if ( !empty( $action ) )
     2815                if ( ! empty( $action ) ) {
    28122816                        $url = bp_displayed_user_domain() . $bp->{$component}->slug . '/' . $action;
    2813                 else
     2817                } else {
    28142818                        $url = bp_displayed_user_domain() . $bp->{$component}->slug;
     2819                }
    28152820
    28162821                // Add a slash at the end of our user url.
    28172822                $url = trailingslashit( $url );
    28182823
    28192824                // Add possible query arg.
    2820                 if ( !empty( $query_args ) && is_array( $query_args ) )
     2825                if ( ! empty( $query_args ) && is_array( $query_args ) ) {
    28212826                        $url = add_query_arg( $query_args, $url );
     2827                }
    28222828
    28232829                // To nonce, or not to nonce...
    2824                 if ( true === $nonce )
     2830                if ( true === $nonce ) {
    28252831                        $url = wp_nonce_url( $url );
    2826                 elseif ( is_string( $nonce ) )
     2832                } elseif ( is_string( $nonce ) ) {
    28272833                        $url = wp_nonce_url( $url, $nonce );
     2834                }
    28282835
    28292836                // Return the url, if there is one.
    2830                 if ( !empty( $url ) )
     2837                if ( ! empty( $url ) ) {
    28312838                        return $url;
     2839                }
    28322840        }
    28332841
    28342842
  • src/bp-members/classes/class-bp-members-component.php

    diff --git src/bp-members/classes/class-bp-members-component.php src/bp-members/classes/class-bp-members-component.php
    index 77777d645..9e6fbcd42 100644
    class BP_Members_Component extends BP_Component {  
    314314
    315315                $access       = bp_core_can_edit_settings();
    316316                $slug         = bp_get_profile_slug();
    317                 $profile_link = bp_get_members_component_link( $slug );
     317                $profile_link = bp_get_members_component_link( buddypress()->profile->id );
    318318
    319319                // Change Avatar.
    320320                if ( buddypress()->avatar->show_avatars ) {
  • src/bp-templates/bp-nouveau/buddypress/common/search-and-filters-bar.php

    diff --git src/bp-templates/bp-nouveau/buddypress/common/search-and-filters-bar.php src/bp-templates/bp-nouveau/buddypress/common/search-and-filters-bar.php
    index 20441b2f3..d07d70cfb 100644
     
    33 * BP Nouveau Search & filters bar
    44 *
    55 * @since 3.0.0
    6  * @version 3.1.0
     6 * @version 8.0.0
    77 */
    88?>
    99<div class="subnav-filters filters no-ajax" id="subnav-filters">
    1010
    11         <?php if ( 'friends' !== bp_current_component() ) : ?>
    12         <div class="subnav-search clearfix">
     11        <?php if ( bp_get_friends_slug() !== bp_current_component() ) : ?>
     12                <div class="subnav-search clearfix">
    1313
    14                 <?php if ( 'activity' === bp_current_component() ) : ?>
    15                         <div class="feed"><a href="<?php bp_sitewide_activity_feed_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>"><span class="bp-screen-reader-text"><?php esc_html_e( 'RSS', 'buddypress' ); ?></span></a></div>
    16                 <?php endif; ?>
     14                        <?php if ( bp_get_activity_slug() === bp_current_component() ) : ?>
     15                                <div class="feed"><a href="<?php bp_sitewide_activity_feed_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>"><span class="bp-screen-reader-text"><?php esc_html_e( 'RSS', 'buddypress' ); ?></span></a></div>
     16                        <?php endif; ?>
    1717
    18                 <?php bp_nouveau_search_form(); ?>
     18                        <?php bp_nouveau_search_form(); ?>
    1919
    20         </div>
     20                </div>
    2121        <?php endif; ?>
    2222
    2323                <?php if ( bp_is_user() && ! bp_is_current_action( 'requests' ) ) : ?>
    2424                        <?php bp_get_template_part( 'common/filters/user-screens-filters' ); ?>
    25                 <?php elseif ( 'groups' === bp_current_component() ) : ?>
     25                <?php elseif ( bp_get_groups_slug() === bp_current_component() ) : ?>
    2626                        <?php bp_get_template_part( 'common/filters/groups-screens-filters' ); ?>
    2727                <?php else : ?>
    2828                        <?php bp_get_template_part( 'common/filters/directory-filters' ); ?>
  • 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 25b9af487..69a72e110 100644
     
    33 * Common functions
    44 *
    55 * @since 3.0.0
    6  * @version 3.1.0
     6 * @version 8.0.0
    77 */
    88
    99// Exit if accessed directly.
    function bp_nouveau_ajax_button( $output = '', $button = null, $before = '', $af  
    237237 * }
    238238 */
    239239function bp_nouveau_wrapper( $args = array() ) {
    240  /**
    241         * Classes need to be determined & set by component to a certain degree
    242         *
    243         * Check the component to find a default container_class to add
    244         */
    245         $current_component_class = bp_current_component() . '-meta';
     240        /**
     241         * Classes need to be determined & set by component to a certain degree.
     242         *
     243         * Check the component to find a default container_class based on the component ID to add.
     244         * We need to to this because bp_current_component() is using the component slugs which can differ
     245         * from the component ID.
     246         */
     247        $current_component_id = bp_core_get_active_components( array( 'slug' => bp_current_component() ) );
     248        if ( $current_component_id && 1 === count( $current_component_id ) ) {
     249                $current_component_id = reset( $current_component_id );
     250        } else {
     251                $current_component_id = bp_current_component();
     252        }
     253
     254        $current_component_class = $current_component_id . '-meta';
    246255
    247256        if ( bp_is_group_activity() ) {
    248257                $generic_class = ' activity-meta ';
    function bp_nouveau_wrapper( $args = array() ) {  
    255264                array(
    256265                        'container'         => 'div',
    257266                        'container_id'      => '',
    258                         'container_classes' => array( $generic_class, $current_component_class   ),
     267                        'container_classes' => array( $generic_class, $current_component_class ),
    259268                        'output'            => '',
    260269                ),
    261270                'nouveau_wrapper'
    function bp_nouveau_get_component_filters( $context = '', $component = '' ) {  
    532541        }
    533542
    534543        if ( empty( $component ) ) {
    535                 if ( 'directory' === $context || 'user' === $context ) {
    536                         $component = bp_current_component();
     544                if ( 'user' === $context ) {
     545                        $component = bp_core_get_active_components( array( 'slug' => bp_current_component() ) );
     546                        $component = reset( $component );
    537547
    538548                        if ( 'friends' === $component ) {
    539549                                $context   = 'friends';
    function bp_nouveau_get_component_filters( $context = '', $component = '' ) {  
    543553                        $component = 'activity';
    544554                } elseif ( 'group' === $context && bp_is_group_members() ) {
    545555                        $component = 'members';
     556                } else {
     557                        $component = bp_current_component();
    546558                }
    547559        }
    548560
  • 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 5ee755a05..e195c22a5 100644
     
    33 * Common template tags
    44 *
    55 * @since 3.0.0
    6  * @version 7.0.0
     6 * @version 8.0.0
    77 */
    88
    99// Exit if accessed directly.
    function bp_nouveau_current_object() {  
    20682068                }
    20692069
    20702070        } else {
    2071                 $data_filter = bp_current_component();
     2071                $component_id = bp_current_component();
     2072                if ( ! bp_is_directory() ) {
     2073                        $component_id = bp_core_get_active_components( array( 'slug' => $component_id ) );
     2074                        $component_id = reset( $component_id );
     2075                }
     2076
     2077                $data_filter  = $component_id;
     2078
    20722079                if ( 'friends' === $data_filter && bp_is_user_friend_requests() ) {
    20732080                        $data_filter = 'friend_requests';
    20742081                }
    20752082
    20762083                $component['members_select']   = 'members-order-select';
    20772084                $component['members_order_by'] = 'members-order-by';
    2078                 $component['object']           = bp_current_component();
     2085                $component['object']           = $component_id;
    20792086                $component['data_filter']      = $data_filter;
    20802087        }
    20812088
    function bp_nouveau_filter_options() {  
    22322239        function bp_nouveau_get_filter_options() {
    22332240                $output = '';
    22342241
    2235                 if ( 'notifications' === bp_current_component() ) {
     2242                if ( bp_get_notifications_slug() === bp_current_component() ) {
    22362243                        $output = bp_nouveau_get_notifications_filters();
    22372244
    22382245                } else {