Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Activator
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 activate
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Fired during plugin activation
4 *
5 * @link       https://BrianHenryIE.com
6 * @since      1.0.0
7 *
8 * @package brianhenryie/bh-wc-checkout-rate-limiter
9 */
10
11namespace BrianHenryIE\Checkout_Rate_Limiter\WP_Includes;
12
13/**
14 * Fired during plugin activation.
15 *
16 * This class defines all code necessary to run during the plugin's activation.
17 *
18 * @since      1.0.0
19 * @package brianhenryie/bh-wc-checkout-rate-limiter
20 *
21 * @author     BrianHenryIE <BrianHenryIE@gmail.com>
22 */
23class Activator {
24
25    const ACTIVATED_TIME_OPTION_KEY = 'bh_wc_checkout_rate_limiter_activated_time';
26
27    /**
28     * Record each time the plugin has been activated.
29     *
30     * I.e. was the plugin active when the denial of service attack happened?
31     *
32     * @since    1.0.0
33     */
34    public static function activate(): void {
35
36        $option_key = self::ACTIVATED_TIME_OPTION_KEY;
37
38        $activations = get_option( $option_key, array() );
39
40        $activations[] = time();
41
42        update_option( $option_key, $activations );
43
44    }
45
46}