Version Description
(06-April-2021) =
* New: Added filter to be able to dequeue related.css
add_filter( 'yarpp_enqueue_related_style', '_\_return_false' );
* New: Added friendly per-post meta box options to disable YARPP automatic display on a specific post
Download this release
Release Info
Developer | jeffparker |
Plugin | Yet Another Related Posts Plugin (YARPP) |
Version | 5.17.0 |
Comparing to | |
See all releases |
Code changes from version 5.16.0 to 5.17.0
- classes/YARPP_Admin.php +44 -10
- classes/YARPP_Core.php +27 -2
- includes/template_metabox.php +3 -3
- readme.txt +17 -3
- yarpp.php +2 -2
classes/YARPP_Admin.php
CHANGED
@@ -34,6 +34,7 @@ class YARPP_Admin {
|
|
34 |
add_action('admin_init', array($this, 'ajax_register'));
|
35 |
add_action('admin_init', array($this, 'review_register'));
|
36 |
add_action('admin_menu', array($this, 'ui_register'));
|
|
|
37 |
|
38 |
add_filter('current_screen', array($this, 'settings_screen'));
|
39 |
add_filter('screen_settings', array($this, 'render_screen_settings'), 10, 2);
|
@@ -515,13 +516,12 @@ class YARPP_Admin {
|
|
515 |
public function enqueue() {
|
516 |
$version = defined('WP_DEBUG') && WP_DEBUG ? time() : YARPP_VERSION;
|
517 |
$screen = get_current_screen();
|
518 |
-
$options_basic = false;
|
519 |
if (!is_null($screen) && $screen->id === 'settings_page_yarpp') {
|
520 |
-
$options_basic = true;
|
521 |
wp_enqueue_style('yarpp_switch_options', plugins_url('style/options_switch.css', dirname(__FILE__)), array(), $version );
|
522 |
wp_enqueue_script('yarpp_switch_options', yarpp_get_file_url_for_environment('js/options_switch.min.js', 'js/options_switch.js'), array('jquery'), $version );
|
523 |
|
524 |
-
wp_enqueue_style('wp-pointer');
|
|
|
525 |
wp_enqueue_style('yarpp_remodal', plugins_url('lib/plugin-deactivation-survey/remodal.css', dirname(__FILE__)), array(), $version );
|
526 |
wp_enqueue_style('yarpp_deactivate', plugins_url('lib/plugin-deactivation-survey/deactivate-feedback-form.css', dirname(__FILE__)), array(), $version );
|
527 |
wp_enqueue_style('yarpp_default_theme', plugins_url('lib/plugin-deactivation-survey/remodal-default-theme.css', dirname(__FILE__)), array(), $version );
|
@@ -546,12 +546,8 @@ class YARPP_Admin {
|
|
546 |
|
547 |
$metabox_post_types = $this->core->get_option('auto_display_post_types');
|
548 |
if (!is_null($screen) && ($screen->id == 'post' || in_array( $screen->id, $metabox_post_types))) {
|
549 |
-
$options_basic = true;
|
550 |
wp_enqueue_script('yarpp_metabox', plugins_url('js/metabox.js', dirname(__FILE__)), array('jquery'), $version );
|
551 |
}
|
552 |
-
if ( true === $options_basic ) {
|
553 |
-
wp_enqueue_style('yarpp_options', plugins_url('style/options_basic.css', dirname(__FILE__)), array(), $version );
|
554 |
-
}
|
555 |
}
|
556 |
|
557 |
public function settings_link($links, $file) {
|
@@ -570,9 +566,39 @@ class YARPP_Admin {
|
|
570 |
include_once(YARPP_DIR . '/includes/yarpp_options.php');
|
571 |
}
|
572 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
|
574 |
// @since 3.4: don't actually compute results here, but use ajax instead
|
575 |
public function metabox() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
?>
|
577 |
<style>
|
578 |
.yarpp-metabox-options {
|
@@ -582,13 +608,21 @@ class YARPP_Admin {
|
|
582 |
float: none; visibility: hidden; opacity: 1; margin: 5px 7px 0 7px;
|
583 |
}
|
584 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
585 |
<?php
|
586 |
if ( !get_the_ID() ) {
|
587 |
-
echo "<div><p>".__("Related
|
588 |
-
} else {
|
589 |
-
wp_nonce_field( 'yarpp_display', 'yarpp_display-nonce', false );
|
590 |
echo '<div id="yarpp-related-posts"><img height="20px" width="20px" src="' . esc_url( admin_url( 'images/spinner-2x.gif' ) ) . '" alt="loading..." /></div>';
|
591 |
}
|
|
|
592 |
}
|
593 |
|
594 |
// @since 3.3: default metaboxes to show:
|
34 |
add_action('admin_init', array($this, 'ajax_register'));
|
35 |
add_action('admin_init', array($this, 'review_register'));
|
36 |
add_action('admin_menu', array($this, 'ui_register'));
|
37 |
+
add_action( 'save_post', array($this, 'yarpp_save_meta_box' ) );
|
38 |
|
39 |
add_filter('current_screen', array($this, 'settings_screen'));
|
40 |
add_filter('screen_settings', array($this, 'render_screen_settings'), 10, 2);
|
516 |
public function enqueue() {
|
517 |
$version = defined('WP_DEBUG') && WP_DEBUG ? time() : YARPP_VERSION;
|
518 |
$screen = get_current_screen();
|
|
|
519 |
if (!is_null($screen) && $screen->id === 'settings_page_yarpp') {
|
|
|
520 |
wp_enqueue_style('yarpp_switch_options', plugins_url('style/options_switch.css', dirname(__FILE__)), array(), $version );
|
521 |
wp_enqueue_script('yarpp_switch_options', yarpp_get_file_url_for_environment('js/options_switch.min.js', 'js/options_switch.js'), array('jquery'), $version );
|
522 |
|
523 |
+
wp_enqueue_style('wp-pointer');
|
524 |
+
wp_enqueue_style('yarpp_options', plugins_url('style/options_basic.css', dirname(__FILE__)), array(), $version );
|
525 |
wp_enqueue_style('yarpp_remodal', plugins_url('lib/plugin-deactivation-survey/remodal.css', dirname(__FILE__)), array(), $version );
|
526 |
wp_enqueue_style('yarpp_deactivate', plugins_url('lib/plugin-deactivation-survey/deactivate-feedback-form.css', dirname(__FILE__)), array(), $version );
|
527 |
wp_enqueue_style('yarpp_default_theme', plugins_url('lib/plugin-deactivation-survey/remodal-default-theme.css', dirname(__FILE__)), array(), $version );
|
546 |
|
547 |
$metabox_post_types = $this->core->get_option('auto_display_post_types');
|
548 |
if (!is_null($screen) && ($screen->id == 'post' || in_array( $screen->id, $metabox_post_types))) {
|
|
|
549 |
wp_enqueue_script('yarpp_metabox', plugins_url('js/metabox.js', dirname(__FILE__)), array('jquery'), $version );
|
550 |
}
|
|
|
|
|
|
|
551 |
}
|
552 |
|
553 |
public function settings_link($links, $file) {
|
566 |
include_once(YARPP_DIR . '/includes/yarpp_options.php');
|
567 |
}
|
568 |
}
|
569 |
+
/**
|
570 |
+
* Function to save the meta box.
|
571 |
+
*
|
572 |
+
* @param mixed $post_id Post ID.
|
573 |
+
*/
|
574 |
+
public function yarpp_save_meta_box( $post_id ) {
|
575 |
+
$yarpp_meta = array();
|
576 |
+
// Return if we're doing an autosave.
|
577 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
578 |
+
return;
|
579 |
+
}
|
580 |
+
// Verify our nonce here.
|
581 |
+
if ( ! isset( $_POST['yarpp_display-nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['yarpp_display-nonce'] ), 'yarpp_display' ) ) {
|
582 |
+
return;
|
583 |
+
}
|
584 |
+
if ( isset( $_POST['yarpp_display_for_this_post'] ) ) {
|
585 |
+
$yarpp_meta['yarpp_display_for_this_post'] = 1;
|
586 |
+
} else {
|
587 |
+
$yarpp_meta['yarpp_display_for_this_post'] = 0;
|
588 |
+
}
|
589 |
+
update_post_meta( $post_id, 'yarpp_meta', $yarpp_meta );
|
590 |
+
}
|
591 |
|
592 |
// @since 3.4: don't actually compute results here, but use ajax instead
|
593 |
public function metabox() {
|
594 |
+
global $post;
|
595 |
+
$metabox_post_types = $this->core->get_option('auto_display_post_types');
|
596 |
+
$yarpp_meta = get_post_meta( $post->ID, 'yarpp_meta', true );
|
597 |
+
if ( isset( $yarpp_meta['yarpp_display_for_this_post'] ) && 0 === $yarpp_meta['yarpp_display_for_this_post'] ) {
|
598 |
+
$yarpp_disable_here = 0;
|
599 |
+
} else {
|
600 |
+
$yarpp_disable_here = 1;
|
601 |
+
}
|
602 |
?>
|
603 |
<style>
|
604 |
.yarpp-metabox-options {
|
608 |
float: none; visibility: hidden; opacity: 1; margin: 5px 7px 0 7px;
|
609 |
}
|
610 |
</style>
|
611 |
+
<?php if ( in_array( get_post_type(), $metabox_post_types ) ) { ?>
|
612 |
+
<p>
|
613 |
+
<input type="checkbox" id="yarpp_display_for_this_post" name="yarpp_display_for_this_post" <?php checked( 1, $yarpp_disable_here, true ); ?> />
|
614 |
+
<label for="yarpp_display_for_this_post"><strong><?php esc_html_e( 'Automatically display related content on this post', 'yarpp' ); ?></strong></label>
|
615 |
+
<br />
|
616 |
+
<em><?php esc_html_e( 'If this is unchecked, then YARPP will not automatically insert the related posts at the end of this post.', 'yarpp' ); ?></em>
|
617 |
+
</p>
|
618 |
+
<?php } ?>
|
619 |
<?php
|
620 |
if ( !get_the_ID() ) {
|
621 |
+
echo "<div><p>".__("Related posts will be displayed once you save this post",'yarpp').".</p></div>";
|
622 |
+
} else {
|
|
|
623 |
echo '<div id="yarpp-related-posts"><img height="20px" width="20px" src="' . esc_url( admin_url( 'images/spinner-2x.gif' ) ) . '" alt="loading..." /></div>';
|
624 |
}
|
625 |
+
wp_nonce_field( 'yarpp_display', 'yarpp_display-nonce', false );
|
626 |
}
|
627 |
|
628 |
// @since 3.3: default metaboxes to show:
|
classes/YARPP_Core.php
CHANGED
@@ -1180,7 +1180,16 @@ class YARPP {
|
|
1180 |
public function display_related($reference_ID = null, $args = array(), $echo = true) {
|
1181 |
// Avoid infinite recursion here.
|
1182 |
if ( $this->do_not_query_for_related()) return false;
|
1183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1184 |
$output = null;
|
1185 |
|
1186 |
if (is_numeric($reference_ID)) {
|
@@ -1561,7 +1570,19 @@ class YARPP {
|
|
1561 |
*/
|
1562 |
$wp_query->is_single = false;
|
1563 |
}
|
1564 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1565 |
/*
|
1566 |
* DEFAULT CONTENT FILTERS
|
1567 |
*/
|
@@ -1569,6 +1590,10 @@ class YARPP {
|
|
1569 |
public function the_content($content) {
|
1570 |
// Avoid infinite recursion.
|
1571 |
if (is_feed() || $this->do_not_query_for_related()) return $content;
|
|
|
|
|
|
|
|
|
1572 |
|
1573 |
/* If the content includes <!--noyarpp-->, don't display */
|
1574 |
if (!stristr($content, '<!--noyarpp-->')) {
|
1180 |
public function display_related($reference_ID = null, $args = array(), $echo = true) {
|
1181 |
// Avoid infinite recursion here.
|
1182 |
if ( $this->do_not_query_for_related()) return false;
|
1183 |
+
wp_register_style('yarppRelatedCss', plugins_url('/style/related.css', YARPP_MAIN_FILE ), array(), YARPP_VERSION);
|
1184 |
+
/**
|
1185 |
+
* Filter to allow dequeing of related.css.
|
1186 |
+
*
|
1187 |
+
* @param boolean default true
|
1188 |
+
*/
|
1189 |
+
$enqueue_related_style = apply_filters( 'yarpp_enqueue_related_style', true );
|
1190 |
+
if ( true === $enqueue_related_style ) {
|
1191 |
+
wp_enqueue_style( 'yarppRelatedCss' );
|
1192 |
+
}
|
1193 |
$output = null;
|
1194 |
|
1195 |
if (is_numeric($reference_ID)) {
|
1570 |
*/
|
1571 |
$wp_query->is_single = false;
|
1572 |
}
|
1573 |
+
/*
|
1574 |
+
* Return true if user disabled the YARPP related post for the current post, false otherwise.
|
1575 |
+
*
|
1576 |
+
* @return bool
|
1577 |
+
*/
|
1578 |
+
public function yarpp_disabled_for_this_post() {
|
1579 |
+
global $post;
|
1580 |
+
$yarpp_meta = get_post_meta( $post->ID, 'yarpp_meta', true );
|
1581 |
+
if ( isset( $yarpp_meta['yarpp_display_for_this_post'] ) && 0 === (int) $yarpp_meta['yarpp_display_for_this_post'] ) {
|
1582 |
+
return true;
|
1583 |
+
}
|
1584 |
+
return false;
|
1585 |
+
}
|
1586 |
/*
|
1587 |
* DEFAULT CONTENT FILTERS
|
1588 |
*/
|
1590 |
public function the_content($content) {
|
1591 |
// Avoid infinite recursion.
|
1592 |
if (is_feed() || $this->do_not_query_for_related()) return $content;
|
1593 |
+
// If YARPP related post is disabled for this post then return original content.
|
1594 |
+
if ( true === $this->yarpp_disabled_for_this_post() ) {
|
1595 |
+
return $content;
|
1596 |
+
}
|
1597 |
|
1598 |
/* If the content includes <!--noyarpp-->, don't display */
|
1599 |
if (!stristr($content, '<!--noyarpp-->')) {
|
includes/template_metabox.php
CHANGED
@@ -9,7 +9,7 @@ if ($yarpp->debug) {
|
|
9 |
$output .= "<p>title keywords: {$keywords['title']}</p>";
|
10 |
}
|
11 |
|
12 |
-
$output .= '<p>'.__( '
|
13 |
|
14 |
if ($yarpp->debug) {
|
15 |
$output .= "<p>last updated: ".$wpdb->get_var("select max(date) as updated from {$wpdb->prefix}yarpp_related_cache where reference_ID = '$reference_ID'")."</p>";
|
@@ -26,9 +26,9 @@ if (have_posts()) {
|
|
26 |
$output .= '</li>';
|
27 |
}
|
28 |
$output .= '</ol>';
|
29 |
-
$output .= '<p>'.__( 'Whether all
|
30 |
} else {
|
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>';
|
9 |
$output .= "<p>title keywords: {$keywords['title']}</p>";
|
10 |
}
|
11 |
|
12 |
+
$output .= '<p><strong>'.__( 'Related Posts:' , 'yarpp').'</strong></p>';
|
13 |
|
14 |
if ($yarpp->debug) {
|
15 |
$output .= "<p>last updated: ".$wpdb->get_var("select max(date) as updated from {$wpdb->prefix}yarpp_related_cache where reference_ID = '$reference_ID'")."</p>";
|
26 |
$output .= '</li>';
|
27 |
}
|
28 |
$output .= '</ol>';
|
29 |
+
$output .= '<p>'. __( 'Whether all matches are actually displayed and how they are displayed depends on your YARPP display options.' , 'yarpp') . ' ' . __('Updating the post may change the matches.','yarpp') . '</p>';
|
30 |
} else {
|
31 |
+
$output .= '<p><em>' . __('No related posts matched.','yarpp') . ' ' . __('Updating the post may change the matches.','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>';
|
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.7
|
8 |
-
Stable tag: 5.
|
9 |
|
10 |
The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
|
11 |
|
@@ -121,7 +121,11 @@ Some WordPress themes treat the home page as an archive or a "page." Go to "Sett
|
|
121 |
|
122 |
= How can I prevent the "related posts" list from displaying on specific posts? =
|
123 |
|
124 |
-
|
|
|
|
|
|
|
|
|
125 |
|
126 |
= I'm using the Thumbnails display in YARPP 4. How do I override the style of the text that displays? The title only shows two lines, the font is larger than I'd like, I'd like to center the thumbnails, etc. =
|
127 |
|
@@ -309,6 +313,16 @@ add_action(
|
|
309 |
`
|
310 |
|
311 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
= 5.16.0 (29-March-2021) =
|
313 |
* Enhancement: Switched to minified JavaScript in YARPP Admin for a speed boost
|
314 |
* [Bugfix](https://wordpress.org/support/topic/cannot-save-changes-spinning-forever/): Resolved conflict with Easy Forms for MailChimp which was preventing YARPP settings from being saved
|
@@ -1111,5 +1125,5 @@ After a break of many years, the plugin is 100% supported now that the baton has
|
|
1111 |
* Initial upload
|
1112 |
|
1113 |
== Upgrade Notice ==
|
1114 |
-
= 5.
|
1115 |
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.7
|
8 |
+
Stable tag: 5.17.0
|
9 |
|
10 |
The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
|
11 |
|
121 |
|
122 |
= How can I prevent the "related posts" list from displaying on specific posts? =
|
123 |
|
124 |
+
When editing a post or page, uncheck “Display Related Posts”, which is located next to the WordPress editor. Be sure to update or publish to save your changes.
|
125 |
+
|
126 |
+
An older method was to add `<?noyarpp-->` to the HTML code of any post to prevent related posts from displaying. This solution will only work if you are using "Automatic Display" in the "Display Options" section.
|
127 |
+
|
128 |
+
If you are programatically calling `yarpp_related()`, the shortcode `[yarpp]` from PHP code or the YARPP Block, you'll have to do your own checking to see if related posts are appropriate to display or not.
|
129 |
|
130 |
= I'm using the Thumbnails display in YARPP 4. How do I override the style of the text that displays? The title only shows two lines, the font is larger than I'd like, I'd like to center the thumbnails, etc. =
|
131 |
|
313 |
`
|
314 |
|
315 |
== Changelog ==
|
316 |
+
= 5.17.0 (06-April-2021) =
|
317 |
+
* [New](https://wordpress.org/support/topic/unable-to-dequeue-related-css-stylesheet/): Added filter to be able to dequeue related.css
|
318 |
+
`
|
319 |
+
add_filter( 'yarpp_enqueue_related_style', '_\_return_false' );
|
320 |
+
`
|
321 |
+
* New: Added friendly per-post meta box options to disable YARPP automatic display on a specific post
|
322 |
+
|
323 |
+
= 5.16.1 (29-March-2021) =
|
324 |
+
* Bugfix: include new minified JS files
|
325 |
+
|
326 |
= 5.16.0 (29-March-2021) =
|
327 |
* Enhancement: Switched to minified JavaScript in YARPP Admin for a speed boost
|
328 |
* [Bugfix](https://wordpress.org/support/topic/cannot-save-changes-spinning-forever/): Resolved conflict with Easy Forms for MailChimp which was preventing YARPP settings from being saved
|
1125 |
* Initial upload
|
1126 |
|
1127 |
== Upgrade Notice ==
|
1128 |
+
= 5.17.0 =
|
1129 |
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.
|
6 |
Author: YARPP
|
7 |
Author URI: https://yarpp.com/
|
8 |
Plugin URI: https://yarpp.com/
|
@@ -24,7 +24,7 @@ if(!defined('WP_CONTENT_DIR')){
|
|
24 |
define('WP_CONTENT_DIR', substr($tr,0,strrpos($tr,'/')));
|
25 |
}
|
26 |
|
27 |
-
define('YARPP_VERSION', '5.
|
28 |
|
29 |
define('YARPP_DIR', dirname(__FILE__));
|
30 |
/**
|
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.17.0
|
6 |
Author: YARPP
|
7 |
Author URI: https://yarpp.com/
|
8 |
Plugin URI: https://yarpp.com/
|
24 |
define('WP_CONTENT_DIR', substr($tr,0,strrpos($tr,'/')));
|
25 |
}
|
26 |
|
27 |
+
define('YARPP_VERSION', '5.17.0');
|
28 |
|
29 |
define('YARPP_DIR', dirname(__FILE__));
|
30 |
/**
|