WooCommerce PDF Invoices & Packing Slips - Version 2.13.1

Version Description

  • Fix: load missing non-historical settings for existing invoices
  • Tweak: print file & line number for exceptions in error logs & output
  • Marked tested up to WooCommerce 6.2
Download this release

Release Info

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

Code changes from version 2.13.0 to 2.13.1

includes/class-wcpdf-settings-callbacks.php CHANGED
@@ -85,7 +85,8 @@ class Settings_Callbacks {
85
  $type = 'text';
86
  }
87
 
88
- printf( '<input type="%1$s" id="%2$s" name="%3$s" value="%4$s" size="%5$s" placeholder="%6$s" %7$s/>', esc_attr( $type ), esc_attr( $id ), esc_attr( $setting_name ), esc_attr( $current ), esc_attr( $size ), esc_attr( $placeholder ), ! empty( $disabled ) ? 'disabled="disabled"' : '' );
 
89
 
90
  // output description.
91
  if ( ! empty( $description ) ) {
85
  $type = 'text';
86
  }
87
 
88
+ $size = ! empty( $size ) ? sprintf( 'size="%s"', esc_attr( $size ) ) : '';
89
+ printf( '<input type="%1$s" id="%2$s" name="%3$s" value="%4$s" %5$s placeholder="%6$s" %7$s/>', esc_attr( $type ), esc_attr( $id ), esc_attr( $setting_name ), esc_attr( $current ), $size, esc_attr( $placeholder ), ! empty( $disabled ) ? 'disabled="disabled"' : '' );
90
 
91
  // output description.
92
  if ( ! empty( $description ) ) {
includes/class-wcpdf-settings-general.php CHANGED
@@ -158,7 +158,6 @@ class Settings_General {
158
  'args' => array(
159
  'option_name' => $option_name,
160
  'id' => 'shop_name',
161
- 'size' => '72',
162
  'translatable' => true,
163
  )
164
  ),
158
  'args' => array(
159
  'option_name' => $option_name,
160
  'id' => 'shop_name',
 
161
  'translatable' => true,
162
  )
163
  ),
includes/documents/abstract-wcpdf-order-document.php CHANGED
@@ -136,19 +136,22 @@ abstract class Order_Document {
136
  }
137
 
138
  // get historical settings if enabled
139
- if ( !empty( $this->order ) && $this->use_historical_settings() == true ) {
140
  $order_settings = WCX_Order::get_meta( $this->order, "_wcpdf_{$this->slug}_settings" );
141
- if (!empty($order_settings) && !is_array($order_settings)) {
142
  $order_settings = maybe_unserialize( $order_settings );
143
  }
144
- if (!empty($order_settings) && is_array($order_settings)) {
145
- // not sure what happens if combining with current settings will have unwanted side effects
146
- // like unchecked options being enabled because missing = unchecked in historical - disabled for now
147
- // $settings = (array) $order_settings + (array) $settings;
148
- $settings = $order_settings;
 
 
 
149
  }
150
  }
151
- if ( $this->storing_settings_enabled() && empty( $order_settings ) && !empty( $this->order ) ) {
152
  // this is either the first time the document is generated, or historical settings are disabled
153
  // in both cases, we store the document settings
154
  // exclude non historical settings from being saved in order meta
136
  }
137
 
138
  // get historical settings if enabled
139
+ if ( ! empty( $this->order ) && $this->use_historical_settings() == true ) {
140
  $order_settings = WCX_Order::get_meta( $this->order, "_wcpdf_{$this->slug}_settings" );
141
+ if ( ! empty( $order_settings ) && ! is_array( $order_settings ) ) {
142
  $order_settings = maybe_unserialize( $order_settings );
143
  }
144
+ if ( ! empty( $order_settings ) && is_array( $order_settings ) ) {
145
+ // ideally we should combine the order settings with the latest settings, so that new settings will
146
+ // automatically be applied to existing orders too. However, doing this by combining arrays is not
147
+ // possible because the way settings are currently stored means unchecked options are not included.
148
+ // This means there is no way to tell whether an option didn't exist yet (in which case the new
149
+ // option should be added) or whether the option was simly unchecked (in which case it should not
150
+ // be overwritten). This can only be address by storing unchecked checkboxes too.
151
+ $settings = (array) $order_settings + array_intersect_key( (array) $settings, array_flip( $this->get_non_historical_settings() ) );
152
  }
153
  }
154
+ if ( $this->storing_settings_enabled() && empty( $order_settings ) && ! empty( $this->order ) ) {
155
  // this is either the first time the document is generated, or historical settings are disabled
156
  // in both cases, we store the document settings
157
  // exclude non historical settings from being saved in order meta
includes/wcpdf-functions.php CHANGED
@@ -199,7 +199,11 @@ function wcpdf_log_error( $message, $level = 'error', $e = null ) {
199
  $logger = wc_get_logger();
200
  $context = array( 'source' => 'wpo-wcpdf' );
201
 
202
- if ( apply_filters( 'wcpdf_log_stacktrace', false ) && !empty($e) && is_callable( array( $e, 'getTraceAsString') ) ) {
 
 
 
 
203
  $message .= "\n".$e->getTraceAsString();
204
  }
205
 
@@ -226,7 +230,10 @@ function wcpdf_output_error( $message, $level = 'error', $e = null ) {
226
  ?>
227
  <div style="border: 2px solid red; padding: 5px;">
228
  <h3><?php echo wp_kses_post( $message ); ?></h3>
229
- <?php if ( !empty($e) && is_callable( array( $e, 'getTraceAsString') ) ): ?>
 
 
 
230
  <pre><?php echo $e->getTraceAsString(); ?></pre>
231
  <?php endif ?>
232
  </div>
199
  $logger = wc_get_logger();
200
  $context = array( 'source' => 'wpo-wcpdf' );
201
 
202
+ if ( is_callable( array( $e, 'getFile' ) ) && is_callable( array( $e, 'getLine' ) ) ) {
203
+ $message = sprintf( '%s (%s:%d)', $message, $e->getFile(), $e->getLine() );
204
+ }
205
+
206
+ if ( apply_filters( 'wcpdf_log_stacktrace', false ) && is_callable( array( $e, 'getTraceAsString' ) ) ) {
207
  $message .= "\n".$e->getTraceAsString();
208
  }
209
 
230
  ?>
231
  <div style="border: 2px solid red; padding: 5px;">
232
  <h3><?php echo wp_kses_post( $message ); ?></h3>
233
+ <?php if ( is_callable( array( $e, 'getFile' ) ) && is_callable( array( $e, 'getLine' ) ) ): ?>
234
+ <pre><?php echo $e->getFile(); ?> (<?php echo $e->getLine(); ?>)</pre>
235
+ <?php endif ?>
236
+ <?php if ( is_callable( array( $e, 'getTraceAsString' ) ) ): ?>
237
  <pre><?php echo $e->getTraceAsString(); ?></pre>
238
  <?php endif ?>
239
  </div>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice,
5
  Requires at least: 3.5
6
  Tested up to: 5.9
7
  Requires PHP: 7.1
8
- Stable tag: 2.13.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -102,6 +102,11 @@ There's a setting on the Status tab of the settings page that allows you to togg
102
 
103
  == Changelog ==
104
 
 
 
 
 
 
105
  = 2.13.0 =
106
  * New: include dompdf temporary folder in cleanup procedure
107
  * New: Add CSS row classes for WPC Product Bundles
5
  Requires at least: 3.5
6
  Tested up to: 5.9
7
  Requires PHP: 7.1
8
+ Stable tag: 2.13.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
102
 
103
  == Changelog ==
104
 
105
+ = 2.13.1 =
106
+ * Fix: load missing non-historical settings for existing invoices
107
+ * Tweak: print file & line number for exceptions in error logs & output
108
+ * Marked tested up to WooCommerce 6.2
109
+
110
  = 2.13.0 =
111
  * New: include dompdf temporary folder in cleanup procedure
112
  * New: Add CSS row classes for WPC Product Bundles
woocommerce-pdf-invoices-packingslips.php CHANGED
@@ -3,14 +3,14 @@
3
  * Plugin Name: WooCommerce PDF Invoices & Packing Slips
4
  * Plugin URI: https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-bundle/
5
  * Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
6
- * Version: 2.13.0
7
  * Author: WP Overnight
8
  * Author URI: https://www.wpovernight.com
9
  * License: GPLv2 or later
10
  * License URI: https://opensource.org/licenses/gpl-license.php
11
  * Text Domain: woocommerce-pdf-invoices-packing-slips
12
  * WC requires at least: 2.2.0
13
- * WC tested up to: 6.1.0
14
  */
15
 
16
  if ( ! defined( 'ABSPATH' ) ) {
@@ -21,7 +21,7 @@ if ( !class_exists( 'WPO_WCPDF' ) ) :
21
 
22
  class WPO_WCPDF {
23
 
24
- public $version = '2.13.0';
25
  public $plugin_basename;
26
  public $legacy_mode;
27
  public $legacy_textdomain;
3
  * Plugin Name: WooCommerce PDF Invoices & Packing Slips
4
  * Plugin URI: https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-bundle/
5
  * Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
6
+ * Version: 2.13.1
7
  * Author: WP Overnight
8
  * Author URI: https://www.wpovernight.com
9
  * License: GPLv2 or later
10
  * License URI: https://opensource.org/licenses/gpl-license.php
11
  * Text Domain: woocommerce-pdf-invoices-packing-slips
12
  * WC requires at least: 2.2.0
13
+ * WC tested up to: 6.2
14
  */
15
 
16
  if ( ! defined( 'ABSPATH' ) ) {
21
 
22
  class WPO_WCPDF {
23
 
24
+ public $version = '2.13.1';
25
  public $plugin_basename;
26
  public $legacy_mode;
27
  public $legacy_textdomain;