From 8ea02b28c2bded2c717a1a42c32316477be70153 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Fri, 18 Oct 2024 10:46:47 +0000 Subject: [PATCH] chore: lint --- includes/Blocks/Block.php | 2 +- includes/Model/Block.php | 11 ++--------- includes/Utilities/DOMHelpers.php | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/includes/Blocks/Block.php b/includes/Blocks/Block.php index 8a4272b2..e1d026a3 100644 --- a/includes/Blocks/Block.php +++ b/includes/Blocks/Block.php @@ -8,7 +8,7 @@ namespace WPGraphQL\ContentBlocks\Blocks; use WPGraphQL\ContentBlocks\Data\BlockAttributeResolver; -use \WPGraphQL\ContentBlocks\Model\Block as BlockModel; +use WPGraphQL\ContentBlocks\Model\Block as BlockModel; use WPGraphQL\ContentBlocks\Registry\Registry; use WPGraphQL\ContentBlocks\Type\Scalar\Scalar; use WPGraphQL\ContentBlocks\Utilities\WPGraphQLHelpers; diff --git a/includes/Model/Block.php b/includes/Model/Block.php index b2bf64c8..9e423b25 100644 --- a/includes/Model/Block.php +++ b/includes/Model/Block.php @@ -56,6 +56,7 @@ public function __construct( \WP_Block $block ) { if ( ! $this->data->block_type ) { graphql_debug( sprintf( + // translators: %s is the block name. __( 'Block type not found for block: %s', 'wp-graphql-content-blocks' ), $this->data->name ?: 'Unknown' ), @@ -154,14 +155,6 @@ protected function resolve_attributes(): array { protected function resolve_attribute( string $attribute_name ) { $attribute_config = $this->data->block_type->attributes[ $attribute_name ] ?? []; - return BlockAttributeResolver::resolve_block_attribute( $attribute_config, $this->get_rendered_block(), $this->data->attributes[ $attribute_name ] ); - - $allowed_types = [ 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' ]; - // If attribute type is set and valid, sanitize value. - if ( isset( $attribute['type'] ) && in_array( $attribute_config['type'], $allowed_types, true ) && rest_validate_value_from_schema( $result, $attribute_config ) ) { - $result = rest_sanitize_value_from_schema( $result, $attribute_config ); - } - - return $result; + return BlockAttributeResolver::resolve_block_attribute( $attribute_config, $this->get_rendered_block() ?? '', $this->data->attributes[ $attribute_name ] ); } } diff --git a/includes/Utilities/DOMHelpers.php b/includes/Utilities/DOMHelpers.php index 4f76b879..82381fcb 100644 --- a/includes/Utilities/DOMHelpers.php +++ b/includes/Utilities/DOMHelpers.php @@ -37,7 +37,7 @@ public static function parse_attribute( string $html, string $selector, string $ $selector = '*'; } - $nodes = $doc->find( $selector ); + $nodes = $doc->find( $selector ); foreach ( $nodes as $node ) { if ( $node->hasAttribute( $attribute ) ) {