Version Description
- Solved bug by improving regular expression for mailto links
- Changed script attribute
languagetotype - Script only loaded on options page (hopefully this solves the dashboard toggle problem some people are experiencing)
- Added support for widget_content filter of the Logic Widget plugin
Download this release
Release Info
| Developer | freelancephp |
| Plugin | |
| Version | 0.41 |
| Comparing to | |
| See all releases | |
Code changes from version 0.40 to 0.41
- email-encoder-bundle.php +37 -23
- methods/ascii.php +1 -1
- readme.txt +16 -2
email-encoder-bundle.php
CHANGED
|
@@ -4,7 +4,7 @@ Plugin Name: Email Encoder Bundle
|
|
| 4 |
Plugin URI: http://www.freelancephp.net/email-encoder-php-class-wp-plugin/
|
| 5 |
Description: Protect email addresses on your site from spambots and being used for spamming by using one of the encoding methods.
|
| 6 |
Author: Victor Villaverde Laan
|
| 7 |
-
Version: 0.
|
| 8 |
Author URI: http://www.freelancephp.net
|
| 9 |
License: Dual licensed under the MIT and GPL licenses
|
| 10 |
*/
|
|
@@ -20,7 +20,7 @@ class WP_Email_Encoder_Bundle {
|
|
| 20 |
* Current version
|
| 21 |
* @var string
|
| 22 |
*/
|
| 23 |
-
var $version = '0.
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Used as prefix for options entry and could be used as text domain (for translations)
|
|
@@ -38,7 +38,7 @@ class WP_Email_Encoder_Bundle {
|
|
| 38 |
* @var array
|
| 39 |
*/
|
| 40 |
var $options = array(
|
| 41 |
-
'method' =>
|
| 42 |
'encode_mailtos' => 1,
|
| 43 |
'encode_emails' => 1,
|
| 44 |
'class_name' => 'mailto-link',
|
|
@@ -46,6 +46,7 @@ class WP_Email_Encoder_Bundle {
|
|
| 46 |
'filter_widgets' => 1,
|
| 47 |
'filter_comments' => 1,
|
| 48 |
'filter_rss' => 1,
|
|
|
|
| 49 |
'powered_by' => 1,
|
| 50 |
);
|
| 51 |
|
|
@@ -54,7 +55,7 @@ class WP_Email_Encoder_Bundle {
|
|
| 54 |
* @var array
|
| 55 |
*/
|
| 56 |
var $regexp_patterns = array(
|
| 57 |
-
'mailto' => '/<a
|
| 58 |
'tag' => '/\[encode_email\s+(.*?)\]/is',
|
| 59 |
'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
|
| 60 |
);
|
|
@@ -91,7 +92,7 @@ class WP_Email_Encoder_Bundle {
|
|
| 91 |
$this->_set_options();
|
| 92 |
|
| 93 |
// load text domain for translations
|
| 94 |
-
load_plugin_textdomain( $this->domain, dirname(
|
| 95 |
|
| 96 |
// set uninstall hook
|
| 97 |
if ( function_exists( 'register_deactivation_hook' ) )
|
|
@@ -103,7 +104,7 @@ class WP_Email_Encoder_Bundle {
|
|
| 103 |
add_action( 'the_posts', array( $this, 'the_posts' ) );
|
| 104 |
|
| 105 |
// set filters
|
| 106 |
-
add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ),
|
| 107 |
}
|
| 108 |
|
| 109 |
/**
|
|
@@ -156,9 +157,8 @@ class WP_Email_Encoder_Bundle {
|
|
| 156 |
add_filter( 'widget_title', array( $this, '_filter_callback' ), $priority );
|
| 157 |
add_filter( 'widget_text', array( $this, '_filter_callback' ), $priority );
|
| 158 |
|
| 159 |
-
// Only if Widget Logic plugin is installed
|
| 160 |
-
|
| 161 |
-
//add_filter( 'widget_content', array( $this, 'filter_content' ), $priority );
|
| 162 |
}
|
| 163 |
}
|
| 164 |
|
|
@@ -191,7 +191,7 @@ class WP_Email_Encoder_Bundle {
|
|
| 191 |
* Callback admin_menu
|
| 192 |
*/
|
| 193 |
function admin_menu() {
|
| 194 |
-
if ( function_exists('add_options_page') AND current_user_can('manage_options') ) {
|
| 195 |
// add options page
|
| 196 |
$page = add_options_page( 'Email Encoder Bundle', 'Email Encoder Bundle',
|
| 197 |
'manage_options', __FILE__, array( $this, 'options_page' ) );
|
|
@@ -205,12 +205,19 @@ class WP_Email_Encoder_Bundle {
|
|
| 205 |
// register settings
|
| 206 |
register_setting( $this->domain, $this->options_name );
|
| 207 |
|
| 208 |
-
//
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
-
|
| 213 |
-
|
|
|
|
| 214 |
}
|
| 215 |
|
| 216 |
/**
|
|
@@ -218,7 +225,7 @@ class WP_Email_Encoder_Bundle {
|
|
| 218 |
*/
|
| 219 |
function options_page() {
|
| 220 |
?>
|
| 221 |
-
<script
|
| 222 |
jQuery(function( $ ){
|
| 223 |
// remove message
|
| 224 |
$( '.settings-error' )
|
|
@@ -273,7 +280,7 @@ jQuery(function( $ ){
|
|
| 273 |
<div class="icon32" id="icon-options-custom" style="background:url( <?php echo plugins_url( 'images/icon-email-encoder-bundle.png', __FILE__ ) ?> ) no-repeat 50% 50%"><br></div>
|
| 274 |
<h2>Email Encoder Bundle</h2>
|
| 275 |
|
| 276 |
-
<script
|
| 277 |
var methodInfo = <?php echo json_encode( $this->methods ) ?>;
|
| 278 |
</script>
|
| 279 |
<div class="postbox-container metabox-holder meta-box-sortables" style="width: 69%">
|
|
@@ -308,13 +315,13 @@ jQuery(function( $ ){
|
|
| 308 |
<th><?php _e( 'Encode emails', $this->domain ) ?></th>
|
| 309 |
<td>
|
| 310 |
<label><input type="checkbox" name="<?php echo $this->options_name ?>[encode_tags]" value="1" checked="checked" disabled="disabled" />
|
| 311 |
-
<span><?php _e( 'Encode <code>[encode_email]</code>
|
| 312 |
</label>
|
| 313 |
<br/><label><input type="checkbox" id="encode_mailtos" name="<?php echo $this->options_name ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
|
| 314 |
-
<span><?php _e( '
|
| 315 |
</label>
|
| 316 |
<br/><label><input type="checkbox" id="encode_emails" name="<?php echo $this->options_name ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> />
|
| 317 |
-
<span><?php _e( '
|
| 318 |
</label>
|
| 319 |
</td>
|
| 320 |
</tr>
|
|
@@ -326,12 +333,12 @@ jQuery(function( $ ){
|
|
| 326 |
<tr>
|
| 327 |
<th><?php _e( 'Options has effect on', $this->domain ) ?></th>
|
| 328 |
<td><label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
|
| 329 |
-
<span><?php _e( '
|
| 330 |
</label>
|
| 331 |
<br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_comments]" name="<?php echo $this->options_name ?>[filter_comments]" value="1" <?php checked('1', (int) $options['filter_comments']); ?> />
|
| 332 |
-
<span><?php _e( '
|
| 333 |
<br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_widgets]" name="<?php echo $this->options_name ?>[filter_widgets]" value="1" <?php checked('1', (int) $options['filter_widgets']); ?> />
|
| 334 |
-
<span><?php _e( '
|
| 335 |
</td>
|
| 336 |
</tr>
|
| 337 |
<tr>
|
|
@@ -558,7 +565,14 @@ jQuery(function( $ ){
|
|
| 558 |
}
|
| 559 |
}
|
| 560 |
|
|
|
|
| 561 |
$this->set_method( $this->options['method'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
}
|
| 563 |
|
| 564 |
/**
|
| 4 |
Plugin URI: http://www.freelancephp.net/email-encoder-php-class-wp-plugin/
|
| 5 |
Description: Protect email addresses on your site from spambots and being used for spamming by using one of the encoding methods.
|
| 6 |
Author: Victor Villaverde Laan
|
| 7 |
+
Version: 0.41
|
| 8 |
Author URI: http://www.freelancephp.net
|
| 9 |
License: Dual licensed under the MIT and GPL licenses
|
| 10 |
*/
|
| 20 |
* Current version
|
| 21 |
* @var string
|
| 22 |
*/
|
| 23 |
+
var $version = '0.41';
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Used as prefix for options entry and could be used as text domain (for translations)
|
| 38 |
* @var array
|
| 39 |
*/
|
| 40 |
var $options = array(
|
| 41 |
+
'method' => 'lim_email_ascii',
|
| 42 |
'encode_mailtos' => 1,
|
| 43 |
'encode_emails' => 1,
|
| 44 |
'class_name' => 'mailto-link',
|
| 46 |
'filter_widgets' => 1,
|
| 47 |
'filter_comments' => 1,
|
| 48 |
'filter_rss' => 1,
|
| 49 |
+
'widget_content_filter' => 0,
|
| 50 |
'powered_by' => 1,
|
| 51 |
);
|
| 52 |
|
| 55 |
* @var array
|
| 56 |
*/
|
| 57 |
var $regexp_patterns = array(
|
| 58 |
+
'mailto' => '/<a[^<>]*?href=["\']mailto:(.*?)["\'].*?>(.*?)<\/a[\s+]*>/is',
|
| 59 |
'tag' => '/\[encode_email\s+(.*?)\]/is',
|
| 60 |
'email' => '/([A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6})/is',
|
| 61 |
);
|
| 92 |
$this->_set_options();
|
| 93 |
|
| 94 |
// load text domain for translations
|
| 95 |
+
load_plugin_textdomain( $this->domain, FALSE, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
|
| 96 |
|
| 97 |
// set uninstall hook
|
| 98 |
if ( function_exists( 'register_deactivation_hook' ) )
|
| 104 |
add_action( 'the_posts', array( $this, 'the_posts' ) );
|
| 105 |
|
| 106 |
// set filters
|
| 107 |
+
add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ), 10 );
|
| 108 |
}
|
| 109 |
|
| 110 |
/**
|
| 157 |
add_filter( 'widget_title', array( $this, '_filter_callback' ), $priority );
|
| 158 |
add_filter( 'widget_text', array( $this, '_filter_callback' ), $priority );
|
| 159 |
|
| 160 |
+
// Only if Widget Logic plugin is installed and 'widget_content' option is activated
|
| 161 |
+
add_filter( 'widget_content', array( $this, '_filter_callback' ), $priority );
|
|
|
|
| 162 |
}
|
| 163 |
}
|
| 164 |
|
| 191 |
* Callback admin_menu
|
| 192 |
*/
|
| 193 |
function admin_menu() {
|
| 194 |
+
if ( function_exists( 'add_options_page' ) AND current_user_can( 'manage_options' ) ) {
|
| 195 |
// add options page
|
| 196 |
$page = add_options_page( 'Email Encoder Bundle', 'Email Encoder Bundle',
|
| 197 |
'manage_options', __FILE__, array( $this, 'options_page' ) );
|
| 205 |
// register settings
|
| 206 |
register_setting( $this->domain, $this->options_name );
|
| 207 |
|
| 208 |
+
// actions
|
| 209 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_print_scripts' ) );
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
function admin_print_scripts( $hook_suffix ) {
|
| 213 |
+
if( $hook_suffix == 'settings_page_email-encoder-bundle/email-encoder-bundle' ) {
|
| 214 |
+
// set dashboard postbox
|
| 215 |
+
wp_admin_css( 'dashboard' );
|
| 216 |
+
wp_enqueue_script( 'dashboard' );
|
| 217 |
|
| 218 |
+
// add style and script for ajax encoder
|
| 219 |
+
wp_enqueue_script( 'email_encoder', plugins_url( 'js/email-encoder-bundle.js', __FILE__ ), array( 'jquery' ), $this->version );
|
| 220 |
+
}
|
| 221 |
}
|
| 222 |
|
| 223 |
/**
|
| 225 |
*/
|
| 226 |
function options_page() {
|
| 227 |
?>
|
| 228 |
+
<script type="text/javascript">
|
| 229 |
jQuery(function( $ ){
|
| 230 |
// remove message
|
| 231 |
$( '.settings-error' )
|
| 280 |
<div class="icon32" id="icon-options-custom" style="background:url( <?php echo plugins_url( 'images/icon-email-encoder-bundle.png', __FILE__ ) ?> ) no-repeat 50% 50%"><br></div>
|
| 281 |
<h2>Email Encoder Bundle</h2>
|
| 282 |
|
| 283 |
+
<script type="text/javascript">
|
| 284 |
var methodInfo = <?php echo json_encode( $this->methods ) ?>;
|
| 285 |
</script>
|
| 286 |
<div class="postbox-container metabox-holder meta-box-sortables" style="width: 69%">
|
| 315 |
<th><?php _e( 'Encode emails', $this->domain ) ?></th>
|
| 316 |
<td>
|
| 317 |
<label><input type="checkbox" name="<?php echo $this->options_name ?>[encode_tags]" value="1" checked="checked" disabled="disabled" />
|
| 318 |
+
<span><?php _e( 'Encode <code>[encode_email]</code> shortcode', $this->domain ) ?></span>
|
| 319 |
</label>
|
| 320 |
<br/><label><input type="checkbox" id="encode_mailtos" name="<?php echo $this->options_name ?>[encode_mailtos]" value="1" <?php checked('1', (int) $options['encode_mailtos']); ?> />
|
| 321 |
+
<span><?php _e( 'Automatically encode mailto-links', $this->domain ) ?></span>
|
| 322 |
</label>
|
| 323 |
<br/><label><input type="checkbox" id="encode_emails" name="<?php echo $this->options_name ?>[encode_emails]" value="1" <?php checked('1', (int) $options['encode_emails']); ?> />
|
| 324 |
+
<span><?php _e( 'Automatically replace plain emailaddresses to encoded mailto-links', $this->domain ) ?></span>
|
| 325 |
</label>
|
| 326 |
</td>
|
| 327 |
</tr>
|
| 333 |
<tr>
|
| 334 |
<th><?php _e( 'Options has effect on', $this->domain ) ?></th>
|
| 335 |
<td><label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_posts]" value="1" <?php checked('1', (int) $options['filter_posts']); ?> />
|
| 336 |
+
<span><?php _e( 'All posts', $this->domain ) ?></span>
|
| 337 |
</label>
|
| 338 |
<br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_comments]" name="<?php echo $this->options_name ?>[filter_comments]" value="1" <?php checked('1', (int) $options['filter_comments']); ?> />
|
| 339 |
+
<span><?php _e( 'All comments', $this->domain ) ?></span></label>
|
| 340 |
<br/><label><input type="checkbox" id="<?php echo $this->options_name ?>[filter_widgets]" name="<?php echo $this->options_name ?>[filter_widgets]" value="1" <?php checked('1', (int) $options['filter_widgets']); ?> />
|
| 341 |
+
<span><?php if ( $this->options[ 'widget_logic_filter' ] ) { _e( 'All widgets (uses the widget_content filter of the Widget Logic plugin)', $this->domain ); } else { _e( 'All text widgets', $this->domain ); } ?></span></label>
|
| 342 |
</td>
|
| 343 |
</tr>
|
| 344 |
<tr>
|
| 565 |
}
|
| 566 |
}
|
| 567 |
|
| 568 |
+
// set encode method
|
| 569 |
$this->set_method( $this->options['method'] );
|
| 570 |
+
|
| 571 |
+
// set widget_content filter of Widget Logic plugin
|
| 572 |
+
$widget_logic_opts = get_option( 'widget_logic' );
|
| 573 |
+
if ( key_exists( 'widget_logic-options-filter', $widget_logic_opts ) ) {
|
| 574 |
+
$this->options[ 'widget_logic_filter' ] = ( $widget_logic_opts[ 'widget_logic-options-filter' ] == 'checked' ) ? 1 : 0;
|
| 575 |
+
}
|
| 576 |
}
|
| 577 |
|
| 578 |
/**
|
methods/ascii.php
CHANGED
|
@@ -46,7 +46,7 @@ function lim_email_ascii( $email, $display, $obj ) {
|
|
| 46 |
$MailIndexes = str_replace("\\", "\\\\", $MailIndexes);
|
| 47 |
$MailIndexes = str_replace("\"", "\\\"", $MailIndexes);
|
| 48 |
|
| 49 |
-
return '<script
|
| 50 |
. 'ML="'. $MailLettersEnc .'";'
|
| 51 |
. 'MI="'. $MailIndexes .'";'
|
| 52 |
. 'OT="";'
|
| 46 |
$MailIndexes = str_replace("\\", "\\\\", $MailIndexes);
|
| 47 |
$MailIndexes = str_replace("\"", "\\\"", $MailIndexes);
|
| 48 |
|
| 49 |
+
return '<script type="text/javascript">/*<