ad1574c5c5
git-svn-id: https://plugins.svn.wordpress.org/prismatic/trunk@2142173 b8457f37-d9ea-0310-8a92-e5e31aec5664
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php // Prismatic - Gutenberg Blocks
|
|
|
|
function prismatic_register_block_assets() {
|
|
|
|
global $prismatic_options_general;
|
|
|
|
$script_url = null;
|
|
|
|
if (isset($prismatic_options_general['library'])) {
|
|
|
|
if ($prismatic_options_general['library'] === 'prism') {
|
|
|
|
$script_url = plugins_url('/js/blocks-prism.js', dirname(__FILE__));
|
|
|
|
} elseif ($prismatic_options_general['library'] === 'highlight') {
|
|
|
|
$script_url = plugins_url('/js/blocks-highlight.js', dirname(__FILE__));
|
|
|
|
} elseif ($prismatic_options_general['library'] === 'plain') {
|
|
|
|
$script_url = plugins_url('/js/blocks-plain.js', dirname(__FILE__));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($script_url) {
|
|
|
|
$style_url = plugins_url('/css/styles-blocks.css', dirname(__FILE__));
|
|
|
|
$script_dep = ['wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor', 'wp-hooks'];
|
|
$style_dep = [];
|
|
|
|
wp_register_script('prismatic-blocks', $script_url, $script_dep);
|
|
wp_register_style ('prismatic-blocks', $style_url, $style_dep);
|
|
|
|
register_block_type('prismatic/blocks', array('editor_script' => 'prismatic-blocks', 'style' => 'prismatic-blocks', 'render_callback' => 'prismatic_render_html'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function prismatic_render_html($attributes, $content) {
|
|
|
|
return html_entity_decode($content);
|
|
|
|
} |