Widgets: Add missing no JS notice in Widgets screen.

Add an H1 heading and an admin notice to display on the Widgets screen when JS is not available. Invite the user to either install or activate the Classic Widgets plugin, as that plugin provides basic functionality without JS.

Props afercia, nihar007, huzaifaalmesbah, joedolson, matthewfarlymn, bvreeman22, bosskhj, devmuhib, shailu25, joedolson.
Fixes #58738.
Built from https://develop.svn.wordpress.org/trunk@56671


git-svn-id: http://core.svn.wordpress.org/trunk@56183 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2023-09-25 00:00:17 +00:00
parent 223b713734
commit 8743d1318c
2 changed files with 45 additions and 2 deletions

View File

@ -73,7 +73,50 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
do_action( 'widgets_admin_page' );
?>
<div id="widgets-editor" class="blocks-widgets-container"></div>
<div id="widgets-editor" class="blocks-widgets-container">
<?php // JavaScript is disabled. ?>
<div class="wrap hide-if-js widgets-editor-no-js">
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
<?php
if ( file_exists( WP_PLUGIN_DIR . '/classic-widgets/classic-widgets.php' ) ) {
// If Classic Widgets is already installed, provide a link to activate the plugin.
$installed = true;
$plugin_activate_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=classic-widgets/classic-widgets.php', 'activate-plugin_classic-widgets/classic-widgets.php' );
$message = sprintf(
/* translators: %s: Link to activate the Classic Widgets plugin. */
__( 'The block widgets require JavaScript. Please enable JavaScript in your browser settings, or activate the <a href="%s">Classic Widgets plugin</a>.' ),
esc_url( $plugin_activate_url )
);
} else {
// If Classic Widgets 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-widgets' ), 'install-plugin_classic-widgets' );
$message = sprintf(
/* translators: %s: A link to install the Classic Widgets plugin. */
__( 'The block widgets require JavaScript. Please enable JavaScript in your browser settings, or install the <a href="%s">Classic Widgets plugin</a>.' ),
esc_url( $plugin_install_url )
);
}
/**
* Filters the message displayed in the block widget interface when JavaScript is
* not enabled in the browser.
*
* @since 6.4.0
*
* @param string $message The message being displayed.
* @param bool $installed Whether the Classic Widget plugin is installed.
*/
$message = apply_filters( 'block_widgets_no_javascript_message', $message, $installed );
wp_admin_notice(
$message,
array(
'type' => 'error',
'additional_classes' => array( 'hide-if-js' ),
)
);
?>
</div>
</div>
<?php
/** This action is documented in wp-admin/widgets-form.php */

View File

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