PluginProbe ʕ •ᴥ•ʔ
Email Encoder – Protect Email Addresses and Phone Numbers / 2.0.6
Email Encoder – Protect Email Addresses and Phone Numbers v2.0.6
2.5.3 2.5.2 2.5.1 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 / core / includes / classes / class-email-encoder-bundle-settings.php
email-encoder-bundle / core / includes / classes Last commit date
class-email-encoder-bundle-ajax.php 6 years ago class-email-encoder-bundle-helpers.php 6 years ago class-email-encoder-bundle-run-admin.php 6 years ago class-email-encoder-bundle-run.php 6 years ago class-email-encoder-bundle-settings.php 6 years ago class-email-encoder-bundle-validate.php 6 years ago index.php 6 years ago
class-email-encoder-bundle-settings.php
795 lines
1 <?php
2
3 /**
4 * Class Email_Encoder_Settings
5 *
6 * This class contains all of our important settings
7 * Here you can configure the whole plugin behavior.
8 *
9 * @since 2.0.0
10 * @package EEB
11 * @author Ironikus <info@ironikus.com>
12 */
13 class Email_Encoder_Settings{
14
15 /**
16 * Our globally used capability
17 *
18 * @var string
19 * @since 2.0.0
20 */
21 private $admin_cap;
22
23 /**
24 * The main page name
25 *
26 * @var string
27 * @since 2.0.0
28 */
29 private $page_name;
30
31 /**
32 * Email_Encoder_Settings constructor.
33 *
34 * We define all of our necessary settings in here.
35 * If you need to do plugin related changes, everything will
36 * be available in this file.
37 */
38 function __construct(){
39 $this->admin_cap = 'manage_options';
40 $this->page_name = 'email-encoder-bundle-option-page';
41 $this->page_title = EEB_NAME;
42 $this->final_outout_buffer_hook = 'final_output';
43 $this->widget_callback_hook = 'widget_output';
44 $this->template_tags = array( 'eeb_filter' => 'template_tag_eeb_filter', 'eeb_mailto' => 'template_tag_eeb_mailto' );
45 $this->settings_key = 'WP_Email_Encoder_Bundle_options';
46 $this->version_key = 'email-encoder-bundle-version';
47 $this->image_secret_key = 'email-encoder-bundle-img-key';
48 $this->at_identifier = '##eebAddIdent##';
49 $this->previous_version = null;
50 $this->hook_priorities = array(
51 'buffer_final_output' => 1000,
52 'setup_single_filter_hooks' => 100,
53 'add_custom_template_tags' => 10,
54 'load_frontend_header_styling' => 10,
55 'eeb_dynamic_sidebar_params' => 100,
56 'filter_rss' => 100,
57 'filter_page' => 100,
58 'filter_content' => 100,
59 'first_version_init' => 100,
60 'version_update' => 100,
61 'display_email_image' => 10,
62 'callback_rss_remove_shortcodes' => 10,
63 'load_ajax_scripts_styles' => 10,
64 'load_ajax_scripts_styles_admin' => 10,
65 );
66
67 //Regex
68 $this->email_regex = '([_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,}))';
69 $this->soft_attribute_regex = array(
70 'woocommerce_variation_attribute_tag' => '/data-product_variations="([^"]*)"/i',
71 'jetpack_carousel_image_attribute_tag' => '/data-image-meta="([^"]*)"/i',
72 'html_placeholder_tag' => '/placeholder="([^"]*)"/i',
73 );
74
75 //Load data
76 $this->settings = $this->load_settings();
77 $this->version = $this->load_version();
78 $this->email_image_secret = $this->load_email_image_secret();
79 }
80
81 /**
82 * ######################
83 * ###
84 * #### MAIN SETTINGS
85 * ###
86 * ######################
87 */
88
89 /**
90 * Load the settings for our admin settings page
91 *
92 * @return array - An array with all available settings and filled values
93 */
94 private function load_settings(){
95 $fields = array(
96
97 'protect' => array(
98 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
99 'id' => 'protect',
100 'type' => 'multi-input',
101 'input-type' => 'radio',
102 'title' => __( 'Protect emails', 'email-encoder-bundle' ),
103 'inputs' => array(
104 1 => array(
105 'label' => __( 'Full-page scan', 'email-encoder-bundle' ),
106 'description' => __('This will check the whole page against any mails and secures them.', 'email-encoder-bundle' )
107 ),
108 2 => array(
109 'label' => __( 'Wordpress filters', 'email-encoder-bundle' ),
110 'description' => __('Secure only mails that occur within WordPress filters. (Not recommended)', 'email-encoder-bundle' ),
111 'advanced' => true,
112 ),
113 3 => array(
114 'label' => __( 'Don\'t do anything.', 'email-encoder-bundle' ),
115 'description' => __('This turns off the protection for emails. (Not recommended)', 'email-encoder-bundle')
116 ),
117 ),
118 'required' => false
119 ),
120
121 'protect_using' => array(
122 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
123 'id' => 'protect_using',
124 'type' => 'multi-input',
125 'input-type' => 'radio',
126 'title' => __( 'Protect emails using', 'email-encoder-bundle' ),
127 'inputs' => array(
128 'with_javascript' => array(
129 'label' => __( 'automatically the best method (including javascript)', 'email-encoder-bundle' )
130 ),
131 'without_javascript' => array(
132 'label' => __( 'automatically the best method (excluding javascript)', 'email-encoder-bundle' ),
133 ),
134 'strong_method' => array(
135 'label' => __( 'a strong method that replaces all emails with a "*protection text*".', 'email-encoder-bundle' ),
136 'description' => __('You can configure the protection text within the advanced settings.', 'email-encoder-bundle')
137 ),
138 'char_encode' => array(
139 'label' => __( 'simple HTML character encoding.', 'email-encoder-bundle' ),
140 'description' => __('Offers good (but not the best) protection, which saves you in most scenarios.', 'email-encoder-bundle')
141 ),
142 ),
143 'required' => false
144 ),
145
146 'filter_body' => array(
147 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
148 'id' => 'filter_body',
149 'type' => 'multi-input',
150 'input-type' => 'checkbox',
151 'advanced' => true,
152 'title' => __( 'Protect...', 'email-encoder-bundle' ),
153 'label' => __( 'Customize what this plugin protects.', 'email-encoder-bundle' ),
154 'inputs' => array(
155 'filter_rss' => array(
156 'advanced' => true,
157 'label' => __( 'RSS feed', 'email-encoder-bundle' ),
158 'description' => __( 'Activating this option results in protecting the rss feed based on the given protection method.', 'email-encoder-bundle' )
159 ),
160 'remove_shortcodes_rss' => array(
161 'advanced' => true,
162 'label' => __( 'Remove all shortcodes from the RSS feeds', 'email-encoder-bundle' ),
163 'description' => __( 'Activating this option results in protecting the rss feed based on the given protection method.', 'email-encoder-bundle' )
164 ),
165 'input_strong_protection' => array(
166 'advanced' => true,
167 'label' => __( 'input form email fields using strong protection.', 'email-encoder-bundle' ),
168 'description' => __( 'Warning: this option could conflict with certain form plugins. Test it first. (Requires javascript)', 'email-encoder-bundle' )
169 ),
170 'encode_mailtos' => array(
171 'advanced' => true,
172 'label' => __( 'plain emails by converting them to mailto links', 'email-encoder-bundle' ),
173 'description' => __( 'Plain emails will be automatically converted to mailto links where possible.', 'email-encoder-bundle' )
174 ),
175 'convert_plain_to_image' => array(
176 'advanced' => true,
177 'label' => __( 'plain emails by converting them to png images', 'email-encoder-bundle' ),
178 'description' => __( 'Plain emails will be automatically converted to png images where possible.', 'email-encoder-bundle' )
179 ),
180 'protect_shortcode_tags' => array(
181 'advanced' => true,
182 'label' => __( 'shortcode content', 'email-encoder-bundle' ),
183 'description' => __( 'Protect every shortcode content separately. (This may slows down your site)', 'email-encoder-bundle' )
184 ),
185 'filter_hook' => array(
186 'advanced' => true,
187 'label' => __( 'emails from "init" hook', 'email-encoder-bundle' ),
188 'description' => __( 'Check this option if you want to register the email filters on the "init" hook instead of the "wp" hook.', 'email-encoder-bundle' )
189 ),
190 'deactivate_rtl' => array(
191 'advanced' => true,
192 'label' => __( 'mailto links without CSS direction', 'email-encoder-bundle' ),
193 'description' => __( 'Check this option if your site does not support CSS directions.', 'email-encoder-bundle' )
194 ),
195 'no_script_tags' => array(
196 'advanced' => true,
197 'label' => __( 'no script tags', 'email-encoder-bundle' ),
198 'description' => __( 'Check this option if you face issues with encoded script tags. This will deactivate protection for script tags.', 'email-encoder-bundle' )
199 ),
200 'no_attribute_validation' => array(
201 'advanced' => true,
202 'label' => __( 'html attributes without soft encoding.', 'email-encoder-bundle' ),
203 'description' => __( 'Do not soft-filter all html attributes. This might optimizes the performance, but can break the site if other plugins use your email in attribute tags.', 'email-encoder-bundle' )
204 ),
205 ),
206 'required' => false,
207 ),
208
209 'image_settings' => array(
210 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
211 'id' => 'image_settings',
212 'type' => 'multi-input',
213 'input-type' => 'text',
214 'advanced' => true,
215 'title' => __( 'Image settings', 'email-encoder-bundle' ),
216 'label' => __( 'Customize the settings for dynamically created images.', 'email-encoder-bundle' ),
217 'inputs' => array(
218 'image_color' => array(
219 'advanced' => true,
220 'label' => __( 'Image Colors', 'email-encoder-bundle' ),
221 'description' => __( 'Please include RGB colors, comme saparated. E.g.: 0,0,255', 'email-encoder-bundle' )
222 ),
223 'image_background_color' => array(
224 'advanced' => true,
225 'label' => __( 'Image Background Colors', 'email-encoder-bundle' ),
226 'description' => __( 'Please include RGB colors, comme saparated. E.g.: 0,0,255', 'email-encoder-bundle' )
227 ),
228 'image_text_opacity' => array(
229 'advanced' => true,
230 'label' => __( 'Text Opacity', 'email-encoder-bundle' ),
231 'description' => __( 'Change the text opacity for the created images. 0 = not transparent - 127 = completely transprent', 'email-encoder-bundle' )
232 ),
233 'image_background_opacity' => array(
234 'advanced' => true,
235 'label' => __( 'Background Opacity', 'email-encoder-bundle' ),
236 'description' => __( 'Change the background opacity for the created images. 0 = not transparent - 127 = completely transprent', 'email-encoder-bundle' )
237 ),
238 'image_font_size' => array(
239 'advanced' => true,
240 'label' => __( 'Font Size', 'email-encoder-bundle' ),
241 'description' => __( 'Change the font size of the image text. Default: 4 - You can choose from 1 - 5', 'email-encoder-bundle' )
242 ),
243 ),
244 'required' => false,
245 ),
246
247 'skip_posts' => array(
248 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
249 'id' => 'skip_posts',
250 'type' => 'text',
251 'advanced' => true,
252 'title' => __('Exclude post id\'s from protection', 'email-encoder-bundle'),
253 'placeholder' => '',
254 'required' => false,
255 'description' => __('By comma separating post id\'s ( e.g. 123,4535,643), you are able to exclude these posts from the logic protection.', 'email-encoder-bundle')
256 ),
257
258 'protection_text' => array(
259 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
260 'id' => 'protection_text',
261 'type' => 'text',
262 'advanced' => true,
263 'title' => __('Set protection text *', 'email-encoder-bundle'),
264 'placeholder' => '',
265 'required' => false,
266 'description' => __('This text will be shown for protected email addresses and within noscript tags.', 'email-encoder-bundle')
267 ),
268
269 'class_name' => array(
270 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
271 'id' => 'class_name',
272 'type' => 'text',
273 'advanced' => true,
274 'title' => __('Additional classes', 'email-encoder-bundle'),
275 'label' => __('Add extra classes to mailto links.', 'email-encoder-bundle'),
276 'placeholder' => '',
277 'required' => false,
278 'description' => __('Leave blank for none', 'email-encoder-bundle')
279 ),
280
281 'footer_scripts' => array(
282 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
283 'id' => 'footer_scripts',
284 'type' => 'checkbox',
285 'advanced' => true,
286 'title' => __('Load scripts in footer', 'email-encoder-bundle'),
287 'label' => __('Check this button if you want to load all frontend scripts within the footer.', 'email-encoder-bundle'),
288 'placeholder' => '',
289 'required' => false,
290 'description' => __('This forces every script to be enqueued within the footer.', 'email-encoder-bundle')
291 ),
292
293 'show_encoded_check' => array(
294 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
295 'id' => 'show_encoded_check',
296 'type' => 'checkbox',
297 'title' => __('Security Check', 'email-encoder-bundle'),
298 'label' => __('Mark emails on the site as successfully encoded', 'email-encoder-bundle') . '<i class="dashicons-before dashicons-lock" style="color:green;"></i>',
299 'placeholder' => '',
300 'required' => false,
301 'description' => __('Only visible for admin users. If your emails look broken, simply deactivate this feature.', 'email-encoder-bundle')
302 ),
303
304 'own_admin_menu' => array(
305 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
306 'id' => 'own_admin_menu',
307 'type' => 'checkbox',
308 'advanced' => true,
309 'title' => __('Admin Menu', 'email-encoder-bundle'),
310 'label' => __('Show this page in the main menu item', 'email-encoder-bundle'),
311 'placeholder' => '',
312 'required' => false,
313 'description' => __('Otherwise it will be shown in "Settings"-menu.', 'email-encoder-bundle')
314 ),
315
316 'encoder_form' => array(
317 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
318 'id' => 'encoder_form',
319 'type' => 'multi-input',
320 'input-type' => 'checkbox',
321 'advanced' => true,
322 'title' => __( 'Encoder form settings', 'email-encoder-bundle' ),
323 'inputs' => array(
324 'display_encoder_form' => array(
325 'label' => __( 'Activate the encoder form.', 'email-encoder-bundle' ),
326 'description' => __( 'This allows you to use the email encoder form, as well as the shortcode and template tag.', 'email-encoder-bundle' )
327 ),
328 'powered_by' => array(
329 'label' => __( 'Show a "powered by" link on bottom of the encoder form', 'email-encoder-bundle' ),
330 ),
331 ),
332 'required' => false
333 ),
334
335 'advanced_settings' => array(
336 'fieldset' => array( 'slug' => 'main', 'label' => 'Label' ),
337 'id' => 'advanced_settings',
338 'type' => 'checkbox',
339 'title' => __('Advanced Settings', 'email-encoder-bundle'),
340 'label' => __('Show advanced settings for more configuration possibilities.', 'email-encoder-bundle'),
341 'placeholder' => '',
342 'required' => false,
343 'description' => __('Activate the advanced settings in case you want to customize the default logic or you want to troubleshoot the plugin.', 'email-encoder-bundle')
344 ),
345
346 );
347
348 $fields = apply_filters( 'eeb/settings/pre_filter_fields', $fields );
349
350 $default_values = array(
351 'protect' => 1,
352 'filter_rss' => 1,
353 'display_encoder_form' => 1,
354 'powered_by' => 1,
355 'protect_using' => 'with_javascript',
356 'class_name' => 'mail-link',
357 'protection_text' => '*protected email*',
358 'image_color' => '0,0,0',
359 'image_background_color'=> '0,0,0',
360 'image_text_opacity' => '0',
361 'image_background_opacity' => '127',
362 'image_font_size' => '4',
363 );
364 $values = get_option( $this->settings_key );
365
366 if( empty( $values ) && ! is_array( $values ) ){
367 update_option( $this->settings_key, $default_values );
368 $values = $default_values;
369 }
370
371 //Bakwards compatibility
372 if( ! isset( $values['protect_using'] ) ){
373 $values['protect_using'] = 'with_javascript';
374 $values['display_encoder_form'] = 1;
375 }
376
377 //In case the mailto functiinality was deactivated, we will set it do "Do nothing" as well.
378 if( ! isset( $values['protect'] ) ){
379 $values['protect'] = 1;
380 }
381 ///Backwards compatibility
382
383 //Value corrections
384 if( ! isset( $values['image_color'] ) ){
385 $values['image_color'] = $default_values['image_color'];
386 }
387 $image_color = explode( ',', $values['image_color'] );
388 if( count( $image_color ) != 3 ){
389 $values['image_color'] = $default_values['image_color'];
390 }
391 foreach( explode( ',', $values['image_color'] ) as $image_color_key => $image_color_single ){
392 if( ! is_numeric( trim( $image_color_single ) ) ){
393 $values['image_color'] = $default_values['image_color'];
394 }
395 }
396
397 if( ! isset( $values['image_background_color'] ) ){
398 $values['image_background_color'] = $default_values['image_background_color'];
399 }
400 $image_background_color = explode( ',', $values['image_background_color'] );
401 if( count( $image_background_color ) != 3 ){
402 $values['image_background_color'] = $default_values['image_background_color'];
403 }
404 foreach( explode( ',', $values['image_background_color'] ) as $image_background_color_key => $image_background_color_single ){
405 if( ! is_numeric( trim( $image_background_color_single ) ) ){
406 $values['image_background_color'] = $default_values['image_background_color'];
407 }
408 }
409
410 if( ! isset( $values['image_text_opacity'] ) || ! is_numeric( $values['image_text_opacity'] ) ){
411 $values['image_text_opacity'] = $default_values['image_text_opacity'];
412 }
413 if( ! isset( $values['image_background_opacity'] ) || ! is_numeric( $values['image_background_opacity'] ) ){
414 $values['image_background_opacity'] = $default_values['image_background_opacity'];
415 }
416 if( ! isset( $values['image_font_size'] ) || ! is_numeric( $values['image_font_size'] ) ){
417 $values['image_font_size'] = $default_values['image_font_size'];
418 }
419 ///Value corrections
420
421 foreach( $fields as $key => $field ){
422 if( $field['type'] === 'multi-input' ){
423 foreach( $field['inputs'] as $smi_key => $smi_data ){
424
425 if( $field['input-type'] === 'radio' ){
426 if( isset( $values[ $key ] ) && (string) $values[ $key ] === (string) $smi_key ){
427 $fields[ $key ]['value'] = $values[ $key ];
428 }
429 } else {
430 if( isset( $values[ $smi_key ] ) ){
431 $fields[ $key ]['inputs'][ $smi_key ]['value'] = $values[ $smi_key ];
432 }
433 }
434
435 }
436 } else {
437 if( isset( $values[ $key ] ) ){
438 $fields[ $key ]['value'] = $values[ $key ];
439 }
440 }
441 }
442
443 return apply_filters( 'eeb/settings/fields', $fields );
444 }
445
446 /**
447 * ######################
448 * ###
449 * #### VERSIONING
450 * ###
451 * ######################
452 */
453
454 public function load_version(){
455
456 $current_version = get_option( $this->get_version_key() );
457
458 if( empty( $current_version ) ){
459 $current_version = EEB_VERSION;
460 update_option( $this->get_version_key(), $current_version );
461
462 add_action( 'init', array( $this, 'first_version_init' ), $this->get_hook_priorities( 'first_version_init' ) );
463 } else {
464 if( $current_version !== EEB_VERSION ){
465 $this->previous_version = $current_version;
466 $current_version = EEB_VERSION;
467 update_option( $this->get_version_key(), $current_version );
468
469 add_action( 'init', array( $this, 'version_update' ), $this->get_hook_priorities( 'version_update' ) );
470 }
471 }
472
473 return $current_version;
474 }
475
476 public function load_email_image_secret(){
477
478 if( ! (bool) $this->get_setting( 'convert_plain_to_image', true, 'filter_body' ) ){
479 return false;
480 }
481
482 $image_descret = get_option( $this->get_image_secret_key() );
483
484 if( ! empty( $image_descret ) ){
485 return $image_descret;
486 }
487
488 $key = '';
489
490 for ($i = 0; $i < 265; $i++) {
491 $key .= chr(mt_rand(33, 126));
492 }
493
494 update_option( $this->get_image_secret_key(), $key );
495
496 return $key;
497 }
498
499 /**
500 * Fires an action after our settings key was initially set
501 * the very first time.
502 *
503 * @return void
504 */
505 public function first_version_init(){
506 do_action( 'eeb/settings/first_version_init', EEB_VERSION );
507 }
508
509 /**
510 * Fires after the version of the plugin is initially updated
511 *
512 * @return void
513 */
514 public function version_update(){
515 do_action( 'eeb/settings/version_update', EEB_VERSION, $this->previous_version );
516 }
517
518 /**
519 * ######################
520 * ###
521 * #### CALLABLE FUNCTIONS
522 * ###
523 * ######################
524 */
525
526 /**
527 * Our admin cap handler function
528 *
529 * This function handles the admin capability throughout
530 * the whole plugin.
531 *
532 * $target - With the target function you can make a more precised filtering
533 * by changing it for specific actions.
534 *
535 * @param string $target - A identifier where the call comes from
536 * @return mixed
537 */
538 public function get_admin_cap( $target = 'main' ){
539 /**
540 * Customize the globally used capability for this plugin
541 *
542 * This filter is called every time the capability is needed.
543 */
544 return apply_filters( 'eeb/settings/capability', $this->admin_cap, $target );
545 }
546
547 /**
548 * Return the page name for our admin page
549 *
550 * @return string - the page name
551 */
552 public function get_page_name(){
553 /*
554 * Filter the page name based on your needs
555 */
556 return apply_filters( 'eeb/settings/page_name', $this->page_name );
557 }
558
559 /**
560 * Return the page title for our admin page
561 *
562 * @return string - the page title
563 */
564 public function get_page_title(){
565 /*
566 * Filter the page title based on your needs.
567 */
568 return apply_filters( 'eeb/settings/page_title', $this->page_title );
569 }
570
571 /**
572 * Return the settings_key
573 *
574 * @return string - the settings key
575 */
576 public function get_settings_key(){
577 return $this->settings_key;
578 }
579
580 /**
581 * Return the version_key
582 *
583 * @return string - the version_key
584 */
585 public function get_version_key(){
586 return $this->version_key;
587 }
588
589 /**
590 * Return the image_secret_key
591 *
592 * @return string - the image_secret_key
593 */
594 public function get_image_secret_key(){
595 return $this->image_secret_key;
596 }
597
598 /**
599 * Return the email_image_secret
600 *
601 * @return string - the email_image_secret
602 */
603 public function get_email_image_secret(){
604 return $this->email_image_secret;
605 }
606
607 /**
608 * Return the version
609 *
610 * @return string - the version
611 */
612 public function get_version(){
613 return apply_filters( 'eeb/settings/get_version', $this->version );
614 }
615
616 /**
617 * Return the default template tags
618 *
619 * @return array - the template tags
620 */
621 public function get_template_tags(){
622 return apply_filters( 'eeb/settings/get_template_tags', $this->template_tags );
623 }
624
625 /**
626 * Return the widget callback hook name
627 *
628 * @return string - the final widget callback hook name
629 */
630 public function get_widget_callback_hook(){
631 return apply_filters( 'eeb/settings/widget_callback_hook', $this->widget_callback_hook );
632 }
633
634 /**
635 * Return the final output buffer hook name
636 *
637 * @return string - the final output buffer hook name
638 */
639 public function get_final_outout_buffer_hook(){
640 return apply_filters( 'eeb/settings/final_outout_buffer_hook', $this->final_outout_buffer_hook );
641 }
642
643 /**
644 * Return the @ symbol identifier
645 *
646 * @return string - the @ symbol identifier
647 */
648 public function get_at_identifier(){
649 return apply_filters( 'eeb/settings/at_identifier', $this->at_identifier );
650 }
651
652 /**
653 * @link http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/
654 * @param boolean $include
655 * @return string
656 */
657 public function get_email_regex( $include = false ){
658
659 if ($include === true) {
660 $return = $this->email_regex;
661 } else {
662 $return = '/' . $this->email_regex . '/i';
663 }
664
665 return apply_filters( 'eeb/settings/get_email_regex', $return, $include );
666 }
667
668 /**
669 * Get Woocommerce variation attribute regex
670 *
671 * @param boolean $include
672 * @return string
673 */
674 public function get_soft_attribute_regex( $single = null ){
675
676 $return = $this->soft_attribute_regex;
677
678 if( $single !== null ){
679 if( isset( $this->soft_attribute_regex[ $single ] ) ){
680 $return = $this->soft_attribute_regex[ $single ];
681 } else {
682 $return = false;
683 }
684 }
685
686 return apply_filters( 'eeb/settings/get_soft_attribute_regex', $return, $single );
687 }
688
689 /**
690 * Get hook priorities
691 *
692 * @param boolean $single - wether you want to return only a single hook priority or not
693 * @return mixed - An array or string of hook priority(-ies)
694 */
695 public function get_hook_priorities( $single = false ){
696
697 $return = $this->hook_priorities;
698 $default = false;
699
700 if( $single ){
701 if( isset( $this->hook_priorities[ $single ] ) ){
702 $return = $this->hook_priorities[ $single ];
703 } else {
704 $return = 10;
705 $default = true;
706 }
707 }
708
709 return apply_filters( 'eeb/settings/get_hook_priorities', $return, $default, $single );
710 }
711
712 /**
713 * ######################
714 * ###
715 * #### Settings helper
716 * ###
717 * ######################
718 */
719
720 /**
721 * Get the admin page url
722 *
723 * @return string - The admin page url
724 */
725 public function get_admin_page_url(){
726
727 $url = admin_url( "options-general.php?page=" . $this->get_page_name() );
728
729 return apply_filters( 'eeb/settings/get_admin_page_url', $url );
730 }
731
732 /**
733 * Helper function to reload the settings
734 *
735 * @return array - An array of all available settings
736 */
737 public function reload_settings(){
738
739 $this->settings = $this->load_settings();
740
741 return $this->settings;
742 }
743
744 /**
745 * Return the default strings that are available
746 * for this plugin.
747 *
748 * @param $slug - the identifier for your specified setting
749 * @param $single - wether you only want to return the value or the whole settings element
750 * @param $group - in case you call a multi-input that contains multiple values (e.g. checkbox), you can set a sub-slug to grab the sub value
751 * @return string - the default string
752 */
753 public function get_setting( $slug = '', $single = false, $group = '' ){
754 $return = $this->settings;
755
756 if( empty( $slug ) ){
757 return $return;
758 }
759
760 if( isset( $this->settings[ $slug ] ) || ( ! empty( $group ) && isset( $this->settings[ $group ] ) ) ){
761 if( $single ){
762 $return = false; // Default false
763
764 //Set default to the main valie if available given with radio buttons)
765 if( isset( $this->settings[ $slug ]['value'] ) ){
766 $return = $this->settings[ $slug ]['value'];
767 }
768
769 if(
770 ! empty( $group )
771 && isset( $this->settings[ $group ]['type'] )
772 && $this->settings[ $group ]['type'] === 'multi-input'
773 )
774 {
775 if( isset( $this->settings[ $group ]['inputs'][ $slug ] ) && isset( $this->settings[ $group ]['inputs'][ $slug ]['value'] ) ){
776 $return = $this->settings[ $group ]['inputs'][ $slug ]['value'];
777 }
778 }
779
780 } else {
781
782 if( ! empty( $group ) && isset( $this->settings[ $group ] ) ){
783 $return = $this->settings[ $group ];
784 } else {
785 $return = $this->settings[ $slug ];
786 }
787
788 }
789
790 }
791
792 return $return;
793 }
794
795 }