PluginProbe ʕ •ᴥ•ʔ
Email Encoder – Protect Email Addresses and Phone Numbers / 2.3.6
Email Encoder – Protect Email Addresses and Phone Numbers v2.3.6
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 6 months ago DisplayEmailImage.php 6 months ago Front.php 6 months ago FrontBuffering.php 6 months ago FrontCore.php 6 months ago FrontEnqueue.php 6 months ago FrontTemplateTags.php 6 months ago
FrontCore.php
133 lines
1 <?php
2
3 namespace OnlineOptimisation\EmailEncoderBundle\Front;
4
5 use OnlineOptimisation\EmailEncoderBundle\Traits\PluginHelper;
6
7 class FrontCore
8 {
9 use PluginHelper;
10
11 private int $protection_method;
12 private bool $protect_shortcode_tags;
13 private bool $protect_using;
14
15
16 public function boot(): void {
17
18 add_action( 'init', [ $this, 'register' ] );
19 }
20
21
22 public function register(): void {
23 $this->protection_method = (int) $this->getSetting( 'protect', true );
24 $this->protect_shortcode_tags = $this->getSettingBool( 'protect_shortcode_tags', true, 'filter_body' );
25
26 $hook_name = (bool) $this->getSetting( 'filter_hook', true, 'filter_body' ) ? 'init' : 'wp';
27
28 add_action( $hook_name, [ $this, 'register_hooks' ], 100 );
29 add_action( $hook_name, [ $this, 'register_rss_hooks' ], 100 );
30 }
31
32
33 public function register_rss_hooks(): void {
34
35 if ( !is_feed() ) {
36 return;
37 }
38
39 $filter_rss = $this->getSettingBool( 'filter_rss', true, 'filter_body' );
40 $remove_shortcodes_rss = $this->getSettingBool( 'remove_shortcodes_rss', true, 'filter_body' );
41
42 if ( $filter_rss ) {
43 add_filter( $this->getFinalOutputBufferHook(), [ $this, 'filter_rss' ], 100 );
44 }
45
46 if ( $remove_shortcodes_rss ) {
47 add_filter( $this->getFinalOutputBufferHook(), [ $this, 'remove_shortcodes' ], 100 );
48 }
49
50 }
51
52
53 public function register_hooks(): void {
54
55 $exit_early = $this->protection_method === $this->settings()::PROTECT_DISABLED
56 || $this->isQueryParameterExcluded()
57 || $this->isPostExcluded()
58 ;
59
60 if ( $exit_early ) {
61 return;
62 }
63
64
65 if ( $this->protection_method === $this->settings()::PROTECT_FILTERS_ONLY ) {
66
67 $filter_hooks = [
68 'the_title',
69 'the_content',
70 'the_excerpt',
71 'get_the_excerpt',
72
73 //Comment related
74 'comment_text',
75 'comment_excerpt',
76 'comment_url',
77 'get_comment_author_url',
78 'get_comment_author_url_link',
79
80 //Widgets
81 'widget_title',
82 'widget_text',
83 'widget_content',
84 'widget_output',
85 ];
86
87 $filter_hooks = apply_filters( 'eeb/frontend/wordpress_filters', $filter_hooks );
88
89 foreach ( $filter_hooks as $hook ) {
90 add_filter( $hook, [ $this, 'filter_content' ], 100 );
91 }
92 }
93 elseif ( $this->protection_method === $this->settings()::PROTECT_FULL_PAGE ) {
94
95 add_filter( $this->getFinalOutputBufferHook(), [ $this, 'filter_page' ], 100 );
96 }
97
98 if ( $this->protect_shortcode_tags ) {
99 add_filter( 'do_shortcode_tag', [ $this, 'filter_content' ], 10 );
100 }
101
102 }
103
104
105 public function filter_page( string $content ): string {
106
107 $protect_using = (string) $this->getSetting( 'protect_using', true );
108 return $this->filterPage( $content, $protect_using );
109 }
110
111
112 public function filter_content( string $content ): string {
113
114 $protect_using = (string) $this->getSetting( 'protect_using', true );
115 return $this->filterContent( $content, $protect_using );
116 }
117
118
119 public function filter_rss( string $content ): string {
120
121 $protection_type = (string) $this->getSetting( 'protect_using', true );
122 return $this->validate()->filter_rss( $content, $protection_type );
123 }
124
125
126 // strip shortcodes like [eeb_content], [eeb_form]
127 public function remove_shortcodes( string $content ): string {
128
129 return strip_shortcodes( $content );
130 }
131
132 }
133