function bsh_shortcode_style($property, $value, $type = 'default') { global $shortcode_style; if (!empty($value)) { if ($type === 'color' or $type === 'gradient' or $type === 'border-darken') { $value = bsh_determine_color($value); } if ($type === 'text-shadow') { if ($value == 'primary') { $shortcode_style .= 'text-shadow: -1px -1px 0 rgba(0,0,0,0.1);'; } else { $color = new Color($value); $shortcode_style .= 'text-shadow: -1px -1px 0 #' . $color->darken(10) . ';'; } } if ($type === 'gradient') { $color = new Color($value); $gradient = $color->makeGradient(10); $shortcode_style .= "\n\t\t\t\tbackground: #" . $gradient['light'] . ";\n\t\t\t\tbackground: -moz-linear-gradient(top, #" . $gradient['light'] . " 0%, #" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#" . $gradient['light'] . "), color-stop(100%,#" . $gradient['dark'] . "));\n\t\t\t\tbackground: -webkit-linear-gradient(top, #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: -o-linear-gradient(top, #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: -ms-linear-gradient(top, #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: linear-gradient(to bottom, #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='" . $gradient['light'] . "', endColorstr='" . $gradient['dark'] . "',GradientType=0 );\n\t\t\t"; } elseif ($type === 'border-darken') { $color = new Color($value); $shortcode_style .= $property . ': #' . $color->darken(10) . ';'; } elseif ($type === 'radius') { $shortcode_style .= ' -moz-border-radius: ' . $value . '; -khtml-border-radius: ' . $value . '; -ie-border-radius: ' . $value . '; -o-border-radius: ' . $value . '; border-radius: ' . $value . '; '; } else { $css = $property . ': ' . $value; $shortcode_style .= $css . ';'; } } }
/** * Set the (inline) css for the widget rendering. * * @param array $instance An array containing settings for the widget. * @param string $uid Identifiant of the widget. * @param boolean $flat_design Enabling flat design mode. * @since 2.0.0 */ public function css($instance, $uid, $flat_design) { require_once LWS_INCLUDES_DIR . 'phpcolors/Color.php'; try { $maxwidth = round($instance['width']); } catch (Exception $ex) { $maxwidth = 0; } $txt_color = $instance['txt_color']; $color = new Color($instance['bg_color']); $opacity = (11 - $instance['bg_opacity']) / 11; if ($opacity < 0.1) { $opacity = 0; } if ($color->isDark()) { $gradient = $color->makeGradient(20); } else { $gradient = $color->makeGradient(15); } $border = new Color($gradient['light']); $icon = new Color($txt_color); if ($border->isDark()) { $ico_color = '#' . $icon->darken(1); $unit_color = '#' . $icon->lighten(1); } else { $ico_color = '#' . $icon->lighten(1); $unit_color = '#' . $icon->darken(1); } if ($color->isDark()) { if ($icon->isDark()) { $bcc = $icon->darken(4); } else { $bcc = $icon->darken(30); } } else { if ($icon->isDark()) { $bcc = $icon->lighten(4); } else { $bcc = $icon->lighten(20); } } if ($flat_design) { $gradient_dark = Color::hexToRgbString($instance['bg_color'], $opacity); $gradient_light = Color::hexToRgbString($instance['bg_color'], $opacity); $border_color1 = '#' . $bcc; $border_color2 = '#' . $bcc; } else { $gradient_dark = Color::hexToRgbString('#' . $gradient['dark'], $opacity); $gradient_light = Color::hexToRgbString('#' . $gradient['light'], $opacity); $border_color1 = '#' . $border->darken(); $border_color2 = '#' . $border->darken(16); } $id = $uid; $shadows = !$flat_design; $borders = $instance['show_borders']; include LWS_PUBLIC_DIR . 'partials/live-weather-station-widget-ephemeris-display-css.php'; }
public static function generate_css_gradient($selector, $style, $mod_name) { $mod = get_theme_mod($mod_name); if (!empty($mod)) { $color = new Color($mod); $gradient = $color->makeGradient(); echo $selector . "{\n\t\t\t\tbackground: #" . $gradient['light'] . ";\n\t\t\t\tbackground: -moz-linear-gradient(top, #" . $gradient['light'] . " 0%, #" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#" . $gradient['light'] . "), color-stop(100%,#" . $gradient['dark'] . "));\n\t\t\t\tbackground: -webkit-linear-gradient(top, #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: -o-linear-gradient(top, #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: -ms-linear-gradient(top, #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: linear-gradient(to bottom, #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#" . $gradient['light'] . "', endColorstr='#" . $gradient['dark'] . "',GradientType=0 );\n\t\t\t}"; } }