Skip to content

Commit 373df73

Browse files
release: fixes
- Fixed early textdomain loading issue - Fixed uploaded files not showing up in emails with WooCommerce
2 parents 6c3a8ac + 6458a82 commit 373df73

File tree

5 files changed

+182
-123
lines changed

5 files changed

+182
-123
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
*

classes/plugin.class.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,15 @@ function __construct() {
169169

170170
// Changing display to label in orders
171171
add_filter( 'woocommerce_order_item_display_meta_key', 'ppom_woocommerce_order_key', 10, 3 );
172-
// Few inputs like file/crop/image need to show meta value in tags
173-
add_filter( 'woocommerce_order_item_display_meta_value', 'ppom_woocommerce_order_value', 10, 3 );
172+
173+
// when email improvements feature enabled in woocommerce.
174+
if ( ppom_wc_email_improvements_enabled() ) {
175+
add_action( 'woocommerce_order_item_meta_end', 'ppom_woocommerce_order_item_meta_html', 10, 4 );
176+
add_filter( 'woocommerce_display_item_meta', '__return_empty_string' );
177+
} else {
178+
// Few inputs like file/crop/image need to show meta value in tags
179+
add_filter( 'woocommerce_order_item_display_meta_value', 'ppom_woocommerce_order_value', 10, 3 );
180+
}
174181
// Hiding some additional field like ppom_has_quantities
175182
add_filter( 'woocommerce_order_item_get_formatted_meta_data', 'ppom_woocommerce_hide_order_meta', 10, 2 );
176183
// see: https://github.com/woocommerce/woocommerce/issues/23294

inc/woocommerce.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,3 +1414,42 @@ function ppom_wc_order_again_compatibility( $cart_item_data, $item, $order ) {
14141414

14151415
return $cart_item_data;
14161416
}
1417+
1418+
/**
1419+
* Outputs the formatted meta data for WooCommerce order items.
1420+
*
1421+
* @param int $item_id The item ID.
1422+
* @param \WC_Order_Item_Product $item The order item object.
1423+
*/
1424+
function ppom_woocommerce_order_item_meta_html( $item_id, $item ) {
1425+
$formatted_meta = $item->get_formatted_meta_data();
1426+
1427+
$strings = array();
1428+
$meta_item_html = '';
1429+
$output_args = apply_filters( 'ppom_woocommerce_item_meta_args',
1430+
array(
1431+
'before' => '<div>',
1432+
'after' => '</div>',
1433+
'separator' => '<br>',
1434+
'label_before' => '<span style="float: left;">',
1435+
'label_after' => ':</span> ',
1436+
)
1437+
);
1438+
foreach ( $formatted_meta as $meta ) {
1439+
$strings[] = $output_args['before'] . $output_args['label_before'] . wp_kses_post( $meta->display_key ) . $output_args['label_after'] . ppom_woocommerce_order_value( $meta->display_value, $meta, $item ) . $output_args['after'];
1440+
}
1441+
1442+
if ( $strings ) {
1443+
$meta_item_html = implode( $output_args['separator'], $strings );
1444+
}
1445+
echo wp_kses_post( $meta_item_html );
1446+
}
1447+
1448+
/**
1449+
* Check if the email improvements feature is enabled.
1450+
*
1451+
* @return bool
1452+
*/
1453+
function ppom_wc_email_improvements_enabled() {
1454+
return 'yes' === get_option( 'woocommerce_feature_email_improvements_enabled', 'no' );
1455+
}

0 commit comments

Comments
 (0)