Yet Another Related Posts Plugin (YARPP) - Version 2.1.1

Version Description

Download this release

Release Info

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

Code changes from version 2.1 to 2.1.1

Files changed (6) hide show
  1. includes.php +17 -19
  2. keywords.php +39 -0
  3. magic.php +39 -58
  4. options.php +131 -95
  5. readme.txt +31 -6
  6. yarpp.php +1 -2
includes.php CHANGED
@@ -1,5 +1,8 @@
1
  <?php
2
 
 
 
 
3
  // here's a list of all the options YARPP uses (except version), as well as their default values, sans the yarpp_ prefix, split up into binary options and value options. These arrays are used in updating settings (options.php) and other tasks.
4
  $yarpp_value_options = array('threshold' => 5,
5
  'limit' => 5,
@@ -68,12 +71,12 @@ function yarpp_activate() {
68
  if (!yarpp_enabled()) {
69
  // $wpdb->query("ALTER TABLE `wp_posts` DROP INDEX `yarpp_cache`");
70
  if (!$wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_title` ( `post_title`)")) {
71
- echo "<!--MySQL error on adding yarpp_title: ";
72
  $wpdb->print_error();
73
  echo "-->";
74
  }
75
  if (!$wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_content` ( `post_content`)")) {
76
- echo "<!--MySQL error on adding yarpp_content: ";
77
  $wpdb->print_error();
78
  echo "-->";
79
  }
@@ -81,8 +84,8 @@ function yarpp_activate() {
81
  return 0;
82
  }
83
  }
84
- add_option('yarpp_version','2.1');
85
- update_option('yarpp_version','2.1');
86
  return 1;
87
  }
88
 
@@ -90,9 +93,10 @@ function yarpp_myisam_check() {
90
  global $wpdb;
91
  $tables = $wpdb->get_results("show table status like '$wpdb->posts'");
92
  foreach ($tables as $table) {
93
- if ($table->Engine == 'MyISAM') return 1;
 
94
  }
95
- return 0;
96
  }
97
 
98
  function yarpp_upgrade_check($inuse = false) {
@@ -126,8 +130,7 @@ function yarpp_upgrade_check($inuse = false) {
126
  }
127
 
128
  if (!$inuse)
129
- echo '<div id="message" class="updated fade" style="background-color: rgb(207, 235, 247);"><h3>An important message from YARPP:</h3><p>Thank you for upgrading to YARPP 2.0. YARPP 2.0 adds the much requested ability to limit related entry results by certain tags or categories. 2.0 also brings more fine tuned control of the magic algorithm, letting you specify how the algorithm should consider or not consider entry content, titles, tags, and categories. Make sure to adjust the new settings to your liking and perhaps readjust your threshold.</p><p>For more information, check out the <a href="http://mitcho.com/code/yarpp/">YARPP documentation</a>. (This message will not be displayed again.)</p></div>';
130
- update_option('yarpp_version','2.0');
131
  }
132
 
133
  if (get_option('yarpp_version') < 2.03) {
@@ -135,8 +138,8 @@ function yarpp_upgrade_check($inuse = false) {
135
  $wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_content` ( `post_content`)"); update_option('yarpp_version','2.03');
136
  }
137
 
138
- if (get_option('yarpp_version') < 2.1) {
139
- update_option('yarpp_version','2.1');
140
  }
141
 
142
  // just in case, try to add the index one more time.
@@ -148,7 +151,7 @@ function yarpp_upgrade_check($inuse = false) {
148
  }
149
 
150
  function yarpp_admin_menu() {
151
- add_options_page('Related Posts (YARPP)', 'Related Posts (YARPP)', 8, 'yet-another-related-posts-plugin/options.php', 'yarpp_options_page');
152
  //if (function_exists('add_submenu_page')) add_submenu_page('options-general.php', 'Related Posts (YARPP)', 'Related Posts (YARPP)', 8, 'yet-another-related-posts-plugin/options.php');
153
  }
154
 
@@ -156,7 +159,7 @@ function yarpp_options_page() {
156
  require(str_replace('includes.php','options.php',__FILE__));
157
  }
158
 
159
- // This function was written by tyok
160
  function widget_yarpp_init() {
161
 
162
  if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
@@ -167,12 +170,12 @@ function widget_yarpp_init() {
167
  global $wpdb, $post;
168
  if (is_single()) {
169
  echo $before_widget;
170
- echo $before_title . 'Related Posts' . $after_title;
171
  echo yarpp_related(array('post'),array());
172
  echo $after_widget;
173
  }
174
  }
175
- register_sidebar_widget(__('YARPP'), 'widget_yarpp');
176
  }
177
 
178
  function yarpp_default($content) {
@@ -297,11 +300,6 @@ function yarpp_upgrade_one_five() {
297
  unset($yarpp_version);
298
  }
299
 
300
- // upgrade to 1.5!
301
- function yarpp_upgrade_one_six() {
302
- global $wpdb;
303
- }
304
-
305
  define('LOREMIPSUM','Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras tincidunt justo a urna. Ut turpis. Phasellus convallis, odio sit amet cursus convallis, eros orci scelerisque velit, ut sodales neque nisl at ante. Suspendisse metus. Curabitur auctor pede quis mi. Pellentesque lorem justo, condimentum ac, dapibus sit amet, ornare et, erat. Quisque velit. Etiam sodales dui feugiat neque suscipit bibendum. Integer mattis. Nullam et ante non sem commodo malesuada. Pellentesque ultrices fermentum lectus. Maecenas hendrerit neque ac est. Fusce tortor mi, tristique sed, cursus at, pellentesque non, dui. Suspendisse potenti.');
306
 
307
  function yarpp_excerpt($content,$length) {
1
  <?php
2
 
3
+ require_once('magic.php');
4
+ require_once('keywords.php');
5
+
6
  // here's a list of all the options YARPP uses (except version), as well as their default values, sans the yarpp_ prefix, split up into binary options and value options. These arrays are used in updating settings (options.php) and other tasks.
7
  $yarpp_value_options = array('threshold' => 5,
8
  'limit' => 5,
71
  if (!yarpp_enabled()) {
72
  // $wpdb->query("ALTER TABLE `wp_posts` DROP INDEX `yarpp_cache`");
73
  if (!$wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_title` ( `post_title`)")) {
74
+ echo "<!--".__('MySQL error on adding yarpp_title','yarpp').": ";
75
  $wpdb->print_error();
76
  echo "-->";
77
  }
78
  if (!$wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_content` ( `post_content`)")) {
79
+ echo "<!--".__('MySQL error on adding yarpp_content','yarpp').": ";
80
  $wpdb->print_error();
81
  echo "-->";
82
  }
84
  return 0;
85
  }
86
  }
87
+ add_option('yarpp_version','2.11');
88
+ update_option('yarpp_version','2.11');
89
  return 1;
90
  }
91
 
93
  global $wpdb;
94
  $tables = $wpdb->get_results("show table status like '$wpdb->posts'");
95
  foreach ($tables as $table) {
96
+ if ($table->Engine == 'MyISAM') return true;
97
+ else return $table->Engine;
98
  }
99
+ return 'UNKNOWN';
100
  }
101
 
102
  function yarpp_upgrade_check($inuse = false) {
130
  }
131
 
132
  if (!$inuse)
133
+ echo '<div id="message" class="updated fade" style="background-color: rgb(207, 235, 247);">'.__('<h3>An important message from YARPP:</h3><p>Thank you for upgrading to YARPP 2. YARPP 2.0 adds the much requested ability to limit related entry results by certain tags or categories. 2.0 also brings more fine tuned control of the magic algorithm, letting you specify how the algorithm should consider or not consider entry content, titles, tags, and categories. Make sure to adjust the new settings to your liking and perhaps readjust your threshold.</p><p>For more information, check out the <a href="http://mitcho.com/code/yarpp/">YARPP documentation</a>. (This message will not be displayed again.)</p>','yarpp').'</div>';
 
134
  }
135
 
136
  if (get_option('yarpp_version') < 2.03) {
138
  $wpdb->query("ALTER TABLE $wpdb->posts ADD FULLTEXT `yarpp_content` ( `post_content`)"); update_option('yarpp_version','2.03');
139
  }
140
 
141
+ if (get_option('yarpp_version') < 2.11) {
142
+ update_option('yarpp_version','2.11');
143
  }
144
 
145
  // just in case, try to add the index one more time.
151
  }
152
 
153
  function yarpp_admin_menu() {
154
+ add_options_page(__('Related Posts (YARPP)','yarpp'),__('Related Posts (YARPP)','yarpp'), 8, 'yet-another-related-posts-plugin/options.php', 'yarpp_options_page');
155
  //if (function_exists('add_submenu_page')) add_submenu_page('options-general.php', 'Related Posts (YARPP)', 'Related Posts (YARPP)', 8, 'yet-another-related-posts-plugin/options.php');
156
  }
157
 
159
  require(str_replace('includes.php','options.php',__FILE__));
160
  }
161
 
162
+ // This function was written by @tyok
163
  function widget_yarpp_init() {
164
 
165
  if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
170
  global $wpdb, $post;
171
  if (is_single()) {
172
  echo $before_widget;
173
+ echo $before_title . __('Related Posts','yarpp') . $after_title;
174
  echo yarpp_related(array('post'),array());
175
  echo $after_widget;
176
  }
177
  }
178
+ register_sidebar_widget(__('YARPP','yarpp'), 'widget_yarpp');
179
  }
180
 
181
  function yarpp_default($content) {
300
  unset($yarpp_version);
301
  }
302
 
 
 
 
 
 
303
  define('LOREMIPSUM','Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras tincidunt justo a urna. Ut turpis. Phasellus convallis, odio sit amet cursus convallis, eros orci scelerisque velit, ut sodales neque nisl at ante. Suspendisse metus. Curabitur auctor pede quis mi. Pellentesque lorem justo, condimentum ac, dapibus sit amet, ornare et, erat. Quisque velit. Etiam sodales dui feugiat neque suscipit bibendum. Integer mattis. Nullam et ante non sem commodo malesuada. Pellentesque ultrices fermentum lectus. Maecenas hendrerit neque ac est. Fusce tortor mi, tristique sed, cursus at, pellentesque non, dui. Suspendisse potenti.');
304
 
305
  function yarpp_excerpt($content,$length) {
keywords.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $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');
4
+
5
+ function yarpp_extract_keywords($source,$num_to_ret = 20) {
6
+ global $post, $overusedwords;
7
+
8
+ if (function_exists('mb_split'))
9
+ $wordlist = mb_split('\s*[^\w]+\s*', strtolower($source));
10
+ else
11
+ $wordlist = split('\s*[^\w]+\s*', strtolower($source));
12
+
13
+ // Build an array of the unique words and number of times they occur.
14
+ $a = array_count_values($wordlist);
15
+
16
+ // Remove the stop words from the list.
17
+ foreach ($overusedwords as $word) {
18
+ unset($a[$word]);
19
+ }
20
+ arsort($a, SORT_NUMERIC);
21
+
22
+ $num_words = count($a);
23
+ $num_to_ret = $num_words > $num_to_ret ? $num_to_ret : $num_words;
24
+
25
+ $outwords = array_slice($a, 0, $num_to_ret);
26
+ return implode(' ', array_keys($outwords));
27
+ }
28
+
29
+ function post_title_keywords($num_to_ret = 20) {
30
+ global $post;
31
+ return yarpp_extract_keywords($post->post_title);
32
+ }
33
+
34
+ function post_body_keywords($num_to_ret = 20) {
35
+ global $post;
36
+ return yarpp_extract_keywords($post->post_content);
37
+ }
38
+
39
+ ?>
magic.php CHANGED
@@ -1,64 +1,40 @@
1
  <?php
2
 
3
- $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');
4
-
5
- function post_title_keywords($num_to_ret = 20) {
6
- global $post, $overusedwords;
7
- $wordlist = preg_split('/\s*[\s+\.|\?|,|(|)|\-+|\'|\"|=|;|&#0215;|\$|\/|:|{|}]\s*/i', strtolower($post->post_title));
8
-
9
- // Build an array of the unique words and number of times they occur.
10
- $a = array_count_values($wordlist);
11
-
12
- // Remove the stop words from the list.
13
- foreach ($overusedwords as $word) {
14
- unset($a[$word]);
15
- }
16
- arsort($a, SORT_NUMERIC);
17
-
18
- $num_words = count($a);
19
- $num_to_ret = $num_words > $num_to_ret ? $num_to_ret : $num_words;
20
-
21
- $outwords = array_slice($a, 0, $num_to_ret);
22
- return implode(' ', array_keys($outwords));
23
- }
24
-
25
- // post_body_keywords()
26
- // Based on create_post_keywords by Peter Bowyer with major changes by mitcho
27
- /**
28
- * Builds a word frequency list from the Wordpress post, and returns a string
29
- * to be used in matching against the MySQL full-text index.
30
- *
31
- * @param integer $num_to_ret The number of words to use when matching against
32
- * the database.
33
- * @return string The words
34
- */
35
- function post_body_keywords($num_to_ret = 20) {
36
- global $post, $overusedwords;
37
-
38
- $string = strip_tags(apply_filters_if_white('the_content',$post->post_content));
39
-
40
- // Remove punctuation and split
41
- $wordlist = preg_split('/\s*[\s+\.|\?|,|(|)|\-+|\'|\"|=|;|&#0215;|\$|\/|:|{|}]\s*/i', strtolower($string));
42
 
43
- // Build an array of the unique words and number of times they occur.
44
- $a = array_count_values($wordlist);
45
 
46
- // Remove the stop words from the list.
47
- foreach ($overusedwords as $word) {
48
- unset($a[$word]);
49
  }
50
- arsort($a, SORT_NUMERIC);
51
-
52
- $num_words = count($a);
53
- $num_to_ret = $num_words > $num_to_ret ? $num_to_ret : $num_words;
54
-
55
- $outwords = array_slice($a, 0, $num_to_ret);
56
- return implode(' ', array_keys($outwords));
57
-
58
  }
59
 
60
  function yarpp_sql($type,$args,$giveresults = true,$domain='website') {
61
- global $wpdb, $post;
 
 
 
 
62
 
63
  // set the "domain prefix", used for all the preferences.
64
  if ($domain == 'rss')
@@ -94,10 +70,15 @@ function yarpp_sql($type,$args,$giveresults = true,$domain='website') {
94
  // if cross_relate is set, override the type argument and make sure both matches are accepted in the sql query
95
  if ($cross_relate) $type = array('post','page');
96
 
 
 
97
  // Fetch keywords
98
  $body_terms = post_body_keywords();
99
  $title_terms = post_title_keywords();
100
 
 
 
 
101
  // Make sure the post is not from the future
102
  $time_difference = get_settings('gmt_offset');
103
  $now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));
@@ -126,9 +107,9 @@ function yarpp_sql($type,$args,$giveresults = true,$domain='website') {
126
 
127
  $criteria = array();
128
  if ($bodyweight)
129
- $criteria['body'] = "(MATCH (post_content) AGAINST ('".post_body_keywords()."'))";
130
  if ($titleweight)
131
- $criteria['title'] = "(MATCH (post_title) AGAINST ('".post_title_keywords()."'))";
132
  if ($tagweight)
133
  $criteria['tag'] = "COUNT( DISTINCT tagtax.term_taxonomy_id )";
134
  if ($catweight)
@@ -198,7 +179,7 @@ function yarpp_sql($type,$args,$giveresults = true,$domain='website') {
198
  $newsql = "select count(t.ID) from ($newsql) as t";
199
  }
200
 
201
- //echo "<!--$newsql-->";
202
  return $newsql;
203
  }
204
 
@@ -248,7 +229,7 @@ function yarpp_related($type,$args,$echo = true,$domain = 'website') {
248
  $post_content = stripslashes($post_content);
249
  $output .= "$before_title<a href='$permalink' rel='bookmark' title='Permanent Link: $title'>$title";
250
  if ($show_score and $userdata->user_level >= 8 and $domain != 'rss')
251
- $output .= ' <abbr title="'.round($result->score,3).' is the YARPP match score between the current entry and this related entry. You are seeing this value because you are logged in to WordPress as an administrator. It is not shown to regular visitors.">('.round($result->score,3).')</abbr>';
252
  $output .= '</a>';
253
  if ($show_excerpt) {
254
  $output .= $before_post . yarpp_excerpt($post_content,$excerpt_length) . $after_post;
@@ -257,7 +238,7 @@ function yarpp_related($type,$args,$echo = true,$domain = 'website') {
257
  }
258
  $output = stripslashes(stripslashes($before_related)).$output.stripslashes(stripslashes($after_related));
259
  if ($promote_yarpp)
260
- $output .= "\n<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>";
261
 
262
  } else {
263
  $output = $no_results;
1
  <?php
2
 
3
+ /* yarpp_cache_keywords is EXPERIMENTAL and not used.
4
+ * Don't worry about it. ^^
5
+ */
6
+ function yarpp_cache_keywords() {
7
+ global $wpdb, $post, $yarpp_debug;
8
+ $body_terms = post_body_keywords();
9
+ $title_terms = post_title_keywords();
10
+ /*
11
+ CREATE TABLE `mitcho_wrdp1`.`wp_yarpp_keyword_cache` (
12
+ `ID` BIGINT( 20 ) UNSIGNED NOT NULL ,
13
+ `body` TEXT NOT NULL ,
14
+ `title` TEXT NOT NULL ,
15
+ `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
16
+ PRIMARY KEY ( `ID` )
17
+ ) ENGINE = MYISAM COMMENT = 'YARPP''s keyword cache table'
18
+ */
19
+ $timeout = 400;
20
+
21
+ if ($yarpp_debug) echo '<!--'.$wpdb->get_var("select count(*) as count from wp_yarpp_keyword_cache where ID = $post->ID and date > date_sub(now(),interval $timeout minute)").'-->';
22
+
23
+ if ($wpdb->get_var("select count(*) as count from wp_yarpp_keyword_cache where ID = $post->ID and date > date_sub(now(),interval $timeout minute)") == 0) {
24
+ $wpdb->query('set names utf8');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ $wpdb->query("insert into wp_yarpp_keyword_cache (ID,body,title) values ($post->ID,'$body_terms','$title_terms') on duplicate key update body = '$body_terms', title = '$title_terms'");
 
27
 
28
+ if ($yarpp_debug) echo "<!--"."insert into wp_yarpp_keyword_cache (ID,body,title) values ($post->ID,'$body_terms','$title_terms') on duplicate key update body = '$body_terms', title = '$title_terms'"."-->";
 
 
29
  }
 
 
 
 
 
 
 
 
30
  }
31
 
32
  function yarpp_sql($type,$args,$giveresults = true,$domain='website') {
33
+ global $wpdb, $post, $yarpp_debug;
34
+
35
+ // set $yarpp_debug
36
+ if (isset($_REQUEST['yarpp_debug']))
37
+ $yarpp_debug = true;
38
 
39
  // set the "domain prefix", used for all the preferences.
40
  if ($domain == 'rss')
70
  // if cross_relate is set, override the type argument and make sure both matches are accepted in the sql query
71
  if ($cross_relate) $type = array('post','page');
72
 
73
+ yarpp_cache_keywords();
74
+
75
  // Fetch keywords
76
  $body_terms = post_body_keywords();
77
  $title_terms = post_title_keywords();
78
 
79
+ if ($yarpp_debug) echo "<!--TITLE TERMS: $title_terms-->"; // debug
80
+ if ($yarpp_debug) echo "<!--BODY TERMS: $body_terms-->"; // debug
81
+
82
  // Make sure the post is not from the future
83
  $time_difference = get_settings('gmt_offset');
84
  $now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));
107
 
108
  $criteria = array();
109
  if ($bodyweight)
110
+ $criteria['body'] = "(MATCH (post_content) AGAINST ('$body_terms'))";
111
  if ($titleweight)
112
+ $criteria['title'] = "(MATCH (post_title) AGAINST ('$title_terms'))";
113
  if ($tagweight)
114
  $criteria['tag'] = "COUNT( DISTINCT tagtax.term_taxonomy_id )";
115
  if ($catweight)
179
  $newsql = "select count(t.ID) from ($newsql) as t";
180
  }
181
 
182
+ if ($yarpp_debug) echo "<!--$newsql-->";
183
  return $newsql;
184
  }
185
 
229
  $post_content = stripslashes($post_content);
230
  $output .= "$before_title<a href='$permalink' rel='bookmark' title='Permanent Link: $title'>$title";
231
  if ($show_score and $userdata->user_level >= 8 and $domain != 'rss')
232
+ $output .= ' <abbr title="'.sprintf(__('%f is the YARPP match score between the current entry and this related entry. You are seeing this value because you are logged in to WordPress as an administrator. It is not shown to regular visitors.','yarpp'),round($result->score,3)).'">('.round($result->score,3).')</abbr>';
233
  $output .= '</a>';
234
  if ($show_excerpt) {
235
  $output .= $before_post . yarpp_excerpt($post_content,$excerpt_length) . $after_post;
238
  }
239
  $output = stripslashes(stripslashes($before_related)).$output.stripslashes(stripslashes($after_related));
240
  if ($promote_yarpp)
241
+ $output .= "\n<p>".__("Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.",'yarpp')."</p>";
242
 
243
  } else {
244
  $output = $no_results;
options.php CHANGED
@@ -1,17 +1,34 @@
1
  <?php
2
- // Begin Related Posts Options
3
 
4
  global $wpdb, $yarpp_value_options, $yarpp_binary_options, $wp_version;
5
 
 
 
 
 
 
 
 
6
  $yarpp_myisam = true;
7
- if (!yarpp_myisam_check()) {
8
- echo "<div class='updated'>Your database's <code>$wpdb->posts</code> table is not set up to use the <a href='http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html'>MyISAM storage engine</a> which is required for YARPP to use the \"consider titles\" and \"consider bodies\" criteria. These two options have been disabled.<br />
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- To restore these features, please update your <code>$wpdb->posts</code> by executing the following SQL directive: <code>ALTER TABLE `$wpdb->posts` ENGINE = MyISAM;</code> . No data will be erased by altering the table's engine, although there are performance implications.</div>";
11
-
12
- yarpp_set_option('title',1);
13
- yarpp_set_option('body',1);
14
- $yarpp_myisam = false;
15
  }
16
 
17
  $yarpp_twopointfive = true;
@@ -27,9 +44,9 @@ if ($yarpp_myisam) {
27
  if (!yarpp_enabled()) {
28
  echo '<div class="updated">';
29
  if (yarpp_activate())
30
- echo 'The YARPP database had an error but has been fixed.';
31
  else
32
- echo 'The YARPP database has an error which could not be fixed.';
33
  echo '</div>';
34
  }
35
  }
@@ -94,12 +111,19 @@ function importance($option,$desc,$type='word',$tr="<tr valign='top'>
94
  <th scope='row'>",$inputplus = '') {
95
  $value = yarpp_get_option($option);
96
 
 
 
 
 
 
97
  echo " $tr$desc</th>
98
  <td>
99
- <input $inputplus type='radio' name='$option' value='1'". (($value == 1) ? ' checked="checked"': '' )." /> do not consider
100
- <input $inputplus type='radio' name='$option' value='2'". (($value == 2) ? ' checked="checked"': '' )." /> consider
101
- <input $inputplus type='radio' name='$option' value='3'". (($value == 3) ? ' checked="checked"': '' )." /> require at least one $type in common
102
- <input $inputplus type='radio' name='$option' value='4'". (($value == 4) ? ' checked="checked"': '' )." /> require more than one $type in common
 
 
103
  </td>
104
  </tr>";
105
  }
@@ -110,9 +134,10 @@ function importance2($option,$desc,$type='word',$tr="<tr valign='top'>
110
 
111
  echo " $tr$desc</th>
112
  <td>
113
- <input $inputplus type='radio' name='$option' value='1'". (($value == 1) ? ' checked="checked"': '' )." /> do not consider
114
- <input $inputplus type='radio' name='$option' value='2'". (($value == 2) ? ' checked="checked"': '' )." /> consider
115
- <input $inputplus type='radio' name='$option' value='3'". (($value == 3) ? ' checked="checked"': '' )." /> consider with extra weight
 
116
  </td>
117
  </tr>";
118
  }
@@ -121,10 +146,14 @@ function select($option,$desc,$type='word',$tr="<tr valign='top'>
121
  <th scope='row'>",$inputplus = '') {
122
  echo " $tr$desc</th>
123
  <td>
124
- <input $inputplus type='radio' name='$option' value='1'". ((yarpp_get_option($option) == 1) ? ' checked="checked"': '' )." /> do not consider
125
- <input $inputplus type='radio' name='$option' value='2'". ((yarpp_get_option($option) == 2) ? ' checked="checked"': '' )." /> consider
126
- <input $inputplus type='radio' name='$option' value='3'". ((yarpp_get_option($option) == 3) ? ' checked="checked"': '' )." /> require at least one $type in common
127
- <input $inputplus type='radio' name='$option' value='4'". ((yarpp_get_option($option) == 4) ? ' checked="checked"': '' )." /> require more than one $type in common
 
 
 
 
128
  </td>
129
  </tr>";
130
  }
@@ -136,7 +165,7 @@ function select($option,$desc,$type='word',$tr="<tr valign='top'>
136
  var rss=document.createElement("link");
137
  rss.setAttribute("rel", "alternate");
138
  rss.setAttribute("type", "application/rss+xml");
139
- rss.setAttribute('title',"Yet Another Related Posts Plugin version history (RSS 2.0)");
140
  rss.setAttribute("href", "http://mitcho.com/code/yarpp/yarpp.rss");
141
  document.getElementsByTagName("head")[0].appendChild(rss);
142
 
@@ -164,25 +193,35 @@ document.getElementsByTagName("body")[0].setAttribute('onload',"excerpt();rss_ex
164
  <input type="hidden" name="bn" value="PP-DonationsBF" />
165
 
166
  <h2>
167
- <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" title="Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal" style="float:right" />
168
- Yet Another Related Posts Plugin Options <small><?php echo yarpp_get_option('version'); ?></small>
 
 
 
 
 
 
 
 
 
 
169
  </h2>
170
  </form>
171
 
172
  <form method="post">
173
 
174
 
175
- <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 &amp; Mike Lu</a>.</small></p>
176
 
177
 
178
  <!--The Pool-->
179
- <h3>"The Pool"</h3>
180
- <p>"The Pool" refers to the pool of posts and pages that are candidates for display as related to the current entry.</p>
181
 
182
  <table class="form-table" style="margin-top: 0">
183
  <tbody>
184
  <tr valign='top'>
185
- <th scope='row'>Disallow by category:</th><td><div style="overflow:auto;max-height:100px;">
186
  <?php
187
  $discats = explode(',',yarpp_get_option('discats'));
188
  array_unshift($discats,' ');
@@ -191,8 +230,8 @@ document.getElementsByTagName("body")[0].setAttribute('onload',"excerpt();rss_ex
191
  }?>
192
  </div></td></tr>
193
  <tr valign='top'>
194
- <th scope='row'>Disallow by tag: </th>
195
- <td><div style="overflow:auto;max-height:100px;"><!--Enter tags to use to block entries. Delimit with commas. Tags that do not currently exist will be ignored.<br /><input name='distags' type='text' id='$option' value='<?php implode(",",array_map("yarpp_mapthetag",explode(",",htmlspecialchars(stripslashes(yarpp_get_option($option))))));?>' size='40' />-->
196
  <?php
197
  $distags = explode(',',yarpp_get_option('distags'));
198
  array_unshift($distags,' ');
@@ -200,34 +239,28 @@ document.getElementsByTagName("body")[0].setAttribute('onload',"excerpt();rss_ex
200
  echo "<input type='checkbox' name='distags[$tag->term_id]' value='true'". (array_search($tag->term_id,$distags) ? ' checked="checked"': '' )." /> <label>$tag->name</label> ";// for='distags[$tag->term_id]'
201
  }?>
202
  </div></td></tr>
203
- <?php checkbox('show_past_post',"Show password protected posts?"); ?>
204
- <?php checkbox('past_only',"Show only previous posts?"); ?>
205
  </tbody>
206
  </table>
207
 
208
  <!-- Relatedness -->
209
- <h3>"Relatedness" options</h3>
210
- <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="#" class='info'>more&gt;<span>The higher the match threshold, the more restrictive, and you get less related posts overall. The default match threshold is 5. If you want to find an appropriate match threshhold, 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 appropriate threshold for your site.</span></a></p>
211
 
212
  <table class="form-table" style="margin-top: 0">
213
  <tbody>
214
 
215
- <!-- <div id="mySlider"><span>do not consider</span>
216
- <span>consider</span>
217
- <span>require</span>
218
- <span>require multiple</span>
219
- </div>-->
220
-
221
- <?php textbox('threshold','Match threshold:')?>
222
- <?php importance2('title',"Titles: ",'word',"<tr valign='top'>
223
  <th scope='row'>",(!$yarpp_myisam?' readonly="readonly" disabled="disabled"':''))?>
224
- <?php importance2('body',"Bodies: ",'word',"<tr valign='top'>
225
  <th scope='row'>",(!$yarpp_myisam?' readonly="readonly" disabled="disabled"':''))?>
226
- <?php importance('tags',"Tags: ",'tag',"<tr valign='top'>
227
  <th scope='row'>",(!$yarpp_twopointfive?' readonly="readonly" disabled="disabled"':''))?>
228
- <?php importance('categories',"Categories: ",'category',"<tr valign='top'>
229
  <th scope='row'>",(!$yarpp_twopointfive?' readonly="readonly" disabled="disabled"':''))?>
230
- <?php checkbox('cross_relate',"Cross-relate posts and pages? <a href='#' class='info'>more&gt;<span>When the \"Cross-relate posts and pages\" option is selected, the <code>related_posts()</code>, <code>related_pagaes()</code>, and <code>related_entries()</code> all will give the same output, returning both related pages and posts.</span></a>"); ?>
231
  </tbody>
232
  </table>
233
 
@@ -269,7 +302,7 @@ document.getElementsByTagName("body")[0].setAttribute('onload',"excerpt();rss_ex
269
 
270
 
271
  <!-- Display options -->
272
- <h3>Display options <small>for your website</small></h3>
273
 
274
  <table class="form-table" style="margin-top: 0">
275
  <?php
@@ -278,57 +311,60 @@ document.getElementsByTagName("body")[0].setAttribute('onload',"excerpt();rss_ex
278
  $democode = stripslashes(yarpp_get_option('before_related',true))."
279
  ";
280
  for ($i=1;$i<=yarpp_get_option('limit');$i++) {
281
- $democode .= stripslashes(yarpp_get_option('before_title',true)).stripslashes(htmlspecialchars("<a href='PERMALINK$i'>RELATED TITLE $i</a>")).(yarpp_get_option('show_excerpt')?"\r\t".stripslashes(yarpp_get_option('before_post',true)).yarpp_excerpt(LOREMIPSUM,yarpp_get_option('excerpt_length')).stripslashes(yarpp_get_option('before_post',true)):'').stripslashes(yarpp_get_option('after_title',true))."
282
  ";
283
  }
284
  $democode .= stripslashes(yarpp_get_option('after_related',true));
285
  if (yarpp_get_option('promote_yarpp'))
286
- $democode .= htmlspecialchars("\n<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>");
287
 
288
- checkbox('auto_display',"Automatically display related posts? <a href='#' class='info'>more&gt;<span>This option automatically displays related posts right after the content on single entry pages. If this option is off, you will need to manually insert <code>related_posts()</code> or variants (<code>related_pagaes()</code> and <code>related_entries()</code>) into your theme files.</span></a>","<tr valign='top'>
289
- <th class='th-full' colspan='2' scope='row'>",'','<td rowspan="11" style="border-left:8px white solid;"><b>Website display code example</b><br /><small>(Update options to reload.)</small><br/>'
290
  ."<code><pre style='overflow:auto;width:350px;'>".($democode)."</pre></code></td>"); ?>
291
- <?php textbox('limit','Maximum number of related posts:')?>
292
  <tr valign='top'>
293
- <th>Before / after related entries:</th>
294
- <td><input name="before_related" type="text" id="before_related" value="<?php echo stripslashes(yarpp_get_option('before_related',true)); ?>" size="10" /> / <input name="after_related" type="text" id="after_related" value="<?php echo stripslashes(yarpp_get_option('after_related',true)); ?>" size="10" /><em><small> For example: &lt;ol&gt;&lt;/ol&gt; or &lt;div&gt;&lt;/div&gt;</small></em>
295
  </td>
296
  </tr>
297
  <tr valign='top'>
298
- <th>Before / after each related entry:</th>
299
- <td><input name="before_title" type="text" id="before_title" value="<?php echo stripslashes(yarpp_get_option('before_title',true)); ?>" size="10" /> / <input name="after_title" type="text" id="after_title" value="<?php echo stripslashes(yarpp_get_option('after_title',true)); ?>" size="10" /><em><small> For example: &lt;li&gt;&lt;/li&gt; or &lt;dl&gt;&lt;/dl&gt;</small></em>
300
  </td>
301
  </tr>
302
- <?php checkbox('show_excerpt',"Show excerpt?","<tr valign='top'><th colspan='2'>",' onclick="javascript:excerpt()"'); ?>
303
- <?php textbox('excerpt_length','Excerpt length (No. of words):',null,"<tr name='excerpted' valign='top' ".(yarpp_get_option('show_excerpt')?'':"style='display:none'").">
304
  <th>")?>
305
 
306
  <tr name="excerpted" valign='top' <?php echo (yarpp_get_option('show_excerpt')?'':"style='display:none'")?>>
307
- <th>Before / after (Excerpt):</th>
308
- <td><input name="before_post" type="text" id="before_post" value="<?php echo stripslashes(yarpp_get_option('before_post',true)); ?>" size="10" /> / <input name="after_post" type="text" id="after_post" value="<?php echo stripslashes(yarpp_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>
309
  </td>
310
  </tr>
311
 
312
  <tr name="excerpted" valign='top'>
313
- <th>Order results:</th>
314
  <td><select name="order" id="order">
315
- <option value="score DESC" <?php echo (yarpp_get_option('order')=='score DESC'?' selected="selected"':'')?>>score (high relevance to low)</option>
316
- <option value="score ASC" <?php echo (yarpp_get_option('order')=='score ASC'?' selected="selected"':'')?>>score (low relevance to high)</option>
317
- <option value="post_date DESC" <?php echo (yarpp_get_option('order')=='post_date DESC'?' selected="selected"':'')?>>date (new to old)</option>
318
- <option value="post_date ASC" <?php echo (yarpp_get_option('order')=='post_date ASC'?' selected="selected"':'')?>>date (old to new)</option>
319
- <option value="post_title ASC" <?php echo (yarpp_get_option('order')=='post_title ASC'?' selected="selected"':'')?>>title (alphabetical)</option>
320
- <option value="post_title DESC" <?php echo (yarpp_get_option('order')=='post_title DESC'?' selected="selected"':'')?>>title (reverse alphabetical)</option>
321
  </select>
322
  </td>
323
  </tr>
324
 
325
- <?php textbox('no_results','Default display if no results:','40')?>
326
- <?php checkbox('show_score',"Show admins (user level > 8) the match scores? <a href='#' class='info'>more&gt;<span>With this option on, each related entry's total 'match score' (all above the threshold, set above) are displayed after each entry title, <em>if you are an administrator and logged in.</em> Even if you see these values, your visitors will not.</span></a>"); ?>
327
- <?php checkbox('promote_yarpp',"Help promote Yet Another Related Posts Plugin? <a href='#' class='info'>more&gt;<span>This option will add the code <code>&lt;p&gt;Related posts brought to you by &lt;a href='http://mitcho.com/code/yarpp/'&gt;Yet Another Related Posts Plugin&lt;/a&gt;.&lt;/p&gt;</code>. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated.</span></a>"); ?>
 
 
 
328
  </table>
329
 
330
  <!-- Display options for RSS -->
331
- <h3>Display options <small>for RSS</small> <span style='color:red;'>NEW!</span></h3>
332
 
333
  <table class="form-table" style="margin-top: 0">
334
  <?php
@@ -337,55 +373,57 @@ checkbox('auto_display',"Automatically display related posts? <a href='#' class=
337
  $democode = stripslashes(yarpp_get_option('rss_before_related',true))."
338
  ";
339
  for ($i=1;$i<=yarpp_get_option('rss_limit');$i++) {
340
- $democode .= stripslashes(yarpp_get_option('rss_before_title',true)).stripslashes(htmlspecialchars("<a href='PERMALINK$i'>RELATED TITLE $i</a>")).(yarpp_get_option('rss_show_excerpt')?"\r\t".stripslashes(yarpp_get_option('rss_before_post',true)).yarpp_excerpt(LOREMIPSUM,yarpp_get_option('rss_excerpt_length')).stripslashes(yarpp_get_option('rss_before_post',true)):'').stripslashes(yarpp_get_option('rss_after_title',true))."
341
  ";
342
  }
343
  $democode .= stripslashes(yarpp_get_option('rss_after_related',true));
344
  if (yarpp_get_option('rss_promote_yarpp'))
345
- $democode .= htmlspecialchars("\n<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>");
346
 
347
- checkbox('rss_display',"Display related posts in feeds? <a href='#' class='info'>more&gt;<span>This option displays related posts at the end of each item in your RSS and Atom feeds. No template changes are needed.</span></a>","<tr valign='top'><th colspan='3'>",' onclick="javascript:do_rss_display();"');
348
- checkbox('rss_excerpt_display',"Display related posts in the descriptions? <a href='#' class='info'>more&gt;<span>This option displays the related posts in the RSS description fields, not just the content. If your feeds are set up to only display excerpts, however, only the description field is used, so this option is required for any display at all.</span></a>","<tr name='rss_displayed' valign='top'>
349
- <th class='th-full' colspan='2' scope='row'>",'','<td rowspan="10" style="border-left:8px white solid;"><b>RSS display code example</b><br /><small>(Update options to reload.)</small><br/>'
350
  ."<code><pre style='overflow:auto;width:350px;'>".($democode)."</pre></code></td>"); ?>
351
  <?php textbox('rss_limit','Maximum number of related posts:',2,"<tr valign='top' name='rss_displayed'>
352
  <th scope='row'>")?>
353
  <tr name='rss_displayed' valign='top'>
354
- <th>Before / after related entries display:</th>
355
- <td><input name="rss_before_related" type="text" id="rss_before_related" value="<?php echo stripslashes(yarpp_get_option('rss_before_related',true)); ?>" size="10" /> / <input name="rss_after_related" type="text" id="rss_after_related" value="<?php echo stripslashes(yarpp_get_option('rss_after_related',true)); ?>" size="10" /><em><small> For example: &lt;ol&gt;&lt;/ol&gt; or &lt;div&gt;&lt;/div&gt;</small></em>
356
  </td>
357
  </tr>
358
  <tr name='rss_displayed' valign='top'>
359
- <th>Before / after each related entry:</th>
360
- <td><input name="rss_before_title" type="text" id="rss_before_title" value="<?php echo stripslashes(yarpp_get_option('rss_before_title',true)); ?>" size="10" /> / <input name="rss_after_title" type="text" id="rss_after_title" value="<?php echo stripslashes(yarpp_get_option('rss_after_title',true)); ?>" size="10" /><em><small> For example: &lt;li&gt;&lt;/li&gt; or &lt;dl&gt;&lt;/dl&gt;</small></em>
361
  </td>
362
  </tr>
363
- <?php checkbox('rss_show_excerpt',"Show excerpt?","<tr name='rss_displayed' valign='top'><th colspan='2'>",' onclick="javascript:rss_excerpt()"'); ?>
364
- <?php textbox('rss_excerpt_length','Excerpt length (No. of words):',null,"<tr name='rss_excerpted' valign='top' ".(yarpp_get_option('rss_show_excerpt')?'':"style='display:none'").">
365
  <th>")?>
366
 
367
  <tr name="rss_excerpted" valign='top' <?php echo (yarpp_get_option('rss_show_excerpt')?'':"style='display:none'")?>>
368
- <th>Before / after (Excerpt):</th>
369
- <td><input name="rss_before_post" type="text" id="rss_before_post" value="<?php echo stripslashes(yarpp_get_option('rss_before_post',true)); ?>" size="10" /> / <input name="rss_after_post" type="text" id="rss_after_post" value="<?php echo stripslashes(yarpp_get_option('rss_after_post')); ?>" size="10" /><em><small> For example: &lt;li&gt;&lt;/li&gt; or &lt;dl&gt;&lt;/dl&gt;</small></em>
370
  </td>
371
  </tr>
372
 
373
  <tr name='rss_displayed' valign='top'>
374
- <th>Order results:</th>
375
  <td><select name="rss_order" id="rss_order">
376
- <option value="score DESC" <?php echo (yarpp_get_option('rss_order')=='score DESC'?' selected="selected"':'')?>>score (high relevance to low)</option>
377
- <option value="score ASC" <?php echo (yarpp_get_option('rss_order')=='score ASC'?' selected="selected"':'')?>>score (low relevance to high)</option>
378
- <option value="post_date DESC" <?php echo (yarpp_get_option('rss_order')=='post_date DESC'?' selected="selected"':'')?>>date (new to old)</option>
379
- <option value="post_date ASC" <?php echo (yarpp_get_option('rss_order')=='post_date ASC'?' selected="selected"':'')?>>date (old to new)</option>
380
- <option value="post_title ASC" <?php echo (yarpp_get_option('rss_order')=='post_title ASC'?' selected="selected"':'')?>>title (alphabetical)</option>
381
- <option value="post_title DESC" <?php echo (yarpp_get_option('rss_order')=='post_title DESC'?' selected="selected"':'')?>>title (reverse alphabetical)</option>
382
  </select>
383
  </td>
384
  </tr>
385
 
386
- <?php textbox('rss_no_results','Default display if no results:','40',"<tr valign='top' name='rss_displayed'>
387
  <th scope='row'>")?>
388
- <?php checkbox('rss_promote_yarpp',"Help promote Yet Another Related Posts Plugin? <a href='#' class='info'>more&gt;<span>This option will add the code <code>&lt;p&gt;Related posts brought to you by &lt;a href='http://mitcho.com/code/yarpp/'&gt;Yet Another Related Posts Plugin&lt;/a&gt;.&lt;/p&gt;</code>. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated.</span></a>","<tr valign='top' name='rss_displayed'>
 
 
389
  <th class='th-full' colspan='2' scope='row'>"); ?>
390
  </table>
391
 
@@ -399,6 +437,4 @@ checkbox('rss_excerpt_display',"Display related posts in the descriptions? <a hr
399
 
400
  <?php
401
 
402
- // End Related Posts Options
403
-
404
  ?>
1
  <?php
 
2
 
3
  global $wpdb, $yarpp_value_options, $yarpp_binary_options, $wp_version;
4
 
5
+ if ($_POST['myisam_override']) {
6
+ yarpp_set_option('myisam_override',1);
7
+ echo "<div class='updated'>"
8
+ .__("The MyISAM check has been overridden. You may now use the \"consider titles\" and \"consider bodies\" relatedness criteria.")
9
+ ."</div>";
10
+ }
11
+
12
  $yarpp_myisam = true;
13
+ if (!yarpp_get_option('myisam_override')) {
14
+ $yarpp_check_return = yarpp_myisam_check();
15
+ if ($yarpp_check_return !== true) { // if it's not *exactly* true
16
+ echo "<div class='updated'>"
17
+ .sprintf(__("YARPP's \"consider titles\" and \"consider bodies\" relatedness criteria require your <code>%s</code> table to use the <a href='http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html'>MyISAM storage engine</a>, but the table seems to be using the <code>%s</code> engine. These two options have been disabled.",'yarpp'),$wpdb->posts,$yarpp_check_return)
18
+ ."<br />"
19
+ .sprintf(__("To restore these features, please update your <code>%s</code> table by executing the following SQL directive: <code>ALTER TABLE `%s` ENGINE = MyISAM;</code> . No data will be erased by altering the table's engine, although there are performance implications.",'yarpp'),$wpdb->posts,$wpdb->posts)
20
+ ."<br />"
21
+ .sprintf(__("If, despite this check, you are sure that <code>%s</code> is using the MyISAM engine, press this magic button:",'yarpp'),$wpdb->posts)
22
+ ."<br />"
23
+ ."<form method='post'><input type='submit' name='myisam_override' value='"
24
+ .__("Trust me. Let me use MyISAM features.",'yarpp')
25
+ ."'></input></form>"
26
+ ."</div>";
27
 
28
+ yarpp_set_option('title',1);
29
+ yarpp_set_option('body',1);
30
+ $yarpp_myisam = false;
31
+ }
 
32
  }
33
 
34
  $yarpp_twopointfive = true;
44
  if (!yarpp_enabled()) {
45
  echo '<div class="updated">';
46
  if (yarpp_activate())
47
+ _e('The YARPP database had an error but has been fixed.','yarpp');
48
  else
49
+ _e('The YARPP database has an error which could not be fixed.','yarpp');
50
  echo '</div>';
51
  }
52
  }
111
  <th scope='row'>",$inputplus = '') {
112
  $value = yarpp_get_option($option);
113
 
114
+ // $type could be...
115
+ __('word','yarpp');
116
+ __('tag','yarpp');
117
+ __('category','yarpp');
118
+
119
  echo " $tr$desc</th>
120
  <td>
121
+ <input $inputplus type='radio' name='$option' value='1'". (($value == 1) ? ' checked="checked"': '' )." /> ".__("do not consider",'yarpp')."
122
+ <input $inputplus type='radio' name='$option' value='2'". (($value == 2) ? ' checked="checked"': '' )." /> ".__("consider",'yarpp')."
123
+ <input $inputplus type='radio' name='$option' value='3'". (($value == 3) ? ' checked="checked"': '' )." />
124
+ ".sprintf(__("require at least one %s in common",'yarpp'),__($type,'yarpp'))."
125
+ <input $inputplus type='radio' name='$option' value='4'". (($value == 4) ? ' checked="checked"': '' )." />
126
+ ".sprintf(__("require more than one %s in common",'yarpp'),__($type,'yarpp'))."
127
  </td>
128
  </tr>";
129
  }
134
 
135
  echo " $tr$desc</th>
136
  <td>
137
+ <input $inputplus type='radio' name='$option' value='1'". (($value == 1) ? ' checked="checked"': '' )." />
138
+ ".__("do not consider",'yarpp')."
139
+ <input $inputplus type='radio' name='$option' value='2'". (($value == 2) ? ' checked="checked"': '' )." /> ".__("consider",'yarpp')."
140
+ <input $inputplus type='radio' name='$option' value='3'". (($value == 3) ? ' checked="checked"': '' )." /> ".__("consider with extra weight",'yarpp')."
141
  </td>
142
  </tr>";
143
  }
146
  <th scope='row'>",$inputplus = '') {
147
  echo " $tr$desc</th>
148
  <td>
149
+ <input $inputplus type='radio' name='$option' value='1'". ((yarpp_get_option($option) == 1) ? ' checked="checked"': '' )." />
150
+ ".__("do not consider",'yarpp')."
151
+ <input $inputplus type='radio' name='$option' value='2'". ((yarpp_get_option($option) == 2) ? ' checked="checked"': '' )." />
152
+ ".__("consider",'yarpp')."
153
+ <input $inputplus type='radio' name='$option' value='3'". ((yarpp_get_option($option) == 3) ? ' checked="checked"': '' )." />
154
+ ".sprintf(__("require at least one %s in common",'yarpp'),__($type,'yarpp'))."
155
+ <input $inputplus type='radio' name='$option' value='4'". ((yarpp_get_option($option) == 4) ? ' checked="checked"': '' )." />
156
+ ".sprintf(__("require more than one %s in common",'yarpp'),__($type,'yarpp'))."
157
  </td>
158
  </tr>";
159
  }
165
  var rss=document.createElement("link");
166
  rss.setAttribute("rel", "alternate");
167
  rss.setAttribute("type", "application/rss+xml");
168
+ rss.setAttribute('title',"<?php _e("Yet Another Related Posts Plugin version history (RSS 2.0)",'yarpp');?>");
169
  rss.setAttribute("href", "http://mitcho.com/code/yarpp/yarpp.rss");
170
  document.getElementsByTagName("head")[0].appendChild(rss);
171
 
193
  <input type="hidden" name="bn" value="PP-DonationsBF" />
194
 
195
  <h2>
196
+ <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" title="<?php _e('Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal');?>" style="float:right" />
197
+ <?php _e('Yet Another Related Posts Plugin Options','yarpp');?> <small><?php
198
+
199
+ $display_version = yarpp_get_option('version');
200
+ $split = explode('.',$display_version);
201
+ if (strlen($split[1]) == 1)
202
+ echo $display_version;
203
+ else {
204
+ $pos = strpos($display_version,'.')+2;
205
+ echo substr($display_version,0,$pos).'.'.substr($display_version,$pos);
206
+ }
207
+ ?></small>
208
  </h2>
209
  </form>
210
 
211
  <form method="post">
212
 
213
 
214
+ <p><small><?php _e('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 &amp; Mike Lu</a>.','yarpp');?></small></p>
215
 
216
 
217
  <!--The Pool-->
218
+ <h3><?php _e('"The Pool"','yarpp');?></h3>
219
+ <p><?php _e('"The Pool" refers to the pool of posts and pages that are candidates for display as related to the current entry.','yarpp');?></p>
220
 
221
  <table class="form-table" style="margin-top: 0">
222
  <tbody>
223
  <tr valign='top'>
224
+ <th scope='row'><?php _e('Disallow by category:','yarpp');?></th><td><div style="overflow:auto;max-height:100px;">
225
  <?php
226
  $discats = explode(',',yarpp_get_option('discats'));
227
  array_unshift($discats,' ');
230
  }?>
231
  </div></td></tr>
232
  <tr valign='top'>
233
+ <th scope='row'><?php _e('Disallow by tag:','yarpp');?></th>
234
+ <td><div style="overflow:auto;max-height:100px;">
235
  <?php
236
  $distags = explode(',',yarpp_get_option('distags'));
237
  array_unshift($distags,' ');
239
  echo "<input type='checkbox' name='distags[$tag->term_id]' value='true'". (array_search($tag->term_id,$distags) ? ' checked="checked"': '' )." /> <label>$tag->name</label> ";// for='distags[$tag->term_id]'
240
  }?>
241
  </div></td></tr>
242
+ <?php checkbox('show_past_post',__("Show password protected posts?",'yarpp')); ?>
243
+ <?php checkbox('past_only',__("Show only previous posts?",'yarpp')); ?>
244
  </tbody>
245
  </table>
246
 
247
  <!-- Relatedness -->
248
+ <h3><?php _e('"Relatedness" options','yarpp');?></h3>
249
+ <p><?php _e('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>.','yarpp');?> <a href="#" class='info'>more&gt;<span><?php _e('The higher the match threshold, the more restrictive, and you get less related posts overall. The default match threshold is 5. If you want to find an appropriate match threshhold, 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 appropriate threshold for your site.','yarpp');?></span></a></p>
250
 
251
  <table class="form-table" style="margin-top: 0">
252
  <tbody>
253
 
254
+ <?php textbox('threshold',__('Match threshold:','yarpp'))?>
255
+ <?php importance2('title',__("Titles: ",'yarpp'),'word',"<tr valign='top'>
 
 
 
 
 
 
256
  <th scope='row'>",(!$yarpp_myisam?' readonly="readonly" disabled="disabled"':''))?>
257
+ <?php importance2('body',__("Bodies: ",'yarpp'),'word',"<tr valign='top'>
258
  <th scope='row'>",(!$yarpp_myisam?' readonly="readonly" disabled="disabled"':''))?>
259
+ <?php importance('tags',__("Tags: ",'yarpp'),'tag',"<tr valign='top'>
260
  <th scope='row'>",(!$yarpp_twopointfive?' readonly="readonly" disabled="disabled"':''))?>
261
+ <?php importance('categories',__("Categories: ",'yarpp'),'category',"<tr valign='top'>
262
  <th scope='row'>",(!$yarpp_twopointfive?' readonly="readonly" disabled="disabled"':''))?>
263
+ <?php checkbox('cross_relate',__("Cross-relate posts and pages?",'yarpp')." <a href='#' class='info'>more&gt;<span>".__("When the \"Cross-relate posts and pages\" option is selected, the <code>related_posts()</code>, <code>related_pages()</code>, and <code>related_entries()</code> all will give the same output, returning both related pages and posts.",'yarpp')."</span></a>"); ?>
264
  </tbody>
265
  </table>
266
 
302
 
303
 
304
  <!-- Display options -->
305
+ <h3><?php _e("Display options <small>for your website</small>",'yarpp');?></h3>
306
 
307
  <table class="form-table" style="margin-top: 0">
308
  <?php
311
  $democode = stripslashes(yarpp_get_option('before_related',true))."
312
  ";
313
  for ($i=1;$i<=yarpp_get_option('limit');$i++) {
314
+ $democode .= stripslashes(yarpp_get_option('before_title',true)).stripslashes(htmlspecialchars("<a href='".__("PERMALINK",'yarpp')."$i'>".__("RELATED TITLE",'yarpp')." $i</a>")).(yarpp_get_option('show_excerpt')?"\r\t".stripslashes(yarpp_get_option('before_post',true)).yarpp_excerpt(LOREMIPSUM,yarpp_get_option('excerpt_length')).stripslashes(yarpp_get_option('before_post',true)):'').stripslashes(yarpp_get_option('after_title',true))."
315
  ";
316
  }
317
  $democode .= stripslashes(yarpp_get_option('after_related',true));
318
  if (yarpp_get_option('promote_yarpp'))
319
+ $democode .= htmlspecialchars("\n<p>".__("Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.",'yarpp')."</p>");
320
 
321
+ checkbox('auto_display',__("Automatically display related posts?",'yarpp')." <a href='#' class='info'>more&gt;<span>".__("This option automatically displays related posts right after the content on single entry pages. If this option is off, you will need to manually insert <code>related_posts()</code> or variants (<code>related_pages()</code> and <code>related_entries()</code>) into your theme files.",'yarpp')."</span></a>","<tr valign='top'>
322
+ <th class='th-full' colspan='2' scope='row'>",'','<td rowspan="11" style="border-left:8px white solid;"><b>'.__("Website display code example",'yarpp').'</b><br /><small>'.__("(Update options to reload.)",'yarpp').'</small><br/>'
323
  ."<code><pre style='overflow:auto;width:350px;'>".($democode)."</pre></code></td>"); ?>
324
+ <?php textbox('limit',__('Maximum number of related posts:','yarpp'))?>
325
  <tr valign='top'>
326
+ <th><?php _e("Before / after related entries:",'yarpp');?></th>
327
+ <td><input name="before_related" type="text" id="before_related" value="<?php echo stripslashes(yarpp_get_option('before_related',true)); ?>" size="10" /> / <input name="after_related" type="text" id="after_related" value="<?php echo stripslashes(yarpp_get_option('after_related',true)); ?>" size="10" /><em><small> <?php _e("For example:",'yarpp');?> &lt;ol&gt;&lt;/ol&gt; or &lt;div&gt;&lt;/div&gt;</small></em>
328
  </td>
329
  </tr>
330
  <tr valign='top'>
331
+ <th><?php _e("Before / after each related entry:",'yarpp');?></th>
332
+ <td><input name="before_title" type="text" id="before_title" value="<?php echo stripslashes(yarpp_get_option('before_title',true)); ?>" size="10" /> / <input name="after_title" type="text" id="after_title" value="<?php echo stripslashes(yarpp_get_option('after_title',true)); ?>" size="10" /><em><small> <?php _e("For example:",'yarpp');?> &lt;li&gt;&lt;/li&gt; or &lt;dl&gt;&lt;/dl&gt;</small></em>
333
  </td>
334
  </tr>
335
+ <?php checkbox('show_excerpt',__("Show excerpt?",'yarpp'),"<tr valign='top'><th colspan='2'>",' onclick="javascript:excerpt()"'); ?>
336
+ <?php textbox('excerpt_length',__('Excerpt length (No. of words):','yarpp'),null,"<tr name='excerpted' valign='top' ".(yarpp_get_option('show_excerpt')?'':"style='display:none'").">
337
  <th>")?>
338
 
339
  <tr name="excerpted" valign='top' <?php echo (yarpp_get_option('show_excerpt')?'':"style='display:none'")?>>
340
+ <th><?php _e("Before / after (Excerpt):",'yarpp');?></th>
341
+ <td><input name="before_post" type="text" id="before_post" value="<?php echo stripslashes(yarpp_get_option('before_post',true)); ?>" size="10" /> / <input name="after_post" type="text" id="after_post" value="<?php echo stripslashes(yarpp_get_option('after_post')); ?>" size="10" /><em><small> <?php _e("For example:",'yarpp');?> &lt;li&gt;&lt;/li&gt; or &lt;dl&gt;&lt;/dl&gt;</small></em>
342
  </td>
343
  </tr>
344
 
345
  <tr name="excerpted" valign='top'>
346
+ <th><?php _e("Order results:",'yarpp');?></th>
347
  <td><select name="order" id="order">
348
+ <option value="score DESC" <?php echo (yarpp_get_option('order')=='score DESC'?' selected="selected"':'')?>><?php _e("score (high relevance to low)",'yarpp');?></option>
349
+ <option value="score ASC" <?php echo (yarpp_get_option('order')=='score ASC'?' selected="selected"':'')?>><?php _e("score (low relevance to high)",'yarpp');?></option>
350
+ <option value="post_date DESC" <?php echo (yarpp_get_option('order')=='post_date DESC'?' selected="selected"':'')?>><?php _e("date (new to old)",'yarpp');?></option>
351
+ <option value="post_date ASC" <?php echo (yarpp_get_option('order')=='post_date ASC'?' selected="selected"':'')?>><?php _e("date (old to new)",'yarpp');?></option>
352
+ <option value="post_title ASC" <?php echo (yarpp_get_option('order')=='post_title ASC'?' selected="selected"':'')?>><?php _e("title (alphabetical)",'yarpp');?></option>
353
+ <option value="post_title DESC" <?php echo (yarpp_get_option('order')=='post_title DESC'?' selected="selected"':'')?>><?php _e("title (reverse alphabetical)",'yarpp');?></option>
354
  </select>
355
  </td>
356
  </tr>
357
 
358
+ <?php textbox('no_results',__('Default display if no results:','yarpp'),'40')?>
359
+ <?php checkbox('show_score',__("Show admins (user level > 8) the match scores?",'yarpp')." <a href='#' class='info'>more&gt;<span>".__("With this option on, each related entry's total 'match score' (all above the threshold, set above) are displayed after each entry title, <em>if you are an administrator and logged in.</em> Even if you see these values, your visitors will not.",'yarpp')."</span></a>"); ?>
360
+ <?php checkbox('promote_yarpp',__("Help promote Yet Another Related Posts Plugin?",'yarpp')
361
+ ." <a href='#' class='info'>more&gt;<span>"
362
+ .sprintf(__("This option will add the code %s. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated."),"<code>".htmlspecialchars(__("Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.",'yarpp'))."</code>")
363
+ ."</span></a>"); ?>
364
  </table>
365
 
366
  <!-- Display options for RSS -->
367
+ <h3><?php _e("Display options <small>for RSS</small>",'yarpp');?> <span style='color:red;'>NEW!</span></h3>
368
 
369
  <table class="form-table" style="margin-top: 0">
370
  <?php
373
  $democode = stripslashes(yarpp_get_option('rss_before_related',true))."
374
  ";
375
  for ($i=1;$i<=yarpp_get_option('rss_limit');$i++) {
376
+ $democode .= stripslashes(yarpp_get_option('rss_before_title',true)).stripslashes(htmlspecialchars("<a href='".__("RELATED TITLE",'yarpp')."$i'>".__("RELATED TITLE",'yarpp')." $i</a>")).(yarpp_get_option('rss_show_excerpt')?"\r\t".stripslashes(yarpp_get_option('rss_before_post',true)).yarpp_excerpt(LOREMIPSUM,yarpp_get_option('rss_excerpt_length')).stripslashes(yarpp_get_option('rss_before_post',true)):'').stripslashes(yarpp_get_option('rss_after_title',true))."
377
  ";
378
  }
379
  $democode .= stripslashes(yarpp_get_option('rss_after_related',true));
380
  if (yarpp_get_option('rss_promote_yarpp'))
381
+ $democode .= htmlspecialchars("\n<p>".__("Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.",'yarpp')."</p>");
382
 
383
+ checkbox('rss_display',__("Display related posts in feeds?",'yarpp')." <a href='#' class='info'>more&gt;<span>".__("This option displays related posts at the end of each item in your RSS and Atom feeds. No template changes are needed.",'yarpp')."</span></a>","<tr valign='top'><th colspan='3'>",' onclick="javascript:do_rss_display();"');
384
+ checkbox('rss_excerpt_display',__("Display related posts in the descriptions?",'yarpp')." <a href='#' class='info'>more&gt;<span>".__("This option displays the related posts in the RSS description fields, not just the content. If your feeds are set up to only display excerpts, however, only the description field is used, so this option is required for any display at all.",'yarpp')."</span></a>","<tr name='rss_displayed' valign='top'>
385
+ <th class='th-full' colspan='2' scope='row'>",'','<td rowspan="10" style="border-left:8px white solid;"><b>'.__("RSS display code example",'yarpp').'</b><br /><small>'.__("(Update options to reload.)",'yarpp').'</small><br/>'
386
  ."<code><pre style='overflow:auto;width:350px;'>".($democode)."</pre></code></td>"); ?>
387
  <?php textbox('rss_limit','Maximum number of related posts:',2,"<tr valign='top' name='rss_displayed'>
388
  <th scope='row'>")?>
389
  <tr name='rss_displayed' valign='top'>
390
+ <th><?php _e("Before / after related entries display:",'yarpp');?></th>
391
+ <td><input name="rss_before_related" type="text" id="rss_before_related" value="<?php echo stripslashes(yarpp_get_option('rss_before_related',true)); ?>" size="10" /> / <input name="rss_after_related" type="text" id="rss_after_related" value="<?php echo stripslashes(yarpp_get_option('rss_after_related',true)); ?>" size="10" /><em><small> <?php _e("For example:",'yarpp');?> &lt;ol&gt;&lt;/ol&gt; or &lt;div&gt;&lt;/div&gt;</small></em>
392
  </td>
393
  </tr>
394
  <tr name='rss_displayed' valign='top'>
395
+ <th><?php _e("Before / after each related entry:",'yarpp');?></th>
396
+ <td><input name="rss_before_title" type="text" id="rss_before_title" value="<?php echo stripslashes(yarpp_get_option('rss_before_title',true)); ?>" size="10" /> / <input name="rss_after_title" type="text" id="rss_after_title" value="<?php echo stripslashes(yarpp_get_option('rss_after_title',true)); ?>" size="10" /><em><small> <?php _e("For example:",'yarpp');?> &lt;li&gt;&lt;/li&gt; or &lt;dl&gt;&lt;/dl&gt;</small></em>
397
  </td>
398
  </tr>
399
+ <?php checkbox('rss_show_excerpt',__("Show excerpt?",'yarpp'),"<tr name='rss_displayed' valign='top'><th colspan='2'>",' onclick="javascript:rss_excerpt()"'); ?>
400
+ <?php textbox('rss_excerpt_length',__('Excerpt length (No. of words):','yarpp'),null,"<tr name='rss_excerpted' valign='top' ".(yarpp_get_option('rss_show_excerpt')?'':"style='display:none'").">
401
  <th>")?>
402
 
403
  <tr name="rss_excerpted" valign='top' <?php echo (yarpp_get_option('rss_show_excerpt')?'':"style='display:none'")?>>
404
+ <th><?php _e("Before / after (excerpt):",'yarpp');?></th>
405
+ <td><input name="rss_before_post" type="text" id="rss_before_post" value="<?php echo stripslashes(yarpp_get_option('rss_before_post',true)); ?>" size="10" /> / <input name="rss_after_post" type="text" id="rss_after_post" value="<?php echo stripslashes(yarpp_get_option('rss_after_post')); ?>" size="10" /><em><small> <?php _e("For example:",'yarpp');?> &lt;li&gt;&lt;/li&gt; or &lt;dl&gt;&lt;/dl&gt;</small></em>
406
  </td>
407
  </tr>
408
 
409
  <tr name='rss_displayed' valign='top'>
410
+ <th><?php _e("Order results:",'yarpp');?></th>
411
  <td><select name="rss_order" id="rss_order">
412
+ <option value="score DESC" <?php echo (yarpp_get_option('rss_order')=='score DESC'?' selected="selected"':'')?>><?php _e("score (high relevance to low)",'yarpp');?></option>
413
+ <option value="score ASC" <?php echo (yarpp_get_option('rss_order')=='score ASC'?' selected="selected"':'')?>><?php _e("score (low relevance to high)",'yarpp');?></option>
414
+ <option value="post_date DESC" <?php echo (yarpp_get_option('rss_order')=='post_date DESC'?' selected="selected"':'')?>><?php _e("date (new to old)",'yarpp');?></option>
415
+ <option value="post_date ASC" <?php echo (yarpp_get_option('rss_order')=='post_date ASC'?' selected="selected"':'')?>><?php _e("date (old to new)",'yarpp');?></option>
416
+ <option value="post_title ASC" <?php echo (yarpp_get_option('rss_order')=='post_title ASC'?' selected="selected"':'')?>><?php _e("title (alphabetical)",'yarpp');?></option>
417
+ <option value="post_title DESC" <?php echo (yarpp_get_option('rss_order')=='post_title DESC'?' selected="selected"':'')?>><?php _e("title (reverse alphabetical)",'yarpp');?></option>
418
  </select>
419
  </td>
420
  </tr>
421
 
422
+ <?php textbox('rss_no_results',__('Default display if no results:','yarpp'),'40',"<tr valign='top' name='rss_displayed'>
423
  <th scope='row'>")?>
424
+ <?php checkbox('rss_promote_yarpp',__("Help promote Yet Another Related Posts Plugin?",'yarpp')." <a href='#' class='info'>more&gt;<span>"
425
+ .sprintf(__("This option will add the code %s. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated."),"<code>".htmlspecialchars(__("Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.",'yarpp'))."</code>")
426
+ ."</span></a>","<tr valign='top' name='rss_displayed'>
427
  <th class='th-full' colspan='2' scope='row'>"); ?>
428
  </table>
429
 
437
 
438
  <?php
439
 
 
 
440
  ?>
readme.txt CHANGED
@@ -7,7 +7,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=mitcho%4
7
  Tags: related, posts, post, pages, page, RSS, feed, feeds
8
  Requires at least: 2.3
9
  Tested up to: 2.7
10
- Stable tag: 2.1
11
 
12
  Returns a list of the related entries based on a unique algorithm using titles, post bodies, tags, and categories. Now with RSS feed support!
13
 
@@ -53,7 +53,7 @@ By default, `related_posts()` gives you back posts only, `related_pages()` gives
53
 
54
  The `related` functions can be used in conjunction to the regular "auto display" option.
55
 
56
- **Customizing the `related_` functions**
57
 
58
  Since YARPP 2.1, you can specify some custom options for each instance of `related_*()`. The arguments are specified as a single array argument (`related_*(array(key=>value, key=>value, ...))`).
59
 
@@ -108,16 +108,30 @@ If your question isn't here, ask your own question at [the Wordpress.org forums]
108
 
109
  Most likely you have "no related posts" right now as the default "match threshold" is too high. Here's what I recommend to find an appropriate match threshold: first, lower your match threshold in the YARPP prefs to something ridiculously low, like 1 or 0.5. Make sure the last option "show admins the match scores" is on. Most likely the really low threshold will pull up many posts that aren't actually related (false positives), so look at some of your posts' related posts and their match scores. This will help you find an appropriate threshold. You want it lower than what you have now, but high enough so it doesn't have many false positives.
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  = I turned off one of the relatedness criteria (titles, bodies, tags, or categories) and now every page says "no related posts"! =
112
 
113
  This has to do with the way the "match score" is computed. Every entry's match score is the weighted sum of its title-score, body-score, tag-score, and category-score. If you turn off one of the relatedness criteria, you will no doubt have to lower your match threshold to get the same number of related entries to show up. Alternatively, you can consider one of the other criteria "with extra weight".
114
 
115
  It is recommended that you tweak your match threshold whenever you make changes to the "makeup" of your match score (i.e., the settings for the titles, bodies, tags, and categories items).
116
 
117
- = A weird number is displayed after each related post. What is this? =
118
-
119
- This is the match score for each of those entries, relative to the current entry. Don't worry, though--this is just being displayed because the "show admins the match scores" option is on (as it is by default) and only blog admins can see those scores. Your readers will not see these values. See above for how to use these values.
120
-
121
  = XXX plugin stopped working after I installed YARPP! =
122
 
123
  Please submit such bugs by starting a new thread on [the Wordpress.org forums](http://wordpress.org/tags/yet-another-related-posts-plugin). I check the forums regularly and will try to release a quick bugfix.
@@ -126,6 +140,12 @@ Please submit such bugs by starting a new thread on [the Wordpress.org forums](h
126
 
127
  I highly recommend you disactivate YARPP, replace it with the new one, and then reactivate it.
128
 
 
 
 
 
 
 
129
  == Version log ==
130
 
131
  * 1.0
@@ -182,6 +202,11 @@ I highly recommend you disactivate YARPP, replace it with the new one, and then
182
  * Bugfix: `related_*_exist()` functions produced invalid queries
183
  * A warning for `wp_posts` with non-MyISAM engines and semi-compatibility with non-MyISAM setups.
184
  * Bugfix: [a better notice for users of Wordpress < 2.5](http://www.mattcutts.com/blog/wordpress-plugin-related-posts/#comment-131194) regarding the "compare tags" and "compare categories" features.
 
 
 
 
 
185
 
186
  == Future versions ==
187
 
7
  Tags: related, posts, post, pages, page, RSS, feed, feeds
8
  Requires at least: 2.3
9
  Tested up to: 2.7
10
+ Stable tag: 2.1.1
11
 
12
  Returns a list of the related entries based on a unique algorithm using titles, post bodies, tags, and categories. Now with RSS feed support!
13
 
53
 
54
  The `related` functions can be used in conjunction to the regular "auto display" option.
55
 
56
+ **Customizing the "related" functions**
57
 
58
  Since YARPP 2.1, you can specify some custom options for each instance of `related_*()`. The arguments are specified as a single array argument (`related_*(array(key=>value, key=>value, ...))`).
59
 
108
 
109
  Most likely you have "no related posts" right now as the default "match threshold" is too high. Here's what I recommend to find an appropriate match threshold: first, lower your match threshold in the YARPP prefs to something ridiculously low, like 1 or 0.5. Make sure the last option "show admins the match scores" is on. Most likely the really low threshold will pull up many posts that aren't actually related (false positives), so look at some of your posts' related posts and their match scores. This will help you find an appropriate threshold. You want it lower than what you have now, but high enough so it doesn't have many false positives.
110
 
111
+ = Does YARPP work with full-width characters or languages that don't use spaces between words? =
112
+
113
+ YARPP works fine with full-width (double-byte) characters, assuming your WordPress database is set up with Unicode support. 99% of the time, if you're able to write blog posts with full-width characters and they're displayed correctly, YARPP will work on your blog.
114
+
115
+ However, YARPP does have difficulty with languages that don't place spaces between words (Chinese, Japanese, etc.). For these languages, the "consider body" and "consider titles" options in the "Relatedness options" may not be very helpful. Using only tags and categories may work better for these languages.
116
+
117
+ = Does YARPP slow down my blog/server? =
118
+
119
+ A little bit, yes. Every time you display a post with automatic display of related posts (or one of the `related_*()` functions) it will calculate the related posts, which can be a database-intensive operation. *I highly recommend all YARPP users use a page-caching plugin, such as [WP-SuperCache](http://ocaoimh.ie/wp-super-cache/).* For the majority of users, this type of caching will be enough to stem the performance issues.
120
+
121
+ If you have a large blog with many (>1000) posts or have many tags or categories, YARPP may noticibly affect your blog's performance, even with a caching plugin. For these large blogs, for the time being I recommend you disable the "consider tags" and "consider categories" options. Turning off any "disallow" tags or categories will also speed things up.
122
+
123
+ In the future I will be building a YARPP-internal cache system so that YARPP can calculate all the post-relations at one time and then re-use those results every time, rather than calculating them on the fly.
124
+
125
+ = I get a PHP error saying "Cannot redeclare `related_posts()`" =
126
+
127
+ You most likely have another related posts plugin activated at the same time. Please disactivate those other plugins first before using YARPP.
128
+
129
  = I turned off one of the relatedness criteria (titles, bodies, tags, or categories) and now every page says "no related posts"! =
130
 
131
  This has to do with the way the "match score" is computed. Every entry's match score is the weighted sum of its title-score, body-score, tag-score, and category-score. If you turn off one of the relatedness criteria, you will no doubt have to lower your match threshold to get the same number of related entries to show up. Alternatively, you can consider one of the other criteria "with extra weight".
132
 
133
  It is recommended that you tweak your match threshold whenever you make changes to the "makeup" of your match score (i.e., the settings for the titles, bodies, tags, and categories items).
134
 
 
 
 
 
135
  = XXX plugin stopped working after I installed YARPP! =
136
 
137
  Please submit such bugs by starting a new thread on [the Wordpress.org forums](http://wordpress.org/tags/yet-another-related-posts-plugin). I check the forums regularly and will try to release a quick bugfix.
140
 
141
  I highly recommend you disactivate YARPP, replace it with the new one, and then reactivate it.
142
 
143
+ = Does YARPP come in different languages? =
144
+
145
+ YARPP has been [internationalized](http://codex.wordpress.org/Writing_a_Plugin#Internationalizing_Your_Plugin) as of version 2.1.1. No localizations have been made yet, but they are coming.
146
+
147
+ If you are a bilingual speaker of English and another language and an avid user of YARPP, I would love to talk to you about localizing YARPP! Localizing YARPP can be pretty easy using [the Codestyling Localization plugin](http://www.code-styling.de/english/development/wordpress-plugin-codestyling-localization-en). Please [contact me](mailto:yarpp@mitcho.com) *first* before translating to make sure noone else is working on your language. Thanks!
148
+
149
  == Version log ==
150
 
151
  * 1.0
202
  * Bugfix: `related_*_exist()` functions produced invalid queries
203
  * A warning for `wp_posts` with non-MyISAM engines and semi-compatibility with non-MyISAM setups.
204
  * Bugfix: [a better notice for users of Wordpress < 2.5](http://www.mattcutts.com/blog/wordpress-plugin-related-posts/#comment-131194) regarding the "compare tags" and "compare categories" features.
205
+ * 2.1.1
206
+ * Bugfix: keywords with forward slashes (\) could make the main SQL query ill-formed.
207
+ * Bugfix: Added an override option for the [false MyISAM warnings](http://wordpress.org/support/topic/211043).
208
+ * Preparing for localization! (See note at the bottom of the FAQ.)
209
+ * Adding a debug mode--just try adding `&yarpp_debug=1` to your URL's and look at the HTML source.
210
 
211
  == Future versions ==
212
 
yarpp.php CHANGED
@@ -3,12 +3,11 @@
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://mitcho.com/code/yarpp/
5
  Description: Returns a list of the related entries based on a unique algorithm using titles, post bodies, tags, and categories. Now with RSS feed support!
6
- Version: 2.1
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  */
9
 
10
  require_once('includes.php');
11
- require_once('magic.php');
12
  require_once('related-functions.php');
13
 
14
  add_action('admin_menu','yarpp_admin_menu');
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://mitcho.com/code/yarpp/
5
  Description: Returns a list of the related entries based on a unique algorithm using titles, post bodies, tags, and categories. Now with RSS feed support!
6
+ Version: 2.1.1
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  */
9
 
10
  require_once('includes.php');
 
11
  require_once('related-functions.php');
12
 
13
  add_action('admin_menu','yarpp_admin_menu');