PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 1.2.4
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v1.2.4
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 3.6.66 All 195 releases
fluentform / app / Modules / Track / TrackModule.php

TrackModule.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 1.2.4, at app/Modules/Track/TrackModule.php

161 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace FluentForm\App\Modules\Track;
2
3 use FluentForm\AdminNotice;
4 use FluentForm\App;
5 use FluentForm\Framework\Helpers\ArrayHelper;
6
7 class TrackModule
8 {
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')) {
16 $this->showInitialConsent();
17 }
18 }
19
20 public function showInitialConsent()
21 {
22 $notice = $this->getInitialNotice();
23 AdminNotice::addNotice($notice);
24 }
25
26 public function rejectTrack()
27 {
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 }
47 update_option($this->initialConsentKey, $notificationPref);
48 }
49
50 public function sendInitialInfo()
51 {
52 $email_enabled = sanitize_text_field($_REQUEST['email_enabled']);
53 $notice_name = sanitize_text_field($_REQUEST['notice_name']);
54
55 $notificationPref = get_option($this->initialConsentKey, array());
56
57 $notificationPref[$notice_name] = array(
58 'status' => 'yes',
59 'email_subscribed' => ($email_enabled) ? 'yes' : 'no',
60 'timestamp' => time()
61 );
62
63 update_option($this->initialConsentKey, $notificationPref);
64
65 $logData = $this->getLogData();
66 $logData['email_subscribed'] = $email_enabled;
67 try {
68 wp_remote_post(
69 $this->apiUrl,
70 array(
71 'body' => array(
72 'plugin_log_id' => 1,
73 'plugin' => 'fluentform',
74 'data' => $logData
75 )
76 )
77 );
78 } catch (\Exception $exception) {
79
80 }
81 }
82
83 private function getLogData()
84 {
85 global $wpdb;
86 //WP_DEBUG
87 if ( defined('WP_DEBUG') && WP_DEBUG ){
88 $debug = 1;
89 } else {
90 $debug = 0;
91 }
92
93 //WPLANG
94 if ( defined( 'WPLANG' ) && WPLANG ) {
95 $lang = WPLANG;
96 } else {
97 $lang = 'default';
98 }
99
100 $ip_address = '';
101 if ( array_key_exists( 'SERVER_ADDR', $_SERVER ) ) {
102 $ip_address = $_SERVER[ 'SERVER_ADDR' ];
103 } else if ( array_key_exists( 'LOCAL_ADDR', $_SERVER ) ) {
104 $ip_address = $_SERVER[ 'LOCAL_ADDR' ];
105 }
106
107 $host_name = gethostbyaddr( $ip_address );
108
109 $active_plugins = (array) get_option( 'active_plugins', array() );
110 $current_user = wp_get_current_user();
111 if ( ! empty ( $current_user->user_email ) ) {
112 $email = $current_user->user_email;
113 } else {
114 $email = get_option( 'admin_email' );
115 }
116 $data = array(
117 'version' => App::getVersion(),
118 'wp_version' => get_bloginfo('version'),
119 'multisite_enabled' => is_multisite(),
120 'server_type' => $_SERVER['SERVER_SOFTWARE'],
121 'php_version' => phpversion(),
122 'mysql_version' => $wpdb->db_version(),
123 'wp_memory_limit' => WP_MEMORY_LIMIT,
124 'wp_debug_mode' => $debug,
125 'wp_lang' => $lang,
126 'wp_max_upload_size' => size_format( wp_max_upload_size() ),
127 'php_max_post_size' => ini_get( 'post_max_size' ),
128 'hostname' => $host_name,
129 'smtp' => ini_get('SMTP'),
130 'smtp_port' => ini_get('smtp_port'),
131 'active_plugins' => $active_plugins,
132 'email' => $email,
133 'display_name' => $current_user->display_name,
134 'ip_address' => $ip_address,
135 'domain' => site_url()
136 );
137
138 return $data;
139 }
140
141 public function getInitialNotice()
142 {
143 return array(
144 'name' => 'track_data_notice',
145 'title' => __( 'Want to make FluentForm better with just one click?', 'ninja-forms' ),
146 '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 FluentForm tips and tricks occasionally',
147 'links' => array(
148 array(
149 'href' => admin_url('admin.php?page=fluent_forms'),
150 'btn_text' => 'Yes, I want to make FluentForm Better',
151 'btn_atts' => 'class="button-primary ff_track_yes" data-notice_name="track_data_notice"'
152 ),
153 array(
154 'href' => admin_url('admin.php?page=fluent_forms'),
155 'btn_text' => 'No, Please don\'t collect errors or other data',
156 'btn_atts' => 'class="button-secondary ff_nag_cross" data-notice_type="permanent" data-notice_name="track_data_notice"'
157 )
158 ),
159 );
160 }
161 }