Skip to content

Commit 3162111

Browse files
committed
Move setting registration logic
Add mailchimp default keys to ignore list Printing empty item footer message is more efficient Delete all options when uninstalled
1 parent 36ade7c commit 3162111

File tree

5 files changed

+52
-16
lines changed

5 files changed

+52
-16
lines changed

create-settings.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ function star_cloudprnt_is_woo_activated()
88

99
function star_cloudprnt_settings()
1010
{
11-
12-
/* Attempt to set the default print job trigger to "status_processing" for new installs, but "thankyou" for sites that have
13-
already been running with the plugin - to avoid potentially breaking thos sites after upgrading the plugin, since some sites use
14-
other plugins to change the default order status.
15-
*/
16-
$trigger_default = "status_processing"; // Recommended default for new sites, at which time users can choose another option if preferred
17-
if(get_option('star-cloudprnt-select') != "")
18-
$trigger_default = "thankyou";
1911

2012
add_settings_section("star_cloudprnt_setup_section", "CloudPRNT Setup", "star_cloudprnt_setup_section_info", "star_cloudprnt_setup");
2113
add_settings_field("star-cloudprnt-select", "CloudPRNT", "star_cloudprnt_select_display", "star_cloudprnt_setup", "star_cloudprnt_setup_section");
@@ -35,6 +27,17 @@ function star_cloudprnt_settings()
3527
add_settings_field("star-cloudprnt-order-fields", "Additional Order Fields", "star_cloudPRNT_order_fields_display", "star_cloudprnt_setup", "star_cloudprnt_design_section");
3628
add_settings_field("star-cloudprnt-logo", "Logo", "star_cloudPRNT_print_logo_display", "star_cloudprnt_setup", "star_cloudprnt_design_section");
3729

30+
}
31+
32+
function star_cloudprnt_register_settings()
33+
{
34+
/* Attempt to set the default print job trigger to "status_processing" for new installs, but "thankyou" for sites that have
35+
already been running with the plugin - to avoid potentially breaking thos sites after upgrading the plugin, since some sites use
36+
other plugins to change the default order status.
37+
*/
38+
$trigger_default = "status_processing"; // Recommended default for new sites, at which time users can choose another option if preferred
39+
if(get_option('star-cloudprnt-select') != false)
40+
$trigger_default = "thankyou";
3841

3942
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-select");
4043
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-printer-select");
@@ -51,7 +54,7 @@ function star_cloudprnt_settings()
5154
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-print-order-meta-cb");
5255
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-print-order-meta-reformat-keys", array("default" => "on"));
5356
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-print-order-meta-hidden", array("default" => "off"));
54-
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-print-order-meta-exclusions", array("default" => "is_vat_exempt,"));
57+
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-print-order-meta-exclusions", array("default" => "is_vat_exempt, mailchimp_woocommerce_campaign_id, mailchimp_woocommerce_landing_site"));
5558

5659
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-print-logo-top-cb");
5760
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-print-logo-top-input");
@@ -61,7 +64,8 @@ function star_cloudprnt_settings()
6164
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-buzzer-start", array("default" => ""));
6265
register_setting("star_cloudprnt_setup_section", "star-cloudprnt-buzzer-end", array("default" => ""));
6366
}
64-
67+
68+
6569
function star_cloudprnt_menu_item()
6670
{
6771
add_submenu_page("options-general.php", "Star CloudPRNT for WooCommerce", "Star CloudPRNT for WooCommerce", "manage_options", "star-cloudprnt-settings-admin", "star_cloudprnt_page");

order-handler.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ function star_cloudprnt_print_address($printer, $selectedPrinter, $order, $order
167167
$postcode = $gkv('_shipping_postcode');
168168
$tel = $gkv('_billing_phone');
169169

170+
$printer->add_new_line(1);
171+
170172
$printer->set_text_emphasized();
171173
if ($a1 == '')
172174
{
@@ -286,9 +288,12 @@ function star_cloudprnt_print_items_footer(&$printer, &$selectedPrinter, &$order
286288
{
287289
$item_footer_message = get_option('star-cloudprnt-print-items-footer-message');
288290

291+
if(empty($item_footer_message))
292+
return;
293+
289294
$printer->add_new_line(1);
290295
$printer->add_text_line(wordwrap($item_footer_message, $selectedPrinter['columns'], "\n", true));
291-
$printer->add_new_line(1);
296+
292297
}
293298

294299
// Print info below items list

readme.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: star, printing, printers, automated, e-commerce, store, sales, downloadabl
44
Requires at least: 5.0
55
Tested up to: 5.6
66
Requires PHP: 7.2
7-
Stable tag: 2.0.0
7+
Stable tag: 2.0.1
88
License: MIT
99

1010
Star CloudPRNT for WooCommerce enables Cloud printing technology with your Star Receipt printer.
@@ -85,12 +85,12 @@ If issues continue, then please check the quality of your printers internet conn
8585

8686
This means that you printer is unable to connect with your server, and can have many potential causes:
8787

88-
# As a first step, if you are using an mC-Print2 or mC-Print3 model printer, the please update your printer firmware to version 3.0 or later to ensure compatibility with web hosts that have stronger TLS encryption.
88+
As a first step, if you are using an mC-Print2 or mC-Print3 model printer, the please update your printer firmware to version 3.0 or later to ensure compatibility with web hosts that have stronger TLS encryption.
8989
Firmware can be updated using the Star "mC-Print Utility" app, available via Google Play, or Apple App stores.
9090

91-
# Check that the printer has a working outgoing internet connection. Star tech support may be able to help with this if needed.
91+
Check that the printer has a working outgoing internet connection. Star tech support may be able to help with this if needed.
9292

93-
# Ensure that your your hosting does not have a traffic filter that may be blocking the printer from connecting to your web site or aggressively caching responses to your sites CloudPRNT URL. It may be necessary to ask your hosting provided to set up a rule to allow your printer to connect to your sites CloudPRNT URL. They must allow at least GET and POST requests without caching responses.
93+
Ensure that your your hosting does not have a traffic filter that may be blocking the printer from connecting to your web site or aggressively caching responses to your sites CloudPRNT URL. It may be necessary to ask your hosting provided to set up a rule to allow your printer to connect to your sites CloudPRNT URL. They must allow at least GET and POST requests without caching responses.
9494

9595

9696
== Screenshots ==
@@ -110,6 +110,12 @@ This means that you printer is unable to connect with your server, and can have
110110

111111
== Changelog ==
112112

113+
= 2.0.1 =
114+
* Do not print any blank lines if the items footer text is empty
115+
* Add some mailchimp metadata key names to the defailt exclusions list
116+
* Change the timing for registering settings, to avoid reported issue with accessing settings with their default value.
117+
* Remove all settings when uninstalled
118+
113119
= 2.0.0 =
114120
* Make printing trigger method user configurable
115121
* Clean-up settings page design

star-cloudprnt-for-woocommerce.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Star CloudPRNT for WooCommerce
44
* Plugin URI: http://www.star-emea.com
55
* Description: Star CloudPRNT for WooCommerce enables cloud printing technology with your Star Receipt printer.
6-
* Version: 2.0.0
6+
* Version: 2.0.1 beta 01
77
* Author: lawrenceowen, athompson1, gcubero, fmahmood
88
* Author URI: http://www.star-emea.com/support
99
* Requires at least: 5.0
@@ -24,6 +24,8 @@
2424
include_once(plugin_dir_path(__FILE__).star_cloudprnt_get_os_path('create-settings.php'));
2525
include_once(plugin_dir_path(__FILE__).star_cloudprnt_get_os_path('order-handler.php'));
2626

27+
star_cloudprnt_register_settings();
28+
2729
// Run page setup and woo commerce hooks
2830
star_cloudprnt_create_settings_page();
2931
star_cloudprnt_setup_order_handler();

uninstall.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,23 @@ function rrmdir($dir)
2828
delete_option('star-cloudprnt-print-logo-top-input');
2929
delete_option('star-cloudprnt-print-logo-bottom-cb');
3030
delete_option('star-cloudprnt-print-logo-bottom-input');
31+
32+
delete_option("star-cloudprnt-printer-encoding-select");
33+
delete_option("star-cloudprnt-print-copies-input");
34+
35+
delete_option("star-cloudprnt-trigger");
36+
37+
delete_option("star-cloudprnt-print-header-title");
38+
39+
delete_option("star-cloudprnt-print-items-footer-message");
40+
41+
delete_option("star_cloudprnt_setup_section");
42+
delete_option("star-cloudprnt-print-order-meta-reformat-keys");
43+
delete_option("star-cloudprnt-print-order-meta-hidden");
44+
delete_option("star-cloudprnt-print-order-meta-exclusions");
45+
46+
delete_option("star-cloudprnt-buzzer-start");
47+
delete_option( "star-cloudprnt-buzzer-end");
48+
49+
3150
?>

0 commit comments

Comments
 (0)