Version Description
Download this release
Release Info
Developer | mitchoyoshitaka |
Plugin | Yet Another Related Posts Plugin (YARPP) |
Version | 3.6b2 |
Comparing to | |
See all releases |
Code changes from version 3.6b1 to 3.6b2
- class-admin.php +52 -3
- class-core.php +1 -0
- class-widget.php +1 -1
- js/options.js +38 -5
- options-meta-boxes.php +69 -41
- options.css +21 -1
- options.php +2 -0
- readme.txt +3 -1
- yarpp-templates/yarpp-template-example.php +4 -2
- yarpp-templates/yarpp-template-list.php +4 -3
- yarpp-templates/yarpp-template-photoblog.php +4 -2
- yarpp-templates/yarpp-template-random.php +4 -3
- yarpp-templates/yarpp-template-thumbnail.php +4 -3
- yarpp-templates/yarpp-template-wpml.php +4 -2
- yarpp.php +2 -2
class-admin.php
CHANGED
@@ -14,6 +14,14 @@ class YARPP_Admin {
|
|
14 |
wp_redirect( admin_url( '/options-general.php?page=yarpp' ) );
|
15 |
exit;
|
16 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
add_action( 'admin_init', array( $this, 'ajax_register' ) );
|
19 |
add_action( 'admin_menu', array( $this, 'ui_register' ) );
|
@@ -30,11 +38,26 @@ class YARPP_Admin {
|
|
30 |
if ( $this->templates === false )
|
31 |
$this->templates = array();
|
32 |
// get basenames only
|
33 |
-
$this->templates = array_map('
|
34 |
}
|
35 |
return (array) $this->templates;
|
36 |
}
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
function ajax_register() {
|
39 |
// Register AJAX services
|
40 |
if ( defined('DOING_AJAX') && DOING_AJAX ) {
|
@@ -236,7 +259,7 @@ jQuery(function () {
|
|
236 |
require(YARPP_DIR.'/options.php');
|
237 |
}
|
238 |
|
239 |
-
// since 3.4: don't actually compute results here, but use ajax instead
|
240 |
function metabox() {
|
241 |
?>
|
242 |
<style>
|
@@ -259,13 +282,39 @@ jQuery(function () {
|
|
259 |
}
|
260 |
}
|
261 |
|
262 |
-
// since 3.3: default metaboxes to show:
|
263 |
function default_hidden_meta_boxes($hidden, $screen) {
|
264 |
if ( 'settings_page_yarpp' == $screen->id )
|
265 |
$hidden = array( 'yarpp_pool', 'yarpp_relatedness' );
|
266 |
return $hidden;
|
267 |
}
|
268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
/*
|
270 |
* AJAX SERVICES
|
271 |
*/
|
14 |
wp_redirect( admin_url( '/options-general.php?page=yarpp' ) );
|
15 |
exit;
|
16 |
}
|
17 |
+
|
18 |
+
// if action=flush and the nonce is correct, reset the cache
|
19 |
+
if ( isset($_GET['action']) && $_GET['action'] == 'copy_templates' &&
|
20 |
+
check_ajax_referer( 'yarpp_copy_templates', false, false ) !== false ) {
|
21 |
+
$this->copy_templates();
|
22 |
+
wp_redirect( admin_url( '/options-general.php?page=yarpp' ) );
|
23 |
+
exit;
|
24 |
+
}
|
25 |
|
26 |
add_action( 'admin_init', array( $this, 'ajax_register' ) );
|
27 |
add_action( 'admin_menu', array( $this, 'ui_register' ) );
|
38 |
if ( $this->templates === false )
|
39 |
$this->templates = array();
|
40 |
// get basenames only
|
41 |
+
$this->templates = array_map(array($this, 'get_template_data'), $this->templates);
|
42 |
}
|
43 |
return (array) $this->templates;
|
44 |
}
|
45 |
|
46 |
+
public function get_template_data( $file ) {
|
47 |
+
$headers = array(
|
48 |
+
'name' => 'Template Name',
|
49 |
+
'description' => 'Description',
|
50 |
+
'author' => 'Author',
|
51 |
+
'uri' => 'Author URI',
|
52 |
+
);
|
53 |
+
$data = get_file_data( $file, $headers );
|
54 |
+
$data['file'] = $file;
|
55 |
+
$data['basename'] = basename($file);
|
56 |
+
if ( empty($data['name']) )
|
57 |
+
$data['name'] = $data['basename'];
|
58 |
+
return $data;
|
59 |
+
}
|
60 |
+
|
61 |
function ajax_register() {
|
62 |
// Register AJAX services
|
63 |
if ( defined('DOING_AJAX') && DOING_AJAX ) {
|
259 |
require(YARPP_DIR.'/options.php');
|
260 |
}
|
261 |
|
262 |
+
// @since 3.4: don't actually compute results here, but use ajax instead
|
263 |
function metabox() {
|
264 |
?>
|
265 |
<style>
|
282 |
}
|
283 |
}
|
284 |
|
285 |
+
// @since 3.3: default metaboxes to show:
|
286 |
function default_hidden_meta_boxes($hidden, $screen) {
|
287 |
if ( 'settings_page_yarpp' == $screen->id )
|
288 |
$hidden = array( 'yarpp_pool', 'yarpp_relatedness' );
|
289 |
return $hidden;
|
290 |
}
|
291 |
|
292 |
+
// @since 3.6: UI to copy templates
|
293 |
+
function can_copy_templates() {
|
294 |
+
$theme_dir = get_stylesheet_directory();
|
295 |
+
// If we can't write to the theme, return false
|
296 |
+
if ( !is_dir($theme_dir) || !is_writable($theme_dir) )
|
297 |
+
return false;
|
298 |
+
|
299 |
+
require_once(ABSPATH . 'wp-admin/includes/file.php');
|
300 |
+
WP_Filesystem( false, get_stylesheet_directory() );
|
301 |
+
global $wp_filesystem;
|
302 |
+
// direct method is the only method that I've tested so far
|
303 |
+
return $wp_filesystem->method == 'direct';
|
304 |
+
}
|
305 |
+
|
306 |
+
function copy_templates() {
|
307 |
+
$templates_dir = trailingslashit(trailingslashit(YARPP_DIR) . 'yarpp-templates');
|
308 |
+
|
309 |
+
require_once(ABSPATH . 'wp-admin/includes/file.php');
|
310 |
+
WP_Filesystem( false, get_stylesheet_directory() );
|
311 |
+
global $wp_filesystem;
|
312 |
+
if ( $wp_filesystem->method != 'direct' )
|
313 |
+
return false;
|
314 |
+
|
315 |
+
return copy_dir( $templates_dir, get_stylesheet_directory(), array('.svn') );
|
316 |
+
}
|
317 |
+
|
318 |
/*
|
319 |
* AJAX SERVICES
|
320 |
*/
|
class-core.php
CHANGED
@@ -565,6 +565,7 @@ class YARPP {
|
|
565 |
),
|
566 |
'users' => $wpdb->get_var("select count(ID) from $wpdb->users"),
|
567 |
),
|
|
|
568 |
'locale' => get_bloginfo( 'language' ),
|
569 |
'url' => get_bloginfo('url'),
|
570 |
'plugins' => array(
|
565 |
),
|
566 |
'users' => $wpdb->get_var("select count(ID) from $wpdb->users"),
|
567 |
),
|
568 |
+
'post_thumbnails' => current_theme_supports( 'post-thumbnails' ),
|
569 |
'locale' => get_bloginfo( 'language' ),
|
570 |
'url' => get_bloginfo('url'),
|
571 |
'plugins' => array(
|
class-widget.php
CHANGED
@@ -75,7 +75,7 @@ class YARPP_Widget extends WP_Widget {
|
|
75 |
<p><input class="checkbox" id="<?php echo $this->get_field_id('use_template'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="checkbox" <?php checked(!!$instance['template']) ?> /> <label for="<?php echo $this->get_field_id('use_template'); ?>"><?php _e("Display using a custom template file",'yarpp');?></label></p>
|
76 |
<p id="<?php echo $this->get_field_id('template_file_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'); ?>">
|
77 |
<?php foreach ($templates as $template): ?>
|
78 |
-
<option value='<?php echo esc_attr($template); ?>'<?php selected($template, $instance['template']);?>><?php echo esc_html($template); ?></option>
|
79 |
<?php endforeach; ?>
|
80 |
</select><p>
|
81 |
<script type="text/javascript">
|
75 |
<p><input class="checkbox" id="<?php echo $this->get_field_id('use_template'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="checkbox" <?php checked(!!$instance['template']) ?> /> <label for="<?php echo $this->get_field_id('use_template'); ?>"><?php _e("Display using a custom template file",'yarpp');?></label></p>
|
76 |
<p id="<?php echo $this->get_field_id('template_file_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'); ?>">
|
77 |
<?php foreach ($templates as $template): ?>
|
78 |
+
<option value='<?php echo esc_attr($template['basename']); ?>'<?php selected($template['basename'], $instance['template']);?>><?php echo esc_html($template['name']); ?></option>
|
79 |
<?php endforeach; ?>
|
80 |
</select><p>
|
81 |
<script type="text/javascript">
|
js/options.js
CHANGED
@@ -161,16 +161,49 @@ jQuery(function($) {
|
|
161 |
});
|
162 |
|
163 |
$('.yarpp_help[data-help]').hover(function() {
|
164 |
-
var
|
|
|
165 |
options = {
|
166 |
content: help,
|
167 |
position: {
|
168 |
edge: 'left',
|
169 |
align: 'center',
|
170 |
-
of:
|
171 |
-
}
|
|
|
|
|
172 |
|
173 |
-
var pointer =
|
174 |
-
|
|
|
|
|
175 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
});
|
161 |
});
|
162 |
|
163 |
$('.yarpp_help[data-help]').hover(function() {
|
164 |
+
var that = $(this),
|
165 |
+
help = '<p>' + that.attr('data-help') + '</p>',
|
166 |
options = {
|
167 |
content: help,
|
168 |
position: {
|
169 |
edge: 'left',
|
170 |
align: 'center',
|
171 |
+
of: that
|
172 |
+
},
|
173 |
+
document: {body: that}
|
174 |
+
};
|
175 |
|
176 |
+
var pointer = that.pointer(options).pointer('open');
|
177 |
+
that.closest('.yarpp_form_row, p').mouseleave(function () {
|
178 |
+
pointer.pointer('close');
|
179 |
+
});
|
180 |
});
|
181 |
+
|
182 |
+
$('.yarpp_copy_templates_button').live('click', function() {
|
183 |
+
window.location = window.location + (window.location.search.length ? '&' : '?') + 'action=copy_templates&_ajax_nonce=' + $('#yarpp_copy_templates-nonce').val();
|
184 |
+
});
|
185 |
+
|
186 |
+
function template_info() {
|
187 |
+
var template = $(this).find('option:selected'),
|
188 |
+
row = template.closest('.yarpp_form_row');
|
189 |
+
if ( !!template.attr('data-url') ) {
|
190 |
+
row.find('.template_author_wrap')
|
191 |
+
.toggle( !!template.attr('data-author') )
|
192 |
+
.find('span').empty().append('<a>' + template.attr('data-author') + '</a>')
|
193 |
+
.attr('href', template.attr('data-url'));
|
194 |
+
} else {
|
195 |
+
row.find('.template_author_wrap')
|
196 |
+
.toggle( !!template.attr('data-author') )
|
197 |
+
.find('span').text(template.attr('data-author'));
|
198 |
+
}
|
199 |
+
row.find('.template_description_wrap')
|
200 |
+
.toggle( !!template.attr('data-description') )
|
201 |
+
.find('span').text(template.attr('data-description'));
|
202 |
+
row.find('.template_file_wrap')
|
203 |
+
.toggle( !!template.attr('data-basename') )
|
204 |
+
.find('span').text(template.attr('data-basename'));
|
205 |
+
}
|
206 |
+
$('#template_file, #rss_template_file')
|
207 |
+
.each(template_info)
|
208 |
+
.change(template_info);
|
209 |
});
|
options-meta-boxes.php
CHANGED
@@ -7,14 +7,25 @@ class YARPP_Meta_Box {
|
|
7 |
checked(yarpp_get_option($option) == 1);
|
8 |
echo " /> <label for='yarpp-$option'>$desc</label></div></div>";
|
9 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
function template_checkbox( $rss = false, $class = '' ) {
|
11 |
global $yarpp;
|
12 |
$pre = $rss ? 'rss_' : '';
|
13 |
$chosen_template = yarpp_get_option( "{$pre}template" );
|
14 |
-
echo "<div class='yarpp_form_row $class'><div><input type='checkbox' name='{$pre}use_template' class='{$pre}template' value='true'";
|
15 |
-
disabled(!count($yarpp->admin->get_templates()), true);
|
16 |
checked( !!$chosen_template );
|
17 |
-
echo
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
function template_file( $rss = false, $class = '' ) {
|
20 |
global $yarpp;
|
@@ -23,10 +34,13 @@ class YARPP_Meta_Box {
|
|
23 |
_e("Template file:",'yarpp');
|
24 |
echo "</div><div><select name='{$pre}template_file' id='{$pre}template_file'>";
|
25 |
$chosen_template = yarpp_get_option("{$pre}template");
|
26 |
-
foreach ($yarpp->admin->get_templates() as $template)
|
27 |
-
<option value='
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
30 |
}
|
31 |
function textbox($option, $desc, $size=2, $class='', $note = '') {
|
32 |
$value = esc_attr(yarpp_get_option($option));
|
@@ -179,24 +193,31 @@ class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
|
|
179 |
function display() {
|
180 |
global $yarpp;
|
181 |
|
182 |
-
echo
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
$this->checkbox('promote_yarpp',__("Help promote Yet Another Related Posts Plugin?",'yarpp')
|
202 |
." <span class='yarpp_help' data-help='" . esc_attr(sprintf(__("This option will add the code %s. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated.", 'yarpp'),"<code>".htmlspecialchars(sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'), 'http://yarpp.org'))."</code>")) ."'> </span>");
|
@@ -209,27 +230,34 @@ class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
|
|
209 |
function display() {
|
210 |
global $yarpp;
|
211 |
|
212 |
-
echo
|
|
|
213 |
|
214 |
-
|
215 |
-
|
216 |
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
$this->beforeafter(array('rss_before_related', 'rss_after_related'),__("Before / after related entries:",'yarpp'), 15, 'rss_not_templated rss_displayed', __("For example:",'yarpp') . ' <ol></ol>' . __(' or ','yarpp') . '<div></div>');
|
222 |
-
$this->beforeafter(array('rss_before_title', 'rss_after_title'),__("Before / after each related entry:",'yarpp'), 15, 'rss_not_templated rss_displayed', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
223 |
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
$this->beforeafter(array('rss_before_post', 'rss_after_post'),__("Before / after (excerpt):",'yarpp'), 10, 'rss_excerpted', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
228 |
|
229 |
-
|
|
|
|
|
|
|
|
|
|
|
230 |
|
231 |
-
|
232 |
|
|
|
|
|
|
|
|
|
|
|
233 |
$this->checkbox('rss_promote_yarpp', __("Help promote Yet Another Related Posts Plugin?",'yarpp') . " <span class='yarpp_help' data-help='" . esc_attr(sprintf(__("This option will add the code %s. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated.", 'yarpp'),"<code>" . htmlspecialchars(sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'), 'http://yarpp.org'))."</code>")) . "'> </span>", 'rss_displayed');
|
234 |
}
|
235 |
}
|
@@ -296,7 +324,7 @@ class YARPP_Meta_Box_Optin extends YARPP_Meta_Box {
|
|
296 |
|
297 |
echo '<label for="optin">' . __('Send YARPP settings and usage data back to YARPP.', 'yarpp') . '</label>';
|
298 |
|
299 |
-
echo '<p>This is entirely optional, but will help improve future versions of YARPP. <input type="button" value="Learn
|
300 |
}
|
301 |
}
|
302 |
|
7 |
checked(yarpp_get_option($option) == 1);
|
8 |
echo " /> <label for='yarpp-$option'>$desc</label></div></div>";
|
9 |
}
|
10 |
+
|
11 |
+
private function offer_copy_templates() {
|
12 |
+
global $yarpp;
|
13 |
+
return ( !count($yarpp->admin->get_templates()) && $yarpp->admin->can_copy_templates() );
|
14 |
+
}
|
15 |
+
|
16 |
function template_checkbox( $rss = false, $class = '' ) {
|
17 |
global $yarpp;
|
18 |
$pre = $rss ? 'rss_' : '';
|
19 |
$chosen_template = yarpp_get_option( "{$pre}template" );
|
20 |
+
echo "<div class='yarpp_form_row $class'><div><input type='checkbox' name='{$pre}use_template' id='yarpp-{$pre}use_template' class='{$pre}template' value='true'";
|
21 |
+
disabled( !count($yarpp->admin->get_templates()), true );
|
22 |
checked( !!$chosen_template );
|
23 |
+
echo ' /> ';
|
24 |
+
|
25 |
+
// todo: i18n
|
26 |
+
$copy = "</p><p style='border-top: 1px solid #333; padding-top: 10px;'>This option is disabled because no YARPP templates were found in your theme. Would you like to copy some sample templates bundled with YARPP into your theme? <input type='button' class='button button-small yarpp_copy_templates_button' value='Copy Templates'/>";
|
27 |
+
|
28 |
+
echo "<label for='yarpp-{$pre}use_template'>" . __("Display using a custom template file",'yarpp')." <span class='yarpp_help' data-help='" . esc_attr(__("This advanced option gives you full power to customize how your related posts are displayed. Templates (stored in your theme folder) are written in PHP.",'yarpp') . ( $this->offer_copy_templates() ? $copy : '')) . "'> </span>" . "</label></div></div>";
|
29 |
}
|
30 |
function template_file( $rss = false, $class = '' ) {
|
31 |
global $yarpp;
|
34 |
_e("Template file:",'yarpp');
|
35 |
echo "</div><div><select name='{$pre}template_file' id='{$pre}template_file'>";
|
36 |
$chosen_template = yarpp_get_option("{$pre}template");
|
37 |
+
foreach ($yarpp->admin->get_templates() as $template) {
|
38 |
+
echo "<option value='" . esc_attr($template['basename']) . "'" . selected($template['basename'], $chosen_template, false);
|
39 |
+
foreach ( $template as $key => $value )
|
40 |
+
echo " data-{$key}='" . esc_attr($value) . "'";
|
41 |
+
echo '>' . esc_html($template['name']) . '</option>';
|
42 |
+
}
|
43 |
+
echo "</select><p class='template_file_wrap'><span id='{$pre}template_file'></span></p><p class='template_author_wrap'>" . __('Author:') . " <span id='{$pre}template_author'></span></p><p class='template_description_wrap'><span id='{$pre}template_description'></span></p></div></div>";
|
44 |
}
|
45 |
function textbox($option, $desc, $size=2, $class='', $note = '') {
|
46 |
$value = esc_attr(yarpp_get_option($option));
|
193 |
function display() {
|
194 |
global $yarpp;
|
195 |
|
196 |
+
echo "<div style='overflow:hidden'>";
|
197 |
+
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>";
|
198 |
+
$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')) . "'> </span>");
|
199 |
+
|
200 |
+
$this->textbox('limit',__('Maximum number of related posts:','yarpp'));
|
201 |
+
$this->template_checkbox( false );
|
202 |
+
echo "</div>";
|
203 |
+
|
204 |
+
echo "<div class='postbox yarpp_subbox templated'>";
|
205 |
+
$this->template_file( false, 'templated' );
|
206 |
+
echo "</div>";
|
207 |
+
|
208 |
+
echo "<div class='postbox yarpp_subbox not_templated'>";
|
209 |
+
$this->beforeafter(array('before_related', 'after_related'),__("Before / after related entries:",'yarpp'), 15, 'not_templated', __("For example:",'yarpp') . ' <ol></ol>' . __(' or ','yarpp') . '<div></div>');
|
210 |
+
$this->beforeafter(array('before_title', 'after_title'),__("Before / after each related entry:",'yarpp'),15, 'not_templated', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
211 |
+
|
212 |
+
$this->checkbox('show_excerpt', __("Show excerpt?",'yarpp'), 'not_templated');
|
213 |
+
$this->textbox('excerpt_length', __('Excerpt length (No. of words):','yarpp'), 10, 'excerpted');
|
214 |
+
|
215 |
+
$this->beforeafter(array('before_post', 'after_post'), __("Before / after (excerpt):",'yarpp'), 10, 'excerpted', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
216 |
+
|
217 |
+
$this->displayorder('order');
|
218 |
+
|
219 |
+
$this->textbox('no_results', __('Default display if no results:','yarpp'), 40, 'not_templated');
|
220 |
+
echo "</div>";
|
221 |
|
222 |
$this->checkbox('promote_yarpp',__("Help promote Yet Another Related Posts Plugin?",'yarpp')
|
223 |
." <span class='yarpp_help' data-help='" . esc_attr(sprintf(__("This option will add the code %s. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated.", 'yarpp'),"<code>".htmlspecialchars(sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'), 'http://yarpp.org'))."</code>")) ."'> </span>");
|
230 |
function display() {
|
231 |
global $yarpp;
|
232 |
|
233 |
+
echo "<div style='overflow:hidden'>";
|
234 |
+
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>";
|
235 |
|
236 |
+
$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')) . "'> </span>",'');
|
237 |
+
$this->checkbox('rss_excerpt_display',__("Display related posts in the descriptions?",'yarpp')." <span class='yarpp_help' data-help='" . esc_attr(__("This option displays the related posts in the RSS description fields, not just the content. If your feeds are set up to only display excerpts, however, only the description field is used, so this option is required for any display at all.",'yarpp')) . "'> </span>", 'rss_displayed');
|
238 |
|
239 |
+
$this->textbox('rss_limit',__('Maximum number of related posts:','yarpp'), 2, 'rss_displayed');
|
240 |
+
$this->template_checkbox( true, 'rss_displayed' );
|
241 |
+
echo "</div>";
|
|
|
|
|
|
|
242 |
|
243 |
+
echo "<div class='postbox yarpp_subbox rss_templated rss_displayed'>";
|
244 |
+
$this->template_file( true, 'rss_templated' );
|
245 |
+
echo "</div>";
|
|
|
246 |
|
247 |
+
echo "<div class='postbox yarpp_subbox rss_not_templated rss_displayed'>";
|
248 |
+
$this->beforeafter(array('rss_before_related', 'rss_after_related'),__("Before / after related entries:",'yarpp'), 15, 'rss_not_templated rss_displayed', __("For example:",'yarpp') . ' <ol></ol>' . __(' or ','yarpp') . '<div></div>');
|
249 |
+
$this->beforeafter(array('rss_before_title', 'rss_after_title'),__("Before / after each related entry:",'yarpp'), 15, 'rss_not_templated rss_displayed', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
250 |
+
|
251 |
+
$this->checkbox('rss_show_excerpt', __("Show excerpt?",'yarpp'), 'rss_not_templated rss_displayed');
|
252 |
+
$this->textbox('rss_excerpt_length', __('Excerpt length (No. of words):','yarpp'), 10, 'rss_excerpted');
|
253 |
|
254 |
+
$this->beforeafter(array('rss_before_post', 'rss_after_post'),__("Before / after (excerpt):",'yarpp'), 10, 'rss_excerpted', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
255 |
|
256 |
+
$this->displayorder('rss_order', 'rss_displayed');
|
257 |
+
|
258 |
+
$this->textbox('rss_no_results', __('Default display if no results:','yarpp'), 40, 'rss_not_templated rss_displayed');
|
259 |
+
echo "</div>";
|
260 |
+
|
261 |
$this->checkbox('rss_promote_yarpp', __("Help promote Yet Another Related Posts Plugin?",'yarpp') . " <span class='yarpp_help' data-help='" . esc_attr(sprintf(__("This option will add the code %s. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated.", 'yarpp'),"<code>" . htmlspecialchars(sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'), 'http://yarpp.org'))."</code>")) . "'> </span>", 'rss_displayed');
|
262 |
}
|
263 |
}
|
324 |
|
325 |
echo '<label for="optin">' . __('Send YARPP settings and usage data back to YARPP.', 'yarpp') . '</label>';
|
326 |
|
327 |
+
echo '<p>This is entirely optional, but will help improve future versions of YARPP. <input type="button" value="Learn More" id="yarpp-optin-learnmore" class="button button-small" style="float:right"/></p>';
|
328 |
}
|
329 |
}
|
330 |
|
options.css
CHANGED
@@ -106,6 +106,14 @@ a.yarpp_help:hover {
|
|
106 |
display: inline-block;
|
107 |
}
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
.yarpp_form_row {
|
110 |
overflow: auto;
|
111 |
}
|
@@ -123,7 +131,7 @@ a.yarpp_help:hover {
|
|
123 |
padding-bottom: 5px;
|
124 |
}
|
125 |
.yarpp_form_label {
|
126 |
-
width:
|
127 |
}
|
128 |
.yarpp_form_textbox > .yarpp_form_label {
|
129 |
padding-top: 13px;
|
@@ -155,3 +163,15 @@ a.yarpp_help:hover {
|
|
155 |
max-width: 60%;
|
156 |
}
|
157 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
display: inline-block;
|
107 |
}
|
108 |
|
109 |
+
#yarpp_display_optin {
|
110 |
+
border-width: 2px;
|
111 |
+
}
|
112 |
+
|
113 |
+
.yarpp_subbox {
|
114 |
+
margin-bottom: 5px;
|
115 |
+
background: #fdfdfd;
|
116 |
+
}
|
117 |
.yarpp_form_row {
|
118 |
overflow: auto;
|
119 |
}
|
131 |
padding-bottom: 5px;
|
132 |
}
|
133 |
.yarpp_form_label {
|
134 |
+
width: 150px;
|
135 |
}
|
136 |
.yarpp_form_textbox > .yarpp_form_label {
|
137 |
padding-top: 13px;
|
163 |
max-width: 60%;
|
164 |
}
|
165 |
}
|
166 |
+
|
167 |
+
.yarpp_copy_templates_button {
|
168 |
+
float: right;
|
169 |
+
}
|
170 |
+
|
171 |
+
.template_file_wrap, .template_author_wrap, .template_description_wrap {
|
172 |
+
margin: 3px 0;
|
173 |
+
}
|
174 |
+
|
175 |
+
.template_file_wrap {
|
176 |
+
font-family: monospace;
|
177 |
+
}
|
options.php
CHANGED
@@ -151,6 +151,8 @@ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
|
151 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
152 |
wp_nonce_field( 'yarpp_display_demo', 'yarpp_display_demo-nonce', false );
|
153 |
wp_nonce_field( 'yarpp_display_exclude_terms', 'yarpp_display_exclude_terms-nonce', false );
|
|
|
|
|
154 |
?>
|
155 |
<div id="poststuff" class="metabox-holder has-right-sidebar">
|
156 |
|
151 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
152 |
wp_nonce_field( 'yarpp_display_demo', 'yarpp_display_demo-nonce', false );
|
153 |
wp_nonce_field( 'yarpp_display_exclude_terms', 'yarpp_display_exclude_terms-nonce', false );
|
154 |
+
if ( !count($yarpp->admin->get_templates()) && $yarpp->admin->can_copy_templates() )
|
155 |
+
wp_nonce_field( 'yarpp_copy_templates', 'yarpp_copy_templates-nonce', false );
|
156 |
?>
|
157 |
<div id="poststuff" class="metabox-holder has-right-sidebar">
|
158 |
|
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 |
-
*
|
|
|
|
|
239 |
* Code cleanup:
|
240 |
* Settings screen UI have been rewritten to use `div`s rather than `table`s!
|
241 |
* Inline help in settings screen now use WordPress pointers
|
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:
|
242 |
* Settings screen UI have been rewritten to use `div`s rather than `table`s!
|
243 |
* Inline help in settings screen now use WordPress pointers
|
yarpp-templates/yarpp-template-example.php
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
|
|
|
3 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
|
|
4 |
*/
|
5 |
?><h3>Related Posts</h3>
|
6 |
<?php if (have_posts()):?>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Template Name: Simple
|
4 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
5 |
+
Description: A simple example YARPP template.
|
6 |
*/
|
7 |
?><h3>Related Posts</h3>
|
8 |
<?php if (have_posts()):?>
|
yarpp-templates/yarpp-template-list.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
|
|
4 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
5 |
*/
|
6 |
?><h3>Related Posts</h3>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Template Name: List
|
4 |
+
Description: This template returns the related posts as a comma-separated list.
|
5 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
6 |
*/
|
7 |
?><h3>Related Posts</h3>
|
yarpp-templates/yarpp-template-photoblog.php
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
|
|
|
|
|
3 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
4 |
*/ ?>
|
5 |
<h3>Related Photos</h3>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Template Name: Yet Another Photoblog
|
4 |
+
Description: Requires the Yet Another Photoblog plugin
|
5 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
6 |
*/ ?>
|
7 |
<h3>Related Photos</h3>
|
yarpp-templates/yarpp-template-random.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
|
|
4 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
5 |
*/ ?>
|
6 |
<h3>Related Posts</h3>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Template Name: Random
|
4 |
+
Description: This template gives you a random other post in case there are no related posts
|
5 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
6 |
*/ ?>
|
7 |
<h3>Related Posts</h3>
|
yarpp-templates/yarpp-template-thumbnail.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
|
|
4 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
5 |
*/ ?>
|
6 |
<h3>Related Photos</h3>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Template Name: Thumbnails
|
4 |
+
Description: Requires a theme which supports post thumbnails
|
5 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
6 |
*/ ?>
|
7 |
<h3>Related Photos</h3>
|
yarpp-templates/yarpp-template-wpml.php
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
|
|
|
|
|
3 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
4 |
*/
|
5 |
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Template Name: WPML
|
4 |
+
Description: An example template for use with the WPML plugin
|
5 |
Author: mitcho (Michael Yoshitaka Erlewine)
|
6 |
*/
|
7 |
|
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.
|
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.
|
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.6b2
|
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.6b2');
|
13 |
define('YARPP_DIR', dirname(__FILE__));
|
14 |
define('YARPP_NO_RELATED', ':(');
|
15 |
define('YARPP_RELATED', ':)');
|