Yet Another Related Posts Plugin (YARPP) - Version 3.6b4

Version Description

Download this release

Release Info

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

Code changes from version 3.6b3 to 3.6b4

Files changed (5) hide show
  1. class-core.php +35 -14
  2. options-meta-boxes.php +2 -2
  3. readme.txt +2 -0
  4. template-builtin.php +3 -2
  5. yarpp.php +2 -2
class-core.php CHANGED
@@ -671,7 +671,6 @@ class YARPP {
671
$current_query = $wp_query;
672
$current_pagenow = $pagenow;
673
674
- $output = '';
675
$wp_query = new WP_Query();
676
if ( YARPP_NO_RELATED == $cache_status ) {
677
// If there are no related posts, get no query
@@ -688,19 +687,28 @@ class YARPP {
688
$this->prep_query( $current_query->is_feed );
689
$related_query = $wp_query; // backwards compatibility
690
691
if ( 'metabox' == $domain ) {
692
- include(YARPP_DIR.'/template-metabox.php');
693
} elseif ( !!$template && file_exists(STYLESHEETPATH . '/' . $template) ) {
694
global $post;
695
ob_start();
696
include(STYLESHEETPATH . '/' . $template);
697
- $output = ob_get_contents();
698
ob_end_clean();
699
} elseif ( 'widget' == $domain ) {
700
- include(YARPP_DIR.'/template-widget.php');
701
} else {
702
- include(YARPP_DIR.'/template-builtin.php');
703
}
704
705
if ( YARPP_NO_RELATED == $cache_status ) {
706
// Uh, do nothing. Stay very still.
@@ -714,11 +722,13 @@ class YARPP {
714
$pagenow = $current_pagenow; unset($current_pagenow);
715
716
if ($promote_yarpp && $domain != 'metabox')
717
- $output .= "\n<p>".sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'), 'http://yarpp.org')."</p>";
718
-
719
if ( $optin )
720
$output .= "<img src='http://yarpp.org/pixel.png?" . md5(get_bloginfo('url')) . "'/>\n";
721
-
722
if ($echo)
723
echo $output;
724
return $output;
@@ -818,27 +828,38 @@ class YARPP {
818
819
$this->cache_bypass->begin_demo_time( $limit );
820
821
- $output = '';
822
$wp_query = new WP_Query();
823
$wp_query->query('');
824
825
$this->prep_query( $domain == 'rss' );
826
$related_query = $wp_query; // backwards compatibility
827
828
- if ( !!$template && file_exists(STYLESHEETPATH . '/' . $template) ) {
829
global $post;
830
ob_start();
831
include(STYLESHEETPATH . '/' . $template);
832
- $output = ob_get_contents();
833
ob_end_clean();
834
} else {
835
include(YARPP_DIR.'/template-builtin.php');
836
}
837
-
838
$this->cache_bypass->end_demo_time();
839
-
840
if ($promote_yarpp)
841
- $output .= "\n<p>".sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'), 'http://yarpp.org')."</p>";
842
843
if ( $echo )
844
echo $output;
671
$current_query = $wp_query;
672
$current_pagenow = $pagenow;
673
674
$wp_query = new WP_Query();
675
if ( YARPP_NO_RELATED == $cache_status ) {
676
// If there are no related posts, get no query
687
$this->prep_query( $current_query->is_feed );
688
$related_query = $wp_query; // backwards compatibility
689
690
+ $output = "<div class='";
691
+ if ( 'website' == $domain )
692
+ $output .= "yarpp-related";
693
+ else
694
+ $output .= "yarpp-related-{$domain}";
695
+ $output .= "'>\n";
696
if ( 'metabox' == $domain ) {
697
+ include(YARPP_DIR . '/template-metabox.php');
698
+ } elseif ( !!$template && 'thumbnails' == $template ) {
699
+ include(YARPP_DIR . '/template-thumbnails.php');
700
} elseif ( !!$template && file_exists(STYLESHEETPATH . '/' . $template) ) {
701
global $post;
702
ob_start();
703
include(STYLESHEETPATH . '/' . $template);
704
+ $output .= ob_get_contents();
705
ob_end_clean();
706
} elseif ( 'widget' == $domain ) {
707
+ include(YARPP_DIR . '/template-widget.php');
708
} else {
709
+ include(YARPP_DIR . '/template-builtin.php');
710
}
711
+ $output = trim($output) . "\n";
712
713
if ( YARPP_NO_RELATED == $cache_status ) {
714
// Uh, do nothing. Stay very still.
722
$pagenow = $current_pagenow; unset($current_pagenow);
723
724
if ($promote_yarpp && $domain != 'metabox')
725
+ $output .= "<p>".sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'), 'http://yarpp.org')."</p>\n";
726
+
727
if ( $optin )
728
$output .= "<img src='http://yarpp.org/pixel.png?" . md5(get_bloginfo('url')) . "'/>\n";
729
+
730
+ $output .= "</div>\n";
731
+
732
if ($echo)
733
echo $output;
734
return $output;
828
829
$this->cache_bypass->begin_demo_time( $limit );
830
831
+ $output = "<div class='";
832
+ if ( 'website' == $domain )
833
+ $output .= "yarpp-related";
834
+ else
835
+ $output .= "yarpp-related-{$domain}";
836
+ $output .= "'>\n";
837
+
838
$wp_query = new WP_Query();
839
$wp_query->query('');
840
841
$this->prep_query( $domain == 'rss' );
842
$related_query = $wp_query; // backwards compatibility
843
844
+ if ( !!$template && 'thumbnails' == $template ) {
845
+ include(YARPP_DIR . '/template-thumbnails.php');
846
+ } elseif ( !!$template && file_exists(STYLESHEETPATH . '/' . $template) ) {
847
global $post;
848
ob_start();
849
include(STYLESHEETPATH . '/' . $template);
850
+ $output .= ob_get_contents();
851
ob_end_clean();
852
} else {
853
include(YARPP_DIR.'/template-builtin.php');
854
}
855
+ $output = trim($output) . "\n";
856
+
857
$this->cache_bypass->end_demo_time();
858
+
859
if ($promote_yarpp)
860
+ $output .= "<p>".sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'), 'http://yarpp.org')."</p>\n";
861
+
862
+ $output .= "</div>";
863
864
if ( $echo )
865
echo $output;
options-meta-boxes.php CHANGED
@@ -226,7 +226,7 @@ class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
226
function display() {
227
global $yarpp;
228
229
- echo "<div style='overflow:visible'>";
230
echo '<div class="yarpp_code_display"><strong>' . __("Website display code example",'yarpp') . '</strong><br /><small>' . __("(Update options to reload.)", 'yarpp') . "</small><br/><div id='display_demo_web'></div></div>";
231
$this->checkbox('auto_display',__("Automatically display related posts?",'yarpp')." <span class='yarpp_help' data-help='" . esc_attr(__("This option automatically displays related posts right after the content on single entry pages. If this option is off, you will need to manually insert <code>related_posts()</code> or variants (<code>related_pages()</code> and <code>related_entries()</code>) into your theme files.",'yarpp')) . "'>&nbsp;</span>");
232
@@ -264,7 +264,7 @@ class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
264
function display() {
265
global $yarpp;
266
267
- echo "<div style='overflow:visible'>";
268
echo '<div class="rss_displayed yarpp_code_display"><b>' . __("RSS display code example",'yarpp') . '</b><br /><small>' . __("(Update options to reload.)",'yarpp') . "</small><br/><div id='display_demo_rss'></div></div>";
269
270
$this->checkbox('rss_display',__("Display related posts in feeds?",'yarpp')." <span class='yarpp_help' data-help='" . esc_attr(__("This option displays related posts at the end of each item in your RSS and Atom feeds. No template changes are needed.",'yarpp')) . "'>&nbsp;</span>",'');
226
function display() {
227
global $yarpp;
228
229
+ echo "<div style='overflow:auto'>";
230
echo '<div class="yarpp_code_display"><strong>' . __("Website display code example",'yarpp') . '</strong><br /><small>' . __("(Update options to reload.)", 'yarpp') . "</small><br/><div id='display_demo_web'></div></div>";
231
$this->checkbox('auto_display',__("Automatically display related posts?",'yarpp')." <span class='yarpp_help' data-help='" . esc_attr(__("This option automatically displays related posts right after the content on single entry pages. If this option is off, you will need to manually insert <code>related_posts()</code> or variants (<code>related_pages()</code> and <code>related_entries()</code>) into your theme files.",'yarpp')) . "'>&nbsp;</span>");
232
264
function display() {
265
global $yarpp;
266
267
+ echo "<div style='overflow:auto'>";
268
echo '<div class="rss_displayed yarpp_code_display"><b>' . __("RSS display code example",'yarpp') . '</b><br /><small>' . __("(Update options to reload.)",'yarpp') . "</small><br/><div id='display_demo_rss'></div></div>";
269
270
$this->checkbox('rss_display',__("Display related posts in feeds?",'yarpp')." <span class='yarpp_help' data-help='" . esc_attr(__("This option displays related posts at the end of each item in your RSS and Atom feeds. No template changes are needed.",'yarpp')) . "'>&nbsp;</span>",'');
readme.txt CHANGED
@@ -235,7 +235,9 @@ If you are a bilingual speaker of English and another language and an avid user
235
== Changelog ==
236
237
= 3.6 =
238
* Improvements to YARPP custom template UI
239
* A new "copy templates" button allows one-button installation of bundled templates into the current theme, if filesystem permissions make it possible.
240
* Header information in YARPP custom templates are now displayed to users in the settings UI. Available fields are `Template Name`, `Description`, `Author`, `Author URI`, in the same format as plugin and theme file headers. See bundled templates for examples.
241
* Code cleanup:
235
== Changelog ==
236
237
= 3.6 =
238
+ * All YARPP output is now wrapped in a `div` with class `yarpp-related`, `yarpp-related-widget`, or `yarpp-related-rss` as appropriate ([by request](https://wordpress.org/support/topic/adding-a-main-div-to-default-template)).
239
* Improvements to YARPP custom template UI
240
+ * A new design for the template chooser
241
* A new "copy templates" button allows one-button installation of bundled templates into the current theme, if filesystem permissions make it possible.
242
* Header information in YARPP custom templates are now displayed to users in the settings UI. Available fields are `Template Name`, `Description`, `Author`, `Author URI`, in the same format as plugin and theme file headers. See bundled templates for examples.
243
* Code cleanup:
template-builtin.php CHANGED
@@ -13,6 +13,7 @@ $options = array( 'before_title', 'after_title', 'show_excerpt', 'excerpt_length
13
extract( $this->parse_args( $args, $options ) );
14
15
if (have_posts()) {
16
while (have_posts()) {
17
the_post();
18
@@ -29,7 +30,7 @@ if (have_posts()) {
29
$output .= $after_title."\n";
30
31
}
32
- $output = $before_related . "\n" . $output . $after_related;
33
} else {
34
- $output = $no_results;
35
}
13
extract( $this->parse_args( $args, $options ) );
14
15
if (have_posts()) {
16
+ $output .= $before_related . "\n";
17
while (have_posts()) {
18
the_post();
19
30
$output .= $after_title."\n";
31
32
}
33
+ $output .= $after_related . "\n";
34
} else {
35
+ $output .= $no_results;
36
}
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.6b3
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.6b3');
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.6b4
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.6b4');
13
define('YARPP_DIR', dirname(__FILE__));
14
define('YARPP_NO_RELATED', ':(');
15
define('YARPP_RELATED', ':)');