WordPress / revisions-extended

71 stars 11 forks source link

Turn off the excerpt at the api level. #109

Closed StevenDufresne closed 3 years ago

StevenDufresne commented 3 years ago

This is an example PR and an alternative to #108.

Currently, this PR uses the filter_response_by_context inherited method to determine if the parent supports the excerpt and turns it off. This is most likely not the best place for this check, as it's not an expected place to change the functionality of the underlying post type but after reading the documentation, I wasn't sure what made the most sense. Any ideas?

I think it makes more sense to have this code in the backend because it means that Gutenberg will be responsible for turning it off. It will do a better job upping its priority, limit the 'flash' on load and future proof our code.

coreymckrill commented 3 years ago

It's too bad there's not a place to filter the results of post_type_supports as that would allow us to adjust this more consistently. I'm a little worried this will turn into a whack-a-mole as we find other places where there's a check on support for excerpts that we'll need to adjust depending on the parent post type. But for now, this seems like a good approach.

StevenDufresne commented 3 years ago

@coreymckrill I committed your suggestion.

What about the function where we are modifying the post type; filter_response_by_context. Are we okay with it? I looked for another hook and still can't find a place to add that code.

coreymckrill commented 3 years ago

Yeah, I'm not sure filter_response_by_context is the best place to add it, but I don't have any better ideas right now. We can change it later if it turns out to be a problem.