Add mobile web app support (Add to Home Screen)#91
Conversation
Enable Press This to work as a standalone mobile web app via Add to Home Screen on Android and iOS. Adds Web App Manifest with Share Target API support, app icons, mobile web app meta tags, and standalone mode UI handling. Closes #2 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds Progressive Web App (Add to Home Screen) support for Press This, including a web app manifest endpoint and UI behavior tweaks for standalone display mode.
Changes:
- Serve a Web App Manifest via a new public REST endpoint, including Share Target support.
- Add standalone-mode behavior adjustments (redirect behavior + menu items).
- Add mobile web app meta tags and icon/manifest links in the Press This HTML head.
Reviewed changes
Copilot reviewed 5 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/PressThisEditor.js | Detects standalone mode to adjust redirect behavior. |
| src/components/Header.js | Adds standalone-only menu items and standalone detection. |
| press-this-plugin.php | Registers a new REST route and returns the manifest JSON. |
| includes/class-press-this-assets.php | Syncs script dependencies by adding wp-keyboard-shortcuts. |
| class-wp-press-this-plugin.php | Injects mobile web app meta tags and manifest/icon links. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Set Content-Type to application/manifest+json per W3C spec. Localize the app name in both the manifest endpoint and the apple-mobile-web-app-title meta tag for translation support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 10 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace string-matching tests (reading source with fs.readFileSync and checking for substrings) with proper behavioral tests that import isStandaloneMode() and assert return values against mocked browser APIs. Covers: matchMedia standalone match, navigator.standalone (iOS Safari), neither condition met, and matchMedia unavailable (graceful degradation).
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 11 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 11 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 12 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Resolve conflicts in Header.js: keep both standalone mode (mobile-web-app) and scheduling (trunk) features, with standalone menu items in their own MenuGroup inside the dropdown.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 11 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
tests/php/test-rest-endpoints.php:116
- Since this test suite now includes a GET-only
/press-this/v1/manifestroute, the later test docblockTest that all routes use POST method.is no longer accurate (it only checks the POST routes list). Consider updating that docblock (and/or the test name) to clarify it asserts POST methods only for the POST routes, to avoid confusion when adding future GET routes.
* Test that all 5 REST routes are registered.
*/
public function test_routes_are_registered() {
do_action( 'rest_api_init' );
$server = rest_get_server();
$routes = $server->get_routes();
$this->assertArrayHasKey( '/press-this/v1/manifest', $routes );
$this->assertArrayHasKey( '/press-this/v1/scrape', $routes );
$this->assertArrayHasKey( '/press-this/v1/save', $routes );
$this->assertArrayHasKey( '/press-this/v1/sideload', $routes );
$this->assertArrayHasKey( '/press-this/v1/validate-embeds', $routes );
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds missing tab level to match sibling MenuGroup indentation, fixing prettier/prettier lint errors.
Summary
Enables Press This to work as a standalone mobile web app that can be added to the home screen on Android and iOS. Implements the core features from #2 (originally WordPress core Trac #33195).
/press-this/v1/manifest) with Share Target API support (Android)mobile-web-app-capable,apple-mobile-web-app-capable,theme-color, etc.)window.close()in redirects, add "View Site" and "New Post" menu itemsShare Target
The manifest
share_targetreuses Press This's existing GET params (?u=...&t=...), so sharing a URL from another Android app opens Press This with the URL pre-filled — no editor changes needed.Future enhancements
These are out of scope for this PR but documented for future work:
apple-touch-startup-imagetags per device resolutionPOST+multipart/form-dataTest plan
<head>/wp-json/press-this/v1/manifest— confirm valid JSON with correct dynamic URLswindow.close()