Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions class.jetpack-user-agent.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Automattic\Jetpack\Mobile;
use Automattic\Jetpack\Device_Detection;

/**
* Determine if the current User Agent matches the passed $kind
Expand All @@ -13,5 +13,25 @@
* $return_matched_agent is true, returns the UA string
*/
function jetpack_is_mobile( $kind = 'any', $return_matched_agent = false ) {
return Mobile::is_mobile( $kind, $return_matched_agent );
$pre = apply_filters( 'pre_jetpack_is_mobile', null, $kind, $return_matched_agent );
if ( $pre ) {
return $pre;
}

$return = false;
$device_info = Device_Detection::get_info();

if ( 'any' === $kind ) {
$return = $device_info['is_mobile'];
} elseif ( 'smart' === $kind ) {
$return = $device_info['is_smartphone'];
} elseif ( 'dumb' === $kind ) {
$return = $device_info['is_mobile'] && ! $device_info['is_smartphone'];
}

if ( $return_matched_agent && true === $return ) {
$return = $device_info['is_mobile_matched_ua'];
}

return apply_filters( 'jetpack_is_mobile', $return, $kind, $return_matched_agent );
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"automattic/jetpack-config": "@dev",
"automattic/jetpack-connection": "@dev",
"automattic/jetpack-constants": "@dev",
"automattic/jetpack-device-detection": "@dev",
"automattic/jetpack-error": "@dev",
"automattic/jetpack-jitm": "@dev",
"automattic/jetpack-logo": "@dev",
"automattic/jetpack-mobile": "@dev",
"automattic/jetpack-options": "@dev",
"automattic/jetpack-partner": "@dev",
"automattic/jetpack-redirect": "@dev",
Expand Down
62 changes: 31 additions & 31 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading