Make WordPress Core

Changeset 56672


Ignore:
Timestamp:
09/25/2023 12:05:31 AM (13 months ago)
Author:
joedolson
Message:

Editor: Improve no JS message for block editor.

Show the user a link to install the classic editor if they do not have JavaScript available and the plugin is not already installed.

Props bosskhj, audrasjb, huzaifaalmesbah, sajjad67, joedolson, costdev.
Fixes #59229.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-blocks.php

    r56570 r56672  
    321321        <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
    322322        <?php
    323         $message = sprintf(
    324             /* translators: %s: A link to install the Classic Editor plugin. */
    325             __( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or try the <a href="%s">Classic Editor plugin</a>.' ),
    326             esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ) )
    327         );
     323        if ( file_exists( WP_PLUGIN_DIR . '/classic-editor/classic-editor.php' ) ) {
     324            // If Classic Editor is already installed, provide a link to activate the plugin.
     325            $installed           = true;
     326            $plugin_activate_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=classic-editor/classic-editor.php', 'activate-plugin_classic-editor/classic-editor.php' );
     327            $message             = sprintf(
     328                /* translators: %s: Link to activate the Classic Editor plugin. */
     329                __( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or activate the <a href="%s">Classic Editor plugin</a>.' ),
     330                esc_url( $plugin_activate_url )
     331            );
     332        } else {
     333            // If Classic Editor is not installed, provide a link to install it.
     334            $installed          = false;
     335            $plugin_install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=classic-editor' ), 'install-plugin_classic-editor' );
     336            $message            = sprintf(
     337                /* translators: %s: Link to install the Classic Editor plugin. */
     338                __( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or install the <a href="%s">Classic Editor plugin</a>.' ),
     339                esc_url( $plugin_install_url )
     340            );
     341        }
    328342
    329343        /**
     
    332346         *
    333347         * @since 5.0.3
     348         * @since 6.4.0 Added `$installed` parameter.
    334349         *
    335          * @param string  $message The message being displayed.
    336          * @param WP_Post $post    The post being edited.
     350         * @param string  $message   The message being displayed.
     351         * @param WP_Post $post      The post being edited.
     352         * @param bool    $installed Whether the classic editor is installed.
    337353         */
    338354        $message = apply_filters( 'block_editor_no_javascript_message', $message, $post );
Note: See TracChangeset for help on using the changeset viewer.