Get columns and formats
public get_columns ( ) : array | ||
Результат | array | Columns and formats. |
/** * Sanitize the data for update/create * * @since 1.0 * @access private * * @param array $data The data to sanitize. * * @return array The sanitized data, based off column defaults. */ private function sanitize_columns($data) { $columns = $this->db->get_columns(); $default_values = $this->db->get_column_defaults(); foreach ($columns as $key => $type) { // Only sanitize data that we were provided if (!array_key_exists($key, $data)) { continue; } switch ($type) { case '%s': if ('email' == $key) { $data[$key] = sanitize_email($data[$key]); } elseif ('notes' == $key) { $data[$key] = strip_tags($data[$key]); } else { $data[$key] = sanitize_text_field($data[$key]); } break; case '%d': if (!is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { $data[$key] = $default_values[$key]; } else { $data[$key] = absint($data[$key]); } break; case '%f': // Convert what was given to a float $value = floatval($data[$key]); if (!is_float($value)) { $data[$key] = $default_values[$key]; } else { $data[$key] = $value; } break; default: $data[$key] = sanitize_text_field($data[$key]); break; } } return $data; }