mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-13 19:56:27 +09:00
- added setting 'Restricted Access Post Title' for restricted posts displayed in archive;
- fixed access class for posts visible in query but that have restriction settings (message or redirect);
This commit is contained in:
@@ -502,6 +502,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
|
||||
'conditional' => array( 'accessible', '=', 2 ),
|
||||
),
|
||||
array(
|
||||
'id' => 'restricted_access_post_title',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
|
||||
'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'restricted_access_message',
|
||||
'type' => 'wp_editor',
|
||||
@@ -513,22 +519,25 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
$settings_map = array_merge(
|
||||
$settings_map,
|
||||
array(
|
||||
'accessible' => array(
|
||||
'accessible' => array(
|
||||
'sanitize' => 'int',
|
||||
),
|
||||
'access_redirect' => array(
|
||||
'access_redirect' => array(
|
||||
'sanitize' => 'url',
|
||||
),
|
||||
'access_exclude_uris' => array(
|
||||
'access_exclude_uris' => array(
|
||||
'sanitize' => 'url',
|
||||
),
|
||||
'home_page_accessible' => array(
|
||||
'home_page_accessible' => array(
|
||||
'sanitize' => 'bool',
|
||||
),
|
||||
'category_page_accessible' => array(
|
||||
'category_page_accessible' => array(
|
||||
'sanitize' => 'bool',
|
||||
),
|
||||
'restricted_access_message' => array(
|
||||
'restricted_access_post_title' => array(
|
||||
'sanitize' => 'text',
|
||||
),
|
||||
'restricted_access_message' => array(
|
||||
'sanitize' => 'wp_kses',
|
||||
),
|
||||
)
|
||||
|
||||
@@ -543,6 +543,7 @@ if ( ! class_exists( 'um\Config' ) ) {
|
||||
'access_exclude_uris' => array(),
|
||||
'home_page_accessible' => 1,
|
||||
'category_page_accessible' => 1,
|
||||
'restricted_access_post_title' => __( 'Restricted content', 'ultimate-member' ),
|
||||
'restricted_access_message' => '',
|
||||
'restricted_blocks' => 0,
|
||||
'enable_blocks' => 0,
|
||||
@@ -801,4 +802,4 @@ if ( ! class_exists( 'um\Config' ) ) {
|
||||
}
|
||||
//end class
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,6 +704,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
}
|
||||
|
||||
$restricted_global_message = UM()->options()->get( 'restricted_access_message' );
|
||||
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
||||
|
||||
if ( is_object( $query ) ) {
|
||||
$is_singular = $query->is_singular();
|
||||
@@ -750,16 +751,18 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
//if not single query when exclude if set _um_access_hide_from_queries
|
||||
if ( empty( $restriction['_um_access_hide_from_queries'] ) ) {
|
||||
|
||||
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
|
||||
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
}
|
||||
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
$post->post_excerpt = '';
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
$post->post_excerpt = '';
|
||||
}
|
||||
|
||||
$post = apply_filters( 'um_restricted_archive_post', $post, $restriction );
|
||||
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
}
|
||||
@@ -771,10 +774,14 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
}
|
||||
|
||||
$post = apply_filters( 'um_restricted_singular_post', $post, $restriction );
|
||||
|
||||
$this->current_single_post = $post;
|
||||
|
||||
/**
|
||||
@@ -854,16 +861,18 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
//if not single query when exclude if set _um_access_hide_from_queries
|
||||
if ( empty( $restriction['_um_access_hide_from_queries'] ) ) {
|
||||
|
||||
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
|
||||
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
}
|
||||
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
$post->post_excerpt = '';
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
$post->post_excerpt = '';
|
||||
}
|
||||
|
||||
$post = apply_filters( 'um_restricted_archive_post', $post, $restriction );
|
||||
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
}
|
||||
@@ -875,6 +884,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
|
||||
$this->current_single_post = $post;
|
||||
|
||||
@@ -883,6 +893,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
}
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
|
||||
$this->current_single_post = $post;
|
||||
|
||||
@@ -891,6 +902,8 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
$post = apply_filters( 'um_restricted_singular_post', $post, $restriction );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -941,16 +954,18 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
if ( empty( $is_singular ) ) {
|
||||
if ( empty( $restriction['_um_access_hide_from_queries'] ) ) {
|
||||
|
||||
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
|
||||
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
}
|
||||
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
$post->post_excerpt = '';
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
$post->post_excerpt = '';
|
||||
}
|
||||
|
||||
$post = apply_filters( 'um_restricted_archive_post', $post, $restriction );
|
||||
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
}
|
||||
@@ -962,6 +977,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
|
||||
$this->current_single_post = $post;
|
||||
|
||||
@@ -970,6 +986,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
}
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
$post->post_title = stripslashes( $restricted_global_title );
|
||||
|
||||
$this->current_single_post = $post;
|
||||
|
||||
@@ -978,6 +995,8 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
$post = apply_filters( 'um_restricted_singular_post', $post, $restriction );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user