PluginProbe ʕ •ᴥ•ʔ
Email Encoder – Protect Email Addresses and Phone Numbers / 2.3.9
Email Encoder – Protect Email Addresses and Phone Numbers v2.3.9
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 / Traits / PluginHelper.php
email-encoder-bundle / src / Traits Last commit date
PluginHelper.php 6 months ago
PluginHelper.php
216 lines
1 <?php
2
3 namespace OnlineOptimisation\EmailEncoderBundle\Traits;
4
5 use Legacy\EmailEncoderBundle\Email_Encoder;
6 use Legacy\EmailEncoderBundle\Email_Encoder_Helpers;
7 use Legacy\EmailEncoderBundle\Email_Encoder_Settings;
8 use Legacy\EmailEncoderBundle\Email_Encoder_Validate;
9
10 use OnlineOptimisation\EmailEncoderBundle\Admin\Admin;
11 use OnlineOptimisation\EmailEncoderBundle\Front\Front;
12 use OnlineOptimisation\EmailEncoderBundle\Validate\Validate;
13
14 trait PluginHelper
15 {
16 # MAJORS =================================================================
17
18 public function plugin(): Email_Encoder
19 {
20 return Email_Encoder::instance();
21 }
22
23 // public function validate(): Email_Encoder_Validate
24 public function validate(): Validate
25 {
26 return $this->plugin()->validate;
27 }
28
29 public function helper(): Email_Encoder_Helpers
30 {
31 return $this->plugin()->helpers;
32 }
33
34 public function settings(): Email_Encoder_Settings
35 {
36 return $this->plugin()->settings;
37 }
38
39 public function context() //: Admin|Front
40 {
41 return $this->plugin()->context;
42 }
43
44 # SETTINGS ===============================================================
45
46 public function getSetting( string $slug = '', bool $single = false, string $group = '' )
47 {
48 $value = $this->plugin()->settings->get_setting( $slug, $single, $group );
49 if ( is_string( $value ) ) {
50 $value = sanitize_text_field( $value );
51 }
52
53 return $value;
54 }
55
56 public function getSettingBool( string $slug = '', bool $single = false, string $group = '' ): bool {
57 return filter_var( $this->getSetting( $slug, $single, $group ), FILTER_VALIDATE_BOOLEAN );
58 }
59
60 public function getPageName(): string
61 {
62 return $this->plugin()->settings->get_page_name();
63 }
64
65 public function getPageTitle(): string
66 {
67 return $this->plugin()->settings->get_page_title();
68 }
69
70 public function getSettingsKey(): string
71 {
72 return $this->plugin()->settings->get_settings_key();
73 }
74
75 public function getFinalOutputBufferHook(): string
76 {
77 return $this->plugin()->settings->get_final_output_buffer_hook();
78 }
79
80 public function getWidgetCallbackHook(): string
81 {
82 return $this->plugin()->settings->get_widget_callback_hook();
83 }
84
85 public function getTemplateTags(): array
86 {
87 return $this->plugin()->settings->get_template_tags();
88 }
89
90 public function getSafeHtmlAttr(): array
91 {
92 return $this->plugin()->settings->get_safe_html_attr();
93 }
94
95 public function getAdminCap( string $target = 'main' ): string
96 {
97 return $this->plugin()->settings->get_admin_cap( $target );
98 }
99
100 public function getHookPriorities( string $method ): string
101 {
102 return $this->plugin()->settings->get_hook_priorities( $method );
103 }
104
105 public function reloadSettings(): ?array
106 {
107 return $this->plugin()->settings->reload_settings();
108 }
109
110 # VALIDATE ===============================================================
111
112 public function isQueryParameterExcluded(): bool
113 {
114 return $this->validate()->form->is_query_parameter_excluded();
115 }
116
117 public function isPostExcluded(): bool
118 {
119 return $this->validate()->form->is_post_excluded();
120 }
121
122
123 public function filterContent( string $content, string $protect_using ): string
124 {
125 return $this->validate()->filters->filter_content( $content, $protect_using );
126 }
127
128 public function filterPage( string $content, string $protect_using ): string
129 {
130 return $this->validate()->filters->filter_page( $content, $protect_using );
131 }
132
133 public function filterPlainEmails( ...$args ): string
134 {
135 return $this->validate()->filters->filter_plain_emails( ...$args );
136 }
137
138
139 public function dynamicJsEmailEncoding( ...$args ): string
140 {
141 return $this->validate()->encoding->dynamic_js_email_encoding( ...$args );
142 }
143
144 public function tempEncodeAtSymbol( ...$args ): string
145 {
146 return $this->validate()->encoding->temp_encode_at_symbol( ...$args );
147 }
148
149 public function encodeAscii( ...$args ): string
150 {
151 return $this->validate()->encoding->encode_ascii( ...$args );
152 }
153
154 public function encodeEscape( ...$args ): string
155 {
156 return $this->validate()->encoding->encode_escape( ...$args );
157 }
158
159 public function encodeEmailCss( ...$args ): string
160 {
161 return $this->validate()->encoding->encode_email_css( ...$args );
162 }
163
164 public function createProtectedMailto( ...$args ): string
165 {
166 return $this->validate()->encoding->create_protected_mailto( ...$args );
167 }
168
169 public function createProtectedHrefAtt( ...$args ): string
170 {
171 return $this->validate()->encoding->create_protected_href_att( ...$args );
172 }
173
174 public function getEncodedEmailIcon( ...$args ): string
175 {
176 return $this->validate()->encoding->get_encoded_email_icon( ...$args );
177 }
178
179 public function generateEmailImageUrl( ...$args ): string
180 {
181 return $this->validate()->encoding->generate_email_image_url( ...$args );
182 }
183
184
185 public function getEncoderForm( ...$args ): string
186 {
187 return $this->validate()->form->get_encoder_form( ...$args );
188 }
189
190
191 # LOG ====================================================================
192
193 public function log( $data ): void
194 {
195 error_log( print_r( $data, true ) );
196 }
197
198 # USEFUL =================================================================
199
200 private function assetJsDir( string $filename ): string {
201 return EEB_PLUGIN_DIR . 'assets/js/' . $filename;
202 }
203
204 private function assetCssDir( string $filename ): string {
205 return EEB_PLUGIN_DIR . 'assets/css/' . $filename;
206 }
207
208 private function assetJsUrl( string $filename ): string {
209 return EEB_PLUGIN_URL . 'assets/js/' . $filename;
210 }
211
212 private function assetCssUrl( string $filename ): string {
213 return EEB_PLUGIN_URL . 'assets/css/' . $filename;
214 }
215
216 }