raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Accepts file uploads from swfupload or other asynchronous upload methods.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 if ( defined('ABSPATH') )
mp-wp_genesis 10 require_once(ABSPATH . 'wp-load.php');
mp-wp_genesis 11 else
mp-wp_genesis 12 require_once('../wp-load.php');
mp-wp_genesis 13
mp-wp_genesis 14 // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
mp-wp_genesis 15 if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
mp-wp_genesis 16 $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
mp-wp_genesis 17 elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
mp-wp_genesis 18 $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
mp-wp_genesis 19 unset($current_user);
mp-wp_genesis 20 require_once('admin.php');
mp-wp_genesis 21
mp-wp_genesis 22 header('Content-Type: text/plain; charset=' . get_option('blog_charset'));
mp-wp_genesis 23
mp-wp_genesis 24 if ( !current_user_can('upload_files') )
mp-wp_genesis 25 wp_die(__('You do not have permission to upload files.'));
mp-wp_genesis 26
mp-wp_genesis 27 // just fetch the detail form for that attachment
mp-wp_genesis 28 if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) {
mp-wp_genesis 29 if ( 2 == $_REQUEST['fetch'] ) {
mp-wp_genesis 30 add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
mp-wp_genesis 31 echo get_media_item($id, array( 'send' => false, 'delete' => false ));
mp-wp_genesis 32 } else {
mp-wp_genesis 33 echo get_media_item($id);
mp-wp_genesis 34 }
mp-wp_genesis 35 exit;
mp-wp_genesis 36 }
mp-wp_genesis 37
mp-wp_genesis 38 check_admin_referer('media-form');
mp-wp_genesis 39
mp-wp_genesis 40 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
mp-wp_genesis 41 if (is_wp_error($id)) {
mp-wp_genesis 42 echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
mp-wp_genesis 43 exit;
mp-wp_genesis 44 }
mp-wp_genesis 45
mp-wp_genesis 46 if ( $_REQUEST['short'] ) {
mp-wp_genesis 47 // short form response - attachment ID only
mp-wp_genesis 48 echo $id;
mp-wp_genesis 49 }
mp-wp_genesis 50 else {
mp-wp_genesis 51 // long form response - big chunk o html
mp-wp_genesis 52 $type = $_REQUEST['type'];
mp-wp_genesis 53 echo apply_filters("async_upload_{$type}", $id);
mp-wp_genesis 54 }
mp-wp_genesis 55
mp-wp_genesis 56 ?>