template = $template; if ( is_front_page() ) $this->currentpage = 'frontpage'; elseif ( is_404() ) $this->currentpage = '_404'; elseif ( is_page() || is_single() || is_singular() ) $this->currentpage = 'singular'; elseif ( is_author() ) $this->currentpage = 'author'; elseif ( is_date() ) $this->currentpage = 'date'; elseif ( is_tag() ) $this->currentpage = 'tag'; elseif ( is_category() ) $this->currentpage = 'category'; elseif ( is_search() ) $this->currentpage = 'search'; elseif ( is_home() ) $this->currentpage = 'home'; elseif ( is_archive() ) $this->currentpage = 'archive'; else $this->currentpage = 'fallback'; $this->HeroContent = new BenjaminHeroContent( null, $this->template, $this->currentpage, $pf_include ); $this->HeroBackground = new BenjaminHeroBG( null, $this->template, $this->currentpage ); $this->HeroBackground->getBackground(); } public function __toString() { return $this->output(); } // the output public function output() { $output = ''; $size = $this->heroSize( $this->template ); $style = $this->HeroBackground->getStyle( $this->template ); $post_format = $this->isPostFormat(); $class = $size; $class .= $this->HeroBackground->image ? ' hero--has-background' : ''; $class .= $post_format ? ' hero--is-post-format' : ''; $output .= '
'; $output .= '
'; $output .= $this->HeroContent->getContent(); $output .= '
'; $output .= '
'; return $output; } function isPostFormat() { global $post; if ($this->currentpage !== 'singular') return false; $format = get_post_format(); if ( $format == 'video' && $this->HeroContent->getVideo() ) return 'video'; elseif ( $format == 'gallery' && $this->HeroContent->getGallery() ) return 'gallery'; elseif ( $format == 'image' && $this->HeroContent->getImage() ) return 'image'; elseif ($format == 'audio' && $this->HeroContent->getAudio() ) { add_action('wp_footer', 'benjamin_enqueue_visualizer_script' ); return 'audio'; }elseif ( $format == 'quote' && $this->HeroContent->getQuote() ) return 'quote'; else return false; return false; } /** * The hero has different sizes depending on which template is displayed * @param [type] $template [description] * @return [type] [description] */ function heroSize($template = null) { $setting = get_theme_mod($template . '_hero_size_setting', 'slim'); $size ='usa-hero--'.$setting; return $size; } }