/**
  * @param array $post
  * @param array $files
  */
 public function bind(array $post, array $files = array())
 {
     parent::bind($post, $files);
     // remove the old image
     if (isset($post['ab_remove_logo']) && file_exists(get_option('ab_settings_company_logo_path'))) {
         unlink(get_option('ab_settings_company_logo_path'));
         update_option('ab_settings_company_logo_path', '');
         update_option('ab_settings_company_logo_url', '');
     }
     // and add new
     if (isset($files['ab_settings_company_logo']) && $files['ab_settings_company_logo']['tmp_name']) {
         if (in_array($files['ab_settings_company_logo']['type'], array("image/gif", "image/jpeg", "image/png"))) {
             $movefile = wp_handle_upload($files['ab_settings_company_logo'], array('test_form' => false));
             if ($movefile) {
                 $imageResize = new AB_ImageResize($movefile['file']);
                 $imageResize->resizeImage(150, 150);
                 $imageResize->saveImage($movefile['file']);
                 $this->data['ab_settings_company_logo_path'] = $movefile['file'];
                 $this->data['ab_settings_company_logo_url'] = $movefile['url'];
                 // remove the old image
                 if (file_exists(get_option('ab_settings_company_logo_path'))) {
                     unlink(get_option('ab_settings_company_logo_path'));
                 }
             }
         }
     }
 }
 /**
  * @param array $post
  * @param array $files
  */
 public function bind(array $post, array $files = array())
 {
     if (isset($post['wp_user_id']) && !$post['wp_user_id']) {
         $post['wp_user_id'] = null;
     }
     parent::bind($post);
     if (isset($files['avatar']) && $files['avatar']['tmp_name']) {
         if (in_array($files['avatar']['type'], array("image/gif", "image/jpeg", "image/png"))) {
             $movefile = wp_handle_upload($files['avatar'], array('test_form' => false));
             if ($movefile) {
                 $imageResize = new AB_ImageResize($movefile['file']);
                 $imageResize->resizeImage(80, 80);
                 $imageResize->saveImage($movefile['file'], 80);
                 $this->data['avatar_path'] = $movefile['file'];
                 $this->data['avatar_url'] = $movefile['url'];
             }
         }
     }
 }