← All changes
|
includes/admin/class-charitable-admin-blocks.php
+35
-0
1.8.11.2
→
1.8.13
View file →
| @@ -417,8 +417,43 @@ | ||
| 417 | 417 | do_action( 'after_charitable_admin_block_enqueue_scripts', $min, $version, $assets_dir ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Hook name may be used by other code. Changing it would break existing functionality. |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
| 421 | + * Loads the stylesheet for the block editor canvas (the editor iframe). | |
| 422 | + * | |
| 423 | + * Since WP 6.3 the post editor canvas is an iframe, so anything enqueued on | |
| 424 | + * admin_enqueue_scripts lands in the parent admin document and cannot style the | |
| 425 | + * blocks inside it. `enqueue_block_assets` is the hook core collects to build the | |
| 426 | + * iframe's assets (see _wp_get_iframed_editor_assets()), so styles enqueued here | |
| 427 | + * are injected into the canvas properly. | |
| 428 | + * | |
| 429 | + * This replaces reliance on Gutenberg's useCompatibilityStyles back-compat shim, | |
| 430 | + * which used to clone charitable-admin.css into the iframe and log | |
| 431 | + * "charitable-admin-2.0-css was added to the iframe incorrectly" on every load. | |
| 432 | + * | |
| 433 | + * @since 1.8.12.1 | |
| 434 | + * | |
| 435 | + * @return void | |
| 436 | + */ | |
| 437 | + public function enqueue_block_editor_canvas_styles() { | |
| 438 | + | |
| 439 | + // `enqueue_block_assets` also fires on the front end; these rules are editor-only. | |
| 440 | + if ( ! is_admin() ) { | |
| 441 | + return; | |
| 442 | + } | |
| 443 | + | |
| 444 | + $min = charitable_get_min_suffix(); | |
| 445 | + $version = charitable()->get_version(); | |
| 446 | + | |
| 447 | + wp_enqueue_style( | |
| 448 | + 'charitable-block-editor-canvas', | |
| 449 | + charitable()->get_path( 'assets', false ) . 'css/admin/charitable-block-editor-canvas' . $min . '.css', | |
| 450 | + array(), | |
| 451 | + $version | |
| 452 | + ); | |
| 453 | + } | |
| 454 | + | |
| 455 | + /** | |
| 421 | 456 | * Retrieves localized strings for the Charitable Blocks editor. |
| 422 | 457 | * |
| 423 | 458 | * @since 1.8.0 |
| 424 | 459 | * @version 1.8.3 |