Fine-grained disable the block editor - #2496
Conversation
The parent class already implements this as a no-op
|
PR to update Action Scheduler version to match WooCommerce version has been created: #2514 |
| */ | ||
| public function should_load_blocks_for_post_type( string $post_type = '' ): bool { | ||
| // Set up a static variable to ensure we don't check the same post type multiple times. | ||
| static $checked_post_types = []; |
There was a problem hiding this comment.
Use tribe_cache()[ $cache_key ] (ArrayAccess API) for memoization. Static variables will not flush on wp_cache_flush calls making programmatic cache invalidation difficult (includes test, but not only those).
There was a problem hiding this comment.
On the topic of memoization: is this worth it? Are there so many calls to this method to justify it and run the risk of serving a stale result (e.g. because the post types have been filtered later)?
It looks like the expensive call in this method is the one to $this->determine_current_post_type(); should that method memoized?
I'm asking this question as I do not have an order of how many calls are made to this method.
There was a problem hiding this comment.
On the topic of memoization: is this worth it? Are there so many calls to this method to justify it and run the risk of serving a stale result (e.g. because the post types have been filtered later)?
My thought process here was that every place that calls should_load_blocks() could potentially get to this method as well. Because this method runs apply_filters(), and that isn't necessarily a light call, I wanted to minimize the number of times the logic needs to run.
With that said, I can switch to tribe_cache() instead.
I'm asking this question as I do not have an order of how many calls are made to this method.
At the moment it's only called in one place. However, I was trying to be defensive about it ahead of time, knowing how the calls are likely to expand over time.
| } | ||
|
|
||
| // Try to use the global post object. | ||
| if ( isset( $GLOBALS['post']->post_type ) ) { |
There was a problem hiding this comment.
Will this work reliably in REST API and Ajax context?
There was a problem hiding this comment.
Will this work reliably in REST API and Ajax context?
That's a good question: I think it would make sense to have a separate case for those situations outside of this method, since the post type isn't as relevant in those contexts.
🎫 Ticket
[TICKET_ID]
🗒️ Description
🎥 Artifacts
✔️ Checklist
npm run changelogto add changelog file(s). More info herewpunitorintegrationtests.wpunitorintegrationtests.