Yet Another Related Posts Plugin (YARPP) - Version 3.5

Version Description

  • New public YARPP query API, which supports custom post types
    • Documentation in the "other notes" section of the readme
    • Changed format of weight, template, recent parameters in options and in optional args
  • Further main query optimization:
    • What's cooler than joining four tables? Joining two.
    • Exclude now simply uses term_taxonomy_ids instead of term_ids
  • Bugfix: "related posts" preview metabox was not always working properly
  • Changes to the related_*() and yarpp_related() function signatures.
  • Added "consider with extra weight" to taxonomy criteria as well
  • Code cleanup:
    • Don't clear the cache when it's already empty
    • protect the sql method as it shouldn't be public
    • Further use of utility functions from 3.1 like wp_list_pluck()
    • New constant, YARPP_EXTRA_WEIGHT to define the "extra weight." By default, it's 3.
  • Localizations:
    • Added Slovak (sk_SK) localization by Forex
    • Added Romanian (ro_RO) localization by Uhren Shop
    • Updated it_IT, ko_KR, fr_FR, sv_SE, ja localizations
Download this release

Release Info

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

Code changes from version 3.5b5 to 3.5

Files changed (3) hide show
  1. options-meta-boxes.php +1 -0
  2. readme.txt +25 -17
  3. yarpp.php +3 -3
options-meta-boxes.php CHANGED
@@ -197,6 +197,7 @@ class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
197
  <td>
198
  <select name="template_file" id="template_file">
199
  <?php
 
200
  foreach ($yarpp->admin->get_templates() as $template): ?>
201
  <option value='<?php echo esc_attr($template)?>'<?php selected($template, $chosen_template);?>><?php echo esc_html($template)?></option>
202
  <?php endforeach; ?>
197
  <td>
198
  <select name="template_file" id="template_file">
199
  <?php
200
+ $chosen_template = yarpp_get_option('template');
201
  foreach ($yarpp->admin->get_templates() as $template): ?>
202
  <option value='<?php echo esc_attr($template)?>'<?php selected($template, $chosen_template);?>><?php echo esc_html($template)?></option>
203
  <?php endforeach; ?>
readme.txt CHANGED
@@ -6,21 +6,21 @@ Plugin URI: http://yarpp.org/
6
  Donate link: http://tinyurl.com/donatetomitcho
7
  Tags: related, posts, post, pages, page, RSS, feed, feeds
8
  Requires at least: 3.0
9
- Tested up to: 3.3.1
10
- Stable tag: 3.4.3
11
 
12
- Display a list of related entries on your site and feeds based on a unique algorithm. Templating allows customization of the display.
13
 
14
  == Description ==
15
 
16
  Yet Another Related Posts Plugin (YARPP) gives you a list of posts and/or pages related to the current entry, introducing the reader to other relevant content on your site. Key features include:
17
 
18
- 1. **An advanced and versatile algorithm**: Using a customizable algorithm considering post titles, content, tags, categories, and **now custom taxonomies**, YARPP finds related content from across your site. **Improved and optimized in 3.4!** [Learn more](http://wordpress.tv/2011/01/29/michael-%E2%80%9Cmitcho%E2%80%9D-erlewine-the-yet-another-related-posts-plugin-algorithm-explained/)
19
- 2. **Templating**: The [YARPP templating system](http://mitcho.com/blog/projects/yarpp-3-templates/) puts you in charge of how your posts are displayed.
20
- 3. **Caching**: YARPP organically caches the related posts data as your site is visited, greatly improving performance.
21
- 4. **Related posts in RSS feeds**: Display related posts in your RSS and Atom feeds with custom display options.
22
- 5. **Disallowing certain tags or categories**: You can choose certain tags or categories as disallowed, meaning any page or post with such tags or categories will not be served up by the plugin.
23
- 6. **Related posts and pages**: Puts you in control of pulling up related posts, pages, or both. YARPP does not yet fully support custom post types; look for these in a future version.
24
 
25
  This plugin requires PHP 5 and MySQL 4.1 or greater.
26
 
@@ -34,7 +34,9 @@ I try to respond to inquiries on the forums on a regular basis and hope to build
34
 
35
  = Testimonials =
36
 
37
- "One of my favorite [plugin]s I just activated on my blog is called Yet Another Related Posts Plugin... I've been blogging seven or eight years now so I have a lot of archives, and it actually surprises me sometimes when I blog about something and I visit the permalink to see I've written about it before... and it also increases the traffic on your blog because when they come in just to one entry, they'll see this other stuff going on." - [Matt Mullenweg](http://ma.tt), WordPress creator
 
 
38
 
39
  "The first one I ended up trying was Yet Another Related Posts Plugin (YARPP), and mitcho has really done a fantastic job on it:
40
 
@@ -68,6 +70,10 @@ YARPP allows the advanced user with knowledge of PHP to customize the display of
68
 
69
  If your question isn't here, ask your own question at [the Wordpress.org forums](http://wordpress.org/tags/yet-another-related-posts-plugin?forum_id=10#postform). *Please do not email with questions.*
70
 
 
 
 
 
71
  = How can I move the related posts display? =
72
 
73
  If you do not want to show the Related Posts display in its default position (right below the post content), first go to YARPP options and turn off the "automatically display" option in the "website" section. If you would like to instead display it in your sidebar and you have a widget-aware theme, YARPP provides a Related Posts widget which you can add under "Appearance" > "Widgets".
@@ -76,7 +82,7 @@ If you would like to add the Related Posts display elsewhere, edit your relevant
76
 
77
  = Does YARPP slow down my blog/server? =
78
 
79
- The YARPP calculation of related content does make a little impact, yes. However, YARPP caches all of its results, so any post's results need only be calculated once. YARPP's queries have been significantly optimized in version 3.4.
80
 
81
  If you find that the YARPP database calls are still too database-intensive, try the following:
82
 
@@ -125,9 +131,9 @@ The official [YARPP Experiments](http://wordpress.org/extend/plugins/yarpp-exper
125
 
126
  = Custom displays and custom post type support =
127
 
128
- Developers can call YARPP's powerful relatedness algorithm from anywhere in their own code.
129
 
130
- yarpp_related(get_the_ID(), array(
131
  // Pool options: these determine the "pool" of entities which are considered
132
  'post_type' => array('post', 'page', ...),
133
  'show_pass_post' => false, // show password-protected posts
@@ -156,11 +162,13 @@ Developers can call YARPP's powerful relatedness algorithm from anywhere in thei
156
  'template' => , // either the name of a file in your active theme or the boolean false to use the builtin template
157
  'limit' => 5, // maximum number of results
158
  'order' => 'score DESC'
159
- ));
 
 
160
 
161
  Options which are not specified will default to those specified in the YARPP settings page. Additionally, if you are using the builtin template rather than specifying a custom template file in `template`, the following arguments can be used to override the various parts of the builtin template: `before_title`, `after_title`, `before_post`, `after_post`, `before_related`, `after_related`, `no_results`, `excerpt_length`.
162
 
163
- If you need to use related entries programmatically or to know whether they exist, you can use the functions `yarpp_get_related($reference_ID, $args)` and `yarpp_related_exist($reference_ID, $args)`. `yarpp_get_related` returns an array of `post` objects, just like the WordPress function `get_posts`. `yarpp_related_exist` returns a boolean for whether any such related entries exist. For each function, `$args` takes the same arguments as those shown for `yarpp_related` above, except for the various display and template options.
164
 
165
  Note that custom YARPP queries using the functions mentioned here are *not* cached in the built-in YARPP caching system. Thus, if you notice any performance hits, you may need to write your own code to cache the results.
166
 
@@ -223,7 +231,7 @@ If you are a bilingual speaker of English and another language and an avid user
223
  == Changelog ==
224
 
225
  = 3.5 =
226
- * New public YARPP query API
227
  * Documentation in the "other notes" section of the readme
228
  * Changed format of `weight`, `template`, `recent` parameters in options and in optional args
229
  * Further main query optimization:
@@ -404,7 +412,7 @@ If you are a bilingual speaker of English and another language and an avid user
404
  * Rewrote `include` and `require` paths
405
  * Bugfix: localizations were not working with WordPress 2.9 ([a CodeStyling Localizations bug](http://wordpress.org/support/topic/343389))
406
  * Bugfix: [redundant entries for "unrelatedness" were being inserted](http://wordpress.org/support/topic/344859)
407
- * Bugfix: [`yearpp_clear_cache` bug on empty input](http://wordpress.org/support/topic/343001)
408
  * Version checking code no longer uses Snoopy.
409
  * New localization: Hindi by [Outshine Solutions](http://outshinesolutions.com/)
410
  = 3.1.2 =
6
  Donate link: http://tinyurl.com/donatetomitcho
7
  Tags: related, posts, post, pages, page, RSS, feed, feeds
8
  Requires at least: 3.0
9
+ Tested up to: 3.4
10
+ Stable tag: 3.5
11
 
12
+ Display a list of related entries on your site and feeds based on a unique algorithm. Now with custom post type support!
13
 
14
  == Description ==
15
 
16
  Yet Another Related Posts Plugin (YARPP) gives you a list of posts and/or pages related to the current entry, introducing the reader to other relevant content on your site. Key features include:
17
 
18
+ 1. **Templating**: The [YARPP templating system](http://mitcho.com/blog/projects/yarpp-3-templates/) puts you in charge of how your posts are displayed.
19
+ 2. **Related posts, pages, and custom post types**: [Learn about CPT support](http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/other_notes/). **New in 3.5!**
20
+ 3. **An advanced and versatile algorithm**: Using a customizable algorithm considering post titles, content, tags, categories, and custom taxonomies, YARPP finds related content from across your site. [Learn more](http://wordpress.tv/2011/01/29/michael-%E2%80%9Cmitcho%E2%80%9D-erlewine-the-yet-another-related-posts-plugin-algorithm-explained/). **Improved and optimized in 3.5!**
21
+ 4. **Caching**: YARPP organically caches the related posts data as your site is visited, greatly improving performance.
22
+ 5. **Related posts in RSS feeds**: Display related posts in your RSS and Atom feeds with custom display options.
23
+ 6. **Disallowing certain tags or categories**: You can choose certain tags or categories as disallowed, meaning any page or post with such tags or categories will not be served up by the plugin.
24
 
25
  This plugin requires PHP 5 and MySQL 4.1 or greater.
26
 
34
 
35
  = Testimonials =
36
 
37
+ "One of my favorite [plugin]s I just activated on my blog is called Yet Another Related Posts Plugin... I've been blogging seven or eight years now so I have a lot of archives, and it actually surprises me sometimes when I blog about something and I visit the permalink to see I've written about it before... and it also increases the traffic on your blog because when they come in just to one entry, they'll see this other stuff going on."
38
+
39
+ - [Matt Mullenweg](http://ma.tt), WordPress creator
40
 
41
  "The first one I ended up trying was Yet Another Related Posts Plugin (YARPP), and mitcho has really done a fantastic job on it:
42
 
70
 
71
  If your question isn't here, ask your own question at [the Wordpress.org forums](http://wordpress.org/tags/yet-another-related-posts-plugin?forum_id=10#postform). *Please do not email with questions.*
72
 
73
+ = How can I use the custom template feature? =
74
+
75
+ YARPP's [custom templates feature](http://mitcho.com/blog/projects/yarpp-3-templates/) allows you to uber-customize the related posts display using the same coding conventions and [Template Tags](http://codex.wordpress.org/Template_Tags) as in WordPress themes. Custom templates must be in your *active theme's main directory* in order to be recognized by YARPP. If your theme did not ship with YARPP templates, move the files in the `yarpp-templates` directory which ships with YARPP into your active theme's main directory. Be sure to move the *files* (which must be named `yarpp-template-`...`.php`) to your theme, not the entire directory.
76
+
77
  = How can I move the related posts display? =
78
 
79
  If you do not want to show the Related Posts display in its default position (right below the post content), first go to YARPP options and turn off the "automatically display" option in the "website" section. If you would like to instead display it in your sidebar and you have a widget-aware theme, YARPP provides a Related Posts widget which you can add under "Appearance" > "Widgets".
82
 
83
  = Does YARPP slow down my blog/server? =
84
 
85
+ The YARPP calculation of related content does make a little impact, yes. However, YARPP caches all of its results, so any post's results need only be calculated once. YARPP's queries have been significantly optimized in version 3.5.
86
 
87
  If you find that the YARPP database calls are still too database-intensive, try the following:
88
 
131
 
132
  = Custom displays and custom post type support =
133
 
134
+ Developers can call YARPP's powerful relatedness algorithm from anywhere in their own code. Some examples and more details are in [my slides from my WordCamp Birmingham talk](http://www.slideshare.net/mitcho/relate-all-the-things).
135
 
136
+ yarpp_related(array(
137
  // Pool options: these determine the "pool" of entities which are considered
138
  'post_type' => array('post', 'page', ...),
139
  'show_pass_post' => false, // show password-protected posts
162
  'template' => , // either the name of a file in your active theme or the boolean false to use the builtin template
163
  'limit' => 5, // maximum number of results
164
  'order' => 'score DESC'
165
+ ),
166
+ $reference_ID, // second argument: (optional) the post ID. If not included, it will use the current post.
167
+ true); // third argument: (optional) true to echo the HTML block; false to return it
168
 
169
  Options which are not specified will default to those specified in the YARPP settings page. Additionally, if you are using the builtin template rather than specifying a custom template file in `template`, the following arguments can be used to override the various parts of the builtin template: `before_title`, `after_title`, `before_post`, `after_post`, `before_related`, `after_related`, `no_results`, `excerpt_length`.
170
 
171
+ If you need to use related entries programmatically or to know whether they exist, you can use the functions `yarpp_get_related($args, $reference_ID)` and `yarpp_related_exist($args, $reference_ID)`. `yarpp_get_related` returns an array of `post` objects, just like the WordPress function `get_posts`. `yarpp_related_exist` returns a boolean for whether any such related entries exist. For each function, `$args` takes the same arguments as those shown for `yarpp_related` above, except for the various display and template options.
172
 
173
  Note that custom YARPP queries using the functions mentioned here are *not* cached in the built-in YARPP caching system. Thus, if you notice any performance hits, you may need to write your own code to cache the results.
174
 
231
  == Changelog ==
232
 
233
  = 3.5 =
234
+ * New public YARPP query API, which supports custom post types
235
  * Documentation in the "other notes" section of the readme
236
  * Changed format of `weight`, `template`, `recent` parameters in options and in optional args
237
  * Further main query optimization:
412
  * Rewrote `include` and `require` paths
413
  * Bugfix: localizations were not working with WordPress 2.9 ([a CodeStyling Localizations bug](http://wordpress.org/support/topic/343389))
414
  * Bugfix: [redundant entries for "unrelatedness" were being inserted](http://wordpress.org/support/topic/344859)
415
+ * Bugfix: [`yarpp_clear_cache` bug on empty input](http://wordpress.org/support/topic/343001)
416
  * Version checking code no longer uses Snoopy.
417
  * New localization: Hindi by [Outshine Solutions](http://outshinesolutions.com/)
418
  = 3.1.2 =
yarpp.php CHANGED
@@ -2,14 +2,14 @@
2
  /*
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://yarpp.org/
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.5b5
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  Author URI: http://mitcho.com/
9
  Donate link: http://tinyurl.com/donatetomitcho
10
  */
11
 
12
- define('YARPP_VERSION', '3.5b5');
13
  define('YARPP_DIR', dirname(__FILE__));
14
  define('YARPP_NO_RELATED', ':(');
15
  define('YARPP_RELATED', ':)');
2
  /*
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://yarpp.org/
5
+ Description: Returns a list of related entries based on a unique algorithm for display on your blog and RSS feeds. Now with custom post type support!
6
+ Version: 3.5
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  Author URI: http://mitcho.com/
9
  Donate link: http://tinyurl.com/donatetomitcho
10
  */
11
 
12
+ define('YARPP_VERSION', '3.5');
13
  define('YARPP_DIR', dirname(__FILE__));
14
  define('YARPP_NO_RELATED', ':(');
15
  define('YARPP_RELATED', ':)');