From cc9b248937c8e0a7060b04a106f6daf9f86bf862 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 27 Nov 2012 16:17:53 +0000 Subject: [PATCH] Always send nocache_headers() for admin-ajax.php. This prevents iOS from caching ajax calls. http://stackoverflow.com/questions/12506897/is-safari-on-ios-6-caching-ajax-results Turn off multi selection uploads for mobile devices. Currently Plupload cannot upload multiple files in iOS Safari. Only the first file makes it to the queue. Empty wp on unload to work around caching in iOS Safari. Props azaozz, miqrogroove, nacin fixes #22552 git-svn-id: http://core.svn.wordpress.org/trunk@22872 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-ajax.php | 1 + wp-admin/includes/media.php | 5 +++++ wp-includes/js/media-models.js | 5 +++++ wp-includes/media.php | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 2d073bc63d..65398f182e 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -36,6 +36,7 @@ require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' ); @header( 'X-Robots-Tag: noindex' ); send_nosniff_header(); +nocache_headers(); do_action( 'admin_init' ); diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index e3a912ac81..2f7f318931 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -1508,6 +1508,11 @@ $plupload_init = array( 'multipart_params' => $post_params ); +// Multi-file uploading doesn't currently work in iOS Safari, +// single-file allows the built-in camera to be used as source for images +if ( wp_is_mobile() ) + $plupload_init['multi_selection'] = false; + $plupload_init = apply_filters( 'plupload_init', $plupload_init ); ?> diff --git a/wp-includes/js/media-models.js b/wp-includes/js/media-models.js index 15129e1cd1..7da7327a1d 100644 --- a/wp-includes/js/media-models.js +++ b/wp-includes/js/media-models.js @@ -809,4 +809,9 @@ window.wp = window.wp || {}; } }); + // Clean up. Prevents mobile browsers caching + $(window).on('unload', function(){ + window.wp = null; + }); + }(jQuery)); \ No newline at end of file diff --git a/wp-includes/media.php b/wp-includes/media.php index 878941ebbe..1612b80d2e 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1254,6 +1254,11 @@ function wp_plupload_default_settings() { 'multipart' => true, 'urlstream_upload' => true, ); + + // Multi-file uploading doesn't currently work in iOS Safari, + // single-file allows the built-in camera to be used as source for images + if ( wp_is_mobile() ) + $defaults['multi_selection'] = false; $defaults = apply_filters( 'plupload_default_settings', $defaults );