/** * Save the settings */ function save() { global $current_section; set_transient('wcdn_flush_rewrite_rules', true); $settings = $this->get_settings($current_section); woocommerce_update_options($settings); }
function update_woo_settings() { global $woocommerce_settings, $rtWooGLAdmin; woocommerce_update_options($woocommerce_settings['rtwoogl']); $endPoint = trailingslashit(get_option('rtwoogl_api_endpoint', '')); $token = get_option('rtwoogl_private_token', ''); $response = $rtWooGLAdmin->test_connection($endPoint, $token); if ($response['result'] == 'error') { update_site_option('rtwoogl_settings_error', '<div id="rtwoogl_message" class="error fade"><p><strong>' . $response['message'] . '</strong></p></div>'); } }
/** * Update options * * @return void * @since 1.0 * @author Andrea Grillo <*****@*****.**> * @author Antonio La Rocca <*****@*****.**> * @see woocommerce_update_options function * @internal fire two action (before and after update): yit_panel_wc_before_update and yit_panel_wc_after_update */ public function woocommerce_update_options() { if (isset($_POST['yit_panel_wc_options_nonce']) && wp_verify_nonce($_POST['yit_panel_wc_options_nonce'], 'yit_panel_wc_options_' . $this->settings['page'])) { do_action('yit_panel_wc_before_update'); $yit_options = $this->get_main_array_options(); $current_tab = $this->get_current_tab(); woocommerce_update_options($yit_options[$current_tab]); do_action('yit_panel_wc_after_update'); } elseif (isset($_REQUEST['yit-action']) && $_REQUEST['yit-action'] == 'wc-options-reset') { $yit_options = $this->get_main_array_options(); $current_tab = $this->get_current_tab(); foreach ($yit_options[$current_tab] as $id => $option) { if (isset($option['default'])) { update_option($option['id'], $option['default']); } } } }
public static function update_options($options) { $rule_id = self::$RULE_ID; if (!empty($rule_id)) { $settings = self::get_rule_settings_by_id($rule_id); woocommerce_update_options($settings); } }
/** * Update options * * @return void * @since 1.0 * @author Andrea Grillo <*****@*****.**> * @author Antonio La Rocca <*****@*****.**> * @see woocommerce_update_options function * @internal fire two action (before and after update): yit_panel_wc_before_update and yit_panel_wc_after_update */ public function woocommerce_update_options() { if (isset($_POST['yit_panel_wc_options_nonce']) && wp_verify_nonce($_POST['yit_panel_wc_options_nonce'], 'yit_panel_wc_options_' . $this->settings['page'])) { do_action('yit_panel_wc_before_update'); $yit_options = $this->get_main_array_options(); $current_tab = $this->get_current_tab(); if (version_compare(WC()->version, '2.4.0', '>=')) { if (!empty($yit_options[$current_tab])) { foreach ($yit_options[$current_tab] as $option) { if (isset($option['id']) && isset($_POST[$option['id']]) && isset($option['type']) && !in_array($option['type'], $this->wc_type)) { $_POST[$option['id']] = maybe_serialize($_POST[$option['id']]); } } } } woocommerce_update_options($yit_options[$current_tab]); do_action('yit_panel_wc_after_update'); } elseif (isset($_REQUEST['yit-action']) && $_REQUEST['yit-action'] == 'wc-options-reset' && isset($_POST['yith_wc_reset_options_nonce']) && wp_verify_nonce($_POST['yith_wc_reset_options_nonce'], 'yith_wc_reset_options_' . $this->settings['page'])) { $yit_options = $this->get_main_array_options(); $current_tab = $this->get_current_tab(); foreach ($yit_options[$current_tab] as $id => $option) { if (isset($option['default'])) { update_option($option['id'], $option['default']); } } } }
public static function prdctfltr_update_settings() { if (isset($_POST['pfa_taxonomy'])) { $adv_filters = array(); for ($i = 0; $i < count($_POST['pfa_taxonomy']); $i++) { $adv_filters['pfa_title'][$i] = $_POST['pfa_title'][$i]; $adv_filters['pfa_taxonomy'][$i] = $_POST['pfa_taxonomy'][$i]; $adv_filters['pfa_include'][$i] = isset($_POST['pfa_include'][$i]) ? $_POST['pfa_include'][$i] : array(); $adv_filters['pfa_orderby'][$i] = isset($_POST['pfa_orderby'][$i]) ? $_POST['pfa_orderby'][$i] : ''; $adv_filters['pfa_order'][$i] = isset($_POST['pfa_order'][$i]) ? $_POST['pfa_order'][$i] : ''; $adv_filters['pfa_multiselect'][$i] = isset($_POST['pfa_multiselect'][$i]) ? $_POST['pfa_multiselect'][$i] : 'no'; $adv_filters['pfa_relation'][$i] = isset($_POST['pfa_relation'][$i]) ? $_POST['pfa_relation'][$i] : 'IN'; $adv_filters['pfa_adoptive'][$i] = isset($_POST['pfa_adoptive'][$i]) ? $_POST['pfa_adoptive'][$i] : 'no'; $adv_filters['pfa_none'][$i] = isset($_POST['pfa_none'][$i]) ? $_POST['pfa_none'][$i] : 'no'; $adv_filters['pfa_limit'][$i] = isset($_POST['pfa_limit'][$i]) ? $_POST['pfa_limit'][$i] : ''; $adv_filters['pfa_hierarchy'][$i] = isset($_POST['pfa_hierarchy'][$i]) ? $_POST['pfa_hierarchy'][$i] : 'no'; $adv_filters['pfa_hierarchy_mode'][$i] = isset($_POST['pfa_hierarchy_mode'][$i]) ? $_POST['pfa_hierarchy_mode'][$i] : 'no'; $adv_filters['pfa_mode'][$i] = isset($_POST['pfa_mode'][$i]) ? $_POST['pfa_mode'][$i] : 'showall'; $adv_filters['pfa_style'][$i] = isset($_POST['pfa_style'][$i]) ? $_POST['pfa_style'][$i] : 'pf_attr_text'; $adv_filters['pfa_term_customization'][$i] = isset($_POST['pfa_term_customization'][$i]) ? $_POST['pfa_term_customization'][$i] : ''; } update_option('wc_settings_prdctfltr_advanced_filters', $adv_filters); } if (isset($_POST['pfr_taxonomy'])) { $rng_filters = array(); for ($i = 0; $i < count($_POST['pfr_taxonomy']); $i++) { $rng_filters['pfr_title'][$i] = $_POST['pfr_title'][$i]; $rng_filters['pfr_taxonomy'][$i] = $_POST['pfr_taxonomy'][$i]; $rng_filters['pfr_include'][$i] = isset($_POST['pfr_include'][$i]) ? $_POST['pfr_include'][$i] : array(); $rng_filters['pfr_orderby'][$i] = isset($_POST['pfr_orderby'][$i]) ? $_POST['pfr_orderby'][$i] : ''; $rng_filters['pfr_order'][$i] = isset($_POST['pfr_order'][$i]) ? $_POST['pfr_order'][$i] : ''; $rng_filters['pfr_style'][$i] = isset($_POST['pfr_style'][$i]) ? $_POST['pfr_style'][$i] : 'flat'; $rng_filters['pfr_grid'][$i] = isset($_POST['pfr_grid'][$i]) ? $_POST['pfr_grid'][$i] : 'no'; $rng_filters['pfr_custom'][$i] = isset($_POST['pfr_custom'][$i]) ? $_POST['pfr_custom'][$i] : 'no'; } update_option('wc_settings_prdctfltr_range_filters', $rng_filters); } if (isset($_POST['wc_settings_prdctfltr_active_filters'])) { update_option('wc_settings_prdctfltr_active_filters', $_POST['wc_settings_prdctfltr_active_filters']); } woocommerce_update_options(self::prdctfltr_get_settings('update')); delete_transient('prdctfltr_default'); }
/** * Save settings */ public function save() { global $woocommerce, $woocommerce_settings, $current_section; $settings = $this->get_settings(); include_once MailPoet_WooCommerce_Add_on()->wc_plugin_path() . 'admin/settings/settings-save.php'; $current_section = empty($_REQUEST['section']) ? 'general' : sanitize_text_field(urldecode($_REQUEST['section'])); woocommerce_update_options($settings); if ($current_section == 'lists') { // Each list of newsletters that have 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'); } } }
/** * dhwc_product_brand_save_admin_settings function */ function dhwc_product_brand_save_admin_settings() { woocommerce_update_options(dhwc_product_brand_get_admin_settings()); }
/** * Save settings in a single field in the database for each tab's fields (one field per tab). */ public function save_settings() { global $woocommerce_settings; // Make sure our settings fields are recognised. $this->add_settings_fields(); $current_tab = $this->get_tab_in_view(current_filter(), 'woocommerce_update_options_'); woocommerce_update_options($woocommerce_settings[$current_tab]); }
/** * Uses the WooCommerce options API to save settings via the @see woocommerce_update_options() function. * * @uses woocommerce_update_options() * @uses self::get_settings() * @since 1.0 */ public static function update_subscription_settings() { // Make sure automatic payments are on when manual renewals are switched off if (!isset($_POST[self::$option_prefix . '_accept_manual_renewals']) && isset($_POST[self::$option_prefix . '_turn_off_automatic_payments'])) { unset($_POST[self::$option_prefix . '_turn_off_automatic_payments']); } woocommerce_update_options(self::get_settings()); }
public static function update_settings() { global $current_section; woocommerce_update_options(self::get_settings($current_section)); }
public function wcla_update_options() { woocommerce_update_options(WCLA_Utilities::get_fields()); }
/** * Save the 'Pre-Orders' settings page * * @since 1.0 */ public function save_settings() { woocommerce_update_options($this->get_settings()); }
public static function update_admin_settings() { woocommerce_update_options(self::get_admin_form()); }
/** * save_settings() * * Save settings in a single field in the database for each tab's fields (one field per tab). */ function save_settings() { global $woocommerce_settings; // Make sure our settings fields are recognised. $this->add_settings_fields(); $current_tab = $this->get_tab_in_view(current_filter(), 'woocommerce_update_options_'); woocommerce_update_options($woocommerce_settings[$current_tab]); // This is to prevent html being stripped until the WC settings api supports custom field saving if (isset($_POST['wc_cvo_s_price_text'])) { $data = wp_unslash(wp_kses_post($_POST['wc_cvo_s_price_text'])); update_option('wc_cvo_s_price_text', $data); } }
/** * Render the sub-menu page for 'CSV Export' * * @since 3.0 */ public function render_submenu_pages() { // permissions check if (!current_user_can('manage_woocommerce')) { return; } $this->tabs = array('export' => __('Export', WC_Customer_Order_CSV_Export::TEXT_DOMAIN), 'settings' => __('Settings', WC_Customer_Order_CSV_Export::TEXT_DOMAIN)); $current_tab = empty($_GET['tab']) ? 'export' : urldecode($_GET['tab']); // settings if (!empty($_POST) && 'settings' == $current_tab) { // security check if (!wp_verify_nonce($_POST['_wpnonce'], __FILE__)) { wp_die(__('Action failed. Please refresh the page and retry.', WC_Customer_Order_CSV_Export::TEXT_DOMAIN)); } if (isset($_POST['wc_customer_order_csv_export_test_method'])) { // process test $export = new WC_Customer_Order_CSV_Export_Handler(0); $result = $export->test_export_via($_POST['wc_customer_order_csv_export_test_method']); $this->message_handler->add_message($result); } else { $orig_start_inverval = get_option('wc_customer_order_csv_export_auto_export_start_time') . get_option('wc_customer_order_csv_export_auto_export_interval'); // save settings woocommerce_update_options($this->get_settings('settings')); // clear scheduled export event if export interval and/or start time were changed if ($orig_start_inverval !== get_option('wc_customer_order_csv_export_auto_export_start_time') . get_option('wc_customer_order_csv_export_auto_export_interval')) { // note this resets the next scheduled execution time to the time options were saved + the interval wp_clear_scheduled_hook('wc_customer_order_csv_export_auto_export_orders'); } $this->message_handler->add_message(__('Your settings have been saved.', WC_Customer_Order_CSV_Export::TEXT_DOMAIN)); } } ?> <div class="wrap woocommerce"> <form method="post" id="mainform" action="" enctype="multipart/form-data"> <h2 class="nav-tab-wrapper woo-nav-tab-wrapper"> <?php foreach ($this->tabs as $tab_id => $tab_title) { $class = $tab_id == $current_tab ? array('nav-tab', 'nav-tab-active') : array('nav-tab'); $url = add_query_arg('tab', $tab_id, admin_url('admin.php?page=wc_customer_order_csv_export')); printf('<a href="%s" class="%s">%s</a>', esc_url($url), implode(' ', array_map('sanitize_html_class', $class)), esc_html($tab_title)); } ?> </h2> <?php $this->message_handler->show_messages(); if ('settings' == $current_tab) { $this->render_settings_page(); } else { $this->render_export_page(); } ?> </form> </div> <?php }
function update_settings() { woocommerce_update_options(self::get_settings()); }
public static function woocommerce_hide_product_update_options() { woocommerce_update_options(WooCommerce_Hide_Products_Admin::woocommerce_hide_product_admin_options()); }
/** * Update plugin options. * * @return void * @since 1.0.0 */ public function update_options() { foreach ($this->options as $option) { woocommerce_update_options($option); } foreach ($this->colors_options as $name => $option) { foreach ($option as $id => $color) { $this->colors_options[$name][$id] = isset($_POST['yith_wcwl_color_' . $name . '_' . $id]) && !empty($_POST['yith_wcwl_color_' . $name . '_' . $id]) ? woocommerce_format_hex($_POST['yith_wcwl_color_' . $name . '_' . $id]) : ''; } } update_option('yith_wcwl_frontend_css_colors', maybe_serialize($this->colors_options)); }
/** * Update Settings * * Updates the voucher options when being saved. * * @package WooCommerce - PDF Vouchers * @since 1.6 */ public function woo_vou_update_settings() { woocommerce_update_options($this->woo_vou_get_settings()); }
/** * Update plugin options. * * @return void * @since 1.0.0 */ public function update_options() { foreach ($this->options as $option) { woocommerce_update_options($option); } }
/** * Update options * * @return void * @since 1.0 * @author Andrea Grillo <*****@*****.**> * @author Antonio La Rocca <*****@*****.**> * @see woocommerce_update_options function * @internal fire two action (before and after update): yit_panel_wc_before_update and yit_panel_wc_after_update */ public function woocommerce_update_options() { if (isset($_POST['yit_panel_wc_options_nonce']) && wp_verify_nonce($_POST['yit_panel_wc_options_nonce'], 'yit_panel_wc_options_' . $this->settings['page'])) { do_action('yit_panel_wc_before_update'); $yit_options = $this->get_main_array_options(); $current_tab = $this->get_current_tab(); if (version_compare(WC()->version, '2.4.0', '>=')) { if (!empty($yit_options[$current_tab])) { foreach ($yit_options[$current_tab] as $option) { if (isset($option['id']) && isset($_POST[$option['id']]) && isset($option['type']) && !in_array($option['type'], $this->wc_type)) { $_POST[$option['id']] = maybe_serialize($_POST[$option['id']]); } } } } foreach ($_POST as $name => $value) { // Check if current POST var which name ends with a specific needle $attachment_id_needle = "-yith-attachment-id"; $is_hidden_input = ($temp = strlen($name) - strlen($attachment_id_needle)) >= 0 && strpos($name, $attachment_id_needle, $temp) !== FALSE; if ($is_hidden_input) { // Is an input element of type "hidden" coupled with an input element for selecting an element from the media gallery $yit_options[$current_tab][$name] = array("type" => "text", "id" => $name); } } woocommerce_update_options($yit_options[$current_tab]); do_action('yit_panel_wc_after_update'); } elseif (isset($_REQUEST['yit-action']) && $_REQUEST['yit-action'] == 'wc-options-reset' && isset($_POST['yith_wc_reset_options_nonce']) && wp_verify_nonce($_POST['yith_wc_reset_options_nonce'], 'yith_wc_reset_options_' . $this->settings['page'])) { $yit_options = $this->get_main_array_options(); $current_tab = $this->get_current_tab(); foreach ($yit_options[$current_tab] as $id => $option) { if (isset($option['default'])) { update_option($option['id'], $option['default']); } } } }
function update_option() { woocommerce_update_options($this->settings); }
function woocommerce_settings() { global $woocommerce, $woocommerce_settings; $current_tab = isset($_GET['tab']) ? $_GET['tab'] : 'general'; // Save settings if (isset($_POST) && $_POST) { if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'woocommerce-settings')) { die(__('Action failed. Please refresh the page and retry.', 'woocommerce')); } switch ($current_tab) { case "general": case "pages": case "catalog": case "inventory": case "shipping": case "tax": case "email": case "integration": woocommerce_update_options($woocommerce_settings[$current_tab]); break; } do_action('woocommerce_update_options'); do_action('woocommerce_update_options_' . $current_tab); if ($current_tab == 'shipping') { do_action('woocommerce_update_options_shipping_methods'); } // Shipping Methods flush_rewrite_rules(false); wp_redirect(add_query_arg('subtab', esc_attr(str_replace('#', '', $_POST['subtab'])), add_query_arg('saved', 'true', admin_url('admin.php?page=woocommerce&tab=' . $current_tab)))); exit; } // Settings saved message if (isset($_GET['saved']) && $_GET['saved']) { echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'woocommerce') . '</strong></p></div>'; flush_rewrite_rules(false); do_action('woocommerce_settings_saved'); } // Hide WC Link if (isset($_GET['hide-wc-extensions-message'])) { update_option('hide-wc-extensions-message', 1); } // Install/page installer $install_complete = false; // Add pages button if (isset($_GET['install_woocommerce_pages']) && $_GET['install_woocommerce_pages']) { require_once 'woocommerce-admin-install.php'; woocommerce_create_pages(); update_option('skip_install_woocommerce_pages', 1); $install_complete = true; // Skip button } elseif (isset($_GET['skip_install_woocommerce_pages']) && $_GET['skip_install_woocommerce_pages']) { update_option('skip_install_woocommerce_pages', 1); $install_complete = true; } if ($install_complete) { ?> <div id="message" class="updated woocommerce-message wc-connect"> <div class="squeezer"> <h4><?php _e('<strong>Congratulations!</strong> – WooCommerce has been installed and setup. Enjoy :)', 'woocommerce'); ?> </h4> <p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/woocommerce/" data-text="A open-source (free) #ecommerce plugin for #WordPress that helps you sell anything. Beautifully." data-via="WooThemes" data-size="large" data-hashtags="WooCommerce">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p> </div> </div> <?php // Flush rules after install flush_rewrite_rules(false); // Set installed option update_option('woocommerce_installed', 0); } ?> <div class="wrap woocommerce"> <form method="post" id="mainform" action=""> <div class="icon32 icon32-woocommerce-settings" id="icon-woocommerce"><br></div><h2 class="nav-tab-wrapper woo-nav-tab-wrapper"> <?php $tabs = array('general' => __('General', 'woocommerce'), 'pages' => __('Pages', 'woocommerce'), 'catalog' => __('Catalog', 'woocommerce'), 'inventory' => __('Inventory', 'woocommerce'), 'tax' => __('Tax', 'woocommerce'), 'shipping' => __('Shipping', 'woocommerce'), 'payment_gateways' => __('Payment Gateways', 'woocommerce'), 'email' => __('Emails', 'woocommerce'), 'integration' => __('Integration', 'woocommerce')); $tabs = apply_filters('woocommerce_settings_tabs_array', $tabs); foreach ($tabs as $name => $label) { echo '<a href="' . admin_url('admin.php?page=woocommerce&tab=' . $name) . '" class="nav-tab '; if ($current_tab == $name) { echo 'nav-tab-active'; } echo '">' . $label . '</a>'; } do_action('woocommerce_settings_tabs'); ?> </h2> <?php wp_nonce_field('woocommerce-settings', '_wpnonce', true, true); ?> <?php if (!get_option('hide-wc-extensions-message')) { ?> <div id="woocommerce_extensions"><a href="<?php echo add_query_arg('hide-wc-extensions-message', 'true'); ?> " class="hide">×</a><?php echo sprintf(__('More functionality and gateway options available via <a href="%s" target="_blank">WC official extensions</a>.', 'woocommerce'), 'http://www.woothemes.com/extensions/woocommerce-extensions/'); ?> </div> <?php } ?> <?php switch ($current_tab) { case "general": case "pages": case "catalog": case "inventory": case "tax": case "email": case "integration": woocommerce_admin_fields($woocommerce_settings[$current_tab]); break; case "shipping": $links = array('<a href="#shipping-options">' . __('Shipping Options', 'woocommerce') . '</a>'); foreach ($woocommerce->shipping->shipping_methods as $method) { $title = isset($method->method_title) && $method->method_title ? ucwords($method->method_title) : ucwords($method->id); $links[] = '<a href="#shipping-' . $method->id . '">' . $title . '</a>'; } echo '<div class="subsubsub_section"><ul class="subsubsub"><li>' . implode(' | </li><li>', $links) . '</li></ul><br class="clear" />'; // Gateway ordering echo '<div class="section" id="shipping-options">'; woocommerce_admin_fields($woocommerce_settings[$current_tab]); ?> <h3><?php _e('Shipping Methods', 'woocommerce'); ?> </h3> <p><?php _e('Your activated shipping methods are listed below. Drag and drop rows to re-order them for display on the frontend.', 'woocommerce'); ?> </p> <table class="wc_shipping widefat" cellspacing="0"> <thead> <tr> <th><?php _e('Default', 'woocommerce'); ?> </th> <th><?php _e('Shipping Method', 'woocommerce'); ?> </th> <th><?php _e('Status', 'woocommerce'); ?> </th> </tr> </thead> <tbody> <?php foreach ($woocommerce->shipping->shipping_methods as $method) { $default_shipping_method = get_option('woocommerce_default_shipping_method'); echo '<tr> <td width="1%" class="radio"> <input type="radio" name="default_shipping_method" value="' . $method->id . '" ' . checked($default_shipping_method, $method->id, false) . ' /> <input type="hidden" name="method_order[]" value="' . $method->id . '" /> <td> <p><strong>' . $method->title . '</strong><br/> <small>' . __('Method ID', 'woocommerce') . ': ' . $method->id . '</small></p> </td> <td>'; if ($method->enabled == 'yes') { echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success.png" alt="yes" />'; } else { echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success-off.png" alt="no" />'; } echo '</td> </tr>'; } ?> </tbody> </table> <?php echo '</div>'; // Specific method options foreach ($woocommerce->shipping->shipping_methods as $method) { echo '<div class="section" id="shipping-' . $method->id . '">'; $method->admin_options(); echo '</div>'; } echo '</div>'; break; case "payment_gateways": $links = array('<a href="#gateway-order">' . __('Payment Gateways', 'woocommerce') . '</a>'); foreach ($woocommerce->payment_gateways->payment_gateways() as $gateway) { $title = isset($gateway->method_title) && $gateway->method_title ? ucwords($gateway->method_title) : ucwords($gateway->id); $links[] = '<a href="#gateway-' . $gateway->id . '">' . $title . '</a>'; } echo '<div class="subsubsub_section"><ul class="subsubsub"><li>' . implode(' | </li><li>', $links) . '</li></ul><br class="clear" />'; // Gateway ordering echo '<div class="section" id="gateway-order">'; ?> <h3><?php _e('Payment Gateways', 'woocommerce'); ?> </h3> <p><?php _e('Your activated payment gateways are listed below. Drag and drop rows to re-order them for display on the checkout.', 'woocommerce'); ?> </p> <table class="wc_gateways widefat" cellspacing="0"> <thead> <tr> <th width="1%"><?php _e('Default', 'woocommerce'); ?> </th> <th><?php _e('Gateway', 'woocommerce'); ?> </th> <th><?php _e('Status', 'woocommerce'); ?> </th> </tr> </thead> <tbody> <?php foreach ($woocommerce->payment_gateways->payment_gateways() as $gateway) { $default_gateway = get_option('woocommerce_default_gateway'); echo '<tr> <td width="1%" class="radio"> <input type="radio" name="default_gateway" value="' . $gateway->id . '" ' . checked($default_gateway, $gateway->id, false) . ' /> <input type="hidden" name="gateway_order[]" value="' . $gateway->id . '" /> </td> <td> <p><strong>' . $gateway->title . '</strong><br/> <small>' . __('Gateway ID', 'woocommerce') . ': ' . $gateway->id . '</small></p> </td> <td>'; if ($gateway->enabled == 'yes') { echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success.png" alt="yes" />'; } else { echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/success-off.png" alt="no" />'; } echo '</td> </tr>'; } ?> </tbody> </table> <?php echo '</div>'; // Specific gateway options foreach ($woocommerce->payment_gateways->payment_gateways() as $gateway) { echo '<div class="section" id="gateway-' . $gateway->id . '">'; $gateway->admin_options(); echo '</div>'; } echo '</div>'; break; default: do_action('woocommerce_settings_tabs_' . $current_tab); break; } ?> <p class="submit"> <input name="save" class="button-primary" type="submit" value="<?php _e('Save changes', 'woocommerce'); ?> " /> <input type="hidden" name="subtab" id="last_tab" /> </p> </form> <script type="text/javascript"> jQuery(window).load(function(){ // Subsubsub tabs jQuery('ul.subsubsub li a:eq(0)').addClass('current'); jQuery('.subsubsub_section .section:gt(0)').hide(); jQuery('ul.subsubsub li a').click(function(){ jQuery('a', jQuery(this).closest('ul.subsubsub')).removeClass('current'); jQuery(this).addClass('current'); jQuery('.section', jQuery(this).closest('.subsubsub_section')).hide(); jQuery( jQuery(this).attr('href') ).show(); jQuery('#last_tab').val( jQuery(this).attr('href') ); return false; }); <?php if (isset($_GET['subtab']) && $_GET['subtab']) { echo 'jQuery("ul.subsubsub li a[href=#' . $_GET['subtab'] . ']").click();'; } ?> // Countries jQuery('select#woocommerce_allowed_countries').change(function(){ if (jQuery(this).val()=="specific") { jQuery(this).parent().parent().next('tr').show(); } else { jQuery(this).parent().parent().next('tr').hide(); } }).change(); // Color picker jQuery('.colorpick').each(function(){ jQuery('.colorpickdiv', jQuery(this).parent()).farbtastic(this); jQuery(this).click(function() { if ( jQuery(this).val() == "" ) jQuery(this).val('#'); jQuery('.colorpickdiv', jQuery(this).parent() ).show(); }); }); jQuery(document).mousedown(function(){ jQuery('.colorpickdiv').hide(); }); // Edit prompt jQuery(function(){ var changed = false; jQuery('input, textarea, select, checkbox').change(function(){ changed = true; }); jQuery('.woo-nav-tab-wrapper a').click(function(){ if (changed) { window.onbeforeunload = function() { return '<?php echo __('The changes you made will be lost if you navigate away from this page.', 'woocommerce'); ?> '; } } else { window.onbeforeunload = ''; } }); jQuery('.submit input').click(function(){ window.onbeforeunload = ''; }); }); // Sorting jQuery('table.wc_gateways tbody, table.wc_shipping tbody').sortable({ items:'tr', cursor:'move', axis:'y', handle: 'td', scrollSensitivity:40, helper:function(e,ui){ ui.children().each(function(){ jQuery(this).width(jQuery(this).width()); }); ui.css('left', '0'); return ui; }, start:function(event,ui){ ui.item.css('background-color','#f6f6f6'); }, stop:function(event,ui){ ui.item.removeAttr('style'); } }); // Chosen selects jQuery("select.chosen_select").chosen(); jQuery("select.chosen_select_nostd").chosen({ allow_single_deselect: 'true' }); }); </script> </div> <?php }
function save_admin_settings() { woocommerce_update_options($this->settings); }
function pierry_variation_fields_update_settings() { $settings = false; if (isset($_GET['section']) && $_GET['section'] == 'pierry_variation_fields') { $settings = pierry_variation_fields_settings_fields(); } if ($settings !== false) { woocommerce_update_options($settings); } }
/** * Function for saving settings for Gift Certificate */ public function save_smart_coupon_admin_settings() { woocommerce_update_options($this->sc_general_settings); }
/** * Uses the WooCommerce options API to save settings via the @see woocommerce_update_options() function. * * @uses woocommerce_update_options() * @uses self::get_settings() * @since 1.0 */ public static function update_subscription_settings() { if (empty($_POST['_wcsnonce']) || !wp_verify_nonce($_POST['_wcsnonce'], 'wcs_subscription_settings')) { return; } // Make sure automatic payments are on when manual renewals are switched off if (!isset($_POST[self::$option_prefix . '_accept_manual_renewals']) && isset($_POST[self::$option_prefix . '_turn_off_automatic_payments'])) { unset($_POST[self::$option_prefix . '_turn_off_automatic_payments']); } woocommerce_update_options(self::get_settings()); }
/** * Uses the WooCommerce options API to save settings via the @see woocommerce_update_options() function. * * @uses woocommerce_update_options() * @uses self::get_settings() * @since 1.0 */ public static function update_subscription_settings() { woocommerce_update_options(self::get_settings()); }
/** * Settings page. * * Handles the display of the main woocommerce settings page in admin. * * @access public * @return void */ function woocommerce_settings() { global $woocommerce, $woocommerce_settings, $current_section, $current_tab; do_action('woocommerce_settings_start'); // Get current tab/section $current_tab = empty($_GET['tab']) ? 'general' : sanitize_text_field(urldecode($_GET['tab'])); $current_section = empty($_REQUEST['section']) ? '' : sanitize_text_field(urldecode($_REQUEST['section'])); // Save settings if (!empty($_POST)) { if (empty($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'woocommerce-settings')) { die(__('Action failed. Please refresh the page and retry.', 'woocommerce')); } if (!$current_section) { $old_base_color = get_option('woocommerce_frontend_css_base_color'); $old_base_color = get_option('woocommerce_frontend_css_base_color'); include_once 'settings/settings-save.php'; switch ($current_tab) { case "payment_gateways": woocommerce_update_options($woocommerce_settings[$current_tab]); $woocommerce->payment_gateways->process_admin_options(); break; case "shipping": woocommerce_update_options($woocommerce_settings[$current_tab]); $woocommerce->shipping->process_admin_options(); break; default: if (isset($woocommerce_settings[$current_tab])) { woocommerce_update_options($woocommerce_settings[$current_tab]); } // Trigger action for tab do_action('woocommerce_update_options_' . $current_tab); break; } do_action('woocommerce_update_options'); // Handle Colour Settings if ($current_tab == 'general' && get_option('woocommerce_frontend_css') == 'yes') { // Save settings $primary = !empty($_POST['woocommerce_frontend_css_primary']) ? woocommerce_format_hex($_POST['woocommerce_frontend_css_primary']) : ''; $secondary = !empty($_POST['woocommerce_frontend_css_secondary']) ? woocommerce_format_hex($_POST['woocommerce_frontend_css_secondary']) : ''; $highlight = !empty($_POST['woocommerce_frontend_css_highlight']) ? woocommerce_format_hex($_POST['woocommerce_frontend_css_highlight']) : ''; $content_bg = !empty($_POST['woocommerce_frontend_css_content_bg']) ? woocommerce_format_hex($_POST['woocommerce_frontend_css_content_bg']) : ''; $subtext = !empty($_POST['woocommerce_frontend_css_subtext']) ? woocommerce_format_hex($_POST['woocommerce_frontend_css_subtext']) : ''; $colors = array('primary' => $primary, 'secondary' => $secondary, 'highlight' => $highlight, 'content_bg' => $content_bg, 'subtext' => $subtext); $old_colors = get_option('woocommerce_frontend_css_colors'); update_option('woocommerce_frontend_css_colors', $colors); if ($old_colors != $colors) { woocommerce_compile_less_styles(); } } } else { // If saving a shipping methods options, load 'er up if ($current_tab == 'shipping' || $current_tab == 'payment_gateways' && class_exists($current_section)) { $current_section_class = new $current_section(); do_action('woocommerce_update_options_' . $current_tab . '_' . $current_section_class->id); // If saving an email's options, load theme } elseif ($current_tab == 'email') { // Load mailer $mailer = $woocommerce->mailer(); if (class_exists($current_section)) { $current_section_class = new $current_section(); do_action('woocommerce_update_options_' . $current_tab . '_' . $current_section_class->id); } else { do_action('woocommerce_update_options_' . $current_tab . '_' . $current_section); } // Save tax } elseif ($current_tab == 'tax') { include_once 'settings/settings-tax-rates.php'; woocommerce_tax_rates_setting_save(); } else { // Save section only do_action('woocommerce_update_options_' . $current_tab . '_' . $current_section); } } // Clear any unwanted data $woocommerce->clear_product_transients(); delete_transient('woocommerce_cache_excluded_uris'); // Redirect back to the settings page $redirect = add_query_arg('saved', 'true'); if (!empty($_POST['subtab'])) { $redirect = add_query_arg('subtab', esc_attr(str_replace('#', '', $_POST['subtab'])), $redirect); } wp_safe_redirect($redirect); exit; } // Get any returned messages $error = empty($_GET['wc_error']) ? '' : urldecode(stripslashes($_GET['wc_error'])); $message = empty($_GET['wc_message']) ? '' : urldecode(stripslashes($_GET['wc_message'])); if ($error || $message) { if ($error) { echo '<div id="message" class="error fade"><p><strong>' . esc_html($error) . '</strong></p></div>'; } else { echo '<div id="message" class="updated fade"><p><strong>' . esc_html($message) . '</strong></p></div>'; } } elseif (!empty($_GET['saved'])) { echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'woocommerce') . '</strong></p></div>'; } // Were the settings saved? if (!empty($_GET['saved'])) { do_action('woocommerce_settings_saved'); } // Hide WC Link if (!empty($_GET['hide-wc-extensions-message'])) { update_option('hide-wc-extensions-message', 1); } ?> <div class="wrap woocommerce"> <form method="post" id="mainform" action="" enctype="multipart/form-data"> <div class="icon32 icon32-woocommerce-settings" id="icon-woocommerce"><br /></div><h2 class="nav-tab-wrapper woo-nav-tab-wrapper"> <?php $tabs = array('general' => __('General', 'woocommerce'), 'catalog' => __('Catalog', 'woocommerce'), 'pages' => __('Pages', 'woocommerce'), 'inventory' => __('Inventory', 'woocommerce'), 'tax' => __('Tax', 'woocommerce'), 'shipping' => __('Shipping', 'woocommerce'), 'payment_gateways' => __('Payment Gateways', 'woocommerce'), 'email' => __('Emails', 'woocommerce'), 'integration' => __('Integration', 'woocommerce')); if (!$woocommerce->integrations->get_integrations()) { unset($tabs['integration']); } $tabs = apply_filters('woocommerce_settings_tabs_array', $tabs); foreach ($tabs as $name => $label) { echo '<a href="' . admin_url('admin.php?page=woocommerce_settings&tab=' . $name) . '" class="nav-tab '; if ($current_tab == $name) { echo 'nav-tab-active'; } echo '">' . $label . '</a>'; } do_action('woocommerce_settings_tabs'); ?> </h2> <?php wp_nonce_field('woocommerce-settings', '_wpnonce', true, true); ?> <?php if (!get_option('hide-wc-extensions-message')) { ?> <div id="woocommerce_extensions"><a href="<?php echo add_query_arg('hide-wc-extensions-message', 'true'); ?> " class="hide">×</a><?php printf(__('More functionality and gateway options available via <a href="%s" target="_blank">WC official extensions</a>.', 'woocommerce'), 'http://www.woothemes.com/extensions/woocommerce-extensions/'); ?> </div> <?php } ?> <?php switch ($current_tab) { case "general": include_once 'settings/settings-frontend-styles.php'; woocommerce_admin_fields($woocommerce_settings[$current_tab]); break; case "tax": $links = array('<a href="' . admin_url('admin.php?page=woocommerce_settings&tab=tax') . '" class="' . ($current_section == '' ? 'current' : '') . '">' . __('Tax Options', 'woocommerce') . '</a>'); // Get tax classes and display as links $tax_classes = array_filter(array_map('trim', explode("\n", get_option('woocommerce_tax_classes')))); $links[] = __('Tax Rates', 'woocommerce') . ': <a href="' . admin_url('admin.php?page=woocommerce_settings&tab=tax§ion=standard') . '" class="' . ($current_section == 'standard' ? 'current' : '') . '">' . __('Standard', 'woocommerce') . '</a>'; if ($tax_classes) { foreach ($tax_classes as $class) { $links[] = '<a href="' . admin_url('admin.php?page=woocommerce_settings&tab=tax§ion=' . sanitize_title($class)) . '" class="' . ($current_section == sanitize_title($class) ? 'current' : '') . '">' . $class . '</a>'; } } echo '<ul class="subsubsub"><li>' . implode(' | </li><li>', $links) . '</li></ul><br class="clear" />'; if ($current_section == 'standard' || in_array($current_section, array_map('sanitize_title', $tax_classes))) { include_once 'settings/settings-tax-rates.php'; woocommerce_tax_rates_setting(); } else { woocommerce_admin_fields($woocommerce_settings[$current_tab]); } break; case "pages": case "catalog": case "inventory": woocommerce_admin_fields($woocommerce_settings[$current_tab]); break; case "email": $current = $current_section ? '' : 'class="current"'; $links = array('<a href="' . admin_url('admin.php?page=woocommerce_settings&tab=email') . '" ' . $current . '>' . __('Email Options', 'woocommerce') . '</a>'); // Define emails that can be customised here $mailer = $woocommerce->mailer(); $email_templates = $mailer->get_emails(); foreach ($email_templates as $email) { $title = empty($email->title) ? ucwords($email->id) : ucwords($email->title); $current = get_class($email) == $current_section ? 'class="current"' : ''; $links[] = '<a href="' . add_query_arg('section', get_class($email), admin_url('admin.php?page=woocommerce_settings&tab=email')) . '"' . $current . '>' . esc_html($title) . '</a>'; } echo '<ul class="subsubsub"><li>' . implode(' | </li><li>', $links) . '</li></ul><br class="clear" />'; // Specific email options if ($current_section) { foreach ($email_templates as $email) { if (get_class($email) == $current_section) { $email->admin_options(); break; } } } else { woocommerce_admin_fields($woocommerce_settings[$current_tab]); } break; case "shipping": include 'settings/settings-shipping-methods.php'; $current = $current_section ? '' : 'class="current"'; $links = array('<a href="' . admin_url('admin.php?page=woocommerce_settings&tab=shipping') . '" ' . $current . '>' . __('Shipping Options', 'woocommerce') . '</a>'); // Load shipping methods so we can show any global options they may have $shipping_methods = $woocommerce->shipping->load_shipping_methods(); foreach ($shipping_methods as $method) { if (!$method->has_settings()) { continue; } $title = empty($method->method_title) ? ucwords($method->id) : ucwords($method->method_title); $current = get_class($method) == $current_section ? 'class="current"' : ''; $links[] = '<a href="' . add_query_arg('section', get_class($method), admin_url('admin.php?page=woocommerce_settings&tab=shipping')) . '"' . $current . '>' . esc_html($title) . '</a>'; } echo '<ul class="subsubsub"><li>' . implode(' | </li><li>', $links) . '</li></ul><br class="clear" />'; // Specific method options if ($current_section) { foreach ($shipping_methods as $method) { if (get_class($method) == $current_section && $method->has_settings()) { $method->admin_options(); break; } } } else { woocommerce_admin_fields($woocommerce_settings[$current_tab]); } break; case "payment_gateways": include 'settings/settings-payment-gateways.php'; $current = $current_section ? '' : 'class="current"'; $links = array('<a href="' . admin_url('admin.php?page=woocommerce_settings&tab=payment_gateways') . '" ' . $current . '>' . __('Payment Gateways', 'woocommerce') . '</a>'); // Load shipping methods so we can show any global options they may have $payment_gateways = $woocommerce->payment_gateways->payment_gateways(); foreach ($payment_gateways as $gateway) { $title = empty($gateway->method_title) ? ucwords($gateway->id) : ucwords($gateway->method_title); $current = get_class($gateway) == $current_section ? 'class="current"' : ''; $links[] = '<a href="' . add_query_arg('section', get_class($gateway), admin_url('admin.php?page=woocommerce_settings&tab=payment_gateways')) . '"' . $current . '>' . esc_html($title) . '</a>'; } echo '<ul class="subsubsub"><li>' . implode(' | </li><li>', $links) . '</li></ul><br class="clear" />'; // Specific method options if ($current_section) { foreach ($payment_gateways as $gateway) { if (get_class($gateway) == $current_section) { $gateway->admin_options(); break; } } } else { woocommerce_admin_fields($woocommerce_settings[$current_tab]); } break; case "integration": $integrations = $woocommerce->integrations->get_integrations(); $current_section = empty($current_section) ? key($integrations) : $current_section; $links = array(); foreach ($integrations as $integration) { $title = empty($integration->method_title) ? ucwords($integration->id) : ucwords($integration->method_title); $current = $integration->id == $current_section ? 'class="current"' : ''; $links[] = '<a href="' . add_query_arg('section', $integration->id, admin_url('admin.php?page=woocommerce_settings&tab=integration')) . '"' . $current . '>' . esc_html($title) . '</a>'; } echo '<ul class="subsubsub"><li>' . implode(' | </li><li>', $links) . '</li></ul><br class="clear" />'; if (isset($integrations[$current_section])) { $integrations[$current_section]->admin_options(); } break; default: do_action('woocommerce_settings_tabs_' . $current_tab); break; } ?> <p class="submit"> <?php if (!isset($GLOBALS['hide_save_button'])) { ?> <input name="save" class="button-primary" type="submit" value="<?php _e('Save changes', 'woocommerce'); ?> " /> <?php } ?> <input type="hidden" name="subtab" id="last_tab" /> </p> </form> <script type="text/javascript"> jQuery(window).load(function(){ // Countries jQuery('select#woocommerce_allowed_countries').change(function(){ if (jQuery(this).val()=="specific") { jQuery(this).parent().parent().next('tr').show(); } else { jQuery(this).parent().parent().next('tr').hide(); } }).change(); // Color picker jQuery('.colorpick').each(function(){ jQuery('.colorpickdiv', jQuery(this).parent()).farbtastic(this); jQuery(this).click(function() { if ( jQuery(this).val() == "" ) jQuery(this).val('#'); jQuery('.colorpickdiv', jQuery(this).parent() ).show(); }); }); jQuery(document).mousedown(function(){ jQuery('.colorpickdiv').hide(); }); // Edit prompt jQuery(function(){ var changed = false; jQuery('input, textarea, select, checkbox').change(function(){ changed = true; }); jQuery('.woo-nav-tab-wrapper a').click(function(){ if (changed) { window.onbeforeunload = function() { return '<?php echo __('The changes you made will be lost if you navigate away from this page.', 'woocommerce'); ?> '; } } else { window.onbeforeunload = ''; } }); jQuery('.submit input').click(function(){ window.onbeforeunload = ''; }); }); // Sorting jQuery('table.wc_gateways tbody, table.wc_shipping tbody').sortable({ items:'tr', cursor:'move', axis:'y', handle: 'td', scrollSensitivity:40, helper:function(e,ui){ ui.children().each(function(){ jQuery(this).width(jQuery(this).width()); }); ui.css('left', '0'); return ui; }, start:function(event,ui){ ui.item.css('background-color','#f6f6f6'); }, stop:function(event,ui){ ui.item.removeAttr('style'); } }); // Chosen selects jQuery("select.chosen_select").chosen(); jQuery("select.chosen_select_nostd").chosen({ allow_single_deselect: 'true' }); }); </script> </div> <?php }