PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.1
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 +17 -41 6.326.16.1 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
@@ -24,28 +25,17 @@
24 25 *
25 26 * @return void
26 27 */
27 28 public static function schedule_send() {
28 - $timestamp = wp_next_scheduled( 'formidable_send_usage' );
29 -
30 - if ( ! self::tracking_allowed() ) {
31 - if ( $timestamp ) {
32 - // Remove the scheduled event if it's not allowed and it's scheduled.
33 - wp_unschedule_event( $timestamp, 'formidable_send_usage' );
34 - }
35 -
29 + if ( wp_next_scheduled( 'formidable_send_usage' ) ) {
36 30 return;
37 31 }
38 32
39 - if ( $timestamp ) {
40 - return;
41 - }
42 -
43 33 $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 ),
34 + 'day' => rand( 0, 6 ) * DAY_IN_SECONDS,
35 + 'hour' => rand( 0, 23 ) * HOUR_IN_SECONDS,
36 + 'minute' => rand( 0, 59 ) * MINUTE_IN_SECONDS,
37 + 'second' => rand( 0, 59 ),
48 38 );
49 39
50 40 $offset = array_sum( $tracking );
51 41 $init_send = strtotime( 'next sunday' ) + $offset;
@@ -56,12 +46,8 @@
56 46 /**
57 47 * Adds once weekly to the existing schedules.
58 48 *
59 49 * @since 3.06.04
60 - *
61 - * @param array $schedules Schedules.
62 - *
63 - * @return array
64 50 */
65 51 public static function add_schedules( $schedules = array() ) {
66 52 $schedules['weekly'] = array(
67 53 'interval' => DAY_IN_SECONDS * 7,
@@ -70,19 +56,8 @@
70 56 return $schedules;
71 57 }
72 58
73 59 /**
74 - * Checks if tracking is allowed.
75 - *
76 - * @since 6.16.3
77 - *
78 - * @return bool
79 - */
80 - public static function tracking_allowed() {
81 - return (bool) FrmAppHelper::get_settings()->tracking;
82 - }
83 -
84 - /**
85 60 * @since 3.06.04
86 61 *
87 62 * @return void
88 63 */
@@ -94,13 +69,11 @@
94 69 /**
95 70 * Loads scripts.
96 71 *
97 72 * @since 6.16.1
98 - *
99 - * @return void
100 73 */
101 74 public static function load_scripts() {
102 - if ( self::is_forms_list_page() || FrmAppHelper::is_admin_page( 'formidable-form-templates' ) || FrmAppHelper::is_admin_page() ) {
75 + if ( self::is_forms_list_page() || FrmAppHelper::is_admin_page( 'formidable-form-templates' ) ) {
103 76 wp_enqueue_script( 'frm-usage-tracking', FrmAppHelper::plugin_url() . '/js/admin/usage-tracking.js', array( 'formidable_dom' ), FrmAppHelper::$plug_version, true );
104 77 }
105 78 }
106 79
@@ -111,15 +84,20 @@
111 84 *
112 85 * @return bool
113 86 */
114 87 private static function is_forms_list_page() {
115 - if ( ! FrmAppHelper::on_form_listing_page() ) {
88 + if ( ! FrmAppHelper::is_admin_page() ) {
116 89 return false;
117 90 }
118 91
119 - // Exclude Trash page.
92 + // Check Trash page.
120 93 $form_type = FrmAppHelper::simple_get( 'form_type' );
121 - return 'published' === $form_type;
94 + if ( $form_type && 'published' !== $form_type ) {
95 + return false;
96 + }
97 +
98 + // Check edit or settings page.
99 + return ! FrmAppHelper::simple_get( 'frm_action' );
122 100 }
123 101
124 102 /**
125 103 * AJAX handler to track flows.
@@ -124,10 +102,8 @@
124 102 /**
125 103 * AJAX handler to track flows.
126 104 *
127 105 * @since 6.16.1
128 - *
129 - * @return void
130 106 */
131 107 public static function ajax_track_flows() {
132 108 FrmAppHelper::permission_check( 'frm_view_forms' );
133 109 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -150,13 +126,13 @@
150 126 *
151 127 * @return void
152 128 */
153 129 public static function update_flows_data( $key, $value ) {
130 + $flows_data = self::get_flows_data();
131 +
154 132 if ( '' === $key || '' === $value ) {
155 133 return;
156 134 }
157 -
158 - $flows_data = self::get_flows_data();
159 135
160 136 if ( ! isset( $flows_data[ $key ] ) ) {
161 137 $flows_data[ $key ] = array();
162 138 }