From 8ed24bbbdaccc1e598be7a02bdc71f9567b98f38 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Tue, 31 Jul 2018 14:41:46 +0000 Subject: [PATCH] Gutenberg: Restrict "Try Gutenberg" based on capability and gutenstatus When Gutenberg is either not installed, or not activated, only show the callout to users with the install_plugins capability. When Gutenberg is activated, expand that to include all users with the edit_posts capability. Props pento. Fixes #44680. git-svn-id: https://develop.svn.wordpress.org/trunk@43543 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/dashboard.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 0c5bb5f5b1..c0bfff9a73 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -24,6 +24,18 @@ function wp_dashboard_setup() { /* Register Widgets and Controls */ + // Try Gutenberg + + // If Gutenberg isn't activated, only show the panel to users who can install and activate it. + $plugins = get_plugins(); + if ( is_plugin_inactive( 'gutenberg/gutenberg.php' ) && ! current_user_can( 'install_plugins' ) ) { + remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' ); + } + // If Gutenberg is activated, only show it to users who can use it. + if ( is_plugin_active( 'gutenberg/gutenberg.php' ) && ! current_user_can( 'edit_posts' ) ) { + remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' ); + } + $response = wp_check_browser_version(); if ( $response && $response['upgrade'] ) {