1, 'js' => 1, 'match' => '.module-table.tb_freeze_table', ); } /** * Normalize stored table data into head/body/cols arrays. */ public static function parse_data(array $mod_settings):array { $data = isset($mod_settings['table_content']) ? $mod_settings['table_content'] : array(); if (is_string($data)) { $data = json_decode($data, true); } $data = (array) $data + array( 'head' => array(), 'body' => array(), 'cols' => array(), ); $col_count = isset($data['col_count']) ? (int) $data['col_count'] : 0; if ($col_count === 0) { $col_count = count($data['head']); foreach ($data['body'] as $row) { $col_count = max($col_count, count((array) $row)); } } $head = array(); for ($i = 0; $i < $col_count; ++$i) { $head[$i] = isset($data['head'][$i]) ? (string) $data['head'][$i] : ''; } $data['head'] = $head; for ($i = 0; $i < $col_count; ++$i) { if (!isset($data['cols'][$i])) { $data['cols'][$i] = array('stack' => true, 'width' => ''); } else { $data['cols'][$i] = (array) $data['cols'][$i] + array('stack' => true, 'width' => ''); } } foreach ($data['body'] as $r => $row) { $row = array_values((array) $row); for ($i = 0; $i < $col_count; ++$i) { if (!isset($row[$i])) { $row[$i] = ''; } } $data['body'][$r] = array_slice($row, 0, $col_count); } $data['col_count'] = $col_count; return $data; } public static function get_static_content(array $module):string { $data = self::parse_data($module['mod_settings']); if (empty($data['head']) && empty($data['body'])) { return ''; } $output = '
| ' . wp_kses_post($cell) . ' | '; } $output .= '
|---|
| ' . wp_kses_post($cell) . ' | '; } $output .= '