Basically, if there is only one layout available to this plugin, then it should just automatically add that layout upon click of the Add button (instead of a popup list like it does today).
My reasoning behind this is because that I like the functionality / layout of this field over the Repeater field.
If you can point me in the right direction I can write a plugin for this. But I’m not sure where I should start.
For now I am handling this with some simple front-end JS…
/*! FLEXIBLE CONTENT: AUTO-CLICK IF SINGLE OPTION **/
acf.add_action('ready', function($body){
$body.find('#post').on('click', 'a[data-event="add-layout"]', function(){
var $button = $(this);
var $target = $button.parents('.acf-flexible-content').eq(0).find('.clones').find('.layout');
if ($target.length === 1) {
setTimeout(function(){
var $popup = $button.next('.acf-fc-popup');
$popup.find('a').eq(0).click();
$popup.remove();
}, 0);
}
});
});
This reply has been marked as private.