Advertisement
verygoodplugins

Untitled

May 12th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1.     public function sync_crm_fields() {
  2.         // Load built in fields first
  3. //      require dirname(__FILE__) . '/admin/ontraport-fields.php';
  4.  
  5. //      $built_in_fields = array();
  6.  
  7. //      foreach( $ontraport_fields as $index => $data ) {
  8. //          $built_in_fields[$data['crm_field']] = $data['crm_label'];
  9. //      }
  10.  
  11.         //asort($built_in_fields);
  12.        
  13.         if( !$this->params)
  14.             $this->get_params();
  15.  
  16.         // Get custom fields
  17.         $crm_fields = array();
  18.  
  19.         $request = "https://api.ontraport.com/1/objects/meta?format=byId&objectID=0";  
  20.         $response = wp_remote_get($request, $this->params);
  21.        
  22.         $body = json_decode(wp_remote_retrieve_body( $response ));
  23.  
  24.         error_log(print_r($body, true));
  25.  
  26.         foreach($body['data']['fields'] as $key => $field_data) {
  27.             $crm_fields[$key] = $field_data['alias'];
  28.         }
  29.  
  30.         asort($crm_fields);
  31.  
  32.         wp_fusion()->settings->set('crm_fields', $crm_fields);
  33.  
  34.         return $crm_fields;
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement