WordPress Related Posts - Version 2.3

Version Description

  • Earn money by displaying promoted content
  • Bugfixes
Download this release

Release Info

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

Code changes from version 2.2 to 2.3

config.php CHANGED
@@ -163,7 +163,7 @@ function wp_rp_install() {
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' => '',
@@ -196,7 +196,6 @@ function wp_rp_install() {
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
  );
@@ -207,11 +206,22 @@ function wp_rp_install() {
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');
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' => '',
196
  'ctr_dashboard_enabled' => false,
197
  'promoted_content_enabled' => false,
198
  'enable_themes' => false,
 
199
  'custom_theme_enabled' => false,
200
  'traffic_exchange_enabled' => false
201
  );
206
  wp_rp_related_posts_db_table_install();
207
  }
208
 
209
+ function wp_rp_migrate_2_2() {
210
+ $wp_rp_meta = get_option('wp_rp_meta');
211
+ $wp_rp_options = get_option('wp_rp_options');
212
+
213
+ $wp_rp_meta['version'] = '2.3';
214
+
215
  if(isset($wp_rp_options['show_santa_hat'])) {
216
  unset($wp_rp_options['show_santa_hat']);
217
  }
218
+ if(isset($wp_rp_options['show_RP_in_posts'])) {
219
+ unset($wp_rp_options['show_RP_in_posts']);
220
+ }
221
+
222
+ update_option('wp_rp_meta', $wp_rp_meta);
223
+ update_option('wp_rp_options', $wp_rp_options);
224
+ }
225
 
226
  function wp_rp_migrate_2_1() {
227
  $wp_rp_meta = get_option('wp_rp_meta');
notifications.php CHANGED
@@ -113,12 +113,6 @@ function wp_rp_load_remote_notifications() {
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;
113
  $meta['show_blogger_network_form'] = false;
114
  }
115
 
 
 
 
 
 
 
116
  if(isset($data->show_traffic_exchange) && $data->show_traffic_exchange) {
117
  $meta['show_traffic_exchange'] = true;
118
  $options['traffic_exchange_enabled'] = true;
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.2
9
 
10
  WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
11
 
@@ -62,6 +62,10 @@ Yes, related posts are responsive so they adapt to the screen size to ensure max
62
 
63
  == Changelog ==
64
 
 
 
 
 
65
  = 2.2 =
66
  * Updated theme settings with one new theme
67
  * Option to enable related posts in article text
5
  License: GPLv2
6
  Requires at least: 3.3
7
  Tested up to: 3.5
8
+ Stable tag: 2.3
9
 
10
  WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
11
 
62
 
63
  == Changelog ==
64
 
65
+ = 2.3 =
66
+ * Earn money by displaying promoted content
67
+ * Bugfixes
68
+
69
  = 2.2 =
70
  * Updated theme settings with one new theme
71
  * Option to enable related posts in article text
recommendations.php CHANGED
@@ -8,15 +8,11 @@ function wp_rp_update_tags($post_id) {
8
  $post = get_post($post->post_parent);
9
  }
10
 
11
- if ($post->post_type === 'nav_menu_item') {
12
- return;
13
- }
14
-
15
  $wpdb->query(
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
 
@@ -212,7 +208,7 @@ function wp_rp_fetch_related_posts_v2($limit = 10, $exclude_ids = array()) {
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)) {
@@ -231,6 +227,7 @@ function wp_rp_fetch_related_posts_v2($limit = 10, $exclude_ids = array()) {
231
  SELECT post.ID, post.post_title, post.post_excerpt, post.post_content, post.post_date, post.comment_count
232
  FROM $wpdb->posts as post
233
  WHERE post.ID IN (" . implode(', ', array_fill(0, count($related_post_ids), '%s')) . ")
 
234
  AND post_status = 'publish'
235
  AND post_date_gmt < %s",
236
  array_merge($related_post_ids, array($now, $limit)));
@@ -271,7 +268,7 @@ function wp_rp_fetch_related_posts($limit = 10, $exclude_ids = array()) {
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);
277
  }
8
  $post = get_post($post->post_parent);
9
  }
10
 
 
 
 
 
11
  $wpdb->query(
12
  $wpdb->prepare('DELETE from ' . $wpdb->prefix . 'wp_rp_tags WHERE post_id=%d', $post->ID)
13
  );
14
 
15
+ if ($post->post_type !== 'post' || $post->post_status !== 'publish') {
16
  return;
17
  }
18
 
208
  $exclude_categories_labels,
209
  array($limit * 2)
210
  )
211
+ ); // limit * 2 just in case
212
 
213
  $related_posts_with_score = $wpdb->get_results($post_id_query, 0);
214
  if (empty($related_posts_with_score)) {
227
  SELECT post.ID, post.post_title, post.post_excerpt, post.post_content, post.post_date, post.comment_count
228
  FROM $wpdb->posts as post
229
  WHERE post.ID IN (" . implode(', ', array_fill(0, count($related_post_ids), '%s')) . ")
230
+ AND post_type = 'post'
231
  AND post_status = 'publish'
232
  AND post_date_gmt < %s",
233
  array_merge($related_post_ids, array($now, $limit)));
268
  if ($taglist) {
269
  $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 " .
270
  (!$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 ") .
271
+ "p.post_status = 'publish' AND p.post_type = 'post' AND p.post_date_gmt < '$now' GROUP BY t_r.object_id ORDER BY cnt DESC, p.post_date_gmt DESC LIMIT $limit;";
272
 
273
  $related_posts = $wpdb->get_results($q);
274
  }
settings.php CHANGED
@@ -255,7 +255,6 @@ function wp_rp_settings_page() {
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
  );
@@ -357,6 +356,9 @@ function wp_rp_settings_page() {
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">
@@ -456,6 +458,18 @@ jQuery(function($) {
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>
@@ -649,11 +663,6 @@ jQuery(function($) {
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>
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
  'custom_theme_enabled' => isset($postdata['wp_rp_custom_theme_enabled']),
259
  'traffic_exchange_enabled' => isset($postdata['wp_rp_traffic_exchange_enabled'])
260
  );
356
  <?php if($meta['show_traffic_exchange'] && $options['traffic_exchange_enabled']): ?>
357
  <input type="hidden" id="wp_rp_show_traffic_exchange_statistics" value="1" />
358
  <?php endif; ?>
359
+ <?php if($meta['remote_recommendations'] && $options['promoted_content_enabled']): ?>
360
+ <input type="hidden" id="wp_rp_show_promoted_content_statistics" value="1" />
361
+ <?php endif; ?>
362
 
363
  <div class="header">
364
  <div class="support">
458
 
459
  <form method="post" enctype="multipart/form-data" action="" id="wp_rp_settings_form">
460
  <?php if ($options['ctr_dashboard_enabled']): ?>
461
+ <div id="wp_rp_earnings_holder" style="display:none;">
462
+ <h2><?php _e('Earnings', 'wp_related_posts'); ?></h2>
463
+ <div class="container">
464
+ <p>By displaying promoted posts on your site you've already earned:</p>
465
+ <div id="wp_rp_earnings_wrap">
466
+ <span class="num"></span>
467
+ <a href="#" class="claim disabled">claim
468
+ <span class="payout-explain">You can claim the money when it reaches <span class="payout"></span>.</span>
469
+ </a>
470
+ </div>
471
+ </div>
472
+ </div>
473
  <div id="wp_rp_statistics_holder">
474
  <div id="wp_rp_statistics_collapsible" block="statistics" class="collapsible<?php if(!$meta['show_statistics']) { echo " collapsed"; } ?>">
475
  <a href="#" class="collapse-handle">Collapse</a>
663
  <input name="wp_rp_on_rss" type="checkbox" id="wp_rp_on_rss" value="yes"<?php checked($options['on_rss']); ?>>
664
  <?php _e("Display Related Posts in Feed",'wp_related_posts');?>
665
  </label>
 
 
 
 
 
666
  <?php if($meta['show_traffic_exchange']): ?>
667
  <br />
668
  <label>
static/css/dashboard.css CHANGED
@@ -44,6 +44,15 @@
44
  #wp_rp_wrap div#wp_rp_statistics_wrap div.message.enable {color: #82c1cb;}
45
  #wp_rp_wrap div#wp_rp_statistics_wrap div.message.unavailable {color: #848484; display: none; padding-top: 20px;}
46
 
 
 
 
 
 
 
 
 
 
47
  #wp_rp_dashboard_widget #wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li {display:block;width:100%;}
48
  #wp_rp_dashboard_widget #wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li div.overlay {z-index:100;width: 100%;margin:0;left:-10px;}
49
  #wp_rp_dashboard_widget #wp_rp_statistics_wrap {padding: 0;}
44
  #wp_rp_wrap div#wp_rp_statistics_wrap div.message.enable {color: #82c1cb;}
45
  #wp_rp_wrap div#wp_rp_statistics_wrap div.message.unavailable {color: #848484; display: none; padding-top: 20px;}
46
 
47
+ #wp_rp_earnings_wrap {position: relative;}
48
+ #wp_rp_earnings_wrap .num {font-size:48px; line-height: 1em; color:#e77001; font-weight:bold;}
49
+ #wp_rp_earnings_wrap a.claim {font-size: 16px; margin-left: 10px; color: #333;}
50
+ #wp_rp_earnings_wrap a.claim .payout-explain {display: none;}
51
+ #wp_rp_earnings_wrap a.claim.disabled {cursor: default; color: #999; text-decoration: none;}
52
+ #wp_rp_earnings_wrap a.claim.disabled .payout-explain {border: 1px solid #ccc; padding: 15px; color: #333; border-radius: 2px; margin-left: 10px;}
53
+ #wp_rp_earnings_wrap a.claim.disabled:hover .payout-explain {display: inline;}
54
+
55
+
56
  #wp_rp_dashboard_widget #wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li {display:block;width:100%;}
57
  #wp_rp_dashboard_widget #wp_rp_wrap div#wp_rp_statistics_wrap ul.statistics li div.overlay {z-index:100;width: 100%;margin:0;left:-10px;}
58
  #wp_rp_dashboard_widget #wp_rp_statistics_wrap {padding: 0;}
static/js/dashboard.js CHANGED
@@ -1,9 +1,11 @@
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);
 
 
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_earnings_wrap"),i=a("#wp_rp_earnings_holder"),g=a("#wp_rp_statistics_wrap"),j=a("#wp_rp_dashboard_url").val(),h=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;promoted_content_enabled=0<a("#wp_rp_show_promoted_content_statistics").length;update_interval=req_timeout=null;update_interval_sec=
2
+ 2E3;update_interval_error_sec=3E4;updating=!1;ul=null;stats={};set_update_interval=function(a){a||(a=update_interval_sec);clearInterval(update_interval);0<a&&(update_interval=setInterval(update_dashboard,a))};display_error=function(e){var k=a("#wp_rp_statistics_wrap");e||k.find(".unavailable").slideDown();set_update_interval(update_interval_error_sec);updating=!1};create_dashboard=function(){ul=a('<ul class="statistics" />');g.find(".unavailable").slideUp();ul.append('<li class="title"><div class="desktop">Desktop</div><div class="mobile">Mobile</div></li>');
3
+ ul.append(d('<li class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',{"class":"ctr",title:"click-through rate",range:"last 30 days"}));ul.append(d('<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(d('<li class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',
4
+ {"class":"clicks",title:"clicks",range:"last 30 days"}));g.append(ul);traffic_exchange_enabled&&g.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),
5
+ a.getJSON(j+"pageviews/?callback=?",{blog_id:h,auth_key:f},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);stats.mobile_pageviews=Math.max(c.mobile_pageviews,stats.mobile_pageviews||0);stats.mobile_clicks=Math.max(c.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(c.pageviews-
6
+ stats.mobile_pageviews,stats.desktop_pageviews||0);stats.desktop_clicks=Math.max(c.clicks-stats.mobile_clicks,stats.desktop_clicks||0);var d=0<stats.desktop_pageviews&&(100*(stats.desktop_clicks/stats.desktop_pageviews)).toFixed(1)||0;stats.network_in_pageviews=Math.max(c.network_in_pageviews,stats.network_in_pageviews||0);if(promoted_content_enabled&&c.promoted_content_money_earned){stats.promoted_content_money_earned=Math.max(c.promoted_content_money_earned,stats.promoted_content_money_earned||
7
+ 0);var l=(stats.promoted_content_money_earned/100).toFixed(2),f=(c.meta.min_payout/100).toFixed(2);b.find(".num").html("$"+l);b.find(".payout").html("$"+f);stats.promoted_content_money_earned>=c.meta.min_payout&&b.find(".claim").hasClass("disabled")&&(b.find(".claim").removeClass("disabled"),b.find(".claim").attr("href","mailto:relatedpostsplugin@gmail.com?subject="+encodeURIComponent("I earned over $50!")+"&body="+encodeURIComponent("I would like to claim my money.\nMy reference code is: "+h+" \nMy PayPal account is:\n")));
8
+ i.show()}ul.find(".ctr .num.all").html(d+"%");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);g.find(".network .num").html(stats.network_in_pageviews);updating=!1}}))};h&&f&&(update_dashboard(!0),update_interval=setInterval(update_dashboard,2E3));a("#wp_rp_turn_on_statistics a.turn-on").click(function(e){e.preventDefault();
9
+ 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());
10
+ 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 d=a(this).closest(".collapsible"),c=d.find(".container"),g=d.hasClass("collapsed"),f=d.attr("block");g?(c.slideDown(),a.post(ajaxurl,{action:"rp_show_hide_"+f,show:!0})):(c.slideUp(),a.post(ajaxurl,{action:"rp_show_hide_"+
11
+ f,hide:!0}));d.toggleClass("collapsed");b.preventDefault()})})})(jQuery);
wp_related_posts.php CHANGED
@@ -1,14 +1,14 @@
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,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 (($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
  }
@@ -147,11 +147,19 @@ function wp_rp_generate_related_posts_list_items($related_posts) {
147
  function wp_rp_should_exclude() {
148
  global $wpdb, $post;
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
 
156
  $result = $wpdb->get_col($q);
157
 
@@ -206,8 +214,7 @@ function wp_rp_head_resources() {
206
  $remote_recommendations = false;
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,10 +236,10 @@ function wp_rp_head_resources() {
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
 
1
  <?php
2
  /*
3
  Plugin Name: WordPress Related Posts
4
+ Version: 2.3
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.3');
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 ($post->post_type === 'post' && (($options["on_single_post"] && is_single()) || (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
  }
147
  function wp_rp_should_exclude() {
148
  global $wpdb, $post;
149
 
150
+ if (!$post || !$post->ID) {
151
+ return true;
152
+ }
153
+
154
+ if ($post->post_type !== 'post') {
155
+ return true;
156
+ }
157
+
158
  $options = wp_rp_get_options();
159
 
160
  if(!$options['exclude_categories']) { return false; }
161
 
162
+ $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'] . ')';
163
 
164
  $result = $wpdb->get_col($q);
165
 
214
  $remote_recommendations = false;
215
  $output = '';
216
 
217
+ if (is_single()) {
 
218
  $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
219
  $remote_recommendations = $meta['remote_recommendations'] && $statistics_enabled;
220
  }
236
  "\twindow._wp_rp_post_tags = {$post_tags};\n" .
237
  "\twindow._wp_rp_static_base_url = '" . esc_js(WP_RP_STATIC_BASE_URL) . "';\n" .
238
  "\twindow._wp_rp_promoted_content = " . ($options['promoted_content_enabled'] ? 'true' : 'false') . ";\n" .
 
239
  "\twindow._wp_rp_plugin_version = '" . WP_RP_VERSION . "';\n" .
240
  "\twindow._wp_rp_traffic_exchange = " . ($options['traffic_exchange_enabled'] ? 'true' : 'false') . ";\n" .
241
  (current_user_can('delete_users') ? "\twindow._wp_rp_admin_ajax_url = '" . admin_url('admin-ajax.php') . "';\n" : '') .
242
+ "\twindow._wp_rp_num_rel_posts = '" . $options['max_related_posts'] . "';\n" .
243
  "</script>\n";
244
  }
245