| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: My Custom Block |
| 4 |
Description: A custom block for my theme. |
| 5 |
Version: 1.0 |
| 6 |
Author: Your Name |
| 7 |
*/ |
| 8 |
|
| 9 |
// Exit if accessed directly. |
| 10 |
if (!defined('ABSPATH')) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
add_action('enqueue_block_editor_assets', function () { |
| 15 |
if (is_user_logged_in()) { |
| 16 |
wp_enqueue_script( |
| 17 |
'wdk-block-share-backend', |
| 18 |
WPDIRECTORYKIT_URL . '/blocks/inc/block-share/block.js', |
| 19 |
array('wp-blocks', 'wp-element', 'wp-editor', 'wp-i18n', 'wp-api-fetch'), |
| 20 |
23 |
| 21 |
); |
| 22 |
} |
| 23 |
}); |
| 24 |
|
| 25 |
add_action('wdk_block_block_share_enqueue_assets', function () { |
| 26 |
wp_enqueue_script( |
| 27 |
'wdk-block-share-frontend', |
| 28 |
WPDIRECTORYKIT_URL . '/blocks/inc/block-share/frontend.js', |
| 29 |
array(), |
| 30 |
22 |
| 31 |
); |
| 32 |
}); |
| 33 |
|
| 34 |
|
| 35 |
add_action('init', function () |
| 36 |
{ |
| 37 |
register_block_type('my-plugin/wdk-block-share', array( |
| 38 |
'editor_script' => 'wdk-block-share', |
| 39 |
'style' => 'wdk-block-share-style', |
| 40 |
'editor_style' => 'wdk-block-share-editor', |
| 41 |
)); |
| 42 |
} |
| 43 |
); |
| 44 |
|