-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwordpress-email-obfuscator-shortcode.php
More file actions
42 lines (35 loc) · 1.09 KB
/
wordpress-email-obfuscator-shortcode.php
File metadata and controls
42 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/*
Plugin Name: Email Obfuscator Shortcode
Description: Shortcode to obfuscate email addresses.
Author: websperts <hello@websperts.com>
Author URI: http://websperts.com/
Plugin URI: https://github.com/websperts/wordpress-email-obfuscator-shortcode
License: MIT
Version: 0.0.1
*/
defined('ABSPATH') || exit;
function email_shortcode($attributes) {
extract(shortcode_atts(array(
'address' => '',
'text' => '',
'at' => 'AT',
'dot' => 'DOT'
), $attributes));
if (empty($address)) {
return '';
} else {
$address = str_replace(array('@', '.'), array(' '.$at.' ', ' '.$dot.' '), $address);
if (empty($text)) {
$text = $address;
}
return '<span class="obfuscated" data-content="'.$text.'"'.(!empty($at) ? ' data-at="'.$at.'"' : '').(!empty($dot) ? ' data-dot="'.$dot.'"' : '').'>'.$address.'</span>';
}
}
add_shortcode('email', 'email_shortcode');
function deobfuscate_script() {
wp_register_script('deobfuscate_script', plugins_url('deobfuscate.min.js', __FILE__), null, '1.0', true);
wp_enqueue_script('deobfuscate_script');
}
add_action('wp_enqueue_scripts', 'deobfuscate_script');
?>