mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- fixed content restriction for some themes, which make the_content filter;
This commit is contained in:
@@ -28,6 +28,12 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
private $allow_access;
|
||||
|
||||
|
||||
/**
|
||||
* @var \WP_Post
|
||||
*/
|
||||
private $current_single_post;
|
||||
|
||||
|
||||
/**
|
||||
* Access constructor.
|
||||
*/
|
||||
@@ -35,7 +41,6 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
|
||||
$this->singular_page = false;
|
||||
|
||||
|
||||
$this->redirect_handler = false;
|
||||
$this->allow_access = false;
|
||||
|
||||
@@ -592,13 +597,19 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
|
||||
$this->current_single_post = $post;
|
||||
add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 );
|
||||
|
||||
if ( 'attachment' == $post->post_type ) {
|
||||
remove_filter( 'the_content', 'prepend_attachment' );
|
||||
}
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
|
||||
if ( 'attachment' == $post->post_type ) {
|
||||
$this->current_single_post = $post;
|
||||
add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 );
|
||||
|
||||
if ( 'attachment' == $post->post_type ) {
|
||||
remove_filter( 'the_content', 'prepend_attachment' );
|
||||
}
|
||||
}
|
||||
@@ -694,6 +705,18 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function replace_post_content( $content ) {
|
||||
$content = $this->current_single_post->post_content;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Protect Post Types in menu query
|
||||
* Restrict content new logic
|
||||
|
||||
Reference in New Issue
Block a user