You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think Foxhound is an awesome theme and a big step forward for the entire WP theming community, kudos!
It seems like one of the major challenges that still needs to be solved is allowing the user to set arbitrary permalinks. I don't have a solution for that, but I figured I'd start an issue so we can all brainstorm ideas.
I'm guessing the problem is that the JS client doesn't know which endpoint it should query for the data, because the only thing it knows is the URI. Are there any other problems besides that one?
My first thought on the unknown endpoint issue would be something like this:
Setup a custom endpoint which receives a URI as a parameter, e.g., https://example.org/wp-json/foxhound/v1/uri/contact-us or https://example.org/wp-json/foxhound/v1/uri/2017/03/foo-bar
That endpoint can look up the corresponding post/term/author/whatever data, and the appropriate theme template (single, page, archive, etc) using the same functions that WP does when it processes requests server-side.
The endpoint could prepare the data using the corresponding API controller
The endpoint could tell the client which template to use by sending a custom HTTP header, like X-Foxhound-Template
Another idea would be to have client make a request to https://example.org/wp-json/foxhound/v1/uri/contact-us/json or https://example.org/2017/03/foo-bar/json directly, and let WP do the normal work of looking up the data/template on it's own, but then have Foxhound hook in at template_redirect or earlier and prepare the data using the appropriate API controller, then output it with wp_send_json(). I'm guessing this would be slower than the custom API endpoint, but I haven't tested that.
I haven't tested either of those ideas, so there could be big holes in them, but hopefully it's enough to start a discussion that leads to something.
The text was updated successfully, but these errors were encountered:
@iandunn Either the first or the second idea are worth considering. Ideally you don't want to recreate existing core functionality of WordPress in JavaScript.
I think Foxhound is an awesome theme and a big step forward for the entire WP theming community, kudos!
It seems like one of the major challenges that still needs to be solved is allowing the user to set arbitrary permalinks. I don't have a solution for that, but I figured I'd start an issue so we can all brainstorm ideas.
I'm guessing the problem is that the JS client doesn't know which endpoint it should query for the data, because the only thing it knows is the URI. Are there any other problems besides that one?
My first thought on the unknown endpoint issue would be something like this:
https://example.org/wp-json/foxhound/v1/uri/contact-us
orhttps://example.org/wp-json/foxhound/v1/uri/2017/03/foo-bar
X-Foxhound-Template
Another idea would be to have client make a request to
https://example.org/wp-json/foxhound/v1/uri/contact-us/json
orhttps://example.org/2017/03/foo-bar/json
directly, and let WP do the normal work of looking up the data/template on it's own, but then have Foxhound hook in attemplate_redirect
or earlier and prepare the data using the appropriate API controller, then output it withwp_send_json()
. I'm guessing this would be slower than the custom API endpoint, but I haven't tested that.I haven't tested either of those ideas, so there could be big holes in them, but hopefully it's enough to start a discussion that leads to something.
The text was updated successfully, but these errors were encountered: