Skip to content

Commit c7420f6

Browse files
committed
more cherry picking
1 parent 5e09e12 commit c7420f6

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

classes/admin/class-page-settings.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,14 @@ public function set_page_values( $pages ) {
138138
}
139139

140140
/**
141-
* Save the settings.
141+
* Save the redirect on login setting.
142+
*
143+
* @param bool $redirect_on_login Whether to redirect on login.
142144
*
143145
* @return void
144146
*/
145-
public function save_settings() {
146-
// Nonce is already checked in store_settings_form_options() which calls this method.
147-
$redirect_on_login = isset( $_POST['prpl-redirect-on-login'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
148-
? \sanitize_text_field( \wp_unslash( $_POST['prpl-redirect-on-login'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
149-
: false;
150-
151-
\update_user_meta( \get_current_user_id(), 'prpl_redirect_on_login', (bool) $redirect_on_login );
147+
public function save_redirect_on_login( $redirect_on_login = false ) {
148+
\update_user_meta( \get_current_user_id(), 'prpl_redirect_on_login', $redirect_on_login );
152149
}
153150

154151
/**

classes/ui/class-chart.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ public function get_chart_data( $args = [] ) {
109109
*/
110110
$previous_period_activities = [];
111111
if ( $args['normalized'] ) {
112-
$previous_month_start = ( clone $periods[0]['start_date'] )->modify( '-1 month' );
113-
$previous_month_end = ( clone $periods[0]['start_date'] )->modify( '-1 day' );
112+
$first_period_start = $periods[0]['start_date'];
113+
$previous_month_start = ( clone $first_period_start )->modify( '-1 month' );
114+
$previous_month_end = ( clone $first_period_start )->modify( '-1 day' );
114115
$previous_period_activities = $args['items_callback']( $previous_month_start, $previous_month_end );
115116
if ( $args['filter_results'] ) {
116117
$activities = $args['filter_results']( $activities );

classes/utils/class-date.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,15 @@ public function get_periods( $start_date, $end_date, $frequency ) {
6868
if ( empty( $date_ranges ) ) {
6969
return [];
7070
}
71-
if ( $end_date->format( 'z' ) !== \end( $date_ranges )['end_date']->format( 'z' ) ) {
72-
$final_end = clone \end( $date_ranges )['end_date'];
71+
$last_range = \end( $date_ranges );
72+
/**
73+
* The end date of the last range.
74+
*
75+
* @var \DateTime $last_end_date
76+
*/
77+
$last_end_date = $last_range['end_date'];
78+
if ( $end_date->format( 'z' ) !== $last_end_date->format( 'z' ) ) {
79+
$final_end = clone $last_end_date;
7380
$date_ranges[] = $this->get_range( $final_end->modify( '+1 day' ), $end_date );
7481
}
7582

0 commit comments

Comments
 (0)