You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3KB

  1. <?php // Prismatic - Gutenberg Blocks
  2. function prismatic_register_block_assets() {
  3. global $prismatic_options_general;
  4. if (!function_exists('register_block_type')) return;
  5. $script_url = null;
  6. if (isset($prismatic_options_general['library'])) {
  7. if ($prismatic_options_general['library'] === 'prism') {
  8. $script_url = plugins_url('/js/blocks-prism.js', dirname(__FILE__));
  9. } elseif ($prismatic_options_general['library'] === 'highlight') {
  10. $script_url = plugins_url('/js/blocks-highlight.js', dirname(__FILE__));
  11. } elseif ($prismatic_options_general['library'] === 'plain') {
  12. $script_url = plugins_url('/js/blocks-plain.js', dirname(__FILE__));
  13. }
  14. }
  15. if ($script_url) {
  16. $style_url = plugins_url('/css/styles-blocks.css', dirname(__FILE__));
  17. $script_dep = ['wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor', 'wp-hooks'];
  18. $style_dep = [];
  19. wp_register_script('prismatic-blocks', $script_url, $script_dep);
  20. wp_register_style ('prismatic-blocks', $style_url, $style_dep);
  21. register_block_type('prismatic/blocks', array('editor_script' => 'prismatic-blocks', 'style' => 'prismatic-blocks', 'render_callback' => 'prismatic_render_html'));
  22. }
  23. }
  24. function prismatic_render_html($attributes, $content) {
  25. return html_entity_decode($content);
  26. }