Yet Another Related Posts Plugin (YARPP) - Version 4.0.4b3

Version Description

Download this release

Release Info

Developer mitchoyoshitaka
Plugin Icon 128x128 Yet Another Related Posts Plugin (YARPP)
Version 4.0.4b3
Comparing to
See all releases

Code changes from version 4.0.4b2 to 4.0.4b3

Files changed (3) hide show
  1. class-core.php +33 -10
  2. readme.txt +1 -0
  3. yarpp.php +2 -2
class-core.php CHANGED
@@ -1212,16 +1212,23 @@ class YARPP {
1212
 
1213
  // @since 3.3: use PHP serialized format instead of JSON
1214
  function version_info( $enforce_cache = false ) {
1215
- if (false === ($result = $this->get_transient('yarpp_version_info')) || $enforce_cache) {
1216
- $version = YARPP_VERSION;
1217
- $remote = wp_remote_post("http://yarpp.org/checkversion.php?format=php&version={$version}");
1218
-
1219
- if (is_wp_error($remote))
1220
- return false;
1221
-
1222
- if ( $result = @unserialize($remote['body']) )
1223
- $this->set_transient('yarpp_version_info', $result, 60 * 60 * 24);
 
 
 
1224
  }
 
 
 
 
1225
  return $result;
1226
  }
1227
 
@@ -1231,7 +1238,10 @@ class YARPP {
1231
  return true;
1232
 
1233
  $remote = wp_remote_post( 'http://yarpp.org/optin/2/', array( 'body' => $this->optin_data() ) );
1234
- if ( is_wp_error($remote) || !isset($remote['body']) || $remote['body'] != 'ok' ) {
 
 
 
1235
  // try again later
1236
  $this->set_transient( 'yarpp_optin', null, 60 * 60 );
1237
  return false;
@@ -1262,6 +1272,7 @@ class YARPP {
1262
  if ( !is_null( $data ) )
1263
  update_option( $transient, $data );
1264
  }
 
1265
  }
1266
 
1267
  private function delete_transient( $transient ) {
@@ -1269,6 +1280,18 @@ class YARPP {
1269
  delete_option( $transient . '_timeout' );
1270
  }
1271
 
 
 
 
 
 
 
 
 
 
 
 
 
1272
  // 3.5.2: clean_pre is deprecated in WP 3.4, so implement here.
1273
  function clean_pre( $text ) {
1274
  $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text);
1212
 
1213
  // @since 3.3: use PHP serialized format instead of JSON
1214
  function version_info( $enforce_cache = false ) {
1215
+ if ( !$enforce_cache && false !== ($result = $this->get_transient('yarpp_version_info')) )
1216
+ return $result;
1217
+
1218
+ $version = YARPP_VERSION;
1219
+ $remote = wp_remote_post("http://yarpp.org/checkversion.php?format=php&version={$version}");
1220
+
1221
+ if ( is_wp_error($remote) ||
1222
+ wp_remote_retrieve_response_code( $remote ) != 200 ||
1223
+ !isset($remote['body']) ) {
1224
+ // try again later
1225
+ $this->set_transient('yarpp_version_info', null, 60 * 60);
1226
+ return false;
1227
  }
1228
+
1229
+ if ( $result = @unserialize($remote['body']) )
1230
+ $this->set_transient('yarpp_version_info', $result, 60 * 60 * 24);
1231
+
1232
  return $result;
1233
  }
1234
 
1238
  return true;
1239
 
1240
  $remote = wp_remote_post( 'http://yarpp.org/optin/2/', array( 'body' => $this->optin_data() ) );
1241
+ if ( is_wp_error($remote) ||
1242
+ wp_remote_retrieve_response_code( $remote ) != 200 ||
1243
+ !isset($remote['body']) ||
1244
+ $remote['body'] != 'ok' ) {
1245
  // try again later
1246
  $this->set_transient( 'yarpp_optin', null, 60 * 60 );
1247
  return false;
1272
  if ( !is_null( $data ) )
1273
  update_option( $transient, $data );
1274
  }
1275
+ $this->kick_other_caches();
1276
  }
1277
 
1278
  private function delete_transient( $transient ) {
1280
  delete_option( $transient . '_timeout' );
1281
  }
1282
 
1283
+ // 4.0.4: helper function to force other caching systems which are too aggressive
1284
+ // <cough>DB Cache Reloaded (Fix)</cough> to flush when YARPP transients are set.
1285
+ private function kick_other_caches() {
1286
+ if ( class_exists( 'DBCacheReloaded' ) ) {
1287
+ global $wp_db_cache_reloaded;
1288
+ if ( is_object( $wp_db_cache_reloaded ) && is_a( $wp_db_cache_reloaded, 'DBCacheReloaded' ) ) {
1289
+ // if DBCR offered a more granualar way of just flushing options, I'd love that.
1290
+ $wp_db_cache_reloaded->dbcr_clear();
1291
+ }
1292
+ }
1293
+ }
1294
+
1295
  // 3.5.2: clean_pre is deprecated in WP 3.4, so implement here.
1296
  function clean_pre( $text ) {
1297
  $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text);
readme.txt CHANGED
@@ -261,6 +261,7 @@ If you are a bilingual speaker of English and another language and an avid user
261
  * [Bugfix](https://wordpress.org/support/topic/yarp-403-breaks-paginated-posts): 4.0.3 broke some paginated post displays
262
  * [Bugfix](https://wordpress.org/support/topic/custom-post-type-support-on-widget): custom post type support was not working properly in widget displays
263
  * Updated French localization and stopword list
 
264
 
265
  = 4.0.3 =
266
  * Bugfix: on sites where custom templates are not available, the "thumbnails" display option would get reset when visiting the YARPP settings page
261
  * [Bugfix](https://wordpress.org/support/topic/yarp-403-breaks-paginated-posts): 4.0.3 broke some paginated post displays
262
  * [Bugfix](https://wordpress.org/support/topic/custom-post-type-support-on-widget): custom post type support was not working properly in widget displays
263
  * Updated French localization and stopword list
264
+ * Bugfix: forces the DB Cache Reloaded (Fix) plugins to flush when necessary
265
 
266
  = 4.0.3 =
267
  * Bugfix: on sites where custom templates are not available, the "thumbnails" display option would get reset when visiting the YARPP settings page
yarpp.php CHANGED
@@ -3,13 +3,13 @@
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://yarpp.org/
5
  Description: Returns a list of related entries based on a unique algorithm for display on your blog and RSS feeds. Now with Now with thumbnail support built-in!
6
- Version: 4.0.4b2
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  Author URI: http://mitcho.com/
9
  Donate link: http://tinyurl.com/donatetomitcho
10
  */
11
 
12
- define('YARPP_VERSION', '4.0.4b2');
13
  define('YARPP_DIR', dirname(__FILE__));
14
  define('YARPP_NO_RELATED', ':(');
15
  define('YARPP_RELATED', ':)');
3
  Plugin Name: Yet Another Related Posts Plugin
4
  Plugin URI: http://yarpp.org/
5
  Description: Returns a list of related entries based on a unique algorithm for display on your blog and RSS feeds. Now with Now with thumbnail support built-in!
6
+ Version: 4.0.4b3
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  Author URI: http://mitcho.com/
9
  Donate link: http://tinyurl.com/donatetomitcho
10
  */
11
 
12
+ define('YARPP_VERSION', '4.0.4b3');
13
  define('YARPP_DIR', dirname(__FILE__));
14
  define('YARPP_NO_RELATED', ':(');
15
  define('YARPP_RELATED', ':)');