File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -685,3 +685,31 @@ function is_html( $string ) { // phpcs:ignore Universal.NamingConventions.NoRese
685
685
return ( wp_strip_all_tags ( $ string ) !== $ string );
686
686
}
687
687
}
688
+
689
+ /**
690
+ * Check if a site supports the block editor.
691
+ *
692
+ * @return boolean True if the site supports the block editor, false otherwise.
693
+ */
694
+ function site_supports_blocks () {
695
+ $ return = true ;
696
+
697
+ if ( \version_compare ( \get_bloginfo ( 'version ' ), '5.9 ' , '< ' ) ) {
698
+ $ return = false ;
699
+ } elseif ( \function_exists ( 'classicpress_version ' ) ) {
700
+ $ return = false ;
701
+ } elseif (
702
+ ! \function_exists ( 'register_block_type_from_metadata ' ) ||
703
+ ! \function_exists ( 'do_blocks ' )
704
+ ) {
705
+ $ return = false ;
706
+ }
707
+
708
+ /**
709
+ * Allow plugins to disable block editor support,
710
+ * thus disabling blocks registered by the Webmentions plugin.
711
+ *
712
+ * @param boolean $supports_blocks True if the site supports the block editor, false otherwise.
713
+ */
714
+ return apply_filters ( 'webmention_site_supports_blocks ' , $ return );
715
+ }
Original file line number Diff line number Diff line change @@ -120,9 +120,11 @@ function init() {
120
120
require_once __DIR__ . '/includes/class-discovery.php ' ;
121
121
add_action ( 'init ' , array ( '\Webmention\Discovery ' , 'init ' ) );
122
122
123
- // initialize Webmention Bloks.
124
- require_once __DIR__ . '/includes/class-block.php ' ;
125
- add_action ( 'init ' , array ( '\Webmention\Block ' , 'init ' ) );
123
+ if ( site_supports_blocks () ) {
124
+ // initialize Webmention Bloks.
125
+ require_once __DIR__ . '/includes/class-block.php ' ;
126
+ add_action ( 'init ' , array ( '\Webmention\Block ' , 'init ' ) );
127
+ }
126
128
127
129
// load local avatar store.
128
130
if ( WEBMENTION_LOCAL_AVATAR_STORE ) {
You can’t perform that action at this time.
0 commit comments