Version Description
- Extract thumbnails from post content
- Statistics for mobile devices
- Exclude pages from related posts
- Bugfixes
Download this release
Release Info
Developer | jureham |
Plugin | WordPress Related Posts |
Version | 2.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 2.1
- config.php +21 -0
- readme.txt +7 -1
- recommendations.php +21 -5
- settings.php +199 -190
- static/css/dashboard.css +22 -14
- static/img/desktop_icon.png +0 -0
- static/img/mobile_icon.png +0 -0
- static/js/dashboard.js +9 -7
- thumbnailer.php +125 -17
- wp_related_posts.php +14 -5
config.php
CHANGED
@@ -38,6 +38,8 @@ define("WP_RP_RECOMMENDATIONS_CATEGORIES_SCORE", 5);
|
|
38 |
|
39 |
define("WP_RP_RECOMMENDATIONS_NUM_PREGENERATED_POSTS", 50);
|
40 |
|
|
|
|
|
41 |
global $wp_rp_options, $wp_rp_meta;
|
42 |
$wp_rp_options = false;
|
43 |
$wp_rp_meta = false;
|
@@ -201,6 +203,25 @@ function wp_rp_install() {
|
|
201 |
wp_rp_related_posts_db_table_install();
|
202 |
}
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
function wp_rp_migrate_1_7() {
|
205 |
$wp_rp_meta = get_option('wp_rp_meta');
|
206 |
$wp_rp_options = get_option('wp_rp_options');
|
38 |
|
39 |
define("WP_RP_RECOMMENDATIONS_NUM_PREGENERATED_POSTS", 50);
|
40 |
|
41 |
+
define("WP_RP_THUMBNAILS_NUM_PREGENERATED_POSTS", 50);
|
42 |
+
|
43 |
global $wp_rp_options, $wp_rp_meta;
|
44 |
$wp_rp_options = false;
|
45 |
$wp_rp_meta = false;
|
203 |
wp_rp_related_posts_db_table_install();
|
204 |
}
|
205 |
|
206 |
+
function wp_rp_migrate_2_0() {
|
207 |
+
$wp_rp_meta = get_option('wp_rp_meta');
|
208 |
+
$wp_rp_options = get_option('wp_rp_options');
|
209 |
+
|
210 |
+
$wp_rp_meta['version'] = '2.1';
|
211 |
+
|
212 |
+
if ($wp_rp_options['default_thumbnail_path']) {
|
213 |
+
$upload_dir = wp_upload_dir();
|
214 |
+
$wp_rp_options['default_thumbnail_path'] = $upload_dir['baseurl'] . $wp_rp_options['default_thumbnail_path'];
|
215 |
+
}
|
216 |
+
|
217 |
+
update_option('wp_rp_options', $wp_rp_options);
|
218 |
+
update_option('wp_rp_meta', $wp_rp_meta);
|
219 |
+
|
220 |
+
if($wp_rp_options['display_thumbnail'] && $wp_rp_options['thumbnail_use_attached']) {
|
221 |
+
wp_rp_process_latest_post_thumbnails();
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
function wp_rp_migrate_1_7() {
|
226 |
$wp_rp_meta = get_option('wp_rp_meta');
|
227 |
$wp_rp_options = get_option('wp_rp_options');
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
5 |
License: GPLv2
|
6 |
Requires at least: 3.3
|
7 |
Tested up to: 3.5
|
8 |
-
Stable tag: 2.
|
9 |
|
10 |
WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
|
11 |
|
@@ -63,6 +63,12 @@ Yes, related posts are responsive so they adapt to the screen size to ensure max
|
|
63 |
|
64 |
== Changelog ==
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
= 2.0.2 =
|
67 |
* Fixed bug for post_types with no tags
|
68 |
|
5 |
License: GPLv2
|
6 |
Requires at least: 3.3
|
7 |
Tested up to: 3.5
|
8 |
+
Stable tag: 2.1
|
9 |
|
10 |
WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
|
11 |
|
63 |
|
64 |
== Changelog ==
|
65 |
|
66 |
+
= 2.1 =
|
67 |
+
* Extract thumbnails from post content
|
68 |
+
* Statistics for mobile devices
|
69 |
+
* Exclude pages from related posts
|
70 |
+
* Bugfixes
|
71 |
+
|
72 |
= 2.0.2 =
|
73 |
* Fixed bug for post_types with no tags
|
74 |
|
recommendations.php
CHANGED
@@ -16,9 +16,11 @@ function wp_rp_update_tags($post_id) {
|
|
16 |
$wpdb->prepare('DELETE from ' . $wpdb->prefix . 'wp_rp_tags WHERE post_id=%d', $post->ID)
|
17 |
);
|
18 |
|
19 |
-
if ($post->post_status
|
20 |
-
|
21 |
}
|
|
|
|
|
22 |
}
|
23 |
add_action('save_post', 'wp_rp_update_tags');
|
24 |
|
@@ -161,8 +163,11 @@ function wp_rp_fetch_related_posts_v2($limit = 10, $exclude_ids = array()) {
|
|
161 |
|
162 |
$tags_query = "SELECT label FROM " . $wpdb->prefix . "wp_rp_tags WHERE post_id=$post->ID;";
|
163 |
$tags = $wpdb->get_col($tags_query, 0);
|
164 |
-
if (
|
165 |
$tags = wp_rp_generate_tags($post);
|
|
|
|
|
|
|
166 |
}
|
167 |
|
168 |
if($options['exclude_categories']) {
|
@@ -173,6 +178,9 @@ function wp_rp_fetch_related_posts_v2($limit = 10, $exclude_ids = array()) {
|
|
173 |
}
|
174 |
|
175 |
$total_number_of_posts = $wpdb->get_col("SELECT count(distinct(post_id)) FROM " . $wpdb->prefix . "wp_rp_tags;", 0);
|
|
|
|
|
|
|
176 |
$total_number_of_posts = $total_number_of_posts[0];
|
177 |
|
178 |
$post_id_query = $wpdb->prepare("
|
@@ -196,10 +204,18 @@ function wp_rp_fetch_related_posts_v2($limit = 10, $exclude_ids = array()) {
|
|
196 |
GROUP BY target.post_id
|
197 |
ORDER BY score desc
|
198 |
LIMIT %d;",
|
199 |
-
array_merge(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
$related_posts_with_score = $wpdb->get_results($post_id_query, 0);
|
202 |
-
if (
|
203 |
return array();
|
204 |
}
|
205 |
|
16 |
$wpdb->prepare('DELETE from ' . $wpdb->prefix . 'wp_rp_tags WHERE post_id=%d', $post->ID)
|
17 |
);
|
18 |
|
19 |
+
if ($post->post_type === 'page' || $post->post_status !== 'publish') {
|
20 |
+
return;
|
21 |
}
|
22 |
+
|
23 |
+
wp_rp_generate_tags($post);
|
24 |
}
|
25 |
add_action('save_post', 'wp_rp_update_tags');
|
26 |
|
163 |
|
164 |
$tags_query = "SELECT label FROM " . $wpdb->prefix . "wp_rp_tags WHERE post_id=$post->ID;";
|
165 |
$tags = $wpdb->get_col($tags_query, 0);
|
166 |
+
if (empty($tags)) {
|
167 |
$tags = wp_rp_generate_tags($post);
|
168 |
+
if (empty($tags)) {
|
169 |
+
return array();
|
170 |
+
}
|
171 |
}
|
172 |
|
173 |
if($options['exclude_categories']) {
|
178 |
}
|
179 |
|
180 |
$total_number_of_posts = $wpdb->get_col("SELECT count(distinct(post_id)) FROM " . $wpdb->prefix . "wp_rp_tags;", 0);
|
181 |
+
if (empty($total_number_of_posts)) {
|
182 |
+
return array();
|
183 |
+
}
|
184 |
$total_number_of_posts = $total_number_of_posts[0];
|
185 |
|
186 |
$post_id_query = $wpdb->prepare("
|
204 |
GROUP BY target.post_id
|
205 |
ORDER BY score desc
|
206 |
LIMIT %d;",
|
207 |
+
array_merge(
|
208 |
+
array($total_number_of_posts, $total_number_of_posts),
|
209 |
+
$tags,
|
210 |
+
array($exclude_ids_str),
|
211 |
+
$tags,
|
212 |
+
$exclude_categories_labels,
|
213 |
+
array($limit * 2)
|
214 |
+
)
|
215 |
+
); // limit * just in case
|
216 |
|
217 |
$related_posts_with_score = $wpdb->get_results($post_id_query, 0);
|
218 |
+
if (empty($related_posts_with_score)) {
|
219 |
return array();
|
220 |
}
|
221 |
|
settings.php
CHANGED
@@ -262,6 +262,8 @@ function wp_rp_settings_page()
|
|
262 |
$new_options['exclude_categories'] = trim($postdata['wp_rp_exclude_categories']);
|
263 |
}
|
264 |
|
|
|
|
|
265 |
if(isset($postdata['wp_rp_theme_name'])) { // If this isn't set, maybe the AJAX didn't load...
|
266 |
$new_options['theme_name'] = trim($postdata['wp_rp_theme_name']);
|
267 |
|
@@ -295,7 +297,7 @@ function wp_rp_settings_page()
|
|
295 |
}
|
296 |
|
297 |
if (((array) $old_options) != $new_options) {
|
298 |
-
if($new_options['ctr_dashboard_enabled']) {
|
299 |
$meta['show_statistics'] = true;
|
300 |
|
301 |
if($new_options['display_thumbnail']) {
|
@@ -310,6 +312,10 @@ function wp_rp_settings_page()
|
|
310 |
} else {
|
311 |
wp_rp_add_admin_notice('updated', __('Settings saved.', 'wp_related_posts'));
|
312 |
}
|
|
|
|
|
|
|
|
|
313 |
} else {
|
314 |
// I should duplicate success message here
|
315 |
wp_rp_add_admin_notice('updated', __('Settings saved.', 'wp_related_posts'));
|
@@ -350,7 +356,6 @@ function wp_rp_settings_page()
|
|
350 |
</p>
|
351 |
</div>
|
352 |
<h2 class="title"><?php _e("Related Posts",'wp_related_posts');?></h2>
|
353 |
-
<p class="desc"><?php _e("WordPress Related Posts Plugin places a list of related articles via WordPress tags at the bottom of your post.",'wp_related_posts');?></p>
|
354 |
</div>
|
355 |
<div id="wp-rp-survey" class="updated highlight" style="display:none;"><p><?php _e("Please fill out",'wp_related_posts');?> <a class="link" target="_blank" href="http://wprelatedposts.polldaddy.com/s/quick-survey"><?php _e("a quick survey", 'wp_related_posts');?></a>.<a href="#" class="close" style="float: right;">x</a></p></div>
|
356 |
|
@@ -364,7 +369,7 @@ function wp_rp_settings_page()
|
|
364 |
Turn on Advanced Features
|
365 |
</h2>
|
366 |
<ul>
|
367 |
-
<li>Real-time Analytics provided by a <a target="_blank" href="http://
|
368 |
<li>Thumbnail Support</li>
|
369 |
<li>Promoted Content</li>
|
370 |
</ul>
|
@@ -440,204 +445,208 @@ jQuery(function($) {
|
|
440 |
<?php endif; ?>
|
441 |
|
442 |
<form method="post" enctype="multipart/form-data" action="" id="wp_rp_settings_form">
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
|
|
450 |
</div>
|
451 |
</div>
|
452 |
-
|
453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
|
455 |
-
|
|
|
456 |
|
457 |
-
|
458 |
-
|
459 |
-
<h3><?php _e("Basic Settings",'wp_related_posts');?></h3>
|
460 |
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
<input name="wp_rp_related_posts_title" type="text" id="wp_rp_related_posts_title" value="<?php esc_attr_e($options['related_posts_title']); ?>" class="regular-text" />
|
466 |
-
</td>
|
467 |
-
</tr>
|
468 |
-
<tr valign="top">
|
469 |
-
<th scope="row"><?php _e('Number of Posts:', 'wp_related_posts');?></th>
|
470 |
-
<td>
|
471 |
-
<input name="wp_rp_max_related_posts" type="number" step="1" id="wp_rp_max_related_posts" class="small-text" min="1" value="<?php esc_attr_e($options['max_related_posts']); ?>" />
|
472 |
-
</td>
|
473 |
-
</tr>
|
474 |
-
</table>
|
475 |
-
|
476 |
-
<h3>Theme Settings</h3>
|
477 |
-
<table class="form-table">
|
478 |
-
<tr id="wp_rp_theme_options_wrap">
|
479 |
-
<th scope="row">Select Theme:</th>
|
480 |
-
<td>
|
481 |
-
<label>
|
482 |
-
<input name="wp_rp_enable_themes" type="checkbox" id="wp_rp_enable_themes" value="yes"<?php checked($options["enable_themes"]); ?> />
|
483 |
-
<?php _e("Enable Themes",'wp_related_posts'); ?>*
|
484 |
-
</label>
|
485 |
-
<div class="theme-list"></div>
|
486 |
-
</td>
|
487 |
-
</tr>
|
488 |
-
<tr id="wp_rp_theme_custom_css_wrap" style="display: none; ">
|
489 |
-
<th scope="row"></th>
|
490 |
-
<td>
|
491 |
-
<textarea style="width: 300px; height: 215px;" name="wp_rp_theme_custom_css" class="custom-css"><?php echo htmlspecialchars($theme_custom_css, ENT_QUOTES); ?></textarea>
|
492 |
-
</td>
|
493 |
-
</tr>
|
494 |
-
<tr>
|
495 |
-
<th scope="row"><?php _e("Thumbnail Options:",'wp_related_posts'); ?></th>
|
496 |
-
<td>
|
497 |
-
<label>
|
498 |
-
<input name="wp_rp_display_thumbnail" type="checkbox" id="wp_rp_display_thumbnail" value="yes"<?php checked($options["display_thumbnail"]); ?> onclick="wp_rp_display_thumbnail_onclick();" />
|
499 |
-
<?php _e("Display Thumbnails For Related Posts",'wp_related_posts');?>
|
500 |
-
</label>
|
501 |
-
<br />
|
502 |
-
<span id="wp_rp_thumbnail_span" style="<?php echo $options["display_thumbnail"] ? '' : 'display:none;'; ?>">
|
503 |
-
<label>
|
504 |
-
<input name="wp_rp_thumbnail_display_title" type="checkbox" id="wp_rp_thumbnail_display_title" value="yes"<?php checked($options["thumbnail_display_title"]); ?> />
|
505 |
-
<?php _e('Display Post Titles', 'wp_related_posts');?>
|
506 |
-
</label>
|
507 |
-
<br />
|
508 |
-
|
509 |
-
<?php
|
510 |
-
global $wpdb;
|
511 |
-
|
512 |
-
$custom_fields = $wpdb->get_col( "SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY LOWER(meta_key)" );
|
513 |
-
|
514 |
-
if($custom_fields) :
|
515 |
-
?>
|
516 |
-
<label><input name="wp_rp_thumbnail_use_custom" type="radio" value="no" <?php checked(!$options['thumbnail_use_custom']); ?>> Use featured image</label>
|
517 |
-
<label><input name="wp_rp_thumbnail_use_custom" type="radio" value="yes" <?php checked($options['thumbnail_use_custom']); ?>> Use custom field</label>
|
518 |
-
|
519 |
-
<select name="wp_rp_thumbnail_custom_field" id="wp_rp_thumbnail_custom_field" class="postform">
|
520 |
-
|
521 |
-
<?php foreach ( $custom_fields as $custom_field ) : ?>
|
522 |
-
<option value="<?php esc_attr_e($custom_field); ?>"<?php selected($options["thumbnail_custom_field"], $custom_field); ?>><?php esc_html_e($custom_field);?></option>
|
523 |
-
<?php endforeach; ?>
|
524 |
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
</label>
|
533 |
-
<br />
|
534 |
-
|
535 |
-
|
536 |
-
<br />
|
537 |
-
<label>
|
538 |
-
<?php _e('For posts without images, a default image will be shown.<br/>
|
539 |
-
You can upload your own default image here','wp_related_posts');?>
|
540 |
-
<input type="file" name="wp_rp_default_thumbnail" />
|
541 |
-
</label>
|
542 |
-
<?php if($options['default_thumbnail_path']) : ?>
|
543 |
-
<span style="display: inline-block; vertical-align: top; *display: inline; zoom: 1;">
|
544 |
-
<img style="padding: 3px; border: 1px solid #DFDFDF; border-radius: 3px;" valign="top" width="80" height="80" src="<?php esc_attr_e(wp_rp_get_default_thumbnail_url()); ?>" alt="selected thumbnail" />
|
545 |
<br />
|
|
|
|
|
546 |
<label>
|
547 |
-
<input
|
548 |
-
<?php _e("
|
549 |
</label>
|
550 |
-
</span>
|
551 |
-
<?php endif; ?>
|
552 |
-
</span>
|
553 |
-
</td>
|
554 |
-
</tr>
|
555 |
-
<tr>
|
556 |
-
<th scope="row"><?php _e("Display Options:",'wp_related_posts'); ?></th>
|
557 |
-
<td>
|
558 |
-
<label>
|
559 |
-
<input name="wp_rp_display_comment_count" type="checkbox" id="wp_rp_display_comment_count" value="yes" <?php checked($options["display_comment_count"]); ?>>
|
560 |
-
<?php _e("Display Number of Comments",'wp_related_posts');?>
|
561 |
-
</label><br />
|
562 |
-
<label>
|
563 |
-
<input name="wp_rp_display_publish_date" type="checkbox" id="wp_rp_display_publish_date" value="yes" <?php checked($options["display_publish_date"]); ?>>
|
564 |
-
<?php _e("Display Publish Date",'wp_related_posts');?>
|
565 |
-
</label><br />
|
566 |
-
<label>
|
567 |
-
<input name="wp_rp_display_excerpt" type="checkbox" id="wp_rp_display_excerpt" value="yes"<?php checked($options["display_excerpt"]); ?> onclick="wp_rp_display_excerpt_onclick();" >
|
568 |
-
<?php _e("Display Post Excerpt",'wp_related_posts');?>
|
569 |
-
</label>
|
570 |
-
<label id="wp_rp_excerpt_max_length_label"<?php echo $options["display_excerpt"] ? '' : ' style="display: none;"'; ?>>
|
571 |
-
<input name="wp_rp_excerpt_max_length" type="text" id="wp_rp_excerpt_max_length" class="small-text" value="<?php esc_attr_e($options["excerpt_max_length"]); ?>" /> <span class="description"><?php _e('Maximum Number of Characters.', 'wp_related_posts'); ?></span>
|
572 |
-
</label><br/>
|
573 |
-
<label for="wp_rp_related_posts_title_tag">
|
574 |
-
<?php _e('Related Posts Title Tag', 'wp_related_posts'); ?>
|
575 |
-
<select name="wp_rp_related_posts_title_tag" id="wp_rp_related_posts_title_tag" class="postform">
|
576 |
-
<?php
|
577 |
-
foreach ($title_tags as $tag) :
|
578 |
-
?>
|
579 |
-
<option value="<?php esc_attr_e($tag); ?>"<?php selected($related_posts_title_tag, $tag); ?>><<?php esc_html_e($tag); ?>></option>
|
580 |
-
<?php endforeach; ?>
|
581 |
-
</select>
|
582 |
-
</label>
|
583 |
-
</td>
|
584 |
-
</tr>
|
585 |
-
</table>
|
586 |
-
<h3><?php _e("Other Settings:",'wp_related_posts'); ?></h3>
|
587 |
-
<table class="form-table">
|
588 |
-
<tr valign="top">
|
589 |
-
<th scope="row"><?php _e('Exclude these Categories:', 'wp_related_posts'); ?></th>
|
590 |
-
<td>
|
591 |
-
<div class="excluded-categories">
|
592 |
-
<?php
|
593 |
-
$exclude = explode(',', $options['exclude_categories']);
|
594 |
-
$args = array(
|
595 |
-
'orderby' => 'name',
|
596 |
-
'order' => 'ASC',
|
597 |
-
'hide_empty' => false
|
598 |
-
);
|
599 |
-
|
600 |
-
foreach (get_categories($args) as $category) :
|
601 |
-
?>
|
602 |
-
<label>
|
603 |
-
<input name="wp_rp_exclude_categories[]" type="checkbox" id="wp_rp_exclude_categories" value="<?php esc_attr_e($category->cat_ID); ?>"<?php checked(in_array($category->cat_ID, $exclude)); ?> />
|
604 |
-
<?php esc_html_e($category->cat_name); ?>
|
605 |
<br />
|
606 |
-
</label>
|
607 |
-
<?php endforeach; ?>
|
608 |
-
</div>
|
609 |
-
</td>
|
610 |
-
</tr>
|
611 |
-
<tr valign="top">
|
612 |
-
<td colspan="2">
|
613 |
-
<label>
|
614 |
-
<input name="wp_rp_on_single_post" type="checkbox" id="wp_rp_on_single_post" value="yes" <?php checked($options['on_single_post']); ?>>
|
615 |
-
<?php _e("Auto Insert Related Posts",'wp_related_posts');?>
|
616 |
-
</label>
|
617 |
-
(or add <pre style="display: inline"><?php wp_related_posts()?></pre> to your single post template)
|
618 |
-
<br />
|
619 |
-
<label>
|
620 |
-
<input name="wp_rp_on_rss" type="checkbox" id="wp_rp_on_rss" value="yes"<?php checked($options['on_rss']); ?>>
|
621 |
-
<?php _e("Display Related Posts in Feed",'wp_related_posts');?>
|
622 |
-
</label>
|
623 |
-
<br />
|
624 |
-
<label>
|
625 |
-
<input name="wp_rp_ctr_dashboard_enabled" type="checkbox" id="wp_rp_ctr_dashboard_enabled" value="yes" <?php checked($options['ctr_dashboard_enabled']); ?> />
|
626 |
-
<?php _e("Turn statistics on",'wp_related_posts');?>*
|
627 |
-
</label>
|
628 |
-
<br />
|
629 |
-
<label>
|
630 |
-
<input name="wp_rp_promoted_content_enabled" type="checkbox" id="wp_rp_promoted_content_enabled" value="yes" <?php checked($options['promoted_content_enabled']); ?> />
|
631 |
-
<?php _e('Promoted Content', 'wp_related_posts');?>
|
632 |
-
</label>
|
633 |
-
</td>
|
634 |
-
</tr>
|
635 |
-
</table>
|
636 |
-
<p class="submit"><input type="submit" value="<?php _e('Save changes', 'wp_related_posts'); ?>" class="button-primary" /></p>
|
637 |
|
638 |
-
|
639 |
-
|
640 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
641 |
</div>
|
642 |
</div>
|
643 |
<?php }
|
262 |
$new_options['exclude_categories'] = trim($postdata['wp_rp_exclude_categories']);
|
263 |
}
|
264 |
|
265 |
+
$preprocess_thumbnails = $new_options['display_thumbnail'] && $new_options['thumbnail_use_attached'] && (!$old_options['display_thumbnail'] || !$old_options['thumbnail_use_attached']);
|
266 |
+
|
267 |
if(isset($postdata['wp_rp_theme_name'])) { // If this isn't set, maybe the AJAX didn't load...
|
268 |
$new_options['theme_name'] = trim($postdata['wp_rp_theme_name']);
|
269 |
|
297 |
}
|
298 |
|
299 |
if (((array) $old_options) != $new_options) {
|
300 |
+
if($new_options['ctr_dashboard_enabled'] && !$old_options['ctr_dashboard_enabled']) {
|
301 |
$meta['show_statistics'] = true;
|
302 |
|
303 |
if($new_options['display_thumbnail']) {
|
312 |
} else {
|
313 |
wp_rp_add_admin_notice('updated', __('Settings saved.', 'wp_related_posts'));
|
314 |
}
|
315 |
+
|
316 |
+
if($preprocess_thumbnails) {
|
317 |
+
wp_rp_process_latest_post_thumbnails();
|
318 |
+
}
|
319 |
} else {
|
320 |
// I should duplicate success message here
|
321 |
wp_rp_add_admin_notice('updated', __('Settings saved.', 'wp_related_posts'));
|
356 |
</p>
|
357 |
</div>
|
358 |
<h2 class="title"><?php _e("Related Posts",'wp_related_posts');?></h2>
|
|
|
359 |
</div>
|
360 |
<div id="wp-rp-survey" class="updated highlight" style="display:none;"><p><?php _e("Please fill out",'wp_related_posts');?> <a class="link" target="_blank" href="http://wprelatedposts.polldaddy.com/s/quick-survey"><?php _e("a quick survey", 'wp_related_posts');?></a>.<a href="#" class="close" style="float: right;">x</a></p></div>
|
361 |
|
369 |
Turn on Advanced Features
|
370 |
</h2>
|
371 |
<ul>
|
372 |
+
<li>Real-time Analytics provided by a <a target="_blank" href="http://related-posts.com/tos/">3rd party service</a></li>
|
373 |
<li>Thumbnail Support</li>
|
374 |
<li>Promoted Content</li>
|
375 |
</ul>
|
445 |
<?php endif; ?>
|
446 |
|
447 |
<form method="post" enctype="multipart/form-data" action="" id="wp_rp_settings_form">
|
448 |
+
<?php if ($options['ctr_dashboard_enabled']): ?>
|
449 |
+
<div id="wp_rp_statistics_collapsible" block="statistics" class="collapsible<?php if(!$meta['show_statistics']) { echo " collapsed"; } ?>">
|
450 |
+
<a href="#" class="collapse-handle">Collapse</a>
|
451 |
+
<h2><?php _e('Statistics', 'wp_related_posts'); ?></h2>
|
452 |
+
<div class="container" <?php if(!$meta['show_statistics']) { echo ' style="display: none;" '; } ?>>
|
453 |
+
<div id="wp_rp_statistics_wrap">
|
454 |
+
<div class="message unavailable"><?php _e("Statistics currently unavailable",'wp_related_posts'); ?></div>
|
455 |
+
</div>
|
456 |
</div>
|
457 |
</div>
|
458 |
+
<?php endif; ?>
|
459 |
+
|
460 |
+
<div>
|
461 |
+
<h2><?php _e("Settings",'wp_related_posts');?></h2>
|
462 |
+
|
463 |
+
<?php do_action('wp_rp_admin_notices'); ?>
|
464 |
+
|
465 |
+
<div class="container">
|
466 |
+
<h3><?php _e("Basic Settings",'wp_related_posts');?></h3>
|
467 |
+
|
468 |
+
<table class="form-table">
|
469 |
+
<tr valign="top">
|
470 |
+
<th scope="row"><?php _e('Related Posts Title:', 'wp_related_posts'); ?></th>
|
471 |
+
<td>
|
472 |
+
<input name="wp_rp_related_posts_title" type="text" id="wp_rp_related_posts_title" value="<?php esc_attr_e($options['related_posts_title']); ?>" class="regular-text" />
|
473 |
+
</td>
|
474 |
+
</tr>
|
475 |
+
<tr valign="top">
|
476 |
+
<th scope="row"><?php _e('Number of Posts:', 'wp_related_posts');?></th>
|
477 |
+
<td>
|
478 |
+
<input name="wp_rp_max_related_posts" type="number" step="1" id="wp_rp_max_related_posts" class="small-text" min="1" value="<?php esc_attr_e($options['max_related_posts']); ?>" />
|
479 |
+
</td>
|
480 |
+
</tr>
|
481 |
+
</table>
|
482 |
+
|
483 |
+
<h3>Theme Settings</h3>
|
484 |
+
<table class="form-table">
|
485 |
+
<tr id="wp_rp_theme_options_wrap">
|
486 |
+
<th scope="row">Select Theme:</th>
|
487 |
+
<td>
|
488 |
+
<label>
|
489 |
+
<input name="wp_rp_enable_themes" type="checkbox" id="wp_rp_enable_themes" value="yes"<?php checked($options["enable_themes"]); ?> />
|
490 |
+
<?php _e("Enable Themes",'wp_related_posts'); ?>*
|
491 |
+
</label>
|
492 |
+
<div class="theme-list"></div>
|
493 |
+
</td>
|
494 |
+
</tr>
|
495 |
+
<tr id="wp_rp_theme_custom_css_wrap" style="display: none; ">
|
496 |
+
<th scope="row"></th>
|
497 |
+
<td>
|
498 |
+
<textarea style="width: 300px; height: 215px;" name="wp_rp_theme_custom_css" class="custom-css"><?php echo htmlspecialchars($theme_custom_css, ENT_QUOTES); ?></textarea>
|
499 |
+
</td>
|
500 |
+
</tr>
|
501 |
+
<tr>
|
502 |
+
<th scope="row"><?php _e("Thumbnail Options:",'wp_related_posts'); ?></th>
|
503 |
+
<td>
|
504 |
+
<label>
|
505 |
+
<input name="wp_rp_display_thumbnail" type="checkbox" id="wp_rp_display_thumbnail" value="yes"<?php checked($options["display_thumbnail"]); ?> onclick="wp_rp_display_thumbnail_onclick();" />
|
506 |
+
<?php _e("Display Thumbnails For Related Posts",'wp_related_posts');?>
|
507 |
+
</label>
|
508 |
+
<br />
|
509 |
+
<span id="wp_rp_thumbnail_span" style="<?php echo $options["display_thumbnail"] ? '' : 'display:none;'; ?>">
|
510 |
+
<label>
|
511 |
+
<input name="wp_rp_thumbnail_display_title" type="checkbox" id="wp_rp_thumbnail_display_title" value="yes"<?php checked($options["thumbnail_display_title"]); ?> />
|
512 |
+
<?php _e('Display Post Titles', 'wp_related_posts');?>
|
513 |
+
</label>
|
514 |
+
<br />
|
515 |
|
516 |
+
<?php
|
517 |
+
global $wpdb;
|
518 |
|
519 |
+
$custom_fields = $wpdb->get_col( "SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY LOWER(meta_key)" );
|
|
|
|
|
520 |
|
521 |
+
if($custom_fields) :
|
522 |
+
?>
|
523 |
+
<label><input name="wp_rp_thumbnail_use_custom" type="radio" value="no" <?php checked(!$options['thumbnail_use_custom']); ?>> Use featured image</label>
|
524 |
+
<label><input name="wp_rp_thumbnail_use_custom" type="radio" value="yes" <?php checked($options['thumbnail_use_custom']); ?>> Use custom field</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
|
526 |
+
<select name="wp_rp_thumbnail_custom_field" id="wp_rp_thumbnail_custom_field" class="postform">
|
527 |
+
|
528 |
+
<?php foreach ( $custom_fields as $custom_field ) : ?>
|
529 |
+
<option value="<?php esc_attr_e($custom_field); ?>"<?php selected($options["thumbnail_custom_field"], $custom_field); ?>><?php esc_html_e($custom_field);?></option>
|
530 |
+
<?php endforeach; ?>
|
531 |
+
|
532 |
+
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
<br />
|
534 |
+
<?php endif; ?>
|
535 |
+
|
536 |
<label>
|
537 |
+
<input name="wp_rp_thumbnail_use_attached" type="checkbox" value="yes" <?php checked($options["thumbnail_use_attached"]); ?>>
|
538 |
+
<?php _e("If featured image is missing, show an image from the post",'wp_related_posts');?>
|
539 |
</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
540 |
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
541 |
|
542 |
+
|
543 |
+
<br />
|
544 |
+
<label>
|
545 |
+
<?php _e('For posts without images, a default image will be shown.<br/>
|
546 |
+
You can upload your own default image here','wp_related_posts');?>
|
547 |
+
<input type="file" name="wp_rp_default_thumbnail" />
|
548 |
+
</label>
|
549 |
+
<?php if($options['default_thumbnail_path']) : ?>
|
550 |
+
<span style="display: inline-block; vertical-align: top; *display: inline; zoom: 1;">
|
551 |
+
<img style="padding: 3px; border: 1px solid #DFDFDF; border-radius: 3px;" valign="top" width="80" height="80" src="<?php esc_attr_e(wp_rp_get_default_thumbnail_url()); ?>" alt="selected thumbnail" />
|
552 |
+
<br />
|
553 |
+
<label>
|
554 |
+
<input type="checkbox" name="wp_rp_default_thumbnail_remove" value="yes" />
|
555 |
+
<?php _e("Remove selected",'wp_related_posts');?>
|
556 |
+
</label>
|
557 |
+
</span>
|
558 |
+
<?php endif; ?>
|
559 |
+
</span>
|
560 |
+
</td>
|
561 |
+
</tr>
|
562 |
+
<tr>
|
563 |
+
<th scope="row"><?php _e("Display Options:",'wp_related_posts'); ?></th>
|
564 |
+
<td>
|
565 |
+
<label>
|
566 |
+
<input name="wp_rp_display_comment_count" type="checkbox" id="wp_rp_display_comment_count" value="yes" <?php checked($options["display_comment_count"]); ?>>
|
567 |
+
<?php _e("Display Number of Comments",'wp_related_posts');?>
|
568 |
+
</label><br />
|
569 |
+
<label>
|
570 |
+
<input name="wp_rp_display_publish_date" type="checkbox" id="wp_rp_display_publish_date" value="yes" <?php checked($options["display_publish_date"]); ?>>
|
571 |
+
<?php _e("Display Publish Date",'wp_related_posts');?>
|
572 |
+
</label><br />
|
573 |
+
<label>
|
574 |
+
<input name="wp_rp_display_excerpt" type="checkbox" id="wp_rp_display_excerpt" value="yes"<?php checked($options["display_excerpt"]); ?> onclick="wp_rp_display_excerpt_onclick();" >
|
575 |
+
<?php _e("Display Post Excerpt",'wp_related_posts');?>
|
576 |
+
</label>
|
577 |
+
<label id="wp_rp_excerpt_max_length_label"<?php echo $options["display_excerpt"] ? '' : ' style="display: none;"'; ?>>
|
578 |
+
<input name="wp_rp_excerpt_max_length" type="text" id="wp_rp_excerpt_max_length" class="small-text" value="<?php esc_attr_e($options["excerpt_max_length"]); ?>" /> <span class="description"><?php _e('Maximum Number of Characters.', 'wp_related_posts'); ?></span>
|
579 |
+
</label><br/>
|
580 |
+
<label for="wp_rp_related_posts_title_tag">
|
581 |
+
<?php _e('Related Posts Title Tag', 'wp_related_posts'); ?>
|
582 |
+
<select name="wp_rp_related_posts_title_tag" id="wp_rp_related_posts_title_tag" class="postform">
|
583 |
+
<?php
|
584 |
+
foreach ($title_tags as $tag) :
|
585 |
+
?>
|
586 |
+
<option value="<?php esc_attr_e($tag); ?>"<?php selected($related_posts_title_tag, $tag); ?>><<?php esc_html_e($tag); ?>></option>
|
587 |
+
<?php endforeach; ?>
|
588 |
+
</select>
|
589 |
+
</label>
|
590 |
+
</td>
|
591 |
+
</tr>
|
592 |
+
</table>
|
593 |
+
<h3><?php _e("Other Settings:",'wp_related_posts'); ?></h3>
|
594 |
+
<table class="form-table">
|
595 |
+
<tr valign="top">
|
596 |
+
<th scope="row"><?php _e('Exclude these Categories:', 'wp_related_posts'); ?></th>
|
597 |
+
<td>
|
598 |
+
<div class="excluded-categories">
|
599 |
+
<?php
|
600 |
+
$exclude = explode(',', $options['exclude_categories']);
|
601 |
+
$args = array(
|
602 |
+
'orderby' => 'name',
|
603 |
+
'order' => 'ASC',
|
604 |
+
'hide_empty' => false
|
605 |
+
);
|
606 |
+
|
607 |
+
foreach (get_categories($args) as $category) :
|
608 |
+
?>
|
609 |
+
<label>
|
610 |
+
<input name="wp_rp_exclude_categories[]" type="checkbox" id="wp_rp_exclude_categories" value="<?php esc_attr_e($category->cat_ID); ?>"<?php checked(in_array($category->cat_ID, $exclude)); ?> />
|
611 |
+
<?php esc_html_e($category->cat_name); ?>
|
612 |
+
<br />
|
613 |
+
</label>
|
614 |
+
<?php endforeach; ?>
|
615 |
+
</div>
|
616 |
+
</td>
|
617 |
+
</tr>
|
618 |
+
<tr valign="top">
|
619 |
+
<td colspan="2">
|
620 |
+
<label>
|
621 |
+
<input name="wp_rp_on_single_post" type="checkbox" id="wp_rp_on_single_post" value="yes" <?php checked($options['on_single_post']); ?>>
|
622 |
+
<?php _e("Auto Insert Related Posts",'wp_related_posts');?>
|
623 |
+
</label>
|
624 |
+
(or add <pre style="display: inline"><?php wp_related_posts()?></pre> to your single post template)
|
625 |
+
<br />
|
626 |
+
<label>
|
627 |
+
<input name="wp_rp_on_rss" type="checkbox" id="wp_rp_on_rss" value="yes"<?php checked($options['on_rss']); ?>>
|
628 |
+
<?php _e("Display Related Posts in Feed",'wp_related_posts');?>
|
629 |
+
</label>
|
630 |
+
<br />
|
631 |
+
<label>
|
632 |
+
<input name="wp_rp_ctr_dashboard_enabled" type="checkbox" id="wp_rp_ctr_dashboard_enabled" value="yes" <?php checked($options['ctr_dashboard_enabled']); ?> />
|
633 |
+
<?php _e("Turn statistics on",'wp_related_posts');?>*
|
634 |
+
</label>
|
635 |
+
<br />
|
636 |
+
<label>
|
637 |
+
<input name="wp_rp_promoted_content_enabled" type="checkbox" id="wp_rp_promoted_content_enabled" value="yes" <?php checked($options['promoted_content_enabled']); ?> />
|
638 |
+
<?php _e('Promoted Content', 'wp_related_posts');?>*
|
639 |
+
</label>
|
640 |
+
</td>
|
641 |
+
</tr>
|
642 |
+
</table>
|
643 |
+
<p class="submit"><input type="submit" value="<?php _e('Save changes', 'wp_related_posts'); ?>" class="button-primary" /></p>
|
644 |
+
|
645 |
+
</form>
|
646 |
+
<div>
|
647 |
+
* Provided via <a target="_blank" href="http://related-posts.com/tos/">3rd party service</a>.
|
648 |
+
</div>
|
649 |
+
</div>
|
650 |
</div>
|
651 |
</div>
|
652 |
<?php }
|
static/css/dashboard.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
#wp_rp_wrap div.header {
|
2 |
#wp_rp_wrap .updated, #wp_rp_wrap .error {max-width: 600px; margin-right: 254px; }
|
3 |
#wp_rp_wrap div.header h2.title {font-size: 2.5em; line-height: 1em; font-weight: bold;}
|
4 |
#wp_rp_wrap div.header p.desc {font-size: 1.2em; line-height: 1.5em; max-width: 430px;}
|
@@ -7,13 +7,25 @@
|
|
7 |
#wp_rp_wrap div.header div.support p {margin: 0; font-size: 11px;}
|
8 |
#wp_rp_wrap div.header div.support p a {color: #82c1cb; font-weight: bold; text-decoration: none;}
|
9 |
|
10 |
-
|
11 |
-
#wp_rp_wrap div#wp_rp_statistics_wrap
|
12 |
-
|
13 |
-
#wp_rp_wrap div#
|
14 |
-
#wp_rp_wrap div#
|
15 |
-
#wp_rp_wrap div#
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
#wp_rp_wrap div#wp_rp_statistics_wrap div.message {font-size: 25px; line-height: 1em; padding-top: 50px; margin-bottom: 15px; position: relative; font-weight: bold;}
|
19 |
#wp_rp_wrap div#wp_rp_statistics_wrap div.message.enable {color: #82c1cb;}
|
@@ -24,11 +36,7 @@
|
|
24 |
#wp_rp_dashboard_widget #wp_rp_statistics_wrap {padding: 0;}
|
25 |
#wp_rp_dashboard_widget #wp_rp_wrap {margin: 0px;}
|
26 |
#wp_rp_dashboard_widget .statistics {margin: 0px;}
|
27 |
-
|
28 |
-
color: #8F8F8F;
|
29 |
-
border-bottom: 1px solid #ECECEC;
|
30 |
-
font-family: inherit;
|
31 |
-
}
|
32 |
#wp_rp_invite_friends_form { background: #f7f7f7; padding: 15px; margin: 30px 0px; border: 1px solid #e1e1e1; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
|
33 |
#wp_rp_invite_friends_form h2 { font-size: 19px; line-height: 20px; padding: 0px; }
|
34 |
#wp_rp_invite_friends_submit { background: #8bc7d1; border-color: #57aab8; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; color: white; padding: 8px 25px; font-size: 15px; text-shadow: 0px 1px 1px #888; font-weight: bold; box-shadow: 0px 1px 4px -2px black, 0px 1px 0px #a8d9e0 inset; }
|
@@ -110,7 +118,7 @@ form.wp_rp_message_form a.dismiss {float: right;}
|
|
110 |
padding: 0 5px;
|
111 |
border: 1px solid #dfdfdf;
|
112 |
}
|
113 |
-
|
114 |
/* collapsible CSS */
|
115 |
#wp_rp_wrap .collapsible .collapse-handle {
|
116 |
margin-top: 16px;
|
1 |
+
#wp_rp_wrap div.header {position: relative; padding-bottom: 5px;}
|
2 |
#wp_rp_wrap .updated, #wp_rp_wrap .error {max-width: 600px; margin-right: 254px; }
|
3 |
#wp_rp_wrap div.header h2.title {font-size: 2.5em; line-height: 1em; font-weight: bold;}
|
4 |
#wp_rp_wrap div.header p.desc {font-size: 1.2em; line-height: 1.5em; max-width: 430px;}
|
7 |
#wp_rp_wrap div.header div.support p {margin: 0; font-size: 11px;}
|
8 |
#wp_rp_wrap div.header div.support p a {color: #82c1cb; font-weight: bold; text-decoration: none;}
|
9 |
|
10 |
+
|
11 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap {position: relative;}
|
12 |
+
|
13 |
+
#wp_rp_wrap div#wp_rp_statistics_collapsible {max-width: 600px;}
|
14 |
+
#wp_rp_wrap div#wp_rp_statistics_collapsible.collapsed {border-bottom: 1px solid #ddd;}
|
15 |
+
#wp_rp_wrap div#wp_rp_statistics_collapsible.collapsed {border-bottom: 1px solid #ddd;}
|
16 |
+
|
17 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics {margin: 0;}
|
18 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li.title div {background-size: 40px 40px; height: 20px; padding: 20px 0 0 0; text-transform: uppercase; margin: 5px 0;}
|
19 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li.title .mobile {float: left; text-align: left; background: url(../img/mobile_icon.png) no-repeat; background-size: 40px 40px; padding-left: 45px;}
|
20 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li.title .desktop {float: right; text-align: right; background: url(../img/desktop_icon.png) no-repeat right; background-size: 40px 40px; padding-right: 45px;}
|
21 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li {position: relative; overflow: hidden; border-bottom: 1px solid #ddd; margin: 0; height: 60px;}
|
22 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li h5 {text-transform: uppercase; text-align: center; font-weight: normal; padding: 5px 0; margin: 20px auto 0 auto; font-size: 13px;}
|
23 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li h5 span {text-transform: lowercase; font-size: 11px; color: #999; margin-left: 10px;}
|
24 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li p.num {position: absolute; right: 0; font-size: 40px; line-height: 40px; color: #82c1cb; font-weight: bold; margin: 10px 0;}
|
25 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li p.num.mobile {position: absolute; left: 0;}
|
26 |
+
#wp_rp_wrap div#wp_rp_statistics_wrap div.description {position: absolute; right: -200px; width: 170px; padding: 5px; top: 0; border: 1px solid #ddd; display: none;}
|
27 |
+
#wp_rp_dashboard_widget #wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li.clicks {border-bottom: 0;}
|
28 |
+
|
29 |
|
30 |
#wp_rp_wrap div#wp_rp_statistics_wrap div.message {font-size: 25px; line-height: 1em; padding-top: 50px; margin-bottom: 15px; position: relative; font-weight: bold;}
|
31 |
#wp_rp_wrap div#wp_rp_statistics_wrap div.message.enable {color: #82c1cb;}
|
36 |
#wp_rp_dashboard_widget #wp_rp_statistics_wrap {padding: 0;}
|
37 |
#wp_rp_dashboard_widget #wp_rp_wrap {margin: 0px;}
|
38 |
#wp_rp_dashboard_widget .statistics {margin: 0px;}
|
39 |
+
|
|
|
|
|
|
|
|
|
40 |
#wp_rp_invite_friends_form { background: #f7f7f7; padding: 15px; margin: 30px 0px; border: 1px solid #e1e1e1; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
|
41 |
#wp_rp_invite_friends_form h2 { font-size: 19px; line-height: 20px; padding: 0px; }
|
42 |
#wp_rp_invite_friends_submit { background: #8bc7d1; border-color: #57aab8; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; color: white; padding: 8px 25px; font-size: 15px; text-shadow: 0px 1px 1px #888; font-weight: bold; box-shadow: 0px 1px 4px -2px black, 0px 1px 0px #a8d9e0 inset; }
|
118 |
padding: 0 5px;
|
119 |
border: 1px solid #dfdfdf;
|
120 |
}
|
121 |
+
|
122 |
/* collapsible CSS */
|
123 |
#wp_rp_wrap .collapsible .collapse-handle {
|
124 |
margin-top: 16px;
|
static/img/desktop_icon.png
ADDED
Binary file
|
static/img/mobile_icon.png
ADDED
Binary file
|
static/js/dashboard.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
-
(function(a){var d=function(
|
2 |
-
function(
|
3 |
-
|
4 |
-
range:"last 30 days"}));ul.
|
5 |
-
|
6 |
-
|
7 |
-
(
|
|
|
|
1 |
+
(function(a){var d=function(b,d){a.each(d,function(a,d){b=b.replace(RegExp("{{ *"+a+" *}}"),d)});return b};a(function(){var b=a("#wp_rp_statistics_wrap"),i=a("#wp_rp_dashboard_url").val(),g=a("#wp_rp_blog_id").val(),h=a("#wp_rp_auth_key").val();update_interval=req_timeout=null;update_interval_sec=2E3;update_interval_error_sec=3E4;updating=!1;ul=null;set_update_interval=function(a){a||(a=update_interval_sec);clearInterval(update_interval);0<a&&(update_interval=setInterval(update_dashboard,a))};display_error=
|
2 |
+
function(e){var f=a("#wp_rp_statistics_wrap");e||f.find(".unavailable").slideDown();set_update_interval(update_interval_error_sec);updating=!1};create_dashboard=function(){ul=a('<ul class="statistics" />');b.find(".unavailable").slideUp();ul.append('<li class="title"><div class="desktop">Desktop</div><div class="mobile">Mobile</div></li>');ul.append(d('<li description="{{description}}" class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',
|
3 |
+
{"class":"ctr",title:"click-through rate",description:"Number of clicks on a Related Post divided by the number of times the post was shown to readers. Tip: Using thumbnails will generally rise Click-through Rates.",range:"last 30 days"}));ul.append(d('<li description="{{description}}" class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',{"class":"pageviews",title:"page views",description:"Number of times the page (usually post) was loaded to readers.",
|
4 |
+
range:"last 30 days"}));ul.append(d('<li description="{{description}}" class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',{"class":"clicks",title:"clicks",description:"Number of times a reader has clicked on one of the Related Posts.",range:"last 30 days"}));b.append('<div class="description"/>');var e=b.find(".description");a("#wp_rp_settings_form").length&&(ul.on("mouseenter","li.stats",function(){var f=a(this),c=f.offset().top-
|
5 |
+
f.parent().offset().top;e.text(f.attr("description")).css("margin-top",c+"px").show()}),b.on("mouseleave",function(){e.text("").hide()}));b.append(ul)};update_dashboard=function(e){updating||(updating=!0,req_timeout=setTimeout(function(){display_error(!e)},2E3),a.getJSON(i+"pageviews/?callback=?",{blog_id:g,auth_key:h},function(a){var c=a.data;clearTimeout(req_timeout);if(!a||"ok"!==a.status||!a.data)display_error(!e);else{ul||create_dashboard();set_update_interval(a.data.update_interval);var b=c.pageviews-
|
6 |
+
c.mobile_pageviews,c=c.clicks-c.mobile_clicks,d=0<b?(100*(c/b)).toFixed(1):0;ul.find(".ctr .num.all").html(d+"%");ul.find(".pageviews .num.all").html(b);ul.find(".clicks .num.all").html(c);ul.find(".ctr .num.mobile").html(a.data.mobile_ctr.toFixed(1)+"%");ul.find(".pageviews .num.mobile").html(a.data.mobile_pageviews);ul.find(".clicks .num.mobile").html(a.data.mobile_clicks);updating=!1}}))};g&&h&&(update_dashboard(!0),update_interval=setInterval(update_dashboard,2E3));a("#wp_rp_turn_on_statistics a.turn-on").click(function(e){e.preventDefault();
|
7 |
+
var e=a("#wp_rp_static_base_url").val(),b=!1,c=function(){b||(a("#wp_rp_settings_form").submit(),b=!0)};a("#wp_rp_ctr_dashboard_enabled, #wp_rp_display_thumbnail, #wp_rp_enable_themes, #wp_rp_promoted_content_enabled").prop("checked",!0);a("#wp_rp_settings_form").append('<input type="hidden" value="statistics+thumbnails+promoted" name="wp_rp_turn_on_button_pressed" id="wp_rp_turn_on_button_pressed">');a("<img />").load(c).error(c).attr("src",e+"stats.gif?action=turn_on_button&ads=1&nc="+(new Date).getTime());
|
8 |
+
setTimeout(c,1E3)});a(".wp_rp_notification .close").on("click",function(b){a.ajax({url:a(this).attr("href"),data:{noredirect:!0}});a(this).parent().slideUp(function(){a(this).remove()});b.preventDefault()});a("#wp_rp_wrap .collapsible .collapse-handle").on("click",function(b){var f=a(this).closest(".collapsible"),c=f.find(".container"),d=f.hasClass("collapsed"),g=f.attr("block");d?(c.slideDown(),a.post(ajaxurl,{action:"rp_show_hide_"+g,show:!0})):(c.slideUp(),a.post(ajaxurl,{action:"rp_show_hide_"+
|
9 |
+
g,hide:!0}));f.toggleClass("collapsed");b.preventDefault()})})})(jQuery);
|
thumbnailer.php
CHANGED
@@ -14,7 +14,7 @@ function wp_rp_upload_default_thumbnail_file() {
|
|
14 |
$path = image_resize($upload['file'], WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT, true);
|
15 |
if (!is_wp_error($path)) {
|
16 |
$upload_dir = wp_upload_dir();
|
17 |
-
return $upload_dir['
|
18 |
}
|
19 |
return $path;
|
20 |
}
|
@@ -27,7 +27,7 @@ function wp_rp_get_default_thumbnail_url($seed = false) {
|
|
27 |
$upload_dir = wp_upload_dir();
|
28 |
|
29 |
if ($options['default_thumbnail_path']) {
|
30 |
-
return $
|
31 |
} else {
|
32 |
if ($seed) {
|
33 |
$next_seed = rand();
|
@@ -52,14 +52,13 @@ function wp_rp_extract_post_image($post_id) {
|
|
52 |
'order' => 'ASC',
|
53 |
);
|
54 |
|
55 |
-
|
56 |
-
$attachments = get_posts($args);
|
57 |
$image_id = '-1';
|
58 |
if ( $attachments ) {
|
59 |
foreach ( $attachments as $attachment ) {
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
break;
|
64 |
}
|
65 |
}
|
@@ -67,37 +66,146 @@ function wp_rp_extract_post_image($post_id) {
|
|
67 |
return $image_id;
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
function wp_rp_get_post_thumbnail_img($related_post) {
|
71 |
-
|
72 |
-
|
73 |
return false;
|
74 |
}
|
75 |
|
76 |
-
|
77 |
-
|
78 |
|
79 |
-
|
80 |
$img = '<img src="' . esc_attr($thumbnail_src) . '" alt="' . esc_attr(wptexturize($related_post->post_title)) . '" />';
|
81 |
return $img;
|
82 |
}
|
83 |
} else if (has_post_thumbnail($related_post->ID)) {
|
84 |
-
|
85 |
'alt' => esc_attr(wptexturize($related_post->post_title)),
|
86 |
'title' => false
|
87 |
);
|
88 |
$img = get_the_post_thumbnail($related_post->ID, 'thumbnail', $attr);
|
89 |
-
|
90 |
}
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
$img = wp_get_attachment_image($image_id, 'thumbnail');
|
96 |
return $img;
|
97 |
}
|
|
|
|
|
|
|
|
|
98 |
}
|
99 |
|
100 |
$img = '<img src="'. esc_attr(wp_rp_get_default_thumbnail_url($related_post->ID)) . '" alt="' . esc_attr(wptexturize($related_post->post_title)) . '" />';
|
101 |
return $img;
|
102 |
}
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
14 |
$path = image_resize($upload['file'], WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT, true);
|
15 |
if (!is_wp_error($path)) {
|
16 |
$upload_dir = wp_upload_dir();
|
17 |
+
return $upload_dir['url'] . '/' . wp_basename($path);
|
18 |
}
|
19 |
return $path;
|
20 |
}
|
27 |
$upload_dir = wp_upload_dir();
|
28 |
|
29 |
if ($options['default_thumbnail_path']) {
|
30 |
+
return $options['default_thumbnail_path'];
|
31 |
} else {
|
32 |
if ($seed) {
|
33 |
$next_seed = rand();
|
52 |
'order' => 'ASC',
|
53 |
);
|
54 |
|
55 |
+
$attachments = get_posts($args);
|
|
|
56 |
$image_id = '-1';
|
57 |
if ( $attachments ) {
|
58 |
foreach ( $attachments as $attachment ) {
|
59 |
+
$img = wp_get_attachment_image($attachment->ID, 'thumbnail');
|
60 |
+
if($img) {
|
61 |
+
$image_id = $attachment->ID;
|
62 |
break;
|
63 |
}
|
64 |
}
|
66 |
return $image_id;
|
67 |
}
|
68 |
|
69 |
+
function wp_rp_direct_filesystem_method() {
|
70 |
+
return 'direct';
|
71 |
+
}
|
72 |
+
|
73 |
+
function wp_rp_actually_extract_images_from_post_html($post) {
|
74 |
+
$content = $post->post_content;
|
75 |
+
preg_match_all('/<img (?:[^>]+ )?src="([^"]+)"/', $content, $matches);
|
76 |
+
$urls = $matches[1];
|
77 |
+
|
78 |
+
$img_url = false;
|
79 |
+
|
80 |
+
if(count($urls) == 0) {
|
81 |
+
return $img_url;
|
82 |
+
}
|
83 |
+
array_splice($urls, 10);
|
84 |
+
|
85 |
+
$upload_dir = wp_upload_dir();
|
86 |
+
if($upload_dir['error'] !== false) {
|
87 |
+
return $img_url;
|
88 |
+
}
|
89 |
+
|
90 |
+
require_once(ABSPATH . 'wp-admin/includes/file.php');
|
91 |
+
|
92 |
+
global $wp_filesystem;
|
93 |
+
add_filter('filesystem_method', 'wp_rp_direct_filesystem_method');
|
94 |
+
WP_Filesystem();
|
95 |
+
|
96 |
+
foreach ($urls as $url) {
|
97 |
+
$url = html_entity_decode($url);
|
98 |
+
|
99 |
+
$http_response = wp_remote_get($url, array('timeout' => 10));
|
100 |
+
if(is_wp_error($http_response)) {
|
101 |
+
continue;
|
102 |
+
}
|
103 |
+
$img_data = wp_remote_retrieve_body($http_response);
|
104 |
+
|
105 |
+
$img_name = wp_unique_filename($upload_dir['path'], wp_basename(parse_url($url, PHP_URL_PATH)));
|
106 |
+
$img_path = $upload_dir['path'] . '/' . $img_name;
|
107 |
+
|
108 |
+
if(!$wp_filesystem->put_contents($img_path, $img_data, FS_CHMOD_FILE)) {
|
109 |
+
continue;
|
110 |
+
}
|
111 |
+
|
112 |
+
$resized_img_path = image_resize($img_path, WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT, true);
|
113 |
+
|
114 |
+
if(is_wp_error($resized_img_path)) {
|
115 |
+
continue;
|
116 |
+
}
|
117 |
+
|
118 |
+
$img_url = $upload_dir['url'] . '/' . urlencode(wp_basename($resized_img_path));
|
119 |
+
|
120 |
+
break;
|
121 |
+
}
|
122 |
+
|
123 |
+
remove_filter('filesystem_method', 'wp_rp_direct_filesystem_method');
|
124 |
+
|
125 |
+
return $img_url;
|
126 |
+
}
|
127 |
+
|
128 |
+
function wp_rp_cron_do_extract_images_from_post_html($post_id) {
|
129 |
+
$post_id = (int) $post_id;
|
130 |
+
$post = get_post($post_id);
|
131 |
+
|
132 |
+
$img_url = wp_rp_actually_extract_images_from_post_html($post);
|
133 |
+
|
134 |
+
if($img_url) {
|
135 |
+
update_post_meta($post_id, '_wp_rp_extracted_image_url', $img_url);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
add_action('wp_rp_cron_extract_images_from_post_html', 'wp_rp_cron_do_extract_images_from_post_html');
|
139 |
+
|
140 |
+
function wp_rp_extract_images_from_post_html($post) {
|
141 |
+
update_post_meta($post->ID, '_wp_rp_extracted_image_url', '');
|
142 |
+
if(empty($post->post_content)) { return; }
|
143 |
+
|
144 |
+
wp_schedule_single_event(time(), 'wp_rp_cron_extract_images_from_post_html', array($post->ID));
|
145 |
+
}
|
146 |
+
|
147 |
+
function wp_rp_post_save_update_image($post_id) {
|
148 |
+
$post = get_post($post_id);
|
149 |
+
|
150 |
+
if(empty($post->post_content) || $post->post_status !== 'publish' || $post->post_type === 'page' || $post->post_type === 'nav_menu_item') {
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
|
154 |
+
delete_post_meta($post->ID, '_wp_rp_extracted_image_url');
|
155 |
+
|
156 |
+
wp_rp_get_post_thumbnail_img($post);
|
157 |
+
}
|
158 |
+
add_action('save_post', 'wp_rp_post_save_update_image');
|
159 |
+
|
160 |
+
|
161 |
function wp_rp_get_post_thumbnail_img($related_post) {
|
162 |
+
$options = wp_rp_get_options();
|
163 |
+
if (!$options["display_thumbnail"]) {
|
164 |
return false;
|
165 |
}
|
166 |
|
167 |
+
if ($options['thumbnail_use_custom']) {
|
168 |
+
$thumbnail_src = get_post_meta($related_post->ID, $options["thumbnail_custom_field"], true);
|
169 |
|
170 |
+
if ($thumbnail_src) {
|
171 |
$img = '<img src="' . esc_attr($thumbnail_src) . '" alt="' . esc_attr(wptexturize($related_post->post_title)) . '" />';
|
172 |
return $img;
|
173 |
}
|
174 |
} else if (has_post_thumbnail($related_post->ID)) {
|
175 |
+
$attr = array(
|
176 |
'alt' => esc_attr(wptexturize($related_post->post_title)),
|
177 |
'title' => false
|
178 |
);
|
179 |
$img = get_the_post_thumbnail($related_post->ID, 'thumbnail', $attr);
|
180 |
+
return $img;
|
181 |
}
|
182 |
|
183 |
+
if($options["thumbnail_use_attached"]) {
|
184 |
+
$image_url = get_post_meta($related_post->ID, '_wp_rp_extracted_image_url', false);
|
185 |
+
|
186 |
+
if(!empty($image_url) && ($image_url[0] != '')) {
|
187 |
+
$img = '<img src="' . esc_attr($image_url[0]) . '" alt="' . esc_attr(wptexturize($related_post->post_title)) . '" />';
|
188 |
+
return $img;
|
189 |
+
}
|
190 |
+
|
191 |
+
$image_id = wp_rp_extract_post_image($related_post->ID);
|
192 |
+
if ($image_id !== '-1') {
|
193 |
$img = wp_get_attachment_image($image_id, 'thumbnail');
|
194 |
return $img;
|
195 |
}
|
196 |
+
|
197 |
+
if(empty($image_url)) {
|
198 |
+
wp_rp_extract_images_from_post_html($related_post);
|
199 |
+
}
|
200 |
}
|
201 |
|
202 |
$img = '<img src="'. esc_attr(wp_rp_get_default_thumbnail_url($related_post->ID)) . '" alt="' . esc_attr(wptexturize($related_post->post_title)) . '" />';
|
203 |
return $img;
|
204 |
}
|
205 |
|
206 |
+
function wp_rp_process_latest_post_thumbnails() {
|
207 |
+
$latest_posts = get_posts(array('numberposts' => WP_RP_THUMBNAILS_NUM_PREGENERATED_POSTS));
|
208 |
+
foreach ($latest_posts as $post) {
|
209 |
+
wp_rp_get_post_thumbnail_img($post);
|
210 |
+
}
|
211 |
+
}
|
wp_related_posts.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WordPress Related Posts
|
4 |
-
Version: 2.
|
5 |
Plugin URI: http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/
|
6 |
Description: Generate a related posts list via tags of WordPress
|
7 |
Author: Jure Ham
|
8 |
Author URI: http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/
|
9 |
*/
|
10 |
|
11 |
-
define('WP_RP_VERSION', '2.
|
12 |
|
13 |
include_once(dirname(__FILE__) . '/config.php');
|
14 |
include_once(dirname(__FILE__) . '/lib/stemmer.php');
|
@@ -135,6 +135,7 @@ function wp_rp_generate_related_posts_list_items($related_posts) {
|
|
135 |
|
136 |
function wp_rp_should_exclude() {
|
137 |
global $wpdb, $post;
|
|
|
138 |
$options = wp_rp_get_options();
|
139 |
|
140 |
if($options['exclude_categories'] === '') { return false; }
|
@@ -142,6 +143,7 @@ function wp_rp_should_exclude() {
|
|
142 |
$q = 'SELECT COUNT(tt.term_id) FROM '. $wpdb->term_taxonomy.' tt, ' . $wpdb->term_relationships.' tr WHERE tt.taxonomy = \'category\' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id = '.$post->ID . ' AND tt.term_id IN (' . $options['exclude_categories'] . ')';
|
143 |
|
144 |
$result = $wpdb->get_col($q);
|
|
|
145 |
$count = (int) $result[0];
|
146 |
|
147 |
return $count > 0;
|
@@ -168,7 +170,11 @@ function wp_rp_head_resources() {
|
|
168 |
|
169 |
if ($statistics_enabled) {
|
170 |
$tags = $wpdb->get_col("SELECT label FROM " . $wpdb->prefix . "wp_rp_tags WHERE post_id=$post->ID ORDER BY weight desc;", 0);
|
171 |
-
|
|
|
|
|
|
|
|
|
172 |
|
173 |
$output .= "<script type=\"text/javascript\">\n" .
|
174 |
"\twindow._wp_rp_blog_id = '" . esc_js($meta['blog_id']) . "';\n" .
|
@@ -184,7 +190,7 @@ function wp_rp_head_resources() {
|
|
184 |
}
|
185 |
|
186 |
if ($remote_recommendations) {
|
187 |
-
$output .= '<script type="text/javascript" src="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_RECOMMENDATIONS_JS_FILE . '?version=' . WP_RP_VERSION . '"
|
188 |
$output .= '<link rel="stylesheet" href="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_RECOMMENDATIONS_CSS_FILE . '?version=' . WP_RP_VERSION . '" />' . "\n";
|
189 |
}
|
190 |
|
@@ -234,7 +240,10 @@ function wp_rp_get_related_posts($before_title = '', $after_title = '') {
|
|
234 |
|
235 |
if ($related_posts) {
|
236 |
$output = wp_rp_generate_related_posts_list_items($related_posts);
|
237 |
-
$output = '<ul class="' . $css_classes . '" style="visibility:
|
|
|
|
|
|
|
238 |
}
|
239 |
|
240 |
if ($title != '') {
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WordPress Related Posts
|
4 |
+
Version: 2.1
|
5 |
Plugin URI: http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/
|
6 |
Description: Generate a related posts list via tags of WordPress
|
7 |
Author: Jure Ham
|
8 |
Author URI: http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/
|
9 |
*/
|
10 |
|
11 |
+
define('WP_RP_VERSION', '2.1');
|
12 |
|
13 |
include_once(dirname(__FILE__) . '/config.php');
|
14 |
include_once(dirname(__FILE__) . '/lib/stemmer.php');
|
135 |
|
136 |
function wp_rp_should_exclude() {
|
137 |
global $wpdb, $post;
|
138 |
+
|
139 |
$options = wp_rp_get_options();
|
140 |
|
141 |
if($options['exclude_categories'] === '') { return false; }
|
143 |
$q = 'SELECT COUNT(tt.term_id) FROM '. $wpdb->term_taxonomy.' tt, ' . $wpdb->term_relationships.' tr WHERE tt.taxonomy = \'category\' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id = '.$post->ID . ' AND tt.term_id IN (' . $options['exclude_categories'] . ')';
|
144 |
|
145 |
$result = $wpdb->get_col($q);
|
146 |
+
|
147 |
$count = (int) $result[0];
|
148 |
|
149 |
return $count > 0;
|
170 |
|
171 |
if ($statistics_enabled) {
|
172 |
$tags = $wpdb->get_col("SELECT label FROM " . $wpdb->prefix . "wp_rp_tags WHERE post_id=$post->ID ORDER BY weight desc;", 0);
|
173 |
+
if (!empty($tags)) {
|
174 |
+
$post_tags = '[' . implode(', ', array_map(create_function('$v', 'return "\'" . urlencode(substr($v, strpos($v, \'_\') + 1)) . "\'";'), $tags)) . ']';
|
175 |
+
} else {
|
176 |
+
$post_tags = '[]';
|
177 |
+
}
|
178 |
|
179 |
$output .= "<script type=\"text/javascript\">\n" .
|
180 |
"\twindow._wp_rp_blog_id = '" . esc_js($meta['blog_id']) . "';\n" .
|
190 |
}
|
191 |
|
192 |
if ($remote_recommendations) {
|
193 |
+
$output .= '<script type="text/javascript" src="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_RECOMMENDATIONS_JS_FILE . '?version=' . WP_RP_VERSION . '"></script>' . "\n";
|
194 |
$output .= '<link rel="stylesheet" href="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_RECOMMENDATIONS_CSS_FILE . '?version=' . WP_RP_VERSION . '" />' . "\n";
|
195 |
}
|
196 |
|
240 |
|
241 |
if ($related_posts) {
|
242 |
$output = wp_rp_generate_related_posts_list_items($related_posts);
|
243 |
+
$output = '<ul class="' . $css_classes . '" style="visibility: ' . ($remote_recommendations ? 'hidden' : 'visible') . '">' . $output . '</ul>';
|
244 |
+
if($remote_recommendations) {
|
245 |
+
$output = $output . '<script type="text/javascript">window._wp_rp_callback_widget_exists && window._wp_rp_callback_widget_exists();</script>';
|
246 |
+
}
|
247 |
}
|
248 |
|
249 |
if ($title != '') {
|