Yet Another Related Posts Plugin (YARPP) - Version 5.15.1

Version Description

(11-March-2021) = * Bugfix: fix issue pushing 5.15.0

Download this release

Release Info

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

Code changes from version 5.14.0 to 5.15.1

classes/YARPP_Admin.php CHANGED
@@ -521,17 +521,24 @@ class YARPP_Admin {
521
 
522
  wp_enqueue_style('wp-pointer');
523
  wp_enqueue_style('yarpp_options', plugins_url('style/options_basic.css', dirname(__FILE__)), array(), $version );
 
 
 
524
 
525
  wp_enqueue_script('postbox');
526
  wp_enqueue_script('wp-pointer');
 
527
  wp_enqueue_script('yarpp_options', plugins_url('js/options_basic.js', dirname(__FILE__)), array('jquery'), $version );
528
  // Localize the script with messages
529
  $translation_strings = array(
530
- 'alert_message' => __( 'This will delete all cache for YARPP.

Are you sure?', 'yarpp' ),
531
- 'success' => __( 'Cache cleared successfully!', 'yarpp' ),
532
- 'forbidden' => __( 'You are not allowed to do this!', 'yarpp' ),
533
- 'nonce_fail' => __( 'You left this page open for too long. Please refresh the page and try again!', 'yarpp' ),
534
- 'error' => __( 'There is some error!', 'yarpp' ),
 
 
 
535
  );
536
  wp_localize_script( 'yarpp_options', 'yarpp_messages', $translation_strings );
537
  }
521
 
522
  wp_enqueue_style('wp-pointer');
523
  wp_enqueue_style('yarpp_options', plugins_url('style/options_basic.css', dirname(__FILE__)), array(), $version );
524
+ wp_enqueue_style('yarpp_remodal', plugins_url('lib/plugin-deactivation-survey/remodal.css', dirname(__FILE__)), array(), $version );
525
+ wp_enqueue_style('yarpp_deactivate', plugins_url('lib/plugin-deactivation-survey/deactivate-feedback-form.css', dirname(__FILE__)), array(), $version );
526
+ wp_enqueue_style('yarpp_default_theme', plugins_url('lib/plugin-deactivation-survey/remodal-default-theme.css', dirname(__FILE__)), array(), $version );
527
 
528
  wp_enqueue_script('postbox');
529
  wp_enqueue_script('wp-pointer');
530
+ wp_enqueue_script('yarpp_remodal', plugins_url('lib/plugin-deactivation-survey/remodal.min.js', dirname(__FILE__)), array(), $version );
531
  wp_enqueue_script('yarpp_options', plugins_url('js/options_basic.js', dirname(__FILE__)), array('jquery'), $version );
532
  // Localize the script with messages
533
  $translation_strings = array(
534
+ 'alert_message' => __( 'This will clear all of YARPP’s cached related results.<br> Are you sure?', 'yarpp' ),
535
+ 'model_title' => __( 'YARPP Cache', 'yarpp' ),
536
+ 'success' => __( 'Cache cleared successfully!', 'yarpp' ),
537
+ 'logo' => plugins_url('/images/icon-256x256.png', YARPP_MAIN_FILE),
538
+ 'bgcolor'=> '#fff',
539
+ 'forbidden' => __( 'You are not allowed to do this!', 'yarpp' ),
540
+ 'nonce_fail' => __( 'You left this page open for too long. Please refresh the page and try again!', 'yarpp' ),
541
+ 'error' => __( 'There is some error. Please refresh the page and try again!', 'yarpp' ),
542
  );
543
  wp_localize_script( 'yarpp_options', 'yarpp_messages', $translation_strings );
544
  }
classes/YARPP_Cache.php CHANGED
@@ -464,20 +464,13 @@ abstract class YARPP_Cache {
464
  */
465
  protected function query_safely($wpdb_method, $args) {
466
  global $wpdb;
467
- $last_error = $wpdb->last_error;
468
- $wpdb->last_error = null;
469
- ob_start();
470
  $value = call_user_func_array(
471
  array( $wpdb, $wpdb_method ),
472
  $args
473
  );
474
  if ( $wpdb->last_error ) {
475
- ob_clean();
476
-
477
  return new WP_Error( 'yarpp_bad_db', $wpdb->last_error );
478
  }
479
- ob_flush();
480
- $wpdb->last_error = $last_error;
481
 
482
  return $value;
483
  }
464
  */
465
  protected function query_safely($wpdb_method, $args) {
466
  global $wpdb;
 
 
 
467
  $value = call_user_func_array(
468
  array( $wpdb, $wpdb_method ),
469
  $args
470
  );
471
  if ( $wpdb->last_error ) {
 
 
472
  return new WP_Error( 'yarpp_bad_db', $wpdb->last_error );
473
  }
 
 
474
 
475
  return $value;
476
  }
classes/YARPP_Core.php CHANGED
@@ -144,7 +144,7 @@ class YARPP {
144
 
145
  private function load_default_options() {
146
  $this->default_options = array(
147
- 'threshold' => 4,
148
  'limit' => 4,
149
  'excerpt_length' => 10,
150
  'recent' => false,
@@ -180,8 +180,8 @@ class YARPP {
180
  'myisam_override' => false,
181
  'exclude' => '',
182
  'weight' => array(
183
- 'title' => 1,
184
- 'body' => 1,
185
  'tax' => array(
186
  'category' => 1,
187
  'post_tag' => 1
@@ -310,13 +310,6 @@ class YARPP {
310
  }
311
 
312
  public function activate() {
313
- /*
314
- * If it's not known to be disabled, but the indexes aren't there.
315
- */
316
- if ( !$this->diagnostic_fulltext_indices()) {
317
- $this->enable_fulltext();
318
- }
319
-
320
  if ((bool) $this->cache->is_enabled() === false) {
321
  $this->cache->setup();
322
  }
@@ -365,19 +358,36 @@ class YARPP {
365
  * Attempts to add the fulltext indexes on the posts table.
366
  *
367
  * @since 5.1.8
 
368
  * @return bool
369
  */
370
  public function enable_fulltext() {
371
- /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  * If we haven't already re-attempted creating the database indexes and the database doesn't support adding
373
  * those indexes, disable it.
374
  */
375
  if (!(bool) $this->get_option(YARPP_DB_Options::YARPP_MYISAM_OVERRIDE) &&
376
  ! $this->db_schema->database_supports_fulltext_indexes()) {
377
- $this->disable_fulltext();
378
- return false;
379
  }
380
-
 
 
381
  if(! $this->db_schema->title_column_has_index()) {
382
  if ( $this->db_schema->add_title_index() ) {
383
  $this->db_options->delete_fulltext_db_error_record();
@@ -387,7 +397,10 @@ class YARPP {
387
  return false;
388
  }
389
  }
 
 
390
 
 
391
  if(! $this->db_schema->content_column_has_index()){
392
  if ( $this->db_schema->add_content_index()) {
393
  $this->db_options->delete_fulltext_db_error_record();
@@ -397,8 +410,7 @@ class YARPP {
397
  return false;
398
  }
399
  }
400
-
401
- return true;
402
  }
403
 
404
  /**
@@ -418,6 +430,21 @@ class YARPP {
418
  $this->set_option(array('threshold' => round($threshold / 2)));
419
  }
420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  /*
422
  * Try to retrieve fulltext index from database.
423
  * @return bool
144
 
145
  private function load_default_options() {
146
  $this->default_options = array(
147
+ 'threshold' => 1,
148
  'limit' => 4,
149
  'excerpt_length' => 10,
150
  'recent' => false,
180
  'myisam_override' => false,
181
  'exclude' => '',
182
  'weight' => array(
183
+ 'title' => 0,
184
+ 'body' => 0,
185
  'tax' => array(
186
  'category' => 1,
187
  'post_tag' => 1
310
  }
311
 
312
  public function activate() {
 
 
 
 
 
 
 
313
  if ((bool) $this->cache->is_enabled() === false) {
314
  $this->cache->setup();
315
  }
358
  * Attempts to add the fulltext indexes on the posts table.
359
  *
360
  * @since 5.1.8
361
+ * @deprecated use YARPP::enable_fulltext_titles() and YARPP::enable_fulltext_contents() instead
362
  * @return bool
363
  */
364
  public function enable_fulltext() {
365
+ _deprecated_function('YARPP::enable_fulltext','5.15.0');
366
+ if(! $this->db_supports_fulltext()){
367
+ return false;
368
+ }
369
+ if(! $this->enable_fulltext_titles()){
370
+ return false;
371
+ }
372
+ if( ! $this->enable_fulltext_contents()){
373
+ return false;
374
+ }
375
+ return true;
376
+ }
377
+
378
+ protected function db_supports_fulltext(){
379
+ /*
380
  * If we haven't already re-attempted creating the database indexes and the database doesn't support adding
381
  * those indexes, disable it.
382
  */
383
  if (!(bool) $this->get_option(YARPP_DB_Options::YARPP_MYISAM_OVERRIDE) &&
384
  ! $this->db_schema->database_supports_fulltext_indexes()) {
385
+ $this->disable_fulltext();
386
+ return false;
387
  }
388
+ return true;
389
+ }
390
+ public function enable_fulltext_titles(){
391
  if(! $this->db_schema->title_column_has_index()) {
392
  if ( $this->db_schema->add_title_index() ) {
393
  $this->db_options->delete_fulltext_db_error_record();
397
  return false;
398
  }
399
  }
400
+ return true;
401
+ }
402
 
403
+ public function enable_fulltext_contents(){
404
  if(! $this->db_schema->content_column_has_index()){
405
  if ( $this->db_schema->add_content_index()) {
406
  $this->db_options->delete_fulltext_db_error_record();
410
  return false;
411
  }
412
  }
413
+ return true;
 
414
  }
415
 
416
  /**
430
  $this->set_option(array('threshold' => round($threshold / 2)));
431
  }
432
 
433
+ /**
434
+ * Returns true if we consider this to be a big database (based on posts records); false otherwise.
435
+ * Uses the constants YARPP_BIG_DB
436
+ * @return bool
437
+ */
438
+ public function diagnostic_big_db(){
439
+ global $wpdb;
440
+ if(! defined('YARPP_BIG_DB')){
441
+ define('YARPP_BIG_DB', 2000);
442
+ }
443
+ $sql = 'SELECT count(*) FROM ' . $wpdb->posts;
444
+ $posts_count = $wpdb->get_var($sql);
445
+ return (int)$posts_count > YARPP_BIG_DB;
446
+ }
447
+
448
  /*
449
  * Try to retrieve fulltext index from database.
450
  * @return bool
classes/YARPP_DB_Options.php CHANGED
@@ -158,4 +158,11 @@ class YARPP_DB_Options {
158
  public function get_fulltext_db_error() {
159
  return (string)get_option(self::FULLTEXT_DB_ERROR, esc_html__( 'No error recorded.', 'yarpp' ));
160
  }
 
 
 
 
 
 
 
161
  }
158
  public function get_fulltext_db_error() {
159
  return (string)get_option(self::FULLTEXT_DB_ERROR, esc_html__( 'No error recorded.', 'yarpp' ));
160
  }
161
+
162
+ /**
163
+ * @return bool
164
+ */
165
+ public function has_fulltext_db_error() {
166
+ return (bool)get_option(self::FULLTEXT_DB_ERROR, false);
167
+ }
168
  }
classes/YARPP_Meta_Box.php CHANGED
@@ -73,7 +73,7 @@ class YARPP_Meta_Box {
73
  $weight = (int) yarpp_get_option("weight[$option]");
74
 
75
  /* Both require MyISAM fulltext indexing: */
76
- $fulltext = $this->yarpp->diagnostic_fulltext_indices() ? '' : ' readonly="readonly" disabled="disabled"';
77
 
78
  echo "<div class='yarpp_form_row yarpp_form_select'><div class='yarpp_form_label'>{$desc}</div><div>";
79
  echo "<select name='weight[{$option}]'>";
73
  $weight = (int) yarpp_get_option("weight[$option]");
74
 
75
  /* Both require MyISAM fulltext indexing: */
76
+ $fulltext = $this->yarpp->db_schema->database_supports_fulltext_indexes() ? '' : ' readonly="readonly" disabled="disabled"';
77
 
78
  echo "<div class='yarpp_form_row yarpp_form_select'><div class='yarpp_form_label'>{$desc}</div><div>";
79
  echo "<select name='weight[{$option}]'>";
classes/YARPP_Meta_Box_Relatedness.php CHANGED
@@ -23,7 +23,8 @@ class YARPP_Meta_Box_Relatedness extends YARPP_Meta_Box {
23
  */
24
  protected function disabled_warning(){
25
  global $yarpp, $wpdb;
26
- if ( $yarpp->db_schema->database_supports_fulltext_indexes() && ! $yarpp->diagnostic_fulltext_indices()) {
 
27
  ?>
28
  <div class='yarpp-callout yarpp-notice'>
29
  <p><?php
@@ -39,56 +40,60 @@ class YARPP_Meta_Box_Relatedness extends YARPP_Meta_Box {
39
  </a>
40
  </p>
41
  <div id="yarpp_fulltext_details" class="hidden">
42
- <?php if ( $database_supports_fulltext_indexes ){ ?>
43
- <p><?php esc_html_e('YARPP can automatically create "full-text indexes" to enable comparing posts based on titles and bodies. To do so, click the button below.');?></p>
44
- <?php } else { ?>
45
- <p><?php
46
- printf(
47
- esc_html__('Because full-text indexing is not supported by your current table engine, "%1$s", YARPP cannot compare posts based on their titles or bodies.','yarpp'),
48
- 'InnoDB',
49
- '5.6.4',
50
- '<code>' . $wpdb->posts . '</code>',
51
- 'MyISAM'
52
- );
53
- ?>
54
- </p>
55
- <p><?php
56
- printf(
57
- esc_html__('Please contact your host about updating MySQL to at latest version %1$s, or run the following SQL code on your MySQL client (eg PHPMyAdmin) or terminal:', 'yarpp'),
58
- '5.6.4'
59
- );
60
- ?>
61
- </p>
62
- <code class="yarpp_separated">ALTER TABLE `<?php echo $wpdb->posts;?>` ENGINE = MyISAM;</code>
63
- <p><?php
64
- esc_html_e('After you have done that, click the button below to enable comparing titles and bodies using full-text indexes."','yarpp');
65
- ?>
66
- </p>
67
- <?php } ?>
68
- <form method="post" class="yarpp_separated">
69
- <input type='submit' class='button yarpp_spin_on_click' name='myisam_override' value='Create FULLTEXT indexes'/>
70
- <span class="spinner"></span>
71
- </form>
72
  <p><?php
73
- esc_html_e(
74
- 'Note: although no data should be lost, it is always recommended to perform a full database backup before doing this.','yarpp'
75
- );
76
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  </p>
78
- <?php if( ! $database_supports_fulltext_indexes){ ?>
79
- <p>
80
- <?php
81
- printf(
82
- esc_html__('See MySQL %1$sstorage engines%2$s documentation for details on MySQL engines.','yarpp'),
83
- '<a href="https://dev.mysql.com/doc/refman/8.0/en/storage-engines.html" target="_blank">',
84
- '</a>'
85
- );
86
- ?>
87
- </p>
88
- <?php } ?>
89
  </div>
90
  </div>
91
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
93
  }
94
  }
23
  */
24
  protected function disabled_warning(){
25
  global $yarpp, $wpdb;
26
+ $database_supports_fulltext_indexes = $yarpp->db_schema->database_supports_fulltext_indexes();
27
+ if ( ! $database_supports_fulltext_indexes ) {
28
  ?>
29
  <div class='yarpp-callout yarpp-notice'>
30
  <p><?php
40
  </a>
41
  </p>
42
  <div id="yarpp_fulltext_details" class="hidden">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  <p><?php
44
+ printf(
45
+ esc_html__('Because full-text indexing is not supported by your current table engine, "%1$s", YARPP cannot compare posts based on their titles or bodies.','yarpp'),
46
+ 'InnoDB',
47
+ '5.6.4',
48
+ '<code>' . $wpdb->posts . '</code>',
49
+ 'MyISAM'
50
+ );
51
+ ?>
52
+ </p>
53
+ <p><?php
54
+ printf(
55
+ esc_html__('Please contact your host about updating MySQL to at latest version %1$s, or run the following SQL code on your MySQL client (eg PHPMyAdmin) or terminal:', 'yarpp'),
56
+ '5.6.4'
57
+ );
58
+ ?>
59
+ </p>
60
+ <p>
61
+ <?php
62
+ printf(
63
+ esc_html__('See MySQL %1$sstorage engines%2$s documentation for details on MySQL engines.','yarpp'),
64
+ '<a href="https://dev.mysql.com/doc/refman/8.0/en/storage-engines.html" target="_blank">',
65
+ '</a>'
66
+ );
67
+ ?>
68
  </p>
 
 
 
 
 
 
 
 
 
 
 
69
  </div>
70
  </div>
71
  <?php
72
+ } elseif($yarpp->diagnostic_big_db()){
73
+ // it's a big database. So while we *can* automatically add indexes, we need to warn the site owner.
74
+ ?>
75
+ <div class='yarpp-callout yarpp-notice'>
76
+ <p><?php esc_html_e('Enabling comparisons using titles or bodies will automatically add "fulltext indexes".', 'yarpp');?>
77
+ <a href="#" id="yarpp_fulltext_expand"><?php
78
+ printf(
79
+ // translators: icon to expand
80
+ __('Show Details %s','yarpp'),
81
+ '[+]'
82
+ );
83
+ ?>
84
+ </a>
85
+ </p>
86
+ <div id="yarpp_fulltext_details" class="hidden">
87
+ <p><?php esc_html_e('"Fulltext indexes" will improve YARPP’s algorithm but may affect performance.', 'yarpp');?></p>
88
+ <p><?php esc_html_e('You have a large database and so adding them may take several minutes and cause the website to become unresponsive during this time. We recommend performing this action during off-peak hours.', 'yarpp');?></p>
89
+ <p><?php esc_html_e('Please make a database backup before attempting this, and consider adding the indexes manually by running the following queries:', 'yarpp');?></p>
90
+ <code>
91
+ ALTER TABLE <?php echo $wpdb->posts;?> ADD FULLTEXT `yarpp_content` (`post_content`);
92
+ ALTER TABLE <?php echo $wpdb->posts;?> ADD FULLTEXT `yarpp_title` (`post_title`);
93
+ </code>
94
+ </div>
95
+ </div>
96
+ <?php
97
  }
98
  }
99
  }
includes/phtmls/yarpp_options.phtml CHANGED
@@ -47,8 +47,14 @@
47
  <?php wp_nonce_field( 'update_yarpp', 'update_yarpp-nonce' ); ?>
48
  </div>
49
  <br><br>
 
 
50
  <div>
51
- <p><input type="button" name="yarpp-clear-cache" id="yarpp-clear-cache" class="button-secondary" value="<?php _e("Empty cache", 'yarpp'); ?>"> <label for="yarpp-clear-cache"><small><?php _e('Use this button to manually clear YARPP cache', 'yarpp'); ?></small></label></p>
 
 
 
 
52
  <?php wp_nonce_field( 'clear_cache_yarpp', 'clear_cache-nonce' ); ?>
53
  </div>
54
 
47
  <?php wp_nonce_field( 'update_yarpp', 'update_yarpp-nonce' ); ?>
48
  </div>
49
  <br><br>
50
+ <div class="" id="display_notices" style="display: none;">
51
+ </div>
52
  <div>
53
+ <p>
54
+ <input type="button" name="yarpp-clear-cache" id="yarpp-clear-cache" class="button-secondary" value="<?php _e("Empty cache", 'yarpp'); ?>">
55
+ <span id="yarpp-clear-cache-label"><small><?php _e('Use this button to manually clear YARPP cache', 'yarpp'); ?></small></span>
56
+ <span class="spinner" style="float: none;"></span>
57
+ </p>
58
  <?php wp_nonce_field( 'clear_cache_yarpp', 'clear_cache-nonce' ); ?>
59
  </div>
60
 
includes/yarpp_myisam_notice.php CHANGED
@@ -2,35 +2,19 @@
2
  /**
3
  * @var $yarpp YARPP
4
  */
5
- if (isset($_POST['myisam_override'])) {
6
 
7
- yarpp_set_option(YARPP_DB_Options::YARPP_MYISAM_OVERRIDE, true);
8
- $enabled = $yarpp->enable_fulltext();
9
-
10
- if($enabled){
11
- ?>
12
- <div class="notice notice-success">
13
- <?php
14
- esc_html_e(
15
- 'Full-text indexes have been added to the posts table. You may now use titles and bodies as relatedness criteria.',
16
- 'yarpp'
17
- );
18
- ?></div>
19
  <?php
20
-
21
- } else {
22
-
23
- yarpp_set_option(YARPP_DB_Options::YARPP_MYISAM_OVERRIDE, 0);
24
- ?><div class="notice notice-error" >
25
- <span class="yarpp-red"><?php esc_html_e('Full-text Index creation did not work!','yarpp');?></span><br/>
26
- <?php
27
- printf(
28
- esc_html__( 'There was an error adding the full-text index to your posts table: %s', 'yarpp' ),
29
- $yarpp->db_options->get_fulltext_db_error()
30
- );
31
- ?><br/>
32
- <?php esc_html_e( 'Titles and bodies still cannot be used as relatedness criteria.', 'yarpp' ); ?>
33
- </div>
34
- <?php
35
- }
36
- }
2
  /**
3
  * @var $yarpp YARPP
4
  */
 
5
 
6
+ if($yarpp->db_options->has_fulltext_db_error()){
7
+ ?>
8
+ <div class="notice notice-error" >
9
+ <span class="yarpp-red"><?php esc_html_e('Full-text Index creation did not work!','yarpp');?></span><br/>
 
 
 
 
 
 
 
 
10
  <?php
11
+ printf(
12
+ esc_html__( 'There was an error adding the full-text index to your posts table: %s', 'yarpp' ),
13
+ $yarpp->db_options->get_fulltext_db_error()
14
+ );
15
+ $yarpp->db_options->delete_fulltext_db_error_record();
16
+ ?><br/>
17
+ <?php esc_html_e( 'Titles and bodies still cannot be used as relatedness criteria.', 'yarpp' ); ?>
18
+ </div>
19
+ <?php
20
+ }
 
 
 
 
 
 
 
includes/yarpp_options.php CHANGED
@@ -1,10 +1,11 @@
1
  <?php
 
 
 
 
 
2
  global $wpdb, $wp_version, $yarpp;
3
 
4
- if(!$yarpp->enabled() && !$yarpp->activate()) {
5
- echo '<div class="updated">'.__('The YARPP database has an error which could not be fixed.','yarpp').'</div>';
6
- }
7
-
8
  /* Check to see that templates are in the right place */
9
  if (!$yarpp->diagnostic_custom_templates()) {
10
 
@@ -83,6 +84,13 @@ if (isset($_POST['update_yarpp']) && check_admin_referer('update_yarpp', 'update
83
  if ( isset($_POST['weight']) ) {
84
  $new_options['weight'] = array();
85
  $new_options['require_tax'] = array();
 
 
 
 
 
 
 
86
  foreach ( (array) $_POST['weight'] as $key => $value) {
87
  if ( $value == 'consider' )
88
  $new_options['weight'][$key] = 1;
1
  <?php
2
+ /**
3
+ * @global $wpdb WPDB
4
+ * @global $wp_version string
5
+ * @global $yarpp YARPP
6
+ */
7
  global $wpdb, $wp_version, $yarpp;
8
 
 
 
 
 
9
  /* Check to see that templates are in the right place */
10
  if (!$yarpp->diagnostic_custom_templates()) {
11
 
84
  if ( isset($_POST['weight']) ) {
85
  $new_options['weight'] = array();
86
  $new_options['require_tax'] = array();
87
+ // if we're going to use titles or bodies, make sure those indexes exist.
88
+ if(isset($_POST['weight']['title']) && $_POST['weight']['title'] !== 'no'){
89
+ $yarpp->enable_fulltext_titles();
90
+ }
91
+ if(isset($_POST['weight']['body']) && $_POST['weight']['body'] !== 'no'){
92
+ $yarpp->enable_fulltext_contents();
93
+ }
94
  foreach ( (array) $_POST['weight'] as $key => $value) {
95
  if ( $value == 'consider' )
96
  $new_options['weight'][$key] = 1;
js/options_basic.js CHANGED
@@ -336,32 +336,72 @@ jQuery(function($) {
336
  $(this).text('Show Details [+]');
337
  }
338
  });
339
- $('#yarpp-clear-cache').click(function() {
340
- if ( confirm(yarpp_messages.alert_message) ){
341
- $.ajax({
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  type:'POST',
343
  url: ajaxurl,
344
  data: {
345
  action: 'yarpp_clear_cache',
346
- clear_cache: true,
347
  '_ajax_nonce': $('#clear_cache-nonce').val()
348
  },
 
 
 
349
  success:function(data){
350
- if( 'success' == data ) {
351
- var message = yarpp_messages.success;
352
- } else if( 'forbidden' == data ) {
353
- var message = yarpp_messages.forbidden;
354
- } else if( 'nonce_fail' == data ) {
355
- var message = yarpp_messages.nonce_fail;
356
- } else {
357
- var message = yarpp_messages.error;
358
- }
359
- alert(message);
 
 
 
 
 
360
  },
361
  error:function(data){
362
- alert(yarpp_messages.nonce_fail);
 
 
 
363
  }
364
  });
365
- }
366
  });
367
  });
336
  $(this).text('Show Details [+]');
337
  }
338
  });
339
+ var yarpp_model = $(
340
+ '\
341
+ <div id="shareaholic-deactivate-dialog" class="shareaholic-deactivate-dialog" data-remodal-id="">\
342
+ <div class="shareaholic-deactivate-header" style="background-image: url(' + yarpp_messages.logo + '); background-color: ' + yarpp_messages.bgcolor + ';"><div class="shareaholic-deactivate-text"><h2>' +yarpp_messages.model_title + '</h2></div></div>\
343
+ <div class="shareaholic-deactivate-body">\
344
+ <div class="shareaholic-deactivate-body-foreword">' + yarpp_messages.alert_message + '</div>\
345
+ <div class="shareaholic-deactivate-dialog-footer">\
346
+ <input type="submit" class="button confirm button-secondary" id="yarpp-clear-cache-submit" value="Delete"/>\
347
+ <button data-remodal-action="cancel" class="button button-secondary">Cancel</button>\
348
+ </div>\
349
+ </div>\
350
+ </div>\
351
+ '
352
+ )[0];
353
+ $('#yarpp-clear-cache').click(function() {
354
+ var inst = $(yarpp_model).remodal({hashTracking:false,closeOnOutsideClick:false});
355
+ inst.open();
356
+ event.preventDefault();
357
+ });
358
+ $( document.body ).on(
359
+ 'click',
360
+ '#yarpp-clear-cache-submit',
361
+ function() {
362
+ var inst = $(yarpp_model).remodal();
363
+ /**
364
+ * Closes the modal window
365
+ */
366
+ inst.close();
367
+ var cache_button = '#yarpp-clear-cache';
368
+ var display_notices = '#display_notices';
369
+ var notice_class = 'notice notice-error is-dismissible';
370
+ $(cache_button).prop( "disabled", true );
371
+ $.ajax({
372
  type:'POST',
373
  url: ajaxurl,
374
  data: {
375
  action: 'yarpp_clear_cache',
 
376
  '_ajax_nonce': $('#clear_cache-nonce').val()
377
  },
378
+ beforeSend: function() {
379
+ $(cache_button).siblings( '.spinner' ).addClass( 'is-active' );
380
+ },
381
  success:function(data){
382
+ $(cache_button).siblings( '.spinner' ).removeClass( 'is-active' );
383
+ $(display_notices).show();
384
+ if( 'success' == data ) {
385
+ var message = yarpp_messages.success;
386
+ notice_class = 'notice notice-success is-dismissible';
387
+ $(cache_button).prop( "disabled", false );
388
+ } else if( 'forbidden' == data ) {
389
+ var message = yarpp_messages.forbidden;
390
+ } else if( 'nonce_fail' == data ) {
391
+ var message = yarpp_messages.nonce_fail;
392
+ } else {
393
+ var message = yarpp_messages.error;
394
+ }
395
+ $(display_notices).addClass( notice_class );
396
+ $(display_notices).html('<p>' + message + '</p>');
397
  },
398
  error:function(data){
399
+ $(display_notices).show();
400
+ $(display_notices).addClass( notice_class );
401
+ $(cache_button).siblings( '.spinner' ).removeClass( 'is-active' );
402
+ $(display_notices).html('<p>' + yarpp_messages.error + '</p>');
403
  }
404
  });
405
+ $(display_notices).delay(5000).fadeOut(1000);
406
  });
407
  });
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.6
8
- Stable tag: 5.14.0
9
 
10
  The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
11
 
@@ -309,6 +309,15 @@ add_action(
309
  `
310
 
311
  == Changelog ==
 
 
 
 
 
 
 
 
 
312
  = 5.14.0 (9-March-2021) =
313
  * Enhancement: Improve pageload speed by avoiding checking YARPP database requirements on frontend requests
314
 
@@ -1091,5 +1100,5 @@ After a break of many years, the plugin is 100% supported now that the baton has
1091
  * Initial upload
1092
 
1093
  == Upgrade Notice ==
1094
- = 5.14.0 =
1095
  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.6
8
+ Stable tag: 5.15.1
9
 
10
  The most popular plugin to display a list of related posts on your site based on a powerful unique algorithm.
11
 
309
  `
310
 
311
  == Changelog ==
312
+ = 5.15.1 (11-March-2021) =
313
+ * Bugfix: fix issue pushing 5.15.0
314
+
315
+ = 5.15.0 (11-March-2021) =
316
+ * [Enhancement](https://wordpress.org/support/topic/5-14-0-rendered-our-site-unusable/): Default to not comparing using titles and bodies and only add database indexes when they are enabled to improve performance
317
+ * Enhancement: Default algorithm threshold changed from 4 to 1 to more reliably find related content on new installs
318
+ * Enhancement: Clear cache button uses modal dialogs instead of native browser alerts
319
+ * [Bugfix](https://wordpress.org/support/topic/breaking-layout-5-14-0-wp5-7-twenty-fifteen/): apparent Oxygen Builder conflict
320
+
321
  = 5.14.0 (9-March-2021) =
322
  * Enhancement: Improve pageload speed by avoiding checking YARPP database requirements on frontend requests
323
 
1100
  * Initial upload
1101
 
1102
  == Upgrade Notice ==
1103
+ = 5.15.1 =
1104
  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.14.0
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.14.0');
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.15.1
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.15.1');
28
 
29
  define('YARPP_DIR', dirname(__FILE__));
30
  /**