|
1 <?php |
|
2 /** |
|
3 * WordPress Administration Media API. |
|
4 * |
|
5 * @package WordPress |
|
6 * @subpackage Administration |
|
7 */ |
|
8 |
|
9 /** |
|
10 * {@internal Missing Short Description}} |
|
11 * |
|
12 * @since unknown |
|
13 * |
|
14 * @return unknown |
|
15 */ |
|
16 function media_upload_tabs() { |
|
17 $_default_tabs = array( |
|
18 'type' => __('From Computer'), // handler action suffix => tab text |
|
19 'type_url' => __('From URL'), |
|
20 'gallery' => __('Gallery'), |
|
21 'library' => __('Media Library') |
|
22 ); |
|
23 |
|
24 return apply_filters('media_upload_tabs', $_default_tabs); |
|
25 } |
|
26 |
|
27 /** |
|
28 * {@internal Missing Short Description}} |
|
29 * |
|
30 * @since unknown |
|
31 * |
|
32 * @param unknown_type $tabs |
|
33 * @return unknown |
|
34 */ |
|
35 function update_gallery_tab($tabs) { |
|
36 global $wpdb; |
|
37 |
|
38 if ( !isset($_REQUEST['post_id']) ) { |
|
39 unset($tabs['gallery']); |
|
40 return $tabs; |
|
41 } |
|
42 |
|
43 if ( intval($_REQUEST['post_id']) ) |
|
44 $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id']))); |
|
45 |
|
46 if ( empty($attachments) ) { |
|
47 unset($tabs['gallery']); |
|
48 return $tabs; |
|
49 } |
|
50 |
|
51 $tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>$attachments</span>"); |
|
52 |
|
53 return $tabs; |
|
54 } |
|
55 add_filter('media_upload_tabs', 'update_gallery_tab'); |
|
56 |
|
57 /** |
|
58 * {@internal Missing Short Description}} |
|
59 * |
|
60 * @since unknown |
|
61 */ |
|
62 function the_media_upload_tabs() { |
|
63 global $redir_tab; |
|
64 $tabs = media_upload_tabs(); |
|
65 |
|
66 if ( !empty($tabs) ) { |
|
67 echo "<ul id='sidemenu'>\n"; |
|
68 if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) ) |
|
69 $current = $redir_tab; |
|
70 elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) |
|
71 $current = $_GET['tab']; |
|
72 else |
|
73 $current = apply_filters('media_upload_default_tab', 'type'); |
|
74 |
|
75 foreach ( $tabs as $callback => $text ) { |
|
76 $class = ''; |
|
77 if ( $current == $callback ) |
|
78 $class = " class='current'"; |
|
79 $href = add_query_arg(array('tab'=>$callback, 's'=>false, 'paged'=>false, 'post_mime_type'=>false, 'm'=>false)); |
|
80 $link = "<a href='" . esc_url($href) . "'$class>$text</a>"; |
|
81 echo "\t<li id='" . esc_attr("tab-$callback") . "'>$link</li>\n"; |
|
82 } |
|
83 echo "</ul>\n"; |
|
84 } |
|
85 } |
|
86 |
|
87 /** |
|
88 * {@internal Missing Short Description}} |
|
89 * |
|
90 * @since unknown |
|
91 * |
|
92 * @param unknown_type $id |
|
93 * @param unknown_type $alt |
|
94 * @param unknown_type $title |
|
95 * @param unknown_type $align |
|
96 * @param unknown_type $url |
|
97 * @param unknown_type $rel |
|
98 * @param unknown_type $size |
|
99 * @return unknown |
|
100 */ |
|
101 function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') { |
|
102 |
|
103 $htmlalt = ( empty($alt) ) ? $title : $alt; |
|
104 |
|
105 $html = get_image_tag($id, $htmlalt, $title, $align, $size); |
|
106 |
|
107 $rel = $rel ? ' rel="attachment wp-att-' . esc_attr($id).'"' : ''; |
|
108 |
|
109 if ( $url ) |
|
110 $html = '<a href="' . esc_url($url) . "\"$rel>$html</a>"; |
|
111 |
|
112 $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size ); |
|
113 |
|
114 return $html; |
|
115 } |
|
116 |
|
117 /** |
|
118 * {@internal Missing Short Description}} |
|
119 * |
|
120 * @since unknown |
|
121 * |
|
122 * @param unknown_type $html |
|
123 * @param unknown_type $id |
|
124 * @param unknown_type $alt |
|
125 * @param unknown_type $title |
|
126 * @param unknown_type $align |
|
127 * @param unknown_type $url |
|
128 * @param unknown_type $size |
|
129 * @return unknown |
|
130 */ |
|
131 function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) { |
|
132 |
|
133 if ( empty($alt) || apply_filters( 'disable_captions', '' ) ) |
|
134 return $html; |
|
135 |
|
136 $id = ( 0 < (int) $id ) ? 'attachment_' . $id : ''; |
|
137 |
|
138 preg_match( '/width="([0-9]+)/', $html, $matches ); |
|
139 if ( ! isset($matches[1]) ) |
|
140 return $html; |
|
141 |
|
142 $width = $matches[1]; |
|
143 |
|
144 $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); |
|
145 if ( empty($align) ) |
|
146 $align = 'none'; |
|
147 |
|
148 $alt = ! empty($alt) ? addslashes($alt) : ''; |
|
149 |
|
150 $shcode = '[caption id="' . $id . '" align="align' . $align |
|
151 . '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/caption]'; |
|
152 |
|
153 return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); |
|
154 } |
|
155 add_filter( 'image_send_to_editor', 'image_add_caption', 20, 7 ); |
|
156 |
|
157 /** |
|
158 * {@internal Missing Short Description}} |
|
159 * |
|
160 * @since unknown |
|
161 * |
|
162 * @param unknown_type $html |
|
163 */ |
|
164 function media_send_to_editor($html) { |
|
165 ?> |
|
166 <script type="text/javascript"> |
|
167 /* <![CDATA[ */ |
|
168 var win = window.dialogArguments || opener || parent || top; |
|
169 win.send_to_editor('<?php echo addslashes($html); ?>'); |
|
170 /* ]]> */ |
|
171 </script> |
|
172 <?php |
|
173 exit; |
|
174 } |
|
175 |
|
176 /** |
|
177 * {@internal Missing Short Description}} |
|
178 * |
|
179 * This handles the file upload POST itself, creating the attachment post. |
|
180 * |
|
181 * @since unknown |
|
182 * |
|
183 * @param unknown_type $file_id |
|
184 * @param unknown_type $post_id |
|
185 * @param unknown_type $post_data |
|
186 * @return unknown |
|
187 */ |
|
188 function media_handle_upload($file_id, $post_id, $post_data = array()) { |
|
189 $overrides = array('test_form'=>false); |
|
190 |
|
191 $time = current_time('mysql'); |
|
192 if ( $post = get_post($post_id) ) { |
|
193 if ( substr( $post->post_date, 0, 4 ) > 0 ) |
|
194 $time = $post->post_date; |
|
195 } |
|
196 |
|
197 $name = $_FILES[$file_id]['name']; |
|
198 $file = wp_handle_upload($_FILES[$file_id], $overrides, $time); |
|
199 |
|
200 if ( isset($file['error']) ) |
|
201 return new WP_Error( 'upload_error', $file['error'] ); |
|
202 |
|
203 $name_parts = pathinfo($name); |
|
204 $name = trim( substr( $name, 0, -(1 + strlen($name_parts['extension'])) ) ); |
|
205 |
|
206 $url = $file['url']; |
|
207 $type = $file['type']; |
|
208 $file = $file['file']; |
|
209 $title = $name; |
|
210 $content = ''; |
|
211 |
|
212 // use image exif/iptc data for title and caption defaults if possible |
|
213 if ( $image_meta = @wp_read_image_metadata($file) ) { |
|
214 if ( trim($image_meta['title']) ) |
|
215 $title = $image_meta['title']; |
|
216 if ( trim($image_meta['caption']) ) |
|
217 $content = $image_meta['caption']; |
|
218 } |
|
219 |
|
220 // Construct the attachment array |
|
221 $attachment = array_merge( array( |
|
222 'post_mime_type' => $type, |
|
223 'guid' => $url, |
|
224 'post_parent' => $post_id, |
|
225 'post_title' => $title, |
|
226 'post_content' => $content, |
|
227 ), $post_data ); |
|
228 |
|
229 // Save the data |
|
230 $id = wp_insert_attachment($attachment, $file, $post_id); |
|
231 if ( !is_wp_error($id) ) { |
|
232 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); |
|
233 } |
|
234 |
|
235 return $id; |
|
236 |
|
237 } |
|
238 |
|
239 /** |
|
240 * {@internal Missing Short Description}} |
|
241 * |
|
242 * @since unknown |
|
243 * |
|
244 * @param unknown_type $file_array |
|
245 * @param unknown_type $post_id |
|
246 * @param unknown_type $desc |
|
247 * @param unknown_type $post_data |
|
248 * @return unknown |
|
249 */ |
|
250 function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) { |
|
251 $overrides = array('test_form'=>false); |
|
252 $file = wp_handle_sideload($file_array, $overrides); |
|
253 |
|
254 if ( isset($file['error']) ) |
|
255 return new WP_Error( 'upload_error', $file['error'] ); |
|
256 |
|
257 $url = $file['url']; |
|
258 $type = $file['type']; |
|
259 $file = $file['file']; |
|
260 $title = preg_replace('/\.[^.]+$/', '', basename($file)); |
|
261 $content = ''; |
|
262 |
|
263 // use image exif/iptc data for title and caption defaults if possible |
|
264 if ( $image_meta = @wp_read_image_metadata($file) ) { |
|
265 if ( trim($image_meta['title']) ) |
|
266 $title = $image_meta['title']; |
|
267 if ( trim($image_meta['caption']) ) |
|
268 $content = $image_meta['caption']; |
|
269 } |
|
270 |
|
271 $title = @$desc; |
|
272 |
|
273 // Construct the attachment array |
|
274 $attachment = array_merge( array( |
|
275 'post_mime_type' => $type, |
|
276 'guid' => $url, |
|
277 'post_parent' => $post_id, |
|
278 'post_title' => $title, |
|
279 'post_content' => $content, |
|
280 ), $post_data ); |
|
281 |
|
282 // Save the data |
|
283 $id = wp_insert_attachment($attachment, $file, $post_id); |
|
284 if ( !is_wp_error($id) ) { |
|
285 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); |
|
286 return $url; |
|
287 } |
|
288 return $id; |
|
289 } |
|
290 |
|
291 /** |
|
292 * {@internal Missing Short Description}} |
|
293 * |
|
294 * Wrap iframe content (produced by $content_func) in a doctype, html head/body |
|
295 * etc any additional function args will be passed to content_func. |
|
296 * |
|
297 * @since unknown |
|
298 * |
|
299 * @param unknown_type $content_func |
|
300 */ |
|
301 function wp_iframe($content_func /* ... */) { |
|
302 ?> |
|
303 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
304 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> |
|
305 <head> |
|
306 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> |
|
307 <title><?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — <?php _e('WordPress'); ?></title> |
|
308 <?php |
|
309 wp_enqueue_style( 'global' ); |
|
310 wp_enqueue_style( 'wp-admin' ); |
|
311 wp_enqueue_style( 'colors' ); |
|
312 if ( 0 === strpos( $content_func, 'media' ) ) |
|
313 wp_enqueue_style( 'media' ); |
|
314 wp_enqueue_style( 'ie' ); |
|
315 ?> |
|
316 <script type="text/javascript"> |
|
317 //<![CDATA[ |
|
318 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; |
|
319 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'}; |
|
320 //]]> |
|
321 </script> |
|
322 <?php |
|
323 do_action('admin_print_styles'); |
|
324 do_action('admin_print_scripts'); |
|
325 do_action('admin_head'); |
|
326 if ( is_string($content_func) ) |
|
327 do_action( "admin_head_{$content_func}" ); |
|
328 ?> |
|
329 </head> |
|
330 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>> |
|
331 <?php |
|
332 $args = func_get_args(); |
|
333 $args = array_slice($args, 1); |
|
334 call_user_func_array($content_func, $args); |
|
335 |
|
336 do_action('admin_print_footer_scripts'); |
|
337 ?> |
|
338 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> |
|
339 </body> |
|
340 </html> |
|
341 <?php |
|
342 } |
|
343 |
|
344 /** |
|
345 * {@internal Missing Short Description}} |
|
346 * |
|
347 * @since unknown |
|
348 */ |
|
349 function media_buttons() { |
|
350 global $post_ID, $temp_ID; |
|
351 $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); |
|
352 $context = apply_filters('media_buttons_context', __('Upload/Insert %s')); |
|
353 $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID"; |
|
354 $media_title = __('Add Media'); |
|
355 $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image"); |
|
356 $image_title = __('Add an Image'); |
|
357 $video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src&type=video"); |
|
358 $video_title = __('Add Video'); |
|
359 $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&type=audio"); |
|
360 $audio_title = __('Add Audio'); |
|
361 $out = <<<EOF |
|
362 |
|
363 <a href="{$image_upload_iframe_src}&TB_iframe=true" id="add_image" class="thickbox" title='$image_title' onclick="return false;"><img src='images/media-button-image.gif' alt='$image_title' /></a> |
|
364 <a href="{$video_upload_iframe_src}&TB_iframe=true" id="add_video" class="thickbox" title='$video_title' onclick="return false;"><img src='images/media-button-video.gif' alt='$video_title' /></a> |
|
365 <a href="{$audio_upload_iframe_src}&TB_iframe=true" id="add_audio" class="thickbox" title='$audio_title' onclick="return false;"><img src='images/media-button-music.gif' alt='$audio_title' /></a> |
|
366 <a href="{$media_upload_iframe_src}&TB_iframe=true" id="add_media" class="thickbox" title='$media_title' onclick="return false;"><img src='images/media-button-other.gif' alt='$media_title' /></a> |
|
367 |
|
368 EOF; |
|
369 printf($context, $out); |
|
370 } |
|
371 add_action( 'media_buttons', 'media_buttons' ); |
|
372 |
|
373 /** |
|
374 * {@internal Missing Short Description}} |
|
375 * |
|
376 * @since unknown |
|
377 * |
|
378 * @return unknown |
|
379 */ |
|
380 function media_upload_form_handler() { |
|
381 check_admin_referer('media-form'); |
|
382 |
|
383 $errors = null; |
|
384 |
|
385 if ( isset($_POST['send']) ) { |
|
386 $keys = array_keys($_POST['send']); |
|
387 $send_id = (int) array_shift($keys); |
|
388 } |
|
389 |
|
390 if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { |
|
391 $post = $_post = get_post($attachment_id, ARRAY_A); |
|
392 if ( isset($attachment['post_content']) ) |
|
393 $post['post_content'] = $attachment['post_content']; |
|
394 if ( isset($attachment['post_title']) ) |
|
395 $post['post_title'] = $attachment['post_title']; |
|
396 if ( isset($attachment['post_excerpt']) ) |
|
397 $post['post_excerpt'] = $attachment['post_excerpt']; |
|
398 if ( isset($attachment['menu_order']) ) |
|
399 $post['menu_order'] = $attachment['menu_order']; |
|
400 |
|
401 if ( isset($send_id) && $attachment_id == $send_id ) { |
|
402 if ( isset($attachment['post_parent']) ) |
|
403 $post['post_parent'] = $attachment['post_parent']; |
|
404 } |
|
405 |
|
406 $post = apply_filters('attachment_fields_to_save', $post, $attachment); |
|
407 |
|
408 if ( isset($post['errors']) ) { |
|
409 $errors[$attachment_id] = $post['errors']; |
|
410 unset($post['errors']); |
|
411 } |
|
412 |
|
413 if ( $post != $_post ) |
|
414 wp_update_post($post); |
|
415 |
|
416 foreach ( get_attachment_taxonomies($post) as $t ) |
|
417 if ( isset($attachment[$t]) ) |
|
418 wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false); |
|
419 } |
|
420 |
|
421 if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?> |
|
422 <script type="text/javascript"> |
|
423 /* <![CDATA[ */ |
|
424 var win = window.dialogArguments || opener || parent || top; |
|
425 win.tb_remove(); |
|
426 /* ]]> */ |
|
427 </script> |
|
428 <?php |
|
429 exit; |
|
430 } |
|
431 |
|
432 if ( isset($send_id) ) { |
|
433 $attachment = stripslashes_deep( $_POST['attachments'][$send_id] ); |
|
434 |
|
435 $html = $attachment['post_title']; |
|
436 if ( !empty($attachment['url']) ) { |
|
437 if ( strpos($attachment['url'], 'attachment_id') || false !== strpos($attachment['url'], get_permalink($_POST['post_id'])) ) |
|
438 $rel = " rel='attachment wp-att-" . esc_attr($send_id)."'"; |
|
439 $html = "<a href='{$attachment['url']}'$rel>$html</a>"; |
|
440 } |
|
441 |
|
442 $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); |
|
443 return media_send_to_editor($html); |
|
444 } |
|
445 |
|
446 return $errors; |
|
447 } |
|
448 |
|
449 /** |
|
450 * {@internal Missing Short Description}} |
|
451 * |
|
452 * @since unknown |
|
453 * |
|
454 * @return unknown |
|
455 */ |
|
456 function media_upload_image() { |
|
457 $errors = array(); |
|
458 $id = 0; |
|
459 |
|
460 if ( isset($_POST['html-upload']) && !empty($_FILES) ) { |
|
461 // Upload File button was clicked |
|
462 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); |
|
463 unset($_FILES); |
|
464 if ( is_wp_error($id) ) { |
|
465 $errors['upload_error'] = $id; |
|
466 $id = false; |
|
467 } |
|
468 } |
|
469 |
|
470 if ( !empty($_POST['insertonlybutton']) ) { |
|
471 $src = $_POST['insertonly']['src']; |
|
472 if ( !empty($src) && !strpos($src, '://') ) |
|
473 $src = "http://$src"; |
|
474 $alt = esc_attr($_POST['insertonly']['alt']); |
|
475 if ( isset($_POST['insertonly']['align']) ) { |
|
476 $align = esc_attr($_POST['insertonly']['align']); |
|
477 $class = " class='align$align'"; |
|
478 } |
|
479 if ( !empty($src) ) |
|
480 $html = "<img src='$src' alt='$alt'$class />"; |
|
481 $html = apply_filters('image_send_to_editor_url', $html, $src, $alt, $align); |
|
482 return media_send_to_editor($html); |
|
483 } |
|
484 |
|
485 if ( !empty($_POST) ) { |
|
486 $return = media_upload_form_handler(); |
|
487 |
|
488 if ( is_string($return) ) |
|
489 return $return; |
|
490 if ( is_array($return) ) |
|
491 $errors = $return; |
|
492 } |
|
493 |
|
494 if ( isset($_POST['save']) ) { |
|
495 $errors['upload_notice'] = __('Saved.'); |
|
496 return media_upload_gallery(); |
|
497 } |
|
498 |
|
499 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) |
|
500 return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id ); |
|
501 |
|
502 return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); |
|
503 } |
|
504 |
|
505 /** |
|
506 * {@internal Missing Short Description}} |
|
507 * |
|
508 * @since unknown |
|
509 * |
|
510 * @param unknown_type $file |
|
511 * @param unknown_type $post_id |
|
512 * @param unknown_type $desc |
|
513 * @return unknown |
|
514 */ |
|
515 function media_sideload_image($file, $post_id, $desc = null) { |
|
516 if (!empty($file) ) { |
|
517 $file_array['name'] = basename($file); |
|
518 $tmp = download_url($file); |
|
519 $file_array['tmp_name'] = $tmp; |
|
520 $desc = @$desc; |
|
521 |
|
522 if ( is_wp_error($tmp) ) { |
|
523 @unlink($file_array['tmp_name']); |
|
524 $file_array['tmp_name'] = ''; |
|
525 } |
|
526 |
|
527 $id = media_handle_sideload($file_array, $post_id, $desc); |
|
528 $src = $id; |
|
529 |
|
530 if ( is_wp_error($id) ) { |
|
531 @unlink($file_array['tmp_name']); |
|
532 return $id; |
|
533 } |
|
534 } |
|
535 |
|
536 if ( !empty($src) ) { |
|
537 $alt = @$desc; |
|
538 $html = "<img src='$src' alt='$alt' />"; |
|
539 return $html; |
|
540 } |
|
541 } |
|
542 |
|
543 /** |
|
544 * {@internal Missing Short Description}} |
|
545 * |
|
546 * @since unknown |
|
547 * |
|
548 * @return unknown |
|
549 */ |
|
550 function media_upload_audio() { |
|
551 $errors = array(); |
|
552 $id = 0; |
|
553 |
|
554 if ( isset($_POST['html-upload']) && !empty($_FILES) ) { |
|
555 // Upload File button was clicked |
|
556 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); |
|
557 unset($_FILES); |
|
558 if ( is_wp_error($id) ) { |
|
559 $errors['upload_error'] = $id; |
|
560 $id = false; |
|
561 } |
|
562 } |
|
563 |
|
564 if ( !empty($_POST['insertonlybutton']) ) { |
|
565 $href = $_POST['insertonly']['href']; |
|
566 if ( !empty($href) && !strpos($href, '://') ) |
|
567 $href = "http://$href"; |
|
568 $title = esc_attr($_POST['insertonly']['title']); |
|
569 if ( empty($title) ) |
|
570 $title = basename($href); |
|
571 if ( !empty($title) && !empty($href) ) |
|
572 $html = "<a href='$href' >$title</a>"; |
|
573 $html = apply_filters('audio_send_to_editor_url', $html, $href, $title); |
|
574 return media_send_to_editor($html); |
|
575 } |
|
576 |
|
577 if ( !empty($_POST) ) { |
|
578 $return = media_upload_form_handler(); |
|
579 |
|
580 if ( is_string($return) ) |
|
581 return $return; |
|
582 if ( is_array($return) ) |
|
583 $errors = $return; |
|
584 } |
|
585 |
|
586 if ( isset($_POST['save']) ) { |
|
587 $errors['upload_notice'] = __('Saved.'); |
|
588 return media_upload_gallery(); |
|
589 } |
|
590 |
|
591 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) |
|
592 return wp_iframe( 'media_upload_type_url_form', 'audio', $errors, $id ); |
|
593 |
|
594 return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id ); |
|
595 } |
|
596 |
|
597 /** |
|
598 * {@internal Missing Short Description}} |
|
599 * |
|
600 * @since unknown |
|
601 * |
|
602 * @return unknown |
|
603 */ |
|
604 function media_upload_video() { |
|
605 $errors = array(); |
|
606 $id = 0; |
|
607 |
|
608 if ( isset($_POST['html-upload']) && !empty($_FILES) ) { |
|
609 // Upload File button was clicked |
|
610 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); |
|
611 unset($_FILES); |
|
612 if ( is_wp_error($id) ) { |
|
613 $errors['upload_error'] = $id; |
|
614 $id = false; |
|
615 } |
|
616 } |
|
617 |
|
618 if ( !empty($_POST['insertonlybutton']) ) { |
|
619 $href = $_POST['insertonly']['href']; |
|
620 if ( !empty($href) && !strpos($href, '://') ) |
|
621 $href = "http://$href"; |
|
622 $title = esc_attr($_POST['insertonly']['title']); |
|
623 if ( empty($title) ) |
|
624 $title = basename($href); |
|
625 if ( !empty($title) && !empty($href) ) |
|
626 $html = "<a href='$href' >$title</a>"; |
|
627 $html = apply_filters('video_send_to_editor_url', $html, $href, $title); |
|
628 return media_send_to_editor($html); |
|
629 } |
|
630 |
|
631 if ( !empty($_POST) ) { |
|
632 $return = media_upload_form_handler(); |
|
633 |
|
634 if ( is_string($return) ) |
|
635 return $return; |
|
636 if ( is_array($return) ) |
|
637 $errors = $return; |
|
638 } |
|
639 |
|
640 if ( isset($_POST['save']) ) { |
|
641 $errors['upload_notice'] = __('Saved.'); |
|
642 return media_upload_gallery(); |
|
643 } |
|
644 |
|
645 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) |
|
646 return wp_iframe( 'media_upload_type_url_form', 'video', $errors, $id ); |
|
647 |
|
648 return wp_iframe( 'media_upload_type_form', 'video', $errors, $id ); |
|
649 } |
|
650 |
|
651 /** |
|
652 * {@internal Missing Short Description}} |
|
653 * |
|
654 * @since unknown |
|
655 * |
|
656 * @return unknown |
|
657 */ |
|
658 function media_upload_file() { |
|
659 $errors = array(); |
|
660 $id = 0; |
|
661 |
|
662 if ( isset($_POST['html-upload']) && !empty($_FILES) ) { |
|
663 // Upload File button was clicked |
|
664 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); |
|
665 unset($_FILES); |
|
666 if ( is_wp_error($id) ) { |
|
667 $errors['upload_error'] = $id; |
|
668 $id = false; |
|
669 } |
|
670 } |
|
671 |
|
672 if ( !empty($_POST['insertonlybutton']) ) { |
|
673 $href = $_POST['insertonly']['href']; |
|
674 if ( !empty($href) && !strpos($href, '://') ) |
|
675 $href = "http://$href"; |
|
676 $title = esc_attr($_POST['insertonly']['title']); |
|
677 if ( empty($title) ) |
|
678 $title = basename($href); |
|
679 if ( !empty($title) && !empty($href) ) |
|
680 $html = "<a href='$href' >$title</a>"; |
|
681 $html = apply_filters('file_send_to_editor_url', $html, $href, $title); |
|
682 return media_send_to_editor($html); |
|
683 } |
|
684 |
|
685 if ( !empty($_POST) ) { |
|
686 $return = media_upload_form_handler(); |
|
687 |
|
688 if ( is_string($return) ) |
|
689 return $return; |
|
690 if ( is_array($return) ) |
|
691 $errors = $return; |
|
692 } |
|
693 |
|
694 if ( isset($_POST['save']) ) { |
|
695 $errors['upload_notice'] = __('Saved.'); |
|
696 return media_upload_gallery(); |
|
697 } |
|
698 |
|
699 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) |
|
700 return wp_iframe( 'media_upload_type_url_form', 'file', $errors, $id ); |
|
701 |
|
702 return wp_iframe( 'media_upload_type_form', 'file', $errors, $id ); |
|
703 } |
|
704 |
|
705 /** |
|
706 * {@internal Missing Short Description}} |
|
707 * |
|
708 * @since unknown |
|
709 * |
|
710 * @return unknown |
|
711 */ |
|
712 function media_upload_gallery() { |
|
713 $errors = array(); |
|
714 |
|
715 if ( !empty($_POST) ) { |
|
716 $return = media_upload_form_handler(); |
|
717 |
|
718 if ( is_string($return) ) |
|
719 return $return; |
|
720 if ( is_array($return) ) |
|
721 $errors = $return; |
|
722 } |
|
723 |
|
724 wp_enqueue_script('admin-gallery'); |
|
725 return wp_iframe( 'media_upload_gallery_form', $errors ); |
|
726 } |
|
727 |
|
728 /** |
|
729 * {@internal Missing Short Description}} |
|
730 * |
|
731 * @since unknown |
|
732 * |
|
733 * @return unknown |
|
734 */ |
|
735 function media_upload_library() { |
|
736 $errors = array(); |
|
737 if ( !empty($_POST) ) { |
|
738 $return = media_upload_form_handler(); |
|
739 |
|
740 if ( is_string($return) ) |
|
741 return $return; |
|
742 if ( is_array($return) ) |
|
743 $errors = $return; |
|
744 } |
|
745 |
|
746 return wp_iframe( 'media_upload_library_form', $errors ); |
|
747 } |
|
748 |
|
749 /** |
|
750 * Retrieve HTML for the image alignment radio buttons with the specified one checked. |
|
751 * |
|
752 * @since unknown |
|
753 * |
|
754 * @param unknown_type $post |
|
755 * @param unknown_type $checked |
|
756 * @return unknown |
|
757 */ |
|
758 function image_align_input_fields( $post, $checked = '' ) { |
|
759 |
|
760 $alignments = array('none' => __('None'), 'left' => __('Left'), 'center' => __('Center'), 'right' => __('Right')); |
|
761 if ( !array_key_exists( (string) $checked, $alignments ) ) |
|
762 $checked = 'none'; |
|
763 |
|
764 $out = array(); |
|
765 foreach ($alignments as $name => $label) { |
|
766 $name = esc_attr($name); |
|
767 $out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'". |
|
768 ( $checked == $name ? " checked='checked'" : "" ) . |
|
769 " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>" . $label . "</label>"; |
|
770 } |
|
771 return join("\n", $out); |
|
772 } |
|
773 |
|
774 /** |
|
775 * Retrieve HTML for the size radio buttons with the specified one checked. |
|
776 * |
|
777 * @since unknown |
|
778 * |
|
779 * @param unknown_type $post |
|
780 * @param unknown_type $checked |
|
781 * @return unknown |
|
782 */ |
|
783 function image_size_input_fields( $post, $checked = '' ) { |
|
784 |
|
785 // get a list of the actual pixel dimensions of each possible intermediate version of this image |
|
786 $size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full size')); |
|
787 |
|
788 foreach ( $size_names as $size => $name ) { |
|
789 $downsize = image_downsize($post->ID, $size); |
|
790 |
|
791 // is this size selectable? |
|
792 $enabled = ( $downsize[3] || 'full' == $size ); |
|
793 $css_id = "image-size-{$size}-{$post->ID}"; |
|
794 // if this size is the default but that's not available, don't select it |
|
795 if ( $checked && !$enabled ) |
|
796 $checked = ''; |
|
797 // if $checked was not specified, default to the first available size that's bigger than a thumbnail |
|
798 if ( !$checked && $enabled && 'thumbnail' != $size ) |
|
799 $checked = $size; |
|
800 |
|
801 $html = "<div class='image-size-item'><input type='radio' ".( $enabled ? '' : "disabled='disabled'")."name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'".( $checked == $size ? " checked='checked'" : '') ." />"; |
|
802 |
|
803 $html .= "<label for='{$css_id}'>" . __($name). "</label>"; |
|
804 // only show the dimensions if that choice is available |
|
805 if ( $enabled ) |
|
806 $html .= " <label for='{$css_id}' class='help'>" . sprintf( __("(%d × %d)"), $downsize[1], $downsize[2] ). "</label>"; |
|
807 |
|
808 $html .= '</div>'; |
|
809 |
|
810 $out[] = $html; |
|
811 } |
|
812 |
|
813 return array( |
|
814 'label' => __('Size'), |
|
815 'input' => 'html', |
|
816 'html' => join("\n", $out), |
|
817 ); |
|
818 } |
|
819 |
|
820 /** |
|
821 * Retrieve HTML for the Link URL buttons with the default link type as specified. |
|
822 * |
|
823 * @since unknown |
|
824 * |
|
825 * @param unknown_type $post |
|
826 * @param unknown_type $url_type |
|
827 * @return unknown |
|
828 */ |
|
829 function image_link_input_fields($post, $url_type='') { |
|
830 |
|
831 $file = wp_get_attachment_url($post->ID); |
|
832 $link = get_attachment_link($post->ID); |
|
833 |
|
834 $url = ''; |
|
835 if ( $url_type == 'file' ) |
|
836 $url = $file; |
|
837 elseif ( $url_type == 'post' ) |
|
838 $url = $link; |
|
839 |
|
840 return "<input type='text' class='urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br /> |
|
841 <button type='button' class='button urlnone' title=''>" . __('None') . "</button> |
|
842 <button type='button' class='button urlfile' title='" . esc_attr($file) . "'>" . __('File URL') . "</button> |
|
843 <button type='button' class='button urlpost' title='" . esc_attr($link) . "'>" . __('Post URL') . "</button> |
|
844 "; |
|
845 } |
|
846 |
|
847 /** |
|
848 * {@internal Missing Short Description}} |
|
849 * |
|
850 * @since unknown |
|
851 * |
|
852 * @param unknown_type $form_fields |
|
853 * @param unknown_type $post |
|
854 * @return unknown |
|
855 */ |
|
856 function image_attachment_fields_to_edit($form_fields, $post) { |
|
857 if ( substr($post->post_mime_type, 0, 5) == 'image' ) { |
|
858 $form_fields['post_title']['required'] = true; |
|
859 $file = wp_get_attachment_url($post->ID); |
|
860 |
|
861 $form_fields['image_url']['value'] = $file; |
|
862 |
|
863 $form_fields['post_excerpt']['label'] = __('Caption'); |
|
864 $form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image'); |
|
865 |
|
866 $form_fields['post_content']['label'] = __('Description'); |
|
867 |
|
868 $form_fields['align'] = array( |
|
869 'label' => __('Alignment'), |
|
870 'input' => 'html', |
|
871 'html' => image_align_input_fields($post, get_option('image_default_align')), |
|
872 ); |
|
873 |
|
874 $form_fields['image-size'] = image_size_input_fields($post, get_option('image_default_size')); |
|
875 } |
|
876 return $form_fields; |
|
877 } |
|
878 |
|
879 add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2); |
|
880 |
|
881 /** |
|
882 * {@internal Missing Short Description}} |
|
883 * |
|
884 * @since unknown |
|
885 * |
|
886 * @param unknown_type $form_fields |
|
887 * @param unknown_type $post |
|
888 * @return unknown |
|
889 */ |
|
890 function media_single_attachment_fields_to_edit( $form_fields, $post ) { |
|
891 unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']); |
|
892 return $form_fields; |
|
893 } |
|
894 |
|
895 function media_post_single_attachment_fields_to_edit( $form_fields, $post ) { |
|
896 unset($form_fields['image_url']); |
|
897 return $form_fields; |
|
898 } |
|
899 |
|
900 /** |
|
901 * {@internal Missing Short Description}} |
|
902 * |
|
903 * @since unknown |
|
904 * |
|
905 * @param unknown_type $post |
|
906 * @param unknown_type $attachment |
|
907 * @return unknown |
|
908 */ |
|
909 function image_attachment_fields_to_save($post, $attachment) { |
|
910 if ( substr($post['post_mime_type'], 0, 5) == 'image' ) { |
|
911 if ( strlen(trim($post['post_title'])) == 0 ) { |
|
912 $post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid'])); |
|
913 $post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.'); |
|
914 } |
|
915 } |
|
916 |
|
917 return $post; |
|
918 } |
|
919 |
|
920 add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2); |
|
921 |
|
922 /** |
|
923 * {@internal Missing Short Description}} |
|
924 * |
|
925 * @since unknown |
|
926 * |
|
927 * @param unknown_type $html |
|
928 * @param unknown_type $attachment_id |
|
929 * @param unknown_type $attachment |
|
930 * @return unknown |
|
931 */ |
|
932 function image_media_send_to_editor($html, $attachment_id, $attachment) { |
|
933 $post =& get_post($attachment_id); |
|
934 if ( substr($post->post_mime_type, 0, 5) == 'image' ) { |
|
935 $url = $attachment['url']; |
|
936 |
|
937 if ( isset($attachment['align']) ) |
|
938 $align = $attachment['align']; |
|
939 else |
|
940 $align = 'none'; |
|
941 |
|
942 if ( !empty($attachment['image-size']) ) |
|
943 $size = $attachment['image-size']; |
|
944 else |
|
945 $size = 'medium'; |
|
946 |
|
947 $rel = ( $url == get_attachment_link($attachment_id) ); |
|
948 |
|
949 return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size); |
|
950 } |
|
951 |
|
952 return $html; |
|
953 } |
|
954 |
|
955 add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3); |
|
956 |
|
957 /** |
|
958 * {@internal Missing Short Description}} |
|
959 * |
|
960 * @since unknown |
|
961 * |
|
962 * @param unknown_type $post |
|
963 * @param unknown_type $errors |
|
964 * @return unknown |
|
965 */ |
|
966 function get_attachment_fields_to_edit($post, $errors = null) { |
|
967 if ( is_int($post) ) |
|
968 $post =& get_post($post); |
|
969 if ( is_array($post) ) |
|
970 $post = (object) $post; |
|
971 |
|
972 $image_url = wp_get_attachment_url($post->ID); |
|
973 |
|
974 $edit_post = sanitize_post($post, 'edit'); |
|
975 |
|
976 $form_fields = array( |
|
977 'post_title' => array( |
|
978 'label' => __('Title'), |
|
979 'value' => $edit_post->post_title, |
|
980 ), |
|
981 'post_excerpt' => array( |
|
982 'label' => __('Caption'), |
|
983 'value' => $edit_post->post_excerpt, |
|
984 ), |
|
985 'post_content' => array( |
|
986 'label' => __('Description'), |
|
987 'value' => $edit_post->post_content, |
|
988 'input' => 'textarea', |
|
989 ), |
|
990 'url' => array( |
|
991 'label' => __('Link URL'), |
|
992 'input' => 'html', |
|
993 'html' => image_link_input_fields($post, get_option('image_default_link_type')), |
|
994 'helps' => __('Enter a link URL or click above for presets.'), |
|
995 ), |
|
996 'menu_order' => array( |
|
997 'label' => __('Order'), |
|
998 'value' => $edit_post->menu_order |
|
999 ), |
|
1000 'image_url' => array( |
|
1001 'label' => __('File URL'), |
|
1002 'input' => 'html', |
|
1003 'html' => "<input type='text' class='urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . esc_attr($image_url) . "' /><br />", |
|
1004 'value' => isset($edit_post->post_url) ? $edit_post->post_url : '', |
|
1005 'helps' => __('Location of the uploaded file.'), |
|
1006 ) |
|
1007 ); |
|
1008 |
|
1009 foreach ( get_attachment_taxonomies($post) as $taxonomy ) { |
|
1010 $t = (array) get_taxonomy($taxonomy); |
|
1011 if ( empty($t['label']) ) |
|
1012 $t['label'] = $taxonomy; |
|
1013 if ( empty($t['args']) ) |
|
1014 $t['args'] = array(); |
|
1015 |
|
1016 $terms = get_object_term_cache($post->ID, $taxonomy); |
|
1017 if ( empty($terms) ) |
|
1018 $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); |
|
1019 |
|
1020 $values = array(); |
|
1021 |
|
1022 foreach ( $terms as $term ) |
|
1023 $values[] = $term->name; |
|
1024 $t['value'] = join(', ', $values); |
|
1025 |
|
1026 $form_fields[$taxonomy] = $t; |
|
1027 } |
|
1028 |
|
1029 // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default |
|
1030 // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) |
|
1031 $form_fields = array_merge_recursive($form_fields, (array) $errors); |
|
1032 |
|
1033 $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); |
|
1034 |
|
1035 return $form_fields; |
|
1036 } |
|
1037 |
|
1038 /** |
|
1039 * Retrieve HTML for media items of post gallery. |
|
1040 * |
|
1041 * The HTML markup retrieved will be created for the progress of SWF Upload |
|
1042 * component. Will also create link for showing and hiding the form to modify |
|
1043 * the image attachment. |
|
1044 * |
|
1045 * @since unknown |
|
1046 * |
|
1047 * @param int $post_id Optional. Post ID. |
|
1048 * @param array $errors Errors for attachment, if any. |
|
1049 * @return string |
|
1050 */ |
|
1051 function get_media_items( $post_id, $errors ) { |
|
1052 if ( $post_id ) { |
|
1053 $post = get_post($post_id); |
|
1054 if ( $post && $post->post_type == 'attachment' ) |
|
1055 $attachments = array($post->ID => $post); |
|
1056 else |
|
1057 $attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') ); |
|
1058 } else { |
|
1059 if ( is_array($GLOBALS['wp_the_query']->posts) ) |
|
1060 foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) |
|
1061 $attachments[$attachment->ID] = $attachment; |
|
1062 } |
|
1063 |
|
1064 $output = ''; |
|
1065 foreach ( (array) $attachments as $id => $attachment ) |
|
1066 if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) ) |
|
1067 $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress'><div class='bar'></div></div><div id='media-upload-error-$id'></div><div class='filename'></div>$item\n</div>"; |
|
1068 |
|
1069 return $output; |
|
1070 } |
|
1071 |
|
1072 /** |
|
1073 * Retrieve HTML form for modifying the image attachment. |
|
1074 * |
|
1075 * @since unknown |
|
1076 * |
|
1077 * @param int $attachment_id Attachment ID for modification. |
|
1078 * @param string|array $args Optional. Override defaults. |
|
1079 * @return string HTML form for attachment. |
|
1080 */ |
|
1081 function get_media_item( $attachment_id, $args = null ) { |
|
1082 global $redir_tab; |
|
1083 |
|
1084 $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true, 'show_title' => true ); |
|
1085 $args = wp_parse_args( $args, $default_args ); |
|
1086 extract( $args, EXTR_SKIP ); |
|
1087 |
|
1088 global $post_mime_types; |
|
1089 if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) ) |
|
1090 $thumb_url = $thumb_url[0]; |
|
1091 else |
|
1092 return false; |
|
1093 |
|
1094 $toggle_on = __('Show'); |
|
1095 $toggle_off = __('Hide'); |
|
1096 |
|
1097 $post = get_post($attachment_id); |
|
1098 |
|
1099 $filename = basename($post->guid); |
|
1100 $title = esc_attr($post->post_title); |
|
1101 |
|
1102 if ( $_tags = get_the_tags($attachment_id) ) { |
|
1103 foreach ( $_tags as $tag ) |
|
1104 $tags[] = $tag->name; |
|
1105 $tags = esc_attr(join(', ', $tags)); |
|
1106 } |
|
1107 |
|
1108 $type = ''; |
|
1109 if ( isset($post_mime_types) ) { |
|
1110 $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type)); |
|
1111 $type = array_shift($keys); |
|
1112 $type = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />"; |
|
1113 } |
|
1114 |
|
1115 $form_fields = get_attachment_fields_to_edit($post, $errors); |
|
1116 |
|
1117 if ( $toggle ) { |
|
1118 $class = empty($errors) ? 'startclosed' : 'startopen'; |
|
1119 $toggle_links = " |
|
1120 <a class='toggle describe-toggle-on' href='#'>$toggle_on</a> |
|
1121 <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>"; |
|
1122 } else { |
|
1123 $class = 'form-table'; |
|
1124 $toggle_links = ''; |
|
1125 } |
|
1126 |
|
1127 $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case |
|
1128 $display_title = $show_title ? "<div class='filename new'>" . wp_html_excerpt($display_title, 60) . "</div>" : ''; |
|
1129 |
|
1130 $gallery = ( (isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab']) || (isset($redir_tab) && 'gallery' == $redir_tab) ) ? true : false; |
|
1131 $order = ''; |
|
1132 |
|
1133 foreach ( $form_fields as $key => $val ) { |
|
1134 if ( 'menu_order' == $key ) { |
|
1135 if ( $gallery ) |
|
1136 $order = '<div class="menu_order"> <input class="menu_order_input" type="text" id="attachments['.$attachment_id.'][menu_order]" name="attachments['.$attachment_id.'][menu_order]" value="'.$val['value'].'" /></div>'; |
|
1137 else |
|
1138 $order = '<input type="hidden" name="attachments['.$attachment_id.'][menu_order]" value="'.$val['value'].'" />'; |
|
1139 |
|
1140 unset($form_fields['menu_order']); |
|
1141 break; |
|
1142 } |
|
1143 } |
|
1144 |
|
1145 $item = " |
|
1146 $type |
|
1147 $toggle_links |
|
1148 $order |
|
1149 $display_title |
|
1150 <table class='slidetoggle describe $class'> |
|
1151 <thead class='media-item-info'> |
|
1152 <tr> |
|
1153 <td class='A1B1' rowspan='4'><img class='thumbnail' src='$thumb_url' alt='' /></td> |
|
1154 <td>$filename</td> |
|
1155 </tr> |
|
1156 <tr><td>$post->post_mime_type</td></tr> |
|
1157 <tr><td>" . mysql2date($post->post_date, get_option('time_format')) . "</td></tr> |
|
1158 <tr><td>" . apply_filters('media_meta', '', $post) . "</td></tr> |
|
1159 </thead> |
|
1160 <tbody>\n"; |
|
1161 |
|
1162 $defaults = array( |
|
1163 'input' => 'text', |
|
1164 'required' => false, |
|
1165 'value' => '', |
|
1166 'extra_rows' => array(), |
|
1167 ); |
|
1168 |
|
1169 $delete_href = wp_nonce_url("post.php?action=delete-post&post=$attachment_id", 'delete-post_' . $attachment_id); |
|
1170 if ( $send ) |
|
1171 $send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />"; |
|
1172 if ( $delete ) |
|
1173 $delete = "<a href=\"#\" class=\"del-link\" onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __('Delete') . "</a>"; |
|
1174 if ( ( $send || $delete ) && !isset($form_fields['buttons']) ) |
|
1175 $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete |
|
1176 <div id=\"del_attachment_$attachment_id\" class=\"del-attachment\" style=\"display:none;\">" . sprintf(__("You are about to delete <strong>%s</strong>."), $filename) . " <a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Continue') . "</a> |
|
1177 <a href=\"#\" class=\"del-link\" onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a></div></td></tr>\n"); |
|
1178 |
|
1179 $hidden_fields = array(); |
|
1180 |
|
1181 foreach ( $form_fields as $id => $field ) { |
|
1182 if ( $id{0} == '_' ) |
|
1183 continue; |
|
1184 |
|
1185 if ( !empty($field['tr']) ) { |
|
1186 $item .= $field['tr']; |
|
1187 continue; |
|
1188 } |
|
1189 |
|
1190 $field = array_merge($defaults, $field); |
|
1191 $name = "attachments[$attachment_id][$id]"; |
|
1192 |
|
1193 if ( $field['input'] == 'hidden' ) { |
|
1194 $hidden_fields[$name] = $field['value']; |
|
1195 continue; |
|
1196 } |
|
1197 |
|
1198 $required = $field['required'] ? '<abbr title="required" class="required">*</abbr>' : ''; |
|
1199 $aria_required = $field['required'] ? " aria-required='true' " : ''; |
|
1200 $class = $id; |
|
1201 $class .= $field['required'] ? ' form-required' : ''; |
|
1202 |
|
1203 $item .= "\t\t<tr class='$class'>\n\t\t\t<th valign='top' scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}</span><span class='alignright'>$required</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>"; |
|
1204 if ( !empty($field[$field['input']]) ) |
|
1205 $item .= $field[$field['input']]; |
|
1206 elseif ( $field['input'] == 'textarea' ) { |
|
1207 $item .= "<textarea type='text' id='$name' name='$name'" . $aria_required . ">" . esc_html( $field['value'] ) . "</textarea>"; |
|
1208 } else { |
|
1209 $item .= "<input type='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "'" . $aria_required . "/>"; |
|
1210 } |
|
1211 if ( !empty($field['helps']) ) |
|
1212 $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique((array) $field['helps']) ) . '</p>'; |
|
1213 $item .= "</td>\n\t\t</tr>\n"; |
|
1214 |
|
1215 $extra_rows = array(); |
|
1216 |
|
1217 if ( !empty($field['errors']) ) |
|
1218 foreach ( array_unique((array) $field['errors']) as $error ) |
|
1219 $extra_rows['error'][] = $error; |
|
1220 |
|
1221 if ( !empty($field['extra_rows']) ) |
|
1222 foreach ( $field['extra_rows'] as $class => $rows ) |
|
1223 foreach ( (array) $rows as $html ) |
|
1224 $extra_rows[$class][] = $html; |
|
1225 |
|
1226 foreach ( $extra_rows as $class => $rows ) |
|
1227 foreach ( $rows as $html ) |
|
1228 $item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n"; |
|
1229 } |
|
1230 |
|
1231 if ( !empty($form_fields['_final']) ) |
|
1232 $item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n"; |
|
1233 $item .= "\t</tbody>\n"; |
|
1234 $item .= "\t</table>\n"; |
|
1235 |
|
1236 foreach ( $hidden_fields as $name => $value ) |
|
1237 $item .= "\t<input type='hidden' name='$name' id='$name' value='" . esc_attr( $value ) . "' />\n"; |
|
1238 |
|
1239 if ( $post->post_parent < 1 && isset($_REQUEST['post_id']) ) { |
|
1240 $parent = (int) $_REQUEST['post_id']; |
|
1241 $parent_name = "attachments[$attachment_id][post_parent]"; |
|
1242 |
|
1243 $item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='" . $parent . "' />\n"; |
|
1244 } |
|
1245 |
|
1246 return $item; |
|
1247 } |
|
1248 |
|
1249 /** |
|
1250 * {@internal Missing Short Description}} |
|
1251 * |
|
1252 * @since unknown |
|
1253 */ |
|
1254 function media_upload_header() { |
|
1255 ?> |
|
1256 <script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script> |
|
1257 <div id="media-upload-header"> |
|
1258 <?php the_media_upload_tabs(); ?> |
|
1259 </div> |
|
1260 <?php |
|
1261 } |
|
1262 |
|
1263 /** |
|
1264 * {@internal Missing Short Description}} |
|
1265 * |
|
1266 * @since unknown |
|
1267 * |
|
1268 * @param unknown_type $errors |
|
1269 */ |
|
1270 function media_upload_form( $errors = null ) { |
|
1271 global $type, $tab; |
|
1272 |
|
1273 $flash_action_url = admin_url('async-upload.php'); |
|
1274 |
|
1275 // If Mac and mod_security, no Flash. :( |
|
1276 $flash = true; |
|
1277 if ( false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mac') && apache_mod_loaded('mod_security') ) |
|
1278 $flash = false; |
|
1279 |
|
1280 $flash = apply_filters('flash_uploader', $flash); |
|
1281 $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; |
|
1282 |
|
1283 ?> |
|
1284 <script type="text/javascript"> |
|
1285 //<![CDATA[ |
|
1286 var uploaderMode = 0; |
|
1287 jQuery(document).ready(function($){ |
|
1288 uploaderMode = getUserSetting('uploader'); |
|
1289 $('.upload-html-bypass a').click(function(){deleteUserSetting('uploader');uploaderMode=0;swfuploadPreLoad();return false;}); |
|
1290 $('.upload-flash-bypass a').click(function(){setUserSetting('uploader', '1');uploaderMode=1;swfuploadPreLoad();return false;}); |
|
1291 }); |
|
1292 //]]> |
|
1293 </script> |
|
1294 <div id="media-upload-notice"> |
|
1295 <?php if (isset($errors['upload_notice']) ) { ?> |
|
1296 <?php echo $errors['upload_notice']; ?> |
|
1297 <?php } ?> |
|
1298 </div> |
|
1299 <div id="media-upload-error"> |
|
1300 <?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { ?> |
|
1301 <?php echo $errors['upload_error']->get_error_message(); ?> |
|
1302 <?php } ?> |
|
1303 </div> |
|
1304 |
|
1305 <?php do_action('pre-upload-ui'); ?> |
|
1306 |
|
1307 <?php if ( $flash ) : ?> |
|
1308 <script type="text/javascript"> |
|
1309 //<![CDATA[ |
|
1310 var swfu; |
|
1311 SWFUpload.onload = function() { |
|
1312 var settings = { |
|
1313 button_text: '<span class="button"><?php _e('Select Files'); ?></span>', |
|
1314 button_text_style: '.button { text-align: center; font-weight: bold; font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; }', |
|
1315 button_height: "24", |
|
1316 button_width: "132", |
|
1317 button_text_top_padding: 2, |
|
1318 button_image_url: '<?php echo includes_url('images/upload.png'); ?>', |
|
1319 button_placeholder_id: "flash-browse-button", |
|
1320 upload_url : "<?php echo esc_attr( $flash_action_url ); ?>", |
|
1321 flash_url : "<?php echo includes_url('js/swfupload/swfupload.swf'); ?>", |
|
1322 file_post_name: "async-upload", |
|
1323 file_types: "<?php echo apply_filters('upload_file_glob', '*.*'); ?>", |
|
1324 post_params : { |
|
1325 "post_id" : "<?php echo $post_id; ?>", |
|
1326 "auth_cookie" : "<?php if ( is_ssl() ) echo $_COOKIE[SECURE_AUTH_COOKIE]; else echo $_COOKIE[AUTH_COOKIE]; ?>", |
|
1327 "_wpnonce" : "<?php echo wp_create_nonce('media-form'); ?>", |
|
1328 "type" : "<?php echo $type; ?>", |
|
1329 "tab" : "<?php echo $tab; ?>", |
|
1330 "short" : "1" |
|
1331 }, |
|
1332 file_size_limit : "<?php echo wp_max_upload_size(); ?>b", |
|
1333 file_dialog_start_handler : fileDialogStart, |
|
1334 file_queued_handler : fileQueued, |
|
1335 upload_start_handler : uploadStart, |
|
1336 upload_progress_handler : uploadProgress, |
|
1337 upload_error_handler : uploadError, |
|
1338 upload_success_handler : uploadSuccess, |
|
1339 upload_complete_handler : uploadComplete, |
|
1340 file_queue_error_handler : fileQueueError, |
|
1341 file_dialog_complete_handler : fileDialogComplete, |
|
1342 swfupload_pre_load_handler: swfuploadPreLoad, |
|
1343 swfupload_load_failed_handler: swfuploadLoadFailed, |
|
1344 custom_settings : { |
|
1345 degraded_element_id : "html-upload-ui", // id of the element displayed when swfupload is unavailable |
|
1346 swfupload_element_id : "flash-upload-ui" // id of the element displayed when swfupload is available |
|
1347 }, |
|
1348 debug: false |
|
1349 }; |
|
1350 swfu = new SWFUpload(settings); |
|
1351 }; |
|
1352 //]]> |
|
1353 </script> |
|
1354 |
|
1355 <div id="flash-upload-ui"> |
|
1356 <?php do_action('pre-flash-upload-ui'); ?> |
|
1357 |
|
1358 <div> |
|
1359 <?php _e( 'Choose files to upload' ); ?> |
|
1360 <div id="flash-browse-button"></div> |
|
1361 <span><input id="cancel-upload" disabled="disabled" onclick="cancelUpload()" type="button" value="<?php esc_attr_e('Cancel Upload'); ?>" class="button" /></span> |
|
1362 </div> |
|
1363 <?php do_action('post-flash-upload-ui'); ?> |
|
1364 <p class="howto"><?php _e('After a file has been uploaded, you can add titles and descriptions.'); ?></p> |
|
1365 </div> |
|
1366 <?php endif; // $flash ?> |
|
1367 |
|
1368 <div id="html-upload-ui"> |
|
1369 <?php do_action('pre-html-upload-ui'); ?> |
|
1370 <p id="async-upload-wrap"> |
|
1371 <label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?></label> |
|
1372 <input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" name="html-upload" value="<?php esc_attr_e('Upload'); ?>" /> <a href="#" onclick="return top.tb_remove();"><?php _e('Cancel'); ?></a> |
|
1373 </p> |
|
1374 <div class="clear"></div> |
|
1375 <?php if ( is_lighttpd_before_150() ): ?> |
|
1376 <p><?php _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p> |
|
1377 <?php endif;?> |
|
1378 <?php do_action('post-html-upload-ui', $flash); ?> |
|
1379 </div> |
|
1380 <?php do_action('post-upload-ui'); ?> |
|
1381 <?php |
|
1382 } |
|
1383 |
|
1384 /** |
|
1385 * {@internal Missing Short Description}} |
|
1386 * |
|
1387 * @since unknown |
|
1388 * |
|
1389 * @param unknown_type $type |
|
1390 * @param unknown_type $errors |
|
1391 * @param unknown_type $id |
|
1392 */ |
|
1393 function media_upload_type_form($type = 'file', $errors = null, $id = null) { |
|
1394 media_upload_header(); |
|
1395 |
|
1396 $post_id = intval($_REQUEST['post_id']); |
|
1397 |
|
1398 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); |
|
1399 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
|
1400 ?> |
|
1401 |
|
1402 <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form"> |
|
1403 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
|
1404 <?php wp_nonce_field('media-form'); ?> |
|
1405 |
|
1406 <h3 class="media-title"><?php _e('Add media files from your computer'); ?></h3> |
|
1407 |
|
1408 <?php media_upload_form( $errors ); ?> |
|
1409 |
|
1410 <script type="text/javascript"> |
|
1411 //<![CDATA[ |
|
1412 jQuery(function($){ |
|
1413 var preloaded = $(".media-item.preloaded"); |
|
1414 if ( preloaded.length > 0 ) { |
|
1415 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); |
|
1416 } |
|
1417 updateMediaForm(); |
|
1418 }); |
|
1419 //]]> |
|
1420 </script> |
|
1421 <div id="media-items"> |
|
1422 <?php |
|
1423 if ( $id ) { |
|
1424 if ( !is_wp_error($id) ) { |
|
1425 add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); |
|
1426 echo get_media_items( $id, $errors ); |
|
1427 } else { |
|
1428 echo '<div id="media-upload-error">'.esc_html($id->get_error_message()).'</div>'; |
|
1429 exit; |
|
1430 } |
|
1431 } |
|
1432 ?> |
|
1433 </div> |
|
1434 <p class="savebutton ml-submit"> |
|
1435 <input type="submit" class="button" name="save" value="<?php esc_attr_e( 'Save all changes' ); ?>" /> |
|
1436 </p> |
|
1437 <?php |
|
1438 } |
|
1439 |
|
1440 /** |
|
1441 * {@internal Missing Short Description}} |
|
1442 * |
|
1443 * @since unknown |
|
1444 * |
|
1445 * @param unknown_type $type |
|
1446 * @param unknown_type $errors |
|
1447 * @param unknown_type $id |
|
1448 */ |
|
1449 function media_upload_type_url_form($type = 'file', $errors = null, $id = null) { |
|
1450 media_upload_header(); |
|
1451 |
|
1452 $post_id = intval($_REQUEST['post_id']); |
|
1453 |
|
1454 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); |
|
1455 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
|
1456 |
|
1457 $callback = "type_url_form_$type"; |
|
1458 ?> |
|
1459 |
|
1460 <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form"> |
|
1461 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
|
1462 <?php wp_nonce_field('media-form'); ?> |
|
1463 |
|
1464 <?php if ( is_callable($callback) ) { ?> |
|
1465 |
|
1466 <h3 class="media-title"><?php _e('Add media file from URL'); ?></h3> |
|
1467 |
|
1468 <script type="text/javascript"> |
|
1469 //<![CDATA[ |
|
1470 var addExtImage = { |
|
1471 |
|
1472 width : '', |
|
1473 height : '', |
|
1474 align : 'alignnone', |
|
1475 |
|
1476 insert : function() { |
|
1477 var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = null; |
|
1478 |
|
1479 if ( '' == f.src.value || '' == t.width ) return false; |
|
1480 |
|
1481 if ( f.title.value ) { |
|
1482 title = f.title.value.replace(/['"<>]+/g, ''); |
|
1483 title = ' title="'+title+'"'; |
|
1484 } |
|
1485 |
|
1486 if ( f.alt.value ) { |
|
1487 alt = f.alt.value.replace(/['"<>]+/g, ''); |
|
1488 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> |
|
1489 caption = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
|
1490 <?php } ?> |
|
1491 } |
|
1492 |
|
1493 cls = caption ? '' : ' class="'+t.align+'"'; |
|
1494 |
|
1495 html = '<img alt="'+alt+'" src="'+f.src.value+'"'+title+cls+' width="'+t.width+'" height="'+t.height+'" />'; |
|
1496 |
|
1497 if ( f.url.value ) |
|
1498 html = '<a href="'+f.url.value+'">'+html+'</a>'; |
|
1499 |
|
1500 if ( caption ) |
|
1501 html = '[caption id="" align="'+t.align+'" width="'+t.width+'" caption="'+caption+'"]'+html+'[/caption]'; |
|
1502 |
|
1503 var win = window.dialogArguments || opener || parent || top; |
|
1504 win.send_to_editor(html); |
|
1505 }, |
|
1506 |
|
1507 resetImageData : function() { |
|
1508 var t = addExtImage; |
|
1509 |
|
1510 t.width = t.height = ''; |
|
1511 document.getElementById('go_button').style.color = '#bbb'; |
|
1512 if ( ! document.forms[0].src.value ) |
|
1513 document.getElementById('status_img').src = 'images/required.gif'; |
|
1514 else document.getElementById('status_img').src = 'images/no.png'; |
|
1515 }, |
|
1516 |
|
1517 updateImageData : function() { |
|
1518 var t = addExtImage; |
|
1519 |
|
1520 t.width = t.preloadImg.width; |
|
1521 t.height = t.preloadImg.height; |
|
1522 document.getElementById('go_button').style.color = '#333'; |
|
1523 document.getElementById('status_img').src = 'images/yes.png'; |
|
1524 }, |
|
1525 |
|
1526 getImageData : function() { |
|
1527 var t = addExtImage, src = document.forms[0].src.value; |
|
1528 |
|
1529 if ( ! src ) { |
|
1530 t.resetImageData(); |
|
1531 return false; |
|
1532 } |
|
1533 document.getElementById('status_img').src = 'images/wpspin_light.gif'; |
|
1534 t.preloadImg = new Image(); |
|
1535 t.preloadImg.onload = t.updateImageData; |
|
1536 t.preloadImg.onerror = t.resetImageData; |
|
1537 t.preloadImg.src = src; |
|
1538 } |
|
1539 } |
|
1540 //]]> |
|
1541 </script> |
|
1542 |
|
1543 <div id="media-items"> |
|
1544 <div class="media-item media-blank"> |
|
1545 <?php echo apply_filters($callback, call_user_func($callback)); ?> |
|
1546 </div> |
|
1547 </div> |
|
1548 </form> |
|
1549 <?php |
|
1550 } else { |
|
1551 wp_die( __('Unknown action.') ); |
|
1552 } |
|
1553 } |
|
1554 |
|
1555 /** |
|
1556 * {@internal Missing Short Description}} |
|
1557 * |
|
1558 * @since unknown |
|
1559 * |
|
1560 * @param unknown_type $errors |
|
1561 */ |
|
1562 function media_upload_gallery_form($errors) { |
|
1563 global $redir_tab; |
|
1564 |
|
1565 $redir_tab = 'gallery'; |
|
1566 media_upload_header(); |
|
1567 |
|
1568 $post_id = intval($_REQUEST['post_id']); |
|
1569 $form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=gallery&post_id=$post_id"); |
|
1570 ?> |
|
1571 |
|
1572 <script type="text/javascript"> |
|
1573 <!-- |
|
1574 jQuery(function($){ |
|
1575 var preloaded = $(".media-item.preloaded"); |
|
1576 if ( preloaded.length > 0 ) { |
|
1577 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); |
|
1578 updateMediaForm(); |
|
1579 } |
|
1580 }); |
|
1581 --> |
|
1582 </script> |
|
1583 <div id="sort-buttons" class="hide-if-no-js"> |
|
1584 <span> |
|
1585 <?php _e('All Tabs:'); ?> |
|
1586 <a href="#" id="showall"><?php _e('Show'); ?></a> |
|
1587 <a href="#" id="hideall" style="display:none;"><?php _e('Hide'); ?></a> |
|
1588 </span> |
|
1589 <?php _e('Sort Order:'); ?> |
|
1590 <a href="#" id="asc"><?php _e('Ascending'); ?></a> | |
|
1591 <a href="#" id="desc"><?php _e('Descending'); ?></a> | |
|
1592 <a href="#" id="clear"><?php _e('Clear'); ?></a> |
|
1593 </div> |
|
1594 <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form validate" id="gallery-form"> |
|
1595 <?php wp_nonce_field('media-form'); ?> |
|
1596 <?php //media_upload_form( $errors ); ?> |
|
1597 <table class="widefat" cellspacing="0"> |
|
1598 <thead><tr> |
|
1599 <th><?php _e('Media'); ?></th> |
|
1600 <th class="order-head"><?php _e('Order'); ?></th> |
|
1601 </tr></thead> |
|
1602 </table> |
|
1603 <div id="media-items"> |
|
1604 <?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?> |
|
1605 <?php echo get_media_items($post_id, $errors); ?> |
|
1606 </div> |
|
1607 |
|
1608 <p class="ml-submit"> |
|
1609 <input type="submit" class="button savebutton" style="display:none;" name="save" id="save-all" value="<?php esc_attr_e( 'Save all changes' ); ?>" /> |
|
1610 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
|
1611 <input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" /> |
|
1612 <input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" /> |
|
1613 </p> |
|
1614 |
|
1615 <div id="gallery-settings" style="display:none;"> |
|
1616 <div class="title"><?php _e('Gallery Settings'); ?></div> |
|
1617 <table id="basic" class="describe"><tbody> |
|
1618 <tr> |
|
1619 <th scope="row" class="label"> |
|
1620 <label> |
|
1621 <span class="alignleft"><?php _e('Link thumbnails to:'); ?></span> |
|
1622 </label> |
|
1623 </th> |
|
1624 <td class="field"> |
|
1625 <input type="radio" name="linkto" id="linkto-file" value="file" /> |
|
1626 <label for="linkto-file" class="radio"><?php _e('Image File'); ?></label> |
|
1627 |
|
1628 <input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" /> |
|
1629 <label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label> |
|
1630 </td> |
|
1631 </tr> |
|
1632 |
|
1633 <tr> |
|
1634 <th scope="row" class="label"> |
|
1635 <label> |
|
1636 <span class="alignleft"><?php _e('Order images by:'); ?></span> |
|
1637 </label> |
|
1638 </th> |
|
1639 <td class="field"> |
|
1640 <select id="orderby" name="orderby"> |
|
1641 <option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option> |
|
1642 <option value="title"><?php _e('Title'); ?></option> |
|
1643 <option value="ID"><?php _e('Date/Time'); ?></option> |
|
1644 <option value="rand"><?php _e('Random'); ?></option> |
|
1645 </select> |
|
1646 </td> |
|
1647 </tr> |
|
1648 |
|
1649 <tr> |
|
1650 <th scope="row" class="label"> |
|
1651 <label> |
|
1652 <span class="alignleft"><?php _e('Order:'); ?></span> |
|
1653 </label> |
|
1654 </th> |
|
1655 <td class="field"> |
|
1656 <input type="radio" checked="checked" name="order" id="order-asc" value="asc" /> |
|
1657 <label for="order-asc" class="radio"><?php _e('Ascending'); ?></label> |
|
1658 |
|
1659 <input type="radio" name="order" id="order-desc" value="desc" /> |
|
1660 <label for="order-desc" class="radio"><?php _e('Descending'); ?></label> |
|
1661 </td> |
|
1662 </tr> |
|
1663 |
|
1664 <tr> |
|
1665 <th scope="row" class="label"> |
|
1666 <label> |
|
1667 <span class="alignleft"><?php _e('Gallery columns:'); ?></span> |
|
1668 </label> |
|
1669 </th> |
|
1670 <td class="field"> |
|
1671 <select id="columns" name="columns"> |
|
1672 <option value="2"><?php _e('2'); ?></option> |
|
1673 <option value="3" selected="selected"><?php _e('3'); ?></option> |
|
1674 <option value="4"><?php _e('4'); ?></option> |
|
1675 <option value="5"><?php _e('5'); ?></option> |
|
1676 <option value="6"><?php _e('6'); ?></option> |
|
1677 <option value="7"><?php _e('7'); ?></option> |
|
1678 <option value="8"><?php _e('8'); ?></option> |
|
1679 <option value="9"><?php _e('9'); ?></option> |
|
1680 </select> |
|
1681 </td> |
|
1682 </tr> |
|
1683 </tbody></table> |
|
1684 |
|
1685 <p class="ml-submit"> |
|
1686 <input type="button" class="button" style="display:none;" onmousedown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" /> |
|
1687 <input type="button" class="button" style="display:none;" onmousedown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" /> |
|
1688 </p> |
|
1689 </div> |
|
1690 </form> |
|
1691 <?php |
|
1692 } |
|
1693 |
|
1694 /** |
|
1695 * {@internal Missing Short Description}} |
|
1696 * |
|
1697 * @since unknown |
|
1698 * |
|
1699 * @param unknown_type $errors |
|
1700 */ |
|
1701 function media_upload_library_form($errors) { |
|
1702 global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types; |
|
1703 |
|
1704 media_upload_header(); |
|
1705 |
|
1706 $post_id = intval($_REQUEST['post_id']); |
|
1707 |
|
1708 $form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=library&post_id=$post_id"); |
|
1709 |
|
1710 $_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0; |
|
1711 if ( $_GET['paged'] < 1 ) |
|
1712 $_GET['paged'] = 1; |
|
1713 $start = ( $_GET['paged'] - 1 ) * 10; |
|
1714 if ( $start < 1 ) |
|
1715 $start = 0; |
|
1716 add_filter( 'post_limits', $limit_filter = create_function( '$a', "return 'LIMIT $start, 10';" ) ); |
|
1717 |
|
1718 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); |
|
1719 |
|
1720 ?> |
|
1721 |
|
1722 <form id="filter" action="" method="get"> |
|
1723 <input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" /> |
|
1724 <input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" /> |
|
1725 <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" /> |
|
1726 <input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" /> |
|
1727 |
|
1728 <p id="media-search" class="search-box"> |
|
1729 <label class="screen-reader-text" for="media-search-input"><?php _e('Search Media');?>:</label> |
|
1730 <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?>" /> |
|
1731 <input type="submit" value="<?php esc_attr_e( 'Search Media' ); ?>" class="button" /> |
|
1732 </p> |
|
1733 |
|
1734 <ul class="subsubsub"> |
|
1735 <?php |
|
1736 $type_links = array(); |
|
1737 $_num_posts = (array) wp_count_attachments(); |
|
1738 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); |
|
1739 foreach ( $matches as $_type => $reals ) |
|
1740 foreach ( $reals as $real ) |
|
1741 if ( isset($num_posts[$_type]) ) |
|
1742 $num_posts[$_type] += $_num_posts[$real]; |
|
1743 else |
|
1744 $num_posts[$_type] = $_num_posts[$real]; |
|
1745 // If available type specified by media button clicked, filter by that type |
|
1746 if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) { |
|
1747 $_GET['post_mime_type'] = $type; |
|
1748 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); |
|
1749 } |
|
1750 if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' ) |
|
1751 $class = ' class="current"'; |
|
1752 else |
|
1753 $class = ''; |
|
1754 $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))) . "'$class>".__('All Types')."</a>"; |
|
1755 foreach ( $post_mime_types as $mime_type => $label ) { |
|
1756 $class = ''; |
|
1757 |
|
1758 if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) |
|
1759 continue; |
|
1760 |
|
1761 if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) |
|
1762 $class = ' class="current"'; |
|
1763 |
|
1764 $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))) . "'$class>" . sprintf(_n($label[2][0], $label[2][1], $num_posts[$mime_type]), "<span id='$mime_type-counter'>" . number_format_i18n( $num_posts[$mime_type] ) . '</span>') . '</a>'; |
|
1765 } |
|
1766 echo implode(' | </li>', $type_links) . '</li>'; |
|
1767 unset($type_links); |
|
1768 ?> |
|
1769 </ul> |
|
1770 |
|
1771 <div class="tablenav"> |
|
1772 |
|
1773 <?php |
|
1774 $page_links = paginate_links( array( |
|
1775 'base' => add_query_arg( 'paged', '%#%' ), |
|
1776 'format' => '', |
|
1777 'prev_text' => __('«'), |
|
1778 'next_text' => __('»'), |
|
1779 'total' => ceil($wp_query->found_posts / 10), |
|
1780 'current' => $_GET['paged'] |
|
1781 )); |
|
1782 |
|
1783 if ( $page_links ) |
|
1784 echo "<div class='tablenav-pages'>$page_links</div>"; |
|
1785 ?> |
|
1786 |
|
1787 <div class="alignleft actions"> |
|
1788 <?php |
|
1789 |
|
1790 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; |
|
1791 |
|
1792 $arc_result = $wpdb->get_results( $arc_query ); |
|
1793 |
|
1794 $month_count = count($arc_result); |
|
1795 |
|
1796 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> |
|
1797 <select name='m'> |
|
1798 <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option> |
|
1799 <?php |
|
1800 foreach ($arc_result as $arc_row) { |
|
1801 if ( $arc_row->yyear == 0 ) |
|
1802 continue; |
|
1803 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); |
|
1804 |
|
1805 if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) |
|
1806 $default = ' selected="selected"'; |
|
1807 else |
|
1808 $default = ''; |
|
1809 |
|
1810 echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>"; |
|
1811 echo esc_html( $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear" ); |
|
1812 echo "</option>\n"; |
|
1813 } |
|
1814 ?> |
|
1815 </select> |
|
1816 <?php } ?> |
|
1817 |
|
1818 <input type="submit" id="post-query-submit" value="<?php echo esc_attr( __( 'Filter »' ) ); ?>" class="button-secondary" /> |
|
1819 |
|
1820 </div> |
|
1821 |
|
1822 <br class="clear" /> |
|
1823 </div> |
|
1824 </form> |
|
1825 |
|
1826 <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form validate" id="library-form"> |
|
1827 |
|
1828 <?php wp_nonce_field('media-form'); ?> |
|
1829 <?php //media_upload_form( $errors ); ?> |
|
1830 |
|
1831 <script type="text/javascript"> |
|
1832 <!-- |
|
1833 jQuery(function($){ |
|
1834 var preloaded = $(".media-item.preloaded"); |
|
1835 if ( preloaded.length > 0 ) { |
|
1836 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); |
|
1837 updateMediaForm(); |
|
1838 } |
|
1839 }); |
|
1840 --> |
|
1841 </script> |
|
1842 |
|
1843 <div id="media-items"> |
|
1844 <?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?> |
|
1845 <?php echo get_media_items(null, $errors); ?> |
|
1846 </div> |
|
1847 <p class="ml-submit"> |
|
1848 <input type="submit" class="button savebutton" name="save" value="<?php esc_attr_e( 'Save all changes' ); ?>" /> |
|
1849 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
|
1850 </p> |
|
1851 </form> |
|
1852 <?php |
|
1853 } |
|
1854 |
|
1855 /** |
|
1856 * {@internal Missing Short Description}} |
|
1857 * |
|
1858 * @since unknown |
|
1859 * |
|
1860 * @return unknown |
|
1861 */ |
|
1862 function type_url_form_image() { |
|
1863 |
|
1864 if ( apply_filters( 'disable_captions', '' ) ) { |
|
1865 $alt = __('Alternate Text'); |
|
1866 $alt_help = __('Alt text for the image, e.g. “The Mona Lisa”'); |
|
1867 } else { |
|
1868 $alt = __('Image Caption'); |
|
1869 $alt_help = __('Also used as alternate text for the image'); |
|
1870 } |
|
1871 |
|
1872 $default_align = get_option('image_default_align'); |
|
1873 if ( empty($default_align) ) |
|
1874 $default_align = 'none'; |
|
1875 |
|
1876 return ' |
|
1877 <table class="describe"><tbody> |
|
1878 <tr> |
|
1879 <th valign="top" scope="row" class="label" style="width:120px;"> |
|
1880 <span class="alignleft"><label for="src">' . __('Image URL') . '</label></span> |
|
1881 <span class="alignright"><img id="status_img" src="images/required.gif" title="required" alt="required" /></span> |
|
1882 </th> |
|
1883 <td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td> |
|
1884 </tr> |
|
1885 |
|
1886 <tr> |
|
1887 <th valign="top" scope="row" class="label"> |
|
1888 <span class="alignleft"><label for="title">' . __('Image Title') . '</label></span> |
|
1889 <span class="alignright"><abbr title="required" class="required">*</abbr></span> |
|
1890 </th> |
|
1891 <td class="field"><p><input id="title" name="title" value="" type="text" aria-required="true" /></p></td> |
|
1892 </tr> |
|
1893 |
|
1894 <tr> |
|
1895 <th valign="top" scope="row" class="label"> |
|
1896 <span class="alignleft"><label for="alt">' . $alt . '</label></span> |
|
1897 </th> |
|
1898 <td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" /> |
|
1899 <p class="help">' . $alt_help . '</p></td> |
|
1900 </tr> |
|
1901 |
|
1902 <tr class="align"> |
|
1903 <th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th> |
|
1904 <td class="field"> |
|
1905 <input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' /> |
|
1906 <label for="align-none" class="align image-align-none-label">' . __('None') . '</label> |
|
1907 <input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'left' ? ' checked="checked"' : '').' /> |
|
1908 <label for="align-left" class="align image-align-left-label">' . __('Left') . '</label> |
|
1909 <input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'center' ? ' checked="checked"' : '').' /> |
|
1910 <label for="align-center" class="align image-align-center-label">' . __('Center') . '</label> |
|
1911 <input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'right' ? ' checked="checked"' : '').' /> |
|
1912 <label for="align-right" class="align image-align-right-label">' . __('Right') . '</label> |
|
1913 </td> |
|
1914 </tr> |
|
1915 |
|
1916 <tr> |
|
1917 <th valign="top" scope="row" class="label"> |
|
1918 <span class="alignleft"><label for="url">' . __('Link Image To:') . '</label></span> |
|
1919 </th> |
|
1920 <td class="field"><input id="url" name="url" value="" type="text" /><br /> |
|
1921 |
|
1922 <button type="button" class="button" value="" onclick="document.forms[0].url.value=null">' . __('None') . '</button> |
|
1923 <button type="button" class="button" value="" onclick="document.forms[0].url.value=document.forms[0].src.value">' . __('Link to image') . '</button> |
|
1924 <p class="help">' . __('Enter a link URL or click above for presets.') . '</p></td> |
|
1925 </tr> |
|
1926 |
|
1927 <tr> |
|
1928 <td></td> |
|
1929 <td> |
|
1930 <input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" /> |
|
1931 </td> |
|
1932 </tr> |
|
1933 </tbody></table> |
|
1934 '; |
|
1935 |
|
1936 } |
|
1937 |
|
1938 /** |
|
1939 * {@internal Missing Short Description}} |
|
1940 * |
|
1941 * @since unknown |
|
1942 * |
|
1943 * @return unknown |
|
1944 */ |
|
1945 function type_url_form_audio() { |
|
1946 return ' |
|
1947 <table class="describe"><tbody> |
|
1948 <tr> |
|
1949 <th valign="top" scope="row" class="label"> |
|
1950 <span class="alignleft"><label for="insertonly[href]">' . __('Audio File URL') . '</label></span> |
|
1951 <span class="alignright"><abbr title="required" class="required">*</abbr></span> |
|
1952 </th> |
|
1953 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td> |
|
1954 </tr> |
|
1955 <tr> |
|
1956 <th valign="top" scope="row" class="label"> |
|
1957 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span> |
|
1958 <span class="alignright"><abbr title="required" class="required">*</abbr></span> |
|
1959 </th> |
|
1960 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td> |
|
1961 </tr> |
|
1962 <tr><td></td><td class="help">' . __('Link text, e.g. “Still Alive by Jonathan Coulton”') . '</td></tr> |
|
1963 <tr> |
|
1964 <td></td> |
|
1965 <td> |
|
1966 <input type="submit" class="button" name="insertonlybutton" value="' . esc_attr__('Insert into Post') . '" /> |
|
1967 </td> |
|
1968 </tr> |
|
1969 </tbody></table> |
|
1970 '; |
|
1971 } |
|
1972 |
|
1973 /** |
|
1974 * {@internal Missing Short Description}} |
|
1975 * |
|
1976 * @since unknown |
|
1977 * |
|
1978 * @return unknown |
|
1979 */ |
|
1980 function type_url_form_video() { |
|
1981 return ' |
|
1982 <table class="describe"><tbody> |
|
1983 <tr> |
|
1984 <th valign="top" scope="row" class="label"> |
|
1985 <span class="alignleft"><label for="insertonly[href]">' . __('Video URL') . '</label></span> |
|
1986 <span class="alignright"><abbr title="required" class="required">*</abbr></span> |
|
1987 </th> |
|
1988 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td> |
|
1989 </tr> |
|
1990 <tr> |
|
1991 <th valign="top" scope="row" class="label"> |
|
1992 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span> |
|
1993 <span class="alignright"><abbr title="required" class="required">*</abbr></span> |
|
1994 </th> |
|
1995 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td> |
|
1996 </tr> |
|
1997 <tr><td></td><td class="help">' . __('Link text, e.g. “Lucy on YouTube“') . '</td></tr> |
|
1998 <tr> |
|
1999 <td></td> |
|
2000 <td> |
|
2001 <input type="submit" class="button" name="insertonlybutton" value="' . esc_attr__('Insert into Post') . '" /> |
|
2002 </td> |
|
2003 </tr> |
|
2004 </tbody></table> |
|
2005 '; |
|
2006 } |
|
2007 |
|
2008 /** |
|
2009 * {@internal Missing Short Description}} |
|
2010 * |
|
2011 * @since unknown |
|
2012 * |
|
2013 * @return unknown |
|
2014 */ |
|
2015 function type_url_form_file() { |
|
2016 return ' |
|
2017 <table class="describe"><tbody> |
|
2018 <tr> |
|
2019 <th valign="top" scope="row" class="label"> |
|
2020 <span class="alignleft"><label for="insertonly[href]">' . __('URL') . '</label></span> |
|
2021 <span class="alignright"><abbr title="required" class="required">*</abbr></span> |
|
2022 </th> |
|
2023 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td> |
|
2024 </tr> |
|
2025 <tr> |
|
2026 <th valign="top" scope="row" class="label"> |
|
2027 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span> |
|
2028 <span class="alignright"><abbr title="required" class="required">*</abbr></span> |
|
2029 </th> |
|
2030 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td> |
|
2031 </tr> |
|
2032 <tr><td></td><td class="help">' . __('Link text, e.g. “Ransom Demands (PDF)”') . '</td></tr> |
|
2033 <tr> |
|
2034 <td></td> |
|
2035 <td> |
|
2036 <input type="submit" class="button" name="insertonlybutton" value="' . esc_attr__('Insert into Post') . '" /> |
|
2037 </td> |
|
2038 </tr> |
|
2039 </tbody></table> |
|
2040 '; |
|
2041 } |
|
2042 |
|
2043 /** |
|
2044 * {@internal Missing Short Description}} |
|
2045 * |
|
2046 * Support a GET parameter for disabling the flash uploader. |
|
2047 * |
|
2048 * @since unknown |
|
2049 * |
|
2050 * @param unknown_type $flash |
|
2051 * @return unknown |
|
2052 */ |
|
2053 function media_upload_use_flash($flash) { |
|
2054 if ( array_key_exists('flash', $_REQUEST) ) |
|
2055 $flash = !empty($_REQUEST['flash']); |
|
2056 return $flash; |
|
2057 } |
|
2058 |
|
2059 add_filter('flash_uploader', 'media_upload_use_flash'); |
|
2060 |
|
2061 /** |
|
2062 * {@internal Missing Short Description}} |
|
2063 * |
|
2064 * @since unknown |
|
2065 */ |
|
2066 function media_upload_flash_bypass() { |
|
2067 echo '<p class="upload-flash-bypass">'; |
|
2068 printf( __('You are using the Flash uploader. Problems? Try the <a href="%s">Browser uploader</a> instead.'), esc_url(add_query_arg('flash', 0)) ); |
|
2069 echo '</p>'; |
|
2070 } |
|
2071 |
|
2072 /** |
|
2073 * {@internal Missing Short Description}} |
|
2074 * |
|
2075 * @since unknown |
|
2076 */ |
|
2077 function media_upload_html_bypass($flash = true) { |
|
2078 echo '<p class="upload-html-bypass">'; |
|
2079 _e('You are using the Browser uploader.'); |
|
2080 if ( $flash ) { |
|
2081 // the user manually selected the browser uploader, so let them switch back to Flash |
|
2082 echo ' '; |
|
2083 printf( __('Try the <a href="%s">Flash uploader</a> instead.'), esc_url(add_query_arg('flash', 1)) ); |
|
2084 } |
|
2085 echo "</p>\n"; |
|
2086 } |
|
2087 |
|
2088 add_action('post-flash-upload-ui', 'media_upload_flash_bypass'); |
|
2089 add_action('post-html-upload-ui', 'media_upload_html_bypass'); |
|
2090 |
|
2091 /** |
|
2092 * {@internal Missing Short Description}} |
|
2093 * |
|
2094 * Make sure the GET parameter sticks when we submit a form. |
|
2095 * |
|
2096 * @since unknown |
|
2097 * |
|
2098 * @param unknown_type $url |
|
2099 * @return unknown |
|
2100 */ |
|
2101 function media_upload_bypass_url($url) { |
|
2102 if ( array_key_exists('flash', $_REQUEST) ) |
|
2103 $url = add_query_arg('flash', intval($_REQUEST['flash'])); |
|
2104 return $url; |
|
2105 } |
|
2106 |
|
2107 add_filter('media_upload_form_url', 'media_upload_bypass_url'); |
|
2108 |
|
2109 add_filter('async_upload_image', 'get_media_item', 10, 2); |
|
2110 add_filter('async_upload_audio', 'get_media_item', 10, 2); |
|
2111 add_filter('async_upload_video', 'get_media_item', 10, 2); |
|
2112 add_filter('async_upload_file', 'get_media_item', 10, 2); |
|
2113 |
|
2114 add_action('media_upload_image', 'media_upload_image'); |
|
2115 add_action('media_upload_audio', 'media_upload_audio'); |
|
2116 add_action('media_upload_video', 'media_upload_video'); |
|
2117 add_action('media_upload_file', 'media_upload_file'); |
|
2118 |
|
2119 add_filter('media_upload_gallery', 'media_upload_gallery'); |
|
2120 |
|
2121 add_filter('media_upload_library', 'media_upload_library'); |
|
2122 |
|
2123 ?> |