mirror of
https://gitlab.com/ArkHost/WP-WHMCS-Pricing.git
synced 2026-09-20 01:47:34 +02:00
v1.0-release
This commit is contained in:
@@ -137,6 +137,46 @@ class WHMCS_Pricing_Admin {
|
||||
)
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'decimal_separator',
|
||||
__('Decimal Separator', 'whmcs-pricing'),
|
||||
array($this, 'render_select_field'),
|
||||
'whmcs-pricing',
|
||||
'whmcs_pricing_display_section',
|
||||
array(
|
||||
'name' => 'decimal_separator',
|
||||
'options' => array(
|
||||
'.' => __('Period (.) - Example: 1,234.56', 'whmcs-pricing'),
|
||||
',' => __('Comma (,) - Example: 1.234,56', 'whmcs-pricing')
|
||||
),
|
||||
'description' => __('Choose the character to use as decimal separator', 'whmcs-pricing')
|
||||
)
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'hide_currency_symbol',
|
||||
__('Hide Currency Symbol', 'whmcs-pricing'),
|
||||
array($this, 'render_checkbox_field'),
|
||||
'whmcs-pricing',
|
||||
'whmcs_pricing_display_section',
|
||||
array(
|
||||
'name' => 'hide_currency_symbol',
|
||||
'label' => __('Hide currency symbol/prefix from prices', 'whmcs-pricing')
|
||||
)
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'hide_billing_cycle',
|
||||
__('Hide Billing Cycle', 'whmcs-pricing'),
|
||||
array($this, 'render_checkbox_field'),
|
||||
'whmcs-pricing',
|
||||
'whmcs_pricing_display_section',
|
||||
array(
|
||||
'name' => 'hide_billing_cycle',
|
||||
'label' => __('Hide billing cycle text (e.g., "per month") from prices', 'whmcs-pricing')
|
||||
)
|
||||
);
|
||||
|
||||
// Performance Settings Section
|
||||
add_settings_section(
|
||||
'whmcs_pricing_performance_section',
|
||||
@@ -439,6 +479,28 @@ class WHMCS_Pricing_Admin {
|
||||
<?php
|
||||
}
|
||||
|
||||
public function render_select_field($args) {
|
||||
$settings = get_option('whmcs_pricing_settings', array());
|
||||
$value = isset($settings[$args['name']]) ? $settings[$args['name']] : '';
|
||||
|
||||
// Set default value if not set
|
||||
if (empty($value) && isset($args['default'])) {
|
||||
$value = $args['default'];
|
||||
}
|
||||
?>
|
||||
<select name="whmcs_pricing_settings[<?php echo esc_attr($args['name']); ?>]" class="regular-text">
|
||||
<?php foreach ($args['options'] as $option_value => $option_label): ?>
|
||||
<option value="<?php echo esc_attr($option_value); ?>" <?php selected($value, $option_value); ?>>
|
||||
<?php echo esc_html($option_label); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php if (isset($args['description'])): ?>
|
||||
<p class="description"><?php echo esc_html($args['description']); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function render_currency_field($args) {
|
||||
$settings = get_option('whmcs_pricing_settings', array());
|
||||
$value = isset($settings[$args['name']]) ? $settings[$args['name']] : 'USD';
|
||||
@@ -464,7 +526,8 @@ class WHMCS_Pricing_Admin {
|
||||
'SGD' => 'SGD - Singapore Dollar (S$)',
|
||||
'NZD' => 'NZD - New Zealand Dollar (NZ$)',
|
||||
'MXN' => 'MXN - Mexican Peso (Mex$)',
|
||||
'ZAR' => 'ZAR - South African Rand (R)'
|
||||
'ZAR' => 'ZAR - South African Rand (R)',
|
||||
'ARS' => 'ARS - Argentine Peso ($)'
|
||||
);
|
||||
?>
|
||||
<select name="whmcs_pricing_settings[<?php echo esc_attr($args['name']); ?>]" class="regular-text">
|
||||
@@ -492,7 +555,7 @@ class WHMCS_Pricing_Admin {
|
||||
}
|
||||
|
||||
// Sanitize text fields
|
||||
$text_fields = array('api_identifier', 'api_secret', 'default_currency');
|
||||
$text_fields = array('api_identifier', 'api_secret', 'default_currency', 'decimal_separator');
|
||||
foreach ($text_fields as $field) {
|
||||
if (isset($input[$field])) {
|
||||
$sanitized[$field] = sanitize_text_field($input[$field]);
|
||||
@@ -506,6 +569,8 @@ class WHMCS_Pricing_Admin {
|
||||
|
||||
// Sanitize checkboxes
|
||||
$sanitized['show_decimals'] = isset($input['show_decimals']) ? true : false;
|
||||
$sanitized['hide_currency_symbol'] = isset($input['hide_currency_symbol']) ? true : false;
|
||||
$sanitized['hide_billing_cycle'] = isset($input['hide_billing_cycle']) ? true : false;
|
||||
$sanitized['debug_mode'] = isset($input['debug_mode']) ? true : false;
|
||||
|
||||
return $sanitized;
|
||||
|
||||
Reference in New Issue
Block a user