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

Version Description

Download this release

Release Info

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

Code changes from version 3.4.1b1 to 3.4.1b2

Files changed (4) hide show
  1. class-core.php +19 -15
  2. readme.txt +2 -0
  3. related-functions.php +3 -3
  4. yarpp.php +2 -2
class-core.php CHANGED
@@ -406,16 +406,17 @@ class YARPP {
406
* @param (array) $args
407
* @param (bool) $echo
408
*/
409
- function display_related($reference_ID, $args = array(), $echo = true) {
410
global $wp_query, $pagenow;
411
412
$this->upgrade_check();
413
414
// if we're already in a YARPP loop, stop now.
415
if ( $this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time() )
416
return false;
417
- if ( is_null($reference_ID) )
418
- $reference_ID = get_the_ID();
419
420
$this->setup_active_cache( $args );
421
@@ -449,7 +450,7 @@ class YARPP {
449
'orderby' => $orders[0],
450
'order' => $orders[1],
451
'showposts' => $limit,
452
- 'post_type' => $args['post_type']
453
));
454
}
455
$this->prep_query( $current_query->is_feed );
@@ -492,14 +493,15 @@ class YARPP {
492
* @param (int) $reference_ID - obligatory
493
* @param (array) $args
494
*/
495
- function get_related($reference_ID, $args = array()) {
496
$this->upgrade_check();
497
498
// if we're already in a YARPP loop, stop now.
499
if ( $this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time() )
500
return false;
501
- if ( is_null($reference_ID) )
502
- $reference_ID = get_the_ID();
503
504
$this->setup_active_cache( $args );
505
@@ -520,7 +522,7 @@ class YARPP {
520
'orderby' => $orders[0],
521
'order' => $orders[1],
522
'showposts' => $limit,
523
- 'post_type' => $args['post_type']
524
));
525
$this->active_cache->end_yarpp_time(); // YARPP time is over... :(
526
@@ -531,14 +533,12 @@ class YARPP {
531
* @param (int) $reference_ID
532
* @param (array) $args
533
*/
534
- function related_exist($reference_ID, $args = array()) {
535
- global $post;
536
-
537
$this->upgrade_check();
538
539
- if ( is_object($post) && is_null($reference_ID) )
540
- $reference_ID = $post->ID;
541
-
542
// if we're already in a YARPP loop, stop now.
543
if ( $this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time() )
544
return false;
@@ -552,7 +552,11 @@ class YARPP {
552
553
$this->active_cache->begin_yarpp_time($reference_ID); // get ready for YARPP TIME!
554
$related_query = new WP_Query();
555
- $related_query->query(array('p'=>$reference_ID,'showposts'=>1,'post_type'=>$args['post_type']));
556
$return = $related_query->have_posts();
557
unset($related_query);
558
$this->active_cache->end_yarpp_time(); // YARPP time is over. :(
406
* @param (array) $args
407
* @param (bool) $echo
408
*/
409
+ function display_related($reference_ID = false, $args = array(), $echo = true) {
410
global $wp_query, $pagenow;
411
412
$this->upgrade_check();
413
+
414
+ if ( !$reference_ID )
415
+ $reference_ID = get_the_ID();
416
417
// if we're already in a YARPP loop, stop now.
418
if ( $this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time() )
419
return false;
420
421
$this->setup_active_cache( $args );
422
450
'orderby' => $orders[0],
451
'order' => $orders[1],
452
'showposts' => $limit,
453
+ 'post_type' => ( isset($args['post_type']) ? $args['post_type'] : $this->get_post_types() )
454
));
455
}
456
$this->prep_query( $current_query->is_feed );
493
* @param (int) $reference_ID - obligatory
494
* @param (array) $args
495
*/
496
+ function get_related($reference_ID = false, $args = array()) {
497
$this->upgrade_check();
498
+
499
+ if ( !$reference_ID )
500
+ $reference_ID = get_the_ID();
501
502
// if we're already in a YARPP loop, stop now.
503
if ( $this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time() )
504
return false;
505
506
$this->setup_active_cache( $args );
507
522
'orderby' => $orders[0],
523
'order' => $orders[1],
524
'showposts' => $limit,
525
+ 'post_type' => ( isset($args['post_type']) ? $args['post_type'] : $this->get_post_types() )
526
));
527
$this->active_cache->end_yarpp_time(); // YARPP time is over... :(
528
533
* @param (int) $reference_ID
534
* @param (array) $args
535
*/
536
+ function related_exist($reference_ID = false, $args = array()) {
537
$this->upgrade_check();
538
539
+ if ( !$reference_ID )
540
+ $reference_ID = get_the_ID();
541
+
542
// if we're already in a YARPP loop, stop now.
543
if ( $this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time() )
544
return false;
552
553
$this->active_cache->begin_yarpp_time($reference_ID); // get ready for YARPP TIME!
554
$related_query = new WP_Query();
555
+ $related_query->query(array(
556
+ 'p' => $reference_ID,
557
+ 'showposts' => 1,
558
+ 'post_type' => ( isset($args['post_type']) ? $args['post_type'] : $this->get_post_types() )
559
+ ));
560
$return = $related_query->have_posts();
561
unset($related_query);
562
$this->active_cache->end_yarpp_time(); // YARPP time is over. :(
readme.txt CHANGED
@@ -174,7 +174,9 @@ If you are a bilingual speaker of English and another language and an avid user
174
== Changelog ==
175
176
= 3.4.1 =
177
* [Bugfix](http://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-34-images-problem-using-template): restore `global $post` access to custom templates
178
* Updated `sv_SE`, `ko_KR` localizations
179
= 3.4 =
180
* Major optimizations to the main related posts query, in particular with regard to taxonomy lookups
174
== Changelog ==
175
176
= 3.4.1 =
177
+ * Bugfix for calling `related_posts()` directly
178
* [Bugfix](http://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-34-images-problem-using-template): restore `global $post` access to custom templates
179
+ * Add defaults for the `post_type` arg.
180
* Updated `sv_SE`, `ko_KR` localizations
181
= 3.4 =
182
* Major optimizations to the main related posts query, in particular with regard to taxonomy lookups
related-functions.php CHANGED
@@ -1,6 +1,6 @@
1
<?php
2
3
- function yarpp_related($reference_ID, $args = array(), $echo = false) {
4
global $yarpp;
5
6
if ( is_array($reference_ID) ) {
@@ -11,7 +11,7 @@ function yarpp_related($reference_ID, $args = array(), $echo = false) {
11
return $yarpp->display_related($reference_ID, $args, $echo);
12
}
13
14
- function yarpp_related_exist($reference_ID, $args = array()) {
15
global $yarpp;
16
17
if ( is_array($reference_ID) ) {
@@ -22,7 +22,7 @@ function yarpp_related_exist($reference_ID, $args = array()) {
22
return $yarpp->related_exist($reference_ID, $args, $echo);
23
}
24
25
- function yarpp_get_related($reference_ID, $args = array()) {
26
global $yarpp;
27
return $yarpp->get_related($reference_ID, $args);
28
}
1
<?php
2
3
+ function yarpp_related($reference_ID = false, $args = array(), $echo = false) {
4
global $yarpp;
5
6
if ( is_array($reference_ID) ) {
11
return $yarpp->display_related($reference_ID, $args, $echo);
12
}
13
14
+ function yarpp_related_exist($reference_ID = false, $args = array()) {
15
global $yarpp;
16
17
if ( is_array($reference_ID) ) {
22
return $yarpp->related_exist($reference_ID, $args, $echo);
23
}
24
25
+ function yarpp_get_related($reference_ID = false, $args = array()) {
26
global $yarpp;
27
return $yarpp->get_related($reference_ID, $args);
28
}
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. A templating feature allows customization of the display.
6
- Version: 3.4.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', '3.4.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. A templating feature allows customization of the display.
6
+ Version: 3.4.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', '3.4.1b2');
13
define('YARPP_DIR', dirname(__FILE__));
14
define('YARPP_NO_RELATED', ':(');
15
define('YARPP_RELATED', ':)');