Skip to content

Instantly share code, notes, and snippets.

Created May 4, 2017 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2e9d87df11fee5508477337c1004c70f to your computer and use it in GitHub Desktop.
Save anonymous/2e9d87df11fee5508477337c1004c70f to your computer and use it in GitHub Desktop.
function education_hub_render_featured_content( $content_details = array() ) {
$home_news_read_more_text = education_hub_get_option( 'home_news_read_more_text' );
if ( empty( $content_details ) ) {
return;
}
?>
<div id="featured-content">
<div class="container">
<div class="inner-wrapper featured-content-column-<?php echo absint( count( $content_details ) ); ?>">
<?php foreach ($content_details as $content ): ?>
<article>
<header class="entry-header"><h2 class="entry-title"><a href="<?php echo esc_url( $content['url'] ); ?>"><?php echo esc_attr( $content['title'] ); ?></a></h2></header>
<?php if ( ! empty( $content['images'] ) ): ?>
<a href="<?php echo esc_url( $content['url'] ); ?>"><img src="<?php echo esc_url( $content['images'][0]); ?>" alt="<?php echo esc_attr( $content['title'] ); ?>" width="<?php echo esc_attr( $content['images'][1]); ?>" height="<?php echo esc_attr( $content['images'][2]); ?>" /></a>
<?php endif; ?>
<div class="entry-content">
<div>
<?php
$excerpt_content = wp_kses_post( $content['excerpt'] );
echo wp_kses_post( wpautop( $excerpt_content ) );
?>
</div>
</div>
<?php if ( ! empty( $home_news_read_more_text ) ): ?>
<a href="<?php echo esc_url( $content['url'] ); ?>" class="button"><?php echo esc_html( $home_news_read_more_text ); ?></a>
<?php endif ?>
</article>
<?php endforeach; ?>
</div>
</div>
</div>
<?php
}
function education_hub_get_home_events_block_content() {
$home_events_section_status = education_hub_get_option( 'home_events_section_status' );
if ( true !== $home_events_section_status ) {
return;
}
$home_events_section_title = education_hub_get_option( 'home_events_section_title' );
$home_events_category = education_hub_get_option( 'home_events_category' );
$home_events_number = education_hub_get_option( 'home_events_number' );
$home_events_excerpt_length = education_hub_get_option( 'home_events_excerpt_length' );
$home_news_read_more_text = education_hub_get_option( 'home_news_read_more_text' );
$qargs = array(
'posts_per_page' => absint( $home_events_number ),
'no_found_rows' => true,
'post_type' => 'post',
);
if ( absint( $home_events_category ) > 0 ) {
$qargs['category'] = absint( $home_events_category );
}
$all_posts = get_posts( $qargs );
ob_start();
?>
<?php if ( ! empty( $all_posts ) ) : ?>
<div class="recent-events">
<h2><?php echo esc_html( $home_events_section_title ); ?></h2>
<?php global $post; ?>
<?php foreach ( $all_posts as $post ) : ?>
<?php setup_postdata( $post ); ?>
<div class="event-post">
<?php if (has_post_thumbnail() ): ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'thumbnail', array( 'class' => 'alignleft' ) ); ?></a>
<?php endif ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php if ( absint( $home_events_excerpt_length ) > 0 ): ?>
<p><?php echo education_hub_the_excerpt( absint( $home_events_excerpt_length ), $post ); ?></p>
<?php endif ?>
<?php if ( ! empty( $home_news_read_more_text ) ): ?>
<a href="<?php the_permalink(); ?>" class="button"><?php echo esc_html( $home_news_read_more_text ); ?></a>
<?php endif ?>
</div> <!-- .event-post -->
<?php endforeach ?>
<?php wp_reset_postdata(); ?>
</div> <!-- .recent-events -->
<?php endif; ?>
<?php
$output = ob_get_contents();
ob_end_clean();
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment