Yet Another Related Posts Plugin (YARPP) - Version 5.1.0

Version Description

(2019-07-10) = * Bugfix: Related Posts metabox did not load within Gutenberg Editor * Bugfix: Fixed 'Deactivate YARPP Pro' button, including moving functionality to proper WP AJAX functions * Enhancement: Related Post thumbnails should not be 'pinnable' to Pinterest * Enhancement: Review Notice * Enhancement: Modernized Editor Metabox design * Enhancement: Added 'Refresh' button to Editor Metabox

Download this release

Release Info

Developer jeffparker
Plugin Icon 128x128 Yet Another Related Posts Plugin (YARPP)
Version 5.1.0
Comparing to
See all releases

Code changes from version 5.0.1 to 5.1.0

classes/YARPP_Admin.php CHANGED
@@ -1,178 +1,298 @@
1
<?php
2
3
class YARPP_Admin {
4
- public $core;
5
- public $hook;
6
-
7
- function __construct(&$core) {
8
- $this->core = &$core;
9
-
10
- /* If action = flush and the nonce is correct, reset the cache */
11
- if (isset($_GET['action']) && $_GET['action'] === 'flush' && check_ajax_referer('yarpp_cache_flush', false, false) !== false) {
12
- $this->core->cache->flush();
13
- wp_redirect(admin_url('/options-general.php?page=yarpp'));
14
- die();
15
- }
16
-
17
- /* If action = copy_templates and the nonce is correct, copy templates */
18
- if (isset($_GET['action']) && $_GET['action'] === 'copy_templates' && check_ajax_referer('yarpp_copy_templates', false, false) !== false) {
19
- $this->copy_templates();
20
- wp_redirect(admin_url('/options-general.php?page=yarpp'));
21
- die();
22
- }
23
-
24
-
25
- add_action('admin_init', array($this, 'ajax_register'));
26
- add_action('admin_menu', array($this, 'ui_register'));
27
-
28
- add_filter('current_screen', array($this, 'settings_screen'));
29
- add_filter('screen_settings', array($this, 'render_screen_settings'), 10, 2);
30
- add_filter('default_hidden_meta_boxes', array($this, 'default_hidden_meta_boxes'), 10, 2);
31
- }
32
33
- /**
34
- * @since 4.0.3 Moved method to Core.
35
- */
36
- public function get_templates() {
37
- return $this->core->get_templates();
38
- }
39
40
- /**
41
- * Register AJAX services
42
- */
43
- function ajax_register() {
44
- if (defined('DOING_AJAX') && DOING_AJAX) {
45
- add_action('wp_ajax_yarpp_display_exclude_terms', array($this, 'ajax_display_exclude_terms'));
46
- add_action('wp_ajax_yarpp_display_demo', array($this, 'ajax_display_demo'));
47
- add_action('wp_ajax_yarpp_display', array($this, 'ajax_display'));
48
- add_action('wp_ajax_yarpp_optin_data', array($this, 'ajax_optin_data'));
49
- add_action('wp_ajax_yarpp_optin_enable', array($this, 'ajax_optin_enable'));
50
- add_action('wp_ajax_yarpp_optin_disable', array($this, 'ajax_optin_disable'));
51
- add_action('wp_ajax_yarpp_set_display_code', array($this, 'ajax_set_display_code'));
52
- }
53
- }
54
-
55
- function ui_register() {
56
- global $wp_version;
57
-
58
- if (get_option('yarpp_activated')) {
59
-
60
- delete_option('yarpp_activated');
61
- delete_option('yarpp_upgraded');
62
-
63
- /* Optin/Pro message */
64
- add_action('admin_notices', array($this, 'install_notice'));
65
-
66
- } elseif (get_option('yarpp_upgraded') && current_user_can('manage_options') && $this->core->get_option('optin')) {
67
- add_action('admin_notices', array($this, 'upgrade_notice'));
68
- }
69
-
70
- if ($this->core->get_option('optin')) delete_option('yarpp_upgraded');
71
-
72
- /*
73
- * Setup Admin
74
- */
75
- $titleName = 'YARPP';
76
- $this->hook = add_options_page($titleName, $titleName, 'manage_options', 'yarpp', array($this, 'options_page'));
77
-
78
- /**
79
- * @since 3.0.12 Add settings link to the plugins page.
80
- */
81
- add_filter('plugin_action_links', array($this, 'settings_link'), 10, 2);
82
-
83
- $metabox_post_types = $this->core->get_option('auto_display_post_types');
84
- if (!in_array('post', $metabox_post_types)) $metabox_post_types[] = 'post';
85
-
86
- /**
87
- * @since 3.0 Add meta box.
88
- */
89
- if(!$this->core->yarppPro['active']){
90
- foreach ($metabox_post_types as $post_type) {
91
- $optionsUrl = esc_url(admin_url('options-general.php?page=yarpp'));
92
- $title =
93
- __('Related Posts' , 'yarpp').
94
- '<span class="postbox-title-action">'.
95
- '<a href="'.$optionsUrl. '" class="edit-box open-box">'.__('Configure').'</a>'.
96
- '</span>';
97
- add_meta_box('yarpp_relatedposts',$title, array($this, 'metabox'), $post_type, 'normal');
98
- }
99
}
100
-
101
- /**
102
- * @since 3.3: properly enqueue scripts for admin.
103
- */
104
- add_action('admin_enqueue_scripts', array($this, 'enqueue'));
105
- }
106
-
107
- /**
108
- * @since 3.5.4 Only load metabox code if we're going to be on the settings page.
109
*/
110
- function settings_screen($current_screen) {
111
- if ($current_screen->id !== 'settings_page_yarpp') return $current_screen;
112
-
113
- /**
114
- * @since 3.3: Load options page sections as meta-boxes.
115
- */
116
- include_once(YARPP_DIR.'/includes/yarpp_meta_boxes_hooks.php');
117
-
118
- /**
119
- * @since 3.5.5 Check that add_help_tab method callable (WP >= 3.3).
120
- */
121
- if (is_callable(array($current_screen, 'add_help_tab'))) {
122
- $current_screen->add_help_tab(array(
123
- 'id' => 'faq',
124
- 'title' => __('Frequently Asked Questions', 'yarpp'),
125
- 'callback' => array(&$this, 'help_faq')
126
- ));
127
-
128
- $current_screen->add_help_tab(array(
129
- 'id' => 'dev',
130
- 'title' => __('Developing with YARPP', 'yarpp'),
131
- 'callback' => array(&$this, 'help_dev')
132
- ));
133
-
134
- $current_screen->add_help_tab(array(
135
- 'id' => 'optin',
136
- 'title' => __('Optional Data Collection', 'yarpp'),
137
- 'callback' => array(&$this, 'help_optin')
138
- ));
139
- }
140
-
141
- return $current_screen;
142
- }
143
-
144
- private $readme = null;
145
-
146
- public function help_faq() {
147
- if (is_null($this->readme)) $this->readme = file_get_contents(YARPP_DIR.'/readme.txt');
148
-
149
- if (preg_match('!== Frequently Asked Questions ==(.*?)^==!sm', $this->readme, $matches)) {
150
- echo $this->markdown($matches[1]);
151
} else {
152
- echo(
153
- '<a href="https://wordpress.org/extend/plugins/yet-another-related-posts-plugin/faq/">'.
154
__('Frequently Asked Questions', 'yarpp').
155
'</a>'
156
);
157
}
158
- }
159
-
160
- public function help_dev() {
161
- if (is_null($this->readme)) $this->readme = file_get_contents(YARPP_DIR.'/readme.txt');
162
163
- if (preg_match('!== Developing with YARPP ==(.*?)^==!sm', $this->readme, $matches)) {
164
- echo $this->markdown( $matches[1] );
165
} else {
166
- echo(
167
- '<a href="https://wordpress.org/extend/plugins/yet-another-related-posts-plugin/faq/" target="_blank">'.
168
__('Developing with YARPP', 'yarpp').
169
'</a>'
170
);
171
}
172
- }
173
174
- public function help_optin() {
175
- echo(
176
'<p>'.
177
__("With your permission, YARPP will send information about YARPP's settings, usage, and environment
178
back to a central server at ", 'yarpp').'<code>yarpp.org</code>'.'.&nbsp;'.
@@ -182,115 +302,111 @@ class YARPP_Admin {
182
'for country, domain, and date installed information.'.
183
'</p>'.
184
'<p>'.
185
- __("This information will be used to improve YARPP in the future and help decide future development
186
- decisions for YARPP.",
187
'yarpp'
188
).' '.
189
'</p>'.
190
'<p>'.
191
- '<strong>'.
192
__("Contributing this data will help make YARPP better for you and for other YARPP users.",
193
'yarpp' ).'</strong>'.
194
'</p>'
195
);
196
-
197
- echo(
198
'<p>'.
199
__("The following information is sent back to YARPP:", 'yarpp').
200
'</p>'.
201
- '<div id="optin_data_frame"></div>'.
202
'<p>'.
203
__("In addition, YARPP also loads an invisible pixel image with your YARPP results to know how often YARPP is being used.", 'yarpp').
204
'</p>'
205
);
206
- }
207
-
208
- function the_optin_button($action, $echo = false) {
209
-
210
- $status = ($this->core->yarppPro['active']) ? 'disabled' : null;
211
-
212
- if ($action === 'disable'){
213
- $out =
214
- '<a id="yarpp-optin-button'.$status.'" class="button" '.$status.'>'.
215
- 'No, Thanks. Please <strong>'.$action.'</strong> sending usage data'.
216
'</a>';
217
- } else {
218
- $out =
219
- '<a id="yarpp-optin-button'.$status.'" class="button" '.$status.'>'.
220
- 'Yes, <strong>'.$action.'</strong> sending usage data back to help improve YARPP'.
221
'</a>';
222
- }
223
-
224
- if ($echo){
225
- echo $out;
226
- return null;
227
- } else {
228
- return $out;
229
- }
230
- }
231
-
232
- function the_donothing_button($msg, $echo = false) {
233
-
234
- $out ='<a href="options-general.php?page=yarpp" class="button">'.$msg.'</a>';
235
-
236
- if ($echo){
237
- echo $out;
238
- return null;
239
- } else {
240
- return $out;
241
- }
242
- }
243
-
244
- function optin_button_script($optinAction, $echo=false) {
245
- wp_nonce_field('yarpp_optin_'.$optinAction, 'yarpp_optin-nonce', false);
246
-
247
- ob_start();
248
- include(YARPP_DIR.'/includes/optin_notice.js.php');
249
- $out = ob_get_contents();
250
- ob_end_clean();
251
-
252
- if($echo){
253
- echo $out;
254
- return null;
255
- } else {
256
- return $out;
257
- }
258
-
259
- }
260
-
261
- function upgrade_notice() {
262
- $optinAction = ($this->core->get_option('optin')) ? 'disable' : 'enable';
263
- $this->optin_notice('upgrade', $optinAction);
264
}
265
266
- public function install_notice(){
267
- $optinAction = ($this->core->get_option('optin')) ? 'disable' : 'enable';
268
- $this->optin_notice('install', $optinAction);
269
}
270
271
- public function optin_notice($type=false, $optinAction) {
272
- $screen = get_current_screen();
273
- if(is_null($screen) || $screen->id == 'settings_page_yarpp') return;
274
-
275
- switch($type) {
276
- case 'upgrade':
277
- delete_option('yarpp_upgraded');
278
- break;
279
- case 'install':
280
- default:
281
- $user = get_current_user_id();
282
- update_user_option($user, 'yarpp_saw_optin', true);
283
- }
284
-
285
- $out = '<div class="updated fade"><p>';
286
287
- if($type === 'upgrade'){
288
- $out .= '<strong>'.sprintf(__('%1$s updated successfully.'), 'Yet Another Related Posts Plugin').'</strong>';
289
}
290
291
- if ($type === 'install'){
292
$tmp = __('Thank you for installing <span>Yet Another Related Posts Plugin</span>!', 'yarpp');
293
- $out .= '<strong>'.str_replace('<span>','<span style="font-style:italic; font-weight: inherit;">', $tmp).'</strong>';
294
}
295
296
if($this->core->yarppPro['active']){
@@ -315,278 +431,324 @@ class YARPP_Admin {
315
}
316
317
echo $out.'</div>';
318
- }
319
-
320
- // faux-markdown, required for the help text rendering
321
- protected function markdown( $text ) {
322
- $replacements = array(
323
- // strip each line
324
- '!\s*[\r\n] *!' => "\n",
325
-
326
- // headers
327
- '!^=(.*?)=\s*$!m' => '<h3>\1</h3>',
328
-
329
- // bullets
330
- '!^(\* .*([\r\n]\* .*)*)$!m' => "<ul>\n\\1\n</ul>",
331
- '!^\* (.*?)$!m' => '<li>\1</li>',
332
- '!^(\d+\. .*([\r\n]\d+\. .*)*)$!m' => "<ol>\n\\1\n</ol>",
333
- '!^\d+\. (.*?)$!m' => '<li>\1</li>',
334
-
335
- // code block
336
- '!^(\t.*([\r\n]\t.*)*)$!m' => "<pre>\n\\1\n</pre>",
337
-
338
- // wrap p
339
- '!^([^<\t].*[^>])$!m' => '<p>\1</p>',
340
- // bold
341
- '!\*([^*]*?)\*!' => '<strong>\1</strong>',
342
- // code
343
- '!`([^`]*?)`!' => '<code>\1</code>',
344
- // links
345
- '!\[([^]]+)\]\(([^)]+)\)!' => '<a href="\2" target="_new">\1</a>',
346
- );
347
- $text = preg_replace(array_keys($replacements), array_values($replacements), $text);
348
-
349
- return $text;
350
- }
351
-
352
- public function render_screen_settings ($output, $current_screen) {
353
- if ( $current_screen->id != 'settings_page_yarpp' )
354
- return $output;
355
-
356
- $output .= "<div id='yarpp_extra_screen_settings'><label for='yarpp_display_code'><input type='checkbox' name='yarpp_display_code' id='yarpp_display_code'";
357
- $output .= checked($this->core->get_option('display_code'), true, false);
358
- $output .= " />";
359
- $output .= __('Show example code output', 'yarpp');
360
- $output .= '</label></div>';
361
-
362
- return $output;
363
- }
364
-
365
- // since 3.3
366
- public function enqueue() {
367
- $version = defined('WP_DEBUG') && WP_DEBUG ? time() : YARPP_VERSION;
368
- $screen = get_current_screen();
369
- if (!is_null($screen) && $screen->id === 'settings_page_yarpp') {
370
-
371
- wp_enqueue_style('yarpp_switch_options', plugins_url('style/options_switch.css', dirname(__FILE__)), array(), $version );
372
- wp_enqueue_script('yarpp_switch_options', plugins_url('js/options_switch.js', dirname(__FILE__)), array('jquery'), $version );
373
-
374
- wp_enqueue_style('wp-pointer');
375
- wp_enqueue_style('yarpp_options', plugins_url('style/options_basic.css', dirname(__FILE__)), array(), $version );
376
-
377
- wp_enqueue_script('postbox');
378
- wp_enqueue_script('wp-pointer');
379
- wp_enqueue_script('yarpp_options', plugins_url('js/options_basic.js', dirname(__FILE__)), array('jquery'), $version );
380
-
381
- }
382
-
383
- $metabox_post_types = $this->core->get_option('auto_display_post_types');
384
- if (!is_null($screen) && ($screen->id == 'post' || in_array( $screen->id, $metabox_post_types))) {
385
- wp_enqueue_script('yarpp_metabox', plugins_url('js/metabox.js', dirname(__FILE__)), array('jquery'), $version );
386
- }
387
- }
388
-
389
- public function settings_link($links, $file) {
390
- $this_plugin = dirname(plugin_basename(dirname(__FILE__))).'/yarpp.php';
391
- if($file == $this_plugin) {
392
- $links[] = '<a href="options-general.php?page=yarpp">'.__('Settings').'</a>';
393
- }
394
- return $links;
395
- }
396
-
397
- public function options_page() {
398
- $mode = (isset($_GET['mode'])) ? htmlentities(strtolower($_GET['mode'])) : null;
399
- if ($mode !== 'basic' && ($mode === 'pro' || $this->core->yarppPro['active'])){
400
- include_once(YARPP_DIR.'/includes/yarpp_pro_options.php');
401
} else {
402
- include_once(YARPP_DIR . '/includes/yarpp_options.php');
403
}
404
- }
405
-
406
- // @since 3.4: don't actually compute results here, but use ajax instead
407
- public function metabox() {
408
- ?>
409
- <style>
410
- #yarpp_relatedposts h3 .postbox-title-action {
411
- right: 30px;
412
- top: 5px;
413
- position: absolute;
414
- padding: 0;
415
- }
416
- #yarpp_relatedposts:hover .edit-box {
417
- display: inline;
418
- }
419
- </style>
420
- <?php
421
- if ( !get_the_ID() ) {
422
- echo "<div><p>".__("Related entries may be displayed once you save your entry",'yarpp').".</p></div>";
423
- } else {
424
- wp_nonce_field( 'yarpp_display', 'yarpp_display-nonce', false );
425
- echo '<div id="yarpp-related-posts"><img src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" alt="" /></div>';
426
- }
427
- }
428
-
429
- // @since 3.3: default metaboxes to show:
430
- public function default_hidden_meta_boxes($hidden, $screen) {
431
- if ($screen->id === 'settings_page_yarpp') {
432
- $hidden = $this->core->default_hidden_metaboxes;
433
- }
434
- return $hidden;
435
- }
436
-
437
- // @since 4: UI to copy templates
438
- public function can_copy_templates() {
439
- $theme_dir = get_stylesheet_directory();
440
- // If we can't write to the theme, return false
441
- if (!is_dir($theme_dir) || !is_writable($theme_dir)) return false;
442
-
443
- require_once(ABSPATH.'wp-admin/includes/file.php');
444
- WP_Filesystem(false, get_stylesheet_directory());
445
- global $wp_filesystem;
446
- // direct method is the only method that I've tested so far
447
- return $wp_filesystem->method === 'direct';
448
- }
449
-
450
- public function copy_templates() {
451
- $templates_dir = trailingslashit(trailingslashit(YARPP_DIR).'yarpp-templates');
452
-
453
- require_once(ABSPATH.'wp-admin/includes/file.php');
454
- WP_Filesystem(false, get_stylesheet_directory());
455
- global $wp_filesystem;
456
- if ( $wp_filesystem->method !== 'direct') return false;
457
-
458
- return copy_dir($templates_dir, get_stylesheet_directory(), array('.svn'));
459
- }
460
-
461
- /*
462
- * AJAX SERVICES
463
- */
464
-
465
- public function ajax_display_exclude_terms() {
466
- check_ajax_referer('yarpp_display_exclude_terms');
467
-
468
- if (!isset($_REQUEST['taxonomy'])) return;
469
-
470
- $taxonomy = (string) $_REQUEST['taxonomy'];
471
-
472
- header("HTTP/1.1 200");
473
- header("Content-Type: text/html; charset=UTF-8");
474
-
475
- $exclude_tt_ids = wp_parse_id_list($this->core->get_option('exclude'));
476
- $exclude_term_ids = $this->get_term_ids_from_tt_ids( $taxonomy, $exclude_tt_ids );
477
- // if ('category' === $taxonomy) $exclude .= ','.get_option('default_category');
478
-
479
- $terms = get_terms($taxonomy, array(
480
- 'exclude' => $exclude_term_ids,
481
- 'hide_empty' => false,
482
- 'hierarchical' => false,
483
- 'number' => 100,
484
- 'offset' => $_REQUEST['offset']
485
- ));
486
-
487
- if ( !count($terms) ) {
488
- echo ':('; // no more :(
489
- exit;
490
- }
491
-
492
- foreach ($terms as $term) {
493
- echo "<span><input type='checkbox' name='exclude[{$term->term_taxonomy_id}]' id='exclude_{$term->term_taxonomy_id}' value='true' /> <label for='exclude_{$term->term_taxonomy_id}'>" . esc_html($term->name) . "</label></span> ";
494
- }
495
- exit;
496
- }
497
-
498
- public function get_term_ids_from_tt_ids( $taxonomy, $tt_ids ) {
499
- global $wpdb;
500
- $tt_ids = wp_parse_id_list($tt_ids);
501
- if ( empty($tt_ids) )
502
- return array();
503
- return $wpdb->get_col("select term_id from $wpdb->term_taxonomy where taxonomy = '{$taxonomy}' and term_taxonomy_id in (" . join(',', $tt_ids) . ")");
504
- }
505
-
506
- public function ajax_display() {
507
- check_ajax_referer('yarpp_display');
508
-
509
- if (!isset($_REQUEST['ID'])) return;
510
-
511
- $args = array(
512
- 'post_type' => array('post'),
513
- 'domain' => isset($_REQUEST['domain']) ? $_REQUEST['domain'] : 'website'
514
- );
515
-
516
- if ($this->core->get_option('cross_relate')) $args['post_type'] = $this->core->get_post_types();
517
-
518
- $return = $this->core->display_related(absint($_REQUEST['ID']), $args, false);
519
-
520
- header("HTTP/1.1 200");
521
- header("Content-Type: text/html; charset=UTF-8");
522
- echo $return;
523
-
524
- die();
525
- }
526
-
527
- public function ajax_display_demo() {
528
- check_ajax_referer('yarpp_display_demo');
529
-
530
- header("HTTP/1.1 200");
531
- header("Content-Type: text/html; charset=UTF-8");
532
-
533
- $args = array(
534
- 'post_type' => array('post'),
535
- 'domain' => (isset($_REQUEST['domain'])) ? $_REQUEST['domain'] : 'website'
536
- );
537
-
538
- $return = $this->core->display_demo_related($args, false);
539
- echo preg_replace("/[\n\r]/",'',nl2br(htmlspecialchars($return)));
540
- exit;
541
- }
542
543
- /**
544
- * Display optin data in a human readable format on the help tab.
545
- */
546
- public function ajax_optin_data() {
547
- check_ajax_referer('yarpp_optin_data');
548
-
549
- header("HTTP/1.1 200");
550
- header("Content-Type: text/html; charset=UTF-8");
551
-
552
- $data = $this->core->optin_data();
553
- $this->core->pretty_echo($data);
554
- die();
555
- }
556
-
557
- public function ajax_optin_disable() {
558
- check_ajax_referer('yarpp_optin_disable');
559
-
560
- $this->core->set_option('optin', false);
561
562
header("HTTP/1.1 200");
563
- header("Content-Type: text; charset=UTF-8");
564
- echo 'ok';
565
-
566
- die();
567
}
568
569
- public function ajax_optin_enable() {
570
- check_ajax_referer('yarpp_optin_enable');
571
-
572
- $this->core->set_option('optin', true);
573
- $this->core->optin_ping();
574
-
575
- header("HTTP/1.1 200");
576
- header("Content-Type: text; charset=UTF-8");
577
- echo 'ok';
578
-
579
- die();
580
- }
581
-
582
- public function ajax_set_display_code() {
583
- check_ajax_referer( 'yarpp_set_display_code' );
584
-
585
- header("HTTP/1.1 200");
586
- header("Content-Type: text; charset=UTF-8");
587
-
588
- $data = $this->core->set_option( 'display_code', isset($_REQUEST['checked']) );
589
- echo 'ok';
590
- die();
591
- }
592
}
1
<?php
2
3
class YARPP_Admin {
4
+ public $core;
5
+ public $hook;
6
+
7
+ const ACTIVATE_TIMESTAMP_OPTION = 'yarpp_activate_timestamp';
8
+ const REVIEW_DISMISS_OPTION = 'yarpp_review_notice';
9
+ const REVIEW_FIRST_PERIOD = 604800; // 7 days in seconds
10
+ const REVIEW_LATER_PERIOD = 5184000; // 60 days in seconds
11
+ const REVIEW_FOREVER_PERIOD = 63113904; // 2 years in seconds
12
+
13
+ function __construct(&$core) {
14
+ $this->core = &$core;
15
+
16
+ /* If action = flush and the nonce is correct, reset the cache */
17
+ if (isset($_GET['action']) && $_GET['action'] === 'flush' && check_ajax_referer('yarpp_cache_flush', false, false) !== false) {
18
+ $this->core->cache->flush();
19
+ wp_redirect(admin_url('/options-general.php?page=yarpp'));
20
+ die();
21
+ }
22
23
+ /* If action = copy_templates and the nonce is correct, copy templates */
24
+ if (isset($_GET['action']) && $_GET['action'] === 'copy_templates' && check_ajax_referer('yarpp_copy_templates', false, false) !== false) {
25
+ $this->copy_templates();
26
+ wp_redirect(admin_url('/options-general.php?page=yarpp'));
27
+ die();
28
+ }
29
30
+ add_action('admin_init', array($this, 'ajax_register'));
31
+ add_action('admin_init', array($this, 'review_register'));
32
+ add_action('admin_menu', array($this, 'ui_register'));
33
+
34
+ add_filter('current_screen', array($this, 'settings_screen'));
35
+ add_filter('screen_settings', array($this, 'render_screen_settings'), 10, 2);
36
+ add_filter('default_hidden_meta_boxes', array($this, 'default_hidden_meta_boxes'), 10, 2);
37
+ }
38
+
39
+ /**
40
+ * @since 4.0.3 Moved method to Core.
41
+ */
42
+ public function get_templates() {
43
+ return $this->core->get_templates();
44
+ }
45
+
46
+ /**
47
+ * Register Review notice
48
+ */
49
+ function review_register() {
50
+ self::check_review_dismissal();
51
+ self::check_plugin_review();
52
+ }
53
+
54
+ /**
55
+ * Register AJAX services
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
+ add_action('wp_ajax_yarpp_switch', array($this, 'ajax_switch'));
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Check review notice status for current user
72
+ *
73
+ * @since 5.1.0
74
+ */
75
+ public static function check_review_dismissal() {
76
+
77
+ global $current_user;
78
+ $user_id = $current_user->ID;
79
+
80
+ if (!is_admin() ||
81
+ !current_user_can('edit_posts') ||
82
+ !isset($_GET['_wpnonce']) ||
83
+ !wp_verify_nonce($_GET['_wpnonce'], 'review-nonce') ||
84
+ !isset($_GET['yarpp_defer_t']) ||
85
+ !isset($_GET[self::REVIEW_DISMISS_OPTION])) {
86
+ return;
87
+ }
88
+
89
+ $the_meta_array = array (
90
+ 'dismiss_defer_period' => $_GET["yarpp_defer_t"],
91
+ 'dismiss_timestamp' => time()
92
+ );
93
+
94
+ update_user_meta($user_id, self::REVIEW_DISMISS_OPTION, $the_meta_array);
95
+ }
96
+
97
+ /**
98
+ * Check if we should display the review notice
99
+ *
100
+ * @since 5.1.0
101
+ */
102
+ public static function check_plugin_review() {
103
+
104
+ global $current_user;
105
+ $user_id = $current_user->ID;
106
+
107
+ $show_review_notice = false;
108
+ $activation_timestamp = get_site_option(self::ACTIVATE_TIMESTAMP_OPTION);
109
+ $review_dismissal_array = get_user_meta($user_id, self::REVIEW_DISMISS_OPTION, true);
110
+ $dismiss_defer_period = isset($review_dismissal_array['dismiss_defer_period']) ? $review_dismissal_array['dismiss_defer_period'] : 0;
111
+ $dismiss_timestamp = isset($review_dismissal_array['dismiss_timestamp']) ? $review_dismissal_array['dismiss_timestamp'] : time();
112
+
113
+ if ($dismiss_timestamp + $dismiss_defer_period <= time()) {
114
+ $show_review_notice = true;
115
+ }
116
+
117
+ if (!$activation_timestamp) {
118
+ $activation_timestamp = time();
119
+ add_site_option(self::ACTIVATE_TIMESTAMP_OPTION, $activation_timestamp);
120
+ }
121
+
122
+ // display review message after a certain period of time after activation
123
+ if ((time() - $activation_timestamp > self::REVIEW_FIRST_PERIOD) && $show_review_notice == true) {
124
+ add_action('admin_notices', array('YARPP_Admin', 'display_review_notice'));
125
+ }
126
+ }
127
+
128
+ /**
129
+ * @since 5.1.0
130
+ */
131
+ public static function display_review_notice() {
132
+
133
+ $dismiss_forever = add_query_arg( array(
134
+ self::REVIEW_DISMISS_OPTION => true,
135
+ 'yarpp_defer_t' => self::REVIEW_FOREVER_PERIOD
136
+ ));
137
+
138
+ $dismiss_forlater = add_query_arg( array(
139
+ self::REVIEW_DISMISS_OPTION => true,
140
+ 'yarpp_defer_t' => self::REVIEW_LATER_PERIOD
141
+ ));
142
+
143
+ $dismiss_forever_url = wp_nonce_url($dismiss_forever, 'review-nonce');
144
+ $dismiss_forlater_url = wp_nonce_url($dismiss_forlater, 'review-nonce');
145
+
146
+ echo '
147
+ <style>
148
+ .yarpp-review-notice {
149
+ background-size: contain; background-position: right bottom; background-repeat: no-repeat; background-image: url(' . plugins_url('../images/icon-256x256.png', __FILE__) . ');
150
+ }
151
+ .yarpp-review-notice-text {
152
+ background: rgba(255, 255, 255, 0.9); text-shadow: white 0px 0px 10px; margin-right: 8em !important;
153
}
154
+
155
+ @media only screen and (max-width: 782px) {
156
+ .yarpp-review-notice-text {
157
+ margin-right: 12em !important;
158
+ }
159
+ }
160
+ @media screen and (max-width: 580px) {
161
+ .yarpp-review-notice {
162
+ background: #ffffff;
163
+ }
164
+ .yarpp-review-notice-text {
165
+ margin-right: 0 !important;
166
+ }
167
+ }
168
+ </style>
169
+ <div class="notice notice-info is-dismissible yarpp-review-notice">
170
+ <p class="yarpp-review-notice-text">' . __('Hey there! We noticed that you have had success using ', 'yarpp') . '<a href="' . admin_url('options-general.php?page=yarpp') . '">YARPP - Related Posts</a>! ' . __('Could you please do us a BIG favor and give us a quick 5-star rating on WordPress? It will boost our motivation and spread the word. We would really appreciate it 🤗 — Team YARPP', 'yarpp') . '
171
+ <br />
172
+ <br />
173
+ <a onclick="location.href=\'' . $dismiss_forever_url . '\';" class="button button-primary" href="' . esc_url('https://wordpress.org/support/plugin/yet-another-related-posts-plugin/reviews/?rate=5#new-post') . '" target="_blank">' . __('Ok, you deserve it', 'yarpp') . '</a> &nbsp;
174
+ <a href="' . $dismiss_forlater_url . '">' . __('No, maybe later', 'yarpp') . '</a> &nbsp;
175
+ <a href="' . $dismiss_forever_url . '">' . __('I already did', 'yarpp') . '</a>
176
+ </p>
177
+ </div>';
178
+ }
179
+
180
+ function ui_register() {
181
+ global $wp_version;
182
+
183
+ if (get_option('yarpp_activated')) {
184
+
185
+ delete_option('yarpp_activated');
186
+ delete_option('yarpp_upgraded');
187
+
188
+ /* Optin/Pro message */
189
+ add_action('admin_notices', array($this, 'install_notice'));
190
+
191
+ } elseif (get_option('yarpp_upgraded') && current_user_can('manage_options') && $this->core->get_option('optin')) {
192
+ add_action('admin_notices', array($this, 'upgrade_notice'));
193
+ }
194
+
195
+ if ($this->core->get_option('optin')) delete_option('yarpp_upgraded');
196
+
197
+ /*
198
+ * Setup Admin
199
*/
200
+ $titleName = 'YARPP';
201
+ $this->hook = add_options_page($titleName, $titleName, 'manage_options', 'yarpp', array($this, 'options_page'));
202
+
203
+ /**
204
+ * @since 3.0.12 Add settings link to the plugins page.
205
+ */
206
+ add_filter('plugin_action_links', array($this, 'settings_link'), 10, 2);
207
+
208
+ $metabox_post_types = $this->core->get_option('auto_display_post_types');
209
+ if (!in_array('post', $metabox_post_types)) $metabox_post_types[] = 'post';
210
+
211
+ /**
212
+ * @since 3.0 Add meta box in Editor
213
+ */
214
+ if(!$this->core->yarppPro['active']){
215
+ foreach ($metabox_post_types as $post_type) {
216
+ $title = __('Related Posts' , 'yarpp');
217
+ add_meta_box('yarpp_relatedposts',$title, array($this, 'metabox'), $post_type, 'normal');
218
+ }
219
+ }
220
+
221
+ /**
222
+ * @since 3.3: properly enqueue scripts for admin.
223
+ */
224
+ add_action('admin_enqueue_scripts', array($this, 'enqueue'));
225
+ }
226
+
227
+ /**
228
+ * @since 3.5.4 Only load metabox code if we're going to be on the settings page.
229
+ */
230
+ function settings_screen($current_screen) {
231
+ if ($current_screen->id !== 'settings_page_yarpp') return $current_screen;
232
+
233
+ /**
234
+ * @since 3.3: Load options page sections as meta-boxes.
235
+ */
236
+ include_once(YARPP_DIR.'/includes/yarpp_meta_boxes_hooks.php');
237
+
238
+ /**
239
+ * @since 3.5.5 Check that add_help_tab method callable (WP >= 3.3).
240
+ */
241
+ if (is_callable(array($current_screen, 'add_help_tab'))) {
242
+ $current_screen->add_help_tab(array(
243
+ 'id' => 'faq',
244
+ 'title' => __('Frequently Asked Questions', 'yarpp'),
245
+ 'callback' => array(&$this, 'help_faq')
246
+ ));
247
+
248
+ $current_screen->add_help_tab(array(
249
+ 'id' => 'dev',
250
+ 'title' => __('Developing with YARPP', 'yarpp'),
251
+ 'callback' => array(&$this, 'help_dev')
252
+ ));
253
+
254
+ $current_screen->add_help_tab(array(
255
+ 'id' => 'optin',
256
+ 'title' => __('Optional Data Collection', 'yarpp'),
257
+ 'callback' => array(&$this, 'help_optin')
258
+ ));
259
+ }
260
+
261
+ return $current_screen;
262
+ }
263
+
264
+ private $readme = null;
265
+
266
+ public function help_faq() {
267
+ if (is_null($this->readme)) $this->readme = file_get_contents(YARPP_DIR.'/readme.txt');
268
+
269
+ if (preg_match('!== Frequently Asked Questions ==(.*?)^==!sm', $this->readme, $matches)) {
270
+ echo $this->markdown($matches[1]);
271
} else {
272
+ echo(
273
+ '<a href="https://wordpress.org/plugins/yet-another-related-posts-plugin/#faq">'.
274
__('Frequently Asked Questions', 'yarpp').
275
'</a>'
276
);
277
}
278
+ }
279
+
280
+ public function help_dev() {
281
+ if (is_null($this->readme)) $this->readme = file_get_contents(YARPP_DIR.'/readme.txt');
282
283
+ if (preg_match('!== Developing with YARPP ==(.*?)^==!sm', $this->readme, $matches)) {
284
+ echo $this->markdown( $matches[1] );
285
} else {
286
+ echo(
287
+ '<a href="https://wordpress.org/plugins/yet-another-related-posts-plugin/#faq" target="_blank">'.
288
__('Developing with YARPP', 'yarpp').
289
'</a>'
290
);
291
}
292
+ }
293
294
+ public function help_optin() {
295
+ echo(
296
'<p>'.
297
__("With your permission, YARPP will send information about YARPP's settings, usage, and environment
298
back to a central server at ", 'yarpp').'<code>yarpp.org</code>'.'.&nbsp;'.
302
'for country, domain, and date installed information.'.
303
'</p>'.
304
'<p>'.
305
+ __("This information will be used to improve YARPP in the future and help decide future development
306
+ decisions for YARPP.",
307
'yarpp'
308
).' '.
309
'</p>'.
310
'<p>'.
311
+ '<strong>'.
312
__("Contributing this data will help make YARPP better for you and for other YARPP users.",
313
'yarpp' ).'</strong>'.
314
'</p>'
315
);
316
+
317
+ echo(
318
'<p>'.
319
__("The following information is sent back to YARPP:", 'yarpp').
320
'</p>'.
321
+ '<div id="optin_data_frame"></div>'.
322
'<p>'.
323
__("In addition, YARPP also loads an invisible pixel image with your YARPP results to know how often YARPP is being used.", 'yarpp').
324
'</p>'
325
);
326
+ }
327
+
328
+ function the_optin_button($action, $echo = false) {
329
+ $status = ($this->core->yarppPro['active']) ? 'disabled' : null;
330
+
331
+ if ($action === 'disable'){
332
+ $out =
333
+ '<a id="yarpp-optin-button'.$status.'" class="button" '.$status.'>'.
334
+ 'No, Thanks. Please <strong>'.$action.'</strong> sending usage data'.
335
'</a>';
336
+ } else {
337
+ $out =
338
+ '<a id="yarpp-optin-button'.$status.'" class="button" '.$status.'>'.
339
+ 'Yes, <strong>'.$action.'</strong> sending usage data back to help improve YARPP'.
340
'</a>';
341
}
342
343
+ if ($echo){
344
+ echo $out;
345
+ return null;
346
+ } else {
347
+ return $out;
348
+ }
349
+ }
350
+
351
+ function the_donothing_button($msg, $echo = false) {
352
+ $out ='<a href="options-general.php?page=yarpp" class="button">'.$msg.'</a>';
353
+ if ($echo){
354
+ echo $out;
355
+ return null;
356
+ } else {
357
+ return $out;
358
+ }
359
+ }
360
+
361
+ function optin_button_script($optinAction, $echo=false) {
362
+ wp_nonce_field('yarpp_optin_'.$optinAction, 'yarpp_optin-nonce', false);
363
+
364
+ ob_start();
365
+ include(YARPP_DIR.'/includes/optin_notice.js.php');
366
+ $out = ob_get_contents();
367
+ ob_end_clean();
368
+
369
+ if($echo){
370
+ echo $out;
371
+ return null;
372
+ } else {
373
+ return $out;
374
+ }
375
+ }
376
+
377
+ function upgrade_notice() {
378
+ $optinAction = ($this->core->get_option('optin')) ? 'disable' : 'enable';
379
+ $this->optin_notice('upgrade', $optinAction);
380
+ }
381
+
382
+ public function install_notice(){
383
+ $optinAction = ($this->core->get_option('optin')) ? 'disable' : 'enable';
384
+ $this->optin_notice('install', $optinAction);
385
+ }
386
+
387
+ public function optin_notice($type=false, $optinAction) {
388
+ $screen = get_current_screen();
389
+ if(is_null($screen) || $screen->id == 'settings_page_yarpp') return;
390
+
391
+ switch($type) {
392
+ case 'upgrade':
393
+ delete_option('yarpp_upgraded');
394
+ break;
395
+ case 'install':
396
+ default:
397
+ $user = get_current_user_id();
398
+ update_user_option($user, 'yarpp_saw_optin', true);
399
}
400
401
+ $out = '<div class="updated fade"><p>';
402
403
+ if($type === 'upgrade'){
404
+ $out .= '<strong>'.sprintf(__('%1$s updated successfully.'), 'Yet Another Related Posts Plugin').'</strong>';
405
}
406
407
+ if ($type === 'install'){
408
$tmp = __('Thank you for installing <span>Yet Another Related Posts Plugin</span>!', 'yarpp');
409
+ $out .= '<strong>'.str_replace('<span>','<span style="font-style:italic; font-weight: inherit;">', $tmp).'</strong>';
410
}
411
412
if($this->core->yarppPro['active']){
431
}
432
433
echo $out.'</div>';
434
+ }
435
+
436
+ // faux-markdown, required for the help text rendering
437
+ protected function markdown( $text ) {
438
+ $replacements = array(
439
+ // strip each line
440
+ '!\s*[\r\n] *!' => "\n",
441
+
442
+ // headers
443
+ '!^=(.*?)=\s*$!m' => '<h3>\1</h3>',
444
+
445
+ // bullets
446
+ '!^(\* .*([\r\n]\* .*)*)$!m' => "<ul>\n\\1\n</ul>",
447
+ '!^\* (.*?)$!m' => '<li>\1</li>',
448
+ '!^(\d+\. .*([\r\n]\d+\. .*)*)$!m' => "<ol>\n\\1\n</ol>",
449
+ '!^\d+\. (.*?)$!m' => '<li>\1</li>',
450
+
451
+ // code block
452
+ '!^(\t.*([\r\n]\t.*)*)$!m' => "<pre>\n\\1\n</pre>",
453
+
454
+ // wrap p
455
+ '!^([^<\t].*[^>])$!m' => '<p>\1</p>',
456
+ // bold
457
+ '!\*([^*]*?)\*!' => '<strong>\1</strong>',
458
+ // code
459
+ '!`([^`]*?)`!' => '<code>\1</code>',
460
+ // links
461
+ '!\[([^]]+)\]\(([^)]+)\)!' => '<a href="\2" target="_new">\1</a>',
462
+ );
463
+ $text = preg_replace(array_keys($replacements), array_values($replacements), $text);
464
+
465
+ return $text;
466
+ }
467
+
468
+ public function render_screen_settings ($output, $current_screen) {
469
+ if ( $current_screen->id != 'settings_page_yarpp' )
470
+ return $output;
471
+
472
+ $output .= "<div id='yarpp_extra_screen_settings'><label for='yarpp_display_code'><input type='checkbox' name='yarpp_display_code' id='yarpp_display_code'";
473
+ $output .= checked($this->core->get_option('display_code'), true, false);
474
+ $output .= " />";
475
+ $output .= __('Show example code output', 'yarpp');
476
+ $output .= '</label></div>';
477
+
478
+ return $output;
479
+ }
480
+
481
+ // since 3.3
482
+ public function enqueue() {
483
+ $version = defined('WP_DEBUG') && WP_DEBUG ? time() : YARPP_VERSION;
484
+ $screen = get_current_screen();
485
+ if (!is_null($screen) && $screen->id === 'settings_page_yarpp') {
486
+ wp_enqueue_style('yarpp_switch_options', plugins_url('style/options_switch.css', dirname(__FILE__)), array(), $version );
487
+ wp_enqueue_script('yarpp_switch_options', plugins_url('js/options_switch.js', dirname(__FILE__)), array('jquery'), $version );
488
+
489
+ wp_enqueue_style('wp-pointer');
490
+ wp_enqueue_style('yarpp_options', plugins_url('style/options_basic.css', dirname(__FILE__)), array(), $version );
491
+
492
+ wp_enqueue_script('postbox');
493
+ wp_enqueue_script('wp-pointer');
494
+ wp_enqueue_script('yarpp_options', plugins_url('js/options_basic.js', dirname(__FILE__)), array('jquery'), $version );
495
+ }
496
+
497
+ $metabox_post_types = $this->core->get_option('auto_display_post_types');
498
+ if (!is_null($screen) && ($screen->id == 'post' || in_array( $screen->id, $metabox_post_types))) {
499
+ wp_enqueue_script('yarpp_metabox', plugins_url('js/metabox.js', dirname(__FILE__)), array('jquery'), $version );
500
+ }
501
+ }
502
+
503
+ public function settings_link($links, $file) {
504
+ $this_plugin = dirname(plugin_basename(dirname(__FILE__))).'/yarpp.php';
505
+ if($file == $this_plugin) {
506
+ $links[] = '<a href="options-general.php?page=yarpp">'.__('Settings').'</a>';
507
+ }
508
+ return $links;
509
+ }
510
+
511
+ public function options_page() {
512
+ $mode = (isset($_GET['mode'])) ? htmlentities(strtolower($_GET['mode'])) : null;
513
+ if ($mode !== 'basic' && ($mode === 'pro' || $this->core->yarppPro['active'])){
514
+ include_once(YARPP_DIR.'/includes/yarpp_pro_options.php');
515
+ } else {
516
+ include_once(YARPP_DIR . '/includes/yarpp_options.php');
517
+ }
518
+ }
519
+
520
+ // @since 3.4: don't actually compute results here, but use ajax instead
521
+ public function metabox() {
522
+ ?>
523
+ <style>
524
+ .yarpp-metabox-options {
525
+ margin: 10px 0;
526
+ }
527
+ #yarpp-related-posts .spinner {
528
+ float: none; visibility: hidden; opacity: 1; margin: 5px 0 0 7px;
529
+ }
530
+ </style>
531
+ <?php
532
+ if ( !get_the_ID() ) {
533
+ echo "<div><p>".__("Related entries may be displayed once you save your entry",'yarpp').".</p></div>";
534
+ } else {
535
+ wp_nonce_field( 'yarpp_display', 'yarpp_display-nonce', false );
536
+ echo '<div id="yarpp-related-posts"><img height="20px" width="20px" src="' . esc_url( admin_url( 'images/spinner-2x.gif' ) ) . '" alt="loading..." /></div>';
537
+ }
538
+ }
539
+
540
+ // @since 3.3: default metaboxes to show:
541
+ public function default_hidden_meta_boxes($hidden, $screen) {
542
+ if ($screen->id === 'settings_page_yarpp') {
543
+ $hidden = $this->core->default_hidden_metaboxes;
544
+ }
545
+ return $hidden;
546
+ }
547
+
548
+ // @since 4: UI to copy templates
549
+ public function can_copy_templates() {
550
+ $theme_dir = get_stylesheet_directory();
551
+ // If we can't write to the theme, return false
552
+ if (!is_dir($theme_dir) || !is_writable($theme_dir)) return false;
553
+
554
+ require_once(ABSPATH.'wp-admin/includes/file.php');
555
+ WP_Filesystem(false, get_stylesheet_directory());
556
+ global $wp_filesystem;
557
+ // direct method is the only method that I've tested so far
558
+ return $wp_filesystem->method === 'direct';
559
+ }
560
+
561
+ public function copy_templates() {
562
+ $templates_dir = trailingslashit(trailingslashit(YARPP_DIR).'yarpp-templates');
563
+
564
+ require_once(ABSPATH.'wp-admin/includes/file.php');
565
+ WP_Filesystem(false, get_stylesheet_directory());
566
+ global $wp_filesystem;
567
+ if ( $wp_filesystem->method !== 'direct') return false;
568
+
569
+ return copy_dir($templates_dir, get_stylesheet_directory(), array('.svn'));
570
+ }
571
+
572
+ /*
573
+ * AJAX SERVICES
574
+ */
575
+
576
+ public function ajax_display_exclude_terms() {
577
+ check_ajax_referer('yarpp_display_exclude_terms');
578
+
579
+ if (!isset($_REQUEST['taxonomy'])) return;
580
+
581
+ $taxonomy = (string) $_REQUEST['taxonomy'];
582
+
583
+ header("HTTP/1.1 200");
584
+ header("Content-Type: text/html; charset=UTF-8");
585
+
586
+ $exclude_tt_ids = wp_parse_id_list($this->core->get_option('exclude'));
587
+ $exclude_term_ids = $this->get_term_ids_from_tt_ids( $taxonomy, $exclude_tt_ids );
588
+ // if ('category' === $taxonomy) $exclude .= ','.get_option('default_category');
589
+
590
+ $terms = get_terms($taxonomy, array(
591
+ 'exclude' => $exclude_term_ids,
592
+ 'hide_empty' => false,
593
+ 'hierarchical' => false,
594
+ 'number' => 100,
595
+ 'offset' => $_REQUEST['offset']
596
+ ));
597
+
598
+ if ( !count($terms) ) {
599
+ echo ':('; // no more :(
600
+ exit;
601
+ }
602
+
603
+ foreach ($terms as $term) {
604
+ echo "<span><input type='checkbox' name='exclude[{$term->term_taxonomy_id}]' id='exclude_{$term->term_taxonomy_id}' value='true' /> <label for='exclude_{$term->term_taxonomy_id}'>" . esc_html($term->name) . "</label></span> ";
605
+ }
606
+ exit;
607
+ }
608
+
609
+ public function get_term_ids_from_tt_ids( $taxonomy, $tt_ids ) {
610
+ global $wpdb;
611
+ $tt_ids = wp_parse_id_list($tt_ids);
612
+ if ( empty($tt_ids) )
613
+ return array();
614
+ return $wpdb->get_col("select term_id from $wpdb->term_taxonomy where taxonomy = '{$taxonomy}' and term_taxonomy_id in (" . join(',', $tt_ids) . ")");
615
+ }
616
+
617
+ public function ajax_display() {
618
+ check_ajax_referer('yarpp_display');
619
+
620
+ if (!isset($_REQUEST['ID'])) return;
621
+
622
+ $args = array(
623
+ 'post_type' => array('post'),
624
+ 'domain' => isset($_REQUEST['domain']) ? $_REQUEST['domain'] : 'website'
625
+ );
626
+
627
+ if ($this->core->get_option('cross_relate')) $args['post_type'] = $this->core->get_post_types();
628
+
629
+ $return = $this->core->display_related(absint($_REQUEST['ID']), $args, false);
630
+
631
+ header("HTTP/1.1 200");
632
+ header("Content-Type: text/html; charset=UTF-8");
633
+ echo $return;
634
+
635
+ die();
636
+ }
637
+
638
+ public function ajax_display_demo() {
639
+ check_ajax_referer('yarpp_display_demo');
640
+
641
+ header("HTTP/1.1 200");
642
+ header("Content-Type: text/html; charset=UTF-8");
643
+
644
+ $args = array(
645
+ 'post_type' => array('post'),
646
+ 'domain' => (isset($_REQUEST['domain'])) ? $_REQUEST['domain'] : 'website'
647
+ );
648
+
649
+ $return = $this->core->display_demo_related($args, false);
650
+ echo preg_replace("/[\n\r]/",'',nl2br(htmlspecialchars($return)));
651
+ exit;
652
+ }
653
+
654
+ /**
655
+ * Display optin data in a human readable format on the help tab.
656
+ */
657
+ public function ajax_optin_data() {
658
+ check_ajax_referer('yarpp_optin_data');
659
+
660
+ header("HTTP/1.1 200");
661
+ header("Content-Type: text/html; charset=UTF-8");
662
+
663
+ $data = $this->core->optin_data();
664
+ $this->core->pretty_echo($data);
665
+ die();
666
+ }
667
+
668
+ public function ajax_optin_disable() {
669
+ check_ajax_referer('yarpp_optin_disable');
670
+
671
+ $this->core->set_option('optin', false);
672
+
673
+ header("HTTP/1.1 200");
674
+ header("Content-Type: text; charset=UTF-8");
675
+ echo 'ok';
676
+
677
+ die();
678
+ }
679
+
680
+ public function ajax_optin_enable() {
681
+ check_ajax_referer('yarpp_optin_enable');
682
+
683
+ $this->core->set_option('optin', true);
684
+ $this->core->optin_ping();
685
+
686
+ header("HTTP/1.1 200");
687
+ header("Content-Type: text; charset=UTF-8");
688
+ echo 'ok';
689
+
690
+ die();
691
+ }
692
+
693
+ /**
694
+ * Handles switching between Pro and Basic versions
695
+ *
696
+ * For example:
697
+ * ../wp-admin/admin-ajax.php?action=yarpp_switch&go=pro
698
+ * ../wp-admin/admin-ajax.php?action=yarpp_switch&go=basic
699
+ *
700
+ * @since 5.1.0
701
+ */
702
+ public function ajax_switch() {
703
+ check_ajax_referer('yarpp_switch');
704
+
705
+ if (!is_admin() ||
706
+ !current_user_can('manage_options')) {
707
+ return;
708
+ }
709
+
710
+ if (!isset($_GET['go']) || trim($_GET['go']) === '') die();
711
+
712
+ $switch = htmlentities($_GET['go']);
713
+
714
+ function switchYarppPro($status){
715
+ $yarppPro = get_option('yarpp_pro');
716
+ $yarpp = get_option('yarpp');
717
+
718
+ if($status){
719
+ $yarppPro['optin'] = (bool) $yarpp['optin'];
720
+ $yarpp['optin'] = false;
721
} else {
722
+ $yarpp['optin'] = (bool) $yarppPro['optin'];
723
}
724
725
+ $yarppPro['active'] = $status;
726
+ update_option('yarpp',$yarpp);
727
+ update_option('yarpp_pro',$yarppPro);
728
729
header("HTTP/1.1 200");
730
+ header("Content-Type: text/plain; charset=UTF-8");
731
+ die('ok');
732
}
733
734
+ switch ($switch){
735
+ case 'basic':
736
+ switchYarppPro(0);
737
+ break;
738
+ case 'pro':
739
+ switchYarppPro(1);
740
+ break;
741
+ }
742
+ }
743
+
744
+ public function ajax_set_display_code() {
745
+ check_ajax_referer( 'yarpp_set_display_code' );
746
+
747
+ header("HTTP/1.1 200");
748
+ header("Content-Type: text; charset=UTF-8");
749
+
750
+ $data = $this->core->set_option( 'display_code', isset($_REQUEST['checked']) );
751
+ echo 'ok';
752
+ die();
753
+ }
754
}
classes/YARPP_Core.php CHANGED
@@ -453,7 +453,7 @@ class YARPP {
453
)
454
);
455
456
- $url = plugins_url('includes/styles_thumbnails.css.php?'.$queryStr, dirname(__FILE__));
457
wp_enqueue_style("yarpp-thumbnails-".$dimensions['size'], $url, array(), YARPP_VERSION, 'all');
458
}
459
@@ -468,10 +468,10 @@ class YARPP {
468
if ($dimensions['crop'] && $downsized[1] && $downsized[2]
469
&& ($downsized[1] != $dimensions['width'] || $downsized[2] != $dimensions['height'])
470
) {
471
- /*
472
* We want to trigger re-computation of the thumbnail here.
473
- * (only if downsized width and height are specified, for Photon behavior)
474
- */
475
$fullSizePath = get_attached_file($thumbnail_id);
476
if ($fullSizePath !== false && file_exists($fullSizePath)) {
477
require_once(ABSPATH.'wp-admin/includes/image.php');
@@ -590,7 +590,7 @@ class YARPP {
590
'rss_excerpt_display' => true,
591
'promote_yarpp' => false,
592
'rss_promote_yarpp' => false
593
- );
594
595
$yarpp_options = array();
596
foreach ($yarpp_3_3_options as $key => $default) {
@@ -1493,7 +1493,7 @@ class YARPP {
1493
if (is_wp_error($remote) || wp_remote_retrieve_response_code($remote) != 200 || !isset($remote['body'])){
1494
$this->set_transient('yarpp_version_info', null, 60*60);
1495
return false;
1496
- }
1497
1498
if ($result = @unserialize($remote['body'])) $this->set_transient('yarpp_version_info', $result, 60*60*24);
1499
453
)
454
);
455
456
+ $url = plugins_url('includes/styles_thumbnails.css.php?'.$queryStr, dirname(__FILE__));
457
wp_enqueue_style("yarpp-thumbnails-".$dimensions['size'], $url, array(), YARPP_VERSION, 'all');
458
}
459
468
if ($dimensions['crop'] && $downsized[1] && $downsized[2]
469
&& ($downsized[1] != $dimensions['width'] || $downsized[2] != $dimensions['height'])
470
) {
471
+ /*
472
* We want to trigger re-computation of the thumbnail here.
473
+ * (only if downsized width and height are specified, for Photon behavior)
474
+ */
475
$fullSizePath = get_attached_file($thumbnail_id);
476
if ($fullSizePath !== false && file_exists($fullSizePath)) {
477
require_once(ABSPATH.'wp-admin/includes/image.php');
590
'rss_excerpt_display' => true,
591
'promote_yarpp' => false,
592
'rss_promote_yarpp' => false
593
+ );
594
595
$yarpp_options = array();
596
foreach ($yarpp_3_3_options as $key => $default) {
1493
if (is_wp_error($remote) || wp_remote_retrieve_response_code($remote) != 200 || !isset($remote['body'])){
1494
$this->set_transient('yarpp_version_info', null, 60*60);
1495
return false;
1496
+ }
1497
1498
if ($result = @unserialize($remote['body'])) $this->set_transient('yarpp_version_info', $result, 60*60*24);
1499
classes/YARPP_Meta_Box_Optin.php CHANGED
@@ -7,7 +7,7 @@ class YARPP_Meta_Box_Optin extends YARPP_Meta_Box {
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>&nbsp;&nbsp;'.
11
'<a href="http://www.yarpp.com" target="_blank" style="float:right;text-decoration:underline">Learn more</a>'.
12
'</p>'.
13
'<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 class="yarpp_switch_button button" data-go="pro">Turn them on now</a>&nbsp;&nbsp;'.
11
'<a href="http://www.yarpp.com" target="_blank" style="float:right;text-decoration:underline">Learn more</a>'.
12
'</p>'.
13
'<p>'.
images/icon-256x256.png ADDED
Binary file
includes/init_functions.php CHANGED
@@ -1,5 +1,4 @@
1
<?php
2
- /* Init Functions ---------------------------------------------------------------------------------------------------*/
3
4
function yarpp_init() {
5
global $yarpp;
1
<?php
2
3
function yarpp_init() {
4
global $yarpp;
includes/phtmls/yarpp_options.phtml CHANGED
@@ -38,14 +38,14 @@
38
<?php do_meta_boxes('settings_page_yarpp', 'normal', array()) ?>
39
</div>
40
41
- <script language="javascript">
42
- var spinner = '<?php echo esc_url(admin_url('images/wpspin_light.gif')) ?>',
43
- loading = '<img class="loading" src="'+spinner+'" alt="loading..."/>';
44
</script>
45
46
<div>
47
<input type="submit" class='button-primary' name="update_yarpp" value="<?php _e('Save Changes')?>" />
48
- <?php wp_nonce_field( 'update_yarpp', 'update_yarpp-nonce' ); ?>
49
</div>
50
51
</div><!--#poststuff-->
38
<?php do_meta_boxes('settings_page_yarpp', 'normal', array()) ?>
39
</div>
40
41
+ <script>
42
+ var spinner = '<?php echo esc_url(admin_url('images/spinner-2x.gif')) ?>',
43
+ loading = '<img height="20px" width="20px" class="loading" src="'+spinner+'" alt="loading..."/>';
44
</script>
45
46
<div>
47
<input type="submit" class='button-primary' name="update_yarpp" value="<?php _e('Save Changes')?>" />
48
+ <?php wp_nonce_field( 'update_yarpp', 'update_yarpp-nonce' ); ?>
49
</div>
50
51
</div><!--#poststuff-->
includes/phtmls/yarpp_pro_options.phtml CHANGED
@@ -14,8 +14,8 @@
14
<p>
15
<?php if ($yarpp->yarppPro['active']): ?>
16
Welcome to your <strong>YARPP Pro</strong> dashboard! Here you have access to the most powerful features of YARPP.
17
<a
18
- href="<?php echo plugins_url('/', dirname(__FILE__))?>/yarpp_switch.php"
19
class="yarpp_switch_button button to_corner" data-go="basic">
20
Deactivate &nbsp;<strong>YARPP Pro</strong>&nbsp;
21
</a>
@@ -42,7 +42,6 @@
42
<?php if (!$yarpp->yarppPro['active']): ?>
43
<p>
44
<a
45
- href="<?php echo plugins_url('/', dirname(__FILE__))?>yarpp_switch.php"
46
class="yarpp_switch_button button-primary" data-go="pro">
47
Activate <strong>YARPP Pro</strong> Now
48
</a>
@@ -88,19 +87,6 @@
88
</div>
89
</div>
90
91
- <div id="yarpp_pro_dashboard_wrapper">
92
- <iframe
93
- style="border: 0"
94
- id="yarpp_pro_dashboard"
95
- src="<?php echo $url ?>"
96
- frameborder="0"
97
- border="0"
98
- cellspacing="0"
99
- scrolling="yes"
100
- >
101
- </iframe>
102
- </div>
103
-
104
<script>jQuery("#screen-options-link-wrap").hide();</script>
105
<?php endif ?>
106
</div>
14
<p>
15
<?php if ($yarpp->yarppPro['active']): ?>
16
Welcome to your <strong>YARPP Pro</strong> dashboard! Here you have access to the most powerful features of YARPP.
17
+ <?php wp_nonce_field( 'yarpp_switch', 'yarpp_switch-nonce' ); ?>
18
<a
19
class="yarpp_switch_button button to_corner" data-go="basic">
20
Deactivate &nbsp;<strong>YARPP Pro</strong>&nbsp;
21
</a>
42
<?php if (!$yarpp->yarppPro['active']): ?>
43
<p>
44
<a
45
class="yarpp_switch_button button-primary" data-go="pro">
46
Activate <strong>YARPP Pro</strong> Now
47
</a>
87
</div>
88
</div>
89
90
<script>jQuery("#screen-options-link-wrap").hide();</script>
91
<?php endif ?>
92
</div>
includes/template_metabox.php CHANGED
@@ -16,8 +16,8 @@ if ($yarpp->debug) {
16
}
17
18
if (have_posts()) {
19
- $output .= '<style>#yarpp-related-posts ol li { list-style-type: decimal; }</style>';
20
- $output .= '<ol>';
21
while (have_posts()) {
22
the_post();
23
$output .= "<li><a href='post.php?action=edit&post=" . get_the_ID() . "'>" . get_the_title() . "</a>";
@@ -25,7 +25,9 @@ if (have_posts()) {
25
$output .= '</li>';
26
}
27
$output .= '</ol>';
28
- $output .= '<p>'.__( 'Whether all of these related entries are actually displayed and how they are displayed depends on your YARPP display options.' , 'yarpp').'</p>';
29
} else {
30
$output .= '<p><em>'.__('No related posts.','yarpp').'</em></p>';
31
}
16
}
17
18
if (have_posts()) {
19
+ $output .= '<style>#yarpp-related-posts ol li { list-style-type: decimal; margin: 10px 0;} #yarpp-related-posts ol li a {text-decoration: none;}</style>';
20
+ $output .= '<ol id="yarpp-list">';
21
while (have_posts()) {
22
the_post();
23
$output .= "<li><a href='post.php?action=edit&post=" . get_the_ID() . "'>" . get_the_title() . "</a>";
25
$output .= '</li>';
26
}
27
$output .= '</ol>';
28
+ $output .= '<p>'.__( 'Whether all of these related entries are actually displayed and how they are displayed depends on your YARPP display options.' , 'yarpp') . '</p>';
29
} else {
30
$output .= '<p><em>'.__('No related posts.','yarpp').'</em></p>';
31
}
32
+
33
+ $output .= '<p class="yarpp-metabox-options"><a href="' . esc_url(admin_url('options-general.php?page=yarpp')) . '" class="button-secondary">' . __('Configure Options', 'yarpp') . '</a> <a id="yarpp-refresh" href="#" class="button-secondary">' . __('Refresh', 'yarpp') . '</a><span class="spinner"></span></p>';
includes/template_thumbnails.php CHANGED
@@ -28,19 +28,19 @@ if (have_posts()) {
28
while (have_posts()) {
29
the_post();
30
31
- $output .= "<a class='yarpp-thumbnail' href='" . get_permalink() . "' title='" . the_title_attribute('echo=0') . "'>" . "\n";
32
33
$post_thumbnail_html = '';
34
if ( has_post_thumbnail() ) {
35
if ( $this->diagnostic_generate_thumbnails() )
36
$this->ensure_resized_post_thumbnail( get_the_ID(), $dimensions );
37
- $post_thumbnail_html = get_the_post_thumbnail( null, $dimensions['size'] );
38
}
39
40
if ( trim($post_thumbnail_html) != '' )
41
$output .= $post_thumbnail_html;
42
else
43
- $output .= '<span class="yarpp-thumbnail-default"><img src="' . esc_url($thumbnails_default) . '"/></span>';
44
45
$output .= '<span class="yarpp-thumbnail-title">' . get_the_title() . '</span>';
46
$output .= '</a>' . "\n";
28
while (have_posts()) {
29
the_post();
30
31
+ $output .= "<a class='yarpp-thumbnail' rel='norewrite' href='" . get_permalink() . "' title='" . the_title_attribute('echo=0') . "'>" . "\n";
32
33
$post_thumbnail_html = '';
34
if ( has_post_thumbnail() ) {
35
if ( $this->diagnostic_generate_thumbnails() )
36
$this->ensure_resized_post_thumbnail( get_the_ID(), $dimensions );
37
+ $post_thumbnail_html = get_the_post_thumbnail(null, $dimensions['size'], array('data-pin-nopin' => 'true') );
38
}
39
40
if ( trim($post_thumbnail_html) != '' )
41
$output .= $post_thumbnail_html;
42
else
43
+ $output .= '<span class="yarpp-thumbnail-default"><img src="' . esc_url($thumbnails_default) . '" alt="Default Thumbnail" data-pin-nopin="true" /></span>';
44
45
$output .= '<span class="yarpp-thumbnail-title">' . get_the_title() . '</span>';
46
$output .= '</a>' . "\n";
includes/yarpp_switch.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- if (!isset($_GET['go']) || trim($_GET['go']) === '') die();
3
-
4
- include_once(realpath('../../../../').'/wp-config.php');
5
- $switch = htmlentities($_GET['go']);
6
-
7
- function switchYarppPro($status){
8
- $yarppPro = get_option('yarpp_pro');
9
- $yarpp = get_option('yarpp');
10
-
11
- if($status){
12
- $yarppPro['optin'] = (bool) $yarpp['optin'];
13
- $yarpp['optin'] = false;
14
- } else {
15
- $yarpp['optin'] = (bool) $yarppPro['optin'];
16
- }
17
-
18
- $yarppPro['active'] = $status;
19
- update_option('yarpp',$yarpp);
20
- update_option('yarpp_pro',$yarppPro);
21
-
22
- header("HTTP/1.1 200");
23
- header("Content-Type: text/plain; charset=UTF-8");
24
- die('ok');
25
- }
26
-
27
- switch ($switch){
28
- case 'basic':
29
- switchYarppPro(0);
30
- break;
31
- case 'pro':
32
- switchYarppPro(1);
33
- break;
34
- }
js/metabox.js CHANGED
@@ -1,28 +1,73 @@
1
- jQuery(function($) {
2
- var loaded_metabox = false;
3
- var display = $('#yarpp-related-posts');
4
- function metabox_display() {
5
- if ( !$('#yarpp_relatedposts .inside').is(':visible') ||
6
- !display.length ||
7
- !$('#post_ID').val() )
8
- return;
9
- if ( !loaded_metabox ) {
10
- loaded_metabox = true;
11
- $.ajax({type:'POST',
12
- url: ajaxurl,
13
- data: {
14
- action: 'yarpp_display',
15
- domain: 'metabox',
16
- ID: $('#post_ID').val(),
17
- '_ajax_nonce': $('#yarpp_display-nonce').val()
18
- },
19
- success:function(html){display.html(html)},
20
- dataType:'html'});
21
- }
22
- }
23
- $('#yarpp_relatedposts .handlediv, #yarpp_relatedposts-hide').click(
24
- function() {
25
- setTimeout(metabox_display, 0);
26
- });
27
- metabox_display();
28
- });
1
+ jQuery(document).ready(function($) {
2
+ var loaded_metabox = false;
3
+ var display = $('#yarpp-related-posts');
4
+
5
+ /*
6
+ * Populates Metabox initially
7
+ */
8
+ function yarpp_metabox_initial_display() {
9
+ if (!$('#yarpp_relatedposts') ||
10
+ !display.length ||
11
+ !$('#post_ID').val() )
12
+ return;
13
+
14
+ if (!loaded_metabox) {
15
+ loaded_metabox = true;
16
+ yarpp_metabox_populate();
17
+ }
18
+ }
19
+
20
+ /*
21
+ * Populates Metabox
22
+ */
23
+ function yarpp_metabox_populate() {
24
+ $.ajax({
25
+ type:'POST',
26
+ url: ajaxurl,
27
+ data: {
28
+ action: 'yarpp_display',
29
+ domain: 'metabox',
30
+ ID: parseInt($('#post_ID').val()),
31
+ '_ajax_nonce': $('#yarpp_display-nonce').val()
32
+ },
33
+ error: function() {
34
+ display.html("Error");
35
+ },
36
+ success: function(html){
37
+ display.html(html)},
38
+ dataType: 'html'
39
+ }
40
+ );
41
+ }
42
+
43
+ $('#yarpp_relatedposts .handlediv, #yarpp_relatedposts-hide').click(function() {
44
+ setTimeout(yarpp_metabox_initial_display, 0);
45
+ });
46
+
47
+ /*
48
+ * Metabox Refresh Button
49
+ */
50
+ $(document).on('click', '#yarpp-refresh', function(e) {
51
+ e.preventDefault();
52
+
53
+ var display = $('#yarpp-related-posts');
54
+
55
+ if( $(this).hasClass('disabled') )
56
+ return false;
57
+
58
+ $refresh_button = $(this);
59
+ $spinner = $refresh_button.siblings('.spinner');
60
+
61
+ $refresh_button.addClass( 'disabled' );
62
+ $spinner.css( 'visibility', 'visible' );
63
+
64
+ $('#yarpp-list').css( 'opacity', 0.6 );
65
+ yarpp_metabox_populate();
66
+ });
67
+
68
+ /*
69
+ * Initial Load
70
+ */
71
+ yarpp_metabox_initial_display();
72
+
73
+ });
js/options_basic.js CHANGED
@@ -1,289 +1,291 @@
1
jQuery(function($) {
2
- // since 3.3: add screen option toggles
3
- postboxes.add_postbox_toggles(pagenow);
4
5
- function template() {
6
- var metabox = $(this).closest('#yarpp_display_web, #yarpp_display_rss');
7
- if (!metabox.length) return;
8
-
9
- value = metabox.find('.use_template').val();
10
-
11
- metabox.find('.yarpp_subbox').hide();
12
- metabox.find('.template_options_' + value).show();
13
- excerpt.apply(metabox);
14
- }
15
- $('.use_template').each(template).change(template);
16
-
17
- function excerpt() {
18
- var metabox = $(this).closest('#yarpp_display_web, #yarpp_display_rss');
19
- metabox.find('.excerpted').toggle(
20
!!(metabox.find('.use_template').val() === 'builtin' && metabox.find('.show_excerpt input').attr('checked'))
21
);
22
- }
23
- $('.show_excerpt, .use_template, #yarpp-rss_display').click(excerpt);
24
-
25
- var loaded_demo_web = false;
26
- function display() {
27
- if ( !$('#yarpp_display_web .inside').is(':visible') )
28
- return;
29
30
- $( '.yarpp_code_display' ).toggle( $('#yarpp_display_code').is(':checked') );
31
- if ( $('#yarpp_display_web .yarpp_code_display').is(':visible') && !loaded_demo_web ) {
32
- loaded_demo_web = true;
33
- var demo_web = $('#display_demo_web');
34
- $.ajax({type:'POST',
35
- url: ajaxurl,
36
- data: {
37
- action: 'yarpp_display_demo',
38
- domain: 'website',
39
- '_ajax_nonce': $('#yarpp_display_demo-nonce').val()
40
- },
41
- beforeSend:function(){demo_web.html(loading)},
42
- success:function(html){demo_web.html('<pre>'+html+'</pre>')},
43
- dataType:'html'});
44
- }
45
- }
46
- $('#yarpp_display_web .handlediv, #yarpp_display_web-hide').click(display);
47
- display();
48
49
- var loaded_demo_rss = false;
50
- function rss_display() {
51
- if ( !$('#yarpp_display_rss .inside').is(':visible') )
52
- return;
53
- if ( $('#yarpp-rss_display').is(':checked') ) {
54
- $('.rss_displayed').show();
55
- $( '.yarpp_code_display' ).toggle( $('#yarpp_display_code').is(':checked') );
56
- if ( $('#yarpp_display_rss .yarpp_code_display').is(':visible') && !loaded_demo_rss ) {
57
- loaded_demo_rss = true;
58
- var demo_rss = $('#display_demo_rss');
59
- $.ajax({type:'POST',
60
- url: ajaxurl,
61
- data: {
62
- action: 'yarpp_display_demo',
63
- domain: 'rss',
64
- '_ajax_nonce': $('#yarpp_display_demo-nonce').val()
65
- },
66
- beforeSend:function(){demo_rss.html(loading)},
67
- success:function(html){demo_rss.html('<pre>'+html+'</pre>')},
68
- dataType:'html'});
69
- }
70
- $('#yarpp_display_rss').each(template);
71
- } else {
72
- $('.rss_displayed').hide();
73
- }
74
- }
75
- $('#yarpp-rss_display, #yarpp_display_rss .handlediv, #yarpp_display_rss-hide').click(rss_display);
76
- rss_display();
77
78
- var loaded_disallows = false;
79
- function load_disallows() {
80
- if ( loaded_disallows || !$('#yarpp_pool .inside').is(':visible') )
81
- return;
82
- loaded_disallows = true;
83
-
84
- var finished_taxonomies = {},
85
- term_indices = {};
86
- function load_disallow(taxonomy) {
87
- if (taxonomy in finished_taxonomies)
88
- return;
89
- var display = $('#exclude_' + taxonomy);
90
- // only do one query at a time:
91
- if (display.find('.loading').length)
92
- return;
93
-
94
- if ( taxonomy in term_indices )
95
- term_indices[taxonomy] = term_indices[taxonomy] + 100;
96
- else
97
- term_indices[taxonomy] = 0;
98
- $.ajax({type:'POST',
99
- url: ajaxurl,
100
- data: { action: 'yarpp_display_exclude_terms',
101
- taxonomy: taxonomy,
102
- offset: term_indices[taxonomy],
103
- '_ajax_nonce': $('#yarpp_display_exclude_terms-nonce').val()
104
- },
105
- beforeSend:function(){
106
- display.append(loading)
107
- },
108
- success:function(html){
109
- display.find('.loading').remove();
110
- if (':(' == html) { // no more :(
111
- finished_taxonomies[taxonomy] = true;
112
- return;
113
- }
114
- display.append(html);
115
- },
116
- dataType:'html'}
117
- );
118
- }
119
-
120
- $('.exclude_terms').each(function() {
121
- var id = jQuery(this).attr('id'), taxonomy;
122
- if (!id)
123
- return;
124
-
125
- taxonomy = id.replace('exclude_','');
126
-
127
- load_disallow(taxonomy);
128
- $('#exclude_' + taxonomy).parent('.yarpp_scroll_wrapper').scroll(function() {
129
- var parent = $(this),
130
- content = parent.children('div');
131
- if ( parent.scrollTop() + parent.height() > content.height() - 10 )
132
- load_disallow(taxonomy);
133
- })
134
- })
135
-
136
- }
137
- $('#yarpp_pool .handlediv, #yarpp_pool-hide').click(load_disallows);
138
- load_disallows();
139
140
- function show_help( section ) {
141
- $('#tab-link-' + section + ' a').click();
142
- $('#contextual-help-link').click();
143
- }
144
- $('#yarpp-optin-learnmore').click(function() { show_help('optin'); });
145
- $('#yarpp-help-cpt').click(function() { show_help('dev'); });
146
- if ( location.hash == '#help-optin' )
147
- setTimeout( function() { show_help('optin'); } );
148
149
- $('.yarpp_help[data-help]').hover(function() {
150
- var that = $(this),
151
- help = '<p>' + that.attr('data-help') + '</p>',
152
- options = {
153
- content: help,
154
- position: {
155
- edge: isRtl ? 'right' : 'left',
156
- align: 'center',
157
- of: that
158
- },
159
- document: {body: that}
160
- };
161
-
162
- var pointer = that.pointer(options).pointer('open');
163
- that.closest('.yarpp_form_row, p').mouseleave(function () {
164
- pointer.pointer('close');
165
- });
166
- });
167
168
- $('.yarpp_template_button[data-help]').hover(function() {
169
- var that = $(this),
170
- help = '<p>' + that.attr('data-help') + '</p>',
171
- options = {
172
- content: help,
173
- position: {
174
- edge: 'bottom',
175
- // align: 'center',
176
- of: that
177
- },
178
- document: {body: that}
179
- };
180
-
181
- var pointer = that.pointer(options).pointer('open');
182
- that.mouseleave(function () {
183
- pointer.pointer('close');
184
- });
185
- });
186
- $('.yarpp_template_button:not(.disabled)').click(function() {
187
- $(this).siblings('input')
188
- .val($(this).attr('data-value'))
189
- .change();
190
- $(this).siblings().removeClass('active');
191
- $(this).addClass('active');
192
- });
193
194
- $('.yarpp_copy_templates_button').live('click', function() {
195
- window.location = window.location + (window.location.search.length ? '&' : '?') + 'action=copy_templates&_ajax_nonce=' + $('#yarpp_copy_templates-nonce').val();
196
- });
197
-
198
- function template_info() {
199
- var template = $(this).find('option:selected'),
200
- row = template.closest('.yarpp_form_row');
201
- if ( !!template.attr('data-url') ) {
202
- row.find('.template_author_wrap')
203
- .toggle( !!template.attr('data-author') )
204
- .find('span').empty().append('<a>' + template.attr('data-author') + '</a>')
205
- .attr('href', template.attr('data-url'));
206
- } else {
207
- row.find('.template_author_wrap')
208
- .toggle( !!template.attr('data-author') )
209
- .find('span').text(template.attr('data-author'));
210
- }
211
- row.find('.template_description_wrap')
212
- .toggle( !!template.attr('data-description') )
213
- .find('span').text(template.attr('data-description'));
214
- row.find('.template_file_wrap')
215
- .toggle( !!template.attr('data-basename') )
216
- .find('span').text(template.attr('data-basename'));
217
- }
218
- $('#template_file, #rss_template_file')
219
- .each(template_info)
220
- .change(template_info);
221
222
- var loaded_optin_data = false;
223
- function _display_optin_data() {
224
- if ( !$('#optin_data_frame').is(':visible') || loaded_optin_data )
225
- return;
226
- loaded_optin_data = true;
227
- var frame = $('#optin_data_frame');
228
- $.ajax({type:'POST',
229
- url: ajaxurl,
230
- data: {
231
- action: 'yarpp_optin_data',
232
- '_ajax_nonce': $('#yarpp_optin_data-nonce').val()
233
- },
234
- beforeSend:function(){frame.html(loading)},
235
- success:function(html){frame.html('<pre>'+html+'</pre>')},
236
- dataType:'html'});
237
- }
238
- function display_optin_data() {
239
- setTimeout(_display_optin_data, 0);
240
- }
241
- $('#yarpp-optin-learnmore, a[aria-controls=tab-panel-optin]').bind('click focus', display_optin_data);
242
- display_optin_data();
243
-
244
- function sync_no_results() {
245
- var value = $(this).find('input').attr('value');
246
- if ( $(this).hasClass('sync_no_results') )
247
- $('.sync_no_results input').attr('value', value);
248
- if ( $(this).hasClass('sync_rss_no_results') )
249
- $('.sync_rss_no_results input').attr('value', value);
250
- }
251
- $('.sync_no_results, .sync_rss_no_results').change(sync_no_results);
252
-
253
- $('#yarpp_display_code').click(function() {
254
- var args = {
255
- action: 'yarpp_set_display_code',
256
- '_ajax_nonce': $('#yarpp_set_display_code-nonce').val()
257
- };
258
- if ( $(this).is(':checked') )
259
- args.checked = true;
260
- $.ajax({type:'POST', url: ajaxurl, data: args});
261
- display();
262
- rss_display();
263
- });
264
-
265
- function auto_display_archive() {
266
- var available = $('.yarpp_form_post_types').is(':has(input[type=checkbox]:checked)');
267
- $('#yarpp-auto_display_archive')
268
- .attr('disabled', !available);
269
- if ( !available )
270
- $('#yarpp-auto_display_archive').attr('checked', false);
271
- }
272
- $('.yarpp_form_post_types input[type=checkbox]').change(auto_display_archive);
273
- auto_display_archive();
274
275
- $("#yarpp_fulltext_expand").click(function(e){
276
- e.preventDefault();
277
- var $details = $("#yarpp_fulltext_details");
278
279
- $details.slideToggle();
280
281
- if ($details.hasClass('hidden')) {
282
- $details.removeClass('hidden');
283
- $(this).text('Hide Details [-]');
284
- }else{
285
- $details.addClass('hidden');
286
- $(this).text('Show Details [+]');
287
- }
288
- });
289
});
1
jQuery(function($) {
2
+ // since 3.3: add screen option toggles
3
+ postboxes.add_postbox_toggles(pagenow);
4
5
+ function template() {
6
+ var metabox = $(this).closest('#yarpp_display_web, #yarpp_display_rss');
7
+ if (!metabox.length) return;
8
+
9
+ value = metabox.find('.use_template').val();
10
+
11
+ metabox.find('.yarpp_subbox').hide();
12
+ metabox.find('.template_options_' + value).show();
13
+ excerpt.apply(metabox);
14
+ }
15
+ $('.use_template').each(template).change(template);
16
+
17
+ function excerpt() {
18
+ var metabox = $(this).closest('#yarpp_display_web, #yarpp_display_rss');
19
+ metabox.find('.excerpted').toggle(
20
!!(metabox.find('.use_template').val() === 'builtin' && metabox.find('.show_excerpt input').attr('checked'))
21
);
22
+ }
23
+ $('.show_excerpt, .use_template, #yarpp-rss_display').click(excerpt);
24
+
25
+ var loaded_demo_web = false;
26
+ function display() {
27
+ if ( !$('#yarpp_display_web .inside').is(':visible') )
28
+ return;
29
30
+ $( '.yarpp_code_display' ).toggle( $('#yarpp_display_code').is(':checked') );
31
+ if ( $('#yarpp_display_web .yarpp_code_display').is(':visible') && !loaded_demo_web ) {
32
+ loaded_demo_web = true;
33
+ var demo_web = $('#display_demo_web');
34
+ $.ajax({type:'POST',
35
+ url: ajaxurl,
36
+ data: {
37
+ action: 'yarpp_display_demo',
38
+ domain: 'website',
39
+ '_ajax_nonce': $('#yarpp_display_demo-nonce').val()
40
+ },
41
+ beforeSend:function(){demo_web.html(loading)},
42
+ success:function(html){demo_web.html('<pre>'+html+'</pre>')},
43
+ dataType:'html'});
44
+ }
45
+ }
46
+ $('#yarpp_display_web .handlediv, #yarpp_display_web-hide').click(display);
47
+ display();
48
49
+ var loaded_demo_rss = false;
50
+ function rss_display() {
51
+ if ( !$('#yarpp_display_rss .inside').is(':visible') )
52
+ return;
53
+ if ( $('#yarpp-rss_display').is(':checked') ) {
54
+ $('.rss_displayed').show();
55
+ $( '.yarpp_code_display' ).toggle( $('#yarpp_display_code').is(':checked') );
56
+ if ( $('#yarpp_display_rss .yarpp_code_display').is(':visible') && !loaded_demo_rss ) {
57
+ loaded_demo_rss = true;
58
+ var demo_rss = $('#display_demo_rss');
59
+ $.ajax({type:'POST',
60
+ url: ajaxurl,
61
+ data: {
62
+ action: 'yarpp_display_demo',
63
+ domain: 'rss',
64
+ '_ajax_nonce': $('#yarpp_display_demo-nonce').val()
65
+ },
66
+ beforeSend:function(){demo_rss.html(loading)},
67
+ success:function(html){demo_rss.html('<pre>'+html+'</pre>')},
68
+ dataType:'html'});
69
+ }
70
+ $('#yarpp_display_rss').each(template);
71
+ } else {
72
+ $('.rss_displayed').hide();
73
+ }
74
+ }
75
+ $('#yarpp-rss_display, #yarpp_display_rss .handlediv, #yarpp_display_rss-hide').click(rss_display);
76
+ rss_display();
77
78
+ var loaded_disallows = false;
79
+ function load_disallows() {
80
+ if ( loaded_disallows || !$('#yarpp_pool .inside').is(':visible') )
81
+ return;
82
+ loaded_disallows = true;
83
+
84
+ var finished_taxonomies = {},
85
+ term_indices = {};
86
+ function load_disallow(taxonomy) {
87
+ if (taxonomy in finished_taxonomies)
88
+ return;
89
+ var display = $('#exclude_' + taxonomy);
90
+ // only do one query at a time:
91
+ if (display.find('.loading').length)
92
+ return;
93
+
94
+ if ( taxonomy in term_indices )
95
+ term_indices[taxonomy] = term_indices[taxonomy] + 100;
96
+ else
97
+ term_indices[taxonomy] = 0;
98
+ $.ajax({type:'POST',
99
+ url: ajaxurl,
100
+ data: {
101
+ action: 'yarpp_display_exclude_terms',
102
+ taxonomy: taxonomy,
103
+ offset: term_indices[taxonomy],
104
+ '_ajax_nonce': $('#yarpp_display_exclude_terms-nonce').val()
105
+ },
106
+ beforeSend:function(){
107
+ display.append(loading)
108
+ },
109
+ success:function(html){
110
+ display.find('.loading').remove();
111
+ if (':(' == html) { // no more :(
112
+ finished_taxonomies[taxonomy] = true;
113
+ return;
114
+ }
115
+ display.append(html);
116
+ },
117
+ dataType:'html'}
118
+ );
119
+ }
120
+
121
+ $('.exclude_terms').each(function() {
122
+ var id = jQuery(this).attr('id'), taxonomy;
123
+ if (!id)
124
+ return;
125
+
126
+ taxonomy = id.replace('exclude_','');
127
+
128
+ load_disallow(taxonomy);
129
+ $('#exclude_' + taxonomy).parent('.yarpp_scroll_wrapper').scroll(function() {
130
+ var parent = $(this),
131
+ content = parent.children('div');
132
+ if ( parent.scrollTop() + parent.height() > content.height() - 10 )
133
+ load_disallow(taxonomy);
134
+ })
135
+ })
136
+
137
+ }
138
+ $('#yarpp_pool .handlediv, #yarpp_pool-hide').click(load_disallows);
139
+ load_disallows();
140
141
+ function show_help( section ) {
142
+ $('#tab-link-' + section + ' a').click();
143
+ $('#contextual-help-link').click();
144
+ }
145
+ $('#yarpp-optin-learnmore').click(function() { show_help('optin'); });
146
+ $('#yarpp-help-cpt').click(function() { show_help('dev'); });
147
+ if ( location.hash == '#help-optin' )
148
+ setTimeout( function() { show_help('optin'); } );
149
150
+ $('.yarpp_help[data-help]').hover(function() {
151
+ var that = $(this),
152
+ help = '<p>' + that.attr('data-help') + '</p>',
153
+ options = {
154
+ content: help,
155
+ position: {
156
+ edge: isRtl ? 'right' : 'left',
157
+ align: 'center',
158
+ of: that
159
+ },
160
+ document: {body: that}
161
+ };
162
+
163
+ var pointer = that.pointer(options).pointer('open');
164
+ that.closest('.yarpp_form_row, p').mouseleave(function () {
165
+ pointer.pointer('close');
166
+ });
167
+ });
168
169
+ $('.yarpp_template_button[data-help]').hover(function() {
170
+ var that = $(this),
171
+ help = '<p>' + that.attr('data-help') + '</p>',
172
+ options = {
173
+ content: help,
174
+ position: {
175
+ edge: 'bottom',
176
+ // align: 'center',
177
+ of: that
178
+ },
179
+ document: {body: that}
180
+ };
181
+
182
+ var pointer = that.pointer(options).pointer('open');
183
+ that.mouseleave(function () {
184
+ pointer.pointer('close');
185
+ });
186
+ });
187
+ $('.yarpp_template_button:not(.disabled)').click(function() {
188
+ $(this).siblings('input')
189
+ .val($(this).attr('data-value'))
190
+ .change();
191
+ $(this).siblings().removeClass('active');
192
+ $(this).addClass('active');
193
+ });
194
195
+ $('.yarpp_copy_templates_button').live('click', function() {
196
+ window.location = window.location + (window.location.search.length ? '&' : '?') + 'action=copy_templates&_ajax_nonce=' + $('#yarpp_copy_templates-nonce').val();
197
+ });
198
+
199
+ function template_info() {
200
+ var template = $(this).find('option:selected'),
201
+ row = template.closest('.yarpp_form_row');
202
+ if ( !!template.attr('data-url') ) {
203
+ row.find('.template_author_wrap')
204
+ .toggle( !!template.attr('data-author') )
205
+ .find('span').empty().append('<a>' + template.attr('data-author') + '</a>')
206
+ .attr('href', template.attr('data-url'));
207
+ } else {
208
+ row.find('.template_author_wrap')
209
+ .toggle( !!template.attr('data-author') )
210
+ .find('span').text(template.attr('data-author'));
211
+ }
212
+ row.find('.template_description_wrap')
213
+ .toggle( !!template.attr('data-description') )
214
+ .find('span').text(template.attr('data-description'));
215
+ row.find('.template_file_wrap')
216
+ .toggle( !!template.attr('data-basename') )
217
+ .find('span').text(template.attr('data-basename'));
218
+ }
219
+ $('#template_file, #rss_template_file')
220
+ .each(template_info)
221
+ .change(template_info);
222
223
+ var loaded_optin_data = false;
224
+ function _display_optin_data() {
225
+ if ( !$('#optin_data_frame').is(':visible') || loaded_optin_data )
226
+ return;
227
+ loaded_optin_data = true;
228
+ var frame = $('#optin_data_frame');
229
+ $.ajax({type:'POST',
230
+ url: ajaxurl,
231
+ data: {
232
+ action: 'yarpp_optin_data',
233
+ '_ajax_nonce': $('#yarpp_optin_data-nonce').val()
234
+ },
235
+ beforeSend:function(){frame.html(loading)},
236
+ success:function(html){frame.html('<pre>'+html+'</pre>')},
237
+ dataType:'html'});
238
+ }
239
+ function display_optin_data() {
240
+ setTimeout(_display_optin_data, 0);
241
+ }
242
+ $('#yarpp-optin-learnmore, a[aria-controls=tab-panel-optin]').bind('click focus', display_optin_data);
243
+ display_optin_data();
244
+
245
+ function sync_no_results() {
246
+ var value = $(this).find('input').attr('value');
247
+ if ( $(this).hasClass('sync_no_results') )
248
+ $('.sync_no_results input').attr('value', value);
249
+ if ( $(this).hasClass('sync_rss_no_results') )
250
+ $('.sync_rss_no_results input').attr('value', value);
251
+ }
252
+ $('.sync_no_results, .sync_rss_no_results').change(sync_no_results);
253
+
254
+ $('#yarpp_display_code').click(function() {
255
+ var args = {
256
+ action: 'yarpp_set_display_code',
257
+ '_ajax_nonce': $('#yarpp_set_display_code-nonce').val()
258
+ };
259
+ if ( $(this).is(':checked') )
260
+ args.checked = true;
261
+ $.ajax({type:'POST', url: ajaxurl, data: args});
262
+ display();
263
+ rss_display();
264
+ });
265
+
266
+ function auto_display_archive() {
267
+ var available = $('.yarpp_form_post_types').is(':has(input[type=checkbox]:checked)');
268
+ $('#yarpp-auto_display_archive')
269
+ .attr('disabled', !available);
270
+ if ( !available )
271
+ $('#yarpp-auto_display_archive').attr('checked', false);
272
+ }
273
+
274
+ $('.yarpp_form_post_types input[type=checkbox]').change(auto_display_archive);
275
+ auto_display_archive();
276
277
+ $("#yarpp_fulltext_expand").click(function(e){
278
+ e.preventDefault();
279
+ var $details = $("#yarpp_fulltext_details");
280
281
+ $details.slideToggle();
282
283
+ if ($details.hasClass('hidden')) {
284
+ $details.removeClass('hidden');
285
+ $(this).text('Hide Details [-]');
286
+ }else{
287
+ $details.addClass('hidden');
288
+ $(this).text('Show Details [+]');
289
+ }
290
+ });
291
});
js/options_switch.js CHANGED
@@ -1,75 +1,81 @@
1
function yarppMakeTheSwitch($,data,url){
2
- $.get(
3
- url,
4
- data,
5
- function(resp){
6
- if(resp === 'ok'){
7
- window.location.href = './options-general.php?page=yarpp';
8
- }
9
- }
10
- );
11
}
12
13
jQuery(document).ready(function($){
14
- $('.yarpp_switch_button').on('click',function(e){
15
- e.preventDefault();
16
- var url = $(this).attr('href'),
17
- data = { go : $(this).data('go') };
18
-
19
- if(data.go === 'basic'){
20
- $('#wpwrap').after(
21
- '<div id="yarpp_pro_disable_overlay">'+
22
- '</div>'+
23
- '<div id="yarpp_pro_disable_confirm">'+
24
- '<p>'+
25
- 'Are you sure you would like to deactivate YARPP Pro?'+
26
- '<br/>'+
27
- 'Doing so will remove all <strong>YARPP Pro</strong> '+
28
- 'content from your site, including sidebar widgets.'+
29
- '</p>'+
30
- '<br/>'+
31
- '<a id="yarpp_proceed_deactivation" class="button">Deactivate YARPP Pro</a>'+
32
- '&nbsp;&nbsp;&nbsp;&nbsp;'+
33
- '<a id="yarpp_cancel_deactivation" class="button-primary">Cancel Deactivation</a>'+
34
- '</div>'
35
- );
36
- $('#yarpp_proceed_deactivation').on('click',function(){
37
- yarppMakeTheSwitch($,data,url);
38
- });
39
-
40
- $('#yarpp_cancel_deactivation').on('click',function(){
41
- window.location.reload();
42
- });
43
-
44
- } else {
45
- yarppMakeTheSwitch($,data,url);
46
- }
47
- });
48
49
- $('#yarpp-display-mode-save').on('click',function(e){
50
- e.preventDefault();
51
- var url = $(this).attr('href'),
52
- data = {ypsdt : true, types : []};
53
54
- $(this).after($('<span class="spinner"></span>'));
55
56
- $i = 0;
57
- $('input','#yarpp-display-mode').each(function(idx,val){
58
- if(val.checked) {
59
- data.types[$i] = val.value;
60
- $i++;
61
- }
62
- });
63
64
- $.get(url,data,function(resp){
65
- setTimeout(function(){
66
- if(resp === 'ok'){
67
- $('.spinner','#yarpp-display-mode').remove();
68
- } else {
69
- $('#yarpp-display-mode').append($('<span style="vertical-align: middle" class="error-message">Something went wrong saving your settings. Please refresh the page and try again.</span>'));
70
- }
71
- },1000);
72
- });
73
});
74
75
});
1
function yarppMakeTheSwitch($,data,url){
2
+ $.get(
3
+ url,
4
+ data,
5
+ function(resp){
6
+ if(resp === 'ok'){
7
+ window.location.href = './options-general.php?page=yarpp';
8
+ }
9
+ }
10
+ );
11
}
12
13
jQuery(document).ready(function($){
14
15
+ $('.yarpp_switch_button').on('click',function(e){
16
+ e.preventDefault();
17
+ var url = ajaxurl,
18
+ data = {
19
+ action: 'yarpp_switch',
20
+ go: $(this).data('go'),
21
+ '_ajax_nonce': $('#yarpp_switch-nonce').val()
22
+ };
23
+
24
+ if(data.go === 'basic'){
25
+ $('#wpwrap').after(
26
+ '<div id="yarpp_pro_disable_overlay">'+
27
+ '</div>'+
28
+ '<div id="yarpp_pro_disable_confirm">'+
29
+ '<p>'+
30
+ 'Are you sure you would like to deactivate YARPP Pro? '+
31
+ 'Doing so will remove all <strong>YARPP Pro</strong> '+
32
+ 'content from your site, including sidebar widgets.'+
33
+ '</p>'+
34
+ '<br/>'+
35
+ '<a id="yarpp_proceed_deactivation" class="button">Deactivate YARPP Pro</a>'+
36
+ '&nbsp;&nbsp;&nbsp;&nbsp;'+
37
+ '<a id="yarpp_cancel_deactivation" class="button-primary">Cancel Deactivation</a>'+
38
+ '</div>'
39
+ );
40
+ $('#yarpp_proceed_deactivation').on('click',function(){
41
+ yarppMakeTheSwitch($,data,url);
42
+ });
43
+
44
+ $('#yarpp_cancel_deactivation').on('click',function(){
45
+ window.location.reload();
46
+ });
47
+ } else {
48
+ yarppMakeTheSwitch($,data,url);
49
+ }
50
+ });
51
52
+ $('#yarpp-display-mode-save').on('click',function(e){
53
+ e.preventDefault();
54
+ var url = $(this).attr('href'),
55
+ data = {
56
+ ypsdt : true,
57
+ types : []
58
+ };
59
60
+ $(this).after($('<span class="spinner"></span>'));
61
62
+ $i = 0;
63
+ $('input','#yarpp-display-mode').each(function(idx,val){
64
+ if(val.checked) {
65
+ data.types[$i] = val.value;
66
+ $i++;
67
+ }
68
+ });
69
+
70
+ $.get(url,data,function(resp){
71
+ setTimeout(function(){
72
+ if(resp === 'ok'){
73
+ $('.spinner','#yarpp-display-mode').remove();
74
+ } else {
75
+ $('#yarpp-display-mode').append($('<span style="vertical-align: middle" class="error-message">Something went wrong saving your settings. Please refresh the page and try again.</span>'));
76
+ }
77
+ },1000);
78
});
79
+ });
80
81
});
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 3.7
5
Requires PHP: 5.2
6
License: GPLv2 or later
7
Tested up to: 5.2
8
- Stable tag: 5.0.1
9
10
Display a list of related posts on your site based on a powerful unique algorithm. Optionally, earn money by including sponsored content.
11
@@ -21,7 +21,7 @@ Yet Another Related Posts Plugin (YARPP) displays pages, posts, and custom post
21
* **An advanced and versatile algorithm**: Using a customizable algorithm considering post titles, content, tags, categories, and custom taxonomies, YARPP finds related content from across your site. [Learn More.](https://wordpress.tv/2011/01/29/michael-mitcho-erlewine-the-yet-another-related-posts-plugin-algorithm-explained/)
22
* **Related posts in feeds**: Display related posts in RSS feeds with custom display options.
23
24
- The Yet Another Related Posts Plugin is the most popular [WordPress Related Posts plugin](https://wordpress.org/plugins/yet-another-related-posts-plugin/), encouraging Discovery and Engagement since 2008.
25
26
This plugin requires PHP 5, MySQL 4.1, and WordPress 3.3 or greater. See [the FAQ](https://wordpress.org/plugins/yet-another-related-posts-plugin/faq/) for answers to common questions.
27
@@ -234,6 +234,14 @@ Yes. Any taxonomy, including custom taxonomies, may be specified in the `weight`
234
If you would like to choose custom taxonomies to choose in the YARPP settings UI, either to exclude certain terms or to consider them in the relatedness formula via the UI, the taxonomy must (a) have either the `show_ui` or `yarpp_support` attribute set to true and (b) must apply to either the post types `post` or `page` or both.
235
236
== Changelog ==
237
= 5.0.1 (2019-07-08) =
238
* [Bugfix](https://wordpress.org/support/topic/styles_thumbnails-css-php-invalid-value/): Fixed invalid CSS rule
239
* Enhancement: Set Cache headers for CSS file
@@ -878,6 +886,6 @@ After a break of many years, the plugin is 100% supported now that the baton has
878
* Initial upload
879
880
== Upgrade Notice ==
881
- = 5.0.1 =
882
We update this plugin regularly so we can make it better for you. Update to the latest version for all of the available features and improvements. Thank you for using YARPP!
883
5
Requires PHP: 5.2
6
License: GPLv2 or later
7
Tested up to: 5.2
8
+ Stable tag: 5.1.0
9
10
Display a list of related posts on your site based on a powerful unique algorithm. Optionally, earn money by including sponsored content.
11
21
* **An advanced and versatile algorithm**: Using a customizable algorithm considering post titles, content, tags, categories, and custom taxonomies, YARPP finds related content from across your site. [Learn More.](https://wordpress.tv/2011/01/29/michael-mitcho-erlewine-the-yet-another-related-posts-plugin-algorithm-explained/)
22
* **Related posts in feeds**: Display related posts in RSS feeds with custom display options.
23
24
+ The **Yet Another Related Posts Plugin** is the most popular [WordPress Related Posts plugin](https://wordpress.org/plugins/yet-another-related-posts-plugin/), encouraging Discovery and Engagement since 2008.
25
26
This plugin requires PHP 5, MySQL 4.1, and WordPress 3.3 or greater. See [the FAQ](https://wordpress.org/plugins/yet-another-related-posts-plugin/faq/) for answers to common questions.
27
234
If you would like to choose custom taxonomies to choose in the YARPP settings UI, either to exclude certain terms or to consider them in the relatedness formula via the UI, the taxonomy must (a) have either the `show_ui` or `yarpp_support` attribute set to true and (b) must apply to either the post types `post` or `page` or both.
235
236
== Changelog ==
237
+ = 5.1.0 (2019-07-10) =
238
+ * [Bugfix](https://wordpress.org/support/topic/yarpp-broken-in-gutenberg-editor/): Related Posts metabox did not load within Gutenberg Editor
239
+ * Bugfix: Fixed 'Deactivate YARPP Pro' button, including moving functionality to proper WP AJAX functions
240
+ * Enhancement: Related Post thumbnails should not be 'pinnable' to Pinterest
241
+ * Enhancement: Review Notice
242
+ * Enhancement: Modernized Editor Metabox design
243
+ * Enhancement: Added 'Refresh' button to Editor Metabox
244
+
245
= 5.0.1 (2019-07-08) =
246
* [Bugfix](https://wordpress.org/support/topic/styles_thumbnails-css-php-invalid-value/): Fixed invalid CSS rule
247
* Enhancement: Set Cache headers for CSS file
886
* Initial upload
887