Introduce wp_is_mobile() and use it instead of $is_iphone global, see #20014

git-svn-id: https://develop.svn.wordpress.org/trunk@20417 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2012-04-10 01:19:30 +00:00
parent fdce6271d0
commit bce0d37a67
11 changed files with 87 additions and 59 deletions

View File

@@ -11,7 +11,7 @@ if ( ! defined( 'WP_ADMIN' ) )
require_once( './admin.php' );
// In case admin-header.php is included in a function.
global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $wp_version, $is_iphone,
global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $wp_version,
$current_site, $update_title, $total_update_count, $parent_file;
// Catch plugins that include admin-header.php before admin.php completes.
@@ -87,9 +87,10 @@ $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-
$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
if ( $is_iphone ) { ?>
<style type="text/css">.row-actions{visibility:visible;}</style>
<?php } ?>
if ( wp_is_mobile() )
$admin_body_class .= ' mobile';
?>
</head>
<body class="wp-admin no-js <?php echo apply_filters( 'admin_body_class', '' ) . " $admin_body_class"; ?>">
<script type="text/javascript">document.body.className = document.body.className.replace('no-js','js');</script>

View File

@@ -5323,6 +5323,10 @@ p.pagenav {
padding: 2px 0 0;
}
.mobile .row-actions {
visibility: visible;
}
tr:hover .row-actions,
div.comment-item:hover .row-actions {
visibility: visible;

View File

@@ -62,10 +62,10 @@ add_filter('media_upload_tabs', 'update_gallery_tab');
* @since 2.5.0
*/
function the_media_upload_tabs() {
global $redir_tab, $is_iphone;
global $redir_tab;
$tabs = media_upload_tabs();
if ( $is_iphone ) {
if ( wp_is_mobile() ) {
unset($tabs['type']);
$default = 'type_url';
} else {
@@ -528,8 +528,6 @@ function media_upload_form_handler() {
* @return unknown
*/
function wp_media_upload_handler() {
global $is_iphone;
$errors = array();
$id = 0;
@@ -600,7 +598,7 @@ function wp_media_upload_handler() {
return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
}
if ( $is_iphone )
if ( wp_is_mobile() )
return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
else
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
@@ -1306,9 +1304,9 @@ function media_upload_header() {
* @param unknown_type $errors
*/
function media_upload_form( $errors = null ) {
global $type, $tab, $pagenow, $is_IE, $is_opera, $is_iphone;
global $type, $tab, $pagenow, $is_IE, $is_opera;
if ( $is_iphone )
if ( wp_is_mobile() )
return;
$upload_action_url = admin_url('async-upload.php');
@@ -1440,9 +1438,7 @@ if ( ($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024 ) { ?>
* @param unknown_type $id
*/
function media_upload_type_form($type = 'file', $errors = null, $id = null) {
global $is_iphone;
if ( $is_iphone )
if ( wp_is_mobile() )
return;
media_upload_header();

View File

@@ -583,9 +583,10 @@ foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
}
function _ipad_meta() {
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false ) { ?>
<meta name="viewport" id="ipad-viewportmeta" content="width=device-width, initial-scale=1">
<?php
if ( wp_is_mobile() ) {
?>
<meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1">
<?php
}
}
add_action('admin_head', '_ipad_meta');

View File

@@ -1,4 +1,4 @@
var postboxes, is_iPad = navigator.userAgent.match(/iPad/);
var postboxes;
(function($) {
postboxes = {

View File

@@ -6,9 +6,7 @@
* @subpackage Administration
*/
global $is_iphone;
if ( $is_iphone ) // cannot upload files from iPhone/iPad
if ( wp_is_mobile() ) // cannot upload files from mobile devices
return;
$_GET['inline'] = 'true';

View File

@@ -56,7 +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' );
$submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
/* translators: add new file */
if ( !$is_iphone )
if ( ! wp_is_mobile() )
$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' );