Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1,642 changes: 3 additions & 1,639 deletions class.jetpack-user-agent.php

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Automattic\Jetpack\Tracking;
use Automattic\Jetpack\Plugin\Tracking as Plugin_Tracking;
use Automattic\Jetpack\Redirect;
use Automattic\Jetpack\Jetpack_User_Agent_Info;

/*
Options:
Expand Down Expand Up @@ -709,10 +710,14 @@ private function __construct() {
jetpack_require_lib( 'functions.wp-notify' );
}

// Hide edit post link if mobile app.
if ( Jetpack_User_Agent_Info::is_mobile_app() ) {
add_filter( 'get_edit_post_link', '__return_empty_string' );
}
add_action(
'plugins_loaded',
function() {
if ( Jetpack_User_Agent_Info::is_mobile_app() ) {
add_filter( 'get_edit_post_link', '__return_empty_string' );
}
}
);

// Update the Jetpack plan from API on heartbeats.
add_action( 'jetpack_heartbeat', array( 'Jetpack_Plan', 'refresh_from_wpcom' ) );
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"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
42 changes: 36 additions & 6 deletions composer.lock

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

4 changes: 4 additions & 0 deletions packages/mobile/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Files not needed to be distributed in the package.
.gitattributes export-ignore
phpunit.xml.dist export-ignore
tests/ export-ignore
31 changes: 31 additions & 0 deletions packages/mobile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Jetpack Constants

A method to detect mobile devices, formerly jetpack_is_mobile.



### Usage

Detect any mobile phone.

```php
use Automattic\Jetpack\Mobile;

$is_mobile = Mobile::is_mobile();
```

Detect a smartphone.

```php
use Automattic\Jetpack\Mobile;

$is_smartphone = Mobile::is_mobile( 'smart' );
```

Detect a dumbphone and return its UA.

```php
use Automattic\Jetpack\Mobile;

$is_smartphone = Mobile::is_mobile( 'dumb', true );
```
24 changes: 24 additions & 0 deletions packages/mobile/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "automattic/jetpack-mobile",
"description": "A method to detect mobile devices, formerly jetpack_is_mobile.",
"type": "library",
"license": "GPL-2.0-or-later",
"require": {},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5",
"php-mock/php-mock": "^2.1"
},
"autoload": {
"classmap": [
"src/"
]
},
"scripts": {
"phpunit": [
"@composer install",
"./vendor/phpunit/phpunit/phpunit --colors=always"
]
},
"minimum-stability": "dev",
"prefer-stable": true
}
7 changes: 7 additions & 0 deletions packages/mobile/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<phpunit bootstrap="tests/php/bootstrap.php" backupGlobals="false" colors="true">
<testsuites>
<testsuite name="main">
<directory prefix="test" suffix=".php">tests/php</directory>
</testsuite>
</testsuites>
</phpunit>
Loading