Version Description
- Fixed several points where warnings related to the use of count() and the Countable interface would occur due to changes in PHP 7.2.
- Tested with WordPress 4.9.
- Added the groups_post_access_posts_where_query_get_post_types filter to allow additional processing to cover for cases like where wc_query is set.
- Fixed a notice related to the use of an undefined variable in the Groups_Post_Access class.
- Added the logo and the option to get reminded later to the Groups notice.
- Added filters on get_previous_post_where and get_next_post_where to restrict access on adjacent posts.
Download this release
Release Info
Developer | itthinx |
Plugin | Groups |
Version | 2.3.1 |
Comparing to | |
See all releases |
Code changes from version 2.3.0 to 2.3.1
- COPYRIGHT.txt +1 -1
- changelog.txt +9 -0
- groups.php +3 -3
- lib/access/class-groups-post-access.php +58 -6
- lib/admin/class-groups-admin-notice.php +46 -8
- lib/admin/groups-admin-groups-edit.php +6 -1
- lib/core/class-groups-group.php +4 -4
- lib/extra/class-groups-extra.php +24 -0
- readme.txt +13 -8
COPYRIGHT.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
|
2 |
Groups
|
3 |
|
4 |
-
Copyright 2011-
|
5 |
|
6 |
The files COPYRIGHT.txt and LICENSE.txt as well as ALL NOTICES IN THE
|
7 |
HEADERS OF ALL FILES MUST BE KEPT INTACT.
|
1 |
|
2 |
Groups
|
3 |
|
4 |
+
Copyright 2011-2018 "kento" (Karim Rahimpur) www.itthinx.com
|
5 |
|
6 |
The files COPYRIGHT.txt and LICENSE.txt as well as ALL NOTICES IN THE
|
7 |
HEADERS OF ALL FILES MUST BE KEPT INTACT.
|
changelog.txt
CHANGED
@@ -1,5 +1,14 @@
|
|
1 |
== Groups by itthinx - changelog.txt ==
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
= 2.3.0 =
|
4 |
* Tested with WordPress 4.8.
|
5 |
* Fixed a REST API access restriction issue, added the filter rest_prepare_{$post_type} to
|
1 |
== Groups by itthinx - changelog.txt ==
|
2 |
|
3 |
+
= 2.3.1 =
|
4 |
+
* Fixed several points where warnings related to the use of count() and the Countable interface would occur due to changes in PHP 7.2.
|
5 |
+
* Tested with WordPress 4.9.
|
6 |
+
* Added the groups_post_access_posts_where_query_get_post_types filter to allow additional processing to cover for cases like where
|
7 |
+
wc_query is set.
|
8 |
+
* Fixed a notice related to the use of an undefined variable in the Groups_Post_Access class.
|
9 |
+
* Added the logo and the option to get reminded later to the Groups notice.
|
10 |
+
* Added filters on get_previous_post_where and get_next_post_where to restrict access on adjacent posts.
|
11 |
+
|
12 |
= 2.3.0 =
|
13 |
* Tested with WordPress 4.8.
|
14 |
* Fixed a REST API access restriction issue, added the filter rest_prepare_{$post_type} to
|
groups.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* groups.php
|
4 |
*
|
5 |
-
* Copyright (c) 2011-
|
6 |
*
|
7 |
* This code is released under the GNU General Public License.
|
8 |
* See COPYRIGHT.txt and LICENSE.txt.
|
@@ -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.3.
|
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.3.
|
36 |
define( 'GROUPS_FILE', __FILE__ );
|
37 |
if ( !defined( 'GROUPS_CORE_DIR' ) ) {
|
38 |
define( 'GROUPS_CORE_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
|
2 |
/**
|
3 |
* groups.php
|
4 |
*
|
5 |
+
* Copyright (c) 2011-2018 "kento" Karim Rahimpur www.itthinx.com
|
6 |
*
|
7 |
* This code is released under the GNU General Public License.
|
8 |
* See COPYRIGHT.txt and LICENSE.txt.
|
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.3.1
|
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.3.1' );
|
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-post-access.php
CHANGED
@@ -121,6 +121,10 @@ class Groups_Post_Access {
|
|
121 |
}
|
122 |
}
|
123 |
}
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
|
126 |
/**
|
@@ -188,7 +192,7 @@ class Groups_Post_Access {
|
|
188 |
if ( is_numeric( $args[0] ) ) {
|
189 |
$post_id = $args[0];
|
190 |
} else if ( $args[0] instanceof WP_Post ) {
|
191 |
-
$post_id = $
|
192 |
}
|
193 |
if ( $post_id ) {
|
194 |
if ( !self::user_can_read_post( $post_id, $user_id ) ) {
|
@@ -229,10 +233,15 @@ class Groups_Post_Access {
|
|
229 |
|
230 |
if ( !apply_filters( 'groups_post_access_posts_where_filter_all', false ) ) {
|
231 |
$filter = true;
|
232 |
-
$post_types =
|
|
|
|
|
|
|
|
|
|
|
233 |
if ( 'any' == $post_types ) {
|
234 |
// we need to filter in this case as it affects any post type
|
235 |
-
}
|
236 |
// if there is at least one post type we handle, we need to filter
|
237 |
$handled = 0;
|
238 |
$handles_post_types = self::get_handles_post_types();
|
@@ -242,11 +251,11 @@ class Groups_Post_Access {
|
|
242 |
}
|
243 |
}
|
244 |
$filter = $handled > 0;
|
245 |
-
}
|
246 |
$filter = self::handles_post_type( $post_types );
|
247 |
-
}
|
248 |
$filter = self::handles_post_type( 'attachment' );
|
249 |
-
}
|
250 |
$filter = self::handles_post_type( 'page' );
|
251 |
} else {
|
252 |
$filter = self::handles_post_type( 'post' );
|
@@ -436,6 +445,49 @@ class Groups_Post_Access {
|
|
436 |
return $result;
|
437 |
}
|
438 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
/**
|
440 |
* Adds an access requirement based on post_id and group_id.
|
441 |
*
|
121 |
}
|
122 |
}
|
123 |
}
|
124 |
+
|
125 |
+
// adjacent posts
|
126 |
+
add_filter( 'get_previous_post_where', array( __CLASS__, 'get_previous_post_where' ), 10, 5 );
|
127 |
+
add_filter( 'get_next_post_where', array( __CLASS__, 'get_next_post_where' ), 10, 5 );
|
128 |
}
|
129 |
|
130 |
/**
|
192 |
if ( is_numeric( $args[0] ) ) {
|
193 |
$post_id = $args[0];
|
194 |
} else if ( $args[0] instanceof WP_Post ) {
|
195 |
+
$post_id = $args[0]->ID;
|
196 |
}
|
197 |
if ( $post_id ) {
|
198 |
if ( !self::user_can_read_post( $post_id, $user_id ) ) {
|
233 |
|
234 |
if ( !apply_filters( 'groups_post_access_posts_where_filter_all', false ) ) {
|
235 |
$filter = true;
|
236 |
+
$post_types = apply_filters(
|
237 |
+
'groups_post_access_posts_where_query_get_post_types',
|
238 |
+
$query->get( 'post_type', null ),
|
239 |
+
$where,
|
240 |
+
$query
|
241 |
+
);
|
242 |
if ( 'any' == $post_types ) {
|
243 |
// we need to filter in this case as it affects any post type
|
244 |
+
} else if ( !empty( $post_types ) && is_array( $post_types ) ) {
|
245 |
// if there is at least one post type we handle, we need to filter
|
246 |
$handled = 0;
|
247 |
$handles_post_types = self::get_handles_post_types();
|
251 |
}
|
252 |
}
|
253 |
$filter = $handled > 0;
|
254 |
+
} else if ( !empty( $post_types ) && is_string( $post_types ) ) {
|
255 |
$filter = self::handles_post_type( $post_types );
|
256 |
+
} else if ( $query->is_attachment ) {
|
257 |
$filter = self::handles_post_type( 'attachment' );
|
258 |
+
} else if ( $query->is_page ) {
|
259 |
$filter = self::handles_post_type( 'page' );
|
260 |
} else {
|
261 |
$filter = self::handles_post_type( 'post' );
|
445 |
return $result;
|
446 |
}
|
447 |
|
448 |
+
/**
|
449 |
+
* Hooked on the get_{$adjacent}_post_where filter to remove restricted posts.
|
450 |
+
*
|
451 |
+
* @param string $where
|
452 |
+
* @param boolean $in_same_term
|
453 |
+
* @param array $excluded_terms
|
454 |
+
* @param string $taxonomy
|
455 |
+
* @param WP_Post $post
|
456 |
+
*
|
457 |
+
* @return string $where modified if appropriate
|
458 |
+
*/
|
459 |
+
public static function get_previous_post_where( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) {
|
460 |
+
return self::get_next_post_where( $where, $in_same_term, $excluded_terms, $taxonomy, $post );
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Hooked on the get_{$adjacent}_post_where filter to remove restricted posts.
|
465 |
+
*
|
466 |
+
* @param string $where
|
467 |
+
* @param boolean $in_same_term
|
468 |
+
* @param array $excluded_terms
|
469 |
+
* @param string $taxonomy
|
470 |
+
* @param WP_Post $post
|
471 |
+
*
|
472 |
+
* @return string $where modified if appropriate
|
473 |
+
*/
|
474 |
+
public static function get_next_post_where( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) {
|
475 |
+
if ( !empty( $post ) ) {
|
476 |
+
// run it through get_posts with suppress_filters set to false so that our posts_where filter is applied and assures only accessible posts are seen
|
477 |
+
$post_ids = get_posts( array( 'post_type' => $post->post_type, 'numberposts' => -1, 'suppress_filters' => false, 'fields' => 'ids' ) );
|
478 |
+
if ( is_array( $post_ids ) && count( $post_ids ) > 0 ) {
|
479 |
+
$post_ids = array_map( 'intval', $post_ids );
|
480 |
+
$condition = ' p.ID IN (' . implode( ',', $post_ids ) . ') ';
|
481 |
+
if ( !empty( $where ) ) {
|
482 |
+
$where .= ' AND ' . $condition;
|
483 |
+
} else {
|
484 |
+
$where = ' WHERE ' . $condition;
|
485 |
+
}
|
486 |
+
}
|
487 |
+
}
|
488 |
+
return $where;
|
489 |
+
}
|
490 |
+
|
491 |
/**
|
492 |
* Adds an access requirement based on post_id and group_id.
|
493 |
*
|
lib/admin/class-groups-admin-notice.php
CHANGED
@@ -42,6 +42,13 @@ class Groups_Admin_Notice {
|
|
42 |
*/
|
43 |
const HIDE_REVIEW_NOTICE = 'groups-hide-review-notice';
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
/**
|
46 |
* The number of seconds in seven days, since init date to show the notice.
|
47 |
*
|
@@ -49,6 +56,13 @@ class Groups_Admin_Notice {
|
|
49 |
*/
|
50 |
const SHOW_LAPSE = 604800;
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
/**
|
53 |
* Adds actions.
|
54 |
*/
|
@@ -62,14 +76,20 @@ class Groups_Admin_Notice {
|
|
62 |
public static function admin_init() {
|
63 |
if ( current_user_can( 'activate_plugins' ) ) {
|
64 |
$user_id = get_current_user_id();
|
65 |
-
if ( !empty( $_GET[self::HIDE_REVIEW_NOTICE] ) ) {
|
66 |
add_user_meta( $user_id, self::HIDE_REVIEW_NOTICE, true );
|
67 |
}
|
|
|
|
|
|
|
68 |
$hide_review_notice = get_user_meta( $user_id, self::HIDE_REVIEW_NOTICE, true );
|
69 |
if ( empty( $hide_review_notice ) ) {
|
70 |
$d = time() - self::get_init_time();
|
71 |
if ( $d >= self::SHOW_LAPSE ) {
|
72 |
-
|
|
|
|
|
|
|
73 |
}
|
74 |
}
|
75 |
}
|
@@ -93,13 +113,30 @@ class Groups_Admin_Notice {
|
|
93 |
public static function admin_notices() {
|
94 |
|
95 |
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
96 |
-
$
|
|
|
97 |
|
98 |
-
$output = '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
$output .= '<p>';
|
100 |
$output .= __( 'Many thanks for using <strong>Groups</strong>!', 'groups' );
|
101 |
$output .= ' ';
|
102 |
$output .= __( 'Could you please spare a minute and give it a review over at WordPress.org?', 'groups' );
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
$output .= '</p>';
|
104 |
$output .= '<p>';
|
105 |
$output .= sprintf(
|
@@ -107,12 +144,13 @@ class Groups_Admin_Notice {
|
|
107 |
esc_url( 'http://wordpress.org/support/view/plugin-reviews/groups?filter=5#postform' ),
|
108 |
__( 'Yes, here we go!', 'groups' )
|
109 |
);
|
110 |
-
$output .= '
|
111 |
$output .= sprintf(
|
112 |
-
'<a
|
113 |
-
esc_url( $
|
114 |
-
esc_html( __( '
|
115 |
);
|
|
|
116 |
$output .= '</p>';
|
117 |
$output .= '<p>';
|
118 |
$output .= sprintf(
|
42 |
*/
|
43 |
const HIDE_REVIEW_NOTICE = 'groups-hide-review-notice';
|
44 |
|
45 |
+
/**
|
46 |
+
* Used to check next time.
|
47 |
+
*
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
const REMIND_LATER_NOTICE = 'groups-remind-later-notice';
|
51 |
+
|
52 |
/**
|
53 |
* The number of seconds in seven days, since init date to show the notice.
|
54 |
*
|
56 |
*/
|
57 |
const SHOW_LAPSE = 604800;
|
58 |
|
59 |
+
/**
|
60 |
+
* The number of seconds in one day, used to show notice later again.
|
61 |
+
*
|
62 |
+
* @var int
|
63 |
+
*/
|
64 |
+
const REMIND_LAPSE = 86400;
|
65 |
+
|
66 |
/**
|
67 |
* Adds actions.
|
68 |
*/
|
76 |
public static function admin_init() {
|
77 |
if ( current_user_can( 'activate_plugins' ) ) {
|
78 |
$user_id = get_current_user_id();
|
79 |
+
if ( !empty( $_GET[self::HIDE_REVIEW_NOTICE] ) && wp_verify_nonce( $_GET['groups_notice'], 'hide' ) ) {
|
80 |
add_user_meta( $user_id, self::HIDE_REVIEW_NOTICE, true );
|
81 |
}
|
82 |
+
if ( !empty( $_GET[self::REMIND_LATER_NOTICE] ) && wp_verify_nonce( $_GET['groups_notice'], 'later' ) ) {
|
83 |
+
update_user_meta( $user_id, self::REMIND_LATER_NOTICE, time() + self::REMIND_LAPSE );
|
84 |
+
}
|
85 |
$hide_review_notice = get_user_meta( $user_id, self::HIDE_REVIEW_NOTICE, true );
|
86 |
if ( empty( $hide_review_notice ) ) {
|
87 |
$d = time() - self::get_init_time();
|
88 |
if ( $d >= self::SHOW_LAPSE ) {
|
89 |
+
$remind_later_notice = get_user_meta( $user_id, self::REMIND_LATER_NOTICE, true );
|
90 |
+
if ( empty( $remind_later_notice ) || ( time() > $remind_later_notice ) ) {
|
91 |
+
add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
|
92 |
+
}
|
93 |
}
|
94 |
}
|
95 |
}
|
113 |
public static function admin_notices() {
|
114 |
|
115 |
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
116 |
+
$hide_url = wp_nonce_url( add_query_arg( self::HIDE_REVIEW_NOTICE, true, $current_url ), 'hide', 'groups_notice' );
|
117 |
+
$remind_url = wp_nonce_url( add_query_arg( self::REMIND_LATER_NOTICE, true, $current_url ), 'later', 'groups_notice' );
|
118 |
|
119 |
+
$output = '';
|
120 |
+
|
121 |
+
$output .= '<style type="text/css">';
|
122 |
+
$output .= 'div.groups-rating {';
|
123 |
+
$output .= sprintf( 'background: url(%s) #fff no-repeat 8px 8px;', GROUPS_PLUGIN_URL . '/images/groups-256x256.png' );
|
124 |
+
$output .= 'padding-left: 76px ! important;';
|
125 |
+
$output .= 'background-size: 64px 64px;';
|
126 |
+
$output .= '}';
|
127 |
+
$output .= '</style>';
|
128 |
+
|
129 |
+
$output .= '<div class="updated groups-rating">';
|
130 |
$output .= '<p>';
|
131 |
$output .= __( 'Many thanks for using <strong>Groups</strong>!', 'groups' );
|
132 |
$output .= ' ';
|
133 |
$output .= __( 'Could you please spare a minute and give it a review over at WordPress.org?', 'groups' );
|
134 |
+
$output .= ' ';
|
135 |
+
$output .= sprintf(
|
136 |
+
'<a style="color:inherit;white-space:nowrap;" href="%s">%s</a>',
|
137 |
+
esc_url( $hide_url ),
|
138 |
+
esc_html( __( 'I have already done that.', 'groups' ) )
|
139 |
+
);
|
140 |
$output .= '</p>';
|
141 |
$output .= '<p>';
|
142 |
$output .= sprintf(
|
144 |
esc_url( 'http://wordpress.org/support/view/plugin-reviews/groups?filter=5#postform' ),
|
145 |
__( 'Yes, here we go!', 'groups' )
|
146 |
);
|
147 |
+
$output .= ' ';
|
148 |
$output .= sprintf(
|
149 |
+
'<a class="button" href="%s">%s</a>',
|
150 |
+
esc_url( $remind_url ),
|
151 |
+
esc_html( __( 'Remind me later', 'groups' ) )
|
152 |
);
|
153 |
+
|
154 |
$output .= '</p>';
|
155 |
$output .= '<p>';
|
156 |
$output .= sprintf(
|
lib/admin/groups-admin-groups-edit.php
CHANGED
@@ -135,7 +135,12 @@ function groups_admin_groups_edit( $group_id ) {
|
|
135 |
$group_object = new Groups_Group( $group_id );
|
136 |
$group_capabilities = $group_object->capabilities;
|
137 |
$group_capabilities_deep = $group_object->capabilities_deep;
|
138 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
139 |
usort( $group_capabilities_deep, array( 'Groups_Utility', 'cmp' ) );
|
140 |
$output .= '<div class="field">';
|
141 |
$output .= __( 'Inherited capabilities:', 'groups' );
|
135 |
$group_object = new Groups_Group( $group_id );
|
136 |
$group_capabilities = $group_object->capabilities;
|
137 |
$group_capabilities_deep = $group_object->capabilities_deep;
|
138 |
+
if (
|
139 |
+
(
|
140 |
+
( !empty( $group_capabilities_deep ) ? count( $group_capabilities_deep ) : 0 ) -
|
141 |
+
( !empty( $group_capabilities ) ? count( $group_capabilities ) : 0 )
|
142 |
+
) > 0
|
143 |
+
) {
|
144 |
usort( $group_capabilities_deep, array( 'Groups_Utility', 'cmp' ) );
|
145 |
$output .= '<div class="field">';
|
146 |
$output .= __( 'Inherited capabilities:', 'groups' );
|
lib/core/class-groups-group.php
CHANGED
@@ -632,7 +632,7 @@ class Groups_Group implements I_Capable {
|
|
632 |
if ( !empty( $include ) && !is_array( $include ) && is_string( $include ) ) {
|
633 |
$include = explode( ',', $include );
|
634 |
}
|
635 |
-
if ( count( $include ) > 0 ) {
|
636 |
$include = implode( ',', array_map( 'intval', array_map( 'trim', $include ) ) );
|
637 |
if ( strlen( $include ) > 0 ) {
|
638 |
$where_include = " group_id IN ($include) ";
|
@@ -647,7 +647,7 @@ class Groups_Group implements I_Capable {
|
|
647 |
if ( !empty( $include_by_name ) && !is_array( $include_by_name ) && is_string( $include_by_name ) ) {
|
648 |
$include_by_name = explode( ',', $include_by_name );
|
649 |
}
|
650 |
-
if ( count( $include_by_name ) > 0 ) {
|
651 |
$include_by_name = "'" . implode( "','", array_map( 'esc_sql', array_map( 'trim', $include_by_name ) ) ) . "'";
|
652 |
if ( strlen( $include_by_name ) > 0 ) {
|
653 |
$where_include_by_name = " name IN ($include_by_name) ";
|
@@ -685,7 +685,7 @@ class Groups_Group implements I_Capable {
|
|
685 |
if ( !empty( $exclude ) && !is_array( $exclude ) && is_string( $exclude ) ) {
|
686 |
$exclude = explode( ',', $exclude );
|
687 |
}
|
688 |
-
if ( count( $exclude ) > 0 ) {
|
689 |
$exclude = implode( ',', array_map( 'intval', array_map( 'trim', $exclude ) ) );
|
690 |
if ( strlen( $exclude ) > 0 ) {
|
691 |
if ( empty( $where ) ) {
|
@@ -703,7 +703,7 @@ class Groups_Group implements I_Capable {
|
|
703 |
if ( !empty( $exclude_by_name ) && !is_array( $exclude_by_name ) && is_string( $exclude_by_name ) ) {
|
704 |
$exclude_by_name = explode( ',', $exclude_by_name );
|
705 |
}
|
706 |
-
if ( count( $exclude_by_name ) > 0 ) {
|
707 |
$exclude_by_name = "'" . implode( "','", array_map( 'esc_sql', array_map( 'trim', $exclude_by_name ) ) ) . "'";
|
708 |
if ( strlen( $exclude_by_name ) > 0 ) {
|
709 |
if ( empty( $where ) ) {
|
632 |
if ( !empty( $include ) && !is_array( $include ) && is_string( $include ) ) {
|
633 |
$include = explode( ',', $include );
|
634 |
}
|
635 |
+
if ( $include !== null && count( $include ) > 0 ) {
|
636 |
$include = implode( ',', array_map( 'intval', array_map( 'trim', $include ) ) );
|
637 |
if ( strlen( $include ) > 0 ) {
|
638 |
$where_include = " group_id IN ($include) ";
|
647 |
if ( !empty( $include_by_name ) && !is_array( $include_by_name ) && is_string( $include_by_name ) ) {
|
648 |
$include_by_name = explode( ',', $include_by_name );
|
649 |
}
|
650 |
+
if ( $include_by_name !== null && count( $include_by_name ) > 0 ) {
|
651 |
$include_by_name = "'" . implode( "','", array_map( 'esc_sql', array_map( 'trim', $include_by_name ) ) ) . "'";
|
652 |
if ( strlen( $include_by_name ) > 0 ) {
|
653 |
$where_include_by_name = " name IN ($include_by_name) ";
|
685 |
if ( !empty( $exclude ) && !is_array( $exclude ) && is_string( $exclude ) ) {
|
686 |
$exclude = explode( ',', $exclude );
|
687 |
}
|
688 |
+
if ( $exclude !== null && count( $exclude ) > 0 ) {
|
689 |
$exclude = implode( ',', array_map( 'intval', array_map( 'trim', $exclude ) ) );
|
690 |
if ( strlen( $exclude ) > 0 ) {
|
691 |
if ( empty( $where ) ) {
|
703 |
if ( !empty( $exclude_by_name ) && !is_array( $exclude_by_name ) && is_string( $exclude_by_name ) ) {
|
704 |
$exclude_by_name = explode( ',', $exclude_by_name );
|
705 |
}
|
706 |
+
if ( $exclude_by_name !== null && count( $exclude_by_name ) > 0 ) {
|
707 |
$exclude_by_name = "'" . implode( "','", array_map( 'esc_sql', array_map( 'trim', $exclude_by_name ) ) ) . "'";
|
708 |
if ( strlen( $exclude_by_name ) > 0 ) {
|
709 |
if ( empty( $where ) ) {
|
lib/extra/class-groups-extra.php
CHANGED
@@ -34,6 +34,7 @@ class Groups_Extra {
|
|
34 |
public static function init() {
|
35 |
add_filter( 'woocommerce_product_is_visible', array( __CLASS__, 'woocommerce_product_is_visible' ), 10, 2 );
|
36 |
add_filter( 'groups_comment_access_comment_count_where', array( __CLASS__, 'groups_comment_access_comment_count_where'), 10, 2 );
|
|
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -68,5 +69,28 @@ class Groups_Extra {
|
|
68 |
}
|
69 |
return $where;
|
70 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
add_action( 'init', array( 'Groups_Extra', 'init' ) );
|
34 |
public static function init() {
|
35 |
add_filter( 'woocommerce_product_is_visible', array( __CLASS__, 'woocommerce_product_is_visible' ), 10, 2 );
|
36 |
add_filter( 'groups_comment_access_comment_count_where', array( __CLASS__, 'groups_comment_access_comment_count_where'), 10, 2 );
|
37 |
+
add_filter( 'groups_post_access_posts_where_query_get_post_types', array( __CLASS__, 'groups_post_access_posts_where_query_get_post_types' ), 10, 3 );
|
38 |
}
|
39 |
|
40 |
/**
|
69 |
}
|
70 |
return $where;
|
71 |
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Checks if the query is a wc_query for product_query; if $post_types is empty, it will assume the product type and return that.
|
75 |
+
*
|
76 |
+
* @param string|array $post_types current query post types
|
77 |
+
* @param string $where the where part of the query
|
78 |
+
* @param WP_Query $query the query
|
79 |
+
*
|
80 |
+
* @return string
|
81 |
+
*/
|
82 |
+
public static function groups_post_access_posts_where_query_get_post_types( $post_types, $where, $query ) {
|
83 |
+
if (
|
84 |
+
empty( $post_types ) ||
|
85 |
+
is_string( $post_types ) && ( $post_types === '' ) ||
|
86 |
+
is_array( $post_types ) && ( count( $post_types ) === 0 )
|
87 |
+
) {
|
88 |
+
$wc_query = $query->get( 'wc_query', null );
|
89 |
+
if ( ! empty( $wc_query ) && $wc_query === 'product_query' ) {
|
90 |
+
$post_types = 'product';
|
91 |
+
}
|
92 |
+
}
|
93 |
+
return $post_types;
|
94 |
+
}
|
95 |
}
|
96 |
add_action( 'init', array( 'Groups_Extra', 'init' ) );
|
readme.txt
CHANGED
@@ -3,8 +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.0
|
6 |
-
Tested up to: 4.
|
7 |
-
|
|
|
8 |
License: GPLv3
|
9 |
|
10 |
Groups is an efficient and powerful solution, providing group-based user membership management, group-based capabilities and content access control.
|
@@ -189,6 +190,15 @@ See also the [Groups Documentation](http://docs.itthinx.com/document/groups/) pa
|
|
189 |
|
190 |
== Changelog ==
|
191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
= 2.3.0 =
|
193 |
* Tested with WordPress 4.8.
|
194 |
* Fixed a REST API access restriction issue, added the filter rest_prepare_{$post_type} to
|
@@ -276,9 +286,4 @@ See also the [Groups Documentation](http://docs.itthinx.com/document/groups/) pa
|
|
276 |
|
277 |
== Upgrade Notice ==
|
278 |
|
279 |
-
|
280 |
-
* This release has been tested with WordPress 4.8, contains a security fix related to the REST API, improvements to stability during activation (undesired concurrent activation, caching, multisite) and updates some translations.
|
281 |
-
* Important note for updates below Groups 2.2.0: Groups 2.2.0 and above also changes the behaviour for post types that Groups should not handle, if a post type is disabled, related entries will not be protected anymore.
|
282 |
-
This is a fundamental change with respect to the previous behavior.
|
283 |
-
* Groups 2.x simplifies the way access restrictions are handled.
|
284 |
-
* We recommend to always make a FULL BACKUP of your site and database before upgrading.
|
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.0
|
6 |
+
Tested up to: 4.9
|
7 |
+
Requires PHP: 5.5.38
|
8 |
+
Stable tag: 2.3.1
|
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.
|
190 |
|
191 |
== Changelog ==
|
192 |
|
193 |
+
= 2.3.1 =
|
194 |
+
* Fixed several points where warnings related to the use of count() and the Countable interface would occur due to changes in PHP 7.2.
|
195 |
+
* Tested with WordPress 4.9.
|
196 |
+
* Added the groups_post_access_posts_where_query_get_post_types filter to allow additional processing to cover for cases like where
|
197 |
+
wc_query is set.
|
198 |
+
* Fixed a notice related to the use of an undefined variable in the Groups_Post_Access class.
|
199 |
+
* Added the logo and the option to get reminded later to the Groups notice.
|
200 |
+
* Added filters on get_previous_post_where and get_next_post_where to restrict access on adjacent posts.
|
201 |
+
|
202 |
= 2.3.0 =
|
203 |
* Tested with WordPress 4.8.
|
204 |
* Fixed a REST API access restriction issue, added the filter rest_prepare_{$post_type} to
|
286 |
|
287 |
== Upgrade Notice ==
|
288 |
|
289 |
+
This release has been tested with WordPress 4.9 and contains several fixes for compatibility with PHP 7.2, fixes related to post filtering and an improved notice handling.
|
|
|
|
|
|
|
|
|
|