diff --git a/includes/core/class-access.php b/includes/core/class-access.php
index 60463bf9..1cafc3b9 100644
--- a/includes/core/class-access.php
+++ b/includes/core/class-access.php
@@ -1,19 +1,23 @@
singular_page = false;
$this->redirect_handler = false;
- $this->allow_access = false;
+ $this->allow_access = false;
// NEW HOOKS
// Navigation line below the post content, change query to exclude restricted
@@ -140,7 +140,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
*
* @return array
*/
- function exclude_posts_array( $force = false, $post_types = false ) {
+ public function exclude_posts_array( $force = false, $post_types = false ) {
if ( $this->ignore_exclude ) {
return array();
}
@@ -335,16 +335,14 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $exclude_posts;
}
-
-
/**
* Get array with restricted terms
*
- * @param \WP_Term_Query $query
+ * @param WP_Term_Query $query
*
* @return array
*/
- function exclude_terms_array( $query ) {
+ public function exclude_terms_array( $query ) {
$exclude = array();
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
@@ -415,11 +413,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $exclude;
}
-
/**
- * @param \WP_Term_Query $query
+ * @param WP_Term_Query $query
*/
- function exclude_hidden_terms_query( $query ) {
+ public function exclude_hidden_terms_query( $query ) {
if ( current_user_can( 'administrator' ) || ! empty( $query->query_vars['um_ignore_exclude'] ) ) {
return;
}
@@ -430,11 +427,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
}
}
-
/**
- * @param \WP_Query $query
+ * @param WP_Query $query
*/
- function exclude_posts( $query ) {
+ public function exclude_posts( $query ) {
if ( current_user_can( 'administrator' ) ) {
return;
}
@@ -472,16 +468,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
}
}
-
/**
- * Exclude restricted post from query if there is a single query that exclude post_not_in by default in \WP_Query
+ * Exclude restricted post from query if there is a single query that exclude post_not_in by default in WP_Query
*
- * @param string $where
- * @param \WP_Query $query
+ * @param string $where
+ * @param WP_Query $query
*
* @return mixed
*/
- function exclude_posts_where( $where, $query ) {
+ public function exclude_posts_where( $where, $query ) {
if ( current_user_can( 'administrator' ) ) {
return $where;
}
@@ -502,18 +497,17 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $where;
}
-
/**
* Change the posts count based on restriction settings
*
* @param object $counts Post counts
- * @param string $type Post type
- * @param string $perm The permission to determine if the posts are 'readable'
- * by the current user.
+ * @param string $type Post type
+ * @param string $perm The permission to determine if the posts are 'readable'
+ * by the current user.
*
* @return object
*/
- function custom_count_posts_handler( $counts, $type = 'post', $perm = '' ) {
+ public function custom_count_posts_handler( $counts, $type = 'post', $perm = '' ) {
if ( current_user_can( 'administrator' ) ) {
return $counts;
}
@@ -565,7 +559,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $counts;
}
-
/**
* Exclude restricted posts in Recent Posts widget
*
@@ -573,7 +566,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
*
* @return array
*/
- function exclude_restricted_posts_widget( $array ) {
+ public function exclude_restricted_posts_widget( $array ) {
if ( current_user_can( 'administrator' ) ) {
return $array;
}
@@ -587,7 +580,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $array;
}
-
/**
* Exclude restricted posts in Recent Posts widget
*
@@ -595,7 +587,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
*
* @return array
*/
- function exclude_restricted_pages( $array ) {
+ public function exclude_restricted_pages( $array ) {
if ( current_user_can( 'administrator' ) ) {
return $array;
}
@@ -608,16 +600,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $array;
}
-
/**
* Exclude restricted posts in widgets
*
* @param string $sql_where
- * @param array $parsed_args
+ * @param array $parsed_args
*
* @return string
*/
- function exclude_restricted_posts_archives_widget( $sql_where, $parsed_args = array() ) {
+ public function exclude_restricted_posts_archives_widget( $sql_where, $parsed_args = array() ) {
if ( current_user_can( 'administrator' ) ) {
return $sql_where;
}
@@ -633,7 +624,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $sql_where;
}
-
/**
* Exclude posts from next, previous navigation
*
@@ -641,11 +631,11 @@ if ( ! class_exists( 'um\core\Access' ) ) {
* @param bool $in_same_term
* @param string|array $excluded_terms
* @param string $taxonomy
- * @param null|\WP_Post $post
+ * @param null|WP_Post $post
*
* @return string
*/
- function exclude_navigation_posts( $where, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category', $post = null ) {
+ public function exclude_navigation_posts( $where, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category', $post = null ) {
if ( current_user_can( 'administrator' ) ) {
return $where;
}
@@ -663,16 +653,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $where;
}
-
/**
- * Replace titles of restricted posts
+ * Replace titles of restricted posts.
*
- * @param string $title
- * @param int|null $id
+ * @param string $title Post title.
+ * @param int|null $id Post ID.
*
* @return string
*/
- function filter_restricted_post_title( $title, $id = null ) {
+ public function filter_restricted_post_title( $title, $id = null ) {
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
return $title;
}
@@ -689,6 +678,29 @@ if ( ! class_exists( 'um\core\Access' ) ) {
$id = absint( $id );
}
+ /**
+ * Filters a marker for ignoring restricted post title changes.
+ *
+ * @param {bool} $ignore Marker for ignoring restricted post title changes. Default `false`. Set to `true` if you want to ignore and show real title.
+ * @param {int} $post_id Post ID.
+ *
+ * @return {bool} Marker for ignoring restricted post title changes.
+ *
+ * @since 2.2.3
+ * @hook um_ignore_restricted_title
+ *
+ * @example
Leave real post titles even they are restricted. By post ID (for ID = 400).
+ * function change_restricted_title( $ignore, $id ) {
+ * // your code here
+ * if ( 400 === $id ) {
+ * $ignore = true;
+ * }
+ * return $ignore;
+ * }
+ * add_filter( 'um_ignore_restricted_title', 'change_restricted_title', 10, 2 );
+ * @example Leave real post titles even they are restricted. For all posts: site-wide logic.
+ * add_filter( 'um_ignore_restricted_title', '__return_true' );
+ */
$ignore = apply_filters( 'um_ignore_restricted_title', false, $id );
if ( $ignore ) {
return $title;
@@ -696,21 +708,20 @@ if ( ! class_exists( 'um\core\Access' ) ) {
if ( $this->is_restricted( $id ) ) {
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
- $title = stripslashes( $restricted_global_title );
+ $title = stripslashes( $restricted_global_title );
}
return $title;
}
-
/**
- * Replace content of restricted posts
+ * Replace content of restricted posts.
*
- * @param string $content
+ * @param string $content Post Content.
*
* @return string
*/
- function filter_restricted_post_content( $content ) {
+ public function filter_restricted_post_content( $content ) {
if ( current_user_can( 'administrator' ) ) {
return $content;
}
@@ -720,6 +731,31 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $content;
}
+ /**
+ * Filters a marker for ignoring restricted post content changes.
+ *
+ * Note: Use with caution! You can make your posts not restricted by using this filter hook.
+ *
+ * @param {bool} $ignore Marker for ignoring restricted post content changes. Default `false`. Set to `true` if you want to ignore and show real content.
+ * @param {int} $post_id Post ID.
+ *
+ * @return {bool} Marker for ignoring restricted post content changes.
+ *
+ * @since 2.2.3
+ * @hook um_ignore_restricted_content
+ *
+ * @example Leave real post content even they are restricted. By post ID (for ID = 400).
+ * function change_restricted_content( $ignore, $id ) {
+ * // your code here
+ * if ( 400 === $id ) {
+ * $ignore = true;
+ * }
+ * return $ignore;
+ * }
+ * add_filter( 'um_ignore_restricted_content', 'change_restricted_content', 10, 2 );
+ * @example Leave real post content even they are restricted. For all posts: site-wide logic.
+ * add_filter( 'um_ignore_restricted_content', '__return_true' );
+ */
$ignore = apply_filters( 'um_ignore_restricted_content', false, $id );
if ( $ignore ) {
return $content;
@@ -741,16 +777,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $content;
}
-
/**
- * Replace excerpt of restricted posts
+ * Replace excerpt of restricted posts.
*
- * @param string $post_excerpt
- * @param \WP_Post $post
+ * @param string $post_excerpt Post Excerpt.
+ * @param WP_Post $post WP_Post instance.
*
* @return string
*/
- function filter_restricted_post_excerpt( $post_excerpt = '', $post = null ) {
+ public function filter_restricted_post_excerpt( $post_excerpt = '', $post = null ) {
if ( empty( $post ) ) {
return $post_excerpt;
}
@@ -759,6 +794,31 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $post_excerpt;
}
+ /**
+ * Filters a marker for ignoring restricted post excerpt changes.
+ *
+ * Note: Use with caution! You can make your posts not restricted by using this filter hook.
+ *
+ * @param {bool} $ignore Marker for ignoring restricted post excerpt changes. Default `false`. Set to `true` if you want to ignore and show real content.
+ * @param {int} $post_id Post ID.
+ *
+ * @return {bool} Marker for ignoring restricted post excerpt changes.
+ *
+ * @since 2.2.3
+ * @hook um_ignore_restricted_excerpt
+ *
+ * @example Leave real post excerpt even they are restricted. By post ID (for ID = 400).
+ * function change_restricted_excerpt( $ignore, $id ) {
+ * // your code here
+ * if ( 400 === $id ) {
+ * $ignore = true;
+ * }
+ * return $ignore;
+ * }
+ * add_filter( 'um_ignore_restricted_excerpt', 'change_restricted_excerpt', 10, 2 );
+ * @example Leave real post excerpt even they are restricted. For all posts: site-wide logic.
+ * add_filter( 'um_ignore_restricted_excerpt', '__return_true' );
+ */
$ignore = apply_filters( 'um_ignore_restricted_excerpt', false, $post->ID );
if ( $ignore ) {
return $post_excerpt;
@@ -771,16 +831,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $post_excerpt;
}
-
/**
* Hide attachment if the post is restricted
*
* @param string $url
- * @param int $attachment_id
+ * @param int $attachment_id
*
* @return boolean|string
*/
- function filter_attachment( $url, $attachment_id ) {
+ public function filter_attachment( $url, $attachment_id ) {
if ( current_user_can( 'administrator' ) ) {
return $url;
}
@@ -788,7 +847,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return ( $attachment_id && $this->is_restricted( $attachment_id ) ) ? false : $url;
}
-
/**
* Hide attachment if the post is restricted
*
@@ -798,7 +856,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
*
* @return bool
*/
- function filter_post_thumbnail( $has_thumbnail, $post = null, $thumbnail_id = false ) {
+ public function filter_post_thumbnail( $has_thumbnail, $post = null, $thumbnail_id = false ) {
if ( empty( $thumbnail_id ) ) {
return $has_thumbnail;
}
@@ -825,14 +883,12 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $has_thumbnail;
}
-
-
/**
* Exclude comments from restricted posts in widgets
*
- * @param \WP_Comment_Query $query
+ * @param WP_Comment_Query $query
*/
- function exclude_posts_comments( $query ) {
+ public function exclude_posts_comments( $query ) {
if ( current_user_can( 'administrator' ) ) {
return;
}
@@ -862,11 +918,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
}
}
-
/**
* @return array
*/
- function get_available_comments_post_types() {
+ public function get_available_comments_post_types() {
global $wp_taxonomies, $wpdb;
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
@@ -907,16 +962,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $restricted_posts;
}
-
/**
* Exclude comments from comments feed
*
- * @param string $where
- * @param \WP_Query $query
+ * @param string $where
+ * @param WP_Query $query
*
* @return string
*/
- function exclude_posts_comments_feed( $where, $query ) {
+ public function exclude_posts_comments_feed( $where, $query ) {
if ( current_user_can( 'administrator' ) ) {
return $where;
}
@@ -924,20 +978,19 @@ if ( ! class_exists( 'um\core\Access' ) ) {
$exclude_posts = $this->exclude_posts_array( true, $this->get_available_comments_post_types() );
if ( ! empty( $exclude_posts ) ) {
$exclude_string = implode( ',', $exclude_posts );
- $where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
+ $where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
}
return $where;
}
-
/**
* @param array|object $stats
* @param int $post_id Post ID. Can be 0 for the whole website
*
* @return object
*/
- function custom_comments_count_handler( $stats = array(), $post_id = 0 ) {
+ public function custom_comments_count_handler( $stats = array(), $post_id = 0 ) {
if ( ! empty( $stats ) || current_user_can( 'administrator' ) ) {
return $stats;
}
@@ -963,14 +1016,13 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $stats_object;
}
-
/**
* @param int $post_id
* @param array $exclude_posts
*
* @return array
*/
- function get_comment_count( $post_id = 0, $exclude_posts = array() ) {
+ public function get_comment_count( $post_id = 0, $exclude_posts = array() ) {
static $cache = array();
if ( isset( $cache[ $post_id ] ) ) {
@@ -1044,15 +1096,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $comment_count;
}
-
/**
* Disable comments if user has not permission to access this post
*
* @param mixed $open
* @param int $post_id
- * @return boolean
+ *
+ * @return bool
*/
- function disable_comments_open( $open, $post_id ) {
+ public function disable_comments_open( $open, $post_id ) {
if ( current_user_can( 'administrator' ) ) {
return $open;
}
@@ -1074,15 +1126,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $open;
}
-
/**
* Disable comments if user has not permission to access this post
*
* @param int $count
* @param int $post_id
- * @return boolean
+ *
+ * @return bool
*/
- function disable_comments_open_number( $count, $post_id = 0 ) {
+ public function disable_comments_open_number( $count, $post_id = 0 ) {
if ( current_user_can( 'administrator' ) ) {
return $count;
}
@@ -1104,15 +1156,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $count;
}
-
/**
* Protect Post Types in menu query
* Restrict content new logic
* @param array $menu_items
* @param array $args
+ *
* @return array
*/
- function filter_menu( $menu_items, $args = array() ) {
+ public function filter_menu( $menu_items, $args = array() ) {
//if empty
if ( empty( $menu_items ) ) {
return $menu_items;
@@ -1159,14 +1211,13 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $filtered_items;
}
-
/**
* @param $block_content
* @param $block
*
* @return string
*/
- function restrict_blocks( $block_content, $block ) {
+ public function restrict_blocks( $block_content, $block ) {
if ( is_admin() ) {
return $block_content;
}
@@ -1246,13 +1297,12 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $block_content;
}
-
/**
- * @param \WP_Post $post
+ * @param WP_Post $post
*
- * @return \WP_Post
+ * @return WP_Post
*/
- function maybe_replace_title( $post ) {
+ public function maybe_replace_title( $post ) {
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
return $post;
}
@@ -1261,28 +1311,28 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $post;
}
- if ( ! is_a( $post, '\WP_Post' ) ) {
+ if ( ! is_a( $post, WP_Post::class ) ) {
return $post;
}
+ /** This filter is documented in includes/core/class-access.php */
$ignore = apply_filters( 'um_ignore_restricted_title', false, $post->ID );
if ( $ignore ) {
return $post;
}
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
- $post->post_title = stripslashes( $restricted_global_title );
+ $post->post_title = stripslashes( $restricted_global_title );
return $post;
}
-
/**
- * @param \WP_Post $nav_item
+ * @param WP_Post $nav_item
*
- * @return \WP_Post
+ * @return WP_Post
*/
- function maybe_replace_nav_menu_title( $nav_item ) {
+ public function maybe_replace_nav_menu_title( $nav_item ) {
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
return $nav_item;
}
@@ -1291,7 +1341,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $nav_item;
}
- if ( ! is_a( $nav_item, '\WP_Post' ) ) {
+ if ( ! is_a( $nav_item, WP_Post::class ) ) {
return $nav_item;
}
@@ -1306,21 +1356,21 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $nav_item;
}
-
/**
* Protect Post Types in query
* Restrict content new logic
*
- * @param array $posts
- * @param array|\WP_Query $query
+ * @param array $posts Posts query result.
+ * @param array|WP_Query $query WP_Query instance.
+ *
* @return array
*/
- function filter_protected_posts( $posts, $query ) {
+ public function filter_protected_posts( $posts, $query ) {
if ( current_user_can( 'administrator' ) ) {
return $posts;
}
- //Woocommerce AJAX fixes....remove filtration on wc-ajax which goes to Front Page
+ // Woocommerce AJAX fixes....remove filtration on wc-ajax which goes to Front Page.
if ( ! empty( $_GET['wc-ajax'] ) && defined( 'WC_DOING_AJAX' ) && WC_DOING_AJAX ) {
return $posts;
}
@@ -1336,8 +1386,8 @@ if ( ! class_exists( 'um\core\Access' ) ) {
$is_singular = ! empty( $query->is_singular ) ? true : false;
}
- if ( is_object( $query ) && is_a( $query, '\WP_Query' ) &&
- ( $query->is_main_query() || ! empty( $query->query_vars['um_main_query'] ) ) ) {
+ if ( is_object( $query ) && is_a( $query, WP_Query::class ) &&
+ ( $query->is_main_query() || ! empty( $query->query_vars['um_main_query'] ) ) ) {
if ( $is_singular ) {
if ( ! UM()->options()->get( 'disable_restriction_pre_queries' ) && $this->is_restricted( $posts[0]->ID ) ) {
$content_restriction = $this->get_post_privacy_settings( $posts[0]->ID );
@@ -1394,7 +1444,30 @@ if ( ! class_exists( 'um\core\Access' ) ) {
*/
do_action( 'um_access_fix_external_post_content' );
- $filtered_posts[] = $this->maybe_replace_title( $post );
+ $filtered_post = $this->maybe_replace_title( $post );
+ /**
+ * Filters restricted via Ultimate Member settings post instance.
+ *
+ * @param {object} $filtered_post Restricted `WP_Post` instance.
+ * @param {object} $post Base `WP_Post` instance before restriction settings apply.
+ * @param {object} $query `WP_Query` for getting posts.
+ *
+ * @return {object} Restricted `WP_Post` instance.
+ *
+ * @since 2.8.2
+ * @hook um_access_restricted_post_instance
+ *
+ * @example Change restricted post title to custom one.
+ * function restricted_post_instance( $filtered_post, $original_post, $query ) {
+ * // your code here
+ * $filtered_post->post_title = 'This post is restricted';
+ * return $filtered_post;
+ * }
+ * add_filter( 'um_access_restricted_post_instance', 'restricted_post_instance', 10, 3 );
+ */
+ $filtered_post = apply_filters( 'um_access_restricted_post_instance', $filtered_post, $post, $query );
+
+ $filtered_posts[] = $filtered_post;
continue;
}
} elseif ( '1' == $restriction['_um_noaccess_action'] ) {
@@ -1417,7 +1490,11 @@ if ( ! class_exists( 'um\core\Access' ) ) {
}
} else {
if ( empty( $restriction['_um_access_hide_from_queries'] ) || UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
- $filtered_posts[] = $this->maybe_replace_title( $post );
+ $filtered_post = $this->maybe_replace_title( $post );
+ /** This filter is documented in includes/core/class-access.php */
+ $filtered_post = apply_filters( 'um_access_restricted_post_instance', $filtered_post, $post, $query );
+
+ $filtered_posts[] = $filtered_post;
continue;
}
}
@@ -1427,13 +1504,12 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $filtered_posts;
}
-
/**
* Set custom access actions and redirection
*
* Old global restrict content logic
*/
- function template_redirect() {
+ public function template_redirect() {
global $post, $wp_query;
//if we logged by administrator it can access to all content
@@ -1532,11 +1608,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
$this->check_access();
}
-
/**
* Check Blog page Content Restriction settings
*/
- function um_access_check_blog_page_settings() {
+ public function um_access_check_blog_page_settings() {
global $wp_query;
if ( ! empty( $wp_query->is_home ) && ! empty( $wp_query->is_posts_page ) ) {
@@ -1574,7 +1649,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
/**
* Check individual term Content Restriction settings
*/
- function um_access_check_individual_term_settings() {
+ public function um_access_check_individual_term_settings() {
//check only tax|tags|categories - skip archive, author, and date lists
if ( ! ( is_tax() || is_tag() || is_category() ) ) {
return;
@@ -1627,7 +1702,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
}
}
-
/**
* @param $template
* @param $type
@@ -1635,7 +1709,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
*
* @return string
*/
- function taxonomy_message( $template, $type, $templates ) {
+ public function taxonomy_message( $template, $type, $templates ) {
return UM()->locate_template( 'restricted-taxonomy.php' );
}
@@ -1646,15 +1720,14 @@ if ( ! class_exists( 'um\core\Access' ) ) {
*
* @return string
*/
- function blog_message( $template, $type, $templates ) {
+ public function blog_message( $template, $type, $templates ) {
return UM()->locate_template( 'restricted-blog.php' );
}
-
/**
* Check global accessible settings
*/
- function um_access_check_global_settings() {
+ public function um_access_check_global_settings() {
global $post;
$curr = UM()->permalinks()->get_current_url();
@@ -1776,13 +1849,12 @@ if ( ! class_exists( 'um\core\Access' ) ) {
}
}
-
/**
* Check access
*
* @return bool
*/
- function check_access() {
+ public function check_access() {
if ( $this->allow_access === true ) {
return true;
}
@@ -1795,7 +1867,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return false;
}
-
/**
* Sends a HTTP header to limit rendering of pages to same origin iframes when loading sensitive pages.
*
@@ -1812,7 +1883,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
}
}
-
/**
* Sets a custom access referer in a redirect URL
*
@@ -1821,7 +1891,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
*
* @return string
*/
- function set_referer( $url, $referer ) {
+ public function set_referer( $url, $referer ) {
/**
* UM hook
@@ -1852,13 +1922,13 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $url;
}
-
/**
* Get privacy settings for post
* return false if post is not private
* Restrict content new logic
*
- * @param \WP_Post|int $post Post ID or object
+ * @param WP_Post|int $post Post ID or object
+ *
* @return bool|array
*/
public function get_post_privacy_settings( $post ) {
@@ -1867,7 +1937,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return false;
}
- if ( ! is_numeric( $post ) && ! is_a( $post, \WP_Post::class ) ) {
+ if ( ! is_numeric( $post ) && ! is_a( $post, WP_Post::class ) ) {
return false;
}
@@ -2014,15 +2084,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return false;
}
-
/**
* Helper for checking if the user can some of the roles array
*
* @param $user_id
* @param $roles
+ *
* @return bool
*/
- function user_can( $user_id, $roles ) {
+ public function user_can( $user_id, $roles ) {
$user_can = false;
if ( ! empty( $roles ) ) {
@@ -2037,7 +2107,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $user_can;
}
-
/**
* Helper for 3rd-party integrations with content restriction settings
*
@@ -2045,7 +2114,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
*
* @return bool
*/
- function um_custom_restriction( $restriction ) {
+ public function um_custom_restriction( $restriction ) {
/**
* UM hook
*
@@ -2070,16 +2139,16 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return apply_filters( 'um_custom_restriction', true, $restriction );
}
-
/**
* Is post restricted?
*
* @param int $post_id
* @param bool $on_single_page
* @param bool $ignore_cache
+ *
* @return bool
*/
- function is_restricted( $post_id, $on_single_page = false, $ignore_cache = false ) {
+ public function is_restricted( $post_id, $on_single_page = false, $ignore_cache = false ) {
// break for incorrect post
if ( empty( $post_id ) ) {
return false;
@@ -2169,16 +2238,16 @@ if ( ! class_exists( 'um\core\Access' ) ) {
return $restricted;
}
-
/**
* Is term restricted?
*
* @param int $term_id
* @param bool $on_term_page
* @param bool $ignore_cache
+ *
* @return bool
*/
- function is_restricted_term( $term_id, $on_term_page = false, $ignore_cache = false ) {
+ public function is_restricted_term( $term_id, $on_term_page = false, $ignore_cache = false ) {
static $cache = array();
if ( isset( $cache[ $term_id ] ) && ! $ignore_cache ) {