Version Description
Download this release
Release Info
Developer | itthinx |
Plugin | Groups |
Version | 2.9.0 |
Comparing to | |
See all releases |
Code changes from version 2.8.0 to 2.9.0
- changelog.txt +6 -0
- groups.php +2 -2
- lib/access/class-groups-comment-access.php +4 -2
- lib/admin/groups-admin-groups.php +22 -2
- lib/core/class-groups-cache-object.php +2 -1
- lib/core/class-groups-capability.php +8 -5
- lib/core/class-groups-controller.php +4 -2
- lib/core/class-groups-group.php +6 -3
- lib/core/class-groups-options.php +4 -2
- lib/core/class-groups-user-group.php +3 -2
- lib/core/class-groups-utility.php +5 -2
- lib/views/class-groups-shortcodes.php +6 -3
- readme.txt +2 -2
changelog.txt
CHANGED
@@ -1,5 +1,11 @@
|
|
1 |
== Groups by itthinx - changelog.txt
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
= 2.8.0 =
|
4 |
* Added the Groups Members block: A block whose content is only visible for members of selected groups.
|
5 |
* Added the Groups Non-Members block: a block whose content is hidden for members of chosen groups.
|
1 |
== Groups by itthinx - changelog.txt
|
2 |
|
3 |
+
= 2.9.0 =
|
4 |
+
* WordPress 5.3 compatible.
|
5 |
+
* Added member counts displayed for each group under Groups > Groups.
|
6 |
+
* Fixed issues with and added missing internal code documentation mainly related to undocumented types.
|
7 |
+
* Guarded against errors in a utility function for comparison of capabilities when the comparison is made against non-objects.
|
8 |
+
|
9 |
= 2.8.0 =
|
10 |
* Added the Groups Members block: A block whose content is only visible for members of selected groups.
|
11 |
* Added the Groups Non-Members block: a block whose content is hidden for members of chosen groups.
|
groups.php
CHANGED
@@ -21,7 +21,7 @@
|
|
21 |
* Plugin Name: Groups
|
22 |
* Plugin URI: http://www.itthinx.com/plugins/groups
|
23 |
* Description: Groups provides group-based user membership management, group-based capabilities and content access control.
|
24 |
-
* Version: 2.
|
25 |
* Author: itthinx
|
26 |
* Author URI: http://www.itthinx.com
|
27 |
* Donate-Link: http://www.itthinx.com
|
@@ -32,7 +32,7 @@
|
|
32 |
if ( !defined( 'ABSPATH' ) ) {
|
33 |
exit;
|
34 |
}
|
35 |
-
define( 'GROUPS_CORE_VERSION', '2.
|
36 |
define( 'GROUPS_FILE', __FILE__ );
|
37 |
if ( !defined( 'GROUPS_CORE_DIR' ) ) {
|
38 |
define( 'GROUPS_CORE_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
|
21 |
* Plugin Name: Groups
|
22 |
* Plugin URI: http://www.itthinx.com/plugins/groups
|
23 |
* Description: Groups provides group-based user membership management, group-based capabilities and content access control.
|
24 |
+
* Version: 2.9.0
|
25 |
* Author: itthinx
|
26 |
* Author URI: http://www.itthinx.com
|
27 |
* Donate-Link: http://www.itthinx.com
|
32 |
if ( !defined( 'ABSPATH' ) ) {
|
33 |
exit;
|
34 |
}
|
35 |
+
define( 'GROUPS_CORE_VERSION', '2.9.0' );
|
36 |
define( 'GROUPS_FILE', __FILE__ );
|
37 |
if ( !defined( 'GROUPS_CORE_DIR' ) ) {
|
38 |
define( 'GROUPS_CORE_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
|
lib/access/class-groups-comment-access.php
CHANGED
@@ -117,6 +117,7 @@ class Groups_Comment_Access {
|
|
117 |
*
|
118 |
* @param array $pieces
|
119 |
* @param WP_Comment_Query $comment_query
|
|
|
120 |
* @return array
|
121 |
*/
|
122 |
public static function comments_clauses( $pieces, $comment_query ) {
|
@@ -142,8 +143,9 @@ class Groups_Comment_Access {
|
|
142 |
/**
|
143 |
* Adds conditions to $where to restrict comment access.
|
144 |
*
|
145 |
-
* @param
|
146 |
-
*
|
|
|
147 |
*/
|
148 |
private static function build_where( $where ) {
|
149 |
|
117 |
*
|
118 |
* @param array $pieces
|
119 |
* @param WP_Comment_Query $comment_query
|
120 |
+
*
|
121 |
* @return array
|
122 |
*/
|
123 |
public static function comments_clauses( $pieces, $comment_query ) {
|
143 |
/**
|
144 |
* Adds conditions to $where to restrict comment access.
|
145 |
*
|
146 |
+
* @param string $where
|
147 |
+
*
|
148 |
+
* @return string
|
149 |
*/
|
150 |
private static function build_where( $where ) {
|
151 |
|
lib/admin/groups-admin-groups.php
CHANGED
@@ -431,6 +431,11 @@ function groups_admin_groups() {
|
|
431 |
|
432 |
$result = $results[$i];
|
433 |
|
|
|
|
|
|
|
|
|
|
|
434 |
// Construct the "edit" URL.
|
435 |
$edit_url = add_query_arg(
|
436 |
array(
|
@@ -451,6 +456,11 @@ function groups_admin_groups() {
|
|
451 |
$current_url
|
452 |
);
|
453 |
|
|
|
|
|
|
|
|
|
|
|
454 |
// Construct row actions for this group.
|
455 |
$row_actions =
|
456 |
'<div class="row-actions">' .
|
@@ -482,7 +492,18 @@ function groups_admin_groups() {
|
|
482 |
$output .= $result->group_id;
|
483 |
$output .= '</td>';
|
484 |
$output .= '<td class="group-name">';
|
485 |
-
$output .= sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
$output .= $row_actions;
|
487 |
$output .= '</td>';
|
488 |
$output .= '<td class="group-description">';
|
@@ -491,7 +512,6 @@ function groups_admin_groups() {
|
|
491 |
|
492 |
$output .= '<td class="capabilities">';
|
493 |
|
494 |
-
$group = new Groups_Group( $result->group_id );
|
495 |
$group_capabilities = $group->capabilities;
|
496 |
$group_capabilities_deep = $group->capabilities_deep;
|
497 |
usort( $group_capabilities_deep, array( 'Groups_Utility', 'cmp' ) );
|
431 |
|
432 |
$result = $results[$i];
|
433 |
|
434 |
+
/**
|
435 |
+
* @var Groups_Group
|
436 |
+
*/
|
437 |
+
$group = new Groups_Group( $result->group_id );
|
438 |
+
|
439 |
// Construct the "edit" URL.
|
440 |
$edit_url = add_query_arg(
|
441 |
array(
|
456 |
$current_url
|
457 |
);
|
458 |
|
459 |
+
$users_url = add_query_arg(
|
460 |
+
array( 'filter_group_ids[0]' => intval( $result->group_id ) ),
|
461 |
+
admin_url( 'users.php' )
|
462 |
+
);
|
463 |
+
|
464 |
// Construct row actions for this group.
|
465 |
$row_actions =
|
466 |
'<div class="row-actions">' .
|
492 |
$output .= $result->group_id;
|
493 |
$output .= '</td>';
|
494 |
$output .= '<td class="group-name">';
|
495 |
+
$output .= sprintf(
|
496 |
+
'<a href="%s">%s</a>',
|
497 |
+
esc_url( $edit_url ),
|
498 |
+
stripslashes( wp_filter_nohtml_kses( $result->name ) )
|
499 |
+
);
|
500 |
+
$output .= ' ';
|
501 |
+
$user_count = is_array( $group->user_ids ) ? count( $group->user_ids ) : 0; // guard against null when there are no users
|
502 |
+
$output .= sprintf(
|
503 |
+
'(<a href="%s">%s</a>)',
|
504 |
+
esc_url( $users_url ),
|
505 |
+
$user_count
|
506 |
+
);
|
507 |
$output .= $row_actions;
|
508 |
$output .= '</td>';
|
509 |
$output .= '<td class="group-description">';
|
512 |
|
513 |
$output .= '<td class="capabilities">';
|
514 |
|
|
|
515 |
$group_capabilities = $group->capabilities;
|
516 |
$group_capabilities_deep = $group->capabilities_deep;
|
517 |
usort( $group_capabilities_deep, array( 'Groups_Utility', 'cmp' ) );
|
lib/core/class-groups-cache-object.php
CHANGED
@@ -58,7 +58,8 @@ class Groups_Cache_Object {
|
|
58 |
* Getter implementation for key and value properties.
|
59 |
*
|
60 |
* @param string $name
|
61 |
-
*
|
|
|
62 |
*/
|
63 |
public function __get( $name ) {
|
64 |
$result = null;
|
58 |
* Getter implementation for key and value properties.
|
59 |
*
|
60 |
* @param string $name
|
61 |
+
*
|
62 |
+
* @return mixed property value or null
|
63 |
*/
|
64 |
public function __get( $name ) {
|
65 |
$result = null;
|
lib/core/class-groups-capability.php
CHANGED
@@ -33,7 +33,7 @@ class Groups_Capability {
|
|
33 |
const READ_CAPABILITY_BY_ID = 'read_capability_by_id';
|
34 |
|
35 |
/**
|
36 |
-
* @var persisted capability object
|
37 |
*/
|
38 |
var $capability = null;
|
39 |
|
@@ -60,7 +60,7 @@ class Groups_Capability {
|
|
60 |
* - group_ids groups that have the capability
|
61 |
*
|
62 |
* @param string $name property's name
|
63 |
-
* @return property value, will return null if property does not exist
|
64 |
*/
|
65 |
public function __get( $name ) {
|
66 |
|
@@ -120,7 +120,8 @@ class Groups_Capability {
|
|
120 |
* - "description" (optional) - dito
|
121 |
*
|
122 |
* @param array $map attributes, requires at least: "capability"
|
123 |
-
*
|
|
|
124 |
*/
|
125 |
public static function create( $map ) {
|
126 |
|
@@ -228,7 +229,8 @@ class Groups_Capability {
|
|
228 |
* Update capability.
|
229 |
*
|
230 |
* @param array $map capability attribute, must contain capability_id
|
231 |
-
*
|
|
|
232 |
*/
|
233 |
public static function update( $map ) {
|
234 |
|
@@ -285,7 +287,8 @@ class Groups_Capability {
|
|
285 |
* Remove capability and its relations.
|
286 |
*
|
287 |
* @param int $capability_id
|
288 |
-
*
|
|
|
289 |
*/
|
290 |
public static function delete( $capability_id ) {
|
291 |
|
33 |
const READ_CAPABILITY_BY_ID = 'read_capability_by_id';
|
34 |
|
35 |
/**
|
36 |
+
* @var object persisted capability object
|
37 |
*/
|
38 |
var $capability = null;
|
39 |
|
60 |
* - group_ids groups that have the capability
|
61 |
*
|
62 |
* @param string $name property's name
|
63 |
+
* @return mixed property value, will return null if property does not exist
|
64 |
*/
|
65 |
public function __get( $name ) {
|
66 |
|
120 |
* - "description" (optional) - dito
|
121 |
*
|
122 |
* @param array $map attributes, requires at least: "capability"
|
123 |
+
*
|
124 |
+
* @return int capability_id on success, otherwise false
|
125 |
*/
|
126 |
public static function create( $map ) {
|
127 |
|
229 |
* Update capability.
|
230 |
*
|
231 |
* @param array $map capability attribute, must contain capability_id
|
232 |
+
*
|
233 |
+
* @return int capability_id on success, otherwise false
|
234 |
*/
|
235 |
public static function update( $map ) {
|
236 |
|
287 |
* Remove capability and its relations.
|
288 |
*
|
289 |
* @param int $capability_id
|
290 |
+
*
|
291 |
+
* @return int capability_id if successful, false otherwise
|
292 |
*/
|
293 |
public static function delete( $capability_id ) {
|
294 |
|
lib/core/class-groups-controller.php
CHANGED
@@ -422,7 +422,8 @@ class Groups_Controller {
|
|
422 |
|
423 |
/**
|
424 |
* Plugin deactivation cleanup.
|
425 |
-
*
|
|
|
426 |
*/
|
427 |
private static function cleanup( $drop = false ) {
|
428 |
|
@@ -574,7 +575,8 @@ class Groups_Controller {
|
|
574 |
*
|
575 |
* @see sem_remove()
|
576 |
*
|
577 |
-
* @param
|
|
|
578 |
* @return boolean
|
579 |
*/
|
580 |
private static function sem_remove( $sem_identifier ) {
|
422 |
|
423 |
/**
|
424 |
* Plugin deactivation cleanup.
|
425 |
+
*
|
426 |
+
* @param $drop boolean overrides the groups_delete_data option, default is false
|
427 |
*/
|
428 |
private static function cleanup( $drop = false ) {
|
429 |
|
575 |
*
|
576 |
* @see sem_remove()
|
577 |
*
|
578 |
+
* @param resource $sem_identifier
|
579 |
+
*
|
580 |
* @return boolean
|
581 |
*/
|
582 |
private static function sem_remove( $sem_identifier ) {
|
lib/core/class-groups-group.php
CHANGED
@@ -249,7 +249,8 @@ class Groups_Group implements I_Capable {
|
|
249 |
* - parent_id (optional)
|
250 |
*
|
251 |
* @param array $map attributes
|
252 |
-
*
|
|
|
253 |
*/
|
254 |
public static function create( $map ) {
|
255 |
global $wpdb;
|
@@ -370,7 +371,8 @@ class Groups_Group implements I_Capable {
|
|
370 |
* Update group.
|
371 |
*
|
372 |
* @param array $map group attribute, must contain group_id
|
373 |
-
*
|
|
|
374 |
*/
|
375 |
public static function update( $map ) {
|
376 |
|
@@ -462,7 +464,8 @@ class Groups_Group implements I_Capable {
|
|
462 |
* Remove group and its relations.
|
463 |
*
|
464 |
* @param int $group_id
|
465 |
-
*
|
|
|
466 |
*/
|
467 |
public static function delete( $group_id ) {
|
468 |
|
249 |
* - parent_id (optional)
|
250 |
*
|
251 |
* @param array $map attributes
|
252 |
+
*
|
253 |
+
* @return int group_id on success, otherwise false
|
254 |
*/
|
255 |
public static function create( $map ) {
|
256 |
global $wpdb;
|
371 |
* Update group.
|
372 |
*
|
373 |
* @param array $map group attribute, must contain group_id
|
374 |
+
*
|
375 |
+
* @return int group_id on success, otherwise false
|
376 |
*/
|
377 |
public static function update( $map ) {
|
378 |
|
464 |
* Remove group and its relations.
|
465 |
*
|
466 |
* @param int $group_id
|
467 |
+
*
|
468 |
+
* @return int group_id if successful, false otherwise
|
469 |
*/
|
470 |
public static function delete( $group_id ) {
|
471 |
|
lib/core/class-groups-options.php
CHANGED
@@ -90,7 +90,8 @@ class Groups_Options {
|
|
90 |
*
|
91 |
* @param string $option the option id
|
92 |
* @param mixed $default default value to retrieve if option is not set
|
93 |
-
*
|
|
|
94 |
*/
|
95 |
public static function get_option( $option, $default = null ) {
|
96 |
$options = self::get_options();
|
@@ -108,7 +109,8 @@ class Groups_Options {
|
|
108 |
* @param string $option the option id
|
109 |
* @param mixed $default default value to retrieve if option is not set
|
110 |
* @param int $user_id retrieve option for this user, defaults to null for current user
|
111 |
-
*
|
|
|
112 |
*/
|
113 |
public static function get_user_option( $option, $default = null, $user_id = null ) {
|
114 |
if ( $user_id === null ) {
|
90 |
*
|
91 |
* @param string $option the option id
|
92 |
* @param mixed $default default value to retrieve if option is not set
|
93 |
+
*
|
94 |
+
* @return mixed option value, $default if set or null
|
95 |
*/
|
96 |
public static function get_option( $option, $default = null ) {
|
97 |
$options = self::get_options();
|
109 |
* @param string $option the option id
|
110 |
* @param mixed $default default value to retrieve if option is not set
|
111 |
* @param int $user_id retrieve option for this user, defaults to null for current user
|
112 |
+
*
|
113 |
+
* @return mixed option value, $default if set or null
|
114 |
*/
|
115 |
public static function get_user_option( $option, $default = null, $user_id = null ) {
|
116 |
if ( $user_id === null ) {
|
lib/core/class-groups-user-group.php
CHANGED
@@ -29,7 +29,7 @@ if ( !defined( 'ABSPATH' ) ) {
|
|
29 |
class Groups_User_Group {
|
30 |
|
31 |
/**
|
32 |
-
* @var persisted object
|
33 |
*/
|
34 |
var $user_group = null;
|
35 |
|
@@ -66,7 +66,8 @@ class Groups_User_Group {
|
|
66 |
* - group_id
|
67 |
*
|
68 |
* @param string $name property's name
|
69 |
-
*
|
|
|
70 |
*/
|
71 |
public function __get( $name ) {
|
72 |
$result = null;
|
29 |
class Groups_User_Group {
|
30 |
|
31 |
/**
|
32 |
+
* @var object persisted object
|
33 |
*/
|
34 |
var $user_group = null;
|
35 |
|
66 |
* - group_id
|
67 |
*
|
68 |
* @param string $name property's name
|
69 |
+
*
|
70 |
+
* @return mixed property value, will return null if property does not exist
|
71 |
*/
|
72 |
public function __get( $name ) {
|
73 |
$result = null;
|
lib/core/class-groups-utility.php
CHANGED
@@ -120,9 +120,10 @@ class Groups_Utility {
|
|
120 |
* Compares the two object's names, used for groups and
|
121 |
* capabilities, i.e. Groups_Group and Groups_Capability can be compared
|
122 |
* if both are of the same class. Otherwise this will return 0.
|
123 |
-
*
|
124 |
* @param Groups_Group|Groups_Capability $o1
|
125 |
* @param Groups_Group|Groups_Capability $o2 must match the class of $o1
|
|
|
126 |
* @return number
|
127 |
*/
|
128 |
public static function cmp( $o1, $o2 ) {
|
@@ -130,7 +131,9 @@ class Groups_Utility {
|
|
130 |
if ( $o1 instanceof Groups_Group && $o2 instanceof Groups_Group ) {
|
131 |
$result = strcmp( $o1->name, $o2->name );
|
132 |
} else if ( $o1 instanceof Groups_Capability && $o2 instanceof Groups_Capability ) {
|
133 |
-
$
|
|
|
|
|
134 |
}
|
135 |
return $result;
|
136 |
}
|
120 |
* Compares the two object's names, used for groups and
|
121 |
* capabilities, i.e. Groups_Group and Groups_Capability can be compared
|
122 |
* if both are of the same class. Otherwise this will return 0.
|
123 |
+
*
|
124 |
* @param Groups_Group|Groups_Capability $o1
|
125 |
* @param Groups_Group|Groups_Capability $o2 must match the class of $o1
|
126 |
+
*
|
127 |
* @return number
|
128 |
*/
|
129 |
public static function cmp( $o1, $o2 ) {
|
131 |
if ( $o1 instanceof Groups_Group && $o2 instanceof Groups_Group ) {
|
132 |
$result = strcmp( $o1->name, $o2->name );
|
133 |
} else if ( $o1 instanceof Groups_Capability && $o2 instanceof Groups_Capability ) {
|
134 |
+
$c1 = is_object( $o1->capability ) && isset( $o1->capability->capability ) ? $o1->capability->capability : '';
|
135 |
+
$c2 = is_object( $o2->capability ) && isset( $o2->capability->capability ) ? $o2->capability->capability : '';
|
136 |
+
$result = strcmp( $c1, $c2 );
|
137 |
}
|
138 |
return $result;
|
139 |
}
|
lib/views/class-groups-shortcodes.php
CHANGED
@@ -135,7 +135,8 @@ class Groups_Shortcodes {
|
|
135 |
*
|
136 |
* @param array $atts attributes
|
137 |
* @param string $content content to render
|
138 |
-
*
|
|
|
139 |
*/
|
140 |
public static function groups_group_info( $atts, $content = null ) {
|
141 |
global $wpdb;
|
@@ -209,7 +210,8 @@ class Groups_Shortcodes {
|
|
209 |
*
|
210 |
* @param array $atts attributes
|
211 |
* @param string $content not used
|
212 |
-
*
|
|
|
213 |
*/
|
214 |
public static function groups_user_groups( $atts, $content = null ) {
|
215 |
$output = '';
|
@@ -373,7 +375,8 @@ class Groups_Shortcodes {
|
|
373 |
*
|
374 |
* @param array $atts attributes
|
375 |
* @param string $content not used
|
376 |
-
*
|
|
|
377 |
*/
|
378 |
public static function groups_groups( $atts, $content = null ) {
|
379 |
global $wpdb;
|
135 |
*
|
136 |
* @param array $atts attributes
|
137 |
* @param string $content content to render
|
138 |
+
*
|
139 |
+
* @return string rendered information
|
140 |
*/
|
141 |
public static function groups_group_info( $atts, $content = null ) {
|
142 |
global $wpdb;
|
210 |
*
|
211 |
* @param array $atts attributes
|
212 |
* @param string $content not used
|
213 |
+
*
|
214 |
+
* @return string rendered groups for current user
|
215 |
*/
|
216 |
public static function groups_user_groups( $atts, $content = null ) {
|
217 |
$output = '';
|
375 |
*
|
376 |
* @param array $atts attributes
|
377 |
* @param string $content not used
|
378 |
+
*
|
379 |
+
* @return string rendered groups
|
380 |
*/
|
381 |
public static function groups_groups( $atts, $content = null ) {
|
382 |
global $wpdb;
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: itthinx, proaktion
|
|
3 |
Donate link: http://www.itthinx.com/plugins/groups
|
4 |
Tags: groups, access, access control, membership, memberships, member, members, capability, capabilities, content, download, downloads, file, file access, files, paypal, permission, permissions, subscription, subscriptions, woocommerce
|
5 |
Requires at least: 4.6
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 5.6.0
|
8 |
-
Stable tag: 2.
|
9 |
License: GPLv3
|
10 |
|
11 |
Groups is an efficient and powerful solution, providing group-based user membership management, group-based capabilities and content access control.
|
3 |
Donate link: http://www.itthinx.com/plugins/groups
|
4 |
Tags: groups, access, access control, membership, memberships, member, members, capability, capabilities, content, download, downloads, file, file access, files, paypal, permission, permissions, subscription, subscriptions, woocommerce
|
5 |
Requires at least: 4.6
|
6 |
+
Tested up to: 5.3
|
7 |
Requires PHP: 5.6.0
|
8 |
+
Stable tag: 2.9.0
|
9 |
License: GPLv3
|
10 |
|
11 |
Groups is an efficient and powerful solution, providing group-based user membership management, group-based capabilities and content access control.
|