Hey folks,
we experience issues with a custom button block after updating from ACF Pro 5.9.2 to 5.9.4.
This notice displays in the block editor for every custom acf block already present.
It works when adding another acf custom button block to the editor, though.
we also noticed that acf_register_block()
was replaced by acf_register_block_type()
it seems.
This is the code for adding the block
acf_register_block_type(array(
'name' => 'acf-button',
'title' => __('Button', 'ZitrusWPBulma-Child'),
'description' => __('A custom block to display a configurable button.', 'ZitrusWPBulma-Child'),
'render_template' => 'parts/blocks/button.php',
'category' => 'layout',
'icon' => 'button',
'keywords' => array( 'button', 'schaltfläche' ),
//'mode' => 'preview'
));
This is the template:
<?php
/**
* Block Name: Button
*
* displays a configurable button in theme style
*
*/
$mode = get_field('mode');
$button = get_field('button');
if( $mode === 'link' AND ! $button ) {
return;
}
$modal_settings = get_field('modal-settings');
if( $mode === 'modal' AND ! $modal_settings ) {
return;
}
$modal_target = ($mode === 'modal') ? 'data-target=' . $modal_settings['target-id'] : '';
$button_target = ($button AND $button['target'] === '_blank') ? 'target="_blank" rel="noopener"' : '';
$href = ($button AND isset($button['url'])) ? 'href="'.esc_url($button['url']).'"' : '';
$label = ($button AND $button['title']) ? $button['title'] : (($modal_settings AND isset($modal_settings['title'])) ? $modal_settings['title'] : '');
$style = get_field('style');
$size = get_field('size');
$alignment = get_field('alignment');
$disabled = false;
if( $style == 'is-disabled' ) {
$disabled = true;
$modal_target = '';
$href = 'javascript:void();';
}
?>
<div class="acf-button-wrapper <?= esc_attr($alignment) ?>">
<a class="acf-button button <?= esc_attr($style) ?> <?= esc_attr($size) ?><?= ($mode === 'modal' AND !$disabled) ? ' modal-button' : '' ?>" <?= ($disabled) ? 'disabled' : ''; ?> <?= $href ?> <?= $button_target ?> <?= $modal_target ?>>
<span><?= esc_html($label) ?></span>
</a>
</div>
Any ideas? Thank you!
This has been reported recently in at least 2 other topics. You can contact the developer here https://www.advancedcustomfields.com/contact/
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF’s Repeater field is a versatile solution for repeating content in #WordPress.
— Advanced Custom Fields (@wp_acf) December 29, 2022
What’s your favorite use case for the Repeater field?
What’s the weirdest thing you’ve ever used it for?
Let us know!👇
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.