$end ) { $remaining = false; $next = false; $length = false; /* translators: 1: start timestamp, 2: end timestamp */ $error = new WP_Error( 'itsec-away-mode-is-current-timestamp-in-range-start-after-end', sprintf( __( 'The supplied data is invalid. The supplied start (%1$s) is after the supplied end (%2$s).', 'better-wp-security' ), $start, $end ) ); } else { $remaining = $end - $now; $next = $start - $now; $length = $end - $start; $error = false; if ( $now < $start ) { $remaining = false; } if ( $next < 0 ) { $next = false; } } return compact( 'active', 'remaining', 'next', 'length', 'error' ); } /** * Check if the current local time falls between the two specified times, inclusive. * * @param int $start The local timestamp signalling the beginning of the active window. * @param int $end The local timestamp signalling the end of the active window. * @param bool $include_details Whether to include additional details about the active window. * * @return array|bool */ public static function is_current_time_active( $start, $end, $include_details = false ) { $current_time = ITSEC_Core::get_current_time(); $now = $current_time - strtotime( date( 'Y-m-d', $current_time ) ); $active = false; if ( $start <= $end ) { if ( $start <= $now && $now <= $end ) { $active = true; } } else { if ( $start <= $now || $now <= $end ) { $active = true; } } if ( ! $include_details ) { return $active; } $remaining = $end - $now; $next = $start - $now; $length = $end - $start; if ( $active && $remaining < 0 ) { $remaining += DAY_IN_SECONDS; } else if ( ! $active && $remaining >= 0 ) { $remaining -= DAY_IN_SECONDS; } if ( $next < 0 ) { $next += DAY_IN_SECONDS; } if ( $length < 0 ) { $length += DAY_IN_SECONDS; } return compact( 'active', 'remaining', 'next', 'length' ); } }