/** * 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); } }
/** * Outputs a custom textarea template in plugin options panel * * @since 1.0.0 * @return void * @author Alberto Ruggiero */ public static function output($option) { $custom_attributes = array(); if (!empty($option['custom_attributes']) && is_array($option['custom_attributes'])) { foreach ($option['custom_attributes'] as $attribute => $attribute_value) { $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"'; } } $option_value = WC_Admin_Settings::get_option($option['id'], $option['default']); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($option['id']); ?> "><?php echo esc_html($option['title']); ?> </label> </th> <td class="forminp forminp-<?php echo sanitize_title($option['type']); ?> "> <textarea name="<?php echo esc_attr($option['id']); ?> " id="<?php echo esc_attr($option['id']); ?> " style="<?php echo esc_attr($option['css']); ?> " class="<?php echo esc_attr($option['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> ><?php echo esc_textarea($option_value); ?> </textarea><br /><br /> <span class="description"><?php echo $option['desc']; ?> </span> </td> </tr> <?php }
/** * Output the settings */ public function output() { global $current_section; if ($current_section == '') { $GLOBALS['hide_save_button'] = true; } $settings = $this->get_settings($current_section); WC_Admin_Settings::output_fields($settings); $this->show_table_products(); }
/** * Render the settings for the current section * * @since 2.0.0 */ public function output() { $settings = $this->get_settings(); // inject the actual setting value before outputting the fields // ::output_fields() uses get_option() but customizations are stored // in a single option so this dynamically returns the correct value foreach ($this->customizations as $filter => $value) { add_filter("pre_option_{$filter}", array($this, 'get_customization')); } WC_Admin_Settings::output_fields($settings); }
/** * 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'); }
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'); } }
/** * 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 the Targets settings */ public function save() { try { $this->verify_request(WooCommerce_Grow_Helpers::get_field('_wpnonce', $_REQUEST), 'woocommerce-grow-targets'); $is_calculate_growth = null !== WooCommerce_Grow_Helpers::get_field('calculate_growth', $_POST) ? true : false; // Calculate and Growth settings if ($is_calculate_growth) { $initial_revenue_number = WooCommerce_Grow_Helpers::get_field('initial_revenue_number', $_POST); $initial_orders_number = WooCommerce_Grow_Helpers::get_field('initial_orders_number', $_POST); $initial_sessions_number = WooCommerce_Grow_Helpers::get_field('initial_sessions_number', $_POST); $initial_cr_number = WooCommerce_Grow_Helpers::get_field('initial_cr_number', $_POST); $initial_aov_number = WooCommerce_Grow_Helpers::get_field('initial_aov_number', $_POST); // Call to GA to get sessions for the last month $ga = WooCommerce_Grow_Google_Analytics::get_instance(); $month = date('m', strtotime('first day of previous month')); $year = date('Y'); list($start_date, $end_date) = WooCommerce_Grow_Helpers::get_first_and_last_of_the_month($month, $year); $initial_sessions = $ga->get_sessions_for_month($month, $year); $filters = array('date_min' => $start_date, 'date_max' => $end_date); $reports = WooCommerce_Grow_Helpers::setup_wc_reports($filters); $initial_revenue = WooCommerce_Grow_Helpers::get_wc_total_sales($reports); $initial_orders = WooCommerce_Grow_Helpers::get_wc_total_orders($reports); WooCommerce_Grow_Helpers::add_debug_log('Revenue: ' . $initial_revenue); WooCommerce_Grow_Helpers::add_debug_log('Orders: ' . $initial_orders); $initial_cr = WooCommerce_Grow_Helpers::calculate_cr($initial_orders, $initial_sessions); $initial_aov = WooCommerce_Grow_Helpers::calculate_aov($initial_revenue, $initial_orders); $growth_rate = WooCommerce_Grow_Helpers::get_field('growth_rate', $_POST); // Save the initial options WooCommerce_Grow_Helpers::update_option('initial_revenue_number', $initial_revenue); WooCommerce_Grow_Helpers::update_option('initial_orders_number', $initial_orders); WooCommerce_Grow_Helpers::update_option('initial_sessions_number', $initial_sessions); WooCommerce_Grow_Helpers::update_option('initial_cr_number', $initial_cr); WooCommerce_Grow_Helpers::update_option('initial_aov_number', $initial_aov); WooCommerce_Grow_Helpers::update_option('growth_rate', $growth_rate); $months = WooCommerce_Grow_Helpers::get_twelve_months_ahead(); foreach ($months as $month) { $target_sessions = WooCommerce_Grow_Helpers::calculate_growth($initial_sessions, $growth_rate); $target_cr = WooCommerce_Grow_Helpers::calculate_growth($initial_cr, $growth_rate); $target_aov = WooCommerce_Grow_Helpers::calculate_growth($initial_aov, $growth_rate); $targets['sessions_percentage'][$month['year']][$month['month']] = ceil($target_sessions); $targets['cr_percentage'][$month['year']][$month['month']] = $target_cr; $targets['aov_percentage'][$month['year']][$month['month']] = $target_aov; $targets['revenue_percentage'][$month['year']][$month['month']] = wc_format_decimal($target_sessions * $target_cr * $target_aov, 2); $targets['orders_percentage'][$month['year']][$month['month']] = ceil($target_sessions * $target_cr); } WooCommerce_Grow_Helpers::update_option('monthly_targets', $targets); } } catch (Exception $e) { WC_Admin_Settings::add_error($e->getMessage()); } }
/** * 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'); } } }
/** * Load user options into class * * @return void */ protected function load_options() { $this->enabled = $this->get_option('enabled'); $this->registration_enabled = WC_Admin_Settings::get_option('woocommerce_enable_signup_and_login_from_checkout') === 'yes' ? true : false; $this->profiles_enabled = $this->registration_enabled && $this->get_option('enable_profiles') === 'yes'; $this->title = $this->get_option('title'); $this->description = $this->get_option('description'); $this->card_types = $this->get_option('card_types'); $this->mode = $this->get_option('mode', 'capture'); $this->sandbox = $this->get_option('sandbox'); $this->site = $this->get_option('site'); $this->env_key = $this->sandbox == 'no' ? 'production' : 'sandbox'; $port = $this->cc_ports[$this->env_key]; $this->api_credentials = array('url' => "https://{$this->site}.{$this->domain}:{$port}{$this->rest_path}", 'mid' => $this->get_option("{$this->env_key}_mid"), 'user' => $this->get_option("{$this->env_key}_user"), 'pass' => $this->get_option("{$this->env_key}_password")); $this->verification = array('void_cvv' => $this->get_option('void_cvv'), 'void_avs' => $this->get_option('void_avs')); }
/** * Include the settings page classes */ public static function get_settings_pages() { if (empty(self::$settings)) { $settings = array(); include_once 'settings/class-wc-settings-page.php'; $settings[] = (include 'settings/class-wc-settings-general.php'); $settings[] = (include 'settings/class-wc-settings-products.php'); $settings[] = (include 'settings/class-wc-settings-tax.php'); $settings[] = (include 'settings/class-wc-settings-checkout.php'); $settings[] = (include 'settings/class-wc-settings-shipping.php'); $settings[] = (include 'settings/class-wc-settings-accounts.php'); $settings[] = (include 'settings/class-wc-settings-emails.php'); $settings[] = (include 'settings/class-wc-settings-integrations.php'); self::$settings = apply_filters('woocommerce_get_settings_pages', $settings); } return self::$settings; }
function woogle_update_license_key_status() { $result = woogle_activate_license_key(); if ($result == NULL) { update_option('woogle_license_key_validated', '0'); update_option('woogle_license_key_expires', '0'); WC_Admin_Settings::add_error(__('Your Woogle License Key is invalid!', 'woogle')); } elseif ($result->license == 'valid' || $result->license == 'expired') { update_option('woogle_license_key_validated', '1'); update_option('woogle_license_key_expires', $result->expires); WC_Admin_Settings::add_message(__('Your Woogle License Key is valid!', 'woogle')); } else { update_option('woogle_license_key_validated', '0'); update_option('woogle_license_key_expires', '0'); WC_Admin_Settings::add_error(__('Your Woogle License Key is invalid!', 'woogle')); } }
/** * Output the settings */ public function output() { global $current_section; // Load shipping methods so we can show any global options they may have $shipping_methods = WC()->shipping->load_shipping_methods(); if ($current_section) { foreach ($shipping_methods as $method) { if (strtolower(get_class($method)) == strtolower($current_section) && $method->has_settings()) { $method->admin_options(); break; } } } else { $settings = $this->get_settings(); WC_Admin_Settings::output_fields($settings); } }
/** * 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 the settings */ public static function save() { global $current_section, $current_tab; if (empty($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'wc-crm-settings')) { die(__('Action failed. Please refresh the page and retry.', 'woocommerce')); } // Trigger actions do_action('wc_crm_settings_save_' . $current_tab); do_action('wc_crm_update_options_' . $current_tab); do_action('wc_crm_update_options'); self::add_message(__('Your settings have been saved.', 'woocommerce')); WC_Admin_Settings::check_download_folder_protection(); // Re-add endpoints and flush rules WC()->query->init_query_vars(); WC()->query->add_endpoints(); flush_rewrite_rules(); do_action('wc_crm_settings_saved'); }
/** * Notices. */ private function notices() { if (isset($_GET['trashed'])) { $trashed = absint($_GET['trashed']); WC_Admin_Settings::add_message(sprintf(_n('1 webhook moved to the Trash.', '%d webhooks moved to the Trash.', $trashed, 'woocommerce'), $trashed)); } if (isset($_GET['untrashed'])) { $untrashed = absint($_GET['untrashed']); WC_Admin_Settings::add_message(sprintf(_n('1 webhook restored from the Trash.', '%d webhooks restored from the Trash.', $untrashed, 'woocommerce'), $untrashed)); } if (isset($_GET['deleted'])) { $deleted = absint($_GET['deleted']); WC_Admin_Settings::add_message(sprintf(_n('1 webhook permanently deleted.', '%d webhooks permanently deleted.', $deleted, 'woocommerce'), $deleted)); } if (isset($_GET['updated'])) { WC_Admin_Settings::add_message(__('Webhook updated successfully.', 'woocommerce')); } if (isset($_GET['created'])) { WC_Admin_Settings::add_message(__('Webhook created successfully.', 'woocommerce')); } }
public function check_pdf_template_version($settings) { $templates = array('woocommerce_gzdp_invoice_template_attachment', 'woocommerce_gzdp_invoice_template_attachment_first'); foreach ($templates as $template) { if ($file = get_option($template)) { $file = get_attached_file($file); if (!$file) { continue; } try { $invoice = new WC_GZDP_Invoice_Preview(); $pdf = new WC_GZDP_PDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->set_invoice($invoice); $pdf->setTemplate($invoice->get_pdf_template()); $pdf->addPage(); } catch (Exception $e) { delete_option($template); WC_Admin_Settings::add_error(_x('Your PDF template seems be converted (version > 1.4) or compressed. Please convert (http://convert.neevia.com/pdfconvert/) your pdf file to version 1.4 or lower before uploading.', 'invoices', 'woocommerce-germanized-pro')); } } } }
/** * Manage activations */ public function pages() { // Anything you need to do before a page is loaded do_action('woocommerce_grow_pages_start'); // Get current tab $current_tab = empty($_GET['tab']) ? 'dashboard' : sanitize_title($_GET['tab']); $this->add_woocommerce_grow_pages(); // Save settings if data has been posted if (!empty($_POST)) { $this->save($current_tab); } // Add any posted messages if (!empty($_GET['wc_grow_error'])) { WC_Admin_Settings::add_error(stripslashes($_GET['wc_error'])); } if (!empty($_GET['wc_grow_message'])) { WC_Admin_Settings::add_message(stripslashes($_GET['wc_message'])); } WC_Admin_Settings::show_messages(); // Add tabs on the Grow page $tabs = apply_filters('woocommerce_grow_page_tabs_array', array()); include 'views/html-grow-page.php'; }
/** * 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(); } } } }
/** * Default options. * * Sets up the default options used on the settings page. */ private static function create_options() { // Include settings so that we can run through defaults include_once dirname(__FILE__) . '/admin/class-wc-admin-settings.php'; $settings = WC_Admin_Settings::get_settings_pages(); foreach ($settings as $section) { if (!method_exists($section, 'get_settings')) { continue; } $subsections = array_unique(array_merge(array(''), array_keys($section->get_sections()))); foreach ($subsections as $subsection) { foreach ($section->get_settings($subsection) as $value) { if (isset($value['default']) && isset($value['id'])) { $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true; add_option($value['id'], $value['default'], '', $autoload ? 'yes' : 'no'); } } } } }
function wc_autoship_import_muenster_file_settings_field($value) { $vars = array('value' => $value, 'description' => WC_Admin_Settings::get_field_description($value), 'frequency_options' => get_option($value['id'])); $relative_path = 'admin/wc-settings/wc-autoship/import-muenster-file'; wc_autoship_import_muenster_include_plugin_template($relative_path, $vars); }
/** * 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); } }
/** * Register WC settings from WP-API to the REST API. * @since 2.7.0 */ public function register_wp_admin_settings() { $pages = WC_Admin_Settings::get_settings_pages(); foreach ($pages as $page) { new WC_Register_WP_Admin_Settings($page, 'page'); } $emails = WC_Emails::instance(); foreach ($emails->get_emails() as $email) { new WC_Register_WP_Admin_Settings($email, 'email'); } }
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); }
/** * Notices. */ public static function notices() { if (isset($_GET['revoked']) && 1 == $_GET['revoked']) { WC_Admin_Settings::add_message(__('API key revoked successfully.', 'woocommerce')); } }
/** * Default options * * Sets up the default options used on the settings page * * @access public */ function create_options() { // Include settings so that we can run through defaults include_once 'admin/class-wc-admin-settings.php'; $settings = WC_Admin_Settings::get_settings_pages(); foreach ($settings as $section) { if (!method_exists($section, 'get_settings')) { continue; } foreach ($section->get_settings() as $value) { if (isset($value['default']) && isset($value['id'])) { $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true; add_option($value['id'], $value['default'], '', $autoload ? 'yes' : 'no'); } } // Special case to install the inventory settings. if ($section instanceof WC_Settings_Products) { foreach ($section->get_settings('inventory') as $value) { if (isset($value['default']) && isset($value['id'])) { $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true; add_option($value['id'], $value['default'], '', $autoload ? 'yes' : 'no'); } } } } }
/** * 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()); }
/** * Create new Woocommerce admin field: yith_ywzm_image_width * * @access public * @param array $value * @return void * @since 1.1.3 */ public function admin_fields_yith_ywzm_image_width($value) { $width = WC_Admin_Settings::get_option($value['id'] . '[width]', $value['default']['width']); $height = WC_Admin_Settings::get_option($value['id'] . '[height]', $value['default']['height']); $crop = WC_Admin_Settings::get_option($value['id'] . '[crop]'); $crop = $crop == 'on' || $crop == '1' ? 1 : 0; $crop = checked(1, $crop, false); ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo esc_html($value['title']); ?> </th> <td class="forminp image_width_settings"> <input name="<?php echo esc_attr($value['id']); ?> [width]" id="<?php echo esc_attr($value['id']); ?> -width" type="text" size="3" value="<?php echo $width; ?> " /> × <input name="<?php echo esc_attr($value['id']); ?> [height]" id="<?php echo esc_attr($value['id']); ?> -height" type="text" size="3" value="<?php echo $height; ?> " />px <span class="description"><?php echo $value['desc']; ?> </span> <br> <label><input name="<?php echo esc_attr($value['id']); ?> [crop]" id="<?php echo esc_attr($value['id']); ?> -crop" type="checkbox" <?php echo $crop; ?> /> <?php _e('Do you want to hard crop the image?', 'woocommerce'); ?> </label> </td> </tr><?php }