Skip to content

Commit 38529a8

Browse files
author
Chris Gårdenberg
committed
feat: List number of free spots on programme list
1 parent 200f40c commit 38529a8

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

PLUGIN-CHECKSUM

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14f81e2c8579a08c36c41a722bb72da7
1+
4ee9133f3a97a05000746eecdbe1169a

content/template/programme/list.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
$spot_left_option = EDU()->get_option( 'eduadmin-spotsLeft', 'exactNumbers' );
3+
$always_few_spots = EDU()->get_option( 'eduadmin-alwaysFewSpots', '3' );
4+
$spot_settings = EDU()->get_option( 'eduadmin-spotsSettings', "1-5\n5-10\n10+" );
25

36
if ( empty( $programmes['Errors'] ) ) {
47
?>

content/template/programme/template/list-item.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@
2828
<?php
2929
if ( ! empty( $programme['ProgrammeStarts'] ) ) {
3030
$next_start = current( $programme['ProgrammeStarts'] );
31+
32+
$spots_left = intval( $next_start['ParticipantNumberLeft'] );
33+
3134
/* translators: 1. The date for the next programme start */
3235
echo wp_kses_post( sprintf( _x( 'Next start: %s', 'Next programme start', 'eduadmin-booking' ), get_display_date( $next_start['StartDate'] ) ) );
3336
echo '<br />';
34-
echo wp_kses_post( $next_start['ParticipantNumberLeft'] > 0 || intval( $next_start['MaxParticipantNumber'] ) == 0 ? '<span class="spots-left">' . _x( 'Spots left', 'frontend', 'eduadmin-booking' ) . '</span>' : '<span class="no-spots">' . _x( 'No spots', 'frontend', 'eduadmin-booking' ) . '</span>' );
37+
echo wp_kses_post("<span class=\"spots-left\">" . get_spots_left( $spots_left, intval( $next_start['MaxParticipantNumber'] ), $spot_left_option, $spot_settings, $always_few_spots ) . "</span>\n");
3538
}
3639
?>
3740
</div>

0 commit comments

Comments
 (0)