Skip to content

Commit d92e6cf

Browse files
authored
Merge pull request #200 from MultinetInteractive/master
2.0.20
2 parents 8629b33 + f087467 commit d92e6cf

5 files changed

Lines changed: 42 additions & 21 deletions

File tree

content/template/bookingTemplate/-login-form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@
5858
unset( EDU()->session['eduadmin-forgotPassSent'] );
5959
?>
6060
<div class="edu-modal warning" style="display: block; clear: both;">
61-
<?php esc_html_e( 'A new password has been sent by email.', 'eduadmin-booking' ); ?>
61+
<?php esc_html_e( 'An email with instructions how to reset your password has been sent.', 'eduadmin-booking' ); ?>
6262
</div>
6363
<?php
6464
} elseif ( isset( EDU()->session['eduadmin-forgotPassSent'] ) && false === EDU()->session['eduadmin-forgotPassSent'] ) {
6565
unset( EDU()->session['eduadmin-forgotPassSent'] );
6666
?>
6767
<div class="edu-modal warning" style="display: block; clear: both;">
68-
<?php esc_html_e( 'Could not send a new password by email.', 'eduadmin-booking' ); ?>
68+
<?php esc_html_e( 'An email with instructions how to reset your password has been sent.', 'eduadmin-booking' ); ?>
6969
</div>
7070
<?php } ?>

content/template/detailTemplate/blocks/event-item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<div data-groupid="eduev<?php echo( $group_by_city ? '-' . esc_attr( $ev['City'] ) : '' ); ?>" class="eventItem<?php echo( $show_more > 0 && $i >= $show_more ? ' showMoreHidden' : '' ); ?>">
2222
<div class="eventDate<?php echo esc_attr( $group_by_city_class ); ?>">
2323
<?php
24-
echo isset( $event_dates[ $ev['EventId'] ] ) ? wp_kses_post( get_logical_date_groups( $event_dates[ $ev['EventId'] ] ) ) : wp_kses_post( get_old_start_end_display_date( $ev['StartDate'], $ev['EndDate'] ) );
24+
echo isset( $event_dates[ $ev['EventId'] ] ) ? get_logical_date_groups( $event_dates[ $ev['EventId'] ] ) : wp_kses_post( get_old_start_end_display_date( $ev['StartDate'], $ev['EndDate'] ) );
2525
echo ! isset( $event_dates[ $ev['EventId'] ] ) || 1 === count( $event_dates[ $ev['EventId'] ] ) ? '<span class="eventTime">, ' . esc_html( date( 'H:i', strtotime( $ev['StartDate'] ) ) ) . ' - ' . esc_html( date( 'H:i', strtotime( $ev['EndDate'] ) ) ) . '</span>' : '';
2626
?>
2727
</div>

eduadmin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Plugin URI: https://www.eduadmin.se
1010
* Description: EduAdmin plugin to allow visitors to book courses at your website
1111
* Tags: booking, participants, courses, events, eduadmin, lega online
12-
* Version: 2.0.19
12+
* Version: 2.0.20
1313
* GitHub Plugin URI: multinetinteractive/eduadmin-wordpress
1414
* GitHub Plugin URI: https://github.com/multinetinteractive/eduadmin-wordpress
1515
* Requires at least: 4.7

includes/edu-text-functions.php

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,36 +231,53 @@ function get_logical_date_groups( $dates, $short = false, $event = null, $show_d
231231
$show_days = true;
232232
}
233233

234-
$n_dates = get_range_from_days( $dates, $short, $event, $show_days );
234+
$n_dates = edu_get_date_range( $dates, $short, $event, $show_days );
235235

236236
return join( '<span class="edu-dateSeparator"></span>', $n_dates );
237237
}
238238

239-
// Copied from http://codereview.stackexchange.com/a/83095/27610
240-
function get_range_from_days( $days, $short, $event, $show_days ) {
239+
function edu_get_date_range( $days, $short, $event, $show_days ) {
241240
usort( $days, "DateComparer" );
242-
$start_date = $days[0];
243-
$finish_date = $days[ count( $days ) - 1 ];
244-
$result = array();
245-
// walk through the dates, breaking at gaps
246-
foreach ( $days as $key => $date ) {
247-
if ( ( $key > 0 ) && ( strtotime( $date['StartDate'] ) - strtotime( $days[ $key - 1 ]['StartDate'] ) > 99999 ) ) {
248-
$result[] = get_start_end_display_date( $start_date, $days[ $key - 1 ], $short, $event, $show_days );
249-
$start_date = $date;
241+
242+
if ( 1 === count( $days ) ) {
243+
return array( get_start_end_display_date( $days[0], $days[0], $short, $event, $show_days ) );
244+
}
245+
246+
$added_dates = array();
247+
248+
$total_days = count( $days );
249+
250+
for ( $x = 0; $x < $total_days; $x++ ) {
251+
$day = $days[ $x ];
252+
253+
$added_dates[ date( 'H:i', strtotime( $day['StartDate'] ) ) . '-' . date( 'H:i', strtotime( $day['EndDate'] ) ) ][] = $day;
254+
}
255+
256+
$ordered_dategroups = array();
257+
258+
foreach ( $added_dates as $time => $_days ) {
259+
$start_date = $_days[0];
260+
$finish_date = $_days[ count( $_days ) - 1 ];
261+
foreach ( $_days as $key => $date ) {
262+
if ( $key > 0 && ( strtotime( $date['StartDate'] ) - strtotime( $_days[ $key - 1 ]['StartDate'] ) > 99999 ) ) {
263+
$ordered_dategroups[ $start_date['StartDate'] ] = get_start_end_display_date( $start_date, $_days[ $key - 1 ], $short, $event, $show_days );
264+
$start_date = $date;
265+
}
250266
}
267+
$ordered_dategroups[ $start_date['StartDate'] ] = get_start_end_display_date( $start_date, $finish_date, $short, $event, $show_days );
251268
}
252-
// force the end
253-
$result[] = get_start_end_display_date( $start_date, $finish_date, $short, $event, $show_days );
254269

255-
if ( count( $result ) > 3 ) {
270+
ksort( $ordered_dategroups );
271+
272+
if ( count( $ordered_dategroups ) > 3 ) {
256273
$n_res = array();
257274
$ret =
258275
'<span class="edu-manyDays" title="' . esc_attr__( 'Show schedule', 'eduadmin-booking' ) . '" onclick="edu_openDatePopup(this);">' .
259276
/* translators: 1: Number of days 2: Date range */
260277
wp_kses_post( sprintf( __( '%1$d days between %2$s', 'eduadmin-booking' ), count( $days ), get_start_end_display_date( $days[0], end( $days ), $short, $show_days ) ) ) .
261278
'</span><div class="edu-DayPopup">
262279
<b>' . esc_html__( 'Schedule', 'eduadmin-booking' ) . '</b><br />
263-
' . join( "<br />\n", $result ) . '
280+
' . join( "<br />\n", $ordered_dategroups ) . '
264281
<br />
265282
<a href="javascript://" onclick="edu_closeDatePopup(event, this);">' . esc_html__( 'Close', 'eduadmin-booking' ) . '</a>
266283
</div>';
@@ -270,7 +287,7 @@ function get_range_from_days( $days, $short, $event, $show_days ) {
270287
return $n_res;
271288
}
272289

273-
return $result;
290+
return $ordered_dategroups;
274291
}
275292

276293
function get_start_end_display_date( $start_date, $end_date, $short = false, $event, $show_days = false ) {

readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: mnchga
33
Tags: booking, participants, courses, events, eduadmin, lega online
44
Requires at least: 4.7
55
Tested up to: 4.9
6-
Stable tag: 2.0.19
6+
Stable tag: 2.0.20
77
Requires PHP: 5.2
88
License: GPL3
99
License-URI: https://www.gnu.org/licenses/gpl-3.0.en.html
@@ -37,6 +37,10 @@ If you notice that your API key doesn't work any more, you have to contact us.
3737

3838
== Changelog ==
3939

40+
### 2.0.20
41+
- chg: Altered the info text you get when you request a password reset.
42+
- chg: Made a new function to group dates, that works better.
43+
4044
### 2.0.19
4145
- add: Added `get_transient` in `eduadmin.php` (`EDU()->get_transient($name, $action, $expiration, ..$args)`)
4246

0 commit comments

Comments
 (0)