diff --git a/includes/class-user-taxonomy.php b/includes/class-user-taxonomy.php index 114e8c13b01d413dcd87a169ab13400d076ece50..a57ef9cf084f00c5b6ec22c67bdd3526012352ba 100644 --- a/includes/class-user-taxonomy.php +++ b/includes/class-user-taxonomy.php @@ -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, diff --git a/includes/functions.php b/includes/functions.php index 75edaa97b4006b7968ca8899aa427310112465b2..62a7b2fa8d1e3c7323063b5d1c46fc5aa8d35b48 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -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 ); +} diff --git a/readme.txt b/readme.txt index beb2bfebe50417684f66a0a8ac6f75d7991a8fba..46fb2f98a9fb7530223a9a88ca6f793cb2722765 100644 --- a/readme.txt +++ b/readme.txt @@ -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 diff --git a/wp-user-groups.php b/wp-user-groups.php index 24d3f5b5f98957d1cb48bf285ed707cfbe2c4d7d..71f86242d300fc2c9c1c0a228d6b80c18c6ab2bf 100644 --- a/wp-user-groups.php +++ b/wp-user-groups.php @@ -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; }