PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.4.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.4.2
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / controllers / FrmUsageController.php

FrmUsageController.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 5.4.2, at classes/controllers/FrmUsageController.php

56 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 /**
7 * @todo Show opt-in popup after plugin activation.
8 * @since 3.06.04
9 */
10 class FrmUsageController {
11
12 /**
13 * Randomize the first send to prevent our servers from crashing.
14 *
15 * @since 3.06.04
16 */
17 public static function schedule_send() {
18 if ( wp_next_scheduled( 'formidable_send_usage' ) ) {
19 return;
20 }
21
22 $tracking = array(
23 'day' => rand( 0, 6 ) * DAY_IN_SECONDS,
24 'hour' => rand( 0, 23 ) * HOUR_IN_SECONDS,
25 'minute' => rand( 0, 59 ) * MINUTE_IN_SECONDS,
26 'second' => rand( 0, 59 ),
27 );
28
29 $offset = array_sum( $tracking );
30 $init_send = strtotime( 'next sunday' ) + $offset;
31
32 wp_schedule_event( $init_send, 'weekly', 'formidable_send_usage' );
33 }
34
35 /**
36 * Adds once weekly to the existing schedules.
37 *
38 * @since 3.06.04
39 */
40 public static function add_schedules( $schedules = array() ) {
41 $schedules['weekly'] = array(
42 'interval' => DAY_IN_SECONDS * 7,
43 'display' => __( 'Once Weekly', 'formidable' ),
44 );
45 return $schedules;
46 }
47
48 /**
49 * @since 3.06.04
50 */
51 public static function send_snapshot() {
52 $usage = new FrmUsage();
53 $usage->send_snapshot();
54 }
55 }
56