Advertisement
verygoodplugins

Untitled

May 13th, 2016
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1.     public function sync_tags() {
  2.        
  3.         if( ! $this->params) $this->get_params($api_url, $api_key );
  4.  
  5.         $available_tags = array();
  6.         $offset = 0;
  7.         $continue = true;
  8.  
  9.         while ($continue == true) {
  10.  
  11.             $request = "https://api.ontraport.com/1/objects?objectID=14&start=" . $offset;
  12.             $response = wp_remote_get($request, $this->params);
  13.             $body_json = json_decode($response['body'], true);
  14.            
  15.             foreach ($body_json['data'] as $row){                      
  16.                 $available_tags[$row['tag_id']] = $row['tag_name'];
  17.             }
  18.  
  19.             if(count($body_json['data'] < 50))
  20.                 $continue = false;
  21.  
  22.             $offset = $offset + 50;
  23.  
  24.         }
  25.        
  26.  
  27.         wp_fusion()->settings->set( 'available_tags', $available_tags );
  28.  
  29.         return $available_tags;
  30.  
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement