WordPress Related Posts - Version 1.7

Version Description

  • Improved thumbnail handling
  • Settings cleanup
  • Traffic exchange and revenue share options (beta)
  • Removed scroll up related posts experiment
Download this release

Release Info

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

Code changes from version 1.6 to 1.7

config.php CHANGED
@@ -28,11 +28,6 @@ define("WP_RP_STATIC_CTR_PAGEVIEW_FILE", "js/pageview.js");
28
  define("WP_RP_STATIC_RECOMMENDATIONS_JS_FILE", "js/recommendations.js");
29
  define("WP_RP_STATIC_RECOMMENDATIONS_CSS_FILE", "css-img/recommendations.css");
30
 
31
- define("WP_RP_STATIC_SCROLLUP_JS_FILE", "js/scrollup.js");
32
- define("WP_RP_STATIC_SCROLLUP_CSS_FILE", "css-img/scrollup.css");
33
-
34
- define("WP_RP_STATIC_BANNER_FILE", "js/welcome.js");
35
-
36
 
37
  global $wp_rp_options, $wp_rp_meta;
38
  $wp_rp_options = false;
@@ -134,7 +129,9 @@ function wp_rp_install() {
134
  'show_turn_on_button' => true,
135
  'name' => '',
136
  'email' => '',
137
- 'show_invite_friends_form' => true
 
 
138
  );
139
 
140
  $wp_rp_options = array(
@@ -159,15 +156,32 @@ function wp_rp_install() {
159
  'theme_name' => 'vertical-m.css',
160
  'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
161
  'ctr_dashboard_enabled' => false,
162
- 'include_promotionail_link' => false,
163
- 'enable_themes' => false,
164
- 'scroll_up_related_posts' => true
165
  );
166
 
167
  update_option('wp_rp_meta', $wp_rp_meta);
168
  update_option('wp_rp_options', $wp_rp_options);
169
  }
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  function wp_rp_migrate_1_5_2_1() { # This was a silent release, but WP_RP_VERSION was not properly updated, so we don't know exactly what happened...
172
  $wp_rp_meta = get_option('wp_rp_meta');
173
 
28
  define("WP_RP_STATIC_RECOMMENDATIONS_JS_FILE", "js/recommendations.js");
29
  define("WP_RP_STATIC_RECOMMENDATIONS_CSS_FILE", "css-img/recommendations.css");
30
 
 
 
 
 
 
31
 
32
  global $wp_rp_options, $wp_rp_meta;
33
  $wp_rp_options = false;
129
  'show_turn_on_button' => true,
130
  'name' => '',
131
  'email' => '',
132
+ 'show_blogger_network_form' => false,
133
+ 'remote_notifications' => array(),
134
+ 'turn_on_button_pressed' => false
135
  );
136
 
137
  $wp_rp_options = array(
156
  'theme_name' => 'vertical-m.css',
157
  'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
158
  'ctr_dashboard_enabled' => false,
159
+ 'enable_themes' => false
 
 
160
  );
161
 
162
  update_option('wp_rp_meta', $wp_rp_meta);
163
  update_option('wp_rp_options', $wp_rp_options);
164
  }
165
 
166
+ function wp_rp_migrate_1_6() {
167
+ $wp_rp_meta = get_option('wp_rp_meta');
168
+ $wp_rp_options = get_option('wp_rp_options');
169
+
170
+ $wp_rp_meta['version'] = '1.7';
171
+
172
+ unset($wp_rp_options['scroll_up_related_posts']);
173
+ unset($wp_rp_options['include_promotionail_link']);
174
+ unset($wp_rp_options['show_invite_friends_form']);
175
+
176
+ $wp_rp_meta['show_blogger_network_form'] = false;
177
+ $wp_rp_meta['remote_notifications'] = array();
178
+
179
+ $wp_rp_meta['turn_on_button_pressed'] = false;
180
+
181
+ update_option('wp_rp_options', $wp_rp_options);
182
+ update_option('wp_rp_meta', $wp_rp_meta);
183
+ }
184
+
185
  function wp_rp_migrate_1_5_2_1() { # This was a silent release, but WP_RP_VERSION was not properly updated, so we don't know exactly what happened...
186
  $wp_rp_meta = get_option('wp_rp_meta');
187
 
lang/default.po DELETED
@@ -1,196 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: wp_related_post\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2009-09-30 21:04+0800\n"
6
- "PO-Revision-Date: \n"
7
- "Last-Translator: Denis <honghua.deng@gmail.com>\n"
8
- "Language-Team: \n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Poedit-KeywordsList: __;_e\n"
13
- "X-Poedit-Basepath: .\n"
14
- "X-Poedit-SearchPath-0: ..\n"
15
-
16
- #: ../wp_related_posts.php:68
17
- msgid "No Related Post"
18
- msgstr ""
19
-
20
- #: ../wp_related_posts.php:72
21
- #: ../wp_related_posts.php:293
22
- #: ../wp_related_posts.php:419
23
- msgid "Random Posts"
24
- msgstr ""
25
-
26
- #: ../wp_related_posts.php:75
27
- #: ../wp_related_posts.php:297
28
- #: ../wp_related_posts.php:420
29
- msgid "Most Commented Posts"
30
- msgstr ""
31
-
32
- #: ../wp_related_posts.php:78
33
- #: ../wp_related_posts.php:301
34
- #: ../wp_related_posts.php:422
35
- msgid "Most Popular Posts"
36
- msgstr ""
37
-
38
- #: ../wp_related_posts.php:239
39
- msgid "Related Posts"
40
- msgstr ""
41
-
42
- #: ../wp_related_posts.php:245
43
- msgid "WordPress Related Posts Setting Updated"
44
- msgstr ""
45
-
46
- #: ../wp_related_posts.php:288
47
- #: ../wp_related_posts.php:432
48
- msgid "No Related Posts Text:"
49
- msgstr ""
50
-
51
- #: ../wp_related_posts.php:289
52
- msgid "No Related Posts"
53
- msgstr ""
54
-
55
- #: ../wp_related_posts.php:292
56
- #: ../wp_related_posts.php:435
57
- msgid "Random Posts Title:"
58
- msgstr ""
59
-
60
- #: ../wp_related_posts.php:296
61
- #: ../wp_related_posts.php:438
62
- msgid "Most Commented Posts Title:"
63
- msgstr ""
64
-
65
- #: ../wp_related_posts.php:300
66
- #: ../wp_related_posts.php:441
67
- msgid "Most Popular Posts Title:"
68
- msgstr ""
69
-
70
- #: ../wp_related_posts.php:330
71
- msgid "Related Posts Settings"
72
- msgstr ""
73
-
74
- #: ../wp_related_posts.php:331
75
- msgid "<a href=\"http://fairyfish.net/2007/09/12/wordpress-23-related-posts-plugin/\">WordPress Related Posts </a>Plugin can generate a related posts list via WordPress tags, and add the related posts to feed."
76
- msgstr ""
77
-
78
- #: ../wp_related_posts.php:332
79
- msgid "If you need assistance please contact"
80
- msgstr ""
81
-
82
- #: ../wp_related_posts.php:332
83
- msgid "support"
84
- msgstr ""
85
-
86
- #: ../wp_related_posts.php:332
87
- msgid "Please fill out"
88
- msgstr ""
89
-
90
- #: ../wp_related_posts.php:332
91
- msgid "a quick survey"
92
- msgstr ""
93
-
94
- #: ../wp_related_posts.php:335
95
- msgid "Do you like this Plugin? Consider to donate!"
96
- msgstr ""
97
-
98
- #: ../wp_related_posts.php:339
99
- msgid "Basic Setting"
100
- msgstr ""
101
-
102
- #: ../wp_related_posts.php:342
103
- msgid "Related Posts Title:"
104
- msgstr ""
105
-
106
- #: ../wp_related_posts.php:348
107
- msgid "Related Posts Title Tag:"
108
- msgstr ""
109
-
110
- #: ../wp_related_posts.php:363
111
- msgid "Maximum Number:"
112
- msgstr ""
113
-
114
- #: ../wp_related_posts.php:369
115
- msgid "Exclude(category IDs):"
116
- msgstr ""
117
-
118
- #: ../wp_related_posts.php:371
119
- msgid "Enter category IDs of the posts which you don't want to display related posts for them. "
120
- msgstr ""
121
-
122
- #: ../wp_related_posts.php:375
123
- msgid "Other Setting:"
124
- msgstr ""
125
-
126
- #: ../wp_related_posts.php:379
127
- msgid "Display Comments Count?"
128
- msgstr ""
129
-
130
- #: ../wp_related_posts.php:384
131
- msgid "Display Pubilsh Date?"
132
- msgstr ""
133
-
134
- #: ../wp_related_posts.php:389
135
- msgid "Auto Insert Related Posts?"
136
- msgstr ""
137
-
138
- #: ../wp_related_posts.php:394
139
- msgid "Display Related Posts on Feed?"
140
- msgstr ""
141
-
142
- #: ../wp_related_posts.php:399
143
- msgid "Excerpt Setting:"
144
- msgstr ""
145
-
146
- #: ../wp_related_posts.php:403
147
- msgid "Display Post Excerpt?"
148
- msgstr ""
149
-
150
- #: ../wp_related_posts.php:407
151
- msgid "Maximum Charaters of Excerpt."
152
- msgstr ""
153
-
154
- #: ../wp_related_posts.php:412
155
- msgid "No Related Post Setting"
156
- msgstr ""
157
-
158
- #: ../wp_related_posts.php:415
159
- msgid "Display:"
160
- msgstr ""
161
-
162
- #: ../wp_related_posts.php:418
163
- msgid "Text: 'No Related Posts'"
164
- msgstr ""
165
-
166
- #: ../wp_related_posts.php:451
167
- msgid "Related Posts with Thumbnail"
168
- msgstr ""
169
-
170
- #: ../wp_related_posts.php:455
171
- msgid "Before using Related Posts with Thumbnail, you must set thumbnail image for your every post."
172
- msgstr ""
173
-
174
- #: ../wp_related_posts.php:459
175
- msgid "Thumbnail Setting:"
176
- msgstr ""
177
-
178
- #: ../wp_related_posts.php:462
179
- msgid "Display Thumbnails For Related Posts"
180
- msgstr ""
181
-
182
- #: ../wp_related_posts.php:466
183
- msgid "Display Post Titles"
184
- msgstr ""
185
-
186
- #: ../wp_related_posts.php:468
187
- msgid "Which field is used for thumbnail?"
188
- msgstr ""
189
-
190
- #: ../wp_related_posts.php:468
191
- msgid "Use Featured Image"
192
- msgstr ""
193
-
194
- #: ../wp_related_posts.php:486
195
- msgid "Save changes"
196
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lang/wp_related_posts-zh_CN.mo DELETED
Binary file
lang/wp_related_posts-zh_CN.po DELETED
@@ -1,197 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: WordPress 2.3 Related Posts Plugin v0.2\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2009-09-30 21:04+0800\n"
6
- "PO-Revision-Date: 2012-09-11 16:06+0100\n"
7
- "Last-Translator: Jure Ham <jure@hamax.si>\n"
8
- "Language-Team: WordPress 中文团队 <team@wp-cn.com>\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Poedit-KeywordsList: _e;__\n"
13
- "X-Poedit-Basepath: .\n"
14
- "X-Poedit-SearchPath-0: ..\n"
15
-
16
- #: ../wp_related_posts.php:68
17
- msgid "No Related Post"
18
- msgstr "暂无相关日志"
19
-
20
- #: ../wp_related_posts.php:72
21
- #: ../wp_related_posts.php:293
22
- #: ../wp_related_posts.php:419
23
- msgid "Random Posts"
24
- msgstr "随机日志"
25
-
26
- #: ../wp_related_posts.php:75
27
- #: ../wp_related_posts.php:297
28
- #: ../wp_related_posts.php:420
29
- msgid "Most Commented Posts"
30
- msgstr "最多留言日志"
31
-
32
- #: ../wp_related_posts.php:78
33
- #: ../wp_related_posts.php:301
34
- #: ../wp_related_posts.php:422
35
- msgid "Most Popular Posts"
36
- msgstr "最流行日志"
37
-
38
- #: ../wp_related_posts.php:239
39
- msgid "Related Posts"
40
- msgstr "相关日志"
41
-
42
- #: ../wp_related_posts.php:245
43
- msgid "WordPress Related Posts Setting Updated"
44
- msgstr "WordPress 相关日志设置已被更新"
45
-
46
- #: ../wp_related_posts.php:288
47
- #: ../wp_related_posts.php:432
48
- msgid "No Related Posts Text:"
49
- msgstr "无相关日志时的文本:"
50
-
51
- #: ../wp_related_posts.php:289
52
- msgid "No Related Posts"
53
- msgstr "暂无相关日志"
54
-
55
- #: ../wp_related_posts.php:292
56
- #: ../wp_related_posts.php:435
57
- msgid "Random Posts Title:"
58
- msgstr "随机日志列表标题:"
59
-
60
- #: ../wp_related_posts.php:296
61
- #: ../wp_related_posts.php:438
62
- msgid "Most Commented Posts Title:"
63
- msgstr "最多留言日志标题:"
64
-
65
- #: ../wp_related_posts.php:300
66
- #: ../wp_related_posts.php:441
67
- msgid "Most Popular Posts Title:"
68
- msgstr "最流行日志标题:"
69
-
70
- #: ../wp_related_posts.php:330
71
- msgid "Related Posts Settings"
72
- msgstr "相关日志设置"
73
-
74
- #: ../wp_related_posts.php:331
75
- msgid "WordPress Related Posts Plugin can generate a related posts list via WordPress tags, and add the related posts to feed."
76
- msgstr "WordPress 相关日志插件 可以通过 WordPress 的标签系统产生一个相关日志列表,并可以添加相关日志至 RSS 中。"
77
-
78
- #: ../wp_related_posts.php:332
79
- msgid "If you need assistance please contact"
80
- msgstr "你在使用这个插件的时候如果有任何问题或者需要帮助,请联系"
81
-
82
- #: ../wp_related_posts.php:332
83
- msgid "support"
84
- msgstr "支援"
85
-
86
- #: ../wp_related_posts.php:332
87
- msgid "Please fill out"
88
- msgstr "请填写"
89
-
90
- #: ../wp_related_posts.php:332
91
- msgid "a quick survey"
92
- msgstr "调查"
93
-
94
- #: ../wp_related_posts.php:335
95
- msgid "Do you like this Plugin? Consider to donate!"
96
- msgstr "喜欢这个插件吗?你可以考虑捐赠支持我继续开发。"
97
-
98
- #: ../wp_related_posts.php:339
99
- msgid "Basic Setting"
100
- msgstr "基本设置"
101
-
102
- #: ../wp_related_posts.php:342
103
- msgid "Related Posts Title:"
104
- msgstr "相关日志列表标题:"
105
-
106
- #: ../wp_related_posts.php:348
107
- msgid "Related Posts Title Tag:"
108
- msgstr "相关日志标题标签:"
109
-
110
- #: ../wp_related_posts.php:363
111
- msgid "Maximum Number:"
112
- msgstr "最多显示:"
113
-
114
- #: ../wp_related_posts.php:369
115
- msgid "Exclude(category IDs):"
116
- msgstr "不包括(分类ID):"
117
-
118
- #: ../wp_related_posts.php:371
119
- msgid "Enter category IDs of the posts which you don't want to display related posts for them. "
120
- msgstr "输入你不想显示相关日志的这类日志的分类 ID"
121
-
122
- #: ../wp_related_posts.php:375
123
- msgid "Other Setting:"
124
- msgstr "其他设置:"
125
-
126
- #: ../wp_related_posts.php:379
127
- msgid "Display Comments Count?"
128
- msgstr "显示留言数?"
129
-
130
- #: ../wp_related_posts.php:384
131
- msgid "Display Pubilsh Date?"
132
- msgstr "显示日志发布日期?"
133
-
134
- #: ../wp_related_posts.php:389
135
- msgid "Auto Insert Related Posts?"
136
- msgstr "自动插入相关日志?"
137
-
138
- #: ../wp_related_posts.php:394
139
- msgid "Display Related Posts on Feed?"
140
- msgstr "在RSS中添加相关日志?"
141
-
142
- #: ../wp_related_posts.php:399
143
- msgid "Excerpt Setting:"
144
- msgstr "摘要设置:"
145
-
146
- #: ../wp_related_posts.php:403
147
- msgid "Display Post Excerpt?"
148
- msgstr "显示日志摘要?"
149
-
150
- #: ../wp_related_posts.php:407
151
- msgid "Maximum Charaters of Excerpt."
152
- msgstr "摘要的最大文本。"
153
-
154
- #: ../wp_related_posts.php:412
155
- msgid "No Related Post Setting"
156
- msgstr "无相关日志时的设置"
157
-
158
- #: ../wp_related_posts.php:415
159
- msgid "Display:"
160
- msgstr "显示:"
161
-
162
- #: ../wp_related_posts.php:418
163
- msgid "Text: 'No Related Posts'"
164
- msgstr "文本:“无相关日志”"
165
-
166
- #: ../wp_related_posts.php:451
167
- msgid "Related Posts with Thumbnail"
168
- msgstr "给相关日志显示缩略图"
169
-
170
- #: ../wp_related_posts.php:455
171
- msgid "Before using Related Posts with Thumbnail, you must set thumbnail image for your every post."
172
- msgstr "在使用给相关日志显示缩略图这个功能之前,你要确保你每篇日志都有缩略图。"
173
-
174
- #: ../wp_related_posts.php:459
175
- msgid "Thumbnail Setting:"
176
- msgstr "缩略图设置:"
177
-
178
- #: ../wp_related_posts.php:462
179
- msgid "Display Thumbnails For Related Posts"
180
- msgstr "给相关日志显示缩略图?"
181
-
182
- #: ../wp_related_posts.php:466
183
- msgid "Display Post Titles"
184
- msgstr "在使用给相关日志显示缩略图的同时还显示相关日志的标题等文本?"
185
-
186
- #: ../wp_related_posts.php:468
187
- msgid "Which field is used for thumbnail?"
188
- msgstr "哪个自定义字段是用于缩略图的?"
189
-
190
- #: ../wp_related_posts.php:468
191
- msgid "Use Featured Image"
192
- msgstr "使用WordPress特色图片"
193
-
194
- #: ../wp_related_posts.php:486
195
- msgid "Save changes"
196
- msgstr "保存修改"
197
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 1.6
9
 
10
  WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
11
 
@@ -59,10 +59,16 @@ Yes, related posts are responsive so they adapt to the screen size to ensure max
59
  == Screenshots ==
60
  1. WordPress Related Posts Default Theme.
61
  2. WordPress Related Posts Settings and Statistics.
62
-
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
 
66
  = 1.6 =
67
  * Bugfixes
68
  * Settings page update
5
  License: GPLv2
6
  Requires at least: 3.3
7
  Tested up to: 3.5
8
+ Stable tag: 1.7
9
 
10
  WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
11
 
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
+ = 1.7 =
67
+ * Improved thumbnail handling
68
+ * Settings cleanup
69
+ * Traffic exchange and revenue share options (beta)
70
+ * Removed scroll up related posts experiment
71
+
72
  = 1.6 =
73
  * Bugfixes
74
  * Settings page update
settings.php CHANGED
@@ -114,6 +114,7 @@ function wp_rp_settings_admin_menu() {
114
 
115
  add_action('admin_print_styles-' . $page, 'wp_rp_settings_styles');
116
  add_action('admin_print_scripts-' . $page, 'wp_rp_settings_scripts');
 
117
 
118
  wp_rp_display_tooltips();
119
  }
@@ -129,15 +130,27 @@ function wp_rp_settings_styles() {
129
  function wp_rp_register_blog() {
130
  $meta = wp_rp_get_meta();
131
 
 
 
 
 
 
 
 
132
  $req_options = array(
133
- 'timeout' => 30
134
  );
135
 
136
- $response = wp_remote_get(WP_RP_CTR_DASHBOARD_URL . 'register/?blog_url=' . get_bloginfo('wpurl') . ($meta['new_user'] ? '&new' : ''), $req_options);
 
 
 
 
137
  if (wp_remote_retrieve_response_code($response) == 200) {
138
  $body = wp_remote_retrieve_body($response);
139
  if ($body) {
140
  $doc = json_decode($body);
 
141
  if ($doc && $doc->status === 'ok') {
142
  $meta['blog_id'] = $doc->data->blog_id;
143
  $meta['auth_key'] = $doc->data->auth_key;
@@ -148,38 +161,122 @@ function wp_rp_register_blog() {
148
  }
149
  }
150
  }
 
 
 
 
151
  return false;
152
  }
153
 
154
- function wp_rp_ajax_invite_friends_callback() {
155
  $postdata = stripslashes_deep($_POST);
156
 
157
  $meta = wp_rp_get_meta();
158
 
159
- if(isset($postdata['name'])) {
160
- $meta['name'] = $postdata['name'];
161
- }
162
- if(isset($postdata['email'])) {
163
- $meta['email'] = $postdata['email'];
164
- }
165
- if(isset($postdata['show'])) {
166
- $meta['show_invite_friends_form'] = true;
167
- }
168
- if(isset($postdata['hide'])) {
169
- $meta['show_invite_friends_form'] = false;
170
- }
171
- if(isset($postdata['recommend'])) {
172
  $meta['remote_recommendations'] = true;
173
  }
174
 
175
  wp_rp_update_meta($meta);
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
- echo 'ok';
179
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  }
181
 
182
- add_action('wp_ajax_rp_invite_friends', 'wp_rp_ajax_invite_friends_callback');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
  function wp_rp_settings_page()
185
  {
@@ -213,9 +310,7 @@ function wp_rp_settings_page()
213
  'thumbnail_use_attached' => isset($postdata['wp_rp_thumbnail_use_attached']),
214
  'thumbnail_use_custom' => isset($postdata['wp_rp_thumbnail_use_custom']) && $postdata['wp_rp_thumbnail_use_custom'] === 'yes',
215
  'ctr_dashboard_enabled' => isset($postdata['wp_rp_ctr_dashboard_enabled']),
216
- 'include_promotionail_link' => isset($postdata['wp_rp_include_promotionail_link']),
217
- 'enable_themes' => isset($postdata['wp_rp_enable_themes']),
218
- 'scroll_up_related_posts' => isset($postdata['wp_rp_scroll_up_related_posts'])
219
  );
220
 
221
  if(!isset($postdata['wp_rp_not_on_categories'])) {
@@ -239,6 +334,10 @@ function wp_rp_settings_page()
239
  $new_options['theme_custom_css'] = $old_options['theme_custom_css'];
240
  }
241
 
 
 
 
 
242
  $default_thumbnail_path = wp_rp_upload_default_thumbnail_file();
243
  if($default_thumbnail_path) {
244
  $new_options['default_thumbnail_path'] = $default_thumbnail_path;
@@ -282,6 +381,7 @@ function wp_rp_settings_page()
282
  <input type="hidden" id="wp_rp_version" value="<?php esc_attr_e(WP_RP_VERSION); ?>" />
283
  <input type="hidden" id="wp_rp_theme_selected" value="<?php esc_attr_e($theme_name); ?>" />
284
  <input type="hidden" id="wp_rp_dashboard_url" value="<?php esc_attr_e(WP_RP_CTR_DASHBOARD_URL); ?>" />
 
285
 
286
  <?php if ($options['ctr_dashboard_enabled']):?>
287
  <input type="hidden" id="wp_rp_blog_id" value="<?php esc_attr_e($meta['blog_id']); ?>" />
@@ -298,162 +398,95 @@ function wp_rp_settings_page()
298
  <h2 class="title"><?php _e("Related Posts",'wp_related_posts');?></h2>
299
  <p class="desc"><?php _e("WordPress Related Posts Plugin places a list of related articles via WordPress tags at the bottom of your post.",'wp_related_posts');?></p>
300
  </div>
301
- <div id="wp-rp-survey" class="updated highlight" style="display:none;"><p><?php _e("Please fill out",'wp_related_posts');?> <a class="link" target="_blank" href="http://wprelatedposts.polldaddy.com/s/new-features"><?php _e("a quick survey", 'wp_related_posts');?></a>.<a href="#" class="close" style="float: right;">x</a></p></div>
302
 
303
  <?php if (isset($message)): ?>
304
  <div id="message" class="updated fade"><p><?php echo $message ?>.</p></div>
305
  <?php endif; ?>
306
 
307
- <?php if(!$meta['show_turn_on_button']): ?>
308
- <form action="https://docs.google.com/a/zemanta.com/spreadsheet/formResponse?formkey=dHhqdWtyZHIwN0Z5R2ZEel9oZVBidEE6MQ&amp;ifq" method="POST" id="wp_rp_invite_friends_form" target="wp_rp_invite_friends_hidden_iframe" <?php if(!$meta['show_invite_friends_form']) { ?>class="up"<?php } ?>>
309
- <input type="hidden" name="pageNumber" value="0">
310
- <input type="hidden" name="backupCache" value="">
311
- <input type="hidden" name="entry.6.single" value="<?php echo get_bloginfo('wpurl'); ?>">
312
-
313
- <a href="#" id="wp_rp_invite_friends_slide"><img src="<?php echo plugins_url('/static/img/up.png', __FILE__); ?>" width="17" height="6" border="0" class="up" /><img src="<?php echo plugins_url('/static/img/down.png', __FILE__); ?>" width="17" height="6" border="0" class="down" /></a>
314
- <h2>Invite friends</h2>
315
-
316
- <div class="slide-down" <?php if(!$meta['show_invite_friends_form']) { ?>style="display: none"<?php } ?>>
317
- <p>Get your friends to use WordPress Related Posts and instantly exchange traffic with them. Your posts will appear on their site and vice versa.</p>
318
-
319
- <?php if(!$meta['name'] || !$meta['email']): ?>
320
- <table class="form-table" id="wp_rp_invite_friends_name_table"><tbody>
321
- <tr valign="top">
322
- <th scope="row"><label for="wp_rp_invite_friends_blogger_name">Your name</label></th>
323
- <td width="1%"><input type="text" name="entry.0.single" value="" id="wp_rp_invite_friends_blogger_name" tabindex="1" requred="required" /></td>
324
- <td rowspan="2"></td>
325
- </tr><tr valign="top">
326
- <th scope="row"><label for="wp_rp_invite_friends_blogger_email">Your email</label></th>
327
- <td><input type="email" name="entry.1.single" value="" id="wp_rp_invite_friends_blogger_email" tabindex="2" requred="required" /><br/></td>
328
- </tr>
329
- </tbody></table>
330
- <div class="hr" id="wp_rp_confirmation_hr"></div>
331
- <? else: ?>
332
- <input type="hidden" name="entry.0.single" value="<?php echo $meta['name']; ?>">
333
- <input type="hidden" name="entry.1.single" value="<?php echo $meta['email']; ?>">
334
- <div class="hr" id="wp_rp_confirmation_hr" style="display: none;"></div>
335
- <?php endif; ?>
336
-
337
- <table class="form-table"><tbody>
338
- <tr valign="top">
339
- <th scope="row"><label for="wp_rp_invite_friends_friend_url">Your friend's blog</label></th>
340
- <td width="1%"><input type="text" name="entry.2.single" value="" id="wp_rp_invite_friends_friend_url" tabindex="3" required="required" /></td>
341
- <td rowspan="2" valign="middle"><input type="submit" name="submit" value="Invite" id="wp_rp_invite_friends_submit" tabindex="5" /></td>
342
- </tr><tr valign="top">
343
- <th scope="row"><label for="wp_rp_invite_friends_friend_email">Your friend's email</label></th>
344
- <td><input type="email" name="entry.4.single" value="" id="wp_rp_invite_friends_friend_email" tabindex="4" required="required" /></td>
345
- </tr>
346
- </tbody></table>
347
- </div>
348
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  <script type="text/javascript">
350
  jQuery(function($) {
351
- var submit = $('#wp_rp_invite_friends_submit'),
352
- form = $('#wp_rp_invite_friends_form'),
353
- blogger_name = $('#wp_rp_invite_friends_blogger_name'),
354
- blogger_email = $('#wp_rp_invite_friends_blogger_email'),
355
- friend_url = $('#wp_rp_invite_friends_friend_url'),
356
- friend_email = $('#wp_rp_invite_friends_friend_email'),
357
- slide_div = form.find('.slide-down'),
358
- submitted = false;
359
- email_regex = /^[^@]+@[^@]+$/;
360
- $('#wp_rp_invite_friends_form').submit(function(event) {
361
- var valid = true;
362
- if(!email_regex.test(friend_email.val())) {
363
- valid = false;
364
- friend_email.animate({backgroundColor: '#faa'}).focus();
365
- } else {
366
- friend_email.css({backgroundColor: ''});
367
- }
368
- if(!friend_url.val()) {
369
- valid = false;
370
- friend_url.animate({backgroundColor: '#faa'}).focus();
371
- } else {
372
- friend_url.css({backgroundColor: ''});
373
- }
374
- if(blogger_email.length && !email_regex.test(blogger_email.val())) {
375
- valid = false;
376
- blogger_email.animate({backgroundColor: '#faa'}).focus();
377
- } else {
378
- blogger_email.css({backgroundColor: ''});
379
- }
380
- if(blogger_name.length && !blogger_name.val()) {
381
- valid = false;
382
- blogger_name.animate({backgroundColor: '#faa'}).focus();
383
- } else {
384
- blogger_name.css({backgroundColor: ''});
385
- }
386
- if(!valid) {
387
- event.preventDefault();
388
- return;
389
- }
390
-
391
- submitted = true;
392
  submit.addClass('disabled');
393
  setTimeout(function() { submit.attr('disabled', true); }, 0);
394
- });
395
-
396
- $('#wp_rp_invite_friends_hidden_iframe').load(function() {
397
- if(!submitted) { return; } else { submitted = false; }
398
-
399
- setTimeout(function() {
400
  submit.attr('disabled', false).removeClass('disabled');
401
- var confirmation = $('<div class="confirmation">An invitation was sent to <span>' + friend_email.val() + '</span>.</div>'),
402
- hr = form.find('#wp_rp_confirmation_hr'),
403
- name_table = $('#wp_rp_invite_friends_name_table');
404
-
405
- name_table.hide();
406
- hr.fadeIn();
407
- confirmation.hide().insertBefore(hr).fadeIn();
408
-
409
- var data = { action: 'rp_invite_friends',
410
- recommend: true };
411
-
412
- if(blogger_name.length && blogger_email.length) {
413
- form.append('<input type="hidden" name="entry.0.single" value="' + blogger_name.val() + '">');
414
- form.append('<input type="hidden" name="entry.1.single" value="' + blogger_email.val() + '">');
415
-
416
- data['name'] = blogger_name.val();
417
- data['email'] = blogger_email.val();
418
-
419
- blogger_name.remove();
420
- blogger_email.remove();
421
- }
422
- $.post(ajaxurl, data);
423
-
424
- form[0].reset();
425
- }, 100);
426
- });
427
-
428
- $('#wp_rp_invite_friends_slide').click(function (event) {
429
- event.preventDefault();
430
- if(form.hasClass('up')) {
431
- slide_div.slideDown();
432
- form.removeClass('up');
433
- $.post(ajaxurl, { action: 'rp_invite_friends', show: true });
434
- } else {
435
- slide_div.slideUp();
436
- form.addClass('up');
437
- $.post(ajaxurl, { action: 'rp_invite_friends', hide: true });
438
- }
439
  });
440
  });
441
  </script>
442
  </form>
443
- <iframe id="wp_rp_invite_friends_hidden_iframe" name="wp_rp_invite_friends_hidden_iframe" style="display: none"></iframe>
444
- <?php endif; ?>
445
-
446
- <?php if($meta['show_turn_on_button']): ?>
447
- <div id="wp_rp_turn_on_statistics">
448
- <table cellspacing="0" cellpadding="0"><tbody><tr>
449
- <td>
450
- <h2>Turn on Statistics & Thumbnails</h2>
451
- <p>Real time traffic analytics are provided via third party service.</p>
452
- </td><td>
453
- <a href="#">Turn on</a>
454
- </td>
455
- </tr></tbody></table>
456
- </div>
457
  <?php endif; ?>
458
 
459
  <form method="post" enctype="multipart/form-data" action="" id="wp_rp_settings_form">
@@ -481,7 +514,7 @@ jQuery(function($) {
481
  </td>
482
  </tr>
483
  <tr valign="top">
484
- <th scope="row"><?php _e('Categories to Exclude:', 'wp_related_posts'); ?></th>
485
  <td>
486
  <?php
487
  $exclude = explode(',', $options['not_on_categories']);
@@ -612,15 +645,6 @@ jQuery(function($) {
612
  </label>
613
  </td>
614
  </tr>
615
- <tr>
616
- <th scope="row"><?php _e("Experimental:",'wp_related_posts'); ?></th>
617
- <td>
618
- <label>
619
- <input name="wp_rp_scroll_up_related_posts" type="checkbox" id="wp_rp_scroll_up_related_posts" value="yes" <?php checked($options["scroll_up_related_posts"]); ?>>
620
- <?php _e("Scroll Up Related Posts",'wp_related_posts');?>*
621
- </label><br />
622
- </td>
623
- </tr>
624
  </table>
625
 
626
  <h3><?php _e("If there are no related posts",'wp_related_posts');?></h3>
@@ -678,11 +702,6 @@ jQuery(function($) {
678
  <?php _e("Display Related Posts in Feed",'wp_related_posts');?>
679
  </label>
680
  <br />
681
- <label>
682
- <input name="wp_rp_include_promotionail_link" type="checkbox" id="wp_rp_include_promotionail_link" value="yes"<?php checked($options['include_promotionail_link']); ?> />
683
- <?php _e('Help Promote This Plugin', 'wp_related_posts'); ?>*
684
- </label>
685
- <br />
686
  <label>
687
  <input name="wp_rp_ctr_dashboard_enabled" type="checkbox" id="wp_rp_ctr_dashboard_enabled" value="yes" <?php checked($options['ctr_dashboard_enabled']); ?> />
688
  <?php _e("Turn statistics on",'wp_related_posts');?>*
114
 
115
  add_action('admin_print_styles-' . $page, 'wp_rp_settings_styles');
116
  add_action('admin_print_scripts-' . $page, 'wp_rp_settings_scripts');
117
+ add_action('load-' . $page, 'wp_rp_settings_onload');
118
 
119
  wp_rp_display_tooltips();
120
  }
130
  function wp_rp_register_blog() {
131
  $meta = wp_rp_get_meta();
132
 
133
+ if ($meta['blog_id'] && ($meta['blog_id'] + time() < 0)) {
134
+ return true;
135
+ }
136
+
137
+ $meta['blog_id'] = -1 * (time() + 60); // lock hack with timeout
138
+ wp_rp_update_meta($meta);
139
+
140
  $req_options = array(
141
+ 'timeout' => 15
142
  );
143
 
144
+ $response = wp_remote_get(WP_RP_CTR_DASHBOARD_URL . 'register/?blog_url=' . get_bloginfo('wpurl') .
145
+ ($meta['new_user'] ? '&new' : '') .
146
+ ($meta['turn_on_button_pressed'] ? ('&turn_on=' . $meta['turn_on_button_pressed']) : ''),
147
+ $req_options);
148
+
149
  if (wp_remote_retrieve_response_code($response) == 200) {
150
  $body = wp_remote_retrieve_body($response);
151
  if ($body) {
152
  $doc = json_decode($body);
153
+
154
  if ($doc && $doc->status === 'ok') {
155
  $meta['blog_id'] = $doc->data->blog_id;
156
  $meta['auth_key'] = $doc->data->auth_key;
161
  }
162
  }
163
  }
164
+
165
+ $meta['blog_id'] = false;
166
+ wp_rp_update_meta($meta);
167
+
168
  return false;
169
  }
170
 
171
+ function wp_rp_ajax_blogger_network_submit_callback() {
172
  $postdata = stripslashes_deep($_POST);
173
 
174
  $meta = wp_rp_get_meta();
175
 
176
+ $meta['show_blogger_network_form'] = false;
177
+ if(isset($postdata['join'])) {
 
 
 
 
 
 
 
 
 
 
 
178
  $meta['remote_recommendations'] = true;
179
  }
180
 
181
  wp_rp_update_meta($meta);
182
 
183
+ die('ok');
184
+ }
185
+ add_action('wp_ajax_blogger_network_submit', 'wp_rp_ajax_blogger_network_submit_callback');
186
+
187
+ function wp_rp_settings_onload() {
188
+ // fetch notifications
189
+ $meta = wp_rp_get_meta();
190
+ $options = wp_rp_get_options();
191
+
192
+ $blog_id = $meta['blog_id'];
193
+ $auth_key = $meta['auth_key'];
194
+
195
+ $req_options = array(
196
+ 'timeout' => 5
197
+ );
198
+
199
+ if(empty($blog_id) || empty($auth_key) || !$options['ctr_dashboard_enabled']) return;
200
+
201
+ // receive remote recommendations
202
+ $url = sprintf('%snotifications/?blog_id=%s&auth_key=%s', WP_RP_CTR_DASHBOARD_URL, $blog_id, $auth_key);
203
+ $response = wp_remote_get($url, $req_options);
204
+
205
+ if (wp_remote_retrieve_response_code($response) == 200) {
206
+ $body = wp_remote_retrieve_body($response);
207
+
208
+ if ($body) {
209
+ $json = json_decode($body);
210
+
211
+ if ($json && isset($json->status) && $json->status === 'ok' && isset($json->data) && is_object($json->data))
212
+ {
213
+ if(!isset($meta['remote_notifications']) || !is_array($meta['remote_notifications'])) {
214
+ $meta['remote_notifications'] = array();
215
+ }
216
+
217
+ $messages_ref =& $meta['remote_notifications'];
218
+ $data = $json->data;
219
 
220
+ if(isset($data->msgs) && is_array($data->msgs)) {
221
+ // add new messages from server and update old ones
222
+ foreach($data->msgs as $msg) {
223
+ $messages_ref[$msg->msg_id] = $msg->text;
224
+ }
225
+
226
+ // sort messages by identifier
227
+ ksort($messages_ref);
228
+ }
229
+
230
+ if(isset($data->turn_on_remote_recommendations) && $data->turn_on_remote_recommendations) {
231
+ $meta['remote_recommendations'] = true;
232
+ } else if(isset($data->turn_off_remote_recommendations) && $data->turn_off_remote_recommendations) {
233
+ $meta['remote_recommendations'] = false;
234
+ }
235
+
236
+ if(isset($data->show_blogger_network_form) && $data->show_blogger_network_form) {
237
+ $meta['show_blogger_network_form'] = true;
238
+ } else if(isset($data->hide_blogger_network_form) && $data->hide_blogger_network_form) {
239
+ $meta['show_blogger_network_form'] = false;
240
+ }
241
+
242
+ wp_rp_update_meta($meta);
243
+ }
244
+ }
245
+ }
246
+ }
247
+
248
+ function wp_rp_print_notifications() {
249
+ $meta = wp_rp_get_meta();
250
+ $messages = $meta['remote_notifications'];
251
+
252
+ if(is_array($messages)) {
253
+ foreach($messages as $id => $text) {
254
+ echo '<div class="wp_rp_notification">
255
+ <a href="' . admin_url('admin-ajax.php?action=rp_dismiss_notification&id=' . $id) . '" class="close">x</a>
256
+ <p>' . $text . '</p>
257
+ </div>';
258
+ }
259
+ }
260
  }
261
 
262
+ add_action('wp_ajax_rp_dismiss_notification', 'wp_rp_ajax_dismiss_notification');
263
+
264
+ function wp_rp_ajax_dismiss_notification() {
265
+ $id = (int)$_REQUEST['id'];
266
+ $meta = wp_rp_get_meta();
267
+ $messages_ref =& $meta['remote_notifications'];
268
+
269
+ if(is_array($messages_ref) && array_key_exists($id, $messages_ref)) {
270
+ unset($messages_ref[$id]);
271
+ wp_rp_update_meta($meta);
272
+ }
273
+
274
+ if($_REQUEST['noredirect']) {
275
+ die('ok');
276
+ }
277
+
278
+ wp_redirect(admin_url('admin.php?page=wordpress-related-posts'));
279
+ }
280
 
281
  function wp_rp_settings_page()
282
  {
310
  'thumbnail_use_attached' => isset($postdata['wp_rp_thumbnail_use_attached']),
311
  'thumbnail_use_custom' => isset($postdata['wp_rp_thumbnail_use_custom']) && $postdata['wp_rp_thumbnail_use_custom'] === 'yes',
312
  'ctr_dashboard_enabled' => isset($postdata['wp_rp_ctr_dashboard_enabled']),
313
+ 'enable_themes' => isset($postdata['wp_rp_enable_themes'])
 
 
314
  );
315
 
316
  if(!isset($postdata['wp_rp_not_on_categories'])) {
334
  $new_options['theme_custom_css'] = $old_options['theme_custom_css'];
335
  }
336
 
337
+ if (isset($postdata['wp_rp_turn_on_button_pressed'])) {
338
+ $meta['turn_on_button_pressed'] = $postdata['wp_rp_turn_on_button_pressed'];
339
+ }
340
+
341
  $default_thumbnail_path = wp_rp_upload_default_thumbnail_file();
342
  if($default_thumbnail_path) {
343
  $new_options['default_thumbnail_path'] = $default_thumbnail_path;
381
  <input type="hidden" id="wp_rp_version" value="<?php esc_attr_e(WP_RP_VERSION); ?>" />
382
  <input type="hidden" id="wp_rp_theme_selected" value="<?php esc_attr_e($theme_name); ?>" />
383
  <input type="hidden" id="wp_rp_dashboard_url" value="<?php esc_attr_e(WP_RP_CTR_DASHBOARD_URL); ?>" />
384
+ <input type="hidden" id="wp_rp_static_base_url" value="<?php esc_attr_e(WP_RP_STATIC_BASE_URL); ?>" />
385
 
386
  <?php if ($options['ctr_dashboard_enabled']):?>
387
  <input type="hidden" id="wp_rp_blog_id" value="<?php esc_attr_e($meta['blog_id']); ?>" />
398
  <h2 class="title"><?php _e("Related Posts",'wp_related_posts');?></h2>
399
  <p class="desc"><?php _e("WordPress Related Posts Plugin places a list of related articles via WordPress tags at the bottom of your post.",'wp_related_posts');?></p>
400
  </div>
401
+ <div id="wp-rp-survey" class="updated highlight" style="display:none;"><p><?php _e("Please fill out",'wp_related_posts');?> <a class="link" target="_blank" href="http://wprelatedposts.polldaddy.com/s/quick-survey"><?php _e("a quick survey", 'wp_related_posts');?></a>.<a href="#" class="close" style="float: right;">x</a></p></div>
402
 
403
  <?php if (isset($message)): ?>
404
  <div id="message" class="updated fade"><p><?php echo $message ?>.</p></div>
405
  <?php endif; ?>
406
 
407
+ <?php wp_rp_print_notifications(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
 
409
+ <?php if($meta['show_turn_on_button']): ?>
410
+ <div id="wp_rp_turn_on_statistics">
411
+ <table cellspacing="0" cellpadding="0"><tbody><tr>
412
+ <td>
413
+ <h2>
414
+ Turn on Advanced Features
415
+ </h2>
416
+ <ul>
417
+ <li>Real-time Analytics provided by a <a target="_blank" href="http://www.zemanta.com/?ref=related-posts-a">3rd party service</a></li>
418
+ <li>Thumbnail Support</li>
419
+ <li>Promoted Content</li>
420
+ </ul>
421
+ </td><td>
422
+ <a class="turn-on" href="#">Turn on</a>
423
+ </td>
424
+ </tr></tbody></table>
425
+ </div>
426
+ <?php endif; ?>
427
+
428
+ <?php if ($meta['show_blogger_network_form'] and $meta['blog_id'] and !$meta['show_turn_on_button']): ?>
429
+ <form action="https://docs.google.com/a/zemanta.com/spreadsheet/formResponse?formkey=dDEyTlhraEd0dnRwVVFMX19LRW8wbWc6MQ&amp;ifq" method="POST" class="wp_rp_message_form" id="wp_rp_blogger_network_form" target="wp_rp_blogger_network_hidden_iframe">
430
+ <input type="hidden" name="pageNumber" value="0" />
431
+ <input type="hidden" name="backupCache" />
432
+ <input type="hidden" name="entry.2.single" value="<?php echo get_bloginfo('wpurl'); ?>" />
433
+ <input type="hidden" name="entry.3.single" value="<?php echo $meta['blog_id']; ?>" />
434
+ <a href="#" class="dismiss"><img width="12" src="<?php echo plugins_url("static/img/close.png", __FILE__); ?>" /></a>
435
+ <h2>Blogger networks</h2>
436
+ <p>Easily link out to similar bloggers to exchange traffic with them. One click out, one click in.</p>
437
+ <table class="form-table"><tbody>
438
+ <tr valign="top">
439
+ <th scope="row"><label for="wp_rp_blogger_network_kind">I want to exchange traffic with</label></th>
440
+ <td width="1%">
441
+ <select name="entry.0.group" id="wp_rp_blogger_network_kind">
442
+ <option value="Automotive" />Automotive bloggers</option>
443
+ <option value="Beauty &amp; Style" />Beauty &amp; Style bloggers</option>
444
+ <option value="Business" />Business bloggers</option>
445
+ <option value="Consumer Tech" />Consumer Tech bloggers</option>
446
+ <option value="Enterprise Tech" />Enterprise Tech bloggers</option>
447
+ <option value="Entertainment" />Entertainment bloggers</option>
448
+ <option value="Family &amp; Parenting" />Family &amp; Parenting bloggers</option>
449
+ <option value="Food &amp; Drink" />Food &amp; Drink bloggers</option>
450
+ <option value="Graphic Arts" />Graphic Arts bloggers</option>
451
+ <option value="Healthy Living" />Healthy Living bloggers</option>
452
+ <option value="Home &amp; Shelter" />Home &amp; Shelter bloggers</option>
453
+ <option value="Lifestyle &amp; Hobby" />Lifestyle &amp; Hobby bloggers</option>
454
+ <option value="Men's Lifestyle" />Men's Lifestyle bloggers</option>
455
+ <option value="Personal Finance" />Personal Finance bloggers</option>
456
+ <option value="Women's Lifestyle" />Women's Lifestyle bloggers</option>
457
+ </select>
458
+ </td>
459
+ <td rowspan="2" valign="middle"><div id="wp_rp_blogger_network_thankyou" class="thankyou"><img src="<?php echo plugins_url("static/img/check.png", __FILE__); ?>" width="30" height="22" />Thanks for showing interest.</div></td>
460
+ </tr>
461
+ <tr valign="top">
462
+ <th scope="row"><label for="wp_rp_blogger_network_email">My email is:</label></th>
463
+ <td><input type="email" name="entry.1.single" value="" id="wp_rp_blogger_network_email" required="required" /></td>
464
+ </tr>
465
+ <tr valign="top">
466
+ <th scope="row"></th>
467
+ <td><input type="submit" name="submit" value="Submit" class="submit" id="wp_rp_blogger_network_submit" /></td>
468
+ </tbody></table>
469
  <script type="text/javascript">
470
  jQuery(function($) {
471
+ var submit = $('#wp_rp_blogger_network_submit');
472
+ $('#wp_rp_blogger_network_form')
473
+ .submit(function(event) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
  submit.addClass('disabled');
475
  setTimeout(function() { submit.attr('disabled', true); }, 0);
476
+ $('#wp_rp_blogger_network_hidden_iframe').load(function() {
 
 
 
 
 
477
  submit.attr('disabled', false).removeClass('disabled');
478
+ $('#wp_rp_blogger_network_thankyou').fadeIn('slow');
479
+ $.post(ajaxurl, {action: 'blogger_network_submit', 'join': true});
480
+ });
481
+ })
482
+ .find('a.dismiss').click(function () {
483
+ $.post(ajaxurl, {action: 'blogger_network_submit'});
484
+ $('#wp_rp_blogger_network_form').slideUp();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  });
486
  });
487
  </script>
488
  </form>
489
+ <iframe id="wp_rp_blogger_network_hidden_iframe" name="wp_rp_blogger_network_hidden_iframe" style="display: none"></iframe>
 
 
 
 
 
 
 
 
 
 
 
 
 
490
  <?php endif; ?>
491
 
492
  <form method="post" enctype="multipart/form-data" action="" id="wp_rp_settings_form">
514
  </td>
515
  </tr>
516
  <tr valign="top">
517
+ <th scope="row"><?php _e('Categories in which posts should not have Related Posts:', 'wp_related_posts'); ?></th>
518
  <td>
519
  <?php
520
  $exclude = explode(',', $options['not_on_categories']);
645
  </label>
646
  </td>
647
  </tr>
 
 
 
 
 
 
 
 
 
648
  </table>
649
 
650
  <h3><?php _e("If there are no related posts",'wp_related_posts');?></h3>
702
  <?php _e("Display Related Posts in Feed",'wp_related_posts');?>
703
  </label>
704
  <br />
 
 
 
 
 
705
  <label>
706
  <input name="wp_rp_ctr_dashboard_enabled" type="checkbox" id="wp_rp_ctr_dashboard_enabled" value="yes" <?php checked($options['ctr_dashboard_enabled']); ?> />
707
  <?php _e("Turn statistics on",'wp_related_posts');?>*
static/css/dashboard.css CHANGED
@@ -44,7 +44,61 @@
44
  #wp_rp_invite_friends_form.up img.down { display: block; }
45
 
46
  #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; }
47
- #wp_rp_turn_on_statistics table { margin: 0px auto; }
48
  #wp_rp_turn_on_statistics h2 { font-weight: bold; }
49
  #wp_rp_turn_on_statistics p { margin: 0px; color: #777; }
50
- #wp_rp_turn_on_statistics a { margin-left: 25px; background: #8bc7d1; border: 1px solid #57aab8; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; color: white; padding: 8px 30px; text-shadow: 0px 1px 1px #888; font-weight: bold; font-size: 20px; line-height: 20px; text-decoration: none; text-transform: uppercase; box-shadow: 0px 1px 4px -2px black, 0px 1px 0px #a8d9e0 inset; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  #wp_rp_invite_friends_form.up img.down { display: block; }
45
 
46
  #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; }
47
+ #wp_rp_turn_on_statistics table {}
48
  #wp_rp_turn_on_statistics h2 { font-weight: bold; }
49
  #wp_rp_turn_on_statistics p { margin: 0px; color: #777; }
50
+ #wp_rp_turn_on_statistics a.turn-on { margin-left: 25px; background: #8bc7d1; border: 1px solid #57aab8; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; color: white; padding: 8px 30px; text-shadow: 0px 1px 1px #888; font-weight: bold; font-size: 20px; line-height: 20px; text-decoration: none; text-transform: uppercase; box-shadow: 0px 1px 4px -2px black, 0px 1px 0px #a8d9e0 inset; }
51
+ #wp_rp_turn_on_statistics ul {padding-left: 20px; color: #666; margin: 5px 0 0 0; font-size: 13px;}
52
+ #wp_rp_turn_on_statistics ul li {list-style-type: disc;}
53
+
54
+ form.wp_rp_message_form { background: #f7f7f7; padding: 20px; margin: 30px 0px; border: 1px solid #e1e1e1; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
55
+ form.wp_rp_message_form p {font-size: 14px;}
56
+ form.wp_rp_message_form h2 { font-size: 19px; line-height: 20px; padding-top: 0px; }
57
+ form.wp_rp_message_form .submit {cursor: pointer; background: #8bc7d1; border: 1px solid #57aab8; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; color: white; padding: 6px 24px; text-shadow: 0px 1px 1px #888; font-weight: bold; font-size: 18px; line-height: 20px; text-decoration: none; text-transform: uppercase; box-shadow: 0px 1px 4px -2px black, 0px 1px 0px #a8d9e0 inset; }
58
+ form.wp_rp_message_form .submit.disabled { background-color: #ddd; border-color: #bababa; }
59
+ form.wp_rp_message_form .thankyou { font-size: 14px; display: none; line-height: 42px;}
60
+ form.wp_rp_message_form .thankyou img { float: left; margin: 10px; }
61
+ form.wp_rp_message_form a.dismiss {float: right;}
62
+
63
+ #wp_rp_enable_ads_form h2 {font-weight: bold;}
64
+
65
+ #wp_rp_wrap .wp_rp_notification {
66
+ border: 1px solid #57aab8;
67
+ background: #f1f9fb;
68
+ -moz-border-radius: 3px;
69
+ -webkit-border-radius: 3px;
70
+ border-radius: 3px;
71
+ margin: 10px 0;
72
+ padding: 0;
73
+ position: relative;
74
+ }
75
+ #wp_rp_wrap .wp_rp_notification p {
76
+ color: #464646;
77
+ font-size: 18px;
78
+ padding: 30px 30px 30px 80px;
79
+ margin: 0;
80
+ background: url(../img/measure_icon.png) 20px 15px no-repeat;
81
+ }
82
+ #wp_rp_wrap .wp_rp_notification .close {
83
+ text-decoration: none;
84
+ overflow: hidden;
85
+ background: url(../img/cross.png) 50% 50% no-repeat;
86
+ text-indent: -9999px;
87
+ display: block;
88
+ width: 24px;
89
+ height: 24px;
90
+ position: absolute;
91
+ right: 8px;
92
+ top: 8px;
93
+ }
94
+
95
+ @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
96
+ .wp_rp_notification p {
97
+ background-image: url(../img/measure_icon_2x.png);
98
+ background-size: 42px 42px;
99
+ }
100
+ .wp_rp_notification .close {
101
+ background-image: url(../img/cross_2x.png);
102
+ background-size: 12px 12px;
103
+ }
104
+ }
static/img/close.png ADDED
Binary file
static/img/cross.png ADDED
Binary file
static/img/cross_2x.png ADDED
Binary file
static/img/measure_icon.png ADDED
Binary file
static/img/measure_icon_2x.png ADDED
Binary file
static/js/dashboard.js CHANGED
@@ -1,5 +1,6 @@
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"),f=a("#wp_rp_dashboard_url").val(),d=a("#wp_rp_blog_id").val(),e=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(b){var g=a("#wp_rp_statistics_wrap");b||g.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(b('<li class="{{class}}"><h4>{{ title}}<span>{{range}}</span></h4><p class="num"></p><div class="overlay"><p>{{description}}</p></div></li>',{"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.",
3
- range:"last 30 days"}));ul.append(b('<li class="{{class}}"><h4>{{ title}}<span>{{range}}</span></h4><p class="num"></p><div class="overlay"><p>{{description}}</p></div></li>',{"class":"pageviews",title:"page views",description:"Number of times the page (usually post) was loaded to readers.",range:"last 30 days"}));ul.append(b('<li class="{{class}}"><h4>{{ title}}<span>{{range}}</span></h4><p class="num"></p><div class="overlay"><p>{{description}}</p></div></li>',{"class":"clicks",title:"clicks",description:"Number of times a reader has clicked on one of the Related Posts.",
4
- range:"last 30 days"}));ul.hide();c.append(ul);ul.slideDown()};update_dashboard=function(b){updating||(updating=!0,req_timeout=setTimeout(function(){display_error(!b)},2E3),a.getJSON(f+"pageviews/?callback=?",{blog_id:d,auth_key:e},function(a){clearTimeout(req_timeout);!a||"ok"!==a.status||!a.data?display_error(!b):(ul||create_dashboard(),set_update_interval(a.data.update_interval),ul.find(".ctr .num").html(a.data.ctr+"%"),ul.find(".pageviews .num").html(a.data.pageviews),ul.find(".clicks .num").html(a.data.clicks),
5
- updating=!1)}))};d&&e&&(update_dashboard(!0),update_interval=setInterval(update_dashboard,2E3));a("#wp_rp_turn_on_statistics a").click(function(b){b.preventDefault();a("#wp_rp_ctr_dashboard_enabled, #wp_rp_include_promotionail_link, #wp_rp_display_thumbnail, #wp_rp_enable_themes, #wp_rp_scroll_up_related_posts").prop("checked",!0);a("#wp_rp_settings_form").submit()})})})(jQuery);
 
1
+ (function(a){var c=function(b,c){a.each(c,function(a,c){b=b.replace(RegExp("{{ *"+a+" *}}"),c)});return b};a(function(){var b=a("#wp_rp_statistics_wrap"),g=a("#wp_rp_dashboard_url").val(),e=a("#wp_rp_blog_id").val(),f=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(d){var h=a("#wp_rp_statistics_wrap");d||h.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(c('<li class="{{class}}"><h4>{{ title}}<span>{{range}}</span></h4><p class="num"></p><div class="overlay"><p>{{description}}</p></div></li>',{"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.",
3
+ range:"last 30 days"}));ul.append(c('<li class="{{class}}"><h4>{{ title}}<span>{{range}}</span></h4><p class="num"></p><div class="overlay"><p>{{description}}</p></div></li>',{"class":"pageviews",title:"page views",description:"Number of times the page (usually post) was loaded to readers.",range:"last 30 days"}));ul.append(c('<li class="{{class}}"><h4>{{ title}}<span>{{range}}</span></h4><p class="num"></p><div class="overlay"><p>{{description}}</p></div></li>',{"class":"clicks",title:"clicks",description:"Number of times a reader has clicked on one of the Related Posts.",
4
+ range:"last 30 days"}));ul.hide();b.append(ul);ul.slideDown()};update_dashboard=function(d){updating||(updating=!0,req_timeout=setTimeout(function(){display_error(!d)},2E3),a.getJSON(g+"pageviews/?callback=?",{blog_id:e,auth_key:f},function(a){clearTimeout(req_timeout);!a||"ok"!==a.status||!a.data?display_error(!d):(ul||create_dashboard(),set_update_interval(a.data.update_interval),ul.find(".ctr .num").html(a.data.ctr+"%"),ul.find(".pageviews .num").html(a.data.pageviews),ul.find(".clicks .num").html(a.data.clicks),
5
+ updating=!1)}))};e&&f&&(update_dashboard(!0),update_interval=setInterval(update_dashboard,2E3));a("#wp_rp_turn_on_statistics a.turn-on").click(function(d){d.preventDefault();var d=a("#wp_rp_static_base_url").val(),c=!1,b=function(){c||(a("#wp_rp_settings_form").submit(),c=!0)};a("#wp_rp_ctr_dashboard_enabled, #wp_rp_display_thumbnail, #wp_rp_enable_themes").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">');
6
+ a("<img />").load(b).error(b).attr("src",d+"stats.gif?action=turn_on_button&ads=1&nc="+(new Date).getTime());setTimeout(b,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()})})})(jQuery);
thumbnailer.php CHANGED
@@ -45,50 +45,48 @@ function wp_rp_extract_post_image($post_id) {
45
  'orderby' => 'id',
46
  'order' => 'ASC',
47
  );
48
- $attachments = get_posts($args);
 
 
49
  $image_id = '-1';
50
  if ( $attachments ) {
51
  foreach ( $attachments as $attachment ) {
52
- $img = wp_get_attachment_image($attachment->ID, 'thumbnail');
53
- if($img) {
54
- $image_id = $attachment->ID;
55
  break;
56
  }
57
  }
58
  }
59
-
60
- add_post_meta($post_id, '_wp_rp_image_id', $image_id);
61
  return $image_id;
62
  }
63
 
64
  function wp_rp_get_post_thumbnail_img($related_post) {
65
- $options = wp_rp_get_options();
66
-
67
- if (!$options["display_thumbnail"]) {
68
  return false;
69
  }
70
 
71
- if ($options['thumbnail_use_custom']) {
72
- $thumbnail_src = get_post_meta($related_post->ID, $options["thumbnail_custom_field"], true);
73
- if ($thumbnail_src) {
 
 
74
  $img = '<img src="' . esc_attr($thumbnail_src) . '" alt="' . esc_attr(wptexturize($related_post->post_title)) . '" />';
75
  return $img;
76
  }
77
  } else if (has_post_thumbnail($related_post->ID)) {
78
- $attr = array(
79
  'alt' => esc_attr(wptexturize($related_post->post_title)),
80
  'title' => false
81
  );
82
  $img = get_the_post_thumbnail($related_post->ID, 'thumbnail', $attr);
83
- return $img;
84
  }
85
 
86
- if($options["thumbnail_use_attached"]) {
87
- $image_id = get_post_meta($related_post->ID, '_wp_rp_image_id', true);
88
- if ($image_id === '') {
89
- $image_id = wp_rp_extract_post_image($related_post->ID);
90
- }
91
- if ($image_id !== '-1') {
92
  $img = wp_get_attachment_image($image_id, 'thumbnail');
93
  return $img;
94
  }
45
  'orderby' => 'id',
46
  'order' => 'ASC',
47
  );
48
+
49
+
50
+ $attachments = get_posts($args);
51
  $image_id = '-1';
52
  if ( $attachments ) {
53
  foreach ( $attachments as $attachment ) {
54
+ $img = wp_get_attachment_image($attachment->ID, 'thumbnail');
55
+ if($img) {
56
+ $image_id = $attachment->ID;
57
  break;
58
  }
59
  }
60
  }
 
 
61
  return $image_id;
62
  }
63
 
64
  function wp_rp_get_post_thumbnail_img($related_post) {
65
+ $options = wp_rp_get_options();
66
+ if (!$options["display_thumbnail"]) {
 
67
  return false;
68
  }
69
 
70
+
71
+ if ($options['thumbnail_use_custom']) {
72
+ $thumbnail_src = get_post_meta($related_post->ID, $options["thumbnail_custom_field"], true);
73
+
74
+ if ($thumbnail_src) {
75
  $img = '<img src="' . esc_attr($thumbnail_src) . '" alt="' . esc_attr(wptexturize($related_post->post_title)) . '" />';
76
  return $img;
77
  }
78
  } else if (has_post_thumbnail($related_post->ID)) {
79
+ $attr = array(
80
  'alt' => esc_attr(wptexturize($related_post->post_title)),
81
  'title' => false
82
  );
83
  $img = get_the_post_thumbnail($related_post->ID, 'thumbnail', $attr);
84
+ return $img;
85
  }
86
 
87
+ if($options["thumbnail_use_attached"]) {
88
+ $image_id = wp_rp_extract_post_image($related_post->ID);
89
+ if ($image_id !== '-1') {
 
 
 
90
  $img = wp_get_attachment_image($image_id, 'thumbnail');
91
  return $img;
92
  }
versions.php CHANGED
@@ -1,4 +1,25 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /* ************************* */
3
  /* Version 1.6 */
4
  /* ************************* */
1
  <?php
2
+ /* ************************* */
3
+ /* Version 1.7 */
4
+ /* ************************* */
5
+
6
+ /* Settings:
7
+
8
+ - scroll_up_related_posts
9
+ - include_promotionail_link
10
+
11
+ */
12
+
13
+ /* Meta options:
14
+
15
+ + show_blogger_network_form
16
+ + show_enable_ads_form - removed in silent release
17
+ + remote_notifications array : Array of received remote notifications stored as (msg_id => text), keys sorted by msg_id
18
+ - show_invite_friends_form
19
+ + turn_on_button_pressed - added in silent release
20
+
21
+ */
22
+
23
  /* ************************* */
24
  /* Version 1.6 */
25
  /* ************************* */
wp_related_posts.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
  /*
3
  Plugin Name: WordPress Related Posts
4
- Version: 1.6
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', '1.6');
12
 
13
  include_once(dirname(__FILE__) . '/config.php');
14
 
@@ -22,7 +22,9 @@ include_once(dirname(__FILE__) . '/compatibility.php');
22
  add_action('init', 'wp_rp_init_hook');
23
  add_filter('the_content', 'wp_rp_add_related_posts_hook', 99);
24
 
 
25
  add_action('wp_before_admin_bar_render', 'wp_rp_extend_adminbar');
 
26
  function wp_rp_extend_adminbar() {
27
  global $wp_admin_bar;
28
 
@@ -194,7 +196,7 @@ function wp_rp_generate_related_posts_list_items($related_posts) {
194
 
195
  $img = wp_rp_get_post_thumbnail_img($related_post);
196
  if ($img) {
197
- $output .= '<a href="' . get_permalink($related_post->ID) . '">' . $img . '</a>';
198
  }
199
 
200
  if (!$options["display_thumbnail"] || ($options["display_thumbnail"] && ($options["thumbnail_display_title"] || !$img))) {
@@ -203,7 +205,7 @@ function wp_rp_generate_related_posts_list_items($related_posts) {
203
  $output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
204
  }
205
 
206
- $output .= '<a href="' . get_permalink($related_post->ID) . '">' . wptexturize($related_post->post_title) . '</a>';
207
 
208
  if ($options["display_comment_count"]){
209
  $output .= " (" . $related_post->comment_count . ")";
@@ -243,9 +245,63 @@ function wp_rp_should_exclude() {
243
  return false;
244
  }
245
 
246
- function wp_rp_get_related_posts($before_title = '', $after_title = '') {
247
- global $wpdb, $post;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
 
 
 
 
 
 
 
 
 
 
249
  if (wp_rp_should_exclude()) {
250
  return;
251
  }
@@ -253,31 +309,24 @@ function wp_rp_get_related_posts($before_title = '', $after_title = '') {
253
  $options = wp_rp_get_options();
254
  $meta = wp_rp_get_meta();
255
 
256
- $output = "";
257
- $output_script = "";
258
 
 
259
  $promotional_link = '';
260
 
261
  $posts_and_title = wp_rp_fetch_posts_and_title();
262
  $related_posts = $posts_and_title['posts'];
263
  $title = $posts_and_title['title'];
264
 
265
- $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
266
- $remote_recommendations = $meta['remote_recommendations'] && $statistics_enabled;
267
-
268
-
269
- $output_script .= "window._wp_rp_static_base_url = \"" . WP_RP_STATIC_BASE_URL . "\";\n";
270
 
271
  if ($related_posts) {
272
  $output = wp_rp_generate_related_posts_list_items($related_posts);
273
- $output = "<ul class=\"related_post wp_rp\" style=\"visibility:" . ($remote_recommendations ? 'hidden' : 'visible') . ";\">" . $output . "</ul>\n";
274
-
275
- if ($options['include_promotionail_link']) {
276
- $promotional_link = ' <a target="_blank" rel="nofollow" title="WordPress Related Posts" href="http://related-posts.com/welcome2/" class="wp_rp_welcome" onclick="return window._wp_rp_show_banner && window._wp_rp_show_banner(event)">[?]</a>';
277
- $output .= "<div id=\"wp_rp_popup_holder\"></div>\n";
278
-
279
- wp_enqueue_script('wp_rp_welcome', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_BANNER_FILE);
280
- }
281
  }
282
 
283
  if ($title != '') {
@@ -289,48 +338,5 @@ function wp_rp_get_related_posts($before_title = '', $after_title = '') {
289
  }
290
  }
291
 
292
- if ($options['enable_themes']) {
293
- $theme_name = $options['theme_name'];
294
-
295
- if ($options["display_thumbnail"]) {
296
- wp_enqueue_style('wp_rp_theme', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_THEMES_THUMBS_PATH . $theme_name);
297
- } else {
298
- wp_enqueue_style('wp_rp_theme', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_THEMES_PATH . $theme_name);
299
- }
300
-
301
- if ($theme_name === 'custom.css') {
302
- $theme_custom_css = $options['theme_custom_css'];
303
-
304
- $output .= '<style>' . $theme_custom_css . '</style>';
305
- }
306
- }
307
-
308
- if ($statistics_enabled) {
309
- $post_tags = '[' . implode(', ', array_map(create_function('$v', 'return "\'" . urlencode($v) . "\'";'), wp_get_post_tags($post->ID, array('fields' => 'names')))) . ']';
310
-
311
- $output_script .= 'window._wp_rp_blog_id = \'' . esc_js($meta['blog_id']) . '\';
312
- window._wp_rp_ajax_img_src_url = "' . esc_js(WP_RP_CTR_REPORT_URL) . '";
313
- window._wp_rp_post_id = \'' . esc_js($post->ID) . '\';
314
- window._wp_rp_thumbnails = ' . ($options["display_thumbnail"] ? 'true' : 'false') . ';
315
- window._wp_rp_post_title = \'' . urlencode($post->post_title) . '\';
316
- window._wp_rp_post_tags = ' . $post_tags . ';';
317
-
318
- wp_enqueue_script('wp_rp_pageview', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_CTR_PAGEVIEW_FILE);
319
- }
320
-
321
- if ($remote_recommendations) {
322
- wp_enqueue_script('wp_rp_recommendations', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_RECOMMENDATIONS_JS_FILE);
323
- wp_enqueue_style('wp_rp_recommendations', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_RECOMMENDATIONS_CSS_FILE);
324
- }
325
-
326
- if ($options['scroll_up_related_posts']) {
327
- wp_enqueue_script('wp_rp_scrollup', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_SCROLLUP_JS_FILE, array('jquery'));
328
- wp_enqueue_style('wp_rp_scrollup', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_SCROLLUP_CSS_FILE);
329
- }
330
-
331
- if ($output_script) {
332
- $output_script = "<script type=\"text/javascript\">\n" . $output_script . "\n</script>";
333
- }
334
-
335
- return "\n" . $output_script . "\n" . $output . "\n";
336
  }
1
  <?php
2
  /*
3
  Plugin Name: WordPress Related Posts
4
+ Version: 1.7
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', '1.7');
12
 
13
  include_once(dirname(__FILE__) . '/config.php');
14
 
22
  add_action('init', 'wp_rp_init_hook');
23
  add_filter('the_content', 'wp_rp_add_related_posts_hook', 99);
24
 
25
+ add_action('wp_head', 'wp_rp_head_resources');
26
  add_action('wp_before_admin_bar_render', 'wp_rp_extend_adminbar');
27
+
28
  function wp_rp_extend_adminbar() {
29
  global $wp_admin_bar;
30
 
196
 
197
  $img = wp_rp_get_post_thumbnail_img($related_post);
198
  if ($img) {
199
+ $output .= '<a href="' . get_permalink($related_post->ID) . '" class="wp_rp_thumbnail">' . $img . '</a>';
200
  }
201
 
202
  if (!$options["display_thumbnail"] || ($options["display_thumbnail"] && ($options["thumbnail_display_title"] || !$img))) {
205
  $output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
206
  }
207
 
208
+ $output .= '<a href="' . get_permalink($related_post->ID) . '" class="wp_rp_title">' . wptexturize($related_post->post_title) . '</a>';
209
 
210
  if ($options["display_comment_count"]){
211
  $output .= " (" . $related_post->comment_count . ")";
245
  return false;
246
  }
247
 
248
+ function wp_rp_head_resources() {
249
+ global $post;
250
+
251
+ if (wp_rp_should_exclude()) {
252
+ return;
253
+ }
254
+
255
+ $meta = wp_rp_get_meta();
256
+ $options = wp_rp_get_options();
257
+ $statistics_enabled = false;
258
+ $remote_recommendations = false;
259
+ $output = '';
260
+
261
+ // turn off statistics or recommendations on non-singular posts
262
+ if(is_single()) {
263
+ $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
264
+ $remote_recommendations = $meta['remote_recommendations'] && $statistics_enabled;
265
+ }
266
+
267
+ if ($statistics_enabled) {
268
+ $post_tags = '[' . implode(', ', array_map(create_function('$v', 'return "\'" . urlencode($v) . "\'";'), wp_get_post_tags($post->ID, array('fields' => 'names')))) . ']';
269
+
270
+ $output .= "<script type=\"text/javascript\">\n" .
271
+ "\twindow._wp_rp_blog_id = '" . esc_js($meta['blog_id']) . "';\n" .
272
+ "\twindow._wp_rp_ajax_img_src_url = '" . esc_js(WP_RP_CTR_REPORT_URL) . "';\n" .
273
+ "\twindow._wp_rp_post_id = '" . esc_js($post->ID) . "';\n" .
274
+ "\twindow._wp_rp_thumbnails = " . ($options['display_thumbnail'] ? 'true' : 'false') . ";\n" .
275
+ "\twindow._wp_rp_post_title = '" . urlencode($post->post_title) . "';\n" .
276
+ "\twindow._wp_rp_post_tags = {$post_tags};\n" .
277
+ "\twindow._wp_rp_static_base_url = '" . esc_js(WP_RP_STATIC_BASE_URL) . "';\n" .
278
+ "</script>\n";
279
+
280
+ $output .= '<script type="text/javascript" src="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_CTR_PAGEVIEW_FILE . '"></script>' . "\n";
281
+ }
282
+
283
+ if ($remote_recommendations) {
284
+ $output .= '<script type="text/javascript" src="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_RECOMMENDATIONS_JS_FILE . '"></script>' . "\n";
285
+ $output .= '<link rel="stylesheet" href="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_RECOMMENDATIONS_CSS_FILE . '" />' . "\n";
286
+ }
287
+
288
+ if ($options['enable_themes']) {
289
+ if ($options["display_thumbnail"]) {
290
+ $theme_url = WP_RP_STATIC_BASE_URL . WP_RP_STATIC_THEMES_THUMBS_PATH;
291
+ } else {
292
+ $theme_url = WP_RP_STATIC_BASE_URL . WP_RP_STATIC_THEMES_PATH;
293
+ }
294
 
295
+ $output .= '<link rel="stylesheet" href="' . $theme_url. $options['theme_name'] . '" />' . "\n";
296
+ if ($options['theme_name'] === 'custom.css') {
297
+ $output .= '<style type="text/css">' . $options['theme_custom_css'] . "</style>\n";
298
+ }
299
+ }
300
+
301
+ echo $output;
302
+ }
303
+
304
+ function wp_rp_get_related_posts($before_title = '', $after_title = '') {
305
  if (wp_rp_should_exclude()) {
306
  return;
307
  }
309
  $options = wp_rp_get_options();
310
  $meta = wp_rp_get_meta();
311
 
312
+ $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
313
+ $remote_recommendations = is_single() && $meta['remote_recommendations'] && $statistics_enabled;
314
 
315
+ $output = "";
316
  $promotional_link = '';
317
 
318
  $posts_and_title = wp_rp_fetch_posts_and_title();
319
  $related_posts = $posts_and_title['posts'];
320
  $title = $posts_and_title['title'];
321
 
322
+ $css_classes = 'related_post wp_rp';
323
+ if ($options['enable_themes']) {
324
+ $css_classes .= ' ' . str_replace(array('.css', '-'), array('', '_'), esc_attr('wp_rp_' . $options['theme_name']));
325
+ }
 
326
 
327
  if ($related_posts) {
328
  $output = wp_rp_generate_related_posts_list_items($related_posts);
329
+ $output = '<ul class="' . $css_classes . '" style="visibility: "' . ($remote_recommendations ? 'hidden' : 'visible') . '">' . $output . '</ul>' . "\n";
 
 
 
 
 
 
 
330
  }
331
 
332
  if ($title != '') {
338
  }
339
  }
340
 
341
+ return "\n" . $output . "\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  }