save_fields() 공개 정적인 메소드

Loops though the woocommerce options array and outputs each field.
public static save_fields ( array $options, array $data = null ) : boolean
$options array Options array to output
$data array Optional. Data to use for saving. Defaults to $_POST.
리턴 boolean
 /**
  * Save settings.
  *
  * Save settings based on WooCommerce save_fields() method.
  *
  * @since 1.0.0
  */
 public function update_options()
 {
     global $current_section;
     if ($current_section == 'shipping_validation') {
         WC_Admin_Settings::save_fields($this->get_settings());
     }
 }
        /**
         * Save settings.
         *
         * @since 1.0.0
         */
        public function save() {

            global $current_section;

            $settings = $this->get_settings( $current_section );
            WC_Admin_Settings::save_fields( $settings );

        }
 /**
  * Save settings
  */
 public function save()
 {
     global $current_section;
     $settings = $this->get_settings();
     WC_Admin_Settings::save_fields($settings);
     if ($current_section) {
         do_action('woocommerce_update_options_' . $this->id . '_' . $current_section);
     }
 }
 public function save_settings()
 {
     WC_Admin_Settings::save_fields($this->settings);
     $is_api_working = $this->check_api() ? 1 : 0;
     update_option(WC_SiftScience_Options::$is_api_setup, $is_api_working);
     if ($is_api_working === 1) {
         WC_Admin_Settings::add_message('API is correctly configured');
     } else {
         WC_Admin_Settings::add_error('API settings are broken');
     }
 }
예제 #5
0
 /**
  * Save settings
  */
 public function save()
 {
     global $current_section, $wpdb;
     if (!$current_section) {
         $settings = $this->get_settings();
         WC_Admin_Settings::save_fields($settings);
     } elseif (!empty($_POST['tax_rate_country'])) {
         $this->save_tax_rates();
     }
     $wpdb->query("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE ('_transient_wc_tax_rates_%') OR `option_name` LIKE ('_transient_timeout_wc_tax_rates_%')");
 }
 /**
  * Save settings.
  */
 public function save()
 {
     global $current_section, $wpdb;
     if (!$current_section) {
         $settings = $this->get_settings();
         WC_Admin_Settings::save_fields($settings);
     } elseif (!empty($_POST['tax_rate_country'])) {
         $this->save_tax_rates();
     }
     WC_Cache_Helper::incr_cache_prefix('taxes');
 }
예제 #7
0
 /**
  * Save settings
  */
 public function save()
 {
     global $current_section;
     if ($current_section == '') {
         $settings = $this->rf_genaral_setting();
     } elseif ($current_section == 'email_template') {
         $settings = $this->rf_email_template_setting();
     } else {
         $settings = $this->rf_social_share_setting();
     }
     WC_Admin_Settings::save_fields($settings);
 }
 /**
  * Save settings
  */
 public function save()
 {
     global $current_section;
     $settings = $this->get_settings();
     WC_Admin_Settings::save_fields($settings);
     if ($current_section == 'lists') {
         // Each list that has been ticked will be saved.
         if (isset($_POST['checkout_lists'])) {
             $checkout_lists = $_POST['checkout_lists'];
             update_option('mailpoet_woocommerce_subscribe_too', $checkout_lists);
         } else {
             delete_option('mailpoet_woocommerce_subscribe_too');
         }
     }
 }
 /**
  * Save settings.
  */
 public function save()
 {
     global $current_section;
     if (!$current_section) {
         WC_Admin_Settings::save_fields($this->get_settings());
     } else {
         $wc_emails = WC_Emails::instance();
         if (in_array($current_section, array_map('sanitize_title', array_keys($wc_emails->get_emails())))) {
             foreach ($wc_emails->get_emails() as $email_id => $email) {
                 if ($current_section === sanitize_title($email_id)) {
                     do_action('woocommerce_update_options_' . $this->id . '_' . $email->id);
                 }
             }
         } else {
             do_action('woocommerce_update_options_' . $this->id . '_' . $current_section);
         }
     }
 }
 /**
  * Save settings.
  */
 public function save()
 {
     $settings = $this->get_settings();
     WC_Admin_Settings::save_fields($settings);
 }
예제 #11
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();
             }
         }
     }
 }
예제 #12
0
/**
 * Update all settings which are passed.
 *
 * @access public
 * @param array $options
 * @return void
 */
function woocommerce_update_options($options)
{
    if (!class_exists('WC_Admin_Settings')) {
        include 'class-wc-admin-settings.php';
    }
    WC_Admin_Settings::save_fields($options);
}
예제 #13
0
/**
 * Update this plugin's WC Settings
 *
 * Hooks into WC's settings api
 * which allows for building, saving, and retrieval of options
 *
 * @since 3.0.0
 */
function update_settings()
{
    \WC_Admin_Settings::save_fields(get_settings());
}
 /**
  * Save settings.
  */
 public function save()
 {
     global $current_section;
     switch ($current_section) {
         case 'options':
             WC_Admin_Settings::save_fields($this->get_settings());
             break;
         case 'classes':
         case '':
             break;
         default:
             $wc_shipping = WC_Shipping::instance();
             foreach ($wc_shipping->get_shipping_methods() as $method_id => $method) {
                 if (in_array($current_section, array($method->id, sanitize_title(get_class($method))))) {
                     do_action('woocommerce_update_options_' . $this->id . '_' . $method->id);
                 }
             }
             break;
     }
     // Increments the transient version to invalidate cache
     WC_Cache_Helper::get_transient_version('shipping', true);
 }
예제 #15
0
/**
 * Update all settings which are passed.
 *
 * @param array $options
 * @param array $data
 */
function woocommerce_update_options($options, $data = null)
{
    if (!class_exists('WC_Admin_Settings')) {
        include dirname(__FILE__) . '/class-wc-admin-settings.php';
    }
    WC_Admin_Settings::save_fields($options, $data);
}
예제 #16
0
 public function print_plugin_options()
 {
     wp_enqueue_script('jquery');
     wp_enqueue_script('jquery-ui-core');
     wp_enqueue_script('jquery-ui-dialog');
     wp_enqueue_style('wp-color-picker');
     wp_enqueue_script('wp-color-picker');
     if (isset($_POST['woof_settings'])) {
         WC_Admin_Settings::save_fields($this->get_options());
         //+++
         if (class_exists('SitePress')) {
             $lang = ICL_LANGUAGE_CODE;
             if (isset($_POST['woof_settings']['wpml_tax_labels']) and !empty($_POST['woof_settings']['wpml_tax_labels'])) {
                 $translations_string = $_POST['woof_settings']['wpml_tax_labels'];
                 $translations_string = explode(PHP_EOL, $translations_string);
                 $translations = array();
                 if (!empty($translations_string) and is_array($translations_string)) {
                     foreach ($translations_string as $line) {
                         if (empty($line)) {
                             continue;
                         }
                         $line = explode(':', $line);
                         if (!isset($translations[$line[0]])) {
                             $translations[$line[0]] = array();
                         }
                         $tmp = explode('^', $line[1]);
                         $translations[$line[0]][$tmp[0]] = $tmp[1];
                     }
                 }
                 $_POST['woof_settings']['wpml_tax_labels'] = $translations;
             }
         }
         //+++
         update_option('woof_settings', $_POST['woof_settings']);
         $this->init_settings();
     }
     //+++
     wp_enqueue_script('jquery-ui-tabs');
     wp_enqueue_script('woof', WOOF_LINK . 'js/plugin_options.js', array('jquery', 'jquery-ui-core', 'jquery-ui-sortable'));
     wp_enqueue_style('woof', WOOF_LINK . 'css/plugin_options.css');
     $args = array("woof_settings" => get_option('woof_settings', array()));
     echo $this->render_html(WOOF_PATH . 'views/plugin_options.php', $args);
 }
 /**
  * Save settings
  */
 public function save()
 {
     $settings = $this->get_settings();
     WC_Admin_Settings::save_fields($settings);
     if (isset($_POST['woocommerce_frontend_css_primary'])) {
         // Save settings
         $primary = !empty($_POST['woocommerce_frontend_css_primary']) ? wc_format_hex($_POST['woocommerce_frontend_css_primary']) : '';
         $secondary = !empty($_POST['woocommerce_frontend_css_secondary']) ? wc_format_hex($_POST['woocommerce_frontend_css_secondary']) : '';
         $highlight = !empty($_POST['woocommerce_frontend_css_highlight']) ? wc_format_hex($_POST['woocommerce_frontend_css_highlight']) : '';
         $content_bg = !empty($_POST['woocommerce_frontend_css_content_bg']) ? wc_format_hex($_POST['woocommerce_frontend_css_content_bg']) : '';
         $subtext = !empty($_POST['woocommerce_frontend_css_subtext']) ? wc_format_hex($_POST['woocommerce_frontend_css_subtext']) : '';
         $colors = array('primary' => $primary, 'secondary' => $secondary, 'highlight' => $highlight, 'content_bg' => $content_bg, 'subtext' => $subtext);
         // 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.', 'woocommerce'), $color));
                 break;
             }
         }
         if ($valid_colors) {
             $old_colors = get_option('woocommerce_frontend_css_colors');
             update_option('woocommerce_frontend_css_colors', $colors);
             if ($old_colors != $colors) {
                 woocommerce_compile_less_styles();
             }
         }
     }
 }
 /**
  * Update a single setting in a group.
  * @since  2.7.0
  * @param  WP_REST_Request $request
  * @return WP_Error|WP_REST_Response
  */
 public function update_item($request)
 {
     $setting = $this->get_setting($request['group'], $request['id']);
     if (is_wp_error($setting)) {
         return $setting;
     }
     if (is_callable(array($this, 'validate_setting_' . $setting['type'] . '_field'))) {
         $value = $this->{'validate_setting_' . $setting['type'] . '_field'}($request['value'], $setting);
     } else {
         $value = $this->validate_setting_text_field($request['value'], $setting);
     }
     if (is_wp_error($value)) {
         return $value;
     }
     if (is_array($setting['option_key'])) {
         $setting['value'] = $value;
         $option_key = $setting['option_key'];
         $prev = get_option($option_key[0]);
         $prev[$option_key[1]] = $request['value'];
         update_option($option_key[0], $prev);
     } else {
         $update_data = array();
         $update_data[$setting['option_key']] = $value;
         $setting['value'] = $value;
         WC_Admin_Settings::save_fields(array($setting), $update_data);
     }
     $response = $this->prepare_item_for_response($setting, $request);
     return rest_ensure_response($response);
 }
 /**
  * Save settings.
  */
 public function save()
 {
     global $current_section;
     $wc_shipping = WC_Shipping::instance();
     if (!$current_section) {
         WC_Admin_Settings::save_fields($this->get_settings());
         $wc_shipping->process_admin_options();
     } else {
         foreach ($wc_shipping->get_shipping_methods() as $method_id => $method) {
             if ($current_section === sanitize_title(get_class($method))) {
                 do_action('woocommerce_update_options_' . $this->id . '_' . $method->id);
             }
         }
     }
     // Increments the transient version to invalidate cache
     WC_Cache_Helper::get_transient_version('shipping', true);
 }
예제 #20
0
 public function print_plugin_options()
 {
     if (isset($_POST['woof_settings'])) {
         WC_Admin_Settings::save_fields($this->get_options());
         //+++
         if (class_exists('SitePress')) {
             $lang = ICL_LANGUAGE_CODE;
             if (isset($_POST['woof_settings']['wpml_tax_labels']) and !empty($_POST['woof_settings']['wpml_tax_labels'])) {
                 $translations_string = $_POST['woof_settings']['wpml_tax_labels'];
                 $translations_string = explode(PHP_EOL, $translations_string);
                 $translations = array();
                 if (!empty($translations_string) and is_array($translations_string)) {
                     foreach ($translations_string as $line) {
                         if (empty($line)) {
                             continue;
                         }
                         $line = explode(':', $line);
                         if (!isset($translations[$line[0]])) {
                             $translations[$line[0]] = array();
                         }
                         $tmp = explode('^', $line[1]);
                         $translations[$line[0]][$tmp[0]] = $tmp[1];
                     }
                 }
                 $_POST['woof_settings']['wpml_tax_labels'] = $translations;
             }
         }
         //+++
         update_option('woof_settings', $_POST['woof_settings']);
         $this->settings = $_POST['woof_settings'];
         $this->init_extensions();
         wp_cache_flush();
         //wp_redirect(admin_url('admin.php?page=wc-settings&tab=woof&settings_saved=1'));
     }
     //+++
     wp_enqueue_script('media-upload');
     wp_enqueue_style('thickbox');
     wp_enqueue_script('thickbox');
     wp_enqueue_script('woof_modernizr', WOOF_LINK . 'js/modernizr.js');
     wp_enqueue_script('woof', WOOF_LINK . 'js/plugin_options.js', array('jquery', 'jquery-ui-core', 'jquery-ui-sortable'));
     $args = array("woof_settings" => $this->settings, "extensions" => $this->get_ext_directories());
     echo $this->render_html(WOOF_PATH . 'views/plugin_options.php', $args);
 }
 /**
  * Save settings
  *
  * @version 2.2.6
  */
 function save()
 {
     global $current_section;
     $settings = $this->get_settings($current_section);
     WC_Admin_Settings::save_fields($settings);
     echo apply_filters('get_wc_jetpack_plus_message', '', 'global');
     do_action('woojetpack_after_settings_save', $this->get_sections(), $current_section);
 }
 /**
  * Save settings
  */
 public function save()
 {
     global $current_section;
     $settings = array();
     if ($this->get_sections()) {
         foreach ($this->get_sections() as $section => $name) {
             if ($section == $current_section) {
                 $settings = apply_filters('woocommerce_gzd_get_settings_' . $section, $this->get_settings());
             }
         }
     }
     if (empty($settings)) {
         return;
     }
     do_action('woocommerce_gzd_before_save_section_' . $current_section, $settings);
     if (apply_filters('wc_germanized_show_settings_' . $current_section, true)) {
         WC_Admin_Settings::save_fields($settings);
     }
     do_action('woocommerce_gzd_after_save_section_' . $current_section, $settings);
 }
예제 #23
0
 /**
  * Save settings
  */
 public function save()
 {
     global $current_section;
     if (!$current_section) {
         $settings = $this->get_settings();
         WC_Admin_Settings::save_fields($settings);
     } else {
         // Init email classes
         WC()->mailer()->init();
         if (class_exists($current_section)) {
             $current_section_class = new $current_section();
             do_action('woocommerce_update_options_' . $this->id . '_' . $current_section_class->id);
         } else {
             do_action('woocommerce_update_options_' . $this->id . '_' . $current_section);
         }
     }
 }
 /**
  * Save global settings 
  */
 public function save()
 {
     global $current_section;
     if ($current_section) {
         if ($this->section_save()) {
             update_option('wc_price_based_country_timestamp', time());
         }
     } else {
         if (isset($_POST['delete_group'])) {
             $section_settings = WCPBC()->get_regions();
             global $wpdb;
             foreach ($_POST['delete_group'] as $region_key) {
                 unset($section_settings[$region_key]);
                 foreach (array('_price', '_regular_price', '_sale_price', '_price_method') as $price_type) {
                     foreach (array('', '_variable') as $variable) {
                         $meta_key = '_' . $region_key . $variable . $price_type;
                         $wpdb->delete($wpdb->postmeta, array('meta_key' => $meta_key));
                     }
                     if ($price_type !== '_price_method') {
                         foreach (array('_min', '_max') as $min_or_max) {
                             $meta_key = '_' . $region_key . $min_or_max . $price_type . '_variation_id';
                             $wpdb->delete($wpdb->postmeta, array('meta_key' => $meta_key));
                         }
                     }
                 }
             }
             update_option('wc_price_based_country_regions', $section_settings);
         }
         //save settings
         $settings = $this->get_settings();
         WC_Admin_Settings::save_fields($settings);
         update_option('wc_price_based_country_timestamp', time());
     }
 }
예제 #25
0
 /**
  * Save settings.
  *
  * Save settings based on WooCommerce save_fields() method.
  *
  * @since 1.0.0
  */
 public function woocommerce_update_options()
 {
     WC_Admin_Settings::save_fields($this->woocommerce_get_settings());
 }
 /**
  * Save settings
  */
 public function save()
 {
     global $current_section;
     if ($_GET['section'] != "upgrades") {
         $settings = $this->get_settings($current_section);
         WC_Admin_Settings::save_fields($settings);
     } else {
         $this->run_update();
     }
 }
 /**
  * Save settings
  */
 public function save()
 {
     global $current_section;
     if (!$current_section) {
         $settings = $this->get_settings();
         WC_Admin_Settings::save_fields($settings);
         WC()->shipping->process_admin_options();
     } elseif (class_exists($current_section)) {
         $current_section_class = new $current_section();
         do_action('woocommerce_update_options_' . $this->id . '_' . $current_section_class->id);
     }
 }
 /**
  * Save settings
  */
 public function save()
 {
     global $current_section;
     if (!$current_section) {
         $settings = $this->get_settings();
         WC_Admin_Settings::save_fields($settings);
         WC()->shipping->process_admin_options();
     } elseif (class_exists($current_section)) {
         $current_section_class = new $current_section();
         do_action('woocommerce_update_options_' . $this->id . '_' . $current_section_class->id);
     }
     // Increments the transient version to invalidate cache
     WC_Cache_Helper::get_transient_version('shipping', true);
 }
 /**
  * Save settings.
  */
 public function save()
 {
     global $current_section;
     $wc_payment_gateways = WC_Payment_Gateways::instance();
     if (!$current_section) {
         WC_Admin_Settings::save_fields($this->get_settings());
         $wc_payment_gateways->process_admin_options();
     } else {
         foreach ($wc_payment_gateways->payment_gateways() as $gateway) {
             if (in_array($current_section, array($gateway->id, sanitize_title(get_class($gateway))))) {
                 do_action('woocommerce_update_options_payment_gateways_' . $gateway->id);
                 $wc_payment_gateways->init();
             }
         }
     }
 }
 /**
  * Save settings.
  */
 public function save()
 {
     global $current_section;
     if (apply_filters('woocommerce_rest_api_valid_to_save', !in_array($current_section, array('keys', 'webhooks')))) {
         $settings = $this->get_settings();
         WC_Admin_Settings::save_fields($settings);
     }
 }