Skip to content

Commit fb04417

Browse files
t-hamanoramonjd3koripeterwilsoncc
authored
Fix Gutenberg plugin assuming its directory is named "gutenberg" (#78705)
* Fix broken Demo menu link when plugin directory is not named "gutenberg" The Demo submenu was registered without a callback, so add_submenu_page() never registered a page hook. In wp-admin/menu-header.php the menu URL then falls back to a file_exists() heuristic on WP_PLUGIN_DIR/{slug}, which only matches when the plugin folder is literally named "gutenberg". Running from gutenberg-build/ (or any other directory) makes the check fail, producing a broken /wp-admin/gutenberg link that 404s. Pass a no-op callback so the page hook is registered and the link becomes independent of the plugin directory name. The admin_init redirect still runs first, so the callback body never executes. Fixes #76473 * Fix plugin deactivation when plugin directory is not named "gutenberg" The version-check failure path hardcoded the plugin slug 'gutenberg/gutenberg.php', so deactivate_plugins() failed to match and the plugin kept running when installed under a different directory name (e.g. gutenberg-build/). Resolve the slug from the main file via plugin_basename( __FILE__ ) so deactivation works regardless of folder name. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Fix collaboration activation hook when plugin directory is not named "gutenberg" The activation hook was registered with the hardcoded slug 'activate_gutenberg/gutenberg.php', so it never fired when the plugin was installed under a different directory name (e.g. gutenberg-build/), leaving the wp_collaboration_enabled default option unset on activation. Build the hook name from the main file's basename via plugin_basename() so it matches the actual slug WordPress fires regardless of folder name. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: 3kori <r1k0@git.wordpress.org> Co-authored-by: peterwilsoncc <peterwilsoncc@git.wordpress.org>
1 parent bb021cc commit fb04417

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

gutenberg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function gutenberg_wordpress_version_notice() {
2727
printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), GUTENBERG_MINIMUM_WP_VERSION );
2828
echo '</p></div>';
2929

30-
deactivate_plugins( array( 'gutenberg/gutenberg.php' ) );
30+
deactivate_plugins( array( plugin_basename( __FILE__ ) ) );
3131
}
3232

3333
/**

lib/compat/wordpress-7.1/collaboration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function gutenberg_set_collaboration_option_on_activation() {
242242
update_option( 'wp_collaboration_enabled', '1' );
243243
}
244244
}
245-
add_action( 'activate_gutenberg/gutenberg.php', 'gutenberg_set_collaboration_option_on_activation' );
245+
add_action( 'activate_' . plugin_basename( dirname( __DIR__, 3 ) . '/gutenberg.php' ), 'gutenberg_set_collaboration_option_on_activation' );
246246

247247
/**
248248
* Modifies the post list UI and heartbeat responses for real-time collaboration.

lib/init.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function gutenberg_menu() {
2727
__( 'Demo', 'gutenberg' ),
2828
__( 'Demo', 'gutenberg' ),
2929
'edit_posts',
30-
'gutenberg'
30+
'gutenberg',
31+
'__return_null',
3132
);
3233

3334
if ( current_user_can( 'edit_posts' ) ) {

0 commit comments

Comments
 (0)