Exemplo n.º 1
0
function fb_sanitize_options($options_array)
{
    foreach ($options_array as $key => $value) {
        if (is_array($value)) {
            $options_array[$key] = fb_sanitize_options($value);
        } else {
            $options_array[$key] = sanitize_text_field($value);
        }
    }
    return $options_array;
}
Exemplo n.º 2
0
function fb_options_validate_plugin($array, $label_prefix, $sanitize = true)
{
    // TODO desperately needs to be driven from plugin definitions
    if ($sanitize) {
        $array = fb_sanitize_options($array);
    }
    if (!isset($array['enabled']) || !$array['enabled']) {
        return $array;
    }
    foreach ($array as $key => $value) {
        $label = '';
        switch ($key) {
            case 'trigger':
                $label = sprintf(__('%s trigger', 'facebook'), $label_prefix);
                break;
            case 'read_time':
                $label = sprintf(__('%s read time', 'facebook'), $label_prefix);
                break;
            case 'width':
                $label = sprintf(__('%s width', 'facebook'), $label_prefix);
                break;
            case 'num_posts':
                $label = sprintf(__('%s number of posts', 'facebook'), $label_prefix);
                break;
        }
        if ($label != '' && fb_options_validate_present($value, $label)) {
            $value = fb_options_validate_integer($value, $label);
        }
        $array[$key] = $value;
    }
    return $array;
}