Ultimate Nofollow - Version 0.1.1

Version Description

  • Stable beta version.
  • Adds full nofollow shortcodes.
  • Adds options page.
Download this release

Release Info

Developer bitacre
Plugin Icon wp plugin Ultimate Nofollow
Version 0.1.1
Comparing to
See all releases

Code changes from version 0.1.0 to 0.1.1

Files changed (2) hide show
  1. nofollow.php +175 -0
  2. readme.txt +14 -7
nofollow.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Ultimate Nofollow
4
+ Plugin URI: http://wikiduh.com/plugins/nofollow
5
+ Description: A suite of tools that gives you complete control over the rel=nofollow tag on an individual link basis.
6
+ Version: 0.1.1
7
+ Author: bitacre
8
+ Author URI: http://wikiduh.com
9
+ License: GPLv2
10
+ Copyright 2012 bitacre (plugins@wikiduh.com)
11
+
12
+ */
13
+
14
+ /***********************
15
+ * OPTIONS PAGE SECTION *
16
+ ************************/
17
+
18
+ /* add plugin's options to white list / defaults */
19
+ function ultnofo_options_init() {
20
+ register_setting( 'ultnofo_options_options', 'ultnofo_item', 'ultnofo_options_validate' );
21
+
22
+ // if option doesn't exist, set defaults
23
+ if( !get_option( 'ultnofo_item' ) ) add_option( 'ultnofo_item', array( 'nofollow_comments' => 1 ), '', 'no' );
24
+ }
25
+
26
+ /* add link to plugin's settings page under 'settings' on the admin menu */
27
+ function ultnofo_options_add_page() {
28
+ add_options_page( 'Ultimate Nofollow Settings', 'Nofollow', 'manage_options', 'ultimate-nofollow', 'ultnofo_options_do_page' );
29
+ }
30
+
31
+ /* sanitize and validate input.
32
+ accepts an array, returns a sanitized array. */
33
+ function ultnofo_options_validate( $input ) {
34
+ $input[ 'nofollow_comments' ] = ( $input[ 'nofollow_comments' ] == 1 ? 1 : 0 ); // (checkbox) if 1 then 1, else 0
35
+ // $input[ 'test_text_1' ] = wp_filter_nohtml_kses( $input[ 'test_text_1' ] ); // (textbox) safe text, no html
36
+ return $input;
37
+ }
38
+
39
+ /* draw the settings page itself */
40
+ function ultnofo_options_do_page() {
41
+ ?>
42
+ <div class="wrap">
43
+ <div class="icon32" id="icon-options-general"><br /></div>
44
+ <h2>Ultimate Nofollow Settings</h2>
45
+ <form method="post" action="options.php">
46
+ <?php settings_fields( 'ultnofo_options_options' ); // nonce settings page ?>
47
+ <?php $options = get_option( 'ultnofo_item' ); // populate $options array from database ?>
48
+ <table class="form-table">
49
+ <tr valign="top"><th scope="row">Add Nofollow to links in comments?</th>
50
+ <td><input name="ultnofo_item[nofollow_comments]" type="checkbox" value="1" <?php checked( '1', $options[ 'nofollow_comments' ] ); ?> /></td>
51
+ </tr>
52
+ <!-- <tr valign="top"><th scope="row">Text:</th>
53
+ <td>
54
+ UA-<input type="text" name="ssga_item[sometext1]" value="<?php // echo $options[ 'test_text_1']; ?>" style="width:90px;" maxlength="8" />
55
+ </td>
56
+ </tr> -->
57
+ </table>
58
+ <p class="submit">
59
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
60
+ </p>
61
+ </form>
62
+ </div>
63
+ <?php
64
+ }
65
+
66
+ /******************************
67
+ * NOFOLLOW SHORTCODES SECTION *
68
+ *******************************/
69
+
70
+ /* define additional plugin meta links */
71
+ function set_plugin_meta_ultnofo( $links, $file ) {
72
+ $plugin = plugin_basename( __FILE__ ); // '/nofollow/nofollow.php' by default
73
+ if ( $file == $plugin ) { // if called for THIS plugin then:
74
+ $newlinks = array(
75
+ '<a href="options-general.php?page=ultimate-nofollow">Settings</a>',
76
+ '<a href="http://wikiduh.com/plugins/nofollow/help">Help Page</a>'
77
+ ); // array of links to add
78
+ return array_merge( $links, $newlinks ); // merge new links into existing $links
79
+ }
80
+ return $links; // return the $links (merged or otherwise)
81
+ }
82
+
83
+ /* valid href starting substring? */
84
+ function ultnofo_valid_url( $href ) {
85
+ $start_strs = array( // list of accepted url protocols
86
+ '/',
87
+ 'http://',
88
+ 'https://',
89
+ 'ftp://',
90
+ 'mailto:',
91
+ 'magnet:',
92
+ 'svn://',
93
+ 'irc:',
94
+ 'gopher://',
95
+ 'telnet://',
96
+ 'nntp://',
97
+ 'worldwind://',
98
+ 'news:',
99
+ 'git://',
100
+ 'mms://'
101
+ );
102
+
103
+ foreach( $start_strs as $start_str )
104
+ if( substr( $href, 0, strlen( $start_str ) ) == $start_str ) return TRUE;
105
+
106
+ return FALSE;
107
+ }
108
+
109
+ /* return nofollow link html or html error comment */
110
+ function ultnofo_nofollow_link( $atts, $content = NULL ) {
111
+ extract(
112
+ shortcode_atts(
113
+ array(
114
+ 'href' => NULL,
115
+ 'title' => NULL,
116
+ 'target' => NULL
117
+ ),
118
+ $atts
119
+ )
120
+ );
121
+
122
+ // href
123
+ if( !ultnofo_valid_url( $href ) ) return '<!-- Ultimate Nofollow Plugin | shortcode insertion failed | given href resource not valid, href must begin with: ' . print_r( $start_strs, TRUE ) . ' -->'; // if url doesn't starts with valid string
124
+ else $href_chunk = ' href="' . $href . '"'; // else add href=''
125
+
126
+ // title
127
+ if( empty( $title ) ) $title_chunk = NULL; // if no $title, omit HTML
128
+ else $title_chunk = ' title="' . trim( htmlentities( strip_tags( $title ), ENT_QUOTES ) ) . '"'; // else add title=''
129
+
130
+ // target
131
+ if( empty( $target ) ) $target_chunk = NULL; // if no $target, omit HTML
132
+ else $target_chunk = ' target="' . trim( htmlentities( strip_tags( $target ), ENT_QUOTES ) ) . '"'; // else add target=''
133
+
134
+ // content
135
+ if( empty( $content ) ) return '<!-- Ultimate Nofollow Plugin | shortcode insertion failed | no link text given -->'; // if url doesn't starts with valid string
136
+ else $content_chunk = trim( htmlentities( strip_tags( $content ), ENT_QUOTES ) ); // else add $content
137
+
138
+ return '<a' . $href_chunk . $target_chunk . $title_chunk . ' rel="nofollow">' . $content_chunk . '</a>';
139
+ }
140
+
141
+ /****************************
142
+ * BLOGROLL NOFOLLOW SECTION *
143
+ *****************************/
144
+
145
+ /**********************************************
146
+ * ADD LINK DIALOGUE NOFOLLOW CHECKBOX SECTION *
147
+ ***********************************************/
148
+
149
+ /*******************************
150
+ * NOFOLLOW ON COMMENTS SECTION *
151
+ ********************************/
152
+
153
+ /************
154
+ * ADD HOOKS *
155
+ *************/
156
+
157
+ // add meta links to plugin's section on 'plugins' page (10=priority, 2=num of args)
158
+ add_filter( 'plugin_row_meta', 'set_plugin_meta_ultnofo', 10, 2 );
159
+
160
+ // add plugin's options to white list on admin initialization
161
+ add_action('admin_init', 'ultnofo_options_init' );
162
+
163
+ // add link to plugin's settings page in 'settings' menu on admin menu initilization
164
+ add_action('admin_menu', 'ultnofo_options_add_page');
165
+
166
+ // add shortcodes
167
+ $shortcodes = array(
168
+ 'relnofollow',
169
+ 'nofollow',
170
+ 'nofol',
171
+ 'nofo',
172
+ 'nf'
173
+ );
174
+ foreach( $shortcodes as $shortcode ) add_shortcode( $shortcode, 'ultnofo_nofollow_link' );
175
+ ?>
readme.txt CHANGED
@@ -5,19 +5,21 @@ Donate link: http://wikiduh.com/donate
5
  Tags: nofollow,link,meta,rel,rel nofollow,seo,link meta,nofollow links,shortcode
6
  Requires at least: 2.8
7
  Tested up to: 3.3.1
8
- Stable tag: 0.1.0
9
 
10
  A suite of tools that gives you complete control over the rel=nofollow tag on an individual link basis.
11
 
12
  == Description ==
13
-
14
  This plugin contains several tools in one to significantly increase your control of the nofollow rel tag on every link on your blog, on both an individual and type basis. It is designed to give you fine-grained control of linking for SEO purposes.
15
 
16
- The plugin's four main additions are:
17
- * a nofollow checkbox to the `insert link` dialogue box,
18
- * several nofollow `shortcodes`,
19
- * a nofollow option for individual (or all) `blogroll links`,
20
- * plus the ability to globally add or remove the nofollow tag in `comments`.
 
 
 
21
 
22
  == Installation ==
23
 
@@ -37,6 +39,11 @@ See the manpages.
37
 
38
  == Changelog ==
39
 
 
 
 
 
 
40
  = 0.1.0 =
41
  * First released beta version.
42
  * Stable, but not all functions active yet.
5
  Tags: nofollow,link,meta,rel,rel nofollow,seo,link meta,nofollow links,shortcode
6
  Requires at least: 2.8
7
  Tested up to: 3.3.1
8
+ Stable tag: 0.1.1
9
 
10
  A suite of tools that gives you complete control over the rel=nofollow tag on an individual link basis.
11
 
12
  == Description ==
 
13
  This plugin contains several tools in one to significantly increase your control of the nofollow rel tag on every link on your blog, on both an individual and type basis. It is designed to give you fine-grained control of linking for SEO purposes.
14
 
15
+ Notice: This plugin is still in beta. While it is stable, not all functions listed are included yet.
16
+
17
+ The plugin's main features are:
18
+ * a nofollow checkbox to the `insert link` dialogue box,
19
+ * several nofollow `shortcodes` (added in v0.1.0),
20
+ * a nofollow option for individual `blogroll links`,
21
+ * plus the ability to globally add or remove the nofollow tag in `comments`,
22
+ * plugin settings page (added in v0.1.1).
23
 
24
  == Installation ==
25
 
39
 
40
  == Changelog ==
41
 
42
+ = 0.1.1 =
43
+ * Stable beta version.
44
+ * Adds full nofollow shortcodes.
45
+ * Adds options page.
46
+
47
  = 0.1.0 =
48
  * First released beta version.
49
  * Stable, but not all functions active yet.