Charitable conflicts with FacetWP REST API
-
Unfortunately I don’t have a minimally reproducible test case for this or a URL where you can see the behavior because we need to get it fixed for our client, but here’s what we observed.
In v1.8.0, the
wp-content/plugins/charitable/includes/admin/class-charitable-admin-blocks.php
file uses a faked REST API request to check whether thecreate-block/campaignblock
block is registered.This resulted in some conflict with FacetWP and deregistered the
/wp-json/facetwp/v1/refresh
endpoint that FacetWP uses on the frontend, resulting in404
errors.Rather than using a fake REST API request, I propose using the
WP_Block_Type_Registry
class to check for the existence of the block to avoid similar unintended side effects.Here is a patch file showing the proposed changes that fix the issue for me:
diff --git a/wp-content/plugins/charitable/includes/admin/class-charitable-admin-blocks.php b/wp-content/plugins/charitable/includes/admin/class-charitable-admin-blocks.php index 093e3184a..6c5c7210d 100644 --- a/wp-content/plugins/charitable/includes/admin/class-charitable-admin-blocks.php +++ b/wp-content/plugins/charitable/includes/admin/class-charitable-admin-blocks.php @@ -80,16 +80,7 @@ if ( ! class_exists( 'Charitable_Admin_Blocks' ) ) : } private function is_block_registered( $block_name ) { - // Use REST API to query if block exists by <namespace>/<name>. - $route = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_name ); - $request = rest_do_request( $route ); - - if ( $request->status == 404 ) { - // Block is not found/registered. - return false; - } - // Block is registered (status is 200). - return true; + return WP_Block_Type_Registry::get_instance()->is_registered( $block_name ); } /**
- The topic ‘Charitable conflicts with FacetWP REST API’ is closed to new replies.