class-wp-plugin-options.php
4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* The admin-specific functionality of the plugin.
*
* @link https://wordpress.org/plugins/woocommerce-role-based-price/
* @package Role Based Price For WooCommerce
* @subpackage Role Based Price For WooCommerce/Admin
* @since 3.0
*/
if( ! defined('WPINC') ) {
die;
}
class WooCommerce_Role_Based_Price_Admin_Settings_Options {
public function __construct() {
add_filter('wc_rbp_settings_pages', array( $this, 'settings_pages' ));
add_filter('wc_rbp_settings_section', array( $this, 'settings_section' ));
add_filter('wc_rbp_settings_fields', array( $this, 'settings_fields' ));
}
public function settings_pages($page) {
$page[] = array( 'id' => 'general', 'slug' => 'general', 'title' => __('General', WC_RBP_TXT) );
$page[] = array(
'id' => 'addonssettings',
'slug' => 'addonssettings',
'title' => __('Extensions Options', WC_RBP_TXT),
);
$page[] = array( 'id' => 'addons', 'slug' => 'wcrbpaddons', 'title' => __('Extensions', WC_RBP_TXT) );
return $page;
}
public function settings_section($section) {
$section['general'][] = array( 'id' => 'general', 'title' => __('General', WC_RBP_TXT) );
$section['addons'][] = array( 'id' => 'addons', 'title' => '' );
$addonSettings = array(
'addon_sample' => array(
'id' => 'addonssettings',
'title' => __('No Addons Activated / Installed.', WC_RBP_TXT),
),
);
$addonSettings = apply_filters('wc_rbp_addon_sections', $addonSettings);
if( count($addonSettings) > 1 )
unset($addonSettings['addon_sample']);
$section['addonssettings'] = $addonSettings;
return $section;
}
public function settings_fields($fields) {
$fields['general']['general'][] = array(
'id' => WC_RBP_DB . 'allowed_roles',
'multiple' => 'true',
'type' => 'select',
'label' => __('Allowed User Roles', WC_RBP_TXT),
'desc' => __('User Roles To List In Product Edit Page', WC_RBP_TXT),
'options' => wc_rbp_sort_array_by_array(wc_rbp_get_user_roles_selectbox(), wc_rbp_allowed_roles()),
'attr' => array(
'class' => 'wc-rbp-enhanced-select',
'multiple' => 'multiple',
),
);
$fields['general']['general'][] = array(
'id' => WC_RBP_DB . 'allowed_price',
'type' => 'select',
'multiple' => TRUE,
'label' => __('Allowed Product Pricing', WC_RBP_TXT),
'desc' => __('Price Fields To List In Product Edit Page', WC_RBP_TXT),
'options' => wc_rbp_sort_array_by_array(wc_rbp_avaiable_price_type(), wc_rbp_allowed_price()),
'attr' => array(
'class' => 'wc-rbp-enhanced-select',
'style' => 'width:auto;max-width:35%;',
'multiple' => 'multiple',
),
);
$price_type = wc_rbp_avaiable_price_type();
foreach( $price_type as $pK => $pV ) {
$fields['general']['general'][] = array(
'id' => WC_RBP_DB . $pK . '_label',
'type' => 'text',
'label' => $pV . __(' Label ', WC_RBP_TXT),
'default' => $pV,
'attr' => array(
'style' => 'width:auto;max-width:35%;',
),
);
}
if( class_exists('woocommerce_wpml') ) {
$fields['general']['general'][] = array(
'id' => WC_RBP_DB . 'enable_wpml_integration',
'type' => 'checkbox',
'label' => __('WPML Integration', WC_RBP_TXT),
'desc' => __('check if you have installed wpml and the price are showing wrong. ', WC_RBP_TXT),
'attr' => array( 'class' => 'wc_rbp_checkbox', ),
);
}
$addonSettings = array( 'addon_sample' => array() );
$addonSettings = apply_filters('wc_rbp_addon_fields', $addonSettings);
unset($addonSettings['addon_sample']);
$fields['addonssettings'] = $addonSettings;
return $fields;
}
}
return new WooCommerce_Role_Based_Price_Admin_Settings_Options;