Skip to content

Commit 46ed713

Browse files
committed
Use enqueue_block_assets, and add note why.
Enqueue_block_editor_assets throws a console error in the block editor when using the iframed editor, and requires use of `enqueue_block_assets` instead. However, this results in assets appearing on the front-end. Wrap code in `is_admin()` to limit scope.
1 parent ed084df commit 46ed713

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/wp-accessibility-alt.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,13 @@ function wpa_add_editor_styles() {
256256
add_editor_style( plugins_url( 'css/editor-style.css', __FILE__ ), false, $wpa_version );
257257
}
258258

259-
add_action( 'enqueue_block_editor_assets', 'wpa_block_editor_assets' );
259+
add_action( 'enqueue_block_assets', 'wpa_block_editor_assets' );
260260
/**
261261
* Enqueue custom block editor styles for WP Accessibility. Used in display of img replacements.
262262
*/
263263
function wpa_block_editor_assets() {
264-
$wpa_version = ( SCRIPT_DEBUG ) ? wp_rand( 10000, 100000 ) : wpa_check_version();
265-
wp_enqueue_style( 'wpa-block-styles', plugins_url( 'css/editor-style.css', __FILE__ ), false, $wpa_version );
264+
if ( is_admin() ) {
265+
$wpa_version = ( SCRIPT_DEBUG ) ? wp_rand( 10000, 100000 ) : wpa_check_version();
266+
wp_enqueue_style( 'wpa-block-styles', plugins_url( 'css/editor-style.css', __FILE__ ), false, $wpa_version );
267+
}
266268
}

0 commit comments

Comments
 (0)