| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
if ( defined('ABSPATH') ) |
|---|
| 10 |
require_once(ABSPATH . 'wp-load.php'); |
|---|
| 11 |
else |
|---|
| 12 |
require_once('../wp-load.php'); |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) |
|---|
| 16 |
$_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie']; |
|---|
| 17 |
elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) |
|---|
| 18 |
$_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie']; |
|---|
| 19 |
unset($current_user); |
|---|
| 20 |
require_once('admin.php'); |
|---|
| 21 |
|
|---|
| 22 |
header('Content-Type: text/plain; charset=' . get_option('blog_charset')); |
|---|
| 23 |
|
|---|
| 24 |
if ( !current_user_can('upload_files') ) |
|---|
| 25 |
wp_die(__('You do not have permission to upload files.')); |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) { |
|---|
| 29 |
if ( 2 == $_REQUEST['fetch'] ) { |
|---|
| 30 |
add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2); |
|---|
| 31 |
echo get_media_item($id, array( 'send' => false, 'delete' => false )); |
|---|
| 32 |
} else { |
|---|
| 33 |
echo get_media_item($id); |
|---|
| 34 |
} |
|---|
| 35 |
exit; |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
check_admin_referer('media-form'); |
|---|
| 39 |
|
|---|
| 40 |
$id = media_handle_upload('async-upload', $_REQUEST['post_id']); |
|---|
| 41 |
if (is_wp_error($id)) { |
|---|
| 42 |
echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>'; |
|---|
| 43 |
exit; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
if ( $_REQUEST['short'] ) { |
|---|
| 47 |
|
|---|
| 48 |
echo $id; |
|---|
| 49 |
} |
|---|
| 50 |
else { |
|---|
| 51 |
|
|---|
| 52 |
$type = $_REQUEST['type']; |
|---|
| 53 |
echo apply_filters("async_upload_{$type}", $id); |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
?> |
|---|
| 57 |
|
|---|