diff --git a/README.md b/README.md index 02be35a..bdbfb9c 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,8 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu ### Next ### +* Compatibility: allow deactivating blocks registered by the plugin. +* Compatibility: avoid Fatal Errors when using ClassicPress. * Fixed: fix a typo in a hook name. ### 1.0.0 ### diff --git a/activitypub.php b/activitypub.php index abb68d9..897a928 100644 --- a/activitypub.php +++ b/activitypub.php @@ -15,6 +15,8 @@ namespace Activitypub; +use function Activitypub\site_supports_blocks; + \defined( 'ACTIVITYPUB_REST_NAMESPACE' ) || \define( 'ACTIVITYPUB_REST_NAMESPACE', 'activitypub/1.0' ); /** @@ -52,10 +54,13 @@ function init() { Admin::init(); Hashtag::init(); Shortcodes::init(); - Blocks::init(); Mention::init(); Health_Check::init(); Scheduler::init(); + + if ( site_supports_blocks() ) { + Blocks::init(); + } } \add_action( 'init', __NAMESPACE__ . '\init' ); diff --git a/includes/functions.php b/includes/functions.php index 2b7a378..47d9249 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -457,3 +457,22 @@ if ( ! function_exists( 'get_self_link' ) ) { return esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . $path ) ) ); } } + +/** + * Check if a site supports the block editor. + * + * @return boolean True if the site supports the block editor, false otherwise. + */ +function site_supports_blocks() { + if ( ! \function_exists( 'register_block_type_from_metadata' ) ) { + return false; + } + + /** + * Allow plugins to disable block editor support, + * thus disabling blocks registered by the ActivityPub plugin. + * + * @param boolean $supports_blocks True if the site supports the block editor, false otherwise. + */ + return apply_filters( 'activitypub_site_supports_blocks', true ); +} diff --git a/readme.txt b/readme.txt index 653cb48..9f1fed6 100644 --- a/readme.txt +++ b/readme.txt @@ -107,6 +107,8 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu = Next = +* Compatibility: allow deactivating blocks registered by the plugin. +* Compatibility: avoid Fatal Errors when using ClassicPress. * Fixed: fix a typo in a hook name. = 1.0.0 =