- fixed content restriction for some themes, which make the_content filter;

This commit is contained in:
nikitozzzzzzz
2018-02-05 11:25:47 +02:00
parent 65e7cbdeaa
commit 9b7cac4f50
+25 -2
View File
@@ -28,6 +28,12 @@ if ( ! class_exists( 'Access' ) ) {
private $allow_access; private $allow_access;
/**
* @var \WP_Post
*/
private $current_single_post;
/** /**
* Access constructor. * Access constructor.
*/ */
@@ -35,7 +41,6 @@ if ( ! class_exists( 'Access' ) ) {
$this->singular_page = false; $this->singular_page = false;
$this->redirect_handler = false; $this->redirect_handler = false;
$this->allow_access = 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'] ) { if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
$post->post_content = stripslashes( $restricted_global_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 ) { if ( 'attachment' == $post->post_type ) {
remove_filter( 'the_content', 'prepend_attachment' ); remove_filter( 'the_content', 'prepend_attachment' );
} }
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { } 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_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' ); 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 * Protect Post Types in menu query
* Restrict content new logic * Restrict content new logic