SEO Smart Links - Version 2.7

Version Description

  • Released SEO Smart Links Premium (read more http://www.prelovac.com/products/seo-smart-links)
  • Fixed a nofollow link issue
  • WP 3.0+ compatibility
Download this release

Release Info

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

Code changes from version 2.5.2 to 2.7

Files changed (2) hide show
  1. readme.txt +12 -2
  2. seo-links.php +66 -34
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: freediver
3
  Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=520781390
4
  Tags: Post, posts, comments, links, seo, google, automatic, affiliate
5
  Requires at least: 2.3
6
- Tested up to: 2.9.2
7
  Stable tag: trunk
8
 
9
  SEO Smart Links provides automatic SEO benefits for your site in addition to custom keyword lists, nofollow and much more.
@@ -11,6 +11,8 @@ SEO Smart Links provides automatic SEO benefits for your site in addition to cus
11
 
12
  == Description ==
13
 
 
 
14
  SEO Smart Links provides automatic SEO benefits for your site in addition to custom keyword lists, nofollow and much more.
15
 
16
  SEO Smart Links can automatically link keywords and phrases in your posts and comments with corresponding posts, pages, categories and tags on your blog.
@@ -21,10 +23,18 @@ It is a perfect solution to get your blog posts interlinked or add affiliate lin
21
 
22
  Everything happens completely transparent, and you can edit the options from the administration settings panel.
23
 
24
- Plugin by Vladimir Prelovac a <a href="http://www.prelovac.com/vladimir/services">WordPress Consultant</a>.
25
 
26
  == Changelog ==
27
 
 
 
 
 
 
 
 
 
28
  = 2.5.2 =
29
  * Added Prevent duplicate links for custom keywords options (credits Adrian Ramiro)
30
 
3
  Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=520781390
4
  Tags: Post, posts, comments, links, seo, google, automatic, affiliate
5
  Requires at least: 2.3
6
+ Tested up to: 3.0.3
7
  Stable tag: trunk
8
 
9
  SEO Smart Links provides automatic SEO benefits for your site in addition to custom keyword lists, nofollow and much more.
11
 
12
  == Description ==
13
 
14
+ <a href="http://www.prelovac.com/products/seo-smart-links">SEO Smart Links Premium</a> is now available with bug fixes, new features and performance improvements. <a href="http://www.prelovac.com/products/seo-smart-links/#new">What is new?</a>
15
+
16
  SEO Smart Links provides automatic SEO benefits for your site in addition to custom keyword lists, nofollow and much more.
17
 
18
  SEO Smart Links can automatically link keywords and phrases in your posts and comments with corresponding posts, pages, categories and tags on your blog.
23
 
24
  Everything happens completely transparent, and you can edit the options from the administration settings panel.
25
 
26
+ Plugin by Vladimir Prelovac, a <a href="http://www.prelovac.com/vladimir/services">WordPress Consultant</a>.
27
 
28
  == Changelog ==
29
 
30
+ = 2.7 =
31
+ * Released SEO Smart Links Premium (read more http://www.prelovac.com/products/seo-smart-links)
32
+ * Fixed a nofollow link issue
33
+ * WP 3.0+ compatibility
34
+
35
+ = 2.6 =
36
+ * Added feature to generate only one link *per target url* (credits Arjun Sandhu http://www.arjunsandhu.com/)
37
+
38
  = 2.5.2 =
39
  * Added Prevent duplicate links for custom keywords options (credits Adrian Ramiro)
40
 
seo-links.php CHANGED
@@ -2,16 +2,18 @@
2
 
3
  /*
4
  Plugin Name: SEO Smart Links
5
- Version: 2.5.2
6
  Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/seo-smart-links
7
  Author: Vladimir Prelovac
8
  Author URI: http://www.prelovac.com/vladimir
9
- Description: SEO Smart Links provides automatic SEO benefits for your site in addition to custom keyword lists, nofollow and much more. (Brian Edition)
10
  */
11
 
12
  // todo It's possible to have option for case insensitive ?
13
  // $count in preg_replace, max links towards same url
14
  // If possible I'd be interested in having the plugin to not autolink keywords within (ie H1, H2 etc)
 
 
15
 
16
  // Avoid name collisions.
17
  if ( !class_exists('SEOLinks') ) :
@@ -39,9 +41,18 @@ class SEOLinks {
39
  add_action( 'save_post', array(&$this,'SEOLinks_delete_cache'));
40
  // Add Options Page
41
  add_action('admin_menu', array(&$this, 'SEOLinks_admin_menu'));
 
 
 
42
 
43
  }
44
 
 
 
 
 
 
 
45
  function SEOLinks_process_text($text, $mode)
46
  {
47
 
@@ -86,7 +97,10 @@ function SEOLinks_process_text($text, $mode)
86
 
87
  $maxlinks=($options['maxlinks']>0) ? $options['maxlinks'] : 0;
88
  $maxsingle=($options['maxsingle']>0) ? $options['maxsingle'] : -1;
 
89
  $minusage = ($options['minusage']>0) ? $options['minusage'] : 1;
 
 
90
 
91
  $arrignore=$this->explode_trim(",", ($options['ignore']));
92
  if ($options['excludeheading'] == "on") {
@@ -150,8 +164,8 @@ function SEOLinks_process_text($text, $mode)
150
 
151
  foreach ($kw_array as $name=>$url)
152
  {
153
-
154
- if ((!$maxlinks || ($links < $maxlinks)) && (trailingslashit($url)!=$thisurl) && !in_array( $options['casesens'] ? $name : strtolower($name), $arrignore))
155
  {
156
  if (($options['customkey_preventduplicatelink'] == TRUE) || $strpos_fnc($text, $name) !== false) { // credit to Dominik Deobald -- TODO: change string search for preg_match
157
  $name= preg_quote($name, '/');
@@ -165,6 +179,7 @@ function SEOLinks_process_text($text, $mode)
165
  if ($newtext!=$text) {
166
  $links++;
167
  $text=$newtext;
 
168
  }
169
  }
170
  }
@@ -186,7 +201,8 @@ function SEOLinks_process_text($text, $mode)
186
  foreach ($posts as $postitem)
187
  {
188
  if ((($options['lposts'] && $postitem->post_type=='post') || ($options['lpages'] && $postitem->post_type=='page')) &&
189
- (!$maxlinks || ($links < $maxlinks)) && (($options['casesens'] ? $postitem->post_title : strtolower($postitem->post_title))!=$thistitle) && (!in_array( ($options['casesens'] ? $postitem->post_title : strtolower($postitem->post_title)), $arrignore)) )
 
190
  {
191
  if ($strpos_fnc($text, $postitem->post_title) !== false) { // credit to Dominik Deobald
192
  $name = preg_quote($postitem->post_title, '/');
@@ -198,9 +214,13 @@ function SEOLinks_process_text($text, $mode)
198
 
199
  $newtext = preg_replace($regexp, $replace, $text, $maxsingle);
200
  if ($newtext!=$text) {
201
- $url = get_permalink($postitem->ID);
202
- $links++;
203
- $text=str_replace('$$$url$$$', $url, $newtext);
 
 
 
 
204
  }
205
  }
206
  }
@@ -220,7 +240,7 @@ function SEOLinks_process_text($text, $mode)
220
 
221
  foreach ($categories as $cat)
222
  {
223
- if ((!$maxlinks || ($links < $maxlinks)) && !in_array( $options['casesens'] ? $cat->name : strtolower($cat->name), $arrignore) )
224
  {
225
  if ($strpos_fnc($text, $cat->name) !== false) { // credit to Dominik Deobald
226
  $name= preg_quote($cat->name, '/');
@@ -229,9 +249,13 @@ function SEOLinks_process_text($text, $mode)
229
 
230
  $newtext = preg_replace($regexp, $replace, $text, $maxsingle);
231
  if ($newtext!=$text) {
232
- $url = (get_category_link($cat->term_id));
233
- $links++;
234
- $text=str_replace('$$$url$$$', $url, $newtext);
 
 
 
 
235
  }
236
  }
237
  }
@@ -261,8 +285,12 @@ function SEOLinks_process_text($text, $mode)
261
  $newtext = preg_replace($regexp, $replace, $text, $maxsingle);
262
  if ($newtext!=$text) {
263
  $url = (get_tag_link($tag->term_id));
264
- $links++;
265
- $text=str_replace('$$$url$$$', $url, $newtext);
 
 
 
 
266
  }
267
  }
268
  }
@@ -300,10 +328,10 @@ function SEOLinks_comment_text_filter($text) {
300
  $options = $this->get_options();
301
  $link=parse_url(get_bloginfo('wpurl'));
302
  $host='http://'.$link['host'];
303
-
304
  if ($options['blanko'])
305
  $result = preg_replace('%<a(\s+.*?href=\S(?!' . $host . '))%i', '<a target="_blank"\\1', $result); // credit to Kaf Oseo
306
-
307
  if ($options['nofolo'])
308
  $result = preg_replace('%<a(\s+.*?href=\S(?!' . $host . '))%i', '<a rel="nofollow"\\1', $result);
309
 
@@ -349,8 +377,9 @@ function SEOLinks_comment_text_filter($text) {
349
  'blanko' =>'',
350
  'onlysingle' => 'on',
351
  'casesens' =>'',
352
- 'allowfeed' => ''
353
-
 
354
  );
355
 
356
  $saved = get_option($this->SEOLinks_DB_option);
@@ -381,6 +410,14 @@ function SEOLinks_comment_text_filter($text) {
381
  {
382
 
383
  $options = $this->get_options();
 
 
 
 
 
 
 
 
384
  if ( isset($_POST['submitted']) ) {
385
 
386
  check_admin_referer('seo-smart-links');
@@ -399,6 +436,7 @@ function SEOLinks_comment_text_filter($text) {
399
  $options['ignorepost']=$_POST['ignorepost'];
400
  $options['maxlinks']=(int) $_POST['maxlinks'];
401
  $options['maxsingle']=(int) $_POST['maxsingle'];
 
402
  $options['minusage']=(int) $_POST['minusage']; // credit to Dominik Deobald
403
  $options['customkey']=$_POST['customkey'];
404
  $options['customkey_preventduplicatelink']=$_POST['customkey_preventduplicatelink'];
@@ -435,6 +473,7 @@ function SEOLinks_comment_text_filter($text) {
435
  $ignorepost=$options['ignorepost'];
436
  $maxlinks=$options['maxlinks'];
437
  $maxsingle=$options['maxsingle'];
 
438
  $minusage=$options['minusage'];
439
  $customkey=stripslashes($options['customkey']);
440
  $customkey_preventduplicatelink=$options['customkey_preventduplicatelink'] == TRUE ? 'checked' : '';
@@ -453,24 +492,15 @@ function SEOLinks_comment_text_filter($text) {
453
  $imgpath=trailingslashit(get_option('siteurl')). 'wp-content/plugins/seo-automatic-links/i';
454
  echo <<<END
455
 
456
- <div class="wrap" style="max-width:950px !important;">
457
  <h2>SEO Smart Links</h2>
458
 
459
  <div id="poststuff" style="margin-top:10px;">
460
 
461
- <div id="sideblock" style="float:right;width:220px;margin-left:10px;">
462
- <h2>Information</h2>
463
- <div id="dbx-content" style="text-decoration:none;">
464
- <img src="$imgpath/home.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/wordpress-plugins/seo-smart-links"> SEO Smart Links Home</a><br />
465
- <img src="$imgpath/rate.png"><a style="text-decoration:none;" href="http://wordpress.org/extend/plugins/seo-automatic-links/"> Rate this plugin</a><br />
466
- <img src="$imgpath/help.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/forum"> Support and Help</a><br />
467
- <br />
468
- <a style="text-decoration:none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2567254"><img src="$imgpath/paypal.gif"></a>
469
- <br /><br />
470
- <img src="$imgpath/more.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/wordpress-plugins"> Cool WordPress Plugins</a><br />
471
- <img src="$imgpath/twit.png"><a style="text-decoration:none;" href="http://twitter.com/vprelovac"> Follow updates on Twitter</a><br />
472
- <img src="$imgpath/idea.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/services"> Need a WordPress Expert?</a>
473
- </div>
474
  </div>
475
 
476
  <div id="mainblock" style="width:710px">
@@ -541,10 +571,12 @@ function SEOLinks_comment_text_filter($text) {
541
  <br><br>
542
 
543
  <h4>Limits</h4>
544
- <p>You can limit the maximum number of links SEO Smart Links will generate per post. Set to 0 for no limit. </p>
545
  Max Links: <input type="text" name="maxlinks" size="2" value="$maxlinks"/>
546
  <p>You can also limit maximum number of links created with the same keyword. Set to 0 for no limit. </p>
547
- Max Single: <input type="text" name="maxsingle" size="2" value="$maxsingle"/>
 
 
548
  <br><br>
549
 
550
  <h4>External Links</h4>
2
 
3
  /*
4
  Plugin Name: SEO Smart Links
5
+ Version: 2.7
6
  Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/seo-smart-links
7
  Author: Vladimir Prelovac
8
  Author URI: http://www.prelovac.com/vladimir
9
+ Description: SEO Smart Links provides automatic SEO benefits for your site in addition to custom keyword lists, nofollow and much more.
10
  */
11
 
12
  // todo It's possible to have option for case insensitive ?
13
  // $count in preg_replace, max links towards same url
14
  // If possible I'd be interested in having the plugin to not autolink keywords within (ie H1, H2 etc)
15
+ //"Would it be possible to add an option for posts to link only within their respective categories? ..."
16
+ //Chad is right, that for maximum SEO benefit, the links need to be created within a particular category to make sure they don't destroy the 'Silo Structure' of the blog. In SEO terms, only links within the same category or to the 'top level' page of another category are 'allowed'.
17
 
18
  // Avoid name collisions.
19
  if ( !class_exists('SEOLinks') ) :
41
  add_action( 'save_post', array(&$this,'SEOLinks_delete_cache'));
42
  // Add Options Page
43
  add_action('admin_menu', array(&$this, 'SEOLinks_admin_menu'));
44
+
45
+ if ($options['notice'])
46
+ add_action('admin_notices', array(&$this,'admin_notice'));
47
 
48
  }
49
 
50
+ function admin_notice() {
51
+
52
+ echo '<div class="updated" style="text-align: center;"><p><a target="_blank" href="http://www.prelovac.com/products/seo-smart-links">SEO Smart Links Premium</a> is now available with bug fixes, new features and performance improvements. <a target="_blank" href="http://www.prelovac.com/products/seo-smart-links/#new">What is new?</a></p><p style="text-align:right"><a href="options-general.php?page=seo-links.php&notice=1">hide</a></p></div>';
53
+
54
+ }
55
+
56
  function SEOLinks_process_text($text, $mode)
57
  {
58
 
97
 
98
  $maxlinks=($options['maxlinks']>0) ? $options['maxlinks'] : 0;
99
  $maxsingle=($options['maxsingle']>0) ? $options['maxsingle'] : -1;
100
+ $maxsingleurl=($options['maxsingleurl']>0) ? $options['maxsingleurl'] : 0;
101
  $minusage = ($options['minusage']>0) ? $options['minusage'] : 1;
102
+
103
+ $urls = array();
104
 
105
  $arrignore=$this->explode_trim(",", ($options['ignore']));
106
  if ($options['excludeheading'] == "on") {
164
 
165
  foreach ($kw_array as $name=>$url)
166
  {
167
+
168
+ if ((!$maxlinks || ($links < $maxlinks)) && (trailingslashit($url)!=$thisurl) && !in_array( $options['casesens'] ? $name : strtolower($name), $arrignore) && (!$maxsingleurl || $urls[$url]<$maxsingleurl) )
169
  {
170
  if (($options['customkey_preventduplicatelink'] == TRUE) || $strpos_fnc($text, $name) !== false) { // credit to Dominik Deobald -- TODO: change string search for preg_match
171
  $name= preg_quote($name, '/');
179
  if ($newtext!=$text) {
180
  $links++;
181
  $text=$newtext;
182
+ if (!isset($urls[$url])) $urls[$url]=1; else $urls[$url]++;
183
  }
184
  }
185
  }
201
  foreach ($posts as $postitem)
202
  {
203
  if ((($options['lposts'] && $postitem->post_type=='post') || ($options['lpages'] && $postitem->post_type=='page')) &&
204
+ (!$maxlinks || ($links < $maxlinks)) && (($options['casesens'] ? $postitem->post_title : strtolower($postitem->post_title))!=$thistitle) && (!in_array( ($options['casesens'] ? $postitem->post_title : strtolower($postitem->post_title)), $arrignore))
205
+ )
206
  {
207
  if ($strpos_fnc($text, $postitem->post_title) !== false) { // credit to Dominik Deobald
208
  $name = preg_quote($postitem->post_title, '/');
214
 
215
  $newtext = preg_replace($regexp, $replace, $text, $maxsingle);
216
  if ($newtext!=$text) {
217
+ $url = get_permalink($postitem->ID);
218
+ if (!$maxsingleurl || $urls[$url]<$maxsingleurl)
219
+ {
220
+ $links++;
221
+ $text=str_replace('$$$url$$$', $url, $newtext);
222
+ if (!isset($urls[$url])) $urls[$url]=1; else $urls[$url]++;
223
+ }
224
  }
225
  }
226
  }
240
 
241
  foreach ($categories as $cat)
242
  {
243
+ if ((!$maxlinks || ($links < $maxlinks)) && !in_array( $options['casesens'] ? $cat->name : strtolower($cat->name), $arrignore) )
244
  {
245
  if ($strpos_fnc($text, $cat->name) !== false) { // credit to Dominik Deobald
246
  $name= preg_quote($cat->name, '/');
249
 
250
  $newtext = preg_replace($regexp, $replace, $text, $maxsingle);
251
  if ($newtext!=$text) {
252
+ $url = (get_category_link($cat->term_id));
253
+ if (!$maxsingleurl || $urls[$url]<$maxsingleurl)
254
+ {
255
+ $links++;
256
+ $text=str_replace('$$$url$$$', $url, $newtext);
257
+ if (!isset($urls[$url])) $urls[$url]=1; else $urls[$url]++;
258
+ }
259
  }
260
  }
261
  }
285
  $newtext = preg_replace($regexp, $replace, $text, $maxsingle);
286
  if ($newtext!=$text) {
287
  $url = (get_tag_link($tag->term_id));
288
+ if (!$maxsingleurl || $urls[$url]<$maxsingleurl)
289
+ {
290
+ $links++;
291
+ $text=str_replace('$$$url$$$', $url, $newtext);
292
+ if (!isset($urls[$url])) $urls[$url]=1; else $urls[$url]++;
293
+ }
294
  }
295
  }
296
  }
328
  $options = $this->get_options();
329
  $link=parse_url(get_bloginfo('wpurl'));
330
  $host='http://'.$link['host'];
331
+
332
  if ($options['blanko'])
333
  $result = preg_replace('%<a(\s+.*?href=\S(?!' . $host . '))%i', '<a target="_blank"\\1', $result); // credit to Kaf Oseo
334
+
335
  if ($options['nofolo'])
336
  $result = preg_replace('%<a(\s+.*?href=\S(?!' . $host . '))%i', '<a rel="nofollow"\\1', $result);
337
 
377
  'blanko' =>'',
378
  'onlysingle' => 'on',
379
  'casesens' =>'',
380
+ 'allowfeed' => '',
381
+ 'maxsingleurl' => '1',
382
+ 'notice'=>'1'
383
  );
384
 
385
  $saved = get_option($this->SEOLinks_DB_option);
410
  {
411
 
412
  $options = $this->get_options();
413
+ if (isset($_GET['notice']))
414
+ {
415
+ if ($_GET['notice']==1)
416
+ {
417
+ $options['notice']=0;
418
+ update_option($this->SEOLinks_DB_option, $options);
419
+ }
420
+ }
421
  if ( isset($_POST['submitted']) ) {
422
 
423
  check_admin_referer('seo-smart-links');
436
  $options['ignorepost']=$_POST['ignorepost'];
437
  $options['maxlinks']=(int) $_POST['maxlinks'];
438
  $options['maxsingle']=(int) $_POST['maxsingle'];
439
+ $options['maxsingleurl']=(int) $_POST['maxsingleurl'];
440
  $options['minusage']=(int) $_POST['minusage']; // credit to Dominik Deobald
441
  $options['customkey']=$_POST['customkey'];
442
  $options['customkey_preventduplicatelink']=$_POST['customkey_preventduplicatelink'];
473
  $ignorepost=$options['ignorepost'];
474
  $maxlinks=$options['maxlinks'];
475
  $maxsingle=$options['maxsingle'];
476
+ $maxsingleurl=$options['maxsingleurl'];
477
  $minusage=$options['minusage'];
478
  $customkey=stripslashes($options['customkey']);
479
  $customkey_preventduplicatelink=$options['customkey_preventduplicatelink'] == TRUE ? 'checked' : '';
492
  $imgpath=trailingslashit(get_option('siteurl')). 'wp-content/plugins/seo-automatic-links/i';
493
  echo <<<END
494
 
495
+ <div class="wrap" style="">
496
  <h2>SEO Smart Links</h2>
497
 
498
  <div id="poststuff" style="margin-top:10px;">
499
 
500
+ <div id="sideblock" style="float:right;width:270px;margin-left:10px;">
501
+
502
+ <iframe width=270 height=800 frameborder="0" src="http://www.prelovac.com/plugin/news.php?id=1&utm_source=plugin&utm_medium=plugin&utm_campaign=SEO%2BSmart%2BLinks"></iframe>
503
+
 
 
 
 
 
 
 
 
 
504
  </div>
505
 
506
  <div id="mainblock" style="width:710px">
571
  <br><br>
572
 
573
  <h4>Limits</h4>
574
+ <p>You can limit the maximum number of different links SEO Smart Links will generate per post. Set to 0 for no limit. </p>
575
  Max Links: <input type="text" name="maxlinks" size="2" value="$maxlinks"/>
576
  <p>You can also limit maximum number of links created with the same keyword. Set to 0 for no limit. </p>
577
+ Max Single: <input type="text" name="maxsingle" size="2" value="$maxsingle"/>
578
+ <p>Limit number of same URLs the plugin will link to. Works only when Max Single above is set to 1. Set to 0 for no limit. </p>
579
+ Max Single URLs: <input type="text" name="maxsingleurl" size="2" value="$maxsingleurl"/>
580
  <br><br>
581
 
582
  <h4>External Links</h4>