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.
Built from https://develop.svn.wordpress.org/trunk@56672


git-svn-id: http://core.svn.wordpress.org/trunk@56184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2023-09-25 00:07:21 +00:00
parent 8743d1318c
commit 8663e65bde
2 changed files with 24 additions and 8 deletions

View File

@ -320,20 +320,36 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<div class="wrap hide-if-js block-editor-no-js"> <div class="wrap hide-if-js block-editor-no-js">
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
<?php <?php
$message = sprintf( if ( file_exists( WP_PLUGIN_DIR . '/classic-editor/classic-editor.php' ) ) {
/* translators: %s: A link to install the Classic Editor plugin. */ // If Classic Editor is already installed, provide a link to activate the plugin.
__( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or try the <a href="%s">Classic Editor plugin</a>.' ), $installed = true;
esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ) ) $plugin_activate_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=classic-editor/classic-editor.php', 'activate-plugin_classic-editor/classic-editor.php' );
); $message = sprintf(
/* translators: %s: Link to activate the Classic Editor plugin. */
__( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or activate the <a href="%s">Classic Editor plugin</a>.' ),
esc_url( $plugin_activate_url )
);
} else {
// If Classic Editor is not installed, provide a link to install it.
$installed = false;
$plugin_install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=classic-editor' ), 'install-plugin_classic-editor' );
$message = sprintf(
/* translators: %s: Link to install the Classic Editor plugin. */
__( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or install the <a href="%s">Classic Editor plugin</a>.' ),
esc_url( $plugin_install_url )
);
}
/** /**
* Filters the message displayed in the block editor interface when JavaScript is * Filters the message displayed in the block editor interface when JavaScript is
* not enabled in the browser. * not enabled in the browser.
* *
* @since 5.0.3 * @since 5.0.3
* @since 6.4.0 Added `$installed` parameter.
* *
* @param string $message The message being displayed. * @param string $message The message being displayed.
* @param WP_Post $post The post being edited. * @param WP_Post $post The post being edited.
* @param bool $installed Whether the classic editor is installed.
*/ */
$message = apply_filters( 'block_editor_no_javascript_message', $message, $post ); $message = apply_filters( 'block_editor_no_javascript_message', $message, $post );
wp_admin_notice( wp_admin_notice(

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.4-alpha-56671'; $wp_version = '6.4-alpha-56672';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.