Commit a2884658 authored by John James Jacoby's avatar John James Jacoby
Browse files

Add `user-group` property to taxonomies.

Also add convenience functions for getting user-groups (and their objects) from WordPress's taxonomy global.

This makes it much easier to work with user-groups in third party code, as it's now possible to use WordPress's internal taxonomy register to retrieve which taxonomies are grouping users together instead of posts.

Also bump to 0.1.5.
parent c64ab9d5
Pipeline #4 skipped
......@@ -542,6 +542,7 @@ class WP_User_Taxonomy {
*/
protected function parse_options() {
return wp_parse_args( $this->args, array(
'user_group' => true, // Custom
'hierarchical' => true,
'public' => false,
'show_ui' => true,
......
......@@ -80,3 +80,48 @@ function wp_set_terms_for_user( $user_id, $taxonomy, $terms = array(), $bulk = f
// 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 );
}
......@@ -2,8 +2,8 @@
Contributors: johnjamesjacoby, stuttter
Tags: taxonomy, term, user, group, type
Requires at least: 4.3
Tested up to: 4.3
Stable tag: 0.1.4
Tested up to: 4.4
Stable tag: 0.1.5
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
......@@ -28,6 +28,7 @@ Also checkout:
* [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 Event Calendar](https://wordpress.org/plugins/wp-event-calendar/ "Flexible events, with a calendar view.")
* [WP User Activity](https://wordpress.org/plugins/wp-user-activity/ "The best way to log activity in WordPress.")
== Screenshots ==
......@@ -65,10 +66,14 @@ The WordPress support forums: https://wordpress.org/plugin/support/wp-user-group
= Where can I find documentation? =
http://github.com/johnjamesjacoby/wp-user-groups/
http://github.com/stuttter/wp-user-groups/
== Changelog ==
= 0.1.5 =
* Added `user_group` property to taxonomies
* Added functions for retrieving only user-groups from taxonomies global
= 0.1.4 =
* Refactor
* Improve asset management
......
......@@ -5,7 +5,7 @@
* Plugin URI: https://wordpress.org/plugins/wp-user-groups/
* Description: Group users together with taxonomies & terms.
* Author: John James Jacoby
* Version: 0.1.4
* Version: 0.1.5
* Author URI: https://profiles.wordpress.org/johnjamesjacoby/
* License: GPL v2 or later
*/
......@@ -51,5 +51,5 @@ function wp_user_groups_get_plugin_url() {
* @return int
*/
function wp_user_groups_get_asset_version() {
return 201509250001;
return 201510130001;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment