PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.14
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
← All changes | app/Modules/Track/TrackModule.php +160 -147 3.6.316.2.14 View file →
@@ -1,170 +1,183 @@
1 -<?php namespace FluentForm\App\Modules\Track;
1 +<?php
2 2
3 -use FluentForm\AdminNotice;
4 -use FluentForm\App;
5 -use FluentForm\Framework\Helpers\ArrayHelper;
3 +namespace FluentForm\App\Modules\Track;
6 4
5 +use FluentForm\App\Http\Controllers\AdminNoticeController;
6 +
7 +//Could not Find any Usage any where
8 +
7 9 class TrackModule
8 10 {
9 - private $apiUrl = 'https://wpfluentform.com';
10 - private $initialConsentKey = '_fluentform_notice_pref';
11 - private $newsletterDelayTimeStamp = 172800; // 7 days
12 -
13 - public function initTrack()
14 - {
15 - if( AdminNotice::shouldShowNotice('track_data_notice') && !$this->isLocalhost() ) {
16 - $this->showInitialConsent();
17 - }
18 - }
19 -
20 - public function showInitialConsent()
11 + private $apiUrl = 'https://fluentform.com';
12 + private $initialConsentKey = '_fluentform_notice_pref';
13 + private $newsletterDelayTimeStamp = 172800; // 7 days
14 +
15 +
16 + private $adminNotice;
17 +
18 + public function __construct()
21 19 {
22 - $notice = $this->getInitialNotice();
23 - AdminNotice::addNotice($notice);
20 + $this->adminNotice = new AdminNoticeController();
24 21 }
25 -
26 - public function rejectTrack()
22 +
23 + public function initTrack()
27 24 {
28 - $notice_name = sanitize_text_field($_REQUEST['notice_name']);
29 - $action_type = sanitize_text_field($_REQUEST['action_type']);
30 - $notificationPref = get_option($this->initialConsentKey, array());
31 -
32 - if($action_type == 'permanent') {
33 - $notificationPref[$notice_name] = array(
34 - 'status' => 'no',
35 - 'email_subscribed' => 'no',
36 - 'timestamp' => time(),
37 - 'temp_disabled' => false
38 - );
39 - } else {
40 - $notificationPref[$notice_name] = array(
41 - 'status' => 'no',
42 - 'email_subscribed' => 'no',
43 - 'timestamp' => time(),
44 - 'temp_disabled' => true
45 - );
46 - }
25 + if ($this->adminNotice->shouldShowNotice('track_data_notice') && $this->isLocalhost()) {
26 + $this->showInitialConsent();
27 + }
28 + }
47 29
48 - update_option($this->initialConsentKey, $notificationPref, 'no');
30 + public function showInitialConsent()
31 + {
32 + $notice = $this->getInitialNotice();
33 + $this->adminNotice->addNotice($notice);
49 34 }
50 -
35 +
36 + public function rejectTrack()
37 + {
38 + $notice_name = sanitize_text_field(wpFluentForm('request')->get('notice_name'));
39 + $action_type = sanitize_text_field(wpFluentForm('request')->get('action_type'));
40 +
41 + $notificationPref = get_option($this->initialConsentKey, []);
42 +
43 + if ('permanent' == $action_type) {
44 + $notificationPref[$notice_name] = [
45 + 'status' => 'no',
46 + 'email_subscribed' => 'no',
47 + 'timestamp' => time(),
48 + 'temp_disabled' => false,
49 + ];
50 + } else {
51 + $notificationPref[$notice_name] = [
52 + 'status' => 'no',
53 + 'email_subscribed' => 'no',
54 + 'timestamp' => time(),
55 + 'temp_disabled' => true,
56 + ];
57 + }
58 +
59 + update_option($this->initialConsentKey, $notificationPref, 'no');
60 + }
61 +
51 62 public function sendInitialInfo()
52 63 {
53 - $email_enabled = sanitize_text_field($_REQUEST['email_enabled']);
54 - $notice_name = sanitize_text_field($_REQUEST['notice_name']);
55 -
56 - $notificationPref = get_option($this->initialConsentKey, array());
57 -
58 - $notificationPref[$notice_name] = array(
59 - 'status' => 'yes',
60 - 'email_subscribed' => ($email_enabled) ? 'yes' : 'no',
61 - 'timestamp' => time()
62 - );
63 -
64 + $email_enabled = sanitize_text_field(wpFluentForm('request')->get('email_enabled'));
65 + $notice_name = sanitize_text_field(wpFluentForm('request')->get('notice_name'));
66 +
67 + $notificationPref = get_option($this->initialConsentKey, []);
68 +
69 + $notificationPref[$notice_name] = [
70 + 'status' => 'yes',
71 + 'email_subscribed' => ($email_enabled) ? 'yes' : 'no',
72 + 'timestamp' => time(),
73 + ];
74 +
64 75 update_option($this->initialConsentKey, $notificationPref, 'no');
65 -
76 +
66 77 $logData = $this->getLogData();
67 78 $logData['email_subscribed'] = $email_enabled;
68 -
69 - try {
70 - wp_remote_post(
71 - $this->apiUrl,
72 - array(
73 - 'body' => array(
74 - 'plugin_log_id' => 1,
75 - 'plugin' => 'fluentform',
76 - 'data' => $logData
77 - )
78 - )
79 - );
80 - } catch (\Exception $exception) {
81 - // ...
82 - }
79 +
80 + try {
81 + wp_remote_post(
82 + $this->apiUrl,
83 + [
84 + 'body' => [
85 + 'plugin_log_id' => 1,
86 + 'plugin' => 'fluentform',
87 + 'data' => $logData,
88 + ],
89 + ]
90 + );
91 + } catch (\Exception $exception) {
92 + // ...
93 + }
83 94 }
84 -
95 +
85 96 private function getLogData()
86 97 {
87 - global $wpdb;
88 - //WP_DEBUG
89 - if ( defined('WP_DEBUG') && WP_DEBUG ){
90 - $debug = 1;
91 - } else {
92 - $debug = 0;
93 - }
98 + global $wpdb;
99 + //WP_DEBUG
100 + if (defined('WP_DEBUG') && WP_DEBUG) {
101 + $debug = 1;
102 + } else {
103 + $debug = 0;
104 + }
94 105
95 - //WPLANG
96 - if ( defined( 'WPLANG' ) && WPLANG ) {
97 - $lang = WPLANG;
98 - } else {
99 - $lang = 'default';
100 - }
106 + //WPLANG
107 + if (defined('WPLANG') && WPLANG) {
108 + $lang = WPLANG;
109 + } else {
110 + $lang = 'default';
111 + }
101 112
102 - $ip_address = '';
103 - if ( array_key_exists( 'SERVER_ADDR', $_SERVER ) ) {
104 - $ip_address = $_SERVER[ 'SERVER_ADDR' ];
105 - } else if ( array_key_exists( 'LOCAL_ADDR', $_SERVER ) ) {
106 - $ip_address = $_SERVER[ 'LOCAL_ADDR' ];
107 - }
108 -
109 - $host_name = gethostbyaddr( $ip_address );
113 + $ip_address = '';
110 114
111 - $active_plugins = (array) get_option( 'active_plugins', array() );
112 - $current_user = wp_get_current_user();
113 - if ( ! empty ( $current_user->user_email ) ) {
114 - $email = $current_user->user_email;
115 - } else {
116 - $email = get_option( 'admin_email' );
117 - }
118 -
119 - $data = array(
120 - 'version' => App::getVersion(),
121 - 'wp_version' => get_bloginfo('version'),
122 - 'multisite_enabled' => is_multisite(),
123 - 'server_type' => $_SERVER['SERVER_SOFTWARE'],
124 - 'php_version' => phpversion(),
125 - 'mysql_version' => $wpdb->db_version(),
126 - 'wp_memory_limit' => WP_MEMORY_LIMIT,
127 - 'wp_debug_mode' => $debug,
128 - 'wp_lang' => $lang,
129 - 'wp_max_upload_size' => size_format( wp_max_upload_size() ),
130 - 'php_max_post_size' => ini_get( 'post_max_size' ),
131 - 'hostname' => $host_name,
132 - 'smtp' => ini_get('SMTP'),
133 - 'smtp_port' => ini_get('smtp_port'),
134 - 'active_plugins' => $active_plugins,
135 - 'email' => $email,
136 - 'display_name' => $current_user->display_name,
137 - 'ip_address' => $ip_address,
138 - 'domain' => site_url()
139 - );
140 -
141 - return $data;
115 + $server = wpFluentForm('request')->server();
116 +
117 + if (array_key_exists('SERVER_ADDR', $server)) {
118 + $ip_address = sanitize_text_field($server['SERVER_ADDR']);
119 + } elseif (array_key_exists('LOCAL_ADDR', $server)) {
120 + $ip_address = sanitize_text_field($server['LOCAL_ADDR']);
121 + }
122 +
123 + $host_name = gethostbyaddr($ip_address);
124 +
125 + $active_plugins = (array) get_option('active_plugins', []);
126 + $current_user = wp_get_current_user();
127 + if (!empty($current_user->user_email)) {
128 + $email = $current_user->user_email;
129 + } else {
130 + $email = get_option('admin_email');
131 + }
132 +
133 + $data = [
134 + 'version' => FLUENTFORM_VERSION,
135 + 'wp_version' => get_bloginfo('version'),
136 + 'multisite_enabled' => is_multisite(),
137 + 'server_type' => sanitize_text_field($server['SERVER_SOFTWARE']),
138 + 'php_version' => phpversion(),
139 + 'mysql_version' => $wpdb->db_version(),
140 + 'wp_memory_limit' => WP_MEMORY_LIMIT,
141 + 'wp_debug_mode' => $debug,
142 + 'wp_lang' => $lang,
143 + 'wp_max_upload_size' => size_format(wp_max_upload_size()),
144 + 'php_max_post_size' => ini_get('post_max_size'),
145 + 'hostname' => $host_name,
146 + 'smtp' => ini_get('SMTP'),
147 + 'smtp_port' => ini_get('smtp_port'),
148 + 'active_plugins' => $active_plugins,
149 + 'email' => $email,
150 + 'display_name' => $current_user->display_name,
151 + 'ip_address' => $ip_address,
152 + 'domain' => site_url(),
153 + ];
154 +
155 + return $data;
142 156 }
143 157
144 - public function getInitialNotice()
145 - {
146 - return array(
147 - 'name' => 'track_data_notice',
148 - 'title' => __( 'Want to make Fluent Forms better with just one click?', 'ninja-forms' ),
149 - 'message' => 'We will collect a few server data if you permit us. It will help us troubleshoot any inconveniences you may face while using FluentForm, and guide us to add better features according to your usage. NO FORM SUBMISSION DATA WILL BE COLLECTED.<br/><input checked type="checkbox" id="ff-optin-send-email"> You can also send me Fluent Forms tips and tricks occasionally',
150 - 'links' => array(
151 - array(
152 - 'href' => admin_url('admin.php?page=fluent_forms'),
153 - 'btn_text' => 'Yes, I want to make Fluent Forms Better',
154 - 'btn_atts' => 'class="button-primary ff_track_yes" data-notice_name="track_data_notice"'
155 - ),
156 - array(
157 - 'href' => admin_url('admin.php?page=fluent_forms'),
158 - 'btn_text' => 'No, Please don\'t collect errors or other data',
159 - 'btn_atts' => 'class="button-secondary ff_nag_cross" data-notice_type="permanent" data-notice_name="track_data_notice"'
160 - )
161 - ),
162 - );
163 - }
164 -
165 -
166 - private function isLocalhost()
167 - {
168 - return in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) );
169 - }
158 + public function getInitialNotice()
159 + {
160 + return [
161 + 'name' => 'track_data_notice',
162 + 'title' => __('Want to make Fluent Forms better with just one click?', 'fluentform'),
163 + 'message' => 'We will collect a few server data if you permit us. It will help us troubleshoot any inconveniences you may face while using FluentForm, and guide us to add better features according to your usage. NO FORM SUBMISSION DATA WILL BE COLLECTED.<br/><input checked type="checkbox" id="ff-optin-send-email"> You can also send me Fluent Forms tips and tricks occasionally',
164 + 'links' => [
165 + [
166 + 'href' => admin_url('admin.php?page=fluent_forms'),
167 + 'btn_text' => 'Yes, I want to make Fluent Forms Better',
168 + 'btn_atts' => 'class="button-primary ff_track_yes" data-notice_name="track_data_notice"',
169 + ],
170 + [
171 + 'href' => admin_url('admin.php?page=fluent_forms'),
172 + 'btn_text' => 'No, Please don\'t collect errors or other data',
173 + 'btn_atts' => 'class="button-secondary ff_nag_cross" data-notice_type="permanent" data-notice_name="track_data_notice"',
174 + ],
175 + ],
176 + ];
177 + }
178 +
179 + private function isLocalhost()
180 + {
181 + return in_array(sanitize_text_field(wpFluentForm('request')->server('REMOTE_ADDR')), ['127.0.0.1', '::1']);
182 + }
170 183 }