Yet Another Related Posts Plugin (YARPP) - Version 4.0.1b2

Version Description

Download this release

Release Info

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

Code changes from version 4.0.1b1 to 4.0.1b2

Files changed (6) hide show
  1. class-cache.php +2 -2
  2. class-core.php +7 -6
  3. class-widget.php +33 -31
  4. options-meta-boxes.php +0 -3
  5. readme.txt +2 -0
  6. yarpp.php +2 -2
class-cache.php CHANGED
@@ -168,8 +168,8 @@ abstract class YARPP_Cache {
168
$newsql .= " + (MATCH (post_title) AGAINST ('".$wpdb->escape($keywords['title'])."')) * ". absint($weight['title']);
169
170
// Build tax criteria query parts based on the weights
171
- foreach ( (array) $weight['tax'] as $tax => $weight ) {
172
- $newsql .= " + " . $this->tax_criteria($reference_ID, $tax) . " * " . intval($weight);
173
}
174
175
$newsql .= ',1) as score';
168
$newsql .= " + (MATCH (post_title) AGAINST ('".$wpdb->escape($keywords['title'])."')) * ". absint($weight['title']);
169
170
// Build tax criteria query parts based on the weights
171
+ foreach ( (array) $weight['tax'] as $tax => $tax_weight ) {
172
+ $newsql .= " + " . $this->tax_criteria($reference_ID, $tax) . " * " . intval($tax_weight);
173
}
174
175
$newsql .= ',1) as score';
class-core.php CHANGED
@@ -1108,19 +1108,20 @@ class YARPP {
1108
return true;
1109
1110
$remote = wp_remote_post( 'http://yarpp.org/optin/1/', array( 'body' => $this->optin_data() ) );
1111
-
1112
- if ( is_wp_error($remote) )
1113
return false;
1114
-
1115
- if ( $result = $remote['body'] )
1116
- $this->set_timeout( 'yarpp_optin', 60 * 60 * 24 * 7 );
1117
}
1118
1119
// a version of the transient functions which is unaffected by caching plugin behavior.
1120
// we want to store this long.
1121
private function get_timeout( $transient ) {
1122
$transient_timeout = $transient . '_timeout';
1123
- if ( get_option( $transient_timeout ) < time() ) {
1124
delete_option( $transient_timeout );
1125
return false; // timed out
1126
}
1108
return true;
1109
1110
$remote = wp_remote_post( 'http://yarpp.org/optin/1/', array( 'body' => $this->optin_data() ) );
1111
+ if ( is_wp_error($remote) || !isset($remote['body']) || $remote['body'] != 'ok' ) {
1112
+ // try again later
1113
+ $this->set_timeout( 'yarpp_optin', 60 * 60 );
1114
return false;
1115
+ }
1116
+ $this->set_timeout( 'yarpp_optin', 60 * 60 * 24 * 7 );
1117
+ return true;
1118
}
1119
1120
// a version of the transient functions which is unaffected by caching plugin behavior.
1121
// we want to store this long.
1122
private function get_timeout( $transient ) {
1123
$transient_timeout = $transient . '_timeout';
1124
+ if ( intval( get_option( $transient_timeout ) ) < time() ) {
1125
delete_option( $transient_timeout );
1126
return false; // timed out
1127
}
class-widget.php CHANGED
@@ -78,41 +78,43 @@ class YARPP_Widget extends WP_Widget {
78
if ( isset($instance['use_template']) )
79
$instance['template'] = $instance['template_file'];
80
81
// if there are YARPP templates installed...
82
$templates = $yarpp->admin->get_templates();
83
- if ( count($templates) ):
84
- $choice = false === $instance['template'] ? 'builtin' :
85
- ( $instance['template'] == 'thumbnails' ? 'thumbnails' : 'custom' );
86
- ?>
87
88
- <p>
89
- <label style="padding-right: 10px;" for="<?php echo $this->get_field_id('use_template_builtin'); ?>"><input id="<?php echo $this->get_field_id('use_template_builtin'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="radio" value="builtin" <?php checked( $choice == 'builtin' ) ?> /> <?php _e( "List", 'yarpp' ); ?></label>
90
91
- <label style="padding-right: 10px;" for="<?php echo $this->get_field_id('use_template_thumbnails'); ?>"><input id="<?php echo $this->get_field_id('use_template_thumbnails'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="radio" value="thumbnails" <?php checked( $choice == 'thumbnails' ) ?> /> <?php _e( "Thumbnails", 'yarpp' ); ?></label>
92
-
93
- <label style="padding-right: 10px;" for="<?php echo $this->get_field_id('use_template_custom'); ?>"><input id="<?php echo $this->get_field_id('use_template_custom'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="radio" value="custom" <?php checked( $choice == 'custom' ) ?> /> <?php _e( "Custom", 'yarpp' ); ?></label>
94
- </p>
95
-
96
- <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" /></label></p>
97
-
98
- <p><label for="<?php echo $this->get_field_id('template_file'); ?>"><?php _e("Template file:",'yarpp');?></label> <select name="<?php echo $this->get_field_name('template_file'); ?>" id="<?php echo $this->get_field_id('template_file'); ?>">
99
- <?php foreach ($templates as $template): ?>
100
- <option value='<?php echo esc_attr($template['basename']); ?>'<?php selected($template['basename'], $instance['template']);?>><?php echo esc_html($template['name']); ?></option>
101
- <?php endforeach; ?>
102
- </select><p>
103
- <script type="text/javascript">
104
- jQuery(function($) {
105
- function ensureTemplateChoice() {
106
- var custom = $('#<?php echo $this->get_field_id('use_template_custom'); ?>').prop('checked');
107
- var builtin = $('#<?php echo $this->get_field_id('use_template_builtin'); ?>').prop('checked');
108
- $('#<?php echo $this->get_field_id('title'); ?>').closest('p').toggle(!!builtin);
109
- $('#<?php echo $this->get_field_id('template_file'); ?>').closest('p').toggle(!!custom);
110
- }
111
- $('input[name="<?php echo $this->get_field_name('use_template'); ?>"]').change(ensureTemplateChoice);
112
- ensureTemplateChoice();
113
- });
114
- </script>
115
- <?php endif; ?>
116
117
<p><input class="checkbox" id="<?php echo $this->get_field_id('promote_yarpp'); ?>" name="<?php echo $this->get_field_name('promote_yarpp'); ?>" type="checkbox" <?php checked($instance['promote_yarpp']) ?> /> <label for="<?php echo $this->get_field_id('promote_yarpp'); ?>"><?php _e("Help promote Yet Another Related Posts Plugin?",'yarpp'); ?></label></p>
118
<?php
78
if ( isset($instance['use_template']) )
79
$instance['template'] = $instance['template_file'];
80
81
+ $choice = false === $instance['template'] ? 'builtin' :
82
+ ( $instance['template'] == 'thumbnails' ? 'thumbnails' : 'custom' );
83
+
84
// if there are YARPP templates installed...
85
$templates = $yarpp->admin->get_templates();
86
+ if ( !count($templates) && $choice == 'custom' )
87
+ $choice = 'builtin';
88
+
89
+ ?>
90
91
+ <p>
92
+ <label style="padding-right: 10px;" for="<?php echo $this->get_field_id('use_template_builtin'); ?>"><input id="<?php echo $this->get_field_id('use_template_builtin'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="radio" value="builtin" <?php checked( $choice == 'builtin' ) ?> /> <?php _e( "List", 'yarpp' ); ?></label>
93
+
94
+ <label style="padding-right: 10px;" for="<?php echo $this->get_field_id('use_template_thumbnails'); ?>"><input id="<?php echo $this->get_field_id('use_template_thumbnails'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="radio" value="thumbnails" <?php checked( $choice == 'thumbnails' ) ?> /> <?php _e( "Thumbnails", 'yarpp' ); ?></label>
95
96
+ <label style="padding-right: 10px;" for="<?php echo $this->get_field_id('use_template_custom'); ?>"><input id="<?php echo $this->get_field_id('use_template_custom'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="radio" value="custom" <?php checked( $choice == 'custom' ); disabled( !count($templates) ); ?> /> <?php _e( "Custom", 'yarpp' ); ?></label>
97
+ </p>
98
+
99
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" /></label></p>
100
+
101
+ <p><label for="<?php echo $this->get_field_id('template_file'); ?>"><?php _e("Template file:",'yarpp');?></label> <select name="<?php echo $this->get_field_name('template_file'); ?>" id="<?php echo $this->get_field_id('template_file'); ?>">
102
+ <?php foreach ($templates as $template): ?>
103
+ <option value='<?php echo esc_attr($template['basename']); ?>'<?php selected($template['basename'], $instance['template']);?>><?php echo esc_html($template['name']); ?></option>
104
+ <?php endforeach; ?>
105
+ </select><p>
106
+ <script type="text/javascript">
107
+ jQuery(function($) {
108
+ function ensureTemplateChoice() {
109
+ var custom = $('#<?php echo $this->get_field_id('use_template_custom'); ?>').prop('checked');
110
+ var builtin = $('#<?php echo $this->get_field_id('use_template_builtin'); ?>').prop('checked');
111
+ $('#<?php echo $this->get_field_id('title'); ?>').closest('p').toggle(!!builtin);
112
+ $('#<?php echo $this->get_field_id('template_file'); ?>').closest('p').toggle(!!custom);
113
+ }
114
+ $('input[name="<?php echo $this->get_field_name('use_template'); ?>"]').change(ensureTemplateChoice);
115
+ ensureTemplateChoice();
116
+ });
117
+ </script>
118
119
<p><input class="checkbox" id="<?php echo $this->get_field_id('promote_yarpp'); ?>" name="<?php echo $this->get_field_name('promote_yarpp'); ?>" type="checkbox" <?php checked($instance['promote_yarpp']) ?> /> <label for="<?php echo $this->get_field_id('promote_yarpp'); ?>"><?php _e("Help promote Yet Another Related Posts Plugin?",'yarpp'); ?></label></p>
120
<?php
options-meta-boxes.php CHANGED
@@ -416,9 +416,6 @@ class YARPP_Meta_Box_Optin extends YARPP_Meta_Box {
416
function display() {
417
global $yarpp;
418
419
- if ( $yarpp->get_option( 'optin' ) )
420
- $yarpp->optin_ping();
421
-
422
// TODO: fix this text and i18nize it
423
echo "<input type='checkbox' id='yarpp-optin' name='optin' value='true'";
424
checked( yarpp_get_option( 'optin' ) == 1 );
416
function display() {
417
global $yarpp;
418
419
// TODO: fix this text and i18nize it
420
echo "<input type='checkbox' id='yarpp-optin' name='optin' value='true'";
421
checked( yarpp_get_option( 'optin' ) == 1 );
readme.txt CHANGED
@@ -247,6 +247,8 @@ If you are a bilingual speaker of English and another language and an avid user
247
* Thumbnail size can be specified by adding `add_image_size( 'yarpp-thumbnail', $width, $height, true );` to your theme's `functions.php` file. In the future I may add some UI to the settings to also set this... feedback is requested on whether this is a good idea.
248
* Fixed a typo and simplified an item in the dynamic `styles-thumbnails.php` styles
249
* Bugfix: a class of `yarpp-related-` with a stray hyphen was sometimes being produced. Now fixed so it produces `yarpp-related`.
250
* Bugfix: some transients expired too soon if object caching was used
251
* The `yarpp_map_post_types` filter now also applies to feeds and takes an extra argument to know whether the context is `website` or `rss`.
252
247
* Thumbnail size can be specified by adding `add_image_size( 'yarpp-thumbnail', $width, $height, true );` to your theme's `functions.php` file. In the future I may add some UI to the settings to also set this... feedback is requested on whether this is a good idea.
248
* Fixed a typo and simplified an item in the dynamic `styles-thumbnails.php` styles
249
* Bugfix: a class of `yarpp-related-` with a stray hyphen was sometimes being produced. Now fixed so it produces `yarpp-related`.
250
+ * [Bugfix](http://wordpress.org/support/topic/bug-in-sql-function-in-yarpp_cache): `term_relationships` table was being joined when unnecessary
251
+ * [Bugfix](http://wordpress.org/support/topic/no-option-to-add-widget-title-in-theme-using-hybrid-core-framework): widget options would not display if custom templates were not available
252
* Bugfix: some transients expired too soon if object caching was used
253
* The `yarpp_map_post_types` filter now also applies to feeds and takes an extra argument to know whether the context is `website` or `rss`.
254
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.1b1
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.1b1');
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.1b2
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.1b2');
13
define('YARPP_DIR', dirname(__FILE__));
14
define('YARPP_NO_RELATED', ':(');
15
define('YARPP_RELATED', ':)');