/**
  * Processes and saves options.
  * If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
  * @since 2.6.0
  * @return bool was anything saved?
  */
 public function process_admin_options()
 {
     if ($this->instance_id) {
         $this->init_instance_settings();
         $post_data = $this->get_post_data();
         foreach ($this->get_instance_form_fields() as $key => $field) {
             if ('title' !== $this->get_field_type($field)) {
                 try {
                     $this->instance_settings[$key] = $this->get_field_value($key, $field, $post_data);
                 } catch (Exception $e) {
                     $this->add_error($e->getMessage());
                 }
             }
         }
         return update_option($this->get_instance_option_key(), apply_filters('woocommerce_shipping_' . $this->id . '_instance_settings_values', $this->instance_settings, $this));
     } else {
         return parent::process_admin_options();
     }
 }
Example #2
0
 /**
  * Admin Panel Options Processing
  * - Saves the options to the DB
  *
  * @since 1.0.0
  * @return boolean|null
  */
 public function process_admin_options()
 {
     // Save regular options
     parent::process_admin_options();
     // Save templates
     if (isset($_POST['template_html_code'])) {
         $this->save_template($_POST['template_html_code'], $this->template_html);
     }
     if (isset($_POST['template_plain_code'])) {
         $this->save_template($_POST['template_plain_code'], $this->template_plain);
     }
 }
 /**
  * Init settings for gateways.
  */
 public function init_settings()
 {
     parent::init_settings();
     $this->enabled = !empty($this->settings['enabled']) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no';
 }
 /**
  * Admin Panel Options Processing
  * - Saves the options to the DB
  *
  * @since 1.0.0
  * @return boolean|null
  */
 public function process_admin_options()
 {
     // Save regular options
     parent::process_admin_options();
     // Save templates
     if (!empty($_POST['template_html_code']) && !empty($this->template_html)) {
         $saved = false;
         $file = get_stylesheet_directory() . '/woocommerce/' . $this->template_html;
         $code = stripslashes($_POST['template_html_code']);
         if (is_writeable($file)) {
             $f = fopen($file, 'w+');
             if ($f !== false) {
                 fwrite($f, $code);
                 fclose($f);
                 $saved = true;
             }
         }
         if (!$saved) {
             $redirect = add_query_arg('wc_error', urlencode(__('Could not write to template file.', 'woocommerce')));
             wp_redirect($redirect);
             exit;
         }
     }
     if (!empty($_POST['template_plain_code']) && !empty($this->template_plain)) {
         $saved = false;
         $file = get_stylesheet_directory() . '/woocommerce/' . $this->template_plain;
         $code = stripslashes($_POST['template_plain_code']);
         if (is_writeable($file)) {
             $f = fopen($file, 'w+');
             if ($f !== false) {
                 fwrite($f, $code);
                 fclose($f);
                 $saved = true;
             }
         }
         if (!$saved) {
             $redirect = add_query_arg('wc_error', __('Could not write to template file.', 'woocommerce'));
             wp_redirect($redirect);
             exit;
         }
     }
 }
Example #5
0
 /**
  * Admin Panel Options Processing.
  */
 public function process_admin_options($post_data = array())
 {
     if (empty($post_data)) {
         $post_data = $_POST;
     }
     // Save regular options
     parent::process_admin_options($post_data);
     // Save templates
     if (isset($_POST['template_html_code'])) {
         $this->save_template($post_data['template_html_code'], $this->template_html);
     }
     if (isset($_POST['template_plain_code'])) {
         $this->save_template($post_data['template_plain_code'], $this->template_plain);
     }
 }