post_content. * @var array $args Contains `form`, `action_key`, `values`. * @var FrmGatedContentAction $this Action class instance. Use get_field_name() / get_field_id(). */ if ( ! defined( 'ABSPATH' ) ) { die( 'You are not allowed to call this page directly.' ); } $frm_gc_items = $instance->post_content['items'] ?? array(); $frm_gc_action_id = (int) $instance->ID; $frm_gc_field_name_base = $this->get_field_name( 'items' ); $frm_gc_types = FrmGatedContentAction::get_types(); // Unique wrapper ID per action instance — prevents JS collisions when multiple // gated content actions exist on the same form. $frm_gc_wrapper_id = 'frm_gc_settings_' . $this->number; // array> — posts grouped by item type key (e.g. 'page', 'post'). $frm_gc_posts = FrmGatedContentAction::get_posts(); $frm_gc_total_posts = array_sum( array_map( 'count', $frm_gc_posts ) ); $frm_gc_use_autocomplete = $frm_gc_total_posts > 50; if ( $frm_gc_use_autocomplete ) { wp_enqueue_script( 'jquery-ui-autocomplete' ); // Pre-encode one autocomplete source per type for reuse in all item rows. $frm_gc_posts_source = array(); foreach ( $frm_gc_posts as $frm_gc_type_key => $frm_gc_type_posts ) { $frm_gc_posts_source[ $frm_gc_type_key ] = FrmGatedContentAction::get_posts_autocomplete_source( $frm_gc_type_posts ); } unset( $frm_gc_type_key, $frm_gc_type_posts ); } ?>

    $frm_gc_item ) : ?>