Route uploads through async-upload.php instead of admin-ajax.php.
Props nacin, koopersmith fixes #22622 git-svn-id: http://core.svn.wordpress.org/trunk@22902 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
51b6b2189b
commit
ea0d28db29
|
@ -13,21 +13,35 @@ if ( defined('ABSPATH') )
|
||||||
else
|
else
|
||||||
require_once('../wp-load.php');
|
require_once('../wp-load.php');
|
||||||
|
|
||||||
// Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
|
if ( ! ( isset( $_REQUEST['action'] ) && 'upload-attachment' == $_REQUEST['action'] ) ) {
|
||||||
if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
|
// Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
|
||||||
$_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
|
if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
|
||||||
elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
|
$_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
|
||||||
$_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
|
elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
|
||||||
if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) )
|
$_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
|
||||||
$_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
|
if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) )
|
||||||
unset($current_user);
|
$_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
|
||||||
require_once('./admin.php');
|
unset($current_user);
|
||||||
|
}
|
||||||
|
|
||||||
header('Content-Type: text/html; charset=' . get_option('blog_charset'));
|
require_once('./admin.php');
|
||||||
|
|
||||||
if ( !current_user_can('upload_files') )
|
if ( !current_user_can('upload_files') )
|
||||||
wp_die(__('You do not have permission to upload files.'));
|
wp_die(__('You do not have permission to upload files.'));
|
||||||
|
|
||||||
|
header('Content-Type: text/html; charset=' . get_option('blog_charset'));
|
||||||
|
|
||||||
|
if ( isset( $_REQUEST['action'] ) && 'upload-attachment' === $_REQUEST['action'] ) {
|
||||||
|
define( 'DOING_AJAX', true );
|
||||||
|
include ABSPATH . 'wp-admin/includes/ajax-actions.php';
|
||||||
|
|
||||||
|
send_nosniff_header();
|
||||||
|
nocache_headers();
|
||||||
|
|
||||||
|
wp_ajax_upload_attachment();
|
||||||
|
die( '0' );
|
||||||
|
}
|
||||||
|
|
||||||
// just fetch the detail form for that attachment
|
// just fetch the detail form for that attachment
|
||||||
if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) {
|
if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) {
|
||||||
$post = get_post( $id );
|
$post = get_post( $id );
|
||||||
|
|
|
@ -1246,7 +1246,7 @@ function wp_plupload_default_settings() {
|
||||||
'file_data_name' => 'async-upload', // key passed to $_FILE.
|
'file_data_name' => 'async-upload', // key passed to $_FILE.
|
||||||
'multiple_queues' => true,
|
'multiple_queues' => true,
|
||||||
'max_file_size' => $max_upload_size . 'b',
|
'max_file_size' => $max_upload_size . 'b',
|
||||||
'url' => admin_url( 'admin-ajax.php', 'relative' ),
|
'url' => admin_url( 'async-upload.php', 'relative' ),
|
||||||
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
|
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
|
||||||
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
||||||
'filters' => array( array( 'title' => __( 'Allowed Files' ), 'extensions' => '*') ),
|
'filters' => array( array( 'title' => __( 'Allowed Files' ), 'extensions' => '*') ),
|
||||||
|
|
Loading…
Reference in New Issue