PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.18
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.18
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 +23 -28 6.356.18 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;
@@ -55,21 +54,15 @@
55 54
56 55 /**
57 56 * Adds once weekly to the existing schedules.
58 57 *
59 - * WordPress core registers an identical 'weekly' schedule of its own, so this adds nothing.
60 - * The 'cron_schedules' registration is gone, and with it the translated label that made
61 - * this run before the text domain loaded.
62 - *
63 58 * @since 3.06.04
64 - * @deprecated 6.35
65 - *
66 - * @param array $schedules Unused. The registered cron schedules, keyed by schedule name.
67 - *
68 - * @return array
69 59 */
70 60 public static function add_schedules( $schedules = array() ) {
71 - _deprecated_function( __METHOD__, '6.35' );
61 + $schedules['weekly'] = array(
62 + 'interval' => DAY_IN_SECONDS * 7,
63 + 'display' => __( 'Once Weekly', 'formidable' ),
64 + );
72 65 return $schedules;
73 66 }
74 67
75 68 /**
@@ -79,9 +72,10 @@
79 72 *
80 73 * @return bool
81 74 */
82 75 public static function tracking_allowed() {
83 - return (bool) FrmAppHelper::get_settings()->tracking;
76 + $settings = FrmAppHelper::get_settings();
77 + return $settings->tracking;
84 78 }
85 79
86 80 /**
87 81 * @since 3.06.04
@@ -96,13 +90,11 @@
96 90 /**
97 91 * Loads scripts.
98 92 *
99 93 * @since 6.16.1
100 - *
101 - * @return void
102 94 */
103 95 public static function load_scripts() {
104 - 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' ) ) {
105 97 wp_enqueue_script( 'frm-usage-tracking', FrmAppHelper::plugin_url() . '/js/admin/usage-tracking.js', array( 'formidable_dom' ), FrmAppHelper::$plug_version, true );
106 98 }
107 99 }
108 100
@@ -113,15 +105,20 @@
113 105 *
114 106 * @return bool
115 107 */
116 108 private static function is_forms_list_page() {
117 - if ( ! FrmAppHelper::on_form_listing_page() ) {
109 + if ( ! FrmAppHelper::is_admin_page() ) {
118 110 return false;
119 111 }
120 112
121 - // Exclude Trash page.
113 + // Check Trash page.
122 114 $form_type = FrmAppHelper::simple_get( 'form_type' );
123 - return 'published' === $form_type;
115 + if ( $form_type && 'published' !== $form_type ) {
116 + return false;
117 + }
118 +
119 + // Check edit or settings page.
120 + return ! FrmAppHelper::simple_get( 'frm_action' );
124 121 }
125 122
126 123 /**
127 124 * AJAX handler to track flows.
@@ -126,10 +123,8 @@
126 123 /**
127 124 * AJAX handler to track flows.
128 125 *
129 126 * @since 6.16.1
130 - *
131 - * @return void
132 127 */
133 128 public static function ajax_track_flows() {
134 129 FrmAppHelper::permission_check( 'frm_view_forms' );
135 130 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -142,9 +137,9 @@
142 137 wp_send_json_success();
143 138 }
144 139
145 140 /**
146 - * Updates flows data. This increases the count of flow_data[ $key ][ $value ].
141 + * Updates flows data.
147 142 *
148 143 * @since 6.16.1
149 144 *
150 145 * @param string $key Flow key.
@@ -152,13 +147,13 @@
152 147 *
153 148 * @return void
154 149 */
155 150 public static function update_flows_data( $key, $value ) {
151 + $flows_data = self::get_flows_data();
152 +
156 153 if ( '' === $key || '' === $value ) {
157 154 return;
158 155 }
159 -
160 - $flows_data = self::get_flows_data();
161 156
162 157 if ( ! isset( $flows_data[ $key ] ) ) {
163 158 $flows_data[ $key ] = array();
164 159 }