Yet Another Related Posts Plugin (YARPP) - Version 3.0.14b1

Version Description

Download this release

Release Info

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

Code changes from version 3.0.13 to 3.0.14b1

Files changed (6) hide show
  1. includes.php +8 -7
  2. magic.php +14 -7
  3. options.php +40 -14
  4. readme.txt +10 -2
  5. template-builtin.php +1 -1
  6. yarpp.php +2 -4
includes.php CHANGED
@@ -54,8 +54,7 @@ $yarpp_binary_options = array('past_only' => true,
54
  'rss_display' => true,
55
  'rss_excerpt_display' => true,
56
  'promote_yarpp' => false,
57
- 'rss_promote_yarpp' => false,
58
- 'ad_hoc_caching' => true);
59
 
60
  function yarpp_enabled() {
61
  global $wpdb;
@@ -197,14 +196,16 @@ function yarpp_admin_menu() {
197
  $hook = add_options_page(__('Related Posts (YARPP)','yarpp'),__('Related Posts (YARPP)','yarpp'), 8, 'yet-another-related-posts-plugin/options.php', 'yarpp_options_page');
198
  //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');
199
  add_action("load-$hook",'yarpp_load_thickbox');
 
 
200
  }
201
 
202
  function yarpp_settings_link($links, $file) {
203
- $this_plugin = dirname(plugin_basename(__FILE__)) . '/yarpp.php';
204
- if($file == $this_plugin) {
205
- $links[] = '<a href="options-general.php?page='.dirname(plugin_basename(__FILE__)).'/options.php">' . __('Settings', 'yarpp') . '</a>';
206
- }
207
- return $links;
208
  }
209
 
210
  function yarpp_load_thickbox() {
54
  'rss_display' => true,
55
  'rss_excerpt_display' => true,
56
  'promote_yarpp' => false,
57
+ 'rss_promote_yarpp' => false);
 
58
 
59
  function yarpp_enabled() {
60
  global $wpdb;
196
  $hook = add_options_page(__('Related Posts (YARPP)','yarpp'),__('Related Posts (YARPP)','yarpp'), 8, 'yet-another-related-posts-plugin/options.php', 'yarpp_options_page');
197
  //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');
198
  add_action("load-$hook",'yarpp_load_thickbox');
199
+ // new in 3.0.12: add settings link to the plugins page
200
+ add_filter('plugin_action_links', 'yarpp_settings_link', 10, 2);
201
  }
202
 
203
  function yarpp_settings_link($links, $file) {
204
+ $this_plugin = dirname(plugin_basename(__FILE__)) . '/yarpp.php';
205
+ if($file == $this_plugin) {
206
+ $links[] = '<a href="options-general.php?page='.dirname(plugin_basename(__FILE__)).'/options.php">' . __('Settings', 'yarpp') . '</a>';
207
+ }
208
+ return $links;
209
  }
210
 
211
  function yarpp_load_thickbox() {
magic.php CHANGED
@@ -271,10 +271,9 @@ function yarpp_related($type,$args,$echo = true,$reference_ID=false,$domain = 'w
271
  }
272
  extract($optvals);
273
 
274
- if (yarpp_get_option('ad_hoc_caching') == 1)
275
- yarpp_cache_enforce($type,$reference_ID);
276
 
277
- $output = '';
278
 
279
  if ($domain != 'demo_web' and $domain != 'demo_rss')
280
  $yarpp_time = true; // get ready for YARPP TIME!
@@ -387,16 +386,24 @@ function yarpp_save_cache($post_ID,$force=true) {
387
  // add it to the queue
388
  array_push($yarpp_caching_queue,$post_ID);
389
 
 
 
 
390
  // go through the queue
391
  while ($ID = array_pop($yarpp_caching_queue)) {
392
  if (array_search($ID,$yarpp_updated_posts) === false) {
393
- //echo "YARPP updating $ID<br/>";
394
- //echo "YARPP QUEUE: ".print_r($yarpp_caching_queue,true)."<br/>";
395
- //echo "YARPP UPDATED: ".print_r($yarpp_updated_posts,true)."<br/>";
396
  yarpp_cache_enforce($type,$ID,$force);
397
- array_push($yarpp_updated_posts,$ID);
398
  }
399
  }
 
 
 
 
 
 
 
 
400
  }
401
 
402
  function yarpp_cache_enforce($type=array('post'),$reference_ID,$force=false) {
271
  }
272
  extract($optvals);
273
 
274
+ yarpp_cache_enforce($type,$reference_ID);
 
275
 
276
+ $output = '';
277
 
278
  if ($domain != 'demo_web' and $domain != 'demo_rss')
279
  $yarpp_time = true; // get ready for YARPP TIME!
386
  // add it to the queue
387
  array_push($yarpp_caching_queue,$post_ID);
388
 
389
+ // any newly targetted posts will have to be cleared
390
+ $yarpp_toclear = array();
391
+
392
  // go through the queue
393
  while ($ID = array_pop($yarpp_caching_queue)) {
394
  if (array_search($ID,$yarpp_updated_posts) === false) {
 
 
 
395
  yarpp_cache_enforce($type,$ID,$force);
396
+ array_push($yarpp_toclear,$ID);
397
  }
398
  }
399
+
400
+ yarpp_cache_clear($yarpp_toclear);
401
+
402
+ }
403
+
404
+ function yarpp_cache_clear($reference_IDs) {
405
+ global $wpdb;
406
+ $wpdb->query("delete from {$wpdb->prefix}yarpp_related_cache where reference_ID in (".implode(',',$reference_IDs).")");
407
  }
408
 
409
  function yarpp_cache_enforce($type=array('post'),$reference_ID,$force=false) {
options.php CHANGED
@@ -105,15 +105,6 @@ $cache_complete = $wpdb->get_var("select (count(p.ID)-sum(c.ID IS NULL))/count(p
105
  FROM $wpdb->posts as p
106
  LEFT JOIN {$wpdb->prefix}yarpp_related_cache as c ON ( p.ID = c.reference_ID )
107
  WHERE p.post_status = 'publish' ");
108
-
109
- if (yarpp_get_option('ad_hoc_caching') != 1) {
110
-
111
- if ($cache_complete > 0 and $cache_complete < 1)
112
- echo '<div class="updated fade" style="background-color: rgb(207, 235, 247);"><p>'.str_replace('<A>','<a class="thickbox" title="'.__('Related posts cache status','yarpp').'" href="#TB_inline?height=100&width=300&inlineId=yarpp-cache-status">',__('Your related posts cache is incomplete. Please build your cache from the <A>related posts status pane</a>.','yarpp')).'</p></div>';
113
-
114
- if ($cache_complete == 0)
115
- echo '<div class="updated fade" style="background-color: rgb(207, 235, 247);"><p>'.str_replace('<A>','<a class="thickbox" title="'.__('Related posts cache status','yarpp').'" href="#TB_inline?height=100&width=300&inlineId=yarpp-cache-status">',__('Your related posts cache is empty. Please build your cache from the <A>related posts status pane</a>.','yarpp')).'</p></div>';
116
- }
117
 
118
  //compute $tagmap
119
  $tagmap = array();
@@ -138,7 +129,7 @@ function checkbox($option,$desc,$tr="<tr valign='top'>
138
  }
139
  function textbox($option,$desc,$size=2,$tr="<tr valign='top'>
140
  <th scope='row'>") {
141
- $value = yarpp_get_option($option,true);
142
  echo " $tr$desc</th>
143
  <td><input name='$option' type='text' id='$option' value='$value' size='$size' /></td>
144
  </tr>";
@@ -522,13 +513,13 @@ checkbox('rss_excerpt_display',__("Display related posts in the descriptions?",'
522
  </div>
523
 
524
  <div style='border:1px solid #ddd;padding:8px;'>
525
- <h3><?php _e('Advanced','yarpp');?> <span style='color:red;'><?php _e('NEW!','yarpp')?></span></h3>
526
 
527
  <table class="form-table" style="margin-top: 0">
528
  <tr valign='top' colspan='2'><td><input class="thickbox button" type="button" value="<?php _e("Show cache status",'yarpp');?>" title="<?php _e('Related posts cache status','yarpp');?>" alt="#TB_inline?height=100&width=300&inlineId=yarpp-cache-status"/>
529
- <?php checkbox('ad_hoc_caching',__("When the cache is incomplete, compute related posts on the fly?",'yarpp')." <a href='#' class='info'>".__('more&gt;','yarpp')."<span>"
530
- .__("If a displayed post's related posts are not cached and this option is on, YARPP will compute them on the fly.<br />If this option is off and a post's related posts have not been cached, it will display as if it has no related posts.",'yarpp')
531
- ."</span></a>"); ?>
532
  </table>
533
  </div>
534
 
@@ -599,6 +590,41 @@ checkbox('rss_excerpt_display',__("Display related posts in the descriptions?",'
599
  </div>
600
  </div>
601
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
602
  <div>
603
  <p class="submit">
604
  <input type="submit" name="update_yarpp" value="<?php _e("Update options",'yarpp')?>" />
105
  FROM $wpdb->posts as p
106
  LEFT JOIN {$wpdb->prefix}yarpp_related_cache as c ON ( p.ID = c.reference_ID )
107
  WHERE p.post_status = 'publish' ");
 
 
 
 
 
 
 
 
 
108
 
109
  //compute $tagmap
110
  $tagmap = array();
129
  }
130
  function textbox($option,$desc,$size=2,$tr="<tr valign='top'>
131
  <th scope='row'>") {
132
+ $value = stripslashes(yarpp_get_option($option,true));
133
  echo " $tr$desc</th>
134
  <td><input name='$option' type='text' id='$option' value='$value' size='$size' /></td>
135
  </tr>";
513
  </div>
514
 
515
  <div style='border:1px solid #ddd;padding:8px;'>
516
+ <h3><?php _e('Advanced','yarpp');?></h3>
517
 
518
  <table class="form-table" style="margin-top: 0">
519
  <tr valign='top' colspan='2'><td><input class="thickbox button" type="button" value="<?php _e("Show cache status",'yarpp');?>" title="<?php _e('Related posts cache status','yarpp');?>" alt="#TB_inline?height=100&width=300&inlineId=yarpp-cache-status"/>
520
+
521
+ <!--<input class="thickbox button" type="button" value="Test queries" title="If you are having trouble getting YARPP to show results, try this test." alt="#TB_inline?height=500&width=500&inlineId=yarpp-test"/>-->
522
+ </td></tr>
523
  </table>
524
  </div>
525
 
590
  </div>
591
  </div>
592
 
593
+ <div id='yarpp-test' style='display:none;'>
594
+ <p>This test has been added in response to <a href='http://wordpress.org/support/topic/284209'>this thread</a> on wordpress.org. Once the bug is resolved, I will remove this screen.</p>
595
+
596
+ <h3>Cache stats:</h3>
597
+
598
+ <?php
599
+ $smct = $wpdb->get_row("select sum(ID = 0) as sm, count(*) as ct from {$wpdb->prefix}yarpp_related_cache");
600
+ echo "<p>Proportion of cached posts which have no related posts at all: ".(round(1000*$smct->sm/$smct->ct)/10)."%</p>";
601
+
602
+ if ((round(1000*$smct->sm/$smct->ct)/10) > 20) {
603
+ echo "<p><b>You seem to be affected by the bug I am trying to fix. Please run a test on a single query (below) and <a href=''>post the results here</a>.</b></p>";
604
+ ?>
605
+
606
+ <h3>Query test:</h3>
607
+
608
+ <p>Please select a post with a good deal of content:</p>
609
+
610
+ <select name='test_post_ID' id='test_post_ID'>
611
+ <?php
612
+ $posts = $wpdb->get_results("select ID, post_title from $wpdb->posts where length(post_content) > 0 and post_type != 'revision' order by length(post_content) desc limit 20");
613
+
614
+ foreach ($posts as $post) {
615
+ echo "<option value='$post->ID'>$post->post_title</option>\n";
616
+ }
617
+ ?>
618
+ </select>
619
+
620
+ <?php
621
+ }
622
+ else
623
+ echo "<p><b>You do not seem to be affected by the bug I'm trying to fix. Thank you.</b></p>";
624
+ ?>
625
+
626
+ </div>
627
+
628
  <div>
629
  <p class="submit">
630
  <input type="submit" name="update_yarpp" value="<?php _e("Update options",'yarpp')?>" />
readme.txt CHANGED
@@ -102,7 +102,7 @@ It is recommended that you tweak your match threshold whenever you make changes
102
 
103
  = Are there any plugins that are incompatible with YARPP? =
104
 
105
- Aside from the DISQUS plugin (see above), currently the only known incompatibility is [with the SEO_Pager plugin](http://wordpress.org/support/topic/267966). Users of SEO Pager are urged to turn off the automatic display option in SEO Pager and instead add the code manually.
106
 
107
  Please submit similar bugs by starting a new thread on [the Wordpress.org forums](http://wordpress.org/tags/yet-another-related-posts-plugin?forum_id=10#postform). I check the forums regularly and will try to release a quick bugfix.
108
 
@@ -143,11 +143,20 @@ We already have localizers lined up for the following languages:
143
  * Hungarian
144
  * Romanian
145
  * Latvian
 
 
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
  == Changelog ==
150
 
 
 
 
 
 
 
 
151
  = 3.0.13 =
152
  * Quick immediate bugfix to 3.0.12
153
  = 3.0.12 =
@@ -301,6 +310,5 @@ If you are a bilingual speaker of English and another language and an avid user
301
  * Also, uses `apply_filters` to apply whatever content text transformation you use (Wikipedia link, Markdown, etc.) before computing similarity.
302
  = 1.0.1 =
303
  * Bugfix: 1.0 assumed you had Markdown installed
304
-
305
  = 1.0 =
306
  * Initial upload
102
 
103
  = Are there any plugins that are incompatible with YARPP? =
104
 
105
+ Aside from the DISQUS plugin (see above), currently the only known incompatibility is [with the SEO_Pager plugin](http://wordpress.org/support/topic/267966) and the [Pagebar 2](http://www.elektroelch.de/hacks/wp/pagebar/) plugin. Users of SEO Pager are urged to turn off the automatic display option in SEO Pager and instead add the code manually. Other related posts plugins, obviously, may also be incompatible.
106
 
107
  Please submit similar bugs by starting a new thread on [the Wordpress.org forums](http://wordpress.org/tags/yet-another-related-posts-plugin?forum_id=10#postform). I check the forums regularly and will try to release a quick bugfix.
108
 
143
  * Hungarian
144
  * Romanian
145
  * Latvian
146
+ * Swedish
147
+ * Thai
148
 
149
  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!
150
 
151
  == Changelog ==
152
 
153
+ = 3.0.14 =
154
+ * Removing the confusing "on the fly caching" setting... it is always on now.
155
+ * Fixed `yarpp_settings_link` dependency when disabled.
156
+ * Breaks (&lt;br /&gt;) are now stripped out of titles.
157
+ * Added plugin incompatibility info for Pagebar.
158
+ * Bugfix: [a slash escaping bug](http://wordpress.org/support/topic/315560)
159
+ * Faster post saving.
160
  = 3.0.13 =
161
  * Quick immediate bugfix to 3.0.12
162
  = 3.0.12 =
310
  * Also, uses `apply_filters` to apply whatever content text transformation you use (Wikipedia link, Markdown, etc.) before computing similarity.
311
  = 1.0.1 =
312
  * Bugfix: 1.0 assumed you had Markdown installed
 
313
  = 1.0 =
314
  * Initial upload
template-builtin.php CHANGED
@@ -30,7 +30,7 @@ if ($related_query->have_posts()) {
30
  while ($related_query->have_posts()) {
31
  $related_query->the_post();
32
 
33
- $output .= "$before_title<a href='".get_permalink()."' rel='bookmark' title='Permanent Link: ".get_the_title()."'>".get_the_title()."";
34
  if ($userdata->user_level >= 8 and $domain != 'rss')
35
  $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(get_the_score(),3)).'">('.round(get_the_score(),3).')</abbr>';
36
  $output .= '</a>';
30
  while ($related_query->have_posts()) {
31
  $related_query->the_post();
32
 
33
+ $output .= "$before_title<a href='".get_permalink()."' rel='bookmark' title='Permanent Link: ".preg_replace('/\s*<br[ /]*>\s*/i', ' ', get_the_title())."'>".get_the_title()."";
34
  if ($userdata->user_level >= 8 and $domain != 'rss')
35
  $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(get_the_score(),3)).'">('.round(get_the_score(),3).')</abbr>';
36
  $output .= '</a>';
yarpp.php CHANGED
@@ -3,13 +3,13 @@
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://mitcho.com/code/yarpp/
5
  Description: Returns a list of related entries based on a unique algorithm for display on your blog and RSS feeds. A templating feature allows customization of the display.
6
- Version: 3.0.13
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  Author URI: http://mitcho.com/
9
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=66G4DATK4999L&item_name=mitcho%2ecom%2fcode%3a%20donate%20to%20Michael%20Yoshitaka%20Erlewine&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&charset=UTF%2d8
10
  */
11
 
12
- define('YARPP_VERSION','3.0.13');
13
 
14
  require_once('includes.php');
15
  require_once('related-functions.php');
@@ -53,5 +53,3 @@ add_filter('posts_request','yarpp_demo_request_filter');
53
  add_filter('post_limits','yarpp_limit_filter');
54
  add_action('parse_query','yarpp_set_score_override_flag'); // sets the score override flag.
55
 
56
- // new in 3.0.12: add settings link to the plugins page
57
- add_filter('plugin_action_links', 'yarpp_settings_link', 10, 2);
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://mitcho.com/code/yarpp/
5
  Description: Returns a list of related entries based on a unique algorithm for display on your blog and RSS feeds. A templating feature allows customization of the display.
6
+ Version: 3.0.14b1
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  Author URI: http://mitcho.com/
9
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=66G4DATK4999L&item_name=mitcho%2ecom%2fcode%3a%20donate%20to%20Michael%20Yoshitaka%20Erlewine&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&charset=UTF%2d8
10
  */
11
 
12
+ define('YARPP_VERSION','3.0.14b1');
13
 
14
  require_once('includes.php');
15
  require_once('related-functions.php');
53
  add_filter('post_limits','yarpp_limit_filter');
54
  add_action('parse_query','yarpp_set_score_override_flag'); // sets the score override flag.
55