Beispiel #1
0
/**
 * Add metabox to User Profiles section
 *
 * @since 0.2.0
 *
 * @param string $type
 */
function wp_user_activity_add_user_profiles_metabox($type = '', $user = null)
{
    // Get hookname
    $hooks = wp_user_profiles_get_section_hooknames('activity');
    // Bail if not the correct type
    if (!in_array($type, $hooks, true)) {
        return;
    }
    // Add the metabox
    add_meta_box('wp_user_activity_user_profile', __('Activity', 'wp-user-activity'), 'wp_user_activity_list_metabox', $type, 'normal', 'default', $user);
}
/**
 * Add the default user profile metaboxes
 *
 * @since 0.1.0
 *
 * @param   string  $type
 * @param   mixed   $user
 */
function wp_user_profiles_add_avatar_meta_box($type = '', $user = null)
{
    // Bail if no profile sections
    if (!function_exists('wp_user_profiles_sections')) {
        return;
    }
    // Support for WP User Profiles 0.1.7 and higher
    if (function_exists('wp_user_profiles_get_section_hooknames')) {
        $types = wp_user_profiles_get_section_hooknames();
        // WP User Profiles 0.1.6 and lower
    } else {
        $types = wp_user_avatars_profile_sections();
    }
    // Bail if not user metaboxes
    if (empty($user) || !in_array($type, $types, true)) {
        return;
    }
    // Register avatar metabox
    add_meta_box('user-avatar', _x('Avatar', 'users user-admin edit screen', 'wp-user-avatars'), 'wp_user_profiles_avatar_metabox', $type, 'side', 'low');
}
Beispiel #3
0
/**
 * Fix submenu highlights
 *
 * @since 0.1.0
 *
 * @global  string  $plugin_page
 * @global  string  $submenu_file
 */
function wp_user_profiles_admin_menu_highlight()
{
    global $plugin_page, $submenu_file;
    // Bail if in user dashboard area
    if (is_user_admin()) {
        return;
    }
    // If not current user's profile page, set to Users and bail
    if (!empty($_GET['user_id']) && get_current_user_id() !== (int) $_GET['user_id']) {
        $submenu_file = wp_user_profiles_get_file();
        return;
    }
    // Get slugs from profile sections
    $plucked = wp_user_profiles_get_section_hooknames();
    // Maybe tweak the highlighted submenu
    if (!in_array($plugin_page, array($plucked), true)) {
        if (current_user_can('list_users')) {
            $submenu_file = 'profile';
        } elseif (is_blog_admin()) {
            $plugin_page = 'profile';
        }
    }
}
 /**
  * Metaboxes for profile sections
  *
  * @since 0.1.6
  */
 public function add_meta_box($type = '')
 {
     // Get hookname
     $hooks = wp_user_profiles_get_section_hooknames('groups');
     // Bail if not the correct type
     if (!in_array($type, $hooks, true)) {
         return;
     }
     // Get the taxonomy
     $tax = get_taxonomy($this->taxonomy);
     $user_id = !empty($_GET['user_id']) ? (int) $_GET['user_id'] : get_current_user_id();
     // Make sure the user can assign terms of the group taxonomy before proceeding.
     if (!current_user_can('edit_user', $user_id) || !current_user_can($tax->cap->assign_terms)) {
         return;
     }
     // Bail if no UI for taxonomy
     if (false === $tax->show_ui) {
         return;
     }
     // Get the terms of the taxonomy.
     $terms = get_terms($this->taxonomy, array('hide_empty' => false));
     // Maybe add the metabox
     add_meta_box('wp_user_taxonomy_' . $this->taxonomy, $tax->label, array($this, 'user_profile_metabox'), $hooks[0], 'normal', 'default', array('user_id' => $user_id, 'tax' => $tax, 'terms' => $terms));
 }
/**
 * Add the default user profile metaboxes
 *
 * @since 0.1.0
 *
 * @param   string  $type
 * @param   mixed   $user
 */
function wp_user_profiles_add_permissions_meta_boxes($type = '', $user = null)
{
    // Get types
    $types = wp_user_profiles_get_section_hooknames('permissions');
    // Bail if not user metaboxes
    if (empty($user) || !in_array($type, $types, true)) {
        return;
    }
    // Color schemes
    add_meta_box('roles', _x('Roles', 'users user-admin edit screen', 'wp-user-profiles'), 'wp_user_profiles_roles_metabox', $type, 'normal', 'core');
    // Color schemes
    add_meta_box('options', _x('Additional Capabilities', 'users user-admin edit screen', 'wp-user-profiles'), 'wp_user_profiles_additional_capabilities_metabox', $type, 'normal', 'core');
}
 /**
  * Meta boxes for this section?
  *
  * @since 0.2.0
  *
  * @param  string  $type
  * @param  WP_User $user
  */
 public function action_add_meta_boxes($type = '', $user = null)
 {
     // Bail if ID is empty
     if (empty($this->id)) {
         return;
     }
     // Get hooknames
     $hookname = wp_user_profiles_get_section_hooknames($this->id);
     // Bail if not these metaboxes
     if ($hookname[0] !== $type || !current_user_can($this->cap, $user->ID)) {
         return;
     }
     // Do the metabox action
     $this->add_meta_boxes($type, $user);
 }