Make WordPress Core

Ticket #3191: 3191.diff

File 3191.diff, 78.0 KB (added by mdawaffe, 18 years ago)
  • wp-includes/script-loader.php

     
    2929                        $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' );
    3030                        $this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '3684' );
    3131                        $this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
     32                        $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), mt_rand() );
    3233                }
    3334        }
    3435
  • wp-admin/inline-uploading.php

     
    1 <?php
    2 require_once('admin.php');
    3 @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    4 
    5 if (!current_user_can('upload_files'))
    6         wp_die(__('You do not have permission to upload files.'));
    7 
    8 wp_reset_vars(array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment'));
    9 
    10 $post = (int) $post;
    11 $images_width = 1;
    12 
    13 switch($action) {
    14 case 'links':
    15 // Do not pass GO.
    16 break;
    17 
    18 case 'delete':
    19 
    20 check_admin_referer('inlineuploading');
    21 
    22 if ( !current_user_can('edit_post', (int) $attachment) )
    23         wp_die(__('You are not allowed to delete this attachment.').' <a href="'.basename(__FILE__)."?post=$post&amp;all=$all&amp;action=upload\">".__('Go back').'</a>');
    24 
    25 wp_delete_attachment($attachment);
    26 
    27 wp_redirect(basename(__FILE__) ."?post=$post&all=$all&action=view&start=$start");
    28 die;
    29 
    30 case 'save':
    31 
    32 check_admin_referer('inlineuploading');
    33 
    34 $overrides = array('action'=>'save');
    35 
    36 $file = wp_handle_upload($_FILES['image'], $overrides);
    37 
    38 if ( isset($file['error']) )
    39         wp_die($file['error'] . '<br /><a href="' . basename(__FILE__) . '?action=upload&post=' . $post . '">'.__('Back to Image Uploading').'</a>');
    40 
    41 $url = $file['url'];
    42 $type = $file['type'];
    43 $file = $file['file'];
    44 $filename = basename($file);
    45 
    46 // Construct the attachment array
    47 $attachment = array(
    48         'post_title' => $imgtitle ? $imgtitle : $filename,
    49         'post_content' => $descr,
    50         'post_type' => 'attachment',
    51         'post_parent' => $post,
    52         'post_mime_type' => $type,
    53         'guid' => $url
    54         );
    55 
    56 // Save the data
    57 $id = wp_insert_attachment($attachment, $file, $post);
    58 
    59 if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
    60         // Generate the attachment's postmeta.
    61         $imagesize = getimagesize($file);
    62         $imagedata['width'] = $imagesize['0'];
    63         $imagedata['height'] = $imagesize['1'];
    64         list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
    65         $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
    66         $imagedata['file'] = $file;
    67 
    68         add_post_meta($id, '_wp_attachment_metadata', $imagedata);
    69 
    70         if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
    71                 if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
    72                         $thumb = wp_create_thumbnail($file, 128);
    73                 elseif ( $imagedata['height'] > 96 )
    74                         $thumb = wp_create_thumbnail($file, 96);
    75 
    76                 if ( @file_exists($thumb) ) {
    77                         $newdata = $imagedata;
    78                         $newdata['thumb'] = basename($thumb);
    79                         update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata);
    80                 } else {
    81                         $error = $thumb;
    82                 }
    83         }
    84 } else {
    85         add_post_meta($id, '_wp_attachment_metadata', array());
    86 }
    87 
    88 wp_redirect(basename(__FILE__) . "?post=$post&all=$all&action=view&start=0");
    89 die();
    90 
    91 case 'upload':
    92 
    93 $current_1 = ' class="current"';
    94 $back = $next = false;
    95 break;
    96 
    97 case 'view':
    98 
    99 // How many images do we show? How many do we query?
    100 $num = 5;
    101 $double = $num * 2;
    102 
    103 if ( $post && (empty($all) || $all == 'false') ) {
    104         $and_post = "AND post_parent = '$post'";
    105         $current_2 = ' class="current"';
    106 } else {
    107         $current_3 = ' class="current"';
    108 }
    109 
    110 if (! current_user_can('edit_others_posts') )
    111         $and_user = "AND post_author = " . $user_ID;
    112 
    113 if ( $last )
    114         $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment' $and_user $and_post") - $num;
    115 else
    116         $start = (int) $start;
    117 
    118 if ( $start < 0 )
    119         $start = 0;
    120 
    121 if ( '' == $sort )
    122         $sort = "post_date_gmt DESC";
    123 
    124 $attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_type = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
    125 
    126 if ( count($attachments) == 0 ) {
    127         wp_redirect( basename(__FILE__) ."?post=$post&action=upload" );
    128         die;
    129 } elseif ( count($attachments) > $num ) {
    130         $next = $start + count($attachments) - $num;
    131 } else {
    132         $next = false;
    133 }
    134 
    135 if ( $start > 0 ) {
    136         $back = $start - $num;
    137         if ( $back < 1 )
    138                 $back = '0';
    139 } else {
    140         $back = false;
    141 }
    142 
    143 $uwidth_sum = 0;
    144 $html = '';
    145 $popups = '';
    146 $style = '';
    147 $script = '';
    148 if ( count($attachments) > 0 ) {
    149         $attachments = array_slice( $attachments, 0, $num );
    150         $__delete = __('Delete');
    151         $__not_linked = __('Not Linked');
    152         $__linked_to_page = __('Linked to Page');
    153         $__linked_to_image = __('Linked to Image');
    154         $__linked_to_file = __('Linked to File');
    155         $__using_thumbnail = __('Using Thumbnail');
    156         $__using_original = __('Using Original');
    157         $__using_title = __('Using Title');
    158         $__using_filename = __('Using Filename');
    159         $__using_icon = __('Using Icon');
    160         $__no_thumbnail = '<del>'.__('No Thumbnail').'</del>';
    161         $__send_to_editor = __('Send to editor');
    162         $__close = __('Close Options');
    163         $__confirmdelete = __('Delete this file from the server?');
    164         $__nothumb = __('There is no thumbnail associated with this photo.');
    165         $script .= "notlinked = '$__not_linked';
    166 linkedtoimage = '$__linked_to_image';
    167 linkedtopage = '$__linked_to_page';
    168 linkedtofile = '$__linked_to_file';
    169 usingthumbnail = '$__using_thumbnail';
    170 usingoriginal = '$__using_original';
    171 usingtitle = '$__using_title';
    172 usingfilename = '$__using_filename';
    173 usingicon = '$__using_icon';
    174 var aa = new Array();
    175 var ab = new Array();
    176 var imga = new Array();
    177 var imgb = new Array();
    178 var srca = new Array();
    179 var srcb = new Array();
    180 var title = new Array();
    181 var filename = new Array();
    182 var icon = new Array();
    183 ";
    184         foreach ( $attachments as $key => $attachment ) {
    185                 $ID = $attachment['ID'];
    186                 $href = get_attachment_link($ID);
    187                 $meta = get_post_meta($ID, '_wp_attachment_metadata', true);
    188                 if (!is_array($meta)) {
    189                         $meta = get_post_meta($ID, 'imagedata', true); // Try 1.6 Alpha meta key
    190                         if (!is_array($meta)) {
    191                                 $meta = array();
    192                         }
    193                         add_post_meta($ID, '_wp_attachment_metadata', $meta);
    194                 }
    195                 $attachment = array_merge($attachment, $meta);
    196                 $noscript = "<noscript>
    197                 <div class='caption'><a href=\"".basename(__FILE__)."?action=links&amp;attachment={$ID}&amp;post={$post}&amp;all={$all}&amp;start={$start}\">Choose Links</a></div>
    198                 </noscript>
    199 ";
    200                 $send_delete_cancel = "<a onclick=\"sendToEditor({$ID});return false;\" href=\"javascript:void()\">$__send_to_editor</a>
    201 <a onclick=\"return confirm('$__confirmdelete')\" href=\"" . wp_nonce_url( basename(__FILE__) . "?action=delete&amp;attachment={$ID}&amp;all=$all&amp;start=$start&amp;post=$post", inlineuploading) . "\">$__delete</a>
    202                 <a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
    203 ";
    204                 $uwidth_sum += 128;
    205                 if ( preg_match('!^image/!', $attachment['post_mime_type'] ) ) {
    206                         $image = & $attachment;
    207                         if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) {
    208                                 $src = str_replace(basename($image['guid']), $image['thumb'], $image['guid']);
    209                                 $script .= "srca[{$ID}] = '$src';
    210 srcb[{$ID}] = '{$image['guid']}';
    211 ";
    212                                 $thumb = 'true';
    213                                 $thumbtext = $__using_thumbnail;
    214                         } else {
    215                                 $src = $image['guid'];
    216                                 $thumb = 'false';
    217                                 $thumbtext = $__no_thumbnail;
    218                         }
    219                         list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']);
    220                         $height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"';
    221                         $xpadding = (128 - $image['uwidth']) / 2;
    222                         $ypadding = (96 - $image['uheight']) / 2;
    223                         $style .= "#target{$ID} img { padding: {$ypadding}px {$xpadding}px; }\n";
    224                         $title = wp_specialchars($image['post_title'], ENT_QUOTES);
    225                         $script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" class=\"imagelink\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    226 ab[{$ID}] = '<a class=\"imagelink\" href=\"{$image['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    227 imga[{$ID}] = '<img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />';
    228 imgb[{$ID}] = '<img id=\"image{$ID}\" src=\"{$image['guid']}\" alt=\"{$title}\" $height_width />';
    229 ";
    230                         $html .= "<div id='target{$ID}' class='attwrap left'>
    231         <div id='div{$ID}' class='imagewrap' onclick=\"doPopup({$ID});\">
    232                 <img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />
    233         </div>
    234         {$noscript}
    235 </div>
    236 ";
    237                         $popups .= "<div id='popup{$ID}' class='popup'>
    238         <a id=\"I{$ID}\" onclick=\"if($thumb)toggleImage({$ID});else alert('$__nothumb');return false;\" href=\"javascript:void()\">$thumbtext</a>
    239         <a id=\"L{$ID}\" onclick=\"toggleLink({$ID});return false;\" href=\"javascript:void()\">$__not_linked</a>
    240         {$send_delete_cancel}
    241 </div>
    242 ";
    243                 } else {
    244                         $title = wp_specialchars($attachment['post_title'], ENT_QUOTES);
    245                         $filename = basename($attachment['guid']);
    246                         $icon = get_attachment_icon($ID);
    247                         $toggle_icon = "<a id=\"I{$ID}\" onclick=\"toggleOtherIcon({$ID});return false;\" href=\"javascript:void()\">$__using_title</a>";
    248                         $script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    249 ab[{$ID}] = '<a id=\"p{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    250 title[{$ID}] = '{$title}';
    251 filename[{$ID}] = '{$filename}';
    252 icon[{$ID}] = '{$icon}';
    253 ";
    254                         $html .= "<div id='target{$ID}' class='attwrap left'>
    255         <div id='div{$ID}' class='otherwrap usingtext' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">
    256                 <a id=\"p{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$title}</a>
    257         </div>
    258         {$noscript}
    259 </div>
    260 ";
    261                         $popups .= "<div id='popup{$ID}' class='popup'>
    262         <div class='filetype'>".__('File Type:').' '.str_replace('/',"/\n",$attachment['post_mime_type'])."</div>
    263         <a id=\"L{$ID}\" onclick=\"toggleOtherLink({$ID});return false;\" href=\"javascript:void()\">$__linked_to_file</a>
    264         {$toggle_icon}
    265         {$send_delete_cancel}
    266 </div>
    267 ";
    268                 }
    269         }
    270 }
    271 
    272 $images_width = $uwidth_sum + ( count($images) * 6 ) + 35;
    273 
    274 break;
    275 
    276 default:
    277         wp_die(__('This script was not meant to be called directly.'));
    278 }
    279 
    280 ?>
    281 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    282 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    283 <head>
    284 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
    285 <title></title>
    286 <meta http-equiv="imagetoolbar" content="no" />
    287 <script type="text/javascript">
    288 // <![CDATA[
    289 /* Define any variables we'll need, such as alternate URLs. */
    290 <?php echo $script; ?>
    291 function htmldecode(st) {
    292         o = document.getElementById('htmldecode');
    293         if (! o) {
    294                 o = document.createElement("A");
    295                 o.id = "htmldecode"
    296         }
    297         o.innerHTML = st;
    298         r = o.innerHTML;
    299         return r;
    300 }
    301 function cancelUpload() {
    302         o = document.getElementById('uploadForm');
    303         o.method = 'GET';
    304         o.action.value = 'view';
    305         o.submit();
    306 }
    307 function doPopup(i) {
    308         if ( popup )
    309         popup.style.display = 'none';
    310         target = document.getElementById('target'+i);
    311         popup = document.getElementById('popup'+i);
    312         popup.style.left = (target.offsetLeft) + 'px';
    313         popup.style.top = (target.offsetTop) + 'px';
    314         popup.style.display = 'block';
    315 }
    316 popup = false;
    317 function selectLink(n) {
    318         o=document.getElementById('div'+n);
    319         if ( typeof document.body.createTextRange == 'undefined' || typeof win.tinyMCE == 'undefined' || win.tinyMCE.configs.length < 1 )
    320                 return;
    321         r = document.body.createTextRange();
    322         if ( typeof r != 'undefined' ) {
    323                 r.moveToElementText(o);
    324                 r.select();
    325         }
    326 }
    327 function toggleLink(n) {
    328         ol=document.getElementById('L'+n);
    329         if ( ol.innerHTML == htmldecode(notlinked) ) {
    330                 ol.innerHTML = linkedtoimage;
    331         } else if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
    332                 ol.innerHTML = linkedtopage;
    333         } else {
    334                 ol.innerHTML = notlinked;
    335         }
    336         updateImage(n);
    337 }
    338 function toggleOtherLink(n) {
    339         ol=document.getElementById('L'+n);
    340         if ( ol.innerHTML == htmldecode(linkedtofile) ) {
    341                 ol.innerHTML = linkedtopage;
    342         } else {
    343                 ol.innerHTML = linkedtofile;
    344         }
    345         updateOtherIcon(n);
    346 }
    347 function toggleImage(n) {
    348         oi = document.getElementById('I'+n);
    349         if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
    350                 oi.innerHTML = usingoriginal;
    351         } else {
    352                 oi.innerHTML = usingthumbnail;
    353         }
    354         updateImage(n);
    355 }
    356 function toggleOtherIcon(n) {
    357         od = document.getElementById('div'+n);
    358         oi = document.getElementById('I'+n);
    359         if ( oi.innerHTML == htmldecode(usingtitle) ) {
    360                 oi.innerHTML = usingfilename;
    361                 od.className = 'otherwrap usingtext';
    362         } else if ( oi.innerHTML == htmldecode(usingfilename) && icon[n] != '' ) {
    363                 oi.innerHTML = usingicon;
    364                 od.className = 'otherwrap usingicon';
    365         } else {
    366                 oi.innerHTML = usingtitle;
    367                 od.className = 'otherwrap usingtext';
    368         }
    369         updateOtherIcon(n);
    370 }
    371 function updateImage(n) {
    372         od=document.getElementById('div'+n);
    373         ol=document.getElementById('L'+n);
    374         oi=document.getElementById('I'+n);
    375         if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
    376                 img = imga[n];
    377         } else {
    378                 img = imgb[n];
    379         }
    380         if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
    381                 od.innerHTML = ab[n]+img+'</a>';
    382         } else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
    383                 od.innerHTML = aa[n]+img+'</a>';
    384         } else {
    385                 od.innerHTML = img;
    386         }
    387 }
    388 function updateOtherIcon(n) {
    389         od=document.getElementById('div'+n);
    390         ol=document.getElementById('L'+n);
    391         oi=document.getElementById('I'+n);
    392         if ( oi.innerHTML == htmldecode(usingfilename) ) {
    393                 txt = filename[n];
    394         } else if ( oi.innerHTML == htmldecode(usingicon) ) {
    395                 txt = icon[n];
    396         } else {
    397                 txt = title[n];
    398         }
    399         if ( ol.innerHTML == htmldecode(linkedtofile) ) {
    400                 od.innerHTML = ab[n]+txt+'</a>';
    401         } else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
    402                 od.innerHTML = aa[n]+txt+'</a>';
    403         } else {
    404                 od.innerHTML = txt;
    405         }
    406 }
    407 
    408 var win = window.opener ? window.opener : window.dialogArguments;
    409 if (!win) win = top;
    410 tinyMCE = win.tinyMCE;
    411 function sendToEditor(n) {
    412         o = document.getElementById('div'+n);
    413         h = o.innerHTML.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // Trim
    414         h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)', 'g'), ' $1="$2"$3'); // Enclose attribs in quotes
    415         h = h.replace(new RegExp(' (width|height)=".*?"', 'g'), ''); // Drop size constraints
    416         h = h.replace(new RegExp(' on(click|mousedown)="[^"]*"', 'g'), ''); // Drop menu events
    417         h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames
    418         h = h.replace(new RegExp('<IMG', 'g'), '<img'); // Lowercase again
    419         h = h.replace(new RegExp('(<img .+?")>', 'g'), '$1 />'); // XHTML
    420         if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') )
    421                 win.tinyMCE.execCommand('mceInsertContent', false, h);
    422         else
    423                 win.edInsertContent(win.edCanvas, h);
    424 }
    425 // ]]>
    426 </script>
    427 <style type="text/css">
    428         <?php if ( $action == 'links' ) : ?>
    429         * html { overflow-x: hidden; }
    430         <?php else : ?>
    431         * html { overflow-y: hidden; }
    432         <?php endif; ?>
    433 
    434         body {
    435                 font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
    436                 border: none;
    437                 margin: 0px;
    438                 height: 150px;
    439                 background: #dfe8f1;
    440         }
    441 
    442         form { margin: 3px 2px 0px 6px; }
    443 
    444         #wrap {
    445                 clear: both;
    446                 padding: 0px;
    447                 width: 100%;
    448         }
    449 
    450         #images {
    451                 position: absolute;
    452                 clear: both;
    453                 margin: 0px;
    454                 padding: 15px 15px;
    455                 width: <?php echo $images_width; ?>px;
    456         }
    457 
    458         #images img { background-color: rgb(209, 226, 239); }
    459 
    460         <?php echo $style; ?>
    461 
    462         .attwrap, .attwrap * {
    463                 margin: 0px;
    464                 padding: 0px;
    465                 border: 0px;
    466         }
    467 
    468         .imagewrap {
    469                 margin-right: 5px;
    470                 overflow: hidden;
    471                 width: 128px;
    472         }
    473 
    474         .otherwrap {
    475                 margin-right: 5px;
    476                 overflow: hidden;
    477                 background-color: #f9fcfe;
    478         }
    479 
    480         .otherwrap a { display: block; }
    481 
    482         .otherwrap a, .otherwrap a:hover, .otherwrap a:active, .otherwrap a:visited { color: blue; }
    483 
    484         .usingicon {
    485                 padding: 0px;
    486                 height: 96px;
    487                 text-align: center;
    488                 width: 128px;
    489         }
    490 
    491         .usingtext {
    492                 padding: 3px;
    493                 height: 90px;
    494                 text-align: left;
    495                 width: 122px;
    496         }
    497 
    498         .filetype {
    499                 font-size: 80%;
    500                 border-bottom: 3px double #89a;
    501         }
    502 
    503         .imagewrap, .imagewrap img, .imagewrap a, .imagewrap a img, .imagewrap a:hover img, .imagewrap a:visited img, .imagewrap a:active img { text-decoration: none; }
    504 
    505         #upload-menu {
    506                 background: #fff;
    507                 margin: 0px;
    508                 padding: 0;
    509                 list-style: none;
    510                 height: 2em;
    511                 border-bottom: 1px solid #448abd;
    512                 width: 100%;
    513         }
    514 
    515         #upload-menu li {
    516                 float: left;
    517                 margin: 0 0 0 .75em;
    518         }
    519 
    520         #upload-menu a {
    521                 display: block;
    522                 padding: 5px;
    523                 text-decoration: none;
    524                 color: #000;
    525                 border-top: 3px solid #fff;
    526         }
    527 
    528         #upload-menu .current a {
    529                 background: #dfe8f1;
    530                 border-right: 2px solid #448abd;
    531         }
    532 
    533         #upload-menu a:hover {
    534                 background: #dfe8f1;
    535                 color: #000;
    536         }
    537 
    538         .tip {
    539                 color: rgb(68, 138, 189);
    540                 padding: 2px 1em;
    541         }
    542 
    543         .inactive {
    544                 color: #fff;
    545                 padding: 1px 3px;
    546         }
    547 
    548         .left { float: left; }
    549 
    550         .right { float: right; }
    551 
    552         .center { text-align: center; }
    553 
    554         #upload-menu li.spacer { margin-left: 40px; }
    555 
    556         #title, #descr {
    557                 width: 99%;
    558                 margin-top: 1px;
    559         }
    560 
    561         th {
    562                 text-align: right;
    563                 width: 4.5em;
    564         }
    565 
    566         #descr { height: 36px; }
    567 
    568         #buttons {
    569                 margin-top: 2px;
    570                 text-align: right;
    571         }
    572 
    573         .popup {
    574                 margin: 4px 4px;
    575                 padding: 1px;
    576                 position: absolute;
    577                 width: 114px;
    578                 display: none;
    579                 background-color: rgb(240, 240, 238);
    580                 border-top: 2px solid #fff;
    581                 border-right: 2px solid #ddd;
    582                 border-bottom: 2px solid #ddd;
    583                 border-left: 2px solid #fff;
    584                 text-align: center;
    585         }
    586 
    587         .imagewrap .popup {
    588                 opacity: .90;
    589                 filter:alpha(opacity=90);
    590         }
    591 
    592         .otherwrap .popup { padding-top: 20px; }
    593 
    594         .popup a, .popup a:visited, .popup a:active {
    595                 background-color: transparent;
    596                 display: block;
    597                 width: 100%;
    598                 text-decoration: none;
    599                 color: #246;
    600         }
    601 
    602         .popup a:hover {
    603                 background-color: #fff;
    604                 color: #000;
    605         }
    606 
    607         .caption { text-align: center; }
    608 
    609         #submit {
    610                 margin: 1px;
    611                 width: 99%;
    612         }
    613 
    614         #submit input, #submit input:focus {
    615                 background: url( images/fade-butt.png );
    616                 border: 3px double #999;
    617                 border-left-color: #ccc;
    618                 border-top-color: #ccc;
    619                 color: #333;
    620                 padding: 0.25em;
    621         }
    622 
    623         #submit input:active {
    624                 background: #f4f4f4;
    625                 border: 3px double #ccc;
    626                 border-left-color: #999;
    627                 border-top-color: #999;
    628         }
    629 
    630         .zerosize {
    631                 width: 0px;
    632                 height: 0px;
    633                 overflow: hidden;
    634                 position: absolute;
    635         }
    636 
    637         #links {
    638                 margin: 3px 8px;
    639                 line-height: 2em;
    640         }
    641 
    642         #links textarea {
    643                 width: 95%;
    644                 height: 4.5em;
    645         }
    646 </style>
    647 <?php if ( ('rtl' == $wp_locale->text_direction) ): ?>
    648 <style type="text/css">
    649         body { font: 13px Tahoma, "Lucida Grande", "Lucida Sans Unicode", Verdana; }
    650 
    651         .usingtext { text-align: right; }
    652 
    653         th { text-align: left; }
    654 
    655         .left, #upload-menu li { float: right; }
    656 
    657         .right { float: left; }
    658 
    659         .popup {
    660                 border-right: 2px solid #fff;
    661                 border-left: 2px solid #ddd;
    662         }
    663 
    664         #upload-menu .current a {
    665                 border-right: 0;
    666                 border-left: 2px solid #448abd;
    667         }
    668 
    669         #submit input, #submit input:focus {
    670                 border-left: 0;
    671                 border-right-color: #ccc;
    672         }
    673 
    674         #submit input:active {
    675                 border-left: 0;
    676                 border-right-color: #999;
    677         }
    678 </style>
    679 <?php endif; ?>
    680 </head>
    681 <body>
    682 <ul id="upload-menu">
    683         <li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__) . "?action=upload&amp;post=$post&amp;all=$all&amp;start=$start"; ?>"><?php _e('Upload'); ?></a></li>
    684 
    685         <?php if ( $attachments = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post'") ): ?>
    686                 <li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=false"; ?>"><?php _e('Browse'); ?></a></li>
    687         <?php endif; ?>
    688 
    689         <?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment'")): ?>
    690                 <li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=true"; ?>"><?php _e('Browse All'); ?></a></li>
    691         <?php endif; ?>
    692 
    693         <li> </li>
    694 
    695         <?php if ( $action == 'view' ): ?>
    696                 <?php if ( false !== $back ): ?>
    697                         <li class="spacer"><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=0"; ?>" title="<?php _e('First'); ?>">|&laquo;</a></li>
    698                         <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$back"; ?>">&laquo; <?php _e('Back'); ?></a></li>
    699                 <?php else: ?>
    700                         <li class="inactive spacer">|&laquo;</li>
    701                         <li class="inactive">&laquo; <?php _e('Back'); ?></li>
    702                 <?php endif; ?>
    703 
    704                 <?php if ( false !== $next ): ?>
    705                         <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$next"; ?>"><?php _e('Next &raquo;'); ?></a></li>
    706                         <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;last=true"; ?>" title="<?php _e('Last'); ?>">&raquo;|</a></li>
    707                 <?php else: ?>
    708                         <li class="inactive"><?php _e('Next &raquo;'); ?></li>
    709                         <li class="inactive">&raquo;|</li>
    710                 <?php endif; ?>
    711         <?php endif; ?>
    712 </ul>
    713 
    714 <?php if ( $action == 'view' ): ?>
    715         <div id="wrap">
    716                 <!--<div class="tip"><?php _e('You can drag and drop these items into your post. Click on one for more options.'); ?></div>-->
    717                 <div id="images">
    718                         <?php echo $html; ?>
    719                         <?php echo $popups; ?>
    720                 </div>
    721         </div>
    722 <?php elseif ( $action == 'upload' ): ?>
    723         <div class="tip"></div>
    724         <form enctype="multipart/form-data" id="uploadForm" method="post" action="<?php echo basename(__FILE__); ?>">
    725                 <table style="width: 99%">
    726                         <tr>
    727                                 <th scope="row"><label for="upload"><?php _e('File:'); ?></label></th>
    728                                 <td><input type="file" id="upload" name="image" /></td>
    729                         </tr>
    730                         <tr>
    731                                 <th scope="row"><label for="title"><?php _e('Title:'); ?></label></th>
    732                                 <td><input type="text" id="title" name="imgtitle" /></td>
    733                         </tr>
    734                         <tr>
    735                                 <th scope="row"><label for="descr"><?php _e('Description:'); ?></label></th>
    736                                 <td><input type="textarea" name="descr" id="descr" value="" /></td>
    737                         </tr>
    738                         <tr id="buttons">
    739                                 <th></th>
    740                                 <td>
    741                                         <input type="hidden" name="action" value="save" />
    742                                         <input type="hidden" name="post" value="<?php echo $post; ?>" />
    743                                         <input type="hidden" name="all" value="<?php echo $all; ?>" />
    744                                         <input type="hidden" name="start" value="<?php echo $start; ?>" />
    745                                         <?php wp_nonce_field( 'inlineuploading' ); ?>
    746                                         <div id="submit">
    747                                                 <input type="submit" value="<?php _e('Upload'); ?>" />
    748                                                 <?php if ( !empty($all) ): ?>
    749                                                         <input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
    750                                                 <?php endif; ?>
    751                                         </div>
    752                                 </td>
    753                         </tr>
    754                 </table>
    755         </form>
    756 <?php elseif ( $action == 'links' ): ?>
    757         <div id="links">
    758                 <?php the_attachment_links($attachment); ?>
    759         </div>
    760 <?php endif; ?>
    761 </body>
    762 </html>
    763  No newline at end of file
  • wp-admin/wp-admin.css

     
    186186        border-style: none;
    187187        padding: 0px;
    188188        margin-bottom: 16px;
    189         height: 15em;
     189        height: 16em;
    190190        width: 100%;
    191191/*      overflow-y: hidden;*/
    192192}
  • wp-admin/admin-functions.php

     
    19731973        $icon = get_attachment_icon($post->ID);
    19741974
    19751975?>
    1976 <p><?php _e('Text linked to file') ?><br />
    1977 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid) ?></a></textarea></p>
    1978 <p><?php _e('Text linked to subpost') ?><br />
    1979 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $post->post_title ?></a></textarea></p>
     1976<form id="the-attachment-links">
     1977<table>
     1978        <tr>
     1979                <th scope="row"><?php _e('Text linked to file') ?></th>
     1980                <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid) ?></a></textarea></td>
     1981        </tr>
     1982        <tr>
     1983                <th scope="row"><?php _e('Text linked to subpost') ?></th>
     1984                <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $post->post_title ?></a></textarea></td>
     1985        </tr>
    19801986<?php if ( $icon ) : ?>
    1981 <p><?php _e('Thumbnail linked to file') ?><br />
    1982 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo $icon ?></a></textarea></p>
    1983 <p><?php _e('Thumbnail linked to subpost') ?><br />
    1984 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $icon ?></a></textarea></p>
     1987        <tr>
     1988                <th scope="row"><?php _e('Thumbnail linked to file') ?></th>
     1989                <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo $icon ?></a></textarea></td>
     1990        </tr>
     1991        <tr>
     1992                <th scope="row"><?php _e('Thumbnail linked to subpost') ?></th>
     1993                <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $icon ?></a></textarea></td>
     1994        </tr>
    19851995<?php endif; ?>
     1996</table>
     1997</form>
    19861998<?php
    19871999}
    19882000
  • wp-admin/upload-js.php

     
     1<?php require_once('admin.php'); cache_javascript_headers(); ?>
     2addLoadEvent( function() {
     3        theFileList = {
     4                currentImage: {ID: 0},
     5                nonce: '',
     6                tab: '',
     7                postID: 0,
     8
     9                initializeVars: function() {
     10                        this.urlData  = document.location.href.split('?');
     11                        this.params = this.urlData[1].toQueryParams();
     12                        this.postID = this.params['post_id'];
     13                        this.tab = this.params['tab'];
     14                        this.style = this.params['style'];
     15                        this.ID = this.params['ID'];
     16                        if ( !this.style )
     17                                this.style = 'default';
     18                        var nonceEl = $('nonce-value');
     19                        if ( nonceEl )
     20                                this.nonce = nonceEl.value;
     21                        if ( this.ID ) {
     22                                this.grabImageData( this.ID );
     23                                this.imageView( this.ID );
     24                        }
     25                },
     26
     27                initializeLinks: function() {
     28                        if ( this.ID )
     29                                return;
     30                        $$('a.file-link').each( function(i) {
     31                                var id = i.id.split('-').pop();
     32                                i.onclick = function(e) { theFileList.imageView(id, e); }
     33                        } );
     34                },
     35
     36                grabImageData: function(id) {
     37                        if ( id == this.currentImage.ID )
     38                                return;
     39                        var thumbEl = $('attachment-thumb-url-' + id);
     40                        if ( thumbEl )
     41                                this.currentImage.thumb = ( 0 == id ? '' : thumbEl.value );
     42                        else
     43                                this.currentImage.thumb = false;
     44                        this.currentImage.src = ( 0 == id ? '' : $('attachment-url-' + id).value );
     45                        this.currentImage.page = ( 0 == id ? '' : $('attachment-page-url-' + id).value );
     46                        this.currentImage.title = ( 0 == id ? '' : $('attachment-title-' + id).value );
     47                        this.currentImage.description = ( 0 == id ? '' : $('attachment-description-' + id).value );
     48                        var widthEl = $('attachment-width-' + id);
     49                        if ( widthEl ) {
     50                                this.currentImage.width = ( 0 == id ? '' : widthEl.value );
     51                                this.currentImage.height = ( 0 == id ? '' : $('attachment-height-' + id).value );
     52                        } else {
     53                                this.currentImage.width = false;
     54                                this.currentImage.height = false;
     55                        }
     56                        this.currentImage.ID = id;
     57                },
     58
     59                imageView: function(id, e) {
     60                        this.prepView(id);
     61                        var h = '';
     62
     63                        h += "<div id='upload-file'>"
     64                        h += "<div id='file-title'>"
     65                        h += "<h2><a href='" + this.currentImage.src + "' title='Direct Link to this file'>" + this.currentImage.title + "</a></h2>";
     66                        h += "<span>[&nbsp";
     67                        h += "<a href='" + this.currentImage.page + "' title='Permalink to the blog page for this file'>page link</a>"
     68                        h += '&nbsp;|&nbsp;';
     69                        h += "<a href='#' onclick='theFileList.editView(" + id + ")'  title='Edit this file'>edit</a>"
     70                        h += '&nbsp;|&nbsp;';
     71                        if ( this.ID ) {
     72                                var params = $H(this.params);
     73                                params.ID = '';
     74                                params.action = '';
     75                                h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "'  title='Browse your files'>cancel</a>";
     76                        } else {
     77                                h += "<a href='#' onclick='theFileList.cancelView()'  title='Browse your files'>cancel</a>";
     78                        }
     79                        h += "&nbsp;]</span>";
     80                        h += '</div>'
     81                        h += "<div id='upload-file-view' class='left'>";
     82                        if ( this.currentImage.thumb )
     83                                h += "<img src='" + this.currentImage.thumb + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
     84                        else
     85                                h += '&nbsp;';
     86                        h += "</div>";
     87
     88                        h += "<form name='uploadoptions' id='uploadoptions' class='left'>";
     89                        if ( this.currentImage.thumb ) {
     90                                h += "<input type='radio' name='display' value='thumb' checked='checked'>Display thumbnail</input><br />";
     91                                h += "<input type='radio' name='display' value='full'>Display full-sized image</input><br /><br />";
     92                        }
     93
     94                        if ( this.currentImage.thumb ) {
     95                                h += "<input type='radio' name='link' value='none' checked='checked'>Do not link to this file</input><br />";
     96                                h += "<input type='radio' name='link' value='file'>Link directly to this file</input><br />";
     97                                h += "<input type='radio' name='link' value='page'>Link to this file's blog page</input><br />";
     98                        } else {
     99                                h += "<input type='radio' name='link' value='file'>Link directly to this file</input><br />";
     100                                h += "<input type='radio' name='link' value='page' checked='checked'>Link to this file's blog page</input><br />";
     101                        }
     102
     103                        h += "<input type='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='Send to editor' />";
     104                        h += "</form>";
     105
     106                        h += "</div>";
     107
     108                        new Insertion.Top('upload-content', h);
     109                        if (e) Event.stop(e);
     110                        return false;
     111                },
     112
     113                editView: function(id, e) {
     114                        this.prepView(id);
     115                        var h = '';
     116
     117                        h += "<form id='upload-file' method='post' action='upload.php?style=inline&amp;tab=upload&amp;post_id=" + this.postID + "'>";
     118                        h += "<div id='file-title'>"
     119                        h += "<h2><a href='" + this.currentImage.src + "' title='Direct Link to this file'>" + this.currentImage.title + "</a></h2>";
     120                        h += "<span>[&nbsp";
     121                        h += "<a href='" + this.currentImage.page + "' title='Permalink to the blog page for this file'>page link</a>"
     122                        h += '&nbsp;|&nbsp;';
     123                        h += "<a href='#' onclick='theFileList.imageView(" + id + ")'  title='View options for this file'>options</a>"
     124                        h += '&nbsp;|&nbsp;';
     125                        if ( this.ID ) {
     126                                var params = $H(this.params);
     127                                params.ID = '';
     128                                params.action = '';
     129                                h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "'  title='Browse your files'>cancel</a>";
     130                        } else {
     131                                h += "<a href='#' onclick='theFileList.cancelView()'  title='Browse your files'>cancel</a>";
     132                        }
     133                        h += "&nbsp;]</span>";
     134                        h += '</div>'
     135                        h += "<div id='upload-file-view' class='left'>";
     136                        if ( this.currentImage.thumb )
     137                                h += "<img src='" + this.currentImage.thumb + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
     138                        else
     139                                h += '&nbsp;';
     140                        h += "</div>";
     141
     142
     143                        h += "<table><tr>"
     144                        h += "<th scope='row'><label for='post_title'>Title:</label></th>";
     145                        h += "<td><input type='text' id='post_title' name='post_title' value='" + this.currentImage.title + "' /></td>";
     146                        h += "</tr><tr>";
     147                        h += "<th scope='row'><label for='post_content'>Description:</label></th>";
     148                        h += "<td><textarea name='post_content' id='post_content'>" + this.currentImage.description + "</textarea></td>";
     149                        h += "</tr><tr id='buttons'><th></th><td>";
     150                        h += "<input type='hidden' name='from_tab' value='" + this.tab + "' />";
     151                        h += "<input type='hidden' name='action' id='action-value' value='save' />";
     152                        h += "<input type='hidden' name='ID' value='" + id + "' />";
     153                        h += "<input type='hidden' name='_wpnonce' value='" + this.nonce + "' />";
     154                        h += "<div id='submit'><input type='submit' value='Save' />";
     155                        h += "<input type='button' name='delete' class='delete' value='Delete' onclick='theFileList.deleteFile(" + id + ");' />";
     156                        h += "</div></td></tr></table></form>";
     157
     158                        new Insertion.Top('upload-content', h);
     159                        if (e) Event.stop(e);
     160                        return false;           
     161                },
     162
     163                prepView: function(id) {
     164                        this.cancelView( true );
     165                        var filesEl = $('upload-files');
     166                        if ( filesEl )
     167                                filesEl.hide();
     168                        this.grabImageData(id);
     169                },
     170
     171                cancelView: function( prep ) {
     172                        if ( !prep ) {
     173                                var filesEl = $('upload-files');
     174                                if ( filesEl )
     175                                        filesEl.show();
     176                        }
     177                        if ( !this.ID )
     178                                this.grabImageData(0);
     179                        var div = $('upload-file');
     180                        if ( div )
     181                                div.remove();
     182                        return false;
     183                },
     184
     185                sendToEditor: function(id) {
     186                        this.grabImageData(id);
     187                        var link = '';
     188                        var display = '';
     189                        var h = '';
     190
     191                        link = $A(document.forms.uploadoptions.elements.link).detect( function(i) { return i.checked; } ).value;
     192                        displayEl = $A(document.forms.uploadoptions.elements.display).detect( function(i) { return i.checked; } )
     193                        if ( displayEl )
     194                                display = displayEl.value;
     195
     196                        if ( 'none' != link )
     197                                h += "<a href='" + ( 'file' == link ? this.currentImage.src : this.currentImage.page ) + "' title='" + this.currentImage.title + "'>";
     198                        if ( display )
     199                                h += "<img src='" + ( 'thumb' == display ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' />";
     200                        else
     201                                h += this.currentImage.title;
     202                        if ( 'none' != link )
     203                                h += "</a>";
     204
     205                        var win = window.opener ? window.opener : window.dialogArguments;
     206                        if ( !win )
     207                                win = top;
     208                        tinyMCE = win.tinyMCE;
     209                        if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') )
     210                                win.tinyMCE.execCommand('mceInsertContent', false, h);
     211                        else
     212                                win.edInsertContent(win.edCanvas, h);
     213                        this.cancelView();
     214                        return false;
     215                },
     216
     217                deleteFile: function(id) {
     218                        if ( confirm("Are you sure you want to delete the file '" + this.currentImage.title + "'?\nClick ok to delete or cancel to go back.") ) {
     219                                $('action-value').value = 'delete';
     220                                $('upload-file').submit();
     221                                return true;
     222                        }
     223                        return false;
     224                }
     225                       
     226        };
     227        theFileList.initializeVars();
     228        theFileList.initializeLinks();
     229} );
  • wp-admin/edit-page-form.php

     
    156156<?php
    157157if (current_user_can('upload_files')) {
    158158        $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
    159         $uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&amp;post=$uploading_iframe_ID", 'inlineuploading');
     159        $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
    160160        $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
    161161        if ( false != $uploading_iframe_src )
    162162                echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
  • wp-admin/upload-rtl.css

     
     1body { font: 13px Tahoma, "Lucida Grande", "Lucida Sans Unicode", Verdana; }
     2
     3#upload-menu li { margin: 0 .75em 0 0; }
     4
     5#upload-menu .current a {
     6        border-right: 0;
     7        border-left: 2px solid #448abd;
     8}
     9
     10#file-title { margin: 0 15px 0 0; }
     11
     12h2 { margin: 0 0 0 .2em; }
     13
     14#upload-files li { margin: 0 15px 15px 0; }
     15
     16th { text-align: right; }
     17
     18.left, table { float: right; }
     19
     20.right, #the-attachment-links { float: left; }
     21
     22#submit input, #submit input:focus {
     23        border-left: 0;
     24        border-right-color: #ccc;
     25}
     26
     27#submit input:active {
     28        border-left: 0;
     29        border-right-color: #999;
     30}
  • wp-admin/upload.php

     
    11<?php
    22require_once('admin.php');
     3
    34@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    45
    56if (!current_user_can('upload_files'))
    67        wp_die(__('You do not have permission to upload files.'));
    78
    8 wp_reset_vars(array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment'));
     9wp_reset_vars(array('action', 'tab', 'from_tab', 'style', 'post_id', 'ID', 'paged', 'post_title', 'post_content', 'delete'));
    910
    10 $post = (int) $post;
    11 $images_width = 1;
     11require_once('upload-functions.php');
     12if ( !$tab )
     13        $tab = 'browse-all';
    1214
    13 switch($action) {
    14 case 'links':
    15 // Do not pass GO.
    16 break;
     15do_action( "upload_files_$tab" );
    1716
    18 case 'delete':
     17add_action( 'admin_head', 'wp_upload_admin_head' );
    1918
    20 check_admin_referer('inlineuploading');
     19$pid = 0;
     20if ( $post_id < 0 )
     21        $pid = $post_id;
     22elseif ( get_post( $post_id ) )
     23        $pid = $post_id;
     24$wp_upload_tabs = array();
     25$all_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'");
     26$post_atts = 0;
     27if ( $pid ) {
     28        $wp_upload_tabs['upload'] = array(__('Upload'), 'upload_files', 'wp_upload_tab_upload');
     29        if ( $all_atts && $post_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$post_id'") )
     30                $wp_upload_tabs['browse'] = array(__('Browse'), 'upload_files', "wp_upload_tab_browse");
     31        if ( $post_atts < $all_atts )
     32                $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse');
     33} else
     34        $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse');
    2135
    22 if ( !current_user_can('edit_post', (int) $attachment) )
    23         wp_die(__('You are not allowed to delete this attachment.').' <a href="'.basename(__FILE__)."?post=$post&amp;all=$all&amp;action=upload\">".__('Go back').'</a>');
     36        $wp_upload_tabs = array_merge($wp_upload_tabs, apply_filters( 'wp_upload_tabs', array() ));
    2437
    25 wp_delete_attachment($attachment);
    26 
    27 wp_redirect(basename(__FILE__) ."?post=$post&all=$all&action=view&start=$start");
    28 die;
    29 
    30 case 'save':
    31 
    32 check_admin_referer('inlineuploading');
    33 
    34 $overrides = array('action'=>'save');
    35 
    36 $file = wp_handle_upload($_FILES['image'], $overrides);
    37 
    38 if ( isset($file['error']) )
    39         wp_die($file['error'] . '<br /><a href="' . basename(__FILE__) . '?action=upload&post=' . $post . '">'.__('Back to Image Uploading').'</a>');
    40 
    41 $url = $file['url'];
    42 $type = $file['type'];
    43 $file = $file['file'];
    44 $filename = basename($file);
    45 
    46 // Construct the attachment array
    47 $attachment = array(
    48         'post_title' => $imgtitle ? $imgtitle : $filename,
    49         'post_content' => $descr,
    50         'post_type' => 'attachment',
    51         'post_parent' => $post,
    52         'post_mime_type' => $type,
    53         'guid' => $url
    54         );
    55 
    56 // Save the data
    57 $id = wp_insert_attachment($attachment, $file, $post);
    58 
    59 if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
    60         // Generate the attachment's postmeta.
    61         $imagesize = getimagesize($file);
    62         $imagedata['width'] = $imagesize['0'];
    63         $imagedata['height'] = $imagesize['1'];
    64         list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
    65         $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
    66         $imagedata['file'] = $file;
    67 
    68         add_post_meta($id, '_wp_attachment_metadata', $imagedata);
    69 
    70         if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
    71                 if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
    72                         $thumb = wp_create_thumbnail($file, 128);
    73                 elseif ( $imagedata['height'] > 96 )
    74                         $thumb = wp_create_thumbnail($file, 96);
    75 
    76                 if ( @file_exists($thumb) ) {
    77                         $newdata = $imagedata;
    78                         $newdata['thumb'] = basename($thumb);
    79                         update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata);
    80                 } else {
    81                         $error = $thumb;
    82                 }
    83         }
    84 } else {
    85         add_post_meta($id, '_wp_attachment_metadata', array());
     38if ( !function_exists($wp_upload_tabs[$tab][2]) ) {
     39        $to_tab = isset($wp_upload_tabs['upload']) ? 'upload' : 'browse-all';
     40        wp_redirect( add_query_arg( 'tab', $to_tab ) );
     41        exit;
    8642}
    8743
    88 wp_redirect(basename(__FILE__) . "?post=$post&all=$all&action=view&start=0");
    89 die();
    90 
    91 case 'upload':
    92 
    93 $current_1 = ' class="current"';
    94 $back = $next = false;
    95 break;
    96 
    97 case 'view':
    98 
    99 // How many images do we show? How many do we query?
    100 $num = 5;
    101 $double = $num * 2;
    102 
    103 if ( $post && (empty($all) || $all == 'false') ) {
    104         $and_post = "AND post_parent = '$post'";
    105         $current_2 = ' class="current"';
    106 } else {
    107         $current_3 = ' class="current"';
    108 }
    109 
    110 if (! current_user_can('edit_others_posts') )
    111         $and_user = "AND post_author = " . $user_ID;
    112 
    113 if ( $last )
    114         $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment' $and_user $and_post") - $num;
    115 else
    116         $start = (int) $start;
    117 
    118 if ( $start < 0 )
    119         $start = 0;
    120 
    121 if ( '' == $sort )
    122         $sort = "post_date_gmt DESC";
    123 
    124 $attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_type = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
    125 
    126 if ( count($attachments) == 0 ) {
    127         wp_redirect( basename(__FILE__) ."?post=$post&action=upload" );
    128         die;
    129 } elseif ( count($attachments) > $num ) {
    130         $next = $start + count($attachments) - $num;
    131 } else {
    132         $next = false;
    133 }
    134 
    135 if ( $start > 0 ) {
    136         $back = $start - $num;
    137         if ( $back < 1 )
    138                 $back = '0';
    139 } else {
    140         $back = false;
    141 }
    142 
    143 $uwidth_sum = 0;
    144 $html = '';
    145 $popups = '';
    146 $style = '';
    147 $script = '';
    148 if ( count($attachments) > 0 ) {
    149         $attachments = array_slice( $attachments, 0, $num );
    150         $__delete = __('Delete');
    151         $__not_linked = __('Not Linked');
    152         $__linked_to_page = __('Linked to Page');
    153         $__linked_to_image = __('Linked to Image');
    154         $__linked_to_file = __('Linked to File');
    155         $__using_thumbnail = __('Using Thumbnail');
    156         $__using_original = __('Using Original');
    157         $__using_title = __('Using Title');
    158         $__using_filename = __('Using Filename');
    159         $__using_icon = __('Using Icon');
    160         $__no_thumbnail = '<del>'.__('No Thumbnail').'</del>';
    161         $__send_to_editor = __('Send to editor');
    162         $__close = __('Close Options');
    163         $__confirmdelete = __('Delete this file from the server?');
    164         $__nothumb = __('There is no thumbnail associated with this photo.');
    165         $script .= "notlinked = '$__not_linked';
    166 linkedtoimage = '$__linked_to_image';
    167 linkedtopage = '$__linked_to_page';
    168 linkedtofile = '$__linked_to_file';
    169 usingthumbnail = '$__using_thumbnail';
    170 usingoriginal = '$__using_original';
    171 usingtitle = '$__using_title';
    172 usingfilename = '$__using_filename';
    173 usingicon = '$__using_icon';
    174 var aa = new Array();
    175 var ab = new Array();
    176 var imga = new Array();
    177 var imgb = new Array();
    178 var srca = new Array();
    179 var srcb = new Array();
    180 var title = new Array();
    181 var filename = new Array();
    182 var icon = new Array();
    183 ";
    184         foreach ( $attachments as $key => $attachment ) {
    185                 $ID = $attachment['ID'];
    186                 $href = get_attachment_link($ID);
    187                 $meta = get_post_meta($ID, '_wp_attachment_metadata', true);
    188                 if (!is_array($meta)) {
    189                         $meta = get_post_meta($ID, 'imagedata', true); // Try 1.6 Alpha meta key
    190                         if (!is_array($meta)) {
    191                                 $meta = array();
    192                         }
    193                         add_post_meta($ID, '_wp_attachment_metadata', $meta);
    194                 }
    195                 $attachment = array_merge($attachment, $meta);
    196                 $noscript = "<noscript>
    197                 <div class='caption'><a href=\"".basename(__FILE__)."?action=links&amp;attachment={$ID}&amp;post={$post}&amp;all={$all}&amp;start={$start}\">Choose Links</a></div>
    198                 </noscript>
    199 ";
    200                 $send_delete_cancel = "<a onclick=\"sendToEditor({$ID});return false;\" href=\"javascript:void()\">$__send_to_editor</a>
    201 <a onclick=\"return confirm('$__confirmdelete')\" href=\"" . wp_nonce_url( basename(__FILE__) . "?action=delete&amp;attachment={$ID}&amp;all=$all&amp;start=$start&amp;post=$post", inlineuploading) . "\">$__delete</a>
    202                 <a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
    203 ";
    204                 $uwidth_sum += 128;
    205                 if ( preg_match('!^image/!', $attachment['post_mime_type'] ) ) {
    206                         $image = & $attachment;
    207                         if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) {
    208                                 $src = str_replace(basename($image['guid']), $image['thumb'], $image['guid']);
    209                                 $script .= "srca[{$ID}] = '$src';
    210 srcb[{$ID}] = '{$image['guid']}';
    211 ";
    212                                 $thumb = 'true';
    213                                 $thumbtext = $__using_thumbnail;
    214                         } else {
    215                                 $src = $image['guid'];
    216                                 $thumb = 'false';
    217                                 $thumbtext = $__no_thumbnail;
    218                         }
    219                         list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']);
    220                         $height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"';
    221                         $xpadding = (128 - $image['uwidth']) / 2;
    222                         $ypadding = (96 - $image['uheight']) / 2;
    223                         $style .= "#target{$ID} img { padding: {$ypadding}px {$xpadding}px; }\n";
    224                         $title = wp_specialchars($image['post_title'], ENT_QUOTES);
    225                         $script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" class=\"imagelink\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    226 ab[{$ID}] = '<a class=\"imagelink\" href=\"{$image['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    227 imga[{$ID}] = '<img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />';
    228 imgb[{$ID}] = '<img id=\"image{$ID}\" src=\"{$image['guid']}\" alt=\"{$title}\" $height_width />';
    229 ";
    230                         $html .= "<div id='target{$ID}' class='attwrap left'>
    231         <div id='div{$ID}' class='imagewrap' onclick=\"doPopup({$ID});\">
    232                 <img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />
    233         </div>
    234         {$noscript}
    235 </div>
    236 ";
    237                         $popups .= "<div id='popup{$ID}' class='popup'>
    238         <a id=\"I{$ID}\" onclick=\"if($thumb)toggleImage({$ID});else alert('$__nothumb');return false;\" href=\"javascript:void()\">$thumbtext</a>
    239         <a id=\"L{$ID}\" onclick=\"toggleLink({$ID});return false;\" href=\"javascript:void()\">$__not_linked</a>
    240         {$send_delete_cancel}
    241 </div>
    242 ";
    243                 } else {
    244                         $title = wp_specialchars($attachment['post_title'], ENT_QUOTES);
    245                         $filename = basename($attachment['guid']);
    246                         $icon = get_attachment_icon($ID);
    247                         $toggle_icon = "<a id=\"I{$ID}\" onclick=\"toggleOtherIcon({$ID});return false;\" href=\"javascript:void()\">$__using_title</a>";
    248                         $script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    249 ab[{$ID}] = '<a id=\"p{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    250 title[{$ID}] = '{$title}';
    251 filename[{$ID}] = '{$filename}';
    252 icon[{$ID}] = '{$icon}';
    253 ";
    254                         $html .= "<div id='target{$ID}' class='attwrap left'>
    255         <div id='div{$ID}' class='otherwrap usingtext' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">
    256                 <a id=\"p{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$title}</a>
    257         </div>
    258         {$noscript}
    259 </div>
    260 ";
    261                         $popups .= "<div id='popup{$ID}' class='popup'>
    262         <div class='filetype'>".__('File Type:').' '.str_replace('/',"/\n",$attachment['post_mime_type'])."</div>
    263         <a id=\"L{$ID}\" onclick=\"toggleOtherLink({$ID});return false;\" href=\"javascript:void()\">$__linked_to_file</a>
    264         {$toggle_icon}
    265         {$send_delete_cancel}
    266 </div>
    267 ";
    268                 }
     44foreach ( $wp_upload_tabs as $t => $tab_array ) {
     45        if ( !current_user_can( $tab_array[1] ) ) {
     46                unset($wp_upload_tabs[$t]);
     47                if ( $tab == $t )
     48                        wp_die(__("You are not allowed to be here"));
    26949        }
    27050}
    27151
    272 $images_width = $uwidth_sum + ( count($images) * 6 ) + 35;
     52include_once('admin-header.php');
    27353
    274 break;
    275 
    276 default:
    277         wp_die(__('This script was not meant to be called directly.'));
     54echo "<ul id='upload-menu'>\n";
     55foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check
     56        $class = 'upload-tab';
     57        $href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '') );
     58        if ( isset($tab_array[3]) && is_array($tab_array[3]) )
     59                add_query_arg( $tab_array[3], $href );
     60        $_href = wp_specialchars( $href, 1 );
     61        if ( $tab == $t )
     62                $class .= ' current';
     63        echo "\t<li class='$class left'><a href='$_href' title='{$tab_array[0]}'>{$tab_array[0]}</a></li>\n";
    27864}
     65echo "</ul>\n\n";
    27966
    280 ?>
    281 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    282 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    283 <head>
    284 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
    285 <title></title>
    286 <meta http-equiv="imagetoolbar" content="no" />
    287 <script type="text/javascript">
    288 // <![CDATA[
    289 /* Define any variables we'll need, such as alternate URLs. */
    290 <?php echo $script; ?>
    291 function htmldecode(st) {
    292         o = document.getElementById('htmldecode');
    293         if (! o) {
    294                 o = document.createElement("A");
    295                 o.id = "htmldecode"
    296         }
    297         o.innerHTML = st;
    298         r = o.innerHTML;
    299         return r;
    300 }
    301 function cancelUpload() {
    302         o = document.getElementById('uploadForm');
    303         o.method = 'GET';
    304         o.action.value = 'view';
    305         o.submit();
    306 }
    307 function doPopup(i) {
    308         if ( popup )
    309         popup.style.display = 'none';
    310         target = document.getElementById('target'+i);
    311         popup = document.getElementById('popup'+i);
    312         popup.style.left = (target.offsetLeft) + 'px';
    313         popup.style.top = (target.offsetTop) + 'px';
    314         popup.style.display = 'block';
    315 }
    316 popup = false;
    317 function selectLink(n) {
    318         o=document.getElementById('div'+n);
    319         if ( typeof document.body.createTextRange == 'undefined' || typeof win.tinyMCE == 'undefined' || win.tinyMCE.configs.length < 1 )
    320                 return;
    321         r = document.body.createTextRange();
    322         if ( typeof r != 'undefined' ) {
    323                 r.moveToElementText(o);
    324                 r.select();
    325         }
    326 }
    327 function toggleLink(n) {
    328         ol=document.getElementById('L'+n);
    329         if ( ol.innerHTML == htmldecode(notlinked) ) {
    330                 ol.innerHTML = linkedtoimage;
    331         } else if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
    332                 ol.innerHTML = linkedtopage;
    333         } else {
    334                 ol.innerHTML = notlinked;
    335         }
    336         updateImage(n);
    337 }
    338 function toggleOtherLink(n) {
    339         ol=document.getElementById('L'+n);
    340         if ( ol.innerHTML == htmldecode(linkedtofile) ) {
    341                 ol.innerHTML = linkedtopage;
    342         } else {
    343                 ol.innerHTML = linkedtofile;
    344         }
    345         updateOtherIcon(n);
    346 }
    347 function toggleImage(n) {
    348         oi = document.getElementById('I'+n);
    349         if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
    350                 oi.innerHTML = usingoriginal;
    351         } else {
    352                 oi.innerHTML = usingthumbnail;
    353         }
    354         updateImage(n);
    355 }
    356 function toggleOtherIcon(n) {
    357         od = document.getElementById('div'+n);
    358         oi = document.getElementById('I'+n);
    359         if ( oi.innerHTML == htmldecode(usingtitle) ) {
    360                 oi.innerHTML = usingfilename;
    361                 od.className = 'otherwrap usingtext';
    362         } else if ( oi.innerHTML == htmldecode(usingfilename) && icon[n] != '' ) {
    363                 oi.innerHTML = usingicon;
    364                 od.className = 'otherwrap usingicon';
    365         } else {
    366                 oi.innerHTML = usingtitle;
    367                 od.className = 'otherwrap usingtext';
    368         }
    369         updateOtherIcon(n);
    370 }
    371 function updateImage(n) {
    372         od=document.getElementById('div'+n);
    373         ol=document.getElementById('L'+n);
    374         oi=document.getElementById('I'+n);
    375         if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
    376                 img = imga[n];
    377         } else {
    378                 img = imgb[n];
    379         }
    380         if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
    381                 od.innerHTML = ab[n]+img+'</a>';
    382         } else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
    383                 od.innerHTML = aa[n]+img+'</a>';
    384         } else {
    385                 od.innerHTML = img;
    386         }
    387 }
    388 function updateOtherIcon(n) {
    389         od=document.getElementById('div'+n);
    390         ol=document.getElementById('L'+n);
    391         oi=document.getElementById('I'+n);
    392         if ( oi.innerHTML == htmldecode(usingfilename) ) {
    393                 txt = filename[n];
    394         } else if ( oi.innerHTML == htmldecode(usingicon) ) {
    395                 txt = icon[n];
    396         } else {
    397                 txt = title[n];
    398         }
    399         if ( ol.innerHTML == htmldecode(linkedtofile) ) {
    400                 od.innerHTML = ab[n]+txt+'</a>';
    401         } else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
    402                 od.innerHTML = aa[n]+txt+'</a>';
    403         } else {
    404                 od.innerHTML = txt;
    405         }
    406 }
     67echo "<div id='upload-content'>\n";
    40768
    408 var win = window.opener ? window.opener : window.dialogArguments;
    409 if (!win) win = top;
    410 tinyMCE = win.tinyMCE;
    411 function sendToEditor(n) {
    412         o = document.getElementById('div'+n);
    413         h = o.innerHTML.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // Trim
    414         h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)', 'g'), ' $1="$2"$3'); // Enclose attribs in quotes
    415         h = h.replace(new RegExp(' (width|height)=".*?"', 'g'), ''); // Drop size constraints
    416         h = h.replace(new RegExp(' on(click|mousedown)="[^"]*"', 'g'), ''); // Drop menu events
    417         h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames
    418         h = h.replace(new RegExp('<IMG', 'g'), '<img'); // Lowercase again
    419         h = h.replace(new RegExp('(<img .+?")>', 'g'), '$1 />'); // XHTML
    420         if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') )
    421                 win.tinyMCE.execCommand('mceInsertContent', false, h);
    422         else
    423                 win.edInsertContent(win.edCanvas, h);
    424 }
    425 // ]]>
    426 </script>
    427 <style type="text/css">
    428         <?php if ( $action == 'links' ) : ?>
    429         * html { overflow-x: hidden; }
    430         <?php else : ?>
    431         * html { overflow-y: hidden; }
    432         <?php endif; ?>
     69call_user_func( $wp_upload_tabs[$tab][2] );
    43370
    434         body {
    435                 font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
    436                 border: none;
    437                 margin: 0px;
    438                 height: 150px;
    439                 background: #dfe8f1;
    440         }
     71echo "</div>\n";
    44172
    442         form { margin: 3px 2px 0px 6px; }
    443 
    444         #wrap {
    445                 clear: both;
    446                 padding: 0px;
    447                 width: 100%;
    448         }
    449 
    450         #images {
    451                 position: absolute;
    452                 clear: both;
    453                 margin: 0px;
    454                 padding: 15px 15px;
    455                 width: <?php echo $images_width; ?>px;
    456         }
    457 
    458         #images img { background-color: rgb(209, 226, 239); }
    459 
    460         <?php echo $style; ?>
    461 
    462         .attwrap, .attwrap * {
    463                 margin: 0px;
    464                 padding: 0px;
    465                 border: 0px;
    466         }
    467 
    468         .imagewrap {
    469                 margin-right: 5px;
    470                 overflow: hidden;
    471                 width: 128px;
    472         }
    473 
    474         .otherwrap {
    475                 margin-right: 5px;
    476                 overflow: hidden;
    477                 background-color: #f9fcfe;
    478         }
    479 
    480         .otherwrap a { display: block; }
    481 
    482         .otherwrap a, .otherwrap a:hover, .otherwrap a:active, .otherwrap a:visited { color: blue; }
    483 
    484         .usingicon {
    485                 padding: 0px;
    486                 height: 96px;
    487                 text-align: center;
    488                 width: 128px;
    489         }
    490 
    491         .usingtext {
    492                 padding: 3px;
    493                 height: 90px;
    494                 text-align: left;
    495                 width: 122px;
    496         }
    497 
    498         .filetype {
    499                 font-size: 80%;
    500                 border-bottom: 3px double #89a;
    501         }
    502 
    503         .imagewrap, .imagewrap img, .imagewrap a, .imagewrap a img, .imagewrap a:hover img, .imagewrap a:visited img, .imagewrap a:active img { text-decoration: none; }
    504 
    505         #upload-menu {
    506                 background: #fff;
    507                 margin: 0px;
    508                 padding: 0;
    509                 list-style: none;
    510                 height: 2em;
    511                 border-bottom: 1px solid #448abd;
    512                 width: 100%;
    513         }
    514 
    515         #upload-menu li {
    516                 float: left;
    517                 margin: 0 0 0 .75em;
    518         }
    519 
    520         #upload-menu a {
    521                 display: block;
    522                 padding: 5px;
    523                 text-decoration: none;
    524                 color: #000;
    525                 border-top: 3px solid #fff;
    526         }
    527 
    528         #upload-menu .current a {
    529                 background: #dfe8f1;
    530                 border-right: 2px solid #448abd;
    531         }
    532 
    533         #upload-menu a:hover {
    534                 background: #dfe8f1;
    535                 color: #000;
    536         }
    537 
    538         .tip {
    539                 color: rgb(68, 138, 189);
    540                 padding: 2px 1em;
    541         }
    542 
    543         .inactive {
    544                 color: #fff;
    545                 padding: 1px 3px;
    546         }
    547 
    548         .left { float: left; }
    549 
    550         .right { float: right; }
    551 
    552         .center { text-align: center; }
    553 
    554         #upload-menu li.spacer { margin-left: 40px; }
    555 
    556         #title, #descr {
    557                 width: 99%;
    558                 margin-top: 1px;
    559         }
    560 
    561         th {
    562                 text-align: right;
    563                 width: 4.5em;
    564         }
    565 
    566         #descr { height: 36px; }
    567 
    568         #buttons {
    569                 margin-top: 2px;
    570                 text-align: right;
    571         }
    572 
    573         .popup {
    574                 margin: 4px 4px;
    575                 padding: 1px;
    576                 position: absolute;
    577                 width: 114px;
    578                 display: none;
    579                 background-color: rgb(240, 240, 238);
    580                 border-top: 2px solid #fff;
    581                 border-right: 2px solid #ddd;
    582                 border-bottom: 2px solid #ddd;
    583                 border-left: 2px solid #fff;
    584                 text-align: center;
    585         }
    586 
    587         .imagewrap .popup {
    588                 opacity: .90;
    589                 filter:alpha(opacity=90);
    590         }
    591 
    592         .otherwrap .popup { padding-top: 20px; }
    593 
    594         .popup a, .popup a:visited, .popup a:active {
    595                 background-color: transparent;
    596                 display: block;
    597                 width: 100%;
    598                 text-decoration: none;
    599                 color: #246;
    600         }
    601 
    602         .popup a:hover {
    603                 background-color: #fff;
    604                 color: #000;
    605         }
    606 
    607         .caption { text-align: center; }
    608 
    609         #submit {
    610                 margin: 1px;
    611                 width: 99%;
    612         }
    613 
    614         #submit input, #submit input:focus {
    615                 background: url( images/fade-butt.png );
    616                 border: 3px double #999;
    617                 border-left-color: #ccc;
    618                 border-top-color: #ccc;
    619                 color: #333;
    620                 padding: 0.25em;
    621         }
    622 
    623         #submit input:active {
    624                 background: #f4f4f4;
    625                 border: 3px double #ccc;
    626                 border-left-color: #999;
    627                 border-top-color: #999;
    628         }
    629 
    630         .zerosize {
    631                 width: 0px;
    632                 height: 0px;
    633                 overflow: hidden;
    634                 position: absolute;
    635         }
    636 
    637         #links {
    638                 margin: 3px 8px;
    639                 line-height: 2em;
    640         }
    641 
    642         #links textarea {
    643                 width: 95%;
    644                 height: 4.5em;
    645         }
    646 </style>
    647 <?php if ( ('rtl' == $wp_locale->text_direction) ): ?>
    648 <style type="text/css">
    649         body { font: 13px Tahoma, "Lucida Grande", "Lucida Sans Unicode", Verdana; }
    650 
    651         .usingtext { text-align: right; }
    652 
    653         th { text-align: left; }
    654 
    655         .left, #upload-menu li { float: right; }
    656 
    657         .right { float: left; }
    658 
    659         .popup {
    660                 border-right: 2px solid #fff;
    661                 border-left: 2px solid #ddd;
    662         }
    663 
    664         #upload-menu .current a {
    665                 border-right: 0;
    666                 border-left: 2px solid #448abd;
    667         }
    668 
    669         #submit input, #submit input:focus {
    670                 border-left: 0;
    671                 border-right-color: #ccc;
    672         }
    673 
    674         #submit input:active {
    675                 border-left: 0;
    676                 border-right-color: #999;
    677         }
    678 </style>
    679 <?php endif; ?>
    680 </head>
    681 <body>
    682 <ul id="upload-menu">
    683         <li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__) . "?action=upload&amp;post=$post&amp;all=$all&amp;start=$start"; ?>"><?php _e('Upload'); ?></a></li>
    684 
    685         <?php if ( $attachments = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post'") ): ?>
    686                 <li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=false"; ?>"><?php _e('Browse'); ?></a></li>
    687         <?php endif; ?>
    688 
    689         <?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment'")): ?>
    690                 <li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=true"; ?>"><?php _e('Browse All'); ?></a></li>
    691         <?php endif; ?>
    692 
    693         <li> </li>
    694 
    695         <?php if ( $action == 'view' ): ?>
    696                 <?php if ( false !== $back ): ?>
    697                         <li class="spacer"><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=0"; ?>" title="<?php _e('First'); ?>">|&laquo;</a></li>
    698                         <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$back"; ?>">&laquo; <?php _e('Back'); ?></a></li>
    699                 <?php else: ?>
    700                         <li class="inactive spacer">|&laquo;</li>
    701                         <li class="inactive">&laquo; <?php _e('Back'); ?></li>
    702                 <?php endif; ?>
    703 
    704                 <?php if ( false !== $next ): ?>
    705                         <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$next"; ?>"><?php _e('Next &raquo;'); ?></a></li>
    706                         <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;last=true"; ?>" title="<?php _e('Last'); ?>">&raquo;|</a></li>
    707                 <?php else: ?>
    708                         <li class="inactive"><?php _e('Next &raquo;'); ?></li>
    709                         <li class="inactive">&raquo;|</li>
    710                 <?php endif; ?>
    711         <?php endif; ?>
    712 </ul>
    713 
    714 <?php if ( $action == 'view' ): ?>
    715         <div id="wrap">
    716                 <!--<div class="tip"><?php _e('You can drag and drop these items into your post. Click on one for more options.'); ?></div>-->
    717                 <div id="images">
    718                         <?php echo $html; ?>
    719                         <?php echo $popups; ?>
    720                 </div>
    721         </div>
    722 <?php elseif ( $action == 'upload' ): ?>
    723         <div class="tip"></div>
    724         <form enctype="multipart/form-data" id="uploadForm" method="post" action="<?php echo basename(__FILE__); ?>">
    725                 <table style="width: 99%">
    726                         <tr>
    727                                 <th scope="row"><label for="upload"><?php _e('File:'); ?></label></th>
    728                                 <td><input type="file" id="upload" name="image" /></td>
    729                         </tr>
    730                         <tr>
    731                                 <th scope="row"><label for="title"><?php _e('Title:'); ?></label></th>
    732                                 <td><input type="text" id="title" name="imgtitle" /></td>
    733                         </tr>
    734                         <tr>
    735                                 <th scope="row"><label for="descr"><?php _e('Description:'); ?></label></th>
    736                                 <td><input type="textarea" name="descr" id="descr" value="" /></td>
    737                         </tr>
    738                         <tr id="buttons">
    739                                 <th></th>
    740                                 <td>
    741                                         <input type="hidden" name="action" value="save" />
    742                                         <input type="hidden" name="post" value="<?php echo $post; ?>" />
    743                                         <input type="hidden" name="all" value="<?php echo $all; ?>" />
    744                                         <input type="hidden" name="start" value="<?php echo $start; ?>" />
    745                                         <?php wp_nonce_field( 'inlineuploading' ); ?>
    746                                         <div id="submit">
    747                                                 <input type="submit" value="<?php _e('Upload'); ?>" />
    748                                                 <?php if ( !empty($all) ): ?>
    749                                                         <input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
    750                                                 <?php endif; ?>
    751                                         </div>
    752                                 </td>
    753                         </tr>
    754                 </table>
    755         </form>
    756 <?php elseif ( $action == 'links' ): ?>
    757         <div id="links">
    758                 <?php the_attachment_links($attachment); ?>
    759         </div>
    760 <?php endif; ?>
    761 </body>
    762 </html>
    763  No newline at end of file
     73include_once('admin-footer.php');
     74?>
  • wp-admin/edit-form-advanced.php

     
    183183<?php
    184184if (current_user_can('upload_files')) {
    185185        $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
    186         $uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&amp;post=$uploading_iframe_ID", 'inlineuploading');
     186        $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
    187187        $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
    188188        if ( false != $uploading_iframe_src )
    189189                echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
  • wp-admin/upload-functions.php

     
     1<?php
     2function wp_upload_display( $dims = false, $href = '' ) {
     3        global $post;
     4        $id = get_the_ID();
     5        $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
     6        if ( isset($attachment_data['width']) )
     7                list($width,$height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128);
     8        ob_start();
     9                the_title();
     10                $post_title = wp_specialchars( ob_get_contents(), 1 );
     11        ob_end_clean();
     12        $post_content = apply_filters( 'content_edit_pre', $post->post_content );
     13       
     14        $class = 'text';
     15        $innerHTML = get_attachment_innerHTML( $id, false, $dims );
     16        if ( $image_src = strstr($innerHTML, 'src="') ) {
     17                $image_src = explode('"', $image_src);
     18                $image_src = $image_src[1];
     19                $class = 'image';
     20                $innerHTML = '&nbsp;' . $innerHTML;
     21        }
     22
     23        $r = '';
     24
     25        if ( $href )
     26                $r .= "<a id='file-link-$id' href='$href' title='$post_title' class='file-link $class'>\n";
     27        if ( $href || $image_src )
     28                $r .= "\t\t\t$innerHTML";
     29        if ( $href )
     30                $r .= "</a>\n";
     31        $r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
     32        $r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='" . get_the_guid() . "' />\n";
     33
     34        if ( $image_src )
     35                $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$image_src' />\n";
     36        if ( isset($width) ) {
     37                $r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
     38                $r .= "\t\t\t\t<input type='hidden' name='attachment-height-$id' id='attachment-height-$id' value='$height' />\n";
     39        }
     40        $r .= "\t\t\t\t<input type='hidden' name='attachment-page-url-$id' id='attachment-page-url-$id' value='" . get_attachment_link( $id ) . "' />\n";
     41        $r .= "\t\t\t\t<input type='hidden' name='attachment-title-$id' id='attachment-title-$id' value='$post_title' />\n";
     42        $r .= "\t\t\t\t<input type='hidden' name='attachment-description-$id' id='attachment-description-$id' value='$post_content' />\n";
     43        $r .= "\t\t\t</p>\n\t\t</div>\n";
     44        return $r;
     45}
     46
     47function wp_upload_view() {
     48        global $style, $post_id;
     49        $id = get_the_ID();
     50?>
     51        <div id="upload-file">
     52                <div id="file-title">
     53                        <h2><a href="<?php the_guid(); ?>" title="Direct link to this file"><?php the_title(); ?></a></h2>
     54                        <span><?php
     55                                echo '[&nbsp;';
     56                                echo '<a href="' . get_permalink() . '" title="' . ('Permalink to the blog page for this file') . '">' . __('page link') . '</a>';
     57                                echo '&nbsp;|&nbsp;';
     58                                        echo '<a href="' . wp_specialchars( add_query_arg( 'action', 'edit' ), 1 ) . '" title="' . __('Edit this file') . '">' . __('edit') . '</a>';
     59                                echo '&nbsp;|&nbsp;';
     60                                echo '<a href="' . wp_specialchars( remove_query_arg( array('action', 'ID') ), 1 ) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
     61                                echo '&nbsp;]'; ?></span>
     62                </div>
     63
     64                <div id="upload-file-view" class="left">
     65<?php   echo wp_upload_display( array(171, 128)  ); ?>
     66                </div>
     67                <?php the_attachment_links( $id ); ?>
     68        </div>
     69<?php
     70}
     71
     72function wp_upload_form() {
     73        $id = get_the_ID();
     74        global $post_id, $tab, $style;
     75        $enctype = $id ? '' : ' enctype="multipart/form-data"';
     76?>
     77        <form<?php echo $enctype; ?> id="upload-file" method="post" action="<?php echo get_option('siteurl') . "/wp-admin/upload.php?style=$style&amp;tab=upload&amp;post_id=$post_id"; ?>">
     78<?php
     79        if ( $id ) :
     80                $attachment = get_post_to_edit( $id );
     81?>
     82                <div id="file-title">
     83                        <h2><a href="<?php the_guid(); ?>" title="Direct link to this file"><?php the_title(); ?></a></h2>
     84                        <span><?php
     85                                echo '[&nbsp;';
     86                                echo '<a href="' . get_permalink() . '" title="' . ('Permalink to the blog page for this file') . '">' . __('page link') . '</a>';
     87                                echo '&nbsp;|&nbsp;';
     88                                        echo '<a href="' . wp_specialchars( add_query_arg( 'action', 'view' ), 1 ) . '" title="' . __('View options for this file') . '">' . __('options') . '</a>';
     89                                echo '&nbsp;|&nbsp;';
     90                                echo '<a href="' . wp_specialchars( remove_query_arg( array('action','ID') ), 1 ) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
     91                                echo '&nbsp;]'; ?></span>
     92                </div>
     93
     94        <div id="upload-file-view" class="left">
     95<?php           echo wp_upload_display( array(171, 128) ); ?>
     96        </div>
     97<?php   endif; ?>
     98                <table>
     99<?php   if ( !$id ): ?>
     100                        <tr>
     101                                <th scope="row"><label for="upload"><?php _e('File:'); ?></label></th>
     102                                <td><input type="file" id="upload" name="image" /></td>
     103                        </tr>
     104<?php   endif; ?>
     105                        <tr>
     106                                <th scope="row"><label for="post_title"><?php _e('Title:'); ?></label></th>
     107                                <td><input type="text" id="post_title" name="post_title" value="<?php echo $attachment->post_title; ?>" /></td>
     108                        </tr>
     109                        <tr>
     110                                <th scope="row"><label for="post_content"><?php _e('Description:'); ?></label></th>
     111                                <td><textarea name="post_content" id="post_content"><?php echo $attachment->post_content; ?></textarea></td>
     112                        </tr>
     113                        <tr id="buttons">
     114                                <th></th>
     115                                <td>
     116                                        <input type="hidden" name="from_tab" value="<?php echo $tab; ?>" />
     117                                        <input type="hidden" name="action" value="<?php echo $id ? 'save' : 'upload'; ?>" />
     118<?php   if ( $post_id ) : ?>
     119                                        <input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
     120<?php   endif; if ( $id ) : ?>
     121                                        <input type="hidden" name="ID" value="<?php echo $id; ?>" />
     122<?php   endif; ?>
     123                                        <?php wp_nonce_field( 'inlineuploading' ); ?>
     124                                        <div id="submit">
     125                                                <input type="submit" value="<?php $id ? _e('Save') : _e('Upload'); ?>" />
     126<?php   if ( $id ) : ?>
     127                                                <input type="submit" name="delete" class="delete" value="<?php _e('Delete'); ?>" />
     128<?php   endif; ?>
     129                                        </div>
     130                                </td>
     131                        </tr>
     132                </table>
     133        </form>
     134<?php
     135}
     136
     137function wp_upload_tab_upload() {
     138        wp_upload_form();
     139}
     140
     141function wp_upload_tab_upload_action() {
     142        global $action;
     143        if ( isset($_POST['delete']) )
     144                $action = 'delete';
     145
     146        switch ( $action ) :
     147        case 'upload' :
     148                global $from_tab, $post_id, $style;
     149                if ( !$from_tab )
     150                        $from_tab = 'upload';
     151
     152                check_admin_referer( 'inlineuploading' );
     153
     154                global $post_id, $post_title, $post_content;
     155
     156                if ( !current_user_can( 'upload_files' ) )
     157                        wp_die( __('You are not allowed to upload files.')
     158                                . " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=$style&amp;tab=browse-all&amp;post_id=$post_id'>"
     159                                . __('Browse Files') . '</a>'
     160                        );
     161
     162                $overrides = array('action'=>'upload');
     163
     164                $file = wp_handle_upload($_FILES['image'], $overrides);
     165
     166                if ( isset($file['error']) )
     167                        wp_die($file['error'] . "<br /><a href='" . get_option('siteurl')
     168                        . "/wp-admin/upload.php?style=$style&amp;tab=$from_tab&amp;post_id=$post_id'>'" . __('Back to Image Uploading') . '</a>'
     169                );
     170
     171                $url = $file['url'];
     172                $type = $file['type'];
     173                $file = $file['file'];
     174                $filename = basename($file);
     175
     176                // Construct the attachment array
     177                $attachment = array(
     178                        'post_title' => $post_title ? $post_title : $filename,
     179                        'post_content' => $post_content,
     180                        'post_type' => 'attachment',
     181                        'post_parent' => $post_id,
     182                        'post_mime_type' => $type,
     183                        'guid' => $url
     184                );
     185
     186                // Save the data
     187                $id = wp_insert_attachment($attachment, $file, $post_id);
     188
     189                if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
     190                        // Generate the attachment's postmeta.
     191                        $imagesize = getimagesize($file);
     192                        $imagedata['width'] = $imagesize['0'];
     193                        $imagedata['height'] = $imagesize['1'];
     194                        list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
     195                        $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
     196                        $imagedata['file'] = $file;
     197
     198                        add_post_meta($id, '_wp_attachment_metadata', $imagedata);
     199
     200                        if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
     201                                if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
     202                                        $thumb = wp_create_thumbnail($file, 128);
     203                                elseif ( $imagedata['height'] > 96 )
     204                                        $thumb = wp_create_thumbnail($file, 96);
     205
     206                                if ( @file_exists($thumb) ) {
     207                                        $newdata = $imagedata;
     208                                        $newdata['thumb'] = basename($thumb);
     209                                        update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata);
     210                                } else {
     211                                        $error = $thumb;
     212                                }
     213                        }
     214                } else {
     215                        add_post_meta($id, '_wp_attachment_metadata', array());
     216                }
     217
     218                wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id");
     219                die;
     220                break;
     221
     222        case 'save' :
     223                global $from_tab, $post_id, $style;
     224                if ( !$from_tab )
     225                        $from_tab = 'upload';
     226                check_admin_referer( 'inlineuploading' );
     227
     228                wp_update_post($_POST);
     229                wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id");
     230                die;
     231                break;
     232
     233        case 'delete' :
     234                global $ID, $post_id, $from_tab, $style;
     235                if ( !$from_tab )
     236                        $from_tab = 'upload';
     237
     238                check_admin_referer( 'inlineuploading' );
     239
     240                if ( !current_user_can('edit_post', (int) $ID) )
     241                        wp_die( __('You are not allowed to delete this attachment.')
     242                                . " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=$style&amp;tab=$from_tab&amp;post_id=$post_id'>"
     243                                . __('Go back') . '</a>'
     244                        );
     245
     246                wp_delete_attachment($ID);
     247
     248                wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id" );
     249                die;
     250                break;
     251
     252        endswitch;
     253}
     254
     255add_action( 'upload_files_upload', 'wp_upload_tab_upload_action' );
     256
     257function wp_upload_grab_attachments( $obj ) {
     258        $obj->is_attachment = true;
     259}
     260
     261function wp_upload_posts_where( $where ) {
     262        global $post_id;
     263        return $where . " AND post_parent = '" . (int) $post_id . "'";
     264}
     265
     266function wp_upload_tab_browse() {
     267        global $wpdb, $action, $paged;
     268        $old_vars = compact( 'paged' );
     269       
     270        switch ( $action ) :
     271        case 'edit' :
     272        case 'view' :
     273                global $ID;
     274                $attachments = query_posts("attachment_id=$ID");
     275                if ( have_posts() ) : while ( have_posts() ) : the_post();
     276                        'edit' == $action ? wp_upload_form() : wp_upload_view();
     277                endwhile; endif;
     278                break;
     279        default :
     280                global $tab, $post_id;
     281                add_action( 'pre_get_posts', 'wp_upload_grab_attachments' );
     282                if ( 'browse' == $tab && $post_id )
     283                        add_filter( 'posts_where', 'wp_upload_posts_where' );
     284                $attachments = query_posts("what_to_show=posts&posts_per_page=10&paged=$paged");
     285                $count_query = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'";
     286                if ( $post_id )
     287                        $count_query .= " AND post_parent = '$post_id'";
     288                $total =  $wpdb->get_var($count_query);
     289
     290                echo "<ul id='upload-files'>\n";
     291                if ( have_posts() ) : while ( have_posts() ) : the_post();
     292                        $href = wp_specialchars( add_query_arg( array('action' => 'view', 'ID' => get_the_ID()) ), 1 );
     293
     294                        echo "\t<li id='file-";
     295                        the_ID();
     296                        echo "' class='left'>\n";
     297                        echo wp_upload_display( array(128,128), $href );
     298                        echo "\t</li>\n";
     299                endwhile;
     300                else :
     301                        echo "\t<li>" . __('There are no attachments to show.') . "</li>\n";
     302                endif;
     303                echo "</ul>\n\n";
     304
     305                echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' )  . "' /></form>\n";
     306
     307//              echo $total;
     308                break;
     309        endswitch;
     310
     311        extract($old_vars);
     312}
     313
     314
     315function wp_upload_tab_browse_action() {
     316        wp_enqueue_script('upload');
     317}
     318
     319add_action( 'upload_files_browse', 'wp_upload_tab_browse_action' );
     320add_action( 'upload_files_browse-all', 'wp_upload_tab_browse_action' );
     321
     322function wp_upload_admin_head() {
     323        global $wp_locale;
     324        echo "<link rel='stylesheet' href='" . get_option('siteurl') . '/wp-admin/upload.css?version=' . get_bloginfo('version') . "' type='text/css' />\n";
     325        if ( 'rtl' == $wp_locale->text_direction )
     326                echo "<link rel='stylesheet' href='" . get_option('siteurl') . '/wp-admin/upload-rtl.css?version=' . get_bloginfo('version') . "' type='text/css' />\n";
     327        if ( 'inline' == @$_GET['style'] ) {
     328                echo "<style type='text/css'>\n";
     329                echo "\t#wphead, #user_info, #adminmenu, #submenu, #footer { display: none; }\n";
     330                echo "\tbody { height: 14em; overflow: hidden; }\n";
     331                echo "\t#upload-content { overflow-y: auto; }\n";
     332                echo "\t#upload-file { position: absolute; }\n";
     333                echo "</style>";
     334        }
     335}
     336
  • wp-admin/menu.php

     
    3030
    3131$submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php');
    3232$submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
     33$submenu['edit.php'][12] = array(__('Uploads'), 'upload_files', 'upload.php');
    3334$submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php');
    3435$submenu['edit.php'][20] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
    3536$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
     
    124125        }
    125126}
    126127
     128unset($id);
     129
    127130ksort($menu); // make it all pretty
    128131
    129132if (! user_can_access_admin_page()) {
  • wp-admin/upload.css

     
     1body { background: #dfe8f1; }
     2
     3.upload-file-data { display: none; }
     4
     5#upload-menu {
     6        background: #fff;
     7        margin: 0px;
     8        padding: 0;
     9        list-style: none;
     10        height: 2em;
     11        border-bottom: 1px solid #448abd;
     12        width: 100%;
     13}
     14
     15#upload-menu li { margin: 0 0 0 .75em; }
     16
     17#upload-menu a {
     18        display: block;
     19        padding: 5px;
     20        color: #000;
     21        border-top: 3px solid #fff;
     22        text-decoration: none;
     23        border-bottom: none;
     24}
     25
     26#upload-menu .current a {
     27        background: #dfe8f1;
     28        border-right: 2px solid #448abd;
     29}
     30
     31#upload-menu a:hover {
     32        background: #dfe8f1;
     33        color: #000;
     34}
     35
     36#upload-content {
     37        position: relative;
     38        clear: both;
     39        margin: 0;
     40        padding: 0;
     41        border: none;
     42        width: 100%;
     43        height: 100%;
     44        background: none;
     45}
     46
     47#upload-file {
     48        position: relative;
     49        margin: 0;
     50        top: 0;
     51        left: 0;
     52        width: 100%;
     53        height: 100%;
     54        background: #dfe8f1;
     55}
     56
     57#upload-file-view { padding: 0 15px; }
     58
     59#file-title {
     60        margin: 0 0 0 15px;
     61        padding: 0;
     62        display: block;
     63}
     64
     65h2 {
     66        margin: 0 .2em 0 0;
     67        padding: 0;
     68        display: inline;
     69        border: none;
     70        font-weight: bold;
     71        font-size: 1.4em;
     72        line-height: 1.4em;
     73}
     74
     75#upload-files {
     76        list-style-type: none;
     77        margin: 0;
     78        padding: 15px 0 0;
     79}
     80
     81#upload-files li { margin: 0 0 15px 15px; }
     82
     83#upload-files a, a.file-link {
     84        border: none;
     85        text-decoration: none;
     86}
     87
     88#upload-files a.file-link {
     89        display: block;
     90        width: 130px;
     91        height: 128px;
     92        background-color: rgb(209, 226, 239);
     93        text-align: center;
     94        overflow-y: hidden;
     95}
     96
     97#upload-files a.file-link.image {
     98        line-height: 128px;
     99        font-size: 2px;
     100        letter-spacing: 0;
     101}
     102
     103#upload-files a.file-link img {
     104        vertical-align: middle;
     105}
     106
     107#the-attachment-links { float: right; }
     108
     109#the-attachment-links textarea {
     110        font-size: 10px;
     111        overflow: hidden;
     112}
     113
     114form table { float: none; }
     115
     116table {
     117        float: left;
     118        margin: 0;
     119        padding: 0 15px;
     120}
     121
     122.left { float: left; }
     123
     124.right { float: right; }
     125
     126.center { text-align: center; }
     127
     128th { text-align: left; }
     129
     130tr, td, th {
     131        margin-top: 0;
     132        padding-top: 0;
     133}
     134
     135#submit {
     136        margin: 1px;
     137        width: 99%;
     138}
     139
     140#submit input, #submit input:focus {
     141        background: url( images/fade-butt.png );
     142        border: 3px double #999;
     143        border-left-color: #ccc;
     144        border-top-color: #ccc;
     145        color: #333;
     146        padding: 0.25em;
     147}
     148
     149#submit input:active {
     150        background: #f4f4f4;
     151        border: 3px double #ccc;
     152        border-left-color: #999;
     153        border-top-color: #999;
     154}
     155
     156#submit input.delete:hover {
     157        background: #ce0000;
     158        color: #fff;
     159}