PluginProbe ʕ •ᴥ•ʔ
Email Encoder – Protect Email Addresses and Phone Numbers / 2.5.0
Email Encoder – Protect Email Addresses and Phone Numbers v2.5.0
2.5.0 2.4.8 trunk 0.10 0.11 0.12 0.20 0.21 0.22 0.30 0.31 0.32 0.40 0.41 0.42 0.50 0.60 0.70 0.71 0.80 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.5 1.5.2 1.51 1.53 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7
email-encoder-bundle / src / Front / FrontCore.php
email-encoder-bundle / src / Front Last commit date
Shortcodes 1 month ago DisplayEmailImage.php 3 months ago Front.php 2 months ago FrontBuffering.php 3 months ago FrontCore.php 3 months ago FrontEnqueue.php 3 months ago FrontTemplateTags.php 3 months ago
FrontCore.php
135 lines
1 <?php
2
3 namespace OnlineOptimisation\EmailEncoderBundle\Front;
4
5 if ( ! defined( 'ABSPATH' ) ) exit;
6
7 use OnlineOptimisation\EmailEncoderBundle\Traits\PluginHelper;
8
9 class FrontCore
10 {
11 use PluginHelper;
12
13 private int $protection_method;
14 private bool $protect_shortcode_tags;
15 // private bool $protect_using;
16
17
18 public function boot(): void
19 {
20 add_action( 'init', [ $this, 'register' ] );
21 }
22
23
24 public function register(): void
25 {
26 $this->protection_method = (int) $this->getSetting( 'protect', true );
27 $this->protect_shortcode_tags = $this->getSettingBool( 'protect_shortcode_tags', true, 'filter_body' );
28
29 $hook_name = (bool) $this->getSetting( 'filter_hook', true, 'filter_body' ) ? 'init' : 'wp';
30
31 add_action( $hook_name, [ $this, 'register_hooks' ], 100 );
32 add_action( $hook_name, [ $this, 'register_rss_hooks' ], 100 );
33 }
34
35
36 public function register_rss_hooks(): void
37 {
38 if ( !is_feed() ) {
39 return;
40 }
41
42 $filter_rss = $this->getSettingBool( 'filter_rss', true, 'filter_body' );
43 $remove_shortcodes_rss = $this->getSettingBool( 'remove_shortcodes_rss', true, 'filter_body' );
44
45 if ( $filter_rss ) {
46 add_filter( $this->getFinalOutputBufferHook(), [ $this, 'filter_rss' ], 100 );
47 }
48
49 if ( $remove_shortcodes_rss ) {
50 add_filter( $this->getFinalOutputBufferHook(), [ $this, 'remove_shortcodes' ], 100 );
51 }
52
53 }
54
55
56 public function register_hooks(): void
57 {
58 $exit_early = $this->protection_method === $this->settings()::PROTECT_DISABLED
59 || $this->isQueryParameterExcluded()
60 || $this->isPostExcluded()
61 ;
62
63 if ( $exit_early ) {
64 return;
65 }
66
67
68 if ( $this->protection_method === $this->settings()::PROTECT_FILTERS_ONLY ) {
69
70 $filter_hooks = [
71 'the_title',
72 'the_content',
73 'the_excerpt',
74 'get_the_excerpt',
75
76 //Comment related
77 'comment_text',
78 'comment_excerpt',
79 'comment_url',
80 'get_comment_author_url',
81 'get_comment_author_url_link',
82
83 //Widgets
84 'widget_title',
85 'widget_text',
86 'widget_content',
87 'widget_output',
88 ];
89
90 $filter_hooks = apply_filters( 'eeb/frontend/wordpress_filters', $filter_hooks );
91
92 foreach ( $filter_hooks as $hook ) {
93 add_filter( $hook, [ $this, 'filter_content' ], 100 );
94 }
95 } elseif ( $this->protection_method === $this->settings()::PROTECT_FULL_PAGE ) {
96
97 add_filter( $this->getFinalOutputBufferHook(), [ $this, 'filter_page' ], 100 );
98 }
99
100 if ( $this->protect_shortcode_tags ) {
101 add_filter( 'do_shortcode_tag', [ $this, 'filter_content' ], 10 );
102 }
103
104 }
105
106
107 public function filter_page( string $content ): string
108 {
109 $protect_using = (string) $this->getSetting( 'protect_using', true );
110 return $this->filterPage( $content, $protect_using );
111 }
112
113
114 public function filter_content( string $content ): string
115 {
116 $protect_using = (string) $this->getSetting( 'protect_using', true );
117 return $this->filterContent( $content, $protect_using );
118 }
119
120
121 public function filter_rss( string $content ): string
122 {
123 $protection_type = (string) $this->getSetting( 'protect_using', true );
124 return $this->validate()->filters->filter_rss( $content, $protection_type );
125 }
126
127
128 // strip shortcodes like [eeb_content], [eeb_form]
129 public function remove_shortcodes( string $content ): string
130 {
131 return strip_shortcodes( $content );
132 }
133
134 }
135