Version Description
- Exclude Domains feature added.
- Not add
rel=nofollow
andtarget=_blank
for #more or #gotop type links. - Not add
rel=nofollow
ortarget=_blank
for those link you already added manually. - Some bug fixes.
Download this release
Release Info
Developer | cybernetikz |
Plugin | Nofollow for external link |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.1
- nofollow-external-link.php +87 -19
- readme.txt +32 -16
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
nofollow-external-link.php
CHANGED
@@ -2,13 +2,46 @@
|
|
2 |
/*
|
3 |
Plugin Name: Nofollow for external link
|
4 |
Plugin URI: http://www.cybernetikz.com
|
5 |
-
Description: Just simple, if you
|
6 |
-
Version: 1.
|
7 |
Author: CyberNetikz
|
8 |
Author URI: http://www.cybernetikz.com
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
add_filter( 'the_content', 'cn_nf_url_parse');
|
13 |
|
14 |
function cn_nf_url_parse( $content ) {
|
@@ -17,28 +50,64 @@ function cn_nf_url_parse( $content ) {
|
|
17 |
if(preg_match_all("/$regexp/siU", $content, $matches, PREG_SET_ORDER)) {
|
18 |
if( !empty($matches) ) {
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
for ($i=0; $i < count($matches); $i++)
|
22 |
{
|
23 |
|
24 |
-
$tag
|
25 |
$tag2 = $matches[$i][0];
|
26 |
-
$url
|
27 |
-
|
28 |
-
$noFollow = '';
|
29 |
-
|
30 |
-
$pattern = '/target\s*=\s*"\s*_blank\s*"/';
|
31 |
-
preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE);
|
32 |
-
if( count($match) < 1 )
|
33 |
-
$noFollow .= ' target="_blank" ';
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
if(
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
41 |
if ($pos === false) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
$tag = rtrim ($tag,'>');
|
43 |
$tag .= $noFollow.'>';
|
44 |
$content = str_replace($tag2,$tag,$content);
|
@@ -49,5 +118,4 @@ function cn_nf_url_parse( $content ) {
|
|
49 |
|
50 |
$content = str_replace(']]>', ']]>', $content);
|
51 |
return $content;
|
52 |
-
|
53 |
}
|
2 |
/*
|
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="nofollow"</code> and <code>target="_blank"</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="nofollow"</code> for the selected external links.
|
6 |
+
Version: 1.1
|
7 |
Author: CyberNetikz
|
8 |
Author URI: http://www.cybernetikz.com
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
12 |
+
add_action('admin_menu', 'cn_nf_plugin_menu');
|
13 |
+
add_action( 'admin_init', 'register_cn_nf_settings' );
|
14 |
+
|
15 |
+
function register_cn_nf_settings() {
|
16 |
+
register_setting( 'cn-nf-settings-group', 'cn_nf_exclude_domains' );
|
17 |
+
}
|
18 |
+
|
19 |
+
function cn_nf_plugin_menu() {
|
20 |
+
add_options_page('Nofollow for external link', 'NoFollow ExtLink', 'manage_options', 'cn_nf_option_page', 'cn_nf_option_page_fn');
|
21 |
+
}
|
22 |
+
|
23 |
+
function cn_nf_option_page_fn() {
|
24 |
+
$cn_nf_exclude_domains = get_option('cn_nf_exclude_domains');
|
25 |
+
?>
|
26 |
+
<div class="wrap">
|
27 |
+
<h2>Nofollow for external link Options</h2>
|
28 |
+
<form method="post" action="options.php" enctype="multipart/form-data">
|
29 |
+
<?php settings_fields( 'cn-nf-settings-group' ); ?>
|
30 |
+
<table class="form-table">
|
31 |
+
<tr valign="top">
|
32 |
+
<th scope="row">Exclude Domains</th>
|
33 |
+
<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>
|
34 |
+
<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>
|
35 |
+
</tr>
|
36 |
+
</table>
|
37 |
+
<p class="submit">
|
38 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
39 |
+
</p>
|
40 |
+
</form>
|
41 |
+
</div>
|
42 |
+
<?php
|
43 |
+
}
|
44 |
+
|
45 |
add_filter( 'the_content', 'cn_nf_url_parse');
|
46 |
|
47 |
function cn_nf_url_parse( $content ) {
|
50 |
if(preg_match_all("/$regexp/siU", $content, $matches, PREG_SET_ORDER)) {
|
51 |
if( !empty($matches) ) {
|
52 |
|
53 |
+
//$ownDomain = get_option('home');
|
54 |
+
$ownDomain = $_SERVER['HTTP_HOST'];
|
55 |
+
|
56 |
+
if(get_option('cn_nf_exclude_domains')!='') {
|
57 |
+
$exclude_domains_list = explode(",",get_option('cn_nf_exclude_domains'));
|
58 |
+
}
|
59 |
+
|
60 |
for ($i=0; $i < count($matches); $i++)
|
61 |
{
|
62 |
|
63 |
+
$tag = $matches[$i][0];
|
64 |
$tag2 = $matches[$i][0];
|
65 |
+
$url = $matches[$i][0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
+
// bypass #more type internal link
|
68 |
+
$res = preg_match('/href(\s)*=(\s)*"#[a-zA-Z0-9-_]+"/',$url);
|
69 |
+
if($res) {
|
70 |
+
continue;
|
71 |
+
}
|
72 |
+
|
73 |
+
$pos = strpos($url,$ownDomain);
|
74 |
if ($pos === false) {
|
75 |
+
|
76 |
+
$domainCheckFlag = true;
|
77 |
+
|
78 |
+
if(count($exclude_domains_list)>0) {
|
79 |
+
$exclude_domains_list = array_filter($exclude_domains_list);
|
80 |
+
foreach($exclude_domains_list as $domain) {
|
81 |
+
$domain = trim($domain);
|
82 |
+
if($domain!='') {
|
83 |
+
$domainCheck = strpos($url,$domain);
|
84 |
+
if($domainCheck === false) {
|
85 |
+
continue;
|
86 |
+
} else {
|
87 |
+
$domainCheckFlag = false;
|
88 |
+
break;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
$noFollow = '';
|
95 |
+
|
96 |
+
// add target=_blank to url
|
97 |
+
$pattern = '/target\s*=\s*"\s*_blank\s*"/';
|
98 |
+
preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE);
|
99 |
+
if( count($match) < 1 )
|
100 |
+
$noFollow .= ' target="_blank"';
|
101 |
+
|
102 |
+
//exclude domain or add nofollow
|
103 |
+
if($domainCheckFlag) {
|
104 |
+
$pattern = '/rel\s*=\s*"\s*[n|d]ofollow\s*"/';
|
105 |
+
preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE);
|
106 |
+
if( count($match) < 1 )
|
107 |
+
$noFollow .= ' rel="nofollow"';
|
108 |
+
}
|
109 |
+
|
110 |
+
// add nofollow/target attr to url
|
111 |
$tag = rtrim ($tag,'>');
|
112 |
$tag .= $noFollow.'>';
|
113 |
$content = str_replace($tag2,$tag,$content);
|
118 |
|
119 |
$content = str_replace(']]>', ']]>', $content);
|
120 |
return $content;
|
|
|
121 |
}
|
readme.txt
CHANGED
@@ -2,17 +2,17 @@
|
|
2 |
Plugin URI: http://www.cybernetikz.com
|
3 |
Contributors: cybernetikz
|
4 |
Donate link:
|
5 |
-
Tags: nofollow,link,rel,rel nofollow,seo,nofollow links,external link,external links,nofollow for external link
|
6 |
Requires at least: 2.9.2
|
7 |
-
Tested up to: 4.2.
|
8 |
-
Stable tag: 1.
|
9 |
License: GPL2
|
10 |
|
11 |
-
Automatically insert `rel=nofollow` and `target=_blank` to all the external links into your website posts or pages.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
Just simple, if you use this plugins, `rel=nofollow` and `target=_blank` will be insert automatically, for all the external links of your website posts or pages.
|
16 |
|
17 |
> <strong>PAID SUPPORT ($30/Hr, We ACCEPT PAYPAL )</strong>
|
18 |
>
|
@@ -29,10 +29,14 @@ Just simple, if you use this plugins, `rel=nofollow` and `target=_blank` will be
|
|
29 |
> please send an email to this address <a href="mailto:support@cybernetikz.com">support@cybernetikz.com</a>
|
30 |
|
31 |
= Feature =
|
32 |
-
* Add `rel=nofollow` for all the external link of your
|
33 |
-
* Add `target=_blank` for all the external link of your
|
34 |
-
*
|
35 |
-
*
|
|
|
|
|
|
|
|
|
36 |
* If you already added `target=_blank` to any post manually, this plugins will not add `target=_blank` for that post.
|
37 |
|
38 |
You can visit our website <a href="http://www.cybernetikz.com/blog/wordpress-plugins-external-links-relnofollow/">cybernetikz.com</a>
|
@@ -43,18 +47,33 @@ Wating for your valuable feedback/comments.
|
|
43 |
|
44 |
1. Download the latest zip file and extract the 'nofollow-external-link' directory.
|
45 |
2. Upload it to your '/wp-content/plugins/' directory.
|
46 |
-
3. Activate 'Nofollow for external link' on the 'Plugins' menu in WordPress.
|
47 |
4. That's it, you are all done :)
|
|
|
48 |
|
49 |
== Frequently Asked Questions ==
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
== Screenshots ==
|
54 |
|
55 |
-
1.
|
|
|
56 |
|
57 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
= 1.0 =
|
59 |
* First released version.
|
60 |
* Please send me your feedback.
|
@@ -62,9 +81,6 @@ Please send me your feedback. Thanks.
|
|
62 |
== Upgrade Notice ==
|
63 |
* First released version.
|
64 |
|
65 |
-
== Readme Generator ==
|
66 |
-
* This plugin's readme.txt file was generated by the [WikiDuh Readme Generator](http://wikiduh.com/project/readme-gen) for WordPress Plugins.
|
67 |
-
|
68 |
== Support ==
|
69 |
|
70 |
* [Plugin Homepage](http://www.cybernetikz.com)
|
2 |
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.2.3
|
8 |
+
Stable tag: 1.1
|
9 |
License: GPL2
|
10 |
|
11 |
+
Automatically insert `rel=nofollow` and `target=_blank` to all the external links into your website posts or pages. Also support exclude domains.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
Just simple, if you use this plugins, `rel=nofollow` and `target=_blank` will be insert 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 ($30/Hr, We ACCEPT PAYPAL )</strong>
|
18 |
>
|
29 |
> please send an email to this address <a href="mailto:support@cybernetikz.com">support@cybernetikz.com</a>
|
30 |
|
31 |
= Feature =
|
32 |
+
* Add `rel=nofollow` for all the external link of your website posts/pages.
|
33 |
+
* Add `target=_blank` for all the external link of your website posts/pages.
|
34 |
+
* You can <strong>exclude domains</strong>, not to add `rel=nofollow` for the selected external links.
|
35 |
+
* Support WordPress multisite.
|
36 |
+
* Also works for custom post type content.
|
37 |
+
* This plugins will not add `rel=nofollow` or `target=_blank` to any `href=#read-more` or `href=#gotop` type links.
|
38 |
+
* This plugins will not add `rel=nofollow` or `target=_blank` any of the internal link of your website posts/pages.
|
39 |
+
* If you already added `rel=dofollow` or `rel=nofollow` to any post manually, this plugins will not add `rel=nofollow` for that post.
|
40 |
* If you already added `target=_blank` to any post manually, this plugins will not add `target=_blank` for that post.
|
41 |
|
42 |
You can visit our website <a href="http://www.cybernetikz.com/blog/wordpress-plugins-external-links-relnofollow/">cybernetikz.com</a>
|
47 |
|
48 |
1. Download the latest zip file and extract the 'nofollow-external-link' directory.
|
49 |
2. Upload it to your '/wp-content/plugins/' directory.
|
50 |
+
3. Activate 'Nofollow for external link' on the 'Plugins' menu in WordPress admin panel.
|
51 |
4. That's it, you are all done :)
|
52 |
+
5. Now check the external links will open in new window and `rel=nofollow` added.
|
53 |
|
54 |
== Frequently Asked Questions ==
|
55 |
+
|
56 |
+
<strong>Ques.</strong> Can i exclude domain not to add `rel=nofollow`? How can i add domain names, for those links i don't want to add `rel=nofollow`?
|
57 |
+
|
58 |
+
<strong>Ans:</strong> Yes now you can exclude domain names. Please go to WordPress Admin Panel -> Settings -> NoFollow ExtLinks, and follow instructions.
|
59 |
+
|
60 |
+
<strong>Ques.</strong> Does this plugins works for custom post type content?
|
61 |
+
|
62 |
+
<strong>Ans:</strong> Yes it does.
|
63 |
|
64 |
== Screenshots ==
|
65 |
|
66 |
+
1. See how the `rel=nofollow` inserted to all the external links.
|
67 |
+
2. Options page for Exclude Domains.
|
68 |
|
69 |
== Changelog ==
|
70 |
+
|
71 |
+
= 1.1 =
|
72 |
+
* Exclude Domains feature added.
|
73 |
+
* Not add `rel=nofollow` and `target=_blank` for #more or #gotop type links.
|
74 |
+
* Not add `rel=nofollow` or `target=_blank` for those link you already added manually.
|
75 |
+
* Some bug fixes.
|
76 |
+
|
77 |
= 1.0 =
|
78 |
* First released version.
|
79 |
* Please send me your feedback.
|
81 |
== Upgrade Notice ==
|
82 |
* First released version.
|
83 |
|
|
|
|
|
|
|
84 |
== Support ==
|
85 |
|
86 |
* [Plugin Homepage](http://www.cybernetikz.com)
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
ADDED
Binary file
|