WooCommerce PDF Invoices & Packing Slips - Version 2.0.12

Version Description

  • Option: Use different HTML parser (debug settings)
Download this release

Release Info

Developer pomegranate
Plugin Icon 128x128 WooCommerce PDF Invoices & Packing Slips
Version 2.0.12
Comparing to
See all releases

Code changes from version 2.0.11 to 2.0.12

includes/class-wcpdf-pdf-maker.php CHANGED
@@ -41,7 +41,8 @@ class PDF_Maker {
41
  'fontCache' => WPO_WCPDF()->main->get_tmp_path('fonts'),
42
  'isRemoteEnabled' => true,
43
  'isFontSubsettingEnabled' => $this->settings['font_subsetting'],
44
- 'isHtml5ParserEnabled' => true,
 
45
  ) ) );
46
 
47
  // instantiate and use the dompdf class
41
  'fontCache' => WPO_WCPDF()->main->get_tmp_path('fonts'),
42
  'isRemoteEnabled' => true,
43
  'isFontSubsettingEnabled' => $this->settings['font_subsetting'],
44
+ // HTML5 parser requires iconv
45
+ 'isHtml5ParserEnabled' => ( isset(WPO_WCPDF()->settings->debug_settings['use_domdocument_parser']) || !extension_loaded('iconv') ) ? false : true,
46
  ) ) );
47
 
48
  // instantiate and use the dompdf class
includes/class-wcpdf-settings-debug.php CHANGED
@@ -1,185 +1,196 @@
1
- <?php
2
- namespace WPO\WC\PDF_Invoices;
3
-
4
- if ( ! defined( 'ABSPATH' ) ) {
5
- exit; // Exit if accessed directly
6
- }
7
-
8
- if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Settings_Debug' ) ) :
9
-
10
- class Settings_Debug {
11
-
12
- function __construct() {
13
- add_action( 'admin_init', array( $this, 'init_settings' ) );
14
- add_action( 'wpo_wcpdf_settings_output_debug', array( $this, 'output' ), 10, 1 );
15
- add_action( 'wpo_wcpdf_after_settings_page', array( $this, 'debug_tools' ), 10, 2 );
16
- }
17
-
18
- public function output( $section ) {
19
- settings_fields( "wpo_wcpdf_settings_debug" );
20
- do_settings_sections( "wpo_wcpdf_settings_debug" );
21
-
22
- submit_button();
23
- }
24
-
25
- public function debug_tools( $tab, $section ) {
26
- if ($tab !== 'debug') {
27
- return;
28
- }
29
- ?>
30
- <form method="post">
31
- <input type="hidden" name="wpo_wcpdf_debug_tools_action" value="install_fonts">
32
- <input type="submit" name="submit" id="submit" class="button" value="<?php _e( 'Reinstall fonts', 'woocommerce-pdf-invoices-packing-slips' ); ?>">
33
- <?php
34
- if (isset($_POST['wpo_wcpdf_debug_tools_action']) && $_POST['wpo_wcpdf_debug_tools_action'] == 'install_fonts') {
35
- $font_path = WPO_WCPDF()->main->get_tmp_path( 'fonts' );
36
-
37
- // clear folder first
38
- if ( function_exists("glob") && $files = glob( $font_path.'/*.*' ) ) {
39
- $exclude_files = array( 'index.php', '.htaccess' );
40
- foreach($files as $file) {
41
- if( is_file($file) && !in_array( basename($file), $exclude_files ) ) {
42
- unlink($file);
43
- }
44
- }
45
- }
46
-
47
- WPO_WCPDF()->main->copy_fonts( $font_path );
48
- printf('<div class="notice notice-success"><p>%s</p></div>', __( 'Fonts reinstalled!', 'woocommerce-pdf-invoices-packing-slips' ) );
49
- }
50
- ?>
51
- </form>
52
- <form method="post">
53
- <input type="hidden" name="wpo_wcpdf_debug_tools_action" value="clear_tmp">
54
- <input type="submit" name="submit" id="submit" class="button" value="<?php _e( 'Remove temporary files', 'woocommerce-pdf-invoices-packing-slips' ); ?>">
55
- <?php
56
- if (isset($_POST['wpo_wcpdf_debug_tools_action']) && $_POST['wpo_wcpdf_debug_tools_action'] == 'clear_tmp') {
57
- $tmp_path = WPO_WCPDF()->main->get_tmp_path('attachments');
58
-
59
- if ( !function_exists("glob") ) {
60
- // glob is disabled
61
- printf('<div class="notice notice-error"><p>%s<br><code>%s</code></p></div>', __( "Unable to read temporary folder contents!", 'woocommerce-pdf-invoices-packing-slips' ), $tmp_path);
62
- } else {
63
- $success = 0;
64
- $error = 0;
65
- if ( $files = glob($tmp_path.'*.pdf') ) { // get all pdf files
66
- foreach($files as $file) {
67
- if(is_file($file)) {
68
- // delete file
69
- if ( unlink($file) === true ) {
70
- $success++;
71
- } else {
72
- $error++;
73
- }
74
- }
75
- }
76
-
77
- if ($error > 0) {
78
- $message = sprintf( __( 'Unable to delete %d files! (deleted %d)', 'woocommerce-pdf-invoices-packing-slips' ), $error, $success);
79
- printf('<div class="notice notice-error"><p>%s</p></div>', $message);
80
- } else {
81
- $message = sprintf( __( 'Successfully deleted %d files!', 'woocommerce-pdf-invoices-packing-slips' ), $success );
82
- printf('<div class="notice notice-success"><p>%s</p></div>', $message);
83
- }
84
- } else {
85
- printf('<div class="notice notice-success"><p>%s</p></div>', __( 'Nothing to delete!', 'woocommerce-pdf-invoices-packing-slips' ) );
86
- }
87
- }
88
- }
89
- ?>
90
- </form>
91
- <form method="post">
92
- <input type="hidden" name="wpo_wcpdf_debug_tools_action" value="delete_legacy_settings">
93
- <input type="submit" name="submit" id="submit" class="button" value="<?php _e( 'Delete legacy (1.X) settings', 'woocommerce-pdf-invoices-packing-slips' ); ?>">
94
- <?php
95
- if (isset($_POST['wpo_wcpdf_debug_tools_action']) && $_POST['wpo_wcpdf_debug_tools_action'] == 'delete_legacy_settings') {
96
- // delete options
97
- delete_option( 'wpo_wcpdf_general_settings' );
98
- delete_option( 'wpo_wcpdf_template_settings' );
99
- delete_option( 'wpo_wcpdf_debug_settings' );
100
- // and delete cache of these options, just in case...
101
- wp_cache_delete( 'wpo_wcpdf_general_settings','options' );
102
- wp_cache_delete( 'wpo_wcpdf_template_settings','options' );
103
- wp_cache_delete( 'wpo_wcpdf_debug_settings','options' );
104
-
105
- printf('<div class="notice notice-success"><p>%s</p></div>', __( 'Legacy settings deleted!', 'woocommerce-pdf-invoices-packing-slips' ) );
106
- }
107
- ?>
108
- </form>
109
- <?php
110
- include( WPO_WCPDF()->plugin_path() . '/includes/views/dompdf-status.php' );
111
- }
112
-
113
- public function init_settings() {
114
- // Register settings.
115
- $page = $option_group = $option_name = 'wpo_wcpdf_settings_debug';
116
-
117
- $settings_fields = array(
118
- array(
119
- 'type' => 'section',
120
- 'id' => 'debug_settings',
121
- 'title' => __( 'Debug settings', 'woocommerce-pdf-invoices-packing-slips' ),
122
- 'callback' => 'section',
123
- ),
124
- array(
125
- 'type' => 'setting',
126
- 'id' => 'legacy_mode',
127
- 'title' => __( 'Legacy mode', 'woocommerce-pdf-invoices-packing-slips' ),
128
- 'callback' => 'checkbox',
129
- 'section' => 'debug_settings',
130
- 'args' => array(
131
- 'option_name' => $option_name,
132
- 'id' => 'legacy_mode',
133
- 'description' => __( "Legacy mode ensures compatibility with templates and filters from previous versions.", 'woocommerce-pdf-invoices-packing-slips' ),
134
- )
135
- ),
136
- array(
137
- 'type' => 'setting',
138
- 'id' => 'calculate_document_numbers',
139
- 'title' => __( 'Calculate document numbers (slow)', 'woocommerce-pdf-invoices-packing-slips' ),
140
- 'callback' => 'checkbox',
141
- 'section' => 'debug_settings',
142
- 'args' => array(
143
- 'option_name' => $option_name,
144
- 'id' => 'calculate_document_numbers',
145
- 'description' => __( "Document numbers (such as invoice numbers) are generated using AUTO_INCREMENT by default. Use this setting if your database auto increments with more than 1.", 'woocommerce-pdf-invoices-packing-slips' ),
146
- )
147
- ),
148
- array(
149
- 'type' => 'setting',
150
- 'id' => 'enable_debug',
151
- 'title' => __( 'Enable debug output', 'woocommerce-pdf-invoices-packing-slips' ),
152
- 'callback' => 'checkbox',
153
- 'section' => 'debug_settings',
154
- 'args' => array(
155
- 'option_name' => $option_name,
156
- 'id' => 'enable_debug',
157
- 'description' => __( "Enable this option to output plugin errors if you're getting a blank page or other PDF generation issues", 'woocommerce-pdf-invoices-packing-slips' ) . '<br>' .
158
- __( '<b>Caution!</b> This setting may reveal errors (from other plugins) in other places on your site too, therefor this is not recommended to leave it enabled on live sites.', 'woocommerce-pdf-invoices-packing-slips' ),
159
- )
160
- ),
161
- array(
162
- 'type' => 'setting',
163
- 'id' => 'html_output',
164
- 'title' => __( 'Output to HTML', 'woocommerce-pdf-invoices-packing-slips' ),
165
- 'callback' => 'checkbox',
166
- 'section' => 'debug_settings',
167
- 'args' => array(
168
- 'option_name' => $option_name,
169
- 'id' => 'html_output',
170
- 'description' => __( 'Send the template output as HTML to the browser instead of creating a PDF.', 'woocommerce-pdf-invoices-packing-slips' ),
171
- )
172
- ),
173
- );
174
-
175
- // allow plugins to alter settings fields
176
- $settings_fields = apply_filters( 'wpo_wcpdf_settings_fields_debug', $settings_fields, $page, $option_group, $option_name );
177
- WPO_WCPDF()->settings->add_settings_fields( $settings_fields, $page, $option_group, $option_name );
178
- return;
179
- }
180
-
181
- }
182
-
183
- endif; // class_exists
184
-
 
 
 
 
 
 
 
 
 
 
 
185
  return new Settings_Debug();
1
+ <?php
2
+ namespace WPO\WC\PDF_Invoices;
3
+
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ exit; // Exit if accessed directly
6
+ }
7
+
8
+ if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Settings_Debug' ) ) :
9
+
10
+ class Settings_Debug {
11
+
12
+ function __construct() {
13
+ add_action( 'admin_init', array( $this, 'init_settings' ) );
14
+ add_action( 'wpo_wcpdf_settings_output_debug', array( $this, 'output' ), 10, 1 );
15
+ add_action( 'wpo_wcpdf_after_settings_page', array( $this, 'debug_tools' ), 10, 2 );
16
+ }
17
+
18
+ public function output( $section ) {
19
+ settings_fields( "wpo_wcpdf_settings_debug" );
20
+ do_settings_sections( "wpo_wcpdf_settings_debug" );
21
+
22
+ submit_button();
23
+ }
24
+
25
+ public function debug_tools( $tab, $section ) {
26
+ if ($tab !== 'debug') {
27
+ return;
28
+ }
29
+ ?>
30
+ <form method="post">
31
+ <input type="hidden" name="wpo_wcpdf_debug_tools_action" value="install_fonts">
32
+ <input type="submit" name="submit" id="submit" class="button" value="<?php _e( 'Reinstall fonts', 'woocommerce-pdf-invoices-packing-slips' ); ?>">
33
+ <?php
34
+ if (isset($_POST['wpo_wcpdf_debug_tools_action']) && $_POST['wpo_wcpdf_debug_tools_action'] == 'install_fonts') {
35
+ $font_path = WPO_WCPDF()->main->get_tmp_path( 'fonts' );
36
+
37
+ // clear folder first
38
+ if ( function_exists("glob") && $files = glob( $font_path.'/*.*' ) ) {
39
+ $exclude_files = array( 'index.php', '.htaccess' );
40
+ foreach($files as $file) {
41
+ if( is_file($file) && !in_array( basename($file), $exclude_files ) ) {
42
+ unlink($file);
43
+ }
44
+ }
45
+ }
46
+
47
+ WPO_WCPDF()->main->copy_fonts( $font_path );
48
+ printf('<div class="notice notice-success"><p>%s</p></div>', __( 'Fonts reinstalled!', 'woocommerce-pdf-invoices-packing-slips' ) );
49
+ }
50
+ ?>
51
+ </form>
52
+ <form method="post">
53
+ <input type="hidden" name="wpo_wcpdf_debug_tools_action" value="clear_tmp">
54
+ <input type="submit" name="submit" id="submit" class="button" value="<?php _e( 'Remove temporary files', 'woocommerce-pdf-invoices-packing-slips' ); ?>">
55
+ <?php
56
+ if (isset($_POST['wpo_wcpdf_debug_tools_action']) && $_POST['wpo_wcpdf_debug_tools_action'] == 'clear_tmp') {
57
+ $tmp_path = WPO_WCPDF()->main->get_tmp_path('attachments');
58
+
59
+ if ( !function_exists("glob") ) {
60
+ // glob is disabled
61
+ printf('<div class="notice notice-error"><p>%s<br><code>%s</code></p></div>', __( "Unable to read temporary folder contents!", 'woocommerce-pdf-invoices-packing-slips' ), $tmp_path);
62
+ } else {
63
+ $success = 0;
64
+ $error = 0;
65
+ if ( $files = glob($tmp_path.'*.pdf') ) { // get all pdf files
66
+ foreach($files as $file) {
67
+ if(is_file($file)) {
68
+ // delete file
69
+ if ( unlink($file) === true ) {
70
+ $success++;
71
+ } else {
72
+ $error++;
73
+ }
74
+ }
75
+ }
76
+
77
+ if ($error > 0) {
78
+ $message = sprintf( __( 'Unable to delete %d files! (deleted %d)', 'woocommerce-pdf-invoices-packing-slips' ), $error, $success);
79
+ printf('<div class="notice notice-error"><p>%s</p></div>', $message);
80
+ } else {
81
+ $message = sprintf( __( 'Successfully deleted %d files!', 'woocommerce-pdf-invoices-packing-slips' ), $success );
82
+ printf('<div class="notice notice-success"><p>%s</p></div>', $message);
83
+ }
84
+ } else {
85
+ printf('<div class="notice notice-success"><p>%s</p></div>', __( 'Nothing to delete!', 'woocommerce-pdf-invoices-packing-slips' ) );
86
+ }
87
+ }
88
+ }
89
+ ?>
90
+ </form>
91
+ <form method="post">
92
+ <input type="hidden" name="wpo_wcpdf_debug_tools_action" value="delete_legacy_settings">
93
+ <input type="submit" name="submit" id="submit" class="button" value="<?php _e( 'Delete legacy (1.X) settings', 'woocommerce-pdf-invoices-packing-slips' ); ?>">
94
+ <?php
95
+ if (isset($_POST['wpo_wcpdf_debug_tools_action']) && $_POST['wpo_wcpdf_debug_tools_action'] == 'delete_legacy_settings') {
96
+ // delete options
97
+ delete_option( 'wpo_wcpdf_general_settings' );
98
+ delete_option( 'wpo_wcpdf_template_settings' );
99
+ delete_option( 'wpo_wcpdf_debug_settings' );
100
+ // and delete cache of these options, just in case...
101
+ wp_cache_delete( 'wpo_wcpdf_general_settings','options' );
102
+ wp_cache_delete( 'wpo_wcpdf_template_settings','options' );
103
+ wp_cache_delete( 'wpo_wcpdf_debug_settings','options' );
104
+
105
+ printf('<div class="notice notice-success"><p>%s</p></div>', __( 'Legacy settings deleted!', 'woocommerce-pdf-invoices-packing-slips' ) );
106
+ }
107
+ ?>
108
+ </form>
109
+ <?php
110
+ include( WPO_WCPDF()->plugin_path() . '/includes/views/dompdf-status.php' );
111
+ }
112
+
113
+ public function init_settings() {
114
+ // Register settings.
115
+ $page = $option_group = $option_name = 'wpo_wcpdf_settings_debug';
116
+
117
+ $settings_fields = array(
118
+ array(
119
+ 'type' => 'section',
120
+ 'id' => 'debug_settings',
121
+ 'title' => __( 'Debug settings', 'woocommerce-pdf-invoices-packing-slips' ),
122
+ 'callback' => 'section',
123
+ ),
124
+ array(
125
+ 'type' => 'setting',
126
+ 'id' => 'legacy_mode',
127
+ 'title' => __( 'Legacy mode', 'woocommerce-pdf-invoices-packing-slips' ),
128
+ 'callback' => 'checkbox',
129
+ 'section' => 'debug_settings',
130
+ 'args' => array(
131
+ 'option_name' => $option_name,
132
+ 'id' => 'legacy_mode',
133
+ 'description' => __( "Legacy mode ensures compatibility with templates and filters from previous versions.", 'woocommerce-pdf-invoices-packing-slips' ),
134
+ )
135
+ ),
136
+ array(
137
+ 'type' => 'setting',
138
+ 'id' => 'calculate_document_numbers',
139
+ 'title' => __( 'Calculate document numbers (slow)', 'woocommerce-pdf-invoices-packing-slips' ),
140
+ 'callback' => 'checkbox',
141
+ 'section' => 'debug_settings',
142
+ 'args' => array(
143
+ 'option_name' => $option_name,
144
+ 'id' => 'calculate_document_numbers',
145
+ 'description' => __( "Document numbers (such as invoice numbers) are generated using AUTO_INCREMENT by default. Use this setting if your database auto increments with more than 1.", 'woocommerce-pdf-invoices-packing-slips' ),
146
+ )
147
+ ),
148
+ array(
149
+ 'type' => 'setting',
150
+ 'id' => 'enable_debug',
151
+ 'title' => __( 'Enable debug output', 'woocommerce-pdf-invoices-packing-slips' ),
152
+ 'callback' => 'checkbox',
153
+ 'section' => 'debug_settings',
154
+ 'args' => array(
155
+ 'option_name' => $option_name,
156
+ 'id' => 'enable_debug',
157
+ 'description' => __( "Enable this option to output plugin errors if you're getting a blank page or other PDF generation issues", 'woocommerce-pdf-invoices-packing-slips' ) . '<br>' .
158
+ __( '<b>Caution!</b> This setting may reveal errors (from other plugins) in other places on your site too, therefor this is not recommended to leave it enabled on live sites.', 'woocommerce-pdf-invoices-packing-slips' ),
159
+ )
160
+ ),
161
+ array(
162
+ 'type' => 'setting',
163
+ 'id' => 'html_output',
164
+ 'title' => __( 'Output to HTML', 'woocommerce-pdf-invoices-packing-slips' ),
165
+ 'callback' => 'checkbox',
166
+ 'section' => 'debug_settings',
167
+ 'args' => array(
168
+ 'option_name' => $option_name,
169
+ 'id' => 'html_output',
170
+ 'description' => __( 'Send the template output as HTML to the browser instead of creating a PDF.', 'woocommerce-pdf-invoices-packing-slips' ),
171
+ )
172
+ ),
173
+ array(
174
+ 'type' => 'setting',
175
+ 'id' => 'use_domdocument_parser',
176
+ 'title' => __( 'Use DOMDocument to parse HTML', 'woocommerce-pdf-invoices-packing-slips' ),
177
+ 'callback' => 'checkbox',
178
+ 'section' => 'debug_settings',
179
+ 'args' => array(
180
+ 'option_name' => $option_name,
181
+ 'id' => 'use_domdocument_parser',
182
+ )
183
+ ),
184
+ );
185
+
186
+ // allow plugins to alter settings fields
187
+ $settings_fields = apply_filters( 'wpo_wcpdf_settings_fields_debug', $settings_fields, $page, $option_group, $option_name );
188
+ WPO_WCPDF()->settings->add_settings_fields( $settings_fields, $page, $option_group, $option_name );
189
+ return;
190
+ }
191
+
192
+ }
193
+
194
+ endif; // class_exists
195
+
196
  return new Settings_Debug();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-
4
  Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice, packing slip, export, email, bulk, automatic
5
  Requires at least: 3.5
6
  Tested up to: 4.8
7
- Stable tag: 2.0.11
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -104,6 +104,9 @@ There's a setting on the Status tab of the settings page that allows you to togg
104
 
105
  **2.0 is a BIG update! Make a full site backup before upgrading**
106
 
 
 
 
107
  = 2.0.11 =
108
  * Fix: Improved fonts update routine (now preserves custom fonts)
109
  * Fix: Enable HTML5 parser by default (fixes issues with libxml)
@@ -189,5 +192,5 @@ There's a setting on the Status tab of the settings page that allows you to togg
189
 
190
  == Upgrade Notice ==
191
 
192
- = 2.0.11 =
193
  **2.0 is a BIG update! Make a full site backup before upgrading!**
4
  Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice, packing slip, export, email, bulk, automatic
5
  Requires at least: 3.5
6
  Tested up to: 4.8
7
+ Stable tag: 2.0.12
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
104
 
105
  **2.0 is a BIG update! Make a full site backup before upgrading**
106
 
107
+ = 2.0.12 =
108
+ * Option: Use different HTML parser (debug settings)
109
+
110
  = 2.0.11 =
111
  * Fix: Improved fonts update routine (now preserves custom fonts)
112
  * Fix: Enable HTML5 parser by default (fixes issues with libxml)
192
 
193
  == Upgrade Notice ==
194
 
195
+ = 2.0.12 =
196
  **2.0 is a BIG update! Make a full site backup before upgrading!**
woocommerce-pdf-invoices-packingslips.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce PDF Invoices & Packing Slips
4
  * Plugin URI: http://www.wpovernight.com
5
  * Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
6
- * Version: 2.0.11
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
@@ -19,7 +19,7 @@ if ( !class_exists( 'WPO_WCPDF' ) ) :
19
 
20
  class WPO_WCPDF {
21
 
22
- public $version = '2.0.11';
23
  public $plugin_basename;
24
  public $legacy_mode;
25
 
3
  * Plugin Name: WooCommerce PDF Invoices & Packing Slips
4
  * Plugin URI: http://www.wpovernight.com
5
  * Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
6
+ * Version: 2.0.12
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
19
 
20
  class WPO_WCPDF {
21
 
22
+ public $version = '2.0.12';
23
  public $plugin_basename;
24
  public $legacy_mode;
25