Add hierarhical managment
This commit is contained in:
134
backend/wordpress/wp-content/plugins/wp-user-groups/readme.txt
Normal file
134
backend/wordpress/wp-content/plugins/wp-user-groups/readme.txt
Normal file
@@ -0,0 +1,134 @@
|
||||
=== WP User Groups ===
|
||||
Contributors: johnjamesjacoby, stuttter
|
||||
Tags: taxonomy, term, user, group, type
|
||||
Requires at least: 4.7
|
||||
Tested up to: 4.9
|
||||
Stable tag: 2.2.0
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9Q4F4EL5YJ62J
|
||||
|
||||
== Description ==
|
||||
|
||||
WP User Groups allows users to be categorized using custom taxonomies & terms.
|
||||
|
||||
* "Groups" & "Types" are created by default, and can be overridden
|
||||
* More user group types can be registered with custom arguments
|
||||
* Edit users and set their relationships
|
||||
* Bulk edit many users to quickly assign several at once
|
||||
* Filter the users list to see which users are in what groups
|
||||
* Not destructive data storage (plugin can be enabled & disabled without damage)
|
||||
* Works great with all WP Term Meta plugins (see below)
|
||||
|
||||
= Also checkout =
|
||||
|
||||
* [WP Chosen](https://wordpress.org/plugins/wp-chosen/ "Make long, unwieldy select boxes much more user-friendly.")
|
||||
* [WP Pretty Filters](https://wordpress.org/plugins/wp-pretty-filters/ "Makes post filters better match what's already in Media & Attachments.")
|
||||
* [WP Event Calendar](https://wordpress.org/plugins/wp-event-calendar/ "The best way to manage events in WordPress.")
|
||||
* [WP Media Categories](https://wordpress.org/plugins/wp-media-categories/ "Add categories to media & attachments.")
|
||||
* [WP Term Order](https://wordpress.org/plugins/wp-term-order/ "Sort taxonomy terms, your way.")
|
||||
* [WP Term Authors](https://wordpress.org/plugins/wp-term-authors/ "Authors for categories, tags, and other taxonomy terms.")
|
||||
* [WP Term Colors](https://wordpress.org/plugins/wp-term-colors/ "Pretty colors for categories, tags, and other taxonomy terms.")
|
||||
* [WP Term Icons](https://wordpress.org/plugins/wp-term-icons/ "Pretty icons for categories, tags, and other taxonomy terms.")
|
||||
* [WP Term Visibility](https://wordpress.org/plugins/wp-term-visibility/ "Visibilities for categories, tags, and other taxonomy terms.")
|
||||
* [WP User Activity](https://wordpress.org/plugins/wp-user-activity/ "The best way to log activity in WordPress.")
|
||||
* [WP User Avatars](https://wordpress.org/plugins/wp-user-avatars/ "Allow users to upload avatars or choose them from your media library.")
|
||||
* [WP User Profiles](https://wordpress.org/plugins/wp-user-profiles/ "A sophisticated way to edit users in WordPress.")
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Menu Items
|
||||
2. Groups Taxonomy
|
||||
3. Types Taxonomy
|
||||
4. User Edit & Assignment
|
||||
5. Users List
|
||||
6. Users List (Filtered)
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Download and install using the built in WordPress plugin installer.
|
||||
1. Activate in the "Plugins" area of your admin by clicking the "Activate" link.
|
||||
1. Visit "Users > Groups" and create some groups
|
||||
1. Add users to groups by editing their profile and checking the boxes
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Does this create new database tables? =
|
||||
|
||||
No. There are no new database tables with this plugin.
|
||||
|
||||
= Does this modify existing database tables? =
|
||||
|
||||
No. All of WordPress's core database tables remain untouched.
|
||||
|
||||
= Does this plugin integrate with user roles? =
|
||||
|
||||
No. This is best left to plugins that choose to integrate with this plugin.
|
||||
|
||||
= Where can I get support? =
|
||||
|
||||
* Basic: https://wordpress.org/support/plugin/wp-user-groups/
|
||||
* Priority: https://chat.flox.io/support/channels/wp-user-groups/
|
||||
|
||||
= Where can I find documentation? =
|
||||
|
||||
http://github.com/stuttter/wp-user-groups/
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= [2.2.0] - 2018/06/05 =
|
||||
* Add "Managed" taxonomy type, so users cannot assign their own groups
|
||||
|
||||
= [2.1.0] - 2018/04/16 =
|
||||
* Add a dedicated nonce for each user taxonomy (thanks Tom Adams!)
|
||||
|
||||
= [2.0.0] - 2017/10/24 =
|
||||
* Fix bug with user filtering
|
||||
* Fix bug with setting user terms
|
||||
* Add `exclusive` group argument to use radios instead of checkboxes
|
||||
|
||||
= [1.1.0] - 2017/03/28 =
|
||||
* Change default taxonomy to `user-group` in wp_get_users_of_group()
|
||||
|
||||
= [1.0.0] - 2016/12/07 =
|
||||
* WordPress 4.7 compatibility
|
||||
* Improved bulk actions (requires WordPress 4.7)
|
||||
* Official stable release
|
||||
|
||||
= [0.2.1] - 2016/05/25 =
|
||||
* Fix bug with user list
|
||||
* Introduce wp_get_users_of_group() helper function
|
||||
* Add unique class to administration forms
|
||||
|
||||
= [0.2.0] - 2015/12/23 =
|
||||
* Support for WP User Profiles 0.2.0
|
||||
|
||||
= [0.1.9] - 2015/12/21 =
|
||||
* Fix bug with User Profiles integration
|
||||
|
||||
= [0.1.8] - 2015/11/11 =
|
||||
* Support for WP User Profiles 0.1.9
|
||||
|
||||
= [0.1.7] - 2015/11/09 =
|
||||
* Update assets & meta
|
||||
|
||||
= [0.1.6] - 2015/10/23 =
|
||||
* Add support for WP User Profiles
|
||||
|
||||
= [0.1.5] - 2015/10/13 =
|
||||
* Added `user_group` property to taxonomies
|
||||
* Added functions for retrieving only user-groups from taxonomies global
|
||||
|
||||
= [0.1.0] - 2015/09/10 =
|
||||
* Refactor
|
||||
* Improve asset management
|
||||
* Styling tweaks
|
||||
|
||||
= [0.1.2] - 2015/09/01 =
|
||||
* Namespace default taxonomy IDs
|
||||
|
||||
= [0.1.1] - 2015/08/24 =
|
||||
* User profile UI uses a mock list-table
|
||||
|
||||
= [0.1.0] - 2015/08/19 =
|
||||
* Initial release
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Plugin Name: WP User Groups
|
||||
* Plugin URI: https://wordpress.org/plugins/wp-user-groups/
|
||||
* Author: John James Jacoby
|
||||
* Author URI: https://profiles.wordpress.org/johnjamesjacoby/
|
||||
* License: GPLv2 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Description: Group users together with taxonomies & terms.
|
||||
* Version: 2.2.0
|
||||
* Text Domain: wp-user-groups
|
||||
* Domain Path: /wp-user-groups/assets/languages/
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Include the User Groups files
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
function _wp_user_groups() {
|
||||
|
||||
// Get the plugin path
|
||||
$plugin_path = plugin_dir_path( __FILE__ ) . 'wp-user-groups/';
|
||||
|
||||
// Classes
|
||||
require_once $plugin_path . 'includes/classes/class-user-taxonomy.php';
|
||||
|
||||
// Functions
|
||||
require_once $plugin_path . 'includes/functions/admin.php';
|
||||
require_once $plugin_path . 'includes/functions/common.php';
|
||||
require_once $plugin_path . 'includes/functions/taxonomies.php';
|
||||
require_once $plugin_path . 'includes/functions/hooks.php';
|
||||
}
|
||||
add_action( 'plugins_loaded', '_wp_user_groups' );
|
||||
|
||||
/**
|
||||
* Return the plugin URL
|
||||
*
|
||||
* @since 0.1.4
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function wp_user_groups_get_plugin_url() {
|
||||
return plugin_dir_url( __FILE__ ) . 'wp-user-groups/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the asset version
|
||||
*
|
||||
* @since 0.1.4
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function wp_user_groups_get_asset_version() {
|
||||
return 201806050001;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
table.user-groups {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
table.user-groups .row-actions {
|
||||
visibility: hidden;
|
||||
}
|
||||
table.user-groups tr:hover .row-actions {
|
||||
visibility: visible;
|
||||
}
|
||||
table.user-groups thead td.check-column,
|
||||
table.user-groups tfoot td.check-column,
|
||||
table.user-groups .inactive th.check-column{
|
||||
padding-left: 6px;
|
||||
}
|
||||
table.user-groups tbody th.check-column,
|
||||
table.user-groups tbody {
|
||||
padding: 12px 0 0 2px;
|
||||
}
|
||||
table.user-groups th,
|
||||
table.user-groups td {
|
||||
padding: 10px;
|
||||
vertical-align: top;
|
||||
width: auto;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
table.user-groups .column-primary {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
table.user-groups .column-primary strong {
|
||||
display: block;
|
||||
margin-bottom: .2em;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
table.user-groups .column-users {
|
||||
width: 10%;
|
||||
padding-right: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table.user-groups .description {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
table.user-groups .inactive td,
|
||||
table.user-groups .inactive th,
|
||||
table.user-groups .active td,
|
||||
table.user-groups .active th {
|
||||
padding: 10px 9px;
|
||||
}
|
||||
|
||||
table.user-groups .active td,
|
||||
table.user-groups .active th {
|
||||
background-color: #f7fcfe;
|
||||
}
|
||||
|
||||
table.user-groups .inactive td,
|
||||
table.user-groups .inactive th,
|
||||
table.user-groups .active td,
|
||||
table.user-groups .active th {
|
||||
-webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1);
|
||||
box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
table.user-groups tr.active + tr.inactive th,
|
||||
table.user-groups tr.active + tr.inactive td {
|
||||
border-top: 1px solid rgba(0,0,0,0.03);
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(0,0,0,0.02), inset 0 -1px 0 #e1e1e1;
|
||||
box-shadow: inset 0 1px 0 rgba(0,0,0,0.02), inset 0 -1px 0 #e1e1e1;
|
||||
}
|
||||
|
||||
table.user-groups tr.active + tr.inactive.update th,
|
||||
table.user-groups tr.active + tr.inactive.update td,
|
||||
table.user-groups tr.active + tr.inactive.updated th,
|
||||
table.user-groups tr.active + tr.inactive.updated td,
|
||||
table.user-groups tbody tr:last-of-type td,
|
||||
table.user-groups tbody tr:last-of-type th {
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
table.user-groups .active th.check-column {
|
||||
border-left: 4px solid #00a0d2;
|
||||
}
|
||||
|
||||
table.user-groups .plugin-title,
|
||||
table.user-groups .theme-title {
|
||||
padding-right: 12px;
|
||||
white-space:nowrap;
|
||||
}
|
||||
|
||||
table.user-groups .inactive .plugin-title strong {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.user-tax-form fieldset {
|
||||
margin: 8px 10px 0 0;
|
||||
}
|
||||
.subsubsub + form + br.clear {
|
||||
display: none;
|
||||
}
|
||||
.tax-actions {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
@media screen and ( min-width: 786px ) {
|
||||
.wp-list-table.tags .column-users {
|
||||
width: 10%;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and ( max-width: 786px ) {
|
||||
table.form-table table th {
|
||||
display: table-cell;
|
||||
}
|
||||
|
||||
table.form-table table td {
|
||||
display: table-cell !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and ( min-width: 1110px ) {
|
||||
table.user-groups {
|
||||
min-width: 650px;
|
||||
}
|
||||
}
|
||||
|
||||
#wp_user_taxonomy_user-group .inside,
|
||||
#wp_user_taxonomy_user-type .inside {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body.toplevel_page_groups .metabox-holder table.user-groups,
|
||||
body.users_page_groups .metabox-holder table.user-groups {
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User Groups Admin
|
||||
*
|
||||
* @package Plugins/Users/Groups/Admin
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Tweak admin styling for a user groups layout
|
||||
*
|
||||
* @since 0.1.4
|
||||
*/
|
||||
function wp_user_groups_admin_assets() {
|
||||
$url = wp_user_groups_get_plugin_url();
|
||||
$ver = wp_user_groups_get_asset_version();
|
||||
|
||||
wp_enqueue_style( 'wp_user_groups', $url. 'assets/css/user-groups.css', false, $ver, false );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add new section to User Profiles
|
||||
*
|
||||
* @since 0.1.9
|
||||
*
|
||||
* @param array $sections
|
||||
*/
|
||||
function wp_user_groups_add_profile_section( $sections = array() ) {
|
||||
|
||||
// Copy for modifying
|
||||
$new_sections = $sections;
|
||||
|
||||
// Add the "Activity" section
|
||||
$new_sections['groups'] = array(
|
||||
'id' => 'groups',
|
||||
'slug' => 'groups',
|
||||
'name' => esc_html__( 'Groups', 'wp-user-activity' ),
|
||||
'cap' => 'edit_profile',
|
||||
'icon' => 'dashicons-groups',
|
||||
'order' => 90
|
||||
);
|
||||
|
||||
// Filter & return
|
||||
return apply_filters( 'wp_user_groups_add_profile_section', $new_sections, $sections );
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User Groups Functions
|
||||
*
|
||||
* @package Plugins/Users/Groups/Functions
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Get terms for a user and a taxonomy
|
||||
*
|
||||
* @since 0.1.0
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param int $taxonomy
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function wp_get_terms_for_user( $user = false, $taxonomy = '' ) {
|
||||
|
||||
// Verify user ID
|
||||
$user_id = is_object( $user )
|
||||
? $user->ID
|
||||
: absint( $user );
|
||||
|
||||
// Bail if empty
|
||||
if ( empty( $user_id ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return user terms
|
||||
return wp_get_object_terms( $user_id, $taxonomy, array(
|
||||
'fields' => 'all_with_object_id'
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save taxonomy terms for a specific user
|
||||
*
|
||||
* @since 0.1.0
|
||||
*
|
||||
* @param int $user_id
|
||||
* @param string $taxonomy
|
||||
* @param array $terms
|
||||
* @param boolean $bulk
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function wp_set_terms_for_user( $user_id, $taxonomy, $terms = array(), $bulk = false ) {
|
||||
|
||||
// Get the taxonomy
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
|
||||
// Make sure the current user can edit the user and assign terms before proceeding.
|
||||
if ( ! current_user_can( 'edit_user', $user_id ) || ! current_user_can( $tax->cap->assign_terms ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $terms ) && empty( $bulk ) ) {
|
||||
$terms = isset( $_POST[ $taxonomy ] )
|
||||
? $_POST[ $taxonomy ]
|
||||
: null;
|
||||
}
|
||||
|
||||
// Delete all user terms
|
||||
if ( is_null( $terms ) || empty( $terms ) ) {
|
||||
wp_delete_object_term_relationships( $user_id, $taxonomy );
|
||||
|
||||
// Set the terms
|
||||
} else {
|
||||
$_terms = array_map( 'sanitize_key', $terms );
|
||||
|
||||
// Sets the terms for the user
|
||||
wp_set_object_terms( $user_id, $_terms, $taxonomy, false );
|
||||
}
|
||||
|
||||
// Clean the cache
|
||||
clean_object_term_cache( $user_id, $taxonomy );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all user groups
|
||||
*
|
||||
* @uses get_taxonomies() To get user-group taxonomies
|
||||
*
|
||||
* @since 0.1.5
|
||||
*
|
||||
* @param array $args Optional. An array of `key => value` arguments to
|
||||
* match against the taxonomy objects. Default empty array.
|
||||
* @param string $output Optional. The type of output to return in the array.
|
||||
* Accepts either taxonomy 'names' or 'objects'. Default 'names'.
|
||||
* @param string $operator Optional. The logical operation to perform.
|
||||
* Accepts 'and' or 'or'. 'or' means only one element from
|
||||
* the array needs to match; 'and' means all elements must
|
||||
* match. Default 'and'.
|
||||
*
|
||||
* @return array A list of taxonomy names or objects.
|
||||
*/
|
||||
function wp_get_user_groups( $args = array(), $output = 'names', $operator = 'and' ) {
|
||||
|
||||
// Parse arguments
|
||||
$r = wp_parse_args( $args, array(
|
||||
'user_group' => true
|
||||
) );
|
||||
|
||||
// Return user group taxonomies
|
||||
return get_taxonomies( $r, $output, $operator );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all user group objects
|
||||
*
|
||||
* @uses wp_get_user_groups() To get user group objects
|
||||
*
|
||||
* @since 0.1.5
|
||||
*
|
||||
* @param array $args See wp_get_user_groups()
|
||||
* @param string $operator See wp_get_user_groups()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wp_get_user_group_objects( $args = array(), $operator = 'and' ) {
|
||||
return wp_get_user_groups( $args, 'objects', $operator );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of users in a specific group
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
function wp_get_users_of_group( $args = array() ) {
|
||||
|
||||
// Parse arguments
|
||||
$r = wp_parse_args( $args, array(
|
||||
'taxonomy' => 'user-group',
|
||||
'term' => '',
|
||||
'term_by' => 'slug'
|
||||
) );
|
||||
|
||||
// Get user IDs in group
|
||||
$term = get_term_by( $r['term_by'], $r['term'], $r['taxonomy'] );
|
||||
$user_ids = get_objects_in_term( $term->term_id, $r['taxonomy'] );
|
||||
|
||||
// Bail if no users in this term
|
||||
if ( empty( $term ) || empty( $user_ids ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Return queried users
|
||||
return get_users( array(
|
||||
'orderby' => 'display_name',
|
||||
'include' => $user_ids,
|
||||
) );
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User Groups Hooks
|
||||
*
|
||||
* @package Plugins/Users/Groups/Hooks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
// Register the default taxonomies
|
||||
add_action( 'init', 'wp_register_default_user_group_taxonomy' );
|
||||
add_action( 'init', 'wp_register_default_user_type_taxonomy' );
|
||||
|
||||
// Enqueue assets
|
||||
add_action( 'admin_head', 'wp_user_groups_admin_assets' );
|
||||
|
||||
// WP User Profiles
|
||||
add_filter( 'wp_user_profiles_sections', 'wp_user_groups_add_profile_section' );
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User Groups Taxonomies
|
||||
*
|
||||
* @package Plugins/Users/Groups/Taxonomy
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Register default user group taxonomies
|
||||
*
|
||||
* This function is hooked onto WordPress's `init` action and creates two new
|
||||
* `WP_User_Taxonomy` objects for user "groups" and "types". It can be unhooked
|
||||
* and these taxonomies can be replaced with your own custom ones.
|
||||
*
|
||||
* @since 0.1.4
|
||||
*/
|
||||
function wp_register_default_user_group_taxonomy() {
|
||||
new WP_User_Taxonomy( 'user-group', 'users/group', array(
|
||||
'singular' => __( 'Group', 'wp-user-groups' ),
|
||||
'plural' => __( 'Groups', 'wp-user-groups' )
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register default user group taxonomies
|
||||
*
|
||||
* This function is hooked onto WordPress's `init` action and creates two new
|
||||
* `WP_User_Taxonomy` objects for user "groups" and "types". It can be unhooked
|
||||
* and these taxonomies can be replaced with your own custom ones.
|
||||
*
|
||||
* @since 0.1.4
|
||||
*/
|
||||
function wp_register_default_user_type_taxonomy() {
|
||||
new WP_User_Taxonomy( 'user-type', 'users/type', array(
|
||||
'singular' => __( 'Type', 'wp-user-groups' ),
|
||||
'plural' => __( 'Types', 'wp-user-groups' )
|
||||
) );
|
||||
}
|
||||
Reference in New Issue
Block a user