33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Ultra Simple Block Registration - PHP Only
|
|
* This ensures the block is registered even if JavaScript fails
|
|
*/
|
|
|
|
add_action('init', function() {
|
|
if (!function_exists('register_block_type')) {
|
|
return;
|
|
}
|
|
|
|
// Register a basic block with PHP only
|
|
register_block_type('maple-code-blocks/basic', array(
|
|
'title' => 'Maple Code Block (Basic)',
|
|
'description' => 'Display code from repositories',
|
|
'category' => 'widgets',
|
|
'icon' => 'editor-code',
|
|
'keywords' => array('maple', 'code', 'github'),
|
|
'attributes' => array(
|
|
'repository' => array(
|
|
'type' => 'string',
|
|
'default' => ''
|
|
)
|
|
),
|
|
'render_callback' => function($attributes) {
|
|
$repo = isset($attributes['repository']) ? $attributes['repository'] : '';
|
|
if (empty($repo)) {
|
|
return '<p>Enter a repository in block settings</p>';
|
|
}
|
|
return do_shortcode('[maple_code_block repo="' . esc_attr($repo) . '"]');
|
|
}
|
|
));
|
|
}, 100); // Very late priority to ensure everything is loaded
|