function cb_featured_image($post, $cb_style) { $cb_mobile = new Mobile_Detect(); $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on'); $cb_custom_fields = get_post_custom(); $cb_post_format = get_post_format(); $cb_post_id = $post->ID; $cb_phone = $cb_mobile->isMobile(); $cb_tablet = $cb_mobile->isTablet(); if ($cb_tablet == true || $cb_phone == true) { $cb_is_mobile = true; } else { $cb_is_mobile = false; } if ($cb_meta_onoff == 'on_posts') { $cb_meta_onoff = 'on'; } if (isset($cb_custom_fields['cb_review_checkbox'][0]) && $cb_custom_fields['cb_review_checkbox'][0] == '1') { $cb_review_checkbox = 'on'; } else { $cb_review_checkbox = 'off'; } if (isset($cb_custom_fields['cb_featured_image_style'][0])) { $cb_featured_image_style = $cb_custom_fields['cb_featured_image_style'][0]; } else { $cb_featured_image_style = 'full-width'; } if (isset($cb_custom_fields['cb_image_credit'][0])) { $cb_image_credit = $cb_custom_fields['cb_image_credit'][0]; } else { $cb_image_credit = NULL; } $cb_video_url = get_post_meta($cb_post_id, 'cb_video_embed_code_post', true); $cb_audio_url = get_post_meta($cb_post_id, 'cb_soundcloud_embed_code_post', true); if (strpos($cb_video_url, 'yout') !== false) { preg_match('([-\\w]{11})', $cb_video_url, $cb_youtube_id); $cb_video_url = '<div id="cbplayer">' . $cb_youtube_id[0] . '</div>'; } if ($cb_review_checkbox == 'on') { $cb_item_type = 'itemprop="itemReviewed"'; } else { $cb_item_type = 'itemprop="headline"'; } $cb_featured_image = $cb_header = $cb_featured_image_url = $cb_image = NULL; if ($cb_style == 'standard' || $cb_style == 'full-width') { $cb_media_bg = '<span id="cb-media-bg"></span>'; } else { $cb_media_bg = NULL; } if ($cb_style != 'off') { if ($cb_post_format == 'video') { $cb_video_type = get_post_meta($cb_post_id, 'cb_video_post_select', true); if ($cb_video_type == '2') { $cb_post_format_icon = '<div class="cb-media-icon cb-lb"><i class="fa fa-play"></i></div>'; $cb_post_format_icon .= '<div id="cb-media-overlay-lb" class="cb-video-lb"><div id="cb-media-frame-lb"><div class="cb-close-m cb-ta-right"><i class="fa cb-times"></i></div>' . do_shortcode($cb_video_url) . '</div></div>'; } else { $cb_post_format_icon = '<div class="cb-media-icon"><i class="fa fa-play"></i></div>'; $cb_post_format_icon .= '<div id="cb-media-overlay">' . $cb_media_bg . '<div id="cb-media-frame">' . do_shortcode($cb_video_url) . '</div></div>'; } } elseif ($cb_post_format == 'audio') { $cb_post_format_icon = '<div class="cb-media-icon"><i class="fa fa-headphones"></i></div>'; $cb_post_format_icon .= '<div id="cb-media-overlay">' . $cb_media_bg . '<div id="cb-media-frame">' . do_shortcode($cb_audio_url) . '</div></div>'; } else { $cb_post_format_icon = NULL; } } else { $cb_post_format_icon = $cb_image_credit = NULL; } if ($cb_image_credit != NULL) { $cb_image_credit = '<div class="cb-image-credit"><i class="fa fa-camera"></i>' . $cb_image_credit . '</div>'; } if ($cb_style == 'parallax' && $cb_is_mobile == true) { $cb_header .= '<div class="cb-entry-header cb-style-full-background">'; } else { $cb_header .= '<div class="cb-entry-header cb-style-' . $cb_style . '">'; } if ($cb_style != 'standard') { $cb_header .= $cb_image_credit; } $cb_header .= '<span class="cb-title-fi"><h1 class="entry-title cb-entry-title cb-single-title" ' . $cb_item_type . '>' . get_the_title() . '</h1>'; if ($cb_meta_onoff == 'on') { $cb_header .= cb_byline(true, $cb_post_id, false, true); } $cb_header .= '</span>'; if ($cb_style != 'standard') { $cb_header .= $cb_post_format_icon; } $cb_header .= '</div>'; if ($cb_style == 'off') { $cb_featured_image .= $cb_header; } elseif ($cb_style == 'standard') { if (has_post_thumbnail()) { $cb_image = '<div class="cb-mask">' . get_the_post_thumbnail($post->ID, 'cb-750-400', array('class' => 'cb-fi-standard')) . $cb_image_credit . $cb_post_format_icon . '</div>'; } $cb_featured_image .= '<header id="cb-standard-featured">'; $cb_featured_image .= $cb_image; $cb_featured_image .= $cb_header; $cb_featured_image .= '</header>'; } elseif ($cb_style == 'page') { if (has_post_thumbnail()) { $cb_page_featured_style = get_post_meta($cb_post_id, 'cb_page_featured_style', true); if ($cb_page_featured_style == '1' || $cb_page_featured_style == NULL) { $cb_featured_image .= '<header id="cb-standard-featured"><div class="cb-mask">' . get_the_post_thumbnail($post->ID, 'cb-750-400') . '</div></header>'; } elseif ($cb_page_featured_style == '2') { $cb_page_featured_image_id = get_post_thumbnail_id($cb_post_id); $cb_page_featured_image_url = wp_get_attachment_image_src($cb_page_featured_image_id, 'cb-1200-520'); $cb_featured_image .= '<header id="cb-full-width-featured" class="wrap clearfix">'; if ($cb_page_featured_image_url != NULL) { $cb_featured_image .= '<script type="text/javascript">jQuery(document).ready(function($){ $("#cb-full-width-featured").backstretch("' . $cb_page_featured_image_url[0] . '", {speed: 350}); }); </script>'; } $cb_featured_image .= '</header>'; } elseif ($cb_page_featured_style == '4') { $cb_featured_image .= '<header id="cb-parallax-featured" class="wrap clearfix">'; if (has_post_thumbnail()) { $cb_featured_image_id = get_post_thumbnail_id($post->ID); $cb_featured_image_url = wp_get_attachment_image_src($cb_featured_image_id, 'cb-thumb-1400'); } else { $cb_featured_image_url = array(); $cb_featured_image_url[] = cb_file_location('/library/images/thumbnail-1400x700.png'); } $cb_featured_image .= '<div class="cb-image" data-type="background" style="background-image: url(' . $cb_featured_image_url[0] . ')"></div><div id="cb-parallax-bg"></div>'; $cb_featured_image .= '</header>'; } elseif ($cb_page_featured_style == '5') { $cb_featured_image .= '<header id="cb-full-background-featured" class="clearfix">'; $cb_bg_slideshow = get_post_meta($cb_post_id, "cb_bg_image_post"); if ($cb_bg_slideshow != NULL) { $cb_featured_image .= '<script type="text/javascript">jQuery(document).ready(function($) { $.backstretch(["'; $i = 0; foreach ($cb_bg_slideshow as $cb_slide) { if ($i != 0) { $cb_featured_image .= '", "'; } $cb_featured_image_url = wp_get_attachment_image_src($cb_slide, 'cb-thumb-1400'); $cb_featured_image .= $cb_featured_image_url[0]; $i++; } $cb_featured_image .= '"], {fade: 750, duration: 5000} ); $(".backstretch").css("position", "absolute" ); }); </script>'; } else { if (has_post_thumbnail()) { $cb_featured_image_id = get_post_thumbnail_id($post->ID); $cb_featured_image_url = wp_get_attachment_image_src($cb_featured_image_id, 'cb-thumb-1400'); } else { $cb_featured_image_url = array(); $cb_featured_image_url[] = cb_file_location('/library/images/thumbnail-1400x700.png'); } if ($cb_featured_image_url != NULL) { $cb_featured_image .= '<script type="text/javascript">jQuery(document).ready(function($){ $.backstretch("' . $cb_featured_image_url[0] . '", {speed: 350}); $(".backstretch").css("position", "absolute" ); }); </script>'; } } $cb_featured_image .= '</header>'; } } } elseif ($cb_style == 'full-width') { if (has_post_thumbnail()) { $cb_featured_image_id = get_post_thumbnail_id($post->ID); $cb_featured_image_url = wp_get_attachment_image_src($cb_featured_image_id, 'cb-1200-520'); } else { $cb_featured_image_url = array(); $cb_featured_image_url[] = cb_file_location('/library/images/thumbnail-1200x520.png'); } $cb_featured_image .= '<header id="cb-full-width-featured" class="wrap clearfix">'; if ($cb_featured_image_url != NULL) { $cb_featured_image .= '<script type="text/javascript">jQuery(document).ready(function($){ $("#cb-full-width-featured").backstretch("' . $cb_featured_image_url[0] . '", {speed: 350}); }); </script>'; } $cb_featured_image .= $cb_header; $cb_featured_image .= '</header>'; } elseif ($cb_style == 'full-background') { $cb_featured_image .= '<header id="cb-full-background-featured" class="clearfix">'; $cb_bg_slideshow = get_post_meta($cb_post_id, "cb_bg_image_post"); $cb_featured_image .= '<div class="cb-mask clearfix wrap">' . $cb_header . '</div>'; if ($cb_bg_slideshow != NULL) { $cb_featured_image .= '<script type="text/javascript">jQuery(document).ready(function($) { $.backstretch(["'; $i = 0; foreach ($cb_bg_slideshow as $cb_slide) { if ($i != 0) { $cb_featured_image .= '", "'; } $cb_featured_image_url = wp_get_attachment_image_src($cb_slide, 'cb-thumb-1400'); $cb_featured_image .= $cb_featured_image_url[0]; $i++; } $cb_featured_image .= '"], {fade: 750, duration: 5000} ); $(".backstretch").css("position", "absolute" ); }); </script>'; } else { if (has_post_thumbnail($cb_post_id) && get_the_post_thumbnail($cb_post_id)) { $cb_featured_image_id = get_post_thumbnail_id($cb_post_id); $cb_featured_image_url = wp_get_attachment_image_src($cb_featured_image_id, 'cb-thumb-1400'); } else { $cb_featured_image_url = array(); $cb_featured_image_url[] = cb_file_location('/library/images/thumbnail-1400x700.png'); } if ($cb_featured_image_url != NULL) { $cb_featured_image .= '<script type="text/javascript">jQuery(document).ready(function($){ $.backstretch("' . $cb_featured_image_url[0] . '", {speed: 350}); $(".backstretch").css("position", "absolute" ); }); </script>'; } } $cb_featured_image .= '</header>'; } elseif ($cb_style == 'parallax' && $cb_is_mobile == false) { $cb_featured_image .= '<header id="cb-parallax-featured" class="wrap clearfix">'; if (has_post_thumbnail($cb_post_id) && get_the_post_thumbnail($cb_post_id)) { $cb_featured_image_id = get_post_thumbnail_id($post->ID); $cb_featured_image_url = wp_get_attachment_image_src($cb_featured_image_id, 'cb-thumb-1400'); } else { $cb_featured_image_url = array(); $cb_featured_image_url[] = cb_file_location('/library/images/thumbnail-1400x700.png'); } $cb_featured_image .= $cb_header; $cb_featured_image .= '<div class="cb-image" data-type="background" style="background-image: url(' . $cb_featured_image_url[0] . ')"></div><div id="cb-parallax-bg"></div>'; $cb_featured_image .= '</header>'; } elseif ($cb_style == 'parallax' && $cb_is_mobile == true) { $cb_featured_image .= '<header id="cb-full-background-featured" class="clearfix">'; $cb_bg_slideshow = get_post_meta($cb_post_id, 'cb_bg_image_post'); $cb_featured_image .= '<div class="cb-mask clearfix wrap">' . $cb_header . '</div>'; if ($cb_bg_slideshow != NULL && count($cb_bg_slideshow) > 1) { $cb_featured_image .= '<script type="text/javascript">jQuery(document).ready(function($) { $.backstretch(["'; $i = 0; foreach ($cb_bg_slideshow as $cb_slide) { if ($i != 0) { $cb_featured_image .= '", "'; } $cb_featured_image_url = wp_get_attachment_image_src($cb_slide, 'cb-thumb-1400'); $cb_featured_image .= $cb_featured_image_url[0]; $i++; } $cb_featured_image .= '"], {fade: 750, duration: 5000} ); $(".backstretch").css("position", "absolute" ); }); </script>'; } else { if (has_post_thumbnail()) { $cb_featured_image_id = get_post_thumbnail_id($post->ID); $cb_featured_image_url = wp_get_attachment_image_src($cb_featured_image_id, 'cb-thumb-1400'); } else { $cb_featured_image_url = array(); $cb_featured_image_url[] = cb_file_location('/library/images/thumbnail-1400x700.png'); } if ($cb_featured_image_url != NULL) { $cb_featured_image .= '<script type="text/javascript">jQuery(document).ready(function($){ $.backstretch("' . $cb_featured_image_url[0] . '", {speed: 350}); $(".backstretch").backstretch("destroy", false); }); </script>'; } } $cb_featured_image .= '</header>'; } return $cb_featured_image; }
function cb_widgets() { require_once cb_file_location('library/widgets/cb-recent-posts-slider-widget.php'); require_once cb_file_location('library/widgets/cb-widget-social-media.php'); require_once cb_file_location('library/widgets/cb-single-image-widget.php'); require_once cb_file_location('library/widgets/cb-facebook-like-widget.php'); require_once cb_file_location('library/widgets/cb-google-follow-widget.php'); }
function cb_get_thumbnail_url($width, $height, $cb_post_id = NULL) { $cb_output = NULL; if (has_post_thumbnail($cb_post_id)) { if ($width == 'full') { $cb_dimensions = 'full'; } else { $cb_dimensions = 'cb-' . $width . '-' . $height; } $cb_output = wp_get_attachment_image_src(get_post_thumbnail_id($cb_post_id), $cb_dimensions); } else { if ($width == 'full') { $width = 1400; $height = 600; } $cb_custom_placeholder = ot_get_option('cb_placeholder_img', NULL); if ($cb_custom_placeholder == NULL) { $cb_thumbnail = cb_file_location('library/images/placeholders/placeholder-' . $width . 'x' . $height . '.png'); $cb_retina_thumbnail = cb_file_location('library/images/placeholders/placeholder-' . $width . 'x' . $height . '@2x.png'); $cb_output = array('0' => esc_url($cb_thumbnail), 'featured_image_url' => esc_url($cb_thumbnail), 'featured_image_url_retina' => esc_url($cb_retina_thumbnail)); } else { $cb_thumbnail = wp_get_attachment_image_src($cb_custom_placeholder, array($width, $height)); $cb_output = array('0' => esc_url($cb_thumbnail[0]), 'featured_image_url' => esc_url($cb_thumbnail[0]), 'featured_image_url_retina' => esc_url($cb_thumbnail[0])); } $cb_thumbnail = cb_file_location('library/images/placeholders/placeholder-' . $width . 'x' . $height . '.png'); $cb_retina_thumbnail = cb_file_location('library/images/placeholders/placeholder-' . $width . 'x' . $height . '@2x.png'); } return $cb_output; }