/** * Get profile section slugs * * @since 0.1.7 */ function wp_user_profiles_get_section_hooknames($section = '') { // What slugs are we looking for $sections = !empty($section) ? array($section) : wp_list_pluck(wp_user_profiles_sections(), 'slug'); // Get file $hooks = array(); $file = wp_user_profiles_get_file(); // Generate hooknames foreach ($sections as $slug) { $hookname = get_plugin_page_hookname($slug, $file); $hooks[] = $hookname; } // Network & user admin corrections array_walk($hooks, '_wp_user_profiles_walk_section_hooknames'); return $hooks; }
/** * Create the Profile navigation in Edit User & Edit Profile pages. * * @since 0.1.0 * * @param object|null $user User to create profile navigation for. * @param string $current Which profile to highlight. * * @return string */ function wp_user_profiles_admin_nav($user = null) { // Bail if no user ID exists here if (empty($user->ID)) { return; } // User admin is a special case where top-level menus replace // tabulated ones. if (is_user_admin()) { return; } // Add the user ID to query arguments when not editing yourself $query_args = !IS_PROFILE_PAGE ? array('user_id' => $user->ID) : array(); // Conditionally add a referer if it exists in the existing request if (!empty($_REQUEST['wp_http_referer'])) { $query_args['wp_http_referer'] = urlencode(stripslashes_deep($_REQUEST['wp_http_referer'])); } // Current page? $current = !empty($_GET['page']) ? sanitize_key($_GET['page']) : 'profile'; // Get tabs $tabs = wp_user_profiles_sections(); $user_url = wp_user_profiles_edit_user_url_filter(); ?> <h2 id="profile-nav" class="nav-tab-wrapper"> <?php foreach ($tabs as $tab) { ?> <?php if (current_user_can($tab->cap, $user->ID)) { $query_args['page'] = $tab->slug; ?> <a class="nav-tab<?php echo $tab->id === $current ? ' nav-tab-active' : ''; ?> " href="<?php echo esc_url(add_query_arg($query_args, $user_url)); ?> "> <?php echo esc_html($tab->name); ?> </a> <?php } ?> <?php } ?> </h2> <?php }
/** * Return array of profile sections * * @since 0.1.0 * * @return string */ function wp_user_avatars_profile_sections() { // Bail if no user profile sections if (!function_exists('wp_user_profiles_sections')) { return array('profile.php', 'user-edit.php'); } // Get sections $sections = wp_list_pluck(wp_user_profiles_sections(), 'slug'); $in_array = array('toplevel_page_profile'); foreach ($sections as $section) { $in_array[] = 'users_page_' . $section; } return $in_array; }