WooCommerce PDF Invoices - Version 2.6.2

Version Description

  • February 2, 2017 =

  • Improved: Company logo setting by just using a attachment url from Media Library. Note that the image won't be shown on settings page anymore.

  • Improved: 'readme.txt' and 'settings-sidebar.php' files.

  • Fixed: bewpi_mpdf filter not working properly. Should be placed before writing html.

  • Fixed: Invoice number compatibility with third party plugins by using get_order_number() method instead of id.

  • Fixed: Invoice number column on mobile by adding a '-' when no invoice number exists.

Download this release

Release Info

Developer baaaaas
Plugin Icon 128x128 WooCommerce PDF Invoices
Version 2.6.2
Comparing to
See all releases

Code changes from version 2.6.1 to 2.6.2

assets/css/admin.css CHANGED
@@ -85,6 +85,9 @@ form.bewpi-settings-form {
85
  #bewpi-plugin-activated-notice button.notice-dismiss {
86
  display: none;
87
  }
 
 
 
88
  /* Sidebar */
89
  .bewpi-sidebar {
90
  width: 25%;
85
  #bewpi-plugin-activated-notice button.notice-dismiss {
86
  display: none;
87
  }
88
+ .manage-column.column-bewpi_invoice_number {
89
+ width: 8%;
90
+ }
91
  /* Sidebar */
92
  .bewpi-sidebar {
93
  width: 25%;
bootstrap.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce PDF Invoices
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-pdf-invoices
5
  * Description: Automatically generate and attach customizable PDF Invoices to WooCommerce emails and connect with Dropbox, Google Drive, OneDrive or Egnyte.
6
- * Version: 2.6.1
7
  * Author: Bas Elbers
8
  * Author URI: http://wcpdfinvoices.com
9
  * License: GPL-2.0+
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
17
  }
18
 
19
- define( 'BEWPI_VERSION', '2.6.1' );
20
 
21
  /**
22
  * Load WooCommerce PDF Invoices plugin.
@@ -39,11 +39,14 @@ add_action( 'plugins_loaded', '_bewpi_load_plugin', 10 );
39
  * @since 2.5.0
40
  */
41
  function _bewpi_on_plugin_update() {
42
- if ( get_site_option( 'bewpi_version' ) !== BEWPI_VERSION ) {
 
43
 
44
- update_email_type_options();
45
-
46
- update_postmeta();
 
 
47
 
48
  update_site_option( 'bewpi_version', BEWPI_VERSION );
49
  }
3
  * Plugin Name: WooCommerce PDF Invoices
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-pdf-invoices
5
  * Description: Automatically generate and attach customizable PDF Invoices to WooCommerce emails and connect with Dropbox, Google Drive, OneDrive or Egnyte.
6
+ * Version: 2.6.2
7
  * Author: Bas Elbers
8
  * Author URI: http://wcpdfinvoices.com
9
  * License: GPL-2.0+
16
  exit;
17
  }
18
 
19
+ define( 'BEWPI_VERSION', '2.6.2' );
20
 
21
  /**
22
  * Load WooCommerce PDF Invoices plugin.
39
  * @since 2.5.0
40
  */
41
  function _bewpi_on_plugin_update() {
42
+ $current_version = get_site_option( 'bewpi_version' );
43
+ if ( BEWPI_VERSION !== $current_version ) {
44
 
45
+ // version 2.6.1- need to be updated with new email options and postmeta.
46
+ if ( version_compare( $current_version, '2.6.1' ) <= 0 ) {
47
+ update_email_type_options();
48
+ update_postmeta();
49
+ }
50
 
51
  update_site_option( 'bewpi_version', BEWPI_VERSION );
52
  }
includes/abstracts/abstract-bewpi-document.php CHANGED
@@ -157,10 +157,10 @@ if ( ! class_exists( 'BEWPI_Abstract_Document' ) ) {
157
  $mpdf->SetHTMLFooter( $html['footer'] );
158
  }
159
 
160
- $mpdf->WriteHTML( $html['style'] . $html['body'] );
161
-
162
  $mpdf = apply_filters( 'bewpi_mpdf', $mpdf );
163
 
 
 
164
  if ( 'F' === $destination ) {
165
  $name = $this->full_path;
166
  } else {
157
  $mpdf->SetHTMLFooter( $html['footer'] );
158
  }
159
 
 
 
160
  $mpdf = apply_filters( 'bewpi_mpdf', $mpdf );
161
 
162
+ $mpdf->WriteHTML( $html['style'] . $html['body'] );
163
+
164
  if ( 'F' === $destination ) {
165
  $name = $this->full_path;
166
  } else {
includes/abstracts/abstract-bewpi-invoice.php CHANGED
@@ -103,7 +103,7 @@ if ( ! class_exists( 'BEWPI_Abstract_Invoice' ) ) {
103
  $this->template_options['bewpi_invoice_number_suffix'],
104
  $digitized_invoice_number,
105
  apply_filters( 'bewpi_formatted_invoice_number_order_date', $this->get_formatted_order_date() ),
106
- $this->order->id,
107
  $this->year,
108
  date_i18n( 'y', strtotime( $this->date ) ),
109
  date_i18n( 'm', strtotime( $this->date ) ),
103
  $this->template_options['bewpi_invoice_number_suffix'],
104
  $digitized_invoice_number,
105
  apply_filters( 'bewpi_formatted_invoice_number_order_date', $this->get_formatted_order_date() ),
106
+ $this->order->get_order_number(),
107
  $this->year,
108
  date_i18n( 'y', strtotime( $this->date ) ),
109
  date_i18n( 'm', strtotime( $this->date ) ),
includes/abstracts/abstract-bewpi-setting.php CHANGED
@@ -113,36 +113,6 @@ if ( ! class_exists( 'BEWPI_Abstract_Setting' ) ) {
113
  <?php
114
  }
115
 
116
- public function logo_callback( $args ) {
117
- $options = get_option( $args['page'] );
118
- ?>
119
- <input id="<?php echo $args['id']; ?>"
120
- name="<?php echo $args['name']; ?>"
121
- type="<?php echo $args['type']; ?>"
122
- accept="image/*"
123
- />
124
- <div class="bewpi-notes"><?php echo $args['desc']; ?></div>
125
- <input id="<?php echo $args['id'] . '-value'; ?>"
126
- name="<?php echo $args['name']; ?>"
127
- type="hidden"
128
- value="<?php echo esc_attr( $options[ $args['name'] ] ); ?>"
129
- />
130
-
131
- <?php
132
- if ( ! empty( $options[ $args['name'] ] ) ) {
133
- ?>
134
- <div id="<?php echo $args['id'] . '-wrapper'; ?>">
135
- <img id="<?php echo $args['id'] . '-image'; ?>"
136
- src="<?php echo esc_attr( $options[ $args['name'] ] ); ?>"/>
137
- <img id="<?php echo $args['id'] . '-delete'; ?>"
138
- src="<?php echo BEWPI_URL . '/assets/images/delete-icon.png'; ?>"
139
- onclick="bewpi.setting.removeCompanyLogo()"
140
- title="<?php _e( 'Remove logo', 'woocommerce-pdf-invoices' ); ?>"/>
141
- </div>
142
- <?php
143
- }
144
- }
145
-
146
  public function textarea_callback( $args ) {
147
  $options = get_option( $args['page'] );
148
  ?>
113
  <?php
114
  }
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  public function textarea_callback( $args ) {
117
  $options = get_option( $args['page'] );
118
  ?>
includes/admin/settings/class-bewpi-admin-settings-template.php CHANGED
@@ -68,6 +68,8 @@ if ( ! class_exists( 'BEWPI_Template_Settings' ) ) {
68
  * @return array
69
  */
70
  private function the_settings() {
 
 
71
  $settings = array(
72
  array(
73
  'id' => 'bewpi-template-name',
@@ -179,12 +181,12 @@ if ( ! class_exists( 'BEWPI_Template_Settings' ) ) {
179
  'id' => 'bewpi-company-logo',
180
  'name' => self::PREFIX . 'company_logo',
181
  'title' => __( 'Company logo', 'woocommerce-pdf-invoices' ),
182
- 'callback' => array( $this, 'logo_callback' ),
183
  'page' => self::SETTINGS_KEY,
184
  'section' => 'header',
185
- 'type' => 'file',
186
- 'desc' => __( 'Supported extensions are GIF, JPG/JPEG and PNG.<br/><b>Note:</b> JPG/JPEG are recommended for best performance.', 'woocommerce-pdf-invoices' ),
187
- 'default' => '',
188
  ),
189
  array(
190
  'id' => 'bewpi-company-address',
@@ -584,52 +586,41 @@ if ( ! class_exists( 'BEWPI_Template_Settings' ) ) {
584
 
585
  // strip strings.
586
  foreach ( $input as $key => $value ) {
587
- if ( isset( $input[ $key ] ) ) {
588
- // strip all html and php tags and properly handle quoted strings.
589
- $output[ $key ] = $this->strip_str( stripslashes( $input[ $key ] ) );
590
  }
 
 
 
 
 
 
 
 
591
  }
592
 
593
  // company logo file upload.
594
  if ( isset( $input['bewpi_company_logo'] ) ) {
595
- $output['bewpi_company_logo'] = $input['bewpi_company_logo'];
596
- }
597
 
598
- if ( isset( $_FILES['bewpi_company_logo'] ) && 0 === $_FILES['bewpi_company_logo']['error'] ) { // Input var okay.
599
- $file = wp_unslash( $_FILES['bewpi_company_logo'] );
600
- if ( $file['size'] <= 2000000 ) {
601
- $override = array( 'test_form' => false );
602
- $company_logo = wp_handle_upload( $file, $override );
603
- $validate_file_code = validate_file( $company_logo['url'] );
604
- if ( 0 === $validate_file_code ) {
605
- $output['bewpi_company_logo'] = $company_logo['url'];
606
- } else {
607
- switch ( $validate_file_code ) {
608
- case 1:
609
- add_settings_error(
610
- esc_attr( self::SETTINGS_KEY ),
611
- 'file-invalid-2',
612
- __( 'File is invalid and contains either \'..\' or \'./\'.', 'woocommerce-pdf-invoices' )
613
- );
614
- break;
615
- case 2:
616
- add_settings_error(
617
- esc_attr( self::SETTINGS_KEY ),
618
- 'file-invalid-3',
619
- __( 'File is invalid and contains \':\' after the first character.', 'woocommerce-pdf-invoices' )
620
- );
621
- break;
622
- }
623
- }
624
- } else {
625
  add_settings_error(
626
  esc_attr( self::SETTINGS_KEY ),
627
- 'file-invalid-1',
628
- __( 'File should be less then 2MB.', 'woocommerce-pdf-invoices' )
629
  );
 
 
 
 
 
 
 
 
630
  }
631
- } elseif ( isset( $_POST['bewpi_company_logo'] ) && ! empty( $_POST['bewpi_company_logo'] ) ) { // Input var okay.
632
- $output['bewpi_company_logo'] = $_POST['bewpi_company_logo'];
633
  }
634
 
635
  $output['bewpi_next_invoice_number'] = intval( $input['bewpi_next_invoice_number'] );
68
  * @return array
69
  */
70
  private function the_settings() {
71
+ $company_logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'thumbnail' );
72
+
73
  $settings = array(
74
  array(
75
  'id' => 'bewpi-template-name',
181
  'id' => 'bewpi-company-logo',
182
  'name' => self::PREFIX . 'company_logo',
183
  'title' => __( 'Company logo', 'woocommerce-pdf-invoices' ),
184
+ 'callback' => array( $this, 'input_callback' ),
185
  'page' => self::SETTINGS_KEY,
186
  'section' => 'header',
187
+ 'type' => 'text',
188
+ 'desc' => sprintf( __( 'Use the <a href="%1$s">Media Library</a> to <a href="%2$s">upload</a> or choose a .jpg, .jpeg, .gif or .png file and copy and paste the <a href="%3$s" target="_blank">URL</a>.', 'woocommerce-pdf-invoices' ), 'media-new.php', 'upload.php', 'https://codex.wordpress.org/Media_Library_Screen#Attachment_Details' ),
189
+ 'default' => ( is_array( $company_logo ) ) ? $company_logo[0] : '',
190
  ),
191
  array(
192
  'id' => 'bewpi-company-address',
586
 
587
  // strip strings.
588
  foreach ( $input as $key => $value ) {
589
+ if ( ! isset( $input[ $key ] ) ) {
590
+ continue;
 
591
  }
592
+
593
+ if ( 'bewpi_company_logo' === $key ) {
594
+ $output[ $key ] = '';
595
+ continue;
596
+ }
597
+
598
+ // strip all html and php tags and properly handle quoted strings.
599
+ $output[ $key ] = $this->strip_str( stripslashes( $input[ $key ] ) );
600
  }
601
 
602
  // company logo file upload.
603
  if ( isset( $input['bewpi_company_logo'] ) ) {
604
+ global $wpdb;
 
605
 
606
+ $attachment_url = esc_url( $input['bewpi_company_logo'] );
607
+ $post = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid=%s", $attachment_url ) ); // db call ok; no-cache ok.
608
+
609
+ if ( null === $post ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
610
  add_settings_error(
611
  esc_attr( self::SETTINGS_KEY ),
612
+ 'file-invalid',
613
+ __( 'Company logo not found. First upload the image to the Media Library.', 'woocommerce-pdf-invoices' )
614
  );
615
+ } elseif ( ! wp_attachment_is_image( $post ) ) {
616
+ add_settings_error(
617
+ esc_attr( self::SETTINGS_KEY ),
618
+ 'file-invalid',
619
+ __( 'Company logo is not an image. The accepted file extensions/mime types are: .jpg, .jpeg, .gif, .png.', 'woocommerce-pdf-invoices' )
620
+ );
621
+ } else {
622
+ $output['bewpi_company_logo'] = $attachment_url;
623
  }
 
 
624
  }
625
 
626
  $output['bewpi_next_invoice_number'] = intval( $input['bewpi_next_invoice_number'] );
includes/be-woocommerce-pdf-invoices.php CHANGED
@@ -456,10 +456,10 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
456
  return $columns;
457
  }
458
 
459
- // put the column after the Status column.
460
- $new_columns = array_slice( $columns, 0, 2, true ) +
461
  array( 'bewpi_invoice_number' => __( 'Invoice No.', 'woocommmerce-pdf-invoices' ) ) +
462
- array_slice( $columns, 2, count( $columns ) - 1, true );
463
 
464
  return $new_columns;
465
  }
@@ -478,6 +478,8 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
478
 
479
  if ( BEWPI_Invoice::exists( $post->ID ) ) {
480
  echo get_post_meta( $post->ID, '_bewpi_invoice_number', true );
 
 
481
  }
482
  }
483
 
456
  return $columns;
457
  }
458
 
459
+ // put the column before actions column.
460
+ $new_columns = array_slice( $columns, 0, count( $columns ) - 1, true ) +
461
  array( 'bewpi_invoice_number' => __( 'Invoice No.', 'woocommmerce-pdf-invoices' ) ) +
462
+ array_slice( $columns, count( $columns ) - 1, count( $columns ) - ( count( $columns ) - 1 ), true );
463
 
464
  return $new_columns;
465
  }
478
 
479
  if ( BEWPI_Invoice::exists( $post->ID ) ) {
480
  echo get_post_meta( $post->ID, '_bewpi_invoice_number', true );
481
+ } else {
482
+ echo '-';
483
  }
484
  }
485
 
includes/partials/settings-sidebar.php CHANGED
@@ -2,6 +2,7 @@
2
  <h3><?php _e( 'WooCommerce PDF Invoices Premium', 'woocommerce-pdf-invoices' ); ?></h3>
3
  <p>
4
  <?php _e( 'This plugin offers a premium version which comes with the following features:', 'woocommerce-pdf-invoices' ); ?><br/>
 
5
  - <?php _e( 'Bulk export and/or download PDF invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
6
  - <?php _e( 'Bill periodically by generating and sending global invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
7
  - <?php _e( 'Add additional PDF\'s to customer invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
@@ -80,6 +81,5 @@
80
  <li><a href="https://wordpress.org/plugins/woocommerce-pdf-invoices/faq/"><?php _e( 'Frequently Asked Questions', 'woocommerce-pdf-invoices' ); ?> </a></li>
81
  <li><a href="https://wordpress.org/support/plugin/woocommerce-pdf-invoices"><?php _e( 'Support forum', 'woocommerce-pdf-invoices' ); ?></a></li>
82
  <li><a href="https://wordpress.org/support/plugin/woocommerce-pdf-invoices"><?php _e( 'Request a feature', 'woocommerce-pdf-invoices' ); ?></a></li>
83
- <li><a href="mailto:baselbers@hotmail.com"><?php _e( 'Email us', 'woocommerce-pdf-invoices' ); ?></a></li>
84
  </ul>
85
  </aside>
2
  <h3><?php _e( 'WooCommerce PDF Invoices Premium', 'woocommerce-pdf-invoices' ); ?></h3>
3
  <p>
4
  <?php _e( 'This plugin offers a premium version which comes with the following features:', 'woocommerce-pdf-invoices' ); ?><br/>
5
+ - <?php _e( 'Bulk generate PDF invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
6
  - <?php _e( 'Bulk export and/or download PDF invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
7
  - <?php _e( 'Bill periodically by generating and sending global invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
8
  - <?php _e( 'Add additional PDF\'s to customer invoices.', 'woocommerce-pdf-invoices' ); ?><br/>
81
  <li><a href="https://wordpress.org/plugins/woocommerce-pdf-invoices/faq/"><?php _e( 'Frequently Asked Questions', 'woocommerce-pdf-invoices' ); ?> </a></li>
82
  <li><a href="https://wordpress.org/support/plugin/woocommerce-pdf-invoices"><?php _e( 'Support forum', 'woocommerce-pdf-invoices' ); ?></a></li>
83
  <li><a href="https://wordpress.org/support/plugin/woocommerce-pdf-invoices"><?php _e( 'Request a feature', 'woocommerce-pdf-invoices' ); ?></a></li>
 
84
  </ul>
85
  </aside>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link:
4
  Tags: woocommerce pdf invoices, invoice, generate, pdf, woocommerce, attachment, email, completed order, customer invoice, processing order, attach, automatic, vat, rate, sequential, number
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
- Stable tag: 2.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -29,6 +29,8 @@ This WooCommerce plugin generates PDF invoices, attaches it to WooCommerce email
29
 
30
  > **WooCommerce PDF Invoices Premium**<br /><br />
31
  > This plugin offers a premium version which comes with the following features:<br /><br />
 
 
32
  > - Periodically bill by generating and sending global invoices<br />
33
  > - Add additional PDF files to customer invoices.<br />
34
  > - Send customer invoices directly to multiple recipients like suppliers.<br />
@@ -217,6 +219,14 @@ add_filter( 'bewpi_formatted_invoice_number', 'alter_formatted_invoice_number',
217
 
218
  == Changelog ==
219
 
 
 
 
 
 
 
 
 
220
  = 2.6.1 - January 30, 2017 =
221
 
222
  - Improved: `bewpi-install-date` option name by renaming it to `bewpi_install_date`.
4
  Tags: woocommerce pdf invoices, invoice, generate, pdf, woocommerce, attachment, email, completed order, customer invoice, processing order, attach, automatic, vat, rate, sequential, number
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
+ Stable tag: 2.6.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
29
 
30
  > **WooCommerce PDF Invoices Premium**<br /><br />
31
  > This plugin offers a premium version which comes with the following features:<br /><br />
32
+ > - Bulk generate PDF invoices<br/>
33
+ > - Bulk export and/or download PDF invoices<br/>
34
  > - Periodically bill by generating and sending global invoices<br />
35
  > - Add additional PDF files to customer invoices.<br />
36
  > - Send customer invoices directly to multiple recipients like suppliers.<br />
219
 
220
  == Changelog ==
221
 
222
+ = 2.6.2 - February 2, 2017 =
223
+
224
+ - Improved: Company logo setting by just using a attachment url from Media Library. Note that the image won't be shown on settings page anymore.
225
+ - Improved: 'readme.txt' and 'settings-sidebar.php' files.
226
+ - Fixed: `bewpi_mpdf` filter not working properly. Should be placed before writing html.
227
+ - Fixed: Invoice number compatibility with third party plugins by using `get_order_number()` method instead of `id`.
228
+ - Fixed: Invoice number column on mobile by adding a '-' when no invoice number exists.
229
+
230
  = 2.6.1 - January 30, 2017 =
231
 
232
  - Improved: `bewpi-install-date` option name by renaming it to `bewpi_install_date`.