$value ) {
$input[ $key ] = apspider_sanitize_field( $value );
}
return $input;
}
// For checkboxes, return '1' if checked, otherwise ''
if ( is_bool( $input ) ) {
return $input ? '1' : '0';
}
// For text fields and other input types, sanitize with WordPress sanitize_text_field function
return sanitize_text_field( $input );
}
// Callback for a list of 'settings' for the sections
function apspider_setup_fields()
{
global $fields;
include_once('apspider-adminfieldsarray.php');
// Cycle through the settings, create the field and register the setting
foreach( $fields as $field ){
add_settings_field( $field['uid'], $field['label'], 'apspider_field_callback', 'apspider_fields', $field['section'], $field );
register_setting( 'apspider_fields', $field['uid'], 'apspider_sanitize_field');
$uid = $field['uid'];
$value = get_option($uid);
if ( $value === false){
update_option($field['uid'], $field['default']);
}
}
}
// Callback to handle each scenario of each settings field created and passed to it.
function apspider_field_callback( $arguments )
{
$value = get_option( $arguments['uid'] );
if( ! $value ) {
$value = $arguments['default'];
}
if ( ! empty ( $arguments['placeholder'] )){
$placeholder = esc_attr($arguments['placeholder']);
} else {
$placeholder = false ;
}
printf('