options = get_option('1day_options');
?>
Users > ... > Generate API key" class="odp_star">', // Title
array($this, 'api_key_callback'), // Callback
'1day-options', // Page
'1day_settings' // Section
);
if (ODP_MULTIPLE_HOTELS)
add_settings_field(
'google_map_api_key', // ID
'Google Map API key', // Title
array($this, 'google_map_api_key_callback'), // Callback
'1day-options', // Page
'1day_settings' // Section
);
add_settings_field(
'date_format', // ID
'Date format', // Title
array($this, 'date_format_callback'), // Callback
'1day-options', // Page
'1day_settings' // Section
);
if (ODP_MULTIPLE_HOTELS)
add_settings_field(
'hotel_page_id', // ID
'Hotel template page id', // Title
array($this, 'hotel_page_id_callback'), // Callback
'1day-options', // Page
'1day_settings' // Section
);
if (ODP_MULTIPLE_HOTELS)
add_settings_field(
'page_count',
'Hotels to display per page',
array($this, 'page_items_count_callback'), // Callback
'1day-options', // Page
'1day_settings' // Section
);
if (ODP_MULTIPLE_HOTELS)
add_settings_field(
'hide_hotel_name',
'Hide hotel name on a room page',
array($this, 'hide_hotel_name_callback'), // Callback
'1day-options', // Page
'1day_settings' // Section
);
}
/**
* Sanitize each setting field as needed
*
* @param array $input Contains all settings fields as array keys
* @return array
*/
public function sanitize($input)
{
$new_input = array();
if (isset($input['api_key']))
$new_input['api_key'] = sanitize_text_field($input['api_key']);
if (isset($input['google_map_api_key']))
$new_input['google_map_api_key'] = sanitize_text_field($input['google_map_api_key']);
if (isset($input['date_format']))
$new_input['date_format'] = sanitize_text_field($input['date_format']);
if (isset($input['hotel_page_id']))
$new_input['hotel_page_id'] = sanitize_text_field($input['hotel_page_id']);
if (isset($input['page_items_count']))
$new_input['page_items_count'] = sanitize_text_field($input['page_items_count']);
$new_input['hide_hotel_name'] = isset($input['hide_hotel_name']) ? 'yes' : 'no';
$new_input['form_position'] = isset($input['form_position']);
return $new_input;
}
/**
* Print the Section text
*/
public function print_section_info()
{
print 'Enter your settings below:';
}
/**
* Get the settings option array and print one of its values
*/
public function api_key_callback()
{
printf(
'',
isset($this->options['api_key']) ? esc_attr($this->options['api_key']) : ''
);
}
public function google_map_api_key_callback()
{
printf(
'',
isset($this->options['google_map_api_key']) ? esc_attr($this->options['google_map_api_key']) : ''
);
}
public function date_format_callback() {
$options = [
'M d, Y',
'm/d/Y',
'd/m/Y',
'd M Y',
'Y/m/d'
];
$new_options = [];
foreach ($options as &$option) {
$date = new DateTime('now');
$new_options[$option] = $date->format($option) . ' (' . $option . ')';
}
$options = $new_options;
$date_format = !empty($this->options['date_format']) ? $this->options['date_format'] : '';
if (empty($date_format))
$date_format = array_keys($options)[0];
?>
',
isset($this->options['hotel_page_id']) ? esc_attr($this->options['hotel_page_id']) : ''
);
}
public function page_items_count_callback()
{
printf(
'',
isset($this->options['page_items_count']) ? esc_attr($this->options['page_items_count']) : ''
);
}
public function hide_hotel_name_callback()
{
$hide_hotel_name = isset($this->options['hide_hotel_name']) ? esc_attr($this->options['hide_hotel_name']) : 'yes';
?>
/>