Version Description
Download this release
Release Info
Developer | mitchoyoshitaka |
Plugin | Yet Another Related Posts Plugin (YARPP) |
Version | 3.6b5 |
Comparing to | |
See all releases |
Code changes from version 3.6b4 to 3.6b5
- class-admin.php +86 -8
- class-core.php +14 -4
- default.png +0 -0
- js/options.js +41 -38
- options-meta-boxes.php +30 -15
- options.css +7 -2
- options.php +1 -0
- readme.txt +3 -0
- template-thumbnails.php +110 -0
- yarpp.php +2 -2
class-admin.php
CHANGED
@@ -23,6 +23,8 @@ class YARPP_Admin {
|
|
23 |
exit;
|
24 |
}
|
25 |
|
|
|
|
|
26 |
add_action( 'admin_init', array( $this, 'ajax_register' ) );
|
27 |
add_action( 'admin_menu', array( $this, 'ui_register' ) );
|
28 |
add_filter( 'current_screen', array( $this, 'settings_screen' ) );
|
@@ -64,17 +66,28 @@ class YARPP_Admin {
|
|
64 |
add_action( 'wp_ajax_yarpp_display_exclude_terms', array( $this, 'ajax_display_exclude_terms' ) );
|
65 |
add_action( 'wp_ajax_yarpp_display_demo', array( $this, 'ajax_display_demo' ) );
|
66 |
add_action( 'wp_ajax_yarpp_display', array( $this, 'ajax_display' ) );
|
|
|
|
|
|
|
67 |
}
|
68 |
}
|
69 |
|
70 |
function ui_register() {
|
71 |
global $wp_version;
|
72 |
-
if ( get_option( 'yarpp_activated' )
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
-
|
78 |
// setup admin
|
79 |
$this->hook = add_options_page(__('Related Posts (YARPP)','yarpp'),__('Related Posts (YARPP)','yarpp'), 'manage_options', 'yarpp', array( $this, 'options_page' ) );
|
80 |
|
@@ -145,8 +158,50 @@ class YARPP_Admin {
|
|
145 |
}
|
146 |
|
147 |
public function help_optin() {
|
148 |
-
//
|
149 |
-
echo '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
|
152 |
// faux-markdown, required for the help text rendering
|
@@ -245,7 +300,7 @@ jQuery(function () {
|
|
245 |
</script>
|
246 |
<?php
|
247 |
}
|
248 |
-
|
249 |
function settings_link($links, $file) {
|
250 |
$this_plugin = dirname(plugin_basename(__FILE__)) . '/yarpp.php';
|
251 |
if($file == $this_plugin) {
|
@@ -398,4 +453,27 @@ jQuery(function () {
|
|
398 |
echo preg_replace("/[\n\r]/",'',nl2br(htmlspecialchars($return)));
|
399 |
exit;
|
400 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
}
|
23 |
exit;
|
24 |
}
|
25 |
|
26 |
+
//add_image_size( 'yarpp-thumbnail', $width, $height, $crop );
|
27 |
+
|
28 |
add_action( 'admin_init', array( $this, 'ajax_register' ) );
|
29 |
add_action( 'admin_menu', array( $this, 'ui_register' ) );
|
30 |
add_filter( 'current_screen', array( $this, 'settings_screen' ) );
|
66 |
add_action( 'wp_ajax_yarpp_display_exclude_terms', array( $this, 'ajax_display_exclude_terms' ) );
|
67 |
add_action( 'wp_ajax_yarpp_display_demo', array( $this, 'ajax_display_demo' ) );
|
68 |
add_action( 'wp_ajax_yarpp_display', array( $this, 'ajax_display' ) );
|
69 |
+
add_action( 'wp_ajax_yarpp_optin_data', array( $this, 'ajax_optin_data' ) );
|
70 |
+
add_action( 'wp_ajax_yarpp_optin', array( $this, 'ajax_optin' ) );
|
71 |
+
add_action( 'wp_ajax_yarpp_optin_dismiss', array( $this, 'ajax_optin_dismiss' ) );
|
72 |
}
|
73 |
}
|
74 |
|
75 |
function ui_register() {
|
76 |
global $wp_version;
|
77 |
+
if ( get_option( 'yarpp_activated' ) ) {
|
78 |
+
if ( version_compare($wp_version, '3.3b1', '>=') ) {
|
79 |
+
delete_option( 'yarpp_activated' );
|
80 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'pointer_enqueue' ) );
|
81 |
+
add_action( 'admin_print_footer_scripts', array( $this, 'pointer_script' ) );
|
82 |
+
}
|
83 |
+
} elseif ( !$this->core->get_option('optin') &&
|
84 |
+
current_user_can('manage_options') &&
|
85 |
+
!get_user_option( 'yarpp_saw_optin' ) ) {
|
86 |
+
$user = get_current_user_id();
|
87 |
+
// update_user_option( $user, 'yarpp_saw_optin', true );
|
88 |
+
add_action( 'admin_notices', array( $this, 'optin_notice' ) );
|
89 |
}
|
90 |
+
|
91 |
// setup admin
|
92 |
$this->hook = add_options_page(__('Related Posts (YARPP)','yarpp'),__('Related Posts (YARPP)','yarpp'), 'manage_options', 'yarpp', array( $this, 'options_page' ) );
|
93 |
|
158 |
}
|
159 |
|
160 |
public function help_optin() {
|
161 |
+
// todo: i18n
|
162 |
+
echo '<p>' . sprintf( "With your permission, YARPP will send information about YARPP's settings, usage, and environment back to a central server at %s.", '<code>yarpp.org</code>') . ' ';
|
163 |
+
echo "This information will be used to improve YARPP in the future and help decide future development decisions for YARPP." . ' ';
|
164 |
+
echo '<strong>' . "Contributing this data will help make YARPP better for you and for other YARPP users." . '</strong></p>';
|
165 |
+
|
166 |
+
if ( !$this->core->get_option( 'optin' ) ) {
|
167 |
+
echo '<p>';
|
168 |
+
$this->print_optin_button();
|
169 |
+
echo '</p>';
|
170 |
+
}
|
171 |
+
|
172 |
+
echo '<p>' . "If you opt-in, the following information is sent back to YARPP:" . '</p>';
|
173 |
+
echo '<div id="optin_data_frame"></div>';
|
174 |
+
echo '<p>' . "In addition, YARPP also loads an invisible pixel image with your YARPP results to know how often YARPP is being used." . '</p>';
|
175 |
+
}
|
176 |
+
|
177 |
+
function print_optin_button() {
|
178 |
+
echo '<a id="yarpp-optin-button" class="button">' . __('Send settings and usage data back to YARPP', 'yarpp') . '</a><span class="yarpp-thankyou" style="display:none"><strong>' . __('Thank you!', 'yarpp') . '</strong></span>';
|
179 |
+
wp_nonce_field( 'yarpp_optin', 'yarpp_optin-nonce', false );
|
180 |
+
echo "<script type='text/javascript'>
|
181 |
+
jQuery(function($){
|
182 |
+
$('#yarpp-optin-button').click(function() {
|
183 |
+
$(this)
|
184 |
+
.hide()
|
185 |
+
.siblings('.yarpp-thankyou').show('slow');
|
186 |
+
$('#yarpp-optin').attr('checked', true);
|
187 |
+
$.ajax({type:'POST',
|
188 |
+
url: ajaxurl,
|
189 |
+
data: {
|
190 |
+
action: 'yarpp_optin',
|
191 |
+
'_ajax_nonce': $('#yarpp_optin-nonce').val()
|
192 |
+
}});
|
193 |
+
});
|
194 |
+
});
|
195 |
+
</script>\n";
|
196 |
+
}
|
197 |
+
|
198 |
+
function optin_notice() {
|
199 |
+
echo '<div class="updated fade">';
|
200 |
+
echo '<p>' . sprintf( "With your permission, YARPP will send information about YARPP's settings, usage, and environment back to a central server at %s.", '<code>yarpp.org</code>') . ' ';
|
201 |
+
echo "This information will be used to improve YARPP in the future and help decide future development decisions for YARPP." . ' ';
|
202 |
+
echo '<strong>' . "Contributing this data will help make YARPP better for you and for other YARPP users." . '</strong></p><p>';
|
203 |
+
$this->print_optin_button();
|
204 |
+
echo '</p></div>';
|
205 |
}
|
206 |
|
207 |
// faux-markdown, required for the help text rendering
|
300 |
</script>
|
301 |
<?php
|
302 |
}
|
303 |
+
|
304 |
function settings_link($links, $file) {
|
305 |
$this_plugin = dirname(plugin_basename(__FILE__)) . '/yarpp.php';
|
306 |
if($file == $this_plugin) {
|
453 |
echo preg_replace("/[\n\r]/",'',nl2br(htmlspecialchars($return)));
|
454 |
exit;
|
455 |
}
|
456 |
+
|
457 |
+
function ajax_optin_data() {
|
458 |
+
check_ajax_referer( 'yarpp_optin_data' );
|
459 |
+
|
460 |
+
header("HTTP/1.1 200");
|
461 |
+
header("Content-Type: text/html; charset=UTF-8");
|
462 |
+
|
463 |
+
$data = $this->core->optin_data();
|
464 |
+
$this->core->pretty_echo($data);
|
465 |
+
exit;
|
466 |
+
}
|
467 |
+
|
468 |
+
function ajax_optin() {
|
469 |
+
check_ajax_referer( 'yarpp_optin' );
|
470 |
+
|
471 |
+
header("HTTP/1.1 200");
|
472 |
+
header("Content-Type: text; charset=UTF-8");
|
473 |
+
|
474 |
+
$data = yarpp_set_option('optin', true);
|
475 |
+
$this->core->optin_ping();
|
476 |
+
echo 'ok';
|
477 |
+
exit;
|
478 |
+
}
|
479 |
}
|
class-core.php
CHANGED
@@ -104,7 +104,11 @@ class YARPP {
|
|
104 |
)
|
105 |
),
|
106 |
'require_tax' => array(), // new in 3.5
|
107 |
-
'optin' => false // new in 3.6
|
|
|
|
|
|
|
|
|
108 |
);
|
109 |
}
|
110 |
|
@@ -541,7 +545,8 @@ class YARPP {
|
|
541 |
'before_title', 'after_title', 'before_post', 'after_post',
|
542 |
'before_related', 'after_related', 'no_results', 'order',
|
543 |
'rss_before_title', 'rss_after_title', 'rss_before_post', 'rss_after_post', 'rss_before_related', 'rss_after_related', 'rss_no_results', 'rss_order',
|
544 |
-
'exclude'
|
|
|
545 |
);
|
546 |
|
547 |
$data = array(
|
@@ -565,7 +570,7 @@ class YARPP {
|
|
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(
|
@@ -687,6 +692,7 @@ class YARPP {
|
|
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";
|
@@ -867,7 +873,11 @@ class YARPP {
|
|
867 |
}
|
868 |
|
869 |
public function parse_args( $args, $options ) {
|
870 |
-
$options_with_rss_variants = array(
|
|
|
|
|
|
|
|
|
871 |
|
872 |
$r = array();
|
873 |
foreach ( $options as $option ) {
|
104 |
)
|
105 |
),
|
106 |
'require_tax' => array(), // new in 3.5
|
107 |
+
'optin' => false, // new in 3.6
|
108 |
+
'thumbnails_heading' => __('Related posts:','yarpp'), // new in 3.6
|
109 |
+
'thumbnails_default' => plugins_url( 'default.png', __FILE__ ), // new in 3.6
|
110 |
+
'rss_thumbnails_heading' => __('Related posts:','yarpp'), // new in 3.6
|
111 |
+
'rss_thumbnails_default' => plugins_url( 'default.png', __FILE__ ) // new in 3.6
|
112 |
);
|
113 |
}
|
114 |
|
545 |
'before_title', 'after_title', 'before_post', 'after_post',
|
546 |
'before_related', 'after_related', 'no_results', 'order',
|
547 |
'rss_before_title', 'rss_after_title', 'rss_before_post', 'rss_after_post', 'rss_before_related', 'rss_after_related', 'rss_no_results', 'rss_order',
|
548 |
+
'exclude', 'thumbnails_heading', 'thumbnails_default', 'rss_thumbnails_heading',
|
549 |
+
'rss_thumbnails_default'
|
550 |
);
|
551 |
|
552 |
$data = array(
|
570 |
),
|
571 |
'users' => $wpdb->get_var("select count(ID) from $wpdb->users"),
|
572 |
),
|
573 |
+
'post_thumbnails' => current_theme_supports( 'post-thumbnails', 'post' ),
|
574 |
'locale' => get_bloginfo( 'language' ),
|
575 |
'url' => get_bloginfo('url'),
|
576 |
'plugins' => array(
|
692 |
$this->prep_query( $current_query->is_feed );
|
693 |
$related_query = $wp_query; // backwards compatibility
|
694 |
|
695 |
+
// @todo: add these classes after the fact and include information about whether any results were given
|
696 |
$output = "<div class='";
|
697 |
if ( 'website' == $domain )
|
698 |
$output .= "yarpp-related";
|
873 |
}
|
874 |
|
875 |
public function parse_args( $args, $options ) {
|
876 |
+
$options_with_rss_variants = array(
|
877 |
+
'limit', 'template', 'excerpt_length', 'before_title',
|
878 |
+
'after_title', 'before_post', 'after_post', 'before_related',
|
879 |
+
'after_related', 'no_results', 'order', 'promote_yarpp',
|
880 |
+
'thumbnails_heading', 'thumbnails_default' );
|
881 |
|
882 |
$r = array();
|
883 |
foreach ( $options as $option ) {
|
default.png
ADDED
Binary file
|
js/options.js
CHANGED
@@ -3,27 +3,29 @@ jQuery(function($) {
|
|
3 |
postboxes.add_postbox_toggles(pagenow);
|
4 |
|
5 |
function template() {
|
6 |
-
var
|
7 |
-
if (
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
excerpt();
|
15 |
}
|
16 |
-
$('.
|
17 |
-
template();
|
18 |
|
19 |
function excerpt() {
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
22 |
else
|
23 |
-
|
24 |
}
|
25 |
-
$('
|
26 |
-
|
27 |
var loaded_demo_web = false;
|
28 |
function display() {
|
29 |
if ( !$('#yarpp_display_web .inside').is(':visible') )
|
@@ -66,34 +68,13 @@ jQuery(function($) {
|
|
66 |
success:function(html){demo_rss.html('<pre>'+html+'</pre>')},
|
67 |
dataType:'html'});
|
68 |
}
|
69 |
-
|
70 |
} else {
|
71 |
$('.rss_displayed').hide();
|
72 |
}
|
73 |
}
|
74 |
$('#yarpp-rss_display, #yarpp_display_rss .handlediv, #yarpp_display_rss-hide').click(rss_display);
|
75 |
rss_display();
|
76 |
-
|
77 |
-
function rss_template() {
|
78 |
-
var value = $('#yarpp-rss_use_template').val();
|
79 |
-
if ( value == 'custom' ) {
|
80 |
-
$('.rss_templated').show();
|
81 |
-
$('.rss_not_templated').hide();
|
82 |
-
} else {
|
83 |
-
$('.rss_templated').hide();
|
84 |
-
$('.rss_not_templated').show();
|
85 |
-
}
|
86 |
-
rss_excerpt();
|
87 |
-
}
|
88 |
-
$('.rss_template').change(rss_template);
|
89 |
-
|
90 |
-
function rss_excerpt() {
|
91 |
-
if ($('#yarpp-rss_display').attr('checked') && $('#yarpp-rss_show_excerpt').attr('checked'))
|
92 |
-
$('.rss_excerpted').show();
|
93 |
-
else
|
94 |
-
$('.rss_excerpted').hide();
|
95 |
-
}
|
96 |
-
$('#yarpp-rss_display, #yarpp-rss_show_excerpt').click(rss_excerpt);
|
97 |
|
98 |
var loaded_disallows = false;
|
99 |
function load_disallows() {
|
@@ -234,4 +215,26 @@ jQuery(function($) {
|
|
234 |
$('#template_file, #rss_template_file')
|
235 |
.each(template_info)
|
236 |
.change(template_info);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
});
|
3 |
postboxes.add_postbox_toggles(pagenow);
|
4 |
|
5 |
function template() {
|
6 |
+
var metabox = $(this).closest('#yarpp_display_web, #yarpp_display_rss');
|
7 |
+
if ( !metabox.length )
|
8 |
+
return;
|
9 |
+
|
10 |
+
value = metabox.find('.use_template').val();
|
11 |
+
|
12 |
+
metabox.find('.yarpp_subbox').hide();
|
13 |
+
metabox.find('.template_options_' + value).show();
|
14 |
+
excerpt.apply(metabox);
|
15 |
}
|
16 |
+
$('.use_template').each(template).change(template);
|
|
|
17 |
|
18 |
function excerpt() {
|
19 |
+
var metabox = $(this).closest('#yarpp_display_web, #yarpp_display_rss');
|
20 |
+
|
21 |
+
if ( metabox.find('.use_template').val() == 'builtin' &&
|
22 |
+
metabox.find('.show_excerpt input').attr('checked') )
|
23 |
+
metabox.find('.excerpted').show();
|
24 |
else
|
25 |
+
metabox.find('.excerpted').hide();
|
26 |
}
|
27 |
+
$('.show_excerpt, .use_template, #yarpp-rss_display').click(excerpt);
|
28 |
+
|
29 |
var loaded_demo_web = false;
|
30 |
function display() {
|
31 |
if ( !$('#yarpp_display_web .inside').is(':visible') )
|
68 |
success:function(html){demo_rss.html('<pre>'+html+'</pre>')},
|
69 |
dataType:'html'});
|
70 |
}
|
71 |
+
$('#yarpp_display_rss').each(template);
|
72 |
} else {
|
73 |
$('.rss_displayed').hide();
|
74 |
}
|
75 |
}
|
76 |
$('#yarpp-rss_display, #yarpp_display_rss .handlediv, #yarpp_display_rss-hide').click(rss_display);
|
77 |
rss_display();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
var loaded_disallows = false;
|
80 |
function load_disallows() {
|
215 |
$('#template_file, #rss_template_file')
|
216 |
.each(template_info)
|
217 |
.change(template_info);
|
218 |
+
|
219 |
+
var loaded_optin_data = false;
|
220 |
+
function _display_optin_data() {
|
221 |
+
if ( !$('#optin_data_frame').is(':visible') || loaded_optin_data )
|
222 |
+
return;
|
223 |
+
loaded_optin_data = true;
|
224 |
+
var frame = $('#optin_data_frame');
|
225 |
+
$.ajax({type:'POST',
|
226 |
+
url: ajaxurl,
|
227 |
+
data: {
|
228 |
+
action: 'yarpp_optin_data',
|
229 |
+
'_ajax_nonce': $('#yarpp_optin_data-nonce').val()
|
230 |
+
},
|
231 |
+
beforeSend:function(){frame.html(loading)},
|
232 |
+
success:function(html){frame.html('<pre>'+html+'</pre>')},
|
233 |
+
dataType:'html'});
|
234 |
+
}
|
235 |
+
function display_optin_data() {
|
236 |
+
setTimeout(_display_optin_data, 0);
|
237 |
+
}
|
238 |
+
$('#yarpp-optin-learnmore, a[aria-controls=tab-panel-optin]').bind('click focus', display_optin_data);
|
239 |
+
display_optin_data();
|
240 |
});
|
options-meta-boxes.php
CHANGED
@@ -32,13 +32,16 @@ class YARPP_Meta_Box {
|
|
32 |
echo "<div data-value='builtin' class='yarpp_template_button";
|
33 |
if ( 'builtin' == $choice )
|
34 |
echo ' active';
|
35 |
-
echo "'><div class='image'></div><div class='label'>" . __('
|
36 |
|
37 |
-
echo "<div data-value='thumbnails' class='yarpp_template_button
|
38 |
if ( 'thumbnails' == $choice )
|
39 |
echo ' active';
|
|
|
|
|
40 |
echo "'";
|
41 |
-
|
|
|
42 |
echo "><div class='image'></div><div class='label'>" . __('Thumbnails', 'yarpp') . "</div></div>";
|
43 |
|
44 |
echo "<div data-value='custom' class='yarpp_template_button";
|
@@ -55,7 +58,7 @@ class YARPP_Meta_Box {
|
|
55 |
}
|
56 |
echo "><div class='image'></div><div class='label'>" . __('Custom', 'yarpp') . "</div></div>";
|
57 |
|
58 |
-
echo "<input type='hidden' name='{$pre}use_template' id='yarpp-{$pre}use_template' class='
|
59 |
|
60 |
echo "</div>";
|
61 |
|
@@ -234,21 +237,27 @@ class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
|
|
234 |
$this->template_checkbox( false );
|
235 |
echo "</div>";
|
236 |
|
237 |
-
echo "<div class='postbox yarpp_subbox
|
238 |
echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
|
239 |
$this->template_file( false );
|
240 |
echo "</div>";
|
241 |
|
242 |
-
echo "<div class='postbox yarpp_subbox
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
$this->beforeafter(array('before_related', 'after_related'),__("Before / after related entries:",'yarpp'), 15, '', __("For example:",'yarpp') . ' <ol></ol>' . __(' or ','yarpp') . '<div></div>');
|
244 |
$this->beforeafter(array('before_title', 'after_title'),__("Before / after each related entry:",'yarpp'),15, '', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
245 |
|
246 |
-
$this->checkbox('show_excerpt', __("Show excerpt?",'yarpp'), '');
|
247 |
$this->textbox('excerpt_length', __('Excerpt length (No. of words):','yarpp'), 10, 'excerpted');
|
248 |
|
249 |
$this->beforeafter(array('before_post', 'after_post'), __("Before / after (excerpt):",'yarpp'), 10, 'excerpted', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
250 |
|
251 |
-
$this->textbox('no_results', __('Default display if no results:','yarpp'), 40
|
252 |
echo "</div>";
|
253 |
|
254 |
$this->displayorder('order');
|
@@ -274,19 +283,25 @@ class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
|
|
274 |
$this->template_checkbox( true, 'rss_displayed' );
|
275 |
echo "</div>";
|
276 |
|
277 |
-
echo "<div class='postbox yarpp_subbox
|
278 |
echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
|
279 |
$this->template_file( true );
|
280 |
echo "</div>";
|
281 |
|
282 |
-
echo "<div class='postbox yarpp_subbox
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
$this->beforeafter(array('rss_before_related', 'rss_after_related'),__("Before / after related entries:",'yarpp'), 15, '', __("For example:",'yarpp') . ' <ol></ol>' . __(' or ','yarpp') . '<div></div>');
|
284 |
$this->beforeafter(array('rss_before_title', 'rss_after_title'),__("Before / after each related entry:",'yarpp'), 15, '', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
285 |
|
286 |
-
$this->checkbox('rss_show_excerpt', __("Show excerpt?",'yarpp'));
|
287 |
-
$this->textbox('rss_excerpt_length', __('Excerpt length (No. of words):','yarpp'), 10, '
|
288 |
|
289 |
-
$this->beforeafter(array('rss_before_post', 'rss_after_post'),__("Before / after (excerpt):",'yarpp'), 10, '
|
290 |
|
291 |
$this->textbox('rss_no_results', __('Default display if no results:','yarpp'), 40);
|
292 |
echo "</div>";
|
@@ -353,11 +368,11 @@ class YARPP_Meta_Box_Optin extends YARPP_Meta_Box {
|
|
353 |
$yarpp->optin_ping();
|
354 |
|
355 |
// TODO: fix this text and i18nize it
|
356 |
-
echo "<input type='checkbox' id='optin' name='optin' value='true'";
|
357 |
checked(yarpp_get_option('optin') == 1);
|
358 |
echo " /> ";
|
359 |
|
360 |
-
echo '<label for="optin">' . __('Send
|
361 |
|
362 |
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>';
|
363 |
}
|
32 |
echo "<div data-value='builtin' class='yarpp_template_button";
|
33 |
if ( 'builtin' == $choice )
|
34 |
echo ' active';
|
35 |
+
echo "'><div class='image'></div><div class='label'>" . __('List', 'yarpp') . "</div></div>";
|
36 |
|
37 |
+
echo "<div data-value='thumbnails' class='yarpp_template_button";
|
38 |
if ( 'thumbnails' == $choice )
|
39 |
echo ' active';
|
40 |
+
if ( !current_theme_supports( 'post-thumbnails', 'post' ) )
|
41 |
+
echo ' disabled';
|
42 |
echo "'";
|
43 |
+
if ( !current_theme_supports( 'post-thumbnails', 'post' ) )
|
44 |
+
echo ' data-help="' . esc_attr( __( 'This option is disabled because your theme does not support post thumbnails.', 'yarpp' ) ) . '"';
|
45 |
echo "><div class='image'></div><div class='label'>" . __('Thumbnails', 'yarpp') . "</div></div>";
|
46 |
|
47 |
echo "<div data-value='custom' class='yarpp_template_button";
|
58 |
}
|
59 |
echo "><div class='image'></div><div class='label'>" . __('Custom', 'yarpp') . "</div></div>";
|
60 |
|
61 |
+
echo "<input type='hidden' name='{$pre}use_template' id='yarpp-{$pre}use_template' class='use_template' value='{$choice}' />";
|
62 |
|
63 |
echo "</div>";
|
64 |
|
237 |
$this->template_checkbox( false );
|
238 |
echo "</div>";
|
239 |
|
240 |
+
echo "<div class='postbox yarpp_subbox template_options_custom'>";
|
241 |
echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
|
242 |
$this->template_file( false );
|
243 |
echo "</div>";
|
244 |
|
245 |
+
echo "<div class='postbox yarpp_subbox template_options_thumbnails'>";
|
246 |
+
$this->textbox('thumbnails_heading', __('Heading:','yarpp'), 40);
|
247 |
+
$this->textbox('thumbnails_default', __('Default image (URL):','yarpp'), 40);
|
248 |
+
$this->textbox('no_results', __('Default display if no results:','yarpp'), 40);
|
249 |
+
echo "</div>";
|
250 |
+
|
251 |
+
echo "<div class='postbox yarpp_subbox template_options_builtin'>";
|
252 |
$this->beforeafter(array('before_related', 'after_related'),__("Before / after related entries:",'yarpp'), 15, '', __("For example:",'yarpp') . ' <ol></ol>' . __(' or ','yarpp') . '<div></div>');
|
253 |
$this->beforeafter(array('before_title', 'after_title'),__("Before / after each related entry:",'yarpp'),15, '', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
254 |
|
255 |
+
$this->checkbox('show_excerpt', __("Show excerpt?",'yarpp'), 'show_excerpt');
|
256 |
$this->textbox('excerpt_length', __('Excerpt length (No. of words):','yarpp'), 10, 'excerpted');
|
257 |
|
258 |
$this->beforeafter(array('before_post', 'after_post'), __("Before / after (excerpt):",'yarpp'), 10, 'excerpted', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
259 |
|
260 |
+
$this->textbox('no_results', __('Default display if no results:','yarpp'), 40);
|
261 |
echo "</div>";
|
262 |
|
263 |
$this->displayorder('order');
|
283 |
$this->template_checkbox( true, 'rss_displayed' );
|
284 |
echo "</div>";
|
285 |
|
286 |
+
echo "<div class='postbox yarpp_subbox template_options_custom rss_displayed'>";
|
287 |
echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
|
288 |
$this->template_file( true );
|
289 |
echo "</div>";
|
290 |
|
291 |
+
echo "<div class='postbox yarpp_subbox template_options_thumbnails'>";
|
292 |
+
$this->textbox('rss_thumbnails_heading', __('Heading:','yarpp'), 40);
|
293 |
+
$this->textbox('rss_thumbnails_default', __('Default image (URL):','yarpp'), 40);
|
294 |
+
$this->textbox('rss_no_results', __('Default display if no results:','yarpp'), 40);
|
295 |
+
echo "</div>";
|
296 |
+
|
297 |
+
echo "<div class='postbox yarpp_subbox template_options_builtin rss_displayed'>";
|
298 |
$this->beforeafter(array('rss_before_related', 'rss_after_related'),__("Before / after related entries:",'yarpp'), 15, '', __("For example:",'yarpp') . ' <ol></ol>' . __(' or ','yarpp') . '<div></div>');
|
299 |
$this->beforeafter(array('rss_before_title', 'rss_after_title'),__("Before / after each related entry:",'yarpp'), 15, '', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
300 |
|
301 |
+
$this->checkbox('rss_show_excerpt', __("Show excerpt?",'yarpp'), 'show_excerpt');
|
302 |
+
$this->textbox('rss_excerpt_length', __('Excerpt length (No. of words):','yarpp'), 10, 'excerpted');
|
303 |
|
304 |
+
$this->beforeafter(array('rss_before_post', 'rss_after_post'),__("Before / after (excerpt):",'yarpp'), 10, 'excerpted', __("For example:",'yarpp') . ' <li></li>' . __(' or ','yarpp') . '<dl></dl>');
|
305 |
|
306 |
$this->textbox('rss_no_results', __('Default display if no results:','yarpp'), 40);
|
307 |
echo "</div>";
|
368 |
$yarpp->optin_ping();
|
369 |
|
370 |
// TODO: fix this text and i18nize it
|
371 |
+
echo "<input type='checkbox' id='yarpp-optin' name='optin' value='true'";
|
372 |
checked(yarpp_get_option('optin') == 1);
|
373 |
echo " /> ";
|
374 |
|
375 |
+
echo '<label for="yarpp-optin">' . __('Send settings and usage data back to YARPP', 'yarpp') . '</label>';
|
376 |
|
377 |
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>';
|
378 |
}
|
options.css
CHANGED
@@ -147,7 +147,7 @@ a.yarpp_help:hover {
|
|
147 |
}
|
148 |
.yarpp_code_display div {
|
149 |
overflow: auto;
|
150 |
-
max-height:
|
151 |
}
|
152 |
.yarpp_scroll_wrapper {
|
153 |
overflow: auto;
|
@@ -176,7 +176,7 @@ a.yarpp_help:hover {
|
|
176 |
font-family: monospace;
|
177 |
}
|
178 |
|
179 |
-
.
|
180 |
font-family: monospace;
|
181 |
}
|
182 |
|
@@ -257,4 +257,9 @@ a.yarpp_help:hover {
|
|
257 |
}
|
258 |
.yarpp_template_button[data-value=custom] > div.image {
|
259 |
background-position: -140px 0px;
|
|
|
|
|
|
|
|
|
|
|
260 |
}
|
147 |
}
|
148 |
.yarpp_code_display div {
|
149 |
overflow: auto;
|
150 |
+
max-height: 300px;
|
151 |
}
|
152 |
.yarpp_scroll_wrapper {
|
153 |
overflow: auto;
|
176 |
font-family: monospace;
|
177 |
}
|
178 |
|
179 |
+
.yarpp_subbox input[type=text], .yarpp_subbox input[type=text] {
|
180 |
font-family: monospace;
|
181 |
}
|
182 |
|
257 |
}
|
258 |
.yarpp_template_button[data-value=custom] > div.image {
|
259 |
background-position: -140px 0px;
|
260 |
+
}
|
261 |
+
|
262 |
+
#optin_data_frame {
|
263 |
+
overflow: scroll;
|
264 |
+
max-height: 300px;
|
265 |
}
|
options.php
CHANGED
@@ -153,6 +153,7 @@ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
|
153 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
154 |
wp_nonce_field( 'yarpp_display_demo', 'yarpp_display_demo-nonce', false );
|
155 |
wp_nonce_field( 'yarpp_display_exclude_terms', 'yarpp_display_exclude_terms-nonce', false );
|
|
|
156 |
if ( !count($yarpp->admin->get_templates()) && $yarpp->admin->can_copy_templates() )
|
157 |
wp_nonce_field( 'yarpp_copy_templates', 'yarpp_copy_templates-nonce', false );
|
158 |
?>
|
153 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
154 |
wp_nonce_field( 'yarpp_display_demo', 'yarpp_display_demo-nonce', false );
|
155 |
wp_nonce_field( 'yarpp_display_exclude_terms', 'yarpp_display_exclude_terms-nonce', false );
|
156 |
+
wp_nonce_field( 'yarpp_optin_data', 'yarpp_optin_data-nonce', false );
|
157 |
if ( !count($yarpp->admin->get_templates()) && $yarpp->admin->can_copy_templates() )
|
158 |
wp_nonce_field( 'yarpp_copy_templates', 'yarpp_copy_templates-nonce', false );
|
159 |
?>
|
readme.txt
CHANGED
@@ -235,6 +235,9 @@ If you are a bilingual speaker of English and another language and an avid user
|
|
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
|
235 |
== Changelog ==
|
236 |
|
237 |
= 3.6 =
|
238 |
+
* New thumbnail template option!
|
239 |
+
* No PHP required -- just visit the settings page
|
240 |
+
* Edit your theme's CSS file to modify the styling
|
241 |
* 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)).
|
242 |
* Improvements to YARPP custom template UI
|
243 |
* A new design for the template chooser
|
template-thumbnails.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* YARPP's built-in thumbnails template
|
4 |
+
* @since 3.6
|
5 |
+
*
|
6 |
+
* This template is used when you choose the built-in thumbnails option.
|
7 |
+
* If you want to create a new template, look at yarpp-templates/yarpp-template-example.php as an example.
|
8 |
+
* More information on the custom templates is available at http://mitcho.com/blog/projects/yarpp-3-templates/
|
9 |
+
*/
|
10 |
+
|
11 |
+
$options = array( 'thumbnails_heading', 'thumbnails_default', 'no_results' );
|
12 |
+
extract( $this->parse_args( $args, $options ) );
|
13 |
+
|
14 |
+
global $_wp_additional_image_sizes;
|
15 |
+
|
16 |
+
// @todo: add support for other theme-specified sizes?
|
17 |
+
// if ( isset($_wp_additional_image_sizes['yarpp-thumbnail']) )
|
18 |
+
// $size = 'yarpp-thumbnail';
|
19 |
+
// elseif ( isset($_wp_additional_image_sizes['post-thumbnail']) )
|
20 |
+
// $size = 'post-thumbnail';
|
21 |
+
|
22 |
+
if ( isset($size) ) {
|
23 |
+
$width = (int) $_wp_additional_image_sizes[$size]['width'];
|
24 |
+
$height = (int) $_wp_additional_image_sizes[$size]['height'];
|
25 |
+
} else {
|
26 |
+
$size = '120x120'; // the ultimate default
|
27 |
+
$width = 120;
|
28 |
+
$height = 120;
|
29 |
+
}
|
30 |
+
$margin = 5;
|
31 |
+
$width_with_margins = $width + 2 * $margin;
|
32 |
+
$height_with_text = $height + 50;
|
33 |
+
$extramargin = 7;
|
34 |
+
|
35 |
+
// a little easter egg: if the default image URL is left blank,
|
36 |
+
// default to the theme's header image. (hopefully it has one)
|
37 |
+
if ( empty($thumbnails_default) )
|
38 |
+
$thumbnails_default = get_header_image();
|
39 |
+
|
40 |
+
$output .= '<h3>' . $thumbnails_heading . '</h3>' . "\n";
|
41 |
+
|
42 |
+
if (have_posts()) {
|
43 |
+
$output .= '<div class="yarpp-thumbnails-horizontal">' . "\n";
|
44 |
+
while (have_posts()) {
|
45 |
+
the_post();
|
46 |
+
|
47 |
+
$output .= "<a class='yarpp-thumbnail' href='" . get_permalink() . "' title='" . the_title_attribute('echo=0') . "'>" . "\n";
|
48 |
+
|
49 |
+
if ( has_post_thumbnail() )
|
50 |
+
$output .= get_the_post_thumbnail( null, $size );
|
51 |
+
else
|
52 |
+
$output .= '<span class="yarpp-thumbnail-default"><img class="yarpp-thumbnail-default-wide" src="' . esc_url($thumbnails_default) . '"/></span>';
|
53 |
+
// assume default images (header images) are wider than they are tall
|
54 |
+
|
55 |
+
$output .= '<span class="yarpp-thumbnail-title">' . get_the_title() . '</span>';
|
56 |
+
$output .= '</a>' . "\n";
|
57 |
+
|
58 |
+
}
|
59 |
+
$output .= "</div>\n";
|
60 |
+
} else {
|
61 |
+
$output .= $no_results;
|
62 |
+
}
|
63 |
+
|
64 |
+
$output .= "
|
65 |
+
<style>
|
66 |
+
.yarpp-thumbnails-horizontal .yarpp-thumbnail, .yarpp-thumbnail-default, .yarpp-thumbnail-title {
|
67 |
+
display: inline-block;
|
68 |
+
*display: inline;
|
69 |
+
}
|
70 |
+
.yarpp-thumbnails-horizontal .yarpp-thumbnail {
|
71 |
+
border: 1px solid rgba(127,127,127,0.1);
|
72 |
+
width: {$width_with_margins}px;
|
73 |
+
height: {$height_with_text}px;
|
74 |
+
margin: {$margin}px;
|
75 |
+
margin-left: 0px;
|
76 |
+
vertical-align: top;
|
77 |
+
}
|
78 |
+
.yarpp-thumbnail > img, .yarpp-thumbnail-default {
|
79 |
+
width: {$width}px;
|
80 |
+
height: {$height}px;
|
81 |
+
margin: {$margin}px;
|
82 |
+
}
|
83 |
+
.yarpp-thumbnails-horizontal .yarpp-thumbnail > img, .yarpp-thumbnails-horizontal .yarpp-thumbnail-default {
|
84 |
+
margin-bottom: 0px;
|
85 |
+
display: block;
|
86 |
+
}
|
87 |
+
.yarpp-thumbnails-horizontal .yarpp-thumbnail-title {
|
88 |
+
font-size: 1em;
|
89 |
+
max-height: 2.8em;
|
90 |
+
line-height: 1.4em;
|
91 |
+
margin: {$extramargin}px;
|
92 |
+
margin-top: 0px;
|
93 |
+
width: {$width}px;
|
94 |
+
text-decoration: inherit;
|
95 |
+
overflow: hidden;
|
96 |
+
}
|
97 |
+
|
98 |
+
.yarpp-thumbnail-default {
|
99 |
+
overflow: hidden;
|
100 |
+
}
|
101 |
+
.yarpp-thumbnail-default > img.yarpp-thumbnail-default-wide {
|
102 |
+
height: {$height}px;
|
103 |
+
max-width: none;
|
104 |
+
}
|
105 |
+
.yarpp-thumbnail-default > img.yarpp-thumbnail-default-tall {
|
106 |
+
width: {$width}px;
|
107 |
+
max-height: none;
|
108 |
+
}
|
109 |
+
</style>
|
110 |
+
";
|
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.6b5
|
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.6b5');
|
13 |
define('YARPP_DIR', dirname(__FILE__));
|
14 |
define('YARPP_NO_RELATED', ':(');
|
15 |
define('YARPP_RELATED', ':)');
|