HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/f/r/e/frenchy/www/french-american.org/repo/app/functions/acf-blocks/event.inc.php
<?php

add_action('acf/init', 'acf_block_event');
function acf_block_event()
{
    if (function_exists('acf_register_block_type')) {
        acf_register_block_type(array(
            'name' => 'event',
            'title' => __('Événement', 'wpstartertheme'),
            'description' => __('Événement', 'wpstartertheme'),
            'render_callback' => 'acf_block_event_render_callback',
            'category' => 'common',
            'icon' => 'calendar-alt',
            'keywords' => array('evenement', 'rdv')
        ));
    }
}

function acf_block_event_render_callback($block, $content = '', $is_preview = true, $post_id)
{
    $context = Timber::get_context();

    // Store block values.
    $context['block'] = $block;

    // Custom classes and alignement
    $className = '';
    $alignment = '';
    if (!empty($block['className'])) {
        $className .= ' ' . $block['className'];
    }
    if (!empty($block['align'])) {
        $alignment = 'align' . $block['align'];
    }

    $context['classes'] = $className;
    $context['alignment'] = $alignment;

    // Store field values.
    $context['fields'] = get_fields();

    // Store $is_preview value.
    $context['is_preview'] = $is_preview;

    // Render the block.
    Timber::render('acf-blocks/event.twig', $context);
}