Skip to content

Commit

Permalink
Widgets: Add missing no JS notice in Widgets screen.
Browse files Browse the repository at this point in the history
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.

git-svn-id: https://develop.svn.wordpress.org/trunk@56671 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
joedolson committed Sep 24, 2023
1 parent 816561d commit c1f6801
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/wp-admin/widgets-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,50 @@
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 */
Expand Down

0 comments on commit c1f6801

Please sign in to comment.