Make WordPress Core


Ignore:
Timestamp:
07/26/2018 03:05:40 PM (8 years ago)
Author:
SergeyBiryukov
Message:

Dashboard: Tweak the "Try Gutenberg" callout:

  • Introduce try_gutenberg_learn_more_link filter that allows hosts or site owners to change the link, to provide extra information about Gutenberg, specific to their service.
  • Only display the "Install" buttons if we're able to directly write to disk to install the plugins.
  • Make sure the "Dismiss" link works correctly.

Props pento, andrew.taylor, leemon.
Fixes #41316.

File:
1 edited

Legend:

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

    r43523 r43537  
    16331633        if ( current_user_can( 'install_plugins' ) ) {
    16341634                if ( empty( $plugins['gutenberg/gutenberg.php'] ) ) {
    1635                         $action = __( 'Install Gutenberg' );
    1636                         $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=gutenberg' ), 'install-plugin_gutenberg' );
    1637                         $classes = ' install-now';
     1635                        if ( get_filesystem_method( array(), WP_PLUGIN_DIR ) === 'direct' ) {
     1636                                $action = __( 'Install Gutenberg' );
     1637                                $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=gutenberg' ), 'install-plugin_gutenberg' );
     1638                                $classes = ' install-now';
     1639                        }
    16381640                } else if ( is_plugin_inactive( 'gutenberg/gutenberg.php' ) ) {
    16391641                        $action = __( 'Activate Gutenberg' );
     
    16431645
    16441646                if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) {
    1645                         $classic_action = __( 'Install the Classic Editor' );
    1646                         $classic_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=classic-editor' ), 'install-plugin_classic-editor' );
    1647                         $classic_classes = ' install-now';
     1647                        if ( get_filesystem_method( array(), WP_PLUGIN_DIR ) === 'direct' ) {
     1648                                $classic_action = __( 'Install the Classic Editor' );
     1649                                $classic_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=classic-editor' ), 'install-plugin_classic-editor' );
     1650                                $classic_classes = ' install-now';
     1651                        }
    16481652                } else if ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) {
    16491653                        $classic_action = __( 'Activate the Classic Editor' );
     
    16961700                                </div>
    16971701
     1702                                <div class="try-gutenberg-action">
    16981703                                        <?php if ( $action ) { ?>
    1699                                                 <div class="try-gutenberg-action">
    1700                                                         <p><a class="button button-primary button-hero<?php echo $classes; ?>" href="<?php echo esc_url( $url ); ?>" data-name="<?php esc_attr_e( 'Gutenberg' ); ?>" data-slug="gutenberg"><?php echo $action; ?></a></p>
    1701                                                         <p>
    1702                                                                 <?php
    1703                                                                         printf(
    1704                                                                                 /* translators: Link to https://wordpress.org/gutenberg/ */
    1705                                                                                 __( '<a href="%s">Learn more about Gutenberg</a>' ),
    1706                                                                                 __( 'https://wordpress.org/gutenberg/' )
    1707                                                                         );
    1708                                                                 ?>
    1709                                                         </p>
    1710                                                 </div>
     1704                                                <p><a class="button button-primary button-hero<?php echo $classes; ?>" href="<?php echo esc_url( $url ); ?>" data-name="<?php esc_attr_e( 'Gutenberg' ); ?>" data-slug="gutenberg"><?php echo $action; ?></a></p>
    17111705                                        <?php } ?>
     1706
     1707                                        <p>
     1708                                                <?php
     1709                                                        $learnmore = sprintf(
     1710                                                                /* translators: Link to https://wordpress.org/gutenberg/ */
     1711                                                                __( '<a href="%s">Learn more about Gutenberg</a>' ),
     1712                                                                __( 'https://wordpress.org/gutenberg/' )
     1713                                                        );
     1714
     1715                                                        /**
     1716                                                         * Filters the "Learn more" link in the Try Gutenberg panel.
     1717                                                         *
     1718                                                         * It allows hosts or site owners to change the link, to provide extra
     1719                                                         * information about Gutenberg, specific to their service.
     1720                                                         *
     1721                                                         * WARNING: This filter will only exist in the 4.9.x series, it will not be
     1722                                                         * added to WordPress 5.0 and later.
     1723                                                         *
     1724                                                         * @since 4.9.8
     1725                                                         */
     1726                                                        echo apply_filters( 'try_gutenberg_learn_more_link', $learnmore );
     1727                                                ?>
     1728                                        </p>
     1729                                </div>
    17121730                        </div>
    17131731
Note: See TracChangeset for help on using the changeset viewer.