WooCommerce PDF Invoices & Packing Slips - Version 2.2.8

Version Description

  • Tested up to WP5.1
  • Tweak: Re-use attachment file if not older than 60 seconds (tentative fix for parallel read & write issues)
  • Dev: Added URL overrides to switch between output mode (&output=html) and debug (&debug=true)
Download this release

Release Info

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

Code changes from version 2.2.7 to 2.2.8

includes/class-wcpdf-main.php CHANGED
@@ -100,11 +100,23 @@ class Main {
100
  if ( !$document ) { // something went wrong, continue trying with other documents
101
  continue;
102
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  // get pdf data & store
105
  $pdf_data = $document->get_pdf();
106
- $filename = $document->get_filename();
107
- $pdf_path = $tmp_path . $filename;
108
  file_put_contents ( $pdf_path, $pdf_data );
109
  $attachments[] = $pdf_path;
110
 
@@ -175,6 +187,11 @@ class Main {
175
  wp_die( __( 'Some of the export parameters are missing.', 'woocommerce-pdf-invoices-packing-slips' ) );
176
  }
177
 
 
 
 
 
 
178
  // Generate the output
179
  $document_type = sanitize_text_field( $_GET['document_type'] );
180
 
@@ -220,6 +237,10 @@ class Main {
220
 
221
  if ( $document ) {
222
  $output_format = WPO_WCPDF()->settings->get_output_format( $document_type );
 
 
 
 
223
  switch ( $output_format ) {
224
  case 'html':
225
  add_filter( 'wpo_wcpdf_use_path', '__return_false' );
100
  if ( !$document ) { // something went wrong, continue trying with other documents
101
  continue;
102
  }
103
+ $filename = $document->get_filename();
104
+ $pdf_path = $tmp_path . $filename;
105
+
106
+ // if this file already exists in the temp path, we'll reuse it if it's not older than 60 seconds
107
+ if (file_exists($pdf_path)) {
108
+ // get last modification date
109
+ if ($filemtime = filemtime($pdf_path)) {
110
+ $time_difference = time() - $filemtime;
111
+ if ( $time_difference < apply_filters( 'wpo_wcpdf_reuse_attachment_age', 60 ) ) {
112
+ $attachments[] = $pdf_path;
113
+ continue;
114
+ }
115
+ }
116
+ }
117
 
118
  // get pdf data & store
119
  $pdf_data = $document->get_pdf();
 
 
120
  file_put_contents ( $pdf_path, $pdf_data );
121
  $attachments[] = $pdf_path;
122
 
187
  wp_die( __( 'Some of the export parameters are missing.', 'woocommerce-pdf-invoices-packing-slips' ) );
188
  }
189
 
190
+ // debug enabled by URL
191
+ if ( isset( $_GET['debug'] ) ) {
192
+ $this->enable_debug();
193
+ }
194
+
195
  // Generate the output
196
  $document_type = sanitize_text_field( $_GET['document_type'] );
197
 
237
 
238
  if ( $document ) {
239
  $output_format = WPO_WCPDF()->settings->get_output_format( $document_type );
240
+ // allow URL override
241
+ if ( isset( $_GET['output'] ) && in_array( $_GET['output'], array( 'html', 'pdf' ) ) ) {
242
+ $output_format = $_GET['output'];
243
+ }
244
  switch ( $output_format ) {
245
  case 'html':
246
  add_filter( 'wpo_wcpdf_use_path', '__return_false' );
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: pomegranate
3
  Donate link: https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-bundle/
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: 5.0
7
  Requires PHP: 5.3
8
- Stable tag: 2.2.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -103,6 +103,11 @@ There's a setting on the Status tab of the settings page that allows you to togg
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
106
  = 2.2.7 =
107
  * Fix: Hardened permissions & security checks on several admin actions (audit by pluginvulnerabilities.com)
108
  * Feature: Show checkmarks for existing documents on order details page buttons too
3
  Donate link: https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-bundle/
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: 5.1
7
  Requires PHP: 5.3
8
+ Stable tag: 2.2.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
103
 
104
  == Changelog ==
105
 
106
+ = 2.2.8 =
107
+ * Tested up to WP5.1
108
+ * Tweak: Re-use attachment file if not older than 60 seconds (tentative fix for parallel read & write issues)
109
+ * Dev: Added URL overrides to switch between output mode (`&output=html`) and debug (`&debug=true`)
110
+
111
  = 2.2.7 =
112
  * Fix: Hardened permissions & security checks on several admin actions (audit by pluginvulnerabilities.com)
113
  * Feature: Show checkmarks for existing documents on order details page buttons too
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.2.7
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
@@ -21,7 +21,7 @@ if ( !class_exists( 'WPO_WCPDF' ) ) :
21
 
22
  class WPO_WCPDF {
23
 
24
- public $version = '2.2.7';
25
  public $plugin_basename;
26
  public $legacy_mode;
27
 
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.2.8
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
21
 
22
  class WPO_WCPDF {
23
 
24
+ public $version = '2.2.8';
25
  public $plugin_basename;
26
  public $legacy_mode;
27