Version Description
- Fixed a bug with storing foreign characters
- Added live search to Browse Existing Dialog
Download this release
Release Info
Developer | jchristopher |
Plugin | Attachments |
Version | 1.1.1 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.1.1
- attachments.php +5 -5
- css/attachments.css +10 -3
- js/attachments.js +150 -0
- media.php +20 -15
- readme.txt +7 -3
attachments.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: Attachments
|
4 |
Plugin URI: http://mondaybynoon.com/wordpress-attachments/
|
5 |
-
Description: Attachments gives the ability to append any number of Media Library items to Pages and
|
6 |
-
Version: 1.1
|
7 |
Author: Jonathan Christopher
|
8 |
Author URI: http://mondaybynoon.com/
|
9 |
*/
|
@@ -120,7 +120,7 @@ function attachments_add()
|
|
120 |
|
121 |
<ul id="attachments-actions">
|
122 |
<li id="attachments-browse">
|
123 |
-
<a href="<?php echo WP_PLUGIN_URL . '/attachments/media.php'; ?>?width=640&height=600" class="button thickbox button-highlighted browse-attachments">
|
124 |
<?php _e("Browse Existing", "attachments")?>
|
125 |
</a>
|
126 |
</li>
|
@@ -299,8 +299,8 @@ function attachments_save($post_id)
|
|
299 |
{
|
300 |
$attachment_details = array(
|
301 |
'id' => $_POST['attachment_id_' . $i],
|
302 |
-
'title' =>
|
303 |
-
'caption' =>
|
304 |
'order' => $_POST['attachment_order_' . $i]
|
305 |
);
|
306 |
|
2 |
/*
|
3 |
Plugin Name: Attachments
|
4 |
Plugin URI: http://mondaybynoon.com/wordpress-attachments/
|
5 |
+
Description: Attachments gives the ability to append any number of Media Library items to Pages, Posts, and Custom Post Types
|
6 |
+
Version: 1.1.1
|
7 |
Author: Jonathan Christopher
|
8 |
Author URI: http://mondaybynoon.com/
|
9 |
*/
|
120 |
|
121 |
<ul id="attachments-actions">
|
122 |
<li id="attachments-browse">
|
123 |
+
<a href="<?php echo WP_PLUGIN_URL . '/attachments/media.php'; ?>?width=640&height=600" title="Attachments" class="button thickbox button-highlighted browse-attachments">
|
124 |
<?php _e("Browse Existing", "attachments")?>
|
125 |
</a>
|
126 |
</li>
|
299 |
{
|
300 |
$attachment_details = array(
|
301 |
'id' => $_POST['attachment_id_' . $i],
|
302 |
+
'title' => str_replace( '"', '"', $_POST['attachment_title_' . $i] ),
|
303 |
+
'caption' => str_replace( '"', '"', $_POST['attachment_caption_' . $i] ),
|
304 |
'order' => $_POST['attachment_order_' . $i]
|
305 |
);
|
306 |
|
css/attachments.css
CHANGED
@@ -6,10 +6,11 @@ ul#attachments-actions { overflow:hidden; zoom:1; padding-top:4px; }
|
|
6 |
ul#attachments-actions li { width:50%; float:left; }
|
7 |
li#attachments-add-new { float:right; text-align:right; }
|
8 |
|
|
|
9 |
|
10 |
-
#attachments-file-list { padding:0
|
11 |
.attachments-file-section { padding:0 0 20px 0; }
|
12 |
-
p.attachments-actions {
|
13 |
|
14 |
#attachments-file-details .attachments img { display:block; }
|
15 |
#attachments-file-details .attachments a { display:block; border:3px solid #fff; float:left; }
|
@@ -57,4 +58,10 @@ p.attachments-actions { padding:10px 0; }
|
|
57 |
/* =========== */
|
58 |
.attachments_checkbox { overflow:hidden; zoom:1; padding:0 0 7px 0; }
|
59 |
.attachments_checkbox input { display:block; float:left; margin-top:2px; }
|
60 |
-
.attachments_checkbox label { display:block; float:left; padding:0 0 0 7px; }
|
|
|
|
|
|
|
|
|
|
|
|
6 |
ul#attachments-actions li { width:50%; float:left; }
|
7 |
li#attachments-add-new { float:right; text-align:right; }
|
8 |
|
9 |
+
#attachments-instructions { background:#fff; margin:0; padding:12px 0 !important; }
|
10 |
|
11 |
+
#attachments-file-list { padding:0; background:#fff; }
|
12 |
.attachments-file-section { padding:0 0 20px 0; }
|
13 |
+
p.attachments-actions { float:right; margin:6px 0 0 !important; }
|
14 |
|
15 |
#attachments-file-details .attachments img { display:block; }
|
16 |
#attachments-file-details .attachments a { display:block; border:3px solid #fff; float:left; }
|
58 |
/* =========== */
|
59 |
.attachments_checkbox { overflow:hidden; zoom:1; padding:0 0 7px 0; }
|
60 |
.attachments_checkbox input { display:block; float:left; margin-top:2px; }
|
61 |
+
.attachments_checkbox label { display:block; float:left; padding:0 0 0 7px; }
|
62 |
+
|
63 |
+
#attachments-tabs .subsubsub { float:left; }
|
64 |
+
#attachments-tabs .subsubsub a { color:#21759b !important; }
|
65 |
+
#attachments-tabs-wrapper { border-bottom:1px solid #dfdfdf; position:relative; }
|
66 |
+
#attachments-tabs #sidemenu { overflow:hidden; zoom:1; background:#f9f9f9; float:none !important; margin:0; }
|
67 |
+
#attachments-live-filter { display:block; width:140px; float:left; margin:0 0 10px; }
|
js/attachments.js
CHANGED
@@ -1,3 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
function attachments_update() {
|
2 |
jQuery('div#attachments_file_list').html(attachments_media);
|
3 |
}
|
1 |
+
// qs_score - Quicksilver Score
|
2 |
+
//
|
3 |
+
// A port of the Quicksilver string ranking algorithm
|
4 |
+
//
|
5 |
+
// "hello world".score("axl") //=> 0.0
|
6 |
+
// "hello world".score("ow") //=> 0.6
|
7 |
+
// "hello world".score("hello world") //=> 1.0
|
8 |
+
//
|
9 |
+
// Tested in Firefox 2 and Safari 3
|
10 |
+
//
|
11 |
+
// The Quicksilver code is available here
|
12 |
+
// http://code.google.com/p/blacktree-alchemy/
|
13 |
+
// http://blacktree-alchemy.googlecode.com/svn/trunk/Crucible/Code/NSString+BLTRRanking.m
|
14 |
+
//
|
15 |
+
// The MIT License
|
16 |
+
//
|
17 |
+
// Copyright (c) 2008 Lachie Cox
|
18 |
+
//
|
19 |
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
20 |
+
// of this software and associated documentation files (the "Software"), to deal
|
21 |
+
// in the Software without restriction, including without limitation the rights
|
22 |
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
23 |
+
// copies of the Software, and to permit persons to whom the Software is
|
24 |
+
// furnished to do so, subject to the following conditions:
|
25 |
+
//
|
26 |
+
// The above copyright notice and this permission notice shall be included in
|
27 |
+
// all copies or substantial portions of the Software.
|
28 |
+
//
|
29 |
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
30 |
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
31 |
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
32 |
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
33 |
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
34 |
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
35 |
+
// THE SOFTWARE.
|
36 |
+
|
37 |
+
|
38 |
+
String.prototype.score = function(abbreviation,offset) {
|
39 |
+
offset = offset || 0 // TODO: I think this is unused... remove
|
40 |
+
|
41 |
+
if(abbreviation.length == 0) return 0.9
|
42 |
+
if(abbreviation.length > this.length) return 0.0
|
43 |
+
|
44 |
+
for (var i = abbreviation.length; i > 0; i--) {
|
45 |
+
var sub_abbreviation = abbreviation.substring(0,i)
|
46 |
+
var index = this.indexOf(sub_abbreviation)
|
47 |
+
|
48 |
+
|
49 |
+
if(index < 0) continue;
|
50 |
+
if(index + abbreviation.length > this.length + offset) continue;
|
51 |
+
|
52 |
+
var next_string = this.substring(index+sub_abbreviation.length)
|
53 |
+
var next_abbreviation = null
|
54 |
+
|
55 |
+
if(i >= abbreviation.length)
|
56 |
+
next_abbreviation = ''
|
57 |
+
else
|
58 |
+
next_abbreviation = abbreviation.substring(i)
|
59 |
+
|
60 |
+
var remaining_score = next_string.score(next_abbreviation,offset+index)
|
61 |
+
|
62 |
+
if (remaining_score > 0) {
|
63 |
+
var score = this.length-next_string.length;
|
64 |
+
|
65 |
+
if(index != 0) {
|
66 |
+
var j = 0;
|
67 |
+
|
68 |
+
var c = this.charCodeAt(index-1)
|
69 |
+
if(c==32 || c == 9) {
|
70 |
+
for(var j=(index-2); j >= 0; j--) {
|
71 |
+
c = this.charCodeAt(j)
|
72 |
+
score -= ((c == 32 || c == 9) ? 1 : 0.15)
|
73 |
+
}
|
74 |
+
|
75 |
+
// XXX maybe not port this heuristic
|
76 |
+
//
|
77 |
+
// } else if ([[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[self characterAtIndex:matchedRange.location]]) {
|
78 |
+
// for (j = matchedRange.location-1; j >= (int) searchRange.location; j--) {
|
79 |
+
// if ([[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[self characterAtIndex:j]])
|
80 |
+
// score--;
|
81 |
+
// else
|
82 |
+
// score -= 0.15;
|
83 |
+
// }
|
84 |
+
} else {
|
85 |
+
score -= index
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
score += remaining_score * next_string.length
|
90 |
+
score /= this.length;
|
91 |
+
return score
|
92 |
+
}
|
93 |
+
}
|
94 |
+
return 0.0
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
// Original code from: http://ejohn.org/blog/jquery-livesearch/
|
99 |
+
// w/ slight modifications to allow full jquery expressions in the list
|
100 |
+
|
101 |
+
// USAGE:
|
102 |
+
|
103 |
+
// Add in the plugin with the following files:
|
104 |
+
|
105 |
+
// <script type="text/javascript" src="jquery.liveupdate/quicksilver.js"></script>
|
106 |
+
// <script type="text/javascript" src="jquery.liveupdate/jquery.liveupdate.js"></script>
|
107 |
+
|
108 |
+
// $('#your-input').liveUpdate('#list-id')
|
109 |
+
// If you have html or anchors in your list, remember it only strips out the innerHTML of each jquery elem
|
110 |
+
// $('#your-input').liveUpdate('ul#list-id a')
|
111 |
+
// You don't have to restrict this to just lists, you can also filter table rows and such
|
112 |
+
// $('#your-input').liveUpdate('#tbl tr td')
|
113 |
+
|
114 |
+
jQuery.fn.liveUpdate = function(list){
|
115 |
+
list = jQuery(list);
|
116 |
+
if ( list.length ) {
|
117 |
+
cache = list.map(function(){
|
118 |
+
return this.innerHTML.toLowerCase();
|
119 |
+
});
|
120 |
+
|
121 |
+
this
|
122 |
+
.keyup(filter).keyup();;
|
123 |
+
}
|
124 |
+
|
125 |
+
return this;
|
126 |
+
|
127 |
+
function filter(){
|
128 |
+
var term = jQuery.trim( jQuery(this).val().toLowerCase() ), scores = [];
|
129 |
+
|
130 |
+
if ( !term ) {
|
131 |
+
list.parents('tr').show();
|
132 |
+
} else {
|
133 |
+
list.parents('tr').hide();
|
134 |
+
|
135 |
+
|
136 |
+
cache.each(function(i){
|
137 |
+
var score = this.score(term);
|
138 |
+
if (score > 0) { scores.push([score, i]); }
|
139 |
+
});
|
140 |
+
|
141 |
+
jQuery.each(scores.sort(function(a, b){return b[0] - a[0];}), function(){
|
142 |
+
jQuery(list[ this[1] ]).parent().show();
|
143 |
+
});
|
144 |
+
}
|
145 |
+
}
|
146 |
+
};
|
147 |
+
|
148 |
+
|
149 |
+
|
150 |
+
|
151 |
function attachments_update() {
|
152 |
jQuery('div#attachments_file_list').html(attachments_media);
|
153 |
}
|
media.php
CHANGED
@@ -25,11 +25,8 @@
|
|
25 |
|
26 |
<div id="attachments-file-list">
|
27 |
|
28 |
-
<p><?php _e("Available attachments are listed from your <strong>Media Library</strong>. If you need to upload a new attachment, please close this dialog and use the available <strong>Add to Media Library</strong> button.", "attachments"); ?> <?php _e("Select/deselect an attachment by clicking its thumbnail. When you're done managing your attachments, click <strong>
|
29 |
|
30 |
-
<p class="attachments-actions"><a href="#" class="attachments-apply button button-highlighted"><?php _e("Apply", "attachments"); ?></a></p>
|
31 |
-
|
32 |
-
|
33 |
<?php
|
34 |
|
35 |
$attachments_attachment_types = array(
|
@@ -60,25 +57,25 @@
|
|
60 |
|
61 |
<ul class="subsubsub">
|
62 |
<?php $attachments_total_types = count( $attachments_attachment_types ); ?>
|
63 |
-
<?php for($attachments_index=0; $attachments_index < $attachments_total_types; $attachments_index++) : ?>
|
64 |
<li>
|
65 |
-
<a href="#attachments-<?php echo $attachments_attachment_types[$attachments_index]['mime']; ?>">
|
66 |
<?php echo $attachments_attachment_types[$attachments_index]['name']; ?>
|
67 |
</a>
|
68 |
</li>
|
69 |
-
<?php if( $attachments_index < $attachments_total_types - 1 ) : ?> |<?php endif ?>
|
70 |
<?php endfor ?>
|
71 |
-
|
72 |
</ul>
|
73 |
|
74 |
-
<
|
|
|
|
|
75 |
|
76 |
<div id="attachments-file-details">
|
77 |
|
78 |
<?php foreach ( $attachments_attachment_types as $attachments_attachment_type ) : ?>
|
79 |
<div class="attachments attachments-file-section attachments-<?php echo $attachments_attachment_type['mime']; ?>" id="attachments-<?php echo $attachments_attachment_type['mime']; ?>">
|
80 |
|
81 |
-
<h2><?php echo __($attachments_attachment_type['name'], "attachments"); ?></h2>
|
82 |
|
83 |
<table class="widefat fixed" cellpadding="0">
|
84 |
<thead>
|
@@ -111,8 +108,8 @@
|
|
111 |
</span>
|
112 |
</a>
|
113 |
</td>
|
114 |
-
<td class="media column-media">
|
115 |
-
|
116 |
</td>
|
117 |
</tr>
|
118 |
<?php endif; endforeach; ?>
|
@@ -129,11 +126,19 @@
|
|
129 |
</div>
|
130 |
<!-- /attachments-tabs -->
|
131 |
|
132 |
-
<p class="attachments-actions"><a href="#" class="attachments-apply button button-highlighted"><?php _e("Apply", "attachments"); ?></a></p>
|
133 |
-
|
134 |
</div>
|
135 |
<!-- /attachments-file-list -->
|
136 |
|
137 |
<script type="text/javascript" charset="utf-8">
|
138 |
-
jQuery('#attachments-tabs').tabs(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
</script>
|
25 |
|
26 |
<div id="attachments-file-list">
|
27 |
|
28 |
+
<p id="attachments-instructions"><?php _e("Available attachments are listed from your <strong>Media Library</strong>. If you need to upload a new attachment, please close this dialog and use the available <strong>Add to Media Library</strong> button.", "attachments"); ?> <?php _e("Select/deselect an attachment by clicking its thumbnail. When you're done managing your attachments, click <strong>Attach</strong>.", "attachments")?></p>
|
29 |
|
|
|
|
|
|
|
30 |
<?php
|
31 |
|
32 |
$attachments_attachment_types = array(
|
57 |
|
58 |
<ul class="subsubsub">
|
59 |
<?php $attachments_total_types = count( $attachments_attachment_types ); ?>
|
60 |
+
<?php for( $attachments_index=0; $attachments_index < $attachments_total_types; $attachments_index++ ) : ?>
|
61 |
<li>
|
62 |
+
<a<?php if( $attachments_index == 0 ) : ?> class="current" <?php endif ?> href="#attachments-<?php echo $attachments_attachment_types[$attachments_index]['mime']; ?>">
|
63 |
<?php echo $attachments_attachment_types[$attachments_index]['name']; ?>
|
64 |
</a>
|
65 |
</li>
|
|
|
66 |
<?php endfor ?>
|
|
|
67 |
</ul>
|
68 |
|
69 |
+
<p class="attachments-actions"><a href="#" class="attachments-apply button button-highlighted"><?php _e("Attach", "attachments"); ?></a></p>
|
70 |
+
|
71 |
+
<p class="clear" id="attachments-live-filter"><input type="text" value="" /></p>
|
72 |
|
73 |
<div id="attachments-file-details">
|
74 |
|
75 |
<?php foreach ( $attachments_attachment_types as $attachments_attachment_type ) : ?>
|
76 |
<div class="attachments attachments-file-section attachments-<?php echo $attachments_attachment_type['mime']; ?>" id="attachments-<?php echo $attachments_attachment_type['mime']; ?>">
|
77 |
|
78 |
+
<!-- <h2><?php echo __($attachments_attachment_type['name'], "attachments"); ?></h2> -->
|
79 |
|
80 |
<table class="widefat fixed" cellpadding="0">
|
81 |
<thead>
|
108 |
</span>
|
109 |
</a>
|
110 |
</td>
|
111 |
+
<td class="media column-media attachment-title">
|
112 |
+
<?php echo $post->post_name; ?>
|
113 |
</td>
|
114 |
</tr>
|
115 |
<?php endif; endforeach; ?>
|
126 |
</div>
|
127 |
<!-- /attachments-tabs -->
|
128 |
|
|
|
|
|
129 |
</div>
|
130 |
<!-- /attachments-file-list -->
|
131 |
|
132 |
<script type="text/javascript" charset="utf-8">
|
133 |
+
jQuery('#attachments-tabs').tabs({
|
134 |
+
selected: 0,
|
135 |
+
select: function(event, ui){
|
136 |
+
jQuery('#attachments-tabs .current').removeClass('current');
|
137 |
+
jQuery('#attachments-tabs li:eq(' + ui.index + ') a').addClass('current');
|
138 |
+
}
|
139 |
+
});
|
140 |
+
</script>
|
141 |
+
|
142 |
+
<script type="text/javascript" charset="utf-8">
|
143 |
+
jQuery('#attachments-live-filter input').liveUpdate('.attachments table tbody tr td.attachment-title')
|
144 |
</script>
|
readme.txt
CHANGED
@@ -4,13 +4,13 @@ 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: 2.8
|
6 |
Tested up to: 3.0.1
|
7 |
-
Stable tag: 1.1
|
8 |
|
9 |
-
Attachments allows you to append any number of items from your WordPress Media Library to Posts and
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
Attachments allows you to append any number of items from your WordPress Media Library to Posts and
|
14 |
|
15 |
There is a **screencast available** on the [plugin home page](http://mondaybynoon.com/wordpress-attachments/)
|
16 |
|
@@ -41,6 +41,10 @@ Attachments uses WordPress' built in Media library for uploads and storage.
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
|
|
44 |
= 1.1 =
|
45 |
* Fixed a bug where Attachments meta box would display on Custom Post Types even when set not to
|
46 |
* Fixed a bug where special characters were lost on save
|
4 |
Tags: post, page, posts, pages, images, PDF, doc, Word, image, jpg, jpeg, picture, pictures, photos, attachment
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.0.1
|
7 |
+
Stable tag: 1.1.1
|
8 |
|
9 |
+
Attachments allows you to append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
+
Attachments allows you to 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.
|
14 |
|
15 |
There is a **screencast available** on the [plugin home page](http://mondaybynoon.com/wordpress-attachments/)
|
16 |
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 1.1.1 =
|
45 |
+
* Fixed a bug with storing foreign characters
|
46 |
+
* Added live search to Browse Existing Dialog
|
47 |
+
|
48 |
= 1.1 =
|
49 |
* Fixed a bug where Attachments meta box would display on Custom Post Types even when set not to
|
50 |
* Fixed a bug where special characters were lost on save
|