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

Version Description

Download this release

Release Info

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

Code changes from version 3.2.3b2 to 3.2.3b3

Files changed (4) hide show
  1. includes.php +11 -15
  2. options.php +26 -17
  3. readme.txt +1 -0
  4. yarpp.php +2 -4
includes.php CHANGED
@@ -104,7 +104,7 @@ function yarpp_activate() {
104
 
105
  if (!get_option('yarpp_version')) {
106
  add_option('yarpp_version',YARPP_VERSION);
107
- yarpp_version_json(true);
108
  } else {
109
  yarpp_upgrade_check();
110
  }
@@ -140,7 +140,7 @@ function yarpp_upgrade_check() {
140
 
141
  $yarpp_cache->upgrade($last_version);
142
 
143
- yarpp_version_json(true);
144
 
145
  update_option('yarpp_version',YARPP_VERSION);
146
  }
@@ -356,23 +356,19 @@ function yarpp_microtime_float() {
356
  return ((float)$usec + (float)$sec);
357
  }
358
 
359
- function yarpp_version_json($enforce_cache = false) {
360
- if (!$enforce_cache)
361
- check_ajax_referer('yarpp_version_json');
362
-
363
- if ($enforce_cache || false === ($result = get_transient('yarpp_version_json'))) {
364
  $version = YARPP_VERSION;
365
- $remote = wp_remote_post("http://mitcho.com/code/yarpp/checkversion.php?version=$version");
366
 
367
- $result = (is_wp_error($remote) ? '{}' : $remote['body']);
 
368
 
369
- set_transient('yarpp_version_json', $result, 60*60*12);
 
370
  }
371
- if ($enforce_cache)
372
- return $result;
373
-
374
- echo $result;
375
- exit;
376
  }
377
 
378
  function yarpp_add_metabox() {
104
 
105
  if (!get_option('yarpp_version')) {
106
  add_option('yarpp_version',YARPP_VERSION);
107
+ yarpp_version_info(true);
108
  } else {
109
  yarpp_upgrade_check();
110
  }
140
 
141
  $yarpp_cache->upgrade($last_version);
142
 
143
+ yarpp_version_info(true);
144
 
145
  update_option('yarpp_version',YARPP_VERSION);
146
  }
356
  return ((float)$usec + (float)$sec);
357
  }
358
 
359
+ // new in 3.2.3: use PHP serialized format instead of JSON
360
+ function yarpp_version_info($enforce_cache = false) {
361
+ if (false === ($result = get_transient('yarpp_version_info')) || $enforce_cache) {
 
 
362
  $version = YARPP_VERSION;
363
+ $remote = wp_remote_post("http://mitcho.com/code/yarpp/checkversion.php?format=php&version={$version}");
364
 
365
+ if (is_wp_error($remote))
366
+ return false;
367
 
368
+ $result = unserialize($remote['body']);
369
+ set_transient('yarpp_version_info', $result, 60*60*12);
370
  }
371
+ return $result;
 
 
 
 
372
  }
373
 
374
  function yarpp_add_metabox() {
options.php CHANGED
@@ -20,6 +20,32 @@ if (!$yarpp_templateable) {
20
  yarpp_set_option('rss_use_template',false);
21
  }
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  if (isset($_POST['myisam_override'])) {
24
  yarpp_set_option('myisam_override',1);
25
  echo "<div class='updated'>"
@@ -240,23 +266,6 @@ do_meta_boxes('settings_page_yarpp', 'normal', array());
240
  load_display_demo_rss();
241
 
242
  var version = jQuery('#yarpp-version').html();
243
-
244
- <?php $ajax_nonce = wp_create_nonce('yarpp_version_json');?>
245
- jQuery.getJSON(ajaxurl,
246
- 'action=yarpp_version_json&_ajax_nonce=<?php echo $ajax_nonce; ?>',
247
- function(json) {
248
- if (json.result == 'newbeta')
249
- jQuery('#yarpp-version')
250
- .addClass('updated')
251
- .html(<?php echo "'<p>" . addslashes(sprintf(__("There is a new beta (%s) of Yet Another Related Posts Plugin. You can <a href=\"%s\">download it here</a> at your own risk.","yarpp"), "'+json.beta.version+'", "<a href=\"'+json.beta.url+'\">")) . "</p>'"; ?>)
252
- .show();
253
- if (json.result == 'new')
254
- jQuery('#yarpp-version')
255
- .addClass('updated')
256
- .html(<?php echo "'<p>" . addslashes(sprintf(__("There is a new version (%s) of Yet Another Related Posts Plugin available! You can <a href=\"%s\">download it here</a>.","yarpp"), "'+json.current.version+'", "'+json.current.url+'\"")) . "</p>'"; ?>)
257
- .show();
258
- }
259
- );
260
  }
261
 
262
  jQuery(yarpp_js_init);
20
  yarpp_set_option('rss_use_template',false);
21
  }
22
 
23
+ // 3.2.3: move version checking here, in PHP:
24
+ if ( current_user_can('update_plugins' ) ) {
25
+ $yarpp_version_info = yarpp_version_info();
26
+
27
+ $slug = 'yet-another-related-posts-plugin';
28
+ $plugin_name = __('Yet Another Related Posts Plugin', 'yarpp');
29
+ $file = basename(YARPP_DIR) . '/yarpp.php';
30
+ if ( $yarpp_version_info['result'] == 'new' ) {
31
+ // make sure the update system is aware of this version
32
+ $current = get_site_transient( 'update_plugins' );
33
+ if ( !isset( $current->response[ $file ] ) ) {
34
+ delete_site_transient( 'update_plugins' );
35
+ wp_update_plugins();
36
+ }
37
+
38
+ echo '<div class="updated"><p>';
39
+ $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $slug . '&TB_iframe=true&width=600&height=800');
40
+ printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update automatically</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $yarpp_version_info['current']['version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) );
41
+ echo '</p></div>';
42
+ } else if ( $yarpp_version_info['result'] == 'newbeta' ) {
43
+ echo '<div class="updated"><p>';
44
+ printf(__("There is a new beta (%s) of Yet Another Related Posts Plugin. You can <a href=\"%s\">download it here</a> at your own risk.","yarpp"), $yarpp_version_info['beta']['version'], $yarpp_version_info['beta']['url']);
45
+ echo '</p></div>';
46
+ }
47
+ }
48
+
49
  if (isset($_POST['myisam_override'])) {
50
  yarpp_set_option('myisam_override',1);
51
  echo "<div class='updated'>"
266
  load_display_demo_rss();
267
 
268
  var version = jQuery('#yarpp-version').html();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  }
270
 
271
  jQuery(yarpp_js_init);
readme.txt CHANGED
@@ -191,6 +191,7 @@ If you are a bilingual speaker of English and another language and an avid user
191
  * Pretty major rewrite to the options page for extensibility and screen options support
192
  * By default, the options screen now only show the display options. "The Pool" and "Relatedness" options can be shown in the screen options tab in the top right corner of the screen.
193
  * Removed the "reset options" button, because it wasn't actually doing anything.
 
194
  * Localizations
195
  * Quick fix to Czech word list file name
196
  * Updated Italian localization (`it_IT`)
191
  * Pretty major rewrite to the options page for extensibility and screen options support
192
  * By default, the options screen now only show the display options. "The Pool" and "Relatedness" options can be shown in the screen options tab in the top right corner of the screen.
193
  * Removed the "reset options" button, because it wasn't actually doing anything.
194
+ * Rebuilt the new version notice to actually have a link which triggers the WordPress plugin updater, at least for new full versions
195
  * Localizations
196
  * Quick fix to Czech word list file name
197
  * Updated Italian localization (`it_IT`)
yarpp.php CHANGED
@@ -3,7 +3,7 @@
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. A templating feature allows customization of the display.
6
- Version: 3.2.3b2
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  Author URI: http://mitcho.com/
9
  Donate link: http://tinyurl.com/donatetomitcho
@@ -13,10 +13,8 @@ Donate link: http://tinyurl.com/donatetomitcho
13
  if (isset($_REQUEST['yarpp_debug']))
14
  $yarpp_debug = true;
15
 
16
- define('YARPP_VERSION','3.2.3b2');
17
  define('YARPP_DIR',dirname(__FILE__));
18
- // 3.2.1: safer new version checking
19
- add_action('wp_ajax_yarpp_version_json', 'yarpp_version_json');
20
 
21
  require_once(YARPP_DIR.'/includes.php');
22
  require_once(YARPP_DIR.'/related-functions.php');
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. A templating feature allows customization of the display.
6
+ Version: 3.2.3b3
7
  Author: mitcho (Michael Yoshitaka Erlewine)
8
  Author URI: http://mitcho.com/
9
  Donate link: http://tinyurl.com/donatetomitcho
13
  if (isset($_REQUEST['yarpp_debug']))
14
  $yarpp_debug = true;
15
 
16
+ define('YARPP_VERSION','3.2.3b3');
17
  define('YARPP_DIR',dirname(__FILE__));
 
 
18
 
19
  require_once(YARPP_DIR.'/includes.php');
20
  require_once(YARPP_DIR.'/related-functions.php');