WordPress Related Posts - Version 2.2

Version Description

  • Updated theme settings with one new theme
  • Option to enable related posts in article text
  • Support for blogging network
  • qTranslate support
  • Christmas Surprise
  • Bugfixes
  • Ho ho ho
Download this release

Release Info

Developer jureham
Plugin Icon wp plugin WordPress Related Posts
Version 2.2
Comparing to
See all releases

Code changes from version 2.1 to 2.2

compatibility.php CHANGED
@@ -1,5 +1,34 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  /* ***************************** */
4
  /* WP RP backwards compatibility */
5
  /* ***************************** */
1
  <?php
2
 
3
+ /* ***************************** */
4
+ /* WP 3.3 compatibility */
5
+ /* ***************************** */
6
+
7
+ if (!function_exists('wp_is_mobile') && version_compare(get_bloginfo('version'), '3.4', '<')) {
8
+ function wp_is_mobile() {
9
+ static $is_mobile;
10
+
11
+ if ( isset($is_mobile) )
12
+ return $is_mobile;
13
+
14
+ if ( empty($_SERVER['HTTP_USER_AGENT']) ) {
15
+ $is_mobile = false;
16
+ } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false // many mobile devices (all iPhone, iPad, etc.)
17
+ || strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false
18
+ || strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/') !== false
19
+ || strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false
20
+ || strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false
21
+ || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false
22
+ || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi') !== false ) {
23
+ $is_mobile = true;
24
+ } else {
25
+ $is_mobile = false;
26
+ }
27
+
28
+ return $is_mobile;
29
+ }
30
+ }
31
+
32
  /* ***************************** */
33
  /* WP RP backwards compatibility */
34
  /* ***************************** */
config.php CHANGED
@@ -163,14 +163,15 @@ function wp_rp_install() {
163
  'new_user' => true,
164
  'show_upgrade_tooltip' => false,
165
  'show_install_tooltip' => true,
166
- 'remote_recommendations' => false,
167
  'show_turn_on_button' => true,
168
  'name' => '',
169
  'email' => '',
170
  'show_blogger_network_form' => false,
171
  'remote_notifications' => array(),
172
  'turn_on_button_pressed' => false,
173
- 'show_statistics' => false
 
174
  );
175
 
176
  $wp_rp_options = array(
@@ -194,7 +195,10 @@ function wp_rp_install() {
194
  'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
195
  'ctr_dashboard_enabled' => false,
196
  'promoted_content_enabled' => false,
197
- 'enable_themes' => false
 
 
 
198
  );
199
 
200
  update_option('wp_rp_meta', $wp_rp_meta);
@@ -203,6 +207,32 @@ function wp_rp_install() {
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');
163
  'new_user' => true,
164
  'show_upgrade_tooltip' => false,
165
  'show_install_tooltip' => true,
166
+ 'remote_recommendations' => true, # WARNING: TODO: Turn this off at the end of this experiment!
167
  'show_turn_on_button' => true,
168
  'name' => '',
169
  'email' => '',
170
  'show_blogger_network_form' => false,
171
  'remote_notifications' => array(),
172
  'turn_on_button_pressed' => false,
173
+ 'show_statistics' => false,
174
+ 'show_traffic_exchange' => false
175
  );
176
 
177
  $wp_rp_options = array(
195
  'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
196
  'ctr_dashboard_enabled' => false,
197
  'promoted_content_enabled' => false,
198
+ 'enable_themes' => false,
199
+ 'show_RP_in_posts' => true,
200
+ 'custom_theme_enabled' => false,
201
+ 'traffic_exchange_enabled' => false
202
  );
203
 
204
  update_option('wp_rp_meta', $wp_rp_meta);
207
  wp_rp_related_posts_db_table_install();
208
  }
209
 
210
+ /*function wp_rp_migrate_2_2() {
211
+ if(isset($wp_rp_options['show_santa_hat'])) {
212
+ unset($wp_rp_options['show_santa_hat']);
213
+ }
214
+ }*/
215
+
216
+ function wp_rp_migrate_2_1() {
217
+ $wp_rp_meta = get_option('wp_rp_meta');
218
+ $wp_rp_options = get_option('wp_rp_options');
219
+
220
+ $wp_rp_meta['version'] = '2.2';
221
+
222
+ $wp_rp_options['custom_theme_enabled'] = $wp_rp_options['theme_name'] == 'custom.css';
223
+ if ($wp_rp_options['custom_theme_enabled']) {
224
+ $wp_rp_options['theme_name'] = 'plain.css';
225
+ }
226
+
227
+ $wp_rp_options['show_RP_in_posts'] = false;
228
+
229
+ $wp_rp_options['traffic_exchange_enabled'] = false;
230
+ $wp_rp_meta['show_traffic_exchange'] = false;
231
+
232
+ update_option('wp_rp_options', $wp_rp_options);
233
+ update_option('wp_rp_meta', $wp_rp_meta);
234
+ }
235
+
236
  function wp_rp_migrate_2_0() {
237
  $wp_rp_meta = get_option('wp_rp_meta');
238
  $wp_rp_options = get_option('wp_rp_options');
dashboard_widget.php CHANGED
@@ -6,6 +6,10 @@
6
  add_action('wp_dashboard_setup', 'wp_rp_dashboard_setup');
7
 
8
  function wp_rp_dashboard_setup() {
 
 
 
 
9
  $options = wp_rp_get_options();
10
  $meta = wp_rp_get_meta();
11
 
@@ -15,7 +19,7 @@ function wp_rp_dashboard_setup() {
15
  }
16
  }
17
 
18
- function wp_rp_display_dashboard_widget() {
19
  $options = wp_rp_get_options();
20
  $meta = wp_rp_get_meta();
21
  ?>
@@ -23,8 +27,11 @@ function wp_rp_display_dashboard_widget() {
23
  <input type="hidden" id="wp_rp_static_base_url" value="<?php esc_attr_e(WP_RP_STATIC_BASE_URL); ?>" />
24
  <input type="hidden" id="wp_rp_blog_id" value="<?php esc_attr_e($meta['blog_id']); ?>" />
25
  <input type="hidden" id="wp_rp_auth_key" value="<?php esc_attr_e($meta['auth_key']); ?>" />
 
 
 
26
 
27
- <div id="wp_rp_wrap">
28
  <?php wp_rp_print_notifications(); ?>
29
  <div id="wp_rp_statistics_wrap"></div>
30
  </div>
6
  add_action('wp_dashboard_setup', 'wp_rp_dashboard_setup');
7
 
8
  function wp_rp_dashboard_setup() {
9
+ if (!current_user_can('delete_users')) {
10
+ return;
11
+ }
12
+
13
  $options = wp_rp_get_options();
14
  $meta = wp_rp_get_meta();
15
 
19
  }
20
  }
21
 
22
+ function wp_rp_display_dashboard_widget() {
23
  $options = wp_rp_get_options();
24
  $meta = wp_rp_get_meta();
25
  ?>
27
  <input type="hidden" id="wp_rp_static_base_url" value="<?php esc_attr_e(WP_RP_STATIC_BASE_URL); ?>" />
28
  <input type="hidden" id="wp_rp_blog_id" value="<?php esc_attr_e($meta['blog_id']); ?>" />
29
  <input type="hidden" id="wp_rp_auth_key" value="<?php esc_attr_e($meta['auth_key']); ?>" />
30
+ <?php if($meta['show_traffic_exchange'] && $options['traffic_exchange_enabled']): ?>
31
+ <input type="hidden" id="wp_rp_show_traffic_exchange_statistics" value="1" />
32
+ <?php endif; ?>
33
 
34
+ <div id="wp_rp_wrap" class="wp_rp_dashboard">
35
  <?php wp_rp_print_notifications(); ?>
36
  <div id="wp_rp_statistics_wrap"></div>
37
  </div>
notifications.php CHANGED
@@ -113,7 +113,22 @@ function wp_rp_load_remote_notifications() {
113
  $meta['show_blogger_network_form'] = false;
114
  }
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  wp_rp_update_meta($meta);
 
117
  }
118
  }
119
  }
113
  $meta['show_blogger_network_form'] = false;
114
  }
115
 
116
+ if(isset($data->show_RP_in_posts) && $data->show_RP_in_posts) {
117
+ $options['show_RP_in_posts'] = true;
118
+ } else if(isset($data->hide_RP_in_posts) && $data->hide_RP_in_posts) {
119
+ $options['show_RP_in_posts'] = false;
120
+ }
121
+
122
+ if(isset($data->show_traffic_exchange) && $data->show_traffic_exchange) {
123
+ $meta['show_traffic_exchange'] = true;
124
+ $options['traffic_exchange_enabled'] = true;
125
+ } else if(isset($data->hide_traffic_exchange) && $data->hide_traffic_exchange) {
126
+ $meta['show_traffic_exchange'] = false;
127
+ $options['traffic_exchange_enabled'] = false;
128
+ }
129
+
130
  wp_rp_update_meta($meta);
131
+ wp_rp_update_options($options);
132
  }
133
  }
134
  }
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.1
9
 
10
  WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
11
 
@@ -13,7 +13,7 @@ WordPress Related Posts generates a list of related posts with thumbnails and gi
13
 
14
  Quickly increase your readers' engagement with your posts by adding Related Posts in the footer of your content. The plugin also delivers statistics about Pageviews and Clicks\*. It supports different styles, thumbnails and is fully customizable.
15
 
16
- After installation, go to Settings -> Related Posts in your plugins list and turn on Thumbnails & Statistics!
17
 
18
  \* Real time traffic analytics are provided via third party service.
19
 
@@ -32,7 +32,6 @@ It places a list of links with thumbnails at the bottom of your posts. It increa
32
  * thumbnail size, style
33
  * number of posts
34
  * display post excerpt, publish date, number of comments
35
- * fallback if there are no related posts
36
  * categories to exclude
37
  * set default image
38
 
@@ -42,13 +41,6 @@ Yes, related posts are responsive so they adapt to the screen size to ensure max
42
 
43
  == Installation ==
44
 
45
- = Via upload: =
46
- 1. Download the plugin .zip file
47
- 2. Log in to yourdomain.com/wp-admin
48
- 3. Click Plugins -> Add New -> Upload
49
- 4. After installation go to Settings -> Related Posts in your plugins list to turn on Thumbnails & Statistics
50
- 5. You're finished!
51
-
52
  = Via admin: =
53
  1. Go to Plugins -> Add New
54
  2. Search for WordPress Related Posts
@@ -56,13 +48,33 @@ Yes, related posts are responsive so they adapt to the screen size to ensure max
56
  4. After installation go to Settings -> Related Posts in your plugins list to turn on Thumbnails & Statistics
57
  5. Done!
58
 
 
 
 
 
 
 
 
59
  == Screenshots ==
60
  1. WordPress Related Posts Default Theme.
61
- 2. WordPress Related Posts Settings and Statistics.
62
  3. WordPress Related Posts responsive theme on a Galaxy Nexus and iPhone 4s.
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  = 2.1 =
67
  * Extract thumbnails from post content
68
  * Statistics for mobile devices
5
  License: GPLv2
6
  Requires at least: 3.3
7
  Tested up to: 3.5
8
+ Stable tag: 2.2
9
 
10
  WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
11
 
13
 
14
  Quickly increase your readers' engagement with your posts by adding Related Posts in the footer of your content. The plugin also delivers statistics about Pageviews and Clicks\*. It supports different styles, thumbnails and is fully customizable.
15
 
16
+ After installation, go to Settings -> Related Posts in your plugins list and Turn on Advanced Features!
17
 
18
  \* Real time traffic analytics are provided via third party service.
19
 
32
  * thumbnail size, style
33
  * number of posts
34
  * display post excerpt, publish date, number of comments
 
35
  * categories to exclude
36
  * set default image
37
 
41
 
42
  == Installation ==
43
 
 
 
 
 
 
 
 
44
  = Via admin: =
45
  1. Go to Plugins -> Add New
46
  2. Search for WordPress Related Posts
48
  4. After installation go to Settings -> Related Posts in your plugins list to turn on Thumbnails & Statistics
49
  5. Done!
50
 
51
+ = Via upload: =
52
+ 1. Download the plugin .zip file
53
+ 2. Log in to yourdomain.com/wp-admin
54
+ 3. Click Plugins -> Add New -> Upload
55
+ 4. After installation go to Settings -> Related Posts in your plugins list to turn on Thumbnails & Statistics
56
+ 5. You're finished!
57
+
58
  == Screenshots ==
59
  1. WordPress Related Posts Default Theme.
60
+ 2. WordPress Related Posts reporting real time statistics for mobile and desktop devices.
61
  3. WordPress Related Posts responsive theme on a Galaxy Nexus and iPhone 4s.
62
 
63
  == Changelog ==
64
 
65
+ = 2.2 =
66
+ * Updated theme settings with one new theme
67
+ * Option to enable related posts in article text
68
+ * Support for blogging network
69
+ * qTranslate support
70
+ * Christmas Surprise
71
+ * Bugfixes
72
+ * Ho ho ho
73
+
74
+ = 2.1.1 =
75
+ * Exlude attachments
76
+ * Use WP_Image_Editor on WP 3.5
77
+
78
  = 2.1 =
79
  * Extract thumbnails from post content
80
  * Statistics for mobile devices
recommendations.php CHANGED
@@ -8,7 +8,7 @@ function wp_rp_update_tags($post_id) {
8
  $post = get_post($post->post_parent);
9
  }
10
 
11
- if ($post->post_type === 'nav_menu_item' || $post->post_type === 'attachment') {
12
  return;
13
  }
14
 
@@ -16,7 +16,7 @@ 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_type === 'page' || $post->post_status !== 'publish') {
20
  return;
21
  }
22
 
@@ -270,7 +270,7 @@ function wp_rp_fetch_related_posts($limit = 10, $exclude_ids = array()) {
270
  $related_posts = false;
271
  if ($taglist) {
272
  $q = "SELECT p.ID, p.post_title, p.post_content,p.post_excerpt, p.post_date, p.comment_count, count(t_r.object_id) as cnt FROM $wpdb->term_taxonomy t_t, $wpdb->term_relationships t_r, $wpdb->posts p WHERE t_t.taxonomy ='post_tag' AND t_t.term_taxonomy_id = t_r.term_taxonomy_id AND t_r.object_id = p.ID AND (t_t.term_id IN ($taglist)) AND p.ID NOT IN ($exclude_ids_str) AND " .
273
- ($options['exclude_categories'] == "" ? "" : "p.ID NOT IN (SELECT tr.object_id FROM $wpdb->term_taxonomy tt, $wpdb->term_relationships tr WHERE tt.taxonomy = 'category' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.term_id IN (" . $options['exclude_categories'] . ")) AND ") .
274
  "p.post_status = 'publish' AND p.post_date_gmt < '$now' GROUP BY t_r.object_id ORDER BY cnt DESC, p.post_date_gmt DESC LIMIT $limit;";
275
 
276
  $related_posts = $wpdb->get_results($q);
@@ -286,7 +286,7 @@ function wp_rp_fetch_random_posts($limit = 10, $exclude_ids = array()) {
286
  $exclude_ids_str = wp_rp_get_exclude_ids_list_string($exclude_ids);
287
 
288
  $q1 = "SELECT ID FROM $wpdb->posts posts WHERE post_status = 'publish' AND post_type = 'post' AND ID NOT IN ($exclude_ids_str)";
289
- if($options['exclude_categories'] != "") {
290
  $q1 .= " AND ID NOT IN (SELECT tr.object_id FROM $wpdb->term_taxonomy tt, $wpdb->term_relationships tr WHERE tt.taxonomy = 'category' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.term_id IN (" . $options['exclude_categories'] . "))";
291
  }
292
  $ids = $wpdb->get_col($q1, 0);
8
  $post = get_post($post->post_parent);
9
  }
10
 
11
+ if ($post->post_type === 'nav_menu_item') {
12
  return;
13
  }
14
 
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_type === 'attachment' || $post->post_status !== 'publish') {
20
  return;
21
  }
22
 
270
  $related_posts = false;
271
  if ($taglist) {
272
  $q = "SELECT p.ID, p.post_title, p.post_content,p.post_excerpt, p.post_date, p.comment_count, count(t_r.object_id) as cnt FROM $wpdb->term_taxonomy t_t, $wpdb->term_relationships t_r, $wpdb->posts p WHERE t_t.taxonomy ='post_tag' AND t_t.term_taxonomy_id = t_r.term_taxonomy_id AND t_r.object_id = p.ID AND (t_t.term_id IN ($taglist)) AND p.ID NOT IN ($exclude_ids_str) AND " .
273
+ (!$options['exclude_categories'] ? "" : "p.ID NOT IN (SELECT tr.object_id FROM $wpdb->term_taxonomy tt, $wpdb->term_relationships tr WHERE tt.taxonomy = 'category' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.term_id IN (" . $options['exclude_categories'] . ")) AND ") .
274
  "p.post_status = 'publish' AND p.post_date_gmt < '$now' GROUP BY t_r.object_id ORDER BY cnt DESC, p.post_date_gmt DESC LIMIT $limit;";
275
 
276
  $related_posts = $wpdb->get_results($q);
286
  $exclude_ids_str = wp_rp_get_exclude_ids_list_string($exclude_ids);
287
 
288
  $q1 = "SELECT ID FROM $wpdb->posts posts WHERE post_status = 'publish' AND post_type = 'post' AND ID NOT IN ($exclude_ids_str)";
289
+ if($options['exclude_categories']) {
290
  $q1 .= " AND ID NOT IN (SELECT tr.object_id FROM $wpdb->term_taxonomy tt, $wpdb->term_relationships tr WHERE tt.taxonomy = 'category' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.term_id IN (" . $options['exclude_categories'] . "))";
291
  }
292
  $ids = $wpdb->get_col($q1, 0);
settings.php CHANGED
@@ -109,6 +109,10 @@ function wp_rp_admin_head() {
109
  add_action('admin_menu', 'wp_rp_settings_admin_menu');
110
 
111
  function wp_rp_settings_admin_menu() {
 
 
 
 
112
  $title = __('Related Posts', 'wp_related_posts');
113
  $count = wp_rp_number_of_available_notifications();
114
 
@@ -219,8 +223,7 @@ function wp_rp_ajax_hide_show_statistics() {
219
 
220
  add_action('wp_ajax_rp_show_hide_statistics', 'wp_rp_ajax_hide_show_statistics');
221
 
222
- function wp_rp_settings_page()
223
- {
224
  $title_tags = array('h2', 'h3', 'h4', 'p', 'div');
225
 
226
  $options = wp_rp_get_options();
@@ -251,7 +254,10 @@ function wp_rp_settings_page()
251
  'thumbnail_use_custom' => isset($postdata['wp_rp_thumbnail_use_custom']) && $postdata['wp_rp_thumbnail_use_custom'] === 'yes',
252
  'ctr_dashboard_enabled' => isset($postdata['wp_rp_ctr_dashboard_enabled']),
253
  'promoted_content_enabled' => isset($postdata['wp_rp_promoted_content_enabled']),
254
- 'enable_themes' => isset($postdata['wp_rp_enable_themes'])
 
 
 
255
  );
256
 
257
  if(!isset($postdata['wp_rp_exclude_categories'])) {
@@ -348,6 +354,10 @@ function wp_rp_settings_page()
348
  <input type="hidden" id="wp_rp_auth_key" value="<?php esc_attr_e($meta['auth_key']); ?>" />
349
  <?php endif; ?>
350
 
 
 
 
 
351
  <div class="header">
352
  <div class="support">
353
  <h4><?php _e("Awesome support", 'wp_related_posts'); ?></h4>
@@ -369,7 +379,7 @@ function wp_rp_settings_page()
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>
@@ -446,12 +456,14 @@ jQuery(function($) {
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>
@@ -489,12 +501,22 @@ jQuery(function($) {
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>
@@ -563,12 +585,12 @@ jQuery(function($) {
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();" >
@@ -627,6 +649,18 @@ jQuery(function($) {
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']); ?> />
109
  add_action('admin_menu', 'wp_rp_settings_admin_menu');
110
 
111
  function wp_rp_settings_admin_menu() {
112
+ if (!current_user_can('delete_users')) {
113
+ return;
114
+ }
115
+
116
  $title = __('Related Posts', 'wp_related_posts');
117
  $count = wp_rp_number_of_available_notifications();
118
 
223
 
224
  add_action('wp_ajax_rp_show_hide_statistics', 'wp_rp_ajax_hide_show_statistics');
225
 
226
+ function wp_rp_settings_page() {
 
227
  $title_tags = array('h2', 'h3', 'h4', 'p', 'div');
228
 
229
  $options = wp_rp_get_options();
254
  'thumbnail_use_custom' => isset($postdata['wp_rp_thumbnail_use_custom']) && $postdata['wp_rp_thumbnail_use_custom'] === 'yes',
255
  'ctr_dashboard_enabled' => isset($postdata['wp_rp_ctr_dashboard_enabled']),
256
  'promoted_content_enabled' => isset($postdata['wp_rp_promoted_content_enabled']),
257
+ 'enable_themes' => isset($postdata['wp_rp_enable_themes']),
258
+ 'show_RP_in_posts' => isset($postdata['wp_rp_show_RP_in_posts']),
259
+ 'custom_theme_enabled' => isset($postdata['wp_rp_custom_theme_enabled']),
260
+ 'traffic_exchange_enabled' => isset($postdata['wp_rp_traffic_exchange_enabled'])
261
  );
262
 
263
  if(!isset($postdata['wp_rp_exclude_categories'])) {
354
  <input type="hidden" id="wp_rp_auth_key" value="<?php esc_attr_e($meta['auth_key']); ?>" />
355
  <?php endif; ?>
356
 
357
+ <?php if($meta['show_traffic_exchange'] && $options['traffic_exchange_enabled']): ?>
358
+ <input type="hidden" id="wp_rp_show_traffic_exchange_statistics" value="1" />
359
+ <?php endif; ?>
360
+
361
  <div class="header">
362
  <div class="support">
363
  <h4><?php _e("Awesome support", 'wp_related_posts'); ?></h4>
379
  Turn on Advanced Features
380
  </h2>
381
  <ul>
382
+ <li>Real-time Analytics*</li>
383
  <li>Thumbnail Support</li>
384
  <li>Promoted Content</li>
385
  </ul>
456
 
457
  <form method="post" enctype="multipart/form-data" action="" id="wp_rp_settings_form">
458
  <?php if ($options['ctr_dashboard_enabled']): ?>
459
+ <div id="wp_rp_statistics_holder">
460
+ <div id="wp_rp_statistics_collapsible" block="statistics" class="collapsible<?php if(!$meta['show_statistics']) { echo " collapsed"; } ?>">
461
+ <a href="#" class="collapse-handle">Collapse</a>
462
+ <h2><?php _e('Statistics', 'wp_related_posts'); ?></h2>
463
+ <div class="container" <?php if(!$meta['show_statistics']) { echo ' style="display: none;" '; } ?>>
464
+ <div id="wp_rp_statistics_wrap">
465
+ <div class="message unavailable"><?php _e("Statistics currently unavailable",'wp_related_posts'); ?></div>
466
+ </div>
467
  </div>
468
  </div>
469
  </div>
501
  <input name="wp_rp_enable_themes" type="checkbox" id="wp_rp_enable_themes" value="yes"<?php checked($options["enable_themes"]); ?> />
502
  <?php _e("Enable Themes",'wp_related_posts'); ?>*
503
  </label>
504
+ <div id="wp_rp_theme_area" style="display: none;">
505
+ <div class="theme-list"></div>
506
+ <div class="theme-screenshot"></div>
507
+ <div class="theme-extra-options">
508
+ <label>
509
+ <input type="checkbox" id="wp_rp_custom_theme_enabled" name="wp_rp_custom_theme_enabled" value="yes"<?php checked($options['custom_theme_enabled']); ?> />
510
+ Customize
511
+ </label>
512
+ </div>
513
+ </div>
514
  </td>
515
  </tr>
516
  <tr id="wp_rp_theme_custom_css_wrap" style="display: none; ">
517
  <th scope="row"></th>
518
  <td>
519
+ <p class="notice">To override default rules please add "!important" after every declaration.</p>
520
  <textarea style="width: 300px; height: 215px;" name="wp_rp_theme_custom_css" class="custom-css"><?php echo htmlspecialchars($theme_custom_css, ENT_QUOTES); ?></textarea>
521
  </td>
522
  </tr>
585
  <th scope="row"><?php _e("Display Options:",'wp_related_posts'); ?></th>
586
  <td>
587
  <label>
588
+ <input name="wp_rp_display_comment_count" type="checkbox" id="wp_rp_display_comment_count" value="yes" <?php checked($options["display_comment_count"]); ?>>
589
+ <?php _e("Display Number of Comments",'wp_related_posts');?>
590
  </label><br />
591
  <label>
592
+ <input name="wp_rp_display_publish_date" type="checkbox" id="wp_rp_display_publish_date" value="yes" <?php checked($options["display_publish_date"]); ?>>
593
+ <?php _e("Display Publish Date",'wp_related_posts');?>
594
  </label><br />
595
  <label>
596
  <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();" >
649
  <input name="wp_rp_on_rss" type="checkbox" id="wp_rp_on_rss" value="yes"<?php checked($options['on_rss']); ?>>
650
  <?php _e("Display Related Posts in Feed",'wp_related_posts');?>
651
  </label>
652
+ <br />
653
+ <label>
654
+ <input name="wp_rp_show_RP_in_posts" type="checkbox" id="wp_rp_show_RP_in_posts" value="yes"<?php checked($options['show_RP_in_posts']); ?>>
655
+ <?php _e("Show related posts in article text",'wp_related_posts');?>
656
+ </label>
657
+ <?php if($meta['show_traffic_exchange']): ?>
658
+ <br />
659
+ <label>
660
+ <input name="wp_rp_traffic_exchange_enabled" type="checkbox" id="wp_rp_traffic_exchange_enabled" value="yes"<?php checked($options['traffic_exchange_enabled']); ?>>
661
+ <?php _e("Enable traffic exchange with blogger networks",'wp_related_posts');?>
662
+ </label>
663
+ <?php endif; ?>
664
  <br />
665
  <label>
666
  <input name="wp_rp_ctr_dashboard_enabled" type="checkbox" id="wp_rp_ctr_dashboard_enabled" value="yes" <?php checked($options['ctr_dashboard_enabled']); ?> />
static/css/dashboard.css CHANGED
@@ -1,20 +1,23 @@
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;}
5
- #wp_rp_wrap div.header div.support {padding: 15px 15px 15px 67px; background: url(../img/icon_support.png) 15px 20px no-repeat; background-size: 37px 37px; border: 1px solid #ddd; float: right; clear: right; width: 150px;}
6
  #wp_rp_wrap div.header div.support h4 {text-transform: uppercase; font-weight: bold; margin: 0; font-size: 11px;}
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;}
@@ -23,9 +26,19 @@
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;}
@@ -51,7 +64,7 @@
51
  #wp_rp_invite_friends_form img.down { display: none; }
52
  #wp_rp_invite_friends_form.up img.down { display: block; }
53
 
54
- #wp_rp_turn_on_statistics { margin: 20px 0px; padding: 20px; background: #f7f7f7; border: 1px solid #e1e1e1; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
55
  #wp_rp_turn_on_statistics table {}
56
  #wp_rp_turn_on_statistics h2 { font-weight: bold; }
57
  #wp_rp_turn_on_statistics p { margin: 0px; color: #777; }
@@ -70,66 +83,27 @@ form.wp_rp_message_form a.dismiss {float: right;}
70
 
71
  #wp_rp_enable_ads_form h2 {font-weight: bold;}
72
 
73
- #wp_rp_wrap .wp_rp_notification {
74
- border: 1px solid #57aab8;
75
- background: #f1f9fb;
76
- -moz-border-radius: 3px;
77
- -webkit-border-radius: 3px;
78
- border-radius: 3px;
79
- margin: 10px 0;
80
- padding: 0;
81
- position: relative;
82
- }
83
- #wp_rp_wrap .wp_rp_notification p {
84
- color: #464646;
85
- font-size: 18px;
86
- padding: 30px 30px 30px 80px;
87
- margin: 0;
88
- background: url(../img/measure_icon.png) 20px 15px no-repeat;
89
- }
90
- #wp_rp_wrap .wp_rp_notification .close {
91
- text-decoration: none;
92
- overflow: hidden;
93
- background: url(../img/cross.png) 50% 50% no-repeat;
94
- text-indent: -9999px;
95
- display: block;
96
- width: 24px;
97
- height: 24px;
98
- position: absolute;
99
- right: 8px;
100
- top: 8px;
101
- }
102
 
103
  @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
104
- .wp_rp_notification p {
105
- background-image: url(../img/measure_icon_2x.png);
106
- background-size: 42px 42px;
107
- }
108
- .wp_rp_notification .close {
109
- background-image: url(../img/cross_2x.png);
110
- background-size: 12px 12px;
111
- }
112
  }
113
 
114
- #wp_rp_wrap .excluded-categories {
115
- width: 250px;
116
- height: 12em;
117
- overflow: auto;
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;
125
- margin-right: 16px;
126
- float: right;
127
- width: 30px;
128
- height: 20px;
129
- background: url('../img/up.jpg') 0% 0% no-repeat;
130
- text-indent: -9999px;
131
- overflow: hidden;
132
- outline: 0;
133
- }
134
  #wp_rp_wrap .collapsible.collapsed .collapse-handle {background-image: url('../img/down.jpg');}
135
  #wp_rp_wrap .collapsible .collapse-handle:after {clear:both;overflow:hidden;height:0;}
 
 
 
 
 
 
 
 
 
1
  #wp_rp_wrap div.header {position: relative; padding-bottom: 5px;}
2
+ #wp_rp_wrap .updated, #wp_rp_wrap .error {max-width: 590px; margin-right: 254px; padding: 5px;}
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;}
5
+ #wp_rp_wrap div.header div.support {padding: 15px 15px 15px 67px; background: url(../img/icon_support.png) 15px 20px no-repeat; background-size: 37px 37px; border: 1px solid #ddd; float: right; clear: right; width: 150px; margin-bottom: 10px;}
6
  #wp_rp_wrap div.header div.support h4 {text-transform: uppercase; font-weight: bold; margin: 0; font-size: 11px;}
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; overflow: hidden;}
12
+ #wp_rp_wrap div#wp_rp_statistics_holder {overflow: hidden;}
13
 
14
+ #wp_rp_wrap div#wp_rp_statistics_collapsible {float: left; min-width: 600px;}
15
  #wp_rp_wrap div#wp_rp_statistics_collapsible.collapsed {border-bottom: 1px solid #ddd;}
16
  #wp_rp_wrap div#wp_rp_statistics_collapsible.collapsed {border-bottom: 1px solid #ddd;}
17
 
18
+ #wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics {margin: 0; float: left; width: 600px;}
19
+ #wp_rp_wrap.wp_rp_dashboard div#wp_rp_statistics_wrap ul.statistics {float: none; width: auto;}
20
+
21
  #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;}
22
  #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;}
23
  #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;}
26
  #wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li h5 span {text-transform: lowercase; font-size: 11px; color: #999; margin-left: 10px;}
27
  #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;}
28
  #wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li p.num.mobile {position: absolute; left: 0;}
29
+
30
  #wp_rp_dashboard_widget #wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li.clicks {border-bottom: 0;}
31
 
32
+ #wp_rp_wrap div#wp_rp_statistics_wrap div.network {position: relative; text-align: center; float: left; height: 123px; width: 140px; margin: 60px 0 0 20px; border: 1px solid #ddd; padding: 30px; border: 1px solid #ddd; border-radius: 3px;}
33
+ #wp_rp_wrap.wp_rp_dashboard div#wp_rp_statistics_wrap div.network {float: none; width: auto; margin: 0px; height: auto; padding: 25px;}
34
+ #wp_rp_wrap div#wp_rp_statistics_wrap div.network .icon {width: 43px; height: 35px; background: url(../img/network_icon.png); background-size: 43px 35px; margin: 0 auto;}
35
+ #wp_rp_wrap div#wp_rp_statistics_wrap div.network span.num {font-size: 36px; font-weight: bold; margin: 20px 0 15px 0; display: block;}
36
+ #wp_rp_wrap div#wp_rp_statistics_wrap div.network h4 {font-size: 16px; color: #333; text-transform: uppercase; font-weight: normal; line-height: 24px; margin: 0; padding: 0;}
37
+ #wp_rp_wrap div#wp_rp_statistics_wrap div.network .description {display: none; position: absolute; top: 0; left: 0; background: #fff; width: 100%; height: 100%;}
38
+ #wp_rp_wrap div#wp_rp_statistics_wrap div.network .description p {margin: 40px 18px; color: #666; font-size: 13px; line-height: 18px;}
39
+ #wp_rp_wrap div#wp_rp_statistics_wrap div.network .description p strong {display: block; font-weight: bold; margin-top: 5px;}
40
+ #wp_rp_wrap div#wp_rp_statistics_wrap div.network:hover .description {display: block;}
41
+
42
 
43
  #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;}
44
  #wp_rp_wrap div#wp_rp_statistics_wrap div.message.enable {color: #82c1cb;}
64
  #wp_rp_invite_friends_form img.down { display: none; }
65
  #wp_rp_invite_friends_form.up img.down { display: block; }
66
 
67
+ #wp_rp_turn_on_statistics {max-width: 600px; margin: 20px 0px; padding: 20px; background: #f7f7f7; border: 1px solid #e1e1e1; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
68
  #wp_rp_turn_on_statistics table {}
69
  #wp_rp_turn_on_statistics h2 { font-weight: bold; }
70
  #wp_rp_turn_on_statistics p { margin: 0px; color: #777; }
83
 
84
  #wp_rp_enable_ads_form h2 {font-weight: bold;}
85
 
86
+ #wp_rp_wrap .wp_rp_notification {border: 1px solid #57aab8; background: #f1f9fb; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; margin: 10px 0; padding: 0; position: relative; clear: right; }
87
+ #wp_rp_wrap .wp_rp_notification p {color: #464646; font-size: 18px; padding: 30px 30px 30px 80px; margin: 0; background: url(../img/measure_icon.png) 20px 15px no-repeat;}
88
+ #wp_rp_wrap .wp_rp_notification .close {text-decoration: none; overflow: hidden; background: url(../img/cross.png) 50% 50% no-repeat; text-indent: -9999px; display: block; width: 24px; height: 24px; position: absolute; right: 8px; top: 8px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
91
+ .wp_rp_notification p {background-image: url(../img/measure_icon_2x.png); background-size: 42px 42px;}
92
+ .wp_rp_notification .close {background-image: url(../img/cross_2x.png); background-size: 12px 12px;}
 
 
 
 
 
 
93
  }
94
 
95
+ #wp_rp_wrap .excluded-categories {width: 250px; height: 12em; overflow: auto; padding: 0 5px; border: 1px solid #dfdfdf;}
 
 
 
 
 
 
96
 
97
  /* collapsible CSS */
98
+ #wp_rp_wrap .collapsible .collapse-handle {margin-top: 16px; margin-right: 16px; float: right; width: 30px; height: 20px; background: url('../img/up.jpg') 0% 0% no-repeat; text-indent: -9999px; overflow: hidden; outline: 0;}
 
 
 
 
 
 
 
 
 
 
99
  #wp_rp_wrap .collapsible.collapsed .collapse-handle {background-image: url('../img/down.jpg');}
100
  #wp_rp_wrap .collapsible .collapse-handle:after {clear:both;overflow:hidden;height:0;}
101
+
102
+ #wp_rp_theme_options_wrap .theme-list {margin: 5px 0; width: 150px; float: left;}
103
+ #wp_rp_theme_options_wrap .theme-screenshot img {width: 448px; margin-top: -30px;}
104
+ #wp_rp_theme_options_wrap .theme-screenshot {height: 170px;}
105
+ #wp_rp_theme_options_wrap .theme-extra-options {clear: left;}
106
+ #wp_rp_theme_options_wrap .custom-theme {clear: both;}
107
+
108
+ #wp_rp_theme_custom_css_wrap td {margin: 0; padding-top: 0;}
109
+ #wp_rp_theme_custom_css_wrap .notice {margin: 0; padding: 0 0 3px 0; color: #666;}
static/img/network_icon.png ADDED
Binary file
static/img/promoted_arrow.png CHANGED
Binary file
static/js/dashboard.js CHANGED
@@ -1,9 +1,9 @@
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);
1
+ (function(a){var b=function(c,b){a.each(b,function(a,b){c=c.replace(RegExp("{{ *"+a+" *}}"),b)});return c};a(function(){var c=a("#wp_rp_statistics_wrap"),h=a("#wp_rp_dashboard_url").val(),g=a("#wp_rp_blog_id").val(),f=a("#wp_rp_auth_key").val();traffic_exchange_enabled=0<a("#wp_rp_show_traffic_exchange_statistics").length;update_interval=req_timeout=null;update_interval_sec=2E3;update_interval_error_sec=3E4;updating=!1;ul=null;stats={};set_update_interval=function(a){a||(a=update_interval_sec);clearInterval(update_interval);
2
+ 0<a&&(update_interval=setInterval(update_dashboard,a))};display_error=function(e){var i=a("#wp_rp_statistics_wrap");e||i.find(".unavailable").slideDown();set_update_interval(update_interval_error_sec);updating=!1};create_dashboard=function(){ul=a('<ul class="statistics" />');c.find(".unavailable").slideUp();ul.append('<li class="title"><div class="desktop">Desktop</div><div class="mobile">Mobile</div></li>');ul.append(b('<li 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",range:"last 30 days"}));ul.append(b('<li 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",range:"last 30 days"}));ul.append(b('<li class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',{"class":"clicks",title:"clicks",range:"last 30 days"}));c.append(ul);traffic_exchange_enabled&&
4
+ c.append('<div class="network"><div class="icon"></div><span class="num"></span><h4>Inbound Visitors</h4><div class="description"><p>Number of visitors that came to your site because this plugin promoted your content on other sites.<strong>Wow, a traffic exchange! :)</strong></p></div></div>')};update_dashboard=function(e){updating||(updating=!0,req_timeout=setTimeout(function(){display_error(!e)},2E3),a.getJSON(h+"pageviews/?callback=?",{blog_id:g,auth_key:f},function(a){var d=a.data;clearTimeout(req_timeout);
5
+ if(!a||"ok"!==a.status||!a.data)display_error(!e);else{ul||create_dashboard();set_update_interval(a.data.update_interval);stats.mobile_pageviews=Math.max(d.mobile_pageviews,stats.mobile_pageviews||0);stats.mobile_clicks=Math.max(d.mobile_clicks,stats.mobile_clicks||0);a=0<stats.mobile_pageviews&&(100*(stats.mobile_clicks/stats.mobile_pageviews)).toFixed(1)||0;stats.desktop_pageviews=Math.max(d.pageviews-stats.mobile_pageviews,stats.desktop_pageviews||0);stats.desktop_clicks=Math.max(d.clicks-stats.mobile_clicks,
6
+ stats.desktop_clicks||0);var b=0<stats.desktop_pageviews&&(100*(stats.desktop_clicks/stats.desktop_pageviews)).toFixed(1)||0;stats.network_in_pageviews=Math.max(d.network_in_pageviews,stats.network_in_pageviews||0);ul.find(".ctr .num.all").html(b+"%");ul.find(".pageviews .num.all").html(stats.desktop_pageviews);ul.find(".clicks .num.all").html(stats.desktop_clicks);ul.find(".ctr .num.mobile").html(a+"%");ul.find(".pageviews .num.mobile").html(stats.mobile_pageviews);ul.find(".clicks .num.mobile").html(stats.mobile_clicks);
7
+ c.find(".network .num").html(stats.network_in_pageviews);updating=!1}}))};g&&f&&(update_dashboard(!0),update_interval=setInterval(update_dashboard,2E3));a("#wp_rp_turn_on_statistics a.turn-on").click(function(e){e.preventDefault();var e=a("#wp_rp_static_base_url").val(),b=!1,d=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">');
8
+ a("<img />").load(d).error(d).attr("src",e+"stats.gif?action=turn_on_button&ads=1&nc="+(new Date).getTime());setTimeout(d,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 c=a(this).closest(".collapsible"),d=c.find(".container"),g=c.hasClass("collapsed"),f=c.attr("block");g?(d.slideDown(),
9
+ a.post(ajaxurl,{action:"rp_show_hide_"+f,show:!0})):(d.slideUp(),a.post(ajaxurl,{action:"rp_show_hide_"+f,hide:!0}));c.toggleClass("collapsed");b.preventDefault()})})})(jQuery);
static/js/themes.js CHANGED
@@ -1,3 +1,4 @@
1
- (function(a){a(function(){var d=a("#wp_rp_theme_options_wrap"),i=a("#wp_rp_json_url").val(),j=a("#wp_rp_version").val(),e=a("#wp_rp_theme_selected").val(),f=null,g=function(){var a=document.createElement("script"),c=document.getElementsByTagName("body").item(0);a.type="text/javascript";a.src=i+"themes.js?plv="+j;c.appendChild(a)},h=function(b){var c=a("#wp_rp_theme_custom_css_wrap");"custom.css"===b?c.show():c.hide()};window.wp_rp_themes_cb=function(b){if(b&&b.themes&&(f=b.themes)){var c=d.find("div.theme-list");
2
- c.empty();a.each(f,function(a,b){c.append("<label><input "+(b.location===e?'checked="checked"':"")+' class="theme-option" type="radio" name="wp_rp_theme_name" value="'+b.location+'" /> '+b.name+"</label><br />")});c.on("click change","input.theme-option",function(){a(this).prop("checked")&&h(a(this).val())});d.show();h(e)}};a("#wp_rp_enable_themes:checked").length&&g();a("#wp_rp_enable_themes").change(function(){a("#wp_rp_enable_themes:checked").length?g():a("#wp_rp_theme_options_wrap div.theme-list").empty()});
3
- (!window.localStorage||!window.localStorage.wp_wp_survey_1)&&a("#wp-rp-survey").show();a("#wp-rp-survey .close, #wp-rp-survey .link").click(function(){a("#wp-rp-survey").fadeOut();window.localStorage&&(window.localStorage.wp_wp_survey_1="close")})})})(jQuery);
 
1
+ (function(a){a(function(){var e=a("#wp_rp_theme_options_wrap"),h=e.find("#wp_rp_theme_area"),l=a("#wp_rp_static_base_url").val(),m=a("#wp_rp_json_url").val(),n=a("#wp_rp_version").val(),p=a("#wp_rp_theme_selected").val(),i=null,j=function(){var a=document.createElement("script"),b=document.getElementsByTagName("body").item(0);a.type="text/javascript";a.src=m+"themes.js?plv="+n;b.appendChild(a)},k=function(){var d=a("#wp_rp_custom_theme_enabled:checked"),b=a("#wp_rp_theme_custom_css_wrap");d.length?
2
+ b.show():b.hide()};k();a("#wp_rp_custom_theme_enabled").on("change",function(){k()});window.wp_rp_themes_cb=function(d){if(d&&d.themes&&(i=d.themes)){var b=e.find("div.theme-list"),f=e.find("div.theme-screenshot"),g=function(b){if("plain.css"==b.val())f.html("");else{var b=l+"img/themes/"+b.val().replace(/\.css$/,".jpg"),c=f.find("img");if(c.length){if(c.attr("src")===b)return}else c=a("<img />"),f.html(c);c.attr("src",b)}};b.empty();a.each(i,function(a,c){"custom.css"!=c.location&&b.append('<label class="theme-label"><input '+
3
+ (c.location===p?'checked="checked"':"")+' class="theme-option" type="radio" name="wp_rp_theme_name" value="'+c.location+'" /> '+c.name+"</label><br />")});b.on("hover","label.theme-label",function(){g(a("input",this))});b.on("mouseleave",function(){g(b.find("input:checked"))});g(b.find("input:checked"));h.show()}};a("#wp_rp_enable_themes:checked").length&&j();a("#wp_rp_enable_themes").change(function(){a("#wp_rp_enable_themes:checked").length?(j(),a("#wp_rp_theme_custom_css_wrap").css({display:a("#wp_rp_custom_theme_enabled:checked").length?
4
+ "table-row":"none"})):(a("#wp_rp_theme_options_wrap div.theme-list").empty(),a("#wp_rp_theme_custom_css_wrap").hide(),h.hide())});(!window.localStorage||!window.localStorage.wp_wp_survey_1)&&a("#wp-rp-survey").show();a("#wp-rp-survey .close, #wp-rp-survey .link").click(function(){a("#wp-rp-survey").fadeOut();window.localStorage&&(window.localStorage.wp_wp_survey_1="close")})})})(jQuery);
thumbnailer.php CHANGED
@@ -11,12 +11,27 @@ function wp_rp_upload_default_thumbnail_file() {
11
  if(isset($upload['error'])) {
12
  return new WP_Error('upload_error', $upload['error']);
13
  } else if(isset($upload['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['url'] . '/' . wp_basename($path);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
- return $path;
20
  }
21
  }
22
  return false;
@@ -86,7 +101,6 @@ function wp_rp_actually_extract_images_from_post_html($post) {
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;
@@ -109,7 +123,20 @@ function wp_rp_actually_extract_images_from_post_html($post) {
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;
@@ -147,7 +174,7 @@ function wp_rp_extract_images_from_post_html($post) {
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
 
11
  if(isset($upload['error'])) {
12
  return new WP_Error('upload_error', $upload['error']);
13
  } else if(isset($upload['file'])) {
14
+ $upload_dir = wp_upload_dir();
15
+
16
+ if (class_exists('WP_Image_Editor')) { // WP 3.5+
17
+ $image = WP_Image_Editor::get_instance($upload['file']);
18
+
19
+ $suffix = WP_RP_THUMBNAILS_WIDTH . 'x' . WP_RP_THUMBNAILS_HEIGHT;
20
+ $resized_img_path = $image->generate_filename($suffix, $upload_dir['path'], 'jpg');
21
+
22
+ $image->resize(WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT, true);
23
+ $image->save($resized_img_path, 'image/jpeg');
24
+
25
+ return $upload_dir['url'] . '/' . urlencode(wp_basename($resized_img_path));
26
+ } else {
27
+ $path = image_resize($upload['file'], WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT, true);
28
+ if (!is_wp_error($path)) {
29
+ return $upload_dir['url'] . '/' . wp_basename($path);
30
+ } else if (array_key_exists('error_getting_dimensions', $path->errors)) {
31
+ return $upload['url'];
32
+ }
33
+ return $path;
34
  }
 
35
  }
36
  }
37
  return false;
101
  if($upload_dir['error'] !== false) {
102
  return $img_url;
103
  }
 
104
  require_once(ABSPATH . 'wp-admin/includes/file.php');
105
 
106
  global $wp_filesystem;
123
  continue;
124
  }
125
 
126
+ if (class_exists('WP_Image_Editor')) { // WP 3.5+
127
+ $image = WP_Image_Editor::get_instance($img_path);
128
+
129
+ $suffix = WP_RP_THUMBNAILS_WIDTH . 'x' . WP_RP_THUMBNAILS_HEIGHT;
130
+ $resized_img_path = $image->generate_filename($suffix, $upload_dir['path'], 'jpg');
131
+
132
+ $image->resize(WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT, true);
133
+ $image->save($resized_img_path, 'image/jpeg');
134
+ } else {
135
+ $resized_img_path = image_resize($img_path, WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT, true);
136
+ if (is_wp_error($resized_img_path) && array_key_exists('error_getting_dimensions', $resized_img_path->errors)) {
137
+ $resized_img_path = $img_path;
138
+ }
139
+ }
140
 
141
  if(is_wp_error($resized_img_path)) {
142
  continue;
174
  function wp_rp_post_save_update_image($post_id) {
175
  $post = get_post($post_id);
176
 
177
+ if(empty($post->post_content) || $post->post_status !== 'publish' || $post->post_type === 'page' || $post->post_type === 'attachment' || $post->post_type === 'nav_menu_item') {
178
  return;
179
  }
180
 
wp_related_posts.php CHANGED
@@ -1,14 +1,14 @@
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');
@@ -47,7 +47,7 @@ function wp_rp_add_related_posts_hook($content) {
47
  global $wp_rp_output, $post;
48
  $options = wp_rp_get_options();
49
 
50
- if ((is_single() && $options["on_single_post"]) || (is_feed() && $options["on_rss"])) {
51
  if (!isset($wp_rp_output[$post->ID])) {
52
  $wp_rp_output[$post->ID] = wp_rp_get_related_posts();
53
  }
@@ -87,6 +87,10 @@ function wp_rp_fetch_posts_and_title() {
87
  wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts');
88
  wp_rp_append_posts($related_posts, 'wp_rp_fetch_random_posts');
89
 
 
 
 
 
90
  return array(
91
  "posts" => $related_posts,
92
  "title" => $title
@@ -98,8 +102,15 @@ function wp_rp_generate_related_posts_list_items($related_posts) {
98
  $output = "";
99
  $i = 0;
100
 
 
 
101
  foreach ($related_posts as $related_post ) {
102
- $output .= '<li position="' . $i++ . '">';
 
 
 
 
 
103
 
104
  $img = wp_rp_get_post_thumbnail_img($related_post);
105
  if ($img) {
@@ -138,7 +149,7 @@ function wp_rp_should_exclude() {
138
 
139
  $options = wp_rp_get_options();
140
 
141
- if($options['exclude_categories'] === '') { return false; }
142
 
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
 
@@ -149,6 +160,39 @@ function wp_rp_should_exclude() {
149
  return $count > 0;
150
  }
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  function wp_rp_head_resources() {
153
  global $post, $wpdb;
154
 
@@ -163,7 +207,7 @@ function wp_rp_head_resources() {
163
  $output = '';
164
 
165
  // turn off statistics or recommendations on non-singular posts
166
- if(is_single()) {
167
  $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
168
  $remote_recommendations = $meta['remote_recommendations'] && $statistics_enabled;
169
  }
@@ -185,7 +229,10 @@ function wp_rp_head_resources() {
185
  "\twindow._wp_rp_post_tags = {$post_tags};\n" .
186
  "\twindow._wp_rp_static_base_url = '" . esc_js(WP_RP_STATIC_BASE_URL) . "';\n" .
187
  "\twindow._wp_rp_promoted_content = " . ($options['promoted_content_enabled'] ? 'true' : 'false') . ";\n" .
 
188
  "\twindow._wp_rp_plugin_version = '" . WP_RP_VERSION . "';\n" .
 
 
189
  "</script>\n";
190
  }
191
 
@@ -206,8 +253,8 @@ function wp_rp_head_resources() {
206
  }
207
 
208
  $output .= '<link rel="stylesheet" href="' . $theme_url . $options['theme_name'] . '?version=' . WP_RP_VERSION . '" />' . "\n";
209
- if ($options['theme_name'] === 'custom.css') {
210
- $output .= '<style type="text/css">' . $options['theme_custom_css'] . "</style>\n";
211
  }
212
  }
213
 
@@ -233,17 +280,19 @@ function wp_rp_get_related_posts($before_title = '', $after_title = '') {
233
  $related_posts = $posts_and_title['posts'];
234
  $title = $posts_and_title['title'];
235
 
 
 
 
 
236
  $css_classes = 'related_post wp_rp';
237
  if ($options['enable_themes']) {
238
  $css_classes .= ' ' . str_replace(array('.css', '-'), array('', '_'), esc_attr('wp_rp_' . $options['theme_name']));
239
  }
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 != '') {
1
  <?php
2
  /*
3
  Plugin Name: WordPress Related Posts
4
+ Version: 2.2
5
  Plugin URI: http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/
6
+ Description: Quickly increase your readers' engagement with your posts by adding Related Posts in the footer of your content.
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.2');
12
 
13
  include_once(dirname(__FILE__) . '/config.php');
14
  include_once(dirname(__FILE__) . '/lib/stemmer.php');
47
  global $wp_rp_output, $post;
48
  $options = wp_rp_get_options();
49
 
50
+ if (($options["on_single_post"] && is_single() && !is_page() && !is_attachment()) || (is_feed() && $options["on_rss"])) {
51
  if (!isset($wp_rp_output[$post->ID])) {
52
  $wp_rp_output[$post->ID] = wp_rp_get_related_posts();
53
  }
87
  wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts');
88
  wp_rp_append_posts($related_posts, 'wp_rp_fetch_random_posts');
89
 
90
+ if(function_exists('qtrans_postsFilter')) {
91
+ $related_posts = qtrans_postsFilter($related_posts);
92
+ }
93
+
94
  return array(
95
  "posts" => $related_posts,
96
  "title" => $title
102
  $output = "";
103
  $i = 0;
104
 
105
+ $statistics_enabled = $options['ctr_dashboard_enabled'];
106
+
107
  foreach ($related_posts as $related_post ) {
108
+ $data_attrs = '';
109
+ if ($statistics_enabled) {
110
+ $data_attrs .= 'data-position="' . $i++ . '" data-poid="in-' . $related_post->ID . '" ';
111
+ }
112
+
113
+ $output .= '<li ' . $data_attrs . '>';
114
 
115
  $img = wp_rp_get_post_thumbnail_img($related_post);
116
  if ($img) {
149
 
150
  $options = wp_rp_get_options();
151
 
152
+ if(!$options['exclude_categories']) { return false; }
153
 
154
  $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'] . ')';
155
 
160
  return $count > 0;
161
  }
162
 
163
+ function wp_rp_ajax_blogger_network_blacklist_callback() {
164
+ if (!current_user_can('delete_users')) {
165
+ die();
166
+ }
167
+
168
+ $sourcefeed = (int) $_GET['sourcefeed'];
169
+
170
+ $meta = wp_rp_get_meta();
171
+
172
+ $blog_id = $meta['blog_id'];
173
+ $auth_key = $meta['auth_key'];
174
+ $req_options = array(
175
+ 'timeout' => 5
176
+ );
177
+ $url = WP_RP_CTR_DASHBOARD_URL . "blacklist/?blog_id=$blog_id&auth_key=$auth_key&sfid=$sourcefeed";
178
+ $response = wp_remote_get($url, $req_options);
179
+
180
+ if (wp_remote_retrieve_response_code($response) == 200) {
181
+ $body = wp_remote_retrieve_body($response);
182
+ if ($body) {
183
+ $doc = json_decode($body);
184
+ if ($doc && $doc->status === 'ok') {
185
+ header_remove();
186
+ header('Content-Type: text/javascript');
187
+ echo "if(window['_wp_rp_blacklist_callback$sourcefeed']) window._wp_rp_blacklist_callback$sourcefeed();";
188
+ }
189
+ }
190
+ }
191
+ die();
192
+ }
193
+
194
+ add_action('wp_ajax_rp_blogger_network_blacklist', 'wp_rp_ajax_blogger_network_blacklist_callback');
195
+
196
  function wp_rp_head_resources() {
197
  global $post, $wpdb;
198
 
207
  $output = '';
208
 
209
  // turn off statistics or recommendations on non-singular posts
210
+ if (is_single() && !is_page() && !is_attachment()) {
211
  $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
212
  $remote_recommendations = $meta['remote_recommendations'] && $statistics_enabled;
213
  }
229
  "\twindow._wp_rp_post_tags = {$post_tags};\n" .
230
  "\twindow._wp_rp_static_base_url = '" . esc_js(WP_RP_STATIC_BASE_URL) . "';\n" .
231
  "\twindow._wp_rp_promoted_content = " . ($options['promoted_content_enabled'] ? 'true' : 'false') . ";\n" .
232
+ (wp_is_mobile() && $options['show_RP_in_posts'] ? "\twindow._wp_rp_show_rp_in_posts = true;\n" : '') .
233
  "\twindow._wp_rp_plugin_version = '" . WP_RP_VERSION . "';\n" .
234
+ "\twindow._wp_rp_traffic_exchange = " . ($options['traffic_exchange_enabled'] ? 'true' : 'false') . ";\n" .
235
+ (current_user_can('delete_users') ? "\twindow._wp_rp_admin_ajax_url = '" . admin_url('admin-ajax.php') . "';\n" : '') .
236
  "</script>\n";
237
  }
238
 
253
  }
254
 
255
  $output .= '<link rel="stylesheet" href="' . $theme_url . $options['theme_name'] . '?version=' . WP_RP_VERSION . '" />' . "\n";
256
+ if ($options['custom_theme_enabled']) {
257
+ $output .= '<style type="text/css">' . "\n" . $options['theme_custom_css'] . "</style>\n";
258
  }
259
  }
260
 
280
  $related_posts = $posts_and_title['posts'];
281
  $title = $posts_and_title['title'];
282
 
283
+ if (!$related_posts) {
284
+ return;
285
+ }
286
+
287
  $css_classes = 'related_post wp_rp';
288
  if ($options['enable_themes']) {
289
  $css_classes .= ' ' . str_replace(array('.css', '-'), array('', '_'), esc_attr('wp_rp_' . $options['theme_name']));
290
  }
291
 
292
+ $output = wp_rp_generate_related_posts_list_items($related_posts);
293
+ $output = '<ul class="' . $css_classes . '" style="visibility: ' . ($remote_recommendations ? 'hidden' : 'visible') . '">' . $output . '</ul>';
294
+ if($remote_recommendations) {
295
+ $output = $output . '<script type="text/javascript">window._wp_rp_callback_widget_exists && window._wp_rp_callback_widget_exists();</script>';
 
 
296
  }
297
 
298
  if ($title != '') {