Nofollow for external link - Version 1.2.0

Version Description

  • Not add rel=nofollow and target=_blank for "/about-us" type internal links.
  • Add rel=nofollow and target=_blank for theme menus
  • Security updates
Download this release

Release Info

Developer cybernetikz
Plugin Icon 128x128 Nofollow for external link
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.2 to 1.2.0

Files changed (4) hide show
  1. index.php +0 -0
  2. nofollow-external-link.php +33 -8
  3. readme.txt +15 -10
  4. screenshot-2.png +0 -0
index.php ADDED
File without changes
nofollow-external-link.php CHANGED
@@ -3,12 +3,25 @@
3
  Plugin Name: Nofollow for external link
4
  Plugin URI: http://www.cybernetikz.com
5
  Description: Just simple, if you activate this plugins, <code>rel=&quot;nofollow&quot;</code> and <code>target=&quot;_blank&quot;</code> will be added automatically, for all the external links of your website <strong>posts</strong> or <strong>pages</strong>. Also you can <strong>exclude domains</strong>, not to add <code>rel=&quot;nofollow&quot;</code> for the selected external links.
6
- Version: 1.1.2
7
  Author: CyberNetikz
8
  Author URI: http://www.cybernetikz.com
9
  License: GPL2
10
  */
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  function cn_nf_admin_sidebar() {
13
 
14
  $banners = array(
@@ -49,19 +62,20 @@ function cn_nf_admin_style() {
49
  }
50
  add_action( 'admin_enqueue_scripts', 'cn_nf_admin_style' );
51
 
52
- add_action('admin_menu', 'cn_nf_plugin_menu');
53
- add_action( 'admin_init', 'register_cn_nf_settings' );
54
-
55
  function register_cn_nf_settings() {
56
  register_setting( 'cn-nf-settings-group', 'cn_nf_exclude_domains' );
 
57
  }
 
58
 
59
  function cn_nf_plugin_menu() {
60
  add_options_page('Nofollow for external link', 'NoFollow ExtLink', 'manage_options', 'cn_nf_option_page', 'cn_nf_option_page_fn');
61
  }
 
62
 
63
  function cn_nf_option_page_fn() {
64
  $cn_nf_exclude_domains = get_option('cn_nf_exclude_domains');
 
65
  ?>
66
  <div class="wrap">
67
  <h2>Nofollow for external link Options</h2>
@@ -70,10 +84,17 @@ function cn_nf_option_page_fn() {
70
  <form method="post" action="options.php" enctype="multipart/form-data">
71
  <?php settings_fields( 'cn-nf-settings-group' ); ?>
72
  <table class="form-table">
 
 
 
 
 
 
 
73
  <tr valign="top">
74
  <th scope="row">Exclude Domains</th>
75
  <td><textarea name="cn_nf_exclude_domains" id="cn_nf_exclude_domains" class="large-text" placeholder="mydomain.com, my-domain.org, another-domain.net"><?php echo $cn_nf_exclude_domains?></textarea>
76
- <br /><em>Domain name <code>MUST BE</code> comma(,) separated. <!--<br />Example: facebook.com, google.com, youtube.com-->Don't need to add <code>http://</code> or <code>https://</code><br /><code>rel="nofollow"</code> will not added to "Exclude Domains"</em></td>
77
  </tr>
78
  </table>
79
  <p class="submit">
@@ -89,8 +110,6 @@ function cn_nf_option_page_fn() {
89
  <?php
90
  }
91
 
92
- add_filter( 'the_content', 'cn_nf_url_parse');
93
-
94
  function cn_nf_url_parse( $content ) {
95
 
96
  $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>";
@@ -113,7 +132,7 @@ function cn_nf_url_parse( $content ) {
113
  $url = $matches[$i][0];
114
 
115
  // bypass #more type internal link
116
- $res = preg_match('/href(\s)*=(\s)*"#[a-zA-Z0-9-_]+"/',$url);
117
  if($res) {
118
  continue;
119
  }
@@ -166,4 +185,10 @@ function cn_nf_url_parse( $content ) {
166
 
167
  $content = str_replace(']]>', ']]&gt;', $content);
168
  return $content;
 
 
 
 
 
 
169
  }
3
  Plugin Name: Nofollow for external link
4
  Plugin URI: http://www.cybernetikz.com
5
  Description: Just simple, if you activate this plugins, <code>rel=&quot;nofollow&quot;</code> and <code>target=&quot;_blank&quot;</code> will be added automatically, for all the external links of your website <strong>posts</strong> or <strong>pages</strong>. Also you can <strong>exclude domains</strong>, not to add <code>rel=&quot;nofollow&quot;</code> for the selected external links.
6
+ Version: 1.2.0
7
  Author: CyberNetikz
8
  Author URI: http://www.cybernetikz.com
9
  License: GPL2
10
  */
11
 
12
+ if( !defined('ABSPATH') ) die('-1');
13
+
14
+ function cn_nf_install() {
15
+ add_option( 'cn_nf_exclude_domains', '');
16
+ add_option( 'cn_nf_apply_to_menu', '1');
17
+ }
18
+ register_activation_hook(__FILE__,'cn_nf_install');
19
+
20
+ function cn_nf_uninstall() {
21
+ delete_option( 'cn_nf_apply_to_menu' );
22
+ }
23
+ register_deactivation_hook(__FILE__,'cn_nf_uninstall');
24
+
25
  function cn_nf_admin_sidebar() {
26
 
27
  $banners = array(
62
  }
63
  add_action( 'admin_enqueue_scripts', 'cn_nf_admin_style' );
64
 
 
 
 
65
  function register_cn_nf_settings() {
66
  register_setting( 'cn-nf-settings-group', 'cn_nf_exclude_domains' );
67
+ register_setting( 'cn-nf-settings-group', 'cn_nf_apply_to_menu' );
68
  }
69
+ add_action( 'admin_init', 'register_cn_nf_settings' );
70
 
71
  function cn_nf_plugin_menu() {
72
  add_options_page('Nofollow for external link', 'NoFollow ExtLink', 'manage_options', 'cn_nf_option_page', 'cn_nf_option_page_fn');
73
  }
74
+ add_action( 'admin_menu', 'cn_nf_plugin_menu');
75
 
76
  function cn_nf_option_page_fn() {
77
  $cn_nf_exclude_domains = get_option('cn_nf_exclude_domains');
78
+ $cn_nf_apply_to_menu = get_option('cn_nf_apply_to_menu');
79
  ?>
80
  <div class="wrap">
81
  <h2>Nofollow for external link Options</h2>
84
  <form method="post" action="options.php" enctype="multipart/form-data">
85
  <?php settings_fields( 'cn-nf-settings-group' ); ?>
86
  <table class="form-table">
87
+
88
+ <tr valign="top">
89
+ <th scope="row">Apply nofollow to Menu</th>
90
+ <td><input <?php echo ($cn_nf_apply_to_menu == 1)?'checked="checked"':''; ?> type="checkbox" name="cn_nf_apply_to_menu" id="cn_nf_apply_to_menu" value="1" /><br />
91
+ <em>If you check this box then <code>rel="nofollow"</code> and <code>target="_blank"</code> will be added to all external links of your <a href="nav-menus.php">Theme Menus</a></em></td>
92
+ </tr>
93
+
94
  <tr valign="top">
95
  <th scope="row">Exclude Domains</th>
96
  <td><textarea name="cn_nf_exclude_domains" id="cn_nf_exclude_domains" class="large-text" placeholder="mydomain.com, my-domain.org, another-domain.net"><?php echo $cn_nf_exclude_domains?></textarea>
97
+ <br /><em>Domain name <strong>must be</strong> comma(,) separated. <!--<br />Example: facebook.com, google.com, youtube.com-->Don't need to add <code>http://</code> or <code>https://</code><br /><code>rel="nofollow"</code> will not added to "Exclude Domains"</em></td>
98
  </tr>
99
  </table>
100
  <p class="submit">
110
  <?php
111
  }
112
 
 
 
113
  function cn_nf_url_parse( $content ) {
114
 
115
  $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>";
132
  $url = $matches[$i][0];
133
 
134
  // bypass #more type internal link
135
+ $res = preg_match('/href(\s)*=(\s)*"[#|\/]*[a-zA-Z0-9-_\/]+"/',$url);
136
  if($res) {
137
  continue;
138
  }
185
 
186
  $content = str_replace(']]>', ']]&gt;', $content);
187
  return $content;
188
+ }
189
+
190
+ add_filter( 'the_content', 'cn_nf_url_parse');
191
+
192
+ if( get_option('cn_nf_apply_to_menu') ) {
193
+ add_filter( 'wp_nav_menu_items', 'cn_nf_url_parse' );
194
  }
readme.txt CHANGED
@@ -3,29 +3,29 @@ Plugin URI: http://www.cybernetikz.com
3
  Contributors: cybernetikz
4
  Donate link:
5
  Tags: nofollow,link,rel=nofollow,rel nofollow,seo,nofollow links,external link,external links,nofollow for external link,nofollow external link,nofollow external links
6
- Requires at least: 2.9.2
7
- Tested up to: 4.5
8
- Stable tag: 1.1.2
9
  License: GPL2
10
 
11
- Automatically insert `rel=nofollow` and `target=_blank` to all the external links into your website posts or pages. Support exclude domains.
12
 
13
  == Description ==
14
 
15
- Just simple, if you use this plugin, `rel=nofollow` and `target=_blank` will be inserted automatically, for all the external links of your website posts or pages. Also you can <strong>exclude domains</strong>, not to add `rel=nofollow` for the selected external links.
16
 
17
  > <strong>Paid Support</strong> ( $30 / Hour, We accept PayPal )
18
  >
19
  > Email us if you need <strong>paid support</strong>, <a href="mailto:support@cybernetikz.com">support@cybernetikz.com</a>
20
 
21
  = Feature =
22
- * Add `rel=nofollow` for all the external links of your website posts/pages.
23
- * Add `target=_blank` for all the external links of your website posts/pages.
24
- * You can <strong>exclude domains</strong>, not to add `rel=nofollow` for the selected external links.
25
  * Support WordPress multisite.
26
- * Also works for custom post type content.
27
  * This plugin will not add `rel=nofollow` or `target=_blank` to any `href=#read-more` or `href=#gotop` type links.
28
- * This plugin will not add `rel=nofollow` or `target=_blank` any of the internal link on your website posts/pages.
29
  * If you already added `rel=dofollow` or `rel=nofollow` to any post manually, this plugin will not add `rel=nofollow` for that post.
30
  * If you already added `target=_blank` to any post manually, this plugin will not add `target=_blank` for that post.
31
 
@@ -55,6 +55,11 @@ Ans: Yes it does.
55
 
56
  == Changelog ==
57
 
 
 
 
 
 
58
  = 1.1.2 =
59
  * Banner added in plugins settings page
60
 
3
  Contributors: cybernetikz
4
  Donate link:
5
  Tags: nofollow,link,rel=nofollow,rel nofollow,seo,nofollow links,external link,external links,nofollow for external link,nofollow external link,nofollow external links
6
+ Requires at least: 2.8.6
7
+ Tested up to: 4.7
8
+ Stable tag: 1.2.0
9
  License: GPL2
10
 
11
+ Automatically insert `rel=nofollow` and `target=_blank` to all the external links into your website posts, pages or menus. Support exclude domain.
12
 
13
  == Description ==
14
 
15
+ Just simple, if you use this plugin, `rel=nofollow` and `target=_blank` will be inserted automatically, for all the external links of your website posts, pages or theme menus. Also you can set <strong>exclude domains</strong>, not to add `rel=nofollow` for the selected external domain links.
16
 
17
  > <strong>Paid Support</strong> ( $30 / Hour, We accept PayPal )
18
  >
19
  > Email us if you need <strong>paid support</strong>, <a href="mailto:support@cybernetikz.com">support@cybernetikz.com</a>
20
 
21
  = Feature =
22
+ * Add `rel=nofollow` for all the external links of your website posts / pages / menus.
23
+ * Add `target=_blank` for all the external links of your website posts / pages / menus.
24
+ * Support <strong>custom post type</strong> content.
25
  * Support WordPress multisite.
26
+ * You can <strong>exclude domains</strong>, not to add `rel=nofollow` for the selected external links.
27
  * This plugin will not add `rel=nofollow` or `target=_blank` to any `href=#read-more` or `href=#gotop` type links.
28
+ * This plugin will not add `rel=nofollow` or `target=_blank` any of the internal link on your website posts / pages.
29
  * If you already added `rel=dofollow` or `rel=nofollow` to any post manually, this plugin will not add `rel=nofollow` for that post.
30
  * If you already added `target=_blank` to any post manually, this plugin will not add `target=_blank` for that post.
31
 
55
 
56
  == Changelog ==
57
 
58
+ = 1.2.0 =
59
+ * Not add `rel=nofollow` and `target=_blank` for "/about-us" type internal links.
60
+ * Add `rel=nofollow` and `target=_blank` for theme menus
61
+ * Security updates
62
+
63
  = 1.1.2 =
64
  * Banner added in plugins settings page
65
 
screenshot-2.png CHANGED
Binary file