function esplanade_validate_theme_options($input) { if (isset($input['submit-general']) || isset($input['reset-general'])) { if (!in_array($input['home_page_layout'], array('grid', 'blog'))) { $input['home_page_layout'] = esplanade_get_option('home_page_layout'); } if (!is_numeric(absint($input['home_page_excerpts'])) || $input['home_page_excerpts'] > get_option('posts_per_page') || '' == $input['home_page_excerpts']) { $input['home_page_excerpts'] = esplanade_get_option('home_page_excerpts'); } else { $input['home_page_excerpts'] = absint($input['home_page_excerpts']); } $input['slider'] = isset($input['slider']) ? true : false; $input['location'] = isset($input['location']) ? true : false; $input['breadcrumbs'] = isset($input['breadcrumbs']) ? true : false; $input['lightbox'] = isset($input['lightbox']) ? true : false; if (!in_array($input['posts_nav_labels'], array('next/prev', 'older/newer', 'earlier/later', 'numbered'))) { $input['posts_nav_labels'] = esplanade_get_option('posts_nav_labels'); } $input['fancy_dropdowns'] = isset($input['fancy_dropdowns']) ? true : false; $input['post_nav'] = isset($input['post_nav']) ? true : false; $input['facebook'] = isset($input['facebook']) ? true : false; $input['twitter'] = isset($input['twitter']) ? true : false; $input['google'] = isset($input['google']) ? true : false; $input['pinterest'] = isset($input['pinterest']) ? true : false; $input['author_box'] = isset($input['author_box']) ? true : false; $input['copyright_notice'] = esc_attr($input['copyright_notice']); $input['theme_credit_link'] = isset($input['theme_credit_link']) ? true : false; $input['author_credit_link'] = isset($input['author_credit_link']) ? true : false; $input['wordpress_credit_link'] = isset($input['wordpress_credit_link']) ? true : false; } elseif (isset($input['submit-layout']) || isset($input['reset-layout'])) { if (!in_array($input['layout'], array('content-sidebar', 'sidebar-content', 'sidebar-content-sidebar', 'no-sidebars', 'full-width'))) { $input['layout'] = esplanade_get_option('layout'); } $input['header_height'] = absint($input['header_height']); $input['sidebar_size'] = str_replace('"', '', $input['sidebar_size']); $input['sidebar_size'] = str_replace('%', '', $input['sidebar_size']); $input['sidebar_size'] = '"' . filter_var($input['sidebar_size'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . '%"'; $input['sidebar_left_size'] = str_replace('"', '', $input['sidebar_left_size']); $input['sidebar_left_size'] = str_replace('%', '', $input['sidebar_left_size']); $input['sidebar_left_size'] = '"' . filter_var($input['sidebar_left_size'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . '%"'; $input['sidebar_right_size'] = str_replace('"', '', $input['sidebar_right_size']); $input['sidebar_right_size'] = str_replace('%', '', $input['sidebar_right_size']); $input['sidebar_right_size'] = '"' . filter_var($input['sidebar_right_size'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . '%"'; $input['header_image_height'] = absint($input['header_image_height']); } elseif (isset($input['submit-design']) || isset($input['reset-general'])) { if (!in_array($input['color_scheme'], array('neutral', 'sand', 'nature', 'earth'))) { $input['color_scheme'] = esplanade_get_option('color_scheme'); } $input['user_css'] = esc_html($input['user_css']); } elseif (isset($input['submit-typography']) || isset($input['reset-typography'])) { $fonts = esplanade_available_fonts(); $units = array('px', 'pt', 'em', '%'); $input['body_font'] = array_key_exists($input['body_font'], $fonts) ? $input['body_font'] : esplanade_get_option('body_font'); $input['headings_font'] = array_key_exists($input['headings_font'], $fonts) ? $input['headings_font'] : esplanade_get_option('headings_font'); $input['content_font'] = array_key_exists($input['content_font'], $fonts) ? $input['content_font'] : esplanade_get_option('content_font'); $input['body_font_size'] = filter_var($input['body_font_size'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['body_font_size_unit'] = in_array($input['body_font_size_unit'], $units) ? $input['body_font_size_unit'] : esplanade_get_option('body_font_size_unit'); $input['body_line_height'] = filter_var($input['body_line_height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['body_line_height_unit'] = in_array($input['body_line_height_unit'], $units) ? $input['body_line_height_unit'] : esplanade_get_option('body_line_height_unit'); $input['h1_font_size'] = filter_var($input['h1_font_size'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['h1_font_size_unit'] = in_array($input['h1_font_size_unit'], $units) ? $input['h1_font_size_unit'] : esplanade_get_option('h1_font_size_unit'); $input['h2_font_size'] = filter_var($input['h2_font_size'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['h2_font_size_unit'] = in_array($input['h2_font_size_unit'], $units) ? $input['h2_font_size_unit'] : esplanade_get_option('h2_font_size_unit'); $input['h3_font_size'] = filter_var($input['h3_font_size'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['h3_font_size_unit'] = in_array($input['h3_font_size_unit'], $units) ? $input['h3_font_size_unit'] : esplanade_get_option('h3_font_size_unit'); $input['h4_font_size'] = filter_var($input['h4_font_size'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['h4_font_size_unit'] = in_array($input['h4_font_size_unit'], $units) ? $input['h4_font_size_unit'] : esplanade_get_option('h4_font_size_unit'); $input['headings_line_height'] = filter_var($input['headings_line_height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['headings_line_height_unit'] = in_array($input['headings_line_height_unit'], $units) ? $input['headings_line_height_unit'] : esplanade_get_option('headings_line_height_unit'); $input['content_font_size'] = filter_var($input['content_font_size'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['content_font_size_unit'] = in_array($input['content_font_size_unit'], $units) ? $input['content_font_size_unit'] : esplanade_get_option('content_font_size_unit'); $input['content_line_height'] = filter_var($input['content_line_height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['content_line_height_unit'] = in_array($input['content_line_height_unit'], $units) ? $input['content_line_height_unit'] : esplanade_get_option('content_line_height_unit'); $input['mobile_font_size'] = filter_var($input['mobile_font_size'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['mobile_font_size_unit'] = in_array($input['mobile_font_size_unit'], $units) ? $input['mobile_font_size_unit'] : esplanade_get_option('mobile_font_size_unit'); $input['mobile_line_height'] = filter_var($input['mobile_line_height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $input['mobile_line_height_unit'] = in_array($input['mobile_line_height_unit'], $units) ? $input['mobile_line_height_unit'] : esplanade_get_option('mobile_line_height_unit'); $input['body_color'] = esc_attr($input['body_color']); $input['headings_color'] = esc_attr($input['headings_color']); $input['content_color'] = esc_attr($input['content_color']); $input['links_color'] = esc_attr($input['links_color']); $input['links_hover_color'] = esc_attr($input['links_hover_color']); $input['menu_color'] = esc_attr($input['menu_color']); $input['menu_hover_color'] = esc_attr($input['menu_hover_color']); $input['sidebar_color'] = esc_attr($input['sidebar_color']); $input['sidebar_title_color'] = esc_attr($input['sidebar_title_color']); $input['sidebar_links_color'] = esc_attr($input['sidebar_links_color']); $input['footer_color'] = esc_attr($input['footer_color']); $input['footer_title_color'] = esc_attr($input['footer_title_color']); $input['footer_links_color'] = esc_attr($input['footer_links_color']); $input['copyright_color'] = esc_attr($input['copyright_color']); $input['copyright_links_color'] = esc_attr($input['copyright_links_color']); } elseif (isset($input['submit-seo']) || isset($input['reset-seo'])) { $tags = array('h1', 'h2', 'h3', 'p', 'div'); foreach ($input as $key => $tag) { if ('reset-seo' != $key && !in_array($tag, $tags)) { $input[$key] = esplanade_get_option($key); } } } if (isset($input['reset-general']) || isset($input['reset-layout']) || isset($input['reset-design']) || isset($input['reset-typography']) || isset($input['reset-seo'])) { $default_options = esplanade_default_options(); foreach ($input as $name => $value) { $input[$name] = $default_options[$name]; } } $input = wp_parse_args($input, get_option('esplanade_theme_options', esplanade_default_options())); return $input; }
/** * Custom style declarations * * Outputs CSS declarations generated by theme options * and custom user defined CSS in the document <head> * * @since Esplanade 1.0 */ function esplanade_custom_styles() { $default_options = esplanade_default_options(); $fonts = esplanade_available_fonts(); ?> <style type="text/css"> <?php if ($default_options['header_height'] != esplanade_get_option('header_height')) { ?> #site-title, #site-description { line-height:<?php echo esplanade_get_option('header_height'); ?> px; } #sidebar-header { margin-top:<?php echo absint((esplanade_get_option('header_height') - 90) / 2); ?> px; } @media screen and (max-width: 1152px) { #sidebar-header { margin-top:<?php echo absint((esplanade_get_option('header_height') - 60) / 2); ?> px; } } @media screen and (max-width: 640px) { #site-title, #site-description { line-height:1.62em; } #sidebar-header { margin-top:0; } } <?php } ?> <?php if ('sidebar-content-sidebar' != esplanade_get_option('layout') && $default_options['sidebar_size'] != esplanade_get_option('sidebar_size')) { ?> <?php if (('content-sidebar' == esplanade_get_option('layout') || 'sidebar-content' == esplanade_get_option('layout')) && $default_options['sidebar_size'] != esplanade_get_option('sidebar_size')) { ?> <?php $sidebar_width = str_replace('"', '', esplanade_get_option('sidebar_size')); ?> <?php $sidebar_width = str_replace('%', '', $sidebar_width); ?> #content { width:<?php echo 100 - 2.77 - $sidebar_width; ?> %; } #sidebar { width:<?php echo $sidebar_width; ?> %; } @media screen and (max-width: 960px) { #content, #sidebar { width:auto; } } <?php } elseif ('content-sidebar' != esplanade_get_option('layout')) { ?> #content { width:100%; } <?php } ?> <?php } elseif ('sidebar-content-sidebar' == esplanade_get_option('layout') && ($default_options['sidebar_left_size'] != esplanade_get_option('sidebar_left_size') || $default_options['sidebar_right_size'] != esplanade_get_option('sidebar_right_size'))) { ?> <?php $sidebar_left_width = str_replace('"', '', esplanade_get_option('sidebar_left_size')); ?> <?php $sidebar_left_width = str_replace('%', '', $sidebar_left_width); ?> <?php $sidebar_right_width = str_replace('"', '', esplanade_get_option('sidebar_right_size')); ?> <?php $sidebar_right_width = str_replace('%', '', $sidebar_right_width); ?> .content-sidebar-wrap { width:<?php echo 100 - 2.1 - $sidebar_right_width; ?> %; } .page-template-template-sidebar-content-sidebar-php .content-sidebar-wrap #content { width:<?php echo 100 - 2.1 - $sidebar_left_width; ?> %; } .page-template-template-sidebar-content-sidebar-php #sidebar-left { width:<?php echo $sidebar_left_width; ?> %; } .page-template-template-sidebar-content-sidebar-php #sidebar-right { width:<?php echo $sidebar_right_width; ?> %; } @media screen and (max-width: 960px) { .content-sidebar-wrap, .page-template-template-sidebar-content-sidebar-php .content-sidebar-wrap #content, .page-template-template-sidebar-content-sidebar-php #sidebar-left, .page-template-template-sidebar-content-sidebar-php #sidebar-right { float:none; width:auto; } } @media screen and (max-width: 640px) { .page-template-template-sidebar-content-sidebar-php #sidebar-left { float:left; width:49.65%; } .page-template-template-sidebar-content-sidebar-php #sidebar-right { float:right; width:43.45%; } } <?php } ?> <?php if (!esplanade_get_option('breadcrumbs') && !esplanade_get_option('esplanade_archive_location') || is_home() && !esplanade_get_option('breadcrumbs')) { ?> #content .post:first-child { padding-top:20px; border-top:none; } <?php } ?> <?php if (!esplanade_get_option('breadcrumbs')) { ?> #current-location{ margin-top:0; } <?php } ?> <?php if (is_home() && !is_paged() && 'blog' == esplanade_get_option('home_page_layout')) { ?> .home #content { width:64.09%; padding:20px; margin-bottom:1.76%; box-shadow:0 0 3px #999; background:#fff; } .home .post { padding:4.28% 0; margin:0; box-shadow:none; background:none; border-top:#eee 1px solid; } .home #content .post:first-child { padding-top:0; border-top:none; } .home #posts-nav { padding:20px 0 0; margin:0; box-shadow:none; background:none; border-top:#eee 1px solid; } <?php } ?> <?php if ('page' == get_option('show_on_front')) { ?> .blog #content { box-shadow:none; background:none; } .blog .post { padding:2.7%; margin-bottom:2.7%; box-shadow:0 0 3px #999; background:#fff; } .blog #posts-nav { padding:20px; margin-bottom:20px; box-shadow:0 0 3px #999; background:#fff; border-top:none; } .paged #content { margin-bottom:1.76%; box-shadow:0 0 3px #999; background:#fff; } .paged .post { padding:4.28% 0; margin:0 20px; box-shadow:none; background:none; border-top:#eee 1px solid; } .paged #posts-nav { padding:20px 0 0; margin:20px; margin-top:0; box-shadow:none; background:none; border-top:#eee 1px solid; } <?php } ?> <?php if ($default_options['body_font'] != esplanade_get_option('body_font')) { ?> body { font-family:<?php echo $fonts[esplanade_get_option('body_font')]; ?> ; } h1, h2, h3, h4, h5, h6, #site-title, #site-description, .entry-title, #comments-title, #reply-title, .widget-title { font-family:<?php echo $fonts[esplanade_get_option('headings_font')]; ?> ; } .entry-content { font-family:<?php echo $fonts[esplanade_get_option('content_font')]; ?> ; } <?php } else { ?> <?php if ($default_options['headings_font'] != esplanade_get_option('headings_font')) { ?> h1, h2, h3, h4, h5, h6 { font-family:<?php echo $fonts[esplanade_get_option('headings_font')]; ?> ; } <?php } ?> <?php if ($default_options['content_font'] != esplanade_get_option('content_font')) { ?> .entry-content { font-family:<?php echo $fonts[esplanade_get_option('content_font')]; ?> ; } <?php } ?> <?php } ?> <?php if ($default_options['body_font_size'] != esplanade_get_option('body_font_size')) { ?> body { font-size:<?php echo esplanade_get_option('body_font_size') . esplanade_get_option('body_font_size_unit'); ?> ; line-height:<?php echo esplanade_get_option('body_line_height') . esplanade_get_option('body_line_height_unit'); ?> ; } <?php } elseif ($default_options['body_line_height'] != esplanade_get_option('body_line_height')) { ?> body { line-height:<?php echo esplanade_get_option('body_line_height') . esplanade_get_option('body_line_height_unit'); ?> ; } <?php } ?> <?php if ($default_options['h1_font_size'] != esplanade_get_option('h1_font_size')) { ?> h1, .single .entry-title, .page .entry-title, .error404 .entry-title { font-size:<?php echo esplanade_get_option('h1_font_size') . esplanade_get_option('h1_font_size_unit'); ?> ; line-height:<?php echo esplanade_get_option('headings_line_height') . esplanade_get_option('headings_line_height_unit'); ?> ; } <?php } ?> <?php if ($default_options['h2_font_size'] != esplanade_get_option('h2_font_size')) { ?> h2, .entry-title { font-size:<?php echo esplanade_get_option('h2_font_size') . esplanade_get_option('h2_font_size_unit'); ?> ; line-height:<?php echo esplanade_get_option('headings_line_height') . esplanade_get_option('headings_line_height_unit'); ?> ; } <?php } ?> <?php if ($default_options['h3_font_size'] != esplanade_get_option('h3_font_size')) { ?> h3, .teaser .entry-title { font-size:<?php echo esplanade_get_option('h3_font_size') . esplanade_get_option('h3_font_size_unit'); ?> ; line-height:<?php echo esplanade_get_option('headings_line_height') . esplanade_get_option('headings_line_height_unit'); ?> ; } <?php } ?> <?php if ($default_options['h4_font_size'] != esplanade_get_option('h4_font_size')) { ?> h4 { font-size:<?php echo esplanade_get_option('h4_font_size') . esplanade_get_option('h4_font_size_unit'); ?> ; line-height:<?php echo esplanade_get_option('headings_line_height') . esplanade_get_option('headings_line_height_unit'); ?> ; } <?php } ?> <?php if ($default_options['headings_line_height'] != esplanade_get_option('headings_line_height')) { ?> h1, h2, h3, h4, h5, h6 { line-height:<?php echo esplanade_get_option('headings_line_height') . esplanade_get_option('headings_line_height_unit'); ?> ; } <?php } ?> <?php if ($default_options['content_font_size'] != esplanade_get_option('content_font_size')) { ?> .entry-content { font-size:<?php echo esplanade_get_option('content_font_size') . esplanade_get_option('content_font_size_unit'); ?> ; line-height:<?php echo esplanade_get_option('content_line_height') . esplanade_get_option('content_line_height_unit'); ?> ; } @media screen and (max-width: 640px) { .entry-content { font-size:<?php echo esplanade_get_option('mobile_font_size') . esplanade_get_option('content_font_size_unit'); ?> ; line-height:<?php echo esplanade_get_option('mobile_line_height') . esplanade_get_option('content_line_height_unit'); ?> ; } } <?php } elseif ($default_options['content_line_height'] != esplanade_get_option('content_line_height')) { ?> .entry-content { line-height:<?php echo esplanade_get_option('content_line_height') . esplanade_get_option('content_line_height'); ?> ; } @media screen and (max-width: 640px) { .entry-content { font-size:<?php echo esplanade_get_option('mobile_font_size') . esplanade_get_option('mobile_font_size_unit'); ?> ; line-height:<?php echo esplanade_get_option('mobile_line_height') . esplanade_get_option('mobile_line_height_unit'); ?> ; } } <?php } elseif ($default_options['mobile_font_size'] != esplanade_get_option('mobile_font_size')) { ?> @media screen and (max-width: 640px) { .entry-content { font-size:<?php echo esplanade_get_option('mobile_font_size') . esplanade_get_option('mobile_font_size_unit'); ?> ; line-height:<?php echo esplanade_get_option('mobile_line_height') . esplanade_get_option('mobile_line_height_unit'); ?> ; } } <?php } elseif ($default_options['mobile_line_height'] != esplanade_get_option('mobile_line_height')) { ?> @media screen and (max-width: 640px) { .entry-content { line-height:<?php echo esplanade_get_option('mobile_line_height') . esplanade_get_option('mobile_line_height_unit'); ?> ; } } <?php } ?> <?php if ($default_options['body_color'] != esplanade_get_option('body_color')) { ?> body { color:<?php echo esplanade_get_option('body_color'); ?> ; } h1, h2, h3, h4, h5, h6, .entry-title, .entry-title a { color:<?php echo esplanade_get_option('headings_color'); ?> ; } .entry-content { color:<?php echo esplanade_get_option('content_color'); ?> ; } <?php } else { ?> <?php if ($default_options['headings_color'] != esplanade_get_option('headings_color')) { ?> h1, h2, h3, h4, h5, h6, .entry-title, .entry-title a { color:<?php echo esplanade_get_option('headings_color'); ?> ; } <?php } ?> <?php if ($default_options['content_color'] != esplanade_get_option('content_color')) { ?> .entry-content { color:<?php echo esplanade_get_option('content_color'); ?> ; } <?php } ?> <?php } ?> <?php if ($default_options['links_color'] != esplanade_get_option('links_color')) { ?> a { color:<?php echo esplanade_get_option('links_color'); ?> ; } <?php } ?> <?php if ($default_options['links_hover_color'] != esplanade_get_option('links_hover_color')) { ?> a:hover { color:<?php echo esplanade_get_option('links_hover_color'); ?> ; } <?php } ?> <?php if ($default_options['menu_color'] != esplanade_get_option('menu_color')) { ?> #access a { color:<?php echo esplanade_get_option('menu_color'); ?> ; } <?php } ?> <?php if ($default_options['menu_hover_color'] != esplanade_get_option('menu_hover_color')) { ?> #access a:hover, #access li.current_page_item > a { color:<?php echo esplanade_get_option('menu_hover_color'); ?> ; } <?php } ?> <?php if ($default_options['sidebar_color'] != esplanade_get_option('sidebar_color')) { ?> #sidebar, #sidebar-left, #sidebar-right { color:<?php echo esplanade_get_option('sidebar_color'); ?> ; } <?php } ?> <?php if ($default_options['sidebar_title_color'] != esplanade_get_option('sidebar_title_color')) { ?> .widget-title { color:<?php echo esplanade_get_option('sidebar_title_color'); ?> ; } <?php } ?> <?php if ($default_options['sidebar_links_color'] != esplanade_get_option('sidebar_links_color')) { ?> .widget-area a { color:<?php echo esplanade_get_option('sidebar_links_color'); ?> ; } <?php } ?> <?php if ($default_options['footer_color'] != esplanade_get_option('footer_color')) { ?> #footer-area { color:<?php echo esplanade_get_option('footer_color'); ?> ; } <?php } ?> <?php if ($default_options['footer_title_color'] != esplanade_get_option('footer_title_color')) { ?> #footer-area .widget-title { color:<?php echo esplanade_get_option('footer_title_color'); ?> ; } <?php } ?> <?php if ($default_options['copyright_color'] != esplanade_get_option('copyright_color')) { ?> #copyright { color:<?php echo esplanade_get_option('copyright_color'); ?> ; } <?php } ?> <?php if ($default_options['copyright_links_color'] != esplanade_get_option('copyright_links_color')) { ?> #copyright a { color:<?php echo esplanade_get_option('copyright_links_color'); ?> ; } <?php } ?> <?php echo esplanade_get_option('user_css'); ?> </style> <?php }