Version Description
(23-November-2020) = * Enhancement: Faster queries and a speed boost (Re-introduces database query improvements while avoiding the fatal error identified by some in v5.10.0) * Enhancement: Speed up by not loading widget.css when not necessary * Bugfix: Part 2 of 2 - Resolves jQuery Migrate Helper warnings * Bugfix: Fixes PHP warning on options page * Bugfix: Fixes integration with Algolia search * Bugfix: Respect "Require at least 1 {Taxonomy} in common" when you press "refresh" in the meta box while editing a post
Download this release
Release Info
Developer | jeffparker |
Plugin | Yet Another Related Posts Plugin (YARPP) |
Version | 5.10.2 |
Comparing to | |
See all releases |
Code changes from version 5.10.1 to 5.10.2
- classes/YARPP_Cache.php +50 -10
- classes/YARPP_Cache_Bypass.php +3 -3
- classes/YARPP_Cache_Postmeta.php +7 -4
- classes/YARPP_Cache_Tables.php +3 -1
- classes/YARPP_Core.php +62 -23
- classes/YARPP_Widget.php +0 -1
- includes/yarpp_options.php +1 -1
- js/options_basic.js +1 -1
- readme.txt +11 -3
- style/widget.css +0 -34
- yarpp.php +2 -2
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 .= ',
|
195 |
|
196 |
$newsql .= "\n from $wpdb->posts \n";
|
197 |
|
@@ -278,10 +289,10 @@ abstract class YARPP_Cache {
|
|
278 |
$newsql .= " and bit_or(terms.term_taxonomy_id in (".join(',', $exclude_tt_ids).")) = 0";
|
279 |
}
|
280 |
|
281 |
-
$post_type_taxonomies = get_object_taxonomies($
|
282 |
foreach ((array) $require_tax as $tax => $number) {
|
283 |
-
// Double-check
|
284 |
-
// we'll never find any related posts, as the reference post
|
285 |
// See https://wordpress.org/support/topic/require-at-least-one-taxonomy-limited-to-taxonomies-available-the-post-type/
|
286 |
if(in_array($tax, $post_type_taxonomies)){
|
287 |
$newsql .= $wpdb->prepare(
|
@@ -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 |
-
|
|
|
|
|
|
|
|
|
|
|
363 |
}
|
364 |
|
365 |
private function extract_keywords( $html, $max = 20, $ID = 0 ) {
|
@@ -453,4 +464,33 @@ 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 |
|
289 |
$newsql .= " and bit_or(terms.term_taxonomy_id in (".join(',', $exclude_tt_ids).")) = 0";
|
290 |
}
|
291 |
|
292 |
+
$post_type_taxonomies = get_object_taxonomies($reference_post->post_type, 'names');
|
293 |
foreach ((array) $require_tax as $tax => $number) {
|
294 |
+
// Double-check the reference post's type actually supports this taxonomy. If not,
|
295 |
+
// we'll never find any related posts, as the reference post can't be assigned any terms in this taxonomy.
|
296 |
// See https://wordpress.org/support/topic/require-at-least-one-taxonomy-limited-to-taxonomies-available-the-post-type/
|
297 |
if(in_array($tax, $post_type_taxonomies)){
|
298 |
$newsql .= $wpdb->prepare(
|
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 |
+
|
477 |
+
/**
|
478 |
+
* Replaces the WP_Query's orderby clause (which normally orders by date) to orderby score instead
|
479 |
+
* @param string $sql
|
480 |
+
* @return string
|
481 |
+
*/
|
482 |
+
protected function orderby_score($sql){
|
483 |
+
global $wpdb;
|
484 |
+
return str_replace(
|
485 |
+
array(
|
486 |
+
"$wpdb->posts.post_date ASC",
|
487 |
+
"$wpdb->posts.post_date DESC"
|
488 |
+
),
|
489 |
+
array(
|
490 |
+
"score ASC, {$wpdb->posts}.ID ASC",
|
491 |
+
"score DESC, {$wpdb->posts}.ID ASC"
|
492 |
+
),
|
493 |
+
$sql
|
494 |
+
);
|
495 |
+
}
|
496 |
}
|
classes/YARPP_Cache_Bypass.php
CHANGED
@@ -50,14 +50,14 @@ class YARPP_Cache_Bypass extends YARPP_Cache {
|
|
50 |
}
|
51 |
|
52 |
public function orderby_filter($arg) {
|
53 |
-
global $wpdb;
|
54 |
-
|
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 |
-
|
61 |
}
|
62 |
|
63 |
return $arg;
|
50 |
}
|
51 |
|
52 |
public function orderby_filter($arg) {
|
|
|
|
|
53 |
/*
|
54 |
* Only order by score if the score function is added in fields_filter,
|
55 |
* which only happens if there are related posts in the post-data.
|
56 |
+
* If ordering by score also order by post ID to keep them consistent in cases where the score is the same
|
57 |
+
* for multiple posts.
|
58 |
*/
|
59 |
if ($this->score_override && is_array($this->related_postdata) && count($this->related_postdata)) {
|
60 |
+
$arg = $this->orderby_score($arg);
|
61 |
}
|
62 |
|
63 |
return $arg;
|
classes/YARPP_Cache_Postmeta.php
CHANGED
@@ -77,12 +77,15 @@ class YARPP_Cache_Postmeta extends YARPP_Cache {
|
|
77 |
}
|
78 |
|
79 |
public function orderby_filter($arg) {
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
83 |
if ($this->score_override &&
|
84 |
is_array($this->related_postdata) && count($this->related_postdata))
|
85 |
-
|
86 |
return $arg;
|
87 |
}
|
88 |
|
77 |
}
|
78 |
|
79 |
public function orderby_filter($arg) {
|
80 |
+
/*
|
81 |
+
* Only order by score if the score function is added in fields_filter,
|
82 |
+
* which only happens if there are related posts in the post-data.
|
83 |
+
* If ordering by score also order by post ID to keep them consistent in cases where the score is the same
|
84 |
+
* for multiple posts.
|
85 |
+
*/
|
86 |
if ($this->score_override &&
|
87 |
is_array($this->related_postdata) && count($this->related_postdata))
|
88 |
+
$arg = $this->orderby_score($arg);
|
89 |
return $arg;
|
90 |
}
|
91 |
|
classes/YARPP_Cache_Tables.php
CHANGED
@@ -134,8 +134,10 @@ 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 =
|
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 = $this->orderby_score($arg);
|
141 |
return $arg;
|
142 |
}
|
143 |
|
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(
|
@@ -32,6 +41,11 @@ class YARPP {
|
|
32 |
'size' => '120x120',
|
33 |
'_default' => true
|
34 |
);
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
public function __construct() {
|
37 |
$this->load_default_options();
|
@@ -855,7 +869,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;
|
@@ -1079,10 +1093,10 @@ class YARPP {
|
|
1079 |
* @return string
|
1080 |
*/
|
1081 |
public function display_related($reference_ID = null, $args = array(), $echo = true) {
|
1082 |
-
|
1083 |
-
|
1084 |
-
if ($this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time()) return false;
|
1085 |
$this->enforce();
|
|
|
1086 |
wp_enqueue_style('yarppRelatedCss', plugins_url('/style/related.css', YARPP_MAIN_FILE));
|
1087 |
$output = null;
|
1088 |
|
@@ -1111,7 +1125,9 @@ class YARPP {
|
|
1111 |
extract($this->parse_args($args, $options));
|
1112 |
|
1113 |
$cache_status = $this->active_cache->enforce($reference_ID);
|
1114 |
-
if ($cache_status === YARPP_DONT_RUN)
|
|
|
|
|
1115 |
if ($cache_status !== YARPP_NO_RELATED) $this->active_cache->begin_yarpp_time($reference_ID, $args);
|
1116 |
|
1117 |
$this->save_post_context();
|
@@ -1155,6 +1171,9 @@ class YARPP {
|
|
1155 |
|
1156 |
$output .= "'>\n";
|
1157 |
|
|
|
|
|
|
|
1158 |
if ($domain === 'metabox') {
|
1159 |
include(YARPP_DIR.'/includes/template_metabox.php');
|
1160 |
} else if ((bool) $template && $template === 'thumbnails') {
|
@@ -1170,7 +1189,7 @@ class YARPP {
|
|
1170 |
} else {
|
1171 |
include(YARPP_DIR.'/includes/template_builtin.php');
|
1172 |
}
|
1173 |
-
|
1174 |
$output = trim($output)."\n";
|
1175 |
|
1176 |
if ($cache_status === YARPP_NO_RELATED) {
|
@@ -1206,10 +1225,11 @@ class YARPP {
|
|
1206 |
* @param (array) $args
|
1207 |
*/
|
1208 |
public function get_related($reference_ID = null, $args = array()) {
|
1209 |
-
|
1210 |
-
if (
|
1211 |
$this->enforce();
|
1212 |
|
|
|
1213 |
if (is_numeric($reference_ID)) {
|
1214 |
$reference_ID = (int) $reference_ID;
|
1215 |
} else {
|
@@ -1227,7 +1247,9 @@ class YARPP {
|
|
1227 |
extract($this->parse_args($args, $options));
|
1228 |
|
1229 |
$cache_status = $this->active_cache->enforce($reference_ID);
|
1230 |
-
if ($cache_status === YARPP_DONT_RUN || $cache_status === YARPP_NO_RELATED)
|
|
|
|
|
1231 |
|
1232 |
/* Get ready for YARPP TIME! */
|
1233 |
$this->active_cache->begin_yarpp_time($reference_ID, $args);
|
@@ -1244,16 +1266,15 @@ class YARPP {
|
|
1244 |
|
1245 |
$related_query->posts = apply_filters(
|
1246 |
'yarpp_results',
|
1247 |
-
$related_query->posts,
|
1248 |
-
|
1249 |
-
|
1250 |
'args' => $args,
|
1251 |
'related_ID' => $reference_ID
|
1252 |
)
|
1253 |
);
|
1254 |
|
1255 |
$this->active_cache->end_yarpp_time();
|
1256 |
-
|
1257 |
return $related_query->posts;
|
1258 |
}
|
1259 |
|
@@ -1262,9 +1283,8 @@ class YARPP {
|
|
1262 |
* @param (array) $args
|
1263 |
*/
|
1264 |
public function related_exist($reference_ID = null, $args = array()) {
|
1265 |
-
|
1266 |
-
if ($this->
|
1267 |
-
|
1268 |
$this->enforce();
|
1269 |
|
1270 |
if (is_numeric($reference_ID)) {
|
@@ -1280,7 +1300,9 @@ class YARPP {
|
|
1280 |
|
1281 |
$cache_status = $this->active_cache->enforce($reference_ID);
|
1282 |
|
1283 |
-
if ($cache_status === YARPP_NO_RELATED)
|
|
|
|
|
1284 |
|
1285 |
/* Get ready for YARPP TIME! */
|
1286 |
$this->active_cache->begin_yarpp_time($reference_ID, $args);
|
@@ -1305,7 +1327,6 @@ class YARPP {
|
|
1305 |
unset($related_query);
|
1306 |
|
1307 |
$this->active_cache->end_yarpp_time();
|
1308 |
-
|
1309 |
return $return;
|
1310 |
}
|
1311 |
|
@@ -1315,7 +1336,8 @@ class YARPP {
|
|
1315 |
* @return string
|
1316 |
*/
|
1317 |
public function display_demo_related($args = array(), $echo = true) {
|
1318 |
-
|
|
|
1319 |
if ($this->cache_bypass->demo_time) return false;
|
1320 |
|
1321 |
$options = array(
|
@@ -1466,15 +1488,14 @@ class YARPP {
|
|
1466 |
*/
|
1467 |
|
1468 |
public function the_content($content) {
|
1469 |
-
|
1470 |
-
if (is_feed()) return $content;
|
1471 |
|
1472 |
/* If the content includes <!--noyarpp-->, don't display */
|
1473 |
if (!stristr($content, '<!--noyarpp-->')) {
|
1474 |
$content .= $this->display_basic();
|
1475 |
$content .= $this->display_pro('website');
|
1476 |
}
|
1477 |
-
|
1478 |
return $content;
|
1479 |
}
|
1480 |
|
@@ -1629,7 +1650,7 @@ class YARPP {
|
|
1629 |
return $text;
|
1630 |
}
|
1631 |
|
1632 |
-
|
1633 |
* Gets the list of valid interval units used by YARPP and MySQL interval statements.
|
1634 |
*
|
1635 |
* @return array keys are valid values for recent units, and for MySQL interval
|
@@ -1642,4 +1663,22 @@ class YARPP {
|
|
1642 |
'month' => __('month(s)','yarpp')
|
1643 |
);
|
1644 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1645 |
}
|
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(
|
41 |
'size' => '120x120',
|
42 |
'_default' => true
|
43 |
);
|
44 |
+
/**
|
45 |
+
* @var bool Set to true while YARPP is rendering related posts (a very bad time to start looking for related
|
46 |
+
* content, and start infintely recursing !)
|
47 |
+
*/
|
48 |
+
private $rendering_related_content;
|
49 |
|
50 |
public function __construct() {
|
51 |
$this->load_default_options();
|
869 |
|
870 |
return wp_list_pluck( $this->post_types, $field );
|
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;
|
1093 |
* @return string
|
1094 |
*/
|
1095 |
public function display_related($reference_ID = null, $args = array(), $echo = true) {
|
1096 |
+
// Avoid infinite recursion here.
|
1097 |
+
if ( $this->do_not_query_for_related()) return false;
|
|
|
1098 |
$this->enforce();
|
1099 |
+
|
1100 |
wp_enqueue_style('yarppRelatedCss', plugins_url('/style/related.css', YARPP_MAIN_FILE));
|
1101 |
$output = null;
|
1102 |
|
1125 |
extract($this->parse_args($args, $options));
|
1126 |
|
1127 |
$cache_status = $this->active_cache->enforce($reference_ID);
|
1128 |
+
if ($cache_status === YARPP_DONT_RUN){
|
1129 |
+
return;
|
1130 |
+
}
|
1131 |
if ($cache_status !== YARPP_NO_RELATED) $this->active_cache->begin_yarpp_time($reference_ID, $args);
|
1132 |
|
1133 |
$this->save_post_context();
|
1171 |
|
1172 |
$output .= "'>\n";
|
1173 |
|
1174 |
+
// Be careful to avoid infinite recursion, because those templates might show each related posts' body or
|
1175 |
+
// excerpt, which would trigger finding its related posts, which would show its related posts body or excerpt...
|
1176 |
+
$this->rendering_related_content = true;
|
1177 |
if ($domain === 'metabox') {
|
1178 |
include(YARPP_DIR.'/includes/template_metabox.php');
|
1179 |
} else if ((bool) $template && $template === 'thumbnails') {
|
1189 |
} else {
|
1190 |
include(YARPP_DIR.'/includes/template_builtin.php');
|
1191 |
}
|
1192 |
+
$this->rendering_related_content = false;
|
1193 |
$output = trim($output)."\n";
|
1194 |
|
1195 |
if ($cache_status === YARPP_NO_RELATED) {
|
1225 |
* @param (array) $args
|
1226 |
*/
|
1227 |
public function get_related($reference_ID = null, $args = array()) {
|
1228 |
+
// Avoid infinite recursion here.
|
1229 |
+
if ( $this->do_not_query_for_related()) return false;
|
1230 |
$this->enforce();
|
1231 |
|
1232 |
+
|
1233 |
if (is_numeric($reference_ID)) {
|
1234 |
$reference_ID = (int) $reference_ID;
|
1235 |
} else {
|
1247 |
extract($this->parse_args($args, $options));
|
1248 |
|
1249 |
$cache_status = $this->active_cache->enforce($reference_ID);
|
1250 |
+
if ($cache_status === YARPP_DONT_RUN || $cache_status === YARPP_NO_RELATED) {
|
1251 |
+
return array();
|
1252 |
+
}
|
1253 |
|
1254 |
/* Get ready for YARPP TIME! */
|
1255 |
$this->active_cache->begin_yarpp_time($reference_ID, $args);
|
1266 |
|
1267 |
$related_query->posts = apply_filters(
|
1268 |
'yarpp_results',
|
1269 |
+
$related_query->posts, array(
|
1270 |
+
|
1271 |
+
'function' => 'get_related',
|
1272 |
'args' => $args,
|
1273 |
'related_ID' => $reference_ID
|
1274 |
)
|
1275 |
);
|
1276 |
|
1277 |
$this->active_cache->end_yarpp_time();
|
|
|
1278 |
return $related_query->posts;
|
1279 |
}
|
1280 |
|
1283 |
* @param (array) $args
|
1284 |
*/
|
1285 |
public function related_exist($reference_ID = null, $args = array()) {
|
1286 |
+
// Avoid infinite recursion here.
|
1287 |
+
if ($this->do_not_query_for_related()) return false;
|
|
|
1288 |
$this->enforce();
|
1289 |
|
1290 |
if (is_numeric($reference_ID)) {
|
1300 |
|
1301 |
$cache_status = $this->active_cache->enforce($reference_ID);
|
1302 |
|
1303 |
+
if ($cache_status === YARPP_NO_RELATED) {
|
1304 |
+
return false;
|
1305 |
+
}
|
1306 |
|
1307 |
/* Get ready for YARPP TIME! */
|
1308 |
$this->active_cache->begin_yarpp_time($reference_ID, $args);
|
1327 |
unset($related_query);
|
1328 |
|
1329 |
$this->active_cache->end_yarpp_time();
|
|
|
1330 |
return $return;
|
1331 |
}
|
1332 |
|
1336 |
* @return string
|
1337 |
*/
|
1338 |
public function display_demo_related($args = array(), $echo = true) {
|
1339 |
+
// If YARPP cache is already finding the current post's content, don't ask it to do it again.
|
1340 |
+
// Avoid infinite recursion here.
|
1341 |
if ($this->cache_bypass->demo_time) return false;
|
1342 |
|
1343 |
$options = array(
|
1488 |
*/
|
1489 |
|
1490 |
public function the_content($content) {
|
1491 |
+
// Avoid infinite recursion.
|
1492 |
+
if (is_feed() || $this->do_not_query_for_related()) return $content;
|
1493 |
|
1494 |
/* If the content includes <!--noyarpp-->, don't display */
|
1495 |
if (!stristr($content, '<!--noyarpp-->')) {
|
1496 |
$content .= $this->display_basic();
|
1497 |
$content .= $this->display_pro('website');
|
1498 |
}
|
|
|
1499 |
return $content;
|
1500 |
}
|
1501 |
|
1650 |
return $text;
|
1651 |
}
|
1652 |
|
1653 |
+
/*
|
1654 |
* Gets the list of valid interval units used by YARPP and MySQL interval statements.
|
1655 |
*
|
1656 |
* @return array keys are valid values for recent units, and for MySQL interval
|
1663 |
'month' => __('month(s)','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 |
+
*
|
1670 |
+
* There are two contrary indicators:
|
1671 |
+
* 1. if the active cache is currently discovering post keywords. Finding related posts at this time causes
|
1672 |
+
* infinite recursion because: in order to discover keywords, you need to get the post's FILTERED content, which
|
1673 |
+
* would trigger adding related content to the post's body, which requires discovering its keywords, etc.
|
1674 |
+
* 2. if YARPP is currently adding related content. Finding related posts at this time can cause infinite recursion
|
1675 |
+
* because: the template file might show a posts't content or excerpt, which would cause adding related content
|
1676 |
+
* to that post body or excerpt, which would start adding related content to it too, etc. *
|
1677 |
+
*
|
1678 |
+
* @return bool
|
1679 |
+
*/
|
1680 |
+
protected function do_not_query_for_related(){
|
1681 |
+
return $this->rendering_related_content ||
|
1682 |
+
($this->active_cache instanceof YARPP_Cache && $this->active_cache->discovering_keywords());
|
1683 |
+
}
|
1684 |
}
|
classes/YARPP_Widget.php
CHANGED
@@ -7,7 +7,6 @@ class YARPP_Widget extends WP_Widget {
|
|
7 |
|
8 |
public function __construct() {
|
9 |
parent::__construct(false, 'Related Posts (YARPP)', array('description' => 'Related Posts and/or Sponsored Content'));
|
10 |
-
wp_enqueue_style('yarppWidgetCss', plugins_url('/style/widget.css', YARPP_MAIN_FILE));
|
11 |
}
|
12 |
|
13 |
public function widget($args, $instance) {
|
7 |
|
8 |
public function __construct() {
|
9 |
parent::__construct(false, 'Related Posts (YARPP)', array('description' => 'Related Posts and/or Sponsored Content'));
|
|
|
10 |
}
|
11 |
|
12 |
public function widget($args, $instance) {
|
includes/yarpp_options.php
CHANGED
@@ -54,7 +54,7 @@ if (current_user_can('update_plugins')) {
|
|
54 |
);
|
55 |
echo '</p></div>';
|
56 |
|
57 |
-
} else if ($yarpp_version_info['result'] === 'newbeta') {
|
58 |
|
59 |
echo '<div class="updated"><p>';
|
60 |
printf(
|
54 |
);
|
55 |
echo '</p></div>';
|
56 |
|
57 |
+
} else if (isset($yarpp_version_info['result']) && $yarpp_version_info['result'] === 'newbeta') {
|
58 |
|
59 |
echo '<div class="updated"><p>';
|
60 |
printf(
|
js/options_basic.js
CHANGED
@@ -316,7 +316,7 @@ jQuery(function($) {
|
|
316 |
$('#yarpp-auto_display_archive')
|
317 |
.attr('disabled', !available);
|
318 |
if ( !available )
|
319 |
-
$('#yarpp-auto_display_archive').
|
320 |
}
|
321 |
|
322 |
$('.yarpp_form_post_types input[type=checkbox]').change(auto_display_archive);
|
316 |
$('#yarpp-auto_display_archive')
|
317 |
.attr('disabled', !available);
|
318 |
if ( !available )
|
319 |
+
$('#yarpp-auto_display_archive').prop('checked', false);
|
320 |
}
|
321 |
|
322 |
$('.yarpp_form_post_types input[type=checkbox]').change(auto_display_archive);
|
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.10.
|
9 |
|
10 |
The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
|
11 |
|
@@ -295,6 +295,14 @@ add_action(
|
|
295 |
`
|
296 |
|
297 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
= 5.10.1 (23-October-2020) =
|
299 |
* [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.
|
300 |
|
@@ -306,7 +314,7 @@ add_action(
|
|
306 |
* Bugfix: Fixes showing/hiding excerpt options when checking excerpt checkboxes
|
307 |
* [Bugfix](https://wordpress.org/support/topic/bug-fix-for-role-related-code/): Fixes "role" in deactivation survey
|
308 |
* [Bugfix](https://wordpress.org/support/topic/php-error-423/): Fixes PHP warning on options page
|
309 |
-
* [Bugfix](https://wordpress.org/support/topic/yarpp-query-migrate-helper-warnings/): Resolves jQuery Migrate Helper warnings
|
310 |
|
311 |
= 5.9.0 (21-September-2020) =
|
312 |
* Enhancement: Clarify that "Also display in archives" includes front page and category pages
|
@@ -1043,5 +1051,5 @@ After a break of many years, the plugin is 100% supported now that the baton has
|
|
1043 |
* Initial upload
|
1044 |
|
1045 |
== Upgrade Notice ==
|
1046 |
-
= 5.10.
|
1047 |
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!
|
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 |
|
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
|
301 |
+
* [Bugfix](https://wordpress.org/support/topic/yarpp-query-migrate-helper-warnings/): Part 2 of 2 - Resolves jQuery Migrate Helper warnings
|
302 |
+
* [Bugfix](https://wordpress.org/support/topic/php-error-423/): Fixes PHP warning on options page
|
303 |
+
* [Bugfix](https://wordpress.org/support/topic/plugin-causes-issues-with-algolia-search-integration/): Fixes integration with Algolia search
|
304 |
+
* [Bugfix](https://wordpress.org/support/topic/require-at-least-one-category-in-common/): Respect "Require at least 1 {Taxonomy} in common" when you press "refresh" in the meta box while editing a post
|
305 |
+
|
306 |
= 5.10.1 (23-October-2020) =
|
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 |
|
314 |
* Bugfix: Fixes showing/hiding excerpt options when checking excerpt checkboxes
|
315 |
* [Bugfix](https://wordpress.org/support/topic/bug-fix-for-role-related-code/): Fixes "role" in deactivation survey
|
316 |
* [Bugfix](https://wordpress.org/support/topic/php-error-423/): Fixes PHP warning on options page
|
317 |
+
* [Bugfix](https://wordpress.org/support/topic/yarpp-query-migrate-helper-warnings/): Part 1 of 2 - Resolves jQuery Migrate Helper warnings
|
318 |
|
319 |
= 5.9.0 (21-September-2020) =
|
320 |
* Enhancement: Clarify that "Also display in archives" includes front page and category pages
|
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!
|
style/widget.css
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
.yarpp_pro_msg{
|
2 |
-
border: 1px ridge #D0D0D0;
|
3 |
-
padding: 0.4em 2em 0.8em;
|
4 |
-
text-align: justify;
|
5 |
-
}
|
6 |
-
|
7 |
-
.yarpp_pro_msg strong{
|
8 |
-
display: inline-block;
|
9 |
-
text-align: center;
|
10 |
-
width: 100%;
|
11 |
-
color: orange;
|
12 |
-
}
|
13 |
-
|
14 |
-
.yarpp_help .wp-pointer-content p {
|
15 |
-
text-align: left;
|
16 |
-
font-family: sans-serif;
|
17 |
-
}
|
18 |
-
|
19 |
-
.yarpp_help_msg {
|
20 |
-
position: absolute;
|
21 |
-
left: 25px;
|
22 |
-
display: none;
|
23 |
-
border: 1px solid #D0D0D0;
|
24 |
-
width: 250px;
|
25 |
-
text-align: justify;
|
26 |
-
padding: 10px 15px;
|
27 |
-
background-color: #FFF;
|
28 |
-
box-shadow: 0 0 0.4em -0.15em #333;
|
29 |
-
z-index: 100;
|
30 |
-
}
|
31 |
-
|
32 |
-
.yarpp_help:hover .yarpp_help_msg{
|
33 |
-
display: block
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
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.
|
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.2
|
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.2');
|
27 |
|
28 |
define('YARPP_DIR', dirname(__FILE__));
|
29 |
/**
|