Contextual Related Posts - Version 1.1

Version Description

Download this release

Release Info

Developer Ajay
Plugin Icon 128x128 Contextual Related Posts
Version 1.1
Comparing to
See all releases

Code changes from version 1.0.1 to 1.1

Files changed (3) hide show
  1. admin.inc.php +7 -0
  2. contextual-related-posts.php +9 -2
  3. readme.txt +10 -2
admin.inc.php CHANGED
@@ -14,6 +14,7 @@ function crp_options() {
14
  $crp_settings[limit] = ($_POST['limit']);
15
  $crp_settings[add_to_content] = (($_POST['add_to_content']) ? true : false);
16
  $crp_settings[add_to_feed] = (($_POST['add_to_feed']) ? true : false);
 
17
 
18
  update_option('ald_crp_settings', $crp_settings);
19
 
@@ -79,6 +80,12 @@ function crp_options() {
79
  <?php _e('Add related posts to feed','ald_crp_plugin'); ?>
80
  </label>
81
  </p>
 
 
 
 
 
 
82
  <p>
83
  <input type="submit" name="crp_save" id="crp_save" value="Save Options" style="border:#00CC00 1px solid" />
84
  <input name="crp_default" type="submit" id="crp_default" value="Default Options" style="border:#FF0000 1px solid" onclick="if (!confirm('<?php _e('Do you want to set options to Default? If you don\'t have a copy of the username, please hit Cancel and copy it first.','ald_crp_plugin'); ?>')) return false;" />
14
  $crp_settings[limit] = ($_POST['limit']);
15
  $crp_settings[add_to_content] = (($_POST['add_to_content']) ? true : false);
16
  $crp_settings[add_to_feed] = (($_POST['add_to_feed']) ? true : false);
17
+ $crp_settings[match_content] = (($_POST['match_content']) ? true : false);
18
 
19
  update_option('ald_crp_settings', $crp_settings);
20
 
80
  <?php _e('Add related posts to feed','ald_crp_plugin'); ?>
81
  </label>
82
  </p>
83
+ <p>
84
+ <label>
85
+ <input type="checkbox" name="match_content" id="match_content" <?php if ($crp_settings[match_content]) echo 'checked="checked"' ?> />
86
+ <?php _e('Find related posts based on content as well as title. If unchecked, only posts titles are used. (I recommend using a caching plugin if you enable this)','ald_crp_plugin'); ?>
87
+ </label>
88
+ </p>
89
  <p>
90
  <input type="submit" name="crp_save" id="crp_save" value="Save Options" style="border:#00CC00 1px solid" />
91
  <input name="crp_default" type="submit" id="crp_default" value="Default Options" style="border:#FF0000 1px solid" onclick="if (!confirm('<?php _e('Do you want to set options to Default? If you don\'t have a copy of the username, please hit Cancel and copy it first.','ald_crp_plugin'); ?>')) return false;" />
contextual-related-posts.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Contextual Related Posts
4
- Version: 1.0.1
5
  Plugin URI: http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/
6
  Description: Show user defined number of contextually related posts. Based on the plugin by <a href="http://weblogtoolscollection.com">Mark Ghosh</a>. <a href="options-general.php?page=crp_options">Configure...</a>
7
  Author: Ajay D'Souza
@@ -30,7 +30,13 @@ function ald_crp() {
30
  $time_difference = get_settings('gmt_offset');
31
  $now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));
32
 
33
- $stuff = addslashes($post->post_title);
 
 
 
 
 
 
34
  $sql = "SELECT ID,post_title,post_content,post_excerpt,post_date,"
35
  . "MATCH(post_title,post_content) AGAINST ('$stuff') AS score "
36
  . "FROM $poststable WHERE "
@@ -94,6 +100,7 @@ function crp_default_options() {
94
  add_to_content => true, // Add related posts to content (only on single pages)
95
  add_to_feed => true, // Add related posts to feed
96
  limit => '5' // How many posts to display?
 
97
  );
98
  return $crp_settings;
99
  }
1
  <?php
2
  /*
3
  Plugin Name: Contextual Related Posts
4
+ Version: 1.1
5
  Plugin URI: http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/
6
  Description: Show user defined number of contextually related posts. Based on the plugin by <a href="http://weblogtoolscollection.com">Mark Ghosh</a>. <a href="options-general.php?page=crp_options">Configure...</a>
7
  Author: Ajay D'Souza
30
  $time_difference = get_settings('gmt_offset');
31
  $now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));
32
 
33
+ if($crp_settings['match_content']) {
34
+ $stuff = addslashes($post->post_title. ' ' . $post->post_content);
35
+ }
36
+ else {
37
+ $stuff = addslashes($post->post_title);
38
+ }
39
+
40
  $sql = "SELECT ID,post_title,post_content,post_excerpt,post_date,"
41
  . "MATCH(post_title,post_content) AGAINST ('$stuff') AS score "
42
  . "FROM $poststable WHERE "
100
  add_to_content => true, // Add related posts to content (only on single pages)
101
  add_to_feed => true, // Add related posts to feed
102
  limit => '5' // How many posts to display?
103
+ match_content => '5' // Match against post content as well as title
104
  );
105
  return $crp_settings;
106
  }
readme.txt CHANGED
@@ -19,9 +19,15 @@ Display a list of contextually related posts for the current post. You can selec
19
 
20
  2. Extract the contents of contextual-related-posts.zip to wp-content/plugins/ folder. You should get a folder called contextual-related-posts.
21
 
22
- 4. Activate the Plugin in WP-Admin.
23
 
24
- 5. Goto Settings > Related Posts to configure
 
 
 
 
 
 
25
 
26
 
27
  == Frequently Asked Questions ==
@@ -35,6 +41,8 @@ WordPress 2.0 or above
35
 
36
  All options can be customized within the Options page in WP-Admin itself
37
 
 
 
38
  For more information, please visit http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/
39
 
40
  = Support =
19
 
20
  2. Extract the contents of contextual-related-posts.zip to wp-content/plugins/ folder. You should get a folder called contextual-related-posts.
21
 
22
+ 3. Activate the Plugin in WP-Admin.
23
 
24
+ 4. Goto Settings > Related Posts to configure
25
+
26
+
27
+ == Changelog ==
28
+
29
+ * 1.1 - Fixed MySQL index key conflicts by using a more unique index key name.
30
+ * 1.0.1 - Release
31
 
32
 
33
  == Frequently Asked Questions ==
41
 
42
  All options can be customized within the Options page in WP-Admin itself
43
 
44
+ The plugin uses the css class `crp_related` in the `div` that surrounds the list items. So, if you are interested, you can add code to your *style.css* file of your theme to style the related posts list.
45
+
46
  For more information, please visit http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/
47
 
48
  = Support =