WordPress.org

Make WordPress Core

Changeset 43544


Ignore:
Timestamp:
07/31/2018 02:51:33 PM (13 months ago)
Author:
jorbin
Message:

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.

4.9 branch commit.

Props pento.
Fixes #44680.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9/src/wp-admin/includes/dashboard.php

    r43537 r43544  
    2424
    2525    /* Register Widgets and Controls */
     26
     27    // Try Gutenberg
     28
     29    // If Gutenberg isn't activated, only show the panel to users who can install and activate it.
     30    $plugins = get_plugins();
     31    if ( is_plugin_inactive( 'gutenberg/gutenberg.php' ) && ! current_user_can( 'install_plugins' ) ) {
     32        remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
     33    }
     34    // If Gutenberg is activated, only show it to users who can use it.
     35    if ( is_plugin_active( 'gutenberg/gutenberg.php' ) && ! current_user_can( 'edit_posts' ) ) {
     36        remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
     37    }
    2638
    2739    $response = wp_check_browser_version();
Note: See TracChangeset for help on using the changeset viewer.