From 7d03ee61f1cd9f7176da52f419d14e3ea1b238cb Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Thu, 21 Mar 2019 16:52:26 +0200 Subject: [PATCH] - code refactoring; --- includes/core/class-access.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 3bd16b5f..d1766151 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -556,10 +556,11 @@ if ( ! class_exists( 'um\core\Access' ) ) { $restriction = get_post_meta( $post->ID, 'um_content_restriction', true ); if ( ! empty( $restriction['_um_custom_access_settings'] ) ) { - if ( ! isset( $restriction['_um_accessible'] ) ) + if ( ! isset( $restriction['_um_accessible'] ) ) { return false; - else + } else { return $restriction; + } } } @@ -573,8 +574,9 @@ if ( ! class_exists( 'um\core\Access' ) ) { $terms = array(); if ( ! empty( $taxonomies ) ) { foreach ( $taxonomies as $taxonomy ) { - if ( empty( $restricted_taxonomies[$taxonomy] ) ) + if ( empty( $restricted_taxonomies[ $taxonomy ] ) ) { continue; + } $terms = array_merge( $terms, wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ) ); } @@ -585,10 +587,11 @@ if ( ! class_exists( 'um\core\Access' ) ) { $restriction = get_term_meta( $term_id, 'um_content_restriction', true ); if ( ! empty( $restriction['_um_custom_access_settings'] ) ) { - if ( ! isset( $restriction['_um_accessible'] ) || '0' == $restriction['_um_accessible'] ) + if ( ! isset( $restriction['_um_accessible'] ) || '0' == $restriction['_um_accessible'] ) { continue; - else + } else { return $restriction; + } } } @@ -610,11 +613,18 @@ if ( ! class_exists( 'um\core\Access' ) ) { $filtered_posts = array(); //if empty - if ( empty( $posts ) ) + if ( empty( $posts ) ) { return $posts; + } $restricted_global_message = UM()->options()->get( 'restricted_access_message' ); + if ( is_object( $query ) ) { + $is_singular = $query->is_singular(); + } else { + $is_singular = ! empty( $query->is_singular ) ? true : false; + } + //other filter foreach ( $posts as $post ) { @@ -631,12 +641,6 @@ if ( ! class_exists( 'um\core\Access' ) ) { continue; } - if ( is_object( $query ) ) { - $is_singular = $query->is_singular(); - } else { - $is_singular = ! empty( $query->is_singular ) ? true : false; - } - //post is private if ( '0' == $restriction['_um_accessible'] ) { $this->singular_page = true;