WP External Links (nofollow new tab seo) - Version 0.34

Version Description

  • Added option only converting external <a> tags to XHTML valid code
  • Changed script attribute language to type
Download this release

Release Info

Developer freelancephp
Plugin Icon 128x128 WP External Links (nofollow new tab seo)
Version 0.34
Comparing to
See all releases

Code changes from version 0.33 to 0.34

Files changed (2) hide show
  1. readme.txt +13 -3
  2. wp-external-links.php +30 -14
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: freelancephp
3
  Tags: links, external, new window, icon, target, _blank, _new, _top, _none, rel, nofollow, javascript, xhtml strict
4
  Requires at least: 2.7.0
5
- Tested up to: 3.1.0
6
- Stable tag: 0.33
7
 
8
  Manage external links on your site: open in new window/tab, set link icon, add "external", add "nofollow" and more.
9
 
@@ -52,13 +52,20 @@ In the last case when using the JavaScript method and jQuery the link would stil
52
 
53
  == Other notes ==
54
 
 
 
 
55
  = Credits =
56
  * Title icon on Admin Options Page was made by [FatCow Web Hosting](http://www.fatcow.com/) taken form [iconfinder](http://findicons.com/icon/164579/link_go?id=427009)
57
 
58
  == Changelog ==
59
 
 
 
 
 
60
  = 0.33 =
61
- * Add option to fix js problem
62
  * Fixed PHP / WP notices
63
 
64
  = 0.32 =
@@ -99,6 +106,9 @@ In the last case when using the JavaScript method and jQuery the link would stil
99
 
100
  == Upgrade Notice ==
101
 
 
 
 
102
  = 0.33 =
103
  * Add option to fix js problem
104
  * Fixed PHP / WP notices
2
  Contributors: freelancephp
3
  Tags: links, external, new window, icon, target, _blank, _new, _top, _none, rel, nofollow, javascript, xhtml strict
4
  Requires at least: 2.7.0
5
+ Tested up to: 3.1.3
6
+ Stable tag: 0.34
7
 
8
  Manage external links on your site: open in new window/tab, set link icon, add "external", add "nofollow" and more.
9
 
52
 
53
  == Other notes ==
54
 
55
+ = TODO =
56
+ * Add a way to exclude links from being filtered
57
+
58
  = Credits =
59
  * Title icon on Admin Options Page was made by [FatCow Web Hosting](http://www.fatcow.com/) taken form [iconfinder](http://findicons.com/icon/164579/link_go?id=427009)
60
 
61
  == Changelog ==
62
 
63
+ = 0.34 =
64
+ * Added option only converting external `<a>` tags to XHTML valid code
65
+ * Changed script attribute `language` to `type`
66
+
67
  = 0.33 =
68
+ * Added option to fix js problem
69
  * Fixed PHP / WP notices
70
 
71
  = 0.32 =
106
 
107
  == Upgrade Notice ==
108
 
109
+ = 0.34 =
110
+ * Solved some issues
111
+
112
  = 0.33 =
113
  * Add option to fix js problem
114
  * Fixed PHP / WP notices
wp-external-links.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP External Links
4
  Plugin URI: http://www.freelancephp.net/wp-external-links-plugin
5
  Description: Manage external links on your site: open in new window/tab, set link icon, add "external", add "nofollow" and more.
6
  Author: Victor Villaverde Laan
7
- Version: 0.33
8
  Author URI: http://www.freelancephp.net
9
  License: Dual licensed under the MIT and GPL licenses
10
  */
@@ -19,7 +19,7 @@ class WP_External_Links {
19
  * Current version
20
  * @var string
21
  */
22
- var $version = '0.33';
23
 
24
  /**
25
  * Used as prefix for options entry and could be used as text domain (for translations)
@@ -46,11 +46,13 @@ class WP_External_Links {
46
  'filter_posts' => 1,
47
  'filter_comments' => 1,
48
  'filter_widgets' => 1,
49
- 'fix_js' => 1,
 
50
  'icon' => 0,
51
  'no_icon_class' => 'no-ext-icon',
52
  'no_icon_same_window' => 0,
53
  'class_name' => 'ext-link',
 
54
  );
55
 
56
  /**
@@ -80,7 +82,7 @@ class WP_External_Links {
80
  $this->_set_options();
81
 
82
  // load text domain for translations
83
- load_plugin_textdomain( $this->domain, dirname( __FILE__ ) . '/lang/', basename( dirname(__FILE__) ) . '/lang/' );
84
 
85
  // set uninstall hook
86
  if ( function_exists( 'register_deactivation_hook' ) )
@@ -137,9 +139,8 @@ class WP_External_Links {
137
  add_filter( 'widget_title', array( $this, 'filter_content' ), $priority );
138
  add_filter( 'widget_text', array( $this, 'filter_content' ), $priority );
139
 
140
- // Only if Widget Logic plugin is installed
141
- // @todo Doesn't work and cannot find another way to filter all widget contents
142
- //add_filter( 'widget_content', array( $this, 'filter_content' ), $priority );
143
  }
144
  }
145
  }
@@ -165,7 +166,7 @@ class WP_External_Links {
165
  ? $this->options[ 'no_icon_class' ]
166
  : '';
167
  ?>
168
- <script language="javascript">/* <![CDATA[ */
169
  /* WP External Links Plugin */
170
  var wpExtLinks = { baseUrl: '<?php echo get_bloginfo( 'url' ) ?>',target: '<?php echo $this->options[ 'target' ] ?>',excludeClass: '<?php echo $excludeClass ?>' };
171
  /* ]]> */</script>
@@ -266,8 +267,10 @@ var wpExtLinks = { baseUrl: '<?php echo get_bloginfo( 'url' ) ?>',target: '<?php
266
  // set target
267
  if ( $this->options[ 'target' ] != '_none' AND ! $this->options[ 'use_js' ] AND ( ! $this->options[ 'no_icon_same_window' ] OR empty( $this->options[ 'no_icon_class' ] ) OR strpos( $attrs[ 'class' ], $this->options[ 'no_icon_class' ] ) === FALSE ) )
268
  $attrs[ 'target' ] = $this->options[ 'target' ];
269
- }
270
 
 
 
 
271
 
272
  // create element code
273
  $link = '<a ';
@@ -300,7 +303,7 @@ var wpExtLinks = { baseUrl: '<?php echo get_bloginfo( 'url' ) ?>',target: '<?php
300
  */
301
  function options_page() {
302
  ?>
303
- <script language="javascript">
304
  jQuery(function( $ ){
305
  // remove message
306
  $( '.settings-error' )
@@ -333,7 +336,12 @@ jQuery(function( $ ){
333
  $inside.css({ display:'none' }).slideDown();
334
  }
335
  });
336
- })
 
 
 
 
 
337
  </script>
338
  <div class="wrap">
339
  <div class="icon32" id="icon-options-custom" style="background:url( <?php echo plugins_url( 'images/icon-wp-external-links.png', __FILE__ ) ?> ) no-repeat 50% 50%"><br></div>
@@ -392,15 +400,17 @@ jQuery(function( $ ){
392
  <br/>&nbsp;&nbsp;<label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_comments]" id="filter_comments" value="1" <?php checked( '1', (int) $options['filter_comments'] ); ?> />
393
  <span><?php _e( 'Comments', $this->domain ) ?></span></label>
394
  <br/>&nbsp;&nbsp;<label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_widgets]" id="filter_widgets" value="1" <?php checked( '1', (int) $options['filter_widgets'] ); ?> />
395
- <span><?php _e( 'Text widgets', $this->domain ) ?></span></label>
396
- <br/>
397
- <br/><span class="description"><?php _e( 'Note: all <code>&lt;a&gt;</code> tags in the selected contents will be converted to XHTML valid code' ) ?></span>
398
  </td>
399
  </tr>
400
  <tr>
401
  <th><?php _e( 'Solve problems...', $this->domain ) ?></th>
402
  <td><label><input type="checkbox" name="<?php echo $this->options_name ?>[fix_js]" id="fix_js" value="1" <?php checked( '1', (int) $options['fix_js'] ); ?> />
403
  <span><?php _e( 'Auto-fix javascript problem (by replacing <code>&lt;/a&gt;</code> with <code>&lt;\/a&gt;</code> in js)', $this->domain ) ?></span></label>
 
 
 
 
404
  </td>
405
  </tr>
406
  </table>
@@ -545,6 +555,12 @@ jQuery(function( $ ){
545
  $this->options[ $key ] = ( empty( $saved_options[ $key ] ) ) ? '' : $saved_options[ $key ];
546
  }
547
  }
 
 
 
 
 
 
548
  }
549
 
550
  } // end class WP_External_Links
4
  Plugin URI: http://www.freelancephp.net/wp-external-links-plugin
5
  Description: Manage external links on your site: open in new window/tab, set link icon, add "external", add "nofollow" and more.
6
  Author: Victor Villaverde Laan
7
+ Version: 0.34
8
  Author URI: http://www.freelancephp.net
9
  License: Dual licensed under the MIT and GPL licenses
10
  */
19
  * Current version
20
  * @var string
21
  */
22
+ var $version = '0.34';
23
 
24
  /**
25
  * Used as prefix for options entry and could be used as text domain (for translations)
46
  'filter_posts' => 1,
47
  'filter_comments' => 1,
48
  'filter_widgets' => 1,
49
+ 'fix_js' => 0,
50
+ 'fix_xhtml' => 0,
51
  'icon' => 0,
52
  'no_icon_class' => 'no-ext-icon',
53
  'no_icon_same_window' => 0,
54
  'class_name' => 'ext-link',
55
+ 'widget_content_filter' => 0,
56
  );
57
 
58
  /**
82
  $this->_set_options();
83
 
84
  // load text domain for translations
85
+ load_plugin_textdomain( $this->domain, FALSE, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
86
 
87
  // set uninstall hook
88
  if ( function_exists( 'register_deactivation_hook' ) )
139
  add_filter( 'widget_title', array( $this, 'filter_content' ), $priority );
140
  add_filter( 'widget_text', array( $this, 'filter_content' ), $priority );
141
 
142
+ // Only if Widget Logic plugin is installed and 'widget_content' option is activated
143
+ add_filter( 'widget_content', array( $this, 'filter_content' ), $priority );
 
144
  }
145
  }
146
  }
166
  ? $this->options[ 'no_icon_class' ]
167
  : '';
168
  ?>
169
+ <script type="text/javascript">/* <![CDATA[ */
170
  /* WP External Links Plugin */
171
  var wpExtLinks = { baseUrl: '<?php echo get_bloginfo( 'url' ) ?>',target: '<?php echo $this->options[ 'target' ] ?>',excludeClass: '<?php echo $excludeClass ?>' };
172
  /* ]]> */</script>
267
  // set target
268
  if ( $this->options[ 'target' ] != '_none' AND ! $this->options[ 'use_js' ] AND ( ! $this->options[ 'no_icon_same_window' ] OR empty( $this->options[ 'no_icon_class' ] ) OR strpos( $attrs[ 'class' ], $this->options[ 'no_icon_class' ] ) === FALSE ) )
269
  $attrs[ 'target' ] = $this->options[ 'target' ];
 
270
 
271
+ } elseif ( $this->options[ 'fix_xhtml' ] ) {
272
+ return $match[ 0 ];
273
+ }
274
 
275
  // create element code
276
  $link = '<a ';
303
  */
304
  function options_page() {
305
  ?>
306
+ <script type="text/javascript">
307
  jQuery(function( $ ){
308
  // remove message
309
  $( '.settings-error' )
336
  $inside.css({ display:'none' }).slideDown();
337
  }
338
  });
339
+
340
+ // note
341
+ $( '#fix_xhtml' ).change(function(){
342
+ $( '#xhtml_convert_all' ).css( 'display', $( this ).attr( 'checked' ) ? 'none' : 'block' );
343
+ }).change();
344
+ });
345
  </script>
346
  <div class="wrap">
347
  <div class="icon32" id="icon-options-custom" style="background:url( <?php echo plugins_url( 'images/icon-wp-external-links.png', __FILE__ ) ?> ) no-repeat 50% 50%"><br></div>
400
  <br/>&nbsp;&nbsp;<label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_comments]" id="filter_comments" value="1" <?php checked( '1', (int) $options['filter_comments'] ); ?> />
401
  <span><?php _e( 'Comments', $this->domain ) ?></span></label>
402
  <br/>&nbsp;&nbsp;<label><input type="checkbox" name="<?php echo $this->options_name ?>[filter_widgets]" id="filter_widgets" value="1" <?php checked( '1', (int) $options['filter_widgets'] ); ?> />
403
+ <span><?php if ( $this->options[ 'widget_logic_filter' ] ) { _e( 'All widgets (uses the <code>widget_content</code> filter of the Widget Logic plugin)', $this->domain ); } else { _e( 'All text widgets', $this->domain ); } ?></span></label>
 
 
404
  </td>
405
  </tr>
406
  <tr>
407
  <th><?php _e( 'Solve problems...', $this->domain ) ?></th>
408
  <td><label><input type="checkbox" name="<?php echo $this->options_name ?>[fix_js]" id="fix_js" value="1" <?php checked( '1', (int) $options['fix_js'] ); ?> />
409
  <span><?php _e( 'Auto-fix javascript problem (by replacing <code>&lt;/a&gt;</code> with <code>&lt;\/a&gt;</code> in js)', $this->domain ) ?></span></label>
410
+ <br/><label><input type="checkbox" name="<?php echo $this->options_name ?>[fix_xhtml]" id="fix_xhtml" value="1" <?php checked( '1', (int) $options['fix_xhtml'] ); ?> />
411
+ <span><?php _e( 'Only convert <strong>external</strong> links of the selected content to valid XHTML code (instead of all &lt;a&gt;-tags)', $this->domain ) ?></span></label>
412
+ <br/>
413
+ <br/><span id="xhtml_convert_all" class="description"><?php _e( 'Note: all <code>&lt;a&gt;</code> tags in the selected contents will be converted to XHTML valid code' ) ?></span>
414
  </td>
415
  </tr>
416
  </table>
555
  $this->options[ $key ] = ( empty( $saved_options[ $key ] ) ) ? '' : $saved_options[ $key ];
556
  }
557
  }
558
+
559
+ // set widget_content filter of Widget Logic plugin
560
+ $widget_logic_opts = get_option( 'widget_logic' );
561
+ if ( key_exists( 'widget_logic-options-filter', $widget_logic_opts ) ) {
562
+ $this->options[ 'widget_logic_filter' ] = ( $widget_logic_opts[ 'widget_logic-options-filter' ] == 'checked' ) ? 1 : 0;
563
+ }
564
  }
565
 
566
  } // end class WP_External_Links