utils
1 week ago
block.json
2 months ago
edit.js
1 week ago
icon.svg
2 months ago
index.js
2 months ago
index.php
2 months ago
save.js
2 months ago
style.scss
1 week ago
index.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Registers the `vk-blocks/visual-embed` block. |
| 4 | * |
| 5 | * @package vk-blocks |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Register Google map block. |
| 10 | * |
| 11 | * @return void |
| 12 | */ |
| 13 | function vk_blocks_register_block_google_map() { |
| 14 | |
| 15 | // Register Style. |
| 16 | if ( ! is_admin() ) { |
| 17 | wp_register_style( |
| 18 | 'vk-blocks/visual-embed', |
| 19 | VK_BLOCKS_DIR_URL . 'build/visual-embed/style.css', |
| 20 | array(), |
| 21 | VK_BLOCKS_VERSION |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | register_block_type( |
| 26 | __DIR__, |
| 27 | array( |
| 28 | 'style' => 'vk-blocks/visual-embed', |
| 29 | 'editor_style' => 'vk-blocks-build-editor-css', |
| 30 | 'editor_script' => 'vk-blocks-build-js', |
| 31 | ) |
| 32 | ); |
| 33 | } |
| 34 | add_action( 'init', 'vk_blocks_register_block_google_map', 99 ); |
| 35 | |
| 36 | /** |
| 37 | * Set allowed URL patterns for visual embed block in the editor. |
| 38 | * |
| 39 | * This function localizes the script with allowed URL patterns |
| 40 | * that can be used in the visual embed block. The patterns are |
| 41 | * filterable to allow customization from other plugins or themes. |
| 42 | * |
| 43 | * @return void |
| 44 | */ |
| 45 | function vk_blocks_visual_embed_set_data() { |
| 46 | |
| 47 | wp_localize_script( |
| 48 | 'vk-blocks-build-js', |
| 49 | 'vkBlocksVisualEmbed', |
| 50 | array( |
| 51 | 'allowedUrlPatterns' => apply_filters( 'vk_blocks_visual_embed_allowed_url_patterns', array() ), |
| 52 | ) |
| 53 | ); |
| 54 | } |
| 55 | add_action( 'enqueue_block_editor_assets', 'vk_blocks_visual_embed_set_data' ); |
| 56 |