Tabbed Rate Tables Accordions
post_name)) {
$base = $post->post_name;
} elseif (is_string($post) && $post !== '') {
$base = $post;
}
}
$uid = sanitize_title(($base ? $base . '-' : '') . 'rates-' . $post_id);
$render_cell = function ($val) {
$content = is_array($val) && isset($val['c']) ? $val['c'] : '';
return wp_kses_post($content);
};
$cell_has_data = function ($html) {
if (!is_string($html)) return false;
return trim(wp_strip_all_tags($html)) !== '';
};
$get_headers = function ($table) {
$headers = [];
if (!empty($table['header']) && is_array($table['header'])) {
foreach ($table['header'] as $th) {
$headers[] = wp_strip_all_tags($th['c'] ?? '');
}
}
return $headers;
};
$accounts = [];
$tab_index = 0;
if (have_rows('table', $post_id)) {
while (have_rows('table', $post_id)) {
the_row();
// sections is flexible content where each layout row IS a table section
$sections = get_sub_field('sections');
$updated = get_sub_field('last_updated');
$table_name = get_sub_field('table_name');
if (empty($sections) || !is_array($sections)) {
continue;
}
foreach ($sections as $layout) {
// only use the table_section layout
if (($layout['acf_fc_layout'] ?? '') !== 'table_section') {
continue;
}
$table = $layout['table_data'] ?? null;
$heading = $layout['table_heading'] ?? '';
$legal_text = $layout['table_legal_text'] ?? '';
if (empty($table) || !is_array($table)) {
continue;
}
$tab_index++;
$accounts[] = [
'index' => $tab_index,
'name' => $heading ?: ('Tab ' . $tab_index),
'table' => $table,
'legal' => $legal_text,
'updated' => $updated,
'table_name' => $table_name
];
}
}
}
?>
$acct) :
$tab_num = $acct['index'];
$effective_date_id = 'effective-pane-' . $uid . '-' . $tab_num;
$datespans .= '' . $acct['updated'] . '';
endforeach; ?>
Last Updated on
id=""
role="tabpanel"
aria-labelledby=""
tabindex="0"
>
| ' . $render_cell($td) . ' | '; if ($has_children) { echo ''; } echo ' |
$acct) : ?>
type="button"
data-bs-toggle="collapse"
data-bs-target="#"
aria-expanded=""
aria-controls=""
>
class="accordion-collapse collapse"aria-labelledby=""
data-bs-parent="#"
>
type="button"
data-bs-toggle="collapse"
data-bs-target="#"
aria-expanded=""
aria-controls=""
>
class="accordion-collapse collapse"aria-labelledby=""
data-bs-parent="#"
>




