Exemplo n.º 1
0
/**
 * outputs properly sanitized data
 *
 * @param	string	$string		the string to run through a validation function
 * @param	string	$function	the validation function
 *
 * @return						a validated string
 */
function mt_projects_meta_box_sanitize($string, $function = 'sanitize_text_field')
{
    switch ($function) {
        case 'intval':
            return intval($string);
        case 'absint':
            return absint($string);
        case 'wp_kses_post':
            return wp_kses_post($string);
        case 'wp_kses_data':
            return wp_kses_data($string);
        case 'esc_url_raw':
            return esc_url_raw($string);
        case 'is_email':
            return is_email($string);
        case 'sanitize_title':
            return sanitize_title($string);
        case 'santitize_boolean':
            return santitize_boolean($string);
        case 'sanitize_text_field':
        default:
            return sanitize_text_field($string);
    }
}
Exemplo n.º 2
0
/**
 * outputs properly sanitized data
 *
 * @param	string	$string		the string to run through a validation function
 * @param	string	$function	the validation function
 *
 * @return						a validated string
 */
function meta_box_sanitize($string, $function = 'sanitize_text_field')
{
    $allowed_html = array('a' => array('href' => true, 'title' => true), 'abbr' => array('title' => true), 'acronym' => array('title' => true), 'b' => array(), 'blockquote' => array('cite' => true), 'cite' => array(), 'code' => array(), 'del' => array('datetime' => true), 'em' => array(), 'i' => array(), 'q' => array('cite' => true), 'strike' => array(), 'strong' => array(), 'iframe' => array('width' => true, 'height' => true, 'frameborder' => true, 'scrolling' => true, 'marginheight' => true, 'marginwidth' => true, 'src' => true), 'script' => array('src' => true), 'p' => array(), 'br' => array(), 'hr' => array(), 'div' => array('class' => true), 'span' => array('class' => true), 'img' => array('src' => true, 'alt' => true, 'class' => true, 'width' => true, 'height' => true), 'table' => array('class' => true), 'tr' => array(), 'td' => array(), 'tbody' => array(), 'tfoot' => array(), 'ul' => array('class' => true), 'ol' => array('class' => true), 'li' => array());
    switch ($function) {
        case 'intval':
            return intval($string);
        case 'absint':
            return absint($string);
        case 'wp_kses_post':
            return wp_kses($string, $allowed_html);
        case 'wp_kses_data':
            return wp_kses_data($string);
        case 'esc_url_raw':
            return esc_url_raw($string);
        case 'is_email':
            return is_email($string);
        case 'sanitize_title':
            return sanitize_title($string);
        case 'santitize_boolean':
            return santitize_boolean($string);
        case 'sanitize_text_field':
        default:
            return wp_kses($string, $allowed_html);
    }
}