Skip to content
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

filter content if Offload Media plugin is installed #83

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Blocks/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,13 @@ public static function get_editor_post_types()
})
);
}

public static function apply_content_filters($content)
{
if (class_exists('Amazon_S3_And_CloudFront_Pro') || class_exists('Amazon_S3_And_CloudFront')) {
$content = apply_filters('as3cf_filter_post_local_to_provider', $content);
}

return $content;
}
}
5 changes: 3 additions & 2 deletions src/PostTypes/BlockEditorPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use WPGraphQL\Utils\Utils;
use WPGraphQLGutenberg\Blocks\Block;
use WPGraphQLGutenberg\Blocks\Registry;
use WPGraphQLGutenberg\Blocks\Utils as BlockUtils;
use WPGraphQLGutenberg\Schema\Utils as SchemaUtils;

if (!defined('WP_GRAPHQL_GUTENBERG_PREVIEW_POST_TYPE_NAME')) {
Expand Down Expand Up @@ -247,7 +248,7 @@ function ($query_args, $source, $args, $context, $info) {
'type' => ['list_of' => ['non_null' => 'Block']],
'resolve' => function ($model) {
return Block::create_blocks(
parse_blocks(get_post($model->ID)->post_content),
parse_blocks(BlockUtils::apply_content_filters(get_post($model->ID)->post_content)),
$model->ID,
Registry::get_registry()
);
Expand All @@ -273,7 +274,7 @@ function ($query_args, $source, $args, $context, $info) {
'resolve' => function ($model) {
return json_encode(
Block::create_blocks(
parse_blocks(get_post($model->ID)->post_content),
parse_blocks(BlockUtils::apply_content_filters(get_post($model->ID)->post_content)),
$model->ID,
Registry::get_registry()
)
Expand Down
9 changes: 5 additions & 4 deletions src/Schema/Types/InterfaceType/BlockEditorContentNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GraphQL\Deferred;
use WPGraphQLGutenberg\Blocks\Block;
use WPGraphQLGutenberg\Blocks\Utils as BlockUtils;
use WPGraphQLGutenberg\Schema\Utils;
use WPGraphQLGutenberg\Blocks\Registry;
use WPGraphQLGutenberg\PostTypes\BlockEditorPreview;
Expand All @@ -20,7 +21,7 @@ function __construct() {
'description' => __('Gutenberg blocks', 'wp-graphql-gutenberg'),
'resolve' => function ($model, $args, $context, $info) {
return Block::create_blocks(
parse_blocks(get_post($model->ID)->post_content),
parse_blocks(BlockUtils::apply_content_filters(get_post($model->ID)->post_content)),
$model->ID,
Registry::get_registry()
);
Expand All @@ -31,7 +32,7 @@ function __construct() {
'description' => __('Gutenberg blocks as json string', 'wp-graphql-gutenberg'),
'resolve' => function ($model, $args, $context, $info) {
$blocks = Block::create_blocks(
parse_blocks(get_post($model->ID)->post_content),
parse_blocks(BlockUtils::apply_content_filters(get_post($model->ID)->post_content)),
$model->ID,
Registry::get_registry()
);
Expand All @@ -50,7 +51,7 @@ function ($model) {

if (!empty($id)) {
return Block::create_blocks(
parse_blocks(get_post($id)->post_content),
parse_blocks(BlockUtils::apply_content_filters(get_post($id)->post_content)),
$id,
Registry::get_registry()
);
Expand All @@ -73,7 +74,7 @@ function ($model) {
if (!empty($id)) {
return json_encode(
Block::create_blocks(
parse_blocks(get_post($id)->post_content),
parse_blocks(BlockUtils::apply_content_filters(get_post($id)->post_content)),
$id,
Registry::get_registry()
)
Expand Down
5 changes: 3 additions & 2 deletions src/Schema/Types/Object/ReusableBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace WPGraphQLGutenberg\Schema\Types\Object;

use WPGraphQLGutenberg\Blocks\Block;
use WPGraphQLGutenberg\Blocks\Utils as BlockUtils;
use WPGraphQLGutenberg\Blocks\Registry;
use WPGraphQLGutenberg\PostTypes\BlockEditorPreview;
use WPGraphQLGutenberg\Schema\Utils;
Expand Down Expand Up @@ -35,7 +36,7 @@ function ($model, $args) {

if (!empty($id)) {
return Block::create_blocks(
parse_blocks(get_post($id)->post_content),
parse_blocks(BlockUtils::apply_content_filters(get_post($id)->post_content)),
$id,
Registry::get_registry()
);
Expand Down Expand Up @@ -71,7 +72,7 @@ function ($model, $args) {
if (!empty($id)) {
return json_encode(
Block::create_blocks(
parse_blocks(get_post($id)->post_content),
parse_blocks(BlockUtils::apply_content_filters(get_post($id)->post_content)),
$id,
Registry::get_registry()
)
Expand Down