Skip to content

Commit d9fef8a

Browse files
committed
Add block support and WP version check for Social Web page
The Social Web dashboard page is now only added if the site supports blocks and the WordPress version is 6.9 or higher. This ensures compatibility with new features and prevents issues on unsupported setups.
1 parent 382fcbc commit d9fef8a

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

includes/wp-admin/class-menu.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Activitypub\WP_Admin;
99

10+
use function Activitypub\site_supports_blocks;
1011
use function Activitypub\user_can_activitypub;
1112

1213
/**
@@ -35,16 +36,19 @@ public static function admin_menu() {
3536
if ( user_can_activitypub( \get_current_user_id() ) ) {
3637
$capability = ACTIVITYPUB_BLOG_MODE === \get_option( 'activitypub_actor_mode' ) ? 'manage_options' : 'activitypub';
3738

38-
$social_web_hook = \add_dashboard_page(
39-
\__( 'Social Web', 'activitypub' ),
40-
\__( 'Social Web', 'activitypub' ),
41-
$capability,
42-
'activitypub-social-web',
43-
array( Social_Web::class, 'render_page' )
44-
);
39+
// Check for block support and WP version.
40+
if ( site_supports_blocks() && \version_compare( \get_bloginfo( 'version' ), '6.9', '>=' ) ) {
41+
$app_hook = \add_dashboard_page(
42+
\__( 'Social Web', 'activitypub' ),
43+
\__( 'Social Web', 'activitypub' ),
44+
$capability,
45+
'activitypub-social-web',
46+
array( Social_Web::class, 'render_page' )
47+
);
4548

46-
\add_action( 'load-' . $social_web_hook, array( Social_Web::class, 'remove_admin_notices' ) );
47-
\add_action( 'admin_print_scripts-' . $social_web_hook, array( Social_Web::class, 'enqueue_scripts' ) );
49+
\add_action( 'load-' . $app_hook, array( Social_Web::class, 'remove_admin_notices' ) );
50+
\add_action( 'admin_print_scripts-' . $app_hook, array( Social_Web::class, 'enqueue_scripts' ) );
51+
}
4852

4953
$followers_list_page = \add_users_page(
5054
\__( 'Followers ⁂', 'activitypub' ),

0 commit comments

Comments
 (0)