PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 2.1.0
WP 2FA – Two-factor authentication for WordPress v2.1.0
4.0.0 1.7.1 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.8.0 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0 3.0.1 3.1.0 3.1.1 3.1.1.2 trunk 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.7.0
wp-2fa / includes / classes / Utils / DateTimeUtils.php
wp-2fa / includes / classes / Utils Last commit date
AbstractMigration.php 4 years ago DateTimeUtils.php 4 years ago Debugging.php 5 years ago GenerateModal.php 4 years ago Migration.php 4 years ago RequestUtils.php 4 years ago SettingsUtils.php 4 years ago UserUtils.php 4 years ago index.php 5 years ago
DateTimeUtils.php
53 lines
1 <?php
2
3 namespace WP2FA\Utils;
4
5 use WP2FA\WP2FA as WP2FA;
6 use WP2FA\Utils\SettingsUtils as SettingsUtils;
7
8 /**
9 * Utility class for date and time manipulation, format conversion and so on.
10 *
11 * @package WP2FA\Utils
12 * @since 1.4.2
13 */
14 class DateTimeUtils {
15
16 /**
17 * @param string|null $grace_policy Grace policy value.
18 * @param int $grace_expiry Expiration time as unix based timestamp.
19 *
20 * @return string Translated grace period expiration string.
21 */
22 public static function format_grace_period_expiration_string( $grace_policy = null, $grace_expiry = - 1 ) {
23 if ( null === $grace_policy ) {
24 $grace_policy = WP2FA::get_wp2fa_setting( 'grace-policy' );
25 }
26
27 if ( 'no-grace-period' === $grace_policy ) {
28 return esc_html__( 'no grace period', 'wp-2fa' );
29 }
30
31 if ( $grace_expiry === - 1 ) {
32 if ( 'use-grace-period' === $grace_policy ) {
33 $grace_period = WP2FA::get_wp2fa_setting( 'grace-period' );
34 $grace_period_denominator = WP2FA::get_wp2fa_setting( 'grace-period-denominator' );
35 $grace_period_string = $grace_period . ' ' . $grace_period_denominator;
36 $grace_expiry = (int) strtotime( $grace_period_string );
37 } else {
38 // this will probably never be reached, leaving it here for now just in case
39 $grace_expiry = time();
40 }
41 }
42
43 $expiration_date_time = implode(' ', [
44 // Purposefully not using the SettingsUtil class as we dont want this prefixed.
45 date_i18n( get_option( 'date_format' ), $grace_expiry ),
46 date_i18n( get_option( 'time_format' ), $grace_expiry )
47 ]);
48
49 /* translators: Grace period expiration label. %s: Date and time formatted using WordPress date and time formats. */
50 return sprintf( esc_html__( 'before %s', 'wp-2fa' ), $expiration_date_time);
51 }
52 }
53