PluginProbe
GetResponse Forms by Optin Cat / 2.0.2
GetResponse Forms by Optin Cat v2.0.2
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 +35 -38 1.4.02.0.2 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,39 +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'] );
83 +
84 + $nonceVerified = wp_verify_nonce( $nonce, 'fca_eoi_activity') == 1;
85 + $idVerified = is_int( $form_id ) && $form_id > 0;
86 +
87 + if ( $nonceVerified && $idVerified ) {
85 88
86 - public function track_activity( $request ) {
87 - if ( empty( $_REQUEST['fca_eoi_track_form_id'] ) ) {
88 - return $request;
89 - }
90 -
91 - require_once $this->settings['plugin_dir'] . 'includes/classes/RobotDetector/RobotDetector.php';
92 -
93 - $form_id = (int) $_REQUEST['fca_eoi_track_form_id'];
94 - if ( get_post($form_id) ) {
89 + require_once FCA_EOI_PLUGIN_DIR . 'includes/classes/RobotDetector/RobotDetector.php';
95 90 $robot_detector = new RobotDetector();
96 - if ( ! $robot_detector->is_robot() ) {
97 - if ( is_user_logged_in() ) {
98 - /* USER IS LOGGED IN , DON'T COUNT AS IMPRESSION */
99 - }else {
100 - $this->add_impression( $form_id );
101 - }
102 -
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 );
103 95 }
104 - }
105 -
106 - exit;
96 + }
97 + wp_send_json_error();
98 +
107 99 }
108 100
109 101 public function format_column_text( $column_name, $value ) {
110 102 if ( $column_name == 'conversion_rate' ) {
@@ -218,17 +210,22 @@
218 210 $wpdb->delete( $this->table_name, array( 'form_id' => $form_id ), '%d' );
219 211 }
220 212
221 213 private function add_activity( $form_id, $activity_type ) {
222 - global $wpdb;
214 +
215 + if ( !defined ( 'FCA_EOI_DISABLE_STATS_TRACKING' )) {
216 +
217 + global $wpdb;
223 218
224 - $time = current_time( 'mysql', 1 );
225 - $wpdb->insert( $this->table_name, array(
226 - 'form_id' => $form_id,
227 - 'type' => $activity_type,
228 - 'timestamp' => $time,
229 - 'day' => $time
230 - ), 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 + }
231 228 }
232 229
233 230 private function get_form_stats_query( $activity_type, $day_interval ) {
234 231 return $this->get_stats_query( 'form_id', $activity_type, $day_interval );