Created
January 29, 2018 04:41
-
-
Save anonymous/44bf9b2f40058dc0211e2b620107c969 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function yummy_pro_menu_page_second_section() { | |
$options = yummy_pro_get_theme_options(); | |
$header_background = ! empty( $options['menu_second_section_image'] ) ? $options['menu_second_section_image'] : get_template_directory_uri() . '/assets/uploads/breakfast.jpg'; | |
$header_title = ! empty( $options['menu_second_section_title'] ) ? $options['menu_second_section_title'] : ''; | |
$content_type = $options['menu_second_section_content_type']; | |
$args = array(); | |
$cat_id = ''; | |
switch ( $content_type ) { | |
case 'category': | |
$cat_id = ! empty( $options['menu_second_section_content_category'] ) ?$options['menu_second_section_content_category'] : ''; | |
if ( ! empty( $cat_id ) ) : | |
$args = array( | |
'post_type' => 'post', | |
'cat' => $cat_id, | |
'posts_per_page' => 10, | |
); | |
endif; | |
break; | |
case 'woo-category': | |
$cat_id = ! empty( $options['menu_second_section_content_woo_category'] ) ?$options['menu_second_section_content_woo_category'] : ''; | |
if ( ! empty( $cat_id ) ) : | |
$args = array( | |
'post_type' => 'product', | |
'posts_per_page' => 10, | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'product_cat', | |
'field' => 'id', | |
'terms' => $cat_id, | |
) ), | |
); | |
endif; | |
break; | |
} | |
if ( empty( $args ) ) { | |
return; | |
} | |
$posts = get_posts( $args ); | |
?> | |
<section id="breakfast-cover" class="parallax" style="background-image:url('<?php echo esc_url( $header_background ); ?>');" data-stellar-background-ratio="0.5" data-stellar-vertical-offset="0"> | |
<div class="black-overlay"></div> | |
<div class="wrapper"> | |
<?php if ( ! empty( $header_title ) ) : ?> | |
<header class="entry-header"> | |
<h2 class="entry-title color-white"><?php echo esc_html( $header_title ); ?></h2> | |
</header> | |
<?php endif; ?> | |
</div><!--.wrapper--> | |
</section><!-- #breakfast-cover --> | |
<section id="breakfast" class="col-2 food-item"> | |
<div class="wrapper"> | |
<div class="breakfast-item add-shadow"> | |
<div class="row no-margin"> | |
<?php | |
$i = 1; | |
foreach ( $posts as $post ) : ?> | |
<div class="column-wrapper"> | |
<div class="recipe-list"> | |
<h4 class="color-black"><a href="<?php the_permalink( $post->ID ); ?>"><?php echo esc_html( $post->post_title ); ?></a></h4> | |
<p><?php echo esc_html( yummy_pro_trim_content( 8, $post ) ); ?></p> | |
<?php if ( 'woo-category' == $content_type ) : ?> | |
<span><?php esc_html_e( 'Price', 'yummy-pro' ); ?> <span class="price"> | |
<?php | |
$product = new WC_Product( $post->ID ); | |
echo $product->get_price_html(); | |
?> | |
</span></span> | |
<?php endif; | |
$tag = ( $content_type == 'woo-category' ) ? 'product_tag' : 'post_tag'; | |
$tags = get_the_terms( $post->ID, $tag ); | |
if ( ! empty( $tags ) ) : | |
foreach ( $tags as $tag ) : ?> | |
<a href="<?php echo esc_url( get_term_link( $tag->term_id ) ); ?>" class="more-link small-btn"><?php echo esc_html( $tag->name ); ?></a> | |
<?php endforeach; | |
endif; | |
?> | |
</div><!--.recipe-list--> | |
<div class="featured-image"> | |
<?php | |
if ( has_post_thumbnail( $post->ID ) ) { | |
$image_url = get_the_post_thumbnail_url( $post->ID, 'post-thumbnail' ); | |
} else { | |
$image_url = get_template_directory_uri() . '/assets/uploads/no-featured-image-300x300.jpg'; | |
} | |
?> | |
<a href="<?php the_permalink( $post->ID ); ?>"><img src="<?php echo esc_url( $image_url ); ?>"></a> | |
</div><!--.featured-image--> | |
</div><!--.column-wrapper--> | |
<?php if ( $i % 2 == 0 ) : ?> | |
</div> | |
<div class="row no-margin"> | |
<?php endif; | |
$i++; | |
endforeach; ?> | |
</div><!--.row--> | |
</div><!--.breakfast-item--> | |
</div><!-- .wrapper --> | |
<div class="page-decoration"> | |
<img src="<?php echo get_template_directory_uri(); ?>/assets/uploads/menu-dish-03.jpg" alt="<?php esc_attr_e( 'Decoration', 'yummy-pro' ); ?>"> | |
<img src="<?php echo get_template_directory_uri(); ?>/assets/uploads/menu-dish-04.jpg" alt="<?php esc_attr_e( 'Decoration', 'yummy-pro' ); ?>"> | |
</div><!-- .page-decoration --> | |
</section><!-- #breakfast --> | |
<?php } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment