本文整理汇总了PHP中WC_Admin_Settings类的典型用法代码示例。如果您正苦于以下问题:PHP WC_Admin_Settings类的具体用法?PHP WC_Admin_Settings怎么用?PHP WC_Admin_Settings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WC_Admin_Settings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Save settings.
*
* @since 1.0.0
*/
public function save() {
global $current_section;
$settings = $this->get_settings( $current_section );
WC_Admin_Settings::save_fields( $settings );
}
示例2: save
/**
* 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);
}
}
示例3: output
/**
* 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
}
示例4: output
/**
* 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();
}
示例5: output
/**
* 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);
}
示例6: save
/**
* 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_%')");
}
示例7: save
/**
* 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');
}
示例8: save_settings
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');
}
}
示例9: save
/**
* 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);
}
示例10: save
/**
* 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());
}
}
示例11: save
/**
* 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');
}
}
}
示例12: load_options
/**
* 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'));
}
示例13: woogle_update_license_key_status
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'));
}
}
示例14: output
/**
* 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);
}
}
示例15: save
/**
* 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);
}
}
}