Email Address Encoder - Version 1.0.6

Version Description

  • Added [encode] shortcode
  • Require PHP 5.3 to fix deprecation warning
Download this release

Release Info

Developer tillkruess
Plugin Icon 128x128 Email Address Encoder
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

Files changed (2) hide show
  1. email-address-encoder.php +37 -12
  2. readme.txt +15 -3
email-address-encoder.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Email Address Encoder
4
  Plugin URI: http://wordpress.org/plugins/email-address-encoder/
5
  Description: A lightweight plugin to protect email addresses from email-harvesting robots by encoding them into decimal and hexadecimal entities.
6
- Version: 1.0.5
7
  Author: Till Krüss
8
  Author URI: https://till.im/
9
  Text Domain: email-address-encoder
@@ -29,6 +29,34 @@ foreach ( array( 'the_content', 'the_excerpt', 'widget_text', 'comment_text', 'c
29
  add_filter( $filter, 'eae_encode_emails', EAE_FILTER_PRIORITY );
30
  }
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  /**
33
  * Searches for plain email addresses in given $string and
34
  * encodes them (by default) with the help of eae_encode_str().
@@ -37,7 +65,8 @@ foreach ( array( 'the_content', 'the_excerpt', 'widget_text', 'comment_text', 'c
37
  * http://daringfireball.net/projects/markdown/
38
  *
39
  * @param string $string Text with email addresses to encode
40
- * @return string $string Given text with encoded email addresses
 
41
  */
42
  function eae_encode_emails( $string ) {
43
 
@@ -73,14 +102,9 @@ function eae_encode_emails( $string ) {
73
  }xi'
74
  );
75
 
76
- return preg_replace_callback(
77
- $regexp,
78
- create_function(
79
- '$matches',
80
- 'return ' . $method . '($matches[0]);'
81
- ),
82
- $string
83
- );
84
 
85
  }
86
 
@@ -96,8 +120,9 @@ function eae_encode_emails( $string ) {
96
  * Whose code is based on a filter by Matthew Wickline, posted to
97
  * the BBEdit-Talk with some optimizations by Milian Wolff.
98
  *
99
- * @param string $string Text with email addresses to encode
100
- * @return string $string Given text with encoded email addresses
 
101
  */
102
  function eae_encode_str( $string ) {
103
 
3
  Plugin Name: Email Address Encoder
4
  Plugin URI: http://wordpress.org/plugins/email-address-encoder/
5
  Description: A lightweight plugin to protect email addresses from email-harvesting robots by encoding them into decimal and hexadecimal entities.
6
+ Version: 1.0.6
7
  Author: Till Krüss
8
  Author URI: https://till.im/
9
  Text Domain: email-address-encoder
29
  add_filter( $filter, 'eae_encode_emails', EAE_FILTER_PRIORITY );
30
  }
31
 
32
+ /**
33
+ * Attempt to register the shortcode relatively late to avoid conflicts.
34
+ */
35
+ add_action( 'init', 'register_shortcode', 1000 );
36
+
37
+ /**
38
+ * Register the [encode] shortcode if it doesn't exist, yet.
39
+ *
40
+ * @return void
41
+ */
42
+ function register_shortcode() {
43
+ if ( ! shortcode_exists( 'encode' ) ) {
44
+ add_shortcode( 'encode', 'eae_shortcode' );
45
+ }
46
+ }
47
+
48
+ /**
49
+ * The [encode] shortcode callback function. Returns encoded shortcode content.
50
+ *
51
+ * @param array $attributes Shortcode attributes
52
+ * @param string $string Shortcode content
53
+ *
54
+ * @return string Encoded given text
55
+ */
56
+ function eae_shortcode( $attributes, $content = '' ) {
57
+ return eae_encode_str( $content );
58
+ }
59
+
60
  /**
61
  * Searches for plain email addresses in given $string and
62
  * encodes them (by default) with the help of eae_encode_str().
65
  * http://daringfireball.net/projects/markdown/
66
  *
67
  * @param string $string Text with email addresses to encode
68
+ *
69
+ * @return string Given text with encoded email addresses
70
  */
71
  function eae_encode_emails( $string ) {
72
 
102
  }xi'
103
  );
104
 
105
+ return preg_replace_callback( $regexp, function ( $matches ) use ( $method ) {
106
+ return $method( $matches[0] );
107
+ }, $string );
 
 
 
 
 
108
 
109
  }
110
 
120
  * Whose code is based on a filter by Matthew Wickline, posted to
121
  * the BBEdit-Talk with some optimizations by Milian Wolff.
122
  *
123
+ * @param string $string Text to encode
124
+ *
125
+ * @return string Encoded given text
126
  */
127
  function eae_encode_str( $string ) {
128
 
readme.txt CHANGED
@@ -4,7 +4,8 @@ Donate link: https://www.paypal.me/tillkruss
4
  Tags: antispam, anti spam, spam, email, e-mail, mail, spider, crawler, harvester, robots, spambot, block, obfuscate, obfuscation, encode, encoder, encoding, encrypt, encryption, protect, protection
5
  Requires at least: 2.0
6
  Tested up to: 4.9
7
- Stable tag: 1.0.5
 
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -31,6 +32,8 @@ For detailed installation instructions, please read the [standard installation p
31
 
32
  This plugin hooks into the WordPress filters like `the_content`, `widget_text` and others (additional filters can be added). On each filter a quick (disableable) search for an @-sign is performed. If an @-sign is found, a (overridable) regular expression looks for plain text email addresses. Found email addresses are replaced with the return value of `eae_encode_str()` (changeable), which obfuscates the email addresses to protect it from being read by email-harvesting robots. This function is slightly faster than WP's built-in `antispambot()` and uses additional hexadecimal entities.
33
 
 
 
34
  = How can I make sure the plugin works? =
35
 
36
  You cannot use Firebug, Web Inspector or Dragonfly, because they decode decimal/hexadecimal entities into plain text. To make sure email addresses are encoded, right-/secondary-click the page, click "View Source", "View Page Source" or "Source" and search for any plain text email addresses. In Firefox, be sure to test with "View Source" not "View Selection Source".
@@ -41,8 +44,8 @@ You specify any valid callback function with the `eae_method` filter to apply to
41
 
42
  = How can I filter other parts of my site? =
43
 
44
- * If the content supports WordPress filters, register the `eae_encode_emails()` function to it: `add_filter( $tag, 'eae_encode_emails' );`.
45
- * If the content is a PHP string, run it through the `eae_encode_emails()` function: `$text = eae_encode_emails( $text );`.
46
  * If you want to encode a single email address, use the `eae_encode_str()` function: `<?php echo eae_encode_str( 'name@domain.com' ); ?>`
47
 
48
  This plugin doesn't encode the entire website for performance reasons, it encodes only the content of the following WordPress filters `the_content`, `the_excerpt`, `widget_text`, `comment_text`, `comment_excerpt`.
@@ -62,6 +65,11 @@ Like this: `add_filter( 'eae_at_sign_check', '__return_false' );`
62
 
63
  == Changelog ==
64
 
 
 
 
 
 
65
  = 1.0.5 =
66
 
67
  * Prevented error when `eae_encode_emails()` doesn't receive a `string`
@@ -91,6 +99,10 @@ Like this: `add_filter( 'eae_at_sign_check', '__return_false' );`
91
 
92
  == Upgrade Notice ==
93
 
 
 
 
 
94
  = 1.0.5 =
95
 
96
  This update includes a minor bug fix.
4
  Tags: antispam, anti spam, spam, email, e-mail, mail, spider, crawler, harvester, robots, spambot, block, obfuscate, obfuscation, encode, encoder, encoding, encrypt, encryption, protect, protection
5
  Requires at least: 2.0
6
  Tested up to: 4.9
7
+ Requires PHP: 5.3
8
+ Stable tag: 1.0.6
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
32
 
33
  This plugin hooks into the WordPress filters like `the_content`, `widget_text` and others (additional filters can be added). On each filter a quick (disableable) search for an @-sign is performed. If an @-sign is found, a (overridable) regular expression looks for plain text email addresses. Found email addresses are replaced with the return value of `eae_encode_str()` (changeable), which obfuscates the email addresses to protect it from being read by email-harvesting robots. This function is slightly faster than WP's built-in `antispambot()` and uses additional hexadecimal entities.
34
 
35
+ Alternatively, you can use the `[encode]` shortcode: `[encode]+1 (234) 567-8900[/encode]`
36
+
37
  = How can I make sure the plugin works? =
38
 
39
  You cannot use Firebug, Web Inspector or Dragonfly, because they decode decimal/hexadecimal entities into plain text. To make sure email addresses are encoded, right-/secondary-click the page, click "View Source", "View Page Source" or "Source" and search for any plain text email addresses. In Firefox, be sure to test with "View Source" not "View Selection Source".
44
 
45
  = How can I filter other parts of my site? =
46
 
47
+ * If the content supports WordPress filters, register the `eae_encode_emails()` function to it: `add_filter( $tag, 'eae_encode_emails' );`
48
+ * If the content is a PHP string, run it through the `eae_encode_emails()` function: `$text = eae_encode_emails( $text );`
49
  * If you want to encode a single email address, use the `eae_encode_str()` function: `<?php echo eae_encode_str( 'name@domain.com' ); ?>`
50
 
51
  This plugin doesn't encode the entire website for performance reasons, it encodes only the content of the following WordPress filters `the_content`, `the_excerpt`, `widget_text`, `comment_text`, `comment_excerpt`.
65
 
66
  == Changelog ==
67
 
68
+ = 1.0.6 =
69
+
70
+ * Added `[encode]` shortcode
71
+ * Require PHP 5.3 to fix deprecation warning
72
+
73
  = 1.0.5 =
74
 
75
  * Prevented error when `eae_encode_emails()` doesn't receive a `string`
99
 
100
  == Upgrade Notice ==
101
 
102
+ = 1.0.6 =
103
+
104
+ This release adds PHP 7.2 compatibility and a new shortcode.
105
+
106
  = 1.0.5 =
107
 
108
  This update includes a minor bug fix.