Version Description
- Tested on WordPress 3.9.
- YARPP Basic and YARPP Pro can now be used simultaneously, rather than being mutually exclusive.
- Added a YARPP Pro option to the YARPP sidebar widget.
- Enlarged "Display Options" panel textbox for increased usability.
- Updated YARPP Pro script to allow for future enhancements.
- Updated MyISAM check notice message to explain its impact on "Pages."
- Added descriptive text to explain new enhancements.
Download this release
Release Info
Developer | jeffparker |
Plugin | ![]() |
Version | 4.2 |
Comparing to | |
See all releases |
Code changes from version 4.1.2 to 4.2
- classes/YARPP_Admin.php +40 -42
- classes/YARPP_Core.php +162 -174
- classes/YARPP_Meta_Box.php +98 -0
- classes/YARPP_Meta_Box_Contact.php +40 -0
- classes/YARPP_Meta_Box_Display_Feed.php +60 -0
- classes/YARPP_Meta_Box_Display_Web.php +72 -0
- classes/YARPP_Meta_Box_Optin.php +30 -0
- classes/YARPP_Meta_Box_Pool.php +33 -0
- classes/YARPP_Meta_Box_Relatedness.php +21 -0
- classes/YARPP_Meta_Boxes.php +0 -484
- classes/YARPP_Widget.php +59 -133
- includes/phtmls/yarpp_meta_box_beforeafter.phtml +27 -0
- includes/phtmls/yarpp_meta_box_checkbox.phtml +12 -0
- includes/phtmls/yarpp_meta_box_pool.phtml +39 -0
- includes/phtmls/yarpp_meta_box_tax_weight.phtml +24 -0
- includes/phtmls/yarpp_meta_box_template_checkbox.phtml +49 -0
- includes/phtmls/yarpp_meta_box_template_file.phtml +34 -0
- includes/phtmls/yarpp_meta_box_textbox.phtml +19 -0
- includes/phtmls/yarpp_options.phtml +73 -0
- includes/phtmls/yarpp_pro_options.phtml +106 -0
- includes/phtmls/yarpp_pro_tag.phtml +7 -0
- includes/phtmls/yarpp_pro_tag_ssp.phtml +6 -0
- includes/phtmls/yarpp_settings_header.phtml +14 -0
- includes/phtmls/yarpp_widget_form.phtml +152 -0
- includes/{styles-thumbnails.css.php → styles_thumbnails.css.php} +0 -0
- includes/template_builtin.php +41 -13
- includes/{template-metabox.php → template_metabox.php} +0 -0
- includes/{template-widget.php → template_widget.php} +0 -0
- includes/yarpp_meta_boxes_hooks.php +93 -0
- includes/yarpp_myisam_notice.php +2 -1
- includes/yarpp_options.php +84 -150
- includes/yarpp_pro_options.php +15 -133
- includes/yarpp_pro_set_display_types.php +11 -0
- includes/yarpp_switch.php +3 -3
- js/options_switch.js +59 -23
- readme.txt +20 -7
- style/options_basic.css +51 -11
- style/options_switch.css +51 -0
- style/related.css +28 -0
- style/widget.css +34 -0
- uninstall.php +2 -1
- yarpp.php +3 -2
classes/YARPP_Admin.php
CHANGED
@@ -15,7 +15,9 @@ class YARPP_Admin {
|
|
15 |
'aid' => null,
|
16 |
'st' => null,
|
17 |
'v' => null,
|
18 |
-
'
|
|
|
|
|
19 |
)
|
20 |
);
|
21 |
|
@@ -54,13 +56,13 @@ class YARPP_Admin {
|
|
54 |
*/
|
55 |
function ajax_register() {
|
56 |
if (defined('DOING_AJAX') && DOING_AJAX) {
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
}
|
65 |
}
|
66 |
|
@@ -125,7 +127,7 @@ class YARPP_Admin {
|
|
125 |
/**
|
126 |
* @since 3.3: Load options page sections as meta-boxes.
|
127 |
*/
|
128 |
-
include_once(YARPP_DIR.'/
|
129 |
|
130 |
/**
|
131 |
* @since 3.5.5 Check that add_help_tab method callable (WP >= 3.3).
|
@@ -271,18 +273,16 @@ class YARPP_Admin {
|
|
271 |
}
|
272 |
|
273 |
function upgrade_notice() {
|
274 |
-
$proAction = ($this->core->yarppPro['active']) ? 'disable' : 'enable';
|
275 |
$optinAction = ($this->core->get_option('optin')) ? 'disable' : 'enable';
|
276 |
-
$this->optin_notice('upgrade', $
|
277 |
}
|
278 |
|
279 |
public function install_notice(){
|
280 |
-
$proAction = ($this->core->yarppPro['active']) ? 'disable' : 'enable';
|
281 |
$optinAction = ($this->core->get_option('optin')) ? 'disable' : 'enable';
|
282 |
-
$this->optin_notice('install', $
|
283 |
}
|
284 |
|
285 |
-
function optin_notice($type=false, $
|
286 |
$screen = get_current_screen();
|
287 |
if(is_null($screen) || $screen->id == 'settings_page_yarpp') return;
|
288 |
|
@@ -311,7 +311,7 @@ class YARPP_Admin {
|
|
311 |
|
312 |
$out .=
|
313 |
'<p>'.
|
314 |
-
'You
|
315 |
'<a href="options-general.php?page=yarpp" class="button">Take me to the settings page</a>'.
|
316 |
'</p>';
|
317 |
|
@@ -370,7 +370,7 @@ class YARPP_Admin {
|
|
370 |
return $text;
|
371 |
}
|
372 |
|
373 |
-
function render_screen_settings
|
374 |
if ( $current_screen->id != 'settings_page_yarpp' )
|
375 |
return $output;
|
376 |
|
@@ -407,7 +407,7 @@ class YARPP_Admin {
|
|
407 |
}
|
408 |
}
|
409 |
|
410 |
-
function settings_link($links, $file) {
|
411 |
$this_plugin = dirname(plugin_basename(dirname(__FILE__))).'/yarpp.php';
|
412 |
if($file == $this_plugin) {
|
413 |
$links[] = '<a href="options-general.php?page=yarpp">'.__('Settings').'</a>';
|
@@ -415,9 +415,9 @@ class YARPP_Admin {
|
|
415 |
return $links;
|
416 |
}
|
417 |
|
418 |
-
function options_page() {
|
419 |
-
|
420 |
-
if($this->core->yarppPro['active
|
421 |
include_once(YARPP_DIR.'/includes/yarpp_pro_options.php');
|
422 |
} else {
|
423 |
include_once(YARPP_DIR . '/includes/yarpp_options.php');
|
@@ -425,7 +425,7 @@ class YARPP_Admin {
|
|
425 |
}
|
426 |
|
427 |
// @since 3.4: don't actually compute results here, but use ajax instead
|
428 |
-
function metabox() {
|
429 |
?>
|
430 |
<style>
|
431 |
#yarpp_relatedposts h3 .postbox-title-action {
|
@@ -448,7 +448,7 @@ class YARPP_Admin {
|
|
448 |
}
|
449 |
|
450 |
// @since 3.3: default metaboxes to show:
|
451 |
-
function default_hidden_meta_boxes($hidden, $screen) {
|
452 |
if ($screen->id === 'settings_page_yarpp') {
|
453 |
$hidden = $this->core->default_hidden_metaboxes;
|
454 |
}
|
@@ -456,36 +456,34 @@ class YARPP_Admin {
|
|
456 |
}
|
457 |
|
458 |
// @since 4: UI to copy templates
|
459 |
-
function can_copy_templates() {
|
460 |
$theme_dir = get_stylesheet_directory();
|
461 |
// If we can't write to the theme, return false
|
462 |
-
if
|
463 |
-
return false;
|
464 |
|
465 |
-
require_once(ABSPATH
|
466 |
-
WP_Filesystem(
|
467 |
global $wp_filesystem;
|
468 |
// direct method is the only method that I've tested so far
|
469 |
-
return $wp_filesystem->method
|
470 |
}
|
471 |
|
472 |
-
function copy_templates() {
|
473 |
-
$templates_dir = trailingslashit(trailingslashit(YARPP_DIR
|
474 |
|
475 |
-
require_once(ABSPATH
|
476 |
-
WP_Filesystem(
|
477 |
global $wp_filesystem;
|
478 |
-
if ( $wp_filesystem->method
|
479 |
-
return false;
|
480 |
|
481 |
-
return copy_dir
|
482 |
}
|
483 |
|
484 |
/*
|
485 |
* AJAX SERVICES
|
486 |
*/
|
487 |
|
488 |
-
function ajax_display_exclude_terms() {
|
489 |
check_ajax_referer('yarpp_display_exclude_terms');
|
490 |
|
491 |
if (!isset($_REQUEST['taxonomy'])) return;
|
@@ -497,7 +495,7 @@ class YARPP_Admin {
|
|
497 |
|
498 |
$exclude_tt_ids = wp_parse_id_list($this->core->get_option('exclude'));
|
499 |
$exclude_term_ids = $this->get_term_ids_from_tt_ids( $taxonomy, $exclude_tt_ids );
|
500 |
-
// if ('category'
|
501 |
|
502 |
$terms = get_terms($taxonomy, array(
|
503 |
'exclude' => $exclude_term_ids,
|
@@ -518,7 +516,7 @@ class YARPP_Admin {
|
|
518 |
exit;
|
519 |
}
|
520 |
|
521 |
-
function get_term_ids_from_tt_ids( $taxonomy, $tt_ids ) {
|
522 |
global $wpdb;
|
523 |
$tt_ids = wp_parse_id_list($tt_ids);
|
524 |
if ( empty($tt_ids) )
|
@@ -526,7 +524,7 @@ class YARPP_Admin {
|
|
526 |
return $wpdb->get_col("select term_id from $wpdb->term_taxonomy where taxonomy = '{$taxonomy}' and term_taxonomy_id in (" . join(',', $tt_ids) . ")");
|
527 |
}
|
528 |
|
529 |
-
function ajax_display() {
|
530 |
check_ajax_referer('yarpp_display');
|
531 |
|
532 |
if (!isset($_REQUEST['ID'])) return;
|
@@ -547,7 +545,7 @@ class YARPP_Admin {
|
|
547 |
die();
|
548 |
}
|
549 |
|
550 |
-
function ajax_display_demo() {
|
551 |
check_ajax_referer('yarpp_display_demo');
|
552 |
|
553 |
header("HTTP/1.1 200");
|
@@ -566,7 +564,7 @@ class YARPP_Admin {
|
|
566 |
/**
|
567 |
* Display optin data in a human readable format on the help tab.
|
568 |
*/
|
569 |
-
function ajax_optin_data() {
|
570 |
check_ajax_referer('yarpp_optin_data');
|
571 |
|
572 |
header("HTTP/1.1 200");
|
@@ -602,7 +600,7 @@ class YARPP_Admin {
|
|
602 |
die();
|
603 |
}
|
604 |
|
605 |
-
function ajax_set_display_code() {
|
606 |
check_ajax_referer( 'yarpp_set_display_code' );
|
607 |
|
608 |
header("HTTP/1.1 200");
|
15 |
'aid' => null,
|
16 |
'st' => null,
|
17 |
'v' => null,
|
18 |
+
'dpid' => null,
|
19 |
+
'optin' => false,
|
20 |
+
'auto_display_post_types' => array('post')
|
21 |
)
|
22 |
);
|
23 |
|
56 |
*/
|
57 |
function ajax_register() {
|
58 |
if (defined('DOING_AJAX') && DOING_AJAX) {
|
59 |
+
add_action('wp_ajax_yarpp_display_exclude_terms', array($this, 'ajax_display_exclude_terms'));
|
60 |
+
add_action('wp_ajax_yarpp_display_demo', array($this, 'ajax_display_demo'));
|
61 |
+
add_action('wp_ajax_yarpp_display', array($this, 'ajax_display'));
|
62 |
+
add_action('wp_ajax_yarpp_optin_data', array($this, 'ajax_optin_data'));
|
63 |
+
add_action('wp_ajax_yarpp_optin_enable', array($this, 'ajax_optin_enable'));
|
64 |
+
add_action('wp_ajax_yarpp_optin_disable', array($this, 'ajax_optin_disable'));
|
65 |
+
add_action('wp_ajax_yarpp_set_display_code', array($this, 'ajax_set_display_code'));
|
66 |
}
|
67 |
}
|
68 |
|
127 |
/**
|
128 |
* @since 3.3: Load options page sections as meta-boxes.
|
129 |
*/
|
130 |
+
include_once(YARPP_DIR.'/includes/yarpp_meta_boxes_hooks.php');
|
131 |
|
132 |
/**
|
133 |
* @since 3.5.5 Check that add_help_tab method callable (WP >= 3.3).
|
273 |
}
|
274 |
|
275 |
function upgrade_notice() {
|
|
|
276 |
$optinAction = ($this->core->get_option('optin')) ? 'disable' : 'enable';
|
277 |
+
$this->optin_notice('upgrade', $optinAction);
|
278 |
}
|
279 |
|
280 |
public function install_notice(){
|
|
|
281 |
$optinAction = ($this->core->get_option('optin')) ? 'disable' : 'enable';
|
282 |
+
$this->optin_notice('install', $optinAction);
|
283 |
}
|
284 |
|
285 |
+
public function optin_notice($type=false, $optinAction) {
|
286 |
$screen = get_current_screen();
|
287 |
if(is_null($screen) || $screen->id == 'settings_page_yarpp') return;
|
288 |
|
311 |
|
312 |
$out .=
|
313 |
'<p>'.
|
314 |
+
'You currently have <strong>YARPP Basic</strong> and <strong>YARPP Pro</strong> enabled.<br/><br/>'.
|
315 |
'<a href="options-general.php?page=yarpp" class="button">Take me to the settings page</a>'.
|
316 |
'</p>';
|
317 |
|
370 |
return $text;
|
371 |
}
|
372 |
|
373 |
+
public function render_screen_settings ($output, $current_screen) {
|
374 |
if ( $current_screen->id != 'settings_page_yarpp' )
|
375 |
return $output;
|
376 |
|
407 |
}
|
408 |
}
|
409 |
|
410 |
+
public function settings_link($links, $file) {
|
411 |
$this_plugin = dirname(plugin_basename(dirname(__FILE__))).'/yarpp.php';
|
412 |
if($file == $this_plugin) {
|
413 |
$links[] = '<a href="options-general.php?page=yarpp">'.__('Settings').'</a>';
|
415 |
return $links;
|
416 |
}
|
417 |
|
418 |
+
public function options_page() {
|
419 |
+
$mode = (isset($_GET['mode'])) ? htmlentities(strtolower($_GET['mode'])) : null;
|
420 |
+
if ($mode !== 'basic' && ($mode === 'pro' || $this->core->yarppPro['active'])){
|
421 |
include_once(YARPP_DIR.'/includes/yarpp_pro_options.php');
|
422 |
} else {
|
423 |
include_once(YARPP_DIR . '/includes/yarpp_options.php');
|
425 |
}
|
426 |
|
427 |
// @since 3.4: don't actually compute results here, but use ajax instead
|
428 |
+
public function metabox() {
|
429 |
?>
|
430 |
<style>
|
431 |
#yarpp_relatedposts h3 .postbox-title-action {
|
448 |
}
|
449 |
|
450 |
// @since 3.3: default metaboxes to show:
|
451 |
+
public function default_hidden_meta_boxes($hidden, $screen) {
|
452 |
if ($screen->id === 'settings_page_yarpp') {
|
453 |
$hidden = $this->core->default_hidden_metaboxes;
|
454 |
}
|
456 |
}
|
457 |
|
458 |
// @since 4: UI to copy templates
|
459 |
+
public function can_copy_templates() {
|
460 |
$theme_dir = get_stylesheet_directory();
|
461 |
// If we can't write to the theme, return false
|
462 |
+
if (!is_dir($theme_dir) || !is_writable($theme_dir)) return false;
|
|
|
463 |
|
464 |
+
require_once(ABSPATH.'wp-admin/includes/file.php');
|
465 |
+
WP_Filesystem(false, get_stylesheet_directory());
|
466 |
global $wp_filesystem;
|
467 |
// direct method is the only method that I've tested so far
|
468 |
+
return $wp_filesystem->method === 'direct';
|
469 |
}
|
470 |
|
471 |
+
public function copy_templates() {
|
472 |
+
$templates_dir = trailingslashit(trailingslashit(YARPP_DIR).'yarpp-templates');
|
473 |
|
474 |
+
require_once(ABSPATH.'wp-admin/includes/file.php');
|
475 |
+
WP_Filesystem(false, get_stylesheet_directory());
|
476 |
global $wp_filesystem;
|
477 |
+
if ( $wp_filesystem->method !== 'direct') return false;
|
|
|
478 |
|
479 |
+
return copy_dir($templates_dir, get_stylesheet_directory(), array('.svn'));
|
480 |
}
|
481 |
|
482 |
/*
|
483 |
* AJAX SERVICES
|
484 |
*/
|
485 |
|
486 |
+
public function ajax_display_exclude_terms() {
|
487 |
check_ajax_referer('yarpp_display_exclude_terms');
|
488 |
|
489 |
if (!isset($_REQUEST['taxonomy'])) return;
|
495 |
|
496 |
$exclude_tt_ids = wp_parse_id_list($this->core->get_option('exclude'));
|
497 |
$exclude_term_ids = $this->get_term_ids_from_tt_ids( $taxonomy, $exclude_tt_ids );
|
498 |
+
// if ('category' === $taxonomy) $exclude .= ','.get_option('default_category');
|
499 |
|
500 |
$terms = get_terms($taxonomy, array(
|
501 |
'exclude' => $exclude_term_ids,
|
516 |
exit;
|
517 |
}
|
518 |
|
519 |
+
public function get_term_ids_from_tt_ids( $taxonomy, $tt_ids ) {
|
520 |
global $wpdb;
|
521 |
$tt_ids = wp_parse_id_list($tt_ids);
|
522 |
if ( empty($tt_ids) )
|
524 |
return $wpdb->get_col("select term_id from $wpdb->term_taxonomy where taxonomy = '{$taxonomy}' and term_taxonomy_id in (" . join(',', $tt_ids) . ")");
|
525 |
}
|
526 |
|
527 |
+
public function ajax_display() {
|
528 |
check_ajax_referer('yarpp_display');
|
529 |
|
530 |
if (!isset($_REQUEST['ID'])) return;
|
545 |
die();
|
546 |
}
|
547 |
|
548 |
+
public function ajax_display_demo() {
|
549 |
check_ajax_referer('yarpp_display_demo');
|
550 |
|
551 |
header("HTTP/1.1 200");
|
564 |
/**
|
565 |
* Display optin data in a human readable format on the help tab.
|
566 |
*/
|
567 |
+
public function ajax_optin_data() {
|
568 |
check_ajax_referer('yarpp_optin_data');
|
569 |
|
570 |
header("HTTP/1.1 200");
|
600 |
die();
|
601 |
}
|
602 |
|
603 |
+
public function ajax_set_display_code() {
|
604 |
check_ajax_referer( 'yarpp_set_display_code' );
|
605 |
|
606 |
header("HTTP/1.1 200");
|
classes/YARPP_Core.php
CHANGED
@@ -12,14 +12,21 @@ class YARPP {
|
|
12 |
*/
|
13 |
public $default_options = array();
|
14 |
public $default_hidden_metaboxes = array();
|
15 |
-
|
16 |
public $yarppPro = null;
|
17 |
public $cache_bypass;
|
18 |
-
|
19 |
public $admin;
|
20 |
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
public function __construct() {
|
25 |
|
@@ -81,7 +88,6 @@ class YARPP {
|
|
81 |
/*
|
82 |
* OPTIONS
|
83 |
*/
|
84 |
-
|
85 |
private function load_default_options() {
|
86 |
$this->default_options = array(
|
87 |
'threshold' => 4,
|
@@ -182,7 +188,7 @@ class YARPP {
|
|
182 |
// ensure defaults if not set:
|
183 |
$options = array_merge($this->default_options, $options);
|
184 |
|
185 |
-
if (is_null
|
186 |
|
187 |
$optionpath = array();
|
188 |
$parsed_option = array();
|
@@ -215,7 +221,6 @@ class YARPP {
|
|
215 |
* @since 3.5.2 Function to enforce YARPP setup if not ready, activate; else upgrade.
|
216 |
*/
|
217 |
public function enforce() {
|
218 |
-
|
219 |
if (!$this->enabled()) {
|
220 |
$this->activate(); // activate calls upgrade later, so it's covered.
|
221 |
} else {
|
@@ -339,7 +344,7 @@ class YARPP {
|
|
339 |
$wpdb->get_results("SHOW INDEX FROM {$wpdb->posts} WHERE Key_name = 'yarpp_title' OR Key_name = 'yarpp_content'");
|
340 |
return ($wpdb->num_rows >= 2);
|
341 |
}
|
342 |
-
|
343 |
public function diagnostic_hidden_metaboxes() {
|
344 |
global $wpdb;
|
345 |
$raw = $wpdb->get_var(
|
@@ -347,9 +352,9 @@ class YARPP {
|
|
347 |
"WHERE meta_key = 'metaboxhidden_settings_page_yarpp' ".
|
348 |
"ORDER BY length(meta_value) ASC LIMIT 1"
|
349 |
);
|
350 |
-
|
351 |
if (!$raw) return $this->default_hidden_metaboxes;
|
352 |
-
|
353 |
$list = maybe_unserialize($raw);
|
354 |
if (!is_array($list)) return $this->default_hidden_metaboxes;
|
355 |
|
@@ -378,14 +383,6 @@ class YARPP {
|
|
378 |
public function diagnostic_generate_thumbnails() {
|
379 |
return (defined('YARPP_GENERATE_THUMBNAILS') && YARPP_GENERATE_THUMBNAILS);
|
380 |
}
|
381 |
-
|
382 |
-
private $default_dimensions = array(
|
383 |
-
'width' => 120,
|
384 |
-
'height' => 120,
|
385 |
-
'crop' => false,
|
386 |
-
'size' => '120x120',
|
387 |
-
'_default' => true
|
388 |
-
);
|
389 |
|
390 |
public function diagnostic_using_thumbnails() {
|
391 |
if ($this->get_option('manually_using_thumbnails')) return true;
|
@@ -430,7 +427,7 @@ class YARPP {
|
|
430 |
)
|
431 |
);
|
432 |
|
433 |
-
$url = plugins_url('includes/
|
434 |
wp_enqueue_style("yarpp-thumbnails-".$dimensions['size'], $url, array(), YARPP_VERSION, 'all');
|
435 |
}
|
436 |
|
@@ -618,7 +615,7 @@ class YARPP {
|
|
618 |
update_option('yarpp', $options);
|
619 |
}
|
620 |
|
621 |
-
function upgrade_3_4b8() {
|
622 |
$options = $this->get_option();
|
623 |
$options['weight'] = array(
|
624 |
'title' => (int) @$options['title'],
|
@@ -719,15 +716,11 @@ class YARPP {
|
|
719 |
|
720 |
public function upgrade_3_5_2b2() {
|
721 |
// fixing the effects of a previous bug affecting non-MyISAM users
|
722 |
-
if (is_null( $this->get_option('weight
|
723 |
-
|| !is_array( $this->get_option('weight'))
|
724 |
-
) {
|
725 |
$weight = $this->default_options['weight'];
|
726 |
|
727 |
// if we're still not using MyISAM
|
728 |
-
if (!$this->get_option('myisam_override')
|
729 |
-
&& $this->diagnostic_myisam_posts() !== true
|
730 |
-
) {
|
731 |
unset($weight['title']);
|
732 |
unset($weight['body']);
|
733 |
}
|
@@ -754,7 +747,6 @@ class YARPP {
|
|
754 |
/*
|
755 |
* UTILITIES
|
756 |
*/
|
757 |
-
|
758 |
private $current_post;
|
759 |
private $current_query;
|
760 |
private $current_pagenow;
|
@@ -954,6 +946,53 @@ class YARPP {
|
|
954 |
/*
|
955 |
* CORE LOOKUP + DISPLAY FUNCTIONS
|
956 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
957 |
|
958 |
/**
|
959 |
* Display related posts
|
@@ -966,147 +1005,119 @@ class YARPP {
|
|
966 |
* @return string
|
967 |
*/
|
968 |
public function display_related($reference_ID = null, $args = array(), $echo = true) {
|
|
|
|
|
|
|
|
|
|
|
969 |
$output = null;
|
970 |
-
/*
|
971 |
-
* YARPP Pro Script Tag
|
972 |
-
*/
|
973 |
-
if((isset($this->yarppPro['active']) && $this->yarppPro['active']) && $args['domain'] === 'website'){
|
974 |
-
|
975 |
-
if(
|
976 |
-
(isset($this->yarppPro['aid']) && isset($this->yarppPro['v']))
|
977 |
-
&& ($this->yarppPro['aid'] && $this->yarppPro['v'])
|
978 |
-
){
|
979 |
-
$ru = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
980 |
-
$output =
|
981 |
-
"\n".
|
982 |
-
'<script>'.
|
983 |
-
'var aid='.$this->yarppPro['aid'].',v="'.$this->yarppPro['v'].'",credomain="adkengage.com",ru="'.$ru.'";'.
|
984 |
-
"document.write('<sc'+'ript type=\"text/javascript\" src=\"http://'+ credomain +'/Scripts/CREReqScript.js\"></sc'+'ript>');".
|
985 |
-
'</script>'.
|
986 |
-
"\n";
|
987 |
-
}
|
988 |
-
} else {
|
989 |
-
|
990 |
-
/* If we're already in a YARPP loop, stop now. */
|
991 |
-
if ($this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time()) return false;
|
992 |
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
$reference_ID = get_the_ID();
|
999 |
-
}
|
1000 |
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
|
1006 |
-
|
1007 |
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
|
1017 |
-
|
1018 |
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
|
1023 |
-
|
1024 |
|
1025 |
-
|
1026 |
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
|
1040 |
-
|
1041 |
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
|
1048 |
-
|
1049 |
-
|
1050 |
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
|
|
1080 |
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
if ($related_count > 0 && $promote_yarpp && $domain != 'metabox') {
|
1091 |
-
$output .=
|
1092 |
-
"<p>".
|
1093 |
-
sprintf(
|
1094 |
-
__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.",'yarpp'),
|
1095 |
-
'http://www.yarpp.com'
|
1096 |
-
).
|
1097 |
-
"</p>\n";
|
1098 |
-
}
|
1099 |
|
1100 |
-
|
1101 |
-
|
1102 |
-
}
|
1103 |
-
$output .= "</div>\n";
|
1104 |
}
|
1105 |
|
|
|
|
|
|
|
1106 |
if ($echo) echo $output;
|
1107 |
return $output;
|
1108 |
-
|
1109 |
-
}/*end display_related*/
|
1110 |
|
1111 |
/*
|
1112 |
* @param (int) $reference_ID
|
@@ -1115,7 +1126,6 @@ class YARPP {
|
|
1115 |
public function get_related($reference_ID = null, $args = array()) {
|
1116 |
/* If we're already in a YARPP loop, stop now. */
|
1117 |
if ($this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time()) return false;
|
1118 |
-
|
1119 |
$this->enforce();
|
1120 |
|
1121 |
if (is_numeric($reference_ID)) {
|
@@ -1377,38 +1387,16 @@ class YARPP {
|
|
1377 |
/* this filter doesn't handle feeds */
|
1378 |
if (is_feed()) return $content;
|
1379 |
|
1380 |
-
$auto_display_post_types = $this->get_option('auto_display_post_types');
|
1381 |
-
|
1382 |
-
/* if it's not an auto-display post type, return */
|
1383 |
-
if (!in_array(get_post_type(), $auto_display_post_types)) return $content;
|
1384 |
-
|
1385 |
-
if (!is_singular()
|
1386 |
-
&& !($this->get_option('auto_display_archive') && (is_archive() || is_home()))
|
1387 |
-
) {
|
1388 |
-
return $content;
|
1389 |
-
}
|
1390 |
-
|
1391 |
/* If the content includes <!--noyarpp-->, don't display */
|
1392 |
-
if
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
} else {
|
1397 |
-
$post_types = array(get_post_type());
|
1398 |
}
|
1399 |
-
|
1400 |
-
$post_types = apply_filters('yarpp_map_post_types', $post_types, 'website');
|
1401 |
|
1402 |
-
return $content
|
1403 |
-
null,
|
1404 |
-
array(
|
1405 |
-
'post_type' => $post_types,
|
1406 |
-
'domain' => 'website'
|
1407 |
-
),
|
1408 |
-
false
|
1409 |
-
);
|
1410 |
}
|
1411 |
-
|
1412 |
public function the_content_feed($content) {
|
1413 |
if (!$this->get_option('rss_display')) return $content;
|
1414 |
|
12 |
*/
|
13 |
public $default_options = array();
|
14 |
public $default_hidden_metaboxes = array();
|
15 |
+
public $debug = false;
|
16 |
public $yarppPro = null;
|
17 |
public $cache_bypass;
|
18 |
+
public $cache;
|
19 |
public $admin;
|
20 |
|
21 |
+
private $active_cache;
|
22 |
+
private $storage_class;
|
23 |
+
private $default_dimensions = array(
|
24 |
+
'width' => 120,
|
25 |
+
'height' => 120,
|
26 |
+
'crop' => false,
|
27 |
+
'size' => '120x120',
|
28 |
+
'_default' => true
|
29 |
+
);
|
30 |
|
31 |
public function __construct() {
|
32 |
|
88 |
/*
|
89 |
* OPTIONS
|
90 |
*/
|
|
|
91 |
private function load_default_options() {
|
92 |
$this->default_options = array(
|
93 |
'threshold' => 4,
|
188 |
// ensure defaults if not set:
|
189 |
$options = array_merge($this->default_options, $options);
|
190 |
|
191 |
+
if (is_null($option)) return $options;
|
192 |
|
193 |
$optionpath = array();
|
194 |
$parsed_option = array();
|
221 |
* @since 3.5.2 Function to enforce YARPP setup if not ready, activate; else upgrade.
|
222 |
*/
|
223 |
public function enforce() {
|
|
|
224 |
if (!$this->enabled()) {
|
225 |
$this->activate(); // activate calls upgrade later, so it's covered.
|
226 |
} else {
|
344 |
$wpdb->get_results("SHOW INDEX FROM {$wpdb->posts} WHERE Key_name = 'yarpp_title' OR Key_name = 'yarpp_content'");
|
345 |
return ($wpdb->num_rows >= 2);
|
346 |
}
|
347 |
+
|
348 |
public function diagnostic_hidden_metaboxes() {
|
349 |
global $wpdb;
|
350 |
$raw = $wpdb->get_var(
|
352 |
"WHERE meta_key = 'metaboxhidden_settings_page_yarpp' ".
|
353 |
"ORDER BY length(meta_value) ASC LIMIT 1"
|
354 |
);
|
355 |
+
|
356 |
if (!$raw) return $this->default_hidden_metaboxes;
|
357 |
+
|
358 |
$list = maybe_unserialize($raw);
|
359 |
if (!is_array($list)) return $this->default_hidden_metaboxes;
|
360 |
|
383 |
public function diagnostic_generate_thumbnails() {
|
384 |
return (defined('YARPP_GENERATE_THUMBNAILS') && YARPP_GENERATE_THUMBNAILS);
|
385 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
|
387 |
public function diagnostic_using_thumbnails() {
|
388 |
if ($this->get_option('manually_using_thumbnails')) return true;
|
427 |
)
|
428 |
);
|
429 |
|
430 |
+
$url = plugins_url('includes/styles_thumbnails.css.php?'.$queryStr, dirname(__FILE__));
|
431 |
wp_enqueue_style("yarpp-thumbnails-".$dimensions['size'], $url, array(), YARPP_VERSION, 'all');
|
432 |
}
|
433 |
|
615 |
update_option('yarpp', $options);
|
616 |
}
|
617 |
|
618 |
+
public function upgrade_3_4b8() {
|
619 |
$options = $this->get_option();
|
620 |
$options['weight'] = array(
|
621 |
'title' => (int) @$options['title'],
|
716 |
|
717 |
public function upgrade_3_5_2b2() {
|
718 |
// fixing the effects of a previous bug affecting non-MyISAM users
|
719 |
+
if (is_null($this->get_option('weight')) || !is_array( $this->get_option('weight'))) {
|
|
|
|
|
720 |
$weight = $this->default_options['weight'];
|
721 |
|
722 |
// if we're still not using MyISAM
|
723 |
+
if (!$this->get_option('myisam_override') && $this->diagnostic_myisam_posts() !== true) {
|
|
|
|
|
724 |
unset($weight['title']);
|
725 |
unset($weight['body']);
|
726 |
}
|
747 |
/*
|
748 |
* UTILITIES
|
749 |
*/
|
|
|
750 |
private $current_post;
|
751 |
private $current_query;
|
752 |
private $current_pagenow;
|
946 |
/*
|
947 |
* CORE LOOKUP + DISPLAY FUNCTIONS
|
948 |
*/
|
949 |
+
protected function display_basic(){
|
950 |
+
/* if it's not an auto-display post type, return */
|
951 |
+
if (!in_array(get_post_type(), $this->get_option('auto_display_post_types'))) return null;
|
952 |
+
|
953 |
+
if (!is_singular() && !($this->get_option('auto_display_archive') && (is_archive() || is_home()))) {
|
954 |
+
return null;
|
955 |
+
}
|
956 |
+
|
957 |
+
if ($this->get_option('cross_relate')) {
|
958 |
+
$post_types = $this->get_post_types();
|
959 |
+
} else {
|
960 |
+
$post_types = array(get_post_type());
|
961 |
+
}
|
962 |
+
|
963 |
+
$post_types = apply_filters('yarpp_map_post_types', $post_types, 'website');
|
964 |
+
|
965 |
+
return $this->display_related(
|
966 |
+
null,
|
967 |
+
array(
|
968 |
+
'post_type' => $post_types,
|
969 |
+
'domain' => 'website'
|
970 |
+
),
|
971 |
+
false
|
972 |
+
);
|
973 |
+
}
|
974 |
+
|
975 |
+
public function display_pro($domain) {
|
976 |
+
if ((is_archive() || is_home() || $domain !== 'website')) return null;
|
977 |
+
if (!in_array(get_post_type(), $this->yarppPro['auto_display_post_types'])) return null;
|
978 |
+
if (!(isset($this->yarppPro['active']) && $this->yarppPro['active'])) return null;
|
979 |
+
if (!(isset($this->yarppPro['aid']) && isset($this->yarppPro['v'])) ||
|
980 |
+
!($this->yarppPro['aid'] && $this->yarppPro['v'])) return null;
|
981 |
+
|
982 |
+
$output = null;
|
983 |
+
$aid = $this->yarppPro['aid'];
|
984 |
+
$v = $this->yarppPro['v'];
|
985 |
+
$dpid = (isset($this->yarppPro['dpid'])) ? $this->yarppPro['dpid'] : null;
|
986 |
+
$ru = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
987 |
+
$ssp = ($dpid) ? '_ssp' : null;
|
988 |
+
|
989 |
+
ob_start();
|
990 |
+
include(YARPP_DIR.'/includes/phtmls/yarpp_pro_tag'.$ssp.'.phtml');
|
991 |
+
$output .= ob_get_contents();
|
992 |
+
ob_end_clean();
|
993 |
+
|
994 |
+
return $output;
|
995 |
+
}
|
996 |
|
997 |
/**
|
998 |
* Display related posts
|
1005 |
* @return string
|
1006 |
*/
|
1007 |
public function display_related($reference_ID = null, $args = array(), $echo = true) {
|
1008 |
+
|
1009 |
+
/* If we're already in a YARPP loop, stop now. */
|
1010 |
+
if ($this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time()) return false;
|
1011 |
+
$this->enforce();
|
1012 |
+
wp_enqueue_style('yarppRelatedCss', YARPP_URL.'/style/related.css');
|
1013 |
$output = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1014 |
|
1015 |
+
if (is_numeric($reference_ID)) {
|
1016 |
+
$reference_ID = (int) $reference_ID;
|
1017 |
+
} else {
|
1018 |
+
$reference_ID = get_the_ID();
|
1019 |
+
}
|
|
|
|
|
1020 |
|
1021 |
+
/**
|
1022 |
+
* @since 3.5.3 don't compute on revisions.
|
1023 |
+
*/
|
1024 |
+
if ($the_post = wp_is_post_revision($reference_ID)) $reference_ID = $the_post;
|
1025 |
|
1026 |
+
$this->setup_active_cache($args);
|
1027 |
|
1028 |
+
$options = array(
|
1029 |
+
'domain',
|
1030 |
+
'limit',
|
1031 |
+
'template',
|
1032 |
+
'order',
|
1033 |
+
'promote_yarpp',
|
1034 |
+
'optin'
|
1035 |
+
);
|
1036 |
|
1037 |
+
extract($this->parse_args($args, $options));
|
1038 |
|
1039 |
+
$cache_status = $this->active_cache->enforce($reference_ID);
|
1040 |
+
if ($cache_status === YARPP_DONT_RUN) return;
|
1041 |
+
if ($cache_status !== YARPP_NO_RELATED) $this->active_cache->begin_yarpp_time($reference_ID, $args);
|
1042 |
|
1043 |
+
$this->save_post_context();
|
1044 |
|
1045 |
+
global $wp_query; $wp_query = new WP_Query();
|
1046 |
|
1047 |
+
if ($cache_status !== YARPP_NO_RELATED) {
|
1048 |
+
$orders = explode(' ', $order);
|
1049 |
+
$wp_query->query(
|
1050 |
+
array(
|
1051 |
+
'p' => $reference_ID,
|
1052 |
+
'orderby' => $orders[0],
|
1053 |
+
'order' => $orders[1],
|
1054 |
+
'showposts' => $limit,
|
1055 |
+
'post_type' => (isset($args['post_type']) ? $args['post_type'] : $this->get_post_types())
|
1056 |
+
)
|
1057 |
+
);
|
1058 |
+
}
|
1059 |
|
1060 |
+
$this->prep_query($this->current_query->is_feed);
|
1061 |
|
1062 |
+
$wp_query->posts = apply_filters('yarpp_results', $wp_query->posts, array(
|
1063 |
+
'function' => 'display_related',
|
1064 |
+
'args' => $args,
|
1065 |
+
'related_ID' => $reference_ID)
|
1066 |
+
);
|
1067 |
|
1068 |
+
$related_query = $wp_query; // backwards compatibility
|
1069 |
+
$related_count = $related_query->post_count;
|
1070 |
|
1071 |
+
$output .= "<div class='";
|
1072 |
+
if ($domain === 'website') {
|
1073 |
+
$output .= "yarpp-related";
|
1074 |
+
} else {
|
1075 |
+
$output .= "yarpp-related-{$domain}";
|
1076 |
+
}
|
1077 |
|
1078 |
+
if ($related_count < 1) {
|
1079 |
+
$output .= " yarpp-related-none";
|
1080 |
+
}
|
1081 |
|
1082 |
+
$output .= "'>\n";
|
1083 |
+
|
1084 |
+
if ($domain === 'metabox') {
|
1085 |
+
include(YARPP_DIR.'/includes/template_metabox.php');
|
1086 |
+
} else if ((bool) $template && $template === 'thumbnails') {
|
1087 |
+
include(YARPP_DIR.'/includes/template_thumbnails.php');
|
1088 |
+
} else if ((bool) $template && file_exists(STYLESHEETPATH.'/'.$template)) {
|
1089 |
+
global $post;
|
1090 |
+
ob_start();
|
1091 |
+
include(STYLESHEETPATH.'/'.$template);
|
1092 |
+
$output .= ob_get_contents();
|
1093 |
+
ob_end_clean();
|
1094 |
+
} else if ($domain === 'widget') {
|
1095 |
+
include(YARPP_DIR.'/includes/template_widget.php');
|
1096 |
+
} else {
|
1097 |
+
include(YARPP_DIR.'/includes/template_builtin.php');
|
1098 |
+
}
|
1099 |
+
|
1100 |
+
$output = trim($output)."\n";
|
1101 |
|
1102 |
+
if ($cache_status === YARPP_NO_RELATED) {
|
1103 |
+
// Uh, do nothing. Stay very still.
|
1104 |
+
} else {
|
1105 |
+
$this->active_cache->end_yarpp_time();
|
1106 |
+
}
|
1107 |
|
1108 |
+
unset($related_query);
|
1109 |
+
$this->restore_post_context();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1110 |
|
1111 |
+
if ($related_count > 0 && $promote_yarpp && $domain != 'metabox') {
|
1112 |
+
$output .= '<p><a href="http://www.yarpp.com" class="yarpp-promote" target="_blank">Powered by</a></p>';
|
|
|
|
|
1113 |
}
|
1114 |
|
1115 |
+
$output .= ($optin) ? '<img src="http://yarpp.org/pixels/'.md5(get_bloginfo('url')).'" alt="YARPP"/>'."\n" : null;
|
1116 |
+
$output .= "</div>\n";
|
1117 |
+
|
1118 |
if ($echo) echo $output;
|
1119 |
return $output;
|
1120 |
+
}
|
|
|
1121 |
|
1122 |
/*
|
1123 |
* @param (int) $reference_ID
|
1126 |
public function get_related($reference_ID = null, $args = array()) {
|
1127 |
/* If we're already in a YARPP loop, stop now. */
|
1128 |
if ($this->cache->is_yarpp_time() || $this->cache_bypass->is_yarpp_time()) return false;
|
|
|
1129 |
$this->enforce();
|
1130 |
|
1131 |
if (is_numeric($reference_ID)) {
|
1387 |
/* this filter doesn't handle feeds */
|
1388 |
if (is_feed()) return $content;
|
1389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1390 |
/* If the content includes <!--noyarpp-->, don't display */
|
1391 |
+
if (!stristr($content, '<!--noyarpp-->')) {
|
1392 |
+
$content .= $this->display_basic();
|
1393 |
+
$content .= '<br/>';
|
1394 |
+
$content .= $this->display_pro('website');
|
|
|
|
|
1395 |
}
|
|
|
|
|
1396 |
|
1397 |
+
return $content;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1398 |
}
|
1399 |
+
|
1400 |
public function the_content_feed($content) {
|
1401 |
if (!$this->get_option('rss_display')) return $content;
|
1402 |
|
classes/YARPP_Meta_Box.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class YARPP_Meta_Box {
|
4 |
+
protected $template_text = null;
|
5 |
+
protected $yarpp = null;
|
6 |
+
|
7 |
+
public function __construct() {
|
8 |
+
global $yarpp;
|
9 |
+
$this->yarpp = $yarpp;
|
10 |
+
$this->template_text =
|
11 |
+
__(
|
12 |
+
"This advanced option gives you full power to customize how your related posts are displayed. ".
|
13 |
+
"Templates (stored in your theme folder) are written in PHP.",
|
14 |
+
'yarpp'
|
15 |
+
);
|
16 |
+
}
|
17 |
+
|
18 |
+
private function offer_copy_templates() {
|
19 |
+
return (!$this->yarpp->diagnostic_custom_templates() && $this->yarpp->admin->can_copy_templates());
|
20 |
+
}
|
21 |
+
|
22 |
+
public function checkbox($option, $desc, $class = null) {
|
23 |
+
include(YARPP_DIR.'/includes/phtmls/yarpp_meta_box_checkbox.phtml');
|
24 |
+
}
|
25 |
+
|
26 |
+
public function template_checkbox($rss=false, $class = null) {
|
27 |
+
$pre = ($rss) ? 'rss_' : '';
|
28 |
+
$chosen_template = yarpp_get_option($pre."template");
|
29 |
+
$choice = ($chosen_template === false)
|
30 |
+
? 'builtin' : (($chosen_template === 'thumbnails') ? 'thumbnails' : 'custom');
|
31 |
+
|
32 |
+
$builtIn = ($choice === 'builtin') ? 'active' : null;
|
33 |
+
|
34 |
+
$thumbnails = ($choice === 'thumbnails') ? 'active' : null;
|
35 |
+
$diagPostThumbs = (!$this->yarpp->diagnostic_post_thumbnails()) ? 'disabled' : null;
|
36 |
+
|
37 |
+
$custom = ($choice === 'custom') ? 'active' : null;
|
38 |
+
$diagCustTemplt = (!$this->yarpp->diagnostic_custom_templates()) ? 'disabled' : null;
|
39 |
+
|
40 |
+
include(YARPP_DIR.'/includes/phtmls/yarpp_meta_box_template_checkbox.phtml');
|
41 |
+
}
|
42 |
+
|
43 |
+
public function template_file($rss=false, $class=null) {
|
44 |
+
$pre = ($rss) ? 'rss_' : '';
|
45 |
+
$chosen_template = yarpp_get_option($pre.'template');
|
46 |
+
|
47 |
+
include(YARPP_DIR.'/includes/phtmls/yarpp_meta_box_template_file.phtml');
|
48 |
+
}
|
49 |
+
|
50 |
+
public function textbox($option, $desc, $size = 2, $class = null, $note = null) {
|
51 |
+
$value = esc_attr(yarpp_get_option($option));
|
52 |
+
|
53 |
+
include(YARPP_DIR.'/includes/phtmls/yarpp_meta_box_textbox.phtml');
|
54 |
+
}
|
55 |
+
|
56 |
+
public function beforeafter($options, $desc, $size = 10, $class = null, $note = null) {
|
57 |
+
include(YARPP_DIR.'/includes/phtmls/yarpp_meta_box_beforeafter.phtml');
|
58 |
+
}
|
59 |
+
|
60 |
+
/* MARK: Last cleaning spot */
|
61 |
+
public function tax_weight($taxonomy) {
|
62 |
+
$weight = (int) yarpp_get_option("weight[tax][{$taxonomy->name}]");
|
63 |
+
$require = (int) yarpp_get_option("require_tax[{$taxonomy->name}]");
|
64 |
+
|
65 |
+
include(YARPP_DIR.'/includes/phtmls/yarpp_meta_box_tax_weight.phtml');
|
66 |
+
}
|
67 |
+
|
68 |
+
/* MARK: Last cleaning spot */
|
69 |
+
public function weight($option, $desc) {
|
70 |
+
$weight = (int) yarpp_get_option("weight[$option]");
|
71 |
+
|
72 |
+
/* Both require MyISAM fulltext indexing: */
|
73 |
+
$fulltext = $this->yarpp->diagnostic_fulltext_disabled() ? ' readonly="readonly" disabled="disabled"' : '';
|
74 |
+
|
75 |
+
echo "<div class='yarpp_form_row yarpp_form_select'><div class='yarpp_form_label'>{$desc}</div><div>";
|
76 |
+
echo "<select name='weight[{$option}]'>";
|
77 |
+
echo "<option {$fulltext} value='no'".((!$weight) ? ' selected="selected"': '')." >".__("do not consider", 'yarpp')."</option>";
|
78 |
+
echo "<option {$fulltext} value='consider'".(($weight == 1) ? ' selected="selected"': '')." > ".__("consider", 'yarpp')."</option>";
|
79 |
+
echo "<option {$fulltext} value='consider_extra'".(($weight > 1) ? ' selected="selected"': '')." > ".__("consider with extra weight", 'yarpp')."</option>";
|
80 |
+
echo "</select></div></div>";
|
81 |
+
}
|
82 |
+
|
83 |
+
public function displayorder($option, $class=null) {
|
84 |
+
echo "<div class='yarpp_form_row yarpp_form_select $class'><div class='yarpp_form_label'>";
|
85 |
+
_e( "Order results:", 'yarpp' );
|
86 |
+
echo "</div><div><select name='$option' id='<?php echo $option; ?>'>";
|
87 |
+
$order = yarpp_get_option( $option );
|
88 |
+
?>
|
89 |
+
<option value="score DESC" <?php echo ( $order == 'score DESC'?' selected="selected"':'' )?>><?php _e( "score (high relevance to low)", 'yarpp' ); ?></option>
|
90 |
+
<option value="score ASC" <?php echo ( $order == 'score ASC'?' selected="selected"':'' )?>><?php _e( "score (low relevance to high)", 'yarpp' ); ?></option>
|
91 |
+
<option value="post_date DESC" <?php echo ( $order == 'post_date DESC'?' selected="selected"':'' )?>><?php _e( "date (new to old)", 'yarpp' ); ?></option>
|
92 |
+
<option value="post_date ASC" <?php echo ( $order == 'post_date ASC'?' selected="selected"':'' )?>><?php _e( "date (old to new)", 'yarpp' ); ?></option>
|
93 |
+
<option value="post_title ASC" <?php echo ( $order == 'post_title ASC'?' selected="selected"':'' )?>><?php _e( "title (alphabetical)", 'yarpp' ); ?></option>
|
94 |
+
<option value="post_title DESC" <?php echo ( $order == 'post_title DESC'?' selected="selected"':'' )?>><?php _e( "title (reverse alphabetical)", 'yarpp' ); ?></option>
|
95 |
+
<?php
|
96 |
+
echo "</select></div></div>";
|
97 |
+
}
|
98 |
+
}
|
classes/YARPP_Meta_Box_Contact.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class YARPP_Meta_Box_Contact extends YARPP_Meta_Box {
|
4 |
+
public function display() {
|
5 |
+
global $yarpp;
|
6 |
+
|
7 |
+
$happy = ($yarpp->diagnostic_happy()) ? 'spin' : null;
|
8 |
+
|
9 |
+
$out =
|
10 |
+
'<ul class="yarpp_contacts">'.
|
11 |
+
'<li>'.
|
12 |
+
'<a href="http://wordpress.org/support/plugin/yet-another-related-posts-plugin" target="_blank">'.
|
13 |
+
'<span class="icon icon-wordpress"></span> '.__('YARPP Forum', 'yarpp').
|
14 |
+
'</a>'.
|
15 |
+
'</li>'.
|
16 |
+
'<li>'.
|
17 |
+
'<a href="http://twitter.com/yarpp" target="_blank">'.
|
18 |
+
'<span class="icon icon-twitter"></span> '.__('YARPP on Twitter', 'yarpp').
|
19 |
+
'</a>'.
|
20 |
+
'</li>'.
|
21 |
+
'<li>'.
|
22 |
+
'<a href="https://www.facebook.com/YARPPRecommendationEngine" target="_blank">'.
|
23 |
+
'<span class="icon icon-facebook"></span> YARPP on Facebook'.
|
24 |
+
'</a>'.
|
25 |
+
'</li>'.
|
26 |
+
'<li>'.
|
27 |
+
'<a href="http://www.yarpp.com" target="_blank">'.
|
28 |
+
'<span class="icon icon-pro"></span> Learn more about YARPP'.
|
29 |
+
'</a>'.
|
30 |
+
'</li>'.
|
31 |
+
'<li>'.
|
32 |
+
'<a href="http://wordpress.org/support/view/plugin-reviews/yet-another-related-posts-plugin" target="_blank">'.
|
33 |
+
'<span class="icon icon-star '.$happy.'"></span> '.__('Review YARPP on WordPress.org', 'yarpp').
|
34 |
+
'</a>'.
|
35 |
+
'</li>'.
|
36 |
+
'</ul>';
|
37 |
+
|
38 |
+
echo $out;
|
39 |
+
}
|
40 |
+
}
|
classes/YARPP_Meta_Box_Display_Feed.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
|
4 |
+
public function display() {
|
5 |
+
global $yarpp;
|
6 |
+
|
7 |
+
echo "<div style='overflow:auto'>";
|
8 |
+
echo '<div class="rss_displayed yarpp_code_display"';
|
9 |
+
if ( !$yarpp->get_option('code_display') )
|
10 |
+
echo ' style="display: none;"';
|
11 |
+
echo '><b>' . __( "RSS display code example", 'yarpp' ) . '</b><br /><small>' . __( "(Update options to reload.)", 'yarpp' ) . "</small><br/><div id='display_demo_rss'></div></div>";
|
12 |
+
|
13 |
+
$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>", '' );
|
14 |
+
$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' );
|
15 |
+
|
16 |
+
$this->textbox( 'rss_limit', __( 'Maximum number of related posts:', 'yarpp' ), 2, 'rss_displayed' );
|
17 |
+
$this->template_checkbox( true, 'rss_displayed' );
|
18 |
+
echo "</div>";
|
19 |
+
|
20 |
+
$chosen_template = yarpp_get_option( "rss_template" );
|
21 |
+
$choice = false === $chosen_template ? 'builtin' :
|
22 |
+
( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
|
23 |
+
|
24 |
+
echo "<div class='postbox yarpp_subbox template_options_custom rss_displayed'";
|
25 |
+
if ( $choice != 'custom' )
|
26 |
+
echo ' style="display: none;"';
|
27 |
+
echo ">";
|
28 |
+
echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
|
29 |
+
$this->template_file( true );
|
30 |
+
echo "</div>";
|
31 |
+
|
32 |
+
echo "<div class='postbox yarpp_subbox template_options_thumbnails'";
|
33 |
+
if ( $choice != 'thumbnails' )
|
34 |
+
echo ' style="display: none;"';
|
35 |
+
echo ">";
|
36 |
+
$this->textbox( 'rss_thumbnails_heading', __( 'Heading:', 'yarpp' ), 40 );
|
37 |
+
$this->textbox( 'rss_thumbnails_default', __( 'Default image (URL):', 'yarpp' ), 40 );
|
38 |
+
$this->textbox( 'rss_no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_rss_no_results' );
|
39 |
+
echo "</div>";
|
40 |
+
|
41 |
+
echo "<div class='postbox yarpp_subbox template_options_builtin rss_displayed'";
|
42 |
+
if ( $choice != 'builtin' )
|
43 |
+
echo ' style="display: none;"';
|
44 |
+
echo ">";
|
45 |
+
$this->beforeafter( array( 'rss_before_related', 'rss_after_related' ), __( "Before / after related entries:", 'yarpp' ), 15, '', __( "For example:", 'yarpp' ) . ' <ol></ol>' . __( ' or ', 'yarpp' ) . '<div></div>' );
|
46 |
+
$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>' );
|
47 |
+
|
48 |
+
$this->checkbox( 'rss_show_excerpt', __( "Show excerpt?", 'yarpp' ), 'show_excerpt' );
|
49 |
+
$this->textbox( 'rss_excerpt_length', __( 'Excerpt length (No. of words):', 'yarpp' ), 10, 'excerpted' );
|
50 |
+
|
51 |
+
$this->beforeafter( array( 'rss_before_post', 'rss_after_post' ), __( "Before / after (excerpt):", 'yarpp' ), 10, 'excerpted', __( "For example:", 'yarpp' ) . ' <li></li>' . __( ' or ', 'yarpp' ) . '<dl></dl>' );
|
52 |
+
|
53 |
+
$this->textbox( 'rss_no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_rss_no_results' );
|
54 |
+
echo "</div>";
|
55 |
+
|
56 |
+
$this->displayorder( 'rss_order', 'rss_displayed' );
|
57 |
+
|
58 |
+
$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://www.yarpp.com' ) )."</code>" ) ) . "'> </span>", 'rss_displayed' );
|
59 |
+
}
|
60 |
+
}
|
classes/YARPP_Meta_Box_Display_Web.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
|
4 |
+
public function display() {
|
5 |
+
global $yarpp;
|
6 |
+
|
7 |
+
echo "<div style='overflow:auto'>";
|
8 |
+
echo '<div class="yarpp_code_display"';
|
9 |
+
if ( !$yarpp->get_option('code_display') )
|
10 |
+
echo ' style="display: none;"';
|
11 |
+
echo '><strong>' . __( "Website display code example", 'yarpp' ) . '</strong><br /><small>' . __( "(Update options to reload.)", 'yarpp' ) . "</small><br/><div id='display_demo_web'></div></div>";
|
12 |
+
|
13 |
+
echo "<div class='yarpp_form_row yarpp_form_post_types'><div>";
|
14 |
+
echo 'Automatically display related content from YARPP Basic on: ';
|
15 |
+
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> ";
|
16 |
+
echo "</div><div>";
|
17 |
+
$post_types = yarpp_get_option( 'auto_display_post_types' );
|
18 |
+
foreach ($yarpp->get_post_types('objects') as $post_type) {
|
19 |
+
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' ";
|
20 |
+
checked( in_array( $post_type->name, $post_types ) );
|
21 |
+
echo "/> {$post_type->labels->name}</label> ";
|
22 |
+
}
|
23 |
+
echo "</div></div>";
|
24 |
+
|
25 |
+
$this->checkbox( 'auto_display_archive', __( "Also display in archives", 'yarpp' ) );
|
26 |
+
|
27 |
+
$this->textbox( 'limit', __( 'Maximum number of related posts:', 'yarpp' ) );
|
28 |
+
$this->template_checkbox( false );
|
29 |
+
echo "</div>";
|
30 |
+
|
31 |
+
$chosen_template = yarpp_get_option( "template" );
|
32 |
+
$choice = false === $chosen_template ? 'builtin' :
|
33 |
+
( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
|
34 |
+
|
35 |
+
echo "<div class='postbox yarpp_subbox template_options_custom'";
|
36 |
+
if ( $choice != 'custom' )
|
37 |
+
echo ' style="display: none;"';
|
38 |
+
echo ">";
|
39 |
+
echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
|
40 |
+
$this->template_file( false );
|
41 |
+
echo "</div>";
|
42 |
+
|
43 |
+
echo "<div class='postbox yarpp_subbox template_options_thumbnails'";
|
44 |
+
if ( $choice != 'thumbnails' )
|
45 |
+
echo ' style="display: none;"';
|
46 |
+
echo ">";
|
47 |
+
$this->textbox( 'thumbnails_heading', __( 'Heading:', 'yarpp' ), 40 );
|
48 |
+
$this->textbox( 'thumbnails_default', __( 'Default image (URL):', 'yarpp' ), 40 );
|
49 |
+
$this->textbox( 'no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_no_results' );
|
50 |
+
echo "</div>";
|
51 |
+
|
52 |
+
echo "<div class='postbox yarpp_subbox template_options_builtin'";
|
53 |
+
if ( $choice != 'builtin' )
|
54 |
+
echo ' style="display: none;"';
|
55 |
+
echo ">";
|
56 |
+
$this->beforeafter( array( 'before_related', 'after_related' ), __( "Before / after related entries:", 'yarpp' ), 15, '', __( "For example:", 'yarpp' ) . ' <ol></ol>' . __( ' or ', 'yarpp' ) . '<div></div>' );
|
57 |
+
$this->beforeafter( array( 'before_title', 'after_title' ), __( "Before / after each related entry:", 'yarpp' ), 15, '', __( "For example:", 'yarpp' ) . ' <li></li>' . __( ' or ', 'yarpp' ) . '<dl></dl>' );
|
58 |
+
|
59 |
+
$this->checkbox( 'show_excerpt', __( "Show excerpt?", 'yarpp' ), 'show_excerpt' );
|
60 |
+
$this->textbox( 'excerpt_length', __( 'Excerpt length (No. of words):', 'yarpp' ), 10, 'excerpted' );
|
61 |
+
|
62 |
+
$this->beforeafter( array( 'before_post', 'after_post' ), __( "Before / after (excerpt):", 'yarpp' ), 10, 'excerpted', __( "For example:", 'yarpp' ) . ' <li></li>' . __( ' or ', 'yarpp' ) . '<dl></dl>' );
|
63 |
+
|
64 |
+
$this->textbox( 'no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_no_results' );
|
65 |
+
echo "</div>";
|
66 |
+
|
67 |
+
$this->displayorder( 'order' );
|
68 |
+
|
69 |
+
$this->checkbox( 'promote_yarpp', __( "Help promote Yet Another Related Posts Plugin?", 'yarpp' )
|
70 |
+
." <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://www.yarpp.com' ) ) . "</code>" ) ) ."'> </span>" );
|
71 |
+
}
|
72 |
+
}
|
classes/YARPP_Meta_Box_Optin.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class YARPP_Meta_Box_Optin extends YARPP_Meta_Box {
|
4 |
+
public function display() {
|
5 |
+
$output =
|
6 |
+
'<p>'.
|
7 |
+
'Enable the free <a href="http://www.yarpp.com" target="_blank">YARPP Pro enhancements</a> to add even '.
|
8 |
+
'more power to your blog or website!'.
|
9 |
+
'<br/><br/>'.
|
10 |
+
'<a href="'.plugins_url('/', dirname(__FILE__)).'includes/yarpp_switch.php" class="yarpp_switch_button button" data-go="pro">Turn them on now</a> '.
|
11 |
+
'<a href="http://www.yarpp.com" target="_blank" style="float:right;text-decoration:underline">Learn more</a>'.
|
12 |
+
'</p>'.
|
13 |
+
'<p>'.
|
14 |
+
'We can continue to improve the YARPP product for you if we know how it's used. Please help us by '.
|
15 |
+
'allowing usage data to be sent back.'.
|
16 |
+
'<br/>'.
|
17 |
+
'</p>'.
|
18 |
+
'<input
|
19 |
+
type="checkbox"
|
20 |
+
id="yarpp-optin"
|
21 |
+
name="optin"
|
22 |
+
value="true" '.
|
23 |
+
checked(yarpp_get_option('optin') == 1 ,true, false).' '.
|
24 |
+
'/>'.
|
25 |
+
'<label for="yarpp-optin">Send usage data back.</label>'.
|
26 |
+
'<a href="#" id="yarpp-optin-learnmore" style="float:right;text-decoration:underline">Learn More</a>'
|
27 |
+
;
|
28 |
+
echo $output;
|
29 |
+
}
|
30 |
+
}
|
classes/YARPP_Meta_Box_Pool.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class YARPP_Meta_Box_Pool extends YARPP_Meta_Box {
|
4 |
+
public function exclude($taxonomy, $string) {
|
5 |
+
global $yarpp;
|
6 |
+
|
7 |
+
echo "<div class='yarpp_form_row yarpp_form_exclude'><div class='yarpp_form_label'>";
|
8 |
+
echo $string;
|
9 |
+
echo "</div><div class='yarpp_scroll_wrapper'><div class='exclude_terms' id='exclude_{$taxonomy}'>";
|
10 |
+
|
11 |
+
$exclude_tt_ids = wp_parse_id_list( yarpp_get_option( 'exclude' ) );
|
12 |
+
$exclude_term_ids = $yarpp->admin->get_term_ids_from_tt_ids($taxonomy, $exclude_tt_ids);
|
13 |
+
if ( count( $exclude_term_ids ) ) {
|
14 |
+
$terms = get_terms( $taxonomy, array( 'include' => $exclude_term_ids ) );
|
15 |
+
foreach ( $terms as $term ) {
|
16 |
+
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> ";
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
echo "</div></div></div>";
|
21 |
+
}
|
22 |
+
|
23 |
+
public function display() {
|
24 |
+
global $yarpp;
|
25 |
+
$postTypeHelpMsg =
|
26 |
+
'If you don't want one of these post types to display as related content, '.
|
27 |
+
'uncheck the appropriate box in the “Display Options” panel below. Make sure you '.
|
28 |
+
'click the “Save Changes button” at the bottom of this page.';
|
29 |
+
|
30 |
+
include(YARPP_DIR.'/includes/phtmls/yarpp_meta_box_pool.phtml');
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
classes/YARPP_Meta_Box_Relatedness.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class YARPP_Meta_Box_Relatedness extends YARPP_Meta_Box {
|
4 |
+
public function display() {
|
5 |
+
global $yarpp;
|
6 |
+
?>
|
7 |
+
<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>
|
8 |
+
|
9 |
+
<?php
|
10 |
+
$this->textbox( 'threshold', __( 'Match threshold:', 'yarpp' ) );
|
11 |
+
$this->weight( 'title', __( "Titles: ", 'yarpp' ) );
|
12 |
+
$this->weight( 'body', __( "Bodies: ", 'yarpp' ) );
|
13 |
+
|
14 |
+
foreach ( $yarpp->get_taxonomies() as $taxonomy ) {
|
15 |
+
$this->tax_weight( $taxonomy );
|
16 |
+
}
|
17 |
+
|
18 |
+
$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>" );
|
19 |
+
$this->checkbox( 'past_only', __( "Show only previous posts?", 'yarpp' ) );
|
20 |
+
}
|
21 |
+
}
|
classes/YARPP_Meta_Boxes.php
DELETED
@@ -1,484 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class YARPP_Meta_Box {
|
4 |
-
protected $template_text = null;
|
5 |
-
|
6 |
-
function __construct() {
|
7 |
-
$this->template_text =
|
8 |
-
__(
|
9 |
-
"This advanced option gives you full power to customize how your related posts are displayed. ".
|
10 |
-
"Templates (stored in your theme folder) are written in PHP.",
|
11 |
-
'yarpp'
|
12 |
-
);
|
13 |
-
}
|
14 |
-
|
15 |
-
function checkbox($option, $desc, $class=null) {
|
16 |
-
$out =
|
17 |
-
"<div class='yarpp_form_row yarpp_form_checkbox $class'><div scope='row'>".
|
18 |
-
"<input type='checkbox' name='$option' id='yarpp-$option' value='true'".
|
19 |
-
checked(yarpp_get_option($option), true, false).
|
20 |
-
" /> <label for='yarpp-$option'>$desc</label></div></div>";
|
21 |
-
|
22 |
-
echo $out;
|
23 |
-
}
|
24 |
-
|
25 |
-
private function offer_copy_templates() {
|
26 |
-
global $yarpp;
|
27 |
-
return (!$yarpp->diagnostic_custom_templates() && $yarpp->admin->can_copy_templates());
|
28 |
-
}
|
29 |
-
|
30 |
-
public function template_checkbox($rss=false, $class=null) {
|
31 |
-
global $yarpp;
|
32 |
-
|
33 |
-
$pre = ($rss) ? 'rss_' : '';
|
34 |
-
$chosen_template = yarpp_get_option($pre."template");
|
35 |
-
$choice = ($chosen_template === false)
|
36 |
-
? 'builtin'
|
37 |
-
: (($chosen_template === 'thumbnails') ? 'thumbnails' : 'custom');
|
38 |
-
|
39 |
-
echo '<div class="yarpp_form_row yarpp_form_template_buttons '.$class.'">';
|
40 |
-
|
41 |
-
echo "<div data-value='builtin' class='yarpp_template_button";
|
42 |
-
if ($choice === 'builtin') echo ' active';
|
43 |
-
echo "'><div class='image'></div><div class='label'>" . __( 'List', 'yarpp' ) . "</div></div>";
|
44 |
-
|
45 |
-
echo "<div data-value='thumbnails' class='yarpp_template_button";
|
46 |
-
if ($choice === 'thumbnails') echo ' active';
|
47 |
-
if (!$yarpp->diagnostic_post_thumbnails()) echo ' disabled';
|
48 |
-
echo "'";
|
49 |
-
if (!$yarpp->diagnostic_post_thumbnails()) {
|
50 |
-
echo ' data-help="'.esc_attr(__('This option is disabled because your theme does not support post thumbnails.', 'yarpp')).'"';
|
51 |
-
}
|
52 |
-
echo "><div class='image'></div><div class='label'>".__('Thumbnails', 'yarpp')."</div></div>";
|
53 |
-
|
54 |
-
echo "<div data-value='custom' class='yarpp_template_button";
|
55 |
-
if ($choice === 'custom') echo ' active';
|
56 |
-
if (!$yarpp->diagnostic_custom_templates()) echo ' disabled';
|
57 |
-
echo "'";
|
58 |
-
if (!$yarpp->diagnostic_custom_templates()) {
|
59 |
-
$help = __('This option is disabled because no YARPP templates were found in your theme.', 'yarpp');
|
60 |
-
if ($this->offer_copy_templates()) {
|
61 |
-
$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'))."'/>";
|
62 |
-
}
|
63 |
-
echo " data-help='".esc_attr($help)."'";
|
64 |
-
}
|
65 |
-
echo "><div class='image'></div><div class='label'>".__('Custom', 'yarpp')."</div></div>";
|
66 |
-
|
67 |
-
echo "<input type='hidden' name='{$pre}use_template' id='yarpp-{$pre}use_template' class='use_template' value='{$choice}' />";
|
68 |
-
|
69 |
-
echo "</div>";
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
public function template_file($rss=false, $class=null) {
|
74 |
-
global $yarpp;
|
75 |
-
$pre = ($rss) ? 'rss_' : '';
|
76 |
-
|
77 |
-
echo "<div class='yarpp_form_row yarpp_form_template_file $class'><div class='yarpp_form_label'>";
|
78 |
-
_e("Template file:", 'yarpp');
|
79 |
-
echo "</div><div><select name='{$pre}template_file' id='{$pre}template_file'>";
|
80 |
-
|
81 |
-
$chosen_template = yarpp_get_option("{$pre}template");
|
82 |
-
foreach ($yarpp->get_templates() as $template) {
|
83 |
-
echo "<option value='".esc_attr($template['basename'])."'".selected($template['basename'], $chosen_template, false);
|
84 |
-
foreach ($template as $key => $value) {
|
85 |
-
echo " data-{$key}='".esc_attr($value)."'";
|
86 |
-
}
|
87 |
-
echo '>'.esc_html($template['name']).'</option>';
|
88 |
-
}
|
89 |
-
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>";
|
90 |
-
}
|
91 |
-
|
92 |
-
public function textbox($option, $desc, $size=2, $class=null, $note=null) {
|
93 |
-
$value = esc_attr(yarpp_get_option($option));
|
94 |
-
echo "<div class='yarpp_form_row yarpp_form_textbox $class'><div class='yarpp_form_label'>";
|
95 |
-
echo "{$desc}</div><div><input name='{$option}' type='text' id='{$option}' value='{$value}' size='{$size}' />";
|
96 |
-
if ($note) {
|
97 |
-
echo " <em><small>{$note}</small></em>";
|
98 |
-
}
|
99 |
-
echo "</div></div>";
|
100 |
-
}
|
101 |
-
|
102 |
-
public function beforeafter($options, $desc, $size=10, $class=null, $note=null) {
|
103 |
-
echo "<div class='yarpp_form_row yarpp_form_textbox {$class}'><div class='yarpp_form_label'>{$desc}</div><div>";
|
104 |
-
$value = esc_attr( yarpp_get_option( $options[0] ) );
|
105 |
-
echo "<input name='{$options[0]}' type='text' id='{$options[0]}' value='{$value}' size='{$size}' /> <span class='yarpp_divider'>/</span> ";
|
106 |
-
$value = esc_attr( yarpp_get_option( $options[1] ) );
|
107 |
-
echo "<input name='{$options[1]}' type='text' id='{$options[1]}' value='{$value}' size='{$size}' />";
|
108 |
-
if ($note){
|
109 |
-
echo " <em><small>{$note}</small></em>";
|
110 |
-
}
|
111 |
-
echo "</div></div>";
|
112 |
-
}
|
113 |
-
|
114 |
-
public function tax_weight($taxonomy) {
|
115 |
-
$weight = (int) yarpp_get_option("weight[tax][{$taxonomy->name}]");
|
116 |
-
$require = (int) yarpp_get_option("require_tax[{$taxonomy->name}]");
|
117 |
-
|
118 |
-
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}]'>";
|
119 |
-
echo "<option value='no'".((!$weight && !$require) ? ' selected="selected"': '' )." > ".__("do not consider", 'yarpp')."</option>";
|
120 |
-
echo "<option value='consider'".(($weight == 1 && !$require) ? ' selected="selected"': '' )." >".__("consider", 'yarpp')."</option>";
|
121 |
-
echo "<option value='consider_extra'".(($weight > 1 && !$require) ? ' selected="selected"': '' )." >".__("consider with extra weight", 'yarpp')."</option>";
|
122 |
-
echo "<option value='require_one'".(($require == 1) ? ' selected="selected"': '' )." >".sprintf(__("require at least one %s in common", 'yarpp'), $taxonomy->labels->singular_name)."</option>";
|
123 |
-
echo "<option value='require_more'".(($require == 2) ? ' selected="selected"': '' )." >".sprintf(__("require more than one %s in common", 'yarpp'), $taxonomy->labels->singular_name)."</option>";
|
124 |
-
echo "</select></div></div>";
|
125 |
-
}
|
126 |
-
|
127 |
-
public function weight($option, $desc) {
|
128 |
-
global $yarpp;
|
129 |
-
|
130 |
-
$weight = (int) yarpp_get_option("weight[$option]");
|
131 |
-
|
132 |
-
/* Both require MyISAM fulltext indexing: */
|
133 |
-
$fulltext = $yarpp->diagnostic_fulltext_disabled() ? ' readonly="readonly" disabled="disabled"' : '';
|
134 |
-
|
135 |
-
echo "<div class='yarpp_form_row yarpp_form_select'><div class='yarpp_form_label'>{$desc}</div><div>";
|
136 |
-
echo "<select name='weight[{$option}]'>";
|
137 |
-
echo "<option {$fulltext} value='no'".((!$weight) ? ' selected="selected"': '')." >".__("do not consider", 'yarpp')."</option>";
|
138 |
-
echo "<option {$fulltext} value='consider'".(($weight == 1) ? ' selected="selected"': '')." > ".__("consider", 'yarpp')."</option>";
|
139 |
-
echo "<option {$fulltext} value='consider_extra'".(($weight > 1) ? ' selected="selected"': '')." > ".__("consider with extra weight", 'yarpp')."</option>";
|
140 |
-
echo "</select></div></div>";
|
141 |
-
}
|
142 |
-
|
143 |
-
public function displayorder($option, $class=null) {
|
144 |
-
echo "<div class='yarpp_form_row yarpp_form_select $class'><div class='yarpp_form_label'>";
|
145 |
-
_e( "Order results:", 'yarpp' );
|
146 |
-
echo "</div><div><select name='$option' id='<?php echo $option; ?>'>";
|
147 |
-
$order = yarpp_get_option( $option );
|
148 |
-
?>
|
149 |
-
<option value="score DESC" <?php echo ( $order == 'score DESC'?' selected="selected"':'' )?>><?php _e( "score (high relevance to low)", 'yarpp' ); ?></option>
|
150 |
-
<option value="score ASC" <?php echo ( $order == 'score ASC'?' selected="selected"':'' )?>><?php _e( "score (low relevance to high)", 'yarpp' ); ?></option>
|
151 |
-
<option value="post_date DESC" <?php echo ( $order == 'post_date DESC'?' selected="selected"':'' )?>><?php _e( "date (new to old)", 'yarpp' ); ?></option>
|
152 |
-
<option value="post_date ASC" <?php echo ( $order == 'post_date ASC'?' selected="selected"':'' )?>><?php _e( "date (old to new)", 'yarpp' ); ?></option>
|
153 |
-
<option value="post_title ASC" <?php echo ( $order == 'post_title ASC'?' selected="selected"':'' )?>><?php _e( "title (alphabetical)", 'yarpp' ); ?></option>
|
154 |
-
<option value="post_title DESC" <?php echo ( $order == 'post_title DESC'?' selected="selected"':'' )?>><?php _e( "title (reverse alphabetical)", 'yarpp' ); ?></option>
|
155 |
-
<?php
|
156 |
-
echo "</select></div></div>";
|
157 |
-
}
|
158 |
-
}
|
159 |
-
|
160 |
-
class YARPP_Meta_Box_Pool extends YARPP_Meta_Box {
|
161 |
-
public function exclude($taxonomy, $string) {
|
162 |
-
global $yarpp;
|
163 |
-
|
164 |
-
echo "<div class='yarpp_form_row yarpp_form_exclude'><div class='yarpp_form_label'>";
|
165 |
-
echo $string;
|
166 |
-
echo "</div><div class='yarpp_scroll_wrapper'><div class='exclude_terms' id='exclude_{$taxonomy}'>";
|
167 |
-
|
168 |
-
$exclude_tt_ids = wp_parse_id_list( yarpp_get_option( 'exclude' ) );
|
169 |
-
$exclude_term_ids = $yarpp->admin->get_term_ids_from_tt_ids($taxonomy, $exclude_tt_ids);
|
170 |
-
if ( count( $exclude_term_ids ) ) {
|
171 |
-
$terms = get_terms( $taxonomy, array( 'include' => $exclude_term_ids ) );
|
172 |
-
foreach ( $terms as $term ) {
|
173 |
-
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> ";
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
echo "</div></div></div>";
|
178 |
-
}
|
179 |
-
|
180 |
-
public function display() {
|
181 |
-
global $yarpp;
|
182 |
-
|
183 |
-
echo "<p>";
|
184 |
-
_e( '"The Pool" refers to the pool of posts and pages that are candidates for display as related to the current entry.', 'yarpp' );
|
185 |
-
echo "</p>\n";
|
186 |
-
?>
|
187 |
-
<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>
|
188 |
-
|
189 |
-
<?php
|
190 |
-
foreach ($yarpp->get_taxonomies() as $taxonomy) {
|
191 |
-
$this->exclude( $taxonomy->name, sprintf( __( 'Disallow by %s:', 'yarpp' ), $taxonomy->labels->singular_name ) );
|
192 |
-
}
|
193 |
-
$this->checkbox( 'show_pass_post', __( "Show password protected posts?", 'yarpp' ) );
|
194 |
-
|
195 |
-
$recent = yarpp_get_option( 'recent' );
|
196 |
-
if ((bool) $recent) {
|
197 |
-
list( $recent_number, $recent_units ) = explode( ' ', $recent );
|
198 |
-
} else {
|
199 |
-
$recent_number = 12;
|
200 |
-
$recent_units = 'month';
|
201 |
-
}
|
202 |
-
$recent_number = "<input name=\"recent_number\" type=\"text\" id=\"recent_number\" value=\"".esc_attr( $recent_number )."\" size=\"2\" />";
|
203 |
-
$recent_units = "<select name=\"recent_units\" id=\"recent_units\">
|
204 |
-
<option value='day'" . ( ( 'day'==$recent_units) ? " selected='selected'" : '' ) . ">" . __( 'day(s)', 'yarpp' )."</option>
|
205 |
-
<option value='week'" . ( ( 'week'==$recent_units ) ? " selected='selected'" : '' ) . ">" . __( 'week(s)', 'yarpp' )."</option>
|
206 |
-
<option value='month'" . ( ( 'month'==$recent_units ) ? " selected='selected'" : '' ) . ">" . __( 'month(s)', 'yarpp' ) . "</option>
|
207 |
-
</select>";
|
208 |
-
|
209 |
-
echo "<div class='yarpp_form_row yarpp_form_checkbox'><div><input type='checkbox' name='recent_only' value='true'";
|
210 |
-
checked((bool) $recent);
|
211 |
-
echo " /> ";
|
212 |
-
echo str_replace( 'NUMBER', $recent_number, str_replace( 'UNITS', $recent_units, __( "Show only posts from the past NUMBER UNITS", 'yarpp' ) ) );
|
213 |
-
echo "</div></div>";
|
214 |
-
|
215 |
-
}
|
216 |
-
|
217 |
-
}/*end class*/
|
218 |
-
|
219 |
-
add_meta_box(
|
220 |
-
'yarpp_pool',
|
221 |
-
__( '"The Pool"', 'yarpp' ),
|
222 |
-
array(new YARPP_Meta_Box_Pool, 'display'),
|
223 |
-
'settings_page_yarpp',
|
224 |
-
'normal',
|
225 |
-
'core'
|
226 |
-
);
|
227 |
-
|
228 |
-
class YARPP_Meta_Box_Relatedness extends YARPP_Meta_Box {
|
229 |
-
function display() {
|
230 |
-
global $yarpp;
|
231 |
-
?>
|
232 |
-
<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>
|
233 |
-
|
234 |
-
<?php
|
235 |
-
$this->textbox( 'threshold', __( 'Match threshold:', 'yarpp' ) );
|
236 |
-
$this->weight( 'title', __( "Titles: ", 'yarpp' ) );
|
237 |
-
$this->weight( 'body', __( "Bodies: ", 'yarpp' ) );
|
238 |
-
|
239 |
-
foreach ( $yarpp->get_taxonomies() as $taxonomy ) {
|
240 |
-
$this->tax_weight( $taxonomy );
|
241 |
-
}
|
242 |
-
|
243 |
-
$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>" );
|
244 |
-
$this->checkbox( 'past_only', __( "Show only previous posts?", 'yarpp' ) );
|
245 |
-
}
|
246 |
-
}
|
247 |
-
|
248 |
-
add_meta_box( 'yarpp_relatedness', __( '"Relatedness" options', 'yarpp' ), array( new YARPP_Meta_Box_Relatedness, 'display' ), 'settings_page_yarpp', 'normal', 'core' );
|
249 |
-
|
250 |
-
class YARPP_Meta_Box_Display_Web extends YARPP_Meta_Box {
|
251 |
-
function display() {
|
252 |
-
global $yarpp;
|
253 |
-
|
254 |
-
echo "<div style='overflow:auto'>";
|
255 |
-
echo '<div class="yarpp_code_display"';
|
256 |
-
if ( !$yarpp->get_option('code_display') )
|
257 |
-
echo ' style="display: none;"';
|
258 |
-
echo '><strong>' . __( "Website display code example", 'yarpp' ) . '</strong><br /><small>' . __( "(Update options to reload.)", 'yarpp' ) . "</small><br/><div id='display_demo_web'></div></div>";
|
259 |
-
|
260 |
-
echo "<div class='yarpp_form_row yarpp_form_post_types'><div class='yarpp_form_label'>";
|
261 |
-
_e( "Automatically display:", 'yarpp' );
|
262 |
-
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>";
|
263 |
-
echo "</div><div>";
|
264 |
-
$post_types = yarpp_get_option( 'auto_display_post_types' );
|
265 |
-
foreach ( $yarpp->get_post_types( 'objects' ) as $post_type ) {
|
266 |
-
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' ";
|
267 |
-
checked( in_array( $post_type->name, $post_types ) );
|
268 |
-
echo "/> {$post_type->labels->name}</label> ";
|
269 |
-
}
|
270 |
-
echo "</div></div>";
|
271 |
-
|
272 |
-
$this->checkbox( 'auto_display_archive', __( "Also display in archives", 'yarpp' ) );
|
273 |
-
|
274 |
-
$this->textbox( 'limit', __( 'Maximum number of related posts:', 'yarpp' ) );
|
275 |
-
$this->template_checkbox( false );
|
276 |
-
echo "</div>";
|
277 |
-
|
278 |
-
$chosen_template = yarpp_get_option( "template" );
|
279 |
-
$choice = false === $chosen_template ? 'builtin' :
|
280 |
-
( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
|
281 |
-
|
282 |
-
echo "<div class='postbox yarpp_subbox template_options_custom'";
|
283 |
-
if ( $choice != 'custom' )
|
284 |
-
echo ' style="display: none;"';
|
285 |
-
echo ">";
|
286 |
-
echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
|
287 |
-
$this->template_file( false );
|
288 |
-
echo "</div>";
|
289 |
-
|
290 |
-
echo "<div class='postbox yarpp_subbox template_options_thumbnails'";
|
291 |
-
if ( $choice != 'thumbnails' )
|
292 |
-
echo ' style="display: none;"';
|
293 |
-
echo ">";
|
294 |
-
$this->textbox( 'thumbnails_heading', __( 'Heading:', 'yarpp' ), 40 );
|
295 |
-
$this->textbox( 'thumbnails_default', __( 'Default image (URL):', 'yarpp' ), 40 );
|
296 |
-
$this->textbox( 'no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_no_results' );
|
297 |
-
echo "</div>";
|
298 |
-
|
299 |
-
echo "<div class='postbox yarpp_subbox template_options_builtin'";
|
300 |
-
if ( $choice != 'builtin' )
|
301 |
-
echo ' style="display: none;"';
|
302 |
-
echo ">";
|
303 |
-
$this->beforeafter( array( 'before_related', 'after_related' ), __( "Before / after related entries:", 'yarpp' ), 15, '', __( "For example:", 'yarpp' ) . ' <ol></ol>' . __( ' or ', 'yarpp' ) . '<div></div>' );
|
304 |
-
$this->beforeafter( array( 'before_title', 'after_title' ), __( "Before / after each related entry:", 'yarpp' ), 15, '', __( "For example:", 'yarpp' ) . ' <li></li>' . __( ' or ', 'yarpp' ) . '<dl></dl>' );
|
305 |
-
|
306 |
-
$this->checkbox( 'show_excerpt', __( "Show excerpt?", 'yarpp' ), 'show_excerpt' );
|
307 |
-
$this->textbox( 'excerpt_length', __( 'Excerpt length (No. of words):', 'yarpp' ), 10, 'excerpted' );
|
308 |
-
|
309 |
-
$this->beforeafter( array( 'before_post', 'after_post' ), __( "Before / after (excerpt):", 'yarpp' ), 10, 'excerpted', __( "For example:", 'yarpp' ) . ' <li></li>' . __( ' or ', 'yarpp' ) . '<dl></dl>' );
|
310 |
-
|
311 |
-
$this->textbox( 'no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_no_results' );
|
312 |
-
echo "</div>";
|
313 |
-
|
314 |
-
$this->displayorder( 'order' );
|
315 |
-
|
316 |
-
$this->checkbox( 'promote_yarpp', __( "Help promote Yet Another Related Posts Plugin?", 'yarpp' )
|
317 |
-
." <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://www.yarpp.com' ) ) . "</code>" ) ) ."'> </span>" );
|
318 |
-
}
|
319 |
-
}
|
320 |
-
|
321 |
-
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' );
|
322 |
-
|
323 |
-
class YARPP_Meta_Box_Display_Feed extends YARPP_Meta_Box {
|
324 |
-
function display() {
|
325 |
-
global $yarpp;
|
326 |
-
|
327 |
-
echo "<div style='overflow:auto'>";
|
328 |
-
echo '<div class="rss_displayed yarpp_code_display"';
|
329 |
-
if ( !$yarpp->get_option('code_display') )
|
330 |
-
echo ' style="display: none;"';
|
331 |
-
echo '><b>' . __( "RSS display code example", 'yarpp' ) . '</b><br /><small>' . __( "(Update options to reload.)", 'yarpp' ) . "</small><br/><div id='display_demo_rss'></div></div>";
|
332 |
-
|
333 |
-
$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>", '' );
|
334 |
-
$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' );
|
335 |
-
|
336 |
-
$this->textbox( 'rss_limit', __( 'Maximum number of related posts:', 'yarpp' ), 2, 'rss_displayed' );
|
337 |
-
$this->template_checkbox( true, 'rss_displayed' );
|
338 |
-
echo "</div>";
|
339 |
-
|
340 |
-
$chosen_template = yarpp_get_option( "rss_template" );
|
341 |
-
$choice = false === $chosen_template ? 'builtin' :
|
342 |
-
( $chosen_template == 'thumbnails' ? 'thumbnails' : 'custom' );
|
343 |
-
|
344 |
-
echo "<div class='postbox yarpp_subbox template_options_custom rss_displayed'";
|
345 |
-
if ( $choice != 'custom' )
|
346 |
-
echo ' style="display: none;"';
|
347 |
-
echo ">";
|
348 |
-
echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
|
349 |
-
$this->template_file( true );
|
350 |
-
echo "</div>";
|
351 |
-
|
352 |
-
echo "<div class='postbox yarpp_subbox template_options_thumbnails'";
|
353 |
-
if ( $choice != 'thumbnails' )
|
354 |
-
echo ' style="display: none;"';
|
355 |
-
echo ">";
|
356 |
-
$this->textbox( 'rss_thumbnails_heading', __( 'Heading:', 'yarpp' ), 40 );
|
357 |
-
$this->textbox( 'rss_thumbnails_default', __( 'Default image (URL):', 'yarpp' ), 40 );
|
358 |
-
$this->textbox( 'rss_no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_rss_no_results' );
|
359 |
-
echo "</div>";
|
360 |
-
|
361 |
-
echo "<div class='postbox yarpp_subbox template_options_builtin rss_displayed'";
|
362 |
-
if ( $choice != 'builtin' )
|
363 |
-
echo ' style="display: none;"';
|
364 |
-
echo ">";
|
365 |
-
$this->beforeafter( array( 'rss_before_related', 'rss_after_related' ), __( "Before / after related entries:", 'yarpp' ), 15, '', __( "For example:", 'yarpp' ) . ' <ol></ol>' . __( ' or ', 'yarpp' ) . '<div></div>' );
|
366 |
-
$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>' );
|
367 |
-
|
368 |
-
$this->checkbox( 'rss_show_excerpt', __( "Show excerpt?", 'yarpp' ), 'show_excerpt' );
|
369 |
-
$this->textbox( 'rss_excerpt_length', __( 'Excerpt length (No. of words):', 'yarpp' ), 10, 'excerpted' );
|
370 |
-
|
371 |
-
$this->beforeafter( array( 'rss_before_post', 'rss_after_post' ), __( "Before / after (excerpt):", 'yarpp' ), 10, 'excerpted', __( "For example:", 'yarpp' ) . ' <li></li>' . __( ' or ', 'yarpp' ) . '<dl></dl>' );
|
372 |
-
|
373 |
-
$this->textbox( 'rss_no_results', __( 'Default display if no results:', 'yarpp' ), 40, 'sync_rss_no_results' );
|
374 |
-
echo "</div>";
|
375 |
-
|
376 |
-
$this->displayorder( 'rss_order', 'rss_displayed' );
|
377 |
-
|
378 |
-
$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://www.yarpp.com' ) )."</code>" ) ) . "'> </span>", 'rss_displayed' );
|
379 |
-
}
|
380 |
-
}
|
381 |
-
|
382 |
-
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');
|
383 |
-
|
384 |
-
class YARPP_Meta_Box_Contact extends YARPP_Meta_Box {
|
385 |
-
function display() {
|
386 |
-
global $yarpp;
|
387 |
-
|
388 |
-
$happy = ($yarpp->diagnostic_happy()) ? 'spin' : null;
|
389 |
-
|
390 |
-
$out =
|
391 |
-
'<ul class="yarpp_contacts">'.
|
392 |
-
'<li>'.
|
393 |
-
'<a href="http://wordpress.org/support/plugin/yet-another-related-posts-plugin" target="_blank">'.
|
394 |
-
'<span class="icon icon-wordpress"></span> '.__('YARPP Forum', 'yarpp').
|
395 |
-
'</a>'.
|
396 |
-
'</li>'.
|
397 |
-
'<li>'.
|
398 |
-
'<a href="http://twitter.com/yarpp" target="_blank">'.
|
399 |
-
'<span class="icon icon-twitter"></span> '.__('YARPP on Twitter', 'yarpp').
|
400 |
-
'</a>'.
|
401 |
-
'</li>'.
|
402 |
-
'<li>'.
|
403 |
-
'<a href="https://www.facebook.com/YARPPRecommendationEngine" target="_blank">'.
|
404 |
-
'<span class="icon icon-facebook"></span> YARPP on Facebook'.
|
405 |
-
'</a>'.
|
406 |
-
'</li>'.
|
407 |
-
'<li>'.
|
408 |
-
'<a href="http://www.yarpp.com" target="_blank">'.
|
409 |
-
'<span class="icon icon-pro"></span> Learn more about YARPP'.
|
410 |
-
'</a>'.
|
411 |
-
'</li>'.
|
412 |
-
'<li>'.
|
413 |
-
'<a href="http://wordpress.org/support/view/plugin-reviews/yet-another-related-posts-plugin" target="_blank">'.
|
414 |
-
'<span class="icon icon-star '.$happy.'"></span> '.__('Review YARPP on WordPress.org', 'yarpp').
|
415 |
-
'</a>'.
|
416 |
-
'</li>'.
|
417 |
-
'</ul>';
|
418 |
-
|
419 |
-
echo $out;
|
420 |
-
}/*end display*/
|
421 |
-
|
422 |
-
}/*end class yarpp_matabox_contact*/
|
423 |
-
|
424 |
-
add_meta_box(
|
425 |
-
'yarpp_display_optin',
|
426 |
-
'Get the Most Out of YARPP',
|
427 |
-
array(
|
428 |
-
new YARPP_Meta_Box_Optin,
|
429 |
-
'display'
|
430 |
-
),
|
431 |
-
'settings_page_yarpp',
|
432 |
-
'side',
|
433 |
-
'core'
|
434 |
-
);
|
435 |
-
|
436 |
-
// longest filter name ever
|
437 |
-
add_filter( "postbox_classes_settings_page_yarpp_yarpp_display_optin", 'yarpp_make_optin_classy' );
|
438 |
-
function yarpp_make_optin_classy( $classes ) {
|
439 |
-
if ( !yarpp_get_option( 'optin' ) )
|
440 |
-
$classes[] = 'yarpp_attention';
|
441 |
-
return $classes;
|
442 |
-
}
|
443 |
-
|
444 |
-
class YARPP_Meta_Box_Optin extends YARPP_Meta_Box {
|
445 |
-
function display() {
|
446 |
-
global $yarpp;
|
447 |
-
|
448 |
-
echo (
|
449 |
-
'<p>'.
|
450 |
-
'Enable the free <a href="http://www.yarpp.com" target="_blank">YARPP Pro enhancements</a> to add even '.
|
451 |
-
'more power to your blog or website!'.
|
452 |
-
'<br/><br/>'.
|
453 |
-
'<a href="'.plugins_url('/', dirname(__FILE__)).'includes/yarpp_switch.php" style="text-decoration:underline" class="yarpp_switch_button" data-go="pro">Turn them on now</a> '.
|
454 |
-
'<a href="http://www.yarpp.com" target="_blank" style="float:right;text-decoration:underline">Learn more</a>'.
|
455 |
-
'</p>'.
|
456 |
-
'<p>'.
|
457 |
-
'We can continue to improve the YARPP product for you if we know how it's used. Please help us by '.
|
458 |
-
'allowing usage data to be sent back.'.
|
459 |
-
'<br/>'.
|
460 |
-
'</p>'
|
461 |
-
);
|
462 |
-
|
463 |
-
echo (
|
464 |
-
'<input type="checkbox" id="yarpp-optin" name="optin" value="true" '.checked(yarpp_get_option('optin') == 1 ,true, false).'/>'.
|
465 |
-
'<label for="yarpp-optin">Send usage data back.</label>'.
|
466 |
-
'<a href="#" id="yarpp-optin-learnmore" style="float:right;text-decoration:underline">Learn More</a>'
|
467 |
-
);
|
468 |
-
|
469 |
-
}/*end display*/
|
470 |
-
|
471 |
-
}/*YARPP_Meta_Box_Optin*/
|
472 |
-
|
473 |
-
add_meta_box(
|
474 |
-
'yarpp_display_contact',
|
475 |
-
__('Contact YARPP', 'yarpp'),
|
476 |
-
array(new YARPP_Meta_Box_Contact, 'display'),
|
477 |
-
'settings_page_yarpp',
|
478 |
-
'side',
|
479 |
-
'core'
|
480 |
-
);
|
481 |
-
|
482 |
-
// since 3.3: hook for registering new YARPP meta boxes
|
483 |
-
do_action('add_meta_boxes_settings_page_yarpp');
|
484 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/YARPP_Widget.php
CHANGED
@@ -6,14 +6,14 @@
|
|
6 |
class YARPP_Widget extends WP_Widget {
|
7 |
|
8 |
public function __construct() {
|
9 |
-
parent::WP_Widget(false,
|
|
|
10 |
}
|
11 |
|
12 |
public function widget($args, $instance) {
|
13 |
-
|
14 |
-
|
15 |
-
if (!is_singular()) return;
|
16 |
|
|
|
17 |
extract($args);
|
18 |
|
19 |
/* Compatibility with pre-3.5 settings: */
|
@@ -30,158 +30,84 @@ class YARPP_Widget extends WP_Widget {
|
|
30 |
}
|
31 |
|
32 |
$title = apply_filters('widget_title', $instance['title']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
echo $before_title;
|
37 |
-
echo $title;
|
38 |
-
echo $after_title;
|
39 |
-
}
|
40 |
-
|
41 |
-
$instance['domain'] = 'widget';
|
42 |
-
$yarpp->display_related(null, $instance, true);
|
43 |
-
echo $after_widget;
|
44 |
}
|
45 |
|
46 |
public function update($new_instance, $old_instance) {
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
$choice = false === $instance['template'] ? 'builtin' :
|
60 |
-
( $instance['template'] == 'thumbnails' ? 'thumbnails' : 'custom' );
|
61 |
-
|
62 |
-
if ((bool) $instance['template'] ) // don't save the title change.
|
63 |
-
$instance['title'] = $old_instance['title'];
|
64 |
-
else // save the title change:
|
65 |
-
$instance['title'] = $new_instance['title'];
|
66 |
-
|
67 |
-
if ((bool) $instance['thumbnails_heading'] ) // don't save the title change.
|
68 |
-
$instance['thumbnails_heading'] = $old_instance['thumbnails_heading'];
|
69 |
-
else // save the title change:
|
70 |
-
$instance['thumbnails_heading'] = $new_instance['thumbnails_heading'];
|
71 |
|
72 |
return $instance;
|
73 |
}
|
74 |
|
75 |
public function form($instance) {
|
76 |
global $yarpp;
|
77 |
-
|
78 |
$instance = wp_parse_args(
|
79 |
$instance,
|
80 |
array(
|
81 |
-
'title' =>
|
82 |
'thumbnails_heading' => $yarpp->get_option('thumbnails_heading'),
|
83 |
'template' => false,
|
84 |
-
'
|
|
|
|
|
85 |
)
|
86 |
);
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
|
93 |
-
$choice = ($instance['template'] ===
|
94 |
-
? 'builtin'
|
95 |
-
: (($instance['template'] === 'thumbnails') ? 'thumbnails' : 'custom');
|
96 |
|
97 |
-
|
98 |
$templates = $yarpp->get_templates();
|
99 |
|
100 |
if (!$yarpp->diagnostic_custom_templates() && $choice === 'custom') $choice = 'builtin';
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
<p class='yarpp-widget-type-control'>
|
105 |
-
<label style="padding-right: 10px; display: inline-block;" for="<?php echo $this->get_field_id('use_template_builtin'); ?>">
|
106 |
-
<input id="<?php echo $this->get_field_id('use_template_builtin'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="radio" value="builtin" <?php checked($choice === 'builtin' ) ?>/>
|
107 |
-
<?php _e("List",'yarpp'); ?>
|
108 |
-
</label>
|
109 |
-
<br/>
|
110 |
-
<label style="padding-right: 10px; display: inline-block;" for="<?php echo $this->get_field_id('use_template_thumbnails'); ?>">
|
111 |
-
<input id="<?php echo $this->get_field_id('use_template_thumbnails'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="radio" value="thumbnails" <?php checked($choice === 'thumbnails') ?>/>
|
112 |
-
<?php _e("Thumbnails", 'yarpp'); ?>
|
113 |
-
</label>
|
114 |
-
<br/>
|
115 |
-
<label style="padding-right: 10px; display: inline-block;" for="<?php echo $this->get_field_id('use_template_custom'); ?>">
|
116 |
-
<input id="<?php echo $this->get_field_id('use_template_custom'); ?>" name="<?php echo $this->get_field_name('use_template'); ?>" type="radio" value="custom" <?php checked($choice === 'custom'); disabled(!count($templates)); ?>/>
|
117 |
-
<?php _e("Custom", 'yarpp'); ?>
|
118 |
-
</label>
|
119 |
-
</p>
|
120 |
-
|
121 |
-
<p>
|
122 |
-
<label for="<?php echo $this->get_field_id('title'); ?>">
|
123 |
-
<?php _e('Title:'); ?>
|
124 |
-
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>"/>
|
125 |
-
</label>
|
126 |
-
</p>
|
127 |
-
|
128 |
-
<p>
|
129 |
-
<label for="<?php echo $this->get_field_id('thumbnails_heading'); ?>">
|
130 |
-
<?php _e('Heading:', 'yarpp'); ?>
|
131 |
-
<input class="widefat" id="<?php echo $this->get_field_id('thumbnails_heading'); ?>" name="<?php echo $this->get_field_name('thumbnails_heading'); ?>" type="text" value="<?php echo esc_attr($instance['thumbnails_heading']); ?>"/>
|
132 |
-
</label>
|
133 |
-
</p>
|
134 |
-
|
135 |
-
<p>
|
136 |
-
<label for="<?php echo $this->get_field_id('template_file'); ?>">
|
137 |
-
<?php _e("Template file:",'yarpp');?>
|
138 |
-
</label>
|
139 |
-
<select name="<?php echo $this->get_field_name('template_file'); ?>" id="<?php echo $this->get_field_id('template_file'); ?>">
|
140 |
-
<?php foreach ($templates as $template): ?>
|
141 |
-
<option value='<?php echo esc_attr($template['basename']); ?>' <?php selected($template['basename'], $instance['template']);?>>
|
142 |
-
<?php echo esc_html($template['name']); ?>
|
143 |
-
</option>
|
144 |
-
<?php endforeach; ?>
|
145 |
-
</select>
|
146 |
-
<p>
|
147 |
-
|
148 |
-
<script type="text/javascript">
|
149 |
-
jQuery(function($) {
|
150 |
-
function ensureTemplateChoice(e) {
|
151 |
-
if (typeof e === 'object' && 'type' in e) {
|
152 |
-
e.stopImmediatePropagation();
|
153 |
-
}
|
154 |
-
|
155 |
-
var this_form = $(this).closest('form'),
|
156 |
-
widget_id = this_form.find('.widget-id').val();
|
157 |
-
|
158 |
-
// if this widget is just in staging:
|
159 |
-
if (/__i__#x2F;.test(widget_id)) return;
|
160 |
-
|
161 |
-
var builtin = !! $('#widget-'+widget_id+'-use_template_builtin').prop('checked'),
|
162 |
-
thumbnails = !! $('#widget-'+widget_id+'-use_template_thumbnails').prop('checked'),
|
163 |
-
custom = !! $('#widget-'+widget_id+'-use_template_custom').prop('checked');
|
164 |
-
|
165 |
-
$('#widget-' + widget_id + '-title').closest('p').toggle(builtin);
|
166 |
-
$('#widget-' + widget_id + '-thumbnails_heading').closest('p').toggle(thumbnails);
|
167 |
-
$('#widget-' + widget_id + '-template_file').closest('p').toggle(custom);
|
168 |
-
|
169 |
-
//console.log(widget_id, custom, builtin);
|
170 |
-
}
|
171 |
-
|
172 |
-
$('#wpbody').on('change', '.yarpp-widget-type-control input', ensureTemplateChoice);
|
173 |
-
$('.yarpp-widget-type-control').each(ensureTemplateChoice);
|
174 |
-
|
175 |
-
});
|
176 |
-
</script>
|
177 |
-
|
178 |
-
<p>
|
179 |
-
<input class="checkbox" id="<?php echo $this->get_field_id('promote_yarpp'); ?>" name="<?php echo $this->get_field_name('promote_yarpp'); ?>" type="checkbox" <?php checked($instance['promote_yarpp']) ?> />
|
180 |
-
<label for="<?php echo $this->get_field_id('promote_yarpp'); ?>">
|
181 |
-
<?php _e("Help promote Yet Another Related Posts Plugin?",'yarpp'); ?>
|
182 |
-
</label>
|
183 |
-
</p>
|
184 |
-
<?php
|
185 |
}
|
186 |
}
|
187 |
|
6 |
class YARPP_Widget extends WP_Widget {
|
7 |
|
8 |
public function __construct() {
|
9 |
+
parent::WP_Widget(false, 'Related Posts (YARPP)', array('description' => 'Related Posts and/or Sponsored Content'));
|
10 |
+
wp_enqueue_style('yarppWidgetCss', YARPP_URL.'/style/widget.css');
|
11 |
}
|
12 |
|
13 |
public function widget($args, $instance) {
|
14 |
+
if (!is_singular()) return;
|
|
|
|
|
15 |
|
16 |
+
global $yarpp;
|
17 |
extract($args);
|
18 |
|
19 |
/* Compatibility with pre-3.5 settings: */
|
30 |
}
|
31 |
|
32 |
$title = apply_filters('widget_title', $instance['title']);
|
33 |
+
$output = $before_widget;
|
34 |
+
if ($instance['use_pro']) {
|
35 |
+
if((isset($yarpp->yarppPro['active']) && $yarpp->yarppPro['active']) &&
|
36 |
+
(isset($yarpp->yarppPro['aid']) && isset($yarpp->yarppPro['v'])) &&
|
37 |
+
($yarpp->yarppPro['aid'] && $yarpp->yarppPro['v'])) {
|
38 |
+
|
39 |
+
$aid = $yarpp->yarppPro['aid'];
|
40 |
+
$v = $yarpp->yarppPro['v'];
|
41 |
+
$dpid = $instance['pro_dpid'];
|
42 |
+
$ru = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
43 |
+
|
44 |
+
/* TODO: Put this on a template */
|
45 |
+
$output .=
|
46 |
+
"\n".
|
47 |
+
'<div id="adkengage_ssp_div"></div>'.
|
48 |
+
'<script type="text/javascript" '.
|
49 |
+
'src="http://adkengage.com/pshandler.js?aid='.$aid.'&v='.$v.'&dpid='.$dpid.'&ru='.$ru.'">'.
|
50 |
+
'</script>'.
|
51 |
+
"\n";
|
52 |
+
}
|
53 |
+
} else {
|
54 |
+
if (!$instance['template']) {
|
55 |
+
$output .= $before_title;
|
56 |
+
$output .= $title;
|
57 |
+
$output .= $after_title;
|
58 |
+
}
|
59 |
+
$instance['domain'] = 'widget';
|
60 |
+
$output .= $yarpp->display_related(null, $instance, false);
|
61 |
+
}
|
62 |
|
63 |
+
$output .= $after_widget;
|
64 |
+
echo $output;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
public function update($new_instance, $old_instance) {
|
68 |
+
$instance = array(
|
69 |
+
'template' => false,
|
70 |
+
'title' => $new_instance['title'],
|
71 |
+
'thumbnails_heading' => $new_instance['thumbnails_heading'],
|
72 |
+
'use_pro' => (isset($new_instance['use_pro'])) ? $new_instance['use_pro'] : false,
|
73 |
+
'pro_dpid' => (isset($new_instance['pro_dpid'])) ? $new_instance['pro_dpid'] : null,
|
74 |
+
'promote_yarpp' => false,
|
75 |
+
);
|
76 |
+
|
77 |
+
if ($new_instance['use_template'] === 'thumbnails') $instance['template'] = 'thumbnails';
|
78 |
+
else if ($new_instance['use_template'] === 'custom' ) $instance['template'] = $new_instance['template_file'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
return $instance;
|
81 |
}
|
82 |
|
83 |
public function form($instance) {
|
84 |
global $yarpp;
|
85 |
+
$id = rtrim($this->get_field_id(null), '-');
|
86 |
$instance = wp_parse_args(
|
87 |
$instance,
|
88 |
array(
|
89 |
+
'title' => 'Related Posts (YARPP)',
|
90 |
'thumbnails_heading' => $yarpp->get_option('thumbnails_heading'),
|
91 |
'template' => false,
|
92 |
+
'use_pro' => false,
|
93 |
+
'pro_dpid' => null,
|
94 |
+
'promote_yarpp' => false,
|
95 |
)
|
96 |
);
|
97 |
|
98 |
+
/* TODO: Deprecate
|
99 |
+
* Compatibility with pre-3.5 settings
|
100 |
+
*/
|
101 |
+
if (isset($instance['use_template'])) $instance['template'] = $instance['template_file'];
|
102 |
|
103 |
+
$choice = ($instance['template']) ? (($instance['template'] === 'thumbnails') ? 'thumbnails' : 'custom') : 'builtin';
|
|
|
|
|
104 |
|
105 |
+
/* Check if YARPP templates are installed */
|
106 |
$templates = $yarpp->get_templates();
|
107 |
|
108 |
if (!$yarpp->diagnostic_custom_templates() && $choice === 'custom') $choice = 'builtin';
|
109 |
+
|
110 |
+
include(YARPP_DIR.'/includes/phtmls/yarpp_widget_form.phtml');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
}
|
112 |
}
|
113 |
|
includes/phtmls/yarpp_meta_box_beforeafter.phtml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="yarpp_form_row yarpp_form_textbox <?php echo $class ?>">
|
2 |
+
<div class="yarpp_form_label">
|
3 |
+
<?php echo $desc ?>
|
4 |
+
</div>
|
5 |
+
<div>
|
6 |
+
<?php $value = esc_attr(yarpp_get_option($options[0])) ?>
|
7 |
+
<input
|
8 |
+
name="<?php echo $options[0] ?>"
|
9 |
+
type="text"
|
10 |
+
id="<?php echo $options[0] ?>"
|
11 |
+
value="<?php echo $value ?>"
|
12 |
+
size="<?php echo $size ?>"
|
13 |
+
/>
|
14 |
+
<span class="yarpp_divider">/</span>
|
15 |
+
<?php $value = esc_attr(yarpp_get_option($options[1])) ?>
|
16 |
+
<input
|
17 |
+
name="<?php echo $options[1] ?>"
|
18 |
+
type="text"
|
19 |
+
id="<?php echo $options[1] ?>"
|
20 |
+
value="<?php echo $value ?>"
|
21 |
+
size="<?php echo $size ?>"
|
22 |
+
/>
|
23 |
+
<?php if($note): ?>
|
24 |
+
<em><small><?php echo $note ?></small></em>
|
25 |
+
<?php endif ?>
|
26 |
+
</div>
|
27 |
+
</div>
|
includes/phtmls/yarpp_meta_box_checkbox.phtml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="yarpp_form_row yarpp_form_checkbox <?php echo $class ?>">
|
2 |
+
<div scope="row">
|
3 |
+
<input
|
4 |
+
type="checkbox"
|
5 |
+
name="<?php echo $option ?>"
|
6 |
+
id="yarpp-<?php echo $option ?>"
|
7 |
+
value="true"
|
8 |
+
<?php checked(yarpp_get_option($option)) ?>
|
9 |
+
/>
|
10 |
+
<label for="yarpp-<?php echo $option ?>"><?php echo $desc ?></label>
|
11 |
+
</div>
|
12 |
+
</div>
|
includes/phtmls/yarpp_meta_box_pool.phtml
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
<?php
|
3 |
+
_e(
|
4 |
+
'"The Pool" refers to the pool of posts and pages that are candidates for display as related to the current entry.',
|
5 |
+
'yarpp'
|
6 |
+
)
|
7 |
+
?>
|
8 |
+
</p>
|
9 |
+
|
10 |
+
<?php
|
11 |
+
foreach ($yarpp->get_taxonomies() as $taxonomy) {
|
12 |
+
$this->exclude($taxonomy->name, sprintf(__('Disallow by %s:', 'yarpp'), $taxonomy->labels->singular_name));
|
13 |
+
}
|
14 |
+
$this->checkbox('show_pass_post', __('Show password protected posts?', 'yarpp'));
|
15 |
+
|
16 |
+
$recent = yarpp_get_option('recent');
|
17 |
+
if ((bool) $recent) {
|
18 |
+
list($recent_number, $recent_units) = explode(' ', $recent);
|
19 |
+
} else {
|
20 |
+
$recent_number = 12;
|
21 |
+
$recent_units = 'month';
|
22 |
+
}
|
23 |
+
|
24 |
+
$recent_number = '<input name="recent_number" type="text" id="recent_number" value="'.esc_attr($recent_number).'" size="2" />';
|
25 |
+
|
26 |
+
$recent_units =
|
27 |
+
'<select name="recent_units" id="recent_units" style="vertical-align:inherit">'.
|
28 |
+
'<option value="day" ' .(($recent_units === 'day') ? 'selected' : null).'>'.__('day(s)', 'yarpp').'</option>'.
|
29 |
+
'<option value="week" ' .(($recent_units === 'week') ? 'selected' : null).'>'.__('week(s)', 'yarpp').'</option>'.
|
30 |
+
'<option value="month" '.(($recent_units === 'month') ? 'selected' : null).'>'.__('month(s)', 'yarpp').'</option>'.
|
31 |
+
'</select>';
|
32 |
+
?>
|
33 |
+
|
34 |
+
<div class='yarpp_form_row yarpp_form_checkbox'>
|
35 |
+
<div>
|
36 |
+
<input type='checkbox' name='recent_only' value='true' <?php checked((bool) $recent) ?> />
|
37 |
+
<?php echo str_replace('NUMBER', $recent_number, str_replace('UNITS', $recent_units, __("Show only posts from the past NUMBER UNITS", 'yarpp'))); ?>
|
38 |
+
</div>
|
39 |
+
</div>
|
includes/phtmls/yarpp_meta_box_tax_weight.phtml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="yarpp_form_row yarpp_form_select">
|
2 |
+
<div class="yarpp_form_label">
|
3 |
+
<?php echo $taxonomy->labels->name ?>:
|
4 |
+
</div>
|
5 |
+
<div>
|
6 |
+
<select name=weight[tax][<?php echo $taxonomy->name ?>]">
|
7 |
+
<option value="no" <?php echo ((!$weight && !$require) ? 'selected' : null) ?> >
|
8 |
+
<?php _e("do not consider", "yarpp") ?>
|
9 |
+
</option>
|
10 |
+
<option value="consider" <?php echo (($weight == 1 && !$require) ? 'selected' : null) ?> >
|
11 |
+
<?php _e("consider", "yarpp") ?>
|
12 |
+
</option>
|
13 |
+
<option value="consider_extra" <?php echo (($weight > 1 && !$require) ? 'selected' : null) ?> >
|
14 |
+
<?php _e("consider with extra weight", "yarpp") ?>
|
15 |
+
</option>
|
16 |
+
<option value="require_one" <?php echo (($require == 1) ? 'selected' : null) ?>>
|
17 |
+
<?php echo sprintf(__("require at least one %s in common", "yarpp"), $taxonomy->labels->singular_name) ?>
|
18 |
+
</option>
|
19 |
+
<option value="require_more" <?php echo (($require == 2) ? 'selected' : null) ?>>
|
20 |
+
<?php echo sprintf(__("require more than one %s in common", "yarpp"), $taxonomy->labels->singular_name) ?>
|
21 |
+
</option>
|
22 |
+
</select>
|
23 |
+
</div>
|
24 |
+
</div>
|
includes/phtmls/yarpp_meta_box_template_checkbox.phtml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|