Skip to content

Commit

Permalink
Break out event wrapper into separate function.
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Oct 26, 2023
1 parent ce83b9e commit 7296e7d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/my-calendar-output.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ function my_calendar_draw_event( $event, $type, $process_date, $time, $template
$container_id = mc_event_container_id( $type, $process_date, $event );
$details = mc_wrap_event_details( $details, $type, $container_id, $data );
$details = $header . $details;
$details = mc_wrap_event( $details, $event, $container_id, $type );
/**
* Runs right after a calendar event template is run.
*
Expand Down Expand Up @@ -302,8 +303,7 @@ function mc_draw_event_header( $data, $type, $template ) {
$event_classes = mc_event_classes( $event, $type );
$nofollow = ( stripos( $event_classes, 'past-event' ) !== false ) ? 'rel="nofollow"' : '';
$container_id = mc_event_container_id( $type, $process_date, $event );
$parent_id = str_replace( 'details-', '', $container_id );
$header = "\n\n <div id='$parent_id' class='$event_classes'>\n";
$header = '';

$event_title = mc_load_template( 'event/' . $type . '-' . 'title', $data );
if ( ! $event_title ) {
Expand Down Expand Up @@ -388,6 +388,24 @@ function mc_draw_event_header( $data, $type, $template ) {
return $header;
}

/**
* Wrap event header & body together.
*
* @param string $content Header & event body content.
* @param object $event Event object.
* @param string $container_id Container ID.
* @param string $type View type.
*
* @return string
*/
function mc_wrap_event( $content, $event, $container_id, $type ) {
$event_classes = mc_event_classes( $event, $type );
$parent_id = str_replace( 'details-', '', $container_id );
$header = "<div id='$parent_id' class='$event_classes'>";

return $header . $content . '</div>';
}

/**
* Wrap event details in its container.
*
Expand Down

0 comments on commit 7296e7d

Please sign in to comment.