WordPress Related Posts - Version 2.9

Version Description

  • Themes are now included with the plugin to simplify loading and customization
  • Simplified javascript loading
Download this release

Release Info

Developer zemanta-panco
Plugin Icon wp plugin WordPress Related Posts
Version 2.9
Comparing to
See all releases

Code changes from version 2.8 to 2.9

config.php CHANGED
@@ -1,580 +1,597 @@
1
- <?php
2
-
3
- define('WP_RP_STATIC_BASE_URL', 'http://dtmvdvtzf8rz0.cloudfront.net/static/');
4
- define('WP_RP_STATIC_THEMES_PATH', 'wp-rp-css/');
5
- define('WP_RP_STATIC_JSON_PATH', 'json/');
6
-
7
- define("WP_RP_DEFAULT_CUSTOM_CSS",
8
- ".related_post_title {
9
- }
10
- ul.related_post {
11
- }
12
- ul.related_post li {
13
- }
14
- ul.related_post li a {
15
- }
16
- ul.related_post li img {
17
- }");
18
-
19
- define('WP_RP_THUMBNAILS_NAME', 'wp_rp_thumbnail');
20
- define('WP_RP_THUMBNAILS_PROP_NAME', 'wp_rp_thumbnail_prop');
21
- define('WP_RP_THUMBNAILS_WIDTH', 150);
22
- define('WP_RP_THUMBNAILS_HEIGHT', 150);
23
- define('WP_RP_THUMBNAILS_DEFAULTS_COUNT', 31);
24
-
25
- define("WP_RP_MAX_LABEL_LENGTH", 32);
26
-
27
- define("WP_RP_CTR_DASHBOARD_URL", "http://d.zemanta.com/");
28
- define("WP_RP_STATIC_CTR_PAGEVIEW_FILE", "js/pageview.js");
29
-
30
- define("WP_RP_STATIC_RECOMMENDATIONS_JS_FILE", "js/recommendations.js");
31
- define("WP_RP_STATIC_RECOMMENDATIONS_CSS_FILE", "wp-rp-css/recommendations.css");
32
-
33
- define("WP_RP_STATIC_INFINITE_RECS_JS_FILE", "js/infiniterecs.js");
34
- define("WP_RP_STATIC_PINTEREST_JS_FILE", "js/pinterest.js");
35
-
36
- define("WP_RP_RECOMMENDATIONS_AUTO_TAGS_MAX_WORDS", 200);
37
- define("WP_RP_RECOMMENDATIONS_AUTO_TAGS_MAX_TAGS", 15);
38
-
39
- define("WP_RP_RECOMMENDATIONS_AUTO_TAGS_SCORE", 2);
40
- define("WP_RP_RECOMMENDATIONS_TAGS_SCORE", 10);
41
- define("WP_RP_RECOMMENDATIONS_CATEGORIES_SCORE", 5);
42
-
43
- define("WP_RP_RECOMMENDATIONS_NUM_PREGENERATED_POSTS", 50);
44
-
45
- define("WP_RP_THUMBNAILS_NUM_PREGENERATED_POSTS", 50);
46
-
47
- global $wp_rp_options, $wp_rp_meta;
48
- $wp_rp_options = false;
49
- $wp_rp_meta = false;
50
-
51
- function wp_rp_get_options() {
52
- global $wp_rp_options, $wp_rp_meta;
53
- if($wp_rp_options) {
54
- return $wp_rp_options;
55
- }
56
-
57
- $wp_rp_options = get_option('wp_rp_options', false);
58
- $wp_rp_meta = get_option('wp_rp_meta', false);
59
-
60
- if(!$wp_rp_meta || !$wp_rp_options || $wp_rp_meta['version'] !== WP_RP_VERSION) {
61
- wp_rp_upgrade();
62
- $wp_rp_meta = get_option('wp_rp_meta');
63
- $wp_rp_options = get_option('wp_rp_options');
64
- }
65
-
66
- $wp_rp_meta = new ArrayObject($wp_rp_meta);
67
- $wp_rp_options = new ArrayObject($wp_rp_options);
68
-
69
- return $wp_rp_options;
70
- }
71
-
72
- function wp_rp_get_meta() {
73
- global $wp_rp_meta;
74
-
75
- if (!$wp_rp_meta) {
76
- wp_rp_get_options();
77
- }
78
-
79
- return $wp_rp_meta;
80
- }
81
-
82
- function wp_rp_update_meta($new_meta) {
83
- global $wp_rp_meta;
84
-
85
- $new_meta = (array) $new_meta;
86
-
87
- $r = update_option('wp_rp_meta', $new_meta);
88
-
89
- if($r && $wp_rp_meta !== false) {
90
- $wp_rp_meta->exchangeArray($new_meta);
91
- }
92
-
93
- return $r;
94
- }
95
-
96
- function wp_rp_update_options($new_options) {
97
- global $wp_rp_options;
98
-
99
- $new_options = (array) $new_options;
100
-
101
- $r = update_option('wp_rp_options', $new_options);
102
-
103
- if($r && $wp_rp_options !== false) {
104
- $wp_rp_options->exchangeArray($new_options);
105
- }
106
-
107
- return $r;
108
- }
109
-
110
- function wp_rp_activate_hook() {
111
- wp_rp_get_options();
112
- wp_rp_schedule_notifications_cron();
113
- }
114
-
115
- function wp_rp_deactivate_hook() {
116
- wp_rp_unschedule_notifications_cron();
117
- }
118
-
119
- function wp_rp_upgrade() {
120
- $wp_rp_meta = get_option('wp_rp_meta', false);
121
- $version = false;
122
-
123
- if($wp_rp_meta) {
124
- $version = $wp_rp_meta['version'];
125
- } else {
126
- $wp_rp_old_options = get_option('wp_rp', false);
127
- if($wp_rp_old_options) {
128
- $version = '1.4';
129
- }
130
- }
131
-
132
- if($version) {
133
- if(version_compare($version, WP_RP_VERSION, '<')) {
134
- call_user_func('wp_rp_migrate_' . str_replace('.', '_', $version));
135
- wp_rp_upgrade();
136
- }
137
- } else {
138
- wp_rp_install();
139
- }
140
- }
141
-
142
- function wp_rp_related_posts_db_table_uninstall() {
143
- global $wpdb;
144
-
145
- $tags_table_name = $wpdb->prefix . "wp_rp_tags";
146
-
147
- $sql = "DROP TABLE " . $tags_table_name;
148
-
149
- $wpdb->query($sql);
150
- }
151
-
152
- function wp_rp_related_posts_db_table_install() {
153
- global $wpdb;
154
-
155
- $tags_table_name = $wpdb->prefix . "wp_rp_tags";
156
- $sql_tags = "CREATE TABLE $tags_table_name (
157
- post_id mediumint(9),
158
- post_date datetime NOT NULL,
159
- label VARCHAR(" . WP_RP_MAX_LABEL_LENGTH . ") NOT NULL,
160
- weight float,
161
- INDEX post_id (post_id),
162
- INDEX label (label)
163
- );";
164
-
165
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
166
- dbDelta($sql_tags);
167
-
168
- $latest_posts = get_posts(array('numberposts' => WP_RP_RECOMMENDATIONS_NUM_PREGENERATED_POSTS));
169
- foreach ($latest_posts as $post) {
170
- wp_rp_generate_tags($post);
171
- }
172
- }
173
-
174
- function wp_rp_install() {
175
- $wp_rp_meta = array(
176
- 'blog_id' => false,
177
- 'auth_key' => false,
178
- 'version' => WP_RP_VERSION,
179
- 'first_version' => WP_RP_VERSION,
180
- 'new_user' => true,
181
- 'blog_tg' => rand(0, 1),
182
- 'remote_recommendations' => false,
183
- 'show_turn_on_button' => true,
184
- 'name' => '',
185
- 'email' => '',
186
- 'remote_notifications' => array(),
187
- 'turn_on_button_pressed' => false,
188
- 'show_statistics' => false,
189
- 'show_traffic_exchange' => false,
190
- 'show_zemanta_linky_option' => true
191
- );
192
-
193
- $wp_rp_options = array(
194
- 'related_posts_title' => __('Related Posts', 'wp_related_posts'),
195
- 'max_related_posts' => 6,
196
- 'exclude_categories' => '',
197
- 'on_single_post' => true,
198
- 'on_rss' => false,
199
- 'max_related_post_age_in_days' => 0,
200
- 'default_thumbnail_path' => false,
201
- 'ctr_dashboard_enabled' => false,
202
- 'promoted_content_enabled' => false,
203
- 'enable_themes' => false,
204
- 'traffic_exchange_enabled' => false,
205
- 'thumbnail_use_custom' => false,
206
- 'thumbnail_custom_field' => false,
207
- 'display_zemanta_linky' => false,
208
-
209
- 'mobile' => array(
210
- 'display_comment_count' => false,
211
- 'display_publish_date' => false,
212
- 'display_excerpt' => false,
213
- 'display_thumbnail' => false,
214
- 'excerpt_max_length' => 200,
215
- 'theme_name' => 'm-modern.css',
216
- 'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
217
- ),
218
- 'desktop' => array(
219
- 'display_comment_count' => false,
220
- 'display_publish_date' => false,
221
- 'display_thumbnail' => false,
222
- 'display_excerpt' => false,
223
- 'excerpt_max_length' => 200,
224
- 'theme_name' => 'vertical.css',
225
- 'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
226
- 'custom_theme_enabled' => false,
227
- )
228
- );
229
-
230
- update_option('wp_rp_meta', $wp_rp_meta);
231
- update_option('wp_rp_options', $wp_rp_options);
232
-
233
- wp_rp_related_posts_db_table_install();
234
- }
235
-
236
- function wp_rp_migrate_2_7() {
237
- global $wpdb;
238
-
239
- $wp_rp_meta = get_option('wp_rp_meta');
240
- $wp_rp_meta['version'] = '2.8';
241
- $wp_rp_meta['new_user'] = false;
242
-
243
- $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key IN ('_wp_rp_extracted_image_url', '_wp_rp_extracted_image_url_full')");
244
-
245
- update_option('wp_rp_meta', $wp_rp_meta);
246
- }
247
-
248
- function wp_rp_migrate_2_6() {
249
- $wp_rp_meta = get_option('wp_rp_meta');
250
- $wp_rp_meta['version'] = '2.7';
251
- $wp_rp_meta['new_user'] = false;
252
- update_option('wp_rp_meta', $wp_rp_meta);
253
- }
254
-
255
- function wp_rp_migrate_2_5() {
256
- $wp_rp_meta = get_option('wp_rp_meta');
257
- $wp_rp_options = get_option('wp_rp_options');
258
-
259
- $wp_rp_meta['version'] = '2.6';
260
-
261
- if (!isset($wp_rp_meta['blog_tg'])) {
262
- $wp_rp_meta['blog_tg'] = rand(0, 1);
263
- }
264
-
265
- $wp_rp_meta['new_user'] = false;
266
-
267
- update_option('wp_rp_meta', $wp_rp_meta);
268
- update_option('wp_rp_options', $wp_rp_options);
269
- }
270
-
271
- function wp_rp_migrate_2_4_1() {
272
- $wp_rp_meta = get_option('wp_rp_meta');
273
- $wp_rp_options = get_option('wp_rp_options');
274
-
275
- $wp_rp_meta['version'] = '2.5';
276
-
277
- $wp_rp_meta['blog_tg'] = rand(0, 1);
278
-
279
- $display_options = array(
280
- 'display_comment_count' => $wp_rp_options['display_comment_count'],
281
- 'display_publish_date' => $wp_rp_options['display_publish_date'],
282
- 'display_thumbnail' => $wp_rp_options['display_thumbnail'],
283
- 'display_excerpt' => $wp_rp_options['display_excerpt'],
284
- 'excerpt_max_length' => $wp_rp_options['excerpt_max_length'],
285
- 'theme_name' => $wp_rp_options['theme_name'],
286
- 'theme_custom_css' => $wp_rp_options['theme_custom_css'],
287
- 'custom_theme_enabled' => $wp_rp_options['custom_theme_enabled']
288
- );
289
-
290
- $wp_rp_options['desktop'] = $display_options;
291
- $wp_rp_options['mobile'] = $display_options;
292
-
293
- if($wp_rp_options['mobile']['theme_name'] !== 'plain.css') {
294
- $wp_rp_options['mobile']['theme_name'] = 'm-modern.css';
295
- }
296
-
297
- unset($wp_rp_options['related_posts_title_tag']);
298
- unset($wp_rp_options['thumbnail_display_title']);
299
- unset($wp_rp_options['thumbnail_use_attached']);
300
- unset($wp_rp_options['display_comment_count']);
301
- unset($wp_rp_options['display_publish_date']);
302
- unset($wp_rp_options['display_thumbnail']);
303
- unset($wp_rp_options['display_excerpt']);
304
- unset($wp_rp_options['excerpt_max_length']);
305
- unset($wp_rp_options['theme_name']);
306
- unset($wp_rp_options['theme_custom_css']);
307
- unset($wp_rp_options['custom_theme_enabled']);
308
-
309
- $wp_rp_options['display_zemanta_linky'] = false;
310
- $wp_rp_meta['show_zemanta_linky_option'] = true;
311
-
312
- update_option('wp_rp_meta', $wp_rp_meta);
313
- update_option('wp_rp_options', $wp_rp_options);
314
- }
315
-
316
- function wp_rp_migrate_2_4() {
317
- $wp_rp_meta = get_option('wp_rp_meta');
318
- $wp_rp_options = get_option('wp_rp_options');
319
-
320
- $wp_rp_meta['version'] = '2.4.1';
321
-
322
- update_option('wp_rp_meta', $wp_rp_meta);
323
- update_option('wp_rp_options', $wp_rp_options);
324
- }
325
- function wp_rp_migrate_2_3() {
326
- $wp_rp_meta = get_option('wp_rp_meta');
327
- $wp_rp_options = get_option('wp_rp_options');
328
-
329
- $wp_rp_meta['version'] = '2.4';
330
-
331
- $wp_rp_options['max_related_post_age_in_days'] = 0;
332
-
333
- wp_rp_related_posts_db_table_uninstall();
334
- wp_rp_related_posts_db_table_install();
335
-
336
- update_option('wp_rp_meta', $wp_rp_meta);
337
- update_option('wp_rp_options', $wp_rp_options);
338
- }
339
-
340
- function wp_rp_migrate_2_2() {
341
- $wp_rp_meta = get_option('wp_rp_meta');
342
- $wp_rp_options = get_option('wp_rp_options');
343
-
344
- $wp_rp_meta['version'] = '2.3';
345
-
346
- if(isset($wp_rp_options['show_santa_hat'])) {
347
- unset($wp_rp_options['show_santa_hat']);
348
- }
349
- if(isset($wp_rp_options['show_RP_in_posts'])) {
350
- unset($wp_rp_options['show_RP_in_posts']);
351
- }
352
-
353
- update_option('wp_rp_meta', $wp_rp_meta);
354
- update_option('wp_rp_options', $wp_rp_options);
355
- }
356
-
357
- function wp_rp_migrate_2_1() {
358
- $wp_rp_meta = get_option('wp_rp_meta');
359
- $wp_rp_options = get_option('wp_rp_options');
360
-
361
- $wp_rp_meta['version'] = '2.2';
362
-
363
- $wp_rp_options['custom_theme_enabled'] = $wp_rp_options['theme_name'] == 'custom.css';
364
- if ($wp_rp_options['custom_theme_enabled']) {
365
- $wp_rp_options['theme_name'] = 'plain.css';
366
- }
367
-
368
- $wp_rp_options['show_RP_in_posts'] = false;
369
-
370
- $wp_rp_options['traffic_exchange_enabled'] = false;
371
- $wp_rp_meta['show_traffic_exchange'] = false;
372
-
373
- update_option('wp_rp_options', $wp_rp_options);
374
- update_option('wp_rp_meta', $wp_rp_meta);
375
- }
376
-
377
- function wp_rp_migrate_2_0() {
378
- $wp_rp_meta = get_option('wp_rp_meta');
379
- $wp_rp_options = get_option('wp_rp_options');
380
-
381
- $wp_rp_meta['version'] = '2.1';
382
-
383
- if ($wp_rp_options['default_thumbnail_path']) {
384
- $upload_dir = wp_upload_dir();
385
- $wp_rp_options['default_thumbnail_path'] = $upload_dir['baseurl'] . $wp_rp_options['default_thumbnail_path'];
386
- }
387
-
388
- update_option('wp_rp_options', $wp_rp_options);
389
- update_option('wp_rp_meta', $wp_rp_meta);
390
-
391
- if($wp_rp_options['display_thumbnail'] && $wp_rp_options['thumbnail_use_attached']) {
392
- wp_rp_process_latest_post_thumbnails();
393
- }
394
- }
395
-
396
- function wp_rp_migrate_1_7() {
397
- $wp_rp_meta = get_option('wp_rp_meta');
398
- $wp_rp_options = get_option('wp_rp_options');
399
-
400
- $wp_rp_meta['version'] = '2.0';
401
-
402
- $wp_rp_options['promoted_content_enabled'] = $wp_rp_options['ctr_dashboard_enabled'];
403
- $wp_rp_options['exclude_categories'] = $wp_rp_options['not_on_categories'];
404
-
405
- $wp_rp_meta['show_statistics'] = $wp_rp_options['ctr_dashboard_enabled'];
406
-
407
- // Commented out since we don't want to lose this info for users that will downgrade the plugin because of the change
408
- //unset($wp_rp_options['missing_rp_algorithm']);
409
- //unset($wp_rp_options['missing_rp_title']);
410
- //unset($wp_rp_options['not_on_categories']);
411
-
412
- // Forgot to unset this the last time.
413
- unset($wp_rp_meta['show_invite_friends_form']);
414
-
415
- update_option('wp_rp_options', $wp_rp_options);
416
- update_option('wp_rp_meta', $wp_rp_meta);
417
-
418
- wp_rp_schedule_notifications_cron();
419
- wp_rp_related_posts_db_table_install();
420
- }
421
-
422
- function wp_rp_migrate_1_6() {
423
- $wp_rp_meta = get_option('wp_rp_meta');
424
- $wp_rp_options = get_option('wp_rp_options');
425
-
426
- $wp_rp_meta['version'] = '1.7';
427
-
428
- unset($wp_rp_options['scroll_up_related_posts']);
429
- unset($wp_rp_options['include_promotionail_link']);
430
- unset($wp_rp_options['show_invite_friends_form']);
431
-
432
- $wp_rp_meta['show_blogger_network_form'] = false;
433
- $wp_rp_meta['remote_notifications'] = array();
434
-
435
- $wp_rp_meta['turn_on_button_pressed'] = false;
436
-
437
- update_option('wp_rp_options', $wp_rp_options);
438
- update_option('wp_rp_meta', $wp_rp_meta);
439
- }
440
-
441
- 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...
442
- $wp_rp_meta = get_option('wp_rp_meta');
443
-
444
- $wp_rp_meta['version'] = '1.5.2';
445
-
446
- update_option('wp_rp_meta', $wp_rp_meta);
447
- }
448
-
449
- function wp_rp_migrate_1_5_2() {
450
- $wp_rp_meta = get_option('wp_rp_meta');
451
- $wp_rp_options = get_option('wp_rp_options');
452
-
453
- $wp_rp_meta['version'] = '1.6';
454
-
455
- $wp_rp_meta['show_install_tooltip'] = false;
456
- $wp_rp_meta['remote_recommendations'] = false;
457
- $wp_rp_meta['show_turn_on_button'] = !($wp_rp_options['ctr_dashboard_enabled'] && $wp_rp_options['display_thumbnail']);
458
- $wp_rp_meta['name'] = '';
459
- $wp_rp_meta['email'] = '';
460
- $wp_rp_meta['show_invite_friends_form'] = false;
461
-
462
- unset($wp_rp_meta['show_ctr_banner']);
463
- unset($wp_rp_meta['show_blogger_network']);
464
-
465
- $wp_rp_options['scroll_up_related_posts'] = false;
466
-
467
- update_option('wp_rp_meta', $wp_rp_meta);
468
- update_option('wp_rp_options', $wp_rp_options);
469
- }
470
- function wp_rp_migrate_1_5_1() {
471
- $wp_rp_options = get_option('wp_rp_options');
472
- $wp_rp_meta = get_option('wp_rp_meta');
473
-
474
- $wp_rp_options['enable_themes'] = true;
475
- $wp_rp_meta['version'] = '1.5.2';
476
-
477
- update_option('wp_rp_options', $wp_rp_options);
478
- update_option('wp_rp_meta', $wp_rp_meta);
479
- }
480
- function wp_rp_migrate_1_5() {
481
- $wp_rp_options = get_option('wp_rp_options');
482
- $wp_rp_meta = get_option('wp_rp_meta');
483
-
484
- $wp_rp_meta['show_blogger_network'] = false;
485
- $wp_rp_meta['version'] = '1.5.1';
486
-
487
- $wp_rp_options['include_promotionail_link'] = false;
488
- $wp_rp_options['ctr_dashboard_enabled'] = !!$wp_rp_options['ctr_dashboard_enabled'];
489
-
490
- update_option('wp_rp_options', $wp_rp_options);
491
- update_option('wp_rp_meta', $wp_rp_meta);
492
- }
493
-
494
- function wp_rp_migrate_1_4() {
495
- global $wpdb;
496
-
497
- $wp_rp = get_option('wp_rp');
498
-
499
- $wp_rp_options = array();
500
-
501
- ////////////////////////////////
502
-
503
- $wp_rp_options['missing_rp_algorithm'] = (isset($wp_rp['wp_no_rp']) && in_array($wp_rp['wp_no_rp'], array('text', 'random', 'commented', 'popularity'))) ? $wp_rp['wp_no_rp'] : 'random';
504
-
505
- if(isset($wp_rp['wp_no_rp_text']) && $wp_rp['wp_no_rp_text']) {
506
- $wp_rp_options['missing_rp_title'] = $wp_rp['wp_no_rp_text'];
507
- } else {
508
- if($wp_rp_options['missing_rp_algorithm'] === 'text') {
509
- $wp_rp_options['missing_rp_title'] = __('No Related Posts', 'wp_related_posts');
510
- } else {
511
- $wp_rp_options['missing_rp_title'] = __('Random Posts', 'wp_related_posts');
512
- }
513
- }
514
-
515
- $wp_rp_options['on_single_post'] = isset($wp_rp['wp_rp_auto']) ? !!$wp_rp['wp_rp_auto'] : true;
516
-
517
- $wp_rp_options['display_comment_count'] = isset($wp_rp['wp_rp_comments']) ? !!$wp_rp['wp_rp_comments'] : false;
518
-
519
- $wp_rp_options['display_publish_date'] = isset($wp_rp['wp_rp_date']) ? !!$wp_rp['wp_rp_date'] : false;
520
-
521
- $wp_rp_options['display_excerpt'] = isset($wp_rp['wp_rp_except']) ? !!$wp_rp['wp_rp_except'] : false;
522
-
523
- if(isset($wp_rp['wp_rp_except_number']) && is_numeric(trim($wp_rp['wp_rp_except_number']))) {
524
- $wp_rp_options['excerpt_max_length'] = intval(trim($wp_rp['wp_rp_except_number']));
525
- } else {
526
- $wp_rp_options['excerpt_max_length'] = 200;
527
- }
528
-
529
- $wp_rp_options['not_on_categories'] = isset($wp_rp['wp_rp_exclude']) ? $wp_rp['wp_rp_exclude'] : '';
530
-
531
- if(isset($wp_rp['wp_rp_limit']) && is_numeric(trim($wp_rp['wp_rp_limit']))) {
532
- $wp_rp_options['max_related_posts'] = intval(trim($wp_rp['wp_rp_limit']));
533
- } else {
534
- $wp_rp_options['max_related_posts'] = 5;
535
- }
536
-
537
- $wp_rp_options['on_rss'] = isset($wp_rp['wp_rp_rss']) ? !!$wp_rp['wp_rp_rss'] : false;
538
-
539
- $wp_rp_options['theme_name'] = isset($wp_rp['wp_rp_theme']) ? $wp_rp['wp_rp_theme'] : 'plain.css';
540
-
541
- $wp_rp_options['display_thumbnail'] = isset($wp_rp['wp_rp_thumbnail']) ? !!$wp_rp['wp_rp_thumbnail'] : false;
542
-
543
- $custom_fields = $wpdb->get_col("SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY LOWER(meta_key)");
544
- if(isset($wp_rp['wp_rp_thumbnail_post_meta']) && in_array($wp_rp['wp_rp_thumbnail_post_meta'], $custom_fields)) {
545
- $wp_rp_options['thumbnail_custom_field'] = $wp_rp['wp_rp_thumbnail_post_meta'];
546
- } else {
547
- $wp_rp_options['thumbnail_custom_field'] = false;
548
- }
549
-
550
- $wp_rp_options['thumbnail_display_title'] = isset($wp_rp['wp_rp_thumbnail_text']) ? !!$wp_rp['wp_rp_thumbnail_text'] : false;
551
-
552
- $wp_rp_options['related_posts_title'] = isset($wp_rp['wp_rp_title']) ? $wp_rp['wp_rp_title'] : '';
553
-
554
- $wp_rp_options['related_posts_title_tag'] = isset($wp_rp['wp_rp_title_tag']) ? $wp_rp['wp_rp_title_tag'] : 'h3';
555
-
556
- $wp_rp_options['default_thumbnail_path'] = (isset($wp_rp['wp_rp_default_thumbnail_path']) && $wp_rp['wp_rp_default_thumbnail_path']) ? $wp_rp['wp_rp_default_thumbnail_path'] : false;
557
-
558
- $wp_rp_options['thumbnail_use_attached'] = isset($wp_rp["wp_rp_thumbnail_extract"]) && ($wp_rp["wp_rp_thumbnail_extract"] === 'yes');
559
-
560
- $wp_rp_options['thumbnail_use_custom'] = $wp_rp_options['thumbnail_custom_field'] && !(isset($wp_rp['wp_rp_thumbnail_featured']) && $wp_rp['wp_rp_thumbnail_featured'] === 'yes');
561
-
562
- $wp_rp_options['theme_custom_css'] = WP_RP_DEFAULT_CUSTOM_CSS;
563
-
564
- $wp_rp_options['ctr_dashboard_enabled'] = false;
565
-
566
- ////////////////////////////////
567
-
568
- $wp_rp_meta = array(
569
- 'blog_id' => false,
570
- 'auth_key' => false,
571
- 'version' => '1.5',
572
- 'first_version' => '1.4',
573
- 'new_user' => false,
574
- 'show_upgrade_tooltip' => true,
575
- 'show_ctr_banner' => true
576
- );
577
-
578
- update_option('wp_rp_meta', $wp_rp_meta);
579
- update_option('wp_rp_options', $wp_rp_options);
580
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define('WP_RP_STATIC_BASE_URL', 'http://dtmvdvtzf8rz0.cloudfront.net/static/');
4
+
5
+ define('WP_RP_STATIC_THEMES_PATH', 'static/themes/');
6
+
7
+ define("WP_RP_DEFAULT_CUSTOM_CSS",
8
+ ".related_post_title {
9
+ }
10
+ ul.related_post {
11
+ }
12
+ ul.related_post li {
13
+ }
14
+ ul.related_post li a {
15
+ }
16
+ ul.related_post li img {
17
+ }");
18
+
19
+ define('WP_RP_THUMBNAILS_NAME', 'wp_rp_thumbnail');
20
+ define('WP_RP_THUMBNAILS_PROP_NAME', 'wp_rp_thumbnail_prop');
21
+ define('WP_RP_THUMBNAILS_WIDTH', 150);
22
+ define('WP_RP_THUMBNAILS_HEIGHT', 150);
23
+ define('WP_RP_THUMBNAILS_DEFAULTS_COUNT', 31);
24
+
25
+ define("WP_RP_MAX_LABEL_LENGTH", 32);
26
+
27
+ define("WP_RP_CTR_DASHBOARD_URL", "http://d.zemanta.com/");
28
+ define("WP_RP_STATIC_LOADER_FILE", "js/loader.js");
29
+
30
+ define("WP_RP_STATIC_INFINITE_RECS_JS_FILE", "js/infiniterecs.js");
31
+ define("WP_RP_STATIC_PINTEREST_JS_FILE", "js/pinterest.js");
32
+
33
+ define("WP_RP_RECOMMENDATIONS_AUTO_TAGS_MAX_WORDS", 200);
34
+ define("WP_RP_RECOMMENDATIONS_AUTO_TAGS_MAX_TAGS", 15);
35
+
36
+ define("WP_RP_RECOMMENDATIONS_AUTO_TAGS_SCORE", 2);
37
+ define("WP_RP_RECOMMENDATIONS_TAGS_SCORE", 10);
38
+ define("WP_RP_RECOMMENDATIONS_CATEGORIES_SCORE", 5);
39
+
40
+ define("WP_RP_RECOMMENDATIONS_NUM_PREGENERATED_POSTS", 50);
41
+
42
+ define("WP_RP_THUMBNAILS_NUM_PREGENERATED_POSTS", 50);
43
+
44
+ global $wp_rp_options, $wp_rp_meta;
45
+ $wp_rp_options = false;
46
+ $wp_rp_meta = false;
47
+
48
+ function wp_rp_get_options() {
49
+ global $wp_rp_options, $wp_rp_meta;
50
+ if($wp_rp_options) {
51
+ return $wp_rp_options;
52
+ }
53
+
54
+ $wp_rp_options = get_option('wp_rp_options', false);
55
+ $wp_rp_meta = get_option('wp_rp_meta', false);
56
+
57
+ if(!$wp_rp_meta || !$wp_rp_options || $wp_rp_meta['version'] !== WP_RP_VERSION) {
58
+ wp_rp_upgrade();
59
+ $wp_rp_meta = get_option('wp_rp_meta');
60
+ $wp_rp_options = get_option('wp_rp_options');
61
+ }
62
+
63
+ $wp_rp_meta = new ArrayObject($wp_rp_meta);
64
+ $wp_rp_options = new ArrayObject($wp_rp_options);
65
+
66
+ return $wp_rp_options;
67
+ }
68
+
69
+ function wp_rp_get_meta() {
70
+ global $wp_rp_meta;
71
+
72
+ if (!$wp_rp_meta) {
73
+ wp_rp_get_options();
74
+ }
75
+
76
+ return $wp_rp_meta;
77
+ }
78
+
79
+ function wp_rp_update_meta($new_meta) {
80
+ global $wp_rp_meta;
81
+
82
+ $new_meta = (array) $new_meta;
83
+
84
+ $r = update_option('wp_rp_meta', $new_meta);
85
+
86
+ if($r && $wp_rp_meta !== false) {
87
+ $wp_rp_meta->exchangeArray($new_meta);
88
+ }
89
+
90
+ return $r;
91
+ }
92
+
93
+ function wp_rp_update_options($new_options) {
94
+ global $wp_rp_options;
95
+
96
+ $new_options = (array) $new_options;
97
+
98
+ $r = update_option('wp_rp_options', $new_options);
99
+
100
+ if($r && $wp_rp_options !== false) {
101
+ $wp_rp_options->exchangeArray($new_options);
102
+ }
103
+
104
+ return $r;
105
+ }
106
+
107
+ function wp_rp_activate_hook() {
108
+ wp_rp_get_options();
109
+ wp_rp_schedule_notifications_cron();
110
+ }
111
+
112
+ function wp_rp_deactivate_hook() {
113
+ wp_rp_unschedule_notifications_cron();
114
+ }
115
+
116
+ function wp_rp_upgrade() {
117
+ $wp_rp_meta = get_option('wp_rp_meta', false);
118
+ $version = false;
119
+
120
+ if($wp_rp_meta) {
121
+ $version = $wp_rp_meta['version'];
122
+ } else {
123
+ $wp_rp_old_options = get_option('wp_rp', false);
124
+ if($wp_rp_old_options) {
125
+ $version = '1.4';
126
+ }
127
+ }
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();
136
+ }
137
+ }
138
+
139
+ function wp_rp_related_posts_db_table_uninstall() {
140
+ global $wpdb;
141
+
142
+ $tags_table_name = $wpdb->prefix . "wp_rp_tags";
143
+
144
+ $sql = "DROP TABLE " . $tags_table_name;
145
+
146
+ $wpdb->query($sql);
147
+ }
148
+
149
+ function wp_rp_related_posts_db_table_install() {
150
+ global $wpdb;
151
+
152
+ $tags_table_name = $wpdb->prefix . "wp_rp_tags";
153
+ $sql_tags = "CREATE TABLE $tags_table_name (
154
+ post_id mediumint(9),
155
+ post_date datetime NOT NULL,
156
+ label VARCHAR(" . WP_RP_MAX_LABEL_LENGTH . ") NOT NULL,
157
+ weight float,
158
+ INDEX post_id (post_id),
159
+ INDEX label (label)
160
+ );";
161
+
162
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
163
+ dbDelta($sql_tags);
164
+
165
+ $latest_posts = get_posts(array('numberposts' => WP_RP_RECOMMENDATIONS_NUM_PREGENERATED_POSTS));
166
+ foreach ($latest_posts as $post) {
167
+ wp_rp_generate_tags($post);
168
+ }
169
+ }
170
+
171
+ function wp_rp_install() {
172
+ $wp_rp_meta = array(
173
+ 'blog_id' => false,
174
+ 'auth_key' => false,
175
+ 'version' => WP_RP_VERSION,
176
+ 'first_version' => WP_RP_VERSION,
177
+ 'new_user' => true,
178
+ 'blog_tg' => rand(0, 1),
179
+ 'remote_recommendations' => false,
180
+ 'show_turn_on_button' => true,
181
+ 'name' => '',
182
+ 'email' => '',
183
+ 'remote_notifications' => array(),
184
+ 'turn_on_button_pressed' => false,
185
+ 'show_statistics' => false,
186
+ 'show_traffic_exchange' => false,
187
+ 'show_zemanta_linky_option' => true,
188
+ 'classic_user' => true
189
+ );
190
+
191
+ $wp_rp_options = array(
192
+ 'related_posts_title' => __('More from my site', 'wp_related_posts'),
193
+ 'max_related_posts' => 6,
194
+ 'exclude_categories' => '',
195
+ 'on_single_post' => true,
196
+ 'on_rss' => false,
197
+ 'max_related_post_age_in_days' => 0,
198
+ 'default_thumbnail_path' => false,
199
+ 'ctr_dashboard_enabled' => false,
200
+ 'promoted_content_enabled' => false,
201
+ 'enable_themes' => false,
202
+ 'traffic_exchange_enabled' => false,
203
+ 'thumbnail_use_custom' => false,
204
+ 'thumbnail_custom_field' => false,
205
+ 'display_zemanta_linky' => false,
206
+
207
+ 'mobile' => array(
208
+ 'display_comment_count' => false,
209
+ 'display_publish_date' => false,
210
+ 'display_excerpt' => false,
211
+ 'display_thumbnail' => false,
212
+ 'excerpt_max_length' => 200,
213
+ 'theme_name' => 'm-modern.css',
214
+ 'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
215
+ ),
216
+ 'desktop' => array(
217
+ 'display_comment_count' => false,
218
+ 'display_publish_date' => false,
219
+ 'display_thumbnail' => false,
220
+ 'display_excerpt' => false,
221
+ 'excerpt_max_length' => 200,
222
+ 'theme_name' => 'vertical-m.css',
223
+ 'theme_custom_css' => WP_RP_DEFAULT_CUSTOM_CSS,
224
+ 'custom_theme_enabled' => false,
225
+ )
226
+ );
227
+
228
+ update_option('wp_rp_meta', $wp_rp_meta);
229
+ update_option('wp_rp_options', $wp_rp_options);
230
+
231
+ wp_rp_related_posts_db_table_install();
232
+ }
233
+
234
+ function wp_rp_is_classic() {
235
+ $meta = wp_rp_get_meta();
236
+ if (isset($meta['classic_user']) && $meta['classic_user']) {
237
+ return true;
238
+ }
239
+ return false;
240
+ }
241
+
242
+ function wp_rp_migrate_2_8() {
243
+ global $wpdb;
244
+
245
+ $wp_rp_meta = get_option('wp_rp_meta');
246
+ $wp_rp_meta['version'] = '2.9';
247
+ $wp_rp_meta['new_user'] = false;
248
+
249
+ update_option('wp_rp_meta', $wp_rp_meta);
250
+ }
251
+
252
+ function wp_rp_migrate_2_7() {
253
+ global $wpdb;
254
+
255
+ $wp_rp_meta = get_option('wp_rp_meta');
256
+ $wp_rp_meta['version'] = '2.8';
257
+ $wp_rp_meta['new_user'] = false;
258
+ $wp_rp_meta['classic_user'] = false;
259
+
260
+ $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key IN ('_wp_rp_extracted_image_url', '_wp_rp_extracted_image_url_full')");
261
+
262
+ update_option('wp_rp_meta', $wp_rp_meta);
263
+ }
264
+
265
+ function wp_rp_migrate_2_6() {
266
+ $wp_rp_meta = get_option('wp_rp_meta');
267
+ $wp_rp_meta['version'] = '2.7';
268
+ $wp_rp_meta['new_user'] = false;
269
+ update_option('wp_rp_meta', $wp_rp_meta);
270
+ }
271
+
272
+ function wp_rp_migrate_2_5() {
273
+ $wp_rp_meta = get_option('wp_rp_meta');
274
+ $wp_rp_options = get_option('wp_rp_options');
275
+
276
+ $wp_rp_meta['version'] = '2.6';
277
+
278
+ if (!isset($wp_rp_meta['blog_tg'])) {
279
+ $wp_rp_meta['blog_tg'] = rand(0, 1);
280
+ }
281
+
282
+ $wp_rp_meta['new_user'] = false;
283
+
284
+ update_option('wp_rp_meta', $wp_rp_meta);
285
+ update_option('wp_rp_options', $wp_rp_options);
286
+ }
287
+
288
+ function wp_rp_migrate_2_4_1() {
289
+ $wp_rp_meta = get_option('wp_rp_meta');
290
+ $wp_rp_options = get_option('wp_rp_options');
291
+
292
+ $wp_rp_meta['version'] = '2.5';
293
+
294
+ $wp_rp_meta['blog_tg'] = rand(0, 1);
295
+
296
+ $display_options = array(
297
+ 'display_comment_count' => $wp_rp_options['display_comment_count'],
298
+ 'display_publish_date' => $wp_rp_options['display_publish_date'],
299
+ 'display_thumbnail' => $wp_rp_options['display_thumbnail'],
300
+ 'display_excerpt' => $wp_rp_options['display_excerpt'],
301
+ 'excerpt_max_length' => $wp_rp_options['excerpt_max_length'],
302
+ 'theme_name' => $wp_rp_options['theme_name'],
303
+ 'theme_custom_css' => $wp_rp_options['theme_custom_css'],
304
+ 'custom_theme_enabled' => $wp_rp_options['custom_theme_enabled']
305
+ );
306
+
307
+ $wp_rp_options['desktop'] = $display_options;
308
+ $wp_rp_options['mobile'] = $display_options;
309
+
310
+ if($wp_rp_options['mobile']['theme_name'] !== 'plain.css') {
311
+ $wp_rp_options['mobile']['theme_name'] = 'm-modern.css';
312
+ }
313
+
314
+ unset($wp_rp_options['related_posts_title_tag']);
315
+ unset($wp_rp_options['thumbnail_display_title']);
316
+ unset($wp_rp_options['thumbnail_use_attached']);
317
+ unset($wp_rp_options['display_comment_count']);
318
+ unset($wp_rp_options['display_publish_date']);
319
+ unset($wp_rp_options['display_thumbnail']);
320
+ unset($wp_rp_options['display_excerpt']);
321
+ unset($wp_rp_options['excerpt_max_length']);
322
+ unset($wp_rp_options['theme_name']);
323
+ unset($wp_rp_options['theme_custom_css']);
324
+ unset($wp_rp_options['custom_theme_enabled']);
325
+
326
+ $wp_rp_options['display_zemanta_linky'] = false;
327
+ $wp_rp_meta['show_zemanta_linky_option'] = true;
328
+
329
+ update_option('wp_rp_meta', $wp_rp_meta);
330
+ update_option('wp_rp_options', $wp_rp_options);
331
+ }
332
+
333
+ function wp_rp_migrate_2_4() {
334
+ $wp_rp_meta = get_option('wp_rp_meta');
335
+ $wp_rp_options = get_option('wp_rp_options');
336
+
337
+ $wp_rp_meta['version'] = '2.4.1';
338
+
339
+ update_option('wp_rp_meta', $wp_rp_meta);
340
+ update_option('wp_rp_options', $wp_rp_options);
341
+ }
342
+ function wp_rp_migrate_2_3() {
343
+ $wp_rp_meta = get_option('wp_rp_meta');
344
+ $wp_rp_options = get_option('wp_rp_options');
345
+
346
+ $wp_rp_meta['version'] = '2.4';
347
+
348
+ $wp_rp_options['max_related_post_age_in_days'] = 0;
349
+
350
+ wp_rp_related_posts_db_table_uninstall();
351
+ wp_rp_related_posts_db_table_install();
352
+
353
+ update_option('wp_rp_meta', $wp_rp_meta);
354
+ update_option('wp_rp_options', $wp_rp_options);
355
+ }
356
+
357
+ function wp_rp_migrate_2_2() {
358
+ $wp_rp_meta = get_option('wp_rp_meta');
359
+ $wp_rp_options = get_option('wp_rp_options');
360
+
361
+ $wp_rp_meta['version'] = '2.3';
362
+
363
+ if(isset($wp_rp_options['show_santa_hat'])) {
364
+ unset($wp_rp_options['show_santa_hat']);
365
+ }
366
+ if(isset($wp_rp_options['show_RP_in_posts'])) {
367
+ unset($wp_rp_options['show_RP_in_posts']);
368
+ }
369
+
370
+ update_option('wp_rp_meta', $wp_rp_meta);
371
+ update_option('wp_rp_options', $wp_rp_options);
372
+ }
373
+
374
+ function wp_rp_migrate_2_1() {
375
+ $wp_rp_meta = get_option('wp_rp_meta');
376
+ $wp_rp_options = get_option('wp_rp_options');
377
+
378
+ $wp_rp_meta['version'] = '2.2';
379
+
380
+ $wp_rp_options['custom_theme_enabled'] = $wp_rp_options['theme_name'] == 'custom.css';
381
+ if ($wp_rp_options['custom_theme_enabled']) {
382
+ $wp_rp_options['theme_name'] = 'plain.css';
383
+ }
384
+
385
+ $wp_rp_options['show_RP_in_posts'] = false;
386
+
387
+ $wp_rp_options['traffic_exchange_enabled'] = false;
388
+ $wp_rp_meta['show_traffic_exchange'] = false;
389
+
390
+ update_option('wp_rp_options', $wp_rp_options);
391
+ update_option('wp_rp_meta', $wp_rp_meta);
392
+ }
393
+
394
+ function wp_rp_migrate_2_0() {
395
+ $wp_rp_meta = get_option('wp_rp_meta');
396
+ $wp_rp_options = get_option('wp_rp_options');
397
+
398
+ $wp_rp_meta['version'] = '2.1';
399
+
400
+ if ($wp_rp_options['default_thumbnail_path']) {
401
+ $upload_dir = wp_upload_dir();
402
+ $wp_rp_options['default_thumbnail_path'] = $upload_dir['baseurl'] . $wp_rp_options['default_thumbnail_path'];
403
+ }
404
+
405
+ update_option('wp_rp_options', $wp_rp_options);
406
+ update_option('wp_rp_meta', $wp_rp_meta);
407
+
408
+ if($wp_rp_options['display_thumbnail'] && $wp_rp_options['thumbnail_use_attached']) {
409
+ wp_rp_process_latest_post_thumbnails();
410
+ }
411
+ }
412
+
413
+ function wp_rp_migrate_1_7() {
414
+ $wp_rp_meta = get_option('wp_rp_meta');
415
+ $wp_rp_options = get_option('wp_rp_options');
416
+
417
+ $wp_rp_meta['version'] = '2.0';
418
+
419
+ $wp_rp_options['promoted_content_enabled'] = $wp_rp_options['ctr_dashboard_enabled'];
420
+ $wp_rp_options['exclude_categories'] = $wp_rp_options['not_on_categories'];
421
+
422
+ $wp_rp_meta['show_statistics'] = $wp_rp_options['ctr_dashboard_enabled'];
423
+
424
+ // Commented out since we don't want to lose this info for users that will downgrade the plugin because of the change
425
+ //unset($wp_rp_options['missing_rp_algorithm']);
426
+ //unset($wp_rp_options['missing_rp_title']);
427
+ //unset($wp_rp_options['not_on_categories']);
428
+
429
+ // Forgot to unset this the last time.
430
+ unset($wp_rp_meta['show_invite_friends_form']);
431
+
432
+ update_option('wp_rp_options', $wp_rp_options);
433
+ update_option('wp_rp_meta', $wp_rp_meta);
434
+
435
+ wp_rp_schedule_notifications_cron();
436
+ wp_rp_related_posts_db_table_install();
437
+ }
438
+
439
+ function wp_rp_migrate_1_6() {
440
+ $wp_rp_meta = get_option('wp_rp_meta');
441
+ $wp_rp_options = get_option('wp_rp_options');
442
+
443
+ $wp_rp_meta['version'] = '1.7';
444
+
445
+ unset($wp_rp_options['scroll_up_related_posts']);
446
+ unset($wp_rp_options['include_promotionail_link']);
447
+ unset($wp_rp_options['show_invite_friends_form']);
448
+
449
+ $wp_rp_meta['show_blogger_network_form'] = false;
450
+ $wp_rp_meta['remote_notifications'] = array();
451
+
452
+ $wp_rp_meta['turn_on_button_pressed'] = false;
453
+
454
+ update_option('wp_rp_options', $wp_rp_options);
455
+ update_option('wp_rp_meta', $wp_rp_meta);
456
+ }
457
+
458
+ 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...
459
+ $wp_rp_meta = get_option('wp_rp_meta');
460
+
461
+ $wp_rp_meta['version'] = '1.5.2';
462
+
463
+ update_option('wp_rp_meta', $wp_rp_meta);
464
+ }
465
+
466
+ function wp_rp_migrate_1_5_2() {
467
+ $wp_rp_meta = get_option('wp_rp_meta');
468
+ $wp_rp_options = get_option('wp_rp_options');
469
+
470
+ $wp_rp_meta['version'] = '1.6';
471
+
472
+ $wp_rp_meta['show_install_tooltip'] = false;
473
+ $wp_rp_meta['remote_recommendations'] = false;
474
+ $wp_rp_meta['show_turn_on_button'] = !($wp_rp_options['ctr_dashboard_enabled'] && $wp_rp_options['display_thumbnail']);
475
+ $wp_rp_meta['name'] = '';
476
+ $wp_rp_meta['email'] = '';
477
+ $wp_rp_meta['show_invite_friends_form'] = false;
478
+
479
+ unset($wp_rp_meta['show_ctr_banner']);
480
+ unset($wp_rp_meta['show_blogger_network']);
481
+
482
+ $wp_rp_options['scroll_up_related_posts'] = false;
483
+
484
+ update_option('wp_rp_meta', $wp_rp_meta);
485
+ update_option('wp_rp_options', $wp_rp_options);
486
+ }
487
+ function wp_rp_migrate_1_5_1() {
488
+ $wp_rp_options = get_option('wp_rp_options');
489
+ $wp_rp_meta = get_option('wp_rp_meta');
490
+
491
+ $wp_rp_options['enable_themes'] = true;
492
+ $wp_rp_meta['version'] = '1.5.2';
493
+
494
+ update_option('wp_rp_options', $wp_rp_options);
495
+ update_option('wp_rp_meta', $wp_rp_meta);
496
+ }
497
+ function wp_rp_migrate_1_5() {
498
+ $wp_rp_options = get_option('wp_rp_options');
499
+ $wp_rp_meta = get_option('wp_rp_meta');
500
+
501
+ $wp_rp_meta['show_blogger_network'] = false;
502
+ $wp_rp_meta['version'] = '1.5.1';
503
+
504
+ $wp_rp_options['include_promotionail_link'] = false;
505
+ $wp_rp_options['ctr_dashboard_enabled'] = !!$wp_rp_options['ctr_dashboard_enabled'];
506
+
507
+ update_option('wp_rp_options', $wp_rp_options);
508
+ update_option('wp_rp_meta', $wp_rp_meta);
509
+ }
510
+
511
+ function wp_rp_migrate_1_4() {
512
+ global $wpdb;
513
+
514
+ $wp_rp = get_option('wp_rp');
515
+
516
+ $wp_rp_options = array();
517
+
518
+ ////////////////////////////////
519
+
520
+ $wp_rp_options['missing_rp_algorithm'] = (isset($wp_rp['wp_no_rp']) && in_array($wp_rp['wp_no_rp'], array('text', 'random', 'commented', 'popularity'))) ? $wp_rp['wp_no_rp'] : 'random';
521
+
522
+ if(isset($wp_rp['wp_no_rp_text']) && $wp_rp['wp_no_rp_text']) {
523
+ $wp_rp_options['missing_rp_title'] = $wp_rp['wp_no_rp_text'];
524
+ } else {
525
+ if($wp_rp_options['missing_rp_algorithm'] === 'text') {
526
+ $wp_rp_options['missing_rp_title'] = __('No Related Posts', 'wp_related_posts');
527
+ } else {
528
+ $wp_rp_options['missing_rp_title'] = __('Random Posts', 'wp_related_posts');
529
+ }
530
+ }
531
+
532
+ $wp_rp_options['on_single_post'] = isset($wp_rp['wp_rp_auto']) ? !!$wp_rp['wp_rp_auto'] : true;
533
+
534
+ $wp_rp_options['display_comment_count'] = isset($wp_rp['wp_rp_comments']) ? !!$wp_rp['wp_rp_comments'] : false;
535
+
536
+ $wp_rp_options['display_publish_date'] = isset($wp_rp['wp_rp_date']) ? !!$wp_rp['wp_rp_date'] : false;
537
+
538
+ $wp_rp_options['display_excerpt'] = isset($wp_rp['wp_rp_except']) ? !!$wp_rp['wp_rp_except'] : false;
539
+
540
+ if(isset($wp_rp['wp_rp_except_number']) && is_numeric(trim($wp_rp['wp_rp_except_number']))) {
541
+ $wp_rp_options['excerpt_max_length'] = intval(trim($wp_rp['wp_rp_except_number']));
542
+ } else {
543
+ $wp_rp_options['excerpt_max_length'] = 200;
544
+ }
545
+
546
+ $wp_rp_options['not_on_categories'] = isset($wp_rp['wp_rp_exclude']) ? $wp_rp['wp_rp_exclude'] : '';
547
+
548
+ if(isset($wp_rp['wp_rp_limit']) && is_numeric(trim($wp_rp['wp_rp_limit']))) {
549
+ $wp_rp_options['max_related_posts'] = intval(trim($wp_rp['wp_rp_limit']));
550
+ } else {
551
+ $wp_rp_options['max_related_posts'] = 5;
552
+ }
553
+
554
+ $wp_rp_options['on_rss'] = isset($wp_rp['wp_rp_rss']) ? !!$wp_rp['wp_rp_rss'] : false;
555
+
556
+ $wp_rp_options['theme_name'] = isset($wp_rp['wp_rp_theme']) ? $wp_rp['wp_rp_theme'] : 'plain.css';
557
+
558
+ $wp_rp_options['display_thumbnail'] = isset($wp_rp['wp_rp_thumbnail']) ? !!$wp_rp['wp_rp_thumbnail'] : false;
559
+
560
+ $custom_fields = $wpdb->get_col("SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY LOWER(meta_key)");
561
+ if(isset($wp_rp['wp_rp_thumbnail_post_meta']) && in_array($wp_rp['wp_rp_thumbnail_post_meta'], $custom_fields)) {
562
+ $wp_rp_options['thumbnail_custom_field'] = $wp_rp['wp_rp_thumbnail_post_meta'];
563
+ } else {
564
+ $wp_rp_options['thumbnail_custom_field'] = false;
565
+ }
566
+
567
+ $wp_rp_options['thumbnail_display_title'] = isset($wp_rp['wp_rp_thumbnail_text']) ? !!$wp_rp['wp_rp_thumbnail_text'] : false;
568
+
569
+ $wp_rp_options['related_posts_title'] = isset($wp_rp['wp_rp_title']) ? $wp_rp['wp_rp_title'] : '';
570
+
571
+ $wp_rp_options['related_posts_title_tag'] = isset($wp_rp['wp_rp_title_tag']) ? $wp_rp['wp_rp_title_tag'] : 'h3';
572
+
573
+ $wp_rp_options['default_thumbnail_path'] = (isset($wp_rp['wp_rp_default_thumbnail_path']) && $wp_rp['wp_rp_default_thumbnail_path']) ? $wp_rp['wp_rp_default_thumbnail_path'] : false;
574
+
575
+ $wp_rp_options['thumbnail_use_attached'] = isset($wp_rp["wp_rp_thumbnail_extract"]) && ($wp_rp["wp_rp_thumbnail_extract"] === 'yes');
576
+
577
+ $wp_rp_options['thumbnail_use_custom'] = $wp_rp_options['thumbnail_custom_field'] && !(isset($wp_rp['wp_rp_thumbnail_featured']) && $wp_rp['wp_rp_thumbnail_featured'] === 'yes');
578
+
579
+ $wp_rp_options['theme_custom_css'] = WP_RP_DEFAULT_CUSTOM_CSS;
580
+
581
+ $wp_rp_options['ctr_dashboard_enabled'] = false;
582
+
583
+ ////////////////////////////////
584
+
585
+ $wp_rp_meta = array(
586
+ 'blog_id' => false,
587
+ 'auth_key' => false,
588
+ 'version' => '1.5',
589
+ 'first_version' => '1.4',
590
+ 'new_user' => false,
591
+ 'show_upgrade_tooltip' => true,
592
+ 'show_ctr_banner' => true
593
+ );
594
+
595
+ update_option('wp_rp_meta', $wp_rp_meta);
596
+ update_option('wp_rp_options', $wp_rp_options);
597
+ }
readme.txt CHANGED
@@ -4,27 +4,29 @@ Tags: related,posts,post,related posts,plugin
4
  License: GPLv2
5
  Requires at least: 3.3
6
  Tested up to: 3.6
7
- Stable tag: 2.8
8
 
9
  WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
10
 
11
  == Description ==
12
 
13
- Quickly increase your readers' engagement with your posts by adding Related Posts in the footer of your content. The plugin also delivers statistics about Pageviews and Clicks\*. It supports different styles, thumbnails and is fully customizable.
 
 
14
 
15
  After installation, go to Settings -> Related Posts in your plugins list and Turn on Advanced Features!
16
 
17
- \* Real time traffic analytics are provided via third party service.
18
 
19
  == Frequently Asked Questions ==
20
 
21
- = Why should I use this plugin and not any other? =
22
 
23
- WordPress Related Posts is constantly improved to bring you the highest rates of audience engagement with your content. Our highest Click-Through rates speak for themselves.
24
 
25
- = What does this plugin do? =
26
 
27
- It places a list of links with thumbnails at the bottom of your posts. It increases pageviews and engages readers to stay on your site longer and discover more of your content.
28
 
29
  = Are there any settings? Plenty! =
30
 
@@ -38,9 +40,13 @@ It places a list of links with thumbnails at the bottom of your posts. It increa
38
 
39
  Yes, related posts are responsive so they adapt to the screen size to ensure maximum click-through rates.
40
 
41
- = Why does Zemanta have 3 similar plugins? What's the difference between them? =
 
 
42
 
43
- We adopted the principle of having three "release channels". You can try the most experimental (still stable!) features in [Related Posts](http://wordpress.org/extend/plugins/related-posts/ "Related Posts"). The more advanced ones are in [WordPress Related Posts](http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/ "WordPress Related Posts"). If you're looking for the Professional version go for [Related Posts by Zemanta](http://wordpress.org/extend/plugins/related-posts-by-zemanta/ "Related Posts by Zemanta").
 
 
44
 
45
  == Installation ==
46
 
@@ -75,6 +81,10 @@ Fix for security vulnerability. Upgrade immediately.
75
 
76
  == Changelog ==
77
 
 
 
 
 
78
  = 2.8 =
79
  * New thumbnailer
80
  * Edit Related Posts gets a visual upgrade, search functionality and a dose of awesome
4
  License: GPLv2
5
  Requires at least: 3.3
6
  Tested up to: 3.6
7
+ Stable tag: 2.9
8
 
9
  WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
10
 
11
  == Description ==
12
 
13
+ Quickly increase your readers' engagement with your posts by adding Related Posts in the footer of your content. Automatically added Related Posts can increase your internal traffic up to 10%. Just install and activate. To attract attention and improve SEO, link out to Related Posts across the web from your compose screen. Search for posts and hand-pick them with ease. Recommendations are provided by Zemanta's world-class semantic service, including advanced analytics.
14
+
15
+ The plugin also delivers statistics about Pageviews and Clicks*. It supports different styles, thumbnails and is fully customizable.
16
 
17
  After installation, go to Settings -> Related Posts in your plugins list and Turn on Advanced Features!
18
 
19
+ * Real time traffic analytics are provided via third party service.
20
 
21
  == Frequently Asked Questions ==
22
 
23
+ = What does this plugin do? =
24
 
25
+ It places a list of links with thumbnails at the bottom of your posts. It increases pageviews and engages readers to stay on your site longer and discover more of your content. It also recommends related posts from across the web and in turn promotes your posts to other users. In this way you get new unique visitors to your site and improve SEO.
26
 
27
+ = Why should I use this plugin and not any other? =
28
 
29
+ WordPress Related Posts is constantly improved to bring you the highest rates of audience engagement with your content. Our highest Click-Through rates speak for themselves.
30
 
31
  = Are there any settings? Plenty! =
32
 
40
 
41
  Yes, related posts are responsive so they adapt to the screen size to ensure maximum click-through rates.
42
 
43
+ = Can I customize the widget? =
44
+
45
+ Yes, Zemanta is offered in different themes which you can also customize with simple CSS.
46
 
47
+ = Will Zemanta steal my "link-juice"? =
48
+
49
+ No, Zemanta does not use redirects and is juice friendly. :)
50
 
51
  == Installation ==
52
 
81
 
82
  == Changelog ==
83
 
84
+ = 2.9 =
85
+ * Themes are now included with the plugin to simplify loading and customization
86
+ * Simplified javascript loading
87
+
88
  = 2.8 =
89
  * New thumbnailer
90
  * Edit Related Posts gets a visual upgrade, search functionality and a dose of awesome
recommendations.php CHANGED
@@ -8,6 +8,9 @@ function wp_rp_update_tags($post_id) {
8
  $post = get_post($post->post_parent);
9
  }
10
 
 
 
 
11
  $wpdb->query(
12
  $wpdb->prepare('DELETE from ' . $wpdb->prefix . 'wp_rp_tags WHERE post_id=%d', $post->ID)
13
  );
@@ -154,73 +157,84 @@ function wp_rp_generate_tags($post) {
154
  function wp_rp_fetch_related_posts_v2($limit = 10, $exclude_ids = array()) {
155
  global $wpdb, $post;
156
 
157
- $related_post_ids = null;
 
 
158
 
159
- $options = wp_rp_get_options();
160
- $exclude_ids_str = wp_rp_get_exclude_ids_list_string($exclude_ids);
 
 
 
 
161
 
162
- $tags_query = "SELECT label FROM " . $wpdb->prefix . "wp_rp_tags WHERE post_id=$post->ID;";
163
- $tags = $wpdb->get_col($tags_query, 0);
164
- if (empty($tags)) {
165
- $tags = wp_rp_generate_tags($post);
166
  if (empty($tags)) {
167
- return array();
 
 
 
168
  }
169
- }
170
 
171
- if($options['exclude_categories']) {
172
- $exclude_categories = get_categories(array('include' => $options['exclude_categories']));
173
- $exclude_categories_labels = array_map(create_function('$c', 'return "C_" . $c->name;'), $exclude_categories);
174
- } else {
175
- $exclude_categories_labels = array();
176
- }
177
 
178
- $total_number_of_posts = $wpdb->get_col("SELECT count(distinct(post_id)) FROM " . $wpdb->prefix . "wp_rp_tags;", 0);
179
- if (empty($total_number_of_posts)) {
180
- return array();
181
- }
182
- $total_number_of_posts = $total_number_of_posts[0];
183
-
184
- $post_id_query = $wpdb->prepare("
185
- SELECT
186
- target.post_id, sum(target.weight * log(%d / least(%d, freqs.freq))) as score
187
- FROM
188
- " . $wpdb->prefix . "wp_rp_tags as target,
189
- (SELECT label, count(1) as freq FROM " . $wpdb->prefix . "wp_rp_tags
190
- WHERE label IN (" . implode(', ', array_fill(0, count($tags), "%s")) . ")
191
- GROUP BY label
192
- ) as freqs
193
- WHERE
194
- target.post_id NOT IN (%s) AND
195
- " . ($options['max_related_post_age_in_days'] > 0 ? "target.post_date > DATE_SUB(CURDATE(), INTERVAL %s DAY) AND" : "") . "
196
- target.label=freqs.label AND
197
- target.label IN (" . implode(', ', array_fill(0, count($tags), "%s")) . ")" .
198
- (empty($exclude_categories_labels) ? "" : " AND
199
- target.post_id NOT IN (
200
- SELECT post_id FROM " . $wpdb->prefix . "wp_rp_tags
201
- WHERE label IN (" . implode(', ', array_fill(0, count($exclude_categories_labels), "%s")) . ")
202
- )") . "
203
- GROUP BY target.post_id
204
- ORDER BY score desc, target.post_id desc
205
- LIMIT %d;",
206
- array_merge(
207
- array($total_number_of_posts, $total_number_of_posts),
208
- $tags,
209
- array($exclude_ids_str),
210
- $options['max_related_post_age_in_days'] > 0 ? array($options['max_related_post_age_in_days']) : array(),
211
- $tags,
212
- $exclude_categories_labels,
213
- array($limit * 2)
214
- )
215
- ); // limit * 2 just in case
 
 
 
 
 
216
 
217
- $related_posts_with_score = $wpdb->get_results($post_id_query, 0);
218
- if (empty($related_posts_with_score)) {
219
- return array();
220
  }
221
 
222
  $related_posts_with_score_map = array();
223
- foreach ($related_posts_with_score as $rp) {
224
  $related_posts_with_score_map[$rp->post_id] = $rp->score;
225
  }
226
 
8
  $post = get_post($post->post_parent);
9
  }
10
 
11
+ delete_post_meta($post->ID, '_wp_rp_related_posts_query_result_cache_expiration');
12
+ delete_post_meta($post->ID, '_wp_rp_related_posts_query_result_cache');
13
+
14
  $wpdb->query(
15
  $wpdb->prepare('DELETE from ' . $wpdb->prefix . 'wp_rp_tags WHERE post_id=%d', $post->ID)
16
  );
157
  function wp_rp_fetch_related_posts_v2($limit = 10, $exclude_ids = array()) {
158
  global $wpdb, $post;
159
 
160
+ $timestamp = time();
161
+ $related_posts_query_result_cache_expiration = (int) get_post_meta($post->ID, '_wp_rp_related_posts_query_result_cache_expiration', true);
162
+ $related_posts_query_result_cache = get_post_meta($post->ID, '_wp_rp_related_posts_query_result_cache', true);
163
 
164
+ if (!$related_posts_query_result_cache || !$related_posts_query_result_cache_expiration || $related_posts_query_result_cache_expiration < $timestamp) { // Cache empty or never cached or cache expired
165
+
166
+ $related_post_ids = null;
167
+
168
+ $options = wp_rp_get_options();
169
+ $exclude_ids_str = wp_rp_get_exclude_ids_list_string($exclude_ids);
170
 
171
+ $tags_query = "SELECT label FROM " . $wpdb->prefix . "wp_rp_tags WHERE post_id=$post->ID;";
172
+ $tags = $wpdb->get_col($tags_query, 0);
 
 
173
  if (empty($tags)) {
174
+ $tags = wp_rp_generate_tags($post);
175
+ if (empty($tags)) {
176
+ return array();
177
+ }
178
  }
 
179
 
180
+ if($options['exclude_categories']) {
181
+ $exclude_categories = get_categories(array('include' => $options['exclude_categories']));
182
+ $exclude_categories_labels = array_map(create_function('$c', 'return "C_" . $c->name;'), $exclude_categories);
183
+ } else {
184
+ $exclude_categories_labels = array();
185
+ }
186
 
187
+ $total_number_of_posts = $wpdb->get_col("SELECT count(distinct(post_id)) FROM " . $wpdb->prefix . "wp_rp_tags;", 0);
188
+ if (empty($total_number_of_posts)) {
189
+ return array();
190
+ }
191
+ $total_number_of_posts = $total_number_of_posts[0];
192
+
193
+ $post_id_query = $wpdb->prepare("
194
+ SELECT
195
+ target.post_id, sum(target.weight * log(%d / least(%d, freqs.freq))) as score
196
+ FROM
197
+ " . $wpdb->prefix . "wp_rp_tags as target,
198
+ (SELECT label, count(1) as freq FROM " . $wpdb->prefix . "wp_rp_tags
199
+ WHERE label IN (" . implode(', ', array_fill(0, count($tags), "%s")) . ")
200
+ GROUP BY label
201
+ ) as freqs
202
+ WHERE
203
+ target.post_id NOT IN (%s) AND
204
+ " . ($options['max_related_post_age_in_days'] > 0 ? "target.post_date > DATE_SUB(CURDATE(), INTERVAL %s DAY) AND" : "") . "
205
+ target.label=freqs.label AND
206
+ target.label IN (" . implode(', ', array_fill(0, count($tags), "%s")) . ")" .
207
+ (empty($exclude_categories_labels) ? "" : " AND
208
+ target.post_id NOT IN (
209
+ SELECT post_id FROM " . $wpdb->prefix . "wp_rp_tags
210
+ WHERE label IN (" . implode(', ', array_fill(0, count($exclude_categories_labels), "%s")) . ")
211
+ )") . "
212
+ GROUP BY target.post_id
213
+ ORDER BY score desc, target.post_id desc
214
+ LIMIT %d;",
215
+ array_merge(
216
+ array($total_number_of_posts, $total_number_of_posts),
217
+ $tags,
218
+ array($exclude_ids_str),
219
+ $options['max_related_post_age_in_days'] > 0 ? array($options['max_related_post_age_in_days']) : array(),
220
+ $tags,
221
+ $exclude_categories_labels,
222
+ array($limit * 2)
223
+ )
224
+ ); // limit * 2 just in case
225
+
226
+ $related_posts_query_result_cache = $wpdb->get_results($post_id_query, 0);
227
+ if (empty($related_posts_query_result_cache)) {
228
+ return array();
229
+ }
230
 
231
+ // Update the cache
232
+ update_post_meta($post->ID, '_wp_rp_related_posts_query_result_cache_expiration', $timestamp + 24 * 60 * 60); // one day
233
+ update_post_meta($post->ID, '_wp_rp_related_posts_query_result_cache', $related_posts_query_result_cache);
234
  }
235
 
236
  $related_posts_with_score_map = array();
237
+ foreach ($related_posts_query_result_cache as $rp) {
238
  $related_posts_with_score_map[$rp->post_id] = $rp->score;
239
  }
240
 
settings.php CHANGED
@@ -268,10 +268,10 @@ function wp_rp_settings_page() {
268
  <div class="wrap" id="wp_rp_wrap">
269
  <input type="hidden" id="wp_rp_ajax_nonce" value="<?php echo wp_create_nonce("wp_rp_ajax_nonce"); ?>" />
270
 
271
- <input type="hidden" id="wp_rp_json_url" value="<?php esc_attr_e(WP_RP_STATIC_BASE_URL . WP_RP_STATIC_JSON_PATH); ?>" />
272
  <input type="hidden" id="wp_rp_version" value="<?php esc_attr_e(WP_RP_VERSION); ?>" />
273
  <input type="hidden" id="wp_rp_dashboard_url" value="<?php esc_attr_e(WP_RP_CTR_DASHBOARD_URL); ?>" />
274
  <input type="hidden" id="wp_rp_static_base_url" value="<?php esc_attr_e(WP_RP_STATIC_BASE_URL); ?>" />
 
275
 
276
  <?php if ($options['ctr_dashboard_enabled']):?>
277
  <input type="hidden" id="wp_rp_blog_id" value="<?php esc_attr_e($meta['blog_id']); ?>" />
268
  <div class="wrap" id="wp_rp_wrap">
269
  <input type="hidden" id="wp_rp_ajax_nonce" value="<?php echo wp_create_nonce("wp_rp_ajax_nonce"); ?>" />
270
 
 
271
  <input type="hidden" id="wp_rp_version" value="<?php esc_attr_e(WP_RP_VERSION); ?>" />
272
  <input type="hidden" id="wp_rp_dashboard_url" value="<?php esc_attr_e(WP_RP_CTR_DASHBOARD_URL); ?>" />
273
  <input type="hidden" id="wp_rp_static_base_url" value="<?php esc_attr_e(WP_RP_STATIC_BASE_URL); ?>" />
274
+ <input type="hidden" id="wp_rp_plugin_static_base_url" value="<?php esc_attr_e(plugins_url("static/", __FILE__)); ?>" />
275
 
276
  <?php if ($options['ctr_dashboard_enabled']):?>
277
  <input type="hidden" id="wp_rp_blog_id" value="<?php esc_attr_e($meta['blog_id']); ?>" />
static/img/themes/m-modern.jpg ADDED
Binary file
static/img/themes/m-plain.jpg ADDED
Binary file
static/img/themes/m-stream.jpg ADDED
Binary file
static/img/themes/modern.jpg ADDED
Binary file
static/img/themes/momma.jpg ADDED
Binary file
static/img/themes/pinterest.jpg ADDED
Binary file
static/img/themes/plain.jpg ADDED
Binary file
static/img/themes/twocolumns.jpg ADDED
Binary file
static/img/themes/vertical-m.jpg ADDED
Binary file
static/img/themes/vertical-s.jpg ADDED
Binary file
static/img/themes/vertical.jpg ADDED
Binary file
static/js/dashboard.js CHANGED
@@ -1,5 +1,5 @@
1
  (function(a){var e=function(b,e){a.each(e,function(a,e){b=b.replace(RegExp("{{ *"+a+" *}}"),e)});return b};a(function(){var b=a("#wp_rp_earnings_wrap"),j=a("#wp_rp_earnings_holder"),f=a("#wp_rp_statistics_wrap"),k=a("#wp_rp_dashboard_url").val(),h=a("#wp_rp_blog_id").val(),i=a("#wp_rp_auth_key").val(),g=a("#wp_rp_ajax_nonce").val();traffic_exchange_enabled=0<a("#wp_rp_show_traffic_exchange_statistics").length;promoted_content_enabled=0<a("#wp_rp_show_promoted_content_statistics").length;update_interval=
2
- req_timeout=null;update_interval_sec=2E3;update_interval_error_sec=3E4;updating=!1;ul=null;stats={};set_update_interval=function(a){a||(a=update_interval_sec);clearInterval(update_interval);0<a&&(update_interval=setInterval(update_dashboard,a))};display_error=function(c){var l=a("#wp_rp_statistics_wrap");c||l.find(".unavailable").slideDown();set_update_interval(update_interval_error_sec);updating=!1};create_dashboard=function(){ul=a('<ul class="statistics" />');f.find(".unavailable").slideUp();ul.append('<li class="title"><div class="desktop">Desktop</div><div class="mobile">Mobile</div></li>');
3
  ul.append(e('<li class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',{"class":"ctr",title:"click-through rate",range:"last 30 days"}));ul.append(e('<li class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',{"class":"pageviews",title:"page views",range:"last 30 days"}));ul.append(e('<li class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',
4
  {"class":"clicks",title:"clicks",range:"last 30 days"}));f.append(ul);traffic_exchange_enabled&&f.append('<div class="network"><div class="icon"></div><span class="num"></span><h4>Inbound Visitors</h4><div class="description"><p>Number of visitors that came to your site because this plugin promoted your content on other sites.<strong>Wow, a traffic exchange! :)</strong></p></div></div>')};update_dashboard=function(c){updating||(updating=!0,req_timeout=setTimeout(function(){display_error(!c)},2E3),
5
  a.getJSON(k+"pageviews/?callback=?",{blog_id:h,auth_key:i},function(a){var d=a.data;clearTimeout(req_timeout);if(!a||"ok"!==a.status||!a.data)display_error(!c);else{ul||create_dashboard();set_update_interval(a.data.update_interval);stats.mobile_pageviews=Math.max(d.mobile_pageviews,stats.mobile_pageviews||0);stats.mobile_clicks=Math.max(d.mobile_clicks,stats.mobile_clicks||0);a=0<stats.mobile_pageviews&&(100*(stats.mobile_clicks/stats.mobile_pageviews)).toFixed(1)||0;stats.desktop_pageviews=Math.max(d.pageviews-
1
  (function(a){var e=function(b,e){a.each(e,function(a,e){b=b.replace(RegExp("{{ *"+a+" *}}"),e)});return b};a(function(){var b=a("#wp_rp_earnings_wrap"),j=a("#wp_rp_earnings_holder"),f=a("#wp_rp_statistics_wrap"),k=a("#wp_rp_dashboard_url").val(),h=a("#wp_rp_blog_id").val(),i=a("#wp_rp_auth_key").val(),g=a("#wp_rp_ajax_nonce").val();traffic_exchange_enabled=0<a("#wp_rp_show_traffic_exchange_statistics").length;promoted_content_enabled=0<a("#wp_rp_show_promoted_content_statistics").length;update_interval=
2
+ req_timeout=null;update_interval_sec=5E3;update_interval_error_sec=3E4;updating=!1;ul=null;stats={};set_update_interval=function(a){a||(a=update_interval_sec);clearInterval(update_interval);0<a&&(update_interval=setInterval(update_dashboard,a))};display_error=function(c){var l=a("#wp_rp_statistics_wrap");c||l.find(".unavailable").slideDown();set_update_interval(update_interval_error_sec);updating=!1};create_dashboard=function(){ul=a('<ul class="statistics" />');f.find(".unavailable").slideUp();ul.append('<li class="title"><div class="desktop">Desktop</div><div class="mobile">Mobile</div></li>');
3
  ul.append(e('<li class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',{"class":"ctr",title:"click-through rate",range:"last 30 days"}));ul.append(e('<li class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',{"class":"pageviews",title:"page views",range:"last 30 days"}));ul.append(e('<li class="{{class}} stats"><p class="num mobile"></p><p class="num all"></p><h5>{{ title}}<span>{{range}}</span></h5></li>',
4
  {"class":"clicks",title:"clicks",range:"last 30 days"}));f.append(ul);traffic_exchange_enabled&&f.append('<div class="network"><div class="icon"></div><span class="num"></span><h4>Inbound Visitors</h4><div class="description"><p>Number of visitors that came to your site because this plugin promoted your content on other sites.<strong>Wow, a traffic exchange! :)</strong></p></div></div>')};update_dashboard=function(c){updating||(updating=!0,req_timeout=setTimeout(function(){display_error(!c)},2E3),
5
  a.getJSON(k+"pageviews/?callback=?",{blog_id:h,auth_key:i},function(a){var d=a.data;clearTimeout(req_timeout);if(!a||"ok"!==a.status||!a.data)display_error(!c);else{ul||create_dashboard();set_update_interval(a.data.update_interval);stats.mobile_pageviews=Math.max(d.mobile_pageviews,stats.mobile_pageviews||0);stats.mobile_clicks=Math.max(d.mobile_clicks,stats.mobile_clicks||0);a=0<stats.mobile_pageviews&&(100*(stats.mobile_clicks/stats.mobile_pageviews)).toFixed(1)||0;stats.desktop_pageviews=Math.max(d.pageviews-
static/js/themes.js CHANGED
@@ -1,5 +1,5 @@
1
- (function(a){a(function(){var i={mobile:{wrap:a("#wp_rp_mobile_theme_options_wrap"),theme_area:a("#wp_rp_mobile_theme_area"),current_theme:a("#wp_rp_mobile_theme_selected").val()},desktop:{wrap:a("#wp_rp_desktop_theme_options_wrap"),theme_area:a("#wp_rp_desktop_theme_area"),current_theme:a("#wp_rp_desktop_theme_selected").val()}},k=a("#wp_rp_static_base_url").val(),l=a("#wp_rp_json_url").val(),m=a("#wp_rp_version").val(),j=null,d=!1;append_get_themes_script=function(){if(d)window.wp_rp_themes_cb();
2
- else{var a=document.createElement("script"),g=document.getElementsByTagName("body").item(0);a.type="text/javascript";a.src=l+"themes2.js?plv="+m;g.appendChild(a)}};update_custom_css_area=function(b){var g=a("#wp_rp_"+b+"_custom_theme_enabled:checked"),e=a("#wp_rp_"+b+"_theme_custom_css_wrap");g.length?(e.show(),g.closest("label").addClass("wp_rp_settings_button_disabled")):(e.hide(),a("#wp_rp_"+b+"_custom_theme_enabled").closest("label").removeClass("wp_rp_settings_button_disabled"))};a.each(i,function(b){update_custom_css_area(b);
3
- a("#wp_rp_"+b+"_custom_theme_enabled").on("change",function(){update_custom_css_area(b)})});window.wp_rp_themes_cb=function(b){if(b&&b.themes&&(j=b.themes))d=!0,a.each(i,function(b,e){var f=e.wrap.find("div.theme-list"),d=e.wrap.find("div.theme-screenshot"),h=function(b){if(b.val()){var b=k+"img/rp-themes/"+b.val().replace(/\.css$/,".jpg"),c=d.find("img");if(c.length){if(c.attr("src")===b)return}else c=a("<img />"),d.html(c);c.attr("src",b)}else d.html("")};f.empty();a.each(j[b],function(a,c){"custom.css"!=
4
- c.location&&f.append('<label class="theme-label"><input '+(c.location===e.current_theme?'checked="checked"':"")+' class="theme-option" type="radio" name="wp_rp_'+b+'_theme_name" value="'+c.location+'" /> '+c.name+"</label><br />")});f.on("hover","label.theme-label",function(){h(a("input",this))});f.on("mouseleave",function(){h(f.find("input:checked"))});h(f.find("input:checked"));e.theme_area.show()});d&&a("#wp_rp_theme_options_wrap").show()};a("#wp_rp_enable_themes:checked").length&&append_get_themes_script();
5
- a("#wp_rp_enable_themes").change(function(){a("#wp_rp_enable_themes:checked").length?append_get_themes_script():a("#wp_rp_theme_options_wrap").hide()})})})(jQuery);
1
+ (function(a){a(function(){var h=a("#wp_rp_plugin_static_base_url").val();platforms={mobile:{wrap:a("#wp_rp_mobile_theme_options_wrap"),theme_area:a("#wp_rp_mobile_theme_area"),current_theme:a("#wp_rp_mobile_theme_selected").val()},desktop:{wrap:a("#wp_rp_desktop_theme_options_wrap"),theme_area:a("#wp_rp_desktop_theme_area"),current_theme:a("#wp_rp_desktop_theme_selected").val()}};themes={mobile:[{name:"Modern",location:"m-modern.css"},{name:"Infinite Stream (experimental)",location:"m-stream.css"},
2
+ {name:"Plain (your own css)",location:"m-plain.css"}],desktop:[{name:"Momma",location:"momma.css"},{name:"Modern",location:"modern.css"},{name:"Vertical (Large)",location:"vertical.css"},{name:"Vertical (Medium)",location:"vertical-m.css"},{name:"Vertical (Small)",location:"vertical-s.css"},{name:"Pinterest Inspired",location:"pinterest.css"},{name:"Two Columns",location:"twocolumns.css"},{name:"Plain (your own css)",location:"plain.css"}]};update_themes=function(){a.each(platforms,function(b,e){var d=
3
+ e.wrap.find("div.theme-list"),f=e.wrap.find("div.theme-screenshot"),g=function(b){if(b.val()){var b=h+"img/themes/"+b.val().replace(/\.css$/,".jpg"),c=f.find("img");if(c.length){if(c.attr("src")===b)return}else c=a("<img />"),f.html(c);c.attr("src",b)}else f.html("")};d.empty();a.each(themes[b],function(a,c){"custom.css"!=c.location&&d.append('<label class="theme-label"><input '+(c.location===e.current_theme?'checked="checked"':"")+' class="theme-option" type="radio" name="wp_rp_'+b+'_theme_name" value="'+
4
+ c.location+'" /> '+c.name+"</label><br />")});d.on("hover","label.theme-label",function(){g(a("input",this))});d.on("mouseleave",function(){g(d.find("input:checked"))});g(d.find("input:checked"));e.theme_area.show()})};update_custom_css_area=function(b){var e=a("#wp_rp_"+b+"_custom_theme_enabled:checked"),d=a("#wp_rp_"+b+"_theme_custom_css_wrap");e.length?(d.show(),e.closest("label").addClass("wp_rp_settings_button_disabled")):(d.hide(),a("#wp_rp_"+b+"_custom_theme_enabled").closest("label").removeClass("wp_rp_settings_button_disabled"))};
5
+ a.each(platforms,function(b){update_custom_css_area(b);a("#wp_rp_"+b+"_custom_theme_enabled").on("change",function(){update_custom_css_area(b)})});a("#wp_rp_enable_themes:checked").length&&(update_themes(),a("#wp_rp_theme_options_wrap").show());a("#wp_rp_enable_themes").change(function(){a("#wp_rp_enable_themes:checked").length?append_get_themes_script():a("#wp_rp_theme_options_wrap").hide()})})})(jQuery);
static/themes/edit_related_posts.css ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #wp_rp_zem_related_posts_holder {position: fixed; top: 0; left: 0; height: 100%; padding-top: 5%; width: 100%; margin: 0; z-index:999999; text-align: center;background:rgba(0,0,0,0.8);}
2
+ #wp_rp_zem_related_posts_holder * {-webkit-box-sizing:content-box; -moz-box-sizing:content-box; box-sizing:content-box;}
3
+ #wp_rp_zem_related_posts_wrap {position: relative; display: inline-block; min-width: 680px; max-width: 90%; height: auto; margin: 0 auto; background: #f8f8f8; border:none; border-radius: 2px; overflow:hidden; text-align: left;box-shadow:0 0 10px rgba(0,0,0,.1);box-shadow:0 0 8px rgba(0,0,0,0.2);}
4
+ #wp_rp_zem_related_posts_wrap > div {background:none;}
5
+
6
+ #wp_rp_zem_related_posts_wrap h4 {font-weight: normal; font-size: 16px; font-weight: bold; margin: 20px; line-height: 16px;}
7
+ #wp_rp_zem_related_posts_wrap h5 {font-weight: normal; font-size: 13px; margin: 20px; line-height: 16px;}
8
+
9
+ #wp_rp_zem_related_posts_wrap .button {background: #f79124;border:none;color:#fff;text-decoration: none; font-size: 15px; line-height: 23px; margin: 0; padding: 7px 25px; cursor: pointer;-webkit-border-radius: 2px; -webkit-appearance: none; border-radius: 2px; white-space: nowrap; position: relative; text-align: center; display: block;}
10
+ #wp_rp_zem_related_posts_wrap .button:hover {box-shadow:0 1px 3px rgba(0,0,0,.2);background: #ff8400;}
11
+ #wp_rp_zem_related_posts_wrap .button:active {box-shadow:0 1px 3px rgba(0,0,0,.2) inset;}
12
+
13
+ #wp_rp_replace_article_wrap {background:#f1f3f3; position: relative; overflow: hidden;}
14
+ #wp_rp_replace_article_wrap div.txt {background:transparent;}
15
+ #wp_rp_replace_article_wrap .content {position: relative;}
16
+ #wp_rp_replace_article_wrap .content ul {height: 180px; overflow-x: auto; overflow-y: hidden; white-space: nowrap;margin:0;padding:0;}
17
+ #wp_rp_replace_article_wrap .content ul li {margin:0 3px 20px 3px;background: #fff; white-space: normal;}
18
+
19
+ #wp_rp_replace_article_wrap .remove-article-sign {display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; color: #fff; text-align: center; font-size: 25px; z-index: 5;background:#f79124;vertical-align:middle;padding-top:140px;}
20
+
21
+ #wp_rp_replace_article_wrap .content .scroll-left:before {content: "\a0"; box-shadow: inset 15px 0px 15px -15px rgba(0, 0, 0, 1); height: 155px; width: 20px; position: absolute; left: 0px; z-index: 4;}
22
+ #wp_rp_replace_article_wrap .content .scroll-right:after {content: "\a0"; box-shadow: inset -15px 0px 15px -15px rgba(0, 0, 0, 1);; height: 155px; width: 20px; position: absolute; right: 0px; z-index: 4;}
23
+
24
+ #wp_rp_zem_related_posts_wrap .selected-header {overflow: hidden;}
25
+ #wp_rp_zem_related_posts_wrap .selected-header h4 {float: left;padding: 10px 0 0 6px;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}
26
+ #wp_rp_zem_related_posts_wrap .selected-header a.save {float: right; top: 25px; right: 25px;}
27
+
28
+ #wp_rp_zem_related_posts_wrap .recommendations-header {overflow: hidden;}
29
+ #wp_rp_zem_related_posts_wrap .recommendations-header h4 {display: inline-block;padding:0 20px 0 5px;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}
30
+ #wp_rp_zem_related_posts_wrap .recommendations-header form.search {display: inline-block; background: none;margin:9px 20px 0 0;float:right;}
31
+ #wp_rp_zem_related_posts_wrap .recommendations-header form.search>input.search {padding:0 0 0 10px; width: 290px;border:1px solid #abb1b3;border-radius:2px;height: 38px;vertical-align:middle;box-sizing:border-box;font-size:13px;background:#fff;}
32
+ #wp_rp_zem_related_posts_wrap .recommendations-header form.search input.go {padding:0;display: inline-block; font-size:13px; line-height: 13px; left:-5px; width:50px; height:38px; vertical-align:middle; text-transform: uppercase;border-radius:0 2px 2px 0;}
33
+ #wp_rp_zem_related_posts_wrap .recommendations-header form.search input.search:focus {border:1px solid #888; font-size: 13px; box-shadow:0px 0px 6px rgba(0,0,0,.15) inset;outline:none;}
34
+ #wp_rp_zem_related_posts_wrap .recommendations-header form.search input.search:focus::-webkit-input-placeholder{
35
+ transition: opacity 0.5s 0.5s ease;
36
+ opacity: 0;
37
+ }
38
+ #wp_rp_zem_related_posts_wrap .recommendations-header form.search input.search::-webkit-search-cancel-button {-webkit-appearance: none;}
39
+ #wp_rp_zem_related_posts_wrap .recommendations-header form.search input.search::-webkit-input-placeholder {font-size:13px;outline:none;line-height:normal;}
40
+ #wp_rp_zem_related_posts_wrap .recommendations-header .search.notice {display: inline-block; background: none;float:right;margin:20px 40px 0 0;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}
41
+
42
+ #wp_rp_zem_related_posts_wrap ul.selected {padding:10px 20px 20px 20px;margin:0;}
43
+ #wp_rp_zem_related_posts_wrap ul li {position: relative; display: inline-block; background: #e6ebed; width: 77px; padding: 4px; margin: 0 3px; vertical-align: top; border-radius: 2px; height: 145px; border: 1px solid #abb1b3; color: #c5c5c5; -webkit-user-drag: element;}
44
+ #wp_rp_zem_related_posts_wrap ul li .droppable {position: absolute; width: 100%; height: 100%; left: 0; top: 0; z-index: -1;}
45
+ #wp_rp_zem_related_posts_wrap ul li span {font-size:12px;line-height:1.3;font-weight:light;}
46
+ #wp_rp_zem_related_posts_wrap ul li .notice {display: block; font-size: 14px; line-height: 17px; padding: 47px 20px; text-align: center; font-weight: light; color: #c5c5c5; text-transform: lowercase;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}
47
+ #wp_rp_zem_related_posts_wrap ul li .title {display: block; height: 45px; overflow: hidden; color: #333; margin:5px 3px;}
48
+ #wp_rp_zem_related_posts_wrap ul li a.open-article {display: block; width: 10px; height:12px; float: right; text-indent:-9999px; background: url(../img/outlink.png) left -12px no-repeat; overflow: hidden;}
49
+ #wp_rp_zem_related_posts_wrap ul li a.open-article:hover {background: url(../img/outlink.png) top left no-repeat;}
50
+ #wp_rp_zem_related_posts_wrap ul li img {width: 77px; height: 77px;}
51
+ #wp_rp_zem_related_posts_wrap ul li a.overlay {display: none; width: 77px; height: 77px; position: absolute; top: 0; left: 0; margin: 4px; background: rgba(25, 100, 180, 0.5); text-decoration: none; cursor: move;}
52
+ #wp_rp_zem_related_posts_wrap ul li a.overlay .txt {width:100%;display: block; text-align: center; color: #fff; font-weight: bold; font-size: 14px; margin: 20px 0; text-transform: uppercase; cursor: pointer;}
53
+ #wp_rp_zem_related_posts_wrap ul li:hover a.overlay {display: block;}
54
+ #wp_rp_zem_related_posts_wrap ul li[draggable=true] {cursor: move; background-color: #fff;}
55
+ #wp_rp_zem_related_posts_wrap ul li[draggable=true]:hover {border: 1px solid #abb1b3; box-shadow: 0px 0px 4px rgba(0,0,0,.3);background-color:#e6ebed;}
56
+ #wp_rp_zem_related_posts_wrap ul.selected li.drop {background-color:#fff;}
57
+ #wp_rp_zem_related_posts_wrap ul li.drop-hint {box-shadow:inset 0 0 4px rgba(0,0,0,0.4);background-color:#ffdfbd;}
58
+ #wp_rp_zem_related_posts_wrap ul li.external {background-image: url(../img/promoted.png); background-repeat:no-repeat;background-size:50%;background-position:center 15px;text-align:center;font-size:10px;}
59
+ #wp_rp_zem_related_posts_wrap ul li.external:hover {background-color: #fff;}
60
+ #wp_rp_zem_related_posts_wrap ul li.external span {font-weight: light;margin-top:55px;color:#adadad;}
61
+ #wp_rp_zem_related_posts_wrap ul li a.open-settings {position: absolute; bottom: 4px; padding: 3px 0; font-size: 12px; width: 77px;font-weight:normal;}
62
+ #wp_rp_zem_related_posts_wrap .content {margin: 20px 24px 0 20px;}
63
+
64
+ #wp_rp_zem_related_posts_wrap .footer {padding: 10px 20px 20px 25px;}
65
+ #wp_rp_zem_related_posts_wrap .footer a {display: block; overflow: hidden; width:88px; height:15px; text-indent: -9999px; background: url(../img/zemanta_logo_footer.png) 0 0 no-repeat; background-size: 88px 15px;}
66
+
67
+ #wp_rp_zem_related_posts_box .hndle .articles_to_insert {margin-left: 7px; color: #999;}
68
+
69
+
70
+ #wp_rp_add_rp {display: block; margin-top: 10px;}
71
+ #wp_rp_add_rp a {background-color: #f79124; background: -webkit-gradient(linear,left top,left bottom,color-stop(0.05,#f79124),color-stop(1,#f57b1e)); border: 1px solid #f57b1e; -webkit-box-shadow: inset 0 1px 0 rgba(230,200,120,0.5);}
72
+
73
+ div.wp_rp_footer a.wp_rp_edit {background: #f79124;border:none;color:#fff !important;text-decoration: none; font-size: 14px !important; line-height: 23px; margin: 0; padding: 6px 20px; cursor: pointer;-webkit-border-radius: 2px; -webkit-appearance: none; border-radius: 2px; white-space: nowrap; position: relative; text-align: center; display: inline-block;text-decoration:none !important;}
74
+ div.wp_rp_footer a.wp_rp_edit:hover {box-shadow:0 1px 3px rgba(0,0,0,.2);background: #ff8400;}
75
+ div.wp_rp_footer a.wp_rp_edit:hover:active {box-shadow:0 1px 3px rgba(0,0,0,.2) inset;}
76
+
77
+
78
+ /* Blacklist */
79
+
80
+ ul.related_post li div.remove_x {position: absolute; top: -13px; right: -13px; width: 26px; height: 26px; background: url(../img/x_btn.png) no-repeat; cursor: pointer; z-index: 2;}
81
+
82
+ #wp_rp_blacklist_confirm_wrapper {position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; z-index: 1000000; background: rgba(0,0,0,0.7);}
83
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_modal {margin: -175px auto 0; border-radius: 6px; width: 510px; background: white; position: relative; top: 50%; overflow: hidden;}
84
+
85
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_header {padding: 20px 20px 10px 20px;}
86
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_header h1 {font-size: 18px; font-weight: 200; margin: 0; color: #454545;}
87
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description {margin: 0 0 10px 0; padding: 20px; color: #111;}
88
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description h2 {text-transform: uppercase; font-size: 14px; font-weight: 400; margin: 0 0 10px 0;}
89
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description h3 {color: #666; font-size: 14px; font-weight: 400; margin: 0 0 20px 0; font-style: italic;}
90
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description h3 a {color: #666; text-decoration: none;}
91
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description h3 a:hover {text-decoration: underline;}
92
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description .wp_rp_survey {margin: 0 0 30px 0;}
93
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description .wp_rp_survey label {display: block; margin: 0 0 5px 0; font-size: 12px;}
94
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description .wp_rp_survey label input {margin: 2px 4px 1px 0; vertical-align: text-bottom;}
95
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description .wp_rp_survey_error {color: #111; margin: 0 0 5px 0;}
96
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description .wp_rp_survey_error.active {color: red;}
97
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_description .wp_rp_notice {font-size: 11px; color: #666; margin: 0 0 30px 0;}
98
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_save {background: #ccc url(../img/logo-grey.png) 430px 32px no-repeat; padding: 20px;}
99
+
100
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_save .wp_rp_button {border:none; color:#fff; text-decoration: none; font-size: 14px; line-height: 23px; margin: 0 10px 0 0; padding: 6px 20px; cursor: pointer; -webkit-border-radius: 2px; -webkit-appearance: none; border-radius: 2px; white-space: nowrap; position: relative; text-align: center; display: inline-block; text-decoration:none;}
101
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_save .wp_rp_button:hover {box-shadow:0 1px 3px rgba(0,0,0,.2);}
102
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_save .wp_rp_button:hover:active {box-shadow:0 1px 3px rgba(0,0,0,.2) inset;}
103
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_save .wp_rp_button.wp_rp_save {background: #f79124;}
104
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_save .wp_rp_button.wp_rp_save:hover {background: #ff8400;}
105
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_save .wp_rp_button.wp_rp_cancel {background: #fff; color: #111;}
106
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_save .wp_rp_button.wp_rp_cancel:hover {background: #fdfdfd;}
107
+
108
+ #wp_rp_blacklist_confirm_wrapper .wp_rp_loader {background: url(../img/loading.gif) no-repeat center center; height: 30px; margin: 20px 0;}
109
+
110
+
111
+ /* special stuff */
112
+ @media only screen and (-webkit-min-device-pixel-ratio:1.5),
113
+ only screen and (min-device-pixel-ratio:1.5) {
114
+
115
+ #wp_rp_zem_related_posts_wrap ul li, #wp_rp_zem_related_posts_wrap ul li:hover, #wp_rp_zem_related_posts_wrap .recommendations-header form.search input.search {
116
+ border:none;
117
+ box-shadow: inset 0 0 1px #000,
118
+ inset 0 0 0 #abb1b3,
119
+ 0 0 0 -1px rgba(0, 0, 0, .5);
120
+ }
121
+ #wp_rp_zem_related_posts_wrap {
122
+ border:none;
123
+ box-shadow: inset 0 0 1px #000,
124
+ inset 0 0 0 #abb1b3,
125
+ 0 0 5px -1px rgba(0, 0, 0, .5)
126
+
127
+ }
128
+ #wp_rp_zem_related_posts_wrap ul li[draggable=true]:hover {
129
+ border:none;
130
+ box-shadow: inset 0 0 1px #000,
131
+ inset 0 0 0 #abb1b3,
132
+ 0 0 6px -1px rgba(0, 0, 0, .5);
133
+ }
134
+ #wp_rp_zem_related_posts_wrap .recommendations-header form.search input.search:focus {
135
+ border:none;
136
+ box-shadow: inset 0 0 1px #000,
137
+ inset 0 0 7px rgba(0,0,0,0.2),
138
+ 0 0 0 -1px rgba(0, 0, 0, .5);
139
+ }
140
+ }
141
+ @-moz-document url-prefix() {
142
+ #wp_rp_zem_related_posts_wrap .recommendations-header form.search input.search {
143
+ height:36px;
144
+ }
145
+ }
146
+
147
+ /* Loader */
148
+ #wp_rp_zem_related_posts_wrap .zem-loader-wrap {position: absolute; top: 52px; left: 0; width: 100%; height: 100%;}
149
+ #wp_rp_zem_related_posts_wrap .zem-loader {width:46.666666666666664px; margin: 110px auto 0 auto; display: none;}
150
+ #wp_rp_zem_related_posts_wrap .zem-no-articles {margin: 110px 0 0 0; text-align: center; display: none; color: #aaa;}
151
+
152
+ #wp_rp_zem_related_posts_wrap .zem-loader-step {background-color:#aaa;float:left;height:10px;margin-left:5px;width:10px;-moz-animation-name:bounce_circleG;-moz-animation-duration:1.9500000000000002s;-moz-animation-iteration-count:infinite;-moz-animation-direction:linear;-moz-border-radius:7px;-webkit-animation-name:bounce_circleG;-webkit-animation-duration:1.9500000000000002s;-webkit-animation-iteration-count:infinite;-webkit-animation-direction:linear;-webkit-border-radius:7px;-ms-animation-name:bounce_circleG;-ms-animation-duration:1.9500000000000002s;-ms-animation-iteration-count:infinite;-ms-animation-direction:linear;-ms-border-radius:7px;-o-animation-name:bounce_circleG;-o-animation-duration:1.9500000000000002s;-o-animation-iteration-count:infinite;-o-animation-direction:linear;-o-border-radius:7px;animation-name:bounce_circleG;animation-duration:1.9500000000000002s;animation-iteration-count:infinite;animation-direction:linear;border-radius:7px;}
153
+ #wp_rp_zem_related_posts_wrap .zem-loader-step.zem-loader-step-1 {-moz-animation-delay:0.39s;-webkit-animation-delay:0.39s;-ms-animation-delay:0.39s;-o-animation-delay:0.39s;animation-delay:0.39s;}
154
+ #wp_rp_zem_related_posts_wrap .zem-loader-step.zem-loader-step-2 {-moz-animation-delay:0.9099999999999999s;-webkit-animation-delay:0.9099999999999999s;-ms-animation-delay:0.9099999999999999s;-o-animation-delay:0.9099999999999999s;animation-delay:0.9099999999999999s;}
155
+ #wp_rp_zem_related_posts_wrap .zem-loader-step.zem-loader-step-3 {-moz-animation-delay:1.1700000000000002s;-webkit-animation-delay:1.1700000000000002s;-ms-animation-delay:1.1700000000000002s;-o-animation-delay:1.1700000000000002s;animation-delay:1.1700000000000002s;}
156
+ @-moz-keyframes bounce_circleG{
157
+ 0% {}
158
+ 50% {background-color:#fff}
159
+ 100% {}
160
+ }
161
+ @-webkit-keyframes bounce_circleG{
162
+ 0%{}
163
+ 50%{background-color:#fff}
164
+ 100%{}
165
+ }
166
+ @-ms-keyframes bounce_circleG{
167
+ 0%{}
168
+ 50%{background-color:#fff}
169
+ 100%{}
170
+ }
171
+ @keyframes bounce_circleG{
172
+ 0%{}
173
+ 50%{background-color:#fff}
174
+ 100%{}
175
+ }
176
+
static/themes/m-modern.css ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp_rp_wrap {
2
+ clear: both;
3
+ }
4
+
5
+ .related_post_title {
6
+ clear: both;
7
+ padding: 0 !important;
8
+ margin: 0 !important;
9
+ }
10
+ div.wp_rp_content {
11
+ display: inline-block !important;
12
+ }
13
+
14
+ div.wp_rp_footer {
15
+ text-align: right !important;
16
+ }
17
+ div.wp_rp_footer a {
18
+ color: #999 !important;
19
+ font-size: 11px !important;
20
+ text-decoration: none !important;
21
+ }
22
+ div.wp_rp_footer a.wp_rp_edit {
23
+ color: #fff !important;
24
+ font-size: 12px !important;
25
+ text-decoration: underline !important;
26
+ font-weight: bold !important;
27
+ background: #f79124 !important;
28
+ border-radius: 2px !important;
29
+ padding: 3px 6px;
30
+ }
31
+ ul.related_post {
32
+ display: inline-block !important;
33
+ position: relative !important;
34
+ margin: 0 !important;
35
+ padding: 0 !important;
36
+ }
37
+ ul.related_post li {
38
+ position: relative !important;
39
+ display: inline-block !important;
40
+ vertical-align: top !important;
41
+ zoom: 1 !important;
42
+ *display: inline !important;
43
+ width: 100px !important;
44
+ margin: 10px 10px 10px 0px !important;
45
+ padding: 0 !important;
46
+ background: none !important;
47
+ }
48
+ ul.related_post li a {
49
+ position: relative !important;
50
+ display: block !important;
51
+ font-size: 12px !important;
52
+ line-height: 1.5em !important;
53
+ text-decoration: none !important;
54
+ margin-bottom: 5px !important;
55
+ text-indent: 0 !important;
56
+ }
57
+ ul.related_post li img {
58
+ display: block !important;
59
+ width: 100px !important;
60
+ height: 100px !important;
61
+ max-width: 100% !important;
62
+ margin: 0 !important;
63
+ padding: 0 !important;
64
+ background: none !important;
65
+ border: none !important;
66
+ float: none !important;
67
+
68
+ border-radius: 3px !important;
69
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
70
+ }
71
+
72
+ ul.related_post li a img.wp_rp_santa_hat {
73
+ display: none !important;
74
+ }
75
+
76
+ ul.related_post li small {
77
+ font-size: 80%;
78
+ }
79
+
80
+ @media screen and (max-width: 480px) {
81
+ ul.related_post li {
82
+ display: block !important;
83
+ width: auto !important;
84
+ clear: both !important;
85
+ }
86
+ ul.related_post li a:nth-child(1) {
87
+ float: left !important;
88
+ }
89
+ ul.related_post li a:nth-child(2) {
90
+ font-size: 14px !important;
91
+ padding: 10px 0 10px 110px !important;
92
+ display: block !important;
93
+ height: 80px !important;
94
+ }
95
+ ul.related_post li img {
96
+ width: 100px !important;
97
+ height: 100px !important;
98
+ }
99
+ }
static/themes/m-plain.css ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ div.wp_rp_footer {
2
+ text-align: right !important;
3
+ }
4
+ div.wp_rp_footer a {
5
+ color: #999 !important;
6
+ font-size: 11px !important;
7
+ text-decoration: none !important;
8
+ }
static/themes/m-stream.css ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp_rp_wrap {
2
+ clear: both;
3
+ }
4
+
5
+ .related_post_title {
6
+ clear: both;
7
+ padding: 0 !important;
8
+ margin: 0 !important;
9
+ }
10
+ div.wp_rp_content {
11
+ display: inline-block !important;
12
+ }
13
+
14
+ div.wp_rp_footer {
15
+ text-align: right !important;
16
+ }
17
+ div.wp_rp_footer a {
18
+ color: #999 !important;
19
+ font-size: 11px !important;
20
+ text-decoration: none !important;
21
+ }
22
+ div.wp_rp_footer a.wp_rp_edit {
23
+ color: #fff !important;
24
+ font-size: 12px !important;
25
+ text-decoration: underline !important;
26
+ font-weight: bold !important;
27
+ background: #f79124 !important;
28
+ border-radius: 2px !important;
29
+ padding: 3px 6px;
30
+ }
31
+ ul.related_post {
32
+ display: inline-block !important;
33
+ position: relative !important;
34
+ margin: 0 !important;
35
+ padding: 0 !important;
36
+ }
37
+ ul.related_post li {
38
+ position: relative !important;
39
+ display: inline-block !important;
40
+ vertical-align: top !important;
41
+ zoom: 1 !important;
42
+ *display: inline !important;
43
+ width: 100px !important;
44
+ margin: 10px 10px 10px 0px !important;
45
+ padding: 0 !important;
46
+ background: none !important;
47
+ }
48
+ ul.related_post li a {
49
+ position: relative !important;
50
+ display: block !important;
51
+ font-size: 12px !important;
52
+ line-height: 1.5em !important;
53
+ text-decoration: none !important;
54
+ margin-bottom: 5px !important;
55
+ text-indent: 0 !important;
56
+ }
57
+ ul.related_post li img {
58
+ display: block !important;
59
+ width: 100px !important;
60
+ height: 100px !important;
61
+ max-width: 100% !important;
62
+ margin: 0 !important;
63
+ padding: 0 !important;
64
+ background: none !important;
65
+ border: none !important;
66
+ float: none !important;
67
+
68
+ border-radius: 3px !important;
69
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
70
+ }
71
+
72
+ ul.related_post li a img.wp_rp_santa_hat {
73
+ display: none !important;
74
+ }
75
+
76
+ ul.related_post li small {
77
+ font-size: 80%;
78
+ }
79
+
80
+ @media screen and (max-width: 480px) {
81
+ ul.related_post li {
82
+ display: block !important;
83
+ width: auto !important;
84
+ clear: both !important;
85
+ }
86
+ ul.related_post li a:nth-child(1) {
87
+ float: left !important;
88
+ }
89
+ ul.related_post li a:nth-child(2) {
90
+ font-size: 14px !important;
91
+ padding: 10px 0 10px 110px !important;
92
+ display: block !important;
93
+ height: 80px !important;
94
+ }
95
+ ul.related_post li img {
96
+ width: 100px !important;
97
+ height: 100px !important;
98
+ }
99
+ }
static/themes/modern.css ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp_rp_wrap {
2
+ clear: both;
3
+ }
4
+
5
+ .wp_rp_wrap .related_post_title {
6
+ background: rgba(245, 245, 245, 1) !important;
7
+ padding: 3px 0 3px 10px !important;
8
+ margin: 0 !important;
9
+ font-weight: normal;
10
+ border-radius: 2px !important;
11
+ border: 1px solid rgba(0, 0, 0, .1) !important;
12
+ clear: both !important;
13
+ }
14
+ div.wp_rp_content {
15
+ display: block !important;
16
+ }
17
+
18
+ div.wp_rp_footer {
19
+ text-align: right !important;
20
+ overflow: hidden !important;
21
+ }
22
+ div.wp_rp_footer a {
23
+ color: #999 !important;
24
+ font-size: 11px !important;
25
+ text-decoration: none !important;
26
+ display: inline-block !important;
27
+ }
28
+ div.wp_rp_footer a.wp_rp_edit {
29
+ color: #fff !important;
30
+ font-size: 12px !important;
31
+ text-decoration: underline !important;
32
+ font-weight: bold !important;
33
+ background: #f79124 !important;
34
+ border-radius: 2px !important;
35
+ padding: 3px 6px;
36
+ }
37
+ ul.related_post {
38
+ margin: 0 0 18px 0 !important;
39
+ padding: 0 !important;
40
+ }
41
+
42
+ ul.related_post li {
43
+ position: relative !important;
44
+ min-height: 60px;
45
+ list-style: none !important;
46
+ padding: 10px 0 10px 0 !important;
47
+ margin: 0 !important;
48
+ border-bottom: 1px solid rgba(0, 0, 0, .1) !important;
49
+ background: none !important;
50
+ }
51
+
52
+ ul.related_post li a {
53
+ position: relative !important;
54
+ text-decoration:none;
55
+ text-indent: 0 !important;
56
+ }
57
+
58
+ ul.related_post li a img {
59
+ width: 60px;
60
+ height: 60px;
61
+ float: left !important;
62
+ margin: 0 10px 0 0 !important;
63
+ padding: 0 !important;
64
+ max-width: 100% !important;
65
+ float: none !important;
66
+ }
67
+
68
+ ul.related_post li a img.wp_rp_santa_hat {
69
+ display: none !important;
70
+ }
71
+
72
+ ul.related_post li a.title {
73
+ vertical-align: top !important;
74
+ }
75
+
76
+ /* override old CSS for new plugin version with CSS classes */
77
+ ul.related_post li a.wp_rp_thumbnail {
78
+ float: left !important;
79
+ margin-right: 10px !important;
80
+ }
81
+ ul.related_post li a.wp_rp_thumbnail img {
82
+ float: none !important;
83
+ margin-right: 0 !important;
84
+ display: block !important;
85
+ }
static/themes/momma.css ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp_rp_wrap {
2
+ clear: both;
3
+ }
4
+
5
+ .wp_rp_wrap .related_post_title {
6
+ clear: both !important;
7
+ margin: 0 !important;
8
+ padding: 20px 0 5px !important;
9
+ border: 0 !important;
10
+ text-align: left !important;
11
+ font-weight: bold !important;
12
+ font-size: 1em !important;
13
+ font-style: normal !important;
14
+ font-variant: normal !important;
15
+ line-height: normal !important;
16
+ }
17
+ div.wp_rp_content {
18
+ display: inline-block !important;
19
+ }
20
+
21
+ div.wp_rp_footer {
22
+ text-align: right !important;
23
+ overflow: hidden !important;
24
+ }
25
+ div.wp_rp_footer a {
26
+ color: #999 !important;
27
+ font-size: 11px !important;
28
+ text-decoration: none !important;
29
+ display: inline-block !important;
30
+ }
31
+ div.wp_rp_footer a.wp_rp_edit {
32
+ color: #fff !important;
33
+ font-size: 12px !important;
34
+ text-decoration: underline !important;
35
+ font-weight: bold !important;
36
+ background: #f79124 !important;
37
+ border-radius: 2px !important;
38
+ padding: 3px 6px;
39
+ }
40
+
41
+ ul.related_post {
42
+ display: inline-block !important;
43
+ position: relative !important;
44
+ margin: 0 !important;
45
+ padding: 0 !important;
46
+ }
47
+ ul.related_post li {
48
+ position: relative !important;
49
+ display: inline-block !important;
50
+ vertical-align: top !important;
51
+ zoom: 1 !important;
52
+ *display: inline !important;
53
+ background: none !important;
54
+ width: 106px !important;
55
+
56
+ min-height: 165px !important;
57
+ margin: 0px !important;
58
+ padding: 5px !important;
59
+ border-right-width: 1px !important;
60
+ border-right-style: solid !important;
61
+ border-right-color: rgb(221, 221, 221) !important;
62
+ border-bottom-style: none !important;
63
+ }
64
+ ul.related_post li:hover {
65
+ background: #dde !important;
66
+ }
67
+ ul.related_post li:last-child {
68
+ border-right: none !important;
69
+ }
70
+ ul.related_post li a {
71
+ position: relative !important;
72
+ display: block !important;
73
+ font-size: 12px !important;
74
+ text-decoration: none !important;
75
+ margin-bottom: 5px !important;
76
+ text-indent: 0 !important;
77
+
78
+ margin: 0 !important;
79
+ border: 0 !important;
80
+ padding: 0 !important;
81
+
82
+ margin: 0px !important;
83
+ font-style: normal !important;
84
+ font-variant: normal !important;
85
+ font-weight: normal !important;
86
+ line-height: normal !important;
87
+ font-family: arial !important;
88
+ color: rgb(68, 68, 68) !important;
89
+ }
90
+ ul.related_post li a.wp_rp_title {
91
+ margin-top: 3px !important;
92
+ }
93
+ ul.related_post li img {
94
+ display: block !important;
95
+ width: 100px !important;
96
+ height: 100px !important;
97
+ max-width: 100% !important;
98
+ margin: 0 !important;
99
+ background: none !important;
100
+
101
+ box-shadow: none !important;
102
+ border-radius: 0 !important;
103
+
104
+ border: 1px solid #ddd !important;
105
+ padding: 2px !important;
106
+ float: none !important;
107
+ }
108
+
109
+ ul.related_post li a img.wp_rp_santa_hat {
110
+ display: none !important;
111
+ }
112
+
113
+ ul.related_post li small {
114
+ font-size: 80%;
115
+ }
116
+
117
+ @media screen and (max-width: 480px) {
118
+ ul.related_post li {
119
+ display: block !important;
120
+ width: auto !important;
121
+ min-height: auto !important;
122
+ clear: both !important;
123
+
124
+ border: 0 !important;
125
+ }
126
+ ul.related_post li a {
127
+ width: auto !important;
128
+ }
129
+ ul.related_post li a:nth-child(1) {
130
+ float: left !important;
131
+ }
132
+ ul.related_post li a:nth-child(2) {
133
+ font-size: 14px !important;
134
+ padding: 10px 0 10px 110px !important;
135
+ display: block !important;
136
+ height: 80px !important;
137
+ }
138
+ ul.related_post li img {
139
+ width: 100px !important;
140
+ height: 100px !important;
141
+ }
142
+ }
static/themes/pinterest.css ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp_rp_wrap {
2
+ clear: both;
3
+ }
4
+ .wp_rp_wrap * {
5
+ box-sizing: content-box !important;
6
+ }
7
+
8
+ ul.related_post {
9
+ list-style:none;
10
+ }
11
+
12
+ div.wp_rp_content {
13
+ display: inline-block !important;
14
+ }
15
+
16
+ ul.related_post, ul.related_post ul {
17
+ margin: 0 !important;
18
+ padding: 0 !important;
19
+ }
20
+
21
+ ul.related_post li {
22
+ display:inline-block;
23
+ width:180px !important;
24
+ vertical-align:top !important;
25
+ padding: 0 !important;
26
+ background: none !important;
27
+
28
+ margin-top: 0;
29
+ margin-right: 15px !important;
30
+ margin-bottom: 0 !important;
31
+ margin-left: 0 !important;
32
+
33
+ float: none !important;
34
+ }
35
+
36
+ @keyframes zemslideup {
37
+ from {transform: translateY(80px);}
38
+ to {transform: translateY(0);}
39
+ }
40
+ @-webkit-keyframes zemslideup {
41
+ from {-webkit-transform: translateY(80px);}
42
+ to {-webkit-transform: translateY(0);}
43
+ }
44
+ @-moz-keyframes zemslideup {
45
+ from {-moz-transform: translateY(80px);}
46
+ to {-moz-transform: translateY(0);}
47
+ }
48
+ @-webkit-keyframes zemfadein {
49
+ from {opacity: 0;}
50
+ to {opacity: 1;}
51
+ }
52
+ @-moz-keyframes zemfadein {
53
+ from {opacity: 0;}
54
+ to {opacity: 1;}
55
+ }
56
+ @keyframes zemfadein {
57
+ from {opacity: 0;}
58
+ to {opacity: 1;}
59
+ }
60
+
61
+ ul.related_post li ul li {
62
+ animation: zemslideup 0.8s ease-out, zemfadein 1s ease-out;
63
+ -webkit-animation: zemslideup 0.8s ease-out, zemfadein 1s ease-out;
64
+ -moz-animation: zemslideup 0.8s ease-out, zemfadein 1s ease-out;
65
+
66
+ border: 1px solid #efefef!important;
67
+ border-radius:1px !important;
68
+ -webkit-border-radius:1px !important;
69
+ -moz-border-radius:1px !important;
70
+ display:block;
71
+ width:150px !important;
72
+ font-size:11px !important;
73
+ background-color:#fff !important;
74
+ box-shadow:0 2px 5px rgba(0,0,0,.16) !important;
75
+ -moz-box-shadow:0 2px 5px rgba(0,0,0,.16) !important;
76
+ -webkit-box-shadow:0px 2px 5px rgba(0,0,0,.16) !important;
77
+ padding:15px !important;
78
+ margin-bottom: 15px !important;
79
+ }
80
+ ul.related_post li ul li:nth-child(odd) {
81
+ animation-duration: 0.6s;
82
+ -webkit-animation-duration: 0.6s;
83
+ -moz-animation-duration: 0.6s;
84
+ }
85
+
86
+ ul.related_post li ul li:hover {
87
+ box-shadow: 0px 5px 20px 3px rgba(0,0,0,0.1) !important;
88
+
89
+ -webkit-transition: all .2s;
90
+ -webkit-transform: scale(1.05, 1.05);;
91
+ -moz-transition: all .2s;
92
+ -moz-transform: scale(1.05, 1.05);;
93
+ transition: all .2s;
94
+ transform: scale(1.05);;
95
+ }
96
+
97
+ ul.related_post li a.wp_rp_title {
98
+ display:block !important;
99
+ text-decoration:none !important;
100
+ width:100% !important;
101
+ color:#000 !important;
102
+ text-indent: 0 !important;
103
+ }
104
+
105
+ ul.related_post li a.wp_rp_thumbnail {
106
+ display:block !important;
107
+ clear:both !important;
108
+ }
109
+
110
+ ul.related_post li a.wp_rp_thumbnail img {
111
+ width:150px !important;
112
+ height:auto !important;
113
+ text-align:center !important;
114
+ border-radius:0 !important;
115
+ box-shadow:none !important;
116
+ padding: 0 !important;
117
+ margin: 0 !important;
118
+ }
119
+
120
+ ul.related_post li p {
121
+ color:#000 !important;
122
+ }
123
+
124
+ ul.related_post li.wp_rp_related_post_load_more {
125
+ display:block;
126
+ width:100% !important;
127
+ margin: 10px 0 !important;
128
+ text-align: center !important;
129
+ }
130
+
131
+ ul.related_post li.wp_rp_related_post_load_more img.zloader {
132
+ box-shadow: none;
133
+ border: none;
134
+ display: none;
135
+ }
136
+
137
+ #wp_rp_related_load_more {
138
+ width: auto !important;
139
+ display: block !important;
140
+
141
+ text-align:center !important;
142
+ border: 1px solid rgba(140,126,126,0.3) !important;
143
+ -moz-box-shadow: inset 0 1px rgba(255,255,255,0.35) !important;
144
+ -webkit-box-shadow: inset 0 1px rgba(255,255,255,0.35) !important;
145
+ box-shadow: inset 0 1px rgba(255,255,255,0.35) !important;
146
+ -moz-border-radius: 6px !important;
147
+ -webkit-border-radius: 6px !important;
148
+ border-radius: 6px !important;
149
+ padding: 7px 9px !important;
150
+ background-color: #f0eded !important;
151
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fdfafb), to(#f0eded), color-stop(0.5, #f9f7f7), color-stop(0.5, #f6f3f4)) !important;
152
+ background-image: -moz-linear-gradient(top, #fdfafb, #f9f7f7 50%, #f6f3f4 50%, #f0eded) !important;
153
+ background-image: -o-linear-gradient(top, #fdfafb, #f9f7f7 50%, #f6f3f4 50%, #f0eded) !important;
154
+ background-image: -webkit-linear-gradient(top, #fdfafb, #f9f7f7 50%, #f6f3f4 50%, #f0eded) !important;
155
+ color: #524d4d !important;
156
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdfafb', endColorstr='#f0eded') !important;
157
+ text-shadow: 0 1px rgba(255,255,255,0.9) !important;
158
+ font-size:12px !important;
159
+ text-decoration:none !important;
160
+ }
161
+
162
+ div.wp_rp_footer {
163
+ text-align: right !important;
164
+ overflow: hidden !important;
165
+ }
166
+ div.wp_rp_footer a {
167
+ color: #999 !important;
168
+ font-size: 11px !important;
169
+ text-decoration: none !important;
170
+ display: inline-block !important;
171
+ }
172
+ div.wp_rp_footer a.wp_rp_edit {
173
+ color: #fff !important;
174
+ font-size: 12px !important;
175
+ text-decoration: underline !important;
176
+ font-weight: bold !important;
177
+ background: #f79124 !important;
178
+ border-radius: 2px !important;
179
+ padding: 3px 6px;
180
+ }
static/themes/plain.css ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ div.wp_rp_footer {
2
+ text-align: right !important;
3
+ }
4
+ div.wp_rp_footer a {
5
+ color: #999 !important;
6
+ font-size: 11px !important;
7
+ text-decoration: none !important;
8
+ }
static/themes/recommendations.css ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ul.related_post li a {word-wrap: break-word;}
2
+ ul.related_post li.wp_rp_promoted a {position:relative;}
3
+ ul.related_post li.wp_rp_remote a {position:relative;}
4
+
5
+ ul.related_post li div.remove_x {
6
+ position: absolute;
7
+ top: -13px;
8
+ right: -13px;
9
+ width: 26px;
10
+ height: 26px;
11
+ background: url(../img/x_btn.png) no-repeat;
12
+ cursor: pointer;
13
+ display: none;
14
+ }
15
+ ul.related_post li:hover div.remove_x { display: block; }
static/themes/twocolumns.css ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp_rp_wrap {
2
+ clear: both;
3
+ }
4
+
5
+ ul.related_post {
6
+ margin: 0 0 18px 0 !important;
7
+ padding: 0 !important;
8
+ -moz-column-count: 2 !important;
9
+ -moz-column-gap: 40px !important;
10
+ -moz-column-rule: 1px solid #ccc !important;
11
+ -webkit-column-count: 2 !important;
12
+ -webkit-column-gap: 40px !important;
13
+ -webkit-column-rule: 1px solid #ccc !important;
14
+ column-count: 2 !important;
15
+ column-gap: 40px !important;
16
+ column-rule: 1px solid #ccc !important;
17
+ }
18
+ ul.related_post li {
19
+ overflow: hidden !important;
20
+ list-style: none !important;
21
+ margin: 0 !important;
22
+ padding: 0 0 10px 0 !important;
23
+ -moz-column-break-inside: avoid !important;
24
+ -webkit-column-break-inside: avoid !important;
25
+ break-inside: avoid-column !important;
26
+ }
27
+ ul.related_post li img {
28
+ display: block !important;
29
+ max-width: 100% !important;
30
+ margin: 0 !important;
31
+ padding: 0 !important;
32
+ background: none !important;
33
+ border: none !important;
34
+ float: none !important;
35
+
36
+ border-radius: 3px !important;
37
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
38
+ }
39
+ ul.related_post li a.wp_rp_thumbnail {
40
+ display: block !important;
41
+ width: 75px !important;
42
+ height: 75px !important;
43
+ overflow: hidden;
44
+ float: left !important;
45
+ margin: 0 10px 0 0 !important;
46
+ padding: 0 !important;
47
+ }
48
+ div.wp_rp_footer {
49
+ text-align: right !important;
50
+ overflow: hidden !important;
51
+ }
52
+ div.wp_rp_footer a {
53
+ color: #999 !important;
54
+ font-size: 11px !important;
55
+ text-decoration: none !important;
56
+ display: inline-block !important;
57
+ }
58
+ div.wp_rp_footer a.wp_rp_edit {
59
+ color: #fff !important;
60
+ font-size: 12px !important;
61
+ text-decoration: underline !important;
62
+ font-weight: bold !important;
63
+ background: #f79124 !important;
64
+ border-radius: 2px !important;
65
+ padding: 3px 6px;
66
+ }
67
+ @media screen and (max-width: 480px) {
68
+ ul.related_post {
69
+ -moz-column-count: auto !important;
70
+ -moz-column-gap: normal !important;
71
+ -moz-column-rule: none !important;
72
+ -webkit-column-count: auto !important;
73
+ -webkit-column-gap: normal !important;
74
+ -webkit-column-rule: none !important;
75
+ column-count: auto !important;
76
+ column-gap: normal !important;
77
+ column-rule: none !important;
78
+ }
79
+ }
static/themes/vertical-m.css ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp_rp_wrap .related_post_title {
2
+ clear: both;
3
+ padding: 0 !important;
4
+ margin: 0 !important;
5
+ }
6
+ div.wp_rp_content {
7
+ display: inline-block !important;
8
+ }
9
+
10
+ div.wp_rp_footer {
11
+ text-align: right !important;
12
+ overflow: hidden !important;
13
+ }
14
+ div.wp_rp_footer a {
15
+ display: inline-block !important;
16
+ color: #999 !important;
17
+ font-size: 11px !important;
18
+ text-decoration: none !important;
19
+ }
20
+ div.wp_rp_footer a.wp_rp_edit {
21
+ color: #fff !important;
22
+ font-size: 12px !important;
23
+ text-decoration: underline !important;
24
+ font-weight: bold !important;
25
+ background: #f79124 !important;
26
+ border-radius: 2px !important;
27
+ padding: 3px 6px;
28
+ }
29
+ ul.related_post {
30
+ display: inline-block !important;
31
+ position: relative !important;
32
+ margin: 0 !important;
33
+ padding: 0 !important;
34
+ }
35
+ ul.related_post li {
36
+ position: relative !important;
37
+ display: inline-block !important;
38
+ vertical-align: top !important;
39
+ zoom: 1 !important;
40
+ *display: inline !important;
41
+ width: 100px !important;
42
+ margin: 10px 10px 10px 0px !important;
43
+ padding: 0 !important;
44
+ background: none !important;
45
+ }
46
+ ul.related_post li a {
47
+ position: relative !important;
48
+ display: block !important;
49
+ font-size: 12px !important;
50
+ line-height: 1.5em !important;
51
+ text-decoration: none !important;
52
+ margin-bottom: 5px !important;
53
+ text-indent: 0 !important;
54
+ }
55
+ ul.related_post li img {
56
+ display: block !important;
57
+ width: 100px !important;
58
+ height: 100px !important;
59
+ max-width: 100% !important;
60
+ margin: 0 !important;
61
+ padding: 0 !important;
62
+ background: none !important;
63
+ border: none !important;
64
+
65
+ border-radius: 3px !important;
66
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
67
+ }
68
+
69
+ ul.related_post li a img.wp_rp_santa_hat {
70
+ display: none !important;
71
+ }
72
+
73
+ ul.related_post li small {
74
+ font-size: 80%;
75
+ }
76
+
77
+ @media screen and (max-width: 480px) {
78
+ ul.related_post li {
79
+ display: block !important;
80
+ width: auto !important;
81
+ clear: both !important;
82
+ }
83
+ ul.related_post li a:nth-child(1) {
84
+ float: left !important;
85
+ }
86
+ ul.related_post li a:nth-child(2) {
87
+ font-size: 14px !important;
88
+ padding: 10px 0 10px 110px !important;
89
+ display: block !important;
90
+ height: 80px !important;
91
+ }
92
+ ul.related_post li img {
93
+ width: 100px !important;
94
+ height: 100px !important;
95
+ }
96
+ }
static/themes/vertical-s.css ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp_rp_wrap .related_post_title {
2
+ clear: both;
3
+ padding: 0 !important;
4
+ margin: 0 !important;
5
+ }
6
+ div.wp_rp_content {
7
+ display: inline-block !important;
8
+ }
9
+
10
+ div.wp_rp_footer {
11
+ text-align: right !important;
12
+ overflow: hidden !important;
13
+ }
14
+ div.wp_rp_footer a {
15
+ color: #999 !important;
16
+ font-size: 11px !important;
17
+ text-decoration: none !important;
18
+ display: inline-block !important;
19
+ }
20
+ div.wp_rp_footer a.wp_rp_edit {
21
+ color: #fff !important;
22
+ font-size: 12px !important;
23
+ text-decoration: underline !important;
24
+ font-weight: bold !important;
25
+ background: #f79124 !important;
26
+ border-radius: 2px !important;
27
+ padding: 3px 6px;
28
+ }
29
+ ul.related_post {
30
+ display: inline-block !important;
31
+ position: relative !important;
32
+ margin: 0 !important;
33
+ padding: 0 !important;
34
+ }
35
+ ul.related_post li {
36
+ position: relative !important;
37
+ display: inline-block !important;
38
+ vertical-align: top !important;
39
+ zoom: 1 !important;
40
+ *display: inline !important;
41
+ width: 75px !important;
42
+ margin: 10px 10px 10px 0px !important;
43
+ padding: 0 !important;
44
+ background: none !important;
45
+ }
46
+ ul.related_post li a {
47
+ position: relative !important;
48
+ display: block !important;
49
+ font-size: 11px !important;
50
+ line-height: 1.5em !important;
51
+ text-decoration: none !important;
52
+ margin-bottom: 5px !important;
53
+ text-indent: 0 !important;
54
+ }
55
+ ul.related_post li img {
56
+ display: block !important;
57
+ width: 75px !important;
58
+ height: 75px !important;
59
+ max-width: 100% !important;
60
+ margin: 0 !important;
61
+ padding: 0 !important;
62
+ background: none !important;
63
+ border: none !important;
64
+
65
+ border-radius: 3px !important;
66
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
67
+ }
68
+
69
+ ul.related_post li a img.wp_rp_santa_hat {
70
+ display: none !important;
71
+ }
72
+
73
+ ul.related_post li small {
74
+ font-size: 80%;
75
+ }
76
+
77
+ @media screen and (max-width: 480px) {
78
+ ul.related_post li {
79
+ display: block !important;
80
+ width: auto !important;
81
+ clear: both !important;
82
+ }
83
+ ul.related_post li a:nth-child(1) {
84
+ float: left !important;
85
+ }
86
+ ul.related_post li a:nth-child(2) {
87
+ font-size: 14px !important;
88
+ padding: 10px 0 10px 110px !important;
89
+ display: block !important;
90
+ height: 80px !important;
91
+ }
92
+ ul.related_post li img {
93
+ width: 100px !important;
94
+ height: 100px !important;
95
+ }
96
+ }
static/themes/vertical.css ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp_rp_wrap .related_post_title {
2
+ clear: both;
3
+ padding: 0 !important;
4
+ margin: 0 !important;
5
+ }
6
+ div.wp_rp_content {
7
+ display: inline-block !important;
8
+ }
9
+
10
+ div.wp_rp_footer {
11
+ text-align: right !important;
12
+ overflow: hidden !important;
13
+ }
14
+ div.wp_rp_footer a {
15
+ color: #999 !important;
16
+ font-size: 11px !important;
17
+ text-decoration: none !important;
18
+ display: inline-block !important;
19
+ }
20
+ div.wp_rp_footer a.wp_rp_edit {
21
+ color: #fff !important;
22
+ font-size: 12px !important;
23
+ text-decoration: underline !important;
24
+ font-weight: bold !important;
25
+ background: #f79124 !important;
26
+ border-radius: 2px !important;
27
+ padding: 3px 6px;
28
+ }
29
+ ul.related_post {
30
+ display: inline-block !important;
31
+ position: relative !important;
32
+ margin: 0 !important;
33
+ padding: 0 !important;
34
+ }
35
+ ul.related_post li {
36
+ position: relative !important;
37
+ display: inline-block !important;
38
+ vertical-align: top !important;
39
+ zoom: 1 !important;
40
+ *display: inline !important;
41
+ width: 150px !important;
42
+ margin: 10px 10px 10px 0px !important;
43
+ padding: 0 !important;
44
+ background: none !important;
45
+ }
46
+ ul.related_post li a {
47
+ position: relative !important;
48
+ display: block !important;
49
+ font-size: 13px !important;
50
+ line-height: 1.6em !important;
51
+ text-decoration: none !important;
52
+ margin-bottom: 5px !important;
53
+ text-indent: 0 !important;
54
+ }
55
+ ul.related_post li img {
56
+ display: block !important;
57
+ width: 150px !important;
58
+ height: 150px !important;
59
+ max-width: 100% !important;
60
+ margin: 0 !important;
61
+ padding: 0 !important;
62
+ background: none !important;
63
+ border: none !important;
64
+
65
+ border-radius: 3px !important;
66
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
67
+ }
68
+
69
+ ul.related_post li a img.wp_rp_santa_hat {
70
+ display: none !important;
71
+ }
72
+
73
+ ul.related_post li small {
74
+ font-size: 80%;
75
+ }
76
+
77
+ @media screen and (max-width: 480px) {
78
+ ul.related_post li {
79
+ display: block !important;
80
+ width: auto !important;
81
+ clear: both !important;
82
+ }
83
+ ul.related_post li a:nth-child(1) {
84
+ float: left !important;
85
+ }
86
+ ul.related_post li a:nth-child(2) {
87
+ font-size: 14px !important;
88
+ padding: 10px 0 10px 110px !important;
89
+ display: block !important;
90
+ height: 80px !important;
91
+ }
92
+ ul.related_post li img {
93
+ width: 100px !important;
94
+ height: 100px !important;
95
+ }
96
+ }
wp_related_posts.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
  /*
3
  Plugin Name: WordPress Related Posts
4
- Version: 2.8
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', '2.8');
12
 
13
  define('WP_RP_PLUGIN_FILE', plugin_basename(__FILE__));
14
 
@@ -32,6 +32,14 @@ register_deactivation_hook(__FILE__, 'wp_rp_deactivate_hook');
32
  add_action('wp_head', 'wp_rp_head_resources');
33
  add_action('wp_before_admin_bar_render', 'wp_rp_extend_adminbar');
34
 
 
 
 
 
 
 
 
 
35
  function wp_rp_extend_adminbar() {
36
  global $wp_admin_bar;
37
 
@@ -49,6 +57,7 @@ global $wp_rp_output;
49
  $wp_rp_output = array();
50
  function wp_rp_add_related_posts_hook($content) {
51
  global $wp_rp_output, $post;
 
52
  $options = wp_rp_get_options();
53
 
54
  if ($post->post_type === 'post' && (($options["on_single_post"] && is_single()) || (is_feed() && $options["on_rss"]))) {
@@ -361,7 +370,7 @@ add_action('wp_ajax_rp_blogger_network_blacklist', 'wp_rp_ajax_blogger_network_b
361
 
362
  function wp_rp_head_resources() {
363
  global $post, $wpdb;
364
-
365
  //error_log("call to wp_rp_head_resources");
366
 
367
  if (wp_rp_should_exclude()) {
@@ -413,25 +422,22 @@ function wp_rp_head_resources() {
413
 
414
  $output .= "<script type=\"text/javascript\">\n" . $output_vars . "</script>\n";
415
 
416
- if ($remote_recommendations) {
417
- $output .= '<script type="text/javascript" src="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_RECOMMENDATIONS_JS_FILE . '?version=' . WP_RP_VERSION . '"></script>' . "\n";
418
- $output .= '<link rel="stylesheet" href="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_RECOMMENDATIONS_CSS_FILE . '?version=' . WP_RP_VERSION . '" />' . "\n";
419
- }
420
-
421
  if($statistics_enabled) {
422
- $output .= '<script type="text/javascript" src="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_CTR_PAGEVIEW_FILE . '?version=' . WP_RP_VERSION . '" async></script>' . "\n";
423
  }
424
 
425
  if ($options['enable_themes']) {
426
- $theme_url = WP_RP_STATIC_BASE_URL . WP_RP_STATIC_THEMES_PATH;
 
 
 
 
427
 
428
- $output .= '<link rel="stylesheet" href="' . $theme_url . $platform_options['theme_name'] . '?version=' . WP_RP_VERSION . '" />' . "\n";
429
  if ($platform_options['custom_theme_enabled']) {
430
  $output .= '<style type="text/css">' . "\n" . $platform_options['theme_custom_css'] . "</style>\n";
431
  }
432
 
433
  if ($platform_options['theme_name'] === 'm-stream.css') {
434
- //error_log("infinite JS loaded");
435
  wp_enqueue_script('wp_rp_infiniterecs', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_INFINITE_RECS_JS_FILE, array('jquery'), WP_RP_VERSION);
436
  }
437
 
@@ -440,7 +446,7 @@ function wp_rp_head_resources() {
440
  }
441
  }
442
 
443
- if (current_user_can('edit_posts')) {
444
  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);
445
  wp_enqueue_script('wp_rp_edit_related_posts_js', WP_RP_STATIC_BASE_URL . 'js/edit_related_posts.js', array('jquery'), WP_RP_VERSION);
446
  }
@@ -497,7 +503,7 @@ function wp_rp_get_related_posts($before_title = '', $after_title = '') {
497
  }
498
 
499
  $posts_footer = '';
500
- if (current_user_can('edit_posts')) {
501
  $posts_footer .= '<div class="wp_rp_footer"><a class="wp_rp_edit" href="#" id="wp_rp_edit_related_posts">Edit Related Posts</a></div>';
502
  }
503
  if ($options['display_zemanta_linky']) {
1
  <?php
2
  /*
3
  Plugin Name: WordPress Related Posts
4
+ Version: 2.9
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', '2.9');
12
 
13
  define('WP_RP_PLUGIN_FILE', plugin_basename(__FILE__));
14
 
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
 
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 ($post->post_type === 'post' && (($options["on_single_post"] && is_single()) || (is_feed() && $options["on_rss"]))) {
370
 
371
  function wp_rp_head_resources() {
372
  global $post, $wpdb;
373
+
374
  //error_log("call to wp_rp_head_resources");
375
 
376
  if (wp_rp_should_exclude()) {
422
 
423
  $output .= "<script type=\"text/javascript\">\n" . $output_vars . "</script>\n";
424
 
 
 
 
 
 
425
  if($statistics_enabled) {
426
+ $output .= '<script type="text/javascript" src="' . WP_RP_STATIC_BASE_URL . WP_RP_STATIC_LOADER_FILE . '?version=' . WP_RP_VERSION . '" async></script>' . "\n";
427
  }
428
 
429
  if ($options['enable_themes']) {
430
+ $theme_url = plugins_url(WP_RP_STATIC_THEMES_PATH, __FILE__);
431
+
432
+ if ($platform_options['theme_name'] !== 'plain.css' && $platform_options['theme_name'] !== 'm-plain.css') {
433
+ $output .= '<link rel="stylesheet" href="' . $theme_url . $platform_options['theme_name'] . '?version=' . WP_RP_VERSION . '" />' . "\n";
434
+ }
435
 
 
436
  if ($platform_options['custom_theme_enabled']) {
437
  $output .= '<style type="text/css">' . "\n" . $platform_options['theme_custom_css'] . "</style>\n";
438
  }
439
 
440
  if ($platform_options['theme_name'] === 'm-stream.css') {
 
441
  wp_enqueue_script('wp_rp_infiniterecs', WP_RP_STATIC_BASE_URL . WP_RP_STATIC_INFINITE_RECS_JS_FILE, array('jquery'), WP_RP_VERSION);
442
  }
443
 
446
  }
447
  }
448
 
449
+ if (current_user_can('edit_posts') && $statistics_enabled) {
450
  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);
451
  wp_enqueue_script('wp_rp_edit_related_posts_js', WP_RP_STATIC_BASE_URL . 'js/edit_related_posts.js', array('jquery'), WP_RP_VERSION);
452
  }
503
  }
504
 
505
  $posts_footer = '';
506
+ if (current_user_can('edit_posts') && $statistics_enabled) {
507
  $posts_footer .= '<div class="wp_rp_footer"><a class="wp_rp_edit" href="#" id="wp_rp_edit_related_posts">Edit Related Posts</a></div>';
508
  }
509
  if ($options['display_zemanta_linky']) {
zemanta/img/logo.png ADDED
Binary file
zemanta/img/menu_icon.png ADDED
Binary file
zemanta/views/assets.php ADDED
@@ -0,0 +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>
zemanta/views/debug.php ADDED
@@ -0,0 +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>
zemanta/views/message.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +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; ?>
zemanta/views/options-input-checkbox.php ADDED
@@ -0,0 +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; ?>
zemanta/views/options-input-text.php ADDED
@@ -0,0 +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; ?>
zemanta/views/options.php ADDED
@@ -0,0 +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>
zemanta/views/scripts.php ADDED
@@ -0,0 +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>
zemanta/views/stylesheet.php ADDED
@@ -0,0 +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>
zemanta/zemanta.php ADDED
@@ -0,0 +1,708 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define('WP_RP_ZEMANTA_PLUGIN_VERSION_OPTION', 'zemanta_plugin_version');
4
+ define('WP_RP_ZEMANTA_PLUGIN_FLASH_META', 'zemanta_plugin_flash');
5
+
6
+ if(!class_exists('WP_Http')) {
7
+ require_once(ABSPATH . WPINC . '/class-http.php');
8
+ }
9
+
10
+ require_once(ABSPATH . 'wp-admin/includes/image.php');
11
+
12
+ class WPRPZemanta {
13
+
14
+ var $version = '1.2.3';
15
+ var $api_url = 'http://api.zemanta.com/services/rest/0.0/';
16
+ var $api_key = '';
17
+ var $options = array();
18
+ var $supported_features = array();
19
+ var $update_notes = array();
20
+ var $flash_data = null;
21
+ var $top_menu_slug = null;
22
+
23
+ public function __construct()
24
+ {
25
+ global $wp_version;
26
+
27
+ // initialize update notes shown once on plugin update
28
+ $this->update_notes['1.0.5'] = __('Please double-check your upload paths in Zemanta Settings, we changed some things that might affect your images.', 'zemanta');
29
+ $this->update_notes['1.0.7'] = __('Please double-check your upload paths in Zemanta Settings, we changed some things that might affect your images.', 'zemanta');
30
+ $this->update_notes['1.0.8'] = __('Please double-check your upload paths in Zemanta Settings, we changed some things that might affect your images.', 'zemanta');
31
+
32
+ add_action('admin_init', array($this, 'init'));
33
+ add_action('admin_init', array($this, 'register_options'));
34
+
35
+ register_activation_hook(dirname(__FILE__) . '/zemanta.php', array($this, 'activate'));
36
+
37
+ $this->supported_features['featured_image'] = version_compare($wp_version, '3.1', '>=') >= 0;
38
+ }
39
+
40
+ /**
41
+ * admin_init
42
+ *
43
+ * Initialize plugin
44
+ *
45
+ */
46
+ public function init()
47
+ {
48
+ add_action('wp_ajax_zemanta_set_featured_image', array($this, 'ajax_zemanta_set_featured_image'));
49
+ add_action('edit_form_advanced', array($this, 'assets'), 1);
50
+ add_action('edit_page_form', array($this, 'assets'), 1);
51
+ add_action('save_post', array($this, 'save_post'), 20);
52
+
53
+ $this->check_plugin_updated();
54
+ $this->create_options();
55
+ $this->check_options();
56
+
57
+ if(!$this->check_dependencies())
58
+ add_action('admin_notices', array($this, 'warning'));
59
+ }
60
+
61
+ /**
62
+ * activate
63
+ *
64
+ * Run any functions needed for plugin activation
65
+ */
66
+ public function activate()
67
+ {
68
+ $this->fix_user_meta();
69
+ }
70
+
71
+ /**
72
+ * admin_head
73
+ *
74
+ * Add any assets to the edit page
75
+ */
76
+ public function assets()
77
+ {
78
+ $this->render('assets', array(
79
+ 'api_key' => $this->api_key,
80
+ 'version' => $this->version,
81
+ 'features' => $this->supported_features
82
+ ));
83
+ }
84
+
85
+ /**
86
+ * warning for no api key
87
+ *
88
+ * Display api key warning
89
+ */
90
+ public function warning_no_api_key()
91
+ {
92
+ $this->render('message', array(
93
+ 'type' => 'error'
94
+ ,'message' => __('You have no Zemanta API key and the plugin was unable to retrieve one. You can still use Zemanta, '.
95
+ 'but until the new key is successfully obtained you will not be able to customize the widget or remove '.
96
+ 'this warning. You may try to deactivate and activate the plugin again to make it retry to obtain the key.', 'zemanta')
97
+ ));
98
+ }
99
+
100
+ /**
101
+ * warning
102
+ *
103
+ * Display plugin warning
104
+ */
105
+ public function warning()
106
+ {
107
+ $this->render('message', array(
108
+ 'type' => 'updated fade'
109
+ ,'message' => __('Zemanta needs either the cURL PHP module or allow_url_fopen enabled to work. Please ask your server administrator to set either of these up.', 'zemanta')
110
+ ));
111
+ }
112
+
113
+ /**
114
+ * add_options
115
+ *
116
+ * Add configuration page to menu
117
+ */
118
+ public function add_options()
119
+ {
120
+ $this->top_menu_slug = add_menu_page(
121
+ __('Zemanta', 'zemanta'),
122
+ __('Zemanta', 'zemanta'),
123
+ 'manage_options', 'zemanta',
124
+ array($this, 'options'),
125
+ plugins_url('/img/menu_icon.png', __FILE__)
126
+ );
127
+ }
128
+
129
+ /**
130
+ * check_options
131
+ *
132
+ * Check to see if we need to create or import options
133
+ */
134
+ public function check_options()
135
+ {
136
+ $this->api_key = $this->get_api_key();
137
+
138
+ if (!$this->api_key)
139
+ {
140
+ $options = get_option('zemanta_options');
141
+
142
+ if (!$options)
143
+ {
144
+ $options = $this->legacy_options($options);
145
+ }
146
+
147
+ $this->api_key = $this->get_api_key();
148
+ if (!$this->api_key)
149
+ {
150
+ $this->api_key = $this->fetch_api_key();
151
+ if ($this->api_key)
152
+ {
153
+ $this->set_api_key($this->api_key);
154
+ }
155
+ else
156
+ {
157
+ add_action('admin_notices', array($this, 'warning_no_api_key'));
158
+ }
159
+ }
160
+ }
161
+ }
162
+
163
+ /**
164
+ * create_options
165
+ *
166
+ * Create the Initial Options
167
+ */
168
+ public function create_options()
169
+ {
170
+ $wp_upload_dir = wp_upload_dir();
171
+ $options = array(
172
+ 'zemanta_option_api_key' => array(
173
+ 'type' => 'apikey'
174
+ ,'title' => __('Your API key (in case you need to contact support)', 'zemanta')
175
+ ,'field' => 'api_key'
176
+ ,'default_value' => $this->api_key
177
+ )
178
+ ,'zemanta_option_image_upload' => array(
179
+ 'type' => 'checkbox'
180
+ ,'title' => __('Automatically upload inserted images to your blog', 'zemanta')
181
+ ,'field' => 'image_uploader'
182
+ //,'description' => __('Using Zemanta image uploader in this way may download copyrighted images to your blog. Make sure you and your blog writers check and understand licenses of each and every image before using them in your blog posts and delete them if they infringe on author\'s rights.')
183
+ )
184
+ );
185
+
186
+ $this->options = apply_filters('zemanta_options', $options);
187
+ }
188
+
189
+ /**
190
+ * register_options
191
+ *
192
+ * Register options with Settings API
193
+ */
194
+ public function register_options()
195
+ {
196
+ register_setting('zemanta_options', 'zemanta_options', array($this, 'validate_options'));
197
+
198
+ add_settings_section('zemanta_options_plugin', null, array($this, 'callback_options_dummy'), 'zemanta');
199
+ add_settings_field('zemanta_option_api_key', 'Your API key', array($this, 'options_set'), 'zemanta', 'zemanta_options_plugin', $this->options['zemanta_option_api_key']);
200
+
201
+ add_settings_section('zemanta_options_image', null, array($this, 'callback_options_dummy'), 'zemanta');
202
+ add_settings_field('zemanta_option_image_upload', 'Enable image uploader', array($this, 'options_set'), 'zemanta', 'zemanta_options_image', $this->options['zemanta_option_image_upload']);
203
+ }
204
+
205
+ /**
206
+ * callback_options_dummy
207
+ *
208
+ * Dummy callback for add_settings_sections
209
+ */
210
+ public function callback_options_dummy()
211
+ {
212
+ }
213
+
214
+ /**
215
+ * options_set
216
+ *
217
+ * Output the fields for the options
218
+ */
219
+ public function options_set($option = null)
220
+ {
221
+ // WordPress < 2.9 has a bug where the settings callback is not passed the arguments value so we check for it here.
222
+ if ($option == null)
223
+ {
224
+ $option = array_shift($this->options);
225
+ }
226
+
227
+ $this->render('options-input-' . $option['type'], array(
228
+ 'option' => $this->get_option($option['field']),
229
+ 'field' => $option['field'],
230
+ 'title' => isset($option['title']) ? $option['title'] : null,
231
+ 'default_value' => isset($option['default_value']) ? $option['default_value'] : null,
232
+ 'description' => isset($option['description']) ? $option['description'] : null
233
+ ));
234
+ }
235
+
236
+ /**
237
+ * validate_options
238
+ *
239
+ * Handle input Validation
240
+ */
241
+ public function validate_options($input) {
242
+ return $input;
243
+ }
244
+
245
+ /**
246
+ * options
247
+ *
248
+ * Add configuration page
249
+ */
250
+ public function options()
251
+ {
252
+ if(!$this->api_key)
253
+ {
254
+ $this->api_key = $this->fetch_api_key();
255
+ $this->set_option('api_key', $this->api_key);
256
+ }
257
+
258
+ $this->render('options', array(
259
+ 'api_key' => $this->api_key
260
+ ));
261
+ }
262
+
263
+ /**
264
+ * sideload_image
265
+ *
266
+ * New image uploader, this is slightly modified version of media_sideload_image from wp-admin/includes/media.php
267
+ *
268
+ * @param string $file the URL of the image to download
269
+ * @param int $post_id The post ID the media is to be associated with
270
+ * @param string $desc Optional. Description of the image
271
+ * @return string|WP_Error uploaded image URL on success
272
+ */
273
+ public function sideload_image($file, $post_id, $desc = null) {
274
+ $tmp = download_url($file);
275
+ preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $file, $matches);
276
+
277
+ $file_array = array(
278
+ // sometimes wikipedia images have % in file names
279
+ // so let's fix it to avoid URL encoding conflicts
280
+ 'name' => str_replace('%', '_', basename($matches[0])),
281
+ 'tmp_name' => $tmp
282
+ );
283
+
284
+ // If error storing temporarily, unlink
285
+ if(is_wp_error($tmp)) {
286
+ @unlink($file_array['tmp_name']);
287
+ $file_array['tmp_name'] = '';
288
+ }
289
+
290
+ $id = media_handle_sideload($file_array, $post_id, $desc);
291
+ if(is_wp_error($id)) {
292
+ @unlink($file_array['tmp_name']);
293
+ return $id;
294
+ }
295
+
296
+ return wp_get_attachment_url($id);
297
+ }
298
+
299
+ /**
300
+ * is_uploader_enabled
301
+ *
302
+ */
303
+ public function is_uploader_enabled()
304
+ {
305
+ return $this->get_option('image_uploader');
306
+ }
307
+
308
+ /**
309
+ * save_post
310
+ *
311
+ * Download images if necessary and update post
312
+ */
313
+ public function save_post($post_id)
314
+ {
315
+ // do not process revisions, autosaves and auto-drafts
316
+ if(wp_is_post_revision($post_id) || wp_is_post_autosave($post_id) || get_post_status($post_id) == 'auto-draft' || isset($_POST['autosave']))
317
+ return;
318
+
319
+ // do not process if uploader disabled
320
+ if(!$this->is_uploader_enabled())
321
+ return;
322
+
323
+ $content = stripslashes($_POST['post_content']);
324
+ $nlcontent = str_replace("\n", '', $content);
325
+ $urls = array();
326
+ $descs = array();
327
+
328
+ // this thingy looks for href instead of alt attributes in images
329
+ // seems like we didn't have alts before
330
+ // it's sort of legacy code that must be dropped at some point
331
+ // @deprecated
332
+ if(preg_match_all('/<div[^>]+zemanta-img[^>]+>.+?<\/div>/', $nlcontent, $matches))
333
+ {
334
+ foreach($matches[0] as $str)
335
+ {
336
+ if(preg_match('/src="([^"]+)"/', $str, $srcurl))
337
+ {
338
+ if(preg_match('/href="([^"]+)"/', $str, $desc))
339
+ $descs[] = $desc[1];
340
+ else
341
+ $descs[] = '';
342
+
343
+ $urls[] = $srcurl[1];
344
+ }
345
+ }
346
+ }
347
+
348
+ // this code looks for all images in the post
349
+ // extracts alt and src attributes for image downloader
350
+ if(preg_match_all('/<img .*?src="[^"]+".*?>/', $nlcontent, $matches))
351
+ {
352
+ foreach($matches[0] as $str)
353
+ {
354
+ if(preg_match('/src="([^"]+)"/', $str, $srcurl))
355
+ {
356
+ if(!in_array($srcurl[1], $urls))
357
+ {
358
+ if(preg_match('/alt="([^"]+)"/', $str, $desc))
359
+ $descs[] = strlen($desc[1]) ? $desc[1] : $srcurl[1];
360
+ else
361
+ $descs[] = $srcurl[1];
362
+
363
+ $urls[] = $srcurl[1];
364
+ }
365
+ }
366
+ }
367
+ }
368
+
369
+ // do not do anything if there no images found in the post
370
+ if(empty($urls))
371
+ return;
372
+
373
+ // download images to blog and replace external URLs with local
374
+ for($i = 0, $c = sizeof($urls); $i < $c; $i++)
375
+ {
376
+ $url = $urls[$i];
377
+ $desc = $descs[$i];
378
+
379
+ // skip images from img.zemanta.com and FMP
380
+ if(strpos($url, 'http://img.zemanta.com/') !== false || preg_match('#https?://.+\.fmpub\.net/#i', $url))
381
+ continue;
382
+
383
+ // skip if already hosted on our blog
384
+ if(strpos($url, get_bloginfo('url')) !== false) {
385
+ continue;
386
+ }
387
+ // upload image from URL and replace URL in the post content
388
+ $localurl = $this->sideload_image($url, $post_id, $desc);
389
+ if(!is_wp_error($localurl) && !empty($localurl))
390
+ $content = str_replace($url, $localurl, $content);
391
+ }
392
+
393
+ // unhook this function so it doesn't loop infinitely
394
+ remove_action('save_post', array($this, 'save_post'), 20);
395
+
396
+ // put modified content back to _POST so other plugins can reuse it
397
+ $_POST['post_content'] = addslashes($content);
398
+
399
+ // update post in database
400
+ wp_update_post(array(
401
+ 'ID' => $post_id,
402
+ 'post_content' => $content)
403
+ );
404
+
405
+ // re-hook this function
406
+ add_action('save_post', array($this, 'save_post'), 20);
407
+ }
408
+
409
+ /**
410
+ * api
411
+ *
412
+ * API Call
413
+ *
414
+ * @param array $arguments Arguments to pass to the API
415
+ */
416
+ public function api($arguments)
417
+ {
418
+ $arguments = array_merge($arguments, array(
419
+ 'api_key'=> $this->api_key
420
+ ));
421
+
422
+ if (!isset($arguments['format']))
423
+ {
424
+ $arguments['format'] = 'xml';
425
+ }
426
+
427
+ return wp_remote_post($this->api_url, array('method' => 'POST', 'body' => $arguments));
428
+ }
429
+
430
+ /**
431
+ * ajax_error
432
+ *
433
+ * Helper function to throw WP_Errors to ajax as json
434
+ */
435
+ public function ajax_error($wp_error) {
436
+ if(is_wp_error($wp_error)) {
437
+ die(json_encode(array(
438
+ 'error' => array(
439
+ 'code' => $wp_error->get_error_code(),
440
+ 'message' => $wp_error->get_error_message(),
441
+ 'data' => $wp_error->get_error_data()
442
+ )
443
+ )));
444
+ }
445
+ }
446
+
447
+ /**
448
+ * ajax_zemanta_set_featured_image
449
+ *
450
+ * Download and set featured image by URL
451
+ * @require WordPress 3.1+
452
+ */
453
+ public function ajax_zemanta_set_featured_image()
454
+ {
455
+ global $post_ID;
456
+
457
+ if(!isset($this->supported_features['featured_image'])) {
458
+ $this->ajax_error(new WP_Error(4, __('Featured image feature is not supported on current platform.', 'zemanta')));
459
+ }
460
+
461
+ $args = wp_parse_args($_REQUEST, array('post_id' => 0, 'image_url' => ''));
462
+ extract($args);
463
+
464
+ $post_id = (int)$post_id;
465
+
466
+ if(!empty($image_url) && $post_id)
467
+ {
468
+ $http_response = wp_remote_get($image_url, array('timeout' => 10));
469
+
470
+ if(!is_wp_error($http_response))
471
+ {
472
+ $data = wp_remote_retrieve_body($http_response);
473
+
474
+ // throw error if there no data
475
+ if(empty($data)) {
476
+ $this->ajax_error(new WP_Error(5, __('Featured image has invalid data.', 'zemanta')));
477
+ }
478
+
479
+ $upload = wp_upload_bits(basename($image_url), null, $data);
480
+
481
+ if(!is_wp_error($upload) && !$upload['error'])
482
+ {
483
+ $filename = $upload['file'];
484
+ $wp_filetype = wp_check_filetype(basename($filename), null );
485
+ $attachment = array(
486
+ 'post_mime_type' => $wp_filetype['type'],
487
+ 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
488
+ 'post_content' => '',
489
+ 'post_status' => 'inherit'
490
+ );
491
+ $attach_id = wp_insert_attachment($attachment, $filename, $post_id);
492
+ $attach_data = wp_generate_attachment_metadata($attach_id, $filename);
493
+ wp_update_attachment_metadata($attach_id, $attach_data);
494
+
495
+ // this is necessary, or _wp_post_thumbnail_html returns broken remove link
496
+ $post_ID = $post_id;
497
+
498
+ // set_post_thumbnail available only since WordPress 3.1
499
+ if(set_post_thumbnail($post_id, $attach_id)) {
500
+ die(json_encode(array(
501
+ // _wp_post_thumbnail_html is private function but we really need it to behave natively
502
+ 'html' => _wp_post_thumbnail_html($attach_id), // call WPSetThumbnailHTML(html) from javascript
503
+ 'attach_id' => $attach_id // call WPSetThumbnailID(attach_id) from javascript
504
+ ))
505
+ );
506
+ } else {
507
+ $this->ajax_error(new WP_Error(1, __('An unexpected error occurred.', 'zemanta')));
508
+ }
509
+ } else {
510
+ $this->ajax_error(new WP_Error(2, sprintf(__('An upload error occurred: %s', 'zemanta'), $upload->get_error_message())));
511
+ }
512
+ } else {
513
+ $this->ajax_error(new WP_Error(3, sprintf(__('An error occurred while image download: %s', 'zemanta'), $http_response->get_error_message())));
514
+ }
515
+ }
516
+
517
+ die(0);
518
+ }
519
+
520
+ /**
521
+ * fetch_api_key
522
+ *
523
+ * Get API Key
524
+ */
525
+ public function fetch_api_key()
526
+ {
527
+ $response = $this->api(array(
528
+ 'method' => 'zemanta.auth.create_user',
529
+ 'partner_id' => 'wordpress-wprp'
530
+ ));
531
+
532
+ if(!is_wp_error($response))
533
+ {
534
+ if(preg_match('/<status>(.+?)<\/status>/', $response['body'], $matches))
535
+ {
536
+ if($matches[1] == 'ok' && preg_match('/<apikey>(.+?)<\/apikey>/', $response['body'], $matches))
537
+ return $matches[1];
538
+ }
539
+ }
540
+
541
+ return '';
542
+ }
543
+
544
+ /**
545
+ * shim
546
+ *
547
+ * Adds Shim to Edit Page for Zemanta Plugin
548
+ */
549
+ public function shim()
550
+ {
551
+ echo '<div id="zemanta-sidebar"></div>';
552
+ }
553
+
554
+ /**
555
+ * legacy_options
556
+ *
557
+ * Get Options from Legacy Options if available
558
+ */
559
+ protected function legacy_options($options)
560
+ {
561
+ if (empty($this->options))
562
+ {
563
+ return false;
564
+ }
565
+
566
+ foreach ($this->options as $option => $details)
567
+ {
568
+ $old_option = get_option('zemanta_' . $details['field']);
569
+
570
+ if ($old_option && !isset($options[$details['field']]))
571
+ {
572
+ $options[$details['field']] = $old_option == 'on' ? 1 : $old_option;
573
+ }
574
+ }
575
+
576
+ update_option('zemanta_options', $options);
577
+
578
+ return get_option('zemanta_options');
579
+ }
580
+
581
+ /**
582
+ * get_option
583
+ *
584
+ * Get Option
585
+ *
586
+ * @param string $name Name of option to retrieve
587
+ */
588
+ protected function get_option($name)
589
+ {
590
+ $options = get_option('zemanta_options');
591
+
592
+ return isset($options[$name]) ? $options[$name] : null;
593
+ }
594
+
595
+ /**
596
+ * set_option
597
+ *
598
+ * Set option
599
+ *
600
+ * @param string $name Name of option to set
601
+ * @param string $value Value of option
602
+ */
603
+ protected function set_option($name, $value)
604
+ {
605
+ $options = get_option('zemanta_options');
606
+
607
+ if ($value === null)
608
+ {
609
+ unset($options[$name]);
610
+ }
611
+ else
612
+ {
613
+ $options[$name] = $value;
614
+ }
615
+
616
+ return update_option('zemanta_options', $options);
617
+ }
618
+
619
+ /**
620
+ * get_api_key
621
+ *
622
+ * Get API Key
623
+ */
624
+ public function get_api_key()
625
+ {
626
+ return $this->get_option('api_key');
627
+ }
628
+
629
+ /**
630
+ * set_api_key
631
+ *
632
+ * Get API Key
633
+ *
634
+ * @param string $api_key API Key to set
635
+ */
636
+ protected function set_api_key($api_key)
637
+ {
638
+ $this->set_option('api_key', $api_key);
639
+ }
640
+
641
+ /**
642
+ * check_dependencies
643
+ *
644
+ * Return true if CURL and DOM XML modules exist and false otherwise
645
+ *
646
+ * @return boolean
647
+ */
648
+ protected function check_dependencies()
649
+ {
650
+ return ((function_exists('curl_init') || ini_get('allow_url_fopen')) && (function_exists('preg_match') || function_exists('ereg')));
651
+ }
652
+
653
+ /**
654
+ * check_plugin_updated
655
+ *
656
+ * Checks whether plugin update happened and triggers update notice
657
+ *
658
+ */
659
+ protected function check_plugin_updated()
660
+ {
661
+ $last_plugin_version = get_option(WP_RP_ZEMANTA_PLUGIN_VERSION_OPTION);
662
+
663
+ // setup current version for new plugin installations
664
+ // zemanta_api_key option presents on older 0.8 versions
665
+ if(!$last_plugin_version && !get_option('zemanta_api_key')) {
666
+ update_option(WP_RP_ZEMANTA_PLUGIN_VERSION_OPTION, $this->version, '', true);
667
+ }
668
+
669
+ // it'll trigger only if different version of plugin was installed before
670
+ if(!$last_plugin_version || version_compare($last_plugin_version, $this->version, '!='))
671
+ {
672
+ // save new version string to database to avoid event doubling
673
+ update_option(WP_RP_ZEMANTA_PLUGIN_VERSION_OPTION, $this->version);
674
+ }
675
+ }
676
+
677
+ /**
678
+ * render
679
+ *
680
+ * Render HTML/JS/CSS to screen
681
+ *
682
+ * @param string $view File to display
683
+ * @param array $arguments Arguments to pass to file
684
+ * @param boolean $return Whether or not to return the output or print it
685
+ */
686
+ protected function render($view, $arguments = array(), $return = false)
687
+ {
688
+ $view_file = untrailingslashit(dirname(__FILE__)) . '/views/' . $view . '.php';
689
+
690
+ extract($arguments, EXTR_SKIP);
691
+
692
+ if ($return)
693
+ ob_start();
694
+
695
+ if(file_exists($view_file))
696
+ include($view_file);
697
+ else
698
+ echo '<pre>View Not Found: ' . $view . '</pre>';
699
+
700
+ if ($return)
701
+ return ob_get_clean();
702
+ }
703
+
704
+ }
705
+
706
+ //
707
+ // End of file zemanta.php
708
+ //