PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 1.1.2
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v1.1.2
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
content-control / classes / Site / Feeds.php

Feeds.php in Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More 1.1.2, at classes/Site/Feeds.php

60 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JP\CC\Site;
5
6 use JP\CC\Options;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12
13 class Feeds {
14
15 public static function init() {
16 add_action( 'the_excerpt', array( __CLASS__, 'filter_feed_posts' ) );
17 add_action( 'the_content', array( __CLASS__, 'filter_feed_posts' ) );
18 add_filter( 'jp_cc_restricted_message', array( __CLASS__, 'restricted_message_filter' ), 10, 1 );
19 }
20
21 public static function filter_feed_posts( $content ) {
22 global $post;
23
24 if( ! is_feed() ) {
25 return $content;
26 }
27
28 if ( ! isset( Restrictions::$protected_posts[ $post->ID ] ) ) {
29 Restrictions::$protected_posts[ $post->ID ] = Restrictions::restricted_content();
30 }
31
32 $restricted_content = Restrictions::$protected_posts[ $post->ID ];
33
34 if ( ! $restricted_content ) {
35 return $content;
36 }
37
38 if ( isset( $restricted_content['override_default_message'] ) ) {
39 $message = $restricted_content['custom_message'];
40 } else {
41 $message = Options::get( 'default_denial_message', '' );
42 }
43
44 if ( empty( $message ) ) {
45 $message = __( 'This content is restricted.', 'content-control' );
46 }
47
48 //return Posts::format_message( $message );
49 return Posts::format_message( $message );
50 }
51
52 public static function restricted_message_filter( $message ) {
53 if ( ! is_feed() ) {
54 return $message;
55 }
56 return do_shortcode( $message );
57 }
58
59 }
60