From 733969c84e0792c07ee35deb09d69f4e919b86ce Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Thu, 19 Aug 2021 01:50:13 +0300 Subject: [PATCH] - added fixes for incorrect posts; --- includes/core/class-access.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 9594e258..1246b581 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -695,6 +695,10 @@ if ( ! class_exists( 'um\core\Access' ) ) { * @return string */ function filter_restricted_post_excerpt( $post_excerpt, $post ) { + if ( empty( $post ) ) { + return $post_excerpt; + } + if ( current_user_can( 'administrator' ) || is_admin() ) { return $post_excerpt; } @@ -751,7 +755,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { } } else { $post_id = get_the_ID(); - if ( $this->is_restricted( $post_id ) ) { + if ( false !== $post_id && $this->is_restricted( $post_id ) ) { $has_thumbnail = false; } } @@ -1629,6 +1633,11 @@ if ( ! class_exists( 'um\core\Access' ) ) { * @return bool|array */ function get_post_privacy_settings( $post ) { + // break for incorrect post + if ( empty( $post ) ) { + return false; + } + static $cache = array(); $cache_key = is_numeric( $post ) ? $post : $post->ID; @@ -1836,6 +1845,11 @@ if ( ! class_exists( 'um\core\Access' ) ) { * @return bool */ function is_restricted( $post_id ) { + // break for incorrect post + if ( empty( $post_id ) ) { + return false; + } + static $cache = array(); if ( isset( $cache[ $post_id ] ) ) {