From c1f68010558ca52e6d03226ec34df04e2b125a61 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Sun, 24 Sep 2023 23:58:42 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@56671 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/widgets-form-blocks.php | 45 +++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/widgets-form-blocks.php b/src/wp-admin/widgets-form-blocks.php index b4c6dd28d4..db13d2e8b9 100644 --- a/src/wp-admin/widgets-form-blocks.php +++ b/src/wp-admin/widgets-form-blocks.php @@ -73,7 +73,50 @@ require_once ABSPATH . 'wp-admin/admin-header.php'; do_action( 'widgets_admin_page' ); ?> -
+
+ +
+

+ Classic Widgets plugin.' ), + 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 Classic Widgets plugin.' ), + 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' ), + ) + ); + ?> +
+