示例#1
0
 function thb_featuredimagebackground()
 {
     $image_size = 'large';
     if (function_exists('is_woocommerce') && is_shop()) {
         $image = thb_get_option('woocommerce_shop_pageheader_background_image');
         thb_get_template_part('partial-featuredimage-background', array('featured_image' => thb_image_get_size($image['id'], $image_size), 'bg_opacity' => thb_get_option('woocommerce_shop_pageheader_background_opacity')));
     } elseif (function_exists('is_woocommerce') && is_product_category()) {
         global $wp_query;
         $cat = $wp_query->get_queried_object();
         $thumbnail_id = get_woocommerce_term_meta($cat->term_id, 'thumbnail_id', true);
         thb_get_template_part('partial-featuredimage-background', array('featured_image' => thb_image_get_size($thumbnail_id, $image_size), 'bg_opacity' => thb_get_option('woocommerce_shop_pageheader_background_opacity')));
     } else {
         $page_id = thb_get_page_ID();
         $is_dynamic_home = $page_id == 0 && is_front_page() && get_option('show_on_front') == 'posts';
         $image = '';
         $templates = array('default', 'single.php', 'single-product.php', 'single-works.php', 'template-archives.php', 'template-blog-classic.php', 'template-blog-stream.php', 'template-portfolio.php', 'template-contact.php', 'template-photogallery.php');
         if ($page_id !== 0 && !is_singular('works') && !is_attachment()) {
             $image = thb_get_featured_image($page_id, $image_size);
         }
         if (thb_check_page_template($page_id, $templates) || thb_is_archive() || is_attachment()) {
             thb_get_template_part('partial-featuredimage-background', array('featured_image' => $image, 'bg_opacity' => thb_get_post_meta(thb_get_page_ID(), 'background_opacity')));
         }
     }
 }
 /**
  * Enqueue the theme styles.
  *
  * @return void
  */
 public function enqueueStyles()
 {
     global $wp_version;
     if (!empty($this->_styles['compressed'])) {
         $deps = array();
         foreach ($this->_styles['compressed'] as $style) {
             foreach ($style['deps'] as $dep) {
                 if (!in_array($dep, $deps) && !$this->isCompressedStyle($dep)) {
                     $deps[] = $dep;
                 }
             }
         }
         $src = thb_custom_resource('frontend/compressStyles');
         wp_enqueue_style('thb_compressed_styles', $src, $deps, $wp_version);
     }
     $i = 0;
     foreach ($this->_styles['not_compressed'] as $style) {
         if (is_array($style)) {
             extract($style);
             $page_id = thb_get_page_ID();
             if (empty($name)) {
                 $name = 'thb_uncompressed_' . $i;
             }
             if (!empty($templates)) {
                 foreach ($templates as $template) {
                     if (thb_check_page_template($page_id, $template)) {
                         wp_enqueue_style($name, $path, $deps, $wp_version, $media);
                         break;
                     }
                 }
             } else {
                 wp_enqueue_style($name, $path, $deps, $wp_version, $media);
             }
         }
         $i++;
     }
 }