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

Version Description

Download this release

Release Info

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

Code changes from version 3.5.3 to 3.5.4b2

cache-postmeta.php CHANGED
@@ -53,6 +53,11 @@ class YARPP_Cache_Postmeta extends YARPP_Cache {
53
LIMIT $limit OFFSET $offset");
54
}
55
56
/**
57
* MAGIC FILTERS
58
*/
53
LIMIT $limit OFFSET $offset");
54
}
55
56
+ public function stats() {
57
+ global $wpdb;
58
+ return wp_list_pluck($wpdb->get_results("select num, count(*) as ct from (select 0 + if(meta_value = '" . YARPP_NO_RELATED . "', 0, substring(substring_index(meta_value,':',2),3)) as num from `{$wpdb->postmeta}` where meta_key = '" . YARPP_POSTMETA_RELATED_KEY . "') as t group by num order by num asc", OBJECT_K), 'ct');
59
+ }
60
+
61
/**
62
* MAGIC FILTERS
63
*/
cache-tables.php CHANGED
@@ -87,6 +87,11 @@ class YARPP_Cache_Tables extends YARPP_Cache {
87
WHERE p.post_status = 'publish' and c.ID IS NULL
88
LIMIT $limit OFFSET $offset");
89
}
90
91
/**
92
* MAGIC FILTERS
87
WHERE p.post_status = 'publish' and c.ID IS NULL
88
LIMIT $limit OFFSET $offset");
89
}
90
+
91
+ public function stats() {
92
+ global $wpdb;
93
+ return wp_list_pluck($wpdb->get_results("select num, count(*) as ct from (select 0 + if(id = 0, 0, count(ID)) as num from {$wpdb->prefix}yarpp_related_cache group by reference_ID) as t group by num order by num asc", OBJECT_K), 'ct');
94
+ }
95
96
/**
97
* MAGIC FILTERS
class-cache.php CHANGED
@@ -298,8 +298,7 @@ abstract class YARPP_Cache {
298
299
$lang = 'en_US';
300
if ( defined('WPLANG') ) {
301
- $lang = substr(WPLANG, 0, 2);
302
- switch ( $lang ) {
303
case 'de':
304
$lang = 'de_DE';
305
case 'it':
@@ -314,6 +313,8 @@ abstract class YARPP_Cache {
314
$lang = 'cs_CZ';
315
case 'nl':
316
$lang = 'nl_NL';
317
}
318
}
319
@@ -473,6 +474,10 @@ class YARPP_Cache_Bypass extends YARPP_Cache {
473
return 0; // always uncached
474
}
475
476
public function uncached($limit = 20, $offset = 0) {
477
return array(); // nothing to cache
478
}
298
299
$lang = 'en_US';
300
if ( defined('WPLANG') ) {
301
+ switch ( substr(WPLANG, 0, 2) ) {
302
case 'de':
303
$lang = 'de_DE';
304
case 'it':
313
$lang = 'cs_CZ';
314
case 'nl':
315
$lang = 'nl_NL';
316
+ default:
317
+ $lang = 'en_US';
318
}
319
}
320
474
return 0; // always uncached
475
}
476
477
+ public function stats() {
478
+ return array(); // always unknown
479
+ }
480
+
481
public function uncached($limit = 20, $offset = 0) {
482
return array(); // nothing to cache
483
}
class-core.php CHANGED
@@ -464,6 +464,18 @@ class YARPP {
464
}
465
}
466
467
private $post_types = null;
468
function get_post_types( $field = 'name' ) {
469
if ( is_null($this->post_types) ) {
464
}
465
}
466
467
+ function is_happy() {
468
+ $stats = $this->cache->stats();
469
+
470
+ if ( !(array_sum( $stats ) > 0) )
471
+ return false;
472
+
473
+ $sum = array_sum(array_map('array_product', array_map(null, array_values($stats), array_keys($stats))));
474
+ $avg = $sum / array_sum( $stats );
475
+
476
+ return $this->cache->cache_status() > 0.1 && $avg > 2;
477
+ }
478
+
479
private $post_types = null;
480
function get_post_types( $field = 'name' ) {
481
if ( is_null($this->post_types) ) {
options-meta-boxes.php CHANGED
@@ -292,14 +292,15 @@ add_meta_box('yarpp_display_rss', __('Display options <small>for RSS</small>','y
292
293
class YARPP_Meta_Box_Contact extends YARPP_Meta_Box {
294
function display() {
295
$pluginurl = plugin_dir_url(__FILE__);
296
?>
297
<ul class='yarpp_contacts'>
298
- <li style="background: url(<?php echo $pluginurl . 'wordpress.png'; ?>) no-repeat left bottom;"><a href="http://wordpress.org/support/plugin/yet-another-related-posts-plugin" target="_blank"><?php _e('YARPP Forum', 'yarpp'); ?></a></li>
299
- <li style="background: url(<?php echo $pluginurl . 'twitter.png' ; ?>) no-repeat left bottom;"><a href="http://twitter.com/yarpp" target="_blank"><?php _e('YARPP on Twitter', 'yarpp'); ?></a></li>
300
- <li style="background: url(<?php echo $pluginurl . 'plugin.png'; ?>) no-repeat left bottom;"><a href="http://yarpp.org" target="_blank"><?php _e('YARPP on the Web', 'yarpp'); ?></a></li>
301
- <li style="background: url(<?php echo $pluginurl . 'star.png'; ?>) no-repeat 3px 2px;"><a href="http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/" target="_blank"><?php _e('Rate YARPP on WordPress.org', 'yarpp'); ?></a></li>
302
- <li style="background: url(<?php echo $pluginurl . 'paypal-icon.png'; ?>) no-repeat left bottom;"><a href='http://tinyurl.com/donatetomitcho' target='_new'><img src="https://www.paypal.com/<?php echo $this->paypal_lang(); ?>i/btn/btn_donate_SM.gif" name="submit" alt="<?php _e('Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal');?>" title="<?php _e('Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal','yarpp');?>"/></a></li>
303
</ul>
304
<?php
305
}
@@ -307,8 +308,7 @@ class YARPP_Meta_Box_Contact extends YARPP_Meta_Box {
307
function paypal_lang() {
308
if ( !defined('WPLANG') )
309
return 'en_US/';
310
- $lang = substr(WPLANG, 0, 2);
311
- switch ( $lang ) {
312
case 'fr':
313
return 'fr_FR/';
314
case 'de':
292
293
class YARPP_Meta_Box_Contact extends YARPP_Meta_Box {
294
function display() {
295
+ global $yarpp;
296
$pluginurl = plugin_dir_url(__FILE__);
297
?>
298
<ul class='yarpp_contacts'>
299
+ <li><a href="http://wordpress.org/support/plugin/yet-another-related-posts-plugin" target="_blank"><span class='icon icon-wordpress'></span> <?php _e('YARPP Forum', 'yarpp'); ?></a></li>
300
+ <li><a href="http://twitter.com/yarpp" target="_blank"><span class='icon icon-twitter'></span> <?php _e('YARPP on Twitter', 'yarpp'); ?></a></li>
301
+ <li><a href="http://yarpp.org" target="_blank"><span class='icon icon-plugin'></span> <?php _e('YARPP on the Web', 'yarpp'); ?></a></li>
302
+ <li><a href="http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/" target="_blank"><span class='icon icon-star <?php if ($yarpp->is_happy()) echo 'spin'; ?>'></span> <?php _e('Rate YARPP on WordPress.org', 'yarpp'); ?></a></li>
303
+ <li><a href='http://tinyurl.com/donatetomitcho' target='_new'><span class='icon icon-paypal'></span> <img src="https://www.paypal.com/<?php echo $this->paypal_lang(); ?>i/btn/btn_donate_SM.gif" name="submit" alt="<?php _e('Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal');?>" title="<?php _e('Donate to mitcho (Michael Yoshitaka Erlewine) for this plugin via PayPal','yarpp');?>"/></a></li>
304
</ul>
305
<?php
306
}
308
function paypal_lang() {
309
if ( !defined('WPLANG') )
310
return 'en_US/';
311
+ switch ( substr(WPLANG, 0, 2) ) {
312
case 'fr':
313
return 'fr_FR/';
314
case 'de':
options.css CHANGED
@@ -15,6 +15,64 @@ ul.yarpp_contacts li a img {
15
vertical-align: bottom;
16
}
17
18
a.info{
19
position:relative;
20
z-index:24;
15
vertical-align: bottom;
16
}
17
18
+ .icon {
19
+ width: 22px;
20
+ height: 22px;
21
+ position: absolute;
22
+ margin-left: -29px;
23
+ margin-top: -1px;
24
+ background-image: url('sprites.png');
25
+ }
26
+ @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
27
+ .icon {
28
+ background-image: url('sprites-2x.png');
29
+ background-size: 110px 22px;
30
+ }
31
+ }
32
+ .icon-wordpress {
33
+ background-position: 0 0;
34
+ }
35
+ .icon-twitter {
36
+ background-position: -22px 0;
37
+ }
38
+ .icon-plugin {
39
+ background-position: -44px 0;
40
+ }
41
+ .icon-star {
42
+ background-position: -66px 0;
43
+ }
44
+ .icon-paypal {
45
+ background-position: -88px 0;
46
+ }
47
+
48
+ .icon.spin, .icon-star:hover {
49
+ transform-origin: 11px 12px;
50
+ -o-transform-origin: 11px 12px;
51
+ -webkit-transform-origin: 11px 12px;
52
+ -moz-transform-origin: 11px 12px;
53
+ animation: 3s ease 2s normal none 1 yarpp-spin;
54
+ -o-animation: 3s ease 2s normal none 1 yarpp-spin;
55
+ -webkit-animation: 3s ease 2s normal none 1 yarpp-spin;
56
+ -moz-animation: 3s ease 2s normal none 1 yarpp-spin;
57
+ z-index: 1;
58
+ }
59
+
60
+ @keyframes yarpp-spin {
61
+ 0% { transform: rotate(0deg) scale(1); }
62
+ 5% { transform: rotate(0deg) scale(1.5); }
63
+ 100% { transform: rotate(360deg) scale(1);}
64
+ }
65
+ @-moz-keyframes yarpp-spin {
66
+ 0% { -moz-transform: rotate(0deg) scale(1); }
67
+ 5% { -moz-transform: rotate(0deg) scale(1.5); }
68
+ 100% { -moz-transform: rotate(360deg) scale(1);}
69
+ }
70
+ @-webkit-keyframes yarpp-spin {
71
+ 0% { -webkit-transform: rotate(0deg) scale(1); }
72
+ 5% { -webkit-transform: rotate(0deg) scale(1.5); }
73
+ 100% { -webkit-transform: rotate(360deg) scale(1);}
74
+ }
75
+
76
a.info{
77
position:relative;
78
z-index:24;
paypal-icon.png DELETED
Binary file
plugin.png DELETED
Binary file
readme.txt CHANGED
@@ -237,6 +237,12 @@ If you are a bilingual speaker of English and another language and an avid user
237
238
== Changelog ==
239
240
= 3.5.3 =
241
242
* [Bugfix](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-no-related-posts-7): Fixed a common cause of "no related posts"!
237
238
== Changelog ==
239
240
+ = 3.5.4 =
241
+
242
+ * Retina icons! Now served faster, in sprite form.
243
+ * Bugfix: stopwords would not be loaded if WPLANG is defined but blank.
244
+ * Add new `stats` method to `YARPP_Cache_*` objects.
245
+
246
= 3.5.3 =
247
248
* [Bugfix](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-no-related-posts-7): Fixed a common cause of "no related posts"!
sprites-2x.png ADDED
Binary file
sprites.png ADDED
Binary file
star.png DELETED
Binary file
twitter.png DELETED
Binary file
wordpress.png DELETED
Binary file
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 custom post type support!
6
- Version: 3.5.3
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', '3.5.3');
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 custom post type support!
6
+ Version: 3.5.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', '3.5.4b2');
13
define('YARPP_DIR', dirname(__FILE__));
14
define('YARPP_NO_RELATED', ':(');
15
define('YARPP_RELATED', ':)');