Changeset 10326
- Timestamp:
- 11/06/2015 12:39:46 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-buddybar.php
r10108 r10326 57 57 58 58 // Then, hook the screen function for the added nav item. 59 bp_core_register_nav_screen_function( $r ); 59 $hooked = bp_core_register_nav_screen_function( $r ); 60 if ( false === $hooked ){ 61 return false; 62 } 60 63 61 64 /** … … 119 122 // If this is for site admins only and the user is not one, don't create the nav item. 120 123 if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) { 121 return false;122 }123 124 /**125 * If this nav item is hidden for the displayed user, and126 * the logged in user is not the displayed user127 * looking at their own profile, don't create the nav item.128 */129 if ( empty( $r['show_for_displayed_user'] ) && ! bp_user_has_access() ) {130 124 return false; 131 125 } … … 415 409 416 410 // Then, hook the screen function for the added subnav item. 417 bp_core_register_subnav_screen_function( $args ); 418 411 $hooked = bp_core_register_subnav_screen_function( $args ); 412 if ( false === $hooked ) { 413 return false; 414 } 419 415 } 420 416 -
trunk/tests/phpunit/testcases/core/nav/bpCoreNewNavItem.php
r9990 r10326 125 125 } 126 126 127 public function test_existence_of_access_protected_user_nav() { 128 $bp_nav = buddypress()->bp_nav; 129 130 $u = $this->factory->user->create(); 131 $u2 = $this->factory->user->create(); 132 $old_current_user = get_current_user_id(); 133 $this->set_current_user( $u2 ); 134 135 $this->go_to( bp_core_get_user_domain( $u ) ); 136 137 $expected = array( 138 'name' => 'Settings', 139 'slug' => 'settings', 140 'link' => trailingslashit( bp_loggedin_user_domain() . 'settings' ), 141 'css_id' => 'settings', 142 'show_for_displayed_user' => false, 143 'position' => 100, 144 'screen_function' => 'bp_settings_screen_general', 145 'default_subnav_slug' => 'general' 146 ); 147 148 $this->assertSame( buddypress()->bp_nav['settings'], $expected ); 149 150 // Clean up 151 buddypress()->bp_nav = $bp_nav; 152 $this->set_current_user( $old_current_user ); 153 } 154 155 public function test_creation_of_access_protected_user_nav() { 156 // The nav item must be added to bp_nav, even if the current user 157 // can't visit that nav item. 158 $bp_nav = buddypress()->bp_nav; 159 160 $u = $this->factory->user->create(); 161 $u2 = $this->factory->user->create(); 162 $old_current_user = get_current_user_id(); 163 $this->set_current_user( $u2 ); 164 165 $this->go_to( bp_core_get_user_domain( $u ) ); 166 167 bp_core_new_nav_item( array( 168 'name' => 'Woof', 169 'slug' => 'woof', 170 'show_for_displayed_user' => false, 171 'position' => 35, 172 'screen_function' => 'woof_screen_function', 173 'default_subnav_slug' => 'woof-one' 174 ) ); 175 176 $expected = array( 177 'name' => 'Woof', 178 'slug' => 'woof', 179 'link' => trailingslashit( bp_loggedin_user_domain() . 'woof' ), 180 'css_id' => 'woof', 181 'show_for_displayed_user' => false, 182 'position' => 35, 183 'screen_function' => 'woof_screen_function', 184 'default_subnav_slug' => 'woof-one' 185 ); 186 187 $this->assertSame( buddypress()->bp_nav['woof'], $expected ); 188 189 // Clean up 190 buddypress()->bp_nav = $bp_nav; 191 $this->set_current_user( $old_current_user ); 192 } 127 193 }
Note: See TracChangeset
for help on using the changeset viewer.