array(__CLASS__, 'render_block'), 'attributes' => array( 'repository' => array( 'type' => 'string', 'default' => '' ), 'theme' => array( 'type' => 'string', 'default' => 'dark' ), 'height' => array( 'type' => 'string', 'default' => '600px' ) ) )); } public static function enqueue_editor_assets() { // Enqueue the block editor script wp_enqueue_script( 'maple-code-blocks-editor', MCB_PLUGIN_URL . 'assets/js/simple-block.js', array('wp-blocks', 'wp-element', 'wp-editor', 'wp-components', 'wp-i18n'), MCB_PLUGIN_VERSION, false // Load in header, not footer ); // Add inline script to ensure registration happens wp_add_inline_script('maple-code-blocks-editor', ' console.log("Maple Code Blocks: Script loaded"); if (typeof wp !== "undefined" && wp.blocks) { console.log("Maple Code Blocks: wp.blocks is available"); } else { console.error("Maple Code Blocks: wp.blocks not available"); } ', 'after'); } public static function render_block($attributes) { $repository = isset($attributes['repository']) ? $attributes['repository'] : ''; $theme = isset($attributes['theme']) ? $attributes['theme'] : 'dark'; $height = isset($attributes['height']) ? $attributes['height'] : '600px'; if (empty($repository)) { return '
Please enter a repository (e.g., facebook/react)
'; } // Use the shortcode for rendering return do_shortcode(sprintf( '[maple_code_block repo="%s" theme="%s" height="%s"]', esc_attr($repository), esc_attr($theme), esc_attr($height) )); } } MCB_Simple_Block::init();