WordPress Related Posts - Version 3.3.3

Version Description

  • Fixed Zemanta Readside plugins incompatibility
  • Uninstallation added
  • Fixed migration bugs
Download this release

Release Info

Developer ddksr
Plugin Icon wp plugin WordPress Related Posts
Version 3.3.3
Comparing to
See all releases

Code changes from version 3.3.2 to 3.3.3

config.php CHANGED
@@ -128,8 +128,14 @@ function wp_rp_upgrade() {
128
 
129
  if($version) {
130
  if(version_compare($version, WP_RP_VERSION, '<')) {
131
- call_user_func('wp_rp_migrate_' . str_replace('.', '_', $version));
132
- wp_rp_upgrade();
 
 
 
 
 
 
133
  }
134
  } else {
135
  wp_rp_install();
@@ -216,6 +222,7 @@ function wp_rp_install() {
216
  'excerpt_max_length' => 200,
217
  'theme_name' => 'm-modern.css',
218
  'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
 
219
  ),
220
  'desktop' => array(
221
  'display_comment_count' => false,
@@ -243,9 +250,14 @@ function wp_rp_is_classic() {
243
  return false;
244
  }
245
 
246
- function wp_rp_migrate_3_3_1() {
247
- global $wpdb;
 
 
 
 
248
 
 
249
  $wp_rp_meta = get_option('wp_rp_meta');
250
  $wp_rp_meta['version'] = '3.3.2';
251
  $wp_rp_meta['new_user'] = false;
128
 
129
  if($version) {
130
  if(version_compare($version, WP_RP_VERSION, '<')) {
131
+ $upgrade_call = 'wp_rp_migrate_' . str_replace('.', '_', $version);
132
+ if (is_callable($upgrade_call)) {
133
+ call_user_func($upgrade_call);
134
+ wp_rp_upgrade();
135
+ }
136
+ else {
137
+ wp_rp_install();
138
+ }
139
  }
140
  } else {
141
  wp_rp_install();
222
  'excerpt_max_length' => 200,
223
  'theme_name' => 'm-modern.css',
224
  'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
225
+ 'custom_theme_enabled' => false,
226
  ),
227
  'desktop' => array(
228
  'display_comment_count' => false,
250
  return false;
251
  }
252
 
253
+ function wp_rp_migrate_3_3_2() {
254
+ $wp_rp_meta = get_option('wp_rp_meta');
255
+ $wp_rp_meta['version'] = '3.3.3';
256
+ $wp_rp_meta['new_user'] = false;
257
+ update_option('wp_rp_meta', $wp_rp_meta);
258
+ }
259
 
260
+ function wp_rp_migrate_3_3_1() {
261
  $wp_rp_meta = get_option('wp_rp_meta');
262
  $wp_rp_meta['version'] = '3.3.2';
263
  $wp_rp_meta['new_user'] = false;
init.php ADDED
@@ -0,0 +1,549 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ define('WP_RP_VERSION', '3.3.3');
3
+
4
+ define('WP_RP_PLUGIN_FILE', plugin_basename(__FILE__));
5
+
6
+ include_once(dirname(__FILE__) . '/config.php');
7
+ include_once(dirname(__FILE__) . '/lib/stemmer.php');
8
+ include_once(dirname(__FILE__) . '/lib/mobile_detect.php');
9
+
10
+ include_once(dirname(__FILE__) . '/admin_notices.php');
11
+ include_once(dirname(__FILE__) . '/notifications.php');
12
+ include_once(dirname(__FILE__) . '/widget.php');
13
+ include_once(dirname(__FILE__) . '/thumbnailer.php');
14
+ include_once(dirname(__FILE__) . '/settings.php');
15
+ include_once(dirname(__FILE__) . '/recommendations.php');
16
+ include_once(dirname(__FILE__) . '/dashboard_widget.php');
17
+ include_once(dirname(__FILE__) . '/edit_related_posts.php');
18
+ include_once(dirname(__FILE__) . '/compatibility.php');
19
+
20
+ register_activation_hook(__FILE__, 'wp_rp_activate_hook');
21
+ register_deactivation_hook(__FILE__, 'wp_rp_deactivate_hook');
22
+
23
+ add_action('wp_head', 'wp_rp_head_resources');
24
+ add_action('wp_before_admin_bar_render', 'wp_rp_extend_adminbar');
25
+
26
+ add_action('plugins_loaded', 'wp_rp_init_zemanta');
27
+
28
+
29
+ function wp_rp_init_zemanta() {
30
+ include_once(dirname(__FILE__) . '/zemanta/zemanta.php');
31
+ if (wp_rp_is_classic()) {
32
+ $wprp_zemanta = new WPRPZemanta();
33
+ }
34
+ }
35
+
36
+ function wp_rp_extend_adminbar() {
37
+ global $wp_admin_bar;
38
+
39
+ if(!is_super_admin() || !is_admin_bar_showing())
40
+ return;
41
+
42
+ $wp_admin_bar->add_menu(array(
43
+ 'id' => 'wp_rp_adminbar_menu',
44
+ 'title' => __('Related Posts', 'wp_related_posts'),
45
+ 'href' => admin_url('admin.php?page=wordpress-related-posts&ref=adminbar')
46
+ ));
47
+ }
48
+
49
+ global $wp_rp_output;
50
+ $wp_rp_output = array();
51
+ function wp_rp_add_related_posts_hook($content) {
52
+ global $wp_rp_output, $post;
53
+
54
+ $options = wp_rp_get_options();
55
+
56
+ if ($content != "" && $post->post_type === 'post' && (($options["on_single_post"] && is_single()) || (is_feed() && $options["on_rss"]))) {
57
+ if (!isset($wp_rp_output[$post->ID])) {
58
+ $wp_rp_output[$post->ID] = wp_rp_get_related_posts();
59
+ }
60
+ $content = str_replace('%RELATEDPOSTS%', '', $content); // used for gp
61
+ $content = $content . $wp_rp_output[$post->ID];
62
+ }
63
+
64
+ return $content;
65
+ }
66
+ add_filter('the_content', 'wp_rp_add_related_posts_hook', 10);
67
+
68
+ global $wp_rp_is_phone;
69
+ function wp_rp_is_phone() {
70
+ global $wp_rp_is_phone;
71
+
72
+ if (!isset($wp_rp_is_phone)) {
73
+ $detect = new WpRpMobileDetect();
74
+ $wp_rp_is_phone = $detect->isMobile() && !$detect->isTablet();
75
+ }
76
+
77
+ return $wp_rp_is_phone;
78
+ }
79
+
80
+ function wp_rp_get_platform_options() {
81
+ $options = wp_rp_get_options();
82
+
83
+ $thumb_options = array('custom_size_thumbnail_enabled' => false);
84
+
85
+ if (!empty($options['custom_size_thumbnail_enabled'])) {
86
+ $thumb_options['custom_size_thumbnail_enabled'] = $options['custom_size_thumbnail_enabled'];
87
+ $thumb_options['custom_thumbnail_width'] = $options['custom_thumbnail_width'];
88
+ $thumb_options['custom_thumbnail_height'] = $options['custom_thumbnail_height'];
89
+ }
90
+ if (wp_rp_is_phone()) {
91
+ return $options['mobile'];
92
+ }
93
+ return $options['desktop'] + $thumb_options;
94
+ }
95
+
96
+ function wp_rp_ajax_load_articles_callback() {
97
+ global $post;
98
+
99
+ $getdata = stripslashes_deep($_GET);
100
+ if (!isset($getdata['post_id'])) {
101
+ die('error');
102
+ }
103
+
104
+ $post = get_post($getdata['post_id']);
105
+ if(!$post) {
106
+ die('error');
107
+ }
108
+
109
+ $from = (isset($getdata['from']) && is_numeric($getdata['from'])) ? intval($getdata['from']) : 0;
110
+ $count = (isset($getdata['count']) && is_numeric($getdata['count'])) ? intval($getdata['count']) : 50;
111
+
112
+ $search = isset($getdata['search']) && $getdata['search'] ? $getdata['search'] : false;
113
+
114
+ $image_size = isset($getdata['size']) ? $getdata['size'] : 'thumbnail';
115
+ if(!($image_size == 'thumbnail' || $image_size == 'full')) {
116
+ die('error');
117
+ }
118
+
119
+ $limit = $count + $from;
120
+
121
+ if ($search) {
122
+ $the_query = new WP_Query(array(
123
+ 's' => $search,
124
+ 'post_type' => 'post',
125
+ 'post_status'=>'publish',
126
+ 'post_count' => $limit));
127
+ $related_posts = $the_query->get_posts();
128
+ } else {
129
+ $related_posts = array();
130
+ wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts_v2', $limit);
131
+ wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts', $limit);
132
+ wp_rp_append_posts($related_posts, 'wp_rp_fetch_random_posts', $limit);
133
+ }
134
+
135
+ if(function_exists('qtrans_postsFilter')) {
136
+ $related_posts = qtrans_postsFilter($related_posts);
137
+ }
138
+
139
+ $response_list = array();
140
+
141
+ foreach (array_slice($related_posts, $from) as $related_post) {
142
+ array_push($response_list, array(
143
+ 'id' => $related_post->ID,
144
+ 'url' => get_permalink($related_post->ID),
145
+ 'title' => $related_post->post_title,
146
+ 'excerpt' => $related_post->post_excerpt,
147
+ 'date' => $related_post->post_date,
148
+ 'comments' => $related_post->comment_count,
149
+ 'img' => wp_rp_get_post_thumbnail_img($related_post, $image_size)
150
+ ));
151
+ }
152
+
153
+ header('Content-Type: text/javascript');
154
+ die(json_encode($response_list));
155
+ }
156
+ add_action('wp_ajax_wp_rp_load_articles', 'wp_rp_ajax_load_articles_callback');
157
+ add_action('wp_ajax_nopriv_wp_rp_load_articles', 'wp_rp_ajax_load_articles_callback');
158
+
159
+ function wp_rp_append_posts(&$related_posts, $fetch_function_name, $limit) {
160
+ $options = wp_rp_get_options();
161
+
162
+ $len = sizeof($related_posts);
163
+ $num_missing_posts = $limit - $len;
164
+ if ($num_missing_posts > 0) {
165
+ $exclude_ids = array_map(create_function('$p', 'return $p->ID;'), $related_posts);
166
+
167
+ $posts = call_user_func($fetch_function_name, $num_missing_posts, $exclude_ids);
168
+ if ($posts) {
169
+ $related_posts = array_merge($related_posts, $posts);
170
+ }
171
+ }
172
+ }
173
+
174
+ function wp_rp_fetch_posts_and_title() {
175
+ $options = wp_rp_get_options();
176
+
177
+ $limit = $options['max_related_posts'];
178
+ $title = $options["related_posts_title"];
179
+
180
+ $related_posts = array();
181
+
182
+ wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts_v2', $limit);
183
+ wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts', $limit);
184
+ wp_rp_append_posts($related_posts, 'wp_rp_fetch_random_posts', $limit);
185
+
186
+ if(function_exists('qtrans_postsFilter')) {
187
+ $related_posts = qtrans_postsFilter($related_posts);
188
+ }
189
+
190
+ return array(
191
+ "posts" => $related_posts,
192
+ "title" => $title
193
+ );
194
+ }
195
+
196
+ function wp_rp_get_next_post(&$related_posts, &$selected_related_posts, &$inserted_urls, &$special_urls, $default_post_type) {
197
+ $post = false;
198
+
199
+ while (!($post && $post->ID) && !(empty($related_posts) && empty($selected_related_posts))) {
200
+ $post_type = $default_post_type;
201
+
202
+ $post = array_shift($selected_related_posts);
203
+
204
+ if ($post && $post->type) {
205
+ $post_type = $post->type;
206
+ }
207
+
208
+ if (!$post || !$post->ID) {
209
+ while (!empty($related_posts) && (!($post = array_shift($related_posts)) || isset($special_urls[get_permalink($post->ID)])));
210
+ }
211
+
212
+ if ($post && $post->ID) {
213
+ $post_url = property_exists($post, 'post_url') ? $post->post_url : get_permalink($post->ID);
214
+ if (isset($inserted_urls[$post_url])) {
215
+ $post = false;
216
+ } else {
217
+ $post->type = $post_type;
218
+ }
219
+ }
220
+ }
221
+
222
+ if (!$post || !$post->ID) {
223
+ return false;
224
+ }
225
+
226
+ $inserted_urls[$post_url] = true;
227
+
228
+ return $post;
229
+ }
230
+
231
+ function wp_rp_generate_related_posts_list_items($related_posts, $selected_related_posts) {
232
+ $options = wp_rp_get_options();
233
+ $platform_options = wp_rp_get_platform_options();
234
+ $output = "";
235
+
236
+ $statistics_enabled = $options['ctr_dashboard_enabled'];
237
+
238
+ $limit = $options['max_related_posts'];
239
+
240
+ $inserted_urls = array(); // Used to prevent duplicates
241
+ $special_urls = array();
242
+
243
+ foreach ($selected_related_posts as $post) {
244
+ if (property_exists($post, 'post_url') && $post->post_url) {
245
+ $special_urls[$post->post_url] = true;
246
+ }
247
+ }
248
+
249
+ $default_post_type = empty($selected_related_posts) ? 'none' : 'empty';
250
+
251
+ $image_size = ($platform_options['theme_name'] == 'pinterest.css') ? 'full' : 'thumbnail';
252
+
253
+ for ($i = 0; $i < $limit; $i++) {
254
+ $related_post = wp_rp_get_next_post($related_posts, $selected_related_posts, $inserted_urls, $special_urls, $default_post_type);
255
+
256
+ if (!$related_post) {
257
+ break;
258
+ }
259
+
260
+ if (property_exists($related_post, 'type')) {
261
+ $post_type = $related_post->type;
262
+ } else {
263
+ $post_type = $default_post_type;
264
+ }
265
+
266
+ if (in_array($post_type, array('empty', 'none'))) {
267
+ $post_id = 'in-' . $related_post->ID;
268
+ } else {
269
+ $post_id = 'ex-' . $related_post->ID;
270
+ }
271
+
272
+ $data_attrs = '';
273
+ if ($statistics_enabled) {
274
+ $data_attrs .= 'data-position="' . $i . '" data-poid="' . $post_id . '" data-post-type="' . $post_type . '" ';
275
+ }
276
+
277
+ $output .= '<li ' . $data_attrs . '>';
278
+
279
+ $post_url = property_exists($related_post, 'post_url') ? $related_post->post_url : get_permalink($related_post->ID);
280
+
281
+ $img = wp_rp_get_post_thumbnail_img($related_post, $image_size);
282
+ if ($img) {
283
+ $output .= '<a href="' . $post_url . '" class="wp_rp_thumbnail">' . $img . '</a>';
284
+ }
285
+
286
+ if ($platform_options["display_publish_date"]) {
287
+ $dateformat = get_option('date_format');
288
+ $output .= '<small class="wp_rp_publish_date">' . mysql2date($dateformat, $related_post->post_date) . '</small> ';
289
+ //$output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
290
+ }
291
+
292
+ $output .= '<a href="' . $post_url . '" class="wp_rp_title">' . wptexturize($related_post->post_title) . '</a>';
293
+
294
+ if ($platform_options["display_comment_count"] && property_exists($related_post, 'comment_count')){
295
+ $output .= '<small class="wp_rp_comments_count"> (' . $related_post->comment_count . ')</small><br />';
296
+ }
297
+
298
+ if ($platform_options["display_excerpt"]){
299
+ $excerpt_max_length = $platform_options["excerpt_max_length"];
300
+ $excerpt = '';
301
+
302
+ if ($related_post->post_excerpt){
303
+ $excerpt = strip_shortcodes(strip_tags($related_post->post_excerpt));
304
+ }
305
+ if (!$excerpt) {
306
+ $excerpt = strip_shortcodes(strip_tags($related_post->post_content));
307
+ }
308
+
309
+ if ($excerpt) {
310
+ if (strlen($excerpt) > $excerpt_max_length) {
311
+ $excerpt = mb_substr($excerpt, 0, $excerpt_max_length - 3) . '...';
312
+ }
313
+ $output .= ' <small class="wp_rp_excerpt">' . $excerpt . '</small>';
314
+ }
315
+ }
316
+ $output .= '</li>';
317
+ }
318
+
319
+ return $output;
320
+ }
321
+
322
+ function wp_rp_should_exclude() {
323
+ global $wpdb, $post;
324
+
325
+ if (!$post || !$post->ID) {
326
+ return true;
327
+ }
328
+
329
+ $options = wp_rp_get_options();
330
+
331
+ if(!$options['exclude_categories']) { return false; }
332
+
333
+ $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'] . ')';
334
+
335
+ $result = $wpdb->get_col($q);
336
+
337
+ $count = (int) $result[0];
338
+
339
+ return $count > 0;
340
+ }
341
+
342
+ function wp_rp_ajax_blogger_network_blacklist_callback() {
343
+ check_ajax_referer('wp_rp_ajax_nonce');
344
+ if (!current_user_can('delete_users')) {
345
+ die();
346
+ }
347
+
348
+ $sourcefeed = (int) $_GET['sourcefeed'];
349
+
350
+ $meta = wp_rp_get_meta();
351
+
352
+ $blog_id = $meta['blog_id'];
353
+ $auth_key = $meta['auth_key'];
354
+ $req_options = array(
355
+ 'timeout' => 5
356
+ );
357
+ $url = WP_RP_CTR_DASHBOARD_URL . "blacklist/?blog_id=$blog_id&auth_key=$auth_key&sfid=$sourcefeed";
358
+ $response = wp_remote_get($url, $req_options);
359
+
360
+ if (wp_remote_retrieve_response_code($response) == 200) {
361
+ $body = wp_remote_retrieve_body($response);
362
+ if ($body) {
363
+ $doc = json_decode($body);
364
+ if ($doc && $doc->status === 'ok') {
365
+ header('Content-Type: text/javascript');
366
+ echo "if(window['_wp_rp_blacklist_callback$sourcefeed']) window._wp_rp_blacklist_callback$sourcefeed();";
367
+ }
368
+ }
369
+ }
370
+ die();
371
+ }
372
+
373
+ add_action('wp_ajax_rp_blogger_network_blacklist', 'wp_rp_ajax_blogger_network_blacklist_callback');
374
+
375
+ function wp_rp_head_resources() {
376
+ global $post, $wpdb;
377
+
378
+ //error_log("call to wp_rp_head_resources");
379
+
380
+ if (wp_rp_should_exclude()) {
381
+ return;
382
+ }
383
+
384
+ $meta = wp_rp_get_meta();
385
+ $options = wp_rp_get_options();
386
+ $platform_options = wp_rp_get_platform_options();
387
+ //error_log('theme name 1: ' . $platform_options['theme_name']);
388
+ $statistics_enabled = false;
389
+ $remote_recommendations = false;
390
+ $output = '';
391
+
392
+ if (is_single()) {
393
+ $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
394
+ $remote_recommendations = $meta['remote_recommendations'] && $statistics_enabled;
395
+ }
396
+
397
+ $output_vars = "\twindow._wp_rp_static_base_url = '" . esc_js(WP_RP_STATIC_BASE_URL) . "';\n" .
398
+ "\twindow._wp_rp_wp_ajax_url = \"" . admin_url('admin-ajax.php') . "\";\n" .
399
+ "\twindow._wp_rp_plugin_version = '" . WP_RP_VERSION . "';\n" .
400
+ "\twindow._wp_rp_post_id = '" . esc_js($post->ID) . "';\n" .
401
+ "\twindow._wp_rp_num_rel_posts = '" . $options['max_related_posts'] . "';\n";
402
+
403
+
404
+ if ($statistics_enabled) {
405
+ $tags = $wpdb->get_col("SELECT DISTINCT(label) FROM " . $wpdb->prefix . "wp_rp_tags WHERE post_id=$post->ID ORDER BY weight desc;", 0);
406
+ if (!empty($tags)) {
407
+ $post_tags = '[' . implode(', ', array_map(create_function('$v', 'return "\'" . urlencode(substr($v, strpos($v, \'_\') + 1)) . "\'";'), $tags)) . ']';
408
+ } else {
409
+ $post_tags = '[]';
410
+ }
411
+
412
+ $output_vars .= "\twindow._wp_rp_blog_id = '" . esc_js($meta['blog_id']) . "';\n" .
413
+ "\twindow._wp_rp_thumbnails = " . ($platform_options['display_thumbnail'] ? 'true' : 'false') . ";\n" .
414
+ "\twindow._wp_rp_post_title = '" . urlencode($post->post_title) . "';\n" .
415
+ "\twindow._wp_rp_post_tags = {$post_tags};\n" .
416
+ "\twindow._wp_rp_remote_recommendations = " . ($remote_recommendations ? 'true' : 'false') . ";\n" .
417
+ "\twindow._wp_rp_promoted_content = " . ($options['promoted_content_enabled'] ? 'true' : 'false') . ";\n" .
418
+ "\twindow._wp_rp_traffic_exchange = " . ($options['traffic_exchange_enabled'] ? 'true' : 'false') . ";\n" .
419
+ (current_user_can('edit_posts') ?
420
+ "\twindow._wp_rp_admin_ajax_url = '" . admin_url('admin-ajax.php') . "';\n" .
421
+ "\twindow._wp_rp_plugin_static_base_url = '" . esc_js(plugins_url('static/' , __FILE__)) . "';\n" .
422
+ "\twindow._wp_rp_ajax_nonce = '" . wp_create_nonce("wp_rp_ajax_nonce") . "';\n" .
423
+ "\twindow._wp_rp_erp_search = true;\n"
424
+ : '');
425
+ }
426
+
427
+ $output .= "<script type=\"text/javascript\">\n" . $output_vars . "</script>\n";
428
+
429
+ if($statistics_enabled) {
430
+ $output .= '<script type="text/javascript" src="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_LOADER_FILE . '?version=' . WP_RP_VERSION . '" async></script>' . "\n";
431
+ }
432
+
433
+ if ($options['enable_themes']) {
434
+ $static_url = plugins_url('static/', __FILE__);
435
+ $theme_url = plugins_url(WP_RP_STATIC_THEMES_PATH, __FILE__);
436
+
437
+
438
+ if ($platform_options['theme_name'] !== 'plain.css' && $platform_options['theme_name'] !== 'm-plain.css') {
439
+ $output .= '<link rel="stylesheet" href="' . $theme_url . $platform_options['theme_name'] . '?version=' . WP_RP_VERSION . '" />' . "\n";
440
+ }
441
+
442
+ if ($platform_options['custom_theme_enabled']) {
443
+ $output .= '<style type="text/css">' . "\n" . $platform_options['theme_custom_css'] . "</style>\n";
444
+ }
445
+
446
+ if ($platform_options['theme_name'] === 'm-stream.css') {
447
+ wp_enqueue_script('wp_rp_infiniterecs', $static_url . WP_RP_STATIC_INFINITE_RECS_JS_FILE, array('jquery'), WP_RP_VERSION);
448
+ }
449
+
450
+ if ($platform_options['theme_name'] === 'pinterest.css') {
451
+ wp_enqueue_script('wp_rp_pinterest', $static_url . WP_RP_STATIC_PINTEREST_JS_FILE, array('jquery'), WP_RP_VERSION);
452
+ }
453
+ }
454
+
455
+ if (current_user_can('edit_posts') && $statistics_enabled) {
456
+ wp_enqueue_style('wp_rp_edit_related_posts_css', $theme_url . 'edit_related_posts.css', array(), WP_RP_VERSION);
457
+ wp_enqueue_script('wp_rp_edit_related_posts_js', $static_url . 'js/edit_related_posts.js', array('jquery'), WP_RP_VERSION);
458
+ }
459
+
460
+ echo $output;
461
+ }
462
+
463
+ function wp_rp_get_selected_posts() {
464
+ global $post;
465
+
466
+ $selected_related_posts = get_post_meta($post->ID, '_wp_rp_selected_related_posts');
467
+ if (empty($selected_related_posts)) {
468
+ return array();
469
+ }
470
+
471
+ $selected_related_posts = $selected_related_posts[0];
472
+ if (empty($selected_related_posts)) {
473
+ return array();
474
+ }
475
+
476
+ $options = wp_rp_get_options();
477
+ $limit = $options['max_related_posts'];
478
+
479
+ return array_slice((array)$selected_related_posts, 0, $limit);
480
+ }
481
+
482
+ global $wp_rp_is_first_widget;
483
+ $wp_rp_is_first_widget = true;
484
+ function wp_rp_get_related_posts($before_title = '', $after_title = '') {
485
+ if (wp_rp_should_exclude()) {
486
+ return;
487
+ }
488
+
489
+ global $post, $wp_rp_is_first_widget;
490
+ global $wp_rp_test_group; // used for AB testing on mobile
491
+
492
+ $options = wp_rp_get_options();
493
+ $platform_options = wp_rp_get_platform_options();
494
+ $meta = wp_rp_get_meta();
495
+
496
+ $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
497
+ $remote_recommendations = is_single() && $meta['remote_recommendations'] && $statistics_enabled;
498
+
499
+ $posts_and_title = wp_rp_fetch_posts_and_title();
500
+ $related_posts = $posts_and_title['posts'];
501
+ $title = $posts_and_title['title'];
502
+
503
+ $selected_related_posts = wp_rp_get_selected_posts();
504
+
505
+ $related_posts_content = "";
506
+
507
+ if (!$related_posts) {
508
+ return;
509
+ }
510
+
511
+ $posts_footer = '';
512
+ if (current_user_can($options['only_admins_can_edit_related_posts'] ? 'manage_options' : 'edit_posts') && $statistics_enabled) {
513
+ $posts_footer .= '<div class="wp_rp_footer"><a class="wp_rp_edit" href="#" id="wp_rp_edit_related_posts">Edit Related Posts</a></div>';
514
+ }
515
+ if ($options['display_zemanta_linky']) {
516
+ $posts_footer .= '<div class="wp_rp_footer"><a class="wp_rp_backlink" target="_blank" href="http://www.zemanta.com/?wp-related-posts" rel="nofollow">Zemanta</a></div>';
517
+ }
518
+
519
+ $css_classes = 'related_post wp_rp';
520
+ $css_classes_wrap = ' ' . str_replace(array('.css', '-'), array('', '_'), esc_attr('wp_rp_' . $platform_options['theme_name']));
521
+
522
+ $related_posts_lis = wp_rp_generate_related_posts_list_items($related_posts, $selected_related_posts);
523
+ $related_posts_ul = '<ul class="' . $css_classes . '" style="visibility: ' . ($remote_recommendations ? 'hidden' : 'visible') . '">' . $related_posts_lis . '</ul>';
524
+
525
+ $related_posts_title = $title ? ($before_title ? $before_title . $title . $after_title : '<h3 class="related_post_title">' . $title . '</h3>') : '';
526
+
527
+ $first_id_attr = '';
528
+ if($wp_rp_is_first_widget) {
529
+ $wp_rp_is_first_widget = false;
530
+ $first_id_attr = 'id="wp_rp_first"';
531
+ }
532
+
533
+ $wrap_style = '';
534
+ //error_log('test group when content:' . $wp_rp_test_group);
535
+ if ($wp_rp_test_group == 2) {
536
+ $wrap_style = ' style="display:none;"';
537
+ }
538
+
539
+ $output = '<div class="wp_rp_wrap ' . $css_classes_wrap . '" ' . $first_id_attr . $wrap_style . '>' .
540
+ '<div class="wp_rp_content">' .
541
+ $related_posts_title .
542
+ $related_posts_ul .
543
+ $posts_footer .
544
+ '</div>' .
545
+ ($remote_recommendations ? '<script type="text/javascript">window._wp_rp_callback_widget_exists ? window._wp_rp_callback_widget_exists() : false;</script>' : '') .
546
+ '</div>';
547
+
548
+ return "\n" . $output . "\n";
549
+ }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: related,posts,post,related posts,plugin
4
  License: GPLv2
5
  Requires at least: 3.3
6
  Tested up to: 3.8
7
- Stable tag: 3.3.2
8
 
9
  WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
10
 
@@ -82,6 +82,11 @@ Fix for security vulnerability. Upgrade immediately.
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
85
  = 3.3.2 =
86
  * Changed default thumbnail title to image file name
87
  * Bug fixes for thumbnailer
4
  License: GPLv2
5
  Requires at least: 3.3
6
  Tested up to: 3.8
7
+ Stable tag: 3.3.3
8
 
9
  WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
10
 
82
 
83
  == Changelog ==
84
 
85
+ = 3.3.3 =
86
+ * Fixed Zemanta Readside plugins incompatibility
87
+ * Uninstallation added
88
+ * Fixed migration bugs
89
+
90
  = 3.3.2 =
91
  * Changed default thumbnail title to image file name
92
  * Bug fixes for thumbnailer
static/img/arrow_down.png CHANGED
Binary file
static/img/arrow_right.png CHANGED
Binary file
static/img/cross.png CHANGED
Binary file
static/img/desktop_icon.png CHANGED
Binary file
static/img/down.png CHANGED
Binary file
static/img/mobile_icon.png CHANGED
Binary file
static/img/network_icon.png CHANGED
Binary file
static/img/outlink.png CHANGED
Binary file
static/img/themes/modern.jpg CHANGED
Binary file
static/img/themes/vertical-s.jpg CHANGED
Binary file
static/img/themes/vertical.jpg CHANGED
Binary file
static/img/up.png CHANGED
Binary file
static/js/edit_related_posts.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function(d){d.event.props.push("dataTransfer");var C=function(d,l){var m=document.createElement("img"),i={action:d,blog_id:window._wp_rp_blog_id,post_id:window._wp_rp_post_id,request_id:window._wp_rp_request_id,_:+new Date},w=[],q=window._wp_rp_static_base_url+"stats.gif?";if(l)for(var j in l)l.hasOwnProperty(j)&&(i[j]=l[j]);for(x in i)i.hasOwnProperty(x)&&w.push(x+"="+i[x]);q+=w.join("&");m.src=q},z=function(){d("#wp_rp_edit_related_posts").click(function(){var k=window._wp_rp_num_rel_posts,l=window._wp_rp_blog_id,
2
+ m=window._wp_rp_post_id,i=!1!==window._wp_rp_remote_recommendations,w=window._wp_rp_admin_ajax_url,q=window._wp_rp_plugin_static_base_url,j=!!window._wp_rp_erp_search,z=!1!==window._wp_rp_promoted_content,H=!1!==window._wp_rp_traffic_exchange,p=0,b={holder:null,wrapper:null,search_form:null,search_input:null,selected_articles_wrap:null,replace_articles_wrap:null,replace_articles_list:null,article_loader:null,article_list:{},articles_to_insert:null,footer:null,save:null},h={},n=[],r={},s=[],D=function(a){a.preventDefault();
3
+ C("edit-related-posts-close");b.holder.remove();d("html").css("overflow","visible")},A=function(a){C("edit-related-posts-save");var c=[];d.each(h,function(){});for(var b=0;b<k;b+=1){var e=h[b];e?"own_sourcefeed"===e.type?c.push({ID:e.aid,post_url:e.url,thumbnail:e.thumbnail,post_title:e.title,post_excerpt:e.excerpt||"",post_content:"",post_date:e.date||"",comment_count:e.comments||0,picked:!!e.picked,type:e.type,pos:b}):c.push({ID:!1,pos:b,type:e.type}):c.push({ID:!1,pos:b,type:"empty"})}d.post(w,
4
+ {action:"rp_update_related_posts",post_id:m,related_posts:JSON.stringify(c),_wpnonce:window._wp_rp_ajax_nonce},a)},E;E=function(a,c,b,e){var c=window._wp_rp_post_tags&&window._wp_rp_post_tags.join(",")||"",g=window._wp_rp_post_title||"",a=a||!1;if(!c&&!g&&!1===a)b(!1);else{var f={},h=i?2:1,j=function(){h-=1;if(0>=h){var a=[],c={};d.each(["external","internal"],function(b,e){f[e]&&("ok"===f[e].status&&f[e].data)&&d.each(f[e].data.results,function(b,e){if(c[e.url])return!0;c[e.url]=!0;a.push(e)})});
5
+ f.external&&"ok"===f.external.status&&(p=f.external.data.settings.num_external_slots);a?b&&a&&b(a):e&&e()}},k=function(a){f["internal"===a.source?"internal":"external"]=a;j()};data={post_id:m,search:a||"",action:"wp_rp_load_articles",count:30};d.ajax({url:window._wp_rp_wp_ajax_url,dataType:"json",data:data,success:function(a){var c=[];d.each(a,function(a,b){c.push({type:"own_sourcefeed",aid:"in_"+b.id,thumbnail:d(b.img).attr("src"),title:b.title,excerpt:b.excerpt,date:b.date,comments:b.comments,url:b.url,
6
+ target_url:b.url})});k({status:"ok",source:"internal",data:{results:c}})},error:j});if(i)if(a)j();else{var a={edit_related_posts_request:!0,blog_id:l,post_id:m,tags:c,title:g,search:a||"",pc:z,tX:H},n=setTimeout(j,2E3);d.ajax({url:"http://sre.zemanta.com/content/",dataType:"jsonp",data:a,success:function(a){clearTimeout(n);k(a)}})}}};var y,F=function(a,c,I){b.replace_articles_list.html("");f.render_selector_shadows();n=[];b.article_loader.find(".zem-no-articles").hide();b.article_loader.find(".zem-loader").show();
7
+ b.article_loader.show();var e=p;E(c,I,function(c){c&&c.length?(b.article_loader.hide(),n=d.grep(c,function(a){return 0>window.location.href.indexOf(a.url)}),d.each(n,function(a,c){r[c.aid]?(c=r[c.aid],n[a]=c):r[c.aid]=c}),f.article_selector(),e!==p&&f.articles()):(b.article_loader.find(".zem-no-articles").show(),b.article_loader.find(".zem-loader").hide());f.render_selector_shadows();a&&a(!0)},function(){b.article_loader.find(".zem-no-articles").show();b.article_loader.find(".zem-loader").hide();
8
+ f.render_selector_shadows();a&&a(!1)})},t=function(a,c,b){a.picked=!0;a.pos=c;h[c]=a;r[a.aid]=a;f.article_li_selected(a);b&&(A(),f.article_selector())},u=function(a,c){delete h[a.pos];a.picked=!1;a.pos=-1;a.elm&&a.elm.html('<div class="droppable" /><span class="notice">Drag post here</span>').attr("draggable",!1).removeClass("external").data("aid",!1);c&&(A(),f.article_selector())},f={article_li_placeholder:function(a,c){a.addClass("external");a.append('<span class="title">'+c.title+"</span>");var b=
9
+ d('<a class="open-settings button" target="_blank" href="http://prefs.zemanta.com/dash/'+l+'/?ref=erp">settings</a>');b.bind("click",function(a){a.stopPropagation()});a.append(b)},article_li:function(a,c){a.html('<div class="droppable" />');a.data("aid",c);a.attr("draggable",!0);a.unbind("dragstart").bind("dragstart",function(b){g.drag(b,c,a)});if(c.external)f.article_li_placeholder(a,c);else{var b=d('<img draggable="false" />');b.error(function(){b.unbind("error");var a=parseInt(c.aid.replace("in_"))||
10
+ parseInt(30*Math.random()),a=q+"thumbs/"+a%30+".jpg";c.thumbnail=a;b.attr("src",a)});c.thumbnail=c.thumbnail||c.thumbnail_url;b.attr("src",c.thumbnail);a.append(b);a.append('<span unselectable="on" class="title">'+c.title+"</span>");var e=d('<a class="open-article" draggable="false" target="_blank" href="'+c.target_url+'">link out</a>');e.bind("click",function(a){a.stopPropagation()});a.append(e)}},article_li_selector:function(a,c){c.elm=a;f.article_li(a,c);var b=d('<a draggable="false" class="insert overlay" href="#"><div class="txt">insert</div></a>');
11
+ b.bind("click",function(a){a.preventDefault();for(a=a=0;a<k-1&&h[a];a+=1);h[a]||t(c,a,!0)});a.append(b)},article_li_selected:function(a){var c=b.article_list[a.pos];a.elm=c;f.article_li(c,a);if(!a.external){var g=d('<a draggable="false" class="remove overlay" href="#"><span class="icon"></span><span class="txt">remove</span></a>');g.bind("click",function(c){c.preventDefault();u(a,!0)});c.append(g)}},article_selector:function(){b.replace_articles_list.html("");var a={};d.each(h,function(c,b){a[b.aid]=
12
+ !0});var c=0;d.each(n,function(g,e){if(!a[e.aid]){var h=d("<li />");f.article_li_selector(h,e);b.replace_articles_list.append(h);c+=1}if(30<=c)return!1});f.render_selector_shadows()},render_selector_shadows:function(){var a=b.replace_articles_list.scrollLeft(),c=b.replace_articles_list[0].scrollWidth-b.replace_articles_list.width();0<a?b.replace_articles_list.addClass("scroll-left"):b.replace_articles_list.removeClass("scroll-left");a<c?b.replace_articles_list.addClass("scroll-right"):b.replace_articles_list.removeClass("scroll-right")},
13
+ external_placeholders:function(){for(var a=0,c=s.length,a=0;a<p-c;a+=1)s.push(k-p+a);for(a=0;a<p&&a<s.length;a+=1)t({external:!0,type:"external",title:"Cross promotion"},s[a],!1)},articles:function(){f.external_placeholders();d.each(h,function(a,c){c&&(c.aid&&c.picked)&&(a<k?t(c,a,!1):u(c,!1))})},all:function(){f.articles();f.article_selector()}},g={hint_timeout:null,dragged_article:null,ie9_drag_start:function(a){1!==a.which||(a.ctrlKey||a.metaKey)||d(this).get(0).dragDrop&&d(this).get(0).dragDrop()},
14
+ drag_hint:function(a){if(!(1!==a.which||a.ctrlKey||a.metaKey)){var a=d(this),c=g.dragged_article||a.data("aid");c&&(g.hint_timeout=setTimeout(function(){!c.picked||c.external?b.wrapper.find("ul.selected li:not(.external)").addClass("drop-hint"):b.wrapper.find("ul.selected li").addClass("drop-hint");c.picked&&!c.external&&b.remove_article_sign.show()},100))}},drag:function(a,c,d){a.dataTransfer.setData("text","wprp_article_"+c.aid);a.dataTransfer.setDragImage?a.dataTransfer.setDragImage(d.get(0),d.outerWidth()/
15
+ 2,d.outerHeight()/2):a.dataTransfer.addElement&&a.dataTransfer.addElement(d.get(0));g.dragged_article=c;setTimeout(function(){b.wrapper.find("li .droppable").css("z-index",2)},1);g.drag_hint(a)},drop_remove:function(a){a.preventDefault();var c=g.dragged_article;g.dragged_article&&!c.external&&(u(c,!0),g.dragend(a))},drop:function(a){d(this).removeClass("drop");a.preventDefault();var c=g.dragged_article;if(!c)return!1;var b=c.pos,e=1*d(this).data("pos");if(b===e)return!1;var f=h[e];if(!f||!(f.external&&
16
+ !c.picked||f.external&&c.external)){var i=c.picked;i&&u(c,!1);f&&(u(f,!1),i&&t(f,b,!1));t(c,e,!0);g.dragend(a)}},dragover:function(a){a.preventDefault();var a=g.dragged_article,c=d(this).data("aid");(!c||!(c.external&&!a.picked||c.external&&a.external))&&d(this).addClass("drop")},dragleave:function(a){a.preventDefault();d(this).removeClass("drop")},dragend:function(){clearTimeout(g.hint_timeout);g.dragged_article=null;b.remove_article_sign.hide();b.wrapper.find("li .droppable").css("z-index",-1);
17
+ b.wrapper.find("ul.selected li").removeClass("drop-hint")},init:function(){b.selected_articles_wrap.delegate("li","dragover",g.dragover).delegate("li","dragleave",g.dragleave).delegate("li","drop",g.drop);b.replace_articles_wrap.bind("dragover",g.dragover).bind("dragleave",g.dragleave).bind("drop",g.drop_remove);b.wrapper.delegate("li[draggable=true]","dragstart",g.drag_hint).delegate("li[draggable=true]","dragend",g.dragend).delegate("li[draggable=true]","mousedown",g.drag_hint).delegate("li[draggable=true]",
18
+ "mouseup",g.dragend).delegate("li[draggable=true]","mousemove",g.ie9_drag_start)}};y={update:F,render:f.all,init:function(){g.init();b.search_form.bind("submit",function(a){a.preventDefault();a=b.search_input.val();F(null,a,!0)});b.replace_articles_list.bind("scroll",f.render_selector_shadows)}};b.holder=d('<div id="wp_rp_zem_related_posts_holder"></div>');b.wrapper=d('<div id="wp_rp_zem_related_posts_wrap"><div class="selected-header"><h4 class="selected-title">Selected posts</h4><a href="#" class="save button">Save and Close</a></div><div class="selected-content"></div></div>');
19
+ b.holder.append(b.wrapper);b.wrapper.bind("click",function(a){a.stopPropagation()});b.save=b.wrapper.find(".save");b.save.bind("click",function(){A(function(){window.location.reload()});return!1});b.selected_articles_wrap=b.wrapper.find(".selected-content");for(var G=d('<ul class="selected" />'),v=0;v<k;v+=1){var B=d('<li><div class="droppable" /><span class="notice">Drag post here</span></li>');B.data("pos",v);b.article_list[v]=B;G.append(B)}b.selected_articles_wrap.append(G);b.replace_articles_wrap=
20
+ d('<div id="wp_rp_replace_article_wrap"><div class="remove-article-sign">Drop article here to remove it</div><div class="recommendations-header"><h4 class="recommendations-title">Recommended posts</h4>'+(j?'<form class="search" action="#"><input placeholder="search" class="search" type="text" /><input class="go button" type="submit" value="go" /></form>':'<div class="search notice">Please upgrade the plugin to use search.</div>')+'</div><div class="content"><ul></ul></div><div class="footer"><a href="http://www.zemanta.com/?ref=edit-rp" target="_blank">zemanta.com</a></div></div>');
21
+ b.wrapper.append(b.replace_articles_wrap);b.replace_articles_list=b.replace_articles_wrap.find(".content ul");b.article_loader=d('<div class="zem-loader-wrap"><div class="zem-no-articles">No results.</div><div class="zem-loader"><div class="zem-loader-step zem-loader-step-1"></div><div class="zem-loader-step zem-loader-step-2"></div><div class="zem-loader-step zem-loader-step-3"></div></div></div>');b.replace_articles_wrap.append(b.article_loader);b.remove_article_sign=b.replace_articles_wrap.find(".remove-article-sign");
22
+ b.search_form=b.replace_articles_wrap.find("form.search");b.search_input=b.replace_articles_wrap.find("input.search");b.footer=b.replace_articles_wrap.find(".footer");b.holder.bind("click",D);d(document).keydown(function(a){27==a.keyCode&&D(a)});d("html").css("overflow","hidden");y.init();(j=d(".wp_rp:first li:not(.wp_rp_special)"))&&j.each(function(a,c){c=d(c);if("own_sourcefeed"==c.data("post-type")){var b={aid:c.data("poid").split("-")[1],url:c.find("a:first").attr("href"),title:c.find("a.wp_rp_title").text(),
23
+ excerpt:c.find(".wp_rp_excerpt").text(),comments:parseInt(c.find(".wp_rp_comments_count").text().replace("(","").replace(")",""),10),date:c.find(".wp_rp_publish_date").text(),text_preview:"",published_datetime:"",thumbnail:c.find("img").attr("src"),picked:!0,type:c.data("post-type"),pos:c.data("position")};n.push(b);r[b.aid]=b;h[a]=b}else({promoted:!0,network:!0,external:!0})[c.data("post-type")]&&s.push(a)});y.update();y.render();d("body").append(b.holder);b.replace_articles_wrap.css("width",Math.min(b.holder.width()-
24
+ 142,Math.max(680,110*k+130))+"px");return!1})};(function l(m,i){i||(i=10,m=0);d("#wp_rp_edit_related_posts").length?z():3E4>m?setTimeout(function(){l(m+i,1.5*i)},i):d(function(){z()})})()})(jQuery);
static/js/infiniterecs.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ var ZemRPResponse=[];
2
+ jQuery(function(c){window._wp_rp_request_id=window._wp_rp_request_id||((new Date).getTime()%60466176/60466176).toString(36).substr(2,5)+Math.random().toString(36).substr(2,10);var h=c(window),i=c(".related_post"),d=!1,a=i.find("li").length,e=-1,j=function(){var b=window._wp_rp_wp_ajax_url+"?action=wp_rp_load_articles&post_id="+window._wp_rp_post_id+"&from="+a+"&count=50";!d&&e!==a&&(d=!0,c.get(b,function(b){c.each(b,function(b,c){ZemRPResponse.push(c)});e=a;a+=b.length;d=!1},"json"))};window.onfocus=
3
+ function(){};window.onblur=function(){};j();h.scroll(function(){var b=i.children(":first");if(h.height()+document.body.scrollTop>b.offset().top){for(var b=0,a=[],d={};10>b;b+=1)(d=ZemRPResponse.shift())&&a.push(d);var e=c(".related_post"),f=e.find("li").last().data("position")+1,g;c.each(a,function(b,a){g=c('<li data-position="'+f+'" data-poid="'+a.id+'"><a href="'+a.url+'" class="wp_rp_thumbnail">'+a.img+'</a><a href="'+a.url+'" class="wp_rp_title">'+a.title+"</a></li>");g.data("position",f);g.data("poid",
4
+ a.id);e.append(g);f+=1});20>=ZemRPResponse.length&&j()}})});
static/js/pinterest.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ (function(){var g=[];window.jQuery&&jQuery(function(c){window._wp_rp_request_id=window._wp_rp_request_id||((new Date).getTime()%60466176/60466176).toString(36).substr(2,5)+Math.random().toString(36).substr(2,10);var h=0,t=c(window),j=1*window._wp_rp_num_rel_posts||5,u=2*j,k=!0,f=c(".wp_rp.related_post"),l=!1,m=!1,z=2*f.outerHeight(!0),n=j,p=function(){if(0>=g.length)return c("#wp_rp_related_load_more").parent().remove(),[];for(var b=0,a=[],e={};b<(k?j:u);b+=1)(e=g.shift())&&a.push(e);k=!1;return a},
2
+ q=function(b){m&&0>=g.length&&c("#wp_rp_related_load_more").parent().remove();!l&&!m&&(l=!0,c.getJSON(window._wp_rp_wp_ajax_url+"?action=wp_rp_load_articles&post_id="+window._wp_rp_post_id+"&from="+n+"&count=50&size=full",function(a){!a||!a.length||"string"===typeof a?(m=!0,0>=g.length&&c("#wp_rp_related_load_more").parent().remove()):(n+=a.length,c.each(a,function(a,c){g.push(c)}),b&&b());l=!1}))},v=function(){var b=function(a){setTimeout(function(){c("#wp_rp_related_load_more").find(".zloader").hide().end().find("span").show()},
3
+ 500);var b=c(".related_post.wp_rp"),d=b.find("li ul li").length,g=null,f=b.find(".wp_rp_related_post_column"),h=function(a){var b=c();f.each(function(a,d){d=c("ul",d);if(null===b.height()||b.height()>=d.height())b=d});b.append(a)};c.each(a,function(a,b){var e=c(b.img);e.load(function(){c(this).data("zloaded",!0)}).error(function(){c(this).data("zloaded",!0)});var f=c('<li data-position="'+d+'" data-poid="'+b.id+'"><a href="'+b.url+'" class="wp_rp_thumbnail"></a><a href="'+b.url+'" class="wp_rp_title">'+
4
+ b.title+"</a></li>");f.data("position",d);f.data("poid",b.id);f.find(".wp_rp_thumbnail").append(e);d+=1;var i=g;setTimeout(function(){!i||!i.length||i.data("zloaded")?h(f,e):i.load(function(){h(f,e)}).error(function(){h(f,e)})},75*a);g=e})};0>=g.length?q(function(){b(p())}):g.length<=2*u?(b(p()),q()):b(p())},w=function(){h&&clearTimeout(h);h=setTimeout(function(){var b=c(".related_post.wp_rp");b.offset().top+b.outerHeight(!0)-t.scrollTop()-t.height()+100<z&&v()},150)},y=-1,r=[],s=0;f.find("li").each(function(b,
5
+ a){a=c(a);a.children().find("img").data("zloaded",!0);var e=a.data("poid"),d=a.data("position"),f=a.data("post-type"),g=a.attr("class"),e=c('<li class="'+g+'" data-post-type="'+f+'" data-position="'+d+'" data-poid="'+e+'"></li>'),d=a.offset().left;d>y&&(y=d,s+=1);d=b%s;e.append(a.children());r[d]?(r[d].find("ul").append(e),a.remove()):(a.empty(),a.attr("data-position",null),a.attr("data-poid",null),a.attr("data-post-type",null),a.addClass("wp_rp_related_post_column"),a.addClass("wp_rp_special"),a.append("<ul></ul>"),
6
+ a.find("ul").append(e),r[d]=a)});w();c(window).bind("scroll.zloader",function(){k?w():c(window).unbind("scroll.zloader")});q();f.append(c('<li class="wp_rp_related_post_load_more wp_rp_special"><a id="wp_rp_related_load_more" href="#"><span>Load more posts</span><img src="'+window._wp_rp_static_base_url+'img/loading.gif" class="zloader" /></a></li>'));f.find("#wp_rp_related_load_more").click(function(b){c("span",this).hide();c(".zloader",this).show();b.preventDefault();v();var b=document.createElement("img"),
7
+ a={action:"pinterest-load-more",blog_id:window._wp_rp_blog_id,post_id:window._wp_rp_post_id,request_id:window._wp_rp_request_id,_:+new Date},e=[],d=window._wp_rp_static_base_url+"stats.gif?";for(x in a)a.hasOwnProperty(x)&&e.push(x+"="+a[x]);d+=e.join("&");b.src=d})})})();
thumbnailer.php CHANGED
@@ -202,8 +202,16 @@ add_action('save_post', 'wp_rp_post_save_update_image');
202
  * Get thumbnails when post is displayed
203
  */
204
 
205
- function wp_rp_get_img_tag($src, $alt) {
206
- return '<img src="'. esc_attr($src) . '" alt="' . esc_attr($alt) . '" />';
 
 
 
 
 
 
 
 
207
  }
208
 
209
  function wp_rp_get_default_thumbnail_url($seed = false, $size = 'thumbnail') {
@@ -313,7 +321,7 @@ function wp_rp_get_attached_img_url($related_post, $size) {
313
  }
314
  }
315
 
316
- if (!$image_data) {
317
  wp_rp_extract_images_from_post($related_post);
318
  return false;
319
  }
@@ -352,7 +360,7 @@ function wp_rp_get_post_thumbnail_img($related_post, $size = null, $force = fals
352
 
353
  $post_title = wptexturize($related_post->post_title);
354
  if (property_exists($related_post, 'thumbnail')) {
355
- return wp_rp_get_img_tag($related_post->thumbnail, $post_title);
356
  }
357
 
358
  $size = wp_rp_get_thumbnail_size_array($size);
@@ -362,16 +370,16 @@ function wp_rp_get_post_thumbnail_img($related_post, $size = null, $force = fals
362
  $thumbnail_src = get_post_meta($related_post->ID, $options["thumbnail_custom_field"], true);
363
 
364
  if ($thumbnail_src) {
365
- return wp_rp_get_img_tag($thumbnail_src, $post_title);
366
  }
367
  }
368
 
369
  $attached_img_url = wp_rp_get_attached_img_url($related_post, $size);
370
  if ($attached_img_url) {
371
- return wp_rp_get_img_tag($attached_img_url, $post_title);
372
  }
373
 
374
- return wp_rp_get_img_tag(wp_rp_get_default_thumbnail_url($related_post->ID, $size), $post_title);
375
  }
376
 
377
  function wp_rp_process_latest_post_thumbnails() {
202
  * Get thumbnails when post is displayed
203
  */
204
 
205
+ function wp_rp_get_img_tag($src, $alt, $size=null) {
206
+ if (!$size || !is_array($size)) {
207
+ $size = array(WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT);
208
+ }
209
+ $size_attr = ($size[0] ? ('width="' . $size[0] . '" ') : '');
210
+ if ($size[1]) {
211
+ $size_attr .= 'height="' . $size[1] . '" ';
212
+ }
213
+ return '<img src="'. esc_attr($src) . '" alt="' . esc_attr($alt) . '" '.$size_attr.'/>';
214
+
215
  }
216
 
217
  function wp_rp_get_default_thumbnail_url($seed = false, $size = 'thumbnail') {
321
  }
322
  }
323
 
324
+ if (!$image_data) {
325
  wp_rp_extract_images_from_post($related_post);
326
  return false;
327
  }
360
 
361
  $post_title = wptexturize($related_post->post_title);
362
  if (property_exists($related_post, 'thumbnail')) {
363
+ return wp_rp_get_img_tag($related_post->thumbnail, $post_title, $size);
364
  }
365
 
366
  $size = wp_rp_get_thumbnail_size_array($size);
370
  $thumbnail_src = get_post_meta($related_post->ID, $options["thumbnail_custom_field"], true);
371
 
372
  if ($thumbnail_src) {
373
+ return wp_rp_get_img_tag($thumbnail_src, $post_title, $size);
374
  }
375
  }
376
 
377
  $attached_img_url = wp_rp_get_attached_img_url($related_post, $size);
378
  if ($attached_img_url) {
379
+ return wp_rp_get_img_tag($attached_img_url, $post_title, $size);
380
  }
381
 
382
+ return wp_rp_get_img_tag(wp_rp_get_default_thumbnail_url($related_post->ID, $size), $post_title, $size);
383
  }
384
 
385
  function wp_rp_process_latest_post_thumbnails() {
uninstall.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //if uninstall not called from WordPress exit
4
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
5
+ exit();
6
+
7
+ delete_option('wp_rp_options');
8
+ delete_option('wp_rp_meta');
wp_related_posts.php CHANGED
@@ -1,555 +1,37 @@
1
  <?php
2
  /*
3
  Plugin Name: WordPress Related Posts
4
- Version: 3.3.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. Click on <a href="admin.php?page=wordpress-related-posts">Related Posts tab</a> to configure your settings.
7
  Author: Zemanta Ltd.
8
  Author URI: http://www.zemanta.com
9
  */
10
 
11
- define('WP_RP_VERSION', '3.3.2');
12
-
13
- define('WP_RP_PLUGIN_FILE', plugin_basename(__FILE__));
14
-
15
- include_once(dirname(__FILE__) . '/config.php');
16
- include_once(dirname(__FILE__) . '/lib/stemmer.php');
17
- include_once(dirname(__FILE__) . '/lib/mobile_detect.php');
18
-
19
- include_once(dirname(__FILE__) . '/admin_notices.php');
20
- include_once(dirname(__FILE__) . '/notifications.php');
21
- include_once(dirname(__FILE__) . '/widget.php');
22
- include_once(dirname(__FILE__) . '/thumbnailer.php');
23
- include_once(dirname(__FILE__) . '/settings.php');
24
- include_once(dirname(__FILE__) . '/recommendations.php');
25
- include_once(dirname(__FILE__) . '/dashboard_widget.php');
26
- include_once(dirname(__FILE__) . '/edit_related_posts.php');
27
- include_once(dirname(__FILE__) . '/compatibility.php');
28
-
29
- register_activation_hook(__FILE__, 'wp_rp_activate_hook');
30
- register_deactivation_hook(__FILE__, 'wp_rp_deactivate_hook');
31
-
32
- add_action('wp_head', 'wp_rp_head_resources');
33
- add_action('wp_before_admin_bar_render', 'wp_rp_extend_adminbar');
34
-
35
- add_action('plugins_loaded', 'wp_rp_init_zemanta');
36
- function wp_rp_init_zemanta() {
37
- include_once(dirname(__FILE__) . '/zemanta/zemanta.php');
38
- if (wp_rp_is_classic()) {
39
- $wprp_zemanta = new WPRPZemanta();
40
- }
41
- }
42
-
43
- function wp_rp_extend_adminbar() {
44
- global $wp_admin_bar;
45
-
46
- if(!is_super_admin() || !is_admin_bar_showing())
47
- return;
48
-
49
- $wp_admin_bar->add_menu(array(
50
- 'id' => 'wp_rp_adminbar_menu',
51
- 'title' => __('Related Posts', 'wp_related_posts'),
52
- 'href' => admin_url('admin.php?page=wordpress-related-posts&ref=adminbar')
53
- ));
54
- }
55
-
56
- global $wp_rp_output;
57
- $wp_rp_output = array();
58
- function wp_rp_add_related_posts_hook($content) {
59
- global $wp_rp_output, $post;
60
-
61
- $options = wp_rp_get_options();
62
-
63
- if ($content != "" && $post->post_type === 'post' && (($options["on_single_post"] && is_single()) || (is_feed() && $options["on_rss"]))) {
64
- if (!isset($wp_rp_output[$post->ID])) {
65
- $wp_rp_output[$post->ID] = wp_rp_get_related_posts();
66
- }
67
- $content = str_replace('%RELATEDPOSTS%', '', $content); // used for gp
68
- $content = $content . $wp_rp_output[$post->ID];
69
- }
70
-
71
- return $content;
72
- }
73
- add_filter('the_content', 'wp_rp_add_related_posts_hook', 10);
74
-
75
- global $wp_rp_is_phone;
76
- function wp_rp_is_phone() {
77
- global $wp_rp_is_phone;
78
-
79
- if (!isset($wp_rp_is_phone)) {
80
- $detect = new WpRpMobileDetect();
81
- $wp_rp_is_phone = $detect->isMobile() && !$detect->isTablet();
82
- }
83
-
84
- return $wp_rp_is_phone;
85
- }
86
-
87
- function wp_rp_get_platform_options() {
88
- $options = wp_rp_get_options();
89
-
90
- $thumb_options = array('custom_size_thumbnail_enabled' => false);
91
-
92
- if (!empty($options['custom_size_thumbnail_enabled'])) {
93
- $thumb_options['custom_size_thumbnail_enabled'] = $options['custom_size_thumbnail_enabled'];
94
- $thumb_options['custom_thumbnail_width'] = $options['custom_thumbnail_width'];
95
- $thumb_options['custom_thumbnail_height'] = $options['custom_thumbnail_height'];
96
- }
97
- if (wp_rp_is_phone()) {
98
- return $options['mobile'];
99
- }
100
- return $options['desktop'] + $thumb_options;
101
- }
102
-
103
- function wp_rp_ajax_load_articles_callback() {
104
- global $post;
105
-
106
- $getdata = stripslashes_deep($_GET);
107
- if (!isset($getdata['post_id'])) {
108
- die('error');
109
- }
110
-
111
- $post = get_post($getdata['post_id']);
112
- if(!$post) {
113
- die('error');
114
- }
115
-
116
- $from = (isset($getdata['from']) && is_numeric($getdata['from'])) ? intval($getdata['from']) : 0;
117
- $count = (isset($getdata['count']) && is_numeric($getdata['count'])) ? intval($getdata['count']) : 50;
118
-
119
- $search = isset($getdata['search']) && $getdata['search'] ? $getdata['search'] : false;
120
-
121
- $image_size = isset($getdata['size']) ? $getdata['size'] : 'thumbnail';
122
- if(!($image_size == 'thumbnail' || $image_size == 'full')) {
123
- die('error');
124
- }
125
-
126
- $limit = $count + $from;
127
-
128
- if ($search) {
129
- $the_query = new WP_Query(array(
130
- 's' => $search,
131
- 'post_type' => 'post',
132
- 'post_status'=>'publish',
133
- 'post_count' => $limit));
134
- $related_posts = $the_query->get_posts();
135
- } else {
136
- $related_posts = array();
137
- wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts_v2', $limit);
138
- wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts', $limit);
139
- wp_rp_append_posts($related_posts, 'wp_rp_fetch_random_posts', $limit);
140
- }
141
-
142
- if(function_exists('qtrans_postsFilter')) {
143
- $related_posts = qtrans_postsFilter($related_posts);
144
- }
145
-
146
- $response_list = array();
147
-
148
- foreach (array_slice($related_posts, $from) as $related_post) {
149
- array_push($response_list, array(
150
- 'id' => $related_post->ID,
151
- 'url' => get_permalink($related_post->ID),
152
- 'title' => $related_post->post_title,
153
- 'excerpt' => $related_post->post_excerpt,
154
- 'date' => $related_post->post_date,
155
- 'comments' => $related_post->comment_count,
156
- 'img' => wp_rp_get_post_thumbnail_img($related_post, $image_size)
157
- ));
158
- }
159
-
160
- header('Content-Type: text/javascript');
161
- die(json_encode($response_list));
162
- }
163
- add_action('wp_ajax_wp_rp_load_articles', 'wp_rp_ajax_load_articles_callback');
164
- add_action('wp_ajax_nopriv_wp_rp_load_articles', 'wp_rp_ajax_load_articles_callback');
165
-
166
- function wp_rp_append_posts(&$related_posts, $fetch_function_name, $limit) {
167
- $options = wp_rp_get_options();
168
-
169
- $len = sizeof($related_posts);
170
- $num_missing_posts = $limit - $len;
171
- if ($num_missing_posts > 0) {
172
- $exclude_ids = array_map(create_function('$p', 'return $p->ID;'), $related_posts);
173
-
174
- $posts = call_user_func($fetch_function_name, $num_missing_posts, $exclude_ids);
175
- if ($posts) {
176
- $related_posts = array_merge($related_posts, $posts);
177
- }
178
- }
179
- }
180
-
181
- function wp_rp_fetch_posts_and_title() {
182
- $options = wp_rp_get_options();
183
-
184
- $limit = $options['max_related_posts'];
185
- $title = $options["related_posts_title"];
186
-
187
- $related_posts = array();
188
-
189
- wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts_v2', $limit);
190
- wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts', $limit);
191
- wp_rp_append_posts($related_posts, 'wp_rp_fetch_random_posts', $limit);
192
-
193
- if(function_exists('qtrans_postsFilter')) {
194
- $related_posts = qtrans_postsFilter($related_posts);
195
- }
196
-
197
- return array(
198
- "posts" => $related_posts,
199
- "title" => $title
200
- );
201
- }
202
-
203
- function wp_rp_get_next_post(&$related_posts, &$selected_related_posts, &$inserted_urls, &$special_urls, $default_post_type) {
204
- $post = false;
205
-
206
- while (!($post && $post->ID) && !(empty($related_posts) && empty($selected_related_posts))) {
207
- $post_type = $default_post_type;
208
-
209
- $post = array_shift($selected_related_posts);
210
-
211
- if ($post && $post->type) {
212
- $post_type = $post->type;
213
- }
214
-
215
- if (!$post || !$post->ID) {
216
- while (!empty($related_posts) && (!($post = array_shift($related_posts)) || isset($special_urls[get_permalink($post->ID)])));
217
- }
218
-
219
- if ($post && $post->ID) {
220
- $post_url = property_exists($post, 'post_url') ? $post->post_url : get_permalink($post->ID);
221
- if (isset($inserted_urls[$post_url])) {
222
- $post = false;
223
- } else {
224
- $post->type = $post_type;
225
- }
226
- }
227
- }
228
-
229
- if (!$post || !$post->ID) {
230
- return false;
231
- }
232
-
233
- $inserted_urls[$post_url] = true;
234
-
235
- return $post;
236
- }
237
-
238
- function wp_rp_generate_related_posts_list_items($related_posts, $selected_related_posts) {
239
- $options = wp_rp_get_options();
240
- $platform_options = wp_rp_get_platform_options();
241
- $output = "";
242
-
243
- $statistics_enabled = $options['ctr_dashboard_enabled'];
244
-
245
- $limit = $options['max_related_posts'];
246
-
247
- $inserted_urls = array(); // Used to prevent duplicates
248
- $special_urls = array();
249
-
250
- foreach ($selected_related_posts as $post) {
251
- if (property_exists($post, 'post_url') && $post->post_url) {
252
- $special_urls[$post->post_url] = true;
253
- }
254
- }
255
-
256
- $default_post_type = empty($selected_related_posts) ? 'none' : 'empty';
257
-
258
- $image_size = ($platform_options['theme_name'] == 'pinterest.css') ? 'full' : 'thumbnail';
259
-
260
- for ($i = 0; $i < $limit; $i++) {
261
- $related_post = wp_rp_get_next_post($related_posts, $selected_related_posts, $inserted_urls, $special_urls, $default_post_type);
262
-
263
- if (!$related_post) {
264
- break;
265
- }
266
-
267
- if (property_exists($related_post, 'type')) {
268
- $post_type = $related_post->type;
269
- } else {
270
- $post_type = $default_post_type;
271
- }
272
-
273
- if (in_array($post_type, array('empty', 'none'))) {
274
- $post_id = 'in-' . $related_post->ID;
275
- } else {
276
- $post_id = 'ex-' . $related_post->ID;
277
- }
278
-
279
- $data_attrs = '';
280
- if ($statistics_enabled) {
281
- $data_attrs .= 'data-position="' . $i . '" data-poid="' . $post_id . '" data-post-type="' . $post_type . '" ';
282
- }
283
-
284
- $output .= '<li ' . $data_attrs . '>';
285
-
286
- $post_url = property_exists($related_post, 'post_url') ? $related_post->post_url : get_permalink($related_post->ID);
287
-
288
- $img = wp_rp_get_post_thumbnail_img($related_post, $image_size);
289
- if ($img) {
290
- $output .= '<a href="' . $post_url . '" class="wp_rp_thumbnail">' . $img . '</a>';
291
- }
292
-
293
- if ($platform_options["display_publish_date"]) {
294
- $dateformat = get_option('date_format');
295
- $output .= '<small class="wp_rp_publish_date">' . mysql2date($dateformat, $related_post->post_date) . '</small> ';
296
- //$output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
297
- }
298
-
299
- $output .= '<a href="' . $post_url . '" class="wp_rp_title">' . wptexturize($related_post->post_title) . '</a>';
300
-
301
- if ($platform_options["display_comment_count"] && property_exists($related_post, 'comment_count')){
302
- $output .= '<small class="wp_rp_comments_count"> (' . $related_post->comment_count . ')</small><br />';
303
- }
304
-
305
- if ($platform_options["display_excerpt"]){
306
- $excerpt_max_length = $platform_options["excerpt_max_length"];
307
- $excerpt = '';
308
-
309
- if ($related_post->post_excerpt){
310
- $excerpt = strip_shortcodes(strip_tags($related_post->post_excerpt));
311
- }
312
- if (!$excerpt) {
313
- $excerpt = strip_shortcodes(strip_tags($related_post->post_content));
314
- }
315
-
316
- if ($excerpt) {
317
- if (strlen($excerpt) > $excerpt_max_length) {
318
- $excerpt = mb_substr($excerpt, 0, $excerpt_max_length - 3) . '...';
319
- }
320
- $output .= ' <small class="wp_rp_excerpt">' . $excerpt . '</small>';
321
- }
322
- }
323
- $output .= '</li>';
324
- }
325
-
326
- return $output;
327
- }
328
-
329
- function wp_rp_should_exclude() {
330
- global $wpdb, $post;
331
-
332
- if (!$post || !$post->ID) {
333
- return true;
334
- }
335
-
336
- $options = wp_rp_get_options();
337
-
338
- if(!$options['exclude_categories']) { return false; }
339
-
340
- $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'] . ')';
341
-
342
- $result = $wpdb->get_col($q);
343
-
344
- $count = (int) $result[0];
345
-
346
- return $count > 0;
347
- }
348
-
349
- function wp_rp_ajax_blogger_network_blacklist_callback() {
350
- check_ajax_referer('wp_rp_ajax_nonce');
351
- if (!current_user_can('delete_users')) {
352
- die();
353
- }
354
-
355
- $sourcefeed = (int) $_GET['sourcefeed'];
356
-
357
- $meta = wp_rp_get_meta();
358
-
359
- $blog_id = $meta['blog_id'];
360
- $auth_key = $meta['auth_key'];
361
- $req_options = array(
362
- 'timeout' => 5
363
- );
364
- $url = WP_RP_CTR_DASHBOARD_URL . "blacklist/?blog_id=$blog_id&auth_key=$auth_key&sfid=$sourcefeed";
365
- $response = wp_remote_get($url, $req_options);
366
-
367
- if (wp_remote_retrieve_response_code($response) == 200) {
368
- $body = wp_remote_retrieve_body($response);
369
- if ($body) {
370
- $doc = json_decode($body);
371
- if ($doc && $doc->status === 'ok') {
372
- header('Content-Type: text/javascript');
373
- echo "if(window['_wp_rp_blacklist_callback$sourcefeed']) window._wp_rp_blacklist_callback$sourcefeed();";
374
- }
375
- }
376
- }
377
- die();
378
- }
379
-
380
- add_action('wp_ajax_rp_blogger_network_blacklist', 'wp_rp_ajax_blogger_network_blacklist_callback');
381
-
382
- function wp_rp_head_resources() {
383
- global $post, $wpdb;
384
-
385
- //error_log("call to wp_rp_head_resources");
386
-
387
- if (wp_rp_should_exclude()) {
388
- return;
389
- }
390
-
391
- $meta = wp_rp_get_meta();
392
- $options = wp_rp_get_options();
393
- $platform_options = wp_rp_get_platform_options();
394
- //error_log('theme name 1: ' . $platform_options['theme_name']);
395
- $statistics_enabled = false;
396
- $remote_recommendations = false;
397
- $output = '';
398
-
399
- if (is_single()) {
400
- $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
401
- $remote_recommendations = $meta['remote_recommendations'] && $statistics_enabled;
402
- }
403
-
404
- $output_vars = "\twindow._wp_rp_static_base_url = '" . esc_js(WP_RP_STATIC_BASE_URL) . "';\n" .
405
- "\twindow._wp_rp_wp_ajax_url = \"" . admin_url('admin-ajax.php') . "\";\n" .
406
- "\twindow._wp_rp_plugin_version = '" . WP_RP_VERSION . "';\n" .
407
- "\twindow._wp_rp_post_id = '" . esc_js($post->ID) . "';\n" .
408
- "\twindow._wp_rp_num_rel_posts = '" . $options['max_related_posts'] . "';\n";
409
-
410
-
411
- if ($statistics_enabled) {
412
- $tags = $wpdb->get_col("SELECT DISTINCT(label) FROM " . $wpdb->prefix . "wp_rp_tags WHERE post_id=$post->ID ORDER BY weight desc;", 0);
413
- if (!empty($tags)) {
414
- $post_tags = '[' . implode(', ', array_map(create_function('$v', 'return "\'" . urlencode(substr($v, strpos($v, \'_\') + 1)) . "\'";'), $tags)) . ']';
415
- } else {
416
- $post_tags = '[]';
417
- }
418
-
419
- $output_vars .= "\twindow._wp_rp_blog_id = '" . esc_js($meta['blog_id']) . "';\n" .
420
- "\twindow._wp_rp_thumbnails = " . ($platform_options['display_thumbnail'] ? 'true' : 'false') . ";\n" .
421
- "\twindow._wp_rp_post_title = '" . urlencode($post->post_title) . "';\n" .
422
- "\twindow._wp_rp_post_tags = {$post_tags};\n" .
423
- "\twindow._wp_rp_remote_recommendations = " . ($remote_recommendations ? 'true' : 'false') . ";\n" .
424
- "\twindow._wp_rp_promoted_content = " . ($options['promoted_content_enabled'] ? 'true' : 'false') . ";\n" .
425
- "\twindow._wp_rp_traffic_exchange = " . ($options['traffic_exchange_enabled'] ? 'true' : 'false') . ";\n" .
426
- (current_user_can('edit_posts') ?
427
- "\twindow._wp_rp_admin_ajax_url = '" . admin_url('admin-ajax.php') . "';\n" .
428
- "\twindow._wp_rp_plugin_static_base_url = '" . esc_js(plugins_url('static/' , __FILE__)) . "';\n" .
429
- "\twindow._wp_rp_ajax_nonce = '" . wp_create_nonce("wp_rp_ajax_nonce") . "';\n" .
430
- "\twindow._wp_rp_erp_search = true;\n"
431
- : '');
432
- }
433
-
434
- $output .= "<script type=\"text/javascript\">\n" . $output_vars . "</script>\n";
435
-
436
- if($statistics_enabled) {
437
- $output .= '<script type="text/javascript" src="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_LOADER_FILE . '?version=' . WP_RP_VERSION . '" async></script>' . "\n";
438
- }
439
-
440
- if ($options['enable_themes']) {
441
- $theme_url = plugins_url(WP_RP_STATIC_THEMES_PATH, __FILE__);
442
-
443
- if ($platform_options['theme_name'] !== 'plain.css' && $platform_options['theme_name'] !== 'm-plain.css') {
444
- $output .= '<link rel="stylesheet" href="' . $theme_url . $platform_options['theme_name'] . '?version=' . WP_RP_VERSION . '" />' . "\n";
445
- }
446
-
447
- if ($platform_options['custom_theme_enabled']) {
448
- $output .= '<style type="text/css">' . "\n" . $platform_options['theme_custom_css'] . "</style>\n";
449
- }
450
-
451
- if ($platform_options['theme_name'] === 'm-stream.css') {
452
- wp_enqueue_script('wp_rp_infiniterecs', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_INFINITE_RECS_JS_FILE, array('jquery'), WP_RP_VERSION);
453
- }
454
-
455
- if ($platform_options['theme_name'] === 'pinterest.css') {
456
- wp_enqueue_script('wp_rp_pinterest', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_PINTEREST_JS_FILE, array('jquery'), WP_RP_VERSION);
457
- }
458
  }
459
-
460
- if (current_user_can('edit_posts') && $statistics_enabled) {
461
- wp_enqueue_style('wp_rp_edit_related_posts_css', WP_RP_STATIC_BASE_URL . 'wp-rp-css/edit_related_posts.css', array(), WP_RP_VERSION);
462
- wp_enqueue_script('wp_rp_edit_related_posts_js', WP_RP_STATIC_BASE_URL . 'js/edit_related_posts.js', array('jquery'), WP_RP_VERSION);
463
- }
464
-
465
- echo $output;
466
- }
467
-
468
- function wp_rp_get_selected_posts() {
469
- global $post;
470
-
471
- $selected_related_posts = get_post_meta($post->ID, '_wp_rp_selected_related_posts');
472
- if (empty($selected_related_posts)) {
473
- return array();
474
  }
475
-
476
- $selected_related_posts = $selected_related_posts[0];
477
- if (empty($selected_related_posts)) {
478
- return array();
479
  }
480
-
481
- $options = wp_rp_get_options();
482
- $limit = $options['max_related_posts'];
483
-
484
- return array_slice((array)$selected_related_posts, 0, $limit);
485
  }
486
-
487
- global $wp_rp_is_first_widget;
488
- $wp_rp_is_first_widget = true;
489
- function wp_rp_get_related_posts($before_title = '', $after_title = '') {
490
- if (wp_rp_should_exclude()) {
491
- return;
492
- }
493
-
494
- global $post, $wp_rp_is_first_widget;
495
- global $wp_rp_test_group; // used for AB testing on mobile
496
-
497
- $options = wp_rp_get_options();
498
- $platform_options = wp_rp_get_platform_options();
499
- $meta = wp_rp_get_meta();
500
-
501
- $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
502
- $remote_recommendations = is_single() && $meta['remote_recommendations'] && $statistics_enabled;
503
-
504
- $posts_and_title = wp_rp_fetch_posts_and_title();
505
- $related_posts = $posts_and_title['posts'];
506
- $title = $posts_and_title['title'];
507
-
508
- $selected_related_posts = wp_rp_get_selected_posts();
509
-
510
- $related_posts_content = "";
511
-
512
- if (!$related_posts) {
513
- return;
514
- }
515
-
516
- $posts_footer = '';
517
- if (current_user_can($options['only_admins_can_edit_related_posts'] ? 'manage_options' : 'edit_posts') && $statistics_enabled) {
518
- $posts_footer .= '<div class="wp_rp_footer"><a class="wp_rp_edit" href="#" id="wp_rp_edit_related_posts">Edit Related Posts</a></div>';
519
  }
520
- if ($options['display_zemanta_linky']) {
521
- $posts_footer .= '<div class="wp_rp_footer"><a class="wp_rp_backlink" target="_blank" href="http://www.zemanta.com/?wp-related-posts" rel="nofollow">Zemanta</a></div>';
522
- }
523
-
524
- $css_classes = 'related_post wp_rp';
525
- $css_classes_wrap = ' ' . str_replace(array('.css', '-'), array('', '_'), esc_attr('wp_rp_' . $platform_options['theme_name']));
526
-
527
- $related_posts_lis = wp_rp_generate_related_posts_list_items($related_posts, $selected_related_posts);
528
- $related_posts_ul = '<ul class="' . $css_classes . '" style="visibility: ' . ($remote_recommendations ? 'hidden' : 'visible') . '">' . $related_posts_lis . '</ul>';
529
-
530
- $related_posts_title = $title ? ($before_title ? $before_title . $title . $after_title : '<h3 class="related_post_title">' . $title . '</h3>') : '';
531
-
532
- $first_id_attr = '';
533
- if($wp_rp_is_first_widget) {
534
- $wp_rp_is_first_widget = false;
535
- $first_id_attr = 'id="wp_rp_first"';
536
- }
537
-
538
- $wrap_style = '';
539
- //error_log('test group when content:' . $wp_rp_test_group);
540
- if ($wp_rp_test_group == 2) {
541
- $wrap_style = ' style="display:none;"';
542
- }
543
-
544
- $output = '<div class="wp_rp_wrap ' . $css_classes_wrap . '" ' . $first_id_attr . $wrap_style . '>' .
545
- '<div class="wp_rp_content">' .
546
- $related_posts_title .
547
- $related_posts_ul .
548
- $posts_footer .
549
- '</div>' .
550
- ($remote_recommendations ? '<script type="text/javascript">window._wp_rp_callback_widget_exists ? window._wp_rp_callback_widget_exists() : false;</script>' : '') .
551
- '</div>';
552
-
553
- return "\n" . $output . "\n";
554
  }
555
 
1
  <?php
2
  /*
3
  Plugin Name: WordPress Related Posts
4
+ Version: 3.3.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. Click on <a href="admin.php?page=wordpress-related-posts">Related Posts tab</a> to configure your settings.
7
  Author: Zemanta Ltd.
8
  Author URI: http://www.zemanta.com
9
  */
10
 
11
+ if (! function_exists('wp_rp_init_zemanta')) {
12
+ function wp_rp_init_error() {
13
+ ?>
14
+ <div class="updated">
15
+ <p><?php _e('Wordpress Related Posts couldn\'t initialize.'); ?></p>
16
+ </div>
17
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
+
20
+ try {
21
+ include_once(dirname(__FILE__) . '/init.php');
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
+ catch (Exception $e) {
24
+ add_action( 'admin_notices', 'wp_rp_init_error' );
 
 
25
  }
 
 
 
 
 
26
  }
27
+ else {
28
+ function wp_rp_multiple_plugins_notice() {
29
+ ?>
30
+ <div class="updated">
31
+ <p><?php _e( 'Oh, it\'s OK, looks like you\'ve already got one related posts plugin installed, so no need for another one.', 'wp_wp_related_posts' ); ?></p>
32
+ </div>
33
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
+ add_action( 'admin_notices', 'wp_rp_multiple_plugins_notice' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
 
zemanta/views/assets.php CHANGED
@@ -1,30 +1,30 @@
1
- <?php
2
-
3
- global $wp_version;
4
-
5
- ?>
6
- <script type="text/javascript">
7
- //<![CDATA[
8
- window.ZemantaGetAPIKey = function () {
9
- return '<?php echo $api_key; ?>';
10
- };
11
-
12
- window.ZemantaPluginVersion = function () {
13
- return '<?php echo $version; ?>';
14
- };
15
-
16
- window.ZemantaPluginType = function () {
17
- return 'gp';
18
- };
19
-
20
- window.ZemantaPluginFeatures = {
21
- <?php
22
- for($i = 0, $keys = array_keys($features), $len = sizeof($keys); $i < $len; $i++) :
23
- echo "\t'" . $keys[$i] . "': " . json_encode($features[$keys[$i]]) . ($i < $len-1 ? ',' : '') . "\n";
24
- endfor;
25
- ?>
26
- };
27
- //]]>
28
- </script>
29
-
30
- <script type="text/javascript" id="zemanta-loader" src="http://fstatic.zemanta.com/plugins/wordpress-wprp/loader.js"></script>
1
+ <?php
2
+
3
+ global $wp_version;
4
+
5
+ ?>
6
+ <script type="text/javascript">
7
+ //<![CDATA[
8
+ window.ZemantaGetAPIKey = function () {
9
+ return '<?php echo $api_key; ?>';
10
+ };
11
+
12
+ window.ZemantaPluginVersion = function () {
13
+ return '<?php echo $version; ?>';
14
+ };
15
+
16
+ window.ZemantaPluginType = function () {
17
+ return 'gp';
18
+ };
19
+
20
+ window.ZemantaPluginFeatures = {
21
+ <?php
22
+ for($i = 0, $keys = array_keys($features), $len = sizeof($keys); $i < $len; $i++) :
23
+ echo "\t'" . $keys[$i] . "': " . json_encode($features[$keys[$i]]) . ($i < $len-1 ? ',' : '') . "\n";
24
+ endfor;
25
+ ?>
26
+ };
27
+ //]]>
28
+ </script>
29
+
30
+ <script type="text/javascript" id="zemanta-loader" src="http://fstatic.zemanta.com/plugins/wordpress-wprp/loader.js"></script>
zemanta/views/debug.php CHANGED
@@ -1,26 +1,26 @@
1
-
2
- <div class="wrap">
3
-
4
- <h2><?php _e('Zemanta Plugin Status', 'zemanta'); ?></h2>
5
-
6
- <p>
7
- <?php _e('API key (if you have one, your WordPress can talk to Zemanta)', 'zemanta'); ?>: <strong><?php echo $api_key; ?></strong>
8
- </p>
9
-
10
- <p>
11
- <?php _e('Zemanta API Status', 'zemanta'); ?>
12
-
13
- <strong>
14
- <?php if ($api_test == 'ok'): ?>
15
-
16
- <span style="color: green;"><?php _e('OK', 'zemanta'); ?></span>
17
-
18
- <?php else: ?>
19
-
20
- <span style="color: red;"><?php _e('Failure', 'zemanta'); ?></span>
21
-
22
- <?php endif; ?>
23
- </strong>
24
- </p>
25
-
26
  </div>
1
+
2
+ <div class="wrap">
3
+
4
+ <h2><?php _e('Zemanta Plugin Status', 'zemanta'); ?></h2>
5
+
6
+ <p>
7
+ <?php _e('API key (if you have one, your WordPress can talk to Zemanta)', 'zemanta'); ?>: <strong><?php echo $api_key; ?></strong>
8
+ </p>
9
+
10
+ <p>
11
+ <?php _e('Zemanta API Status', 'zemanta'); ?>
12
+
13
+ <strong>
14
+ <?php if ($api_test == 'ok'): ?>
15
+
16
+ <span style="color: green;"><?php _e('OK', 'zemanta'); ?></span>
17
+
18
+ <?php else: ?>
19
+
20
+ <span style="color: red;"><?php _e('Failure', 'zemanta'); ?></span>
21
+
22
+ <?php endif; ?>
23
+ </strong>
24
+ </p>
25
+
26
  </div>
zemanta/views/message.php CHANGED
@@ -1,9 +1,9 @@
1
-
2
-
3
- <div class="<?php echo $type; ?>">
4
-
5
- <p>
6
- <strong><?php echo $message; ?></strong>
7
- </p>
8
-
9
  </div>
1
+
2
+
3
+ <div class="<?php echo $type; ?>">
4
+
5
+ <p>
6
+ <strong><?php echo $message; ?></strong>
7
+ </p>
8
+
9
  </div>
zemanta/views/options-input-apikey.php CHANGED
@@ -1,14 +1,14 @@
1
-
2
- <?php if(isset($title)): ?>
3
- <label class="option-label" for="zemanta_options_<?php echo $field; ?>"><?php echo $title; ?></label>
4
- <?php endif; ?>
5
-
6
- <input id="zemanta_options_<?php echo $field; ?>" class="regular-text code" name="zemanta_options[<?php echo $field; ?>]" size="40" type="text" value="<?php echo isset($option) && !empty($option) ? $option : (isset($default_value) ? $default_value : ''); ?>"<?php if(isset($disabled) && $disabled) : ?> disabled="disabled"<?php endif; ?> />
7
-
8
- <?php if (isset($description)): ?>
9
-
10
- <p class="description">
11
- <?php echo $description; ?>
12
- </p>
13
-
14
  <?php endif; ?>
1
+
2
+ <?php if(isset($title)): ?>
3
+ <label class="option-label" for="zemanta_options_<?php echo $field; ?>"><?php echo $title; ?></label>
4
+ <?php endif; ?>
5
+
6
+ <input id="zemanta_options_<?php echo $field; ?>" class="regular-text code" name="zemanta_options[<?php echo $field; ?>]" size="40" type="text" value="<?php echo isset($option) && !empty($option) ? $option : (isset($default_value) ? $default_value : ''); ?>"<?php if(isset($disabled) && $disabled) : ?> disabled="disabled"<?php endif; ?> />
7
+
8
+ <?php if (isset($description)): ?>
9
+
10
+ <p class="description">
11
+ <?php echo $description; ?>
12
+ </p>
13
+
14
  <?php endif; ?>
zemanta/views/options-input-checkbox.php CHANGED
@@ -1,18 +1,18 @@
1
-
2
- <input id="zemanta_options_<?php echo $field; ?>" name="zemanta_options[<?php echo $field; ?>]" type="checkbox" value="1" <?php echo isset($option) && !empty($option) ? 'checked="checked"' : ''; ?><?php if(isset($disabled) && $disabled) : ?> disabled="disabled"<?php endif; ?> />
3
-
4
- <?php if (isset($title)): ?>
5
-
6
- <label for="zemanta_options_<?php echo $field; ?>">
7
- <?php echo $title; ?>
8
- </label>
9
-
10
- <?php endif; ?>
11
-
12
- <?php if (isset($description)): ?>
13
-
14
- <p>
15
- <?php echo $description; ?>
16
- </p>
17
-
18
  <?php endif; ?>
1
+
2
+ <input id="zemanta_options_<?php echo $field; ?>" name="zemanta_options[<?php echo $field; ?>]" type="checkbox" value="1" <?php echo isset($option) && !empty($option) ? 'checked="checked"' : ''; ?><?php if(isset($disabled) && $disabled) : ?> disabled="disabled"<?php endif; ?> />
3
+
4
+ <?php if (isset($title)): ?>
5
+
6
+ <label for="zemanta_options_<?php echo $field; ?>">
7
+ <?php echo $title; ?>
8
+ </label>
9
+
10
+ <?php endif; ?>
11
+
12
+ <?php if (isset($description)): ?>
13
+
14
+ <p>
15
+ <?php echo $description; ?>
16
+ </p>
17
+
18
  <?php endif; ?>
zemanta/views/options-input-text.php CHANGED
@@ -1,10 +1,10 @@
1
-
2
- <input id="zemanta_options_<?php echo $field; ?>" name="zemanta_options[<?php echo $field; ?>]" size="40" type="text" value="<?php echo isset($option) && !empty($option) ? $option : (isset($default_value) ? $default_value : ''); ?>"<?php if(isset($disabled) && $disabled) : ?> disabled="disabled"<?php endif; ?> />
3
-
4
- <?php if (isset($description)): ?>
5
-
6
- <span class="description">
7
- <?php echo $description; ?>
8
- </span>
9
-
10
  <?php endif; ?>
1
+
2
+ <input id="zemanta_options_<?php echo $field; ?>" name="zemanta_options[<?php echo $field; ?>]" size="40" type="text" value="<?php echo isset($option) && !empty($option) ? $option : (isset($default_value) ? $default_value : ''); ?>"<?php if(isset($disabled) && $disabled) : ?> disabled="disabled"<?php endif; ?> />
3
+
4
+ <?php if (isset($description)): ?>
5
+
6
+ <span class="description">
7
+ <?php echo $description; ?>
8
+ </span>
9
+
10
  <?php endif; ?>
zemanta/views/options.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php include(dirname(__FILE__) . '/stylesheet.php'); ?>
2
- <?php include(dirname(__FILE__) . '/scripts.php'); ?>
3
-
4
- <div class="wrap" id="wp-zemanta">
5
-
6
- <div class="logo"><img src="<?php echo plugins_url('/img/logo.png', dirname(__FILE__)); ?>" alt="Zemanta | social blogging" /></div>
7
-
8
- <div class="cols clearfix">
9
- <div class="col-left">
10
- <div class="video">
11
- <iframe src="http://player.vimeo.com/video/46745200?title=0&amp;byline=0&amp;portrait=0" width="100%" height="280px" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
12
- </div>
13
- <p>
14
- <a href="http://prefs.zemanta.com/" target="_blank" class="signin-button prefs-signin">Sign In</a>
15
- </p>
16
- <p class="below-signin-button"><a href="http://prefs.zemanta.com/" target="_blank" class="prefs-signin">to check stats, change settings and more</a></p>
17
- </div>
18
- <div class="col-right">
19
- <div id="tweets_div"></div>
20
- </div>
21
- </div>
22
-
23
- <form action="options.php" method="post" class="settings-form">
24
- <?php settings_fields('zemanta_options'); ?>
25
- <?php do_settings_sections('zemanta'); ?>
26
- <?php do_action('zemanta_options_form'); ?>
27
-
28
- <?php if(!$is_pro) : ?>
29
- <p class="submit">
30
- <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" class="button-primary" />
31
- </p>
32
- <?php endif; ?>
33
-
34
- </form>
35
-
36
- </div>
1
+ <?php include(dirname(__FILE__) . '/stylesheet.php'); ?>
2
+ <?php include(dirname(__FILE__) . '/scripts.php'); ?>
3
+
4
+ <div class="wrap" id="wp-zemanta">
5
+
6
+ <div class="logo"><img src="<?php echo plugins_url('/img/logo.png', dirname(__FILE__)); ?>" alt="Zemanta | social blogging" /></div>
7
+
8
+ <div class="cols clearfix">
9
+ <div class="col-left">
10
+ <div class="video">
11
+ <iframe src="http://player.vimeo.com/video/46745200?title=0&amp;byline=0&amp;portrait=0" width="100%" height="280px" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
12
+ </div>
13
+ <p>
14
+ <a href="http://prefs.zemanta.com/" target="_blank" class="signin-button prefs-signin">Sign In</a>
15
+ </p>
16
+ <p class="below-signin-button"><a href="http://prefs.zemanta.com/" target="_blank" class="prefs-signin">to check stats, change settings and more</a></p>
17
+ </div>
18
+ <div class="col-right">
19
+ <div id="tweets_div"></div>
20
+ </div>
21
+ </div>
22
+
23
+ <form action="options.php" method="post" class="settings-form">
24
+ <?php settings_fields('zemanta_options'); ?>
25
+ <?php do_settings_sections('zemanta'); ?>
26
+ <?php do_action('zemanta_options_form'); ?>
27
+
28
+ <?php if(!$is_pro) : ?>
29
+ <p class="submit">
30
+ <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" class="button-primary" />
31
+ </p>
32
+ <?php endif; ?>
33
+
34
+ </form>
35
+
36
+ </div>
zemanta/views/scripts.php CHANGED
@@ -1,72 +1,72 @@
1
-
2
- <script type="text/javascript">
3
- // settings page
4
- jQuery(document).ready(function ($) {
5
-
6
- // obtain username by apikey and replace signin links with baked URL
7
- (function () {
8
- var api_key = "<?php echo esc_js($api_key); ?>",
9
- get_prefs_url = function (api_key) {
10
- var params = {
11
- method: 'zemanta.preferences',
12
- api_key: api_key,
13
- format: 'json'
14
- };
15
- $.post('http://api.zemanta.com/services/rest/0.0/', params, function (data) {
16
- if (data && data.config_url) {
17
- $('a.prefs-signin').attr('href', data.config_url);
18
- }
19
- });
20
- };
21
-
22
- if(api_key.length) {
23
- get_prefs_url(api_key);
24
- }
25
- }());
26
-
27
- // init twitter widget
28
- $.getScript('http://widgets.twimg.com/j/2/widget.js', function () {
29
- new TWTR.Widget({
30
- version: 2,
31
- type: 'profile',
32
- rpp: 4,
33
- interval: 30000,
34
- width: 250,
35
- height: 300,
36
- id: 'tweets_div',
37
- theme: {
38
- shell: {
39
- background: '#90a6b5',
40
- color: '#ffffff'
41
- },
42
- tweets: {
43
- background: '#ffffff',
44
- color: '#000000',
45
- links: '#f68720'
46
- }
47
- },
48
- features: {
49
- scrollbar: true,
50
- loop: false,
51
- live: true,
52
- behavior: 'all'
53
- }
54
- }).render().setUser('ZemantaSupport').start();
55
- });
56
-
57
- // init "path" fields
58
- $('.basepath').each(function () {
59
- var n = $(this).next('input');
60
- n.css('padding-left', parseInt($(this).width(),10)+2);
61
- $(this).click(function () {
62
- n.focus();
63
- });
64
- });
65
-
66
- // hide custom path field when checkbox is opt'd-out and setup initial state
67
- $('#zemanta_options_image_uploader_custom_path').click(function () {
68
- $('#zemanta_options_image_uploader_dir').parents('tr').toggle(!!$(this).attr('checked'));
69
- }).triggerHandler('click');
70
-
71
- });
72
- </script>
1
+
2
+ <script type="text/javascript">
3
+ // settings page
4
+ jQuery(document).ready(function ($) {
5
+
6
+ // obtain username by apikey and replace signin links with baked URL
7
+ (function () {
8
+ var api_key = "<?php echo esc_js($api_key); ?>",
9
+ get_prefs_url = function (api_key) {
10
+ var params = {
11
+ method: 'zemanta.preferences',
12
+ api_key: api_key,
13
+ format: 'json'
14
+ };
15
+ $.post('http://api.zemanta.com/services/rest/0.0/', params, function (data) {
16
+ if (data && data.config_url) {
17
+ $('a.prefs-signin').attr('href', data.config_url);
18
+ }
19
+ });
20
+ };
21
+
22
+ if(api_key.length) {
23
+ get_prefs_url(api_key);
24
+ }
25
+ }());
26
+
27
+ // init twitter widget
28
+ $.getScript('http://widgets.twimg.com/j/2/widget.js', function () {
29
+ new TWTR.Widget({
30
+ version: 2,
31
+ type: 'profile',
32
+ rpp: 4,
33
+ interval: 30000,
34
+ width: 250,
35
+ height: 300,
36
+ id: 'tweets_div',
37
+ theme: {
38
+ shell: {
39
+ background: '#90a6b5',
40
+ color: '#ffffff'
41
+ },
42
+ tweets: {
43
+ background: '#ffffff',
44
+ color: '#000000',
45
+ links: '#f68720'
46
+ }
47
+ },
48
+ features: {
49
+ scrollbar: true,
50
+ loop: false,
51
+ live: true,
52
+ behavior: 'all'
53
+ }
54
+ }).render().setUser('ZemantaSupport').start();
55
+ });
56
+
57
+ // init "path" fields
58
+ $('.basepath').each(function () {
59
+ var n = $(this).next('input');
60
+ n.css('padding-left', parseInt($(this).width(),10)+2);
61
+ $(this).click(function () {
62
+ n.focus();
63
+ });
64
+ });
65
+
66
+ // hide custom path field when checkbox is opt'd-out and setup initial state
67
+ $('#zemanta_options_image_uploader_custom_path').click(function () {
68
+ $('#zemanta_options_image_uploader_dir').parents('tr').toggle(!!$(this).attr('checked'));
69
+ }).triggerHandler('click');
70
+
71
+ });
72
+ </script>
zemanta/views/stylesheet.php CHANGED
@@ -1,107 +1,107 @@
1
- <style type="text/css">
2
- #wp-zemanta .clearfix:after {
3
- content: ".";
4
- display: block;
5
- clear: both;
6
- visibility: hidden;
7
- line-height: 0;
8
- height: 0;
9
- }
10
-
11
- #wp-zemanta .clearfix {
12
- display: inline-block;
13
- }
14
-
15
- html[xmlns] #wp-zemanta .clearfix {
16
- display: block;
17
- }
18
-
19
- * html #wp-zemanta .clearfix {
20
- height: 1%;
21
- }
22
-
23
- #wp-zemanta {
24
- margin:40px;
25
- width:830px;
26
- -webkit-box-sizing: border-box;
27
- -moz-box-sizing: border-box;
28
- box-sizing: border-box;
29
- }
30
-
31
- #wp-zemanta .logo {
32
- margin-bottom: 30px;
33
- }
34
-
35
- #wp-zemanta .cols {
36
- border-bottom: 1px solid #ccc;
37
- padding-bottom: 35px;
38
- margin-bottom: 35px;
39
- }
40
-
41
- #wp-zemanta .col-left,
42
- #wp-zemanta .col-right {
43
- float: left;
44
- min-height: 280px;
45
- -webkit-box-sizing: border-box;
46
- -moz-box-sizing: border-box;
47
- box-sizing: border-box;
48
- }
49
-
50
- #wp-zemanta .col-left {
51
- width: 530px;
52
- }
53
-
54
- #wp-zemanta .col-left iframe {
55
- display: block;
56
- }
57
-
58
- #wp-zemanta .col-left .video {
59
- background: #fff;
60
- border-top: 2px solid #de8124;
61
- -webkit-box-shadow: 0px 1px 4px rgba(50,50,50,.5);
62
- -moz-box-shadow: 0px 1px 4px rgba(50,50,50,.5);
63
- box-shadow: 0px 1px 4px rgba(50,50,50,.5);
64
- margin-bottom: 30px;
65
- }
66
-
67
- #wp-zemanta .col-right {
68
- width: 250px;
69
- margin-left: 50px;
70
- }
71
-
72
- #wp-zemanta .signin-button {
73
- display: block;
74
- width: 150px;
75
- line-height: 41px;
76
- height: 40px;
77
- margin:0 auto;
78
- text-align: center;
79
- color: #fff;
80
- text-shadow: 0 -1px 1px rgba(0,0,0,.5);
81
- text-decoration: none;
82
- font-size: 20px;
83
- font-weight: bold;
84
- -webkit-border-radius: 3px;
85
- -moz-border-radius: 3px;
86
- border-radius: 3px;
87
- background-color: #f79624;
88
- background-image: -webkit-gradient(linear, left top, left bottom, from(#f79624), to(#f57b1d)); /* Safari 4+, Chrome */
89
- background-image: -webkit-linear-gradient(top, #f79624, #f57b1d); /* Chrome 10+, Safari 5.1+, iOS 5+ */
90
- background-image: -moz-linear-gradient(top, #f79624, #f57b1d); /* Firefox 3.6-15 */
91
- background-image: -o-linear-gradient(top, #f79624, #f57b1d); /* Opera 11.10-12.00 */
92
- background-image: linear-gradient(to bottom, #f79624, #f57b1d); /* Firefox 16+, IE10, Opera 12.50+ */
93
- }
94
- #wp-zemanta .below-signin-button {text-align:center;}
95
- #wp-zemanta .below-signin-button a {
96
- color:#03b6e8;
97
- font-size: 1.4em;
98
- text-decoration: none;
99
- }
100
- #wp-zemanta .below-signin-button a:hover {text-decoration: underline;}
101
- #wp-zemanta .settings-form th, #wp-zemanta .settings-form h3 {display: none;}
102
- #wp-zemanta .settings-form .option-label {margin-bottom: 0px; display: block;}
103
- #wp-zemanta .settings-form td {padding: 0 0 8px 0;}
104
- #wp-zemanta .settings-form .basepath {position: absolute;margin-left: 5px;padding-top:3px;color:#aaa;}
105
- #wp-zemanta .settings-form .form-table {margin:0;}
106
- #wp-zemanta .settings-form p.submit {padding:0;}
107
- </style>
1
+ <style type="text/css">
2
+ #wp-zemanta .clearfix:after {
3
+ content: ".";
4
+ display: block;
5
+ clear: both;
6
+ visibility: hidden;
7
+ line-height: 0;
8
+ height: 0;
9
+ }
10
+
11
+ #wp-zemanta .clearfix {
12
+ display: inline-block;
13
+ }
14
+
15
+ html[xmlns] #wp-zemanta .clearfix {
16
+ display: block;
17
+ }
18
+
19
+ * html #wp-zemanta .clearfix {
20
+ height: 1%;
21
+ }
22
+
23
+ #wp-zemanta {
24
+ margin:40px;
25
+ width:830px;
26
+ -webkit-box-sizing: border-box;
27
+ -moz-box-sizing: border-box;
28
+ box-sizing: border-box;
29
+ }
30
+
31
+ #wp-zemanta .logo {
32
+ margin-bottom: 30px;
33
+ }
34
+
35
+ #wp-zemanta .cols {
36
+ border-bottom: 1px solid #ccc;
37
+ padding-bottom: 35px;
38
+ margin-bottom: 35px;
39
+ }
40
+
41
+ #wp-zemanta .col-left,
42
+ #wp-zemanta .col-right {
43
+ float: left;
44
+ min-height: 280px;
45
+ -webkit-box-sizing: border-box;
46
+ -moz-box-sizing: border-box;
47
+ box-sizing: border-box;
48
+ }
49
+
50
+ #wp-zemanta .col-left {
51
+ width: 530px;
52
+ }
53
+
54
+ #wp-zemanta .col-left iframe {
55
+ display: block;
56
+ }
57
+
58
+ #wp-zemanta .col-left .video {
59
+ background: #fff;
60
+ border-top: 2px solid #de8124;
61
+ -webkit-box-shadow: 0px 1px 4px rgba(50,50,50,.5);
62
+ -moz-box-shadow: 0px 1px 4px rgba(50,50,50,.5);
63
+ box-shadow: 0px 1px 4px rgba(50,50,50,.5);
64
+ margin-bottom: 30px;
65
+ }
66
+
67
+ #wp-zemanta .col-right {
68
+ width: 250px;
69
+ margin-left: 50px;
70
+ }
71
+
72
+ #wp-zemanta .signin-button {
73
+ display: block;
74
+ width: 150px;
75
+ line-height: 41px;
76
+ height: 40px;
77
+ margin:0 auto;
78
+ text-align: center;
79
+ color: #fff;
80
+ text-shadow: 0 -1px 1px rgba(0,0,0,.5);
81
+ text-decoration: none;
82
+ font-size: 20px;
83
+ font-weight: bold;
84
+ -webkit-border-radius: 3px;
85
+ -moz-border-radius: 3px;
86
+ border-radius: 3px;
87
+ background-color: #f79624;
88
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#f79624), to(#f57b1d)); /* Safari 4+, Chrome */
89
+ background-image: -webkit-linear-gradient(top, #f79624, #f57b1d); /* Chrome 10+, Safari 5.1+, iOS 5+ */
90
+ background-image: -moz-linear-gradient(top, #f79624, #f57b1d); /* Firefox 3.6-15 */
91
+ background-image: -o-linear-gradient(top, #f79624, #f57b1d); /* Opera 11.10-12.00 */
92
+ background-image: linear-gradient(to bottom, #f79624, #f57b1d); /* Firefox 16+, IE10, Opera 12.50+ */
93
+ }
94
+ #wp-zemanta .below-signin-button {text-align:center;}
95
+ #wp-zemanta .below-signin-button a {
96
+ color:#03b6e8;
97
+ font-size: 1.4em;
98
+ text-decoration: none;
99
+ }
100
+ #wp-zemanta .below-signin-button a:hover {text-decoration: underline;}
101
+ #wp-zemanta .settings-form th, #wp-zemanta .settings-form h3 {display: none;}
102
+ #wp-zemanta .settings-form .option-label {margin-bottom: 0px; display: block;}
103
+ #wp-zemanta .settings-form td {padding: 0 0 8px 0;}
104
+ #wp-zemanta .settings-form .basepath {position: absolute;margin-left: 5px;padding-top:3px;color:#aaa;}
105
+ #wp-zemanta .settings-form .form-table {margin:0;}
106
+ #wp-zemanta .settings-form p.submit {padding:0;}
107
+ </style>