git-svn-id: https://192.168.0.254/svn/Proyectos.EstudioJuridicoAlmagro_Web/trunk@3 c22fe52d-42d7-ba4f-95f7-33effcf65713
106 lines
2.4 KiB
PHP
106 lines
2.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* echo the font family based on option id
|
|
*/
|
|
|
|
function wpv_font_family($opt_id) {
|
|
echo wpv_get_font_family($opt_id);
|
|
}
|
|
|
|
/**
|
|
* return the font family based on option id
|
|
*/
|
|
|
|
function wpv_get_font_family($opt_id) {
|
|
global $wpv_fonts, $used_google_fonts, $used_local_fonts;
|
|
|
|
$font = wpv_get_option($opt_id . '-face');
|
|
|
|
// we need the google and local fonts cached, so we can generate the correct @import rules
|
|
|
|
if(isset($wpv_fonts[$font]['gf'])) {
|
|
if(!is_array($used_google_fonts)) {
|
|
$used_google_fonts = array($wpv_fonts[$font]['gf']);
|
|
}
|
|
else {
|
|
$used_google_fonts[]= $wpv_fonts[$font]['gf'];
|
|
}
|
|
} elseif(isset($wpv_fonts[$font]['local'])) {
|
|
if(!is_array($used_local_fonts)) {
|
|
$used_local_fonts = array($wpv_fonts[$font]['family']);
|
|
}
|
|
else {
|
|
$used_local_fonts[]= $wpv_fonts[$font]['family'];
|
|
}
|
|
}
|
|
|
|
return $wpv_fonts[$font]['family'];
|
|
}
|
|
|
|
/**
|
|
* return the font family based on option id
|
|
*/
|
|
|
|
function wpv_get_font_url($font) {
|
|
global $wpv_fonts;
|
|
|
|
if(isset($wpv_fonts[$font]['gf'])) {
|
|
// this is a google font
|
|
|
|
return "http://fonts.googleapis.com/css?family=".$wpv_fonts[$font]['gf']."&subset=cyrillic,greek,latin";
|
|
} elseif(isset($wpv_fonts[$font]['local'])) {
|
|
// this is a local @font-face font
|
|
|
|
return WPV_FONTS_URI."$font/stylesheet.css";
|
|
}
|
|
|
|
return '';
|
|
}
|
|
|
|
function wpv_hex2rgba($color, $opacity) {
|
|
return wpv_hex2rgba_plain(wpv_get_option($color), wpv_get_option($opacity));
|
|
}
|
|
|
|
function wpv_hex2rgba_plain($color, $opacity) {
|
|
if($color[0] === '#') {
|
|
$result .= 'rgba(';
|
|
$result .= (string)hexdec($color[1].$color[2]) . ', ';
|
|
$result .= (string)hexdec($color[3].$color[4]) . ', ';
|
|
$result .= (string)hexdec($color[5].$color[6]) . ', ';
|
|
$result .= round($opacity,2) . ')';
|
|
|
|
return $result;
|
|
}
|
|
|
|
return '';
|
|
}
|
|
|
|
function wpv_grad_filter($color, $opacity = 1) {
|
|
if($color[0] != '#') {
|
|
return '#00000000';
|
|
}
|
|
|
|
$color = substr($color, 1);
|
|
|
|
$result = '#';
|
|
$opacity = dechex(floor($opacity*255));
|
|
if(strlen($opacity) == 1) {
|
|
$opacity .= $opacity;
|
|
}
|
|
$result .= $opacity;
|
|
|
|
if(strlen($color) == 3) {
|
|
$color .= $color;
|
|
}
|
|
|
|
$result .= $color;
|
|
|
|
return $result;
|
|
}
|
|
|
|
function wpv_font($opt) {
|
|
?>
|
|
font: <?php wpvge($opt.'-weight')?> <?php wpvge($opt.'-size')?>px/<?php wpvge($opt.'-lheight')?>px <?php wpv_font_family($opt);?>;
|
|
<?php
|
|
}
|