Version Description
- Completely revamped the upload/browse experience. Attachments now uses WordPress default modal dialogs.
Download this release
Release Info
Developer | jchristopher |
Plugin | Attachments |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.1.1 to 1.5
- attachments.options.php +12 -12
- attachments.php +84 -21
- css/attachments.css +15 -1
- js/attachments.js +133 -214
- media.php +0 -144
- readme.txt +4 -1
attachments.options.php
CHANGED
@@ -28,20 +28,20 @@
|
|
28 |
</div>
|
29 |
|
30 |
<?php endforeach ?>
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
<?php endif ?>
|
33 |
-
|
34 |
<?php endif ?>
|
35 |
|
36 |
-
<h3><?php _e("Privacy Settings", "attachments"); ?></h3>
|
37 |
-
<div class="attachments_checkbox">
|
38 |
-
<input type="checkbox" name="attachments_limit_to_user" id="attachments_limit_to_user" value="true"<?php if (get_option('attachments_limit_to_user')=='true') : ?> checked="checked"<?php endif ?> />
|
39 |
-
<label for="attachments_limit_to_user"><?php _e("Users can only see their own attachments", "attachments");?></label>
|
40 |
-
</div>
|
41 |
-
<input type="hidden" name="action" value="update" />
|
42 |
-
<input type="hidden" name="page_options" value="attachments_limit_to_user,<?php if( !empty( $post_types ) ) : foreach( $post_types as $post_type ) : ?>attachments_cpt_<?php echo $post_type->name; ?>,<?php endforeach; endif; ?>" />
|
43 |
-
<p class="submit">
|
44 |
-
<input type="submit" class="button-primary" value="<?php _e("Save", "attachments");?>" />
|
45 |
-
</p>
|
46 |
</form>
|
47 |
</div>
|
28 |
</div>
|
29 |
|
30 |
<?php endforeach ?>
|
31 |
+
|
32 |
+
<input type="hidden" name="action" value="update" />
|
33 |
+
<input type="hidden" name="page_options" value="attachments_limit_to_user,<?php if( !empty( $post_types ) ) : foreach( $post_types as $post_type ) : ?>attachments_cpt_<?php echo $post_type->name; ?>,<?php endforeach; endif; ?>" />
|
34 |
+
<p class="submit">
|
35 |
+
<input type="submit" class="button-primary" value="<?php _e("Save", "attachments");?>" />
|
36 |
+
</p>
|
37 |
+
|
38 |
+
<?php else: ?>
|
39 |
+
|
40 |
+
<?php _e("<p>Attachments can be integrated with your Custom Post Types. Unfortunately, there are none to work with at this time.</p>"); ?>
|
41 |
+
|
42 |
<?php endif ?>
|
43 |
+
|
44 |
<?php endif ?>
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
</form>
|
47 |
</div>
|
attachments.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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.
|
7 |
Author: Jonathan Christopher
|
8 |
Author URI: http://mondaybynoon.com/
|
9 |
*/
|
@@ -37,11 +37,14 @@ global $wpdb;
|
|
37 |
// =========
|
38 |
// = HOOKS =
|
39 |
// =========
|
40 |
-
|
41 |
-
|
42 |
-
add_action('
|
43 |
-
add_action('
|
44 |
-
add_action('
|
|
|
|
|
|
|
45 |
|
46 |
|
47 |
|
@@ -118,15 +121,15 @@ function attachments_add()
|
|
118 |
|
119 |
<div id="attachments-inner">
|
120 |
|
|
|
|
|
|
|
|
|
|
|
121 |
<ul id="attachments-actions">
|
122 |
-
<li
|
123 |
-
<a href="<?php echo
|
124 |
-
|
125 |
-
</a>
|
126 |
-
</li>
|
127 |
-
<li id="attachments-add-new">
|
128 |
-
<a href="media-upload.php?type=image&TB_iframe=true&width=640&height=600" class="button thickbox">
|
129 |
-
<?php _e("Add to Media Library", "attachments")?>
|
130 |
</a>
|
131 |
</li>
|
132 |
</ul>
|
@@ -230,9 +233,27 @@ function attachments_meta_box()
|
|
230 |
*/
|
231 |
function attachments_init_js()
|
232 |
{
|
|
|
|
|
233 |
echo '<script type="text/javascript" charset="utf-8">';
|
234 |
echo ' var attachments_base = "' . WP_PLUGIN_URL . '/attachments"; ';
|
235 |
echo ' var attachments_media = ""; ';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
echo '</script>';
|
237 |
}
|
238 |
|
@@ -386,6 +407,42 @@ function attachments_get_attachments( $post_id=null )
|
|
386 |
}
|
387 |
|
388 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
|
390 |
/**
|
391 |
* This is the main initialization function, it will invoke the necessary meta_box
|
@@ -396,12 +453,18 @@ function attachments_get_attachments( $post_id=null )
|
|
396 |
|
397 |
function attachments_init()
|
398 |
{
|
399 |
-
|
400 |
-
|
401 |
-
wp_enqueue_script('
|
402 |
-
wp_enqueue_style('thickbox');
|
403 |
-
|
404 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
|
406 |
if( function_exists( 'load_plugin_textdomain' ) )
|
407 |
{
|
@@ -414,6 +477,6 @@ function attachments_init()
|
|
414 |
load_plugin_textdomain( 'attachments', false, dirname( plugin_basename( __FILE__ ) ) );
|
415 |
}
|
416 |
}
|
417 |
-
|
418 |
attachments_meta_box();
|
419 |
}
|
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.5
|
7 |
Author: Jonathan Christopher
|
8 |
Author URI: http://mondaybynoon.com/
|
9 |
*/
|
37 |
// =========
|
38 |
// = HOOKS =
|
39 |
// =========
|
40 |
+
if( WP_ADMIN )
|
41 |
+
{
|
42 |
+
add_action( 'admin_menu', 'attachments_init' );
|
43 |
+
add_action( 'admin_head', 'attachments_init_js' );
|
44 |
+
add_action( 'save_post', 'attachments_save' );
|
45 |
+
add_action( 'admin_menu', 'attachments_menu' );
|
46 |
+
add_action( 'admin_init', 'fix_async_upload_image' );
|
47 |
+
}
|
48 |
|
49 |
|
50 |
|
121 |
|
122 |
<div id="attachments-inner">
|
123 |
|
124 |
+
<?php
|
125 |
+
$media_upload_iframe_src = "media-upload.php?type=image&TB_iframe=1";
|
126 |
+
$image_upload_iframe_src = apply_filters( 'image_upload_iframe_src', "$media_upload_iframe_src" );
|
127 |
+
?>
|
128 |
+
|
129 |
<ul id="attachments-actions">
|
130 |
+
<li>
|
131 |
+
<a id="attachments-thickbox" href="<?php echo $image_upload_iframe_src; ?>&attachments_thickbox=1" title="Attachments" class="button button-highlighted">
|
132 |
+
Attach
|
|
|
|
|
|
|
|
|
|
|
133 |
</a>
|
134 |
</li>
|
135 |
</ul>
|
233 |
*/
|
234 |
function attachments_init_js()
|
235 |
{
|
236 |
+
global $pagenow;
|
237 |
+
|
238 |
echo '<script type="text/javascript" charset="utf-8">';
|
239 |
echo ' var attachments_base = "' . WP_PLUGIN_URL . '/attachments"; ';
|
240 |
echo ' var attachments_media = ""; ';
|
241 |
+
if ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow )
|
242 |
+
{
|
243 |
+
echo ' var attachments_upload = true; ';
|
244 |
+
}
|
245 |
+
else
|
246 |
+
{
|
247 |
+
echo ' var attachments_upload = false; ';
|
248 |
+
}
|
249 |
+
if( ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) && is_attachments_context() )
|
250 |
+
{
|
251 |
+
echo ' var attachments_is_attachments_context = true; ';
|
252 |
+
}
|
253 |
+
else
|
254 |
+
{
|
255 |
+
echo ' var attachments_is_attachments_context = false; ';
|
256 |
+
}
|
257 |
echo '</script>';
|
258 |
}
|
259 |
|
407 |
}
|
408 |
|
409 |
|
410 |
+
if( !function_exists( 'fix_async_upload_image' ) )
|
411 |
+
{
|
412 |
+
function fix_async_upload_image() {
|
413 |
+
if( isset( $_REQUEST['attachment_id'] ) )
|
414 |
+
{
|
415 |
+
$GLOBALS['post'] = get_post( $_REQUEST['attachment_id'] );
|
416 |
+
}
|
417 |
+
}
|
418 |
+
}
|
419 |
+
|
420 |
+
function is_attachments_context()
|
421 |
+
{
|
422 |
+
global $pagenow;
|
423 |
+
|
424 |
+
// if post_id is set, it's the editor upload...
|
425 |
+
if ( ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) && !isset( $_REQUEST['post_id'] ) )
|
426 |
+
{
|
427 |
+
return true;
|
428 |
+
}
|
429 |
+
return false;
|
430 |
+
}
|
431 |
+
|
432 |
+
function hijack_thickbox_text($translated_text, $source_text, $domain)
|
433 |
+
{
|
434 |
+
if ( is_attachments_context() )
|
435 |
+
{
|
436 |
+
if ('Insert into Post' == $source_text) {
|
437 |
+
return __('Attach', 'attachments' );
|
438 |
+
}
|
439 |
+
}
|
440 |
+
return $translated_text;
|
441 |
+
}
|
442 |
+
|
443 |
+
|
444 |
+
|
445 |
+
|
446 |
|
447 |
/**
|
448 |
* This is the main initialization function, it will invoke the necessary meta_box
|
453 |
|
454 |
function attachments_init()
|
455 |
{
|
456 |
+
global $pagenow;
|
457 |
+
|
458 |
+
wp_enqueue_script( 'jquery-ui-core' );
|
459 |
+
wp_enqueue_style( 'thickbox' );
|
460 |
+
|
461 |
+
if ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow )
|
462 |
+
{
|
463 |
+
add_filter( 'gettext', 'hijack_thickbox_text', 1, 3 );
|
464 |
+
}
|
465 |
+
|
466 |
+
wp_enqueue_style( 'attachments', WP_PLUGIN_URL . '/attachments/css/attachments.css' );
|
467 |
+
wp_enqueue_script( 'attachments', WP_PLUGIN_URL . '/attachments/js/attachments.js', array( 'thickbox' ), false, false );
|
468 |
|
469 |
if( function_exists( 'load_plugin_textdomain' ) )
|
470 |
{
|
477 |
load_plugin_textdomain( 'attachments', false, dirname( plugin_basename( __FILE__ ) ) );
|
478 |
}
|
479 |
}
|
480 |
+
|
481 |
attachments_meta_box();
|
482 |
}
|
css/attachments.css
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
/* ============ */
|
2 |
/* = META BOX = */
|
3 |
/* ============ */
|
|
|
4 |
#attachments-inner { padding-top:3px; }
|
5 |
ul#attachments-actions { overflow:hidden; zoom:1; padding-top:4px; }
|
6 |
ul#attachments-actions li { width:50%; float:left; }
|
@@ -35,6 +36,7 @@ p.attachments-actions { float:right; margin:6px 0 0 !important; }
|
|
35 |
#attachments-list ul { padding:10px 0; }
|
36 |
#attachments-list li.attachments-file { overflow:hidden; zoom:1; background:#fff; }
|
37 |
.attachments-data { display:none; }
|
|
|
38 |
#poststuff li.attachments-file h2 { margin:0; overflow:hidden; zoom:1; }
|
39 |
#poststuff li.attachments-file h2 a { text-decoration:none; color:inherit; }
|
40 |
#poststuff li.attachments-file h2 span { display:block; float:left; }
|
@@ -64,4 +66,16 @@ p.attachments-actions { float:right; margin:6px 0 0 !important; }
|
|
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; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/* ============ */
|
2 |
/* = META BOX = */
|
3 |
/* ============ */
|
4 |
+
|
5 |
#attachments-inner { padding-top:3px; }
|
6 |
ul#attachments-actions { overflow:hidden; zoom:1; padding-top:4px; }
|
7 |
ul#attachments-actions li { width:50%; float:left; }
|
36 |
#attachments-list ul { padding:10px 0; }
|
37 |
#attachments-list li.attachments-file { overflow:hidden; zoom:1; background:#fff; }
|
38 |
.attachments-data { display:none; }
|
39 |
+
#poststuff li.attachments-file { height:115px; }
|
40 |
#poststuff li.attachments-file h2 { margin:0; overflow:hidden; zoom:1; }
|
41 |
#poststuff li.attachments-file h2 a { text-decoration:none; color:inherit; }
|
42 |
#poststuff li.attachments-file h2 span { display:block; float:left; }
|
66 |
#attachments-tabs .subsubsub a { color:#21759b !important; }
|
67 |
#attachments-tabs-wrapper { border-bottom:1px solid #dfdfdf; position:relative; }
|
68 |
#attachments-tabs #sidemenu { overflow:hidden; zoom:1; background:#f9f9f9; float:none !important; margin:0; }
|
69 |
+
#attachments-live-filter { display:block; width:140px; float:left; margin:0 0 10px; }
|
70 |
+
|
71 |
+
|
72 |
+
/* Hide WP UI elements only for Attachments */
|
73 |
+
body#media-upload.attachments-media-upload #tab-type_url,
|
74 |
+
body#media-upload.attachments-media-upload p.ml-submit,
|
75 |
+
body#media-upload.attachments-media-upload p.savebutton.ml-submit,
|
76 |
+
body#media-upload.attachments-media-upload div.media-item tr.url,
|
77 |
+
body#media-upload.attachments-media-upload div.media-item tr.align,
|
78 |
+
body#media-upload.attachments-media-upload div.media-item tr.image-size,
|
79 |
+
body#media-upload.attachments-media-upload div.media-item tr.image_alt,
|
80 |
+
body#media-upload.attachments-media-upload div.media-item tr.post_content,
|
81 |
+
body#media-upload.attachments-media-upload div.media-item a.del-link { display:none !important; }
|
js/attachments.js
CHANGED
@@ -1,187 +1,151 @@
|
|
1 |
-
|
2 |
-
//
|
3 |
-
//
|
4 |
-
//
|
5 |
-
//
|
6 |
-
//
|
7 |
-
//
|
8 |
-
//
|
9 |
-
//
|
10 |
-
//
|
11 |
-
//
|
12 |
-
// http://
|
13 |
-
// http://
|
14 |
-
//
|
15 |
-
//
|
16 |
-
//
|
17 |
-
//
|
18 |
-
//
|
19 |
-
//
|
20 |
-
//
|
21 |
-
//
|
22 |
-
//
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
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 |
-
}
|
154 |
|
155 |
-
function init_attachments_sortable() {
|
156 |
-
jQuery('div#attachments-list ul').sortable({
|
157 |
-
containment: 'parent',
|
158 |
-
stop: function(e, ui) {
|
159 |
-
jQuery('#attachments-list ul li').each(function(i, id) {
|
160 |
-
jQuery(this).find('input.attachment_order').val(i+1);
|
161 |
-
});
|
162 |
-
}
|
163 |
-
});
|
164 |
-
}
|
165 |
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
}
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
173 |
{
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
182 |
});
|
183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
|
|
|
|
|
|
|
|
|
|
185 |
// Hook our delete links
|
186 |
jQuery('span.attachment-delete a').live('click', function() {
|
187 |
attachment_parent = jQuery(this).parent().parent().parent();
|
@@ -199,52 +163,7 @@ jQuery(document).ready(function() {
|
|
199 |
return false;
|
200 |
});
|
201 |
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
attachment_index = jQuery('li.attachments-file').length;
|
206 |
-
new_attachments = '';
|
207 |
-
jQuery('a.attachments-selected').each(function() {
|
208 |
-
|
209 |
-
attachment_name = jQuery(this).find('span.attachment-file-name').text();
|
210 |
-
attachment_id = jQuery(this).find('span.attachment-file-id').text();
|
211 |
-
attachment_thumbnail = jQuery(this).find('span.attachments-thumbnail').html();
|
212 |
-
|
213 |
-
attachment_index++;
|
214 |
-
new_attachments += '<li class="attachments-file">';
|
215 |
-
new_attachments += '<h2><a href="#" class="attachment-handle"><span class="attachment-handle-icon"><img src="' + attachments_base + '/images/handle.gif" alt="Drag" /></span></a><span class="attachment-name">' + attachment_name + '</span><span class="attachment-delete"><a href="#">Delete</a></span></h2>';
|
216 |
-
new_attachments += '<div class="attachments-fields">';
|
217 |
-
new_attachments += '<div class="textfield" id="field_attachment_title_' + attachment_index + '"><label for="attachment_title_' + attachment_index + '">Title</label><input type="text" id="attachment_title_' + attachment_index + '" name="attachment_title_' + attachment_index + '" value="" size="20" /></div>';
|
218 |
-
new_attachments += '<div class="textfield" id="field_attachment_caption_' + attachment_index + '"><label for="attachment_caption_' + attachment_index + '">Caption</label><input type="text" id="attachment_caption_' + attachment_index + '" name="attachment_caption_' + attachment_index + '" value="" size="20" /></div>';
|
219 |
-
new_attachments += '</div>';
|
220 |
-
new_attachments += '<div class="attachments-data">';
|
221 |
-
new_attachments += '<input type="hidden" name="attachment_id_' + attachment_index + '" id="attachment_id_' + attachment_index + '" value="' + attachment_id + '" />';
|
222 |
-
new_attachments += '<input type="hidden" class="attachment_order" name="attachment_order_' + attachment_index + '" id="attachment_order_' + attachment_index + '" value="' + attachment_index + '" />';
|
223 |
-
new_attachments += '</div>';
|
224 |
-
new_attachments += '<div class="attachment-thumbnail"><span class="attachments-thumbnail">';
|
225 |
-
new_attachments += attachment_thumbnail;
|
226 |
-
new_attachments += '</span></div>';
|
227 |
-
new_attachments += '</li>';
|
228 |
-
});
|
229 |
-
jQuery('div#attachments-list ul').append(new_attachments);
|
230 |
-
tb_remove();
|
231 |
-
attachments_update();
|
232 |
-
|
233 |
-
if(jQuery('#attachments-list li').length > 0) {
|
234 |
-
|
235 |
-
// We've got some attachments
|
236 |
-
jQuery('#attachments-list').show();
|
237 |
-
|
238 |
-
// Cleanup
|
239 |
-
jQuery('div#attachments-list ul').sortable('destroy');
|
240 |
-
|
241 |
-
// Init sortable
|
242 |
-
init_attachments_sortable();
|
243 |
-
|
244 |
-
}
|
245 |
-
|
246 |
-
return false;
|
247 |
-
|
248 |
-
});
|
249 |
-
|
250 |
});
|
1 |
+
function str_replace (search, replace, subject, count) {
|
2 |
+
// http://kevin.vanzonneveld.net
|
3 |
+
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
4 |
+
// + improved by: Gabriel Paderni
|
5 |
+
// + improved by: Philip Peterson
|
6 |
+
// + improved by: Simon Willison (http://simonwillison.net)
|
7 |
+
// + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
|
8 |
+
// + bugfixed by: Anton Ongson
|
9 |
+
// + input by: Onno Marsman
|
10 |
+
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
11 |
+
// + tweaked by: Onno Marsman
|
12 |
+
// + input by: Brett Zamir (http://brett-zamir.me)
|
13 |
+
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
14 |
+
// + input by: Oleg Eremeev
|
15 |
+
// + improved by: Brett Zamir (http://brett-zamir.me)
|
16 |
+
// + bugfixed by: Oleg Eremeev
|
17 |
+
// % note 1: The count parameter must be passed as a string in order
|
18 |
+
// % note 1: to find a global variable in which the result will be given
|
19 |
+
// * example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
|
20 |
+
// * returns 1: 'Kevin.van.Zonneveld'
|
21 |
+
// * example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
|
22 |
+
// * returns 2: 'hemmo, mars'
|
23 |
+
|
24 |
+
var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
|
25 |
+
f = [].concat(search),
|
26 |
+
r = [].concat(replace),
|
27 |
+
s = subject,
|
28 |
+
ra = r instanceof Array, sa = s instanceof Array;
|
29 |
+
s = [].concat(s);
|
30 |
+
if (count) {
|
31 |
+
this.window[count] = 0;
|
32 |
+
}
|
33 |
+
|
34 |
+
for (i=0, sl=s.length; i < sl; i++) {
|
35 |
+
if (s[i] === '') {
|
36 |
+
continue;
|
37 |
+
}
|
38 |
+
for (j=0, fl=f.length; j < fl; j++) {
|
39 |
+
temp = s[i]+'';
|
40 |
+
repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
|
41 |
+
s[i] = (temp).split(f[j]).join(repl);
|
42 |
+
if (count && s[i] !== temp) {
|
43 |
+
this.window[count] += (temp.length-s[i].length)/f[j].length;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
+
return sa ? s : s[0];
|
|
|
47 |
}
|
48 |
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
|
52 |
+
function init_attachments_sortable() {
|
53 |
+
if(jQuery('div#attachments-list ul:data(sortable)').length==0&&jQuery('div#attachments-list ul li').length>0){
|
54 |
+
jQuery('div#attachments-list ul').sortable({
|
55 |
+
containment: 'parent',
|
56 |
+
stop: function(e, ui) {
|
57 |
+
jQuery('#attachments-list ul li').each(function(i, id) {
|
58 |
+
jQuery(this).find('input.attachment_order').val(i+1);
|
59 |
+
});
|
60 |
+
}
|
61 |
+
});
|
62 |
+
}
|
63 |
+
}
|
64 |
|
65 |
|
|
|
|
|
|
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
+
function attachments_handle_attach(title,caption,id,thumb){
|
69 |
+
|
70 |
+
attachment_index = jQuery('li.attachments-file', top.document).length;
|
71 |
+
new_attachments = '';
|
72 |
+
|
73 |
+
attachment_name = title;
|
74 |
+
attachment_caption = caption;
|
75 |
+
attachment_id = id;
|
76 |
+
attachment_thumb = thumb;
|
77 |
+
|
78 |
+
attachment_index++;
|
79 |
+
new_attachments += '<li class="attachments-file">';
|
80 |
+
new_attachments += '<h2><a href="#" class="attachment-handle"><span class="attachment-handle-icon"><img src="' + attachments_base + '/images/handle.gif" alt="Drag" /></span></a><span class="attachment-name">' + attachment_name + '</span><span class="attachment-delete"><a href="#">Delete</a></span></h2>';
|
81 |
+
new_attachments += '<div class="attachments-fields">';
|
82 |
+
new_attachments += '<div class="textfield" id="field_attachment_title_' + attachment_index + '"><label for="attachment_title_' + attachment_index + '">Title</label><input type="text" id="attachment_title_' + attachment_index + '" name="attachment_title_' + attachment_index + '" value="' + attachment_name + '" size="20" /></div>';
|
83 |
+
new_attachments += '<div class="textfield" id="field_attachment_caption_' + attachment_index + '"><label for="attachment_caption_' + attachment_index + '">Caption</label><input type="text" id="attachment_caption_' + attachment_index + '" name="attachment_caption_' + attachment_index + '" value="' + attachment_caption + '" size="20" /></div>';
|
84 |
+
new_attachments += '</div>';
|
85 |
+
new_attachments += '<div class="attachments-data">';
|
86 |
+
new_attachments += '<input type="hidden" name="attachment_id_' + attachment_index + '" id="attachment_id_' + attachment_index + '" value="' + attachment_id + '" />';
|
87 |
+
new_attachments += '<input type="hidden" class="attachment_order" name="attachment_order_' + attachment_index + '" id="attachment_order_' + attachment_index + '" value="' + attachment_index + '" />';
|
88 |
+
new_attachments += '</div>';
|
89 |
+
new_attachments += '<div class="attachment-thumbnail"><span class="attachments-thumbnail">';
|
90 |
+
|
91 |
|
92 |
+
new_attachments += '<img src="' + attachment_thumb + '" width="80" alt="Thumbnail" />';
|
93 |
+
new_attachments += '</span></div>';
|
94 |
+
new_attachments += '</li>';
|
95 |
+
|
96 |
+
jQuery('div#attachments-list ul', top.document).append(new_attachments);
|
97 |
+
|
98 |
+
if(jQuery('#attachments-list li', top.document).length > 0) {
|
99 |
+
|
100 |
+
// We've got some attachments
|
101 |
+
jQuery('#attachments-list', top.document).show();
|
102 |
+
|
103 |
}
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
jQuery(document).ready(function() {
|
108 |
+
|
109 |
+
if(attachments_is_attachments_context)
|
110 |
{
|
111 |
+
jQuery('body').addClass('attachments-media-upload');
|
112 |
+
|
113 |
+
// we need to hijack the Attach button
|
114 |
+
jQuery('td.savesend input').live('click',function(e){
|
115 |
+
e.preventDefault();
|
116 |
+
parent = jQuery(this).parent().parent().parent();
|
117 |
+
title = parent.find('tr.post_title td.field input').val();
|
118 |
+
caption = parent.find('tr.post_excerpt td.field input').val();
|
119 |
+
id = str_replace( 'imgedit-response-', '', parent.find('td.imgedit-response').attr('id') );
|
120 |
+
thumb = parent.parent().parent().find('img.pinkynail').attr('src');
|
121 |
+
attachments_handle_attach(title,caption,id,thumb);
|
122 |
+
jQuery(this).after('<span class="attachments-attached-note"> Attached</span>').parent().find('span.attachments-attached-note').delay(1000).fadeOut();
|
123 |
+
return false;
|
124 |
+
});
|
125 |
}
|
126 |
+
|
127 |
+
// we're going to handle the Thickbox
|
128 |
+
jQuery("body").click(function(event) {
|
129 |
+
if (jQuery(event.target).is('a#attachments-thickbox')) {
|
130 |
+
tb_show("Attach a file", event.target.href, false);
|
131 |
+
return false;
|
132 |
+
}
|
133 |
});
|
134 |
|
135 |
+
// Modify thickbox link to fit window. Adapted from wp-admin\js\media-upload.dev.js.
|
136 |
+
jQuery('a#attachments-thickbox').each( function() {
|
137 |
+
var href = jQuery(this).attr('href'), width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
|
138 |
+
if ( ! href ) return;
|
139 |
+
href = href.replace(/&width=[0-9]+/g, '');
|
140 |
+
href = href.replace(/&height=[0-9]+/g, '');
|
141 |
+
jQuery(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
|
142 |
+
});
|
143 |
|
144 |
+
// If there are no attachments, let's hide this thing...
|
145 |
+
if(jQuery('div#attachments-list li').length == 0) {
|
146 |
+
jQuery('#attachments-list').hide();
|
147 |
+
}
|
148 |
+
|
149 |
// Hook our delete links
|
150 |
jQuery('span.attachment-delete a').live('click', function() {
|
151 |
attachment_parent = jQuery(this).parent().parent().parent();
|
163 |
return false;
|
164 |
});
|
165 |
|
166 |
+
// we also need to get a bit hacky with sortable...
|
167 |
+
setInterval('init_attachments_sortable()',500);
|
168 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
});
|
media.php
DELETED
@@ -1,144 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
error_reporting(0);
|
4 |
-
require_once(dirname(__FILE__) . '/../../../wp-admin/admin.php');
|
5 |
-
require( dirname(__FILE__) . '/../../../wp-config.php' );
|
6 |
-
|
7 |
-
global $wpdb;
|
8 |
-
global $userdata;
|
9 |
-
|
10 |
-
// set the user info in case we need to limit to the current author
|
11 |
-
get_currentuserinfo();
|
12 |
-
|
13 |
-
if( get_option('attachments_limit_to_user') == 'true' )
|
14 |
-
{
|
15 |
-
$attachments_sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_author = " . $userdata->ID . " ORDER BY post_modified DESC";
|
16 |
-
}
|
17 |
-
else
|
18 |
-
{
|
19 |
-
$attachments_sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_modified DESC";
|
20 |
-
}
|
21 |
-
|
22 |
-
$attachment_files = $wpdb->get_results( $attachments_sql );
|
23 |
-
|
24 |
-
?>
|
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(
|
33 |
-
|
34 |
-
array(
|
35 |
-
'name' => 'Images',
|
36 |
-
'mime' => 'image',
|
37 |
-
),
|
38 |
-
array(
|
39 |
-
'name' => 'Videos',
|
40 |
-
'mime' => 'video'
|
41 |
-
),
|
42 |
-
array(
|
43 |
-
'name' => 'Documents',
|
44 |
-
'mime' => 'application'
|
45 |
-
),
|
46 |
-
array(
|
47 |
-
'name' => 'Audio',
|
48 |
-
'mime' => 'audio'
|
49 |
-
),
|
50 |
-
|
51 |
-
);
|
52 |
-
|
53 |
-
?>
|
54 |
-
|
55 |
-
|
56 |
-
<div id="attachments-tabs">
|
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>
|
82 |
-
<tr>
|
83 |
-
<th scope="col" id="icon" class="manage-column column-icon">Icon</th>
|
84 |
-
<th scope="col" id="media" class="manage-column column-media">File</th>
|
85 |
-
</tr>
|
86 |
-
</thead>
|
87 |
-
<tfoot>
|
88 |
-
<tr>
|
89 |
-
<th scope="col" id="icon" class="manage-column column-icon">Icon</th>
|
90 |
-
<th scope="col" id="media" class="manage-column column-media">File</th>
|
91 |
-
</tr>
|
92 |
-
</tfoot>
|
93 |
-
<tbody>
|
94 |
-
<?php foreach ($attachment_files as $post) : if ( strpos($post->post_mime_type, $attachments_attachment_type['mime']) !== false ) : ?>
|
95 |
-
<tr class="author-other status-inherit" valign="top">
|
96 |
-
<td class="column-icon media-icon">
|
97 |
-
<a href="#">
|
98 |
-
<span class="attachments-thumbnail">
|
99 |
-
<?php echo wp_get_attachment_image( $post->ID, array(80, 60), true ); ?>
|
100 |
-
</span>
|
101 |
-
<span class="attachments-data">
|
102 |
-
<span class="attachment-file-name">
|
103 |
-
<?php echo $post->post_name; ?>
|
104 |
-
</span>
|
105 |
-
<span class="attachment-file-id">
|
106 |
-
<?php echo $post->ID; ?>
|
107 |
-
</span>
|
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; ?>
|
116 |
-
</tbody>
|
117 |
-
</table>
|
118 |
-
|
119 |
-
</div>
|
120 |
-
<!-- /attachments-<?php echo $attachments_attachment_type['name']; ?> -->
|
121 |
-
<?php endforeach ?>
|
122 |
-
|
123 |
-
</div>
|
124 |
-
<!-- /attachments-file-details -->
|
125 |
-
|
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,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: 2.8
|
6 |
Tested up to: 3.0.1
|
7 |
-
Stable tag: 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 |
|
@@ -41,6 +41,9 @@ Attachments uses WordPress' built in Media library for uploads and storage.
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
44 |
= 1.1.1 =
|
45 |
* Fixed a bug with storing foreign characters
|
46 |
* Added live search to Browse Existing Dialog
|
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.5
|
8 |
|
9 |
Attachments allows you to append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types
|
10 |
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 1.5 =
|
45 |
+
* Completely revamped the upload/browse experience. Attachments now uses WordPress default modal dialogs.
|
46 |
+
|
47 |
= 1.1.1 =
|
48 |
* Fixed a bug with storing foreign characters
|
49 |
* Added live search to Browse Existing Dialog
|