Yet Another Related Posts Plugin (YARPP) - Version 1.0.1

Version Description

Download this release

Release Info

Developer mitchoyoshitaka
Plugin Icon 128x128 Yet Another Related Posts Plugin (YARPP)
Version 1.0.1
Comparing to
See all releases

Code changes from version 1.0 to 1.0.1

Files changed (4) hide show
  1. readme.txt +11 -7
  2. trunk/readme.txt +0 -55
  3. trunk/yarpp.php +0 -296
  4. yarpp.php +3 -3
readme.txt CHANGED
@@ -6,16 +6,16 @@ Plugin URI: http://mitcho.com/code/
6
  Donate link: http://mitcho.com/code/
7
  Tags: related, posts, post
8
  Requires at least: 2.0
9
- Tested up to: 2.3.1
10
- Stable tag: 1.0
11
 
12
  Returns a list of the related entries based on keyword matches, limited by a certain relatedness threshold. Like the tried and true Related Posts plugins�just better!
13
 
14
  == Description ==
15
 
16
- Yet Another Related Posts Plugin (YARPP) is the result of some tinkering with [John Bowyer's version](http://peter.mapledesign.co.uk/weblog/archives/wordpress-related-posts-plugin) of [Alexander Malov & Mike Lu's Related Entries plugin](http://wasabi.pbwiki.com/Related%20Entries). Modifications made include:
17
 
18
- 1. *Limiting by a threshold*: John Bowyer did the great work of making the algorithm use [[mysql]]'s [fulltext search](dev.mysql.com/doc/en/Fulltext_Search.html) score to identify related posts. But it currently just displayed, for example, the top 5 most "relevant" entries, even if some of them weren't at all similar. Now you can set a threshold limit for relevance, and you get more related posts if there are more related posts. Ha!
19
  2. *Being a better plugin citizen*: now it doesn't require the user to click some sketchy button to `alter` the database and enable a `fulltext key`. Using [`register_activation_hook`](http://codex.wordpress.org/Function_Reference/register_activation_hook), it does it automagically on plugin activation. Just install and go!
20
  3. *Miscellany*: a nicer options screen, displaying the fulltext match score on output for admins, an option to allow related posts from the future, a couple bug fixes, etc.
21
 
@@ -25,13 +25,13 @@ Just put it in your `/wp-content/plugins/` directory, activate, and then drop th
25
 
26
  You can override any options in an individual instance of `related_posts` using the following syntax:
27
 
28
- >`related_posts(limit, threshold, before title, after title, show excerpt, len, before excerpt, after excerpt, show pass posts, past only, show score);
29
 
30
  Most of these should be self-explanatory. They're also in the same order as the options on the YARPP Options pane.
31
 
32
  Example: `related_posts(10, null, 'title: ')` changes the maximum related posts number to 10, keeps the default threshold from the Options pane, and adds `title:` to the beginning of every title.
33
 
34
- There's also a `related_posts_exist)` function. It has three optional arguments to override the defaults: a threshold, the past only boolean, and the show password-protected posts boolean.
35
 
36
  == Examples ==
37
 
@@ -52,4 +52,8 @@ On my own blog I use the following code with `<li>` and `</li>` as the before/af
52
  == Coming soon (probably) ==
53
 
54
  1. Incorporation of tags and categories in the algorithm. I've gotten the code working, but I still need to think about what the most natural algorithm would be for weighing these factors against the mysql fulltext score currently used (and works pretty well, I must say).
55
- 2. Um, something else! Let me know if you have any suggestions for improvement. ^^
 
 
 
 
6
  Donate link: http://mitcho.com/code/
7
  Tags: related, posts, post
8
  Requires at least: 2.0
9
+ Tested up to: 2.3.2
10
+ Stable tag: 1.0.1
11
 
12
  Returns a list of the related entries based on keyword matches, limited by a certain relatedness threshold. Like the tried and true Related Posts plugins�just better!
13
 
14
  == Description ==
15
 
16
+ Yet Another Related Posts Plugin (YARPP) is the result of some tinkering with [Peter Bowyer's version](http://peter.mapledesign.co.uk/weblog/archives/wordpress-related-posts-plugin) of [Alexander Malov & Mike Lu's Related Entries plugin](http://wasabi.pbwiki.com/Related%20Entries). Modifications made include:
17
 
18
+ 1. *Limiting by a threshold*: Peter Bowyer did the great work of making the algorithm use MySQL's [fulltext search](dev.mysql.com/doc/en/Fulltext_Search.html) score to identify related posts. But it currently just displayed, for example, the top 5 most "relevant" entries, even if some of them weren't at all similar. Now you can set a threshold limit for relevance, and you get more related posts if there are more related posts and less if there are less. Ha!
19
  2. *Being a better plugin citizen*: now it doesn't require the user to click some sketchy button to `alter` the database and enable a `fulltext key`. Using [`register_activation_hook`](http://codex.wordpress.org/Function_Reference/register_activation_hook), it does it automagically on plugin activation. Just install and go!
20
  3. *Miscellany*: a nicer options screen, displaying the fulltext match score on output for admins, an option to allow related posts from the future, a couple bug fixes, etc.
21
 
25
 
26
  You can override any options in an individual instance of `related_posts` using the following syntax:
27
 
28
+ > `related_posts(limit, threshold, before title, after title, show excerpt, len, before excerpt, after excerpt, show pass posts, past only, show score);`
29
 
30
  Most of these should be self-explanatory. They're also in the same order as the options on the YARPP Options pane.
31
 
32
  Example: `related_posts(10, null, 'title: ')` changes the maximum related posts number to 10, keeps the default threshold from the Options pane, and adds `title:` to the beginning of every title.
33
 
34
+ There's also a `related_posts_exist()` function. It has three optional arguments to override the defaults: a threshold, the past only boolean, and the show password-protected posts boolean.
35
 
36
  == Examples ==
37
 
52
  == Coming soon (probably) ==
53
 
54
  1. Incorporation of tags and categories in the algorithm. I've gotten the code working, but I still need to think about what the most natural algorithm would be for weighing these factors against the mysql fulltext score currently used (and works pretty well, I must say).
55
+ 2. Um, something else! Let me know if you have any suggestions for improvement. ^^
56
+
57
+ == Version log ==
58
+ 1.0 Initial upload
59
+ 1.0.1 Bugfix: 1.0 assumed you had Markdown installed
trunk/readme.txt DELETED
@@ -1,55 +0,0 @@
1
- === Yet Another Related Posts Plugin ===
2
- Contributors: mitchoyoshitaka
3
- Author: mitcho (Michael Yoshitaka Erlewine)
4
- Author URI: http://mitcho.com/
5
- Plugin URI: http://mitcho.com/code/
6
- Donate link: http://mitcho.com/code/
7
- Tags: related, posts, post
8
- Requires at least: 2.0
9
- Tested up to: 2.3.1
10
- Stable tag: 1.0
11
-
12
- Returns a list of the related entries based on keyword matches, limited by a certain relatedness threshold. Like the tried and true Related Posts plugins�just better!
13
-
14
- == Description ==
15
-
16
- Yet Another Related Posts Plugin (YARPP) is the result of some tinkering with [Peter Bowyer's version](http://peter.mapledesign.co.uk/weblog/archives/wordpress-related-posts-plugin) of [Alexander Malov & Mike Lu's Related Entries plugin](http://wasabi.pbwiki.com/Related%20Entries). Modifications made include:
17
-
18
- 1. *Limiting by a threshold*: Peter Bowyer did the great work of making the algorithm use MySQL's [fulltext search](dev.mysql.com/doc/en/Fulltext_Search.html) score to identify related posts. But it currently just displayed, for example, the top 5 most "relevant" entries, even if some of them weren't at all similar. Now you can set a threshold limit for relevance, and you get more related posts if there are more related posts. Ha!
19
- 2. *Being a better plugin citizen*: now it doesn't require the user to click some sketchy button to `alter` the database and enable a `fulltext key`. Using [`register_activation_hook`](http://codex.wordpress.org/Function_Reference/register_activation_hook), it does it automagically on plugin activation. Just install and go!
20
- 3. *Miscellany*: a nicer options screen, displaying the fulltext match score on output for admins, an option to allow related posts from the future, a couple bug fixes, etc.
21
-
22
- == Installation ==
23
-
24
- Just put it in your `/wp-content/plugins/` directory, activate, and then drop the `related_posts` function in your [WP loop](http://codex.wordpress.org/The_Loop). Change any options in the Related Posts (YARPP) Options pane in Admin > Plugins.
25
-
26
- You can override any options in an individual instance of `related_posts` using the following syntax:
27
-
28
- > `related_posts(limit, threshold, before title, after title, show excerpt, len, before excerpt, after excerpt, show pass posts, past only, show score);`
29
-
30
- Most of these should be self-explanatory. They're also in the same order as the options on the YARPP Options pane.
31
-
32
- Example: `related_posts(10, null, 'title: ')` changes the maximum related posts number to 10, keeps the default threshold from the Options pane, and adds `title:` to the beginning of every title.
33
-
34
- There's also a `related_posts_exist()` function. It has three optional arguments to override the defaults: a threshold, the past only boolean, and the show password-protected posts boolean.
35
-
36
- == Examples ==
37
-
38
- For a barebones setup, just drop `<?php related_posts(); ?>` right after `<?php the_content() ?>`.
39
-
40
- On my own blog I use the following code with `<li>` and `</li>` as the before/after entry options:
41
-
42
- >`<?php if (related_posts_exist()): ?>`
43
- >`<p>Related posts:`
44
- >`<ol>`
45
- >`<?php related_posts();?>`
46
- >`</ol>`
47
- >`</p>`
48
- >`<?php else: ?>`
49
- >`<p>No related posts.</p>`
50
- >`<?php endif; ?>`
51
-
52
- == Coming soon (probably) ==
53
-
54
- 1. Incorporation of tags and categories in the algorithm. I've gotten the code working, but I still need to think about what the most natural algorithm would be for weighing these factors against the mysql fulltext score currently used (and works pretty well, I must say).
55
- 2. Um, something else! Let me know if you have any suggestions for improvement. ^^
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/yarpp.php DELETED
@@ -1,296 +0,0 @@
1
- <?php
2
- /*
3
- Plugin Name: Yet Another Related Posts Plugin
4
- Plugin URI: http://mitcho.com/code
5
- Description: Returns a list of the related entries based on keyword matches, limited by a certain relatedness threshold. Like the tried and true Related Posts plugins—just better!
6
- Version: 1.0
7
- Author: Alexander Malov, Mike Lu, Peter Bowyer, mitcho (Michael Erlewine)
8
- */
9
-
10
- // Begin setup
11
-
12
- $yarpp_version = "1.0";
13
-
14
- function yarpp_enabled() {
15
- global $wpdb;
16
- $indexdata = $wpdb->get_results("show index from $wpdb->posts");
17
- foreach ($indexdata as $index) {
18
- if ($index->Key_name == 'post_related') return 1;
19
- }
20
- return 0;
21
- }
22
-
23
- function yarpp_activate() {
24
- global $wpdb;
25
- add_option('threshold',5);
26
- add_option('limit',5);
27
- add_option('lim',10);
28
- add_option('show_score',true);
29
- if (!yarpp_enabled()) {
30
- $wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `post_related` ( `post_name` , `post_content` )");
31
- }
32
- return 1;
33
- }
34
-
35
- // End setup
36
-
37
- // Begin Related Posts
38
-
39
- // This section was more or less completely written by
40
-
41
- /**
42
- * Builds a word frequency list from the Wordpress post, and returns a string
43
- * to be used in matching against the MySQL full-text index.
44
- *
45
- * @param integer $num_to_ret The number of words to use when matching against
46
- * the database.
47
- * @return string The words
48
- */
49
- function current_post_keywords($num_to_ret = 20) {
50
- global $post;
51
- // An array of weightings, to make adjusting them easier.
52
- $w = array(
53
- 'title' => 2,
54
- 'name' => 2,
55
- 'content' => 1,
56
- 'cat_name' => 3
57
- );
58
-
59
- /*
60
- Thanks to http://www.eatdrinksleepmovabletype.com/tutorials/building_a_weighted_keyword_list/
61
- for the basics for this code. It saved me much typing (or thinking) :)
62
- */
63
-
64
- // This needs experimenting with. I've given post title and url a double
65
- // weighting, changing this may give you better results
66
- $string = str_repeat($post->post_title, $w['title'].' ').
67
- str_repeat(str_replace('-', ' ', $post->post_name).' ', $w['name']).
68
- str_repeat(strip_tags((MARKDOWN_WP_POSTS) ? Markdown($post->post_content) : $post->post_content), $w['content'].' ');//mitcho: strip_tags
69
-
70
- // Cat names don't help with the current query: the category names of other
71
- // posts aren't retrieved by the query to be matched against (and can't be
72
- // indexed)
73
- // But I've left this in just in case...
74
- $post_categories = get_the_category();
75
- foreach ($post_categories as $cat) {
76
- $string .= str_repeat($cat->cat_name.' ', $w['cat_name']);
77
- }
78
-
79
- // Remove punctuation.
80
- $wordlist = preg_split('/\s*[\s+\.|\?|,|(|)|\-+|\'|\"|=|;|&#0215;|\$|\/|:|{|}]\s*/i', strtolower($string));
81
-
82
- // Build an array of the unique words and number of times they occur.
83
- $a = array_count_values($wordlist);
84
-
85
- //Remove words that don't matter--"stop words."
86
- $overusedwords = array( '', 'a', 'an', 'the', 'and', 'of', 'i', 'to', 'is', 'in', 'with', 'for', 'as', 'that', 'on', 'at', 'this', 'my', 'was', 'our', 'it', 'you', 'we', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '10', 'about', 'after', 'all', 'almost', 'along', 'also', 'amp', 'another', 'any', 'are', 'area', 'around', 'available', 'back', 'be', 'because', 'been', 'being', 'best', 'better', 'big', 'bit', 'both', 'but', 'by', 'c', 'came', 'can', 'capable', 'control', 'could', 'course', 'd', 'dan', 'day', 'decided', 'did', 'didn', 'different', 'div', 'do', 'doesn', 'don', 'down', 'drive', 'e', 'each', 'easily', 'easy', 'edition', 'end', 'enough', 'even', 'every', 'example', 'few', 'find', 'first', 'found', 'from', 'get', 'go', 'going', 'good', 'got', 'gt', 'had', 'hard', 'has', 'have', 'he', 'her', 'here', 'how', 'if', 'into', 'isn', 'just', 'know', 'last', 'left', 'li', 'like', 'little', 'll', 'long', 'look', 'lot', 'lt', 'm', 'made', 'make', 'many', 'mb', 'me', 'menu', 'might', 'mm', 'more', 'most', 'much', 'name', 'nbsp', 'need', 'new', 'no', 'not', 'now', 'number', 'off', 'old', 'one', 'only', 'or', 'original', 'other', 'out', 'over', 'part', 'place', 'point', 'pretty', 'probably', 'problem', 'put', 'quite', 'quot', 'r', 're', 'really', 'results', 'right', 's', 'same', 'saw', 'see', 'set', 'several', 'she', 'sherree', 'should', 'since', 'size', 'small', 'so', 'some', 'something', 'special', 'still', 'stuff', 'such', 'sure', 'system', 't', 'take', 'than', 'their', 'them', 'then', 'there', 'these', 'they', 'thing', 'things', 'think', 'those', 'though', 'through', 'time', 'today', 'together', 'too', 'took', 'two', 'up', 'us', 'use', 'used', 'using', 've', 'very', 'want', 'way', 'well', 'went', 'were', 'what', 'when', 'where', 'which', 'while', 'white', 'who', 'will', 'would', 'your');
87
-
88
- // Remove the stop words from the list.
89
- foreach ($overusedwords as $word) {
90
- unset($a[$word]);
91
- }
92
- arsort($a, SORT_NUMERIC);
93
-
94
- $num_words = count($a);
95
- $num_to_ret = $num_words > $num_to_ret ? $num_to_ret : $num_words;
96
-
97
- $outwords = array_slice($a, 0, $num_to_ret);
98
- return implode(' ', array_keys($outwords));
99
-
100
- }
101
-
102
- function related_posts() {
103
-
104
- global $wpdb, $post, $user_level;
105
- get_currentuserinfo();
106
-
107
- // Get option values from the options page--this can be overwritten: see readme
108
- $args = func_get_args();
109
- $options = array('limit','threshold','before_title','after_title','show_excerpt','len','before_post','after_post','show_pass_post','past_only','show_score');
110
- $optvals = array();
111
- foreach (array_keys($options) as $index) {
112
- if (isset($args[$index+1])) {
113
- $optvals[$options[$index]] = stripslashes($args[$index+1]);
114
- } else {
115
- $optvals[$options[$index]] = stripslashes(get_option($options[$index]));
116
- }
117
- }
118
- extract($optvals);
119
-
120
- // Fetch keywords
121
- $terms = current_post_keywords();
122
-
123
- // Make sure the post is not from the future
124
- $time_difference = get_settings('gmt_offset');
125
- $now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));
126
-
127
- // Primary SQL query
128
-
129
- $sql = "SELECT ID, post_title, post_content,"
130
- . "MATCH (post_name, post_content) "
131
- . "AGAINST ('$terms') AS score "
132
- . "FROM $wpdb->posts WHERE "
133
- . "MATCH (post_name, post_content) AGAINST ('$terms') >= $threshold "
134
- . "AND (post_status IN ( 'publish', 'static' ) && ID != '$post->ID') ";
135
- if (past_only) { $sql .= "AND post_date <= '$now' "; }
136
- if ($show_pass_post=='false') { $sql .= "AND post_password ='' "; }
137
- $sql .= "ORDER BY score DESC LIMIT $limit";
138
- $results = $wpdb->get_results($sql);
139
- $output = '';
140
- if ($results) {
141
- foreach ($results as $result) {
142
- $title = stripslashes(apply_filters('the_title', $result->post_title));
143
- $permalink = get_permalink($result->ID);
144
- $post_content = strip_tags($result->post_content);
145
- $post_content = stripslashes($post_content);
146
- $output .= $before_title .'<a href="'. $permalink .'" rel="bookmark" title="Permanent Link: ' . $title . '">' . $title . (($show_score and $user_level >= 8)? ' ('.round($result->score,3).')':'') . '</a>' . $after_title;
147
- if ($show_excerpt=='true') {
148
- $ze = substr($post_content, 0, $len);
149
- $ze = substr($ze, 0, strrpos($ze,''));
150
- $ze = $ze . '...';
151
- $output .= $before_post . $ze . $after_post;
152
- }
153
- }
154
- echo $output;
155
- } else {
156
- echo $before_title.'No related posts'.$after_title;
157
- }
158
- }
159
-
160
- function related_posts_exist($threshold = 0,$past_only = 2,$show_pass_post = 2) {
161
- global $wpdb, $post;
162
-
163
- if ($threshold == 0) $threshold = get_option('threshold');
164
- if ($past_only == 2) $past_only = get_option('past_only');
165
- if ($show_pass_post == 2) $past_only = get_option('show_pass_post');
166
- $terms = current_post_keywords();
167
-
168
- $time_difference = get_settings('gmt_offset');
169
- $now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));
170
-
171
- $sql = "SELECT COUNT(*) as count "
172
- . "FROM $wpdb->posts WHERE "
173
- . "MATCH (post_name, post_content) AGAINST ('$terms') >= $threshold "
174
- . "AND (post_status IN ( 'publish', 'static' ) && ID != '$post->ID') ";
175
- if (past_only) { $sql .= "AND post_date <= '$now' "; }
176
- if ($show_pass_post=='false') { $sql .= "AND post_password ='' "; }
177
- $result = $wpdb->get_var($sql);
178
- return $result > 0 ? true: false;
179
- }
180
-
181
- // End Related Posts
182
-
183
- // Begin Related Posts Options
184
-
185
- function yarpp_subpanel() {
186
- global $yarpp_version;
187
- if (!yarpp_enabled()) {
188
- echo '<div class="updated">';
189
- if (yarpp_activate()) echo 'The YARPP database had an error but has been fixed.';
190
- echo '</div>';
191
- }
192
-
193
- if (isset($_POST['update_yarpp'])) {
194
- $valueoptions = array('limit','threshold','len','before_title','after_title','before_post','after_post');
195
- foreach ($valueoptions as $option) {
196
- update_option($option,$_POST[$option]);
197
- }
198
- $checkoptions = array('past_only','show_score','show_excerpt','show_pass_post');
199
- foreach ($checkoptions as $option) {
200
- (isset($_POST[$option])) ? update_option($option,true) : update_option($option,false);
201
- }
202
- ?> <div class="updated">Options saved!</div><?php
203
- }
204
-
205
- function checkbox($option,$desc,$tr="<tr>
206
- <td colspan='2'>",$inputplus = '') {
207
- echo " $tr<label for='$option'>$desc</label></td>
208
- <td>
209
- <input $inputplus type='checkbox' name='$option' value='true'". ((get_option($option)) ? ' checked="checked"': '' )." />
210
- </td>
211
- </tr>";
212
- }
213
- function textbox($option,$desc,$size=2,$tr="<tr>
214
- <td colspan='2'>") {
215
- echo " $tr<label for='$option'>$desc</label></td>
216
- <td><input name='$option' type='text' id='$option' value='".htmlspecialchars(stripslashes(get_option($option)))."' size='$size' /></td>
217
- </tr>";
218
- }
219
-
220
- if (get_option('threshold') == '') update_option('threshold',5);
221
- if (get_option('length') == '') update_option('length',5);
222
- if (get_option('len') == '') update_option('len',10);
223
- ?>
224
-
225
- <div class="wrap">
226
- <h2>Yet Another Related Posts Plugin Options <small><?php echo $yarpp_version; ?></small></h2>
227
- <p><small>by <a href="http://mitcho.com/code/">mitcho (Michael 芳貴 Erlewine)</a> and based on the fabulous work of <a href="http://peter.mapledesign.co.uk/weblog/archives/wordpress-related-posts-plugin">Peter Bower</a>, <a href="http://wasabi.pbwiki.com/Related%20Entries">Alexander Malov & Mike Lu</a>.</small></p>
228
- <form method="post">
229
- <fieldset class="options">
230
- <h3>"Relatedness" options</h3>
231
- <p>YARPP is different than the <a href="http://wasabi.pbwiki.com/Related%20Entries">previous plugins it is based on</a> as it limits the related posts list by (1) a maximum number and (2) a <em>match threshold</em>. <a href="#" onclick="javascript:document.getElementById('yarpp_match_explanation').style.display = 'inline';this.style.display='none'" id="yarpp_match_explanation_trigger">Tell me more.</a></p>
232
-
233
- <p id="yarpp_match_explanation" style="display:none;">The higher the match threshold, the more restrictive, and you get less related posts overall. By default, the match threshold is 5. If you want to find an appropriate match score, I recommend you turn on the "show admins the match scores" setting below. That way, you can see what kinds of related posts are being picked up and with what kind of match scores, and determine an apprpriate threshold for your site. <a href="#" onclick="javascript:document.getElementById('yarpp_match_explanation_trigger').style.display = 'inline';this.parentNode.style.display='none'" id="yarpp_match_explanation_trigger">Tell me less now.</a></p>
234
-
235
- <table>
236
- <?php textbox('limit','Maximum number of related posts:')?>
237
- <?php textbox('threshold','Match threshold:')?>
238
- </table>
239
- <h3>Display options</h3>
240
- <table>
241
- <tr>
242
- <td colspan='2'><label for="before_title">Before</label> / <label for="after_title">After (Post Title) </label>:</td>
243
- <td><input name="before_title" type="text" id="before_title" value="<?php echo htmlspecialchars(stripslashes(get_option('before_title'))); ?>" size="10" /> / <input name="after_title" type="text" id="after_title" value="<?php echo htmlspecialchars(stripslashes(get_option('after_title'))); ?>" size="10" /><em><small> For example: &lt;li&gt;&lt;/li&gt; or &lt;dl&gt;&lt;/dl&gt;</small></em>
244
- </td>
245
- </tr>
246
- <?php checkbox('show_excerpt',"Show excerpt?","<tr>
247
- <td colspan='2'>",' onclick="javascript:excerpt()"'); ?>
248
- <?php textbox('len','Excerpt length (No. of words):',null,"<tr name='excerpted'>
249
- <td style='background-color: gray; width: .3px;'>&nbsp;</td><td>")?>
250
-
251
- <tr name="excerpted">
252
- <td style='background-color: gray; width: 3px;'>&nbsp;</td><td><label for="before_post">Before</label> / <label for="after_post">After</label> (Excerpt):</td>
253
- <td><input name="before_post" type="text" id="before_post" value="<?php echo htmlspecialchars(stripslashes(get_option('before_post'))); ?>" size="10" /> / <input name="after_post" type="text" id="after_post" value="<?php echo htmlspecialchars(stripslashes(get_option('after_post'))); ?>" size="10" /><em><small> For example: &lt;li&gt;&lt;/li&gt; or &lt;dl&gt;&lt;/dl&gt;</small></em>
254
- </td>
255
- </tr>
256
-
257
- <?php checkbox('show_past_post',"Show password protected posts?"); ?>
258
- <?php checkbox('past_only',"Show only previous posts?"); ?>
259
- <?php checkbox('show_score',"Show admins (user level > 8) the match scores?"); ?>
260
-
261
- </table>
262
- </fieldset>
263
-
264
- <div class="submit"><input type="submit" name="update_yarpp" value="<?php _e('Save!', 'update_yarpp') ?>" style="font-weight:bold;" /></div>
265
-
266
- </form>
267
-
268
- </div>
269
- <script language="javascript">
270
- function excerpt() {
271
- if (!document.getElementsByName('show_excerpt')[0].checked) {
272
- document.getElementsByName('excerpted')[0].style.display = 'none';
273
- document.getElementsByName('excerpted')[1].style.display = 'none';
274
- } else {
275
- document.getElementsByName('excerpted')[0].style.display = 'table-row';
276
- document.getElementsByName('excerpted')[1].style.display = 'table-row';
277
- }
278
- }
279
- excerpt();
280
- </script>
281
-
282
- <?php }
283
-
284
- // End Related Posts Options
285
-
286
- function yarpp_admin_menu() {
287
- if (function_exists('add_submenu_page')) {
288
- add_submenu_page('plugins.php', __('Related Posts (YARPP) Options'), __('Related Posts (YARPP) Options'), 1, __FILE__, 'yarpp_subpanel');
289
- }
290
- }
291
-
292
- // add_action('publish_post', 'find_keywords', 1);
293
- add_action('admin_menu', 'yarpp_admin_menu');
294
- register_activation_hook(__FILE__,'yarpp_activate' );
295
-
296
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
yarpp.php CHANGED
@@ -3,13 +3,13 @@
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://mitcho.com/code
5
  Description: Returns a list of the related entries based on keyword matches, limited by a certain relatedness threshold. Like the tried and true Related Posts plugins—just better!
6
- Version: 1.0
7
  Author: Alexander Malov, Mike Lu, Peter Bowyer, mitcho (Michael Erlewine)
8
  */
9
 
10
  // Begin setup
11
 
12
- $yarpp_version = "1.0";
13
 
14
  function yarpp_enabled() {
15
  global $wpdb;
@@ -65,7 +65,7 @@ function current_post_keywords($num_to_ret = 20) {
65
  // weighting, changing this may give you better results
66
  $string = str_repeat($post->post_title, $w['title'].' ').
67
  str_repeat(str_replace('-', ' ', $post->post_name).' ', $w['name']).
68
- str_repeat(strip_tags((MARKDOWN_WP_POSTS) ? Markdown($post->post_content) : $post->post_content), $w['content'].' ');//mitcho: strip_tags
69
 
70
  // Cat names don't help with the current query: the category names of other
71
  // posts aren't retrieved by the query to be matched against (and can't be
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://mitcho.com/code
5
  Description: Returns a list of the related entries based on keyword matches, limited by a certain relatedness threshold. Like the tried and true Related Posts plugins—just better!
6
+ Version: 1.0.1
7
  Author: Alexander Malov, Mike Lu, Peter Bowyer, mitcho (Michael Erlewine)
8
  */
9
 
10
  // Begin setup
11
 
12
+ $yarpp_version = "1.0.1";
13
 
14
  function yarpp_enabled() {
15
  global $wpdb;
65
  // weighting, changing this may give you better results
66
  $string = str_repeat($post->post_title, $w['title'].' ').
67
  str_repeat(str_replace('-', ' ', $post->post_name).' ', $w['name']).
68
+ str_repeat(strip_tags((defined(MARKDOWN_WP_POSTS)) ? Markdown($post->post_content) : $post->post_content), $w['content'].' ');//mitcho: strip_tags
69
 
70
  // Cat names don't help with the current query: the category names of other
71
  // posts aren't retrieved by the query to be matched against (and can't be