<?php

/* Text */

add_filter( 'of_sanitize_text', 'sanitize_text_field' );



/* Radio */

add_filter( 'of_sanitize_radio', 'of_sanitize_enum', 10, 2);



/* Uploader */

function of_sanitize_upload( $grain_input ) {
	$grain_output = '';
	$grain_filetype = wp_check_filetype($grain_input);
	if ( $grain_filetype["ext"] ) {
		$grain_output = $grain_input;
	}
	return $grain_output;
}
add_filter( 'of_sanitize_upload', 'of_sanitize_upload' );

/* Check that the key value sent is valid */

function of_sanitize_enum( $grain_input, $grain_option ) {
	$grain_output = '';
	if ( array_key_exists( $grain_input, $grain_option['options'] ) ) {
		$grain_output = $grain_input;
	}
	return $grain_output;
}

