PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / 3.1
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress v3.1
4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / ContentProtection / Frontend / PostContent.php
wp-user-avatar / src / ContentProtection / Frontend Last commit date
Checker.php 5 years ago PostContent.php 5 years ago Redirect.php 5 years ago index.php 5 years ago
PostContent.php
143 lines
1 <?php
2
3 namespace ProfilePress\Core\ContentProtection\Frontend;
4
5
6 use ProfilePress\Core\ContentProtection\SettingsPage;
7 use ProfilePress\Core\Classes\PROFILEPRESS_sql;
8
9 class PostContent
10 {
11 public function __construct()
12 {
13 add_filter('the_content', [$this, 'the_content'], 9999999999999999999);
14 }
15
16 public function the_content($content)
17 {
18 $metas = PROFILEPRESS_sql::get_meta_data_by_key(SettingsPage::META_DATA_KEY);
19
20 if (is_array($metas)) {
21
22 foreach ($metas as $meta) {
23
24 $meta = ppress_var($meta, 'meta_value', []);
25
26 if ( ! in_array(ppress_var($meta, 'is_active', true), ['true', true], true)) continue;
27
28 $access_condition = ppress_var($meta, 'access_condition', []);
29
30 $noaccess_action = ppress_var($access_condition, 'noaccess_action');
31
32 if ('message' != $noaccess_action) continue;
33
34 $who_can_access = ppress_var($access_condition, 'who_can_access', 'everyone');
35
36 $access_roles = ppress_var($access_condition, 'access_roles', []);
37
38 $noaccess_message_type = ppress_var($access_condition, 'noaccess_action_message_type', 'global');
39
40 $custom_message = ppress_var($access_condition, 'noaccess_action_message_custom', 'global');
41
42 if (Checker::content_match($meta['content'])) {
43
44 if (Checker::is_blocked($who_can_access, $access_roles)) {
45 $content = $this->get_restricted_message($noaccess_message_type, $custom_message);
46 }
47
48 break;
49 };
50 }
51 }
52
53 return $content;
54 }
55
56 public function get_restricted_message($noaccess_message_type = 'global', $custom_message = '')
57 {
58 $message = '';
59
60 $global_message = ppress_settings_by_key(
61 'global_restricted_access_message',
62 esc_html__('You are unauthorized to view this page.', 'wp-user-avatar'),
63 true
64 );
65
66 switch ($noaccess_message_type) {
67 case 'custom':
68 $message = wpautop($custom_message);
69 break;
70 case 'post_excerpt':
71 $message = $this->get_post_excerpt();
72 break;
73 case 'post_excerpt_global':
74 $message = $this->get_post_excerpt() . $this->parse_message($global_message);
75 break;
76 case 'post_excerpt_custom':
77 $message = $this->get_post_excerpt() . $this->parse_message($custom_message);
78 break;
79 }
80
81 if (empty($message)) {
82 $message = $this->parse_message($global_message);
83 }
84
85 return $message;
86 }
87
88 public function parse_message($message)
89 {
90 return do_shortcode(wpautop($message));
91 }
92
93 public function get_post_excerpt()
94 {
95 global $post;
96
97 if ( ! is_object($post)) return false;
98
99 $length = apply_filters('ppress_content_protection_excerpt_length', 100);
100
101 $more = false;
102
103 if (has_excerpt($post->ID)) {
104 $the_excerpt = $post->post_excerpt;
105 } elseif (strstr($post->post_content, '<!--more-->')) {
106 $more = true;
107 $length = strpos($post->post_content, '<!--more-->');
108 $the_excerpt = $post->post_content;
109 } else {
110 $the_excerpt = $post->post_content;
111 }
112
113 $tags = apply_filters('ppress_content_protection_excerpt_tags', '<a><img><em><i><code><ins><del><strong><blockquote><ul><ol><li><h1><h2><h3><h4><h5><h6><b>');
114
115 if ($more) {
116 $the_excerpt = strip_shortcodes(strip_tags(stripslashes(substr($the_excerpt, 0, $length)), $tags));
117 } else {
118 $the_excerpt = strip_shortcodes(strip_tags(stripslashes($the_excerpt), $tags));
119 $the_excerpt = preg_split('/\b/', $the_excerpt, $length * 2 + 1);
120 $excerpt_waste = array_pop($the_excerpt);
121 $the_excerpt = implode($the_excerpt);
122
123 if ( ! empty($the_excerpt)) {
124 $the_excerpt .= apply_filters('ppress_content_protection_excerpt_extra', ' . . .');
125 }
126 }
127
128 $the_excerpt = wpautop($the_excerpt);
129
130 return apply_filters('ppress_content_protection_excerpt', $the_excerpt, $post, $length, $tags);
131 }
132
133 public static function get_instance()
134 {
135 static $instance = null;
136
137 if (is_null($instance)) {
138 $instance = new self();
139 }
140
141 return $instance;
142 }
143 }