Version Description
- Fixed an issue where changing an Attachment changed all attachments, props @bartoszwww
- Fixed an issue where certain Unicode characters weren't decoded properly, props @stuk88
Download this release
Release Info
Developer | jchristopher |
Plugin | Attachments |
Version | 3.5.1 |
Comparing to | |
See all releases |
Code changes from version 3.5 to 3.5.1
- classes/class.attachments.migrate.php +7 -0
- classes/class.attachments.php +16 -6
- docs/changelog.md +4 -0
- index.php +1 -1
- readme.txt +6 -2
classes/class.attachments.migrate.php
CHANGED
@@ -142,6 +142,9 @@ class AttachmentsMigrate extends Attachments
|
|
142 |
// we're done! let's save everything in our new format
|
143 |
$existing_attachments = version_compare( PHP_VERSION, '5.4.0', '>=' ) ? json_encode( $existing_attachments, JSON_UNESCAPED_UNICODE ) : json_encode( $existing_attachments );
|
144 |
|
|
|
|
|
|
|
145 |
// save it to the database
|
146 |
update_post_meta( $query->post->ID, 'attachments', $existing_attachments );
|
147 |
|
@@ -882,6 +885,10 @@ EOD;
|
|
882 |
|
883 |
// now we can save
|
884 |
$existing_attachments = version_compare( PHP_VERSION, '5.4.0', '>=' ) ? json_encode( $existing_attachments, JSON_UNESCAPED_UNICODE ) : json_encode( $existing_attachments );
|
|
|
|
|
|
|
|
|
885 |
update_post_meta( $query->post->ID, $this->get_meta_key(), $existing_attachments );
|
886 |
|
887 |
}
|
142 |
// we're done! let's save everything in our new format
|
143 |
$existing_attachments = version_compare( PHP_VERSION, '5.4.0', '>=' ) ? json_encode( $existing_attachments, JSON_UNESCAPED_UNICODE ) : json_encode( $existing_attachments );
|
144 |
|
145 |
+
// fix potentially encoded Unicode
|
146 |
+
$existing_attachments = str_replace( '\\', '\\\\', $existing_attachments );
|
147 |
+
|
148 |
// save it to the database
|
149 |
update_post_meta( $query->post->ID, 'attachments', $existing_attachments );
|
150 |
|
885 |
|
886 |
// now we can save
|
887 |
$existing_attachments = version_compare( PHP_VERSION, '5.4.0', '>=' ) ? json_encode( $existing_attachments, JSON_UNESCAPED_UNICODE ) : json_encode( $existing_attachments );
|
888 |
+
|
889 |
+
// fix potentially encoded Unicode
|
890 |
+
$existing_attachments = str_replace( '\\', '\\\\', $existing_attachments );
|
891 |
+
|
892 |
update_post_meta( $query->post->ID, $this->get_meta_key(), $existing_attachments );
|
893 |
|
894 |
}
|
classes/class.attachments.php
CHANGED
@@ -55,7 +55,7 @@ if( !class_exists( 'Attachments' ) ) :
|
|
55 |
global $_wp_additional_image_sizes;
|
56 |
|
57 |
// establish our environment variables
|
58 |
-
$this->version = '3.5';
|
59 |
$this->url = ATTACHMENTS_URL;
|
60 |
$this->dir = ATTACHMENTS_DIR;
|
61 |
$plugin = 'attachments/index.php';
|
@@ -858,12 +858,17 @@ if( !class_exists( 'Attachments' ) ) :
|
|
858 |
});
|
859 |
|
860 |
$element.on( 'click', '.edit-attachment-asset', function( event ) {
|
|
|
861 |
event.preventDefault();
|
|
|
|
|
|
|
862 |
if ( editframe ) {
|
863 |
editframe.open();
|
864 |
editframe.content.mode(router);
|
865 |
return;
|
866 |
}
|
|
|
867 |
editframe = wp.media({
|
868 |
title: title,
|
869 |
multiple: false,
|
@@ -874,7 +879,9 @@ if( !class_exists( 'Attachments' ) ) :
|
|
874 |
text: '<?php _e( "Change", 'attachments' ); ?>'
|
875 |
}
|
876 |
});
|
|
|
877 |
editframe.on( 'select', function(){
|
|
|
878 |
var selection = editframe.state().get('selection');
|
879 |
|
880 |
if ( ! selection )
|
@@ -883,7 +890,7 @@ if( !class_exists( 'Attachments' ) ) :
|
|
883 |
selection.each( function( attachment ) {
|
884 |
|
885 |
// update the ID
|
886 |
-
|
887 |
|
888 |
// update the thumbnail
|
889 |
var updatedThumb = false;
|
@@ -892,21 +899,21 @@ if( !class_exists( 'Attachments' ) ) :
|
|
892 |
if(attachments_isset(attachment.attributes.sizes.thumbnail)){
|
893 |
if(attachments_isset(attachment.attributes.sizes.thumbnail.url)){
|
894 |
updatedThumb = true;
|
895 |
-
|
896 |
}
|
897 |
}
|
898 |
}
|
899 |
}
|
900 |
if( !updatedThumb ){
|
901 |
-
|
902 |
}
|
903 |
|
904 |
// update the name
|
905 |
-
|
906 |
|
907 |
// update the dimensions
|
908 |
if(attachments_isset(attachment.attributes.width)&&attachments_isset(attachment.attributes.height)){
|
909 |
-
|
910 |
}
|
911 |
|
912 |
} );
|
@@ -1553,6 +1560,9 @@ if( !class_exists( 'Attachments' ) ) :
|
|
1553 |
// we're going to store JSON (JSON_UNESCAPED_UNICODE is PHP 5.4+)
|
1554 |
$attachments = version_compare( PHP_VERSION, '5.4.0', '>=' ) ? json_encode( $attachments, JSON_UNESCAPED_UNICODE ) : json_encode( $attachments );
|
1555 |
|
|
|
|
|
|
|
1556 |
// we're going to wipe out any existing Attachments meta (because we'll put it back)
|
1557 |
return update_post_meta( $post_id, $this->meta_key, $attachments );
|
1558 |
}
|
55 |
global $_wp_additional_image_sizes;
|
56 |
|
57 |
// establish our environment variables
|
58 |
+
$this->version = '3.5.1';
|
59 |
$this->url = ATTACHMENTS_URL;
|
60 |
$this->dir = ATTACHMENTS_DIR;
|
61 |
$plugin = 'attachments/index.php';
|
858 |
});
|
859 |
|
860 |
$element.on( 'click', '.edit-attachment-asset', function( event ) {
|
861 |
+
|
862 |
event.preventDefault();
|
863 |
+
|
864 |
+
var targetAttachment = $(event.target).parents(".attachments-attachment");
|
865 |
+
|
866 |
if ( editframe ) {
|
867 |
editframe.open();
|
868 |
editframe.content.mode(router);
|
869 |
return;
|
870 |
}
|
871 |
+
|
872 |
editframe = wp.media({
|
873 |
title: title,
|
874 |
multiple: false,
|
879 |
text: '<?php _e( "Change", 'attachments' ); ?>'
|
880 |
}
|
881 |
});
|
882 |
+
|
883 |
editframe.on( 'select', function(){
|
884 |
+
|
885 |
var selection = editframe.state().get('selection');
|
886 |
|
887 |
if ( ! selection )
|
890 |
selection.each( function( attachment ) {
|
891 |
|
892 |
// update the ID
|
893 |
+
targetAttachment.find('input.attachments-track-id').val(attachment.id);
|
894 |
|
895 |
// update the thumbnail
|
896 |
var updatedThumb = false;
|
899 |
if(attachments_isset(attachment.attributes.sizes.thumbnail)){
|
900 |
if(attachments_isset(attachment.attributes.sizes.thumbnail.url)){
|
901 |
updatedThumb = true;
|
902 |
+
targetAttachment.find('.attachment-thumbnail img').attr('src',attachment.attributes.sizes.thumbnail.url);
|
903 |
}
|
904 |
}
|
905 |
}
|
906 |
}
|
907 |
if( !updatedThumb ){
|
908 |
+
targetAttachment.find('.attachment-thumbnail img').attr('src','');
|
909 |
}
|
910 |
|
911 |
// update the name
|
912 |
+
targetAttachment.find('.attachment-details .filename').text(attachment.attributes.filename);
|
913 |
|
914 |
// update the dimensions
|
915 |
if(attachments_isset(attachment.attributes.width)&&attachments_isset(attachment.attributes.height)){
|
916 |
+
targetAttachment.find('.attachment-details .dimensions').html(attachment.attributes.width + ' × ' + attachment.attributes.height).show();
|
917 |
}
|
918 |
|
919 |
} );
|
1560 |
// we're going to store JSON (JSON_UNESCAPED_UNICODE is PHP 5.4+)
|
1561 |
$attachments = version_compare( PHP_VERSION, '5.4.0', '>=' ) ? json_encode( $attachments, JSON_UNESCAPED_UNICODE ) : json_encode( $attachments );
|
1562 |
|
1563 |
+
// fix potentially encoded Unicode
|
1564 |
+
$attachments = str_replace( '\\', '\\\\', $attachments );
|
1565 |
+
|
1566 |
// we're going to wipe out any existing Attachments meta (because we'll put it back)
|
1567 |
return update_post_meta( $post_id, $this->meta_key, $attachments );
|
1568 |
}
|
docs/changelog.md
CHANGED
@@ -4,6 +4,10 @@ This is a WordPress plugin. [Official download available on WordPress.org](http:
|
|
4 |
|
5 |
<dl>
|
6 |
|
|
|
|
|
|
|
|
|
7 |
<dt>3.5</dt>
|
8 |
<dd>Initial implementation of limiting the number of Attachments</dd>
|
9 |
<dd>You can now change an Attachment asset without having to remove the entire Attachment and re-add something new</dd>
|
4 |
|
5 |
<dl>
|
6 |
|
7 |
+
<dt>3.5.1</dt>
|
8 |
+
<dd>Fixed an issue where changing an Attachment changed all attachments</dd>
|
9 |
+
<dd>Fixed an issue where certain Unicode characters weren't decoded properly</dd>
|
10 |
+
|
11 |
<dt>3.5</dt>
|
12 |
<dd>Initial implementation of limiting the number of Attachments</dd>
|
13 |
<dd>You can now change an Attachment asset without having to remove the entire Attachment and re-add something new</dd>
|
index.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Description: Attachments gives the ability to append any number of Media Library items to Pages, Posts, and Custom Post Types
|
7 |
* Author: Jonathan Christopher
|
8 |
* Author URI: http://mondaybynoon.com/
|
9 |
-
* Version: 3.5
|
10 |
* Text Domain: attachments
|
11 |
* Domain Path: /languages/
|
12 |
* License: GPLv2 or later
|
6 |
* Description: Attachments gives the ability to append any number of Media Library items to Pages, Posts, and Custom Post Types
|
7 |
* Author: Jonathan Christopher
|
8 |
* Author URI: http://mondaybynoon.com/
|
9 |
+
* Version: 3.5.1
|
10 |
* Text Domain: attachments
|
11 |
* Domain Path: /languages/
|
12 |
* License: GPLv2 or later
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://mondaybynoon.com/donate/
|
|
4 |
Tags: post, page, posts, pages, images, PDF, doc, Word, image, jpg, jpeg, picture, pictures, photos, attachment
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.6
|
7 |
-
Stable tag: 3.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -12,7 +12,7 @@ Attachments allows you to simply append any number of items from your WordPress
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
**Extensive** usage instructions are [available on GitHub](https://github.com/jchristopher/attachments
|
16 |
|
17 |
Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types. This plugin *does not* directly interact with your theme, you will need to edit your template files.
|
18 |
|
@@ -81,6 +81,10 @@ Please see [Issues on GitHub](https://github.com/jchristopher/attachments/issues
|
|
81 |
|
82 |
Please see [Attachments' changelog on GitHub](https://github.com/jchristopher/attachments/docs/changelog.md)
|
83 |
|
|
|
|
|
|
|
|
|
84 |
= 3.5 =
|
85 |
* Initial implementation of limiting the number of Attachments
|
86 |
* You can now change an Attachment asset without having to remove the entire Attachment and re-add something new
|
4 |
Tags: post, page, posts, pages, images, PDF, doc, Word, image, jpg, jpeg, picture, pictures, photos, attachment
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.6
|
7 |
+
Stable tag: 3.5.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
**Extensive** usage instructions are [available on GitHub](https://github.com/jchristopher/attachments/#attachments)
|
16 |
|
17 |
Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types. This plugin *does not* directly interact with your theme, you will need to edit your template files.
|
18 |
|
81 |
|
82 |
Please see [Attachments' changelog on GitHub](https://github.com/jchristopher/attachments/docs/changelog.md)
|
83 |
|
84 |
+
= 3.5.1 =
|
85 |
+
* Fixed an issue where changing an Attachment changed all attachments, props @bartoszwww
|
86 |
+
* Fixed an issue where certain Unicode characters weren't decoded properly, props @stuk88
|
87 |
+
|
88 |
= 3.5 =
|
89 |
* Initial implementation of limiting the number of Attachments
|
90 |
* You can now change an Attachment asset without having to remove the entire Attachment and re-add something new
|