Skip to:
Content

BuddyPress.org

Ticket #5436: 5436.04.patch

File 5436.04.patch, 9.8 KB (added by boonebgorges, 11 years ago)
  • src/bp-core/bp-core-actions.php

    diff --git src/bp-core/bp-core-actions.php src/bp-core/bp-core-actions.php
    index df61f5a..2bb2334 100644
    add_action( 'bp_loaded', 'bp_register_theme_directory', 14 ); 
    6666 */
    6767add_action( 'bp_init', 'bp_core_set_uri_globals',    2  );
    6868add_action( 'bp_init', 'bp_setup_globals',           4  );
     69add_action( 'bp_init', 'bp_setup_canonical_stack',   5  );
    6970add_action( 'bp_init', 'bp_setup_nav',               6  );
    7071add_action( 'bp_init', 'bp_setup_title',             8  );
    7172add_action( 'bp_init', 'bp_core_load_admin_bar_css', 12 );
  • src/bp-core/bp-core-component.php

    diff --git src/bp-core/bp-core-component.php src/bp-core/bp-core-component.php
    index c16c17c..6cc77b2 100644
    class BP_Component { 
    338338                // Setup globals
    339339                add_action( 'bp_setup_globals',          array( $this, 'setup_globals'          ), 10 );
    340340
     341                // Set up canonical stack
     342                add_action( 'bp_setup_canonical_stack',  array( $this, 'setup_canonical_stack'  ), 10 );
     343
    341344                // Include required files. Called early to ensure that BP core
    342345                // components are loaded before plugins that hook their loader functions
    343346                // to bp_include with the default priority of 10. This is for backwards
    class BP_Component { 
    380383        }
    381384
    382385        /**
     386         * Set up the canonical URL stack for this component.
     387         *
     388         * @since BuddyPress (2.1.0)
     389         */
     390        public function setup_canonical_stack() {}
     391
     392        /**
    383393         * Set up component navigation.
    384394         *
    385395         * @see bp_core_new_nav_item() For a description of the $main_nav
  • src/bp-core/bp-core-dependency.php

    diff --git src/bp-core/bp-core-dependency.php src/bp-core/bp-core-dependency.php
    index eaf839c..8ce93a7 100644
    function bp_setup_components() { 
    3232}
    3333
    3434/**
     35 * Fire the 'bp_setup_canonical_stack' action, where plugins should set up their canonical URL.
     36 */
     37function bp_setup_canonical_stack() {
     38        do_action( 'bp_setup_canonical_stack' );
     39}
     40
     41/**
    3542 * Fire the 'bp_setup_globals' action, where plugins should initialize global settings.
    3643 */
    3744function bp_setup_globals() {
  • src/bp-core/bp-core-loader.php

    diff --git src/bp-core/bp-core-loader.php src/bp-core/bp-core-loader.php
    index b5ce7fe..12ac2b9 100644
    class BP_Core extends BP_Component { 
    263263function bp_setup_core() {
    264264        buddypress()->core = new BP_Core();
    265265}
    266 add_action( 'bp_setup_components', 'bp_setup_core', 2 );
     266add_action( 'bp_loaded', 'bp_setup_core', 0 );
  • src/bp-groups/bp-groups-loader.php

    diff --git src/bp-groups/bp-groups-loader.php src/bp-groups/bp-groups-loader.php
    index 08edbff..6c1bc47 100644
    class BP_Groups_Component extends BP_Component { 
    241241                        return;
    242242                }
    243243
    244                 if ( bp_is_groups_component() && !empty( $this->current_group ) ) {
    245 
    246                         $this->default_extension = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' );
    247 
    248                         if ( !bp_current_action() ) {
    249                                 $bp->current_action = $this->default_extension;
    250                         }
    251 
    252                         // Prepare for a redirect to the canonical URL
    253                         $bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group );
    254 
    255                         if ( bp_current_action() ) {
    256                                 $bp->canonical_stack['action'] = bp_current_action();
    257                         }
    258 
    259                         if ( !empty( $bp->action_variables ) ) {
    260                                 $bp->canonical_stack['action_variables'] = bp_action_variables();
    261                         }
    262 
    263                         // When viewing the default extension, the canonical URL should not have
    264                         // that extension's slug, unless more has been tacked onto the URL via
    265                         // action variables
    266                         if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) )  {
    267                                 unset( $bp->canonical_stack['action'] );
    268                         }
    269 
    270                 }
    271 
    272244                // Group access control
    273245                if ( bp_is_groups_component() && !empty( $this->current_group ) ) {
    274246                        if ( !$this->current_group->user_has_access ) {
    class BP_Groups_Component extends BP_Component { 
    350322        }
    351323
    352324        /**
     325         * Set up canonical stack for this component.
     326         *
     327         * @since BuddyPress (2.1.0)
     328         */
     329        public function setup_canonical_stack() {
     330                $bp = buddypress();
     331
     332                if ( bp_is_groups_component() && !empty( $this->current_group ) ) {
     333
     334                        $this->default_extension = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' );
     335
     336                        if ( !bp_current_action() ) {
     337                                $bp->current_action = $this->default_extension;
     338                        }
     339
     340                        // Prepare for a redirect to the canonical URL
     341                        $bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group );
     342
     343                        if ( bp_current_action() ) {
     344                                $bp->canonical_stack['action'] = bp_current_action();
     345                        }
     346
     347                        if ( !empty( $bp->action_variables ) ) {
     348                                $bp->canonical_stack['action_variables'] = bp_action_variables();
     349                        }
     350
     351                        // When viewing the default extension, the canonical URL should not have
     352                        // that extension's slug, unless more has been tacked onto the URL via
     353                        // action variables
     354                        if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) )  {
     355                                unset( $bp->canonical_stack['action'] );
     356                        }
     357
     358                }
     359        }
     360
     361        /**
    353362         * Setup BuddyBar navigation
    354363         *
    355364         * @global BuddyPress $bp The one true BuddyPress instance
  • src/bp-members/bp-members-loader.php

    diff --git src/bp-members/bp-members-loader.php src/bp-members/bp-members-loader.php
    index 14c7d75..dff0620 100644
    class BP_Members_Component extends BP_Component { 
    8989
    9090                /** Logged in user ****************************************************/
    9191
     92                // The core userdata of the user who is currently logged in.
     93                $bp->loggedin_user->userdata       = bp_core_get_core_userdata( bp_loggedin_user_id() );
     94
    9295                // Fetch the full name for the logged in user
    93                 $bp->loggedin_user->fullname       = bp_core_get_user_displayname( bp_loggedin_user_id() );
     96                $bp->loggedin_user->fullname       = $bp->loggedin_user->userdata->display_name;
    9497
    9598                // Hits the DB on single WP installs so get this separately
    9699                $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( bp_loggedin_user_id() );
    class BP_Members_Component extends BP_Component { 
    98101                // The domain for the user currently logged in. eg: http://domain.com/members/andy
    99102                $bp->loggedin_user->domain         = bp_core_get_user_domain( bp_loggedin_user_id() );
    100103
    101                 // The core userdata of the user who is currently logged in.
    102                 $bp->loggedin_user->userdata       = bp_core_get_core_userdata( bp_loggedin_user_id() );
    103 
    104104                /** Displayed user ****************************************************/
    105105
    106                 // The domain for the user currently being displayed
    107                 $bp->displayed_user->domain   = bp_core_get_user_domain( bp_displayed_user_id() );
    108 
    109106                // The core userdata of the user who is currently being displayed
    110107                $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
    111108
    112109                // Fetch the full name displayed user
    113                 $bp->displayed_user->fullname = bp_core_get_user_displayname( bp_displayed_user_id() );
     110                $bp->displayed_user->fullname = isset( $bp->displayed_user->userdata->fullname ) ? $bp->displayed_user->userdata->fullname : '';
     111
     112                // The domain for the user currently being displayed
     113                $bp->displayed_user->domain   = bp_core_get_user_domain( bp_displayed_user_id() );
    114114
    115115                /** Signup ***************************************************/
    116116                $bp->signup = new stdClass;
    class BP_Members_Component extends BP_Component { 
    122122                        $bp->profile->slug = 'profile';
    123123                        $bp->profile->id   = 'profile';
    124124                }
     125        }
     126
     127        /**
     128         * Set up canonical stack for this component.
     129         *
     130         * @since BuddyPress (2.1.0)
     131         */
     132        public function setup_canonical_stack() {
     133                $bp = buddypress();
    125134
    126135                /** Default Profile Component *****************************************/
    127136
  • src/bp-xprofile/bp-xprofile-functions.php

    diff --git src/bp-xprofile/bp-xprofile-functions.php src/bp-xprofile/bp-xprofile-functions.php
    index a165405..c7a6521 100644
    function xprofile_update_field_position( $field_id, $position, $field_group_id ) 
    460460}
    461461
    462462/**
     463 * Replace the displayed and logged-in userss fullnames with the xprofile name, if required.
     464 *
     465 * The Members component uses the logged-in user's display_name to set the
     466 * value of buddypress()->loggedin_user->fullname. However, in cases where
     467 * profile sync is disabled, display_name may diverge from the xprofile
     468 * fullname field value, and the xprofile field should take precedence.
     469 *
     470 * Runs at bp_setup_globals:100 to ensure that all components have loaded their
     471 * globals before attempting any overrides.
     472 *
     473 * @since BuddyPress (2.0.0)
     474 */
     475function xprofile_override_user_fullnames() {
     476        // If sync is enabled, the two names will match. No need to continue.
     477        if ( ! bp_disable_profile_sync() ) {
     478                return;
     479        }
     480
     481        if ( bp_loggedin_user_id() ) {
     482                buddypress()->loggedin_user->fullname = bp_core_get_user_displayname( bp_loggedin_user_id() );
     483        }
     484
     485        if ( bp_displayed_user_id() ) {
     486                buddypress()->displayed_user->fullname = bp_core_get_user_displayname( bp_displayed_user_id() );
     487        }
     488}
     489add_action( 'bp_setup_globals', 'xprofile_override_user_fullnames', 100 );
     490
     491/**
    463492 * Setup the avatar upload directory for a user.
    464493 *
    465494 * @package BuddyPress Core
  • src/bp-xprofile/bp-xprofile-loader.php

    diff --git src/bp-xprofile/bp-xprofile-loader.php src/bp-xprofile/bp-xprofile-loader.php
    index 71d84e3..3487f47 100644
    function bp_setup_xprofile() { 
    350350        if ( !isset( $bp->profile->id ) )
    351351                $bp->profile = new BP_XProfile_Component();
    352352}
    353 add_action( 'bp_setup_components', 'bp_setup_xprofile', 6 );
     353add_action( 'bp_setup_components', 'bp_setup_xprofile', 2 );