Skip to content

Commit

Permalink
Add the date to "My events" and update the date order (#93)
Browse files Browse the repository at this point in the history
* Add the date to "My events" and update the date order

* Add the footer to the "My events" template
  • Loading branch information
amieiro authored Feb 19, 2024
1 parent 563ccef commit f5e547f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions includes/class-wporg-gp-translation-events-route.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,11 @@ public function events_user_created() {
'posts_per_page' => 10,
'post_status' => array( 'publish', 'draft' ),
'paged' => $_paged,
'orderby' => 'date',
'order' => 'DESC',
'author' => $user_id,

// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
'meta_key' => '_event_start',
'orderby' => 'meta_value',
'order' => 'DESC',
);
$query = new WP_Query( $args );
$this->tmpl( 'events-user-created', get_defined_vars() );
Expand Down
8 changes: 8 additions & 0 deletions templates/events-user-created.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@
$event_url = gp_url( wp_make_link_relative( $permalink ) );
$event_edit_url = gp_url( 'events/edit/' . $event_id );
$event_status = get_post_status( $event_id );
$event_start = ( new DateTime( get_post_meta( get_the_ID(), '_event_start', true ) ) )->format( 'M j, Y' );
$event_end = ( new DateTime( get_post_meta( get_the_ID(), '_event_end', true ) ) )->format( 'M j, Y' );
?>
<li class="event-list-item">
<a class="event-link-<?php echo esc_attr( $event_status ); ?>" href="<?php echo esc_url( $event_url ); ?>"><?php the_title(); ?></a>
<a href="<?php echo esc_url( $event_edit_url ); ?>" class="button is-small action edit">Edit</a>
<?php if ( 'draft' === $event_status ) : ?>
<span class="event-label-<?php echo esc_attr( $event_status ); ?>"><?php echo esc_html( $event_status ); ?></span>
<?php endif; ?>
<?php if ( $event_start === $event_end ) : ?>
<span class="event-list-date events-i-am-attending"><?php echo esc_html( $event_start ); ?></span>
<?php else : ?>
<span class="event-list-date events-i-am-attending"><?php echo esc_html( $event_start ); ?> - <?php echo esc_html( $event_end ); ?></span>
<?php endif; ?>
<p><?php the_excerpt(); ?></p>
</li>
<?php endwhile; ?>
Expand All @@ -53,5 +60,6 @@
else :
echo 'No events found.';
endif;
gp_tmpl_footer();
?>
</div>

0 comments on commit f5e547f

Please sign in to comment.