PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.19
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.19
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
← All changes | classes/controllers/FrmUsageController.php +11 -25 6.286.19 View file →
@@ -3,8 +3,9 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 /**
7 + * @todo Show opt-in popup after plugin activation.
7 8 * @since 3.06.04
8 9 */
9 10 class FrmUsageController {
10 11
@@ -25,15 +26,13 @@
25 26 * @return void
26 27 */
27 28 public static function schedule_send() {
28 29 $timestamp = wp_next_scheduled( 'formidable_send_usage' );
29 -
30 30 if ( ! self::tracking_allowed() ) {
31 31 if ( $timestamp ) {
32 32 // Remove the scheduled event if it's not allowed and it's scheduled.
33 33 wp_unschedule_event( $timestamp, 'formidable_send_usage' );
34 34 }
35 -
36 35 return;
37 36 }
38 37
39 38 if ( $timestamp ) {
@@ -40,12 +39,12 @@
40 39 return;
41 40 }
42 41
43 42 $tracking = array(
44 - 'day' => random_int( 0, 6 ) * DAY_IN_SECONDS,
45 - 'hour' => random_int( 0, 23 ) * HOUR_IN_SECONDS,
46 - 'minute' => random_int( 0, 59 ) * MINUTE_IN_SECONDS,
47 - 'second' => random_int( 0, 59 ),
43 + 'day' => rand( 0, 6 ) * DAY_IN_SECONDS,
44 + 'hour' => rand( 0, 23 ) * HOUR_IN_SECONDS,
45 + 'minute' => rand( 0, 59 ) * MINUTE_IN_SECONDS,
46 + 'second' => rand( 0, 59 ),
48 47 );
49 48
50 49 $offset = array_sum( $tracking );
51 50 $init_send = strtotime( 'next sunday' ) + $offset;
@@ -56,12 +55,8 @@
56 55 /**
57 56 * Adds once weekly to the existing schedules.
58 57 *
59 58 * @since 3.06.04
60 - *
61 - * @param array $schedules Schedules.
62 - *
63 - * @return array
64 59 */
65 60 public static function add_schedules( $schedules = array() ) {
66 61 $schedules['weekly'] = array(
67 62 'interval' => DAY_IN_SECONDS * 7,
@@ -77,9 +72,10 @@
77 72 *
78 73 * @return bool
79 74 */
80 75 public static function tracking_allowed() {
81 - return (bool) FrmAppHelper::get_settings()->tracking;
76 + $settings = FrmAppHelper::get_settings();
77 + return $settings->tracking;
82 78 }
83 79
84 80 /**
85 81 * @since 3.06.04
@@ -94,13 +90,11 @@
94 90 /**
95 91 * Loads scripts.
96 92 *
97 93 * @since 6.16.1
98 - *
99 - * @return void
100 94 */
101 95 public static function load_scripts() {
102 - if ( self::is_forms_list_page() || FrmAppHelper::is_admin_page( 'formidable-form-templates' ) || FrmAppHelper::is_admin_page() ) {
96 + if ( self::is_forms_list_page() || FrmAppHelper::is_admin_page( 'formidable-form-templates' ) ) {
103 97 wp_enqueue_script( 'frm-usage-tracking', FrmAppHelper::plugin_url() . '/js/admin/usage-tracking.js', array( 'formidable_dom' ), FrmAppHelper::$plug_version, true );
104 98 }
105 99 }
106 100
@@ -111,15 +105,9 @@
111 105 *
112 106 * @return bool
113 107 */
114 108 private static function is_forms_list_page() {
115 - if ( ! FrmAppHelper::on_form_listing_page() ) {
116 - return false;
117 - }
118 -
119 - // Exclude Trash page.
120 - $form_type = FrmAppHelper::simple_get( 'form_type' );
121 - return 'published' === $form_type;
109 + return FrmAppHelper::is_admin_list_page();
122 110 }
123 111
124 112 /**
125 113 * AJAX handler to track flows.
@@ -124,10 +112,8 @@
124 112 /**
125 113 * AJAX handler to track flows.
126 114 *
127 115 * @since 6.16.1
128 - *
129 - * @return void
130 116 */
131 117 public static function ajax_track_flows() {
132 118 FrmAppHelper::permission_check( 'frm_view_forms' );
133 119 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -150,13 +136,13 @@
150 136 *
151 137 * @return void
152 138 */
153 139 public static function update_flows_data( $key, $value ) {
140 + $flows_data = self::get_flows_data();
141 +
154 142 if ( '' === $key || '' === $value ) {
155 143 return;
156 144 }
157 -
158 - $flows_data = self::get_flows_data();
159 145
160 146 if ( ! isset( $flows_data[ $key ] ) ) {
161 147 $flows_data[ $key ] = array();
162 148 }