Yet Another Related Posts Plugin (YARPP) - Version 5.10.0

Version Description

(22-October-2020) = * Enhancement: Faster queries and a speed boost * Enhancement: On posts with page breaks, show YARPP only on the last page * Enhancement: Documentation on how to use [yarpp] shortcode from a theme file (like single.php) or post content * 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. * Bugfix: Fixes showing/hiding excerpt options when checking excerpt checkboxes * Bugfix: Fixes "role" in deactivation survey * Bugfix: Fixes PHP warning on options page * Bugfix: Resolves jQuery Migrate Helper warnings

Download this release

Release Info

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

Code changes from version 5.9.0 to 5.10.0

classes/YARPP_Cache.php CHANGED
@@ -1,7 +1,18 @@
1
  <?php
2
  abstract class YARPP_Cache {
3
  protected $core;
 
 
 
 
4
  protected $yarpp_time = false;
 
 
 
 
 
 
 
5
  public $score_override = false;
6
  public $online_limit = false;
7
  public $last_sql;
@@ -191,7 +202,7 @@ abstract class YARPP_Cache {
191
  }
192
  }
193
 
194
- $newsql .= ',1) as score';
195
 
196
  $newsql .= "\n from $wpdb->posts \n";
197
 
@@ -350,16 +361,16 @@ abstract class YARPP_Cache {
350
  return apply_filters('yarpp_title_keywords', $this->extract_keywords(get_the_title($ID), $max, $ID), $max, $ID);
351
  }
352
  protected function body_keywords( $ID, $max = 20 ) {
353
- global $wp_current_filter;
354
- $filter_count = array_count_values( $wp_current_filter );
355
- if ( ! empty( $filter_count['the_content'] ) && $filter_count['the_content'] > 1 ) {
356
- return '';
357
- }
358
  $post = get_post( $ID );
359
  if ( empty( $post ) ) {
360
  return '';
361
  }
362
- return apply_filters( 'yarpp_body_keywords', $this->extract_keywords( apply_filters( 'the_content', $post->post_content ), $max, $ID ), $max, $ID );
 
 
 
 
 
363
  }
364
 
365
  private function extract_keywords( $html, $max = 20, $ID = 0 ) {
@@ -453,4 +464,13 @@ abstract class YARPP_Cache {
453
  $types = array_slice($types, 0, $max);
454
  return implode(' ', $types);
455
  }
 
 
 
 
 
 
 
 
 
456
  }
1
  <?php
2
  abstract class YARPP_Cache {
3
  protected $core;
4
+ /**
5
+ * During "YARPP Time", we add a bunch of filters to modify WP_Query
6
+ * @var bool
7
+ */
8
  protected $yarpp_time = false;
9
+
10
+ /**
11
+ * Keep track of when we're calculating, so YARPP core can know when to back off from initiating calculating
12
+ * related again.
13
+ * @var bool
14
+ */
15
+ protected $discovering_keywords = false;
16
  public $score_override = false;
17
  public $online_limit = false;
18
  public $last_sql;
202
  }
203
  }
204
 
205
+ $newsql .= ',4) as score';
206
 
207
  $newsql .= "\n from $wpdb->posts \n";
208
 
361
  return apply_filters('yarpp_title_keywords', $this->extract_keywords(get_the_title($ID), $max, $ID), $max, $ID);
362
  }
363
  protected function body_keywords( $ID, $max = 20 ) {
 
 
 
 
 
364
  $post = get_post( $ID );
365
  if ( empty( $post ) ) {
366
  return '';
367
  }
368
+ $this->discovering_keywords = true;
369
+ $body_content = apply_filters( 'the_content', $post->post_content );
370
+ $this->discovering_keywords = false;
371
+ $keywords = apply_filters( 'yarpp_body_keywords', $this->extract_keywords( $body_content, $max, $ID ), $max, $ID );
372
+
373
+ return $keywords;
374
  }
375
 
376
  private function extract_keywords( $html, $max = 20, $ID = 0 ) {
464
  $types = array_slice($types, 0, $max);
465
  return implode(' ', $types);
466
  }
467
+
468
+ /**
469
+ * Returns whether or not we're currently discovering the keywords on a reference post.
470
+ * (This is a very bad time to start looking for related posts! So YARPP core should be able to detect this.)
471
+ * @return bool
472
+ */
473
+ public function discovering_keywords(){
474
+ return $this->discovering_keywords;
475
+ }
476
  }
classes/YARPP_Cache_Bypass.php CHANGED
@@ -55,9 +55,21 @@ class YARPP_Cache_Bypass extends YARPP_Cache {
55
  /*
56
  * Only order by score if the score function is added in fields_filter,
57
  * which only happens if there are related posts in the post-data.
 
 
58
  */
59
  if ($this->score_override && is_array($this->related_postdata) && count($this->related_postdata)) {
60
- return str_replace("$wpdb->posts.post_date","score",$arg);
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
  return $arg;
55
  /*
56
  * Only order by score if the score function is added in fields_filter,
57
  * which only happens if there are related posts in the post-data.
58
+ * If ordering by score also order by post ID to keep them consistent in cases where the score is the same
59
+ * for multiple posts.
60
  */
61
  if ($this->score_override && is_array($this->related_postdata) && count($this->related_postdata)) {
62
+ return str_replace(
63
+ array(
64
+ "$wpdb->posts.post_date ASC",
65
+ "$wpdb->posts.post_date DESC"
66
+ ),
67
+ array(
68
+ "score ASC, yarpp.ID ASC",
69
+ "score DESC, yarpp.ID ASC"
70
+ ),
71
+ $arg
72
+ );
73
  }
74
 
75
  return $arg;
classes/YARPP_Cache_Postmeta.php CHANGED
@@ -78,11 +78,25 @@ class YARPP_Cache_Postmeta extends YARPP_Cache {
78
 
79
  public function orderby_filter($arg) {
80
  global $wpdb;
81
- // only order by score if the score function is added in fields_filter, which only happens
82
- // if there are related posts in the postdata
 
 
 
 
83
  if ($this->score_override &&
84
  is_array($this->related_postdata) && count($this->related_postdata))
85
- return str_replace("$wpdb->posts.post_date","score",$arg);
 
 
 
 
 
 
 
 
 
 
86
  return $arg;
87
  }
88
 
78
 
79
  public function orderby_filter($arg) {
80
  global $wpdb;
81
+ /*
82
+ * Only order by score if the score function is added in fields_filter,
83
+ * which only happens if there are related posts in the post-data.
84
+ * If ordering by score also order by post ID to keep them consistent in cases where the score is the same
85
+ * for multiple posts.
86
+ */
87
  if ($this->score_override &&
88
  is_array($this->related_postdata) && count($this->related_postdata))
89
+ return str_replace(
90
+ array(
91
+ "$wpdb->posts.post_date ASC",
92
+ "$wpdb->posts.post_date DESC"
93
+ ),
94
+ array(
95
+ "score ASC, yarpp.ID ASC",
96
+ "score DESC, yarpp.ID ASC"
97
+ ),
98
+ $arg
99
+ );
100
  return $arg;
101
  }
102
 
classes/YARPP_Cache_Tables.php CHANGED
@@ -134,8 +134,20 @@ class YARPP_Cache_Tables extends YARPP_Cache {
134
 
135
  public function orderby_filter($arg) {
136
  global $wpdb;
 
 
137
  if ($this->yarpp_time and $this->score_override)
138
- $arg = str_replace("$wpdb->posts.post_date","yarpp.score",$arg);
 
 
 
 
 
 
 
 
 
 
139
  return $arg;
140
  }
141
 
134
 
135
  public function orderby_filter($arg) {
136
  global $wpdb;
137
+ // If ordering by score also order by post ID to keep them consistent in cases where the score is the same
138
+ // for multiple posts.
139
  if ($this->yarpp_time and $this->score_override)
140
+ $arg = str_replace(
141
+ array(
142
+ "$wpdb->posts.post_date ASC",
143
+ "$wpdb->posts.post_date DESC"
144
+ ),
145
+ array(
146
+ "score ASC, yarpp.ID ASC",
147
+ "score DESC, yarpp.ID ASC"
148
+ ),
149
+ $arg
150
+ );
151
  return $arg;
152
  }
153
 
classes/YARPP_Core.php CHANGED
@@ -15,7 +15,13 @@ class YARPP {
15
  public $default_hidden_metaboxes = array();
16
  public $debug = false;
17
  public $yarppPro = null;
 
 
 
18
  public $cache_bypass;
 
 
 
19
  public $cache;
20
  public $admin;
21
  /**
@@ -23,6 +29,9 @@ class YARPP {
23
  */
24
  public $db_schema;
25
 
 
 
 
26
  private $active_cache;
27
  private $storage_class;
28
  private $default_dimensions = array(
@@ -855,7 +864,7 @@ class YARPP {
855
 
856
  return wp_list_pluck( $this->post_types, $field );
857
  }
858
-
859
  private function post_type_filter($post_type) {
860
  if ($post_type->public) return true;
861
  if (isset($post_type->yarpp_support)) return $post_type->yarpp_support;
@@ -1022,6 +1031,11 @@ class YARPP {
1022
  if (!is_singular() && !($this->get_option('auto_display_archive') && (is_archive() || is_home()))) {
1023
  return null;
1024
  }
 
 
 
 
 
1025
 
1026
  if ($this->get_option('cross_relate')) {
1027
  $post_types = $this->get_post_types();
@@ -1074,10 +1088,12 @@ class YARPP {
1074
  * @return string
1075
  */
1076
  public function display_related($reference_ID = null, $args = array(), $echo = true) {
1077
-
1078
- /* If we're already in a YARPP loop, stop now. */
1079
- if ($this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time()) return false;
 
1080
  $this->enforce();
 
1081
  wp_enqueue_style('yarppRelatedCss', plugins_url('/style/related.css', YARPP_MAIN_FILE));
1082
  $output = null;
1083
 
@@ -1106,7 +1122,9 @@ class YARPP {
1106
  extract($this->parse_args($args, $options));
1107
 
1108
  $cache_status = $this->active_cache->enforce($reference_ID);
1109
- if ($cache_status === YARPP_DONT_RUN) return;
 
 
1110
  if ($cache_status !== YARPP_NO_RELATED) $this->active_cache->begin_yarpp_time($reference_ID, $args);
1111
 
1112
  $this->save_post_context();
@@ -1201,10 +1219,12 @@ class YARPP {
1201
  * @param (array) $args
1202
  */
1203
  public function get_related($reference_ID = null, $args = array()) {
1204
- /* If we're already in a YARPP loop, stop now. */
1205
- if ($this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time()) return false;
 
1206
  $this->enforce();
1207
 
 
1208
  if (is_numeric($reference_ID)) {
1209
  $reference_ID = (int) $reference_ID;
1210
  } else {
@@ -1222,7 +1242,9 @@ class YARPP {
1222
  extract($this->parse_args($args, $options));
1223
 
1224
  $cache_status = $this->active_cache->enforce($reference_ID);
1225
- if ($cache_status === YARPP_DONT_RUN || $cache_status === YARPP_NO_RELATED) return array();
 
 
1226
 
1227
  /* Get ready for YARPP TIME! */
1228
  $this->active_cache->begin_yarpp_time($reference_ID, $args);
@@ -1239,16 +1261,15 @@ class YARPP {
1239
 
1240
  $related_query->posts = apply_filters(
1241
  'yarpp_results',
1242
- $related_query->posts,
1243
- array(
1244
- 'function' => 'get_related',
1245
  'args' => $args,
1246
  'related_ID' => $reference_ID
1247
  )
1248
  );
1249
 
1250
  $this->active_cache->end_yarpp_time();
1251
-
1252
  return $related_query->posts;
1253
  }
1254
 
@@ -1257,9 +1278,9 @@ class YARPP {
1257
  * @param (array) $args
1258
  */
1259
  public function related_exist($reference_ID = null, $args = array()) {
1260
- /* if we're already in a YARPP loop, stop now. */
1261
- if ($this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time()) return false;
1262
-
1263
  $this->enforce();
1264
 
1265
  if (is_numeric($reference_ID)) {
@@ -1275,7 +1296,9 @@ class YARPP {
1275
 
1276
  $cache_status = $this->active_cache->enforce($reference_ID);
1277
 
1278
- if ($cache_status === YARPP_NO_RELATED) return false;
 
 
1279
 
1280
  /* Get ready for YARPP TIME! */
1281
  $this->active_cache->begin_yarpp_time($reference_ID, $args);
@@ -1300,7 +1323,6 @@ class YARPP {
1300
  unset($related_query);
1301
 
1302
  $this->active_cache->end_yarpp_time();
1303
-
1304
  return $return;
1305
  }
1306
 
@@ -1310,7 +1332,8 @@ class YARPP {
1310
  * @return string
1311
  */
1312
  public function display_demo_related($args = array(), $echo = true) {
1313
- /* if we're already in a demo YARPP loop, stop now. */
 
1314
  if ($this->cache_bypass->demo_time) return false;
1315
 
1316
  $options = array(
@@ -1461,15 +1484,15 @@ class YARPP {
1461
  */
1462
 
1463
  public function the_content($content) {
1464
- /* this filter doesn't handle feeds */
1465
- if (is_feed()) return $content;
 
1466
 
1467
  /* If the content includes <!--noyarpp-->, don't display */
1468
  if (!stristr($content, '<!--noyarpp-->')) {
1469
  $content .= $this->display_basic();
1470
  $content .= $this->display_pro('website');
1471
  }
1472
-
1473
  return $content;
1474
  }
1475
 
@@ -1624,7 +1647,7 @@ class YARPP {
1624
  return $text;
1625
  }
1626
 
1627
- /**
1628
  * Gets the list of valid interval units used by YARPP and MySQL interval statements.
1629
  *
1630
  * @return array keys are valid values for recent units, and for MySQL interval
@@ -1637,4 +1660,13 @@ class YARPP {
1637
  'month' => __('month(s)','yarpp')
1638
  );
1639
  }
 
 
 
 
 
 
 
 
 
1640
  }
15
  public $default_hidden_metaboxes = array();
16
  public $debug = false;
17
  public $yarppPro = null;
18
+ /**
19
+ * @var YARPP_Cache_Bypass
20
+ */
21
  public $cache_bypass;
22
+ /**
23
+ * @var YARPP_Cache
24
+ */
25
  public $cache;
26
  public $admin;
27
  /**
29
  */
30
  public $db_schema;
31
 
32
+ /**
33
+ * @var YARPP_Cache
34
+ */
35
  private $active_cache;
36
  private $storage_class;
37
  private $default_dimensions = array(
864
 
865
  return wp_list_pluck( $this->post_types, $field );
866
  }
867
+
868
  private function post_type_filter($post_type) {
869
  if ($post_type->public) return true;
870
  if (isset($post_type->yarpp_support)) return $post_type->yarpp_support;
1031
  if (!is_singular() && !($this->get_option('auto_display_archive') && (is_archive() || is_home()))) {
1032
  return null;
1033
  }
1034
+ // If we're only viewing a single post with page breaks, only show YARPP its the last page.
1035
+ global $page, $pages;
1036
+ if(is_singular() && is_int($page) && is_array($pages) && $page < count($pages)){
1037
+ return null;
1038
+ }
1039
 
1040
  if ($this->get_option('cross_relate')) {
1041
  $post_types = $this->get_post_types();
1088
  * @return string
1089
  */
1090
  public function display_related($reference_ID = null, $args = array(), $echo = true) {
1091
+
1092
+ // If YARPP cache is already finding the current post's content, don't ask it to do it again.
1093
+ // Avoid infinite recursion here.
1094
+ if ( $this->active_cache_busy()) return false;
1095
  $this->enforce();
1096
+
1097
  wp_enqueue_style('yarppRelatedCss', plugins_url('/style/related.css', YARPP_MAIN_FILE));
1098
  $output = null;
1099
 
1122
  extract($this->parse_args($args, $options));
1123
 
1124
  $cache_status = $this->active_cache->enforce($reference_ID);
1125
+ if ($cache_status === YARPP_DONT_RUN){
1126
+ return;
1127
+ }
1128
  if ($cache_status !== YARPP_NO_RELATED) $this->active_cache->begin_yarpp_time($reference_ID, $args);
1129
 
1130
  $this->save_post_context();
1219
  * @param (array) $args
1220
  */
1221
  public function get_related($reference_ID = null, $args = array()) {
1222
+ // If YARPP cache is already finding the current post's content, don't ask it to do it again.
1223
+ // Avoid infinite recursion here.
1224
+ if ( $this->active_cache_busy()) return false;
1225
  $this->enforce();
1226
 
1227
+
1228
  if (is_numeric($reference_ID)) {
1229
  $reference_ID = (int) $reference_ID;
1230
  } else {
1242
  extract($this->parse_args($args, $options));
1243
 
1244
  $cache_status = $this->active_cache->enforce($reference_ID);
1245
+ if ($cache_status === YARPP_DONT_RUN || $cache_status === YARPP_NO_RELATED) {
1246
+ return array();
1247
+ }
1248
 
1249
  /* Get ready for YARPP TIME! */
1250
  $this->active_cache->begin_yarpp_time($reference_ID, $args);
1261
 
1262
  $related_query->posts = apply_filters(
1263
  'yarpp_results',
1264
+ $related_query->posts, array(
1265
+
1266
+ 'function' => 'get_related',
1267
  'args' => $args,
1268
  'related_ID' => $reference_ID
1269
  )
1270
  );
1271
 
1272
  $this->active_cache->end_yarpp_time();
 
1273
  return $related_query->posts;
1274
  }
1275
 
1278
  * @param (array) $args
1279
  */
1280
  public function related_exist($reference_ID = null, $args = array()) {
1281
+ // If YARPP cache is already finding the current post's content, don't ask it to do it again.
1282
+ // Avoid infinite recursion here.
1283
+ if ($this->active_cache_busy()) return false;
1284
  $this->enforce();
1285
 
1286
  if (is_numeric($reference_ID)) {
1296
 
1297
  $cache_status = $this->active_cache->enforce($reference_ID);
1298
 
1299
+ if ($cache_status === YARPP_NO_RELATED) {
1300
+ return false;
1301
+ }
1302
 
1303
  /* Get ready for YARPP TIME! */
1304
  $this->active_cache->begin_yarpp_time($reference_ID, $args);
1323
  unset($related_query);
1324
 
1325
  $this->active_cache->end_yarpp_time();
 
1326
  return $return;
1327
  }
1328
 
1332
  * @return string
1333
  */
1334
  public function display_demo_related($args = array(), $echo = true) {
1335
+ // If YARPP cache is already finding the current post's content, don't ask it to do it again.
1336
+ // Avoid infinite recursion here.
1337
  if ($this->cache_bypass->demo_time) return false;
1338
 
1339
  $options = array(
1484
  */
1485
 
1486
  public function the_content($content) {
1487
+ // If the cache is currently finding a post's keywords, don't start adding YARPP related posts to it. That's
1488
+ // unnecessarily recursion.
1489
+ if (is_feed() || $this->active_cache_busy()) return $content;
1490
 
1491
  /* If the content includes <!--noyarpp-->, don't display */
1492
  if (!stristr($content, '<!--noyarpp-->')) {
1493
  $content .= $this->display_basic();
1494
  $content .= $this->display_pro('website');
1495
  }
 
1496
  return $content;
1497
  }
1498
 
1647
  return $text;
1648
  }
1649
 
1650
+ /*
1651
  * Gets the list of valid interval units used by YARPP and MySQL interval statements.
1652
  *
1653
  * @return array keys are valid values for recent units, and for MySQL interval
1660
  'month' => __('month(s)','yarpp')
1661
  );
1662
  }
1663
+
1664
+ /**
1665
+ * Detects if the active cache is currently discovering post keywords. If so, it's a bad time
1666
+ * to start calculating related posts yet again.
1667
+ * @return bool
1668
+ */
1669
+ protected function active_cache_busy(){
1670
+ return $this->active_cache instanceof YARPP_Cache && $this->active_cache->discovering_keywords();
1671
+ }
1672
  }
includes/yarpp_options.php CHANGED
@@ -30,7 +30,7 @@ if (current_user_can('update_plugins')) {
30
  $slug = 'yet-another-related-posts-plugin';
31
  $plugin_name = 'Yet Another Related Posts Plugin';
32
  $file = basename(YARPP_DIR).'/yarpp.php';
33
- if ($yarpp_version_info['result'] === 'new') {
34
 
35
  /* Make sure the update system is aware of this version. */
36
  $current = get_site_transient('update_plugins');
30
  $slug = 'yet-another-related-posts-plugin';
31
  $plugin_name = 'Yet Another Related Posts Plugin';
32
  $file = basename(YARPP_DIR).'/yarpp.php';
33
+ if ($yarpp_version_info && isset($yarpp_version_info['result']) && $yarpp_version_info['result'] === 'new') {
34
 
35
  /* Make sure the update system is aware of this version. */
36
  $current = get_site_transient('update_plugins');
js/options_basic.js CHANGED
@@ -25,7 +25,7 @@ jQuery(function($) {
25
  function excerpt() {
26
  var metabox = $(this).closest('#yarpp_display_web, #yarpp_display_rss');
27
  metabox.find('.excerpted').toggle(
28
- !!(metabox.find('.use_template').val() === 'builtin' && metabox.find('.show_excerpt input').attr('checked'))
29
  );
30
  }
31
  $('.show_excerpt, .use_template, #yarpp-rss_display').click(excerpt);
25
  function excerpt() {
26
  var metabox = $(this).closest('#yarpp_display_web, #yarpp_display_rss');
27
  metabox.find('.excerpted').toggle(
28
+ !!(metabox.find('.use_template').val() === 'builtin' && metabox.find('.show_excerpt input').prop('checked'))
29
  );
30
  }
31
  $('.show_excerpt, .use_template, #yarpp-rss_display').click(excerpt);
lib/plugin-deactivation-survey/deactivate-feedback-form.php CHANGED
@@ -60,8 +60,10 @@ if ( ! function_exists( 'shareaholic_deactivate_feedback' ) ) {
60
  $current_user = wp_get_current_user();
61
  if ( $current_user instanceof WP_User && is_user_logged_in() && $current_user->ID ) {
62
  $email = $current_user->user_email;
63
- if ( $current_user->roles[0] ) {
64
- $role = $current_user->roles[0];
 
 
65
  }
66
  } else {
67
  $email = '';
60
  $current_user = wp_get_current_user();
61
  if ( $current_user instanceof WP_User && is_user_logged_in() && $current_user->ID ) {
62
  $email = $current_user->user_email;
63
+ if ( is_array($current_user->roles) ) {
64
+ $role = reset($current_user->roles);
65
+ } else {
66
+ $role = '';
67
  }
68
  } else {
69
  $email = '';
readme.txt CHANGED
@@ -5,7 +5,7 @@ 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.9.0
9
 
10
  The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
11
 
@@ -67,10 +67,22 @@ YARPP adds a REST API endpoint for fetching related posts. The JSON results from
67
 
68
  = Shortcode =
69
 
70
- You can place YARPP manually wherever you’d like in your theme within [The Loop](http://codex.wordpress.org/The_Loop) where you want to display the related posts. Simply insert the following shortcode:
 
 
71
 
72
  `[yarpp]` to show content related to the current post
73
- `[yarpp reference_id=123]` to show content related to post 123 (can be used either inside or outside the loop from theme code)
 
 
 
 
 
 
 
 
 
 
74
 
75
  == Frequently Asked Questions ==
76
 
@@ -84,7 +96,7 @@ Most likely you have "no related posts" right now because the default "match thr
84
 
85
  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" options 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."
86
 
87
- If you would like to add the Related Posts display elsewhere, edit your relevant theme file (most likely something like `single.php`) and add the shortcode code `[yarpp]` (recommended) or PHP function `related_posts();` within [The Loop](http://codex.wordpress.org/The_Loop) where you want to display the related posts. Make sure you don't add `echo related_posts();` or you may end up with duplicates in your related posts section.
88
 
89
  = How can I limit related posts to a certain time frame? For instance, I don't want to show posts from two years ago. =
90
 
@@ -147,7 +159,7 @@ YARPP's thumbnail view requires that a WordPress "featured image" be set for eac
147
 
148
  = How can I use the custom template feature? =
149
 
150
- YARPP's custom templates feature 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.
151
 
152
  = Is YARPP compatible with WordPress Multisite? =
153
 
@@ -283,6 +295,16 @@ add_action(
283
  `
284
 
285
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
286
  = 5.9.0 (21-September-2020) =
287
  * Enhancement: Clarify that "Also display in archives" includes front page and category pages
288
  * Enhancement: `reference_id` parameter support for the YARPP shortcode. For example: `[yarpp reference_id=123]` to show content related to Post ID 123 (can be used either inside or outside the loop from theme code)
@@ -292,7 +314,6 @@ add_action(
292
  = 5.8.0 (08-September-2020) =
293
  * Enhancement: Code hygiene upgrade with usage of `WPDB->prepare` everywhere possible and related improvements
294
  * [Bugfix](https://wordpress.org/support/topic/i-need-to-ad-yarpp-to-my-sidebar-but-it-wont-let-me-upgrade-to-pro/): Since there is no YARPP Pro currently, removed mention of it from the widget form
295
- * [Bugfix](https://wordpress.org/support/topic/bug-fix-for-role-related-code/): Fixes "role" in deactivation survey
296
 
297
  = 5.7.0 (18-August-2020) =
298
  * Enhancement: Ensure that when a post is finally published, YARPP cache for peer posts is cleared to ensure the most related posts are always recommended across every post
@@ -1019,6 +1040,5 @@ After a break of many years, the plugin is 100% supported now that the baton has
1019
  * Initial upload
1020
 
1021
  == Upgrade Notice ==
1022
- = 5.9.0 =
1023
  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!
1024
-
5
  Requires PHP: 5.3
6
  License: GPLv2 or later
7
  Tested up to: 5.5
8
+ Stable tag: 5.10.0
9
 
10
  The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
11
 
67
 
68
  = Shortcode =
69
 
70
+ You can place YARPP's related posts manually wherever you’d like in post content or theme files.
71
+
72
+ To add to post content, use the shortcode:
73
 
74
  `[yarpp]` to show content related to the current post
75
+
76
+ If you know the reference Post ID that you want to show content related to, use:
77
+
78
+ `[yarpp reference_id=123]` to show content related to post 123
79
+
80
+ The add YARRP related posts to your theme files (eg. single.php), we recommend using:
81
+
82
+ `<?php echo do_shortcode('[yarpp]'); ?>`
83
+ `<?php echo do_shortcode('[yarpp reference_id=123]'); ?>`
84
+
85
+ If you're adding the shortcode *outside [the loop](http://codex.wordpress.org/The_Loop)*, you must provide the reference_id.
86
 
87
  == Frequently Asked Questions ==
88
 
96
 
97
  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" options 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."
98
 
99
+ If you would like to add the Related Posts display elsewhere, edit your relevant theme file (most likely something like `single.php`) and add the shortcode code `[yarpp]` (recommended) or PHP function `related_posts();` within [The Loop](https://codex.wordpress.org/The_Loop) where you want to display the related posts. Make sure you don't add `echo related_posts();` or you may end up with duplicates in your related posts section.
100
 
101
  = How can I limit related posts to a certain time frame? For instance, I don't want to show posts from two years ago. =
102
 
159
 
160
  = How can I use the custom template feature? =
161
 
162
+ YARPP's custom templates feature allows you to uber-customize the related posts display using the same coding conventions and [Template Tags](https://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.
163
 
164
  = Is YARPP compatible with WordPress Multisite? =
165
 
295
  `
296
 
297
  == Changelog ==
298
+ = 5.10.0 (22-October-2020) =
299
+ * Enhancement: Faster queries and a speed boost ⚡️
300
+ * [Enhancement](https://wordpress.org/support/topic/yarp-page-break/): On posts with page breaks, show YARPP only on the last page
301
+ * 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
302
+ * 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.
303
+ * Bugfix: Fixes showing/hiding excerpt options when checking excerpt checkboxes
304
+ * [Bugfix](https://wordpress.org/support/topic/bug-fix-for-role-related-code/): Fixes "role" in deactivation survey
305
+ * [Bugfix](https://wordpress.org/support/topic/php-error-423/): Fixes PHP warning on options page
306
+ * [Bugfix](https://wordpress.org/support/topic/yarpp-query-migrate-helper-warnings/): Resolves jQuery Migrate Helper warnings
307
+
308
  = 5.9.0 (21-September-2020) =
309
  * Enhancement: Clarify that "Also display in archives" includes front page and category pages
310
  * Enhancement: `reference_id` parameter support for the YARPP shortcode. For example: `[yarpp reference_id=123]` to show content related to Post ID 123 (can be used either inside or outside the loop from theme code)
314
  = 5.8.0 (08-September-2020) =
315
  * Enhancement: Code hygiene upgrade with usage of `WPDB->prepare` everywhere possible and related improvements
316
  * [Bugfix](https://wordpress.org/support/topic/i-need-to-ad-yarpp-to-my-sidebar-but-it-wont-let-me-upgrade-to-pro/): Since there is no YARPP Pro currently, removed mention of it from the widget form
 
317
 
318
  = 5.7.0 (18-August-2020) =
319
  * Enhancement: Ensure that when a post is finally published, YARPP cache for peer posts is cleared to ensure the most related posts are always recommended across every post
1040
  * Initial upload
1041
 
1042
  == Upgrade Notice ==
1043
+ = 5.10.0 =
1044
  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!
 
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.9.0
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.9.0');
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.10.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.10.0');
27
 
28
  define('YARPP_DIR', dirname(__FILE__));
29
  /**