Version Description
- Bug fixes for "Edit related posts" feature
- Changed URL for static content
- Added settings to fix custom size thumbnails issues (re-generating thumbnails might take a few minutes)
Download this release
Release Info
Developer | zemanta-panco |
Plugin | WordPress Related Posts |
Version | 3.2 |
Comparing to | |
See all releases |
Code changes from version 3.1 to 3.2
- config.php +47 -3
- readme.txt +6 -1
- settings.php +32 -3
- static/js/extras.js +1 -0
- thumbnailer.php +41 -8
- wp_related_posts.php +17 -6
config.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
define('WP_RP_STATIC_BASE_URL', 'http://
|
4 |
|
5 |
define('WP_RP_STATIC_THEMES_PATH', 'static/themes/');
|
6 |
|
@@ -20,6 +20,8 @@ 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);
|
@@ -94,9 +96,7 @@ 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 |
}
|
@@ -200,6 +200,9 @@ function wp_rp_install() {
|
|
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,
|
@@ -239,6 +242,26 @@ function wp_rp_is_classic() {
|
|
239 |
return false;
|
240 |
}
|
241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
function wp_rp_migrate_3_0() {
|
243 |
global $wpdb;
|
244 |
|
@@ -248,8 +271,14 @@ function wp_rp_migrate_3_0() {
|
|
248 |
if (floatval($wp_rp_meta['first_version']) < 2.8 && strpos(get_bloginfo('language'), 'en') === 0) { // Enable widget to all "old" users out there (old = users that started with plugin version 2.7 or below), that have their interface in english.
|
249 |
$wp_rp_meta['classic_user'] = true;
|
250 |
}
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
update_option('wp_rp_meta', $wp_rp_meta);
|
|
|
253 |
}
|
254 |
|
255 |
function wp_rp_migrate_2_9() {
|
@@ -258,8 +287,13 @@ function wp_rp_migrate_2_9() {
|
|
258 |
$wp_rp_meta = get_option('wp_rp_meta');
|
259 |
$wp_rp_meta['version'] = '3.0';
|
260 |
$wp_rp_meta['new_user'] = false;
|
|
|
|
|
|
|
|
|
261 |
|
262 |
update_option('wp_rp_meta', $wp_rp_meta);
|
|
|
263 |
}
|
264 |
|
265 |
function wp_rp_migrate_2_8() {
|
@@ -268,8 +302,13 @@ function wp_rp_migrate_2_8() {
|
|
268 |
$wp_rp_meta = get_option('wp_rp_meta');
|
269 |
$wp_rp_meta['version'] = '2.9';
|
270 |
$wp_rp_meta['new_user'] = false;
|
|
|
|
|
|
|
|
|
271 |
|
272 |
update_option('wp_rp_meta', $wp_rp_meta);
|
|
|
273 |
}
|
274 |
|
275 |
function wp_rp_migrate_2_7() {
|
@@ -279,10 +318,15 @@ function wp_rp_migrate_2_7() {
|
|
279 |
$wp_rp_meta['version'] = '2.8';
|
280 |
$wp_rp_meta['new_user'] = false;
|
281 |
$wp_rp_meta['classic_user'] = false;
|
|
|
|
|
|
|
|
|
282 |
|
283 |
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key IN ('_wp_rp_extracted_image_url', '_wp_rp_extracted_image_url_full')");
|
284 |
|
285 |
update_option('wp_rp_meta', $wp_rp_meta);
|
|
|
286 |
}
|
287 |
|
288 |
function wp_rp_migrate_2_6() {
|
1 |
<?php
|
2 |
|
3 |
+
define('WP_RP_STATIC_BASE_URL', 'http://wprp.zemanta.com/static/');
|
4 |
|
5 |
define('WP_RP_STATIC_THEMES_PATH', 'static/themes/');
|
6 |
|
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_CUSTOM_THUMBNAILS_WIDTH', 150);
|
24 |
+
define('WP_RP_CUSTOM_THUMBNAILS_HEIGHT', 150);
|
25 |
define('WP_RP_THUMBNAILS_DEFAULTS_COUNT', 31);
|
26 |
|
27 |
define("WP_RP_MAX_LABEL_LENGTH", 32);
|
96 |
global $wp_rp_options;
|
97 |
|
98 |
$new_options = (array) $new_options;
|
|
|
99 |
$r = update_option('wp_rp_options', $new_options);
|
|
|
100 |
if($r && $wp_rp_options !== false) {
|
101 |
$wp_rp_options->exchangeArray($new_options);
|
102 |
}
|
200 |
'promoted_content_enabled' => false,
|
201 |
'enable_themes' => false,
|
202 |
'traffic_exchange_enabled' => false,
|
203 |
+
'custom_size_thumbnail_enabled' => false,
|
204 |
+
'custom_thumbnail_width' => WP_RP_CUSTOM_THUMBNAILS_WIDTH,
|
205 |
+
'custom_thumbnail_height' => WP_RP_CUSTOM_THUMBNAILS_HEIGHT,
|
206 |
'thumbnail_use_custom' => false,
|
207 |
'thumbnail_custom_field' => false,
|
208 |
'display_zemanta_linky' => false,
|
242 |
return false;
|
243 |
}
|
244 |
|
245 |
+
function wp_rp_migrate_3_1() {
|
246 |
+
global $wpdb;
|
247 |
+
|
248 |
+
$wp_rp_meta = get_option('wp_rp_meta');
|
249 |
+
$wp_rp_meta['version'] = '3.2';
|
250 |
+
$wp_rp_meta['new_user'] = false;
|
251 |
+
if (floatval($wp_rp_meta['first_version']) < 2.8 && strpos(get_bloginfo('language'), 'en') === 0) { // Enable widget to all "old" users out there (old = users that started with plugin version 2.7 or below), that have their interface in english.
|
252 |
+
$wp_rp_meta['classic_user'] = true;
|
253 |
+
}
|
254 |
+
$wp_rp_options = get_option('wp_rp_options');
|
255 |
+
$wp_rp_options['custom_size_thumbnail_enabled'] = false;
|
256 |
+
$wp_rp_options['custom_thumbnail_width'] = WP_RP_CUSTOM_THUMBNAILS_WIDTH;
|
257 |
+
$wp_rp_options['custom_thumbnail_height'] = WP_RP_CUSTOM_THUMBNAILS_WIDTH;
|
258 |
+
|
259 |
+
update_option('wp_rp_meta', $wp_rp_meta);
|
260 |
+
update_option('wp_rp_options', $wp_rp_options);
|
261 |
+
|
262 |
+
}
|
263 |
+
|
264 |
+
|
265 |
function wp_rp_migrate_3_0() {
|
266 |
global $wpdb;
|
267 |
|
271 |
if (floatval($wp_rp_meta['first_version']) < 2.8 && strpos(get_bloginfo('language'), 'en') === 0) { // Enable widget to all "old" users out there (old = users that started with plugin version 2.7 or below), that have their interface in english.
|
272 |
$wp_rp_meta['classic_user'] = true;
|
273 |
}
|
274 |
+
$wp_rp_options = get_option('wp_rp_options');
|
275 |
+
$wp_rp_options['custom_size_thumbnail_enabled'] = false;
|
276 |
+
$wp_rp_options['custom_thumbnail_width'] = WP_RP_CUSTOM_THUMBNAILS_WIDTH;
|
277 |
+
$wp_rp_options['custom_thumbnail_height'] = WP_RP_CUSTOM_THUMBNAILS_WIDTH;
|
278 |
+
|
279 |
|
280 |
update_option('wp_rp_meta', $wp_rp_meta);
|
281 |
+
update_option('wp_rp_options', $wp_rp_options);
|
282 |
}
|
283 |
|
284 |
function wp_rp_migrate_2_9() {
|
287 |
$wp_rp_meta = get_option('wp_rp_meta');
|
288 |
$wp_rp_meta['version'] = '3.0';
|
289 |
$wp_rp_meta['new_user'] = false;
|
290 |
+
$wp_rp_options = get_option('wp_rp_options');
|
291 |
+
$wp_rp_options['custom_size_thumbnail_enabled'] = false;
|
292 |
+
$wp_rp_options['custom_thumbnail_width'] = WP_RP_CUSTOM_THUMBNAILS_WIDTH;
|
293 |
+
$wp_rp_options['custom_thumbnail_height'] = WP_RP_CUSTOM_THUMBNAILS_WIDTH;
|
294 |
|
295 |
update_option('wp_rp_meta', $wp_rp_meta);
|
296 |
+
update_option('wp_rp_options', $wp_rp_options);
|
297 |
}
|
298 |
|
299 |
function wp_rp_migrate_2_8() {
|
302 |
$wp_rp_meta = get_option('wp_rp_meta');
|
303 |
$wp_rp_meta['version'] = '2.9';
|
304 |
$wp_rp_meta['new_user'] = false;
|
305 |
+
$wp_rp_options = get_option('wp_rp_options');
|
306 |
+
$wp_rp_options['custom_size_thumbnail_enabled'] = false;
|
307 |
+
$wp_rp_options['custom_thumbnail_width'] = WP_RP_CUSTOM_THUMBNAILS_WIDTH;
|
308 |
+
$wp_rp_options['custom_thumbnail_height'] = WP_RP_CUSTOM_THUMBNAILS_WIDTH;
|
309 |
|
310 |
update_option('wp_rp_meta', $wp_rp_meta);
|
311 |
+
update_option('wp_rp_options', $wp_rp_options);
|
312 |
}
|
313 |
|
314 |
function wp_rp_migrate_2_7() {
|
318 |
$wp_rp_meta['version'] = '2.8';
|
319 |
$wp_rp_meta['new_user'] = false;
|
320 |
$wp_rp_meta['classic_user'] = false;
|
321 |
+
$wp_rp_options = get_option('wp_rp_options');
|
322 |
+
$wp_rp_options['custom_size_thumbnail_enabled'] = false;
|
323 |
+
$wp_rp_options['custom_thumbnail_width'] = WP_RP_CUSTOM_THUMBNAILS_WIDTH;
|
324 |
+
$wp_rp_options['custom_thumbnail_height'] = WP_RP_CUSTOM_THUMBNAILS_WIDTH;
|
325 |
|
326 |
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key IN ('_wp_rp_extracted_image_url', '_wp_rp_extracted_image_url_full')");
|
327 |
|
328 |
update_option('wp_rp_meta', $wp_rp_meta);
|
329 |
+
update_option('wp_rp_options', $wp_rp_options);
|
330 |
}
|
331 |
|
332 |
function wp_rp_migrate_2_6() {
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: related,posts,post,related posts,plugin
|
|
4 |
License: GPLv2
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 3.6
|
7 |
-
Stable tag: 3.
|
8 |
|
9 |
WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
|
10 |
|
@@ -81,6 +81,11 @@ Fix for security vulnerability. Upgrade immediately.
|
|
81 |
|
82 |
== Changelog ==
|
83 |
|
|
|
|
|
|
|
|
|
|
|
84 |
= 3.1 =
|
85 |
* Related content (articles) on compose screen for all users with English WordPress interface
|
86 |
* Language detection for WordPressP interface: non-English users don't get the widget, existing ones get opt-out
|
4 |
License: GPLv2
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 3.6
|
7 |
+
Stable tag: 3.2
|
8 |
|
9 |
WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.
|
10 |
|
81 |
|
82 |
== Changelog ==
|
83 |
|
84 |
+
= 3.2 =
|
85 |
+
* Bug fixes for "Edit related posts" feature
|
86 |
+
* Changed URL for static content
|
87 |
+
* Added settings to fix custom size thumbnails issues (re-generating thumbnails might take a few minutes)
|
88 |
+
|
89 |
= 3.1 =
|
90 |
* Related content (articles) on compose screen for all users with English WordPress interface
|
91 |
* Language detection for WordPressP interface: non-English users don't get the widget, existing ones get opt-out
|
settings.php
CHANGED
@@ -60,6 +60,7 @@ function wp_rp_settings_admin_menu() {
|
|
60 |
function wp_rp_settings_scripts() {
|
61 |
wp_enqueue_script('wp_rp_themes_script', plugins_url('static/js/themes.js', __FILE__), array('jquery'), WP_RP_VERSION);
|
62 |
wp_enqueue_script("wp_rp_dashboard_script", plugins_url('static/js/dashboard.js', __FILE__), array('jquery'), WP_RP_VERSION);
|
|
|
63 |
}
|
64 |
function wp_rp_settings_styles() {
|
65 |
wp_enqueue_style("wp_rp_dashboard_style", plugins_url("static/css/dashboard.css", __FILE__), array(), WP_RP_VERSION);
|
@@ -162,6 +163,10 @@ function wp_rp_settings_page() {
|
|
162 |
'traffic_exchange_enabled' => isset($postdata['wp_rp_traffic_exchange_enabled']),
|
163 |
'max_related_post_age_in_days' => (isset($postdata['wp_rp_max_related_post_age_in_days']) && is_numeric(trim($postdata['wp_rp_max_related_post_age_in_days']))) ? intval(trim($postdata['wp_rp_max_related_post_age_in_days'])) : 0,
|
164 |
|
|
|
|
|
|
|
|
|
165 |
'thumbnail_use_custom' => isset($postdata['wp_rp_thumbnail_use_custom']) && $postdata['wp_rp_thumbnail_use_custom'] === 'yes',
|
166 |
'thumbnail_custom_field' => isset($postdata['wp_rp_thumbnail_custom_field']) ? trim($postdata['wp_rp_thumbnail_custom_field']) : '',
|
167 |
'display_zemanta_linky' => $meta['show_zemanta_linky_option'] ? isset($postdata['wp_rp_display_zemanta_linky']) : true,
|
@@ -415,7 +420,7 @@ function wp_rp_settings_page() {
|
|
415 |
<tr id="wp_rp_<?php echo $platform; ?>_theme_custom_css_wrap" style="display: none; ">
|
416 |
<td>
|
417 |
<label>
|
418 |
-
<input name="wp_rp_<?php echo $platform; ?>_display_thumbnail" type="checkbox" id="wp_rp_<?php echo $platform; ?>_display_thumbnail" value="yes" <?php checked($options[$platform]["display_thumbnail"]); ?>
|
419 |
<?php _e("Display Thumbnails For Related Posts",'wp_related_posts');?>
|
420 |
</label><br />
|
421 |
<label>
|
@@ -427,7 +432,7 @@ function wp_rp_settings_page() {
|
|
427 |
<?php _e("Display Publish Date",'wp_related_posts');?>
|
428 |
</label><br />
|
429 |
<label>
|
430 |
-
<input name="wp_rp_<?php echo $platform; ?>_display_excerpt" type="checkbox" id="wp_rp_<?php echo $platform; ?>_display_excerpt" value="yes" <?php checked($options[$platform]["display_excerpt"]); ?>
|
431 |
<?php _e("Display Post Excerpt",'wp_related_posts');?>
|
432 |
</label>
|
433 |
<label id="wp_rp_<?php echo $platform; ?>_excerpt_max_length_label">
|
@@ -492,6 +497,30 @@ function wp_rp_settings_page() {
|
|
492 |
</td>
|
493 |
</tr>
|
494 |
</tbody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
</table><?php
|
496 |
|
497 |
/**************************************
|
@@ -573,4 +602,4 @@ function wp_rp_settings_page() {
|
|
573 |
</div>
|
574 |
</form>
|
575 |
</div>
|
576 |
-
<?php }
|
60 |
function wp_rp_settings_scripts() {
|
61 |
wp_enqueue_script('wp_rp_themes_script', plugins_url('static/js/themes.js', __FILE__), array('jquery'), WP_RP_VERSION);
|
62 |
wp_enqueue_script("wp_rp_dashboard_script", plugins_url('static/js/dashboard.js', __FILE__), array('jquery'), WP_RP_VERSION);
|
63 |
+
wp_enqueue_script("wp_rp_extras_script", plugins_url('static/js/extras.js', __FILE__), array('jquery'), WP_RP_VERSION);
|
64 |
}
|
65 |
function wp_rp_settings_styles() {
|
66 |
wp_enqueue_style("wp_rp_dashboard_style", plugins_url("static/css/dashboard.css", __FILE__), array(), WP_RP_VERSION);
|
163 |
'traffic_exchange_enabled' => isset($postdata['wp_rp_traffic_exchange_enabled']),
|
164 |
'max_related_post_age_in_days' => (isset($postdata['wp_rp_max_related_post_age_in_days']) && is_numeric(trim($postdata['wp_rp_max_related_post_age_in_days']))) ? intval(trim($postdata['wp_rp_max_related_post_age_in_days'])) : 0,
|
165 |
|
166 |
+
'custom_size_thumbnail_enabled' => isset($postdata['wp_rp_custom_size_thumbnail_enabled']) && $postdata['wp_rp_custom_size_thumbnail_enabled'] === 'yes',
|
167 |
+
'custom_thumbnail_width' => isset($postdata['wp_rp_custom_thumbnail_width']) ? intval(trim($postdata['wp_rp_custom_thumbnail_width'])) : WP_RP_CUSTOM_THUMBNAILS_WIDTH ,
|
168 |
+
'custom_thumbnail_height' => isset($postdata['wp_rp_custom_thumbnail_height']) ? intval(trim($postdata['wp_rp_custom_thumbnail_height'])) : WP_RP_CUSTOM_THUMBNAILS_HEIGHT,
|
169 |
+
|
170 |
'thumbnail_use_custom' => isset($postdata['wp_rp_thumbnail_use_custom']) && $postdata['wp_rp_thumbnail_use_custom'] === 'yes',
|
171 |
'thumbnail_custom_field' => isset($postdata['wp_rp_thumbnail_custom_field']) ? trim($postdata['wp_rp_thumbnail_custom_field']) : '',
|
172 |
'display_zemanta_linky' => $meta['show_zemanta_linky_option'] ? isset($postdata['wp_rp_display_zemanta_linky']) : true,
|
420 |
<tr id="wp_rp_<?php echo $platform; ?>_theme_custom_css_wrap" style="display: none; ">
|
421 |
<td>
|
422 |
<label>
|
423 |
+
<input name="wp_rp_<?php echo $platform; ?>_display_thumbnail" type="checkbox" id="wp_rp_<?php echo $platform; ?>_display_thumbnail" value="yes" <?php checked($options[$platform]["display_thumbnail"]); ?> />
|
424 |
<?php _e("Display Thumbnails For Related Posts",'wp_related_posts');?>
|
425 |
</label><br />
|
426 |
<label>
|
432 |
<?php _e("Display Publish Date",'wp_related_posts');?>
|
433 |
</label><br />
|
434 |
<label>
|
435 |
+
<input name="wp_rp_<?php echo $platform; ?>_display_excerpt" type="checkbox" id="wp_rp_<?php echo $platform; ?>_display_excerpt" value="yes" <?php checked($options[$platform]["display_excerpt"]); ?> />
|
436 |
<?php _e("Display Post Excerpt",'wp_related_posts');?>
|
437 |
</label>
|
438 |
<label id="wp_rp_<?php echo $platform; ?>_excerpt_max_length_label">
|
497 |
</td>
|
498 |
</tr>
|
499 |
</tbody>
|
500 |
+
</table>
|
501 |
+
<h3>Custom Size Thumbnails</h3>
|
502 |
+
<table class="form-table">
|
503 |
+
<tbody>
|
504 |
+
<tr><td>
|
505 |
+
<p>All themes are <strong>optimized</strong> for thumbnails of size 150x150px. They might not work well with custom size thumbnails.<br> Specify your custom css to override theme's style.</p>
|
506 |
+
</td></tr>
|
507 |
+
<tr><td>
|
508 |
+
<label>
|
509 |
+
<input name="wp_rp_custom_size_thumbnail_enabled" type="checkbox" id="wp_rp_custom_size_thumbnail_enabled" value="yes" <?php checked($options['custom_size_thumbnail_enabled']); ?> />
|
510 |
+
<?php _e("Use Custom Size Thumbnails",'wp_related_posts');?>
|
511 |
+
</label><br />
|
512 |
+
<div id="wp_rp_custom_thumb_sizes_settings" style="display:none">
|
513 |
+
<label>
|
514 |
+
<?php _e("Custom Width (px)",'wp_related_posts');?>
|
515 |
+
<input name="wp_rp_custom_thumbnail_width" type="text" id="wp_rp_custom_thumbnail_width" class="small-text" value="<?php esc_attr_e($options['custom_thumbnail_width']); ?>" />
|
516 |
+
</label>
|
517 |
+
<label>
|
518 |
+
<?php _e("Custom Height (px)",'wp_related_posts');?>
|
519 |
+
<input name="wp_rp_custom_thumbnail_height" type="text" id="wp_rp_custom_thumbnail_height" class="small-text" value="<?php esc_attr_e($options['custom_thumbnail_height']); ?>" />
|
520 |
+
</label>
|
521 |
+
</div>
|
522 |
+
</td></tr>
|
523 |
+
</tbody>
|
524 |
</table><?php
|
525 |
|
526 |
/**************************************
|
602 |
</div>
|
603 |
</form>
|
604 |
</div>
|
605 |
+
<?php } ?>
|
static/js/extras.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
(function(a){a(function(){var b=a("#wp_rp_custom_thumb_sizes_settings");a("#wp_rp_custom_size_thumbnail_enabled:checked").length?b.show():b.hide();a("#wp_rp_custom_size_thumbnail_enabled").click(function(){b.toggle(this.checked)})})})(jQuery);
|
thumbnailer.php
CHANGED
@@ -10,6 +10,9 @@ function wp_rp_add_image_sizes() {
|
|
10 |
if ($platform_options['theme_name'] == 'pinterest.css') {
|
11 |
add_image_size(WP_RP_THUMBNAILS_PROP_NAME, WP_RP_THUMBNAILS_WIDTH, 0, false);
|
12 |
}
|
|
|
|
|
|
|
13 |
}
|
14 |
add_action('init', 'wp_rp_add_image_sizes');
|
15 |
|
@@ -27,10 +30,14 @@ function wp_rp_upload_default_thumbnail_file() {
|
|
27 |
return false;
|
28 |
}
|
29 |
|
30 |
-
$image_id = media_handle_upload('wp_rp_default_thumbnail', 0)
|
31 |
-
if ($image_id) {
|
32 |
$image_data = wp_rp_get_image_data($image_id);
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
34 |
$upload_dir = wp_upload_dir();
|
35 |
return $upload_dir['url'] . '/' . $image['file'];
|
36 |
}
|
@@ -73,7 +80,11 @@ function wp_rp_upload_attachment($url, $post_id) {
|
|
73 |
}
|
74 |
|
75 |
$attach_data = wp_get_attachment_metadata($attachment_id);
|
76 |
-
|
|
|
|
|
|
|
|
|
77 |
wp_delete_attachment($attachment_id);
|
78 |
return false;
|
79 |
}
|
@@ -124,11 +135,29 @@ function wp_rp_update_attachment_id($attachment_id) {
|
|
124 |
include_once(ABSPATH . 'wp-admin/includes/image.php');
|
125 |
|
126 |
$img_path = get_attached_file($attachment_id);
|
|
|
127 |
if (!$img_path) { return false; }
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
$attach_data = wp_generate_attachment_metadata($attachment_id, $img_path);
|
130 |
wp_update_attachment_metadata($attachment_id, $attach_data);
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
return $attachment_id;
|
133 |
}
|
134 |
|
@@ -258,7 +287,6 @@ function wp_rp_get_attached_img_url($related_post, $size) {
|
|
258 |
// image_id in the db is incorrect
|
259 |
delete_post_meta($related_post->ID, '_wp_rp_image');
|
260 |
}
|
261 |
-
|
262 |
if (!$image_data && has_post_thumbnail($related_post->ID)) {
|
263 |
$image_data = wp_rp_get_image_data(get_post_thumbnail_id($related_post->ID));
|
264 |
}
|
@@ -289,8 +317,13 @@ function wp_rp_get_attached_img_url($related_post, $size) {
|
|
289 |
return false;
|
290 |
}
|
291 |
|
292 |
-
function
|
|
|
|
|
293 |
if (!$size || $size === 'thumbnail') {
|
|
|
|
|
|
|
294 |
return array(WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT);
|
295 |
}
|
296 |
if ($size == 'full') {
|
@@ -305,7 +338,6 @@ function wp_rp_get_thumbanil_size_array($size) {
|
|
305 |
function wp_rp_get_post_thumbnail_img($related_post, $size = null, $force = false) {
|
306 |
$options = wp_rp_get_options();
|
307 |
$platform_options = wp_rp_get_platform_options();
|
308 |
-
|
309 |
if (!($platform_options["display_thumbnail"] || $force)) {
|
310 |
return false;
|
311 |
}
|
@@ -315,8 +347,9 @@ function wp_rp_get_post_thumbnail_img($related_post, $size = null, $force = fals
|
|
315 |
return wp_rp_get_img_tag($related_post->thumbnail, $post_title);
|
316 |
}
|
317 |
|
318 |
-
$size =
|
319 |
if (!$size) { return false; }
|
|
|
320 |
if ($options['thumbnail_use_custom']) {
|
321 |
$thumbnail_src = get_post_meta($related_post->ID, $options["thumbnail_custom_field"], true);
|
322 |
|
10 |
if ($platform_options['theme_name'] == 'pinterest.css') {
|
11 |
add_image_size(WP_RP_THUMBNAILS_PROP_NAME, WP_RP_THUMBNAILS_WIDTH, 0, false);
|
12 |
}
|
13 |
+
if ($platform_options['custom_size_thumbnail_enabled']) {
|
14 |
+
add_image_size(WP_RP_THUMBNAILS_NAME, $platform_options['custom_thumbnail_width'], $platform_options['custom_thumbnail_height'], true);
|
15 |
+
}
|
16 |
}
|
17 |
add_action('init', 'wp_rp_add_image_sizes');
|
18 |
|
30 |
return false;
|
31 |
}
|
32 |
|
33 |
+
if ($image_id = media_handle_upload('wp_rp_default_thumbnail', 0)) {
|
|
|
34 |
$image_data = wp_rp_get_image_data($image_id);
|
35 |
+
$platform_options = wp_rp_get_platform_options();
|
36 |
+
|
37 |
+
$img_width = $platform_options['custom_size_thumbnail_enabled'] ? $platform_options['custom_thumbnail_width'] : WP_RP_THUMBNAILS_WIDTH;
|
38 |
+
$img_height = $platform_options['custom_size_thumbnail_enabled'] ? $platform_options['custom_thumbnail_height'] : WP_RP_THUMBNAILS_HEIGHT;
|
39 |
+
|
40 |
+
if ($image = wp_rp_get_image_with_exact_size($image_data, array($img_width, $img_height))) {
|
41 |
$upload_dir = wp_upload_dir();
|
42 |
return $upload_dir['url'] . '/' . $image['file'];
|
43 |
}
|
80 |
}
|
81 |
|
82 |
$attach_data = wp_get_attachment_metadata($attachment_id);
|
83 |
+
$platform_options = wp_rp_get_platform_options();
|
84 |
+
$min_width = $platform_options['custom_size_thumbnail_enabled'] ? WP_RP_CUSTOM_THUMBNAILS_WIDTH : WP_RP_THUMBNAILS_WIDTH;
|
85 |
+
$min_height = $platform_options['custom_size_thumbnail_enabled'] ? WP_RP_CUSTOM_THUMBNAILS_HEIGHT : WP_RP_THUMBNAILS_HEIGHT;
|
86 |
+
|
87 |
+
if (!$attach_data || $attach_data['width'] < $min_width || $attach_data['height'] < $min_height) {
|
88 |
wp_delete_attachment($attachment_id);
|
89 |
return false;
|
90 |
}
|
135 |
include_once(ABSPATH . 'wp-admin/includes/image.php');
|
136 |
|
137 |
$img_path = get_attached_file($attachment_id);
|
138 |
+
$platform_options = wp_rp_get_platform_options();
|
139 |
if (!$img_path) { return false; }
|
140 |
|
141 |
+
if (!empty($platform_options['custom_size_thumbnail_enabled'])) {
|
142 |
+
// generate_attachment_metadata works with media thumbnail settings only
|
143 |
+
// store user's options to restore them after update
|
144 |
+
$media_thumb_width = get_option('thumbnail_size_w');
|
145 |
+
$media_thumb_height = get_option('thumbnail_size_h');
|
146 |
+
$media_crop = get_option('thumbnail_crop');
|
147 |
+
update_option('thumbnail_size_w', $platform_options['custom_thumbnail_width']);
|
148 |
+
update_option('thumbnail_size_h', $platform_options['custom_thumbnail_height']);
|
149 |
+
update_option('thumbnail_crop', 1);
|
150 |
+
}
|
151 |
+
|
152 |
$attach_data = wp_generate_attachment_metadata($attachment_id, $img_path);
|
153 |
wp_update_attachment_metadata($attachment_id, $attach_data);
|
154 |
|
155 |
+
if (!empty($platform_options['custom_size_thumbnail_enabled'])) {
|
156 |
+
update_option('thumbnail_size_w', $media_thumb_width);
|
157 |
+
update_option('thumbnail_size_h', $media_thumb_height);
|
158 |
+
update_option('thumbnail_crop', $media_crop);
|
159 |
+
}
|
160 |
+
|
161 |
return $attachment_id;
|
162 |
}
|
163 |
|
287 |
// image_id in the db is incorrect
|
288 |
delete_post_meta($related_post->ID, '_wp_rp_image');
|
289 |
}
|
|
|
290 |
if (!$image_data && has_post_thumbnail($related_post->ID)) {
|
291 |
$image_data = wp_rp_get_image_data(get_post_thumbnail_id($related_post->ID));
|
292 |
}
|
317 |
return false;
|
318 |
}
|
319 |
|
320 |
+
function wp_rp_get_thumbnail_size_array($size) {
|
321 |
+
$platform_options = wp_rp_get_platform_options();
|
322 |
+
|
323 |
if (!$size || $size === 'thumbnail') {
|
324 |
+
if ($platform_options['custom_size_thumbnail_enabled']) {
|
325 |
+
return array($platform_options['custom_thumbnail_width'], $platform_options['custom_thumbnail_height']);
|
326 |
+
}
|
327 |
return array(WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT);
|
328 |
}
|
329 |
if ($size == 'full') {
|
338 |
function wp_rp_get_post_thumbnail_img($related_post, $size = null, $force = false) {
|
339 |
$options = wp_rp_get_options();
|
340 |
$platform_options = wp_rp_get_platform_options();
|
|
|
341 |
if (!($platform_options["display_thumbnail"] || $force)) {
|
342 |
return false;
|
343 |
}
|
347 |
return wp_rp_get_img_tag($related_post->thumbnail, $post_title);
|
348 |
}
|
349 |
|
350 |
+
$size = wp_rp_get_thumbnail_size_array($size);
|
351 |
if (!$size) { return false; }
|
352 |
+
|
353 |
if ($options['thumbnail_use_custom']) {
|
354 |
$thumbnail_src = get_post_meta($related_post->ID, $options["thumbnail_custom_field"], true);
|
355 |
|
wp_related_posts.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WordPress Related Posts
|
4 |
-
Version: 3.
|
5 |
Plugin URI: http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/
|
6 |
Description: Quickly increase your readers' engagement with your posts by adding Related Posts in the footer of your content. Click on <a href="admin.php?page=wordpress-related-posts">Related Posts tab</a> to configure your settings.
|
7 |
Author: Zemanta Ltd.
|
8 |
Author URI: http://www.zemanta.com
|
9 |
*/
|
10 |
|
11 |
-
define('WP_RP_VERSION', '3.
|
12 |
|
13 |
define('WP_RP_PLUGIN_FILE', plugin_basename(__FILE__));
|
14 |
|
@@ -87,10 +87,17 @@ function wp_rp_is_phone() {
|
|
87 |
function wp_rp_get_platform_options() {
|
88 |
$options = wp_rp_get_options();
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
if (wp_rp_is_phone()) {
|
91 |
return $options['mobile'];
|
92 |
}
|
93 |
-
return $options['desktop'];
|
94 |
}
|
95 |
|
96 |
function wp_rp_ajax_load_articles_callback() {
|
@@ -143,6 +150,9 @@ function wp_rp_ajax_load_articles_callback() {
|
|
143 |
'id' => $related_post->ID,
|
144 |
'url' => get_permalink($related_post->ID),
|
145 |
'title' => $related_post->post_title,
|
|
|
|
|
|
|
146 |
'img' => wp_rp_get_post_thumbnail_img($related_post, $image_size)
|
147 |
));
|
148 |
}
|
@@ -282,13 +292,14 @@ function wp_rp_generate_related_posts_list_items($related_posts, $selected_relat
|
|
282 |
|
283 |
if ($platform_options["display_publish_date"]){
|
284 |
$dateformat = get_option('date_format');
|
285 |
-
$output .= mysql2date($dateformat, $related_post->post_date) .
|
|
|
286 |
}
|
287 |
|
288 |
$output .= '<a href="' . $post_url . '" class="wp_rp_title">' . wptexturize($related_post->post_title) . '</a>';
|
289 |
|
290 |
if ($platform_options["display_comment_count"] && property_exists($related_post, 'comment_count')){
|
291 |
-
$output .= " (
|
292 |
}
|
293 |
|
294 |
if ($platform_options["display_excerpt"]){
|
@@ -306,7 +317,7 @@ function wp_rp_generate_related_posts_list_items($related_posts, $selected_relat
|
|
306 |
if (strlen($excerpt) > $excerpt_max_length) {
|
307 |
$excerpt = mb_substr($excerpt, 0, $excerpt_max_length - 3) . '...';
|
308 |
}
|
309 |
-
$output .= '<
|
310 |
}
|
311 |
}
|
312 |
$output .= '</li>';
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WordPress Related Posts
|
4 |
+
Version: 3.2
|
5 |
Plugin URI: http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/
|
6 |
Description: Quickly increase your readers' engagement with your posts by adding Related Posts in the footer of your content. Click on <a href="admin.php?page=wordpress-related-posts">Related Posts tab</a> to configure your settings.
|
7 |
Author: Zemanta Ltd.
|
8 |
Author URI: http://www.zemanta.com
|
9 |
*/
|
10 |
|
11 |
+
define('WP_RP_VERSION', '3.2');
|
12 |
|
13 |
define('WP_RP_PLUGIN_FILE', plugin_basename(__FILE__));
|
14 |
|
87 |
function wp_rp_get_platform_options() {
|
88 |
$options = wp_rp_get_options();
|
89 |
|
90 |
+
$thumb_options = array('custom_size_thumbnail_enabled' => false);
|
91 |
+
|
92 |
+
if (!empty($options['custom_size_thumbnail_enabled'])) {
|
93 |
+
$thumb_options['custom_size_thumbnail_enabled'] = $options['custom_size_thumbnail_enabled'];
|
94 |
+
$thumb_options['custom_thumbnail_width'] = $options['custom_thumbnail_width'];
|
95 |
+
$thumb_options['custom_thumbnail_height'] = $options['custom_thumbnail_height'];
|
96 |
+
}
|
97 |
if (wp_rp_is_phone()) {
|
98 |
return $options['mobile'];
|
99 |
}
|
100 |
+
return $options['desktop'] + $thumb_options;
|
101 |
}
|
102 |
|
103 |
function wp_rp_ajax_load_articles_callback() {
|
150 |
'id' => $related_post->ID,
|
151 |
'url' => get_permalink($related_post->ID),
|
152 |
'title' => $related_post->post_title,
|
153 |
+
'excerpt' => $related_post->post_excerpt,
|
154 |
+
'date' => $related_post->post_date,
|
155 |
+
'comments' => $related_post->comment_count,
|
156 |
'img' => wp_rp_get_post_thumbnail_img($related_post, $image_size)
|
157 |
));
|
158 |
}
|
292 |
|
293 |
if ($platform_options["display_publish_date"]){
|
294 |
$dateformat = get_option('date_format');
|
295 |
+
$output .= '<small class="wp_rp_publish_date">' . mysql2date($dateformat, $related_post->post_date) . '</small> ';
|
296 |
+
//$output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
|
297 |
}
|
298 |
|
299 |
$output .= '<a href="' . $post_url . '" class="wp_rp_title">' . wptexturize($related_post->post_title) . '</a>';
|
300 |
|
301 |
if ($platform_options["display_comment_count"] && property_exists($related_post, 'comment_count')){
|
302 |
+
$output .= '<small class="wp_rp_comments_count"> (' . $related_post->comment_count . ')</small><br />';
|
303 |
}
|
304 |
|
305 |
if ($platform_options["display_excerpt"]){
|
317 |
if (strlen($excerpt) > $excerpt_max_length) {
|
318 |
$excerpt = mb_substr($excerpt, 0, $excerpt_max_length - 3) . '...';
|
319 |
}
|
320 |
+
$output .= ' <small class="wp_rp_excerpt">' . $excerpt . '</small>';
|
321 |
}
|
322 |
}
|
323 |
$output .= '</li>';
|