Skip to content

Commit

Permalink
Move hero functions from inc/post-tags.php into inc/featured-media.php
Browse files Browse the repository at this point in the history
  • Loading branch information
benlk committed Jul 8, 2016
1 parent c98d8ac commit 792a9ad
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 43 deletions.
41 changes: 41 additions & 0 deletions inc/featured-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,3 +638,44 @@ function largo_featured_media_post_classes($classes) {
return $classes;
}
add_filter('post_class', 'largo_featured_media_post_classes');

/**
* Determines what type of hero image/video a single post should use
* and returns a class that gets added to its container div
*
* @since 0.4
*/
if ( ! function_exists( 'largo_hero_class' ) ) {
function largo_hero_class( $post_id, $echo = TRUE ) {
$hero_class = "is-empty";
$featured_media = (largo_has_featured_media($post_id))? largo_get_featured_media($post_id) : array();
$type = (isset($featured_media['type']))? $featured_media['type'] : false;

if (get_post_meta($post_id, 'youtube_url', true) || $type == 'video')
$hero_class = 'is-video';
else if ($type == 'gallery')
$hero_class = 'is-gallery';
else if ($type == 'embed-code')
$hero_class = 'is-embed';
else if (has_post_thumbnail($post_id) || $type == 'image')
$hero_class = 'is-image';

if ($echo)
echo $hero_class;
else
return $hero_class;
}
}

/**
* Returns the featured image for a post; deprecated in 0.5.1
* to be used as the hero image with caption and credit (if available)
*
* @since 0.4
* @deprecated 0.5.1
*/
if ( ! function_exists( 'largo_hero_with_caption' ) ) {
function largo_hero_with_caption( $post_id ) {
largo_featured_image_hero($post_id);
}
}
43 changes: 0 additions & 43 deletions inc/post-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -848,49 +848,6 @@ function post_type_icon( $options = array() ) {
}
}

/**
* Determines what type of hero image/video a single post should use
* and returns a class that gets added to its container div
*
* @since 0.4
*/
if ( ! function_exists( 'largo_hero_class' ) ) {
function largo_hero_class( $post_id, $echo = TRUE ) {
$hero_class = "is-empty";
$featured_media = (largo_has_featured_media($post_id))? largo_get_featured_media($post_id) : array();
$type = (isset($featured_media['type']))? $featured_media['type'] : false;

if (get_post_meta($post_id, 'youtube_url', true) || $type == 'video')
$hero_class = 'is-video';
else if ($type == 'gallery')
$hero_class = 'is-gallery';
else if ($type == 'embed-code')
$hero_class = 'is-embed';
else if (has_post_thumbnail($post_id) || $type == 'image')
$hero_class = 'is-image';

if ($echo)
echo $hero_class;
else
return $hero_class;
}
}

/**
* Depricated 0.5.1.
*
* Returns the featured image for a post
* to be used as the hero image with caption and credit (if available)
*
* @since 0.4
*/
if ( ! function_exists( 'largo_hero_with_caption' ) ) {
function largo_hero_with_caption( $post_id ) {

largo_featured_image_hero($post_id);

}
}

/**
* Schema.org article metadata we include in the header of each single post
Expand Down

0 comments on commit 792a9ad

Please sign in to comment.