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 ); |
66 | 66 | */ |
67 | 67 | add_action( 'bp_init', 'bp_core_set_uri_globals', 2 ); |
68 | 68 | add_action( 'bp_init', 'bp_setup_globals', 4 ); |
| 69 | add_action( 'bp_init', 'bp_setup_canonical_stack', 5 ); |
69 | 70 | add_action( 'bp_init', 'bp_setup_nav', 6 ); |
70 | 71 | add_action( 'bp_init', 'bp_setup_title', 8 ); |
71 | 72 | add_action( 'bp_init', 'bp_core_load_admin_bar_css', 12 ); |
diff --git src/bp-core/bp-core-component.php src/bp-core/bp-core-component.php
index c16c17c..6cc77b2 100644
|
|
class BP_Component { |
338 | 338 | // Setup globals |
339 | 339 | add_action( 'bp_setup_globals', array( $this, 'setup_globals' ), 10 ); |
340 | 340 | |
| 341 | // Set up canonical stack |
| 342 | add_action( 'bp_setup_canonical_stack', array( $this, 'setup_canonical_stack' ), 10 ); |
| 343 | |
341 | 344 | // Include required files. Called early to ensure that BP core |
342 | 345 | // components are loaded before plugins that hook their loader functions |
343 | 346 | // to bp_include with the default priority of 10. This is for backwards |
… |
… |
class BP_Component { |
380 | 383 | } |
381 | 384 | |
382 | 385 | /** |
| 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 | /** |
383 | 393 | * Set up component navigation. |
384 | 394 | * |
385 | 395 | * @see bp_core_new_nav_item() For a description of the $main_nav |
diff --git src/bp-core/bp-core-dependency.php src/bp-core/bp-core-dependency.php
index eaf839c..8ce93a7 100644
|
|
function bp_setup_components() { |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
| 35 | * Fire the 'bp_setup_canonical_stack' action, where plugins should set up their canonical URL. |
| 36 | */ |
| 37 | function bp_setup_canonical_stack() { |
| 38 | do_action( 'bp_setup_canonical_stack' ); |
| 39 | } |
| 40 | |
| 41 | /** |
35 | 42 | * Fire the 'bp_setup_globals' action, where plugins should initialize global settings. |
36 | 43 | */ |
37 | 44 | function bp_setup_globals() { |
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 { |
263 | 263 | function bp_setup_core() { |
264 | 264 | buddypress()->core = new BP_Core(); |
265 | 265 | } |
266 | | add_action( 'bp_setup_components', 'bp_setup_core', 2 ); |
| 266 | add_action( 'bp_loaded', 'bp_setup_core', 0 ); |
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 { |
241 | 241 | return; |
242 | 242 | } |
243 | 243 | |
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 | | |
272 | 244 | // Group access control |
273 | 245 | if ( bp_is_groups_component() && !empty( $this->current_group ) ) { |
274 | 246 | if ( !$this->current_group->user_has_access ) { |
… |
… |
class BP_Groups_Component extends BP_Component { |
350 | 322 | } |
351 | 323 | |
352 | 324 | /** |
| 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 | /** |
353 | 362 | * Setup BuddyBar navigation |
354 | 363 | * |
355 | 364 | * @global BuddyPress $bp The one true BuddyPress instance |
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 { |
89 | 89 | |
90 | 90 | /** Logged in user ****************************************************/ |
91 | 91 | |
| 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 | |
92 | 95 | // 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; |
94 | 97 | |
95 | 98 | // Hits the DB on single WP installs so get this separately |
96 | 99 | $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 { |
98 | 101 | // The domain for the user currently logged in. eg: http://domain.com/members/andy |
99 | 102 | $bp->loggedin_user->domain = bp_core_get_user_domain( bp_loggedin_user_id() ); |
100 | 103 | |
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 | | |
104 | 104 | /** Displayed user ****************************************************/ |
105 | 105 | |
106 | | // The domain for the user currently being displayed |
107 | | $bp->displayed_user->domain = bp_core_get_user_domain( bp_displayed_user_id() ); |
108 | | |
109 | 106 | // The core userdata of the user who is currently being displayed |
110 | 107 | $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); |
111 | 108 | |
112 | 109 | // 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() ); |
114 | 114 | |
115 | 115 | /** Signup ***************************************************/ |
116 | 116 | $bp->signup = new stdClass; |
… |
… |
class BP_Members_Component extends BP_Component { |
122 | 122 | $bp->profile->slug = 'profile'; |
123 | 123 | $bp->profile->id = 'profile'; |
124 | 124 | } |
| 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(); |
125 | 134 | |
126 | 135 | /** Default Profile Component *****************************************/ |
127 | 136 | |
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 ) |
460 | 460 | } |
461 | 461 | |
462 | 462 | /** |
| 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 | */ |
| 475 | function 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 | } |
| 489 | add_action( 'bp_setup_globals', 'xprofile_override_user_fullnames', 100 ); |
| 490 | |
| 491 | /** |
463 | 492 | * Setup the avatar upload directory for a user. |
464 | 493 | * |
465 | 494 | * @package BuddyPress Core |
diff --git src/bp-xprofile/bp-xprofile-loader.php src/bp-xprofile/bp-xprofile-loader.php
index 71d84e3..3487f47 100644
|
|
function bp_setup_xprofile() { |
350 | 350 | if ( !isset( $bp->profile->id ) ) |
351 | 351 | $bp->profile = new BP_XProfile_Component(); |
352 | 352 | } |
353 | | add_action( 'bp_setup_components', 'bp_setup_xprofile', 6 ); |
| 353 | add_action( 'bp_setup_components', 'bp_setup_xprofile', 2 ); |