- Timestamp:
- 04/12/2023 10:12:37 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-settings/classes/class-bp-settings-component.php
r13442 r13450 120 120 121 121 /** 122 * Set upnavigation.123 * 124 * @since 1 .5.0125 * 126 * @see BP_Component::setup_nav()for a description of arguments.127 * 128 * @param array $main_nav Optional. See BP_Component::setup_nav()for122 * Register component navigation. 123 * 124 * @since 12.0.0 125 * 126 * @see `BP_Component::register_nav()` for a description of arguments. 127 * 128 * @param array $main_nav Optional. See `BP_Component::register_nav()` for 129 129 * description. 130 * @param array $sub_nav Optional. See BP_Component::setup_nav()for130 * @param array $sub_nav Optional. See `BP_Component::register_nav()` for 131 131 * description. 132 132 */ 133 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 134 135 // Stop if there is no user displayed or logged in. 136 if ( ! is_user_logged_in() && ! bp_displayed_user_id() ) { 137 return; 138 } 139 140 $access = bp_core_can_edit_settings(); 133 public function register_nav( $main_nav = array(), $sub_nav = array() ) { 141 134 $slug = bp_get_settings_slug(); 142 135 143 136 // Add the settings navigation item. 144 137 $main_nav = array( 145 'name' => __( 'Settings', 'buddypress' ),146 'slug' => $slug,147 'position' => 100,148 's how_for_displayed_user' => $access,149 ' screen_function' => 'bp_settings_screen_general',150 ' default_subnav_slug' => 'general',138 'name' => __( 'Settings', 'buddypress' ), 139 'slug' => $slug, 140 'position' => 100, 141 'screen_function' => 'bp_settings_screen_general', 142 'default_subnav_slug' => 'general', 143 'user_has_access_callback' => 'bp_core_can_edit_settings', 151 144 ); 152 145 153 146 // Add General Settings nav item. 154 147 $sub_nav[] = array( 155 'name' => __( 'General', 'buddypress' ), 156 'slug' => 'general', 157 'parent_slug' => $slug, 158 'screen_function' => 'bp_settings_screen_general', 159 'position' => 10, 160 'user_has_access' => $access, 148 'name' => __( 'General', 'buddypress' ), 149 'slug' => 'general', 150 'parent_slug' => $slug, 151 'screen_function' => 'bp_settings_screen_general', 152 'position' => 10, 153 'user_has_access' => false, 154 'user_has_access_callback' => 'bp_core_can_edit_settings', 161 155 ); 162 156 … … 164 158 // retain the old slug and function names for backward compat. 165 159 $sub_nav[] = array( 166 'name' => __( 'Email', 'buddypress' ), 167 'slug' => 'notifications', 168 'parent_slug' => $slug, 169 'screen_function' => 'bp_settings_screen_notification', 170 'position' => 20, 171 'user_has_access' => $access, 172 ); 173 174 // Add Spam Account nav item. 175 if ( bp_current_user_can( 'bp_moderate' ) ) { 176 $sub_nav[] = array( 177 'name' => __( 'Capabilities', 'buddypress' ), 178 'slug' => 'capabilities', 179 'parent_slug' => $slug, 180 'screen_function' => 'bp_settings_screen_capabilities', 181 'position' => 80, 182 'user_has_access' => ! bp_is_my_profile(), 183 ); 184 } 160 'name' => __( 'Email', 'buddypress' ), 161 'slug' => 'notifications', 162 'parent_slug' => $slug, 163 'screen_function' => 'bp_settings_screen_notification', 164 'position' => 20, 165 'user_has_access' => false, 166 'user_has_access_callback' => 'bp_core_can_edit_settings', 167 ); 168 169 $sub_nav[] = array( 170 'name' => _x( 'Profile Visibility', 'Profile settings sub nav', 'buddypress' ), 171 'slug' => 'profile', 172 'parent_slug' => $slug, 173 'screen_function' => 'bp_xprofile_screen_settings', 174 'position' => 30, 175 'user_has_access' => false, 176 'user_has_access_callback' => 'bp_core_can_edit_settings', 177 ); 178 179 $sub_nav[] = array( 180 'name' => __( 'Capabilities', 'buddypress' ), 181 'slug' => 'capabilities', 182 'parent_slug' => $slug, 183 'screen_function' => 'bp_settings_screen_capabilities', 184 'position' => 80, 185 'user_has_access' => false, 186 'user_has_access_callback' => 'bp_settings_show_capability_nav', 187 'generate' => bp_current_user_can( 'bp_moderate' ), 188 ); 185 189 186 190 /** … … 196 200 if ( true === $show_data_page ) { 197 201 $sub_nav[] = array( 198 'name' => __( 'Export Data', 'buddypress' ), 199 'slug' => 'data', 200 'parent_slug' => $slug, 201 'screen_function' => 'bp_settings_screen_data', 202 'position' => 89, 203 'user_has_access' => $access, 202 'name' => __( 'Export Data', 'buddypress' ), 203 'slug' => 'data', 204 'parent_slug' => $slug, 205 'screen_function' => 'bp_settings_screen_data', 206 'position' => 89, 207 'user_has_access' => false, 208 'user_has_access_callback' => 'bp_core_can_edit_settings', 204 209 ); 205 210 } 206 211 207 212 // Add Delete Account nav item. 208 if ( ( ! bp_disable_account_deletion() && bp_is_my_profile() ) || bp_current_user_can( 'delete_users' ) ) {209 $sub_nav[] = array(210 'name' => __( 'Delete Account', 'buddypress' ),211 'slug' => 'delete-account',212 'parent_slug' => $slug,213 'screen_function' => 'bp_settings_screen_delete_account',214 'position' => 90,215 'user_has_access' => ! user_can( bp_displayed_user_id(), 'delete_users' ),216 );217 }218 219 parent:: setup_nav( $main_nav, $sub_nav );213 $sub_nav[] = array( 214 'name' => __( 'Delete Account', 'buddypress' ), 215 'slug' => 'delete-account', 216 'parent_slug' => $slug, 217 'screen_function' => 'bp_settings_screen_delete_account', 218 'position' => 90, 219 'user_has_access' => false, 220 'user_has_access_callback' => 'bp_settings_can_delete_self_account', 221 'generate' => 'bp_settings_show_delete_account_nav', 222 ); 223 224 parent::register_nav( $main_nav, $sub_nav ); 220 225 } 221 226 … … 225 230 * @since 1.5.0 226 231 * 227 * @see BP_Component::setup_nav()for a description of the $wp_admin_nav232 * @see `BP_Component::setup_admin_bar()` for a description of the $wp_admin_nav 228 233 * parameter array. 229 234 * 230 * @param array $wp_admin_nav See BP_Component::setup_admin_bar()for a235 * @param array $wp_admin_nav See `BP_Component::setup_admin_bar()` for a 231 236 * description. 232 237 */
Note: See TracChangeset
for help on using the changeset viewer.