-
+ 0953054DF84F70FCBF637CC1E73EE1883C831889CEF2E626CDFFADCEBE360BDD0E3AC1EF058B5156447E471424B9CCED75BB7060334BE885EA5BB0AE6153B354mp-wp/wp-admin/includes/media.php(0 . 0)(1 . 2047)
34540 <?php
34541 /**
34542 * WordPress Administration Media API.
34543 *
34544 * @package WordPress
34545 * @subpackage Administration
34546 */
34547
34548 /**
34549 * {@internal Missing Short Description}}
34550 *
34551 * @since unknown
34552 *
34553 * @return unknown
34554 */
34555 function media_upload_tabs() {
34556 $_default_tabs = array(
34557 'type' => __('From Computer'), // handler action suffix => tab text
34558 'type_url' => __('From URL'),
34559 'gallery' => __('Gallery'),
34560 'library' => __('Media Library')
34561 );
34562
34563 return apply_filters('media_upload_tabs', $_default_tabs);
34564 }
34565
34566 /**
34567 * {@internal Missing Short Description}}
34568 *
34569 * @since unknown
34570 *
34571 * @param unknown_type $tabs
34572 * @return unknown
34573 */
34574 function update_gallery_tab($tabs) {
34575 global $wpdb;
34576
34577 if ( !isset($_REQUEST['post_id']) ) {
34578 unset($tabs['gallery']);
34579 return $tabs;
34580 }
34581
34582 if ( intval($_REQUEST['post_id']) )
34583 $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id'])));
34584
34585 if ( empty($attachments) ) {
34586 unset($tabs['gallery']);
34587 return $tabs;
34588 }
34589
34590 $tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>$attachments</span>");
34591
34592 return $tabs;
34593 }
34594 add_filter('media_upload_tabs', 'update_gallery_tab');
34595
34596 /**
34597 * {@internal Missing Short Description}}
34598 *
34599 * @since unknown
34600 */
34601 function the_media_upload_tabs() {
34602 global $redir_tab;
34603 $tabs = media_upload_tabs();
34604
34605 if ( !empty($tabs) ) {
34606 echo "<ul id='sidemenu'>\n";
34607 if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) )
34608 $current = $redir_tab;
34609 elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) )
34610 $current = $_GET['tab'];
34611 else {
34612 $keys = array_keys($tabs);
34613 $current = array_shift($keys);
34614 }
34615 foreach ( $tabs as $callback => $text ) {
34616 $class = '';
34617 if ( $current == $callback )
34618 $class = " class='current'";
34619 $href = add_query_arg(array('tab'=>$callback, 's'=>false, 'paged'=>false, 'post_mime_type'=>false, 'm'=>false));
34620 $link = "<a href='" . clean_url($href) . "'$class>$text</a>";
34621 echo "\t<li id='" . attribute_escape("tab-$callback") . "'>$link</li>\n";
34622 }
34623 echo "</ul>\n";
34624 }
34625 }
34626
34627 /**
34628 * {@internal Missing Short Description}}
34629 *
34630 * @since unknown
34631 *
34632 * @param unknown_type $id
34633 * @param unknown_type $alt
34634 * @param unknown_type $title
34635 * @param unknown_type $align
34636 * @param unknown_type $url
34637 * @param unknown_type $rel
34638 * @param unknown_type $size
34639 * @return unknown
34640 */
34641 function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') {
34642
34643 $htmlalt = ( empty($alt) ) ? $title : $alt;
34644
34645 $html = get_image_tag($id, $htmlalt, $title, $align, $size);
34646
34647 $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : '';
34648
34649 if ( $url )
34650 $html = '<a href="' . clean_url($url) . "\"$rel>$html</a>";
34651
34652 $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size );
34653
34654 return $html;
34655 }
34656
34657 /**
34658 * {@internal Missing Short Description}}
34659 *
34660 * @since unknown
34661 *
34662 * @param unknown_type $html
34663 * @param unknown_type $id
34664 * @param unknown_type $alt
34665 * @param unknown_type $title
34666 * @param unknown_type $align
34667 * @param unknown_type $url
34668 * @param unknown_type $size
34669 * @return unknown
34670 */
34671 function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) {
34672
34673 if ( empty($alt) || apply_filters( 'disable_captions', '' ) ) return $html;
34674 $id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
34675
34676 preg_match( '/width="([0-9]+)/', $html, $matches );
34677 if ( ! isset($matches[1]) ) return $html;
34678 $width = $matches[1];
34679
34680 $html = preg_replace( '/align[^\s\'"]+\s?/', '', $html );
34681 if ( empty($align) ) $align = 'none';
34682
34683 $alt = ! empty($alt) ? addslashes($alt) : '';
34684
34685 $shcode = '[caption id="' . $id . '" align="align' . $align
34686 . '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/caption]';
34687
34688 return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
34689 }
34690 add_filter( 'image_send_to_editor', 'image_add_caption', 20, 7 );
34691
34692 /**
34693 * {@internal Missing Short Description}}
34694 *
34695 * @since unknown
34696 *
34697 * @param unknown_type $html
34698 */
34699 function media_send_to_editor($html) {
34700 ?>
34701 <script type="text/javascript">
34702 /* <![CDATA[ */
34703 var win = window.dialogArguments || opener || parent || top;
34704 win.send_to_editor('<?php echo addslashes($html); ?>');
34705 /* ]]> */
34706 </script>
34707 <?php
34708 exit;
34709 }
34710
34711 /**
34712 * {@internal Missing Short Description}}
34713 *
34714 * This handles the file upload POST itself, creating the attachment post.
34715 *
34716 * @since unknown
34717 *
34718 * @param unknown_type $file_id
34719 * @param unknown_type $post_id
34720 * @param unknown_type $post_data
34721 * @return unknown
34722 */
34723 function media_handle_upload($file_id, $post_id, $post_data = array()) {
34724 $overrides = array('test_form'=>false);
34725
34726 $time = current_time('mysql');
34727 if ( $post = get_post($post_id) ) {
34728 if ( substr( $post->post_date, 0, 4 ) > 0 )
34729 $time = $post->post_date;
34730 }
34731
34732 $file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
34733
34734 if ( isset($file['error']) )
34735 return new WP_Error( 'upload_error', $file['error'] );
34736
34737 $url = $file['url'];
34738 $type = $file['type'];
34739 $file = $file['file'];
34740 $title = preg_replace('/\.[^.]+$/', '', basename($file));
34741 $content = '';
34742
34743 // use image exif/iptc data for title and caption defaults if possible
34744 if ( $image_meta = @wp_read_image_metadata($file) ) {
34745 if ( trim($image_meta['title']) )
34746 $title = $image_meta['title'];
34747 if ( trim($image_meta['caption']) )
34748 $content = $image_meta['caption'];
34749 }
34750
34751 // Construct the attachment array
34752 $attachment = array_merge( array(
34753 'post_mime_type' => $type,
34754 'guid' => $url,
34755 'post_parent' => $post_id,
34756 'post_title' => $title,
34757 'post_content' => $content,
34758 ), $post_data );
34759
34760 // Save the data
34761 $id = wp_insert_attachment($attachment, $file, $post_id);
34762 if ( !is_wp_error($id) ) {
34763 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
34764 }
34765
34766 return $id;
34767
34768 }
34769
34770 /**
34771 * {@internal Missing Short Description}}
34772 *
34773 * @since unknown
34774 *
34775 * @param unknown_type $file_array
34776 * @param unknown_type $post_id
34777 * @param unknown_type $desc
34778 * @param unknown_type $post_data
34779 * @return unknown
34780 */
34781 function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) {
34782 $overrides = array('test_form'=>false);
34783 $file = wp_handle_sideload($file_array, $overrides);
34784
34785 if ( isset($file['error']) )
34786 return new WP_Error( 'upload_error', $file['error'] );
34787
34788 $url = $file['url'];
34789 $type = $file['type'];
34790 $file = $file['file'];
34791 $title = preg_replace('/\.[^.]+$/', '', basename($file));
34792 $content = '';
34793
34794 // use image exif/iptc data for title and caption defaults if possible
34795 if ( $image_meta = @wp_read_image_metadata($file) ) {
34796 if ( trim($image_meta['title']) )
34797 $title = $image_meta['title'];
34798 if ( trim($image_meta['caption']) )
34799 $content = $image_meta['caption'];
34800 }
34801
34802 $title = @$desc;
34803
34804 // Construct the attachment array
34805 $attachment = array_merge( array(
34806 'post_mime_type' => $type,
34807 'guid' => $url,
34808 'post_parent' => $post_id,
34809 'post_title' => $title,
34810 'post_content' => $content,
34811 ), $post_data );
34812
34813 // Save the data
34814 $id = wp_insert_attachment($attachment, $file, $post_id);
34815 if ( !is_wp_error($id) ) {
34816 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
34817 return $url;
34818 }
34819 return $id;
34820 }
34821
34822 /**
34823 * {@internal Missing Short Description}}
34824 *
34825 * Wrap iframe content (produced by $content_func) in a doctype, html head/body
34826 * etc any additional function args will be passed to content_func.
34827 *
34828 * @since unknown
34829 *
34830 * @param unknown_type $content_func
34831 */
34832 function wp_iframe($content_func /* ... */) {
34833 ?>
34834 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
34835 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
34836 <head>
34837 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
34838 <title><?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — <?php _e('WordPress'); ?></title>
34839 <?php
34840 wp_enqueue_style( 'global' );
34841 wp_enqueue_style( 'wp-admin' );
34842 wp_enqueue_style( 'colors' );
34843 if ( 0 === strpos( $content_func, 'media' ) )
34844 wp_enqueue_style( 'media' );
34845
34846 ?>
34847 <script type="text/javascript">
34848 //<![CDATA[
34849 function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
34850 //]]>
34851 </script>
34852 <?php
34853 do_action('admin_print_styles');
34854 do_action('admin_print_scripts');
34855 do_action('admin_head');
34856 if ( is_string($content_func) )
34857 do_action( "admin_head_{$content_func}" );
34858 ?>
34859 </head>
34860 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
34861 <?php
34862 $args = func_get_args();
34863 $args = array_slice($args, 1);
34864 call_user_func_array($content_func, $args);
34865 ?>
34866 </body>
34867 </html>
34868 <?php
34869 }
34870
34871 /**
34872 * {@internal Missing Short Description}}
34873 *
34874 * @since unknown
34875 */
34876 function media_buttons() {
34877 global $post_ID, $temp_ID;
34878 $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
34879 $context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
34880 $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
34881 $media_title = __('Add Media');
34882 $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image");
34883 $image_title = __('Add an Image');
34884 $video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src&type=video");
34885 $video_title = __('Add Video');
34886 $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&type=audio");
34887 $audio_title = __('Add Audio');
34888 $out = <<<EOF
34889
34890 <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>
34891 <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>
34892 <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>
34893 <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>
34894
34895 EOF;
34896 printf($context, $out);
34897 }
34898 add_action( 'media_buttons', 'media_buttons' );
34899 add_action('media_upload_media', 'media_upload_handler');
34900
34901 /**
34902 * {@internal Missing Short Description}}
34903 *
34904 * @since unknown
34905 *
34906 * @return unknown
34907 */
34908 function media_upload_form_handler() {
34909 check_admin_referer('media-form');
34910
34911 if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
34912 $post = $_post = get_post($attachment_id, ARRAY_A);
34913 if ( isset($attachment['post_content']) )
34914 $post['post_content'] = $attachment['post_content'];
34915 if ( isset($attachment['post_title']) )
34916 $post['post_title'] = $attachment['post_title'];
34917 if ( isset($attachment['post_excerpt']) )
34918 $post['post_excerpt'] = $attachment['post_excerpt'];
34919 if ( isset($attachment['menu_order']) )
34920 $post['menu_order'] = $attachment['menu_order'];
34921 if ( isset($attachment['post_parent']) )
34922 $post['post_parent'] = $attachment['post_parent'];
34923
34924 $post = apply_filters('attachment_fields_to_save', $post, $attachment);
34925
34926 if ( isset($post['errors']) ) {
34927 $errors[$attachment_id] = $post['errors'];
34928 unset($post['errors']);
34929 }
34930
34931 if ( $post != $_post )
34932 wp_update_post($post);
34933
34934 foreach ( get_attachment_taxonomies($post) as $t )
34935 if ( isset($attachment[$t]) )
34936 wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
34937 }
34938
34939 if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
34940 <script type="text/javascript">
34941 /* <![CDATA[ */
34942 var win = window.dialogArguments || opener || parent || top;
34943 win.tb_remove();
34944 /* ]]> */
34945 </script>
34946 <?php
34947 exit;
34948 }
34949
34950 if ( isset($_POST['send']) ) {
34951 $keys = array_keys($_POST['send']);
34952 $send_id = (int) array_shift($keys);
34953 $attachment = stripslashes_deep( $_POST['attachments'][$send_id] );
34954 $html = $attachment['post_title'];
34955 if ( !empty($attachment['url']) ) {
34956 if ( strpos($attachment['url'], 'attachment_id') || false !== strpos($attachment['url'], get_permalink($_POST['post_id'])) )
34957 $rel = " rel='attachment wp-att-".attribute_escape($send_id)."'";
34958 $html = "<a href='{$attachment['url']}'$rel>$html</a>";
34959 }
34960 $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment);
34961 return media_send_to_editor($html);
34962 }
34963
34964 return $errors;
34965 }
34966
34967 /**
34968 * {@internal Missing Short Description}}
34969 *
34970 * @since unknown
34971 *
34972 * @return unknown
34973 */
34974 function media_upload_image() {
34975 $errors = array();
34976 $id = 0;
34977
34978 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
34979 // Upload File button was clicked
34980 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
34981 unset($_FILES);
34982 if ( is_wp_error($id) ) {
34983 $errors['upload_error'] = $id;
34984 $id = false;
34985 }
34986 }
34987
34988 if ( !empty($_POST['insertonlybutton']) ) {
34989 $src = $_POST['insertonly']['src'];
34990 if ( !empty($src) && !strpos($src, '://') )
34991 $src = "http://$src";
34992 $alt = attribute_escape($_POST['insertonly']['alt']);
34993 if ( isset($_POST['insertonly']['align']) ) {
34994 $align = attribute_escape($_POST['insertonly']['align']);
34995 $class = " class='align$align'";
34996 }
34997 if ( !empty($src) )
34998 $html = "<img src='$src' alt='$alt'$class />";
34999 return media_send_to_editor($html);
35000 }
35001
35002 if ( !empty($_POST) ) {
35003 $return = media_upload_form_handler();
35004
35005 if ( is_string($return) )
35006 return $return;
35007 if ( is_array($return) )
35008 $errors = $return;
35009 }
35010
35011 if ( isset($_POST['save']) ) {
35012 $errors['upload_notice'] = __('Saved.');
35013 return media_upload_gallery();
35014 }
35015
35016 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
35017 return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
35018
35019 return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
35020 }
35021
35022 /**
35023 * {@internal Missing Short Description}}
35024 *
35025 * @since unknown
35026 *
35027 * @param unknown_type $file
35028 * @param unknown_type $post_id
35029 * @param unknown_type $desc
35030 * @return unknown
35031 */
35032 function media_sideload_image($file, $post_id, $desc = null) {
35033 if (!empty($file) ) {
35034 $file_array['name'] = basename($file);
35035 $tmp = download_url($file);
35036 $file_array['tmp_name'] = $tmp;
35037 $desc = @$desc;
35038
35039 if ( is_wp_error($tmp) ) {
35040 @unlink($file_array['tmp_name']);
35041 $file_array['tmp_name'] = '';
35042 }
35043
35044 $id = media_handle_sideload($file_array, $post_id, $desc);
35045 $src = $id;
35046
35047 if ( is_wp_error($id) ) {
35048 @unlink($file_array['tmp_name']);
35049 return $id;
35050 }
35051 }
35052
35053 if ( !empty($src) ) {
35054 $alt = @$desc;
35055 $html = "<img src='$src' alt='$alt' />";
35056 return $html;
35057 }
35058 }
35059
35060 /**
35061 * {@internal Missing Short Description}}
35062 *
35063 * @since unknown
35064 *
35065 * @return unknown
35066 */
35067 function media_upload_audio() {
35068 $errors = array();
35069 $id = 0;
35070
35071 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
35072 // Upload File button was clicked
35073 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
35074 unset($_FILES);
35075 if ( is_wp_error($id) ) {
35076 $errors['upload_error'] = $id;
35077 $id = false;
35078 }
35079 }
35080
35081 if ( !empty($_POST['insertonlybutton']) ) {
35082 $href = $_POST['insertonly']['href'];
35083 if ( !empty($href) && !strpos($href, '://') )
35084 $href = "http://$href";
35085 $title = attribute_escape($_POST['insertonly']['title']);
35086 if ( empty($title) )
35087 $title = basename($href);
35088 if ( !empty($title) && !empty($href) )
35089 $html = "<a href='$href' >$title</a>";
35090 return media_send_to_editor($html);
35091 }
35092
35093 if ( !empty($_POST) ) {
35094 $return = media_upload_form_handler();
35095
35096 if ( is_string($return) )
35097 return $return;
35098 if ( is_array($return) )
35099 $errors = $return;
35100 }
35101
35102 if ( isset($_POST['save']) ) {
35103 $errors['upload_notice'] = __('Saved.');
35104 return media_upload_gallery();
35105 }
35106
35107 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
35108 return wp_iframe( 'media_upload_type_url_form', 'audio', $errors, $id );
35109
35110 return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id );
35111 }
35112
35113 /**
35114 * {@internal Missing Short Description}}
35115 *
35116 * @since unknown
35117 *
35118 * @return unknown
35119 */
35120 function media_upload_video() {
35121 $errors = array();
35122 $id = 0;
35123
35124 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
35125 // Upload File button was clicked
35126 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
35127 unset($_FILES);
35128 if ( is_wp_error($id) ) {
35129 $errors['upload_error'] = $id;
35130 $id = false;
35131 }
35132 }
35133
35134 if ( !empty($_POST['insertonlybutton']) ) {
35135 $href = $_POST['insertonly']['href'];
35136 if ( !empty($href) && !strpos($href, '://') )
35137 $href = "http://$href";
35138 $title = attribute_escape($_POST['insertonly']['title']);
35139 if ( empty($title) )
35140 $title = basename($href);
35141 if ( !empty($title) && !empty($href) )
35142 $html = "<a href='$href' >$title</a>";
35143 return media_send_to_editor($html);
35144 }
35145
35146 if ( !empty($_POST) ) {
35147 $return = media_upload_form_handler();
35148
35149 if ( is_string($return) )
35150 return $return;
35151 if ( is_array($return) )
35152 $errors = $return;
35153 }
35154
35155 if ( isset($_POST['save']) ) {
35156 $errors['upload_notice'] = __('Saved.');
35157 return media_upload_gallery();
35158 }
35159
35160 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
35161 return wp_iframe( 'media_upload_type_url_form', 'video', $errors, $id );
35162
35163 return wp_iframe( 'media_upload_type_form', 'video', $errors, $id );
35164 }
35165
35166 /**
35167 * {@internal Missing Short Description}}
35168 *
35169 * @since unknown
35170 *
35171 * @return unknown
35172 */
35173 function media_upload_file() {
35174 $errors = array();
35175 $id = 0;
35176
35177 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
35178 // Upload File button was clicked
35179 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
35180 unset($_FILES);
35181 if ( is_wp_error($id) ) {
35182 $errors['upload_error'] = $id;
35183 $id = false;
35184 }
35185 }
35186
35187 if ( !empty($_POST['insertonlybutton']) ) {
35188 $href = $_POST['insertonly']['href'];
35189 if ( !empty($href) && !strpos($href, '://') )
35190 $href = "http://$href";
35191 $title = attribute_escape($_POST['insertonly']['title']);
35192 if ( empty($title) )
35193 $title = basename($href);
35194 if ( !empty($title) && !empty($href) )
35195 $html = "<a href='$href' >$title</a>";
35196 return media_send_to_editor($html);
35197 }
35198
35199 if ( !empty($_POST) ) {
35200 $return = media_upload_form_handler();
35201
35202 if ( is_string($return) )
35203 return $return;
35204 if ( is_array($return) )
35205 $errors = $return;
35206 }
35207
35208 if ( isset($_POST['save']) ) {
35209 $errors['upload_notice'] = __('Saved.');
35210 return media_upload_gallery();
35211 }
35212
35213 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
35214 return wp_iframe( 'media_upload_type_url_form', 'file', $errors, $id );
35215
35216 return wp_iframe( 'media_upload_type_form', 'file', $errors, $id );
35217 }
35218
35219 /**
35220 * {@internal Missing Short Description}}
35221 *
35222 * @since unknown
35223 *
35224 * @return unknown
35225 */
35226 function media_upload_gallery() {
35227 $errors = array();
35228
35229 if ( !empty($_POST) ) {
35230 $return = media_upload_form_handler();
35231
35232 if ( is_string($return) )
35233 return $return;
35234 if ( is_array($return) )
35235 $errors = $return;
35236 }
35237
35238 wp_enqueue_script('admin-gallery');
35239 return wp_iframe( 'media_upload_gallery_form', $errors );
35240 }
35241
35242 /**
35243 * {@internal Missing Short Description}}
35244 *
35245 * @since unknown
35246 *
35247 * @return unknown
35248 */
35249 function media_upload_library() {
35250 $errors = array();
35251 if ( !empty($_POST) ) {
35252 $return = media_upload_form_handler();
35253
35254 if ( is_string($return) )
35255 return $return;
35256 if ( is_array($return) )
35257 $errors = $return;
35258 }
35259
35260 return wp_iframe( 'media_upload_library_form', $errors );
35261 }
35262
35263 /**
35264 * Retrieve HTML for the image alignment radio buttons with the specified one checked.
35265 *
35266 * @since unknown
35267 *
35268 * @param unknown_type $post
35269 * @param unknown_type $checked
35270 * @return unknown
35271 */
35272 function image_align_input_fields($post, $checked='') {
35273
35274 $alignments = array('none' => 'None', 'left' => 'Left', 'center' => 'Center', 'right' => 'Right');
35275 if ( !array_key_exists($checked, $alignments) )
35276 $checked = 'none';
35277
35278 $out = array();
35279 foreach ($alignments as $name => $label) {
35280
35281 $out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'".
35282 ( $checked == $name ? " checked='checked'" : "" ) .
35283 " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>" . __($label) . "</label>";
35284 }
35285 return join("\n", $out);
35286 }
35287
35288 /**
35289 * Retrieve HTML for the size radio buttons with the specified one checked.
35290 *
35291 * @since unknown
35292 *
35293 * @param unknown_type $post
35294 * @param unknown_type $checked
35295 * @return unknown
35296 */
35297 function image_size_input_fields($post, $checked='') {
35298
35299 // get a list of the actual pixel dimensions of each possible intermediate version of this image
35300 $size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full size'));
35301
35302 foreach ( $size_names as $size => $name) {
35303 $downsize = image_downsize($post->ID, $size);
35304
35305 // is this size selectable?
35306 $enabled = ( $downsize[3] || 'full' == $size );
35307 $css_id = "image-size-{$size}-{$post->ID}";
35308 // if this size is the default but that's not available, don't select it
35309 if ( $checked && !$enabled )
35310 $checked = '';
35311 // if $checked was not specified, default to the first available size that's bigger than a thumbnail
35312 if ( !$checked && $enabled && 'thumbnail' != $size )
35313 $checked = $size;
35314
35315 $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'" : '') ." />";
35316
35317 $html .= "<label for='{$css_id}'>" . __($name). "</label>";
35318 // only show the dimensions if that choice is available
35319 if ( $enabled )
35320 $html .= " <label for='{$css_id}' class='help'>" . sprintf( __("(%d × %d)"), $downsize[1], $downsize[2] ). "</label>";
35321
35322 $html .= '</div>';
35323
35324 $out[] = $html;
35325 }
35326
35327 return array(
35328 'label' => __('Size'),
35329 'input' => 'html',
35330 'html' => join("\n", $out),
35331 );
35332 }
35333
35334 /**
35335 * Retrieve HTML for the Link URL buttons with the default link type as specified.
35336 *
35337 * @since unknown
35338 *
35339 * @param unknown_type $post
35340 * @param unknown_type $url_type
35341 * @return unknown
35342 */
35343 function image_link_input_fields($post, $url_type='') {
35344
35345 $file = wp_get_attachment_url($post->ID);
35346 $link = get_attachment_link($post->ID);
35347
35348 $url = '';
35349 if ( $url_type == 'file' )
35350 $url = $file;
35351 elseif ( $url_type == 'post' )
35352 $url = $link;
35353
35354 return "<input type='text' class='urlfield' name='attachments[$post->ID][url]' value='" . attribute_escape($url) . "' /><br />
35355 <button type='button' class='button urlnone' title=''>" . __('None') . "</button>
35356 <button type='button' class='button urlfile' title='" . attribute_escape($file) . "'>" . __('File URL') . "</button>
35357 <button type='button' class='button urlpost' title='" . attribute_escape($link) . "'>" . __('Post URL') . "</button>
35358 ";
35359 }
35360
35361 /**
35362 * {@internal Missing Short Description}}
35363 *
35364 * @since unknown
35365 *
35366 * @param unknown_type $form_fields
35367 * @param unknown_type $post
35368 * @return unknown
35369 */
35370 function image_attachment_fields_to_edit($form_fields, $post) {
35371 if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
35372 $form_fields['post_title']['required'] = true;
35373
35374 $form_fields['post_excerpt']['label'] = __('Caption');
35375 $form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image');
35376
35377 $form_fields['post_content']['label'] = __('Description');
35378
35379 $form_fields['align'] = array(
35380 'label' => __('Alignment'),
35381 'input' => 'html',
35382 'html' => image_align_input_fields($post, get_option('image_default_align')),
35383 );
35384
35385 $form_fields['image-size'] = image_size_input_fields($post, get_option('image_default_size'));
35386 }
35387 return $form_fields;
35388 }
35389
35390 add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2);
35391
35392 /**
35393 * {@internal Missing Short Description}}
35394 *
35395 * @since unknown
35396 *
35397 * @param unknown_type $form_fields
35398 * @param unknown_type $post
35399 * @return unknown
35400 */
35401 function media_single_attachment_fields_to_edit( $form_fields, $post ) {
35402 unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']);
35403 return $form_fields;
35404 }
35405
35406 /**
35407 * {@internal Missing Short Description}}
35408 *
35409 * @since unknown
35410 *
35411 * @param unknown_type $post
35412 * @param unknown_type $attachment
35413 * @return unknown
35414 */
35415 function image_attachment_fields_to_save($post, $attachment) {
35416 if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {
35417 if ( strlen(trim($post['post_title'])) == 0 ) {
35418 $post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid']));
35419 $post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.');
35420 }
35421 }
35422
35423 return $post;
35424 }
35425
35426 add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2);
35427
35428 /**
35429 * {@internal Missing Short Description}}
35430 *
35431 * @since unknown
35432 *
35433 * @param unknown_type $html
35434 * @param unknown_type $attachment_id
35435 * @param unknown_type $attachment
35436 * @return unknown
35437 */
35438 function image_media_send_to_editor($html, $attachment_id, $attachment) {
35439 $post =& get_post($attachment_id);
35440 if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
35441 $url = $attachment['url'];
35442
35443 if ( isset($attachment['align']) )
35444 $align = $attachment['align'];
35445 else
35446 $align = 'none';
35447
35448 if ( !empty($attachment['image-size']) )
35449 $size = $attachment['image-size'];
35450 else
35451 $size = 'medium';
35452
35453 $rel = ( $url == get_attachment_link($attachment_id) );
35454
35455 return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size);
35456 }
35457
35458 return $html;
35459 }
35460
35461 add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3);
35462
35463 /**
35464 * {@internal Missing Short Description}}
35465 *
35466 * @since unknown
35467 *
35468 * @param unknown_type $post
35469 * @param unknown_type $errors
35470 * @return unknown
35471 */
35472 function get_attachment_fields_to_edit($post, $errors = null) {
35473 if ( is_int($post) )
35474 $post =& get_post($post);
35475 if ( is_array($post) )
35476 $post = (object) $post;
35477
35478 $edit_post = sanitize_post($post, 'edit');
35479
35480 $form_fields = array(
35481 'post_title' => array(
35482 'label' => __('Title'),
35483 'value' => $edit_post->post_title,
35484 ),
35485 'post_excerpt' => array(
35486 'label' => __('Caption'),
35487 'value' => $edit_post->post_excerpt,
35488 ),
35489 'post_content' => array(
35490 'label' => __('Description'),
35491 'value' => $edit_post->post_content,
35492 'input' => 'textarea',
35493 ),
35494 'url' => array(
35495 'label' => __('Link URL'),
35496 'input' => 'html',
35497 'html' => image_link_input_fields($post, get_option('image_default_link_type')),
35498 'helps' => __('Enter a link URL or click above for presets.'),
35499 ),
35500 'menu_order' => array(
35501 'label' => __('Order'),
35502 'value' => $edit_post->menu_order
35503 ),
35504 );
35505
35506 foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
35507 $t = (array) get_taxonomy($taxonomy);
35508 if ( empty($t['label']) )
35509 $t['label'] = $taxonomy;
35510 if ( empty($t['args']) )
35511 $t['args'] = array();
35512
35513 $terms = get_object_term_cache($post->ID, $taxonomy);
35514 if ( empty($terms) )
35515 $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']);
35516
35517 $values = array();
35518
35519 foreach ( $terms as $term )
35520 $values[] = $term->name;
35521 $t['value'] = join(', ', $values);
35522
35523 $form_fields[$taxonomy] = $t;
35524 }
35525
35526 // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default
35527 // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing )
35528 $form_fields = array_merge_recursive($form_fields, (array) $errors);
35529
35530 $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post);
35531
35532 return $form_fields;
35533 }
35534
35535 /**
35536 * Retrieve HTML for media items of post gallery.
35537 *
35538 * The HTML markup retrieved will be created for the progress of SWF Upload
35539 * component. Will also create link for showing and hiding the form to modify
35540 * the image attachment.
35541 *
35542 * @since unknown
35543 *
35544 * @param int $post_id Optional. Post ID.
35545 * @param array $errors Errors for attachment, if any.
35546 * @return string
35547 */
35548 function get_media_items( $post_id, $errors ) {
35549 if ( $post_id ) {
35550 $post = get_post($post_id);
35551 if ( $post && $post->post_type == 'attachment' )
35552 $attachments = array($post->ID => $post);
35553 else
35554 $attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') );
35555 } else {
35556 if ( is_array($GLOBALS['wp_the_query']->posts) )
35557 foreach ( $GLOBALS['wp_the_query']->posts as $attachment )
35558 $attachments[$attachment->ID] = $attachment;
35559 }
35560
35561 $output = '';
35562 foreach ( (array) $attachments as $id => $attachment )
35563 if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
35564 $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>";
35565
35566 return $output;
35567 }
35568
35569 /**
35570 * Retrieve HTML form for modifying the image attachment.
35571 *
35572 * @since unknown
35573 *
35574 * @param int $attachment_id Attachment ID for modification.
35575 * @param string|array $args Optional. Override defaults.
35576 * @return string HTML form for attachment.
35577 */
35578 function get_media_item( $attachment_id, $args = null ) {
35579 global $redir_tab;
35580
35581 $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true, 'show_title' => true );
35582 $args = wp_parse_args( $args, $default_args );
35583 extract( $args, EXTR_SKIP );
35584
35585 global $post_mime_types;
35586 if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
35587 $thumb_url = $thumb_url[0];
35588 else
35589 return false;
35590
35591 $toggle_on = __('Show');
35592 $toggle_off = __('Hide');
35593
35594 $post = get_post($attachment_id);
35595
35596 $filename = basename($post->guid);
35597 $title = attribute_escape($post->post_title);
35598
35599 if ( $_tags = get_the_tags($attachment_id) ) {
35600 foreach ( $_tags as $tag )
35601 $tags[] = $tag->name;
35602 $tags = attribute_escape(join(', ', $tags));
35603 }
35604
35605 $type = '';
35606 if ( isset($post_mime_types) ) {
35607 $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
35608 $type = array_shift($keys);
35609 $type = "<input type='hidden' id='type-of-$attachment_id' value='" . attribute_escape( $type ) . "' />";
35610 }
35611
35612 $form_fields = get_attachment_fields_to_edit($post, $errors);
35613
35614 if ( $toggle ) {
35615 $class = empty($errors) ? 'startclosed' : 'startopen';
35616 $toggle_links = "
35617 <a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
35618 <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
35619 } else {
35620 $class = 'form-table';
35621 $toggle_links = '';
35622 }
35623
35624 $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
35625 $display_title = $show_title ? "<div class='filename new'>" . wp_html_excerpt($display_title, 60) . "</div>" : '';
35626
35627 $gallery = ( (isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab']) || (isset($redir_tab) && 'gallery' == $redir_tab) ) ? true : false;
35628 $order = '';
35629
35630 foreach ( $form_fields as $key => $val ) {
35631 if ( 'menu_order' == $key ) {
35632 if ( $gallery )
35633 $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>';
35634 else
35635 $order = '<input type="hidden" name="attachments['.$attachment_id.'][menu_order]" value="'.$val['value'].'" />';
35636
35637 unset($form_fields['menu_order']);
35638 break;
35639 }
35640 }
35641
35642 $item = "
35643 $type
35644 $toggle_links
35645 $order
35646 $display_title
35647 <table class='slidetoggle describe $class'>
35648 <thead class='media-item-info'>
35649 <tr>
35650 <td class='A1B1' rowspan='4'><img class='thumbnail' src='$thumb_url' alt='' /></td>
35651 <td>$filename</td>
35652 </tr>
35653 <tr><td>$post->post_mime_type</td></tr>
35654 <tr><td>" . mysql2date($post->post_date, get_option('time_format')) . "</td></tr>
35655 <tr><td>" . apply_filters('media_meta', '', $post) . "</td></tr>
35656 </thead>
35657 <tbody>\n";
35658
35659 $defaults = array(
35660 'input' => 'text',
35661 'required' => false,
35662 'value' => '',
35663 'extra_rows' => array(),
35664 );
35665
35666 $delete_href = wp_nonce_url("post.php?action=delete-post&post=$attachment_id", 'delete-post_' . $attachment_id);
35667 if ( $send )
35668 $send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . attribute_escape( __( 'Insert into Post' ) ) . "' />";
35669 if ( $delete )
35670 $delete = "<a href=\"#\" class=\"del-link\" onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __('Delete') . "</a>";
35671 if ( ( $send || $delete ) && !isset($form_fields['buttons']) )
35672 $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete
35673 <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>
35674 <a href=\"#\" class=\"del-link\" onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a></div></td></tr>\n");
35675
35676 $hidden_fields = array();
35677
35678 foreach ( $form_fields as $id => $field ) {
35679 if ( $id{0} == '_' )
35680 continue;
35681
35682 if ( !empty($field['tr']) ) {
35683 $item .= $field['tr'];
35684 continue;
35685 }
35686
35687 $field = array_merge($defaults, $field);
35688 $name = "attachments[$attachment_id][$id]";
35689
35690 if ( $field['input'] == 'hidden' ) {
35691 $hidden_fields[$name] = $field['value'];
35692 continue;
35693 }
35694
35695 $required = $field['required'] ? '<abbr title="required" class="required">*</abbr>' : '';
35696 $aria_required = $field['required'] ? " aria-required='true' " : '';
35697 $class = $id;
35698 $class .= $field['required'] ? ' form-required' : '';
35699
35700 $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'>";
35701 if ( !empty($field[$field['input']]) )
35702 $item .= $field[$field['input']];
35703 elseif ( $field['input'] == 'textarea' ) {
35704 $item .= "<textarea type='text' id='$name' name='$name'" . $aria_required . ">" . htmlspecialchars( $field['value'] ) . "</textarea>";
35705 } else {
35706 $item .= "<input type='text' id='$name' name='$name' value='" . attribute_escape( $field['value'] ) . "'" . $aria_required . "/>";
35707 }
35708 if ( !empty($field['helps']) )
35709 $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique((array) $field['helps']) ) . '</p>';
35710 $item .= "</td>\n\t\t</tr>\n";
35711
35712 $extra_rows = array();
35713
35714 if ( !empty($field['errors']) )
35715 foreach ( array_unique((array) $field['errors']) as $error )
35716 $extra_rows['error'][] = $error;
35717
35718 if ( !empty($field['extra_rows']) )
35719 foreach ( $field['extra_rows'] as $class => $rows )
35720 foreach ( (array) $rows as $html )
35721 $extra_rows[$class][] = $html;
35722
35723 foreach ( $extra_rows as $class => $rows )
35724 foreach ( $rows as $html )
35725 $item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n";
35726 }
35727
35728 if ( !empty($form_fields['_final']) )
35729 $item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
35730 $item .= "\t</tbody>\n";
35731 $item .= "\t</table>\n";
35732
35733 foreach ( $hidden_fields as $name => $value )
35734 $item .= "\t<input type='hidden' name='$name' id='$name' value='" . attribute_escape( $value ) . "' />\n";
35735
35736 if ( $post->post_parent < 1 && (int) $_REQUEST['post_id'] ) {
35737 $parent = (int) $_REQUEST['post_id'];
35738 $parent_name = "attachments[$attachment_id][post_parent]";
35739
35740 $item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='" . $parent . "' />\n";
35741 }
35742
35743 return $item;
35744 }
35745
35746 /**
35747 * {@internal Missing Short Description}}
35748 *
35749 * @since unknown
35750 */
35751 function media_upload_header() {
35752 ?>
35753 <script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script>
35754 <div id="media-upload-header">
35755 <?php the_media_upload_tabs(); ?>
35756 </div>
35757 <?php
35758 }
35759
35760 /**
35761 * {@internal Missing Short Description}}
35762 *
35763 * @since unknown
35764 *
35765 * @param unknown_type $errors
35766 */
35767 function media_upload_form( $errors = null ) {
35768 global $type, $tab;
35769
35770 $flash_action_url = admin_url('async-upload.php');
35771
35772 // If Mac and mod_security, no Flash. :(
35773 $flash = true;
35774 if ( false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mac') && apache_mod_loaded('mod_security') )
35775 $flash = false;
35776
35777 $flash = apply_filters('flash_uploader', $flash);
35778 $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
35779
35780 ?>
35781 <div id="media-upload-notice">
35782 <?php if (isset($errors['upload_notice']) ) { ?>
35783 <?php echo $errors['upload_notice']; ?>
35784 <?php } ?>
35785 </div>
35786 <div id="media-upload-error">
35787 <?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { ?>
35788 <?php echo $errors['upload_error']->get_error_message(); ?>
35789 <?php } ?>
35790 </div>
35791
35792 <?php do_action('pre-upload-ui'); ?>
35793
35794 <?php if ( $flash ) : ?>
35795 <script type="text/javascript">
35796 <!--
35797 SWFUpload.onload = function() {
35798 swfu = new SWFUpload({
35799 button_text: '<span class="button"><?php _e('Select Files'); ?></span>',
35800 button_text_style: '.button { text-align: center; font-weight: bold; font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif; }',
35801 button_height: "24",
35802 button_width: "132",
35803 button_image_url: '<?php echo includes_url('images/upload.png'); ?>',
35804 button_placeholder_id: "flash-browse-button",
35805 upload_url : "<?php echo attribute_escape( $flash_action_url ); ?>",
35806 flash_url : "<?php echo includes_url('js/swfupload/swfupload.swf'); ?>",
35807 file_post_name: "async-upload",
35808 file_types: "<?php echo apply_filters('upload_file_glob', '*.*'); ?>",
35809 post_params : {
35810 "post_id" : "<?php echo $post_id; ?>",
35811 "auth_cookie" : "<?php if ( is_ssl() ) echo $_COOKIE[SECURE_AUTH_COOKIE]; else echo $_COOKIE[AUTH_COOKIE]; ?>",
35812 "_wpnonce" : "<?php echo wp_create_nonce('media-form'); ?>",
35813 "type" : "<?php echo $type; ?>",
35814 "tab" : "<?php echo $tab; ?>",
35815 "short" : "1"
35816 },
35817 file_size_limit : "<?php echo wp_max_upload_size(); ?>b",
35818 file_dialog_start_handler : fileDialogStart,
35819 file_queued_handler : fileQueued,
35820 upload_start_handler : uploadStart,
35821 upload_progress_handler : uploadProgress,
35822 upload_error_handler : uploadError,
35823 upload_success_handler : uploadSuccess,
35824 upload_complete_handler : uploadComplete,
35825 file_queue_error_handler : fileQueueError,
35826 file_dialog_complete_handler : fileDialogComplete,
35827 swfupload_pre_load_handler: swfuploadPreLoad,
35828 swfupload_load_failed_handler: swfuploadLoadFailed,
35829 custom_settings : {
35830 degraded_element_id : "html-upload-ui", // id of the element displayed when swfupload is unavailable
35831 swfupload_element_id : "flash-upload-ui" // id of the element displayed when swfupload is available
35832 },
35833 debug: false
35834 });
35835 };
35836 //-->
35837 </script>
35838
35839 <div id="flash-upload-ui">
35840 <?php do_action('pre-flash-upload-ui'); ?>
35841
35842 <div><?php _e( 'Choose files to upload' ); ?> <div id="flash-browse-button"></div></div>
35843 <?php do_action('post-flash-upload-ui'); ?>
35844 <p class="howto"><?php _e('After a file has been uploaded, you can add titles and descriptions.'); ?></p>
35845 </div>
35846
35847 <?php endif; // $flash ?>
35848
35849 <div id="html-upload-ui">
35850 <?php do_action('pre-html-upload-ui'); ?>
35851 <p id="async-upload-wrap">
35852 <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>
35853 </p>
35854
35855 <br class="clear" />
35856 <?php if ( is_lighttpd_before_150() ): ?>
35857 <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>
35858 <?php endif;?>
35859 <?php do_action('post-html-upload-ui'); ?>
35860 </div>
35861 <?php do_action('post-upload-ui'); ?>
35862 <?php
35863 }
35864
35865 /**
35866 * {@internal Missing Short Description}}
35867 *
35868 * @since unknown
35869 *
35870 * @param unknown_type $type
35871 * @param unknown_type $errors
35872 * @param unknown_type $id
35873 */
35874 function media_upload_type_form($type = 'file', $errors = null, $id = null) {
35875 media_upload_header();
35876
35877 $post_id = intval($_REQUEST['post_id']);
35878
35879 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
35880 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
35881 ?>
35882
35883 <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">
35884 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
35885 <?php wp_nonce_field('media-form'); ?>
35886
35887 <h3 class="media-title"><?php _e('Add media files from your computer'); ?></h3>
35888
35889 <?php media_upload_form( $errors ); ?>
35890
35891 <script type="text/javascript">
35892 <!--
35893 jQuery(function($){
35894 var preloaded = $(".media-item.preloaded");
35895 if ( preloaded.length > 0 ) {
35896 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
35897 }
35898 updateMediaForm();
35899 });
35900 -->
35901 </script>
35902 <div id="media-items">
35903 <?php
35904 if ( $id ) {
35905 if ( !is_wp_error($id) ) {
35906 echo get_media_items( $id, $errors );
35907 } else {
35908 echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
35909 exit;
35910 }
35911 }
35912 ?>
35913 </div>
35914 <input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
35915 <?php
35916 }
35917
35918 /**
35919 * {@internal Missing Short Description}}
35920 *
35921 * @since unknown
35922 *
35923 * @param unknown_type $type
35924 * @param unknown_type $errors
35925 * @param unknown_type $id
35926 */
35927 function media_upload_type_url_form($type = 'file', $errors = null, $id = null) {
35928 media_upload_header();
35929
35930 $post_id = intval($_REQUEST['post_id']);
35931
35932 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
35933 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
35934
35935 $callback = "type_url_form_$type";
35936 ?>
35937
35938 <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">
35939 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
35940 <?php wp_nonce_field('media-form'); ?>
35941
35942 <?php if ( is_callable($callback) ) { ?>
35943
35944 <h3 class="media-title"><?php _e('Add media file from URL'); ?></h3>
35945
35946 <script type="text/javascript">
35947 //<![CDATA[
35948 var addExtImage = {
35949
35950 width : '',
35951 height : '',
35952 align : 'alignnone',
35953
35954 insert : function() {
35955 var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = null;
35956
35957 if ( '' == f.src.value || '' == t.width ) return false;
35958
35959 if ( f.title.value ) {
35960 title = f.title.value.replace(/['"<>]+/g, '');
35961 title = ' title="'+title+'"';
35962 }
35963
35964 if ( f.alt.value ) {
35965 alt = f.alt.value.replace(/['"<>]+/g, '');
35966 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
35967 caption = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
35968 <?php } ?>
35969 }
35970
35971 cls = caption ? '' : ' class="'+t.align+'"';
35972
35973 html = '<img alt="'+alt+'" src="'+f.src.value+'"'+title+cls+' width="'+t.width+'" height="'+t.height+'" />';
35974
35975 if ( f.url.value )
35976 html = '<a href="'+f.url.value+'">'+html+'</a>';
35977
35978 if ( caption )
35979 html = '[caption id="" align="'+t.align+'" width="'+t.width+'" caption="'+caption+'"]'+html+'[/caption]';
35980
35981 var win = window.dialogArguments || opener || parent || top;
35982 win.send_to_editor(html);
35983 },
35984
35985 resetImageData : function() {
35986 var t = addExtImage;
35987
35988 t.width = t.height = '';
35989 document.getElementById('go_button').style.color = '#bbb';
35990 if ( ! document.forms[0].src.value )
35991 document.getElementById('status_img').src = 'images/required.gif';
35992 else document.getElementById('status_img').src = 'images/no.png';
35993 },
35994
35995 updateImageData : function() {
35996 var t = addExtImage;
35997
35998 t.width = t.preloadImg.width;
35999 t.height = t.preloadImg.height;
36000 document.getElementById('go_button').style.color = '#333';
36001 document.getElementById('status_img').src = 'images/yes.png';
36002 },
36003
36004 getImageData : function() {
36005 var t = addExtImage, src = document.forms[0].src.value;
36006
36007 if ( ! src ) {
36008 t.resetImageData();
36009 return false;
36010 }
36011 document.getElementById('status_img').src = 'images/loading.gif';
36012 t.preloadImg = new Image();
36013 t.preloadImg.onload = t.updateImageData;
36014 t.preloadImg.onerror = t.resetImageData;
36015 t.preloadImg.src = src;
36016 }
36017 }
36018 //]]>
36019 </script>
36020
36021 <div id="media-items">
36022 <div class="media-item media-blank">
36023 <?php echo call_user_func($callback); ?>
36024 </div>
36025 </div>
36026 </form>
36027 <?php
36028 } else {
36029 wp_die( __('Unknown action.') );
36030 }
36031 }
36032
36033 /**
36034 * {@internal Missing Short Description}}
36035 *
36036 * @since unknown
36037 *
36038 * @param unknown_type $errors
36039 */
36040 function media_upload_gallery_form($errors) {
36041 global $redir_tab;
36042
36043 $redir_tab = 'gallery';
36044 media_upload_header();
36045
36046 $post_id = intval($_REQUEST['post_id']);
36047 $form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=gallery&post_id=$post_id");
36048 ?>
36049
36050 <script type="text/javascript">
36051 <!--
36052 jQuery(function($){
36053 var preloaded = $(".media-item.preloaded");
36054 if ( preloaded.length > 0 ) {
36055 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
36056 updateMediaForm();
36057 }
36058 });
36059 -->
36060 </script>
36061
36062 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">
36063 <?php wp_nonce_field('media-form'); ?>
36064 <?php //media_upload_form( $errors ); ?>
36065 <table class="widefat" cellspacing="0">
36066 <thead><tr>
36067 <th><?php _e('Media'); ?></th>
36068 <th class="order-head"><?php _e('Order'); ?></th>
36069 </tr></thead>
36070 </table>
36071 <div id="media-items">
36072 <?php echo get_media_items($post_id, $errors); ?>
36073 </div>
36074
36075 <p class="ml-submit">
36076 <input type="submit" class="button savebutton" style="display:none;" name="save" id="save-all" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
36077 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
36078 <input type="hidden" name="type" value="<?php echo attribute_escape( $GLOBALS['type'] ); ?>" />
36079 <input type="hidden" name="tab" value="<?php echo attribute_escape( $GLOBALS['tab'] ); ?>" />
36080 </p>
36081
36082 <div id="gallery-settings" style="display:none;">
36083 <div class="title"><?php _e('Gallery Settings'); ?></div>
36084 <table id="basic" class="describe"><tbody>
36085 <tr>
36086 <th scope="row" class="label">
36087 <label>
36088 <span class="alignleft"><?php _e('Link thumbnails to:'); ?></span>
36089 </label>
36090 </th>
36091 <td class="field">
36092 <input type="radio" name="linkto" id="linkto-file" value="file" />
36093 <label for="linkto-file" class="radio"><?php _e('Image File'); ?></label>
36094
36095 <input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />
36096 <label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label>
36097 </td>
36098 </tr>
36099
36100 <tr>
36101 <th scope="row" class="label">
36102 <label>
36103 <span class="alignleft"><?php _e('Order images by:'); ?></span>
36104 </label>
36105 </th>
36106 <td class="field">
36107 <select id="orderby" name="orderby">
36108 <option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option>
36109 <option value="post_name"><?php _e('Name'); ?></option>
36110 <option value="ID"><?php _e('Date/Time'); ?></option>
36111 </select>
36112 </td>
36113 </tr>
36114
36115 <tr>
36116 <th scope="row" class="label">
36117 <label>
36118 <span class="alignleft"><?php _e('Order:'); ?></span>
36119 </label>
36120 </th>
36121 <td class="field">
36122 <input type="radio" checked="checked" name="order" id="order-asc" value="asc" />
36123 <label for="order-asc" class="radio"><?php _e('Ascending'); ?></label>
36124
36125 <input type="radio" name="order" id="order-desc" value="desc" />
36126 <label for="order-desc" class="radio"><?php _e('Descending'); ?></label>
36127 </td>
36128 </tr>
36129
36130 <tr>
36131 <th scope="row" class="label">
36132 <label>
36133 <span class="alignleft"><?php _e('Gallery columns:'); ?></span>
36134 </label>
36135 </th>
36136 <td class="field">
36137 <select id="columns" name="columns">
36138 <option value="2"><?php _e('2'); ?></option>
36139 <option value="3" selected="selected"><?php _e('3'); ?></option>
36140 <option value="4"><?php _e('4'); ?></option>
36141 <option value="5"><?php _e('5'); ?></option>
36142 <option value="6"><?php _e('6'); ?></option>
36143 <option value="7"><?php _e('7'); ?></option>
36144 <option value="8"><?php _e('8'); ?></option>
36145 <option value="9"><?php _e('9'); ?></option>
36146 </select>
36147 </td>
36148 </tr>
36149 </tbody></table>
36150
36151 <p class="ml-submit">
36152 <input type="button" class="button" style="display:none;" onmousedown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php echo attribute_escape( __( 'Insert gallery' ) ); ?>" />
36153 <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' ) ); ?>" />
36154 </p>
36155 </div>
36156 </form>
36157 <?php
36158 }
36159
36160 /**
36161 * {@internal Missing Short Description}}
36162 *
36163 * @since unknown
36164 *
36165 * @param unknown_type $errors
36166 */
36167 function media_upload_library_form($errors) {
36168 global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
36169
36170 media_upload_header();
36171
36172 $post_id = intval($_REQUEST['post_id']);
36173
36174 $form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=library&post_id=$post_id");
36175
36176 $_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0;
36177 if ( $_GET['paged'] < 1 )
36178 $_GET['paged'] = 1;
36179 $start = ( $_GET['paged'] - 1 ) * 10;
36180 if ( $start < 1 )
36181 $start = 0;
36182 add_filter( 'post_limits', $limit_filter = create_function( '$a', "return 'LIMIT $start, 10';" ) );
36183
36184 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
36185
36186 ?>
36187
36188 <form id="filter" action="" method="get">
36189 <input type="hidden" name="type" value="<?php echo attribute_escape( $type ); ?>" />
36190 <input type="hidden" name="tab" value="<?php echo attribute_escape( $tab ); ?>" />
36191 <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
36192 <input type="hidden" name="post_mime_type" value="<?php echo attribute_escape( $_GET['post_mime_type'] ); ?>" />
36193
36194 <p id="media-search" class="search-box">
36195 <label class="hidden" for="media-search-input"><?php _e('Search Media');?>:</label>
36196 <input type="text" id="media-search-input" class="search-input" name="s" value="<?php the_search_query(); ?>" />
36197 <input type="submit" value="<?php echo attribute_escape( __( 'Search Media' ) ); ?>" class="button" />
36198 </p>
36199
36200 <ul class="subsubsub">
36201 <?php
36202 $type_links = array();
36203 $_num_posts = (array) wp_count_attachments();
36204 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
36205 foreach ( $matches as $_type => $reals )
36206 foreach ( $reals as $real )
36207 $num_posts[$_type] += $_num_posts[$real];
36208 // If available type specified by media button clicked, filter by that type
36209 if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) {
36210 $_GET['post_mime_type'] = $type;
36211 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
36212 }
36213 if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' )
36214 $class = ' class="current"';
36215 $type_links[] = "<li><a href='" . clean_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))) . "'$class>".__('All Types')."</a>";
36216 foreach ( $post_mime_types as $mime_type => $label ) {
36217 $class = '';
36218
36219 if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
36220 continue;
36221
36222 if ( wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
36223 $class = ' class="current"';
36224
36225 $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>';
36226 }
36227 echo implode(' | </li>', $type_links) . '</li>';
36228 unset($type_links);
36229 ?>
36230 </ul>
36231
36232 <div class="tablenav">
36233
36234 <?php
36235 $page_links = paginate_links( array(
36236 'base' => add_query_arg( 'paged', '%#%' ),
36237 'format' => '',
36238 'prev_text' => __('«'),
36239 'next_text' => __('»'),
36240 'total' => ceil($wp_query->found_posts / 10),
36241 'current' => $_GET['paged']
36242 ));
36243
36244 if ( $page_links )
36245 echo "<div class='tablenav-pages'>$page_links</div>";
36246 ?>
36247
36248 <div class="alignleft actions">
36249 <?php
36250
36251 $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";
36252
36253 $arc_result = $wpdb->get_results( $arc_query );
36254
36255 $month_count = count($arc_result);
36256
36257 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>
36258 <select name='m'>
36259 <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
36260 <?php
36261 foreach ($arc_result as $arc_row) {
36262 if ( $arc_row->yyear == 0 )
36263 continue;
36264 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
36265
36266 if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] )
36267 $default = ' selected="selected"';
36268 else
36269 $default = '';
36270
36271 echo "<option$default value='" . attribute_escape( $arc_row->yyear . $arc_row->mmonth ) . "'>";
36272 echo wp_specialchars( $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear" );
36273 echo "</option>\n";
36274 }
36275 ?>
36276 </select>
36277 <?php } ?>
36278
36279 <input type="submit" id="post-query-submit" value="<?php echo attribute_escape( __( 'Filter »' ) ); ?>" class="button-secondary" />
36280
36281 </div>
36282
36283 <br class="clear" />
36284 </div>
36285 </form>
36286
36287 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="library-form">
36288
36289 <?php wp_nonce_field('media-form'); ?>
36290 <?php //media_upload_form( $errors ); ?>
36291
36292 <script type="text/javascript">
36293 <!--
36294 jQuery(function($){
36295 var preloaded = $(".media-item.preloaded");
36296 if ( preloaded.length > 0 ) {
36297 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
36298 updateMediaForm();
36299 }
36300 });
36301 -->
36302 </script>
36303
36304 <div id="media-items">
36305 <?php echo get_media_items(null, $errors); ?>
36306 </div>
36307 <p class="ml-submit">
36308 <input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
36309 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
36310 </p>
36311 </form>
36312 <?php
36313 }
36314
36315 /**
36316 * {@internal Missing Short Description}}
36317 *
36318 * @since unknown
36319 *
36320 * @return unknown
36321 */
36322 function type_url_form_image() {
36323
36324 if ( apply_filters( 'disable_captions', '' ) ) {
36325 $alt = __('Alternate Text');
36326 $alt_help = __('Alt text for the image, e.g. "The Mona Lisa"');
36327 } else {
36328 $alt = __('Image Caption');
36329 $alt_help = __('Also used as alternate text for the image');
36330 }
36331
36332 $default_align = get_option('image_default_align');
36333 if ( empty($default_align) )
36334 $default_align = 'none';
36335
36336 return '
36337 <table class="describe"><tbody>
36338 <tr>
36339 <th valign="top" scope="row" class="label" style="width:120px;">
36340 <span class="alignleft"><label for="src">' . __('Image URL') . '</label></span>
36341 <span class="alignright"><img id="status_img" src="images/required.gif" title="required" alt="required" /></span>
36342 </th>
36343 <td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td>
36344 </tr>
36345
36346 <tr>
36347 <th valign="top" scope="row" class="label">
36348 <span class="alignleft"><label for="title">' . __('Image Title') . '</label></span>
36349 <span class="alignright"><abbr title="required" class="required">*</abbr></span>
36350 </th>
36351 <td class="field"><p><input id="title" name="title" value="" type="text" aria-required="true" /></p></td>
36352 </tr>
36353
36354 <tr>
36355 <th valign="top" scope="row" class="label">
36356 <span class="alignleft"><label for="alt">' . $alt . '</label></span>
36357 </th>
36358 <td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
36359 <p class="help">' . $alt_help . '</p></td>
36360 </tr>
36361
36362 <tr class="align">
36363 <th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
36364 <td class="field">
36365 <input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' />
36366 <label for="align-none" class="align image-align-none-label">' . __('None') . '</label>
36367 <input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'left' ? ' checked="checked"' : '').' />
36368 <label for="align-left" class="align image-align-left-label">' . __('Left') . '</label>
36369 <input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'center' ? ' checked="checked"' : '').' />
36370 <label for="align-center" class="align image-align-center-label">' . __('Center') . '</label>
36371 <input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'right' ? ' checked="checked"' : '').' />
36372 <label for="align-right" class="align image-align-right-label">' . __('Right') . '</label>
36373 </td>
36374 </tr>
36375
36376 <tr>
36377 <th valign="top" scope="row" class="label">
36378 <span class="alignleft"><label for="url">' . __('Link Image To:') . '</label></span>
36379 </th>
36380 <td class="field"><input id="url" name="url" value="" type="text" /><br />
36381
36382 <button type="button" class="button" value="" onclick="document.forms[0].url.value=null">' . __('None') . '</button>
36383 <button type="button" class="button" value="" onclick="document.forms[0].url.value=document.forms[0].src.value">' . __('Link to image') . '</button>
36384 <p class="help">' . __('Enter a link URL or click above for presets.') . '</p></td>
36385 </tr>
36386
36387 <tr>
36388 <td></td>
36389 <td>
36390 <input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . attribute_escape(__('Insert into Post')) . '" />
36391 </td>
36392 </tr>
36393 </tbody></table>
36394 ';
36395
36396 }
36397
36398 /**
36399 * {@internal Missing Short Description}}
36400 *
36401 * @since unknown
36402 *
36403 * @return unknown
36404 */
36405 function type_url_form_audio() {
36406 return '
36407 <table class="describe"><tbody>
36408 <tr>
36409 <th valign="top" scope="row" class="label">
36410 <span class="alignleft"><label for="insertonly[href]">' . __('Audio File URL') . '</label></span>
36411 <span class="alignright"><abbr title="required" class="required">*</abbr></span>
36412 </th>
36413 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>
36414 </tr>
36415 <tr>
36416 <th valign="top" scope="row" class="label">
36417 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
36418 <span class="alignright"><abbr title="required" class="required">*</abbr></span>
36419 </th>
36420 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>
36421 </tr>
36422 <tr><td></td><td class="help">' . __('Link text, e.g. "Still Alive by Jonathan Coulton"') . '</td></tr>
36423 <tr>
36424 <td></td>
36425 <td>
36426 <input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
36427 </td>
36428 </tr>
36429 </tbody></table>
36430 ';
36431 }
36432
36433 /**
36434 * {@internal Missing Short Description}}
36435 *
36436 * @since unknown
36437 *
36438 * @return unknown
36439 */
36440 function type_url_form_video() {
36441 return '
36442 <table class="describe"><tbody>
36443 <tr>
36444 <th valign="top" scope="row" class="label">
36445 <span class="alignleft"><label for="insertonly[href]">' . __('Video URL') . '</label></span>
36446 <span class="alignright"><abbr title="required" class="required">*</abbr></span>
36447 </th>
36448 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>
36449 </tr>
36450 <tr>
36451 <th valign="top" scope="row" class="label">
36452 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
36453 <span class="alignright"><abbr title="required" class="required">*</abbr></span>
36454 </th>
36455 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>
36456 </tr>
36457 <tr><td></td><td class="help">' . __('Link text, e.g. "Lucy on YouTube"') . '</td></tr>
36458 <tr>
36459 <td></td>
36460 <td>
36461 <input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
36462 </td>
36463 </tr>
36464 </tbody></table>
36465 ';
36466 }
36467
36468 /**
36469 * {@internal Missing Short Description}}
36470 *
36471 * @since unknown
36472 *
36473 * @return unknown
36474 */
36475 function type_url_form_file() {
36476 return '
36477 <table class="describe"><tbody>
36478 <tr>
36479 <th valign="top" scope="row" class="label">
36480 <span class="alignleft"><label for="insertonly[href]">' . __('URL') . '</label></span>
36481 <span class="alignright"><abbr title="required" class="required">*</abbr></span>
36482 </th>
36483 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>
36484 </tr>
36485 <tr>
36486 <th valign="top" scope="row" class="label">
36487 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
36488 <span class="alignright"><abbr title="required" class="required">*</abbr></span>
36489 </th>
36490 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>
36491 </tr>
36492 <tr><td></td><td class="help">' . __('Link text, e.g. "Ransom Demands (PDF)"') . '</td></tr>
36493 <tr>
36494 <td></td>
36495 <td>
36496 <input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
36497 </td>
36498 </tr>
36499 </tbody></table>
36500 ';
36501 }
36502
36503 /**
36504 * {@internal Missing Short Description}}
36505 *
36506 * Support a GET parameter for disabling the flash uploader.
36507 *
36508 * @since unknown
36509 *
36510 * @param unknown_type $flash
36511 * @return unknown
36512 */
36513 function media_upload_use_flash($flash) {
36514 if ( array_key_exists('flash', $_REQUEST) )
36515 $flash = !empty($_REQUEST['flash']);
36516 return $flash;
36517 }
36518
36519 add_filter('flash_uploader', 'media_upload_use_flash');
36520
36521 /**
36522 * {@internal Missing Short Description}}
36523 *
36524 * @since unknown
36525 */
36526 function media_upload_flash_bypass() {
36527 echo '<p class="upload-flash-bypass">';
36528 printf( __('You are using the Flash uploader. Problems? Try the <a href="%s">Browser uploader</a> instead.'), clean_url(add_query_arg('flash', 0)) );
36529 echo '</p>';
36530 }
36531
36532 /**
36533 * {@internal Missing Short Description}}
36534 *
36535 * @since unknown
36536 */
36537 function media_upload_html_bypass() {
36538 echo '<p class="upload-html-bypass">';
36539 if ( array_key_exists('flash', $_REQUEST) )
36540 // the user manually selected the browser uploader, so let them switch back to Flash
36541 printf( __('You are using the Browser uploader. Try the <a href="%s">Flash uploader</a> instead.'), clean_url(add_query_arg('flash', 1)) );
36542 else
36543 // the user probably doesn't have Flash
36544 printf( __('You are using the Browser uploader.') );
36545
36546 echo '</p>';
36547 }
36548
36549 add_action('post-flash-upload-ui', 'media_upload_flash_bypass');
36550 add_action('post-html-upload-ui', 'media_upload_html_bypass');
36551
36552 /**
36553 * {@internal Missing Short Description}}
36554 *
36555 * Make sure the GET parameter sticks when we submit a form.
36556 *
36557 * @since unknown
36558 *
36559 * @param unknown_type $url
36560 * @return unknown
36561 */
36562 function media_upload_bypass_url($url) {
36563 if ( array_key_exists('flash', $_REQUEST) )
36564 $url = add_query_arg('flash', intval($_REQUEST['flash']));
36565 return $url;
36566 }
36567
36568 add_filter('media_upload_form_url', 'media_upload_bypass_url');
36569
36570
36571
36572 add_filter('async_upload_image', 'get_media_item', 10, 2);
36573 add_filter('async_upload_audio', 'get_media_item', 10, 2);
36574 add_filter('async_upload_video', 'get_media_item', 10, 2);
36575 add_filter('async_upload_file', 'get_media_item', 10, 2);
36576
36577 add_action('media_upload_image', 'media_upload_image');
36578 add_action('media_upload_audio', 'media_upload_audio');
36579 add_action('media_upload_video', 'media_upload_video');
36580 add_action('media_upload_file', 'media_upload_file');
36581
36582 add_filter('media_upload_gallery', 'media_upload_gallery');
36583
36584 add_filter('media_upload_library', 'media_upload_library');
36585
36586 ?>