function theme_background_styles() { global $post; $post_id = wpv_get_the_ID(); if (is_null($post_id)) { return; } $bgcolor = wpv_sanitize_accent(wpv_post_meta($post_id, 'background-color', true)); $bgimage = wpv_post_meta($post_id, 'background-image', true); $bgrepeat = wpv_post_meta($post_id, 'background-repeat', true); $bgsize = wpv_post_meta($post_id, 'background-size', true); $bgattachment = wpv_post_meta($post_id, 'background-attachment', true); $bgposition = wpv_post_meta($post_id, 'background-position', true); $page_style = ''; if (!empty($bgcolor)) { $page_style .= "background-color:{$bgcolor};"; } if (!empty($bgimage)) { $page_style .= "background-image:url('{$bgimage}');"; if (!empty($bgrepeat)) { $page_style .= "background-repeat:{$bgrepeat};"; } if (!empty($bgattachment)) { $page_style .= "background-attachment:{$bgattachment};"; } if (!empty($bgsize)) { $page_style .= "background-size:{$bgsize};"; } } if (!empty($page_style) && (is_single() || is_page())) { echo "<style>html{ {$page_style} }</style>"; } }
/** * Wrapper around get_post_meta which takes special pages into account * * @uses get_post_meta() * * @param int $post_id Post ID. * @param string $key Optional. The meta key to retrieve. By default, returns data for all keys. * @param bool $single Whether to return a single value. * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. */ function wpv_post_meta($post_id, $meta = '', $single = false) { $real_id = wpv_get_the_ID(); if ($real_id && $post_id != $real_id) { $post_id = $real_id; } return get_post_meta($post_id, $meta, $single); }
<?php /** * Slider or custom content between the menu and the page title * * @package wpv * @subpackage church-event */ global $wp_embed; $post_id = wpv_get_the_ID(); $content = WpvTemplates::has_header_slider() ? '' : do_shortcode($wp_embed->run_shortcode(wpv_post_meta($post_id, 'page-middle-header-content', true))); $fullwidth = wpv_post_meta($post_id, 'page-middle-header-content-fullwidth', true) === 'true'; $min_height = wpv_post_meta($post_id, 'page-middle-header-min-height', true); if (!WpvTemplates::has_header_slider() && empty($content) && empty($min_height) && !WpvFancyPortfolio::has('disabled')) { return; } if (is_page_template('page-blank.php')) { return; } $style = WpvTemplates::get_title_style(); if (!WpvTemplates::has_header_slider()) { $style .= "min-height:{$min_height}px"; } $type = WpvTemplates::has_header_slider() ? 'type-slider' : 'type-featured'; ?> <header class="header-middle row <?php echo $fullwidth ? 'fullwidth' : 'normal'; ?> <?php echo $type; ?>
/** * Checks whether the current page has a header slider * @return boolean true if there is a header slider */ public static function has_header_slider() { $post_id = wpv_get_the_ID(); return !is_null($post_id) && apply_filters('wpv_has_header_slider', !is_404() && wpv_post_meta($post_id, 'slider-category', true) !== '' && !is_page_template('page-blank.php')); }