示例#1
0
 /**
  * Send tracking rows if allowed
  *
  * @since 1.3.5
  */
 public static function send_rows()
 {
     if (false == self::tracking_allowed()) {
         return;
     }
     $last_row = self::get_last_sent_row();
     include_once CFCORE_PATH . 'classes/db/track.php';
     $highest = Caldera_Forms_Track::get_instance()->highest_id();
     if ($highest <= $last_row) {
         return;
     }
     $partial = false;
     if ($highest - $last_row > 1000) {
         $partial = true;
         $highest = $last_row - $highest;
     }
     $rows = self::prepare_rows_to_send($last_row, $highest);
     $body = array('url' => urlencode(home_url()), 'rows' => $rows, 'plugins' => Caldera_Forms_Support::get_plugins());
     $sent = self::send_to_api(self::$api_url . '/tracking', 'POST', $body);
     if (!is_numeric($sent)) {
         end($rows);
         $key = key($rows);
         update_option(self::$row_tracking_key, intval($rows[$key]));
     }
     if ($partial) {
         wp_schedule_single_event(time() + 59, 'caldera_forms_tracking_send_rows');
     }
 }