| 1 |
<?php |
| 2 |
|
| 3 |
namespace BitCode\BitForm\Core\Util; |
| 4 |
|
| 5 |
use BitCode\BitForm\Core\Form\FormHandler; |
| 6 |
|
| 7 |
final class GutenBlockProvider |
| 8 |
{ |
| 9 |
public function register() |
| 10 |
{ |
| 11 |
if (!function_exists('register_block_type')) { |
| 12 |
return; |
| 13 |
} |
| 14 |
|
| 15 |
add_action('enqueue_block_editor_assets', [$this, 'shortcodeBlock']); |
| 16 |
} |
| 17 |
|
| 18 |
public function shortcodeBlock() |
| 19 |
{ |
| 20 |
wp_enqueue_script( |
| 21 |
'bitforms-runtime', |
| 22 |
BITFORMS_ROOT_URI . '/v1/assets/js/runtime.js', |
| 23 |
null, |
| 24 |
BITFORMS_VERSION, |
| 25 |
true |
| 26 |
); |
| 27 |
wp_enqueue_script( |
| 28 |
'bitforms-gutenberg-block', |
| 29 |
BITFORMS_ROOT_URI . '/v1/assets/js/bitforms-shortcode-block.js', |
| 30 |
['bitforms-runtime', 'wp-blocks', 'wp-i18n', 'wp-components'], |
| 31 |
BITFORMS_VERSION, |
| 32 |
true |
| 33 |
); |
| 34 |
|
| 35 |
/* wp_register_style( |
| 36 |
'bitforms-gutenberg-block', |
| 37 |
plugins_url('style.css', __FILE__), |
| 38 |
array( ), |
| 39 |
filemtime(plugin_dir_path(__FILE__) . 'style.css') |
| 40 |
); */ |
| 41 |
$formHandler = FormHandler::getInstance(); |
| 42 |
$all_forms = $formHandler->admin->getAllForm(); |
| 43 |
$bitformsForms = apply_filters( |
| 44 |
'bitforms_localize_block_script', |
| 45 |
[ |
| 46 |
'forms' => $all_forms |
| 47 |
] |
| 48 |
); |
| 49 |
|
| 50 |
wp_localize_script('bitforms-gutenberg-block', 'bitformsBlock', $bitformsForms); |
| 51 |
} |
| 52 |
} |
| 53 |
|