- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5
Fix: Back-port compatibility fixes for wp-graphql-content-blocks to SnapWP Helper plugin #28
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -37,11 +37,11 @@ final class SchemaFilters implements Registrable { | |
| */ | ||
| public function register_hooks(): void { | ||
| // No need to check for dependencies, since missing filters will just be ignored. | ||
| add_filter( 'wpgraphql_content_blocks_handle_do_block', [ ContentBlocksResolver::class, 'handle_do_block' ], 10, 1 ); | ||
|          | ||
| add_filter( 'wpgraphql_content_blocks_resolver_content', [ $this, 'get_content_from_model' ], 10, 2 ); | ||
| add_filter( 'graphql_object_fields', [ $this, 'overload_content_blocks_resolver' ], 10 ); | ||
|  | ||
| // Cache rendered blocks. | ||
| add_filter( 'pre_render_block', [ $this, 'get_cached_rendered_block' ], 10, 2 ); // @todo: this should be as early priority as possible | ||
| add_filter( 'pre_render_block', [ $this, 'get_cached_rendered_block' ], 11, 2 ); // @todo: this should be as early priority as possible | ||
| // We want to cache the rendered block as late as possible to ensure we're caching the final output. | ||
| add_filter( 'render_block', [ $this, 'cache_rendered_block' ], PHP_INT_MAX - 1, 2 ); | ||
| } | ||
|  | @@ -60,27 +60,6 @@ public function get_content_from_model( $content, $model ): string { | |
| return $content; | ||
| } | ||
|  | ||
| /** | ||
| * Overloads the content blocks resolver to use ourn own resolver. | ||
| * | ||
| * @todo This is necessary because WPGraphQL Content Blocks' resolver is broken. | ||
| * | ||
| * @param array<string,mixed> $fields The config for the interface type. | ||
| * | ||
| * @return array<string,mixed> | ||
| */ | ||
| public function overload_content_blocks_resolver( array $fields ): array { | ||
| if ( ! isset( $fields['editorBlocks'] ) ) { | ||
| return $fields; | ||
| } | ||
|  | ||
| $fields['editorBlocks']['resolve'] = static function ( $node, $args ) { | ||
| return ContentBlocksResolver::resolve_content_blocks( $node, $args ); | ||
| }; | ||
|  | ||
| return $fields; | ||
| } | ||
|  | ||
| /** | ||
| * Get the cached rendered block. | ||
| * | ||
|  | @@ -99,7 +78,7 @@ public function get_cached_rendered_block( $block_content, $parsed_block ) { | |
| } | ||
|  | ||
| // Bail if block content is already set. | ||
| if ( null !== $block_content ) { | ||
| if ( null !== $block_content || empty( $parsed_block ) ) { | ||
| return $block_content; | ||
| } | ||
|  | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this it's unused and removed in v4.2.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed 🚀