label' => _x( 'Everyone', 'Visibility level setting', 'buddypress' ), ), 'adminsonly' => array( 'id' => 'adminsonly', 'label' => _x( 'Only Me', 'Visibility level setting', 'buddypress' ), ), 'loggedin' => array( 'id' => 'loggedin', 'label' => _x( 'All Members', 'Visibility level setting', 'buddypress' ), ), ); if ( bp_is_active( 'friends' ) ) { $this->visibility_levels['friends'] = array( 'id' => 'friends', 'label' => _x( 'My Friends', 'Visibility level setting', 'buddypress' ), ); } // Tables. $global_tables = array( 'table_name_data' => $bp->table_prefix . 'bp_xprofile_data', 'table_name_groups' => $bp->table_prefix . 'bp_xprofile_groups', 'table_name_fields' => $bp->table_prefix . 'bp_xprofile_fields', 'table_name_meta' => $bp->table_prefix . 'bp_xprofile_meta', ); $meta_tables = array( 'xprofile_group' => $bp->table_prefix . 'bp_xprofile_meta', 'xprofile_field' => $bp->table_prefix . 'bp_xprofile_meta', 'xprofile_data' => $bp->table_prefix . 'bp_xprofile_meta', ); $globals = array( 'slug' => $default_slug, 'has_directory' => false, 'notification_callback' => 'xprofile_format_notifications', 'global_tables' => $global_tables, 'meta_tables' => $meta_tables, ); parent::setup_globals( $globals ); } /** * Register component navigation. * * @since 12.0.0 * * @param array $main_nav See `BP_Component::register_nav()` for details. * @param array $sub_nav See `BP_Component::register_nav()` for details. */ public function register_nav( $main_nav = array(), $sub_nav = array() ) { $slug = bp_get_profile_slug(); // Add 'Profile' to the main navigation. $main_nav = array( 'name' => _x( 'Profile', 'Profile header menu', 'buddypress' ), 'slug' => $slug, 'position' => 20, 'screen_function' => 'xprofile_screen_display_profile', 'default_subnav_slug' => 'public', 'item_css_id' => $this->id, ); // Add the subnav items to the profile. $sub_nav[] = array( 'name' => _x( 'View', 'Profile header sub menu', 'buddypress' ), 'slug' => 'public', 'parent_slug' => $slug, 'screen_function' => 'xprofile_screen_display_profile', 'position' => 10, ); // Edit Profile. $sub_nav[] = array( 'name' => _x( 'Edit','Profile header sub menu', 'buddypress' ), 'slug' => 'edit', 'parent_slug' => $slug, 'screen_function' => 'xprofile_screen_edit_profile', 'position' => 20, 'user_has_access' => false, 'user_has_access_callback' => 'bp_core_can_edit_settings', ); parent::register_nav( $main_nav, $sub_nav ); } /** * Set up the Settings > Profile nav item. * * Loaded in a separate method because the Settings component may not * be loaded in time for BP_XProfile_Component::setup_nav(). * * @since 2.1.0 * @deprecated 12.0.0 */ public function setup_settings_nav() { _deprecated_function( __METHOD__, '12.0.0' ); } /** * Set up the Admin Bar. * * @since 1.5.0 * * @param array $wp_admin_nav Admin Bar items. */ public function setup_admin_bar( $wp_admin_nav = array() ) { // Menus for logged in user. if ( is_user_logged_in() ) { $profile_slug = bp_get_profile_slug(); // Add the "Profile" sub menu. $wp_admin_nav[] = array( 'parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => _x( 'Profile', 'My Account Profile', 'buddypress' ), 'href' => bp_loggedin_user_url( bp_members_get_path_chunks( array( $profile_slug ) ) ), ); // View Profile. $wp_admin_nav[] = array( 'parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-public', 'title' => _x( 'View', 'My Account Profile sub nav', 'buddypress' ), 'href' => bp_loggedin_user_url( bp_members_get_path_chunks( array( $profile_slug, 'public' ) ) ), 'position' => 10, ); // Edit Profile. $wp_admin_nav[] = array( 'parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-edit', 'title' => _x( 'Edit', 'My Account Profile sub nav', 'buddypress' ), 'href' => bp_loggedin_user_url( bp_members_get_path_chunks( array( $profile_slug, 'edit' ) ) ), 'position' => 20, ); } parent::setup_admin_bar( $wp_admin_nav ); } /** * Add custom hooks. * * @since 2.0.0 */ public function setup_hooks() { add_filter( 'bp_settings_admin_nav', array( $this, 'setup_settings_admin_nav' ), 2 ); } /** * Sets up the title for pages and