Skip to content

Commit e032e94

Browse files
committed
Don't hide links to the upload form and show an error for mobile devices that cannot upload, see #20410
git-svn-id: https://develop.svn.wordpress.org/trunk@20449 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5ff62a4 commit e032e94

7 files changed

Lines changed: 32 additions & 23 deletions

File tree

wp-admin/includes/media.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,7 @@ function update_gallery_tab($tabs) {
6464
function the_media_upload_tabs() {
6565
global $redir_tab;
6666
$tabs = media_upload_tabs();
67-
68-
if ( wp_is_mobile() ) {
69-
unset($tabs['type']);
70-
$default = 'type_url';
71-
} else {
72-
$default = 'type';
73-
}
67+
$default = 'type';
7468

7569
if ( !empty($tabs) ) {
7670
echo "<ul id='sidemenu'>\n";
@@ -598,10 +592,7 @@ function wp_media_upload_handler() {
598592
return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
599593
}
600594

601-
if ( wp_is_mobile() )
602-
return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
603-
else
604-
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
595+
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
605596
}
606597

607598
/**
@@ -1306,8 +1297,10 @@ function media_upload_header() {
13061297
function media_upload_form( $errors = null ) {
13071298
global $type, $tab, $pagenow, $is_IE, $is_opera;
13081299

1309-
if ( wp_is_mobile() )
1300+
if ( ! _device_can_upload() ) {
1301+
echo '<p>' . __('The web browser on your device cannot be used to upload files. You may be able to use the <a href=" http://wordpress.org/extend/mobile/">native app for your device</a> instead.') . '</p>';
13101302
return;
1303+
}
13111304

13121305
$upload_action_url = admin_url('async-upload.php');
13131306
$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
@@ -1438,8 +1431,6 @@ function media_upload_form( $errors = null ) {
14381431
* @param unknown_type $id
14391432
*/
14401433
function media_upload_type_form($type = 'file', $errors = null, $id = null) {
1441-
if ( wp_is_mobile() )
1442-
return;
14431434

14441435
media_upload_header();
14451436

wp-admin/media-new.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,4 @@
99
$_GET['inline'] = 'true';
1010
/** Administration bootstrap */
1111
require_once('./admin.php');
12-
13-
if ( wp_is_mobile() ) // cannot upload files from mobile devices
14-
return;
15-
1612
require_once('./media-upload.php');

wp-admin/media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<h2>
107107
<?php
108108
echo esc_html( $title );
109-
if ( current_user_can( 'upload_files' ) && ! wp_is_mobile() ) { ?>
109+
if ( current_user_can( 'upload_files' ) ) { ?>
110110
<a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a>
111111
<?php } ?>
112112
</h2>

wp-admin/menu.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@
5656
$menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'div' );
5757
$submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
5858
/* translators: add new file */
59-
if ( ! wp_is_mobile() )
60-
$submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
59+
$submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
6160

6261
$menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'div' );
6362
$submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' );

wp-admin/upload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
<h2>
180180
<?php
181181
echo esc_html( $title );
182-
if ( current_user_can( 'upload_files' ) && ! wp_is_mobile() ) { ?>
182+
if ( current_user_can( 'upload_files' ) ) { ?>
183183
<a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a><?php
184184
}
185185
if ( ! empty( $_REQUEST['s'] ) )

wp-includes/admin-bar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
489489
unset( $cpts['post'] );
490490
}
491491

492-
if ( current_user_can( 'upload_files' ) && ! wp_is_mobile() )
492+
if ( current_user_can( 'upload_files' ) )
493493
$actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' );
494494

495495
if ( current_user_can( 'manage_links' ) )

wp-includes/functions.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3676,3 +3676,26 @@ function _get_non_cached_ids( $object_ids, $cache_key ) {
36763676
return $clean;
36773677
}
36783678

3679+
/**
3680+
* Test if the current device has the capability to upload files.
3681+
*
3682+
* @since 3.4.0
3683+
* @access private
3684+
*
3685+
* @return bool true|false
3686+
*/
3687+
function _device_can_upload() {
3688+
if ( ! wp_is_mobile() )
3689+
return true;
3690+
3691+
$ua = $_SERVER['HTTP_USER_AGENT'];
3692+
3693+
if ( strpos($ua, 'iPhone') !== false
3694+
|| strpos($ua, 'iPad') !== false
3695+
|| strpos($ua, 'iPod') !== false ) {
3696+
return false;
3697+
} else {
3698+
return true;
3699+
}
3700+
}
3701+

0 commit comments

Comments
 (0)