Skip to content
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

Site installation errors in WP admin #222

Open
claudiulodro opened this issue Sep 4, 2019 · 5 comments
Open

Site installation errors in WP admin #222

claudiulodro opened this issue Sep 4, 2019 · 5 comments

Comments

@claudiulodro
Copy link

On every WP admin page I see an error in the console log that the site can't be installed because it has no link to the manifest. It's not really causing any issues, and technically it's correct (there is no manifest link in the admin), but it seems weird that it's trying to make site installation available on the site admin. I think either adding the manifest link in the admin header or disabling site installation in the admin would solve the issue nicely.

Screen Shot 2019-09-04 at 10 42 38 AM

@claudiulodro claudiulodro changed the title Don't offer site installation on WP admin Site installation errors in WP admin Sep 4, 2019
@westonruter
Copy link
Collaborator

Interesting. It's true the manifest is not being added to the admin. That could be fixed via:

diff --git a/wp-includes/class-wp-web-app-manifest.php b/wp-includes/class-wp-web-app-manifest.php
index bb3ac62..5c0d11e 100644
--- a/wp-includes/class-wp-web-app-manifest.php
+++ b/wp-includes/class-wp-web-app-manifest.php
@@ -60,6 +60,7 @@ class WP_Web_App_Manifest {
 	 */
 	public function init() {
 		add_action( 'wp_head', array( $this, 'manifest_link_and_meta' ) );
+		add_action( 'admin_head', array( $this, 'manifest_link_and_meta' ) );
 		add_action( 'rest_api_init', array( $this, 'register_manifest_rest_route' ) );
 		add_filter( 'site_status_tests', array( $this, 'add_short_name_site_status_test' ) );
 	}

But since the admin and the frontend have different service workers with different scopes, and since the admin and frontend can be on different domains entirely, perhaps the admin manifest should have a start_url that is pointing to admin_url()? Would this make sense then that a user could install a PWA for the frontend and a separate PWA for the admin?

@claudiulodro
Copy link
Author

Offline usage and Add to Homescreen don't really make sense for admin IMO. Offline usage especially won't work because no forms will be able to process and saved nonces will be invalid anyways.

The other PWA features could potentially be useful in admin context, though. I think the main case where the same service worker would be desired in both admin and frontend contexts would potentially be for push notifications? There may be other service worker use-cases I'm not familiar with.

@westonruter
Copy link
Collaborator

Eventually service workers will unlock the ability to author and edit posts while being completely offline: #47

When that happens, being able to install the admin to the homescreen would be more useful.

@claudiulodro
Copy link
Author

Great feature! Looking forward to that; I think it'll be super useful for writers!

@westonruter
Copy link
Collaborator

But since the admin and the frontend have different service workers with different scopes, and since the admin and frontend can be on different domains entirely, perhaps the admin manifest should have a start_url that is pointing to admin_url()? Would this make sense then that a user could install a PWA for the frontend and a separate PWA for the admin?

Proposed in #295.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants