jQuery(document).ready(function() { try { // Add Elements button var acf_fc_render = acf.fields.flexible_content.render; acf.fields.flexible_content.render = function() { acf_fc_modal_init(); acf_fc_modal_handle_validation(); return acf_fc_render.apply(this, arguments); } // ACF FC Modal acf_fc_modal_init(); } catch(e) {} }); // Init Modal function acf_fc_modal_init() { jQuery('.acf-flexible-content .layout:not(.acf-clone)').each(function() { var layout = jQuery(this); // Ignoring if it is a nested FC if(layout.parents('.acf-fields').length > 1) return true; else layout.addClass('fc-modal'); // Remove Toggle button and click event layout.find('> .acf-fc-layout-handle').off('click'); layout.find('> .acf-fc-layout-controlls > li:last-child').remove(); // ACF 5.4 layout.find('> .acf-fc-layout-controlls > a:last-child').remove(); // ACF 5.5 // Edit button var controls = layout.find('> .acf-fc-layout-controlls'); if(controls.is('ul')) controls.append('