pristas-peter / wp-graphql-gutenberg

Query gutenberg blocks with wp-graphql
https://wp-graphql-gutenberg.netlify.app
GNU General Public License v3.0
299 stars 61 forks source link

Add a block attribute filter #124

Open jonsherrard opened 3 years ago

jonsherrard commented 3 years ago

Adds a new filter called graphql_gutenberg_block_attribute_value.

Each attribute value is run through this filter.

Inspiration was taken from here: https://github.com/pristas-peter/wp-graphql-gutenberg/issues/81

This allows user to run modify attributes from their functions.php or theme.

The most common use case will probably be running attribute values through WP Offload S3. Which allows users of that plugin to use WP GraphQL Gutenberg for blocks with images or any other media.

<?php
// In functions.php or plugin.php
function my_theme_modify_graphql_gutenberg_block_attribute($value) { 
  $value = apply_filters('as3cf_filter_post_local_to_provider', $value);
   return $value; 
} 

add_filter('graphql_gutenberg_block_attribute_value', 'my_theme_modify_graphql_gutenberg_block_attributes');