From 641f2c5a740f5721357043b7a1c6d3225a1fafb4 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Tue, 14 Sep 2021 18:21:41 +0300 Subject: [PATCH] - fixed restriction logic cases; - fixed conditions for the restriction logic options; --- includes/admin/core/class-admin-metabox.php | 4 +-- .../templates/access/restrict_content.php | 2 +- includes/admin/templates/role/role-edit.php | 2 ++ includes/core/class-access.php | 2 +- includes/core/class-user-posts.php | 26 ++++++++++--------- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index dd69ad14..975fa17d 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -431,7 +431,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { '0' => __( 'Show access restricted message', 'ultimate-member' ), '1' => __( 'Redirect user', 'ultimate-member' ), ), - 'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? '' : array( '_um_access_hide_from_queries', '=', '0' ), + 'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ), ), array( 'id' => '_um_restrict_by_custom_message', @@ -583,7 +583,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { '0' => __( 'Show access restricted message', 'ultimate-member' ), '1' => __( 'Redirect user', 'ultimate-member' ), ), - 'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? '' : array( '_um_access_hide_from_queries', '=', '0' ), + 'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ), ), array( 'id' => '_um_restrict_by_custom_message', diff --git a/includes/admin/templates/access/restrict_content.php b/includes/admin/templates/access/restrict_content.php index 44a37b0d..732847c1 100644 --- a/includes/admin/templates/access/restrict_content.php +++ b/includes/admin/templates/access/restrict_content.php @@ -96,7 +96,7 @@ if ( ! defined( 'ABSPATH' ) ) { '0' => __( 'Show access restricted message', 'ultimate-member' ), '1' => __( 'Redirect user', 'ultimate-member' ), ), - 'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? '' : array( '_um_access_hide_from_queries', '=', '0' ), + 'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ), ), array( 'id' => '_um_restrict_by_custom_message', diff --git a/includes/admin/templates/role/role-edit.php b/includes/admin/templates/role/role-edit.php index b705955a..36845ca5 100644 --- a/includes/admin/templates/role/role-edit.php +++ b/includes/admin/templates/role/role-edit.php @@ -91,6 +91,8 @@ if ( ! empty( $_POST['role'] ) ) { } if ( preg_match( "/^[\p{Latin}\d\-_ ]+$/i", $data['name'] ) ) { + // uses sanitize_title instead of sanitize_key for backward compatibility based on #906 pull-request (https://github.com/ultimatemember/ultimatemember/pull/906) + // roles e.g. "潜水艦subs" with both latin + not-UTB-8 symbols had invalid role ID $id = sanitize_title( $data['name'] ); } else { $auto_increment = UM()->options()->get( 'custom_roles_increment' ); diff --git a/includes/core/class-access.php b/includes/core/class-access.php index a2adffd4..c63213ff 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -1379,7 +1379,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { } } } else { - if ( UM()->options()->get( 'disable_restriction_pre_queries' ) || empty( $restriction['_um_access_hide_from_queries'] ) ) { + if ( empty( $restriction['_um_access_hide_from_queries'] ) || ! UM()->options()->get( 'disable_restriction_pre_queries' ) ) { $filtered_posts[] = $this->maybe_replace_title( $post ); continue; } diff --git a/includes/core/class-user-posts.php b/includes/core/class-user-posts.php index afd50a03..9a04a401 100644 --- a/includes/core/class-user-posts.php +++ b/includes/core/class-user-posts.php @@ -29,12 +29,13 @@ if ( ! class_exists( 'um\core\User_posts' ) ) { */ function add_posts() { $args = array( - 'post_type' => 'post', - 'posts_per_page' => 10, - 'offset' => 0, - 'author' => um_get_requested_user(), - 'post_status' => array( 'publish' ), - 'um_main_query' => true, + 'post_type' => 'post', + 'posts_per_page' => 10, + 'offset' => 0, + 'author' => um_get_requested_user(), + 'post_status' => array( 'publish' ), + 'um_main_query' => true, + 'suppress_filters' => false, ); /** @@ -108,12 +109,13 @@ if ( ! class_exists( 'um\core\User_posts' ) ) { $page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 0; $args = array( - 'post_type' => 'post', - 'posts_per_page' => 10, - 'offset' => ( $page - 1 ) * 10, - 'author' => $author, - 'post_status' => array( 'publish' ), - 'um_main_query' => true, + 'post_type' => 'post', + 'posts_per_page' => 10, + 'offset' => ( $page - 1 ) * 10, + 'author' => $author, + 'post_status' => array( 'publish' ), + 'um_main_query' => true, + 'suppress_filters' => false, ); /**