Skip to content

Commit b8da0f2

Browse files
fix: early textdomain loading
1 parent 24a3068 commit b8da0f2

File tree

3 files changed

+134
-121
lines changed

3 files changed

+134
-121
lines changed

backend/options.php

Lines changed: 109 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -16,117 +16,121 @@
1616
}
1717

1818
/**
19-
* Register Panel Fieds Against Panel ID
20-
* --------------------------------------
19+
* Register Settings Panel
20+
* --------------------------
2121
*/
22-
$core_settings = array(
23-
'ppom_general_section1' => array(
24-
'type' => 'section',
25-
'title' => __( 'Basic Settings', 'woocommerce-product-addon' ),
26-
),
27-
'ppom_disable_bootstrap' => array(
28-
'type' => 'checkbox',
29-
'title' => __( 'Disable Bootstrap', 'woocommerce-product-addon' ),
30-
'desc' => __( 'Bootstrap JS is loaded from a CDN by default. You can disable it if your site is already loading it.', 'woocommerce-product-addon' ),
31-
'label' => __( 'Yes', 'woocommerce-product-addon' ),
32-
),
33-
'ppom_enable_legacy_inputs_rendering' => array(
34-
'type' => 'checkbox',
35-
'title' => __( 'Legacy Inputs Rendering', 'woocommerce-product-addon' ),
36-
'desc' => __( 'PPOM Version 22.0 is a major update. If any issues occur, you can revert to the previous version using this option.', 'woocommerce-product-addon' ),
37-
),
38-
'ppom_new_conditions' => array(
39-
'type' => 'checkbox',
40-
'title' => __( 'Legacy Conditions Script', 'woocommerce-product-addon' ),
41-
'desc' => __( 'If you found any issue in conditions you may enable this option.', 'woocommerce-product-addon' ),
42-
),
43-
'ppom_legacy_price' => array(
44-
'type' => 'checkbox',
45-
'title' => __( 'Enable Legacy Price Calculations', 'woocommerce-product-addon' ),
46-
'desc' => __( 'Enable this option to use the legacy method for price calculations.', 'woocommerce-product-addon' ),
47-
),
48-
'ppom_permission_mfields' => array(
49-
'type' => 'select',
50-
'title' => __( 'PPOM Permissions', 'woocommerce-product-addon' ),
51-
'desc' => __( 'You can set permissions here to allow different roles to manage PPOM fields.', 'woocommerce-product-addon' ),
52-
'default' => 'administrator',
53-
'placeholder' => __( 'choose role', 'woocommerce-product-addon' ),
54-
'options' => ppom_get_all_editable_roles(),
55-
'style' => 'multiselect',
56-
),
57-
'ppom_restricted_file_type' => array(
58-
'type' => 'text',
59-
'title' => __( 'Restricted File Types', 'woocommerce-product-addon' ),
60-
'desc' => __( 'Specify the file types that are restricted from being uploaded in this section.', 'woocommerce-product-addon' ),
61-
'default' => __( 'php,php4,php5,php6,php7,phtml,exe,shtml', 'woocommerce-product-addon' ),
62-
),
63-
'ppom_general_section2' => array(
64-
'type' => 'section',
65-
'title' => __( 'Label Settings', 'woocommerce-product-addon' ),
66-
),
67-
'ppom_label_option_total' => array(
68-
'type' => 'text',
69-
'title' => __( 'Option Total Label Inside Price Table', 'woocommerce-product-addon' ),
70-
'default' => __( 'Option Total', 'woocommerce-product-addon' ),
71-
),
72-
'ppom_label_product_price' => array(
73-
'type' => 'text',
74-
'title' => __( 'Product Price Label inside Price Table', 'woocommerce-product-addon' ),
75-
'default' => __( 'Product Price', 'woocommerce-product-addon' ),
76-
),
77-
'ppom_label_total' => array(
78-
'type' => 'text',
79-
'title' => __( 'Total Label inside Price Table', 'woocommerce-product-addon' ),
80-
'default' => __( 'Total', 'woocommerce-product-addon' ),
81-
),
82-
'ppom_label_total_discount' => array(
83-
'type' => 'text',
84-
'title' => __( 'Total Discount Label Inside Price Table', 'woocommerce-product-addon' ),
85-
'default' => __( 'Total Discount', 'woocommerce-product-addon' ),
86-
),
87-
'ppom_label_option_total_suffex' => array(
88-
'type' => 'text',
89-
'title' => __( 'Option Total Suffix', 'woocommerce-product-addon' ),
90-
'desc' => __( 'Specify the label to display tax or VAT information, such as \'VAT Included\' or \'Tax Applied,\' inside the price table.', 'woocommerce-product-addon' ),
91-
),
92-
);
9322

94-
/**
95-
* Register Panel Against Tab ID
96-
* -------------------------------
97-
*/
98-
$panel_meta = array(
99-
'ppom_admin_core_settings' => array(
100-
'id' => 'ppom_admin_core_settings',
101-
'title' => 'General Settings',
102-
'desc' => '',
103-
'is_sabpanel' => true,
104-
'active' => 'yes',
105-
),
106-
);
23+
function ppom_load_free_options() {
24+
25+
/**
26+
* Register Panel Fieds Against Panel ID
27+
* --------------------------------------
28+
*/
29+
$core_settings = array(
30+
'ppom_general_section1' => array(
31+
'type' => 'section',
32+
'title' => __( 'Basic Settings', 'woocommerce-product-addon' ),
33+
),
34+
'ppom_disable_bootstrap' => array(
35+
'type' => 'checkbox',
36+
'title' => __( 'Disable Bootstrap', 'woocommerce-product-addon' ),
37+
'desc' => __( 'Bootstrap JS is loaded from a CDN by default. You can disable it if your site is already loading it.', 'woocommerce-product-addon' ),
38+
'label' => __( 'Yes', 'woocommerce-product-addon' ),
39+
),
40+
'ppom_enable_legacy_inputs_rendering' => array(
41+
'type' => 'checkbox',
42+
'title' => __( 'Legacy Inputs Rendering', 'woocommerce-product-addon' ),
43+
'desc' => __( 'PPOM Version 22.0 is a major update. If any issues occur, you can revert to the previous version using this option.', 'woocommerce-product-addon' ),
44+
),
45+
'ppom_new_conditions' => array(
46+
'type' => 'checkbox',
47+
'title' => __( 'Legacy Conditions Script', 'woocommerce-product-addon' ),
48+
'desc' => __( 'If you found any issue in conditions you may enable this option.', 'woocommerce-product-addon' ),
49+
),
50+
'ppom_legacy_price' => array(
51+
'type' => 'checkbox',
52+
'title' => __( 'Enable Legacy Price Calculations', 'woocommerce-product-addon' ),
53+
'desc' => __( 'Enable this option to use the legacy method for price calculations.', 'woocommerce-product-addon' ),
54+
),
55+
'ppom_permission_mfields' => array(
56+
'type' => 'select',
57+
'title' => __( 'PPOM Permissions', 'woocommerce-product-addon' ),
58+
'desc' => __( 'You can set permissions here to allow different roles to manage PPOM fields.', 'woocommerce-product-addon' ),
59+
'default' => 'administrator',
60+
'placeholder' => __( 'choose role', 'woocommerce-product-addon' ),
61+
'options' => ppom_get_all_editable_roles(),
62+
'style' => 'multiselect',
63+
),
64+
'ppom_restricted_file_type' => array(
65+
'type' => 'text',
66+
'title' => __( 'Restricted File Types', 'woocommerce-product-addon' ),
67+
'desc' => __( 'Specify the file types that are restricted from being uploaded in this section.', 'woocommerce-product-addon' ),
68+
'default' => __( 'php,php4,php5,php6,php7,phtml,exe,shtml', 'woocommerce-product-addon' ),
69+
),
70+
'ppom_general_section2' => array(
71+
'type' => 'section',
72+
'title' => __( 'Label Settings', 'woocommerce-product-addon' ),
73+
),
74+
'ppom_label_option_total' => array(
75+
'type' => 'text',
76+
'title' => __( 'Option Total Label Inside Price Table', 'woocommerce-product-addon' ),
77+
'default' => __( 'Option Total', 'woocommerce-product-addon' ),
78+
),
79+
'ppom_label_product_price' => array(
80+
'type' => 'text',
81+
'title' => __( 'Product Price Label inside Price Table', 'woocommerce-product-addon' ),
82+
'default' => __( 'Product Price', 'woocommerce-product-addon' ),
83+
),
84+
'ppom_label_total' => array(
85+
'type' => 'text',
86+
'title' => __( 'Total Label inside Price Table', 'woocommerce-product-addon' ),
87+
'default' => __( 'Total', 'woocommerce-product-addon' ),
88+
),
89+
'ppom_label_total_discount' => array(
90+
'type' => 'text',
91+
'title' => __( 'Total Discount Label Inside Price Table', 'woocommerce-product-addon' ),
92+
'default' => __( 'Total Discount', 'woocommerce-product-addon' ),
93+
),
94+
'ppom_label_option_total_suffex' => array(
95+
'type' => 'text',
96+
'title' => __( 'Option Total Suffix', 'woocommerce-product-addon' ),
97+
'desc' => __( 'Specify the label to display tax or VAT information, such as \'VAT Included\' or \'Tax Applied,\' inside the price table.', 'woocommerce-product-addon' ),
98+
),
99+
);
107100

101+
/**
102+
* Register Main Tabs
103+
* --------------------------
104+
*/
105+
$register_tabs = array(
106+
'ppom_general_tab' => array(
107+
'tab_id' => 'ppom_general_tab',
108+
'title' => 'PPOM',
109+
'icon' => '',
110+
'classes' => array( 'active' ),
111+
'enable' => true,
112+
),
113+
);
108114

109-
/**
110-
* Register Main Tabs
111-
* --------------------------
112-
*/
113-
$register_tabs = array(
114-
'ppom_general_tab' => array(
115-
'tab_id' => 'ppom_general_tab',
116-
'title' => 'PPOM',
117-
'icon' => '',
118-
'classes' => array( 'active' ),
119-
'enable' => true,
120-
),
121-
);
115+
/**
116+
* Register Panel Against Tab ID
117+
* -------------------------------
118+
*/
119+
$panel_meta = array(
120+
'ppom_admin_core_settings' => array(
121+
'id' => 'ppom_admin_core_settings',
122+
'title' => 'General Settings',
123+
'desc' => '',
124+
'is_sabpanel' => true,
125+
'active' => 'yes',
126+
),
127+
);
122128

129+
PPOMSETTINGS()->register_tabs( $register_tabs )->register_panel( 'ppom_general_tab', $panel_meta );
130+
PPOMSETTINGS()->register_setting( 'ppom_admin_core_settings', $core_settings );
131+
}
132+
add_action( 'init', 'ppom_load_free_options' );
123133

124-
/**
125-
* Register Settings Panel
126-
* --------------------------
127-
*/
128-
PPOMSETTINGS()->register_tabs( $register_tabs )->register_panel( 'ppom_general_tab', $panel_meta );
129-
PPOMSETTINGS()->register_setting( 'ppom_admin_core_settings', $core_settings );
130134
function ppom_load_pro_options() {
131135
$pro_settings = array(
132136
'ppom_pro_basics' => array(

backend/settings-panel.class.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ class PPOM_SettingsFramework {
7373
var $scripts_class;
7474

7575
function __construct() {
76+
$this->config = array(
77+
'id' => 'ppom',
78+
'plugin_url' => PPOM_URL,
79+
);
7680

77-
78-
$this->register_config();
81+
add_action( 'init', array( $this, 'register_config' ) );
7982

8083
self::$assets_url = $this->get_config( 'plugin_url' ) . '/backend/assets';
8184

@@ -120,9 +123,8 @@ public static function get_instance() {
120123
*/
121124
public function register_config() {
122125

123-
$this->config = array(
126+
$config = array(
124127
'name' => __( 'PPOM Admin Settings', 'woocommerce-product-addon' ),
125-
'id' => 'ppom',
126128
'version' => '1.0',
127129
'form_tag' => false,
128130
'menu_type' => 'wc',
@@ -136,8 +138,9 @@ public function register_config() {
136138
'plugin_name' => __( 'PPOM', 'woocommerce-product-addon' ),
137139
'plugin_version' => PPOM_VERSION,
138140
'plugin_domain' => 'woocommerce-product-addon',
139-
'plugin_url' => PPOM_URL,
140141
);
142+
143+
$this->config = array_merge( $this->config, $config );
141144
}
142145

143146

classes/admin.class.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,7 @@ function __construct() {
3636
/*
3737
* [1] TODO: change this for plugin admin pages
3838
*/
39-
$this->menu_pages = array(
40-
array(
41-
'page_title' => __( 'PPOM', 'woocommerce-product-addon' ),
42-
'menu_title' => __( 'PPOM', 'woocommerce-product-addon' ),
43-
'cap' => 'manage_options',
44-
'slug' => 'ppom',
45-
'callback' => 'product_meta',
46-
'parent_slug' => 'woocommerce',
47-
),
48-
);
49-
39+
add_action( 'init', array( $this, 'menu_page_options' ) );
5040

5141
add_action(
5242
'admin_menu',
@@ -90,6 +80,22 @@ function __construct() {
9080
add_action( 'admin_init', array( $this, 'ppom_create_db_tables' ) );
9181
}
9282

83+
/**
84+
* Menu page options.
85+
*/
86+
public function menu_page_options() {
87+
$this->menu_pages = array(
88+
array(
89+
'page_title' => __( 'PPOM', 'woocommerce-product-addon' ),
90+
'menu_title' => __( 'PPOM', 'woocommerce-product-addon' ),
91+
'cap' => 'manage_options',
92+
'slug' => 'ppom',
93+
'callback' => 'product_meta',
94+
'parent_slug' => 'woocommerce',
95+
),
96+
);
97+
}
98+
9399
/**
94100
* Add upgrade to pro plugin action link.
95101
*

0 commit comments

Comments
 (0)