WooCommerce PDF Invoices & Packing Slips - Version 2.0.6

Version Description

  • Feature: Improved third party invoice number filters (wpo_wcpdf_external_invoice_number_enabled & wpo_wcpdf_external_invoice_number)
  • Fix: Underline position for Open Sans font
  • Fix: Invoice number auto_increment for servers that restarted frequently
  • Fix: Dompdf log file location (preventing open base_dir notices breaking PDF header)
  • Fix: 1.6.6 Settings migration duplicates merging
  • Tweak: Clear fonts folder when manually reinstalling fonts
Download this release

Release Info

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

Code changes from version 2.0.5 to 2.0.6

includes/class-wcpdf-install.php CHANGED
@@ -260,7 +260,7 @@ class Install {
260
 
261
  // merge with existing settings
262
  ${$new_option."_old"} = get_option( $new_option, ${$new_option} ); // second argument loads new as default in case the settings did not exist yet
263
- ${$new_option} = ${$new_option} + ${$new_option."_old"}; // duplicate options take new options as default
264
 
265
  // store new option values
266
  update_option( $new_option, ${$new_option} );
260
 
261
  // merge with existing settings
262
  ${$new_option."_old"} = get_option( $new_option, ${$new_option} ); // second argument loads new as default in case the settings did not exist yet
263
+ ${$new_option} = (array) ${$new_option} + (array) ${$new_option."_old"}; // duplicate options take new options as default
264
 
265
  // store new option values
266
  update_option( $new_option, ${$new_option} );
includes/class-wcpdf-pdf-maker.php CHANGED
@@ -35,6 +35,7 @@ class PDF_Maker {
35
  $options = new Options();
36
  $options->setdefaultFont( 'dejavu sans');
37
  $options->setTempDir( WPO_WCPDF()->main->get_tmp_path('dompdf') );
 
38
  $options->setFontDir( WPO_WCPDF()->main->get_tmp_path('fonts') );
39
  $options->setFontCache( WPO_WCPDF()->main->get_tmp_path('fonts') );
40
  $options->setIsRemoteEnabled( true );
35
  $options = new Options();
36
  $options->setdefaultFont( 'dejavu sans');
37
  $options->setTempDir( WPO_WCPDF()->main->get_tmp_path('dompdf') );
38
+ $options->setLogOutputFile( WPO_WCPDF()->main->get_tmp_path('dompdf') . "/log.htm");
39
  $options->setFontDir( WPO_WCPDF()->main->get_tmp_path('fonts') );
40
  $options->setFontCache( WPO_WCPDF()->main->get_tmp_path('fonts') );
41
  $options->setIsRemoteEnabled( true );
includes/class-wcpdf-settings-debug.php CHANGED
@@ -33,6 +33,17 @@ class Settings_Debug {
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
  WPO_WCPDF()->main->copy_fonts( $font_path );
37
  printf('<div class="notice notice-success"><p>%s</p></div>', __( 'Fonts reinstalled!', 'woocommerce-pdf-invoices-packing-slips' ) );
38
  }
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
  }
includes/documents/abstract-wcpdf-order-document.php CHANGED
@@ -326,8 +326,11 @@ abstract class Order_Document {
326
 
327
  if ( empty( $value ) || ( is_array( $value ) && empty( $filtered_value ) ) ) {
328
  $document_number = null;
329
- } elseif ( is_array( $value ) ) {
330
  // WCPDF 2.0 number data
 
 
 
331
  $document_number = new Document_Number( $value, $this->get_number_settings(), $this, $order );
332
  } else {
333
  // plain number
326
 
327
  if ( empty( $value ) || ( is_array( $value ) && empty( $filtered_value ) ) ) {
328
  $document_number = null;
329
+ } elseif ( $value instanceof Document_Number ) {
330
  // WCPDF 2.0 number data
331
+ $document_number = $value;
332
+ } elseif ( is_array( $value ) ) {
333
+ // WCPDF 2.0 number data as array
334
  $document_number = new Document_Number( $value, $this->get_number_settings(), $this, $order );
335
  } else {
336
  // plain number
includes/documents/class-wcpdf-invoice.php CHANGED
@@ -49,8 +49,19 @@ class Invoice extends Order_Document_Methods {
49
  public function init_number() {
50
  global $wpdb;
51
  // If a third-party plugin claims to generate invoice numbers, trigger this instead
52
- if ( apply_filters( 'woocommerce_invoice_number_by_plugin', false ) ) {
53
  $invoice_number = apply_filters( 'woocommerce_generate_invoice_number', null, $this->order );
 
 
 
 
 
 
 
 
 
 
 
54
  return $invoice_number;
55
  }
56
 
49
  public function init_number() {
50
  global $wpdb;
51
  // If a third-party plugin claims to generate invoice numbers, trigger this instead
52
+ if ( apply_filters( 'woocommerce_invoice_number_by_plugin', false ) || apply_filters( 'wpo_wcpdf_external_invoice_number_enabled', false, $this ) ) {
53
  $invoice_number = apply_filters( 'woocommerce_generate_invoice_number', null, $this->order );
54
+ $invoice_number = apply_filters( 'wpo_wcpdf_external_invoice_number', $invoice_number, $this );
55
+ if ( is_numeric($invoice_number) || $invoice_number instanceof Document_Number ) {
56
+ $this->set_number( $invoice_number );
57
+ } else {
58
+ // invoice number is not numeric, treat as formatted
59
+ // try to extract meaningful number data
60
+ $formatted_number = $invoice_number;
61
+ $number = (int) preg_replace('/\D/', '', $invoice_number);
62
+ $invoice_number = compact( 'number', 'formatted_number' );
63
+ $this->set_number( $invoice_number );
64
+ }
65
  return $invoice_number;
66
  }
67
 
includes/documents/class-wcpdf-sequential-number-store.php CHANGED
@@ -97,7 +97,21 @@ $sql = "CREATE TABLE {$this->table_name} (
97
  $delete = $wpdb->query("TRUNCATE TABLE {$this->table_name}");
98
 
99
  // set auto_increment
100
- $wpdb->query("ALTER TABLE {$this->table_name} AUTO_INCREMENT={$number};");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
 
103
  public function get_last_date( $format = 'Y-m-d H:i:s' ) {
97
  $delete = $wpdb->query("TRUNCATE TABLE {$this->table_name}");
98
 
99
  // set auto_increment
100
+ if ( $number > 1 ) {
101
+ // if AUTO_INCREMENT is not 1, we need to make sure we have a 'highest value' in case of server restarts
102
+ // https://serverfault.com/questions/228690/mysql-auto-increment-fields-resets-by-itself
103
+ $highest_number = (int) $number - 1;
104
+ $wpdb->query("ALTER TABLE {$this->table_name} AUTO_INCREMENT={$highest_number};");
105
+ $data = array(
106
+ 'order_id' => 0,
107
+ 'date' => get_date_from_gmt( date( 'Y-m-d H:i:s' ) ),
108
+ );
109
+ // after this insert, AUTO_INCREMENT will be equal to $number
110
+ $wpdb->insert( $this->table_name, $data );
111
+ } else {
112
+ // simple scenario, no need to insert any rows
113
+ $wpdb->query("ALTER TABLE {$this->table_name} AUTO_INCREMENT={$number};");
114
+ }
115
  }
116
 
117
  public function get_last_date( $format = 'Y-m-d H:i:s' ) {
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.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -102,6 +102,14 @@ There's a setting on the Status tab of the settings page that allows you to togg
102
 
103
  **2.0 is a BIG update! Make a full site backup before upgrading**
104
 
 
 
 
 
 
 
 
 
105
  = 2.0.5 =
106
  * Feature: Remove temporary files (Status tab)
107
  * Fix: Page number replacement
@@ -591,5 +599,5 @@ There's a setting on the Status tab of the settings page that allows you to togg
591
 
592
  == Upgrade Notice ==
593
 
594
- = 2.0.5 =
595
  **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.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
102
 
103
  **2.0 is a BIG update! Make a full site backup before upgrading**
104
 
105
+ = 2.0.6 =
106
+ * Feature: Improved third party invoice number filters (`wpo_wcpdf_external_invoice_number_enabled` & `wpo_wcpdf_external_invoice_number`)
107
+ * Fix: Underline position for Open Sans font
108
+ * Fix: Invoice number auto_increment for servers that restarted frequently
109
+ * Fix: Dompdf log file location (preventing open base_dir notices breaking PDF header)
110
+ * Fix: 1.6.6 Settings migration duplicates merging
111
+ * Tweak: Clear fonts folder when manually reinstalling fonts
112
+
113
  = 2.0.5 =
114
  * Feature: Remove temporary files (Status tab)
115
  * Fix: Page number replacement
599
 
600
  == Upgrade Notice ==
601
 
602
+ = 2.0.6 =
603
  **2.0 is a BIG update! Make a full site backup before upgrading!**
vendor/dompdf/dompdf/lib/fonts/OpenSans-Bold.ufm CHANGED
@@ -19,7 +19,7 @@ Weight Bold
19
  ItalicAngle 0
20
  IsFixedPitch false
21
  UnderlineThickness 50
22
- UnderlinePosition -75
23
  FontHeightOffset 0
24
  Ascender 1069
25
  Descender -293
19
  ItalicAngle 0
20
  IsFixedPitch false
21
  UnderlineThickness 50
22
+ UnderlinePosition -500
23
  FontHeightOffset 0
24
  Ascender 1069
25
  Descender -293
vendor/dompdf/dompdf/lib/fonts/OpenSans-Bold.ufm.php CHANGED
@@ -586,7 +586,7 @@
586
  'ItalicAngle' => '0',
587
  'IsFixedPitch' => 'false',
588
  'UnderlineThickness' => '50',
589
- 'UnderlinePosition' => '-75',
590
  'FontHeightOffset' => '0',
591
  'Ascender' => '1069',
592
  'Descender' => '-293',
586
  'ItalicAngle' => '0',
587
  'IsFixedPitch' => 'false',
588
  'UnderlineThickness' => '50',
589
+ 'UnderlinePosition' => '-500',
590
  'FontHeightOffset' => '0',
591
  'Ascender' => '1069',
592
  'Descender' => '-293',
vendor/dompdf/dompdf/lib/fonts/OpenSans-BoldItalic.ufm CHANGED
@@ -19,7 +19,7 @@ Weight Bold
19
  ItalicAngle -12
20
  IsFixedPitch false
21
  UnderlineThickness 50
22
- UnderlinePosition -75
23
  FontHeightOffset 0
24
  Ascender 1069
25
  Descender -293
19
  ItalicAngle -12
20
  IsFixedPitch false
21
  UnderlineThickness 50
22
+ UnderlinePosition -500
23
  FontHeightOffset 0
24
  Ascender 1069
25
  Descender -293
vendor/dompdf/dompdf/lib/fonts/OpenSans-BoldItalic.ufm.php CHANGED
@@ -586,7 +586,7 @@
586
  'ItalicAngle' => '-12',
587
  'IsFixedPitch' => 'false',
588
  'UnderlineThickness' => '50',
589
- 'UnderlinePosition' => '-75',
590
  'FontHeightOffset' => '0',
591
  'Ascender' => '1069',
592
  'Descender' => '-293',
586
  'ItalicAngle' => '-12',
587
  'IsFixedPitch' => 'false',
588
  'UnderlineThickness' => '50',
589
+ 'UnderlinePosition' => '-500',
590
  'FontHeightOffset' => '0',
591
  'Ascender' => '1069',
592
  'Descender' => '-293',
vendor/dompdf/dompdf/lib/fonts/OpenSans-Italic.ufm CHANGED
@@ -19,7 +19,7 @@ Weight Medium
19
  ItalicAngle -12
20
  IsFixedPitch false
21
  UnderlineThickness 50
22
- UnderlinePosition -75
23
  FontHeightOffset 0
24
  Ascender 1069
25
  Descender -293
19
  ItalicAngle -12
20
  IsFixedPitch false
21
  UnderlineThickness 50
22
+ UnderlinePosition -500
23
  FontHeightOffset 0
24
  Ascender 1069
25
  Descender -293
vendor/dompdf/dompdf/lib/fonts/OpenSans-Italic.ufm.php CHANGED
@@ -586,7 +586,7 @@
586
  'ItalicAngle' => '-12',
587
  'IsFixedPitch' => 'false',
588
  'UnderlineThickness' => '50',
589
- 'UnderlinePosition' => '-75',
590
  'FontHeightOffset' => '0',
591
  'Ascender' => '1069',
592
  'Descender' => '-293',
586
  'ItalicAngle' => '-12',
587
  'IsFixedPitch' => 'false',
588
  'UnderlineThickness' => '50',
589
+ 'UnderlinePosition' => '-500',
590
  'FontHeightOffset' => '0',
591
  'Ascender' => '1069',
592
  'Descender' => '-293',
vendor/dompdf/dompdf/lib/fonts/OpenSans-Normal.ufm CHANGED
@@ -19,7 +19,7 @@ Weight Medium
19
  ItalicAngle 0
20
  IsFixedPitch false
21
  UnderlineThickness 50
22
- UnderlinePosition -75
23
  FontHeightOffset 0
24
  Ascender 1069
25
  Descender -293
19
  ItalicAngle 0
20
  IsFixedPitch false
21
  UnderlineThickness 50
22
+ UnderlinePosition -500
23
  FontHeightOffset 0
24
  Ascender 1069
25
  Descender -293
vendor/dompdf/dompdf/lib/fonts/OpenSans-Normal.ufm.php CHANGED
@@ -586,7 +586,7 @@
586
  'ItalicAngle' => '0',
587
  'IsFixedPitch' => 'false',
588
  'UnderlineThickness' => '50',
589
- 'UnderlinePosition' => '-75',
590
  'FontHeightOffset' => '0',
591
  'Ascender' => '1069',
592
  'Descender' => '-293',
586
  'ItalicAngle' => '0',
587
  'IsFixedPitch' => 'false',
588
  'UnderlineThickness' => '50',
589
+ 'UnderlinePosition' => '-500',
590
  'FontHeightOffset' => '0',
591
  'Ascender' => '1069',
592
  'Descender' => '-293',
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.5
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.5';
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.6
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.6';
23
  public $plugin_basename;
24
  public $legacy_mode;
25