Categories
February 18, 2025
Rates Table
ID)) {
$rate_post_id = (int) $target_post->ID;
} elseif (!empty($post_id)) {
$rate_post_id = (int) $post_id;
} else {
$rate_post_id = get_the_ID();
}
if (!$rate_post_id) {
return;
}
$render_cell = function($cell) {
if (is_array($cell) && array_key_exists('c', $cell)) {
return wp_kses_post($cell['c']);
}
return wp_kses_post((string) $cell);
};
$get_plain = function($cell) {
if (is_array($cell) && array_key_exists('c', $cell)) {
$cell = $cell['c'];
}
return trim(wp_strip_all_tags((string) $cell));
};
$get_cell = function($row, $index) {
if (!is_array($row) || !array_key_exists($index, $row)) {
return '';
}
return $row[$index];
};
$table_rows = get_field('table', $rate_post_id);
$tables = array();
if (is_array($table_rows)) {
foreach ($table_rows as $table_row) {
$sections = $table_row['sections'] ?? null;
if (!is_array($sections)) {
continue;
}
foreach ($sections as $section) {
if (($section['acf_fc_layout'] ?? '') !== 'table_section') {
continue;
}
$table_data = $section['table_data'] ?? null;
if (!is_array($table_data) || empty($table_data['body'])) {
continue;
}
$tables[] = array(
'table_heading' => $section['table_heading'] ?? '',
'table_data' => $table_data,
'legal' => $section['table_legal_text'] ?? ''
);
}
}
}
if (empty($tables)) {
return;
}
?>
$table_item) { ?>
$render_cell($get_cell($row, 0)),
'label_plain' => $row_label,
'rows' => array()
);
$current_group = count($groups) - 1;
}
$groups[$current_group]['rows'][] = $row;
}
$uid = sanitize_title('rate-table-' . $rate_post_id . '-' . $table_index . '-' . wp_unique_id());
$accordion_id = 'accordion-' . $uid;
?>
| 1 ? ' rowspan="' . esc_attr($rowspan) . '"' : ''; ?>> |
|---|
$group) { ?>
1 && $row_index < count($group['rows']) - 1) { ?>