From 2e0af3abb71bb7bc3bd9b6a27e37898f623fd2eb Mon Sep 17 00:00:00 2001 From: Kevin Zoschke Date: Thu, 9 May 2024 11:41:40 -0400 Subject: [PATCH] Add warning in the frontend --- .../jetpack/modules/custom-css/custom-css.php | 40 +++++++++++++++++++ .../custom-css/custom-css/css/blank.css | 36 ++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/modules/custom-css/custom-css.php b/projects/plugins/jetpack/modules/custom-css/custom-css.php index 92333f251878a..1274eb7cfb32a 100644 --- a/projects/plugins/jetpack/modules/custom-css/custom-css.php +++ b/projects/plugins/jetpack/modules/custom-css/custom-css.php @@ -31,6 +31,7 @@ public static function add_hooks() { add_action( 'wp_enqueue_scripts', array( __CLASS__, 'wp_enqueue_scripts' ) ); add_action( 'admin_footer', array( __CLASS__, 'update_initial_state' ) ); + add_action( 'wp_body_open', array( __CLASS__, 'display_frontend_warning' ) ); // Handle Sass/LESS. add_filter( 'customize_value_custom_css', array( __CLASS__, 'customize_value_custom_css' ), 10, 2 ); @@ -1005,6 +1006,45 @@ public static function jetpack_content_width( $content_width ) { return $content_width; } + /** + * Display a deprecation warning on the frontend for site admins only + */ + public static function display_frontend_warning() { + if ( ! current_user_can( 'edit_themes' ) || ! current_user_can( 'edit_theme_options' ) ) { + return; + } + + $notice = ''; + $notice .= '
'; + $notice .= '

' . wp_kses( + sprintf( + // translators: 1: URL to the CSS customization panel, 2: URL to the theme stylesheet documentation. + __( + 'The Start Fresh option in the CSS customization panel is enabled, which means the theme\'s original CSS is not applied. This option will no longer be supported after August 6, 2024 and you\'ll need to modify your theme stylesheet.', + 'jetpack' + ), + esc_url( admin_url( 'customize.php?autofocus%5Bsection%5D=custom_css' ) ), + esc_url( 'https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/' ) + ), + array( + 'i' => array(), + 'b' => array(), + 'a' => array( + 'href' => array(), + 'target' => array(), + ), + ) + ) . '

'; + $notice .= ''; + $notice .= '
'; + $notice .= ''; + + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo $notice; + } + /** * Update the initial state to include the `replace` option (Start Fresh) in the module data. */ diff --git a/projects/plugins/jetpack/modules/custom-css/custom-css/css/blank.css b/projects/plugins/jetpack/modules/custom-css/custom-css/css/blank.css index c84ecefcd9ba0..a046342197c62 100644 --- a/projects/plugins/jetpack/modules/custom-css/custom-css/css/blank.css +++ b/projects/plugins/jetpack/modules/custom-css/custom-css/css/blank.css @@ -1 +1,35 @@ -/* */ \ No newline at end of file +/* */ +.jp-custom-css__deprecation-warning { + position: absolute; + top: 2.5rem; + left: 50%; + z-index: 99999; + transform: translateX( -50% ); + + display: flex; + align-items: flex-start; + width: 80ch; + + background-color: #fef8ee; + border: solid 1px #ccc; + border-left: solid 5px #f0b849; + box-shadow: 0 0 4px 4px rgba( 0, 0, 0, 0.1 ); + + font-size: 1rem; +} + +.jp-custom-css__deprecation-warning p { + margin: 0; + padding: 1em; +} + +.jp-custom-css__deprecation-warning button { + min-width: 48px; + min-height: 48px; + + border-color: transparent; + background-color: transparent; + + font-size: 1.25rem; + font-weight: bold; +}