Ejemplo n.º 1
0
 public static function get_group_settings($settings, $group)
 {
     $options = qsot_options::instance();
     $o = apply_filters('qsot-woocommerce-settings', $options->get_ordered($group));
     $o = apply_filters('qsot-woocommerce-settings-' . $group, $o);
     return array_merge($settings, $o);
 }
Ejemplo n.º 2
0
 public static function current_colors()
 {
     $options = qsot_options::instance();
     $colors = $options->{'qsot-event-frontend-colors'};
     $defaults = self::default_colors();
     return wp_parse_args($colors, $defaults);
 }
Ejemplo n.º 3
0
 /**
  * Save settings
  */
 public function save()
 {
     $settings = $this->get_settings();
     WC_Admin_Settings::save_fields($settings);
     if (isset($_POST['qsot_frontend_css_form_bg'])) {
         // Save settings
         $colors = array();
         foreach (array('form_bg', 'form_border', 'form_action_bg', 'form_helper') as $k) {
             $colors[$k] = !empty($_POST['qsot_frontend_css_' . $k]) ? wc_format_hex($_POST['qsot_frontend_css_' . $k]) : '';
         }
         foreach (array('good_msg', 'bad_msg', 'remove') as $K) {
             foreach (array('_bg', '_border', '_text') as $k) {
                 $colors[$K . $k] = !empty($_POST['qsot_frontend_css_' . $K . $k]) ? wc_format_hex($_POST['qsot_frontend_css_' . $K . $k]) : '';
             }
         }
         foreach (array('past_calendar_item', 'calendar_item') as $K) {
             foreach (array('_bg', '_border', '_text', '_text_hover') as $k) {
                 $colors[$K . $k] = !empty($_POST['qsot_frontend_css_' . $K . $k]) ? wc_format_hex($_POST['qsot_frontend_css_' . $K . $k]) : '';
             }
         }
         // Check the colors.
         $valid_colors = true;
         foreach ($colors as $color) {
             if (!preg_match('/^#[a-f0-9]{6}$/i', $color)) {
                 $valid_colors = false;
                 WC_Admin_Settings::add_error(sprintf(__('Error saving the Frontend Styles, %s is not a valid color, please use only valid colors code.', 'opentickets-community-edition'), $color));
                 break;
             }
         }
         if ($valid_colors) {
             $old_colors = get_option('woocommerce_frontend_css_colors');
             $options = qsot_options::instance();
             $options->{'qsot-event-frontend-colors'} = $colors;
             if ($old_colors != $colors) {
                 QSOT::compile_frontend_styles();
             }
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Save settings
  */
 public function save()
 {
     $settings = $this->get_settings();
     $filtered_settings = $image_id_fields = array();
     // filter out the image ids types, because WC barfs on itself over them
     foreach ($settings as $field) {
         if ('qsot-image-ids' == $field['type']) {
             $image_id_fields[] = $field;
         } else {
             $filtered_settings[] = $field;
         }
     }
     // only allow wc to save the 'safe' ones
     WC_Admin_Settings::save_fields($filtered_settings);
     // handle any image id fields
     foreach ($image_id_fields as $field) {
         // if the field did not have any values passed, then skip it
         if (!isset($_POST[$field['id']])) {
             continue;
         }
         $raw_values = $_POST[$field['id']];
         // next sanitize the individual values for the field
         $values = array_filter(array_map('absint', $raw_values));
         // allow modification of the data
         $values = apply_filters('woocommerce_admin_settings_sanitize_option', $values, $field, $raw_values);
         $values = apply_filters('woocommerce_admin_settings_sanitize_option_' . $field['id'], $values, $field, $raw_values);
         // update the value
         update_option($field['id'], $values);
     }
     if (isset($_POST['qsot_frontend_css_form_bg'])) {
         // Save settings
         $colors = array();
         foreach (array('form_bg', 'form_border', 'form_action_bg', 'form_helper') as $k) {
             $colors[$k] = !empty($_POST['qsot_frontend_css_' . $k]) ? wc_format_hex($_POST['qsot_frontend_css_' . $k]) : '';
         }
         foreach (array('good_msg', 'bad_msg', 'remove') as $K) {
             foreach (array('_bg', '_border', '_text') as $k) {
                 $colors[$K . $k] = !empty($_POST['qsot_frontend_css_' . $K . $k]) ? wc_format_hex($_POST['qsot_frontend_css_' . $K . $k]) : '';
             }
         }
         foreach (array('past_calendar_item', 'calendar_item') as $K) {
             foreach (array('_bg', '_border', '_text', '_text_hover') as $k) {
                 $colors[$K . $k] = !empty($_POST['qsot_frontend_css_' . $K . $k]) ? wc_format_hex($_POST['qsot_frontend_css_' . $K . $k]) : '';
             }
         }
         // Check the colors.
         $valid_colors = true;
         foreach ($colors as $color) {
             if (!preg_match('/^#[a-f0-9]{6}$/i', $color)) {
                 $valid_colors = false;
                 WC_Admin_Settings::add_error(sprintf(__('Error saving the Frontend Styles, %s is not a valid color, please use only valid colors code.', 'opentickets-community-edition'), $color));
                 break;
             }
         }
         if ($valid_colors) {
             $old_colors = get_option('woocommerce_frontend_css_colors');
             $options = qsot_options::instance();
             $options->{'qsot-event-frontend-colors'} = $colors;
             if ($old_colors != $colors) {
                 QSOT::compile_frontend_styles();
             }
         }
     }
 }