Don't hide links to the upload form and show an error for mobile devices that cannot upload, see #20410
git-svn-id: http://svn.automattic.com/wordpress/trunk@20449 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
65382b14f8
commit
817b932ed1
|
@ -64,13 +64,7 @@ add_filter('media_upload_tabs', 'update_gallery_tab');
|
||||||
function the_media_upload_tabs() {
|
function the_media_upload_tabs() {
|
||||||
global $redir_tab;
|
global $redir_tab;
|
||||||
$tabs = media_upload_tabs();
|
$tabs = media_upload_tabs();
|
||||||
|
$default = 'type';
|
||||||
if ( wp_is_mobile() ) {
|
|
||||||
unset($tabs['type']);
|
|
||||||
$default = 'type_url';
|
|
||||||
} else {
|
|
||||||
$default = 'type';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !empty($tabs) ) {
|
if ( !empty($tabs) ) {
|
||||||
echo "<ul id='sidemenu'>\n";
|
echo "<ul id='sidemenu'>\n";
|
||||||
|
@ -598,10 +592,7 @@ function wp_media_upload_handler() {
|
||||||
return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
|
return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( wp_is_mobile() )
|
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
|
||||||
return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
|
|
||||||
else
|
|
||||||
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1306,8 +1297,10 @@ function media_upload_header() {
|
||||||
function media_upload_form( $errors = null ) {
|
function media_upload_form( $errors = null ) {
|
||||||
global $type, $tab, $pagenow, $is_IE, $is_opera;
|
global $type, $tab, $pagenow, $is_IE, $is_opera;
|
||||||
|
|
||||||
if ( wp_is_mobile() )
|
if ( ! _device_can_upload() ) {
|
||||||
|
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>';
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$upload_action_url = admin_url('async-upload.php');
|
$upload_action_url = admin_url('async-upload.php');
|
||||||
$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
|
$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
|
||||||
|
@ -1438,8 +1431,6 @@ if ( ($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024 ) { ?>
|
||||||
* @param unknown_type $id
|
* @param unknown_type $id
|
||||||
*/
|
*/
|
||||||
function media_upload_type_form($type = 'file', $errors = null, $id = null) {
|
function media_upload_type_form($type = 'file', $errors = null, $id = null) {
|
||||||
if ( wp_is_mobile() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
media_upload_header();
|
media_upload_header();
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,4 @@
|
||||||
$_GET['inline'] = 'true';
|
$_GET['inline'] = 'true';
|
||||||
/** Administration bootstrap */
|
/** Administration bootstrap */
|
||||||
require_once('./admin.php');
|
require_once('./admin.php');
|
||||||
|
|
||||||
if ( wp_is_mobile() ) // cannot upload files from mobile devices
|
|
||||||
return;
|
|
||||||
|
|
||||||
require_once('./media-upload.php');
|
require_once('./media-upload.php');
|
||||||
|
|
|
@ -106,7 +106,7 @@ case 'edit' :
|
||||||
<h2>
|
<h2>
|
||||||
<?php
|
<?php
|
||||||
echo esc_html( $title );
|
echo esc_html( $title );
|
||||||
if ( current_user_can( 'upload_files' ) && ! wp_is_mobile() ) { ?>
|
if ( current_user_can( 'upload_files' ) ) { ?>
|
||||||
<a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a>
|
<a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
|
@ -56,8 +56,7 @@ $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu
|
||||||
$menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'div' );
|
$menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'div' );
|
||||||
$submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
|
$submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
|
||||||
/* translators: add new file */
|
/* translators: add new file */
|
||||||
if ( ! wp_is_mobile() )
|
$submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
|
||||||
$submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
|
|
||||||
|
|
||||||
$menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'div' );
|
$menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'div' );
|
||||||
$submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' );
|
$submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' );
|
||||||
|
|
|
@ -179,7 +179,7 @@ require_once('./admin-header.php');
|
||||||
<h2>
|
<h2>
|
||||||
<?php
|
<?php
|
||||||
echo esc_html( $title );
|
echo esc_html( $title );
|
||||||
if ( current_user_can( 'upload_files' ) && ! wp_is_mobile() ) { ?>
|
if ( current_user_can( 'upload_files' ) ) { ?>
|
||||||
<a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a><?php
|
<a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a><?php
|
||||||
}
|
}
|
||||||
if ( ! empty( $_REQUEST['s'] ) )
|
if ( ! empty( $_REQUEST['s'] ) )
|
||||||
|
|
|
@ -489,7 +489,7 @@ function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
|
||||||
unset( $cpts['post'] );
|
unset( $cpts['post'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( current_user_can( 'upload_files' ) && ! wp_is_mobile() )
|
if ( current_user_can( 'upload_files' ) )
|
||||||
$actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' );
|
$actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' );
|
||||||
|
|
||||||
if ( current_user_can( 'manage_links' ) )
|
if ( current_user_can( 'manage_links' ) )
|
||||||
|
|
|
@ -3676,3 +3676,26 @@ function _get_non_cached_ids( $object_ids, $cache_key ) {
|
||||||
return $clean;
|
return $clean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the current device has the capability to upload files.
|
||||||
|
*
|
||||||
|
* @since 3.4.0
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
* @return bool true|false
|
||||||
|
*/
|
||||||
|
function _device_can_upload() {
|
||||||
|
if ( ! wp_is_mobile() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
$ua = $_SERVER['HTTP_USER_AGENT'];
|
||||||
|
|
||||||
|
if ( strpos($ua, 'iPhone') !== false
|
||||||
|
|| strpos($ua, 'iPad') !== false
|
||||||
|
|| strpos($ua, 'iPod') !== false ) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue