Changeset 12559
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/classes/class-bp-members-component.php
r12488 r12559 107 107 if ( bp_is_user() ) { 108 108 require $this->path . 'bp-members/screens/profile.php'; 109 110 // Action - Delete avatar. 111 if ( is_user_logged_in()&& bp_is_user_change_avatar() && bp_is_action_variable( 'delete-avatar', 0 ) ) { 112 require $this->path . 'bp-members/actions/delete-avatar.php'; 113 } 114 115 // Sub-nav items. 116 if ( is_user_logged_in() && 117 in_array( bp_current_action(), array( 'change-avatar', 'change-cover-image' ), true ) 118 ) { 119 require $this->path . 'bp-members/screens/' . bp_current_action() . '.php'; 120 } 109 121 } 110 122 … … 290 302 291 303 /** 304 * Get the Avatar and Cover image subnavs. 305 * 306 * @since 6.0.0 307 * 308 * @return array The Avatar and Cover image subnavs. 309 */ 310 public function get_avatar_cover_image_subnavs() { 311 $subnavs = array(); 312 313 $access = bp_core_can_edit_settings(); 314 $slug = bp_get_profile_slug(); 315 $profile_link = bp_get_members_component_link( $slug ); 316 317 // Change Avatar. 318 if ( buddypress()->avatar->show_avatars ) { 319 $subnavs[] = array( 320 'name' => _x( 'Change Profile Photo', 'Profile header sub menu', 'buddypress' ), 321 'slug' => 'change-avatar', 322 'parent_url' => $profile_link, 323 'parent_slug' => $slug, 324 'screen_function' => 'bp_members_screen_change_avatar', 325 'position' => 30, 326 'user_has_access' => $access 327 ); 328 } 329 330 // Change Cover image. 331 if ( bp_displayed_user_use_cover_image_header() ) { 332 $subnavs[] = array( 333 'name' => _x( 'Change Cover Image', 'Profile header sub menu', 'buddypress' ), 334 'slug' => 'change-cover-image', 335 'parent_url' => $profile_link, 336 'parent_slug' => $slug, 337 'screen_function' => 'bp_members_screen_change_cover_image', 338 'position' => 40, 339 'user_has_access' => $access 340 ); 341 } 342 343 return $subnavs; 344 } 345 346 /** 292 347 * Set up fall-back component navigation if XProfile is inactive. 293 348 * … … 312 367 // Bail if XProfile component is active and there's no custom front page for the user. 313 368 if ( ! bp_displayed_user_has_front_template() && $is_xprofile_active ) { 369 add_action( 'bp_xprofile_setup_nav', array( $this, 'setup_xprofile_nav' ) ); 314 370 return; 315 371 } … … 340 396 'item_css_id' => buddypress()->profile->id 341 397 ); 398 399 /** 400 * The xProfile component is active. 401 * 402 * We need to make sure the Change Avatar and Change Cover Image subnavs are 403 * added just like it was the case before. 404 */ 405 } else { 406 add_action( 'bp_xprofile_setup_nav', array( $this, 'setup_xprofile_nav' ) ); 342 407 } 343 408 … … 394 459 } else { 395 460 $main_nav = $this->main_nav; 396 $sub_nav[] = $this->sub_nav; 461 $sub_nav = array( $this->sub_nav ); 462 463 if ( ! $is_xprofile_active ) { 464 $sub_nav = array_merge( $sub_nav, $this->get_avatar_cover_image_subnavs() ); 465 } 397 466 } 398 467 … … 418 487 // Add the sub nav item. 419 488 bp_core_new_subnav_item( $this->sub_nav, 'members' ); 489 490 // Get the Avatar and cover image subnavs. 491 $this->setup_xprofile_nav(); 492 } 493 494 /** 495 * Set up the xProfile nav. 496 * 497 * @since 6.0.0 498 */ 499 public function setup_xprofile_nav() { 500 // Get the Avatar and cover image subnavs. 501 $items = $this->get_avatar_cover_image_subnavs(); 502 503 foreach ( $items as $item ) { 504 bp_core_new_subnav_item( $item, 'members' ); 505 } 506 } 507 508 /** 509 * Get the Avatar and Cover image admin navs. 510 * 511 * @since 6.0.0 512 * 513 * @param string $admin_bar_menu_id The Admin bar menu ID to attach sub items to. 514 * @return array The Avatar and Cover image admin navs. 515 */ 516 public function get_avatar_cover_image_admin_navs( $admin_bar_menu_id = '' ) { 517 $wp_admin_nav = array(); 518 $profile_link = trailingslashit( bp_loggedin_user_domain() . bp_get_profile_slug() ); 519 520 if ( ! $admin_bar_menu_id ) { 521 $admin_bar_menu_id = $this->id; 522 } 523 524 // Edit Avatar. 525 if ( buddypress()->avatar->show_avatars ) { 526 $wp_admin_nav[] = array( 527 'parent' => 'my-account-' . $admin_bar_menu_id, 528 'id' => 'my-account-' . $admin_bar_menu_id . '-change-avatar', 529 'title' => _x( 'Change Profile Photo', 'My Account Profile sub nav', 'buddypress' ), 530 'href' => trailingslashit( $profile_link . 'change-avatar' ), 531 'position' => 30 532 ); 533 } 534 535 // Edit Cover Image 536 if ( bp_displayed_user_use_cover_image_header() ) { 537 $wp_admin_nav[] = array( 538 'parent' => 'my-account-' . $admin_bar_menu_id, 539 'id' => 'my-account-' . $admin_bar_menu_id . '-change-cover-image', 540 'title' => _x( 'Change Cover Image', 'My Account Profile sub nav', 'buddypress' ), 541 'href' => trailingslashit( $profile_link . 'change-cover-image' ), 542 'position' => 40 543 ); 544 } 545 546 return $wp_admin_nav; 547 } 548 549 /** 550 * Set up the Admin Bar. 551 * 552 * @since 6.0.0 553 * 554 * @param array $wp_admin_nav Admin Bar items. 555 */ 556 public function setup_admin_bar( $wp_admin_nav = array() ) { 557 // Menus for logged in user. 558 if ( is_user_logged_in() ) { 559 $profile_link = trailingslashit( bp_loggedin_user_domain() . bp_get_profile_slug() ); 560 561 if ( ! bp_is_active( 'xprofile' ) ) { 562 // Add the "Profile" sub menu. 563 $wp_admin_nav[] = array( 564 'parent' => buddypress()->my_account_menu_id, 565 'id' => 'my-account-' . $this->id, 566 'title' => _x( 'Profile', 'My Account Profile', 'buddypress' ), 567 'href' => $profile_link 568 ); 569 570 // View Profile. 571 $wp_admin_nav[] = array( 572 'parent' => 'my-account-' . $this->id, 573 'id' => 'my-account-' . $this->id . '-public', 574 'title' => _x( 'View', 'My Account Profile sub nav', 'buddypress' ), 575 'href' => $profile_link, 576 'position' => 10 577 ); 578 579 $wp_admin_nav = array_merge( $wp_admin_nav, $this->get_avatar_cover_image_admin_navs() ); 580 581 /** 582 * The xProfile is active. 583 * 584 * Add the Change Avatar and Change Cover Image Admin Bar items 585 * to the xProfile Admin Bar Menu. 586 */ 587 } else { 588 add_filter( 'bp_xprofile_admin_nav', array( $this, 'setup_xprofile_admin_nav' ), 2 ); 589 } 590 } 591 592 parent::setup_admin_bar( $wp_admin_nav ); 593 } 594 595 /** 596 * Adds "Profile > Change Avatar" & "Profile > Change Cover Image" subnav item 597 * under the "Profile" adminbar menu. 598 * 599 * @since 6.0.0 600 * 601 * @param array $wp_admin_nav The Profile adminbar nav array. 602 * @return array 603 */ 604 public function setup_xprofile_admin_nav( $wp_admin_nav ) { 605 $items = $this->get_avatar_cover_image_admin_navs( buddypress()->profile->id ); 606 607 if ( $items ) { 608 $wp_admin_nav = array_merge( $wp_admin_nav, $items ); 609 } 610 611 return $wp_admin_nav; 420 612 } 421 613 … … 474 666 'BP_REST_Components_Endpoint', 475 667 'BP_REST_Members_Endpoint', 668 'BP_REST_Attachments_Member_Avatar_Endpoint', 476 669 ) ); 477 670 } -
trunk/src/bp-xprofile/classes/class-bp-xprofile-component.php
r12488 r12559 113 113 require $this->path . 'bp-xprofile/screens/public.php'; 114 114 115 // Action - Delete avatar.116 if ( is_user_logged_in()&& bp_is_user_change_avatar() && bp_is_action_variable( 'delete-avatar', 0 ) ) {117 require $this->path . 'bp-xprofile/actions/delete-avatar.php';118 }119 120 115 // Sub-nav items. 121 if ( is_user_logged_in() && 122 in_array( bp_current_action(), array( 'edit', 'change-avatar', 'change-cover-image' ), true ) 123 ) { 124 require $this->path . 'bp-xprofile/screens/' . bp_current_action() . '.php'; 116 if ( is_user_logged_in() && 'edit' === bp_current_action() ) { 117 require $this->path . 'bp-xprofile/screens/edit.php'; 125 118 } 126 119 } … … 279 272 ); 280 273 281 // Change Avatar.282 if ( buddypress()->avatar->show_avatars ) {283 $sub_nav[] = array(284 'name' => _x( 'Change Profile Photo', 'Profile header sub menu', 'buddypress' ),285 'slug' => 'change-avatar',286 'parent_url' => $profile_link,287 'parent_slug' => $slug,288 'screen_function' => 'xprofile_screen_change_avatar',289 'position' => 30,290 'user_has_access' => $access291 );292 }293 294 // Change Cover image.295 if ( bp_displayed_user_use_cover_image_header() ) {296 $sub_nav[] = array(297 'name' => _x( 'Change Cover Image', 'Profile header sub menu', 'buddypress' ),298 'slug' => 'change-cover-image',299 'parent_url' => $profile_link,300 'parent_slug' => $slug,301 'screen_function' => 'xprofile_screen_change_cover_image',302 'position' => 40,303 'user_has_access' => $access304 );305 }306 307 274 // The Settings > Profile nav item can only be set up after 308 275 // the Settings component has run its own nav routine. … … 388 355 'position' => 20 389 356 ); 390 391 // Edit Avatar.392 if ( buddypress()->avatar->show_avatars ) {393 $wp_admin_nav[] = array(394 'parent' => 'my-account-' . $this->id,395 'id' => 'my-account-' . $this->id . '-change-avatar',396 'title' => _x( 'Change Profile Photo', 'My Account Profile sub nav', 'buddypress' ),397 'href' => trailingslashit( $profile_link . 'change-avatar' ),398 'position' => 30399 );400 }401 402 if ( bp_displayed_user_use_cover_image_header() ) {403 $wp_admin_nav[] = array(404 'parent' => 'my-account-' . $this->id,405 'id' => 'my-account-' . $this->id . '-change-cover-image',406 'title' => _x( 'Change Cover Image', 'My Account Profile sub nav', 'buddypress' ),407 'href' => trailingslashit( $profile_link . 'change-cover-image' ),408 'position' => 40409 );410 }411 357 } 412 358 … … 504 450 'BP_REST_XProfile_Field_Groups_Endpoint', 505 451 'BP_REST_XProfile_Data_Endpoint', 506 'BP_REST_Attachments_Member_Avatar_Endpoint',507 452 ) ); 508 453 } -
trunk/tests/phpunit/testcases/core/class-bp-component.php
r12488 r12559 33 33 'BP_REST_Components_Endpoint', 34 34 'BP_REST_Members_Endpoint', 35 'BP_REST_Attachments_Member_Avatar_Endpoint', 35 36 ) ); 36 37 } … … 48 49 $this->assertSame( $bp->unit_test_rest->controllers, array( 49 50 'BP_REST_Components_Endpoint', 51 'BP_REST_Attachments_Member_Avatar_Endpoint', 50 52 ) ); 51 53 } … … 64 66 'BP_REST_Components_Endpoint', 65 67 'BP_REST_Members_Endpoint', 68 'BP_REST_Attachments_Member_Avatar_Endpoint', 66 69 ) ); 67 70 }
Note: See TracChangeset
for help on using the changeset viewer.