jetpack
Last commit date
3rd-party
2 months ago
_inc
4 weeks ago
css
4 weeks ago
extensions
4 weeks ago
images
1 month ago
jetpack_vendor
4 weeks ago
json-endpoints
4 weeks ago
modules
4 weeks ago
sal
4 weeks ago
src
4 weeks ago
vendor
4 weeks ago
views
1 month ago
CHANGELOG.md
4 weeks ago
LICENSE.txt
5 months ago
SECURITY.md
2 years ago
class-jetpack-connection-status.php
2 years ago
class-jetpack-gallery-settings.php
6 months ago
class-jetpack-newsletter-dashboard-widget.php
6 months ago
class-jetpack-pre-connection-jitms.php
2 years ago
class-jetpack-stats-dashboard-widget.php
3 months ago
class-jetpack-xmlrpc-methods.php
6 months ago
class.frame-nonce-preview.php
6 months ago
class.jetpack-admin.php
1 month ago
class.jetpack-autoupdate.php
6 months ago
class.jetpack-cli.php
5 months ago
class.jetpack-client-server.php
2 years ago
class.jetpack-gutenberg.php
2 months ago
class.jetpack-heartbeat.php
3 months ago
class.jetpack-modules-list-table.php
6 months ago
class.jetpack-network-sites-list-table.php
6 months ago
class.jetpack-network.php
1 month ago
class.jetpack-plan.php
2 years ago
class.jetpack-post-images.php
2 months ago
class.jetpack-twitter-cards.php
3 months ago
class.jetpack-user-agent.php
2 years ago
class.jetpack.php
4 weeks ago
class.json-api-endpoints.php
1 month ago
class.json-api.php
5 months ago
class.photon.php
3 years ago
composer.json
4 weeks ago
enhanced-open-graph.php
3 months ago
functions.compat.php
3 months ago
functions.cookies.php
2 years ago
functions.global.php
1 month ago
functions.is-mobile.php
2 years ago
functions.opengraph.php
2 months ago
functions.photon.php
2 years ago
jetpack.php
4 weeks ago
json-api-config.php
3 years ago
json-endpoints.php
2 years ago
load-jetpack.php
2 months ago
locales.php
6 months ago
readme.txt
4 weeks ago
unauth-file-upload.php
6 months ago
uninstall.php
6 months ago
wpml-config.xml
3 years ago
functions.is-mobile.php
74 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase |
| 2 | /** |
| 3 | * This file holds a function that needs to be loaded before WordPress itself |
| 4 | * on WordPress.com. |
| 5 | * |
| 6 | * @package automattic/jetpack |
| 7 | */ |
| 8 | |
| 9 | use Automattic\Jetpack\Device_Detection; |
| 10 | |
| 11 | /** |
| 12 | * Determine if the current User Agent matches the passed $kind |
| 13 | * |
| 14 | * @param string $kind Category of mobile device to check for. |
| 15 | * Either: any, dumb, smart. |
| 16 | * @param bool $return_matched_agent Boolean indicating if the UA should be returned. |
| 17 | * |
| 18 | * @return bool|string Boolean indicating if current UA matches $kind. If |
| 19 | * $return_matched_agent is true, returns the UA string |
| 20 | */ |
| 21 | function jetpack_is_mobile( $kind = 'any', $return_matched_agent = false ) { |
| 22 | |
| 23 | if ( function_exists( 'apply_filters' ) ) { |
| 24 | /** |
| 25 | * Filter the value of jetpack_is_mobile before it is calculated. |
| 26 | * |
| 27 | * Passing a truthy value to the filter will short-circuit determining the |
| 28 | * mobile type, returning the passed value instead. |
| 29 | * |
| 30 | * @since 4.2.0 |
| 31 | * |
| 32 | * @param bool|string $matches Boolean if current UA matches $kind or not. If |
| 33 | * $return_matched_agent is true, should return the UA string |
| 34 | * @param string $kind Category of mobile device being checked |
| 35 | * @param bool $return_matched_agent Boolean indicating if the UA should be returned |
| 36 | */ |
| 37 | $pre = apply_filters( 'pre_jetpack_is_mobile', null, $kind, $return_matched_agent ); |
| 38 | if ( $pre ) { |
| 39 | return $pre; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | $return = false; |
| 44 | $device_info = Device_Detection::get_info(); |
| 45 | |
| 46 | if ( 'any' === $kind ) { |
| 47 | $return = $device_info['is_phone']; |
| 48 | } elseif ( 'smart' === $kind ) { |
| 49 | $return = $device_info['is_smartphone']; |
| 50 | } elseif ( 'dumb' === $kind ) { |
| 51 | $return = $device_info['is_phone'] && ! $device_info['is_smartphone']; |
| 52 | } |
| 53 | |
| 54 | if ( $return_matched_agent && true === $return ) { |
| 55 | $return = $device_info['is_phone_matched_ua']; |
| 56 | } |
| 57 | |
| 58 | if ( function_exists( 'apply_filters' ) ) { |
| 59 | /** |
| 60 | * Filter the value of jetpack_is_mobile |
| 61 | * |
| 62 | * @since 4.2.0 |
| 63 | * |
| 64 | * @param bool|string $matches Boolean if current UA matches $kind or not. If |
| 65 | * $return_matched_agent is true, should return the UA string |
| 66 | * @param string $kind Category of mobile device being checked |
| 67 | * @param bool $return_matched_agent Boolean indicating if the UA should be returned |
| 68 | */ |
| 69 | $return = apply_filters( 'jetpack_is_mobile', $return, $kind, $return_matched_agent ); |
| 70 | } |
| 71 | |
| 72 | return $return; |
| 73 | } |
| 74 |