@ -0,0 +1,7 @@ |
||||
.blog-notice{ |
||||
font-size: .8em; |
||||
font-weight: 300; |
||||
color: rgba(0, 0, 0, 0.55); |
||||
padding-top: .3rem; |
||||
padding-bottom: .3rem; |
||||
} |
After Width: | Height: | Size: 28 KiB |
@ -0,0 +1,48 @@ |
||||
<?php |
||||
|
||||
function notice_render_callback($block, $content = '', $is_preview = false, $post_id = 0) { |
||||
$context = Timber::context(); |
||||
$context['block'] = $block; |
||||
$context['is_preview'] = $is_preview; |
||||
$context['content'] = get_field('content'); |
||||
// Проверяем, есть ли картинка превью в блоке |
||||
if ($is_preview && !empty($block['data']['preview_image'])) { |
||||
echo '<img src="' . esc_url($block['data']['preview_image']) . '" alt="Preview" style="max-width: 100%; height: auto;">'; |
||||
return; |
||||
} |
||||
Timber::render('modules/blog/editor-blocks/notice/editor-block-template.twig', $context); |
||||
} |
||||
|
||||
|
||||
add_action('acf/init', function(){ |
||||
if( function_exists('acf_register_block') ) { |
||||
// register a testimonial block |
||||
|
||||
acf_register_block(array( |
||||
'name' => 'gp_notice', |
||||
'title' => __('GP - Notice'), |
||||
'description' => __('A block to serve a text notice'), |
||||
'render_callback' => 'notice_render_callback', |
||||
'category' => 'formatting', |
||||
'icon' => 'admin-comments', |
||||
'keywords' => array( 'notice', 'simple block', 'gp-block',), |
||||
'mode' => 'preview', |
||||
'example' => array( |
||||
'attributes' => array( |
||||
'data' => array( |
||||
'is_preview' => true, |
||||
'preview_image' => get_template_directory_uri() . '/modules/blog/editor-blocks/notice/assets/img/preview.png' |
||||
) |
||||
) |
||||
), |
||||
'enqueue_assets' => function(){ |
||||
wp_enqueue_style('gp_notice_style', get_template_directory_uri() . '/modules/blog/editor-blocks/notice/assets/css/style.css', array(), '5.0', 'all'); |
||||
} |
||||
)); |
||||
} |
||||
}); |
||||
|
||||
|
||||
|
||||
|
||||
?> |
@ -0,0 +1,4 @@ |
||||
<section class="blog-notice"> |
||||
{{ content }} |
||||
</section> |
||||
|
Loading…
Reference in new issue