Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine committed Oct 18, 2024
1 parent de18aa9 commit 8ea02b2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion includes/Blocks/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 2 additions & 9 deletions includes/Model/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
),
Expand Down Expand Up @@ -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 ] );
}
}
2 changes: 1 addition & 1 deletion includes/Utilities/DOMHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down

0 comments on commit 8ea02b2

Please sign in to comment.