%PDF- %PDF-
Direktori : /home/maraton/maraton.eco-n-tech.co.uk/wp-content/themes/maraton/blocks/Teaserbox/ |
Current File : //home/maraton/maraton.eco-n-tech.co.uk/wp-content/themes/maraton/blocks/Teaserbox/index.php |
<?php acf_register_block( array( 'name' => 'teaserbox', 'title' => __( 'Teaserbox', 'maraton' ), 'description' => __( 'teaserbox. Image and text block.', 'maraton' ), 'render_callback' => 'teaserbox_render_callback', 'category' => 'maraton-blocks', 'icon' => 'editor-quote', 'keywords' => array( 'teaser', 'box', 'image', 'text', 'content'), ) ); function teaserbox_render_callback( $block, $content = '', $is_preview = false ) { $context = Timber::context(); // Store block values. $context['block'] = $block; // Store field values. $context['fields'] = get_fields(); // Store $is_preview value. $context['is_preview'] = $is_preview; // build style string if ($context['fields']['settings']['background_color']) { $context['block']['style'] = 'background-color: ' . $context['fields']['settings']['background_color'] . ';'; } $context['align'] = 'justify-content-center'; if (isset($context['fields']['content']['align'])) { switch ($context['fields']['content']['align']) { case 'left': $context['align'] = 'justify-content-start'; break; case 'right': $context['align'] = 'justify-content-end'; break; case 'center': $context['align'] = 'justify-content-center'; break; } } // Parse content and append svg icon after each a tag $context['fields']['content']['content'] = preg_replace('/<a(.*?)>(.*?)<\/a>/', '<a$1>$2 '.display_svg("/dist/img/arrow-right.svg").'</a>', $context['fields']['content']['content']); // Render the block. Timber::render( 'render-template.twig', $context ); } ?>