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

Generate manifest using WP_Serve_File #2

Open
marco-c opened this issue Nov 1, 2016 · 4 comments
Open

Generate manifest using WP_Serve_File #2

marco-c opened this issue Nov 1, 2016 · 4 comments

Comments

@marco-c
Copy link

marco-c commented Nov 1, 2016

The current mechanism you're using is bound to fail in many WordPress configurations. WP_Serve_File supports several ways to generate the manifest file (it will always use the best option according to the permissions the WordPress configuration has).

@collimarco
Copy link
Contributor

The problem with your solution is that it will fail if other plugins need to serve a manifest. The same can be said for the service worker. This is because you cannot have multiple manifests or service workers for the same page.

The solution used for this plugin allows to merge the contents of that files in case they are already in use for other purposes. I don't see any way to achieve that with WP_Serve_File.

@marco-c
Copy link
Author

marco-c commented Dec 19, 2016

If there's already a manifest.json file, you can read it and add your contents to the already existing content and then serve it via WP_Serve_File.

@collimarco
Copy link
Contributor

collimarco commented Dec 19, 2016

Yes, I understand that. However what if multiple plugins generate the files (manifest, service worker) dynamically? There would be a conflict.
Correct me if I am wrong, but I think that it's a better practice to write that files on disk: if everyone does so, there won't be any conflict. Moreover the user can solve any issue manually.

@marco-c
Copy link
Author

marco-c commented Dec 19, 2016

The problem is that you can't know what other plugins are doing, so even if you write the file on disk, you don't know if you're compatible with other plugins.
Notice that WP_Serve_File will write a file on disk if possible, if it isn't possible it will serve it dynamically: https://github.com/marco-c/WP_Serve_File/blob/master/WP_Serve_File.php#L46.

In theory the best solution would be to have a WordPress API for this, but it isn't available for now.

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