| @@ -1,0 +1,50 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Module Name: Blocks | |
| 4 | + * Module Description: Expand your editor with custom Jetpack blocks for rich content and layout options. | |
| 5 | + * Sort Order: 5 | |
| 6 | + * First Introduced: 13.9-a.8 | |
| 7 | + * Requires Connection: No | |
| 8 | + * Auto Activate: Yes | |
| 9 | + * Module Tags: blocks | |
| 10 | + * Feature: Writing | |
| 11 | + * | |
| 12 | + * @package automattic/jetpack | |
| 13 | + */ | |
| 14 | + | |
| 15 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 16 | + exit( 0 ); | |
| 17 | +} | |
| 18 | + | |
| 19 | +add_action( 'jetpack_activate_module_blocks', 'jetpack_blocks_activate_module' ); | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * Actions needed upon activating the blocks module. | |
| 23 | + * | |
| 24 | + * There is a legacy option to disable Jetpack blocks that we'll delete when this module is activated. | |
| 25 | + * Via jetpack_get_default_modules filter, we remove blocks from the default if the option is true. | |
| 26 | + * We'll leave that in place so _until the module is activated_ we will be sure to respect the previous | |
| 27 | + * setting. | |
| 28 | + * | |
| 29 | + * @since 13.9 | |
| 30 | + * @return void | |
| 31 | + */ | |
| 32 | +function jetpack_blocks_activate_module() { | |
| 33 | + delete_option( 'jetpack_blocks_disabled' ); // The function will check and return early if not present. | |
| 34 | +} | |
| 35 | + | |
| 36 | +Jetpack_Gutenberg::load_block_editor_extensions(); | |
| 37 | +Jetpack_Gutenberg::load_independent_blocks(); | |
| 38 | +Jetpack_Gutenberg::register_block_metadata_collection(); | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * We've switched from enqueue_block_editor_assets to enqueue_block_assets in WP-Admin because the assets with the former are loaded on the main site-editor.php. | |
| 42 | + * | |
| 43 | + * With the latter, the assets are now loaded in the SE iframe; the implementation is now faster because Gutenberg doesn't need to inject the assets in the iframe on client-side. | |
| 44 | + */ | |
| 45 | +if ( is_admin() ) { | |
| 46 | + add_action( 'enqueue_block_assets', array( 'Jetpack_Gutenberg', 'enqueue_block_editor_assets' ) ); | |
| 47 | +} else { | |
| 48 | + add_action( 'enqueue_block_editor_assets', array( 'Jetpack_Gutenberg', 'enqueue_block_editor_assets' ) ); | |
| 49 | +} | |
| 50 | +add_filter( 'render_block', array( 'Jetpack_Gutenberg', 'display_deprecated_block_message' ), 10, 2 ); | |