Changeset 2600483
- Timestamp:
- 09/17/2021 11:18:43 AM (5 years ago)
- Location:
- crm-thrive
- Files:
-
- 31 added
- 6 edited
-
desktop.ini (added)
-
tags/1.13 (added)
-
tags/1.13/admin (added)
-
tags/1.13/admin/class-wsl-admin.php (added)
-
tags/1.13/admin/editor-panel.php (added)
-
tags/1.13/admin/partials (added)
-
tags/1.13/admin/partials/send_to_company_field.php (added)
-
tags/1.13/admin/partials/typeform_token_field.php (added)
-
tags/1.13/crm-thrive.php (added)
-
tags/1.13/helpers.php (added)
-
tags/1.13/includes (added)
-
tags/1.13/includes/assets (added)
-
tags/1.13/includes/assets/custom.js (added)
-
tags/1.13/includes/class-wsl-api.php (added)
-
tags/1.13/includes/class-wsl-beaver-api.php (added)
-
tags/1.13/includes/class-wsl-caldera-api.php (added)
-
tags/1.13/includes/class-wsl-cf7-api.php (added)
-
tags/1.13/includes/class-wsl-divi-api.php (added)
-
tags/1.13/includes/class-wsl-elementor-api.php (added)
-
tags/1.13/includes/class-wsl-formidable-api.php (added)
-
tags/1.13/includes/class-wsl-gravity-api.php (added)
-
tags/1.13/includes/class-wsl-ninja-api.php (added)
-
tags/1.13/includes/class-wsl-smartforms-api.php (added)
-
tags/1.13/includes/class-wsl-thriveform-api.php (added)
-
tags/1.13/includes/class-wsl-typeform-api.php (added)
-
tags/1.13/includes/class-wsl-wpbrizy-api.php (added)
-
tags/1.13/includes/class-wsl-wpf-api.php (added)
-
tags/1.13/includes/class-wsl-wpff-api.php (added)
-
tags/1.13/includes/helpers.php (added)
-
tags/1.13/includes/wsl-base.php (added)
-
tags/1.13/readme.txt (added)
-
trunk/crm-thrive.php (modified) (1 diff)
-
trunk/includes/class-wsl-api.php (modified) (1 diff)
-
trunk/includes/class-wsl-typeform-api.php (modified) (2 diffs)
-
trunk/includes/class-wsl-wpff-api.php (modified) (2 diffs)
-
trunk/includes/helpers.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
crm-thrive/trunk/crm-thrive.php
r2463359 r2600483 5 5 * Plugin URI: https://www.crmthrive.com/ 6 6 * Description: Save the leads to Thrive system generated by various form plugins. We currently support CF7, Ninja Forms, WP Forms, Gravity Forms and Elementor Builder. 7 * Version: 1.1 27 * Version: 1.13 8 8 * Author: Thrive 9 9 * Author URI: https://profiles.wordpress.org/crmthrive/ -
crm-thrive/trunk/includes/class-wsl-api.php
r2286305 r2600483 93 93 } 94 94 95 public function callTypeFormAuth($url, $authorization, $method = 'POST'){ 96 $headers = array(); 97 $headers['Accept'] = "application/json"; 98 $headers['Content-Type'] = "application/json"; 99 $headers['Authorization'] = $authorization; 100 101 $args = array( 102 'headers' => $headers, 103 'timeout' => '30', 104 'redirection' => '5', 105 'httpversion' => '1.0', 106 'blocking' => true, 107 ); 108 109 if($method == 'GET'){ 110 $response = wp_remote_get( $url, $args); 111 }elseif($method == 'POST'){ 112 $args['body'] = json_encode($post_data); 113 $response = wp_remote_post( $url, $args ); 114 }else{ 115 $args['method'] = $method; 116 $response = wp_remote_request( $url, $args ); 117 } 118 119 $body = wp_remote_retrieve_body( $response ); 120 return json_decode($body); 121 } 122 95 123 } 96 124 -
crm-thrive/trunk/includes/class-wsl-typeform-api.php
r2415572 r2600483 164 164 } 165 165 if(strpos(strtolower($field['name']), 'name') !== false){ 166 $value = $ field['name'];166 $value = $this->form_values[$field->name]; 167 167 $this->unset_additional_data($field['name']); 168 168 break; … … 256 256 foreach($formData[0]["answers"] as $k=>$v){ 257 257 if($v["type"] != "email"){ 258 $type = $v["field"]["ref"]; 258 259 $tags = explode('-' , $v["field"]["ref"]); 260 261 if(count($tags) > 4){ 262 $type = $v["type"]; 263 }else{ 264 $type = $v["field"]["ref"]; 265 } 259 266 }else{ 260 267 $type = $v["type"]; -
crm-thrive/trunk/includes/class-wsl-wpff-api.php
r2415572 r2600483 266 266 // Decode Data Object to Follow format Array structure 267 267 foreach($decode_obj['fields'] as $k=>$v){ 268 if(!empty($v['fields'])){ 269 if($v['element'] == 'address'){ 270 $field_names = $v['element']; 271 $field_type = $v['element']; 272 $add_2 = ' '.$formData[$v['attributes']['name']]['address_line_2']; 273 $check_add2 = (!empty($formData[$v['attributes']['name']]['address_line_1'])) ? $add_2:""; 274 275 $city = ' '.$formData[$v['attributes']['name']]['city']; 276 $check_city = (!empty($formData[$v['attributes']['name']]['city'])) ? $city:""; 277 278 $state = ', '.$formData[$v['attributes']['name']]['state']; 279 $check_state = (!empty($formData[$v['attributes']['name']]['state'])) ? $state:""; 280 281 $zip = ' '.$formData[$v['attributes']['name']]['zip']; 282 $check_zip = (!empty($formData[$v['attributes']['name']]['zip'])) ? $zip:""; 283 284 $country = ' '.$formData[$v['attributes']['name']]['country']; 285 $check_country = (!empty($formData[$v['attributes']['name']]['country'])) ? $country:""; 286 $form_values = $formData[$v['attributes']['name']]['address_line_1'].$check_add2.$check_city.$check_state.$check_zip.$check_country; 287 288 // Re-structure Array Fields 289 $fields[] = array( 290 "name" => $field_names, 291 "value" => $form_values, 292 "id" => $k, 293 "type" => $field_type, 294 "address1" => $formData[$v['attributes']['name']]['address_line_1'], 295 "address2" => $formData[$v['attributes']['name']]['address_line_2'], 296 "city" => $formData[$v['attributes']['name']]['city'], 297 "state" => $formData[$v['attributes']['name']]['state'], 298 "postal" => $formData[$v['attributes']['name']]['zip'], 299 "country" => $formData[$v['attributes']['name']]['country'] 300 ); 301 302 foreach($v['fields'] as $f_key=>$f_val){ 303 $fields[] = array( 304 "name" => $f_key, 305 "value" => $formData[$field_names][$f_key], 306 "id" => $k, 307 "type" => $f_key, 308 ); 268 if(isset($v['element']) && $v['element'] == 'container'){ 269 if(isset($v['columns']) && !empty($v['columns'])){ 270 foreach($v['columns'] as $col){ 271 if(isset($col['fields']) && !empty($col['fields'])){ 272 foreach($col['fields'] as $c_k=>$c_v){ 273 $fields[] = $this->get_field_rec($c_k,$c_v,$formData); 274 } 275 } 309 276 } 310 311 }else{ 312 $field_names = "Name"; 313 $field_type = 'name'; 314 $mdname = ' '.$formData[$v['attributes']['name']]['middle_name']; 315 $checkmidname = (!empty($formData[$v['attributes']['name']]['middle_name'])) ? $mdname:""; 316 $form_values = $formData[$v['attributes']['name']]['first_name'].$checkmidname.' '.$formData[$v['attributes']['name']]['last_name']; 317 318 // Re-structure Array Fields 319 $fields[] = array( 320 "name" => $field_names, 321 "value" => $form_values, 322 "id" => $k, 323 "type" => $field_type, 324 "first" => $formData[$v['attributes']['name']]['first_name'], 325 "middle" => $formData[$v['attributes']['name']]['middle_name'], 326 "last" => $formData[$v['attributes']['name']]['last_name'] 327 ); 328 } 329 277 } 330 278 }else{ 331 $field_names = $v['settings']['label']; 332 $form_values = $formData[$v['attributes']['name']]; 333 $field_type = ($v['element'] != "textarea" ) ? $v['attributes']['type']:"textarea"; 334 $names_values = ""; 335 336 // Re-structure Array Fields 337 $fields[] = array( 338 "name" => $field_names, 339 "value" => $form_values, 340 "id" => $k, 341 "type" => $field_type 342 ); 343 } 344 345 // Re-structure Form Settings Array 346 $fields_for_sub[] = array( 347 "id" => $k, 348 "type" => $field_type, 349 "label" => $v['settings']['label'] 350 ); 279 $fields[] = $this->get_field_rec($k,$v,$formData); 280 } 351 281 352 282 } … … 359 289 return $fields; 360 290 } 291 292 public function get_field_rec($k,$v,$formData){ 293 if(!empty($v['fields'])){ 294 if($v['element'] == 'address'){ 295 $field_names = $v['element']; 296 $field_type = $v['element']; 297 $add_2 = ' '.$formData[$v['attributes']['name']]['address_line_2']; 298 $check_add2 = (!empty($formData[$v['attributes']['name']]['address_line_1'])) ? $add_2:""; 299 300 $city = ' '.$formData[$v['attributes']['name']]['city']; 301 $check_city = (!empty($formData[$v['attributes']['name']]['city'])) ? $city:""; 302 303 $state = ', '.$formData[$v['attributes']['name']]['state']; 304 $check_state = (!empty($formData[$v['attributes']['name']]['state'])) ? $state:""; 305 306 $zip = ' '.$formData[$v['attributes']['name']]['zip']; 307 $check_zip = (!empty($formData[$v['attributes']['name']]['zip'])) ? $zip:""; 308 309 $country = ' '.$formData[$v['attributes']['name']]['country']; 310 $check_country = (!empty($formData[$v['attributes']['name']]['country'])) ? $country:""; 311 $form_values = $formData[$v['attributes']['name']]['address_line_1'].$check_add2.$check_city.$check_state.$check_zip.$check_country; 312 313 // Re-structure Array Fields 314 $field = array( 315 "name" => $field_names, 316 "value" => $form_values, 317 "id" => $k, 318 "type" => $field_type, 319 "address1" => $formData[$v['attributes']['name']]['address_line_1'], 320 "address2" => $formData[$v['attributes']['name']]['address_line_2'], 321 "city" => $formData[$v['attributes']['name']]['city'], 322 "state" => $formData[$v['attributes']['name']]['state'], 323 "postal" => $formData[$v['attributes']['name']]['zip'], 324 "country" => $formData[$v['attributes']['name']]['country'] 325 ); 326 327 foreach($v['fields'] as $f_key=>$f_val){ 328 $field = array( 329 "name" => $f_key, 330 "value" => $formData[$field_names][$f_key], 331 "id" => $k, 332 "type" => $f_key, 333 ); 334 } 335 336 }else{ 337 $field_names = "Name"; 338 $field_type = 'name'; 339 $mdname = ' '.$formData[$v['attributes']['name']]['middle_name']; 340 $checkmidname = (!empty($formData[$v['attributes']['name']]['middle_name'])) ? $mdname:""; 341 $form_values = $formData[$v['attributes']['name']]['first_name'].$checkmidname.' '.$formData[$v['attributes']['name']]['last_name']; 342 343 // Re-structure Array Fields 344 $field = array( 345 "name" => $field_names, 346 "value" => $form_values, 347 "id" => $k, 348 "type" => $field_type, 349 "first" => $formData[$v['attributes']['name']]['first_name'], 350 "middle" => $formData[$v['attributes']['name']]['middle_name'], 351 "last" => $formData[$v['attributes']['name']]['last_name'] 352 ); 353 } 354 355 }else{ 356 $field_names = $v['settings']['label']; 357 $form_values = $formData[$v['attributes']['name']]; 358 $field_type = ($v['element'] != "textarea" ) ? $v['attributes']['type']:"textarea"; 359 $names_values = ""; 360 361 // Re-structure Array Fields 362 $field = array( 363 "name" => $field_names, 364 "value" => $form_values, 365 "id" => $k, 366 "type" => $field_type 367 ); 368 } 369 370 return $field; 371 372 // Re-structure Form Settings Array 373 $fields_for_sub[] = array( 374 "id" => $k, 375 "type" => $field_type, 376 "label" => $v['settings']['label'] 377 ); 378 } 361 379 } -
crm-thrive/trunk/includes/helpers.php
r2415572 r2600483 70 70 71 71 function typeform_script() { 72 wp_register_script( "my_custom_script", plugin_dir_url( __FILE__ ).'assets/custom.js', array('jquery') );72 wp_register_script( "my_custom_script", plugin_dir_url( __FILE__ ).'assets/custom.js', array('jquery'), NULL, TRUE ); 73 73 wp_localize_script( 'my_custom_script', 'localize', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ))); 74 74 … … 76 76 wp_enqueue_script( 'my_custom_script' ); 77 77 } 78 add_action( ' admin_enqueue_scripts', 'typeform_script' );78 add_action( 'wp_enqueue_scripts', 'typeform_script' ); 79 79 80 80 function typeform_api($response_id){ … … 83 83 $token = $get_settings["typeform_api_key"]; 84 84 85 //setup the request, you can also use CURLOPT_URL 86 $ret_form = curl_init('https://api.typeform.com/forms'); 87 sleep(30); 88 curl_setopt($ret_form, CURLOPT_RETURNTRANSFER, true); 89 curl_setopt($ret_form, CURLOPT_HTTPHEADER, array( 90 'Content-Type: application/json', 91 'Authorization: Bearer ' . $token 92 )); 93 $data_form = curl_exec($ret_form); 94 $strip = stripslashes($data_form); 95 $decode_obj = json_decode($strip, true); 96 foreach($decode_obj["items"] as $key=>$v){ 97 $ch = curl_init('https://api.typeform.com/forms/'.$v["id"].'/responses?included_response_ids='.$response_id); 98 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 99 curl_setopt($ch, CURLOPT_HTTPHEADER, array( 100 'Content-Type: application/json', 101 'Authorization: Bearer ' . $token 102 )); 85 $api_obj = new Wsl_Api(); 86 $call_init = $api_obj->callTypeFormAuth('https://api.typeform.com/forms', 'Bearer ' . $token, $method = 'GET'); 103 87 104 $data = curl_exec($ch); 105 $strip_data = stripslashes($data); 106 $decode_obj_data = json_decode($strip_data, true); 107 if($decode_obj_data["total_items"] > 0){ 108 $data_items = $decode_obj_data["items"]; 88 $getItems = json_decode(json_encode($call_init), true); 89 90 foreach($getItems["items"] as $key=>$v){ 91 $ch = $api_obj->callTypeFormAuth('https://api.typeform.com/forms/'.$v["id"].'/responses?included_response_ids='.$response_id, 'Bearer ' . $token, $method = 'GET'); 92 $totalItems = json_decode(json_encode($ch), true); 93 if($totalItems["total_items"] > 0){ 94 $data_items = $totalItems["items"]; 109 95 return $data_items; 110 96 }else{ 111 97 return 'Response: false'; 112 98 } 113 114 $info = curl_getinfo($ch);115 curl_close($ch);116 99 } 117 118 $info_form = curl_getinfo($ret_form);119 curl_close($ret_form);120 100 } 121 101 -
crm-thrive/trunk/readme.txt
r2463359 r2600483 4 4 Requires at least: 2.0 5 5 Tested up to: 5.6 6 Stable tag: 1.1 26 Stable tag: 1.13 7 7 Requires PHP: 5.2.4 8 8 License: GPLv2 or later … … 72 72 = 1.12 = 73 73 * Formidable Forms Added 74 75 = 1.13 = 76 * Fixes for typeform and fluent forms
Note: See TracChangeset
for help on using the changeset viewer.