示例#1
0
文件: header.php 项目: Makenrro/repos
function show_logo()
{
    $gen_sets = theme_get_option('general', 'gen_sets');
    $logo_url = isset($gen_sets['_logo']) ? $gen_sets['_logo'] : '';
    $is_logo_hdpi = isset($gen_sets['_logo-ppi']) ? $gen_sets['_logo-ppi'] : '';
    $logo_align = isset($gen_sets["_gen_logo_align"]) ? $gen_sets["_gen_logo_align"] : '';
    $logo_w = isset($gen_sets['_logo_w']) ? $gen_sets['_logo_w'] : '';
    $logo_h = isset($gen_sets['_logo_h']) ? $gen_sets['_logo_h'] : '';
    $logo_it = isset($gen_sets['_logo_it']) ? $gen_sets['_logo_it'] : '';
    $logo_ir = isset($gen_sets['_logo_ir']) ? $gen_sets['_logo_ir'] : '';
    $logo_il = isset($gen_sets['_logo_il']) ? $gen_sets['_logo_il'] : '';
    $logo_ib = isset($gen_sets['_logo_ib']) ? $gen_sets['_logo_ib'] : '';
    $logo_url_result = '';
    if ($logo_url) {
        $logo_url = esc_url($logo_url);
        if ($logo_w || $logo_h) {
            $logo_w = $is_logo_hdpi ? $logo_w * 2 : $logo_w;
            $logo_h = $is_logo_hdpi ? $logo_h * 2 : $logo_h;
            $img_settings = $logo_w ? $logo_h ? array('width' => $logo_w, 'height' => $logo_h, 'crop' => true) : array('width' => $logo_w, 'crop' => true) : ($logo_h ? array('height' => $logo_h, 'crop' => true) : '');
            $logo_url = bfi_thumb($logo_url, $img_settings);
        }
        $logo_url_result = $is_logo_hdpi ? cws_hdpi_to_ldpi_url($logo_url) : $logo_url;
    }
    if ($logo_align == 'center') {
        $logo_align = 'text-align:center;';
    } elseif ($logo_align == 'right') {
        $logo_align = 'float:right;';
    } else {
        $logo_align = 'float:left;';
    }
    $logo_style = '';
    if ($logo_it || $logo_ir || $logo_il || $logo_ib) {
        if ($logo_it) {
            $logo_style .= 'margin-top:' . $logo_it . 'px;';
        }
        if ($logo_ir) {
            $logo_style .= 'margin-right:' . $logo_ir . 'px;';
        }
        if ($logo_il) {
            $logo_style .= 'margin-left:' . $logo_il . 'px;';
        }
        if ($logo_ib) {
            $logo_style .= 'margin-bottom:' . $logo_ib . 'px;';
        }
    }
    if (!empty($logo_url_result)) {
        echo '<div id="kids_logo_block" style="' . $logo_align . ' ' . $logo_style . '" ><a id="kids_logo_text" href="' . home_url() . '"><img src="' . esc_url($logo_url_result) . '" alt="' . get_bloginfo('name') . '" title="' . get_bloginfo('name') . '" /></a></div>';
    }
}
示例#2
0
function cws_process_custom_theme_colors()
{
    $gen_sets = theme_get_option('general', 'gen_sets');
    $new_css = file_get_contents(THEME_DIR . '/front/css/dynamic.css');
    // colors
    $theme_c = isset($gen_sets['_theme_skin_color']) ? $gen_sets['_theme_skin_color'] : THEME_COLOR;
    $theme_c_s = isset($gen_sets['_theme_skin_second_color']) ? $gen_sets['_theme_skin_second_color'] : THEME_COLOR_2;
    $theme_c_t = isset($gen_sets['_theme_skin_third_color']) ? $gen_sets['_theme_skin_third_color'] : THEME_COLOR_3;
    $theme_c_f = isset($gen_sets['_theme_footer_color']) ? $gen_sets['_theme_footer_color'] : THEME_COLOR_FOOTER;
    $theme_c_m = isset($gen_sets['_theme_menu_color']) ? $gen_sets['_theme_menu_color'] : THEME_COLOR_MENU;
    $theme_c_m_h = isset($gen_sets['_theme_menu_hover_color']) ? $gen_sets['_theme_menu_hover_color'] : THEME_COLOR_MENU_HOVER;
    $replacements = array('#cws_theme_color#' => $theme_c, '#cws_theme_color_rgb#' => cws_Hex2RGB($theme_c), '#cws_theme_color_middle#' => $theme_c_s, '#cws_theme_color_middle_rgb#' => cws_Hex2RGB($theme_c_s), '#cws_theme_color_middle_helper#' => $theme_c_t, '#cws_theme_color_middle_helper_rgb#' => cws_Hex2RGB($theme_c_t), '#cws_footer_color#' => $theme_c_f, '#cws_footer_color_rgb#' => cws_Hex2RGB($theme_c_f), '#cws_menu_color#' => $theme_c_m, '#cws_menu_color_rgb#' => cws_Hex2RGB($theme_c_m), '#cws_menu_color_hover#' => $theme_c_m_h, '#cws_menu_color_hover_rgb#' => cws_Hex2RGB($theme_c_m), '#cws_icon_long_shadow_rgb#' => cws_text_shadow_gen($theme_c_m));
    foreach ($replacements as $k => $v) {
        $new_css = str_replace($k, $v, $new_css);
    }
    // fonts
    $menu_gfont = isset($gen_sets['_menu_gfont']) ? $gen_sets['_menu_gfont'] : 'Lobster Two';
    $menu_font_color = isset($gen_sets['_menu_gfont-color']) ? $gen_sets['_menu_gfont-color'] : '#fff';
    $menu_font_subset = isset($gen_sets['_menu_gfont-subset']) ? $gen_sets['_menu_gfont-subset'] : 'latin';
    $menu_font_variant = isset($gen_sets['_menu_gfont-variant']) ? $gen_sets['_menu_gfont-variant'] : '400';
    $menu_font_size = isset($gen_sets['_menu_gfont-font_size']) ? $gen_sets['_menu_gfont-font_size'] : 19;
    $menu_line_height = isset($gen_sets['_menu_gfont-line_height']) ? $gen_sets['_menu_gfont-line_height'] : 1.5;
    $headers_gfont = isset($gen_sets['_headers_gfont']) ? $gen_sets['_headers_gfont'] : 'Lobster Two';
    $headers_font_color = isset($gen_sets['_headers_gfont-color']) ? $gen_sets['_headers_gfont-color'] : '#3185cb';
    $headers_font_subset = isset($gen_sets['_headers_gfont-subset']) ? $gen_sets['_headers_gfont-subset'] : 'latin';
    $headers_font_variant = isset($gen_sets['_headers_gfont-variant']) ? $gen_sets['_headers_gfont-variant'] : '400';
    $headers_font_size = isset($gen_sets['_headers_gfont-font_size']) ? $gen_sets['_headers_gfont-font_size'] : 32;
    $headers_line_height = isset($gen_sets['_headers_gfont-line_height']) ? $gen_sets['_headers_gfont-line_height'] : 1.125;
    $text_gfont = isset($gen_sets['_text_gfont']) ? $gen_sets['_text_gfont'] : '';
    $text_font_color = isset($gen_sets['_text_gfont-color']) ? $gen_sets['_text_gfont-color'] : '#a2825c';
    $text_font_subset = isset($gen_sets['_text_gfont-subset']) ? $gen_sets['_text_gfont-subset'] : 'latin';
    $text_font_variant = isset($gen_sets['_text_gfont-variant']) ? $gen_sets['_text_gfont-variant'] : '400';
    $text_font_size = isset($gen_sets['_text_gfont-font_size']) ? $gen_sets['_text_gfont-font_size'] : 16;
    $text_line_height = isset($gen_sets['_text_gfont-line_height']) ? $gen_sets['_text_gfont-line_height'] : 1.375;
    $import = cws_fonts_buil_import($menu_gfont, $menu_font_variant, $menu_font_subset);
    $import .= cws_fonts_buil_import($headers_gfont, $headers_font_variant, $headers_font_subset);
    $import .= cws_fonts_buil_import($text_gfont, $text_font_variant, $text_font_subset);
    $replacements = array('#cws_menu_font_family#' => $menu_gfont . (strpos($menu_font_variant, 'talic') ? '; font-style: italic' : ''), '#cws_menu_font_color#' => $menu_font_color, '#cws_menu_font_size#' => $menu_font_size, '#cws_menu_line_height#' => $menu_line_height, '#headers_font_family#' => $headers_gfont . (strpos($headers_font_variant, 'talic') ? '; font-style: italic' : ''), '#headers_font_color#' => $headers_font_color, '#headers_font_size#' => $headers_font_size, '#headers_line_height#' => $headers_line_height, '#text_font_family#' => $text_gfont . (strpos($text_font_variant, 'talic') ? '; font-style: italic' : ''), '#text_font_color#' => $text_font_color, '#text_font_size#' => $text_font_size, '#text_line_height#' => $text_line_height);
    foreach ($replacements as $k => $v) {
        $new_css = str_replace($k, $v, $new_css);
    }
    $pretty_social = isset($gen_sets['_pretty_social']) ? $gen_sets['_pretty_social'] : '';
    $_custom_pattern = isset($gen_sets['_theme_load_pattern']) ? $gen_sets['_theme_load_pattern'] : '';
    $is_c_pattern_hdpi = isset($gen_sets['_theme_load_pattern-ppi']) ? $gen_sets['_theme_load_pattern-ppi'] : '';
    $_custom_pattern_header = isset($gen_sets['_theme_header_pattern']) ? $gen_sets['_theme_header_pattern'] : '';
    $is_c_p_header_hdpi = isset($gen_sets['_theme_header_pattern-ppi']) ? $gen_sets['_theme_header_pattern-ppi'] : '';
    $_custom_footer_image = isset($gen_sets['_theme_footer_image']) ? $gen_sets['_theme_footer_image'] : '';
    $is_c_f_img_hdpi = isset($gen_sets['_theme_footer_image-ppi']) ? $gen_sets['_theme_footer_image-ppi'] : '';
    $_custom_footer_padding = isset($gen_sets['_footer_padding']) ? $gen_sets['_footer_padding'] : '';
    if (!$pretty_social) {
        $new_css .= ".pp_social {display:none;}\n";
    }
    if ($_custom_footer_padding) {
        $new_css .= ".page-content .container {padding-bottom: " . $_custom_footer_padding . "px;}\n";
    }
    if ($_custom_footer_padding) {
        $new_css .= ".kids_bottom_content .content_bottom_bg{height:" . $_custom_footer_padding . "px}\n";
    }
    if ($_custom_pattern && $is_c_pattern_hdpi) {
        $new_css .= ".t-custom-pattern .bg-level-2 {background-image: url(" . cws_hdpi_to_ldpi_url($_custom_pattern) . ");}\n";
    } elseif ($_custom_pattern) {
        $new_css .= ".t-custom-pattern .bg-level-2 {background-image: url(" . $_custom_pattern . ");}\n";
    }
    if ($_custom_pattern_header && $is_c_p_header_hdpi) {
        $new_css .= ".bg-level-1 {background-image: url(" . cws_hdpi_to_ldpi_url($_custom_pattern_header) . ");}\n";
    } elseif ($_custom_pattern_header) {
        $new_css .= ".bg-level-1 {background-image: url(" . $_custom_pattern_header . ");}\n";
    }
    if ($_custom_footer_image && $is_c_f_img_hdpi) {
        $new_css .= ".kids_bottom_content .content_bottom_bg {background-image: url(" . cws_hdpi_to_ldpi_url($_custom_footer_image) . ");}\n";
    } elseif ($_custom_footer_image) {
        $new_css .= ".kids_bottom_content .content_bottom_bg {background-image: url(" . $_custom_footer_image . ");}\n";
    }
    /* retina ready */
    if ($is_c_pattern_hdpi || $is_c_p_header_hdpi || $is_c_f_img_hdpi) {
        $new_css .= '@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
					only screen and (min--moz-device-pixel-ratio: 1.5),
					only screen and (-o-device-pixel-ratio: 3/2), 
					only screen and (min-device-pixel-ratio: 1.5) {';
        if ($_custom_pattern && $is_c_pattern_hdpi) {
            $new_css .= ".t-custom-pattern .bg-level-2 {background-image: url(" . $_custom_pattern . "); background-size: " . cws_hdpi_bg_size($_custom_pattern) . "px; }\n";
        }
        if ($_custom_pattern_header && $is_c_p_header_hdpi) {
            $new_css .= ".bg-level-1 {background-image: url(" . $_custom_pattern_header . "); background-size: " . cws_hdpi_bg_size($_custom_pattern_header) . "px;}\n";
        }
        if ($_custom_footer_image && $is_c_f_img_hdpi) {
            $new_css .= ".kids_bottom_content .content_bottom_bg {background-image: url(" . $_custom_footer_image . "); background-size: " . cws_hdpi_bg_size($_custom_footer_image) . "px;}\n";
        }
        $new_css .= '}';
    }
    return $import . $new_css;
}