PluginProbe
GetResponse Forms by Optin Cat / 2.4.1
GetResponse Forms by Optin Cat v2.4.1
1.3.4 1.3.5 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 2.0.0 All 36 releases
← All changes | includes/eoi-activity.php +36 -31 1.3.52.4.1 View file →
@@ -38,10 +38,13 @@
38 38 ),
39 39 'period' => __( 'Last %d days' ),
40 40 'all_time' => __( 'All time' )
41 41 );
42 -
43 - add_filter( 'request', array( $this, 'track_activity' ) );
42 +
43 + if ( !defined ( 'FCA_EOI_DISABLE_STATS_TRACKING' )) {
44 + add_action( 'wp_ajax_fca_eoi_activity', array( $this, 'track_activity' ) );
45 + add_action( 'wp_ajax_nopriv_fca_eoi_activity', array( $this, 'track_activity' ) );
46 + }
44 47 }
45 48
46 49 public function get_text( $name, $category = null, $parameters = array() ) {
47 50 $plain_text = $this->text[ $name ];
@@ -72,31 +75,28 @@
72 75 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
73 76 dbDelta( $sql );
74 77 }
75 78
76 - public function get_tracking_code( $form_id, $escape = true ) {
77 - ob_start();
78 - ?>
79 - jQuery.post( <?php echo json_encode( trailingslashit( get_home_url() ) ) ?>, {
80 - 'fca_eoi_track_form_id': <?php echo $escape ? json_encode( $form_id ) : $form_id ?>
81 - } );
82 - <?php
83 - return ob_get_clean();
84 - }
79 + public function track_activity() {
80 +
81 + $nonce = sanitize_text_field( $_REQUEST['nonce'] );
82 + $form_id = intval( $_REQUEST['form_id'] );
85 83
86 - public function track_activity( $request ) {
87 - if ( empty( $_REQUEST['fca_eoi_track_form_id'] ) ) {
88 - return $request;
89 - }
84 + $nonceVerified = ( wp_verify_nonce( $nonce, 'fca_eoi_activity') OR wp_verify_nonce( $nonce, 'fca_eoi_submit_form') );
85 + $idVerified = is_int( $form_id ) && $form_id > 0;
86 +
87 + if ( $nonceVerified && $idVerified ) {
90 88
91 - require_once $this->settings['plugin_dir'] . 'includes/classes/RobotDetector/RobotDetector.php';
92 -
93 - $robot_detector = new RobotDetector();
94 - if ( ! $robot_detector->is_robot() ) {
95 - $this->add_impression( (int) $_REQUEST['fca_eoi_track_form_id'] );
96 - }
97 -
98 - exit;
89 + require_once FCA_EOI_PLUGIN_DIR . 'includes/classes/RobotDetector/RobotDetector.php';
90 + $robot_detector = new RobotDetector();
91 +
92 + if ( get_post( $form_id ) && !is_user_logged_in() && !$robot_detector->is_robot() ) {
93 + $this->add_impression( $form_id );
94 + wp_send_json_success( $form_id );
95 + }
96 + }
97 + wp_send_json_error();
98 +
99 99 }
100 100
101 101 public function format_column_text( $column_name, $value ) {
102 102 if ( $column_name == 'conversion_rate' ) {
@@ -210,17 +210,22 @@
210 210 $wpdb->delete( $this->table_name, array( 'form_id' => $form_id ), '%d' );
211 211 }
212 212
213 213 private function add_activity( $form_id, $activity_type ) {
214 - global $wpdb;
214 +
215 + if ( !defined ( 'FCA_EOI_DISABLE_STATS_TRACKING' )) {
216 +
217 + global $wpdb;
215 218
216 - $time = current_time( 'mysql', 1 );
217 - $wpdb->insert( $this->table_name, array(
218 - 'form_id' => $form_id,
219 - 'type' => $activity_type,
220 - 'timestamp' => $time,
221 - 'day' => $time
222 - ), array( '%d', '%s', '%s', '%s' ) );
219 + $time = current_time( 'mysql', 1 );
220 + $wpdb->insert( $this->table_name, array(
221 + 'form_id' => $form_id,
222 + 'type' => $activity_type,
223 + 'timestamp' => $time,
224 + 'day' => $time
225 + ), array( '%d', '%s', '%s', '%s' ) );
226 +
227 + }
223 228 }
224 229
225 230 private function get_form_stats_query( $activity_type, $day_interval ) {
226 231 return $this->get_stats_query( 'form_id', $activity_type, $day_interval );