PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 1.5.2
WP 2FA – Two-factor authentication for WordPress v1.5.2
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 / BackgroundProcessing / DeleteGracePeriod.php
wp-2fa / includes / classes / BackgroundProcessing Last commit date
DeleteGracePeriod.php 5 years ago Enforce2FA.php 5 years ago RemoveAllUserData.php 5 years ago RemoveEnabledMethods.php 5 years ago
DeleteGracePeriod.php
68 lines
1 <?php // phpcs:ignore
2
3 namespace WP2FA\BackgroundProcessing;
4
5 use \WP2FA\Admin\SettingsPage as SettingsPage;
6 use WP2FA\Utils\DateTimeUtils;
7 use \WP2FA\WP2FA as WP2FA;
8 use \WP2FA\Authenticator\Authentication as Authentication;
9 use \WP2FA\Admin\UserProfile as UserProfile;
10
11 /**
12 * Class for handling our crons.
13 */
14 class DeleteGracePeriod extends \WP_Background_Process {
15
16 /**
17 * Name of the cron we are going to attach these to.
18 *
19 * @var string
20 */
21 protected $action = '2fa_bg_delete_user_grace_period';
22
23 /**
24 * Task to perform in the BG
25 *
26 * @param object $item Consists of User ID, name of the job we want to do, and optional extras.
27 */
28 protected function task( $item ) {
29
30 if ( empty( $item ) || ! isset( $item ) ) {
31 return false;
32 }
33
34 // Turn a single user into an array.
35 $users = array();
36 if ( isset( $item['user'] ) ) {
37 $users[] = $item['user'];
38 } elseif ( isset( $item['users'] ) ) {
39 $users = $item['users'];
40 }
41
42 // If we still have no data, stop here.
43 if ( empty( $users ) ) {
44 return false;
45 }
46
47 if ( ! is_array( $users ) ) {
48 $users = explode( ',', $users );
49 }
50
51 // Delete grace period from user meta.
52 foreach ( $users as $user ) {
53 $user_id = is_object( $user ) ? $user->ID : $user;
54 UserProfile::delete_expire_and_enforced_keys( $user_id );
55 }
56
57 return false;
58 }
59
60 /**
61 * Fire off event so we know the above tasks have completed.
62 */
63 protected function complete() {
64 parent::complete();
65 }
66
67 }
68