|
212 | 212 | ); |
213 | 213 | } |
214 | 214 |
|
215 | | -if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) { |
216 | | - $message = '<p><strong>' . __( 'Did you know?' ) . '</strong></p><p>' . sprintf( |
217 | | - /* translators: %s: Link to Custom CSS section in the Customizer. */ |
218 | | - __( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ), |
219 | | - esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) ) |
220 | | - ) . '</p>'; |
221 | | - wp_admin_notice( |
222 | | - $message, |
223 | | - array( |
224 | | - 'type' => 'info', |
225 | | - 'id' => 'message', |
226 | | - ) |
227 | | - ); |
| 215 | +if ( preg_match( '/\.css$/', $file ) ) { |
| 216 | + if ( ! wp_is_block_theme() && current_user_can( 'customize' ) ) { |
| 217 | + $message = '<p><strong>' . __( 'Did you know?' ) . '</strong></p><p>' . sprintf( |
| 218 | + /* translators: %s: Link to add custom CSS section in either the Customizer (classic themes) or Site Editor (block themes). */ |
| 219 | + __( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ), |
| 220 | + esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) ) |
| 221 | + ) . '</p>'; |
| 222 | + wp_admin_notice( |
| 223 | + $message, |
| 224 | + array( |
| 225 | + 'type' => 'info', |
| 226 | + 'id' => 'message', |
| 227 | + ) |
| 228 | + ); |
| 229 | + } elseif ( wp_is_block_theme() && current_user_can( 'edit_theme_options' ) ) { |
| 230 | + $site_editor_url = admin_url( |
| 231 | + add_query_arg( |
| 232 | + urlencode_deep( |
| 233 | + array( |
| 234 | + 'p' => '/styles', |
| 235 | + 'section' => '/css', |
| 236 | + ) |
| 237 | + ), |
| 238 | + 'site-editor.php' |
| 239 | + ) |
| 240 | + ); |
| 241 | + |
| 242 | + $message = '<p><strong>' . __( 'Did you know?' ) . '</strong></p><p>' . sprintf( |
| 243 | + /* translators: %s: Link to add custom CSS section in either the Customizer (classic themes) or Site Editor (block themes). */ |
| 244 | + __( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ), |
| 245 | + esc_url( $site_editor_url ) |
| 246 | + ) . '</p>'; |
| 247 | + wp_admin_notice( |
| 248 | + $message, |
| 249 | + array( |
| 250 | + 'type' => 'info', |
| 251 | + 'id' => 'message', |
| 252 | + ) |
| 253 | + ); |
| 254 | + } |
| 255 | + if ( file_exists( preg_replace( '/\.css$/', '.min.css', $file ) ) ) { |
| 256 | + $message = '<p><strong>' . __( 'There is a minified version of this stylesheet.' ) . '</strong></p><p>' . |
| 257 | + __( 'It is likely that this unminified stylesheet will not be served to visitors.' ) . '</p>'; |
| 258 | + wp_admin_notice( |
| 259 | + $message, |
| 260 | + array( |
| 261 | + 'type' => 'warning', |
| 262 | + 'id' => 'wp-css-min-warning', |
| 263 | + ) |
| 264 | + ); |
| 265 | + } |
228 | 266 | } |
229 | 267 | ?> |
230 | 268 |
|
|
0 commit comments