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