Contextual Related Posts - Version 1.3

Version Description

Download this release

Release Info

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

Code changes from version 1.2.2 to 1.3

admin.inc.php CHANGED
@@ -174,8 +174,9 @@ function crp_adminmenu() {
174
  }
175
 
176
  if ((function_exists('add_options_page'))&&($crp_is_admin)) {
177
- add_options_page(__("Related Posts", 'myald_crp_plugin'), __("Related Posts", 'myald_crp_plugin'), 9, 'crp_options', 'crp_options');
178
- }
 
179
  }
180
  add_action('admin_menu', 'crp_adminmenu');
181
 
@@ -192,17 +193,8 @@ if (siw && siw.selectingSomething)
192
  return answer;
193
  }//
194
  </script>
195
- <?php }
196
- add_action('admin_head', 'crp_adminhead');
197
-
198
- function crp_adminfoot() {
199
- global $crp_url;
200
-
201
- ?>
202
  <script type="text/javascript" src="<?php echo $crp_url ?>/wick/sample_data.js.php"></script>
203
  <script type="text/javascript" src="<?php echo $crp_url ?>/wick/wick.js"></script>
204
  <?php }
205
- add_action('admin_footer', 'crp_adminfoot');
206
-
207
 
208
  ?>
174
  }
175
 
176
  if ((function_exists('add_options_page'))&&($crp_is_admin)) {
177
+ $plugin_page = add_options_page(__("Related Posts", 'myald_crp_plugin'), __("Related Posts", 'myald_crp_plugin'), 9, 'crp_options', 'crp_options');
178
+ add_action( 'admin_head-'. $plugin_page, 'crp_adminhead' );
179
+ }
180
  }
181
  add_action('admin_menu', 'crp_adminmenu');
182
 
193
  return answer;
194
  }//
195
  </script>
 
 
 
 
 
 
 
196
  <script type="text/javascript" src="<?php echo $crp_url ?>/wick/sample_data.js.php"></script>
197
  <script type="text/javascript" src="<?php echo $crp_url ?>/wick/wick.js"></script>
198
  <?php }
 
 
199
 
200
  ?>
contextual-related-posts.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Contextual Related Posts
4
- Version: 1.2.2
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
@@ -48,7 +48,7 @@ function ald_crp() {
48
  if ($crp_settings['exclude_pages']) $sql .= "AND post_type = 'post' ";
49
  $sql .= "ORDER BY score DESC ";
50
 
51
- $search_counter = 1;
52
  $searches = $wpdb->get_results($sql);
53
 
54
  $output = '<div id="crp_related">';
@@ -58,18 +58,18 @@ function ald_crp() {
58
  $output .= '<ul>';
59
  foreach($searches as $search) {
60
  $categorys = get_the_category($search->ID); //Fetch categories of the plugin
61
- $p_in_c = false;
62
  $title = trim(stripslashes($search->post_title));
63
- foreach ($categorys as $cat) {
64
- if (!$p_in_c) $p_in_c = (in_array($cat->cat_ID, $exclude_categories)) ? true : false;
 
65
  }
66
 
67
  if (!$p_in_c) {
68
- if ($search_counter <= $limit) {
69
- $output .= '<li><a href="'.get_permalink($search->ID).'" rel="bookmark">'.$title.'</a></li>';
70
- $search_counter++;
71
- } //end of search_counter loop
72
- }
73
  } //end of foreach loop
74
  $output .= '</ul>';
75
  }else{
1
  <?php
2
  /*
3
  Plugin Name: Contextual Related Posts
4
+ Version: 1.3
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
48
  if ($crp_settings['exclude_pages']) $sql .= "AND post_type = 'post' ";
49
  $sql .= "ORDER BY score DESC ";
50
 
51
+ $search_counter = 0;
52
  $searches = $wpdb->get_results($sql);
53
 
54
  $output = '<div id="crp_related">';
58
  $output .= '<ul>';
59
  foreach($searches as $search) {
60
  $categorys = get_the_category($search->ID); //Fetch categories of the plugin
61
+ $p_in_c = false; // Variable to check if post exists in a particular category
62
  $title = trim(stripslashes($search->post_title));
63
+ foreach ($categorys as $cat) { // Loop to check if post exists in excluded category
64
+ $p_in_c = (in_array($cat->cat_ID, $exclude_categories)) ? true : false;
65
+ if ($p_in_c) break; // End loop if post found in category
66
  }
67
 
68
  if (!$p_in_c) {
69
+ $output .= '<li><a href="'.get_permalink($search->ID).'" rel="bookmark">'.$title.'</a></li>';
70
+ $search_counter++;
71
+ }
72
+ if ($search_counter == $limit) break; // End loop when related posts limit is reached
 
73
  } //end of foreach loop
74
  $output .= '</ul>';
75
  }else{
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: Ajay, Mark Ghosh
4
  Donate link: http://ajaydsouza.com/donate/
5
  Stable tag: trunk
6
  Requires at least: 2.5
7
- Tested up to: 2.7
8
 
9
 
10
  Show user defined number of contextually related posts
@@ -32,6 +32,10 @@ Now, you can choose to exclude posts from certain categories as well as exclude
32
 
33
  = Changelog =
34
 
 
 
 
 
35
  * 1.2.2 - Minor bug fixed about limit of posts
36
  * 1.2.1 - Bug fixed to support PHP4
37
  * 1.2
4
  Donate link: http://ajaydsouza.com/donate/
5
  Stable tag: trunk
6
  Requires at least: 2.5
7
+ Tested up to: 2.7.1
8
 
9
 
10
  Show user defined number of contextually related posts
32
 
33
  = Changelog =
34
 
35
+ * 1.3
36
+ - Better optimization in WP-Admin area.
37
+ - Fixed compatibility problems with Simple Tags plugin
38
+ - Fixed large number of queries being generated
39
  * 1.2.2 - Minor bug fixed about limit of posts
40
  * 1.2.1 - Bug fixed to support PHP4
41
  * 1.2
wick/wick_sample.html DELETED
@@ -1,85 +0,0 @@
1
- <html>
2
- <head><title>WICK Testing Ground</title>
3
-
4
- <!-- WICK STEP 1: INSERT CSS -->
5
- <link rel="stylesheet" type="text/css" href="./wick.css" />
6
-
7
- </head>
8
- <body>
9
- <script type="text/javascript" language="JavaScript">
10
- function checkForm() {
11
- answer = true;
12
- if (siw && siw.selectingSomething)
13
- answer = false;
14
- return answer;
15
- }//
16
- </script>
17
- <center>
18
- <p>
19
- Welcome to the very unpolished WICK testing ground.
20
- A view source on this document should give you most information you need
21
- to make WICK work on your site, as i'm still working on more formal documentation
22
- that'll also include integration suggestions to make this work as fast as possible with
23
- large amounts of data.
24
- <br/><br/>
25
- Be sure to enter multiple e-mail addresses in each field, type a few characters, hit the delete key,
26
- use your keyboard's up and down arrows, hit return or tab to select an item, use your mouse to hover and click,
27
- deleting from a current item back into the preceding item, and basically poke around mercilessly.
28
- <br /><br />
29
- <div id="wickStatus">
30
- Loading ... please hold!
31
- </div>
32
- <br /><br />
33
- <form onsubmit="return checkForm()"> <!-- WICK STEP 5: this prevents form from being submitted right-away if a user hits RETURN to select an address -->
34
- My First Box:<br />
35
- <input class="wickEnabled" type="text" size="50" /><br />
36
- My Second Box:<br />
37
- <textarea class="wickEnabled" cols="50" rows="3" wrap="virtual"></textarea>
38
- <!-- WICK STEP 4: ADD "wickEnabled" attribute to input
39
- that'll receive autocompletion using data stored in the "collection" array defined in STEP 2 -->
40
- <br />
41
- My Third Box:<br />
42
- <textarea class="wickEnabled" cols="50" rows="3" wrap="virtual"></textarea>
43
- <br />&#160;<br />
44
- My Fourth Box with developer-built floater USING TABLE: SHRINKS TO CONTENTS:<br />
45
- <div style="position:relative;text-align:left">
46
- <table id="MYCUSTOMFLOATER" class="myCustomFloater" style="position:absolute;top:50px;left:0;background-color:#cecece;display:none;visibility:hidden">
47
- <tr><td><!--
48
- please see: http://chrisholland.blogspot.com/2004/09/geekstuff-css-display-inline-block.html
49
- to explain why i'm using a table here.
50
- You could replace the table/tr/td with a DIV, but you'd have to specify it's width and height
51
- -->
52
- <div class="myCustomFloaterContent">
53
- you should never be seeing this
54
- </div>
55
- </td></tr>
56
- </table>
57
- <textarea class="wickEnabled:MYCUSTOMFLOATER" cols="50" rows="3" wrap="virtual"></textarea>
58
- </div>
59
- <br />
60
- some content lah lah lah
61
- <br />
62
- <!--
63
- My Fourth Box with developer-built floater USING DIV: FIXED WIDTH/HEIGHT:<br />
64
- <div style="position:relative;text-align:left">
65
- <div id="MYCUSTOMFLOATER_TWO" class="myCustomFloater" style="position:absolute;top:50px;left:0;background-color:#cecece;width:300px;height:400px;display:none;visibility:hidden">
66
- <div class="myCustomFloaterContent">
67
- you should never be seeing this
68
- </div>
69
- </div>
70
- <textarea class="wickEnabled:MYCUSTOMFLOATER_TWO" cols="50" rows="3" wrap="virtual"></textarea>
71
- </div>
72
- -->
73
- <br />
74
- My Fifth Box:<br />
75
- <input class="wickEnabled" type="text" size="50" /><br />
76
- </form>
77
- </p>
78
- </center>
79
- <script type="text/javascript" language="JavaScript" src="./sample_data.js.php"></script> <!-- WICK STEP 2: DEFINE COLLECTION ARRAY THAT HOLDS DATA -->
80
- <script type="text/javascript" language="JavaScript" src="./wick.js"></script> <!-- WICK STEP 3: INSERT WICK LOGIC -->
81
- <script>
82
- document.getElementById("wickStatus").innerHTML = '<a target="_blank" href="./sample_data.js.php">Loaded <b>' + collection.length + '</b> Sample Addresses</a>';
83
- </script>
84
- </body>
85
- </html>