-
Notifications
You must be signed in to change notification settings - Fork 844
Moving jetpack_is_mobile into a package #16129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d1f5cd3
Moving jetpack_is_mobile into a package [not verified]
dero 797dbc1
Add is_mobile tests [not verified]
dero 99878a0
Add tests for UA returned value [not verified]
dero 96545e4
Update the class comment and is_mobile method comments. [not verified]
dero 5ea57ae
Rename Mobile package to Device Detection.
dero 4a9724d
Rename Mobile to Device_Detection, implement get_info, update tests […
dero 5b8bc41
Add shorthand methods, update tests. [not verified]
dero 2965e8d
Update Device_Detection package README.
dero 6108e07
Make User_Agent_Info park of Device_Detection package. [not verified]
dero 45a2fdd
Address CR feedback.
dero acc31ff
[not verified] Merge branch 'master' into add/jetpack-mobile-package
gravityrail e336e87
[not verified] Restore master branch versions of unrelated files with…
gravityrail f74e9c9
Add the Jetpack_User_Agent_Info class back. Add deprecation notices.
dero 86bc887
Merge branch 'add/jetpack-mobile-package' of github.com:Automattic/je…
dero b1f20eb
Use __METHOD__ instead of __FUNCTION__.
dero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Address CR feedback.
- Loading branch information
commit 45a2fdd44e7c7e92b34a312e8f2c5105e9ac1d3f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,8 @@ | ||
| <?php | ||
|
|
||
| use Automattic\Jetpack\Device_Detection; | ||
|
|
||
| /** | ||
| * Determine if the current User Agent matches the passed $kind | ||
| * | ||
| * @param string $kind Category of mobile device to check for. | ||
| * Either: any, dumb, smart. | ||
| * @param bool $return_matched_agent Boolean indicating if the UA should be returned | ||
| * Deprecated. No longer needed. | ||
| * | ||
| * @return bool|string Boolean indicating if current UA matches $kind. If | ||
| * $return_matched_agent is true, returns the UA string | ||
| * @package Jetpack | ||
| */ | ||
| function jetpack_is_mobile( $kind = 'any', $return_matched_agent = false ) { | ||
| $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_phone']; | ||
| } elseif ( 'smart' === $kind ) { | ||
| $return = $device_info['is_smartphone']; | ||
| } elseif ( 'dumb' === $kind ) { | ||
| $return = $device_info['is_phone'] && ! $device_info['is_smartphone']; | ||
| } | ||
|
|
||
| if ( $return_matched_agent && true === $return ) { | ||
| $return = $device_info['is_phone_matched_ua']; | ||
| } | ||
|
|
||
| return apply_filters( 'jetpack_is_mobile', $return, $kind, $return_matched_agent ); | ||
| } | ||
| // Silence is golden. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.