Created
April 20, 2019 04:14
-
-
Save yeriepiscesa/370031a387ca034bb44aadf7204871b3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
add_shortcode( 'solusipress_event_date_price', 'solusipress_event_date_price_cb' ); | |
add_shortcode( 'solusipress_event_sponsors', 'solusipress_event_sponsors_cb' ); | |
function solusipress_event_date_price_cb( $atts ) { | |
$prefix = '_spevt_'; | |
$meta_d1 = get_post_meta( get_the_ID(), $prefix.'start_date', true ); | |
$meta_d2 = get_post_meta( get_the_ID(), $prefix.'end_date', true ); | |
$price = get_post_meta( get_the_ID(), $prefix.'price', true ); | |
$url = get_post_meta( get_the_ID(), $prefix.'buy_url', true ); | |
$html = ''; | |
ob_start(); ?> | |
<div class="container event-date-price"> | |
<div class="row"> | |
<div class="col-6 date-box"> | |
<?php | |
$start_date = date( 'Y-m-d H:i:s', $meta_d1 ); | |
$end_date = date( 'Y-m-d H:i:s', $meta_d2 ); | |
$diff = date_diff( date_create( $end_date ), date_create( $start_date ) ); | |
?> | |
<div class="event the-date"> | |
<span class="the-date-date_start"><?php echo date( 'l, d-M-Y', $meta_d1 ) ?></span> | |
<?php if( $diff->days > 0 ): ?> | |
<strong> - </strong> <span class="the-date-date_end"><?php echo date( 'l, d-M-Y', $meta_d2 ) ?></span> | |
<?php else: ?> | |
<br><span class="the-date-time_start"><?php echo date( 'g:iA', $meta_d1 ) ?></span> - | |
<span class="the-date-time_end"><?php echo date( 'g:iA', $meta_d2 ) ?></span> | |
<?php endif; ?> | |
</div> | |
</div> | |
<div class="col-6 price-box"> | |
<div class="event the-price"> | |
<span class="the-price-rate">IDR <?php echo $price ?></span> | |
</div> | |
<a href="<?php echo $url ?>" target="_blank">Get Ticket</a> | |
</div> | |
</div> | |
</div> | |
<?php | |
$html = ob_get_contents(); | |
ob_end_clean(); | |
return $html; | |
} | |
function solusipress_event_sponsors_cb( $atts ) { | |
$prefix = '_spevt_'; | |
$entries = get_post_meta( get_the_ID(), $prefix.'sponsor_group', true ); | |
$html = ''; | |
$cols = 3; | |
$class = 'col-4'; | |
ob_start(); ?> | |
<div class="container"> | |
<?php $i = 0; foreach ( (array) $entries as $key => $entry ): ?> | |
<?php | |
if( $i % $cols == 0 ) { | |
if( $i > 0 ) echo '</div>'; | |
echo '<div class="row">'; | |
} | |
?> | |
<div class="<?php echo $class ?>" style="padding:10px;"> | |
<img src="<?php echo $entry['logo'] ?>"> | |
</div> | |
<?php $i++; endforeach; ?> | |
</div> | |
<?php | |
$html = ob_get_contents(); | |
ob_end_clean(); | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment