Yet Another Related Posts Plugin (YARPP) - Version 5.6.0

Version Description

(13-August-2020) = * New: Configurable in-browser caching option for YARPP REST API * Bugfix: Always include unused categories and terms in YARPP Admin options * Bugfix: Fixed issue with loading CSS files from wrong domain on multilingual sites * Various Admin UI fixes

Download this release

Release Info

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

Code changes from version 5.5.0 to 5.6.0

classes/YARPP_Admin.php CHANGED
@@ -20,15 +20,15 @@ class YARPP_Admin {
20
  /* If action = flush and the nonce is correct, reset the cache */
21
  if (isset($_GET['action']) && $_GET['action'] === 'flush' && check_ajax_referer('yarpp_cache_flush', false, false) !== false) {
22
  $this->core->cache->flush();
23
- wp_redirect(admin_url('/options-general.php?page=yarpp'));
24
- die();
25
  }
26
 
27
  /* If action = copy_templates and the nonce is correct, copy templates */
28
  if (isset($_GET['action']) && $_GET['action'] === 'copy_templates' && check_ajax_referer('yarpp_copy_templates', false, false) !== false) {
29
  $this->copy_templates();
30
- wp_redirect(admin_url('/options-general.php?page=yarpp'));
31
- die();
32
  }
33
 
34
  add_action('admin_init', array($this, 'ajax_register'));
@@ -793,7 +793,7 @@ class YARPP_Admin {
793
  $plugins[] = (object) array(
794
  'title_slugged' => sanitize_title($plugin_data['Name']),
795
  'basename' => plugin_basename(YARPP_MAIN_FILE),
796
- 'logo' => YARPP_URL . '/images/icon-256x256.png',
797
  'api_server' => 'yarpp.com',
798
  'script_cache_ver' => YARPP_VERSION,
799
  'bgcolor' => '#fff',
20
  /* If action = flush and the nonce is correct, reset the cache */
21
  if (isset($_GET['action']) && $_GET['action'] === 'flush' && check_ajax_referer('yarpp_cache_flush', false, false) !== false) {
22
  $this->core->cache->flush();
23
+ wp_safe_redirect(admin_url('/options-general.php?page=yarpp'));
24
+ exit;
25
  }
26
 
27
  /* If action = copy_templates and the nonce is correct, copy templates */
28
  if (isset($_GET['action']) && $_GET['action'] === 'copy_templates' && check_ajax_referer('yarpp_copy_templates', false, false) !== false) {
29
  $this->copy_templates();
30
+ wp_safe_redirect(admin_url('/options-general.php?page=yarpp'));
31
+ exit;
32
  }
33
 
34
  add_action('admin_init', array($this, 'ajax_register'));
793
  $plugins[] = (object) array(
794
  'title_slugged' => sanitize_title($plugin_data['Name']),
795
  'basename' => plugin_basename(YARPP_MAIN_FILE),
796
+ 'logo' => plugins_url('/images/icon-256x256.png', YARPP_MAIN_FILE),
797
  'api_server' => 'yarpp.com',
798
  'script_cache_ver' => YARPP_VERSION,
799
  'bgcolor' => '#fff',
classes/YARPP_Core.php CHANGED
@@ -181,7 +181,9 @@ class YARPP {
181
  'auto_display_post_types' => array('post'),
182
  'pools' => array(),
183
  'manually_using_thumbnails' => false,
184
- 'rest_api_display' => true
 
 
185
  );
186
  }
187
 
@@ -1075,7 +1077,7 @@ class YARPP {
1075
  /* If we're already in a YARPP loop, stop now. */
1076
  if ($this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time()) return false;
1077
  $this->enforce();
1078
- wp_enqueue_style('yarppRelatedCss', YARPP_URL.'/style/related.css');
1079
  $output = null;
1080
 
1081
  if (is_numeric($reference_ID)) {
181
  'auto_display_post_types' => array('post'),
182
  'pools' => array(),
183
  'manually_using_thumbnails' => false,
184
+ 'rest_api_display' => true,
185
+ 'rest_api_client_side_caching' => false,
186
+ 'yarpp_rest_api_cache_time' => 15
187
  );
188
  }
189
 
1077
  /* If we're already in a YARPP loop, stop now. */
1078
  if ($this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time()) return false;
1079
  $this->enforce();
1080
+ wp_enqueue_style('yarppRelatedCss', plugins_url('/style/related.css', YARPP_MAIN_FILE));
1081
  $output = null;
1082
 
1083
  if (is_numeric($reference_ID)) {
classes/YARPP_Meta_Box_Display_Feed.php CHANGED
@@ -13,7 +13,7 @@ class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
13
  $this->checkbox( 'rss_display', __( "Display related posts in feeds?", 'yarpp' )." <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( __( "This option displays related posts at the end of each item in your RSS and Atom feeds. No template changes are needed.", 'yarpp' ) ) . "'>&nbsp;</span>", '' );
14
  $this->checkbox( 'rss_excerpt_display', __( "Display related posts in the descriptions?", 'yarpp' )." <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( __( "This option displays the related posts in the RSS description fields, not just the content. If your feeds are set up to only display excerpts, however, only the description field is used, so this option is required for any display at all.", 'yarpp' ) ) . "'>&nbsp;</span>", 'rss_displayed' );
15
 
16
- $this->textbox( 'rss_limit', __( 'Maximum number of related posts:', 'yarpp' ), 2, 'rss_displayed' );
17
  $this->template_checkbox( true, 'rss_displayed' );
18
  echo "</div>";
19
 
@@ -21,7 +21,9 @@ class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
21
  $choice = false === $chosen_template ? 'builtin' :
22
  ( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
23
 
24
- echo "<div class='postbox yarpp_subbox template_options_custom rss_displayed'";
 
 
25
  if ( $choice != 'custom' )
26
  echo ' style="display: none;"';
27
  echo ">";
@@ -29,16 +31,15 @@ class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
29
  $this->template_file( true );
30
  echo "</div>";
31
 
32
- echo "<div class='postbox yarpp_subbox template_options_thumbnails'";
33
  if ( $choice != 'thumbnails' )
34
  echo ' style="display: none;"';
35
  echo ">";
36
  $this->textbox( 'rss_thumbnails_heading', __( 'Heading:', 'yarpp' ), 40 );
37
  $this->textbox( 'rss_thumbnails_default', __( 'Default image (URL):', 'yarpp' ), 40 );
38
- $this->textbox( 'rss_no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_rss_no_results' );
39
  echo "</div>";
40
 
41
- echo "<div class='postbox yarpp_subbox template_options_builtin rss_displayed'";
42
  if ( $choice != 'builtin' )
43
  echo ' style="display: none;"';
44
  echo ">";
@@ -49,10 +50,16 @@ class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
49
  $this->textbox( 'rss_excerpt_length', __( 'Excerpt length (No. of words):', 'yarpp' ), 10, 'excerpted' );
50
 
51
  $this->beforeafter( array( 'rss_before_post', 'rss_after_post' ), __( "Before / after (excerpt):", 'yarpp' ), 10, 'excerpted', __( "For example:", 'yarpp' ) . ' &lt;li&gt;&lt;/li&gt;' . __( ' or ', 'yarpp' ) . '&lt;dl&gt;&lt;/dl&gt;' );
52
-
53
- $this->textbox( 'rss_no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_rss_no_results' );
54
  echo "</div>";
55
 
 
 
 
 
 
 
 
 
56
  $this->displayorder( 'rss_order', 'rss_displayed' );
57
 
58
  $this->checkbox( 'rss_promote_yarpp', __( "Link to YARPP?", 'yarpp' ) . " <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( sprintf( __( "This option will add the code %s These links are greatly appreciated and keeps us motivated.", 'yarpp' ), "<code>" . htmlspecialchars( sprintf( __( "Powered by <a href='%s' title='WordPress Related Posts Plugin' target='_blank'>YARPP</a>.", 'yarpp' ), 'https://yarpp.com' ) )."</code>" ) ) . "'>&nbsp;</span>", 'rss_displayed' );
13
  $this->checkbox( 'rss_display', __( "Display related posts in feeds?", 'yarpp' )." <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( __( "This option displays related posts at the end of each item in your RSS and Atom feeds. No template changes are needed.", 'yarpp' ) ) . "'>&nbsp;</span>", '' );
14
  $this->checkbox( 'rss_excerpt_display', __( "Display related posts in the descriptions?", 'yarpp' )." <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( __( "This option displays the related posts in the RSS description fields, not just the content. If your feeds are set up to only display excerpts, however, only the description field is used, so this option is required for any display at all.", 'yarpp' ) ) . "'>&nbsp;</span>", 'rss_displayed' );
15
 
16
+ $this->textbox( 'rss_limit', __( 'Maximum number of posts:', 'yarpp' ), 2, 'rss_displayed' );
17
  $this->template_checkbox( true, 'rss_displayed' );
18
  echo "</div>";
19
 
21
  $choice = false === $chosen_template ? 'builtin' :
22
  ( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
23
 
24
+ // Wrap all the options in a div with a gray border
25
+ echo '<div class="postbox rss_displayed">';
26
+ echo "<div class='yarpp_subbox template_options_custom'";
27
  if ( $choice != 'custom' )
28
  echo ' style="display: none;"';
29
  echo ">";
31
  $this->template_file( true );
32
  echo "</div>";
33
 
34
+ echo "<div class='yarpp_subbox template_options_thumbnails'";
35
  if ( $choice != 'thumbnails' )
36
  echo ' style="display: none;"';
37
  echo ">";
38
  $this->textbox( 'rss_thumbnails_heading', __( 'Heading:', 'yarpp' ), 40 );
39
  $this->textbox( 'rss_thumbnails_default', __( 'Default image (URL):', 'yarpp' ), 40 );
 
40
  echo "</div>";
41
 
42
+ echo "<div class='yarpp_subbox template_options_builtin'";
43
  if ( $choice != 'builtin' )
44
  echo ' style="display: none;"';
45
  echo ">";
50
  $this->textbox( 'rss_excerpt_length', __( 'Excerpt length (No. of words):', 'yarpp' ), 10, 'excerpted' );
51
 
52
  $this->beforeafter( array( 'rss_before_post', 'rss_after_post' ), __( "Before / after (excerpt):", 'yarpp' ), 10, 'excerpted', __( "For example:", 'yarpp' ) . ' &lt;li&gt;&lt;/li&gt;' . __( ' or ', 'yarpp' ) . '&lt;dl&gt;&lt;/dl&gt;' );
 
 
53
  echo "</div>";
54
 
55
+ echo '<div class="yarpp_no_results">';
56
+ $this->textbox( 'rss_no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_rss_no_results' );
57
+ echo '</div>';
58
+
59
+ // Close the div that wraps all the options
60
+ echo '</div>';
61
+
62
+
63
  $this->displayorder( 'rss_order', 'rss_displayed' );
64
 
65
  $this->checkbox( 'rss_promote_yarpp', __( "Link to YARPP?", 'yarpp' ) . " <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( sprintf( __( "This option will add the code %s These links are greatly appreciated and keeps us motivated.", 'yarpp' ), "<code>" . htmlspecialchars( sprintf( __( "Powered by <a href='%s' title='WordPress Related Posts Plugin' target='_blank'>YARPP</a>.", 'yarpp' ), 'https://yarpp.com' ) )."</code>" ) ) . "'>&nbsp;</span>", 'rss_displayed' );
classes/YARPP_Meta_Box_Display_Rest_Api.php CHANGED
@@ -2,10 +2,18 @@
2
 
3
  class YARPP_Meta_Box_Display_Rest_Api extends YARPP_Meta_Box {
4
  public function display() {
5
- echo "<div>";
6
  $this->checkbox( 'rest_api_display', __( "Display related posts in REST API?", 'yarpp' )." <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( __( "This option adds related posts to the REST API.", 'yarpp' ) ) . "'>&nbsp;</span>", '' );
7
- echo '<a href="https://support.shareaholic.com/hc/en-us/articles/360046456752">';
8
- esc_html_e('Read the REST API documentation.', 'yarpp');
9
- echo "</a></div>";
 
 
 
 
 
 
 
 
10
  }
11
  }
2
 
3
  class YARPP_Meta_Box_Display_Rest_Api extends YARPP_Meta_Box {
4
  public function display() {
5
+
6
  $this->checkbox( 'rest_api_display', __( "Display related posts in REST API?", 'yarpp' )." <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( __( "This option adds related posts to the REST API.", 'yarpp' ) ) . "'>&nbsp;</span>", '' );
7
+ echo "<div class='yarpp_rest_displayed'>";
8
+ $this->checkbox( 'rest_api_client_side_caching', __( "Enable in-browser caching?", 'yarpp' )." <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( __( "Web browsers will be instructed to cache YARPP REST API results. This can dramatically increase the speed of subsequent YARPP REST API requests, but it also means stale content might be served for the length of the cache time.", 'yarpp' ) ) . "'>&nbsp;</span>", '' );
9
+ echo '<div class="yarpp_rest_browser_cache_displayed">';
10
+ $this->textbox('yarpp_rest_api_cache_time', __('Cache time (in minutes)', 'yarpp'));
11
+ echo '</div>';
12
+
13
+ echo '<a href="https://support.shareaholic.com/hc/en-us/articles/360046456752">';
14
+ esc_html_e('YARPP REST API documentation →', 'yarpp');
15
+ echo "</a>";
16
+
17
+ echo "</div>";
18
  }
19
  }
classes/YARPP_Meta_Box_Display_Web.php CHANGED
@@ -24,7 +24,7 @@ class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
24
 
25
  $this->checkbox( 'auto_display_archive', __( "Also display in archives", 'yarpp' ) );
26
 
27
- $this->textbox( 'limit', __( 'Maximum number of related posts:', 'yarpp' ) );
28
 
29
  $this->template_checkbox( false );
30
  echo "</div>";
@@ -33,7 +33,10 @@ class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
33
  $choice = false === $chosen_template ? 'builtin' :
34
  ( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
35
 
36
- echo "<div class='postbox yarpp_subbox template_options_custom'";
 
 
 
37
  if ( $choice != 'custom' )
38
  echo ' style="display: none;"';
39
  echo ">";
@@ -41,16 +44,15 @@ class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
41
  $this->template_file( false );
42
  echo "</div>";
43
 
44
- echo "<div class='postbox yarpp_subbox template_options_thumbnails'";
45
  if ( $choice != 'thumbnails' )
46
  echo ' style="display: none;"';
47
  echo ">";
48
  $this->textbox( 'thumbnails_heading', __( 'Heading:', 'yarpp' ), 40 );
49
  $this->textbox( 'thumbnails_default', __( 'Default image (URL):', 'yarpp' ), 40 );
50
- $this->textbox( 'no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_no_results' );
51
  echo "</div>";
52
 
53
- echo "<div class='postbox yarpp_subbox template_options_builtin'";
54
  if ( $choice != 'builtin' )
55
  echo ' style="display: none;"';
56
  echo ">";
@@ -61,10 +63,15 @@ class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
61
  $this->textbox( 'excerpt_length', __( 'Excerpt length (No. of words):', 'yarpp' ), 10, 'excerpted' );
62
 
63
  $this->beforeafter( array( 'before_post', 'after_post' ), __( "Before / after (excerpt):", 'yarpp' ), 10, 'excerpted', __( "For example:", 'yarpp' ) . ' &lt;li&gt;&lt;/li&gt;' . __( ' or ', 'yarpp' ) . '&lt;dl&gt;&lt;/dl&gt;' );
64
-
65
- $this->textbox( 'no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_no_results' );
66
  echo "</div>";
67
 
 
 
 
 
 
 
 
68
  $this->displayorder( 'order' );
69
  $this->checkbox( 'promote_yarpp', __( "Link to YARPP?", 'yarpp' ) . " <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( sprintf( __( "This option will add the code %s These links are greatly appreciated and keeps us motivated.", 'yarpp' ), "<code>" . htmlspecialchars( sprintf( __( "Powered by <a href='%s' title='WordPress Related Posts Plugin' target='_blank'>YARPP</a>.", 'yarpp' ), 'https://yarpp.com' ) )."</code>" ) ) . "'>&nbsp;</span>", 'yarpp' );
70
  }
24
 
25
  $this->checkbox( 'auto_display_archive', __( "Also display in archives", 'yarpp' ) );
26
 
27
+ $this->textbox( 'limit', __( 'Maximum number of posts:', 'yarpp' ) );
28
 
29
  $this->template_checkbox( false );
30
  echo "</div>";
33
  $choice = false === $chosen_template ? 'builtin' :
34
  ( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
35
 
36
+ // Wrap all the options in a div with a gray border
37
+ echo '<div class="postbox">';
38
+
39
+ echo "<div class='yarpp_subbox template_options_custom'";
40
  if ( $choice != 'custom' )
41
  echo ' style="display: none;"';
42
  echo ">";
44
  $this->template_file( false );
45
  echo "</div>";
46
 
47
+ echo "<div class='yarpp_subbox template_options_thumbnails'";
48
  if ( $choice != 'thumbnails' )
49
  echo ' style="display: none;"';
50
  echo ">";
51
  $this->textbox( 'thumbnails_heading', __( 'Heading:', 'yarpp' ), 40 );
52
  $this->textbox( 'thumbnails_default', __( 'Default image (URL):', 'yarpp' ), 40 );
 
53
  echo "</div>";
54
 
55
+ echo "<div class='yarpp_subbox template_options_builtin'";
56
  if ( $choice != 'builtin' )
57
  echo ' style="display: none;"';
58
  echo ">";
63
  $this->textbox( 'excerpt_length', __( 'Excerpt length (No. of words):', 'yarpp' ), 10, 'excerpted' );
64
 
65
  $this->beforeafter( array( 'before_post', 'after_post' ), __( "Before / after (excerpt):", 'yarpp' ), 10, 'excerpted', __( "For example:", 'yarpp' ) . ' &lt;li&gt;&lt;/li&gt;' . __( ' or ', 'yarpp' ) . '&lt;dl&gt;&lt;/dl&gt;' );
 
 
66
  echo "</div>";
67
 
68
+ echo '<div class="yarpp_no_results">';
69
+ $this->textbox( 'no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_no_results' );
70
+ echo '</div>';
71
+
72
+ // Close the div that wraps all the options
73
+ echo '</div>';
74
+
75
  $this->displayorder( 'order' );
76
  $this->checkbox( 'promote_yarpp', __( "Link to YARPP?", 'yarpp' ) . " <span class='yarpp_help dashicons dashicons-editor-help' data-help='" . esc_attr( sprintf( __( "This option will add the code %s These links are greatly appreciated and keeps us motivated.", 'yarpp' ), "<code>" . htmlspecialchars( sprintf( __( "Powered by <a href='%s' title='WordPress Related Posts Plugin' target='_blank'>YARPP</a>.", 'yarpp' ), 'https://yarpp.com' ) )."</code>" ) ) . "'>&nbsp;</span>", 'yarpp' );
77
  }
classes/YARPP_Meta_Box_Pool.php CHANGED
@@ -14,7 +14,13 @@ class YARPP_Meta_Box_Pool extends YARPP_Meta_Box {
14
  $exclude_tt_ids = wp_parse_id_list( yarpp_get_option( 'exclude' ) );
15
  $exclude_term_ids = $yarpp->admin->get_term_ids_from_tt_ids($taxonomy, $exclude_tt_ids);
16
  if ( count( $exclude_term_ids ) ) {
17
- $terms = get_terms( $taxonomy, array( 'include' => $exclude_term_ids ) );
 
 
 
 
 
 
18
  foreach ( $terms as $term ) {
19
  echo "<input type='checkbox' name='exclude[{$term->term_taxonomy_id}]' id='exclude_{$term->term_taxonomy_id}' value='true' checked='checked' /> <label for='exclude_{$term->term_taxonomy_id}'>" . esc_html( $term->name ) . "</label> ";
20
  }
14
  $exclude_tt_ids = wp_parse_id_list( yarpp_get_option( 'exclude' ) );
15
  $exclude_term_ids = $yarpp->admin->get_term_ids_from_tt_ids($taxonomy, $exclude_tt_ids);
16
  if ( count( $exclude_term_ids ) ) {
17
+ $terms = get_terms(
18
+ array(
19
+ 'taxonomy' => $taxonomy,
20
+ 'include' => $exclude_term_ids,
21
+ 'hide_empty' => false
22
+ )
23
+ );
24
  foreach ( $terms as $term ) {
25
  echo "<input type='checkbox' name='exclude[{$term->term_taxonomy_id}]' id='exclude_{$term->term_taxonomy_id}' value='true' checked='checked' /> <label for='exclude_{$term->term_taxonomy_id}'>" . esc_html( $term->name ) . "</label> ";
26
  }
classes/YARPP_Rest_Api.php CHANGED
@@ -204,9 +204,25 @@ class YARPP_Rest_Api extends WP_REST_Controller{
204
  }
205
  }
206
  $read_controller_response->set_data($ordered_rest_results);
 
207
  return $read_controller_response;
208
  }
209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  /**
211
  * @param string $post_type
212
  *
204
  }
205
  }
206
  $read_controller_response->set_data($ordered_rest_results);
207
+ $this->maybe_set_caching_headers($read_controller_response);
208
  return $read_controller_response;
209
  }
210
 
211
+ /**
212
+ * If enables, sends HTTP headers along with the response that instructs the browser to cache the results.
213
+ * @param WP_Rest_Response $response
214
+ */
215
+ protected function maybe_set_caching_headers(WP_Rest_Response $response){
216
+ global $yarpp;
217
+ if ($yarpp->get_option('rest_api_client_side_caching')) {
218
+ $seconds_to_cache = (int)$yarpp->get_option('yarpp_rest_api_cache_time') * MINUTE_IN_SECONDS;
219
+ $seconds_to_cache = max($seconds_to_cache, 0); // ensure non-negative values
220
+ $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
221
+ $response->header("Expires", $ts);
222
+ $response->header("Cache-Control", "public, max-age=$seconds_to_cache");
223
+ }
224
+ }
225
+
226
  /**
227
  * @param string $post_type
228
  *
classes/YARPP_Widget.php CHANGED
@@ -7,7 +7,7 @@ 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', YARPP_URL.'/style/widget.css');
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
+ wp_enqueue_style('yarppWidgetCss', plugins_url('/style/widget.css', YARPP_MAIN_FILE));
11
  }
12
 
13
  public function widget($args, $instance) {
includes/phtmls/yarpp_meta_box_pool.phtml CHANGED
@@ -34,7 +34,8 @@
34
 
35
  <div class='yarpp_form_row yarpp_form_checkbox'>
36
  <div>
37
- <input type='checkbox' name='recent_only' value='true' <?php checked((bool) $recent) ?> />
 
38
  <?php
39
 
40
  printf(
@@ -44,6 +45,7 @@
44
  $recent_units
45
  );
46
  ?>
 
47
  </div>
48
  </div>
49
 
34
 
35
  <div class='yarpp_form_row yarpp_form_checkbox'>
36
  <div>
37
+ <input type='checkbox' name='recent_only' id='yarpp-recent_only' value='true' <?php checked((bool) $recent) ?> />
38
+ <label for="yarpp-recent_only">
39
  <?php
40
 
41
  printf(
45
  $recent_units
46
  );
47
  ?>
48
+ </label>
49
  </div>
50
  </div>
51
 
js/options_basic.js CHANGED
@@ -10,6 +10,14 @@ jQuery(function($) {
10
 
11
  metabox.find('.yarpp_subbox').hide();
12
  metabox.find('.template_options_' + value).show();
 
 
 
 
 
 
 
 
13
  excerpt.apply(metabox);
14
  }
15
  $('.use_template').each(template).change(template);
@@ -75,6 +83,29 @@ jQuery(function($) {
75
  $('#yarpp-rss_display, #yarpp_display_rss .handlediv, #yarpp_display_rss-hide').click(rss_display);
76
  rss_display();
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  var loaded_disallows = false;
79
  function load_disallows() {
80
  if ( loaded_disallows || !$('#yarpp_pool .inside').is(':visible') )
10
 
11
  metabox.find('.yarpp_subbox').hide();
12
  metabox.find('.template_options_' + value).show();
13
+
14
+ var no_results_area = metabox.find('.yarpp_no_results');
15
+ // The "no_results" input is special. Its used by the non-custom templates.
16
+ if(value === 'custom'){
17
+ no_results_area.hide();
18
+ } else {
19
+ no_results_area.show();
20
+ }
21
  excerpt.apply(metabox);
22
  }
23
  $('.use_template').each(template).change(template);
83
  $('#yarpp-rss_display, #yarpp_display_rss .handlediv, #yarpp_display_rss-hide').click(rss_display);
84
  rss_display();
85
 
86
+
87
+ function yarpp_rest_display() {
88
+ if ( !$('#yarpp_display_api .inside').is(':visible') )
89
+ return;
90
+ if ( $('#yarpp-rest_api_display').is(':checked') ) {
91
+ $('.yarpp_rest_displayed').show();
92
+ } else {
93
+ $('.yarpp_rest_displayed').hide();
94
+ }
95
+ }
96
+ $('#yarpp-rest_api_display').click(yarpp_rest_display);
97
+ yarpp_rest_display();
98
+
99
+ function yarpp_rest_cache_display() {
100
+ if ( $('#yarpp-rest_api_client_side_caching').is(':checked') ) {
101
+ $('.yarpp_rest_browser_cache_displayed').show();
102
+ } else {
103
+ $('.yarpp_rest_browser_cache_displayed').hide();
104
+ }
105
+ }
106
+ $('#yarpp-rest_api_client_side_caching').click(yarpp_rest_cache_display);
107
+ yarpp_rest_cache_display();
108
+
109
  var loaded_disallows = false;
110
  function load_disallows() {
111
  if ( loaded_disallows || !$('#yarpp_pool .inside').is(':visible') )
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.5.0
9
 
10
  The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
11
 
@@ -20,9 +20,10 @@ The most popular plugin to display a list of related posts on your site based on
20
  * **Templating**: The YARPP templating system gives you advanced control of how your results are displayed.
21
  * **An advanced and versatile algorithm**: Using a customizable algorithm considering post titles, content, tags, categories, and custom taxonomies, YARPP finds related content from across your site.
22
  * **Related posts in feeds**: Display related posts in RSS feeds with custom display options.
 
 
23
  * **HTTPS support**
24
- * **Shortcode support** for placing related posts anywhere inside or outside the content ([documentation](https://wordpress.org/plugins/yet-another-related-posts-plugin/#%0Ahow%20can%20i%20move%20the%20related%20posts%20display%3F%0A))
25
- * **REST API support** ([documentation](https://support.shareaholic.com/hc/en-us/articles/360046456752))
26
  * **Professionally maintained** and supported with regular updates
27
 
28
  **YARPP Algorithm Explained**
@@ -72,10 +73,6 @@ You can place YARPP manually wherever you’d like in your theme within [The Loo
72
 
73
  == Frequently Asked Questions ==
74
 
75
- **Common Questions about YARPP **
76
-
77
- Below are Frequently Asked Questions about YARPP.
78
-
79
  If your question isn't here, ask your own question at [the WordPress.org forums](https://wordpress.org/support/plugin/yet-another-related-posts-plugin).
80
 
81
  = Many pages list "no related posts." =
@@ -285,6 +282,12 @@ add_action(
285
  `
286
 
287
  == Changelog ==
 
 
 
 
 
 
288
  = 5.5.0 (06-August-2020) =
289
  * New: Support for custom page types and taxonomies, including those added by WooCommerce
290
  * Enhancement: Show spinner while full-text indexes are being created
@@ -999,6 +1002,6 @@ After a break of many years, the plugin is 100% supported now that the baton has
999
  * Initial upload
1000
 
1001
  == Upgrade Notice ==
1002
- = 5.5.0 =
1003
  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!
1004
 
5
  Requires PHP: 5.3
6
  License: GPLv2 or later
7
  Tested up to: 5.5
8
+ Stable tag: 5.6.0
9
 
10
  The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
11
 
20
  * **Templating**: The YARPP templating system gives you advanced control of how your results are displayed.
21
  * **An advanced and versatile algorithm**: Using a customizable algorithm considering post titles, content, tags, categories, and custom taxonomies, YARPP finds related content from across your site.
22
  * **Related posts in feeds**: Display related posts in RSS feeds with custom display options.
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
 
29
  **YARPP Algorithm Explained**
73
 
74
  == Frequently Asked Questions ==
75
 
 
 
 
 
76
  If your question isn't here, ask your own question at [the WordPress.org forums](https://wordpress.org/support/plugin/yet-another-related-posts-plugin).
77
 
78
  = Many pages list "no related posts." =
282
  `
283
 
284
  == Changelog ==
285
+ = 5.6.0 (13-August-2020) =
286
+ * New: Configurable in-browser caching option for YARPP REST API
287
+ * Bugfix: Always include unused categories and terms in YARPP Admin options
288
+ * [Bugfix](https://wordpress.org/support/topic/support-for-multilingual-2/): Fixed issue with loading CSS files from wrong domain on multilingual sites
289
+ * Various Admin UI fixes
290
+
291
  = 5.5.0 (06-August-2020) =
292
  * New: Support for custom page types and taxonomies, including those added by WooCommerce
293
  * Enhancement: Show spinner while full-text indexes are being created
1002
  * Initial upload
1003
 
1004
  == Upgrade Notice ==
1005
+ = 5.6.0 =
1006
  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!
1007
 
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.5.0
6
  Author: YARPP
7
  Author URI: https://yarpp.com/
8
  Plugin URI: https://yarpp.com/
@@ -23,9 +23,13 @@ if(!defined('WP_CONTENT_DIR')){
23
  define('WP_CONTENT_DIR', substr($tr,0,strrpos($tr,'/')));
24
  }
25
 
26
- define('YARPP_VERSION', '5.5.0');
27
 
28
  define('YARPP_DIR', dirname(__FILE__));
 
 
 
 
29
  define('YARPP_URL', plugins_url('',__FILE__));
30
  define('YARPP_MAIN_FILE',__FILE__);
31
 
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.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.6.0');
27
 
28
  define('YARPP_DIR', dirname(__FILE__));
29
+ /**
30
+ * @deprecated Instead use plugins_url(...,YARPP_MAIN_FILE);. See https://wordpress.org/support/topic/support-for-multilingual-2/
31
+ * This may be removed after October 2020.
32
+ */
33
  define('YARPP_URL', plugins_url('',__FILE__));
34
  define('YARPP_MAIN_FILE',__FILE__);
35