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
It looks like they are using the rest_prepare_xxx filters to add that entity to a global array. That works well with _embed=true because the rest_prepare_xxx filters of the embedded entities are also called.
My question is: why did you choose to extract the entities from the fields present in the response? Is there a benefit from doing so, or did you find that the Pantheon's approach has some edge cases that are not covered?
The text was updated successfully, but these errors were encountered:
To be honest, we never thought about doing it that way :P
When we initially developed the wp-rest-cache plugin it was for our internal projects. And in those projects we use Advanced Custom Fields together with the ACF to REST API plugin. Now in these ACF fields we use the Post Object field, this post object is also include in the REST response and doesn't use any of the rest_prepare_xxx filters. So since we wanted those entities to also be considered we needed a different approach.
However, I do like the rest_prepare_xxx approach especially since that method would still work correctly when using the _fields parameter. If you would do a request with ?_fields=id,title our approach breaks...
Now since internally we have been using / developing an ACF to REST API add-on for WP REST Cache, we could move the logic for those cases to the add-on and have the WP REST Cache plugin switch to the rest_prepare_xxx approach. So I am adding this to our list of future improvements.
Hey guys, I was taking a look at the code and I saw that the approach you use is different than what the Pantheon people is doing:
It looks like they are using the
rest_prepare_xxx
filters to add that entity to a global array. That works well with_embed=true
because therest_prepare_xxx
filters of the embedded entities are also called.My question is: why did you choose to extract the entities from the fields present in the response? Is there a benefit from doing so, or did you find that the Pantheon's approach has some edge cases that are not covered?
The text was updated successfully, but these errors were encountered: