示例#1
1
 /**
  * @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"))) {
             $uploaded = wp_handle_upload($files['ab_settings_company_logo'], array('test_form' => false));
             if ($uploaded) {
                 $editor = wp_get_image_editor($uploaded['file']);
                 $editor->resize(200, 200);
                 $editor->save($uploaded['file']);
                 $this->data['ab_settings_company_logo_path'] = $uploaded['file'];
                 $this->data['ab_settings_company_logo_url'] = $uploaded['url'];
                 // Remove 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())
 {
     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'));
                 }
             }
         }
     }
 }
 public function save()
 {
     if ($this->isNew()) {
         $colors = array('#B0171F', '#DA70D6', '#BF3EFF', '#8470FF', '#4876FF', '#63B8FF', '#00B2EE', '#00F5FF', '#00C78C', '#BDFCC9', '#B4EEB4', '#7CFC00', '#ADFF2F', '#FFFFF0', '#CDCDB4', '#FFFF00', '#FFF68F', '#F0E68C', '#E3CF57', '#FFEBCD', '#FF8C00', '#EE4000', '#FA8072', '#F08080', '#CD0000');
         // when adding new service - set its color randomly
         $this->data['color'] = $colors[mt_rand(0, count($colors) - 1)];
     }
     $this->data['capacity'] = 1;
     return parent::save();
 }
示例#4
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::$entity_class = 'AB_Staff';
     parent::__construct();
 }
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::$entity_class = 'AB_Category';
     parent::__construct();
 }
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::$entity_class = 'AB_CustomerAppointment';
     parent::__construct();
 }
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::$entity_class = 'AB_StaffScheduleItem';
     parent::__construct();
 }
示例#8
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::$entity_class = 'AB_Coupon';
     parent::__construct();
 }