Skip to content

Commit

Permalink
ver 3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Richmond committed Jan 15, 2014
1 parent 825bedd commit 760314e
Show file tree
Hide file tree
Showing 11 changed files with 2,064 additions and 1,875 deletions.
1,300 changes: 693 additions & 607 deletions config.php

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions readme.txt
Expand Up @@ -3,8 +3,8 @@ Contributors: zemanta
Tags: related,posts,post,related posts,plugin
License: GPLv2
Requires at least: 3.3
Tested up to: 3.6
Stable tag: 3.0
Tested up to: 3.8
Stable tag: 3.3.1

WordPress Related Posts generates a list of related posts with thumbnails and gives you click-through statistics.

Expand All @@ -30,6 +30,7 @@ WordPress Related Posts is constantly improved to bring you the highest rates of

= Are there any settings? Plenty! =

* responsive themes
* thumbnail size, style
* number of posts
* display post excerpt, publish date, number of comments
Expand Down Expand Up @@ -81,6 +82,23 @@ Fix for security vulnerability. Upgrade immediately.

== Changelog ==

= 3.3.1 =
* Added setting for admins to restrict the ability to edit automatically added Related posts to admins only
* Getting ready to reorganize settings page

= 3.3 =
* Fixed compatibility issues with Zemanta Editorial Assistant
* Fixed transparency for images on settings page

= 3.2 =
* 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)

= 3.1 =
* Related content (articles) on compose screen for all users with English WordPress interface
* Language detection for WordPressP interface: non-English users don't get the widget, existing ones get opt-out

= 3.0 =
* Opt-out for Related recommendations (articles)
* Improved caching
Expand Down
45 changes: 41 additions & 4 deletions settings.php
Expand Up @@ -60,6 +60,7 @@ function wp_rp_settings_admin_menu() {
function wp_rp_settings_scripts() {
wp_enqueue_script('wp_rp_themes_script', plugins_url('static/js/themes.js', __FILE__), array('jquery'), WP_RP_VERSION);
wp_enqueue_script("wp_rp_dashboard_script", plugins_url('static/js/dashboard.js', __FILE__), array('jquery'), WP_RP_VERSION);
wp_enqueue_script("wp_rp_extras_script", plugins_url('static/js/extras.js', __FILE__), array('jquery'), WP_RP_VERSION);
}
function wp_rp_settings_styles() {
wp_enqueue_style("wp_rp_dashboard_style", plugins_url("static/css/dashboard.css", __FILE__), array(), WP_RP_VERSION);
Expand Down Expand Up @@ -162,9 +163,14 @@ function wp_rp_settings_page() {
'traffic_exchange_enabled' => isset($postdata['wp_rp_traffic_exchange_enabled']),
'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,

'custom_size_thumbnail_enabled' => isset($postdata['wp_rp_custom_size_thumbnail_enabled']) && $postdata['wp_rp_custom_size_thumbnail_enabled'] === 'yes',
'custom_thumbnail_width' => isset($postdata['wp_rp_custom_thumbnail_width']) ? intval(trim($postdata['wp_rp_custom_thumbnail_width'])) : WP_RP_CUSTOM_THUMBNAILS_WIDTH ,
'custom_thumbnail_height' => isset($postdata['wp_rp_custom_thumbnail_height']) ? intval(trim($postdata['wp_rp_custom_thumbnail_height'])) : WP_RP_CUSTOM_THUMBNAILS_HEIGHT,

'thumbnail_use_custom' => isset($postdata['wp_rp_thumbnail_use_custom']) && $postdata['wp_rp_thumbnail_use_custom'] === 'yes',
'thumbnail_custom_field' => isset($postdata['wp_rp_thumbnail_custom_field']) ? trim($postdata['wp_rp_thumbnail_custom_field']) : '',
'display_zemanta_linky' => $meta['show_zemanta_linky_option'] ? isset($postdata['wp_rp_display_zemanta_linky']) : true,
'only_admins_can_edit_related_posts' => !empty($postdata['wp_rp_only_admins_can_edit_related_posts']),

'mobile' => array(
'display_comment_count' => isset($postdata['wp_rp_mobile_display_comment_count']),
Expand Down Expand Up @@ -415,7 +421,7 @@ function wp_rp_settings_page() {
<tr id="wp_rp_<?php echo $platform; ?>_theme_custom_css_wrap" style="display: none; ">
<td>
<label>
<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"]); ?> onclick="wp_rp_display_thumbnail_onclick();" />
<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"]); ?> />
<?php _e("Display Thumbnails For Related Posts",'wp_related_posts');?>
</label><br />
<label>
Expand All @@ -427,7 +433,7 @@ function wp_rp_settings_page() {
<?php _e("Display Publish Date",'wp_related_posts');?>
</label><br />
<label>
<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"]); ?> onclick="wp_rp_display_excerpt_onclick();" >
<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"]); ?> />
<?php _e("Display Post Excerpt",'wp_related_posts');?>
</label>
<label id="wp_rp_<?php echo $platform; ?>_excerpt_max_length_label">
Expand Down Expand Up @@ -492,6 +498,31 @@ function wp_rp_settings_page() {
</td>
</tr>
</tbody>
</table>
<h3>Custom Size Thumbnails</h3>
<table class="form-table">
<tbody>
<tr><td>
Our themes were created with thumbnail size of 150x150px in mind.<br>
If you want to use custom sizes, override theme's CSS rules in the Custom CSS section under Theme Settings above.
</td></tr>
<tr><td>
<label>
<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']); ?> />
<?php _e("Use Custom Size Thumbnails",'wp_related_posts');?>
</label><br />
<div id="wp_rp_custom_thumb_sizes_settings" style="display:none">
<label>
<?php _e("Custom Width (px)",'wp_related_posts');?>
<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']); ?>" />
</label>
<label>
<?php _e("Custom Height (px)",'wp_related_posts');?>
<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']); ?>" />
</label>
</div>
</td></tr>
</tbody>
</table><?php

/**************************************
Expand Down Expand Up @@ -525,7 +556,7 @@ function wp_rp_settings_page() {
</td>
</tr>
<tr valign="top">
<td colspan="2"><?php if(strpos(get_bloginfo('language'), 'en') === 0): ?>
<td colspan="2"><?php if(strpos(get_bloginfo('language'), 'en') === 0 || $meta['classic_user']): ?>
<br/>
<label>
<input name="wp_rp_classic_state" type="checkbox" id="wp_rp_classic_state" value="yes" <?php checked($meta['classic_user']); ?>>
Expand Down Expand Up @@ -564,6 +595,12 @@ function wp_rp_settings_page() {
<input name="wp_rp_display_zemanta_linky" type="checkbox" id="wp_rp_display_zemanta_linky" value="yes" <?php checked($options['display_zemanta_linky']); ?> />
<?php _e("Support us (show our logo)",'wp_related_posts');?>
</label><?php endif; ?>
<div>
<label>
<input type="checkbox" name="wp_rp_only_admins_can_edit_related_posts" id="wp_rp_only_admins_can_edit_related_posts" value="yes" <?php checked($options['only_admins_can_edit_related_posts']); ?> />
<?php _e("Only admins can edit Related Posts",'wp_related_posts');?>
</label>
</div>
</td>
</tr>
</table>
Expand All @@ -573,4 +610,4 @@ function wp_rp_settings_page() {
</div>
</form>
</div>
<?php }
<?php } ?>
4 changes: 2 additions & 2 deletions static/css/dashboard.css
Expand Up @@ -122,8 +122,8 @@ form.wp_rp_message_form a.dismiss {float: right;}
#wp_rp_wrap .excluded-categories {width: 250px; height: 12em; overflow: auto; padding: 0 5px; border: 1px solid #dfdfdf;}

/* collapsible CSS */
#wp_rp_wrap .collapsible .collapse-handle {margin-top: 16px; margin-right: 16px; float: right; width: 30px; height: 20px; background: url('../img/up.jpg') 0% 0% no-repeat; text-indent: -9999px; overflow: hidden; outline: 0;}
#wp_rp_wrap .collapsible.collapsed .collapse-handle {background-image: url('../img/down.jpg');}
#wp_rp_wrap .collapsible .collapse-handle {margin-top: 16px; margin-right: 16px; float: right; width: 30px; height: 20px; background: url('../img/up.png') 0% 0% no-repeat; text-indent: -9999px; overflow: hidden; outline: 0;}
#wp_rp_wrap .collapsible.collapsed .collapse-handle {background-image: url('../img/down.png');}
#wp_rp_wrap .collapsible .collapse-handle:after {clear:both;overflow:hidden;height:0;}

#wp_rp_theme_options_wrap .wp_rp_settings_button {font-size: 1.5em;padding:0 0 0 20px;background: url('../img/arrow_right.png') left center no-repeat;background-position: 3px 3px;}
Expand Down
Binary file added static/img/down.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/img/turnonscreen.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/js/extras.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 41 additions & 8 deletions thumbnailer.php
Expand Up @@ -10,6 +10,9 @@ function wp_rp_add_image_sizes() {
if ($platform_options['theme_name'] == 'pinterest.css') {
add_image_size(WP_RP_THUMBNAILS_PROP_NAME, WP_RP_THUMBNAILS_WIDTH, 0, false);
}
if ($platform_options['custom_size_thumbnail_enabled']) {
add_image_size(WP_RP_THUMBNAILS_NAME, $platform_options['custom_thumbnail_width'], $platform_options['custom_thumbnail_height'], true);
}
}
add_action('init', 'wp_rp_add_image_sizes');

Expand All @@ -27,10 +30,14 @@ function wp_rp_upload_default_thumbnail_file() {
return false;
}

$image_id = media_handle_upload('wp_rp_default_thumbnail', 0);
if ($image_id) {
if ($image_id = media_handle_upload('wp_rp_default_thumbnail', 0)) {
$image_data = wp_rp_get_image_data($image_id);
if ($image = wp_rp_get_image_with_exact_size($image_data, array(WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT))) {
$platform_options = wp_rp_get_platform_options();

$img_width = $platform_options['custom_size_thumbnail_enabled'] ? $platform_options['custom_thumbnail_width'] : WP_RP_THUMBNAILS_WIDTH;
$img_height = $platform_options['custom_size_thumbnail_enabled'] ? $platform_options['custom_thumbnail_height'] : WP_RP_THUMBNAILS_HEIGHT;

if ($image = wp_rp_get_image_with_exact_size($image_data, array($img_width, $img_height))) {
$upload_dir = wp_upload_dir();
return $upload_dir['url'] . '/' . $image['file'];
}
Expand Down Expand Up @@ -73,7 +80,11 @@ function wp_rp_upload_attachment($url, $post_id) {
}

$attach_data = wp_get_attachment_metadata($attachment_id);
if (!$attach_data || $attach_data['width'] < WP_RP_THUMBNAILS_WIDTH || $attach_data['height'] < WP_RP_THUMBNAILS_HEIGHT) {
$platform_options = wp_rp_get_platform_options();
$min_width = $platform_options['custom_size_thumbnail_enabled'] ? WP_RP_CUSTOM_THUMBNAILS_WIDTH : WP_RP_THUMBNAILS_WIDTH;
$min_height = $platform_options['custom_size_thumbnail_enabled'] ? WP_RP_CUSTOM_THUMBNAILS_HEIGHT : WP_RP_THUMBNAILS_HEIGHT;

if (!$attach_data || $attach_data['width'] < $min_width || $attach_data['height'] < $min_height) {
wp_delete_attachment($attachment_id);
return false;
}
Expand Down Expand Up @@ -124,11 +135,29 @@ function wp_rp_update_attachment_id($attachment_id) {
include_once(ABSPATH . 'wp-admin/includes/image.php');

$img_path = get_attached_file($attachment_id);
$platform_options = wp_rp_get_platform_options();
if (!$img_path) { return false; }

if (!empty($platform_options['custom_size_thumbnail_enabled'])) {
// generate_attachment_metadata works with media thumbnail settings only
// store user's options to restore them after update
$media_thumb_width = get_option('thumbnail_size_w');
$media_thumb_height = get_option('thumbnail_size_h');
$media_crop = get_option('thumbnail_crop');
update_option('thumbnail_size_w', $platform_options['custom_thumbnail_width']);
update_option('thumbnail_size_h', $platform_options['custom_thumbnail_height']);
update_option('thumbnail_crop', 1);
}

$attach_data = wp_generate_attachment_metadata($attachment_id, $img_path);
wp_update_attachment_metadata($attachment_id, $attach_data);

if (!empty($platform_options['custom_size_thumbnail_enabled'])) {
update_option('thumbnail_size_w', $media_thumb_width);
update_option('thumbnail_size_h', $media_thumb_height);
update_option('thumbnail_crop', $media_crop);
}

return $attachment_id;
}

Expand Down Expand Up @@ -258,7 +287,6 @@ function wp_rp_get_attached_img_url($related_post, $size) {
// image_id in the db is incorrect
delete_post_meta($related_post->ID, '_wp_rp_image');
}

if (!$image_data && has_post_thumbnail($related_post->ID)) {
$image_data = wp_rp_get_image_data(get_post_thumbnail_id($related_post->ID));
}
Expand Down Expand Up @@ -289,8 +317,13 @@ function wp_rp_get_attached_img_url($related_post, $size) {
return false;
}

function wp_rp_get_thumbanil_size_array($size) {
function wp_rp_get_thumbnail_size_array($size) {
$platform_options = wp_rp_get_platform_options();

if (!$size || $size === 'thumbnail') {
if ($platform_options['custom_size_thumbnail_enabled']) {
return array($platform_options['custom_thumbnail_width'], $platform_options['custom_thumbnail_height']);
}
return array(WP_RP_THUMBNAILS_WIDTH, WP_RP_THUMBNAILS_HEIGHT);
}
if ($size == 'full') {
Expand All @@ -305,7 +338,6 @@ function wp_rp_get_thumbanil_size_array($size) {
function wp_rp_get_post_thumbnail_img($related_post, $size = null, $force = false) {
$options = wp_rp_get_options();
$platform_options = wp_rp_get_platform_options();

if (!($platform_options["display_thumbnail"] || $force)) {
return false;
}
Expand All @@ -315,8 +347,9 @@ function wp_rp_get_post_thumbnail_img($related_post, $size = null, $force = fals
return wp_rp_get_img_tag($related_post->thumbnail, $post_title);
}

$size = wp_rp_get_thumbanil_size_array($size);
$size = wp_rp_get_thumbnail_size_array($size);
if (!$size) { return false; }

if ($options['thumbnail_use_custom']) {
$thumbnail_src = get_post_meta($related_post->ID, $options["thumbnail_custom_field"], true);

Expand Down

0 comments on commit 760314e

Please sign in to comment.