WooCommerce PDF Invoices & Packing Slips - Version 2.5.4

Version Description

  • Fix: check for existence of WooCommerce functions preventing incidental crashes in specific deployment setups
  • Fix: documents could still be generated programmatically when document disabled and not specifically checking for $documment->is_allowed()
  • Dev: Filter to disable reloading attachment translations
  • Tested up to WooCommerce 4.4 & WP 5.5
Download this release

Release Info

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

Code changes from version 2.5.3 to 2.5.4

includes/class-wcpdf-main.php CHANGED
@@ -101,8 +101,10 @@ class Main {
101
  add_filter( 'wcpdf_disable_deprecation_notices', '__return_true' );
102
 
103
  // reload translations because WC may have switched to site locale (by setting the plugin_locale filter to site locale in wc_switch_to_site_locale())
104
- WPO_WCPDF()->translations();
105
- do_action( 'wpo_wcpdf_reload_attachment_translations' );
 
 
106
 
107
  $attach_to_document_types = $this->get_documents_for_email( $email_id, $order );
108
  foreach ( $attach_to_document_types as $document_type ) {
101
  add_filter( 'wcpdf_disable_deprecation_notices', '__return_true' );
102
 
103
  // reload translations because WC may have switched to site locale (by setting the plugin_locale filter to site locale in wc_switch_to_site_locale())
104
+ if ( apply_filters( 'wpo_wcpdf_allow_reload_attachment_translations', true ) ) {
105
+ WPO_WCPDF()->translations();
106
+ do_action( 'wpo_wcpdf_reload_attachment_translations' );
107
+ }
108
 
109
  $attach_to_document_types = $this->get_documents_for_email( $email_id, $order );
110
  foreach ( $attach_to_document_types as $document_type ) {
includes/documents/abstract-wcpdf-order-document.php CHANGED
@@ -328,7 +328,11 @@ abstract class Order_Document {
328
 
329
  public function is_allowed() {
330
  $allowed = true;
331
- if ( !$this->exists() && !empty( $this->settings['disable_for_statuses'] ) && !empty( $this->order ) && is_callable( array( $this->order, 'get_status' ) ) ) {
 
 
 
 
332
  $status = $this->order->get_status();
333
 
334
  $disabled_statuses = array_map( function($status){
@@ -339,7 +343,7 @@ abstract class Order_Document {
339
  if ( in_array( $status, $disabled_statuses ) ) {
340
  $allowed = false;
341
  }
342
- }
343
  return apply_filters( 'wpo_wcpdf_document_is_allowed', $allowed, $this );
344
  }
345
 
@@ -851,13 +855,14 @@ abstract class Order_Document {
851
 
852
  // get list of WooCommerce statuses
853
  public function get_wc_order_status_list() {
 
854
  if ( version_compare( WOOCOMMERCE_VERSION, '2.2', '<' ) ) {
855
  $statuses = (array) get_terms( 'shop_order_status', array( 'hide_empty' => 0, 'orderby' => 'id' ) );
856
  foreach ( $statuses as $status ) {
857
  $order_statuses[esc_attr( $status->slug )] = esc_html__( $status->name, 'woocommerce' );
858
  }
859
  } else {
860
- $statuses = wc_get_order_statuses();
861
  foreach ( $statuses as $status_slug => $status ) {
862
  $status_slug = 'wc-' === substr( $status_slug, 0, 3 ) ? substr( $status_slug, 3 ) : $status_slug;
863
  $order_statuses[$status_slug] = $status;
328
 
329
  public function is_allowed() {
330
  $allowed = true;
331
+ // Check if document is enabled
332
+ if ( !$this->is_enabled() ) {
333
+ $allowed = false;
334
+ // Check disabled for statuses
335
+ } elseif ( !$this->exists() && !empty( $this->settings['disable_for_statuses'] ) && !empty( $this->order ) && is_callable( array( $this->order, 'get_status' ) ) ) {
336
  $status = $this->order->get_status();
337
 
338
  $disabled_statuses = array_map( function($status){
343
  if ( in_array( $status, $disabled_statuses ) ) {
344
  $allowed = false;
345
  }
346
+ }
347
  return apply_filters( 'wpo_wcpdf_document_is_allowed', $allowed, $this );
348
  }
349
 
855
 
856
  // get list of WooCommerce statuses
857
  public function get_wc_order_status_list() {
858
+ $order_statuses = array();
859
  if ( version_compare( WOOCOMMERCE_VERSION, '2.2', '<' ) ) {
860
  $statuses = (array) get_terms( 'shop_order_status', array( 'hide_empty' => 0, 'orderby' => 'id' ) );
861
  foreach ( $statuses as $status ) {
862
  $order_statuses[esc_attr( $status->slug )] = esc_html__( $status->name, 'woocommerce' );
863
  }
864
  } else {
865
+ $statuses = function_exists('wc_get_order_statuses') ? wc_get_order_statuses() : array();
866
  foreach ( $statuses as $status_slug => $status ) {
867
  $status_slug = 'wc-' === substr( $status_slug, 0, 3 ) ? substr( $status_slug, 3 ) : $status_slug;
868
  $order_statuses[$status_slug] = $status;
includes/documents/class-wcpdf-invoice.php CHANGED
@@ -201,7 +201,7 @@ class Invoice extends Order_Document_Methods {
201
  'args' => array(
202
  'option_name' => $option_name,
203
  'id' => 'disable_for_statuses',
204
- 'options' => wc_get_order_statuses(),
205
  'multiple' => true,
206
  'enhanced_select' => true,
207
  'placeholder' => __( 'Select one or more statuses', 'woocommerce-pdf-invoices-packing-slips' ),
@@ -377,7 +377,7 @@ class Invoice extends Order_Document_Methods {
377
  'args' => array(
378
  'option_name' => $option_name,
379
  'id' => 'disable_free',
380
- 'description' => sprintf(__( "Disable automatic creation/attachment when the order total is %s", 'woocommerce-pdf-invoices-packing-slips' ), wc_price( 0 ) ),
381
  )
382
  ),
383
  array(
201
  'args' => array(
202
  'option_name' => $option_name,
203
  'id' => 'disable_for_statuses',
204
+ 'options' => function_exists('wc_get_order_statuses') ? wc_get_order_statuses() : array(),
205
  'multiple' => true,
206
  'enhanced_select' => true,
207
  'placeholder' => __( 'Select one or more statuses', 'woocommerce-pdf-invoices-packing-slips' ),
377
  'args' => array(
378
  'option_name' => $option_name,
379
  'id' => 'disable_free',
380
+ 'description' => sprintf(__( "Disable automatic creation/attachment when the order total is %s", 'woocommerce-pdf-invoices-packing-slips' ), function_exists('wc_price') ? wc_price( 0 ) : 0 ),
381
  )
382
  ),
383
  array(
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.4
7
  Requires PHP: 5.3
8
- Stable tag: 2.5.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -102,6 +102,12 @@ There's a setting on the Status tab of the settings page that allows you to togg
102
 
103
  == Changelog ==
104
 
 
 
 
 
 
 
105
  = 2.5.3 =
106
  * Fix: WP5.5 compatible PHPMailer integration
107
  * Tested up to WooCommerce 4.3
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.5
7
  Requires PHP: 5.3
8
+ Stable tag: 2.5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
102
 
103
  == Changelog ==
104
 
105
+ = 2.5.4 =
106
+ * Fix: check for existence of WooCommerce functions preventing incidental crashes in specific deployment setups
107
+ * Fix: documents could still be generated programmatically when document disabled and not specifically checking for `$documment->is_allowed()`
108
+ * Dev: Filter to disable reloading attachment translations
109
+ * Tested up to WooCommerce 4.4 & WP 5.5
110
+
111
  = 2.5.3 =
112
  * Fix: WP5.5 compatible PHPMailer integration
113
  * Tested up to WooCommerce 4.3
woocommerce-pdf-invoices-packingslips.php CHANGED
@@ -3,14 +3,14 @@
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.5.3
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
10
  * License URI: http://www.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: 4.3.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.5.3';
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.5.4
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
10
  * License URI: http://www.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: 4.4.0
14
  */
15
 
16
  if ( ! defined( 'ABSPATH' ) ) {
21
 
22
  class WPO_WCPDF {
23
 
24
+ public $version = '2.5.4';
25
  public $plugin_basename;
26
  public $legacy_mode;
27