Yet Another Related Posts Plugin (YARPP) - Version 5.11.0

Version Description

(08-February-2021) = * New: Adds native support for bbPress! Have you ever wanted a nifty Related Posts section on your bbPress topic pages, like the ones you've seen on forums like StackOverflow? It's now possible with YARPP Related Posts! * Enhancement: Updates to provided custom template examples * Enhancement: YARPP post metabox enhancements - adds "edit" and "view" hover options to each link, mimicking the main posts table * Enhancement: Add missing debug info * Bugfix: Avoid REST API warning by providing the page parameter which WP core expects * Deprecated: functions YARPP::maybe_enqueue_thumbnails() and YARPP::enqueue_thumbnails()

Download this release

Release Info

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

Code changes from version 5.10.2 to 5.11.0

classes/YARPP_Admin.php CHANGED
@@ -230,7 +230,7 @@ class YARPP_Admin {
230
  */
231
  if(!$this->core->yarppPro['active']){
232
  foreach ($metabox_post_types as $post_type) {
233
- $title = __('Related Posts' , 'yarpp');
234
  add_meta_box('yarpp_relatedposts',$title, array($this, 'metabox'), $post_type, 'normal');
235
  }
236
  }
230
  */
231
  if(!$this->core->yarppPro['active']){
232
  foreach ($metabox_post_types as $post_type) {
233
+ $title = __('YARPP: Related Posts' , 'yarpp');
234
  add_meta_box('yarpp_relatedposts',$title, array($this, 'metabox'), $post_type, 'normal');
235
  }
236
  }
classes/YARPP_Core.php CHANGED
@@ -92,9 +92,10 @@ class YARPP {
92
  $excerpt_rss_priority = apply_filters('yarpp_excerpt_rss_priority', 600);
93
 
94
  add_filter('the_content', array($this, 'the_content'), $content_priority);
 
95
  add_filter('the_content_feed', array($this, 'the_content_feed'), $feed_priority);
96
  add_filter('the_excerpt_rss', array($this, 'the_excerpt_rss' ), $excerpt_rss_priority);
97
- add_action('wp_enqueue_scripts', array($this, 'maybe_enqueue_thumbnails'));
98
 
99
  /**
100
  * If we're using thumbnails, register yarpp-thumbnail size, if theme has not already.
@@ -479,7 +480,16 @@ class YARPP {
479
  return $dimensions;
480
  }
481
 
482
- public function maybe_enqueue_thumbnails() {
 
 
 
 
 
 
 
 
 
483
  if (is_feed()) return;
484
 
485
  $auto_display_post_types = $this->get_option('auto_display_post_types');
@@ -491,10 +501,23 @@ class YARPP {
491
 
492
  if ($this->get_option('template') !== 'thumbnails') return;
493
 
494
- $this->enqueue_thumbnails($this->thumbnail_dimensions());
495
  }
496
 
 
 
 
 
 
497
  public function enqueue_thumbnails($dimensions) {
 
 
 
 
 
 
 
 
498
  $queryStr = http_build_query(
499
  array(
500
  'width' => $dimensions['width'],
@@ -871,6 +894,16 @@ class YARPP {
871
  }
872
 
873
  private function post_type_filter($post_type) {
 
 
 
 
 
 
 
 
 
 
874
  if ($post_type->public) return true;
875
  if (isset($post_type->yarpp_support)) return $post_type->yarpp_support;
876
  return false;
@@ -914,7 +947,7 @@ class YARPP {
914
  'rss_excerpt_length', 'past_only', 'show_excerpt', 'rss_show_excerpt',
915
  'template', 'rss_template', 'show_pass_post', 'cross_relate',
916
  'rss_display', 'rss_excerpt_display', 'promote_yarpp', 'rss_promote_yarpp',
917
- 'myisam_override', 'weight', 'require_tax', 'auto_display_archive'
918
  ));
919
 
920
  $check_changed = array(
@@ -1664,6 +1697,13 @@ class YARPP {
1664
  );
1665
  }
1666
 
 
 
 
 
 
 
 
1667
  /**
1668
  * Checks if it's an appropriate time to look for related posts, or if we should skip that.
1669
  *
92
  $excerpt_rss_priority = apply_filters('yarpp_excerpt_rss_priority', 600);
93
 
94
  add_filter('the_content', array($this, 'the_content'), $content_priority);
95
+ add_action('bbp_template_after_single_topic', array($this,'add_to_bbpress'));
96
  add_filter('the_content_feed', array($this, 'the_content_feed'), $feed_priority);
97
  add_filter('the_excerpt_rss', array($this, 'the_excerpt_rss' ), $excerpt_rss_priority);
98
+ add_action('wp_enqueue_scripts', array($this, 'maybe_enqueue_thumbnails_stylesheet'));
99
 
100
  /**
101
  * If we're using thumbnails, register yarpp-thumbnail size, if theme has not already.
480
  return $dimensions;
481
  }
482
 
483
+ /**
484
+ * @deprecated 5.11.0
485
+ * @see \YARPP::maybe_enqueue_thumbnails_stylesheet
486
+ */
487
+ public function maybe_enqueue_thumbnails(){
488
+ _deprecated_function('YARPP::maybe_enqueue_thumbnails','5.11.0','YARPP::maybe_enqueue_thumbnails_stylesheet');
489
+ return $this->maybe_enqueue_thumbnails_stylesheet();
490
+ }
491
+
492
+ public function maybe_enqueue_thumbnails_stylesheet() {
493
  if (is_feed()) return;
494
 
495
  $auto_display_post_types = $this->get_option('auto_display_post_types');
501
 
502
  if ($this->get_option('template') !== 'thumbnails') return;
503
 
504
+ $this->enqueue_thumbnails_stylesheet($this->thumbnail_dimensions());
505
  }
506
 
507
+ /**
508
+ * @deprecated 5.11.0
509
+ * @see YARPP::enqueue_thumbnails_stylesheet()
510
+ * @param $dimensions
511
+ */
512
  public function enqueue_thumbnails($dimensions) {
513
+ _deprecated_function('YARPP::enqueue_thumbnails','5.11.0','YARPP::enqueue_thumbnails_stylesheet');
514
+ return $this->enqueue_thumbnails_stylesheet($dimensions);
515
+ }
516
+
517
+ /**
518
+ * @param $dimensions
519
+ */
520
+ public function enqueue_thumbnails_stylesheet($dimensions) {
521
  $queryStr = http_build_query(
522
  array(
523
  'width' => $dimensions['width'],
894
  }
895
 
896
  private function post_type_filter($post_type) {
897
+ // Remove blacklisted post types.
898
+ if(class_exists( 'bbPress' ) && in_array(
899
+ $post_type->name,
900
+ array(
901
+ 'forum', // bbPress forums (ie, group of topics).
902
+ 'reply' // bbPress replies to topics
903
+ )
904
+ )){
905
+ return false;
906
+ }
907
  if ($post_type->public) return true;
908
  if (isset($post_type->yarpp_support)) return $post_type->yarpp_support;
909
  return false;
947
  'rss_excerpt_length', 'past_only', 'show_excerpt', 'rss_show_excerpt',
948
  'template', 'rss_template', 'show_pass_post', 'cross_relate',
949
  'rss_display', 'rss_excerpt_display', 'promote_yarpp', 'rss_promote_yarpp',
950
+ 'myisam_override', 'weight', 'require_tax', 'auto_display_archive', 'exclude'
951
  ));
952
 
953
  $check_changed = array(
1697
  );
1698
  }
1699
 
1700
+ /**
1701
+ * Adds YARPP's content to bbPress topics.
1702
+ */
1703
+ public function add_to_bbpress(){
1704
+ echo $this->display_basic();
1705
+ }
1706
+
1707
  /**
1708
  * Checks if it's an appropriate time to look for related posts, or if we should skip that.
1709
  *
classes/YARPP_Meta_Box.php CHANGED
@@ -10,7 +10,7 @@ class YARPP_Meta_Box {
10
  $this->template_text =
11
  __(
12
  "This advanced option gives you full power to customize how your related posts are displayed. ".
13
- "Templates (stored in your theme folder) are written in PHP.",
14
  'yarpp'
15
  );
16
  }
10
  $this->template_text =
11
  __(
12
  "This advanced option gives you full power to customize how your related posts are displayed. ".
13
+ "Templates are written in PHP and saved in your active theme's folder.",
14
  'yarpp'
15
  );
16
  }
classes/YARPP_Meta_Box_Display_Web.php CHANGED
@@ -16,9 +16,17 @@ class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
16
  echo "</div><div>";
17
  $post_types = yarpp_get_option( 'auto_display_post_types' );
18
  foreach ($yarpp->get_post_types('objects') as $post_type) {
 
 
 
 
 
 
 
 
19
  echo "<label for='yarpp_post_type_{$post_type->name}'><input id='yarpp_post_type_{$post_type->name}' name='auto_display_post_types[{$post_type->name}]' type='checkbox' ";
20
  checked( in_array( $post_type->name, $post_types ) );
21
- echo "/> {$post_type->labels->name}</label> ";
22
  }
23
  echo "</div></div>";
24
 
16
  echo "</div><div>";
17
  $post_types = yarpp_get_option( 'auto_display_post_types' );
18
  foreach ($yarpp->get_post_types('objects') as $post_type) {
19
+ $post_type_title = $post_type->labels->name;
20
+ // Clarify "topics" are from bbPress plugin
21
+ if($post_type->name == 'topic' && class_exists('bbPress')){
22
+ $post_type_title = sprintf(
23
+ __('BuddyPress %s', 'yarpp'),
24
+ $post_type_title
25
+ );
26
+ }
27
  echo "<label for='yarpp_post_type_{$post_type->name}'><input id='yarpp_post_type_{$post_type->name}' name='auto_display_post_types[{$post_type->name}]' type='checkbox' ";
28
  checked( in_array( $post_type->name, $post_types ) );
29
+ echo "/> {$post_type_title}</label> ";
30
  }
31
  echo "</div></div>";
32
 
classes/YARPP_Rest_Api.php CHANGED
@@ -175,7 +175,9 @@ class YARPP_Rest_Api extends WP_REST_Controller{
175
 
176
  $simulated_params = array(
177
  'include' => $ids,
178
- 'per_page' =>$query_params['limit']
 
 
179
  );
180
  if(isset($query_params['context'])){
181
  $simulated_params['context'] = $query_params['context'];
@@ -188,6 +190,9 @@ class YARPP_Rest_Api extends WP_REST_Controller{
188
  $read_controller_response = $read_controller->get_items($simulated_request);
189
  remove_action( 'rest_post_query', array($this, 'ignore_post_type_filter_callback'), 10, 2 );
190
 
 
 
 
191
  $read_controller_posts = $read_controller_response->get_data();
192
  $ordered_rest_results = array();
193
  // Reorder the posts in the response according to what they were in the YARPP response.
175
 
176
  $simulated_params = array(
177
  'include' => $ids,
178
+ 'per_page' =>$query_params['limit'],
179
+ // we only get one page at a time. WP page numbering starts at 1.
180
+ 'page' => 1
181
  );
182
  if(isset($query_params['context'])){
183
  $simulated_params['context'] = $query_params['context'];
190
  $read_controller_response = $read_controller->get_items($simulated_request);
191
  remove_action( 'rest_post_query', array($this, 'ignore_post_type_filter_callback'), 10, 2 );
192
 
193
+ if(is_wp_error($read_controller_response)){
194
+ return $read_controller_response;
195
+ }
196
  $read_controller_posts = $read_controller_response->get_data();
197
  $ordered_rest_results = array();
198
  // Reorder the posts in the response according to what they were in the YARPP response.
includes/template_metabox.php CHANGED
@@ -16,12 +16,13 @@ if ($yarpp->debug) {
16
  }
17
 
18
  if (have_posts()) {
19
- $output .= '<style>#yarpp-related-posts ol li { list-style-type: decimal; margin: 10px 0;} #yarpp-related-posts ol li a {text-decoration: none;}</style>';
20
  $output .= '<ol id="yarpp-list">';
21
  while (have_posts()) {
22
  the_post();
23
- $output .= "<li><a href='post.php?action=edit&post=" . get_the_ID() . "'>" . get_the_title() . "</a>";
24
  $output .= ' (' . round(get_the_score(),3) . ')';
 
25
  $output .= '</li>';
26
  }
27
  $output .= '</ol>';
@@ -30,4 +31,4 @@ if (have_posts()) {
30
  $output .= '<p><em>'.__('No related posts.','yarpp').'</em></p>';
31
  }
32
 
33
- $output .= '<p class="yarpp-metabox-options"><a href="' . esc_url(admin_url('options-general.php?page=yarpp')) . '" class="button-secondary">' . __('Configure Options', 'yarpp') . '</a> <a id="yarpp-refresh" href="#" class="button-secondary">' . __('Refresh', 'yarpp') . '</a><span class="spinner"></span></p>';
16
  }
17
 
18
  if (have_posts()) {
19
+ $output .= '<style>#yarpp-related-posts ol li { list-style-type: decimal; margin: 10px 0;} #yarpp-related-posts ol li a {text-decoration: none;} .yarpp-related-action {visibility: hidden;}</style>';
20
  $output .= '<ol id="yarpp-list">';
21
  while (have_posts()) {
22
  the_post();
23
+ $output .= "<li id='yarpp-related-". get_the_ID() . "'><a class='row-title' href='post.php?action=edit&post=" . get_the_ID() . "'>" . get_the_title() . "</a>";
24
  $output .= ' (' . round(get_the_score(),3) . ')';
25
+ $output .= " <span class='yarpp-related-action' id=yarpp-related-" . get_the_ID() . "-action'><span class='edit'><a href='post.php?action=edit&post=" . get_the_ID() . "'>" . __('Edit','yarpp') ."</a></span> | <span class='view'><a href='" . get_permalink() . "' target='_blank'>" . __('View', 'yarpp') . "</a></span></span>";
26
  $output .= '</li>';
27
  }
28
  $output .= '</ol>';
31
  $output .= '<p><em>'.__('No related posts.','yarpp').'</em></p>';
32
  }
33
 
34
+ $output .= '<p class="yarpp-metabox-options"><a href="' . esc_url(admin_url('options-general.php?page=yarpp')) . '" class="button-secondary">' . __('Configure Options', 'yarpp') . '</a> <a id="yarpp-refresh" href="#" class="button-secondary">' . __('Refresh', 'yarpp') . '</a><span class="spinner"></span></p>';
includes/template_thumbnails.php CHANGED
@@ -51,4 +51,4 @@ if (have_posts()) {
51
  $output .= $no_results;
52
  }
53
 
54
- $this->enqueue_thumbnails( $dimensions );
51
  $output .= $no_results;
52
  }
53
 
54
+ $this->enqueue_thumbnails_stylesheet( $dimensions );
js/metabox.js CHANGED
@@ -45,8 +45,19 @@ jQuery(document).ready(function($) {
45
  });
46
 
47
  /*
48
- * Metabox Refresh Button
49
  */
 
 
 
 
 
 
 
 
 
 
 
50
  $(document).on('click', '#yarpp-refresh', function(e) {
51
  e.preventDefault();
52
 
45
  });
46
 
47
  /*
48
+ * Metabox Actions
49
  */
50
+ $(document).on('touchstart mouseenter', '#yarpp-list li', function() {
51
+ $(this).children('.yarpp-related-action').css( 'visibility', 'visible' );
52
+ });
53
+
54
+ $(document).on('touchend mouseleave', '#yarpp-list li', function() {
55
+ $(this).children('.yarpp-related-action').css( 'visibility', 'hidden' );
56
+ });
57
+
58
+ /*
59
+ * Metabox Refresh Button
60
+ */
61
  $(document).on('click', '#yarpp-refresh', function(e) {
62
  e.preventDefault();
63
 
readme.txt CHANGED
@@ -4,8 +4,8 @@ Tags: related, related posts, similar posts, posts, pages, thumbnails, feeds, mu
4
  Requires at least: 3.7
5
  Requires PHP: 5.3
6
  License: GPLv2 or later
7
- Tested up to: 5.5
8
- Stable tag: 5.10.2
9
 
10
  The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
11
 
@@ -23,6 +23,7 @@ The most popular plugin to display a list of related posts on your site based on
23
  * **REST API support** - Embed related posts in your web or JavaScript driven app! ([documentation](https://support.shareaholic.com/hc/en-us/articles/360046456752))
24
  * **Shortcode support** - Use `[yarpp]` shortcode to place related posts anywhere ([documentation](https://wordpress.org/plugins/yet-another-related-posts-plugin/#%0Ahow%20can%20i%20move%20the%20related%20posts%20display%3F%0A))
25
  * **HTTPS support**
 
26
  * **WordPress Multisite support**
27
  * **Professionally maintained** and supported with regular updates
28
 
@@ -295,6 +296,14 @@ add_action(
295
  `
296
 
297
  == Changelog ==
 
 
 
 
 
 
 
 
298
  = 5.10.2 (23-November-2020) =
299
  * Enhancement: Faster queries and a speed boost ⚡️ (Re-introduces database query improvements while avoiding the fatal error identified by some in v5.10.0)
300
  * [Enhancement](https://wordpress.org/support/topic/yarpp-query-migrate-helper-warnings/): Speed up by not loading widget.css when not necessary
@@ -307,7 +316,7 @@ add_action(
307
  * [Critical Bugfix](https://wordpress.org/support/topic/version-5-10-0-generated-error-500/): Reverts query changes from the v5.10.0 update as it caused 500 fatal errors on some WordPress installations. We sincerely apologies for any issues it may have caused. We did test the release for weeks, but each environment is just a bit different. We are actively testing a bug fix with those affected that volunteered before we release it again.
308
 
309
  = 5.10.0 (22-October-2020) =
310
- * Enhancement: Faster queries and a speed boost ⚡️
311
  * [Enhancement](https://wordpress.org/support/topic/yarp-page-break/): On posts with page breaks, show YARPP only on the last page
312
  * Enhancement: [Documentation](https://wordpress.org/plugins/yet-another-related-posts-plugin/#installation) on how to use `[yarpp]` shortcode from a theme file (like single.php) or post content
313
  * Bugfix: If YARPP has already added its content to a post and somehow `apply_filters('the_content'...)` gets called again, don't try to re-add YARPP's content to the post again.
@@ -1051,5 +1060,5 @@ After a break of many years, the plugin is 100% supported now that the baton has
1051
  * Initial upload
1052
 
1053
  == Upgrade Notice ==
1054
- = 5.10.2 =
1055
  We update this plugin regularly so we can make it better for you. Update to the latest version for all of the available features and improvements. Thank you for using YARPP!
4
  Requires at least: 3.7
5
  Requires PHP: 5.3
6
  License: GPLv2 or later
7
+ Tested up to: 5.6
8
+ Stable tag: 5.11.0
9
 
10
  The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
11
 
23
  * **REST API support** - Embed related posts in your web or JavaScript driven app! ([documentation](https://support.shareaholic.com/hc/en-us/articles/360046456752))
24
  * **Shortcode support** - Use `[yarpp]` shortcode to place related posts anywhere ([documentation](https://wordpress.org/plugins/yet-another-related-posts-plugin/#%0Ahow%20can%20i%20move%20the%20related%20posts%20display%3F%0A))
25
  * **HTTPS support**
26
+ * **bbPress forums support**
27
  * **WordPress Multisite support**
28
  * **Professionally maintained** and supported with regular updates
29
 
296
  `
297
 
298
  == Changelog ==
299
+ = 5.11.0 (08-February-2021) =
300
+ * [New](https://wordpress.org/support/topic/why-related-topics-doesnt-show-up-under-topics-and-replies/): Adds native support for bbPress! Have you ever wanted a nifty Related Posts section on your bbPress topic pages, like the ones you've seen on forums like StackOverflow? It's now possible with YARPP Related Posts!
301
+ * Enhancement: Updates to provided custom template examples
302
+ * Enhancement: YARPP post metabox enhancements - adds "edit" and "view" hover options to each link, mimicking the main posts table
303
+ * Enhancement: Add missing debug info
304
+ * Bugfix: Avoid REST API warning by providing the page parameter which WP core expects
305
+ * Deprecated: functions YARPP::maybe_enqueue_thumbnails() and YARPP::enqueue_thumbnails()
306
+
307
  = 5.10.2 (23-November-2020) =
308
  * Enhancement: Faster queries and a speed boost ⚡️ (Re-introduces database query improvements while avoiding the fatal error identified by some in v5.10.0)
309
  * [Enhancement](https://wordpress.org/support/topic/yarpp-query-migrate-helper-warnings/): Speed up by not loading widget.css when not necessary
316
  * [Critical Bugfix](https://wordpress.org/support/topic/version-5-10-0-generated-error-500/): Reverts query changes from the v5.10.0 update as it caused 500 fatal errors on some WordPress installations. We sincerely apologies for any issues it may have caused. We did test the release for weeks, but each environment is just a bit different. We are actively testing a bug fix with those affected that volunteered before we release it again.
317
 
318
  = 5.10.0 (22-October-2020) =
319
+ * Enhancement: Faster queries and a speed boost
320
  * [Enhancement](https://wordpress.org/support/topic/yarp-page-break/): On posts with page breaks, show YARPP only on the last page
321
  * Enhancement: [Documentation](https://wordpress.org/plugins/yet-another-related-posts-plugin/#installation) on how to use `[yarpp]` shortcode from a theme file (like single.php) or post content
322
  * Bugfix: If YARPP has already added its content to a post and somehow `apply_filters('the_content'...)` gets called again, don't try to re-add YARPP's content to the post again.
1060
  * Initial upload
1061
 
1062
  == Upgrade Notice ==
1063
+ = 5.11.0 =
1064
  We update this plugin regularly so we can make it better for you. Update to the latest version for all of the available features and improvements. Thank you for using YARPP!
style/related.css CHANGED
@@ -2,19 +2,19 @@
2
  margin: 1em 0;
3
  }
4
 
5
- .yarpp-related a{
6
  text-decoration: none;
7
  font-weight: bold;
8
  }
9
 
10
- .yarpp-related .yarpp-thumbnail-title{
11
  text-align: left;
12
  font-weight: bold;
13
  font-size: 96%;
14
  text-decoration: none;
15
  }
16
 
17
- .yarpp-related h3{
18
  font-weight: bold;
19
  padding: 0 0 5px 0;
20
  font-size: 125%;
@@ -22,7 +22,7 @@
22
  margin: 0;
23
  }
24
 
25
- .yarpp-related .yarpp-promote{
26
  clear: both;
27
  background: url(//api.engage.bidsystem.com/adk_mini_logo.png) no-repeat;
28
  float: right;
2
  margin: 1em 0;
3
  }
4
 
5
+ .yarpp-related a {
6
  text-decoration: none;
7
  font-weight: bold;
8
  }
9
 
10
+ .yarpp-related .yarpp-thumbnail-title {
11
  text-align: left;
12
  font-weight: bold;
13
  font-size: 96%;
14
  text-decoration: none;
15
  }
16
 
17
+ .yarpp-related h3 {
18
  font-weight: bold;
19
  padding: 0 0 5px 0;
20
  font-size: 125%;
22
  margin: 0;
23
  }
24
 
25
+ .yarpp-related .yarpp-promote {
26
  clear: both;
27
  background: url(//api.engage.bidsystem.com/adk_mini_logo.png) no-repeat;
28
  float: right;
yarpp-templates/yarpp-template-example.php CHANGED
@@ -1,16 +1,41 @@
1
  <?php
2
  /*
3
- YARPP Template: Simple
 
4
  Author: YARPP Team
5
- Description: A simple example YARPP template.
6
  */
7
- ?><h3>Related Posts</h3>
8
- <?php if (have_posts()):?>
9
- <ol>
10
- <?php while (have_posts()) : the_post(); ?>
11
- <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a><!-- (<?php the_score(); ?>)--></li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  <?php endwhile; ?>
13
- </ol>
14
- <?php else: ?>
15
  <p>No related posts.</p>
16
  <?php endif; ?>
 
1
  <?php
2
  /*
3
+ YARPP Template: Starter Template
4
+ Description: A simple starter example template that you can edit.
5
  Author: YARPP Team
 
6
  */
7
+ ?>
8
+
9
+ <?php
10
+ /*
11
+ Templating in YARPP enables developers to uber-customize their YARPP display using PHP and template tags.
12
+
13
+ The tags we use in YARPP templates are the same as the template tags used in any WordPress template. In fact, any WordPress template tag will work in the YARPP Loop. You can use these template tags to display the excerpt, the post date, the comment count, or even some custom metadata. In addition, template tags from other plugins will also work.
14
+
15
+ If you've ever had to tweak or build a WordPress theme before, you’ll immediately feel at home.
16
+
17
+ // Special template tags which only work within a YARPP Loop:
18
+
19
+ 1. the_score() // this will print the YARPP match score of that particular related post
20
+ 2. get_the_score() // or return the YARPP match score of that particular related post
21
+
22
+ Notes:
23
+ 1. If you would like Pinterest not to save an image, add `data-pin-nopin="true"` to the img tag.
24
+
25
+ */
26
+ ?>
27
+
28
+ <h3>Related Posts</h3>
29
+ <?php if ( have_posts() ) : ?>
30
+ <ul>
31
+ <?php
32
+ while ( have_posts() ) :
33
+ the_post();
34
+ ?>
35
+ <li><a href="<?php the_permalink(); ?>" rel="bookmark norewrite" title="<?php the_title_attribute(); ?>" ><?php the_title(); ?></a><!-- (<?php the_score(); ?>)--></li>
36
  <?php endwhile; ?>
37
+ </ul>
38
+ <?php else : ?>
39
  <p>No related posts.</p>
40
  <?php endif; ?>
41
+
yarpp-templates/yarpp-template-list.php CHANGED
@@ -1,20 +1,43 @@
1
  <?php
2
  /*
3
  YARPP Template: List
4
- Description: This template returns the related posts as a comma-separated list.
5
  Author: YARPP Team
6
  */
7
- ?><h3>Related Posts</h3>
8
 
9
- <?php if (have_posts()):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  $postsArray = array();
11
- while (have_posts()) : the_post();
12
- $postsArray[] = '<a href="'.get_permalink().'" rel="bookmark">'.get_the_title().'</a><!-- ('.get_the_score().')-->';
 
13
  endwhile;
14
 
15
- echo implode(', '."\n",$postsArray); // print out a list of the related items, separated by commas
16
 
17
- else:?>
 
18
 
19
  <p>No related posts.</p>
20
  <?php endif; ?>
1
  <?php
2
  /*
3
  YARPP Template: List
4
+ Description: This template returns posts as a comma-separated list.
5
  Author: YARPP Team
6
  */
7
+ ?>
8
 
9
+ <?php
10
+ /*
11
+ Templating in YARPP enables developers to uber-customize their YARPP display using PHP and template tags.
12
+
13
+ The tags we use in YARPP templates are the same as the template tags used in any WordPress template. In fact, any WordPress template tag will work in the YARPP Loop. You can use these template tags to display the excerpt, the post date, the comment count, or even some custom metadata. In addition, template tags from other plugins will also work.
14
+
15
+ If you've ever had to tweak or build a WordPress theme before, you’ll immediately feel at home.
16
+
17
+ // Special template tags which only work within a YARPP Loop:
18
+
19
+ 1. the_score() // this will print the YARPP match score of that particular related post
20
+ 2. get_the_score() // or return the YARPP match score of that particular related post
21
+
22
+ Notes:
23
+ 1. If you would like Pinterest not to save an image, add `data-pin-nopin="true"` to the img tag.
24
+
25
+ */
26
+ ?>
27
+
28
+ <h3>Related Posts</h3>
29
+ <?php
30
+ if ( have_posts() ) :
31
  $postsArray = array();
32
+ while ( have_posts() ) :
33
+ the_post();
34
+ $postsArray[] = '<a href="' . get_permalink() . '" rel="bookmark norewrite" title="' . the_title_attribute( 'echo=0' ) . '">' . get_the_title() . '</a><!-- (' . get_the_score() . ')-->';
35
  endwhile;
36
 
37
+ echo implode( ', ' . "\n", $postsArray ); // print out a list of the related items, separated by commas
38
 
39
+ else :
40
+ ?>
41
 
42
  <p>No related posts.</p>
43
  <?php endif; ?>
yarpp-templates/yarpp-template-multilingual.php CHANGED
@@ -4,19 +4,45 @@ YARPP Template: Multilingual
4
  Description: An example template for use with the WPML and Polylang plugins
5
  Author: YARPP Team
6
  */
 
7
 
8
- if (function_exists("icl_register_string")) {
9
- icl_register_string("Yet Another Related Posts Plugin", "related posts header", "Related Posts");
10
- icl_register_string("Yet Another Related Posts Plugin", "no related posts message", "No related posts.");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
 
12
 
13
- ?><h3><?php echo (function_exists("icl_t") ? icl_t("Yet Another Related Posts Plugin", "related posts header", "Related Posts") : "Related Posts") ?></h3>
14
- <?php if (have_posts()):?>
15
  <ol>
16
- <?php while (have_posts()) : the_post(); ?>
17
- <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
 
 
 
18
  <?php endwhile; ?>
19
  </ol>
20
- <?php else: ?>
21
- <p><?php echo (function_exists("icl_t") ? icl_t("Yet Another Related Posts Plugin", "no related posts message", "No related posts.") : "No related posts.") ?></p>
 
22
  <?php endif; ?>
4
  Description: An example template for use with the WPML and Polylang plugins
5
  Author: YARPP Team
6
  */
7
+ ?>
8
 
9
+ <?php
10
+ /*
11
+ Templating in YARPP enables developers to uber-customize their YARPP display using PHP and template tags.
12
+
13
+ The tags we use in YARPP templates are the same as the template tags used in any WordPress template. In fact, any WordPress template tag will work in the YARPP Loop. You can use these template tags to display the excerpt, the post date, the comment count, or even some custom metadata. In addition, template tags from other plugins will also work.
14
+
15
+ If you've ever had to tweak or build a WordPress theme before, you’ll immediately feel at home.
16
+
17
+ // Special template tags which only work within a YARPP Loop:
18
+
19
+ 1. the_score() // this will print the YARPP match score of that particular related post
20
+ 2. get_the_score() // or return the YARPP match score of that particular related post
21
+
22
+ Notes:
23
+ 1. If you would like Pinterest not to save an image, add `data-pin-nopin="true"` to the img tag.
24
+
25
+ */
26
+ ?>
27
+
28
+ <?php
29
+ if ( function_exists( 'icl_register_string' ) ) {
30
+ icl_register_string( 'Yet Another Related Posts Plugin', 'related posts header', 'Related Posts' );
31
+ icl_register_string( 'Yet Another Related Posts Plugin', 'no related posts message', 'No related posts.' );
32
  }
33
+ ?>
34
 
35
+ <h3><?php echo ( function_exists( 'icl_t' ) ? icl_t( 'Yet Another Related Posts Plugin', 'related posts header', 'Related Posts' ) : 'Related Posts' ); ?></h3>
36
+ <?php if ( have_posts() ) : ?>
37
  <ol>
38
+ <?php
39
+ while ( have_posts() ) :
40
+ the_post();
41
+ ?>
42
+ <li><a href="<?php the_permalink(); ?>" rel="bookmark norewrite" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
43
  <?php endwhile; ?>
44
  </ol>
45
+ <?php else : ?>
46
+ <p><?php echo ( function_exists( 'icl_t' ) ? icl_t( 'Yet Another Related Posts Plugin', 'no related posts message', 'No related posts.' ) : 'No related posts.' ); ?></p>
47
+
48
  <?php endif; ?>
yarpp-templates/yarpp-template-random.php CHANGED
@@ -1,19 +1,45 @@
1
  <?php
2
  /*
3
- YARPP Template: Random
4
  Description: This template gives you a random other post in case there are no related posts
5
  Author: YARPP Team
6
- */ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  <h3>Related Posts</h3>
8
- <?php if (have_posts()):?>
9
  <ol>
10
- <?php while (have_posts()) : the_post(); ?>
11
- <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a><!-- (<?php the_score(); ?>)--></li>
 
 
 
12
  <?php endwhile; ?>
13
  </ol>
14
 
15
- <?php else:
16
- query_posts("orderby=rand&order=asc&limit=1");
17
- the_post();?>
18
- <p>No related posts were found, so here's a consolation prize: <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>.</p>
 
 
19
  <?php endif; ?>
1
  <?php
2
  /*
3
+ YARPP Template: Random Default
4
  Description: This template gives you a random other post in case there are no related posts
5
  Author: YARPP Team
6
+ */
7
+ ?>
8
+
9
+ <?php
10
+ /*
11
+ Templating in YARPP enables developers to uber-customize their YARPP display using PHP and template tags.
12
+
13
+ The tags we use in YARPP templates are the same as the template tags used in any WordPress template. In fact, any WordPress template tag will work in the YARPP Loop. You can use these template tags to display the excerpt, the post date, the comment count, or even some custom metadata. In addition, template tags from other plugins will also work.
14
+
15
+ If you've ever had to tweak or build a WordPress theme before, you’ll immediately feel at home.
16
+
17
+ // Special template tags which only work within a YARPP Loop:
18
+
19
+ 1. the_score() // this will print the YARPP match score of that particular related post
20
+ 2. get_the_score() // or return the YARPP match score of that particular related post
21
+
22
+ Notes:
23
+ 1. If you would like Pinterest not to save an image, add `data-pin-nopin="true"` to the img tag.
24
+
25
+ */
26
+ ?>
27
+
28
  <h3>Related Posts</h3>
29
+ <?php if ( have_posts() ) : ?>
30
  <ol>
31
+ <?php
32
+ while ( have_posts() ) :
33
+ the_post();
34
+ ?>
35
+ <li><a href="<?php the_permalink(); ?>" rel="bookmark norewrite" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a><!-- (<?php the_score(); ?>)--></li>
36
  <?php endwhile; ?>
37
  </ol>
38
 
39
+ <?php
40
+ else :
41
+ query_posts( 'orderby=rand&order=asc&limit=1' );
42
+ the_post();
43
+ ?>
44
+ <p>No related posts were found, so here's a consolation prize: <a href="<?php the_permalink(); ?>" rel="bookmark norewrite" title="<?php the_title_attribute(); ?>><?php the_title(); ?></a>.</p>
45
  <?php endif; ?>
yarpp-templates/yarpp-template-simple.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ YARPP Template: Simple List
4
+ Description: This template returns posts in an unordered list.
5
+ Author: YARPP Team
6
+ */
7
+ ?>
8
+
9
+ <?php
10
+ /*
11
+ Templating in YARPP enables developers to uber-customize their YARPP display using PHP and template tags.
12
+
13
+ The tags we use in YARPP templates are the same as the template tags used in any WordPress template. In fact, any WordPress template tag will work in the YARPP Loop. You can use these template tags to display the excerpt, the post date, the comment count, or even some custom metadata. In addition, template tags from other plugins will also work.
14
+
15
+ If you've ever had to tweak or build a WordPress theme before, you’ll immediately feel at home.
16
+
17
+ // Special template tags which only work within a YARPP Loop:
18
+
19
+ 1. the_score() // this will print the YARPP match score of that particular related post
20
+ 2. get_the_score() // or return the YARPP match score of that particular related post
21
+
22
+ Notes:
23
+ 1. If you would like Pinterest not to save an image, add `data-pin-nopin="true"` to the img tag.
24
+
25
+ */
26
+ ?>
27
+
28
+ <h3>Related Posts</h3>
29
+ <?php if ( have_posts() ) : ?>
30
+ <ul>
31
+ <?php
32
+ while ( have_posts() ) :
33
+ the_post();
34
+ ?>
35
+ <li><a href="<?php the_permalink(); ?>" rel="bookmark norewrite" title="<?php the_title_attribute(); ?>" ><?php the_title(); ?></a><!-- (<?php the_score(); ?>)--></li>
36
+ <?php endwhile; ?>
37
+ </ul>
38
+ <?php else : ?>
39
+ <p>No related posts.</p>
40
+ <?php endif; ?>
yarpp-templates/yarpp-template-thumbnail.php CHANGED
@@ -1,19 +1,53 @@
1
  <?php
2
  /*
3
  YARPP Template: Thumbnails
4
- Description: Requires a theme which supports post thumbnails
5
  Author: YARPP Team
6
- */ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  <h3>Related Photos</h3>
8
- <?php if (have_posts()):?>
9
- <ol>
10
- <?php while (have_posts()) : the_post(); ?>
11
- <?php if (has_post_thumbnail()):?>
12
- <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a></li>
 
 
 
13
  <?php endif; ?>
14
  <?php endwhile; ?>
15
- </ol>
16
 
17
- <?php else: ?>
18
  <p>No related photos.</p>
19
  <?php endif; ?>
1
  <?php
2
  /*
3
  YARPP Template: Thumbnails
4
+ Description: This template returns the related posts as thumbnails in an ordered list. Requires a theme which supports post thumbnails.
5
  Author: YARPP Team
6
+ */
7
+ ?>
8
+
9
+ <?php
10
+ /*
11
+ Templating in YARPP enables developers to uber-customize their YARPP display using PHP and template tags.
12
+
13
+ The tags we use in YARPP templates are the same as the template tags used in any WordPress template. In fact, any WordPress template tag will work in the YARPP Loop. You can use these template tags to display the excerpt, the post date, the comment count, or even some custom metadata. In addition, template tags from other plugins will also work.
14
+
15
+ If you've ever had to tweak or build a WordPress theme before, you’ll immediately feel at home.
16
+
17
+ // Special template tags which only work within a YARPP Loop:
18
+
19
+ 1. the_score() // this will print the YARPP match score of that particular related post
20
+ 2. get_the_score() // or return the YARPP match score of that particular related post
21
+
22
+ Notes:
23
+ 1. If you would like Pinterest not to save an image, add `data-pin-nopin="true"` to the img tag.
24
+
25
+ */
26
+ ?>
27
+
28
+ <?php
29
+ /* Pick Thumbnail */
30
+ global $_wp_additional_image_sizes;
31
+ if ( isset( $_wp_additional_image_sizes['yarpp-thumbnail'] ) ) {
32
+ $dimensions['size'] = 'yarpp-thumbnail';
33
+ } else {
34
+ $dimensions['size'] = 'medium'; // default
35
+ }
36
+ ?>
37
+
38
  <h3>Related Photos</h3>
39
+ <?php if ( have_posts() ) : ?>
40
+ <ul>
41
+ <?php
42
+ while ( have_posts() ) :
43
+ the_post();
44
+ ?>
45
+ <?php if ( has_post_thumbnail() ) : ?>
46
+ <li><a href="<?php the_permalink(); ?>" rel="bookmark norewrite" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( $dimensions['size'], array( 'data-pin-nopin' => 'true' ) ); ?></a></li>
47
  <?php endif; ?>
48
  <?php endwhile; ?>
49
+ </ul>
50
 
51
+ <?php else : ?>
52
  <p>No related photos.</p>
53
  <?php endif; ?>
yarpp.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Yet Another Related Posts Plugin (YARPP)
4
  Description: Adds related posts to your site and in RSS feeds, based on a powerful, customizable algorithm.
5
- Version: 5.10.2
6
  Author: YARPP
7
  Author URI: https://yarpp.com/
8
  Plugin URI: https://yarpp.com/
@@ -23,7 +23,7 @@ if(!defined('WP_CONTENT_DIR')){
23
  define('WP_CONTENT_DIR', substr($tr,0,strrpos($tr,'/')));
24
  }
25
 
26
- define('YARPP_VERSION', '5.10.2');
27
 
28
  define('YARPP_DIR', dirname(__FILE__));
29
  /**
2
  /*
3
  Plugin Name: Yet Another Related Posts Plugin (YARPP)
4
  Description: Adds related posts to your site and in RSS feeds, based on a powerful, customizable algorithm.
5
+ Version: 5.11.0
6
  Author: YARPP
7
  Author URI: https://yarpp.com/
8
  Plugin URI: https://yarpp.com/
23
  define('WP_CONTENT_DIR', substr($tr,0,strrpos($tr,'/')));
24
  }
25
 
26
+ define('YARPP_VERSION', '5.11.0');
27
 
28
  define('YARPP_DIR', dirname(__FILE__));
29
  /**