このプラグインは WordPress の最新3回のメジャーリリースに対してテストされていません。もうメンテナンスやサポートがされていないかもしれず、最新バージョンの WordPress で使用した場合は互換性の問題が発生する可能性があります。

mobble

説明

mobble provides mobile related conditional functions for your site. e.g. is_iphone(), is_mobile() and is_tablet().

CSS media queries are great for creating responsive web designs but they do not always provide enough control. There are times when not all of the content, JavaScript or CSS on a page is relevant for a particular device. With the mobble functions you can make these kind of tweaks to your theme.

mobble can also add device information to the body class of your theme allowing you to easily target your CSS for different gadgets.

プラグイン制作 by Scott Evans

スクリーンショット

  • Code example - loading different navigations for mobile and desktop.
  • mobble settings screen for enabling/disabling the body class.

インストール

このプラグインをインストールするには:

  1. Upload the mobble folder to the /wp-content/plugins/ directory
  2. WordPress の「プラグイン」メニューからプラグインを有効化してください
  3. You can now use <?php is_mobile(); is_tablet(); // etc ?> functions in your themes/templates
  4. 必要に応じて、デバイス固有のクラス名をbodyに追加しないようにする事も可能です。
    管理画面->設定->mobble から設定を変更してください。

FAQ

Installation Instructions

このプラグインをインストールするには:

  1. Upload the mobble folder to the /wp-content/plugins/ directory
  2. WordPress の「プラグイン」メニューからプラグインを有効化してください
  3. You can now use <?php is_mobile(); is_tablet(); // etc ?> functions in your themes/templates
  4. 必要に応じて、デバイス固有のクラス名をbodyに追加しないようにする事も可能です。
    管理画面->設定->mobble から設定を変更してください。
どんな関数が利用できますか ?

もっとも使うのはこの形でしょう。

<?php
is_handheld(); // any handheld device (phone, tablet, Nintendo)
is_mobile(); // any type of mobile phone (iPhone, Android, etc)
is_tablet(); // any tablet device
is_ios(); // any Apple device (iPhone, iPad, iPod)
?>

次のものを使用することもできます:

<?php
is_iphone();
is_ipad();
is_ipod();
is_android();
is_blackberry();
is_opera_mobile();
is_symbian();
is_kindle();
is_windows_mobile();
is_motorola();
is_samsung();
is_samsung_tablet();
is_sony_ericsson();
is_nintendo();
?>

Inspecting Mobile_Detect.php will also reveal some other useful tools.

使用例

Yup. This first example disables the sidebar for mobile/phone devices:

<?php
if (!is_mobile()) {
    get_sidebar();
}
?>

次の例では、Apple のデバイス (iPhone、iPod、iPad) の場合に特定のスタイルシートを読み込んでいます。

<?php
if (is_ios()) {
    wp_enqueue_style('ios', get_template_directory_uri() . '/ios.css');
}
?>
キャッシュについて

特定の設定では、キャッシュが望ましくない動作を引き起こすことに注意してください。あなたのキャッシュがあまりにもアグレッシブに設定されていると、PHP がスキップされ、デバイス検出が機能しないことがあります。

評価

2017年9月14日
This plugin can be very useful, I used it to implement a "View desktop version" so thanks for your work! 🙂
2017年1月21日 1 reply
hey scott, just wanted to drop by and to say thank you! for the time and effort that went into creating and maintaining this plugin. I use it in any project and it made my life a lot easier
44件のレビューをすべて表示

貢献者と開発者

mobble はオープンソースソフトウェアです。以下の人々がこのプラグインに貢献しています。

貢献者

“mobble” は2ロケールに翻訳されています。 翻訳者のみなさん、翻訳へのご協力ありがとうございます。

“mobble” をあなたの言語に翻訳しましょう。

開発に興味がありますか ?

コードを閲覧するか、SVN リポジトリをチェックするか、開発ログRSS で購読してみてください。

変更履歴

1.6

  • Mobile Detect 2.8.24
  • Add edge body class (props Luca Speranza)
  • Add filters to functions (props Matthew Keasling)

1.5

  • Add German translation (props @rpkoller)
  • Minor PHP improvements
  • Mobile Detect 2.8.17

1.4

  • Run through PHP tidy
  • Mobile detect update to 2.8.13

1.3

  • Update mobile detect library to 2.7.6
  • Small CSS change for 3.8

1.2.1

  • Small bug fix on is_mobile()
  • Moved screenshots out of trunk

1.2

  • Now uses mobile-detect (http://mobiledetect.net/) which provides more accurate and varied detection
  • Mobiles can now be graded (A,B,C) using the mobile-detect API (see mobile-detect.php) or mobiledetect.net
  • is_palm, is_lg, is_nokia will be removed soon – check depricated notices
  • New check for is_kindle – feedback on this one appreciated as I cannot test it

1.1

  • Correction to the PHP.
  • New body class of .desktop for anything not handheld
  • Tested on 3.2+

1.0

  • 最初のリリース。