SEO Smart Links - Version 1.0

Version Description

Download this release

Release Info

Developer freediver
Plugin Icon 128x128 SEO Smart Links
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (8) hide show
  1. i/help.png +0 -0
  2. i/home.png +0 -0
  3. i/idea.png +0 -0
  4. i/more.png +0 -0
  5. i/p1.png +0 -0
  6. readme.txt +68 -0
  7. screenshot-1.png +0 -0
  8. seo-links.php +319 -0
i/help.png ADDED
Binary file
i/home.png ADDED
Binary file
i/idea.png ADDED
Binary file
i/more.png ADDED
Binary file
i/p1.png ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,68 @@
1
+ === SEO Smart Links ===
2
+ Contributors: freediver
3
+ Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=520781390
4
+ Tags: Post, posts, comments, links, seo, google, automatic
5
+ Requires at least: 2.3
6
+ Tested up to: 2.5.1
7
+ Stable tag: 1.0
8
+
9
+ SEO Smart Links can automatically link keywords and phrases in your posts and comments with corresponding posts, pages, categories and tags.
10
+
11
+
12
+ == Description ==
13
+
14
+ SEO Smart Links automatically searches for keywords and phrases in the text of your posts and comments add add links to the corresponding posts, pages, categories and tags on your blog.
15
+
16
+ It's often forgotten about, why not interlink from key pages deeper into the site? If you forget SEO Smart Links won't.
17
+ It also give your visitors an opportunity to visit other sections of your site that may be an interest for them.
18
+
19
+ Everything happens completely transparent, and you can edit the options from the administration settings panel.
20
+
21
+ v1.0:
22
+ - Initial release
23
+
24
+ == Credits ==
25
+
26
+ Some of the ideas of SEO Smart Links plugin came from other plugins. So I can at least thank these people:
27
+
28
+ * [Chris Lynch ](http://www.planetofthepenguins.com "Chris Lynch ") for his [Autolink](http://www.planetofthepenguins.com "Autolink") plugin
29
+
30
+ Thanks.
31
+
32
+ == Installation ==
33
+
34
+ 1. Upload the whole plugin folder to your /wp-content/plugins/ folder.
35
+ 2. Go to the Plugins page and activate the plugin.
36
+ 3. Use the Options page to change your options
37
+ 4. That is all. You can check your posts for new links.
38
+
39
+
40
+ == Screenshots ==
41
+
42
+ 1. Plugin Admin Panel
43
+
44
+ == License ==
45
+
46
+ This file is part of SEO Smart Links.
47
+
48
+ SEO Smart Links is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
49
+
50
+ SEO Smart Links is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
51
+
52
+ You should have received a copy of the GNU General Public License along with SEO Smart Links. If not, see <http://www.gnu.org/licenses/>.
53
+
54
+
55
+ == Frequently Asked Questions ==
56
+
57
+ = How do I correctly use this plugin? =
58
+
59
+ Just install activate it on your blog. Default options are enough to get you going. If you want to tweak it, you can always edit the options. Be sure to check "ignore" options where you can state what keywords and phrases not to link.
60
+
61
+
62
+ = Can I suggest an feature for the plugin? =
63
+
64
+ Of course, visit <a href="http://www.prelovac.com/vladimir/wordpress-plugins/seo-smart-links#comments">SEO Smart Links Home Page</a>
65
+
66
+ = I love your work, are you available for hire? =
67
+
68
+ Yes I am, visit my <a href="http://www.prelovac.com/vladimir/services">WordPress Services</a> page to find out more.
screenshot-1.png ADDED
Binary file
seo-links.php ADDED
@@ -0,0 +1,319 @@
1
+ <?php
2
+
3
+ /*
4
+ Plugin Name: SEO Smart Links
5
+ Version: 1.0
6
+ Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/seo-smart-links
7
+ Author: Vladimir Prelovac
8
+ Author URI: http://www.prelovac.com
9
+ Description: SEO Smart Links can automatically link keywords and phrases in your posts and comments with corresponding posts, pages, categories and tags.
10
+
11
+ */
12
+
13
+
14
+
15
+ // Avoid name collisions.
16
+ if ( !class_exists('SEOLinks') ) :
17
+
18
+ class SEOLinks {
19
+
20
+ // Name for our options in the DB
21
+ var $SEOLinks_DB_option = 'SEOLinks';
22
+ var $SEOLinks_options;
23
+
24
+ // Initialize WordPress hooks
25
+ function SEOLinks() {
26
+ $options = $this->get_options();
27
+ if ($options)
28
+ {
29
+ if ($options['post'] || $options['page'])
30
+ add_filter('the_content', array(&$this, 'SEOLinks_the_content_filter'), 10);
31
+ if ($options['comment'])
32
+ add_filter('comment_text', array(&$this, 'SEOLinks_comment_text_filter'), 10);
33
+ }
34
+ // Add Options Page
35
+ add_action('admin_menu', array(&$this, 'SEOLinks_admin_menu'));
36
+
37
+ }
38
+
39
+ function SEOLinks_process_text($text)
40
+ {
41
+
42
+ global $wpdb, $post;
43
+
44
+ $options = $this->get_options();
45
+
46
+
47
+ $text = " $text ";
48
+
49
+
50
+ //$wpdb->terms;
51
+ //$wpdb->term_taxonomy
52
+
53
+
54
+ if (($post->post_type=='page' && !$options['pageself']) || ($post->post_type=='post' && !$options['postself']))
55
+ $add=', '.$post->post_title;
56
+ else
57
+ $add='';
58
+
59
+ $arrignore=$this->explode_trim(",", strtolower($options['ignore'].$add));
60
+
61
+
62
+
63
+ if ($options['lposts'] || $options['lpages'])
64
+ {
65
+
66
+ $query="SELECT post_title, ID, guid, post_type FROM $wpdb->posts WHERE post_status = 'publish'";
67
+ $posts = $wpdb->get_results($query);
68
+
69
+ foreach ($posts as $postitem)
70
+ {
71
+ $name = $postitem->post_title;
72
+
73
+ if (!in_array( strtolower($name), $arrignore))
74
+ if ( ($options['lposts'] && $postitem->post_type=='post') || ($options['lpages'] && $postitem->post_type=='page') )
75
+ {
76
+
77
+ $url = get_permalink($postitem->ID);
78
+
79
+ $regexp="/(?!(?:[^<]+>|[^>]+<\/a>))\b($name)\b/imsU";
80
+ $replace="<a href=\"$url\">$1</a>";
81
+ $text = preg_replace($regexp, $replace, $text);
82
+ }
83
+ }
84
+ }
85
+
86
+ if ($options['lcats'])
87
+ {
88
+ $query="SELECT wp_terms.name, wp_terms.term_id FROM wp_terms LEFT JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id WHERE wp_term_taxonomy.taxonomy = 'category'";
89
+ $categories = $wpdb->get_results($query);
90
+ foreach ($categories as $cat)
91
+ {
92
+ $name= $cat->name;
93
+ if (!in_array( strtolower($name), $arrignore))
94
+ {
95
+ $url = get_category_link($cat->term_id);
96
+ $regexp="/(?!(?:[^<]+>|[^>]+<\/a>))\b($name)\b/imsU";
97
+ $replace="<a href=\"$url\">$1</a>";
98
+ $text = preg_replace($regexp, $replace, $text);
99
+ }
100
+ }
101
+ }
102
+
103
+ if ($options['ltags'])
104
+ {
105
+
106
+ $query="SELECT wp_terms.name, wp_terms.term_id FROM wp_terms LEFT JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id WHERE wp_term_taxonomy.taxonomy = 'post_tag'";
107
+ $tags = $wpdb->get_results($query);
108
+ foreach ($tags as $tag)
109
+ {
110
+ $name = $tag->name;
111
+ if (!in_array( strtolower($name), $arrignore))
112
+ {
113
+ $url = get_tag_link($tag->term_id);
114
+ $regexp="/(?!(?:[^<]+>|[^>]+<\/a>))\b($name)\b/imsU";
115
+ $replace="<a href=\"$url\">$1</a>";
116
+ $text = preg_replace($regexp, $replace, $text);
117
+ }
118
+ }
119
+ }
120
+
121
+ return trim( $text );
122
+
123
+ }
124
+
125
+ function SEOLinks_the_content_filter($text) {
126
+ return $this->SEOLinks_process_text($text);
127
+ }
128
+
129
+ function SEOLinks_comment_text_filter($text) {
130
+ return $this->SEOLinks_process_text($text);
131
+ }
132
+
133
+ // Handle our options
134
+ function get_options() {
135
+ $options = array(
136
+ 'post' => "",
137
+ 'postself' => "",
138
+ 'page' => "",
139
+ 'pageself' => "",
140
+ 'comment' => "",
141
+ 'lposts' => "",
142
+ 'lpages' => "",
143
+ 'ltags' => "",
144
+ 'lcats' => "",
145
+ 'ignore' => "",
146
+ );
147
+
148
+ $existing_options = get_option($this->SEOLinks_DB_option);
149
+
150
+ if (!empty($existing_options)) {
151
+ foreach ($existing_options as $key => $option)
152
+ $options[$key] = $option;
153
+ }
154
+ else
155
+ return 0;
156
+ return $options;
157
+ }
158
+
159
+ function explode_trim($separator, $text)
160
+ {
161
+ $arr = explode($separator, $text);
162
+
163
+ $ret = array();
164
+ foreach($arr as $e)
165
+ {
166
+ $ret[] = trim($e);
167
+ }
168
+ return $ret;
169
+ }
170
+
171
+ // Set up everything
172
+ function install() {
173
+ $SEOLinks_options = $this->get_options();
174
+ if (!$SEOLinks_options)
175
+ {
176
+ $options = array();
177
+
178
+ $options['post']='on';
179
+ $options['postself']='';
180
+ $options['page']='on';
181
+ $options['pageself']='';
182
+ $options['comment']='';
183
+ $options['lposts']='on';
184
+ $options['lpages']='on';
185
+ $options['lcats']='';
186
+ $options['ltags']='';
187
+ $options['ignore']='about,';
188
+
189
+
190
+ update_option($this->SEOLinks_DB_option, $options);
191
+ }
192
+ }
193
+
194
+ function handle_options()
195
+ {
196
+
197
+
198
+ if ( isset($_POST['submitted']) ) {
199
+ $options = array();
200
+ //print_r($_POST);
201
+
202
+ $options['post']=$_POST['post'];
203
+ $options['postself']=$_POST['postself'];
204
+ $options['page']=$_POST['page'];
205
+ $options['pageself']=$_POST['pageself'];
206
+ $options['comment']=$_POST['comment'];
207
+ $options['lposts']=$_POST['lposts'];
208
+ $options['lpages']=$_POST['lpages'];
209
+ $options['lcats']=$_POST['lcats'];
210
+ $options['ltags']=$_POST['ltags'];
211
+ $options['ignore']=$_POST['ignore'];
212
+
213
+
214
+ update_option($this->SEOLinks_DB_option, $options);
215
+ echo '<div class="updated fade"><p>Plugin settings saved.</p></div>';
216
+ }
217
+
218
+
219
+ $options = $this->get_options();
220
+
221
+ $action_url = $_SERVER['REQUEST_URI'];
222
+
223
+ $post=$options['post']=='on'?'checked':'';
224
+ $postself=$options['postself']=='on'?'checked':'';
225
+ $page=$options['page']=='on'?'checked':'';
226
+ $pageself=$options['pageself']=='on'?'checked':'';
227
+ $comment=$options['comment']=='on'?'checked':'';
228
+ $lposts=$options['lposts']=='on'?'checked':'';
229
+ $lpages=$options['lpages']=='on'?'checked':'';
230
+ $lcats=$options['lcats']=='on'?'checked':'';
231
+ $ltags=$options['ltags']=='on'?'checked':'';
232
+ $ignore=$options['ignore'];
233
+
234
+ $imgpath=trailingslashit(get_option('siteurl')). 'wp-content/plugins/seo-automatic-links/i';
235
+ echo <<<END
236
+
237
+ <div class="wrap" style="max-width:950px !important;">
238
+ <h2>SEO Smart Links</h2>
239
+
240
+ <div id="poststuff" style="margin-top:10px;">
241
+
242
+ <div id="sideblock" style="float:right;width:220px;margin-left:10px;">
243
+ <h3>Information</h3>
244
+ <div id="dbx-content" style="text-decoration:none;">
245
+ <img src="$imgpath/home.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins/seo-smart-links"> SEO Smart Links Home</a><br /><br />
246
+ <img src="$imgpath/idea.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins/seo-smart-links#comments"> Suggest a Feature</a><br /><br />
247
+ <img src="$imgpath/more.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins"> My WordPress Plugins</a><br /><br />
248
+ <br />
249
+
250
+ <p align="center">
251
+ <img src="$imgpath/p1.png"></p>
252
+
253
+ <p> <img src="$imgpath/help.png"><a href="http://www.prelovac.com/vladimir/services"> Need a WordPress Expert?</a></p>
254
+ </div>
255
+ </div>
256
+
257
+ <div id="mainblock" style="width:710px">
258
+
259
+ <div class="dbx-content">
260
+ <form name="SEOLinks" action="$action_url" method="post">
261
+ <input type="hidden" name="submitted" value="1" />
262
+ <h3>Options</h3>
263
+
264
+ <p>SEO Smart Links can automatically link keywords and phrases in your posts and comments with corresponding posts, pages, categories and tags on your blog.</p>
265
+
266
+ <h4>Processing</h4>
267
+ <p>SEO Smart Links can process your posts, pages and comments. Select your preference.</p>
268
+ <input type="checkbox" name="post" $post/><label for="post"> Posts</label>
269
+ <ul><input type="checkbox" name="postself" $postself/><label for="postself"> Allow links to itself</label></ul>
270
+ <input type="checkbox" name="page" $post/><label for="page"> Pages</label>
271
+ <ul><input type="checkbox" name="pageself" $postself/><label for="pageself"> Allow links to itself</label></ul>
272
+ <input type="checkbox" name="comment" $comment /><label for="comment"> Comments</label> <br>
273
+
274
+ <h4>Link to</h4>
275
+ <p>Select what you want automatically to link to.</p>
276
+ <input type="checkbox" name="lposts" $lposts /><label for="lposts"> Posts</label> <br>
277
+ <input type="checkbox" name="lpages" $lpages /><label for="lpages"> Pages</label> <br>
278
+ <input type="checkbox" name="lcats" $lcats /><label for="lcats"> Categories</label> <br>
279
+ <input type="checkbox" name="ltags" $ltags /><label for="ltags"> Tags</label> <br>
280
+
281
+ <h4>Ignore</h4>
282
+ <p>You may wish to ignore certain words or phrases. Seperate them by comma.</p>
283
+ <input type="text" name="ignore" size="90" value="$ignore"/>
284
+
285
+
286
+ <div class="submit"><input type="submit" name="Submit" value="Update" /></div>
287
+ </form>
288
+ </div>
289
+
290
+ <br/><br/><h3>&nbsp;</h3>
291
+ </div>
292
+
293
+ </div>
294
+
295
+ <h5>WordPress plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
296
+ </div>
297
+ END;
298
+
299
+
300
+ }
301
+
302
+ function SEOLinks_admin_menu()
303
+ {
304
+ add_options_page('SEO Smart Links Options', 'SEO Smart Links', 8, basename(__FILE__), array(&$this, 'handle_options'));
305
+ }
306
+
307
+ }
308
+
309
+ endif;
310
+
311
+ if ( class_exists('SEOLinks') ) :
312
+
313
+ $SEOLinks = new SEOLinks();
314
+ if (isset($SEOLinks)) {
315
+ register_activation_hook( __FILE__, array(&$SEOLinks, 'install') );
316
+ }
317
+ endif;
318
+
319
+ ?>