Skip to content

Commit

Permalink
Update mc_event_classes() to echo instead of return; add getter
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Nov 19, 2023
1 parent faafa06 commit 8ee57f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/my-calendar-output.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ function mc_draw_event_header( $data, $type, $template ) {
$image = mc_category_icon( $event );
$image = ( $image ) ? $image . ' ' : '';
$has_image = ( '' !== $image ) ? ' has-image' : '';
$event_classes = mc_event_classes( $event, $type );
$event_classes = mc_get_event_classes( $event, $type );
$nofollow = ( stripos( $event_classes, 'past-event' ) !== false ) ? 'rel="nofollow"' : '';
$container_id = mc_event_container_id( $type, $process_date, $event );
$header = '';
Expand Down Expand Up @@ -709,6 +709,16 @@ function mc_disable_link( $status, $event ) {
}
add_filter( 'mc_disable_link', 'mc_disable_link', 10, 2 );

/**
* Echo classes for a given event.
*
* @param object $event Event Object.
* @param string $type Type of view being shown.
*/
function mc_event_classes( $event, $type ) {
echo mc_get_event_classes( $event, $type );
}

/**
* Generate classes for a given event
*
Expand All @@ -717,7 +727,7 @@ function mc_disable_link( $status, $event ) {
*
* @return string classes
*/
function mc_event_classes( $event, $type ) {
function mc_get_event_classes( $event, $type ) {
$uid = 'mc_' . $type . '_' . $event->occur_id;
$relation = mc_date_relation( $event );
switch ( $relation ) {
Expand Down Expand Up @@ -1316,7 +1326,7 @@ function mc_list_group( $id, $this_id, $template = '{date}, {time}' ) {
$template = mc_get_custom_template( $template );
}
$html = mc_draw_template( $array, $template );
$classes = mc_event_classes( $event, 'related' );
$classes = mc_get_event_classes( $event, 'related' );
$classes .= ( (int) $event_id === (int) $this_id ) ? ' current-event' : '';
$output .= "<li class='$classes'>$html</li>";
}
Expand Down
2 changes: 2 additions & 0 deletions src/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ Translating my plugins is always appreciated. Visit <a href="https://translate.w
* Change: Improve HTML semantics in event display.
* Change: Switch popup triggers to buttons.
* Feature: Add card view.
* Breaking change: `mc_event_classes()` now echos classes. Use `mc_get_event_classes()` to return.


= 3.4.21 =

Expand Down
2 changes: 1 addition & 1 deletion src/templates/legacy-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ function mc_format_upcoming_event( $event, $template, $type ) {
$event = $event['event'];
$today = current_time( 'Y-m-d' );
$date = mc_date( 'Y-m-d H:i:s', strtotime( $details['dtstart'] ), false );
$classes = mc_event_classes( $event, 'upcoming' );
$classes = mc_get_event_classes( $event, 'upcoming' );

if ( my_calendar_date_equal( $date, $today ) ) {
$classes .= ' today';
Expand Down

0 comments on commit 8ee57f6

Please sign in to comment.