Example #1
0
 function radiate_sanitize_hex_color($color)
 {
     if ($unhashed = sanitize_hex_color_no_hash($color)) {
         return '#' . $unhashed;
     }
     return $color;
 }
Example #2
0
/**
 * Adds sanitization callback function: colors
 * @package Travelify
 */
function travelify_sanitize_hexcolor($color)
{
    if ($unhashed = sanitize_hex_color_no_hash($color)) {
        return '#' . $unhashed;
    }
    return $color;
}
 public static function sanitize_hex_color_no_hash_with_transparency($content)
 {
     $return = $content;
     if (trim($content) == 'transparent') {
         $return = trim($content);
     } else {
         $return = sanitize_hex_color_no_hash($content);
     }
     return $return;
 }
Example #4
0
/**
 * Adds sanitization callback function: colors
 * @package phg_gold
 */
function phg_gold_sanitize_hexcolor($color)
{
    if ($unhashed = sanitize_hex_color_no_hash($color)) {
        return '#' . $unhashed;
    }
    return $color;
}
Example #5
0
 function accelerate_color_option_hex_sanitize($color)
 {
     if ($unhashed = sanitize_hex_color_no_hash($color)) {
         return '#' . $unhashed;
     }
     return $color;
 }
Example #6
0
/**
 * Adds sanitization callback function: colors
 * @package Sparkling
 */
function sparkling_sanitize_hexcolor($color)
{
    if ($unhashed = sanitize_hex_color_no_hash($color)) {
        return '#' . $unhashed;
    }
    return $color;
}
 function creative_blog_color_option_hex_sanitize($color)
 {
     if ($unhashed = sanitize_hex_color_no_hash($color)) {
         return '#' . $unhashed;
     }
     return $color;
 }
Example #8
0
/**
 * adds sanitization callback function : colors
 * @package flat_responsive 
*/
function flat_responsive_sanitize_hex_color($color)
{
    if ($unhashed = sanitize_hex_color_no_hash($color)) {
        return '#' . $unhashed;
    }
    return $color;
}
 /**
  * Callback for validating the header_textcolor value.
  *
  * Accepts 'blank', and otherwise uses sanitize_hex_color_no_hash().
  *
  * @since 3.4.0
  */
 public function _sanitize_header_textcolor($color)
 {
     return 'blank' === $color ? 'blank' : sanitize_hex_color_no_hash($color);
 }
 /**
  * Callback for validating the header_textcolor value.
  *
  * Accepts 'blank', and otherwise uses sanitize_hex_color_no_hash().
  * Returns default text color if hex color is empty.
  *
  * @since 3.4.0
  *
  * @param string $color
  * @return mixed
  */
 public function _sanitize_header_textcolor($color)
 {
     if ('blank' === $color) {
         return 'blank';
     }
     $color = sanitize_hex_color_no_hash($color);
     if (empty($color)) {
         $color = get_theme_support('custom-header', 'default-text-color');
     }
     return $color;
 }
function puresimple_sanitize_hex_color($color)
{
    if ($unhashed = sanitize_hex_color_no_hash($color)) {
        return '#' . $unhashed;
    }
    return $color;
}
Example #12
0
 /**
  * Return the default HEX value for a color in a scheme.
  *
  * @param  string $color
  * @param  string $scheme (optional)
  * @param  bool   $hash   (optional)
  *
  * @return string|null
  */
 public function get_default_color($color, $scheme = '', $hash = false)
 {
     /**
      * Load for backwards compatibility prior to WordPress 4.6.
      *
      * @link  https://core.trac.wordpress.org/ticket/27583
      * @since 1.0.0
      */
     if (!function_exists('sanitize_hex_color') || !function_exists('sanitize_hex_color_no_hash')) {
         require_once ABSPATH . 'wp-includes/class-wp-customize-manager.php';
     }
     $scheme = empty($scheme) ? $this->get_current_color_scheme_array() : $this->color_schemes[$this->sanitize_color_scheme($scheme)];
     $hex = isset($scheme['colors'][$color]) ? trim($scheme['colors'][$color], '#') : null;
     return $hash ? sanitize_hex_color('#' . $hex) : sanitize_hex_color_no_hash($hex);
 }
/**
 * Sanitize repeatable data
 *
 * @param $input
 * @param $setting object $wp_customize
 * @return bool|mixed|string|void
 */
function screenr_sanitize_repeatable_data_field($input, $setting)
{
    $control = $setting->manager->get_control($setting->id);
    $fields = $control->fields;
    $input = json_decode($input, true);
    $data = wp_parse_args($input, array());
    if (!is_array($data)) {
        return false;
    }
    if (!isset($data['_items'])) {
        return false;
    }
    $data = $data['_items'];
    foreach ($data as $i => $item_data) {
        foreach ($item_data as $id => $value) {
            if (isset($fields[$id])) {
                switch (strtolower($fields[$id]['type'])) {
                    case 'text':
                        $data[$i][$id] = sanitize_text_field($value);
                        break;
                    case 'textarea':
                        $data[$i][$id] = force_balance_tags($value);
                        break;
                    case 'color':
                        $data[$i][$id] = sanitize_hex_color_no_hash($value);
                        break;
                    case 'coloralpha':
                        $data[$i][$id] = screenr_sanitize_color_alpha($value);
                        break;
                    case 'checkbox':
                        $data[$i][$id] = screenr_sanitize_checkbox($value);
                        break;
                    case 'select':
                        $data[$i][$id] = '';
                        if (is_array($fields[$id]['options']) && !empty($fields[$id]['options'])) {
                            // if is multiple choices
                            if (is_array($value)) {
                                foreach ($value as $k => $v) {
                                    if (isset($fields[$id]['options'][$v])) {
                                        $value[$k] = $v;
                                    }
                                }
                                $data[$i][$id] = $value;
                            } else {
                                // is single choice
                                if (isset($fields[$id]['options'][$value])) {
                                    $data[$i][$id] = $value;
                                }
                            }
                        }
                        break;
                    case 'radio':
                        $data[$i][$id] = sanitize_text_field($value);
                        break;
                    case 'media':
                        $value = wp_parse_args($value, array('url' => '', 'id' => false));
                        $value['id'] = absint($value['id']);
                        $data[$i][$id]['url'] = sanitize_text_field($value['url']);
                        if ($url = wp_get_attachment_url($value['id'])) {
                            $data[$i][$id]['id'] = $value['id'];
                            $data[$i][$id]['url'] = $url;
                        } else {
                            $data[$i][$id]['id'] = '';
                        }
                        break;
                    default:
                        $data[$i][$id] = wp_kses_post($value);
                }
            } else {
                $data[$i][$id] = wp_kses_post($value);
            }
            if (count($data[$i]) != count($fields)) {
                foreach ($fields as $k => $f) {
                    if (!isset($data[$i][$k])) {
                        $data[$i][$k] = '';
                    }
                }
            }
        }
    }
    return $data;
}
Example #14
0
/**
 * adds sanitization callback function : colors
 * @package Encounters Lite 
*/
function encounters_lite_sanitize_hex_color($color)
{
    if ($unhashed = sanitize_hex_color_no_hash($color)) {
        return '#' . $unhashed;
    }
    return $color;
}
Example #15
0
File: color.php Project: fovoc/make
/**
 * Convert a hex string into a comma separated RGB string.
 *
 * @link http://bavotasan.com/2011/convert-hex-color-to-rgb-using-php/
 *
 * @since 1.5.0.
 *
 * @param  $value
 * @return bool|string
 */
function ttfmake_hex_to_rgb($value)
{
    $hex = sanitize_hex_color_no_hash($value);
    if (6 === strlen($hex)) {
        $r = hexdec(substr($hex, 0, 2));
        $g = hexdec(substr($hex, 2, 2));
        $b = hexdec(substr($hex, 4, 2));
    } else {
        if (3 === strlen($hex)) {
            $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1));
            $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
            $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1));
        } else {
            return false;
        }
    }
    return "{$r}, {$g}, {$b}";
}
    /**
     * adds sanitization callback funtion : colors
     * @package Customizr
     * @since Customizr 1.1.4
     */
    function tc_sanitize_hex_color( $color ) {
      if ( $unhashed = sanitize_hex_color_no_hash( $color ) )
        return '#' . $unhashed;

      return $color;
    }
/**
 * User specific functions - saves user settings
 *
 * @since 1.0
 */
function status_save_changes()
{
    if (empty($_POST)) {
        return false;
    }
    if (!isset($_POST['status_design'])) {
        return false;
    }
    $nonce = isset($_POST['_nonce']) ? $_POST['_nonce'] : false;
    if (!$nonce) {
        return false;
    }
    if (!wp_verify_nonce($nonce, 'status-design_form')) {
        return false;
    }
    global $bp;
    $user_id = current_user_can('administrator') && !bp_is_my_profile() ? bp_displayed_user_id() : bp_current_user_id();
    if (!$user_id) {
        return false;
    }
    // Resetting options to default
    if (isset($_POST['status-reset_to_default'])) {
        update_user_meta($user_id, 'status_design_options', false);
        $old = status_get_background_image();
        if ($old['file'] && file_exists($old['file'])) {
            @unlink($old['file']);
        }
        update_user_meta($user_id, 'status_design_bg_image', array());
        wp_redirect(bp_core_get_user_domain($user_id) . $bp->profile->slug . '/design');
        die;
    }
    $update = array();
    foreach ($_POST['status_design'] as $key => $value) {
        $update[$key] = sanitize_text_field($value);
        // Potential fix for issue #119
    }
    if (!function_exists('sanitize_hex_color_no_hash') && file_exists(ABSPATH . WPINC . '/class-wp-customize-manager.php')) {
        require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    }
    if (function_exists('sanitize_hex_color_no_hash')) {
        $sane_bg = sanitize_hex_color_no_hash(ltrim($update['bg-color'], '#'));
        $update['bg-color'] = $sane_bg ? "#{$sane_bg}" : '';
        $sane_link = sanitize_hex_color_no_hash(ltrim($update['link-color'], '#'));
        $update['link-color'] = $sane_link ? "#{$sane_link}" : '';
    } else {
        $update['bg-color'] = preg_match('/^([0-9a-f]{3}){1,2}$/i', ltrim($update['bg-color'], '#')) ? '#' . ltrim($update['bg-color'], '#') : '';
        $update['link-color'] = preg_match('/^([0-9a-f]{3}){1,2}$/i', ltrim($update['link-color'], '#')) ? '#' . ltrim($update['link-color'], '#') : '';
    }
    if (isset($_POST['_status_design-remove_background'])) {
        $old = status_get_background_image();
        if ($old['file'] && file_exists($old['file'])) {
            @unlink($old['file']);
        }
        update_user_meta($user_id, 'status_design_bg_image', array());
    }
    status_handle_image_upload();
    if ($update) {
        update_user_meta($user_id, 'status_design_options', $update);
        wp_redirect(bp_core_get_user_domain($user_id) . $bp->profile->slug . '/design');
        die;
    }
}
 function seasonal_sanitize_hex_colour($color)
 {
     if ($unhashed = sanitize_hex_color_no_hash($color)) {
         return '#' . $unhashed;
     }
     return $color;
 }
 public static function sanitize_hex_with_transparency($value, $wp_settings_instance = false)
 {
     $return = $value;
     if (is_string($value) && strtolower(trim($value)) == 'transparent') {
         $return = 'transparent';
     } else {
         /**
          * NOTE: possible reason for the customizer issues?
          */
         //$return = sanitize_hex( $value, $wp_settings_instance );
         $return = sanitize_hex_color_no_hash($value);
     }
     //self::error_msg( 'calling ' . __METHOD__, array( 'input_value' => $value, 'return' => $return ) );
     return $return;
 }
function clea_presentation_get_current_colors()
{
    // to get all the current theme data in an array
    $mods = get_theme_mods();
    $color = array();
    foreach ($mods as $key => $values) {
        if (!is_array($values)) {
            // echo "<p>values :" . $values . "</p>" ;
            if (is_string($values) && trim($values) != '') {
                $hex = sanitize_hex_color_no_hash($values);
                if (trim($hex) != '') {
                    $color[$key] = $hex;
                    // echo "<p>key : " . $key . "color : " . $color[ $key ] ."</p>" ;
                    // echo "<p>--------------------------------------</p>" ;
                }
            }
        }
    }
    return $color;
}
Example #21
0
 function tc_sanitize_before_db($values_to_save)
 {
     //fired only when necessary
     if (!isset($_POST['action']) || isset($_POST['action']) && 'customize_save' != $_POST['action']) {
         return;
     }
     if (empty($values_to_save)) {
         return $values_to_save;
     }
     $values_to_save = (array) json_decode($values_to_save);
     foreach ($values_to_save as $setting_type => $value) {
         switch ($setting_type) {
             case 'font-size':
             case 'line-height':
             case 'letter-spacing':
                 //number input have to be 2 digits (max) and 2 letters
                 $value = esc_attr($value);
                 // clean input
                 $unit = 'px';
                 $unit = false != strpos($value, 'px') ? 'px' : 'em';
                 $split = explode($unit, $value);
                 $values_to_save[$setting_type] = (int) $split[0] . $unit;
                 // Force the value into integer type and adds the unit.
                 break;
             case 'color':
             case 'color-hover':
                 $values_to_save[$setting_type] = '#' . sanitize_hex_color_no_hash($value);
                 break;
             default:
                 //to do very secure => check if entry exist in list
                 $values_to_save[$setting_type] = sanitize_text_field($value);
                 break;
         }
     }
     return json_encode($values_to_save);
 }
Example #22
0
 function himalayas_color_option_hex_sanitize($color)
 {
     if ($unhashed = sanitize_hex_color_no_hash($color)) {
         return '#' . $unhashed;
     }
     return $color;
 }