Version Description
Download this release
Release Info
Developer | mitchoyoshitaka |
Plugin | Yet Another Related Posts Plugin (YARPP) |
Version | 4.0b8 |
Comparing to | |
See all releases |
Code changes from version 3.6b6 to 4.0b8
- cache-tables.php +1 -1
- class-admin.php +60 -12
- class-core.php +85 -46
- js/options.js +48 -14
- options-meta-boxes.php +182 -130
- options.css +41 -6
- options.php +15 -1
- readme.txt +20 -4
- styles-thumbnails.php +65 -0
- template-thumbnails.php +2 -52
- yarpp.php +2 -2
cache-tables.php
CHANGED
@@ -284,7 +284,7 @@ class YARPP_Cache_Tables extends YARPP_Cache {
|
|
284 |
if ( !is_int($ID) )
|
285 |
return false;
|
286 |
|
287 |
-
// @since
|
288 |
// the old keyword cache would basically have to be recomputed every time the
|
289 |
// relatedness cache was recomputed, but no more, so there's no point in keeping
|
290 |
// these around separately.
|
284 |
if ( !is_int($ID) )
|
285 |
return false;
|
286 |
|
287 |
+
// @since 4: compute fresh each time, instead of using cache table.
|
288 |
// the old keyword cache would basically have to be recomputed every time the
|
289 |
// relatedness cache was recomputed, but no more, so there's no point in keeping
|
290 |
// these around separately.
|
class-admin.php
CHANGED
@@ -28,6 +28,7 @@ class YARPP_Admin {
|
|
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' ) );
|
|
|
31 |
// new in 3.3: set default meta boxes to show:
|
32 |
add_filter( 'default_hidden_meta_boxes', array( $this, 'default_hidden_meta_boxes' ), 10, 2 );
|
33 |
}
|
@@ -68,7 +69,7 @@ class YARPP_Admin {
|
|
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( '
|
72 |
}
|
73 |
}
|
74 |
|
@@ -81,8 +82,9 @@ class YARPP_Admin {
|
|
81 |
add_action( 'admin_print_footer_scripts', array( $this, 'pointer_script' ) );
|
82 |
}
|
83 |
} elseif ( !$this->core->get_option('optin') &&
|
84 |
-
|
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' ) );
|
@@ -159,9 +161,9 @@ class YARPP_Admin {
|
|
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>';
|
@@ -195,12 +197,34 @@ class YARPP_Admin {
|
|
195 |
</script>\n";
|
196 |
}
|
197 |
|
198 |
-
function optin_notice() {
|
199 |
-
echo '<div class="updated fade">';
|
200 |
-
|
201 |
-
|
202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
$this->print_optin_button();
|
|
|
204 |
echo '</p></div>';
|
205 |
}
|
206 |
|
@@ -236,6 +260,19 @@ class YARPP_Admin {
|
|
236 |
return $text;
|
237 |
}
|
238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
// since 3.3
|
240 |
function enqueue() {
|
241 |
$version = defined('WP_DEBUG') && WP_DEBUG ? time() : YARPP_VERSION;
|
@@ -344,7 +381,7 @@ jQuery(function () {
|
|
344 |
return $hidden;
|
345 |
}
|
346 |
|
347 |
-
// @since
|
348 |
function can_copy_templates() {
|
349 |
$theme_dir = get_stylesheet_directory();
|
350 |
// If we can't write to the theme, return false
|
@@ -476,4 +513,15 @@ jQuery(function () {
|
|
476 |
echo 'ok';
|
477 |
exit;
|
478 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
479 |
}
|
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' ) );
|
31 |
+
add_filter( 'screen_settings', array( $this, 'render_screen_settings' ), 10, 2 );
|
32 |
// new in 3.3: set default meta boxes to show:
|
33 |
add_filter( 'default_hidden_meta_boxes', array( $this, 'default_hidden_meta_boxes' ), 10, 2 );
|
34 |
}
|
69 |
add_action( 'wp_ajax_yarpp_display', array( $this, 'ajax_display' ) );
|
70 |
add_action( 'wp_ajax_yarpp_optin_data', array( $this, 'ajax_optin_data' ) );
|
71 |
add_action( 'wp_ajax_yarpp_optin', array( $this, 'ajax_optin' ) );
|
72 |
+
add_action( 'wp_ajax_yarpp_set_display_code', array( $this, 'ajax_set_display_code' ) );
|
73 |
}
|
74 |
}
|
75 |
|
82 |
add_action( 'admin_print_footer_scripts', array( $this, 'pointer_script' ) );
|
83 |
}
|
84 |
} elseif ( !$this->core->get_option('optin') &&
|
85 |
+
current_user_can('manage_options') &&
|
86 |
+
!get_user_option( 'yarpp_saw_optin' )
|
87 |
+
) {
|
88 |
$user = get_current_user_id();
|
89 |
update_user_option( $user, 'yarpp_saw_optin', true );
|
90 |
add_action( 'admin_notices', array( $this, 'optin_notice' ) );
|
161 |
|
162 |
public function help_optin() {
|
163 |
// todo: i18n
|
164 |
+
echo '<p>' . sprintf( __( "With your permission, YARPP will send information about YARPP's settings, usage, and environment back to a central server at %s.", 'yarpp' ), '<code>yarpp.org</code>') . ' ';
|
165 |
+
echo __( "This information will be used to improve YARPP in the future and help decide future development decisions for YARPP.", 'yarpp' ) . ' ';
|
166 |
+
echo '<strong>' . __( "Contributing this data will help make YARPP better for you and for other YARPP users.", 'yarpp' ) . '</strong></p>';
|
167 |
|
168 |
if ( !$this->core->get_option( 'optin' ) ) {
|
169 |
echo '<p>';
|
197 |
</script>\n";
|
198 |
}
|
199 |
|
200 |
+
function optin_notice( $pool = null ) {
|
201 |
+
echo '<div class="updated fade"><p>';
|
202 |
+
|
203 |
+
// @todo i18n
|
204 |
+
if ( is_null( $pool ) );
|
205 |
+
$pool = $this->core->get_option( 'pools[message]' );
|
206 |
+
switch ( $pool ) {
|
207 |
+
case 0:
|
208 |
+
echo "Help make YARPP better by sending information about YARPP's settings and usage statistics.";
|
209 |
+
break;
|
210 |
+
case 1:
|
211 |
+
echo sprintf( __( "With your permission, YARPP will send information about YARPP's settings, usage, and environment back to a central server at %s.", 'yarpp' ), '<code>yarpp.org</code>') . ' ';
|
212 |
+
echo __( "This information will be used to improve YARPP in the future and help decide future development decisions for YARPP.", 'yarpp' ) . ' ';
|
213 |
+
echo '<strong>' . __( "Contributing this data will help make YARPP better for you and for other YARPP users.", 'yarpp' ) . '</strong>';
|
214 |
+
break;
|
215 |
+
case 2:
|
216 |
+
echo "<strong>Help make YARPP better.</strong> ";
|
217 |
+
echo 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>') . ' ';
|
218 |
+
echo "This information will be used to improve YARPP in the future and help decide future development decisions for YARPP.";
|
219 |
+
break;
|
220 |
+
case 3:
|
221 |
+
echo "YARPP can automatically collect diagnostic and usage information from your site and send it to YARPP's author for analysis. The information is sent only with your consent. ";
|
222 |
+
echo '<strong>' . "Contributing this data will help make YARPP better for you and for other YARPP users." . '</strong>';
|
223 |
+
}
|
224 |
+
|
225 |
+
echo '</p><p>';
|
226 |
$this->print_optin_button();
|
227 |
+
echo '<a class="button" href="options-general.php?page=yarpp#help-optin">' . __( 'Learn More', 'yarpp' ) . '</a>';
|
228 |
echo '</p></div>';
|
229 |
}
|
230 |
|
260 |
return $text;
|
261 |
}
|
262 |
|
263 |
+
function render_screen_settings( $output, $current_screen ) {
|
264 |
+
if ( $current_screen->id != 'settings_page_yarpp' )
|
265 |
+
return $output;
|
266 |
+
|
267 |
+
$output .= "<div id='yarpp_extra_screen_settings'><label for='yarpp_display_code'><input type='checkbox' name='yarpp_display_code' id='yarpp_display_code'";
|
268 |
+
$output .= checked( $this->core->get_option('display_code'), true, false );
|
269 |
+
$output .= " />";
|
270 |
+
$output .= __('Show example code output', 'yarpp');
|
271 |
+
$output .= '</label></div>';
|
272 |
+
|
273 |
+
return $output;
|
274 |
+
}
|
275 |
+
|
276 |
// since 3.3
|
277 |
function enqueue() {
|
278 |
$version = defined('WP_DEBUG') && WP_DEBUG ? time() : YARPP_VERSION;
|
381 |
return $hidden;
|
382 |
}
|
383 |
|
384 |
+
// @since 4: UI to copy templates
|
385 |
function can_copy_templates() {
|
386 |
$theme_dir = get_stylesheet_directory();
|
387 |
// If we can't write to the theme, return false
|
513 |
echo 'ok';
|
514 |
exit;
|
515 |
}
|
516 |
+
|
517 |
+
function ajax_set_display_code() {
|
518 |
+
check_ajax_referer( 'yarpp_set_display_code' );
|
519 |
+
|
520 |
+
header("HTTP/1.1 200");
|
521 |
+
header("Content-Type: text; charset=UTF-8");
|
522 |
+
|
523 |
+
$data = yarpp_set_option( 'display_code', isset($_REQUEST['checked']) );
|
524 |
+
echo 'ok';
|
525 |
+
exit;
|
526 |
+
}
|
527 |
}
|
class-core.php
CHANGED
@@ -60,15 +60,15 @@ class YARPP {
|
|
60 |
|
61 |
private function load_default_options() {
|
62 |
$this->default_options = array(
|
63 |
-
'threshold' =>
|
64 |
-
'limit' =>
|
65 |
'excerpt_length' => 10,
|
66 |
'recent' => false, // new in 3.5
|
67 |
'before_title' => '<li>',
|
68 |
'after_title' => '</li>',
|
69 |
'before_post' => ' <small>',
|
70 |
'after_post' => '</small>',
|
71 |
-
'before_related' => '<
|
72 |
'after_related' => '</ol>',
|
73 |
'no_results' => '<p>'.__('No related posts.','yarpp').'</p>',
|
74 |
'order' => 'score DESC',
|
@@ -78,7 +78,7 @@ class YARPP {
|
|
78 |
'rss_after_title' => '</li>',
|
79 |
'rss_before_post' => ' <small>',
|
80 |
'rss_after_post' => '</small>',
|
81 |
-
'rss_before_related' => '<
|
82 |
'rss_after_related' => '</ol>',
|
83 |
'rss_no_results' => '<p>'.__('No related posts.','yarpp').'</p>',
|
84 |
'rss_order' => 'score DESC',
|
@@ -89,7 +89,6 @@ class YARPP {
|
|
89 |
'rss_template' => false, // new in 3.5
|
90 |
'show_pass_post' => false,
|
91 |
'cross_relate' => false,
|
92 |
-
'auto_display' => true,
|
93 |
'rss_display' => false, // changed default in 3.1.7
|
94 |
'rss_excerpt_display' => true,
|
95 |
'promote_yarpp' => false,
|
@@ -105,11 +104,15 @@ class YARPP {
|
|
105 |
)
|
106 |
),
|
107 |
'require_tax' => array(), // new in 3.5
|
108 |
-
'optin' => false, // new in
|
109 |
-
'thumbnails_heading' => __('Related posts:','yarpp'), // new in
|
110 |
-
'thumbnails_default' => plugins_url( 'default.png', __FILE__ ), // new in
|
111 |
-
'rss_thumbnails_heading' => __('Related posts:','yarpp'), // new in
|
112 |
-
'rss_thumbnails_default' => plugins_url( 'default.png', __FILE__ ) // new in
|
|
|
|
|
|
|
|
|
113 |
);
|
114 |
}
|
115 |
|
@@ -229,7 +232,7 @@ class YARPP {
|
|
229 |
|
230 |
/*
|
231 |
* DIAGNOSTICS
|
232 |
-
* @since
|
233 |
*/
|
234 |
|
235 |
function diagnostic_myisam_posts() {
|
@@ -268,6 +271,18 @@ class YARPP {
|
|
268 |
return current_theme_supports( 'post-thumbnails', 'post' );
|
269 |
}
|
270 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
/*
|
272 |
* UPGRADE ROUTINES
|
273 |
*/
|
@@ -291,6 +306,8 @@ class YARPP {
|
|
291 |
$this->upgrade_3_4_4b4();
|
292 |
if ( $last_version && version_compare('3.5.2b2', $last_version) > 0 )
|
293 |
$this->upgrade_3_5_2b2();
|
|
|
|
|
294 |
|
295 |
$this->cache->upgrade($last_version);
|
296 |
// flush cache in 3.4.1b5 as 3.4 messed up calculations.
|
@@ -307,8 +324,8 @@ class YARPP {
|
|
307 |
global $wpdb;
|
308 |
|
309 |
$yarpp_3_3_options = array(
|
310 |
-
'threshold' =>
|
311 |
-
'limit' =>
|
312 |
'template_file' => '', // new in 2.2
|
313 |
'excerpt_length' => 10,
|
314 |
'recent_number' => 12,
|
@@ -317,7 +334,7 @@ class YARPP {
|
|
317 |
'after_title' => '</li>',
|
318 |
'before_post' => ' <small>',
|
319 |
'after_post' => '</small>',
|
320 |
-
'before_related' => '<
|
321 |
'after_related' => '</ol>',
|
322 |
'no_results' => '<p>'.__('No related posts.','yarpp').'</p>',
|
323 |
'order' => 'score DESC',
|
@@ -328,7 +345,7 @@ class YARPP {
|
|
328 |
'rss_after_title' => '</li>',
|
329 |
'rss_before_post' => ' <small>',
|
330 |
'rss_after_post' => '</small>',
|
331 |
-
'rss_before_related' => '<
|
332 |
'rss_after_related' => '</ol>',
|
333 |
'rss_no_results' => '<p>'.__('No related posts.','yarpp').'</p>',
|
334 |
'rss_order' => 'score DESC',
|
@@ -502,17 +519,14 @@ class YARPP {
|
|
502 |
yarpp_set_option(array('weight' => $weight));
|
503 |
}
|
504 |
}
|
505 |
-
|
506 |
-
function is_happy() {
|
507 |
-
$stats = $this->cache->stats();
|
508 |
-
|
509 |
-
if ( !(array_sum( $stats ) > 0) )
|
510 |
-
return false;
|
511 |
-
|
512 |
-
$sum = array_sum(array_map('array_product', array_map(null, array_values($stats), array_keys($stats))));
|
513 |
-
$avg = $sum / array_sum( $stats );
|
514 |
|
515 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
}
|
517 |
|
518 |
private $post_types = null;
|
@@ -568,16 +582,15 @@ class YARPP {
|
|
568 |
'threshold', 'limit', 'excerpt_length', 'recent', 'rss_limit',
|
569 |
'rss_excerpt_length', 'past_only', 'show_excerpt', 'rss_show_excerpt',
|
570 |
'template', 'rss_template', 'show_pass_post', 'cross_relate',
|
571 |
-
'
|
572 |
-
'
|
573 |
));
|
574 |
$check_changed = array(
|
575 |
'before_title', 'after_title', 'before_post', 'after_post',
|
576 |
-
'
|
577 |
-
'
|
578 |
-
'
|
579 |
-
'
|
580 |
-
'rss_thumbnails_default'
|
581 |
);
|
582 |
|
583 |
$data = array(
|
@@ -594,7 +607,8 @@ class YARPP {
|
|
594 |
'myisam_posts' => $this->diagnostic_myisam_posts(),
|
595 |
'fulltext_indices' => $this->diagnostic_fulltext_indices(),
|
596 |
'hidden_metaboxes' => $this->diagnostic_hidden_metaboxes(),
|
597 |
-
'post_thumbnails' => $this->diagnostic_post_thumbnails()
|
|
|
598 |
),
|
599 |
'stats' => array(
|
600 |
'counts' => array(),
|
@@ -612,14 +626,21 @@ class YARPP {
|
|
612 |
'plugins' => array(
|
613 |
'active' => implode( '|', get_option( 'active_plugins', array() ) ),
|
614 |
'sitewide' => implode( '|', get_site_option( 'active_sitewide_plugins', array() ) )
|
615 |
-
)
|
|
|
616 |
);
|
|
|
617 |
|
618 |
$changed = array();
|
619 |
foreach ( $check_changed as $key ) {
|
620 |
if ( $yarpp->default_options[$key] != $settings[$key] )
|
621 |
$changed[] = $key;
|
622 |
}
|
|
|
|
|
|
|
|
|
|
|
623 |
$data['yarpp']['changed_settings'] = implode( '|', $changed );
|
624 |
|
625 |
if ( method_exists( $yarpp->cache, 'cache_status' ) )
|
@@ -729,6 +750,7 @@ class YARPP {
|
|
729 |
}
|
730 |
$this->prep_query( $current_query->is_feed );
|
731 |
$related_query = $wp_query; // backwards compatibility
|
|
|
732 |
|
733 |
// @todo: add these classes after the fact and include information about whether any results were given
|
734 |
$output = "<div class='";
|
@@ -736,7 +758,10 @@ class YARPP {
|
|
736 |
$output .= "yarpp-related";
|
737 |
else
|
738 |
$output .= "yarpp-related-{$domain}";
|
|
|
|
|
739 |
$output .= "'>\n";
|
|
|
740 |
if ( 'metabox' == $domain ) {
|
741 |
include(YARPP_DIR . '/template-metabox.php');
|
742 |
} elseif ( !!$template && 'thumbnails' == $template ) {
|
@@ -765,11 +790,11 @@ class YARPP {
|
|
765 |
wp_reset_postdata();
|
766 |
$pagenow = $current_pagenow; unset($current_pagenow);
|
767 |
|
768 |
-
if ($promote_yarpp && $domain != 'metabox')
|
769 |
$output .= "<p>".sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'), 'http://yarpp.org')."</p>\n";
|
770 |
|
771 |
if ( $optin )
|
772 |
-
$output .= "<img src='http://yarpp.org/
|
773 |
|
774 |
$output .= "</div>\n";
|
775 |
|
@@ -979,19 +1004,33 @@ class YARPP {
|
|
979 |
*/
|
980 |
|
981 |
function the_content($content) {
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
986 |
|
987 |
if ( $this->get_option('cross_relate') )
|
988 |
-
$
|
989 |
-
else if ( 'page' == get_post_type() )
|
990 |
-
$type = array( 'page' );
|
991 |
else
|
992 |
-
$
|
|
|
|
|
993 |
|
994 |
-
return $content . $this->display_related(null, array(
|
|
|
|
|
|
|
995 |
}
|
996 |
|
997 |
function the_content_feed($content) {
|
@@ -1042,7 +1081,7 @@ class YARPP {
|
|
1042 |
return $result;
|
1043 |
}
|
1044 |
|
1045 |
-
// @since
|
1046 |
function optin_ping() {
|
1047 |
if ( get_transient( 'yarpp_optin' ) )
|
1048 |
return true;
|
60 |
|
61 |
private function load_default_options() {
|
62 |
$this->default_options = array(
|
63 |
+
'threshold' => 4, // changed default in 4
|
64 |
+
'limit' => 4, // changed default in 4
|
65 |
'excerpt_length' => 10,
|
66 |
'recent' => false, // new in 3.5
|
67 |
'before_title' => '<li>',
|
68 |
'after_title' => '</li>',
|
69 |
'before_post' => ' <small>',
|
70 |
'after_post' => '</small>',
|
71 |
+
'before_related' => '<h3>'.__('Related posts:','yarpp').'</h3><ol>',
|
72 |
'after_related' => '</ol>',
|
73 |
'no_results' => '<p>'.__('No related posts.','yarpp').'</p>',
|
74 |
'order' => 'score DESC',
|
78 |
'rss_after_title' => '</li>',
|
79 |
'rss_before_post' => ' <small>',
|
80 |
'rss_after_post' => '</small>',
|
81 |
+
'rss_before_related' => '<h3>'.__('Related posts:','yarpp').'</h3><ol>',
|
82 |
'rss_after_related' => '</ol>',
|
83 |
'rss_no_results' => '<p>'.__('No related posts.','yarpp').'</p>',
|
84 |
'rss_order' => 'score DESC',
|
89 |
'rss_template' => false, // new in 3.5
|
90 |
'show_pass_post' => false,
|
91 |
'cross_relate' => false,
|
|
|
92 |
'rss_display' => false, // changed default in 3.1.7
|
93 |
'rss_excerpt_display' => true,
|
94 |
'promote_yarpp' => false,
|
104 |
)
|
105 |
),
|
106 |
'require_tax' => array(), // new in 3.5
|
107 |
+
'optin' => false, // new in 4
|
108 |
+
'thumbnails_heading' => __('Related posts:','yarpp'), // new in 4
|
109 |
+
'thumbnails_default' => plugins_url( 'default.png', __FILE__ ), // new in 4
|
110 |
+
'rss_thumbnails_heading' => __('Related posts:','yarpp'), // new in 4
|
111 |
+
'rss_thumbnails_default' => plugins_url( 'default.png', __FILE__ ), // new in 4
|
112 |
+
'display_code' => false, // new in 4
|
113 |
+
'auto_display_archive' => false, // new in 4
|
114 |
+
'auto_display_post_types' => array( 'post' ), // new in 4, replacing auto_display
|
115 |
+
'pools' => array( 'message' => mt_rand(0,3) ), // new in 4
|
116 |
);
|
117 |
}
|
118 |
|
232 |
|
233 |
/*
|
234 |
* DIAGNOSTICS
|
235 |
+
* @since 4 moved into separate functions. Note return value types can differ.
|
236 |
*/
|
237 |
|
238 |
function diagnostic_myisam_posts() {
|
271 |
return current_theme_supports( 'post-thumbnails', 'post' );
|
272 |
}
|
273 |
|
274 |
+
function diagnostic_happy() {
|
275 |
+
$stats = $this->cache->stats();
|
276 |
+
|
277 |
+
if ( !(array_sum( $stats ) > 0) )
|
278 |
+
return false;
|
279 |
+
|
280 |
+
$sum = array_sum(array_map('array_product', array_map(null, array_values($stats), array_keys($stats))));
|
281 |
+
$avg = $sum / array_sum( $stats );
|
282 |
+
|
283 |
+
return $this->cache->cache_status() > 0.1 && $avg > 2;
|
284 |
+
}
|
285 |
+
|
286 |
/*
|
287 |
* UPGRADE ROUTINES
|
288 |
*/
|
306 |
$this->upgrade_3_4_4b4();
|
307 |
if ( $last_version && version_compare('3.5.2b2', $last_version) > 0 )
|
308 |
$this->upgrade_3_5_2b2();
|
309 |
+
if ( $last_version && version_compare('3.6b7', $last_version) > 0 )
|
310 |
+
$this->upgrade_3_6b7();
|
311 |
|
312 |
$this->cache->upgrade($last_version);
|
313 |
// flush cache in 3.4.1b5 as 3.4 messed up calculations.
|
324 |
global $wpdb;
|
325 |
|
326 |
$yarpp_3_3_options = array(
|
327 |
+
'threshold' => 4,
|
328 |
+
'limit' => 4,
|
329 |
'template_file' => '', // new in 2.2
|
330 |
'excerpt_length' => 10,
|
331 |
'recent_number' => 12,
|
334 |
'after_title' => '</li>',
|
335 |
'before_post' => ' <small>',
|
336 |
'after_post' => '</small>',
|
337 |
+
'before_related' => '<h3>'.__('Related posts:','yarpp').'</h3><ol>',
|
338 |
'after_related' => '</ol>',
|
339 |
'no_results' => '<p>'.__('No related posts.','yarpp').'</p>',
|
340 |
'order' => 'score DESC',
|
345 |
'rss_after_title' => '</li>',
|
346 |
'rss_before_post' => ' <small>',
|
347 |
'rss_after_post' => '</small>',
|
348 |
+
'rss_before_related' => '<h3>'.__('Related posts:','yarpp').'</h3><ol>',
|
349 |
'rss_after_related' => '</ol>',
|
350 |
'rss_no_results' => '<p>'.__('No related posts.','yarpp').'</p>',
|
351 |
'rss_order' => 'score DESC',
|
519 |
yarpp_set_option(array('weight' => $weight));
|
520 |
}
|
521 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
|
523 |
+
function upgrade_3_6b7() {
|
524 |
+
// migrate auto_display setting to auto_display_post_types
|
525 |
+
$options = $this->get_option();
|
526 |
+
$options['auto_display_post_types'] = $options['auto_display'] ?
|
527 |
+
array( 'post' ) : array();
|
528 |
+
unset( $options['auto_display'] );
|
529 |
+
update_option( 'yarpp', $options );
|
530 |
}
|
531 |
|
532 |
private $post_types = null;
|
582 |
'threshold', 'limit', 'excerpt_length', 'recent', 'rss_limit',
|
583 |
'rss_excerpt_length', 'past_only', 'show_excerpt', 'rss_show_excerpt',
|
584 |
'template', 'rss_template', 'show_pass_post', 'cross_relate',
|
585 |
+
'rss_display', 'rss_excerpt_display', 'promote_yarpp', 'rss_promote_yarpp',
|
586 |
+
'myisam_override', 'weight', 'require_tax', 'auto_display_archive'
|
587 |
));
|
588 |
$check_changed = array(
|
589 |
'before_title', 'after_title', 'before_post', 'after_post',
|
590 |
+
'after_related', 'no_results', 'order', 'rss_before_title',
|
591 |
+
'rss_after_title', 'rss_before_post', 'rss_after_post', 'rss_after_related',
|
592 |
+
'rss_no_results', 'rss_order', 'exclude', 'thumbnails_heading',
|
593 |
+
'thumbnails_default', 'rss_thumbnails_heading', 'rss_thumbnails_default', 'display_code'
|
|
|
594 |
);
|
595 |
|
596 |
$data = array(
|
607 |
'myisam_posts' => $this->diagnostic_myisam_posts(),
|
608 |
'fulltext_indices' => $this->diagnostic_fulltext_indices(),
|
609 |
'hidden_metaboxes' => $this->diagnostic_hidden_metaboxes(),
|
610 |
+
'post_thumbnails' => $this->diagnostic_post_thumbnails(),
|
611 |
+
'happy' => $this->diagnostic_happy()
|
612 |
),
|
613 |
'stats' => array(
|
614 |
'counts' => array(),
|
626 |
'plugins' => array(
|
627 |
'active' => implode( '|', get_option( 'active_plugins', array() ) ),
|
628 |
'sitewide' => implode( '|', get_site_option( 'active_sitewide_plugins', array() ) )
|
629 |
+
),
|
630 |
+
'pools' => $settings['pools']
|
631 |
);
|
632 |
+
$data['yarpp']['settings']['auto_display_post_types'] = implode( '|', $settings['auto_display_post_types'] );
|
633 |
|
634 |
$changed = array();
|
635 |
foreach ( $check_changed as $key ) {
|
636 |
if ( $yarpp->default_options[$key] != $settings[$key] )
|
637 |
$changed[] = $key;
|
638 |
}
|
639 |
+
foreach ( array( 'before_related', 'rss_before_related' ) as $key ) {
|
640 |
+
if ( $settings[$key] != '<p>'.__('Related posts:','yarpp').'</p><ol>' &&
|
641 |
+
$settings[$key] != $yarpp->default_options[$key] )
|
642 |
+
$changed[] = $key;
|
643 |
+
}
|
644 |
$data['yarpp']['changed_settings'] = implode( '|', $changed );
|
645 |
|
646 |
if ( method_exists( $yarpp->cache, 'cache_status' ) )
|
750 |
}
|
751 |
$this->prep_query( $current_query->is_feed );
|
752 |
$related_query = $wp_query; // backwards compatibility
|
753 |
+
$related_count = $related_query->post_count;
|
754 |
|
755 |
// @todo: add these classes after the fact and include information about whether any results were given
|
756 |
$output = "<div class='";
|
758 |
$output .= "yarpp-related";
|
759 |
else
|
760 |
$output .= "yarpp-related-{$domain}";
|
761 |
+
if ( 1 > $related_count )
|
762 |
+
$output .= " yarpp-related-none";
|
763 |
$output .= "'>\n";
|
764 |
+
|
765 |
if ( 'metabox' == $domain ) {
|
766 |
include(YARPP_DIR . '/template-metabox.php');
|
767 |
} elseif ( !!$template && 'thumbnails' == $template ) {
|
790 |
wp_reset_postdata();
|
791 |
$pagenow = $current_pagenow; unset($current_pagenow);
|
792 |
|
793 |
+
if ( $related_count > 0 && $promote_yarpp && $domain != 'metabox' )
|
794 |
$output .= "<p>".sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'), 'http://yarpp.org')."</p>\n";
|
795 |
|
796 |
if ( $optin )
|
797 |
+
$output .= "<img src='http://yarpp.org/pixels/" . md5(get_bloginfo('url')) . "'/>\n";
|
798 |
|
799 |
$output .= "</div>\n";
|
800 |
|
1004 |
*/
|
1005 |
|
1006 |
function the_content($content) {
|
1007 |
+
// this filter doesn't handle feeds
|
1008 |
+
if ( is_feed() )
|
1009 |
+
return $content;
|
1010 |
+
|
1011 |
+
$auto_display_post_types = $this->get_option( 'auto_display_post_types' );
|
1012 |
+
|
1013 |
+
// if it's not an auto-display post type, return
|
1014 |
+
if ( !in_array( get_post_type(), $auto_display_post_types ) )
|
1015 |
+
return $content;
|
1016 |
+
|
1017 |
+
if ( !is_singular() && !(
|
1018 |
+
$this->get_option('auto_display_archive') &&
|
1019 |
+
( is_archive() || is_home() )
|
1020 |
+
) )
|
1021 |
+
return $content;
|
1022 |
|
1023 |
if ( $this->get_option('cross_relate') )
|
1024 |
+
$post_types = $this->get_post_types();
|
|
|
|
|
1025 |
else
|
1026 |
+
$post_types = array( get_post_type() );
|
1027 |
+
|
1028 |
+
$post_types = apply_filters( 'yarpp_map_post_types', $post_types );
|
1029 |
|
1030 |
+
return $content . $this->display_related(null, array(
|
1031 |
+
'post_type' => $post_types,
|
1032 |
+
'domain' => 'website'
|
1033 |
+
), false);
|
1034 |
}
|
1035 |
|
1036 |
function the_content_feed($content) {
|
1081 |
return $result;
|
1082 |
}
|
1083 |
|
1084 |
+
// @since 4: optional data collection (default off)
|
1085 |
function optin_ping() {
|
1086 |
if ( get_transient( 'yarpp_optin' ) )
|
1087 |
return true;
|
js/options.js
CHANGED
@@ -17,12 +17,8 @@ jQuery(function($) {
|
|
17 |
|
18 |
function excerpt() {
|
19 |
var metabox = $(this).closest('#yarpp_display_web, #yarpp_display_rss');
|
20 |
-
|
21 |
-
|
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 |
|
@@ -30,7 +26,9 @@ jQuery(function($) {
|
|
30 |
function display() {
|
31 |
if ( !$('#yarpp_display_web .inside').is(':visible') )
|
32 |
return;
|
33 |
-
|
|
|
|
|
34 |
loaded_demo_web = true;
|
35 |
var demo_web = $('#display_demo_web');
|
36 |
$.ajax({type:'POST',
|
@@ -52,9 +50,10 @@ jQuery(function($) {
|
|
52 |
function rss_display() {
|
53 |
if ( !$('#yarpp_display_rss .inside').is(':visible') )
|
54 |
return;
|
55 |
-
if ($('#yarpp-rss_display').
|
56 |
$('.rss_displayed').show();
|
57 |
-
|
|
|
58 |
loaded_demo_rss = true;
|
59 |
var demo_rss = $('#display_demo_rss');
|
60 |
$.ajax({type:'POST',
|
@@ -138,10 +137,14 @@ jQuery(function($) {
|
|
138 |
$('#yarpp_pool .handlediv, #yarpp_pool-hide').click(load_disallows);
|
139 |
load_disallows();
|
140 |
|
141 |
-
|
142 |
-
$('#tab-link-
|
143 |
$('#contextual-help-link').click();
|
144 |
-
}
|
|
|
|
|
|
|
|
|
145 |
|
146 |
$('.yarpp_help[data-help]').hover(function() {
|
147 |
var that = $(this),
|
@@ -168,8 +171,8 @@ jQuery(function($) {
|
|
168 |
options = {
|
169 |
content: help,
|
170 |
position: {
|
171 |
-
edge: '
|
172 |
-
align: 'center',
|
173 |
of: that
|
174 |
},
|
175 |
document: {body: that}
|
@@ -237,4 +240,35 @@ jQuery(function($) {
|
|
237 |
}
|
238 |
$('#yarpp-optin-learnmore, a[aria-controls=tab-panel-optin]').bind('click focus', display_optin_data);
|
239 |
display_optin_data();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
});
|
17 |
|
18 |
function excerpt() {
|
19 |
var metabox = $(this).closest('#yarpp_display_web, #yarpp_display_rss');
|
20 |
+
metabox.find('.excerpted').toggle( !!(metabox.find('.use_template').val() == 'builtin' &&
|
21 |
+
metabox.find('.show_excerpt input').attr('checked')) );
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
$('.show_excerpt, .use_template, #yarpp-rss_display').click(excerpt);
|
24 |
|
26 |
function display() {
|
27 |
if ( !$('#yarpp_display_web .inside').is(':visible') )
|
28 |
return;
|
29 |
+
|
30 |
+
$( '.yarpp_code_display' ).toggle( $('#yarpp_display_code').is(':checked') );
|
31 |
+
if ( $('#yarpp_display_web .yarpp_code_display').is(':visible') && !loaded_demo_web ) {
|
32 |
loaded_demo_web = true;
|
33 |
var demo_web = $('#display_demo_web');
|
34 |
$.ajax({type:'POST',
|
50 |
function rss_display() {
|
51 |
if ( !$('#yarpp_display_rss .inside').is(':visible') )
|
52 |
return;
|
53 |
+
if ( $('#yarpp-rss_display').is(':checked') ) {
|
54 |
$('.rss_displayed').show();
|
55 |
+
$( '.yarpp_code_display' ).toggle( $('#yarpp_display_code').is(':checked') );
|
56 |
+
if ( $('#yarpp_display_rss .yarpp_code_display').is(':visible') && !loaded_demo_rss ) {
|
57 |
loaded_demo_rss = true;
|
58 |
var demo_rss = $('#display_demo_rss');
|
59 |
$.ajax({type:'POST',
|
137 |
$('#yarpp_pool .handlediv, #yarpp_pool-hide').click(load_disallows);
|
138 |
load_disallows();
|
139 |
|
140 |
+
function show_help( section ) {
|
141 |
+
$('#tab-link-' + section + ' a').click();
|
142 |
$('#contextual-help-link').click();
|
143 |
+
}
|
144 |
+
$('#yarpp-optin-learnmore').click(function() { show_help('optin'); });
|
145 |
+
$('#yarpp-help-cpt').click(function() { show_help('dev'); });
|
146 |
+
if ( location.hash == '#help-optin' )
|
147 |
+
setTimeout( function() { show_help('optin'); } );
|
148 |
|
149 |
$('.yarpp_help[data-help]').hover(function() {
|
150 |
var that = $(this),
|
171 |
options = {
|
172 |
content: help,
|
173 |
position: {
|
174 |
+
edge: 'bottom',
|
175 |
+
// align: 'center',
|
176 |
of: that
|
177 |
},
|
178 |
document: {body: that}
|
240 |
}
|
241 |
$('#yarpp-optin-learnmore, a[aria-controls=tab-panel-optin]').bind('click focus', display_optin_data);
|
242 |
display_optin_data();
|
243 |
+
|
244 |
+
function sync_no_results() {
|
245 |
+
var value = $(this).find('input').attr('value');
|
246 |
+
if ( $(this).hasClass('sync_no_results') )
|
247 |
+
$('.sync_no_results input').attr('value', value);
|
248 |
+
if ( $(this).hasClass('sync_rss_no_results') )
|
249 |
+
$('.sync_rss_no_results input').attr('value', value);
|
250 |
+
}
|
251 |
+
$('.sync_no_results, .sync_rss_no_results').change(sync_no_results);
|
252 |
+
|
253 |
+
$('#yarpp_display_code').click(function() {
|
254 |
+
var args = {
|
255 |
+
action: 'yarpp_set_display_code',
|
256 |
+
'_ajax_nonce': $('#yarpp_set_display_code-nonce').val()
|
257 |
+
};
|
258 |
+
if ( $(this).is(':checked') )
|
259 |
+
args.checked = true;
|
260 |
+
$.ajax({type:'POST', url: ajaxurl, data: args});
|
261 |
+
display();
|
262 |
+
rss_display();
|
263 |
+
});
|
264 |
+
|
265 |
+
function auto_display_archive() {
|
266 |
+
var available = $('.yarpp_form_post_types').is(':has(input[type=checkbox]:checked)');
|
267 |
+
$('#yarpp-auto_display_archive')
|
268 |
+
.attr('disabled', !available);
|
269 |
+
if ( !available )
|
270 |
+
$('#yarpp-auto_display_archive').attr('checked', false);
|
271 |
+
}
|
272 |
+
$('.yarpp_form_post_types input[type=checkbox]').change(auto_display_archive);
|
273 |
+
auto_display_archive();
|
274 |
});
|
options-meta-boxes.php
CHANGED
@@ -4,19 +4,19 @@ class YARPP_Meta_Box {
|
|
4 |
protected $template_text = '';
|
5 |
|
6 |
function __construct() {
|
7 |
-
$this->template_text = __("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');
|
8 |
}
|
9 |
|
10 |
-
function checkbox($option, $desc, $class = '') {
|
11 |
echo "<div class='yarpp_form_row yarpp_form_checkbox $class'><div scope='row'>";
|
12 |
echo "<input type='checkbox' name='$option' id='yarpp-$option' value='true'";
|
13 |
-
checked(yarpp_get_option($option) == 1);
|
14 |
echo " /> <label for='yarpp-$option'>$desc</label></div></div>";
|
15 |
}
|
16 |
|
17 |
private function offer_copy_templates() {
|
18 |
global $yarpp;
|
19 |
-
return ( !count($yarpp->admin->get_templates()) && $yarpp->admin->can_copy_templates() );
|
20 |
}
|
21 |
|
22 |
function template_checkbox( $rss = false, $class = '' ) {
|
@@ -27,12 +27,12 @@ class YARPP_Meta_Box {
|
|
27 |
$choice = false === $chosen_template ? 'builtin' :
|
28 |
( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
|
29 |
|
30 |
-
echo "<div class='yarpp_form_row $class'>";
|
31 |
|
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 )
|
@@ -42,21 +42,21 @@ class YARPP_Meta_Box {
|
|
42 |
echo "'";
|
43 |
if ( !$yarpp->diagnostic_post_thumbnails() )
|
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";
|
48 |
if ( 'custom' == $choice )
|
49 |
echo ' active';
|
50 |
-
if ( !count($yarpp->admin->get_templates()) )
|
51 |
echo ' disabled';
|
52 |
echo "'";
|
53 |
-
if ( !count($yarpp->admin->get_templates()) ) {
|
54 |
-
$help = __('This option is disabled because no YARPP templates were found in your theme.', 'yarpp');
|
55 |
if ( $this->offer_copy_templates() )
|
56 |
-
$help .= ' ' . __("Would you like to copy some sample templates bundled with YARPP into your theme?", 'yarpp') . "<input type='button' class='button button-small yarpp_copy_templates_button' value='" . esc_attr(__('Copy Templates', 'yarpp')) . "'/>";
|
57 |
echo " data-help='" . esc_attr( $help ) . "'";
|
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 |
|
@@ -66,97 +66,97 @@ class YARPP_Meta_Box {
|
|
66 |
function template_file( $rss = false, $class = '' ) {
|
67 |
global $yarpp;
|
68 |
$pre = $rss ? 'rss_' : '';
|
69 |
-
echo "<div class='yarpp_form_row $class'><div class='yarpp_form_label'>";
|
70 |
-
_e("Template file:",'yarpp');
|
71 |
echo "</div><div><select name='{$pre}template_file' id='{$pre}template_file'>";
|
72 |
-
$chosen_template = yarpp_get_option("{$pre}template");
|
73 |
-
foreach ($yarpp->admin->get_templates() as $template) {
|
74 |
-
echo "<option value='" . esc_attr($template['basename']) . "'" . selected($template['basename'], $chosen_template, false);
|
75 |
foreach ( $template as $key => $value )
|
76 |
-
echo " data-{$key}='" . esc_attr($value) . "'";
|
77 |
-
echo '>' . esc_html($template['name']) . '</option>';
|
78 |
}
|
79 |
-
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>";
|
80 |
}
|
81 |
-
function textbox($option, $desc, $size=2, $class='', $note = '') {
|
82 |
-
$value = esc_attr(yarpp_get_option($option));
|
83 |
echo "<div class='yarpp_form_row yarpp_form_textbox $class'><div class='yarpp_form_label'>";
|
84 |
echo "$desc</div>
|
85 |
<div><input name='$option' type='text' id='$option' value='$value' size='$size' />";
|
86 |
-
if ( !empty($note) )
|
87 |
echo " <em><small>{$note}</small></em>";
|
88 |
echo "</div></div>";
|
89 |
}
|
90 |
-
function beforeafter($options, $desc, $size=10, $class='', $note = '') {
|
91 |
echo "<div class='yarpp_form_row yarpp_form_textbox $class'><div class='yarpp_form_label'>$desc</div><div>";
|
92 |
-
$value = esc_attr(yarpp_get_option($options[0]));
|
93 |
echo "<input name='{$options[0]}' type='text' id='{$options[0]}' value='$value' size='$size' /> <span class='yarpp_divider'>/</span> ";
|
94 |
-
$value = esc_attr(yarpp_get_option($options[1]));
|
95 |
echo "<input name='{$options[1]}' type='text' id='{$options[1]}' value='$value' size='$size' />";
|
96 |
-
if ( !empty($note) )
|
97 |
echo " <em><small>{$note}</small></em>";
|
98 |
echo "</div></div>";
|
99 |
}
|
100 |
|
101 |
-
function tax_weight($taxonomy) {
|
102 |
-
$weight = (int) yarpp_get_option("weight[tax][{$taxonomy->name}]");
|
103 |
-
$require = (int) yarpp_get_option("require_tax[{$taxonomy->name}]");
|
104 |
echo "<div class='yarpp_form_row yarpp_form_select'><div class='yarpp_form_label'>{$taxonomy->labels->name}:</div><div><select name='weight[tax][{$taxonomy->name}]'>";
|
105 |
-
echo "<option value='no'". ((!$weight && !$require) ? ' selected="selected"': '' )." > " . __("do not consider",'yarpp') . "</option>";
|
106 |
-
echo "<option value='consider'". (($weight == 1 && !$require) ? ' selected="selected"': '' )." >" . __("consider",'yarpp') . "</option>";
|
107 |
-
echo "<option value='consider_extra'". (($weight > 1 && !$require) ? ' selected="selected"': '' )." >" . __("consider with extra weight",'yarpp') . "</option>";
|
108 |
-
echo "<option value='require_one'". (($require == 1) ? ' selected="selected"': '' )." >" . sprintf(__("require at least one %s in common",'yarpp')
|
109 |
-
echo "<option value='require_more'". (($require == 2) ? ' selected="selected"': '' )." >" . sprintf(__("require more than one %s in common",'yarpp')
|
110 |
echo "</select></div></div>";
|
111 |
}
|
112 |
|
113 |
-
function weight($option, $desc) {
|
114 |
global $yarpp;
|
115 |
|
116 |
-
$weight = (int) yarpp_get_option("weight[$option]");
|
117 |
|
118 |
// both require MyISAM fulltext indexing:
|
119 |
$myisam = !$yarpp->myisam ? ' readonly="readonly" disabled="disabled"' : '';
|
120 |
|
121 |
echo "<div class='yarpp_form_row yarpp_form_select'><div class='yarpp_form_label'>$desc</div><div>";
|
122 |
echo "<select name='weight[$option]'>";
|
123 |
-
echo "<option $myisam value='no'". (!$weight ? ' selected="selected"': '' )." >".__("do not consider",'yarpp')."</option>";
|
124 |
-
echo "<option $myisam value='consider'". (($weight == 1) ? ' selected="selected"': '' )." > ".__("consider",'yarpp')."</option>";
|
125 |
-
echo "<option $myisam value='consider_extra'". (($weight > 1) ? ' selected="selected"': '' )." > ".__("consider with extra weight",'yarpp')."</option>";
|
126 |
echo "</select></div></div>";
|
127 |
}
|
128 |
|
129 |
function displayorder( $option, $class = '' ) {
|
130 |
echo "<div class='yarpp_form_row yarpp_form_select $class'><div class='yarpp_form_label'>";
|
131 |
-
_e("Order results:",'yarpp');
|
132 |
echo "</div><div><select name='$option' id='<?php echo $option; ?>'>";
|
133 |
-
$order = yarpp_get_option($option);
|
134 |
?>
|
135 |
-
<option value="score DESC" <?php echo ($order == 'score DESC'?' selected="selected"':'')?>><?php _e("score (high relevance to low)",'yarpp')
|
136 |
-
<option value="score ASC" <?php echo ($order == 'score ASC'?' selected="selected"':'')?>><?php _e("score (low relevance to high)",'yarpp')
|
137 |
-
<option value="post_date DESC" <?php echo ($order == 'post_date DESC'?' selected="selected"':'')?>><?php _e("date (new to old)",'yarpp')
|
138 |
-
<option value="post_date ASC" <?php echo ($order == 'post_date ASC'?' selected="selected"':'')?>><?php _e("date (old to new)",'yarpp')
|
139 |
-
<option value="post_title ASC" <?php echo ($order == 'post_title ASC'?' selected="selected"':'')?>><?php _e("title (alphabetical)",'yarpp')
|
140 |
-
<option value="post_title DESC" <?php echo ($order == 'post_title DESC'?' selected="selected"':'')?>><?php _e("title (reverse alphabetical)",'yarpp')
|
141 |
<?php
|
142 |
echo "</select></div></div>";
|
143 |
}
|
144 |
}
|
145 |
|
146 |
class YARPP_Meta_Box_Pool extends YARPP_Meta_Box {
|
147 |
-
function exclude($taxonomy, $string) {
|
148 |
global $yarpp;
|
149 |
|
150 |
echo "<div class='yarpp_form_row yarpp_form_exclude'><div class='yarpp_form_label'>";
|
151 |
echo $string;
|
152 |
echo "</div><div class='yarpp_scroll_wrapper'><div class='exclude_terms' id='exclude_{$taxonomy}'>";
|
153 |
|
154 |
-
$exclude_tt_ids = wp_parse_id_list(yarpp_get_option('exclude'));
|
155 |
$exclude_term_ids = $yarpp->admin->get_term_ids_from_tt_ids( $taxonomy, $exclude_tt_ids );
|
156 |
-
if ( count($exclude_term_ids) ) {
|
157 |
-
$terms = get_terms($taxonomy, array('include' => $exclude_term_ids));
|
158 |
-
foreach ($terms as $term) {
|
159 |
-
echo "<input type='checkbox' name='exclude[{$term->term_taxonomy_id}]' id='exclude_{$term->term_taxonomy_id}' value='true' checked='checked' /> <label for='exclude_{$term->term_taxonomy_id}'>" . esc_html($term->name) . "</label> ";
|
160 |
}
|
161 |
}
|
162 |
|
@@ -167,172 +167,217 @@ class YARPP_Meta_Box_Pool extends YARPP_Meta_Box {
|
|
167 |
global $yarpp;
|
168 |
|
169 |
echo "<p>";
|
170 |
-
_e('"The Pool" refers to the pool of posts and pages that are candidates for display as related to the current entry.','yarpp');
|
171 |
echo "</p>\n";
|
172 |
?>
|
173 |
-
<div class='yarpp_form_row'><div class='yarpp_form_label'><?php _e('Post types considered:', 'yarpp'); ?></div><div><?php echo implode(', ', $yarpp->get_post_types( 'label' )); ?> <a href='
|
174 |
|
175 |
<?php
|
176 |
-
foreach ($yarpp->get_taxonomies() as $taxonomy) {
|
177 |
-
$this->exclude($taxonomy->name, sprintf(__('Disallow by %s:','yarpp'), $taxonomy->labels->singular_name));
|
178 |
}
|
179 |
-
$this->checkbox('show_pass_post',__("Show password protected posts?",'yarpp'));
|
180 |
|
181 |
-
$recent = yarpp_get_option('recent');
|
182 |
if ( !!$recent ) {
|
183 |
-
list($recent_number, $recent_units) = explode(' ', $recent);
|
184 |
} else {
|
185 |
$recent_number = 12;
|
186 |
$recent_units = 'month';
|
187 |
}
|
188 |
-
$recent_number = "<input name=\"recent_number\" type=\"text\" id=\"recent_number\" value=\"".esc_attr($recent_number)."\" size=\"2\" />";
|
189 |
$recent_units = "<select name=\"recent_units\" id=\"recent_units\">
|
190 |
-
<option value='day'". (('day'==$recent_units)?" selected='selected'":'').">".__('day(s)','yarpp')."</option>
|
191 |
-
<option value='week'". (('week'==$recent_units)?" selected='selected'":'').">".__('week(s)','yarpp')."</option>
|
192 |
-
<option value='month'". (('month'==$recent_units)?" selected='selected'":'').">".__('month(s)','yarpp')."</option>
|
193 |
</select>";
|
194 |
|
195 |
echo "<div class='yarpp_form_row yarpp_form_checkbox'><div><input type='checkbox' name='recent_only' value='true'";
|
196 |
-
checked(!!$recent);
|
197 |
echo " /> ";
|
198 |
-
echo str_replace('NUMBER'
|
199 |
echo "</div></div>";
|
200 |
|
201 |
}
|
202 |
}
|
203 |
|
204 |
-
add_meta_box('yarpp_pool', __('"The Pool"','yarpp'), array(new YARPP_Meta_Box_Pool, 'display'), 'settings_page_yarpp', 'normal', 'core');
|
205 |
|
206 |
class YARPP_Meta_Box_Relatedness extends YARPP_Meta_Box {
|
207 |
function display() {
|
208 |
global $yarpp;
|
209 |
?>
|
210 |
-
<p><?php _e('YARPP limits the related posts list by (1) a maximum number and (2) a <em>match threshold</em>.','yarpp')
|
211 |
|
212 |
<?php
|
213 |
-
$this->textbox( 'threshold', __('Match threshold:','yarpp') );
|
214 |
-
$this->weight( 'title', __("Titles: ",'yarpp') );
|
215 |
-
$this->weight( 'body', __("Bodies: ",'yarpp') );
|
216 |
|
217 |
-
foreach ($yarpp->get_taxonomies() as $taxonomy) {
|
218 |
-
$this->tax_weight($taxonomy);
|
219 |
}
|
220 |
|
221 |
-
$this->checkbox('cross_relate',__("Display results from all post types",'yarpp')." <span class='yarpp_help' data-help='" . esc_attr(__("When \"display results from all post types\" is off, only posts will be displayed as related to a post, only pages will be displayed as related to a page, etc.", 'yarpp')) . "'> </span>");
|
222 |
-
$this->checkbox('past_only',__("Show only previous posts?",'yarpp'));
|
223 |
}
|
224 |
}
|
225 |
|
226 |
-
add_meta_box('yarpp_relatedness', __('"Relatedness" options','yarpp'), array(new YARPP_Meta_Box_Relatedness, 'display'), 'settings_page_yarpp', 'normal', 'core');
|
227 |
|
228 |
class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
|
229 |
function display() {
|
230 |
global $yarpp;
|
231 |
|
232 |
echo "<div style='overflow:auto'>";
|
233 |
-
echo '<div class="yarpp_code_display"
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
-
$this->textbox('limit',__('Maximum number of related posts:','yarpp'));
|
237 |
$this->template_checkbox( false );
|
238 |
echo "</div>";
|
239 |
|
240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
247 |
-
|
248 |
-
|
|
|
|
|
|
|
249 |
echo "</div>";
|
250 |
|
251 |
-
echo "<div class='postbox yarpp_subbox template_options_builtin'
|
252 |
-
|
253 |
-
|
|
|
|
|
|
|
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');
|
264 |
|
265 |
-
$this->checkbox('promote_yarpp',__("Help promote Yet Another Related Posts Plugin?",'yarpp')
|
266 |
-
." <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>");
|
267 |
}
|
268 |
}
|
269 |
|
270 |
-
add_meta_box('yarpp_display_web', __('Display options <small>for your website</small>','yarpp'), array(new YARPP_Meta_Box_Display_Web, 'display'), 'settings_page_yarpp', 'normal', 'core');
|
271 |
|
272 |
class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
|
273 |
function display() {
|
274 |
global $yarpp;
|
275 |
|
276 |
echo "<div style='overflow:auto'>";
|
277 |
-
echo '<div class="rss_displayed yarpp_code_display"
|
|
|
|
|
|
|
278 |
|
279 |
-
$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>",'');
|
280 |
-
$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');
|
281 |
|
282 |
-
$this->textbox('rss_limit',__('Maximum number of related posts:','yarpp'), 2, 'rss_displayed');
|
283 |
$this->template_checkbox( true, 'rss_displayed' );
|
284 |
echo "</div>";
|
285 |
|
286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
293 |
-
|
294 |
-
|
|
|
|
|
|
|
295 |
echo "</div>";
|
296 |
|
297 |
-
echo "<div class='postbox yarpp_subbox template_options_builtin rss_displayed'
|
298 |
-
|
299 |
-
|
|
|
|
|
|
|
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>";
|
308 |
|
309 |
-
$this->displayorder('rss_order', 'rss_displayed');
|
310 |
|
311 |
-
$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');
|
312 |
}
|
313 |
}
|
314 |
|
315 |
-
add_meta_box('yarpp_display_rss', __('Display options <small>for RSS</small>','yarpp'), array(new YARPP_Meta_Box_Display_Feed, 'display'), 'settings_page_yarpp', 'normal', 'core');
|
316 |
|
317 |
class YARPP_Meta_Box_Contact extends YARPP_Meta_Box {
|
318 |
function display() {
|
319 |
global $yarpp;
|
320 |
-
$pluginurl = plugin_dir_url(__FILE__);
|
321 |
?>
|
322 |
<ul class='yarpp_contacts'>
|
323 |
-
<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>
|
324 |
-
<li><a href="http://twitter.com/yarpp" target="_blank"><span class='icon icon-twitter'></span> <?php _e('YARPP on Twitter', 'yarpp'); ?></a></li>
|
325 |
-
<li><a href="http://yarpp.org" target="_blank"><span class='icon icon-plugin'></span> <?php _e('YARPP on the Web', 'yarpp'); ?></a></li>
|
326 |
-
<li><a href="http://wordpress.org/support/view/plugin-reviews/yet-another-related-posts-plugin" target="_blank"><span class='icon icon-star <?php if ($yarpp->
|
327 |
-
<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')
|
328 |
</ul>
|
329 |
<?php
|
330 |
}
|
331 |
|
332 |
function paypal_lang() {
|
333 |
-
if ( !defined('WPLANG') )
|
334 |
return 'en_US/';
|
335 |
-
switch ( substr(WPLANG, 0, 2) ) {
|
336 |
case 'fr':
|
337 |
return 'fr_FR/';
|
338 |
case 'de':
|
@@ -348,7 +393,7 @@ class YARPP_Meta_Box_Contact extends YARPP_Meta_Box {
|
|
348 |
case 'pl':
|
349 |
return 'pl_PL/';
|
350 |
case 'zh':
|
351 |
-
if (preg_match("/^zh_(HK|TW)/i",WPLANG))
|
352 |
return 'zh_HK/';
|
353 |
// actually zh_CN, but interpret as default zh:
|
354 |
return 'zh_XC/';
|
@@ -357,28 +402,35 @@ class YARPP_Meta_Box_Contact extends YARPP_Meta_Box {
|
|
357 |
}
|
358 |
}
|
359 |
}
|
360 |
-
|
361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
|
363 |
class YARPP_Meta_Box_Optin extends YARPP_Meta_Box {
|
364 |
function display() {
|
365 |
global $yarpp;
|
366 |
|
367 |
-
if ( $yarpp->get_option('optin') )
|
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 |
}
|
379 |
}
|
380 |
|
381 |
-
add_meta_box('yarpp_display_contact', __('Contact YARPP','yarpp'), array(new YARPP_Meta_Box_Contact, 'display'), 'settings_page_yarpp', 'side', 'core');
|
382 |
|
383 |
// since 3.3: hook for registering new YARPP meta boxes
|
384 |
do_action( 'add_meta_boxes_settings_page_yarpp' );
|
4 |
protected $template_text = '';
|
5 |
|
6 |
function __construct() {
|
7 |
+
$this->template_text = __( "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' );
|
8 |
}
|
9 |
|
10 |
+
function checkbox( $option, $desc, $class = '' ) {
|
11 |
echo "<div class='yarpp_form_row yarpp_form_checkbox $class'><div scope='row'>";
|
12 |
echo "<input type='checkbox' name='$option' id='yarpp-$option' value='true'";
|
13 |
+
checked( yarpp_get_option( $option ) == 1 );
|
14 |
echo " /> <label for='yarpp-$option'>$desc</label></div></div>";
|
15 |
}
|
16 |
|
17 |
private function offer_copy_templates() {
|
18 |
global $yarpp;
|
19 |
+
return ( !count( $yarpp->admin->get_templates() ) && $yarpp->admin->can_copy_templates() );
|
20 |
}
|
21 |
|
22 |
function template_checkbox( $rss = false, $class = '' ) {
|
27 |
$choice = false === $chosen_template ? 'builtin' :
|
28 |
( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
|
29 |
|
30 |
+
echo "<div class='yarpp_form_row yarpp_form_template_buttons $class'>";
|
31 |
|
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 )
|
42 |
echo "'";
|
43 |
if ( !$yarpp->diagnostic_post_thumbnails() )
|
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";
|
48 |
if ( 'custom' == $choice )
|
49 |
echo ' active';
|
50 |
+
if ( !count( $yarpp->admin->get_templates() ) )
|
51 |
echo ' disabled';
|
52 |
echo "'";
|
53 |
+
if ( !count( $yarpp->admin->get_templates() ) ) {
|
54 |
+
$help = __( 'This option is disabled because no YARPP templates were found in your theme.', 'yarpp' );
|
55 |
if ( $this->offer_copy_templates() )
|
56 |
+
$help .= ' ' . __( "Would you like to copy some sample templates bundled with YARPP into your theme?", 'yarpp' ) . "<input type='button' class='button button-small yarpp_copy_templates_button' value='" . esc_attr( __( 'Copy Templates', 'yarpp' ) ) . "'/>";
|
57 |
echo " data-help='" . esc_attr( $help ) . "'";
|
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 |
|
66 |
function template_file( $rss = false, $class = '' ) {
|
67 |
global $yarpp;
|
68 |
$pre = $rss ? 'rss_' : '';
|
69 |
+
echo "<div class='yarpp_form_row yarpp_form_template_file $class'><div class='yarpp_form_label'>";
|
70 |
+
_e( "Template file:", 'yarpp' );
|
71 |
echo "</div><div><select name='{$pre}template_file' id='{$pre}template_file'>";
|
72 |
+
$chosen_template = yarpp_get_option( "{$pre}template" );
|
73 |
+
foreach ( $yarpp->admin->get_templates() as $template ) {
|
74 |
+
echo "<option value='" . esc_attr( $template['basename'] ) . "'" . selected( $template['basename'], $chosen_template, false );
|
75 |
foreach ( $template as $key => $value )
|
76 |
+
echo " data-{$key}='" . esc_attr( $value ) . "'";
|
77 |
+
echo '>' . esc_html( $template['name'] ) . '</option>';
|
78 |
}
|
79 |
+
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>";
|
80 |
}
|
81 |
+
function textbox( $option, $desc, $size=2, $class='', $note = '' ) {
|
82 |
+
$value = esc_attr( yarpp_get_option( $option ) );
|
83 |
echo "<div class='yarpp_form_row yarpp_form_textbox $class'><div class='yarpp_form_label'>";
|
84 |
echo "$desc</div>
|
85 |
<div><input name='$option' type='text' id='$option' value='$value' size='$size' />";
|
86 |
+
if ( !empty( $note ) )
|
87 |
echo " <em><small>{$note}</small></em>";
|
88 |
echo "</div></div>";
|
89 |
}
|
90 |
+
function beforeafter( $options, $desc, $size=10, $class='', $note = '' ) {
|
91 |
echo "<div class='yarpp_form_row yarpp_form_textbox $class'><div class='yarpp_form_label'>$desc</div><div>";
|
92 |
+
$value = esc_attr( yarpp_get_option( $options[0] ) );
|
93 |
echo "<input name='{$options[0]}' type='text' id='{$options[0]}' value='$value' size='$size' /> <span class='yarpp_divider'>/</span> ";
|
94 |
+
$value = esc_attr( yarpp_get_option( $options[1] ) );
|
95 |
echo "<input name='{$options[1]}' type='text' id='{$options[1]}' value='$value' size='$size' />";
|
96 |
+
if ( !empty( $note ) )
|
97 |
echo " <em><small>{$note}</small></em>";
|
98 |
echo "</div></div>";
|
99 |
}
|
100 |
|
101 |
+
function tax_weight( $taxonomy ) {
|
102 |
+
$weight = (int) yarpp_get_option( "weight[tax][{$taxonomy->name}]" );
|
103 |
+
$require = (int) yarpp_get_option( "require_tax[{$taxonomy->name}]" );
|
104 |
echo "<div class='yarpp_form_row yarpp_form_select'><div class='yarpp_form_label'>{$taxonomy->labels->name}:</div><div><select name='weight[tax][{$taxonomy->name}]'>";
|
105 |
+
echo "<option value='no'". ( ( !$weight && !$require ) ? ' selected="selected"': '' )." > " . __( "do not consider", 'yarpp' ) . "</option>";
|
106 |
+
echo "<option value='consider'". ( ( $weight == 1 && !$require ) ? ' selected="selected"': '' )." >" . __( "consider", 'yarpp' ) . "</option>";
|
107 |
+
echo "<option value='consider_extra'". ( ( $weight > 1 && !$require ) ? ' selected="selected"': '' )." >" . __( "consider with extra weight", 'yarpp' ) . "</option>";
|
108 |
+
echo "<option value='require_one'". ( ( $require == 1 ) ? ' selected="selected"': '' )." >" . sprintf( __( "require at least one %s in common", 'yarpp' ), $taxonomy->labels->singular_name ) . "</option>";
|
109 |
+
echo "<option value='require_more'". ( ( $require == 2 ) ? ' selected="selected"': '' )." >" . sprintf( __( "require more than one %s in common", 'yarpp' ), $taxonomy->labels->singular_name ) . "</option>";
|
110 |
echo "</select></div></div>";
|
111 |
}
|
112 |
|
113 |
+
function weight( $option, $desc ) {
|
114 |
global $yarpp;
|
115 |
|
116 |
+
$weight = (int) yarpp_get_option( "weight[$option]" );
|
117 |
|
118 |
// both require MyISAM fulltext indexing:
|
119 |
$myisam = !$yarpp->myisam ? ' readonly="readonly" disabled="disabled"' : '';
|
120 |
|
121 |
echo "<div class='yarpp_form_row yarpp_form_select'><div class='yarpp_form_label'>$desc</div><div>";
|
122 |
echo "<select name='weight[$option]'>";
|
123 |
+
echo "<option $myisam value='no'". ( !$weight ? ' selected="selected"': '' )." >".__( "do not consider", 'yarpp' )."</option>";
|
124 |
+
echo "<option $myisam value='consider'". ( ( $weight == 1 ) ? ' selected="selected"': '' )." > ".__( "consider", 'yarpp' )."</option>";
|
125 |
+
echo "<option $myisam value='consider_extra'". ( ( $weight > 1 ) ? ' selected="selected"': '' )." > ".__( "consider with extra weight", 'yarpp' )."</option>";
|
126 |
echo "</select></div></div>";
|
127 |
}
|
128 |
|
129 |
function displayorder( $option, $class = '' ) {
|
130 |
echo "<div class='yarpp_form_row yarpp_form_select $class'><div class='yarpp_form_label'>";
|
131 |
+
_e( "Order results:", 'yarpp' );
|
132 |
echo "</div><div><select name='$option' id='<?php echo $option; ?>'>";
|
133 |
+
$order = yarpp_get_option( $option );
|
134 |
?>
|
135 |
+
<option value="score DESC" <?php echo ( $order == 'score DESC'?' selected="selected"':'' )?>><?php _e( "score (high relevance to low)", 'yarpp' ); ?></option>
|
136 |
+
<option value="score ASC" <?php echo ( $order == 'score ASC'?' selected="selected"':'' )?>><?php _e( "score (low relevance to high)", 'yarpp' ); ?></option>
|
137 |
+
<option value="post_date DESC" <?php echo ( $order == 'post_date DESC'?' selected="selected"':'' )?>><?php _e( "date (new to old)", 'yarpp' ); ?></option>
|
138 |
+
<option value="post_date ASC" <?php echo ( $order == 'post_date ASC'?' selected="selected"':'' )?>><?php _e( "date (old to new)", 'yarpp' ); ?></option>
|
139 |
+
<option value="post_title ASC" <?php echo ( $order == 'post_title ASC'?' selected="selected"':'' )?>><?php _e( "title (alphabetical)", 'yarpp' ); ?></option>
|
140 |
+
<option value="post_title DESC" <?php echo ( $order == 'post_title DESC'?' selected="selected"':'' )?>><?php _e( "title (reverse alphabetical)", 'yarpp' ); ?></option>
|
141 |
<?php
|
142 |
echo "</select></div></div>";
|
143 |
}
|
144 |
}
|
145 |
|
146 |
class YARPP_Meta_Box_Pool extends YARPP_Meta_Box {
|
147 |
+
function exclude( $taxonomy, $string ) {
|
148 |
global $yarpp;
|
149 |
|
150 |
echo "<div class='yarpp_form_row yarpp_form_exclude'><div class='yarpp_form_label'>";
|
151 |
echo $string;
|
152 |
echo "</div><div class='yarpp_scroll_wrapper'><div class='exclude_terms' id='exclude_{$taxonomy}'>";
|
153 |
|
154 |
+
$exclude_tt_ids = wp_parse_id_list( yarpp_get_option( 'exclude' ) );
|
155 |
$exclude_term_ids = $yarpp->admin->get_term_ids_from_tt_ids( $taxonomy, $exclude_tt_ids );
|
156 |
+
if ( count( $exclude_term_ids ) ) {
|
157 |
+
$terms = get_terms( $taxonomy, array( 'include' => $exclude_term_ids ) );
|
158 |
+
foreach ( $terms as $term ) {
|
159 |
+
echo "<input type='checkbox' name='exclude[{$term->term_taxonomy_id}]' id='exclude_{$term->term_taxonomy_id}' value='true' checked='checked' /> <label for='exclude_{$term->term_taxonomy_id}'>" . esc_html( $term->name ) . "</label> ";
|
160 |
}
|
161 |
}
|
162 |
|
167 |
global $yarpp;
|
168 |
|
169 |
echo "<p>";
|
170 |
+
_e( '"The Pool" refers to the pool of posts and pages that are candidates for display as related to the current entry.', 'yarpp' );
|
171 |
echo "</p>\n";
|
172 |
?>
|
173 |
+
<div class='yarpp_form_row'><div class='yarpp_form_label'><?php _e( 'Post types considered:', 'yarpp' ); ?></div><div><?php echo implode( ', ', $yarpp->get_post_types( 'label' ) ); ?> <a href='#help-dev' id='yarpp-help-cpt' class='yarpp_help'> </a></div></div>
|
174 |
|
175 |
<?php
|
176 |
+
foreach ( $yarpp->get_taxonomies() as $taxonomy ) {
|
177 |
+
$this->exclude( $taxonomy->name, sprintf( __( 'Disallow by %s:', 'yarpp' ), $taxonomy->labels->singular_name ) );
|
178 |
}
|
179 |
+
$this->checkbox( 'show_pass_post', __( "Show password protected posts?", 'yarpp' ) );
|
180 |
|
181 |
+
$recent = yarpp_get_option( 'recent' );
|
182 |
if ( !!$recent ) {
|
183 |
+
list( $recent_number, $recent_units ) = explode( ' ', $recent );
|
184 |
} else {
|
185 |
$recent_number = 12;
|
186 |
$recent_units = 'month';
|
187 |
}
|
188 |
+
$recent_number = "<input name=\"recent_number\" type=\"text\" id=\"recent_number\" value=\"".esc_attr( $recent_number )."\" size=\"2\" />";
|
189 |
$recent_units = "<select name=\"recent_units\" id=\"recent_units\">
|
190 |
+
<option value='day'" . ( ( 'day'==$recent_units) ? " selected='selected'" : '' ) . ">" . __( 'day(s)', 'yarpp' )."</option>
|
191 |
+
<option value='week'" . ( ( 'week'==$recent_units ) ? " selected='selected'" : '' ) . ">" . __( 'week(s)', 'yarpp' )."</option>
|
192 |
+
<option value='month'" . ( ( 'month'==$recent_units ) ? " selected='selected'" : '' ) . ">" . __( 'month(s)', 'yarpp' ) . "</option>
|
193 |
</select>";
|
194 |
|
195 |
echo "<div class='yarpp_form_row yarpp_form_checkbox'><div><input type='checkbox' name='recent_only' value='true'";
|
196 |
+
checked( !!$recent );
|
197 |
echo " /> ";
|
198 |
+
echo str_replace( 'NUMBER', $recent_number, str_replace( 'UNITS', $recent_units, __( "Show only posts from the past NUMBER UNITS", 'yarpp' ) ) );
|
199 |
echo "</div></div>";
|
200 |
|
201 |
}
|
202 |
}
|
203 |
|
204 |
+
add_meta_box( 'yarpp_pool', __( '"The Pool"', 'yarpp' ), array( new YARPP_Meta_Box_Pool, 'display' ), 'settings_page_yarpp', 'normal', 'core' );
|
205 |
|
206 |
class YARPP_Meta_Box_Relatedness extends YARPP_Meta_Box {
|
207 |
function display() {
|
208 |
global $yarpp;
|
209 |
?>
|
210 |
+
<p><?php _e( 'YARPP limits the related posts list by (1) a maximum number and (2) a <em>match threshold</em>.', 'yarpp' ); ?> <span class='yarpp_help' data-help="<?php echo esc_attr( __( 'The higher the match threshold, the more restrictive, and you get less related posts overall. The default match threshold is 5. If you want to find an appropriate match threshhold, take a look at some post\'s related posts display and their scores. You can see what kinds of related posts are being picked up and with what kind of match scores, and determine an appropriate threshold for your site.', 'yarpp' ) ); ?>"> </span></p>
|
211 |
|
212 |
<?php
|
213 |
+
$this->textbox( 'threshold', __( 'Match threshold:', 'yarpp' ) );
|
214 |
+
$this->weight( 'title', __( "Titles: ", 'yarpp' ) );
|
215 |
+
$this->weight( 'body', __( "Bodies: ", 'yarpp' ) );
|
216 |
|
217 |
+
foreach ( $yarpp->get_taxonomies() as $taxonomy ) {
|
218 |
+
$this->tax_weight( $taxonomy );
|
219 |
}
|
220 |
|
221 |
+
$this->checkbox( 'cross_relate', __( "Display results from all post types", 'yarpp' )." <span class='yarpp_help' data-help='" . esc_attr( __( "When \"display results from all post types\" is off, only posts will be displayed as related to a post, only pages will be displayed as related to a page, etc.", 'yarpp' ) ) . "'> </span>" );
|
222 |
+
$this->checkbox( 'past_only', __( "Show only previous posts?", 'yarpp' ) );
|
223 |
}
|
224 |
}
|
225 |
|
226 |
+
add_meta_box( 'yarpp_relatedness', __( '"Relatedness" options', 'yarpp' ), array( new YARPP_Meta_Box_Relatedness, 'display' ), 'settings_page_yarpp', 'normal', 'core' );
|
227 |
|
228 |
class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
|
229 |
function display() {
|
230 |
global $yarpp;
|
231 |
|
232 |
echo "<div style='overflow:auto'>";
|
233 |
+
echo '<div class="yarpp_code_display"';
|
234 |
+
if ( !$yarpp->get_option('code_display') )
|
235 |
+
echo ' style="display: none;"';
|
236 |
+
echo '><strong>' . __( "Website display code example", 'yarpp' ) . '</strong><br /><small>' . __( "(Update options to reload.)", 'yarpp' ) . "</small><br/><div id='display_demo_web'></div></div>";
|
237 |
+
|
238 |
+
echo "<div class='yarpp_form_row yarpp_form_post_types'><div class='yarpp_form_label'>";
|
239 |
+
_e( "Automatically display:", 'yarpp' );
|
240 |
+
echo " <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>";
|
241 |
+
echo "</div><div>";
|
242 |
+
$post_types = yarpp_get_option( 'auto_display_post_types' );
|
243 |
+
foreach ( $yarpp->get_post_types( 'objects' ) as $post_type ) {
|
244 |
+
echo "<label for='yarpp_post_type_{$post_type->name}'><input id='yarpp_post_type_{$post_type->name}' name='auto_display_post_types[{$post_type->name}]' type='checkbox' ";
|
245 |
+
checked( in_array( $post_type->name, $post_types ) );
|
246 |
+
echo "/> {$post_type->labels->name}</label> ";
|
247 |
+
}
|
248 |
+
echo "</div></div>";
|
249 |
+
|
250 |
+
$this->checkbox( 'auto_display_archive', __( "Also display in archives", 'yarpp' ) );
|
251 |
|
252 |
+
$this->textbox( 'limit', __( 'Maximum number of related posts:', 'yarpp' ) );
|
253 |
$this->template_checkbox( false );
|
254 |
echo "</div>";
|
255 |
|
256 |
+
$chosen_template = yarpp_get_option( "template" );
|
257 |
+
$choice = false === $chosen_template ? 'builtin' :
|
258 |
+
( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
|
259 |
+
|
260 |
+
echo "<div class='postbox yarpp_subbox template_options_custom'";
|
261 |
+
if ( $choice != 'custom' )
|
262 |
+
echo ' style="display: none;"';
|
263 |
+
echo ">";
|
264 |
echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
|
265 |
$this->template_file( false );
|
266 |
echo "</div>";
|
267 |
|
268 |
+
echo "<div class='postbox yarpp_subbox template_options_thumbnails'";
|
269 |
+
if ( $choice != 'thumbnails' )
|
270 |
+
echo ' style="display: none;"';
|
271 |
+
echo ">";
|
272 |
+
$this->textbox( 'thumbnails_heading', __( 'Heading:', 'yarpp' ), 40 );
|
273 |
+
$this->textbox( 'thumbnails_default', __( 'Default image (URL):', 'yarpp' ), 40 );
|
274 |
+
$this->textbox( 'no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_no_results' );
|
275 |
echo "</div>";
|
276 |
|
277 |
+
echo "<div class='postbox yarpp_subbox template_options_builtin'";
|
278 |
+
if ( $choice != 'builtin' )
|
279 |
+
echo ' style="display: none;"';
|
280 |
+
echo ">";
|
281 |
+
$this->beforeafter( array( 'before_related', 'after_related' ), __( "Before / after related entries:", 'yarpp' ), 15, '', __( "For example:", 'yarpp' ) . ' <ol></ol>' . __( ' or ', 'yarpp' ) . '<div></div>' );
|
282 |
+
$this->beforeafter( array( 'before_title', 'after_title' ), __( "Before / after each related entry:", 'yarpp' ), 15, '', __( "For example:", 'yarpp' ) . ' <li></li>' . __( ' or ', 'yarpp' ) . '<dl></dl>' );
|
283 |
|
284 |
+
$this->checkbox( 'show_excerpt', __( "Show excerpt?", 'yarpp' ), 'show_excerpt' );
|
285 |
+
$this->textbox( 'excerpt_length', __( 'Excerpt length (No. of words):', 'yarpp' ), 10, 'excerpted' );
|
286 |
|
287 |
+
$this->beforeafter( array( 'before_post', 'after_post' ), __( "Before / after (excerpt):", 'yarpp' ), 10, 'excerpted', __( "For example:", 'yarpp' ) . ' <li></li>' . __( ' or ', 'yarpp' ) . '<dl></dl>' );
|
288 |
|
289 |
+
$this->textbox( 'no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_no_results' );
|
290 |
echo "</div>";
|
291 |
|
292 |
+
$this->displayorder( 'order' );
|
293 |
|
294 |
+
$this->checkbox( 'promote_yarpp', __( "Help promote Yet Another Related Posts Plugin?", 'yarpp' )
|
295 |
+
." <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>" );
|
296 |
}
|
297 |
}
|
298 |
|
299 |
+
add_meta_box( 'yarpp_display_web', __( 'Display options <small>for your website</small>', 'yarpp' ), array( new YARPP_Meta_Box_Display_Web, 'display' ), 'settings_page_yarpp', 'normal', 'core' );
|
300 |
|
301 |
class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
|
302 |
function display() {
|
303 |
global $yarpp;
|
304 |
|
305 |
echo "<div style='overflow:auto'>";
|
306 |
+
echo '<div class="rss_displayed yarpp_code_display"';
|
307 |
+
if ( !$yarpp->get_option('code_display') )
|
308 |
+
echo ' style="display: none;"';
|
309 |
+
echo '><b>' . __( "RSS display code example", 'yarpp' ) . '</b><br /><small>' . __( "(Update options to reload.)", 'yarpp' ) . "</small><br/><div id='display_demo_rss'></div></div>";
|
310 |
|
311 |
+
$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>", '' );
|
312 |
+
$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' );
|
313 |
|
314 |
+
$this->textbox( 'rss_limit', __( 'Maximum number of related posts:', 'yarpp' ), 2, 'rss_displayed' );
|
315 |
$this->template_checkbox( true, 'rss_displayed' );
|
316 |
echo "</div>";
|
317 |
|
318 |
+
$chosen_template = yarpp_get_option( "rss_template" );
|
319 |
+
$choice = false === $chosen_template ? 'builtin' :
|
320 |
+
( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
|
321 |
+
|
322 |
+
echo "<div class='postbox yarpp_subbox template_options_custom rss_displayed'";
|
323 |
+
if ( $choice != 'custom' )
|
324 |
+
echo ' style="display: none;"';
|
325 |
+
echo ">";
|
326 |
echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
|
327 |
$this->template_file( true );
|
328 |
echo "</div>";
|
329 |
|
330 |
+
echo "<div class='postbox yarpp_subbox template_options_thumbnails'";
|
331 |
+
if ( $choice != 'thumbnails' )
|
332 |
+
echo ' style="display: none;"';
|
333 |
+
echo ">";
|
334 |
+
$this->textbox( 'rss_thumbnails_heading', __( 'Heading:', 'yarpp' ), 40 );
|
335 |
+
$this->textbox( 'rss_thumbnails_default', __( 'Default image (URL):', 'yarpp' ), 40 );
|
336 |
+
$this->textbox( 'rss_no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_rss_no_results' );
|
337 |
echo "</div>";
|
338 |
|
339 |
+
echo "<div class='postbox yarpp_subbox template_options_builtin rss_displayed'";
|
340 |
+
if ( $choice != 'builtin' )
|
341 |
+
echo ' style="display: none;"';
|
342 |
+
echo ">";
|
343 |
+
$this->beforeafter( array( 'rss_before_related', 'rss_after_related' ), __( "Before / after related entries:", 'yarpp' ), 15, '', __( "For example:", 'yarpp' ) . ' <ol></ol>' . __( ' or ', 'yarpp' ) . '<div></div>' );
|
344 |
+
$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>' );
|
345 |
|
346 |
+
$this->checkbox( 'rss_show_excerpt', __( "Show excerpt?", 'yarpp' ), 'show_excerpt' );
|
347 |
+
$this->textbox( 'rss_excerpt_length', __( 'Excerpt length (No. of words):', 'yarpp' ), 10, 'excerpted' );
|
348 |
|
349 |
+
$this->beforeafter( array( 'rss_before_post', 'rss_after_post' ), __( "Before / after (excerpt):", 'yarpp' ), 10, 'excerpted', __( "For example:", 'yarpp' ) . ' <li></li>' . __( ' or ', 'yarpp' ) . '<dl></dl>' );
|
350 |
|
351 |
+
$this->textbox( 'rss_no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_rss_no_results' );
|
352 |
echo "</div>";
|
353 |
|
354 |
+
$this->displayorder( 'rss_order', 'rss_displayed' );
|
355 |
|
356 |
+
$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' );
|
357 |
}
|
358 |
}
|
359 |
|
360 |
+
add_meta_box( 'yarpp_display_rss', __( 'Display options <small>for RSS</small>', 'yarpp' ), array( new YARPP_Meta_Box_Display_Feed, 'display' ), 'settings_page_yarpp', 'normal', 'core' );
|
361 |
|
362 |
class YARPP_Meta_Box_Contact extends YARPP_Meta_Box {
|
363 |
function display() {
|
364 |
global $yarpp;
|
365 |
+
$pluginurl = plugin_dir_url( __FILE__ );
|
366 |
?>
|
367 |
<ul class='yarpp_contacts'>
|
368 |
+
<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>
|
369 |
+
<li><a href="http://twitter.com/yarpp" target="_blank"><span class='icon icon-twitter'></span> <?php _e( 'YARPP on Twitter', 'yarpp' ); ?></a></li>
|
370 |
+
<li><a href="http://yarpp.org" target="_blank"><span class='icon icon-plugin'></span> <?php _e( 'YARPP on the Web', 'yarpp' ); ?></a></li>
|
371 |
+
<li><a href="http://wordpress.org/support/view/plugin-reviews/yet-another-related-posts-plugin" target="_blank"><span class='icon icon-star <?php if ( $yarpp->diagnostic_happy() ) echo 'spin'; ?>'></span> <?php _e( 'Review YARPP on WordPress.org', 'yarpp' ); ?></a></li>
|
372 |
+
<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>
|
373 |
</ul>
|
374 |
<?php
|
375 |
}
|
376 |
|
377 |
function paypal_lang() {
|
378 |
+
if ( !defined( 'WPLANG' ) )
|
379 |
return 'en_US/';
|
380 |
+
switch ( substr( WPLANG, 0, 2 ) ) {
|
381 |
case 'fr':
|
382 |
return 'fr_FR/';
|
383 |
case 'de':
|
393 |
case 'pl':
|
394 |
return 'pl_PL/';
|
395 |
case 'zh':
|
396 |
+
if ( preg_match( "/^zh_(HK|TW)/i", WPLANG ) )
|
397 |
return 'zh_HK/';
|
398 |
// actually zh_CN, but interpret as default zh:
|
399 |
return 'zh_XC/';
|
402 |
}
|
403 |
}
|
404 |
}
|
405 |
+
add_meta_box( 'yarpp_display_optin', __( 'Help Improve YARPP', 'yarpp' ), array( new YARPP_Meta_Box_Optin, 'display' ), 'settings_page_yarpp', 'side', 'core' );
|
406 |
+
|
407 |
+
// longest filter name ever
|
408 |
+
add_filter( "postbox_classes_settings_page_yarpp_yarpp_display_optin", 'yarpp_make_optin_classy' );
|
409 |
+
function yarpp_make_optin_classy( $classes ) {
|
410 |
+
if ( !yarpp_get_option( 'optin' ) )
|
411 |
+
$classes[] = 'yarpp_attention';
|
412 |
+
return $classes;
|
413 |
+
}
|
414 |
|
415 |
class YARPP_Meta_Box_Optin extends YARPP_Meta_Box {
|
416 |
function display() {
|
417 |
global $yarpp;
|
418 |
|
419 |
+
if ( $yarpp->get_option( 'optin' ) )
|
420 |
$yarpp->optin_ping();
|
421 |
|
422 |
// TODO: fix this text and i18nize it
|
423 |
echo "<input type='checkbox' id='yarpp-optin' name='optin' value='true'";
|
424 |
+
checked( yarpp_get_option( 'optin' ) == 1 );
|
425 |
echo " /> ";
|
426 |
|
427 |
+
echo '<label for="yarpp-optin">' . __( 'Send settings and usage data back to YARPP', 'yarpp' ) . '</label>';
|
428 |
|
429 |
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>';
|
430 |
}
|
431 |
}
|
432 |
|
433 |
+
add_meta_box( 'yarpp_display_contact', __( 'Contact YARPP', 'yarpp' ), array( new YARPP_Meta_Box_Contact, 'display' ), 'settings_page_yarpp', 'side', 'core' );
|
434 |
|
435 |
// since 3.3: hook for registering new YARPP meta boxes
|
436 |
do_action( 'add_meta_boxes_settings_page_yarpp' );
|
options.css
CHANGED
@@ -15,6 +15,11 @@ ul.yarpp_contacts li a img {
|
|
15 |
vertical-align: bottom;
|
16 |
}
|
17 |
|
|
|
|
|
|
|
|
|
|
|
18 |
.icon {
|
19 |
width: 22px;
|
20 |
height: 22px;
|
@@ -106,8 +111,8 @@ a.yarpp_help:hover {
|
|
106 |
display: inline-block;
|
107 |
}
|
108 |
|
109 |
-
#yarpp_display_optin {
|
110 |
-
border
|
111 |
}
|
112 |
|
113 |
.yarpp_subbox {
|
@@ -116,29 +121,45 @@ a.yarpp_help:hover {
|
|
116 |
}
|
117 |
.yarpp_form_row {
|
118 |
overflow: visible;
|
|
|
119 |
}
|
120 |
.yarpp_form_row > div {
|
121 |
-
padding: 8px;
|
122 |
display: inline-block;
|
123 |
-
vertical-align: top;
|
124 |
*display: inline;
|
|
|
125 |
}
|
126 |
.yarpp_form_checkbox > div {
|
127 |
-
vertical-align: baseline;
|
128 |
}
|
129 |
.yarpp_form_select > div {
|
130 |
padding-top: 5px;
|
131 |
padding-bottom: 5px;
|
132 |
}
|
|
|
|
|
|
|
133 |
.yarpp_form_label {
|
134 |
width: 190px;
|
135 |
}
|
|
|
|
|
|
|
136 |
.yarpp_form_textbox > .yarpp_form_label {
|
137 |
-
padding-top: 13px;
|
138 |
}
|
139 |
.yarpp_form_select > .yarpp_form_label {
|
140 |
padding-top: 8px;
|
141 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
.yarpp_code_display {
|
144 |
border-left: 8px transparent solid;
|
@@ -180,10 +201,14 @@ a.yarpp_help:hover {
|
|
180 |
font-family: monospace;
|
181 |
}
|
182 |
|
|
|
|
|
|
|
183 |
.yarpp_template_button {
|
184 |
position: relative;
|
185 |
height: 60px;
|
186 |
width: 70px;
|
|
|
187 |
-webkit-border-radius: 3px;
|
188 |
border-radius: 7px;
|
189 |
border: 1px solid #aaa;
|
@@ -262,4 +287,14 @@ a.yarpp_help:hover {
|
|
262 |
#optin_data_frame {
|
263 |
overflow: scroll;
|
264 |
max-height: 300px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
}
|
15 |
vertical-align: bottom;
|
16 |
}
|
17 |
|
18 |
+
/* hide pointer dismiss buttons on this page */
|
19 |
+
.postbox .wp-pointer-buttons {
|
20 |
+
display: none;
|
21 |
+
}
|
22 |
+
|
23 |
.icon {
|
24 |
width: 22px;
|
25 |
height: 22px;
|
111 |
display: inline-block;
|
112 |
}
|
113 |
|
114 |
+
#yarpp_display_optin.yarpp_attention {
|
115 |
+
border: 2px solid #bbb;
|
116 |
}
|
117 |
|
118 |
.yarpp_subbox {
|
121 |
}
|
122 |
.yarpp_form_row {
|
123 |
overflow: visible;
|
124 |
+
padding: 8px;
|
125 |
}
|
126 |
.yarpp_form_row > div {
|
|
|
127 |
display: inline-block;
|
|
|
128 |
*display: inline;
|
129 |
+
vertical-align: baseline;
|
130 |
}
|
131 |
.yarpp_form_checkbox > div {
|
|
|
132 |
}
|
133 |
.yarpp_form_select > div {
|
134 |
padding-top: 5px;
|
135 |
padding-bottom: 5px;
|
136 |
}
|
137 |
+
.yarpp_form_select + .yarpp_form_select {
|
138 |
+
padding-top: 0px;
|
139 |
+
}
|
140 |
.yarpp_form_label {
|
141 |
width: 190px;
|
142 |
}
|
143 |
+
.yarpp_form_label + div {
|
144 |
+
padding-left: 16px;
|
145 |
+
}
|
146 |
.yarpp_form_textbox > .yarpp_form_label {
|
|
|
147 |
}
|
148 |
.yarpp_form_select > .yarpp_form_label {
|
149 |
padding-top: 8px;
|
150 |
}
|
151 |
+
.yarpp_form_post_types label {
|
152 |
+
padding-right: 15px;
|
153 |
+
line-height: 20px;
|
154 |
+
}
|
155 |
+
.yarpp_form_exclude label {
|
156 |
+
padding-right: 5px;
|
157 |
+
line-height: 15px;
|
158 |
+
}
|
159 |
+
.yarpp_form_template_file > .yarpp_form_label {
|
160 |
+
vertical-align: top;
|
161 |
+
padding-top: 5px;
|
162 |
+
}
|
163 |
|
164 |
.yarpp_code_display {
|
165 |
border-left: 8px transparent solid;
|
201 |
font-family: monospace;
|
202 |
}
|
203 |
|
204 |
+
.yarpp_form_template_buttons {
|
205 |
+
padding: 0px;
|
206 |
+
}
|
207 |
.yarpp_template_button {
|
208 |
position: relative;
|
209 |
height: 60px;
|
210 |
width: 70px;
|
211 |
+
padding: 8px;
|
212 |
-webkit-border-radius: 3px;
|
213 |
border-radius: 7px;
|
214 |
border: 1px solid #aaa;
|
287 |
#optin_data_frame {
|
288 |
overflow: scroll;
|
289 |
max-height: 300px;
|
290 |
+
}
|
291 |
+
|
292 |
+
#yarpp_extra_screen_settings {
|
293 |
+
border-top: 1px solid #e0e0e0;
|
294 |
+
}
|
295 |
+
|
296 |
+
.help-tab-content {
|
297 |
+
max-height: 500px;
|
298 |
+
width: 100%;
|
299 |
+
overflow: auto;
|
300 |
}
|
options.php
CHANGED
@@ -79,7 +79,6 @@ if ( $yarpp->myisam && !$yarpp->enabled() ) {
|
|
79 |
}
|
80 |
|
81 |
if (isset($_POST['update_yarpp'])) {
|
82 |
-
|
83 |
$new_options = array();
|
84 |
foreach ($yarpp->default_options as $option => $default) {
|
85 |
if ( is_bool($default) )
|
@@ -114,6 +113,12 @@ if (isset($_POST['update_yarpp'])) {
|
|
114 |
}
|
115 |
}
|
116 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
$new_options['recent'] = isset($_POST['recent_only']) ?
|
119 |
$_POST['recent_number'] . ' ' . $_POST['recent_units'] : false;
|
@@ -154,11 +159,20 @@ 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 |
?>
|
160 |
<div id="poststuff" class="metabox-holder has-right-sidebar">
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
<div class="inner-sidebar" id="side-info-column">
|
163 |
<?php
|
164 |
do_meta_boxes( 'settings_page_yarpp', 'side', array() );
|
79 |
}
|
80 |
|
81 |
if (isset($_POST['update_yarpp'])) {
|
|
|
82 |
$new_options = array();
|
83 |
foreach ($yarpp->default_options as $option => $default) {
|
84 |
if ( is_bool($default) )
|
113 |
}
|
114 |
}
|
115 |
}
|
116 |
+
|
117 |
+
if ( isset( $_POST['auto_display_post_types'] ) ) {
|
118 |
+
$new_options['auto_display_post_types'] = array_keys( $_POST['auto_display_post_types'] );
|
119 |
+
} else {
|
120 |
+
$new_options['auto_display_post_types'] = array();
|
121 |
+
}
|
122 |
|
123 |
$new_options['recent'] = isset($_POST['recent_only']) ?
|
124 |
$_POST['recent_number'] . ' ' . $_POST['recent_units'] : false;
|
159 |
wp_nonce_field( 'yarpp_display_demo', 'yarpp_display_demo-nonce', false );
|
160 |
wp_nonce_field( 'yarpp_display_exclude_terms', 'yarpp_display_exclude_terms-nonce', false );
|
161 |
wp_nonce_field( 'yarpp_optin_data', 'yarpp_optin_data-nonce', false );
|
162 |
+
wp_nonce_field( 'yarpp_set_display_code', 'yarpp_set_display_code-nonce', false );
|
163 |
if ( !count($yarpp->admin->get_templates()) && $yarpp->admin->can_copy_templates() )
|
164 |
wp_nonce_field( 'yarpp_copy_templates', 'yarpp_copy_templates-nonce', false );
|
165 |
?>
|
166 |
<div id="poststuff" class="metabox-holder has-right-sidebar">
|
167 |
|
168 |
+
<?php if ( !$yarpp->get_option('rss_display') ): ?>
|
169 |
+
<style>
|
170 |
+
.rss_displayed {
|
171 |
+
display: none;
|
172 |
+
}
|
173 |
+
</style>
|
174 |
+
<?php endif; ?>
|
175 |
+
|
176 |
<div class="inner-sidebar" id="side-info-column">
|
177 |
<?php
|
178 |
do_meta_boxes( 'settings_page_yarpp', 'side', array() );
|
readme.txt
CHANGED
@@ -130,7 +130,13 @@ The official [YARPP Experiments](http://wordpress.org/extend/plugins/yarpp-exper
|
|
130 |
|
131 |
== Developing with YARPP ==
|
132 |
|
133 |
-
= Custom
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
Developers can call YARPP's powerful relatedness algorithm from anywhere in their own code. Some examples and more details are in [my slides from my WordCamp Birmingham talk](http://www.slideshare.net/mitcho/relate-all-the-things).
|
136 |
|
@@ -234,20 +240,30 @@ If you are a bilingual speaker of English and another language and an avid user
|
|
234 |
|
235 |
== Changelog ==
|
236 |
|
237 |
-
=
|
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 |
-
*
|
|
|
242 |
* [Bugfix](https://wordpress.org/support/topic/related-posts-disappearing-cache-issue): uses of `related_posts_exist()` and `get_related()` without explicit reference ID parameter would incorrectly return no related posts.
|
243 |
-
*
|
|
|
|
|
|
|
244 |
* A new design for the template chooser
|
|
|
245 |
* A new "copy templates" button allows one-button installation of bundled templates into the current theme, if filesystem permissions make it possible.
|
246 |
* 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.
|
247 |
* Code cleanup:
|
248 |
* Settings screen UI have been rewritten to use `div`s rather than `table`s!
|
249 |
* Inline help in settings screen now use WordPress pointers
|
250 |
* Removed keyword cache table, as it does not ctually improve performance much and the overhead of an additional table is not worth it.
|
|
|
|
|
|
|
|
|
|
|
251 |
* Added option to send YARPP setting and usage information back to YARPP (off by default). This information will be used to make more informed decisions about future YARPP development. More info available in the settings.
|
252 |
|
253 |
= 3.5.6 =
|
130 |
|
131 |
== Developing with YARPP ==
|
132 |
|
133 |
+
= Custom post types =
|
134 |
+
|
135 |
+
To make YARPP support your custom post type, the attribute `yarpp_support` must be set to true on the custom post type when it is registered. It will then be available on options on the YARPP settings page.
|
136 |
+
|
137 |
+
If you would like to programmatically control which post types are considered in an automatically-displayed related posts display, use the `yarpp_map_post_types` filter.
|
138 |
+
|
139 |
+
= Custom displays =
|
140 |
|
141 |
Developers can call YARPP's powerful relatedness algorithm from anywhere in their own code. Some examples and more details are in [my slides from my WordCamp Birmingham talk](http://www.slideshare.net/mitcho/relate-all-the-things).
|
142 |
|
240 |
|
241 |
== Changelog ==
|
242 |
|
243 |
+
= 4.0 =
|
244 |
* New thumbnail template option!
|
245 |
* No PHP required -- just visit the settings page
|
246 |
* Edit your theme's CSS file to modify the styling
|
247 |
+
* Auto display settings changes:
|
248 |
+
* Added an "also display in archives" option
|
249 |
* [Bugfix](https://wordpress.org/support/topic/related-posts-disappearing-cache-issue): uses of `related_posts_exist()` and `get_related()` without explicit reference ID parameter would incorrectly return no related posts.
|
250 |
+
* Changes to the output HTML:
|
251 |
+
* 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)). If there are no results, a `yarpp-related-none` class is added.
|
252 |
+
* The "related posts brought to you by YARPP" text is only added if there were results.
|
253 |
+
* Refinements to settings UI:
|
254 |
* A new design for the template chooser
|
255 |
+
* Example code display is now hidden by default; turn them back on from the "screen options" tab.
|
256 |
* A new "copy templates" button allows one-button installation of bundled templates into the current theme, if filesystem permissions make it possible.
|
257 |
* 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.
|
258 |
* Code cleanup:
|
259 |
* Settings screen UI have been rewritten to use `div`s rather than `table`s!
|
260 |
* Inline help in settings screen now use WordPress pointers
|
261 |
* Removed keyword cache table, as it does not ctually improve performance much and the overhead of an additional table is not worth it.
|
262 |
+
* Default option changes:
|
263 |
+
* Default result count is now 4
|
264 |
+
* Default match threshold is now 4
|
265 |
+
* Default for "before related entries" heading uses `h3` instead of `p`
|
266 |
+
* Added `yarpp_map_post_types` filter to programmatically specify what post types should be looked at for automatic displays
|
267 |
* Added option to send YARPP setting and usage information back to YARPP (off by default). This information will be used to make more informed decisions about future YARPP development. More info available in the settings.
|
268 |
|
269 |
= 3.5.6 =
|
styles-thumbnails.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Dynamic styles for YARPP's built-in thumbnails template
|
4 |
+
* @since 4
|
5 |
+
*/
|
6 |
+
|
7 |
+
$height = 120;
|
8 |
+
$width = 120;
|
9 |
+
|
10 |
+
if ( isset($_GET['height']) )
|
11 |
+
$height = (int) $_GET['height'];
|
12 |
+
if ( isset($_GET['width']) )
|
13 |
+
$height = (int) $_GET['width'];
|
14 |
+
|
15 |
+
$margin = 5;
|
16 |
+
$width_with_margins = $width + 2 * $margin;
|
17 |
+
$height_with_text = $height + 50;
|
18 |
+
$extramargin = 7;
|
19 |
+
|
20 |
+
header( 'Content-Type: text/css' );
|
21 |
+
|
22 |
+
?>
|
23 |
+
.yarpp-thumbnails-horizontal .yarpp-thumbnail, .yarpp-thumbnail-default, .yarpp-thumbnail-title {
|
24 |
+
display: inline-block;
|
25 |
+
*display: inline;
|
26 |
+
}
|
27 |
+
.yarpp-thumbnails-horizontal .yarpp-thumbnail {
|
28 |
+
border: 1px solid rgba(127,127,127,0.1);
|
29 |
+
width: <?php echo $width_with_margins; ?>px;
|
30 |
+
height: <?php echo $height_with_text; ?>px;
|
31 |
+
margin: <?php echo $margin; ?>px;
|
32 |
+
margin-left: 0px;
|
33 |
+
vertical-align: top;
|
34 |
+
}
|
35 |
+
.yarpp-thumbnail > img, .yarpp-thumbnail-default {
|
36 |
+
width: <?php echo $width; ?>px;
|
37 |
+
height: <?php echo $height; ?>px;
|
38 |
+
margin: <?php echo $margin; ?>px;
|
39 |
+
}
|
40 |
+
.yarpp-thumbnails-horizontal .yarpp-thumbnail > img, .yarpp-thumbnails-horizontal .yarpp-thumbnail-default {
|
41 |
+
margin-bottom: 0px;
|
42 |
+
display: block;
|
43 |
+
}
|
44 |
+
.yarpp-thumbnails-horizontal .yarpp-thumbnail-title {
|
45 |
+
font-size: 1em;
|
46 |
+
max-height: 2.8em;
|
47 |
+
line-height: 1.4em;
|
48 |
+
margin: <?php echo $extramargin; ?>px;
|
49 |
+
margin-top: 0px;
|
50 |
+
width: <?php echo $width; ?>px;
|
51 |
+
text-decoration: inherit;
|
52 |
+
overflow: hidden;
|
53 |
+
}
|
54 |
+
|
55 |
+
.yarpp-thumbnail-default {
|
56 |
+
overflow: hidden;
|
57 |
+
}
|
58 |
+
.yarpp-thumbnail-default > img.yarpp-thumbnail-default-wide {
|
59 |
+
height: <?php echo $height; ?>px;
|
60 |
+
max-width: none;
|
61 |
+
}
|
62 |
+
.yarpp-thumbnail-default > img.yarpp-thumbnail-default-tall {
|
63 |
+
width: <?php echo $width; ?>px;
|
64 |
+
max-height: none;
|
65 |
+
}
|
template-thumbnails.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* YARPP's built-in thumbnails template
|
4 |
-
* @since
|
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.
|
@@ -27,10 +27,6 @@ if ( isset($size) ) {
|
|
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)
|
@@ -61,50 +57,4 @@ if (have_posts()) {
|
|
61 |
$output .= $no_results;
|
62 |
}
|
63 |
|
64 |
-
|
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 |
-
";
|
1 |
<?php
|
2 |
/*
|
3 |
* YARPP's built-in thumbnails template
|
4 |
+
* @since 4
|
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.
|
27 |
$width = 120;
|
28 |
$height = 120;
|
29 |
}
|
|
|
|
|
|
|
|
|
30 |
|
31 |
// a little easter egg: if the default image URL is left blank,
|
32 |
// default to the theme's header image. (hopefully it has one)
|
57 |
$output .= $no_results;
|
58 |
}
|
59 |
|
60 |
+
wp_enqueue_style( "yarpp-thumbnails-$size", plugins_url( 'styles-thumbnails.php?' . http_build_query( compact('height','width') ), __FILE__ ), array(), YARPP_VERSION, 'all' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
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', '
|
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: 4.0b8
|
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', '4.0b8');
|
13 |
define('YARPP_DIR', dirname(__FILE__));
|
14 |
define('YARPP_NO_RELATED', ':(');
|
15 |
define('YARPP_RELATED', ':)');
|