WooCommerce PDF Invoices - Version 2.0.1

Version Description

  • March 26, 2015 =

  • Fixed: Validation errors

  • Fixed: Parse error '['

Download this release

Release Info

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

Code changes from version 2.0.0 to 2.0.1

admin/classes/woocommerce-pdf-invoices.php CHANGED
@@ -273,7 +273,7 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
273
  public function woocommerce_order_page_action_view_invoice( $order ) {
274
  $invoice = new WPI_Invoice(new WC_Order($order->id), $this->textdomain);
275
  if( $invoice->exists() ) {
276
- $this->show_invoice_button('View invoice', $order->id, 'view', '', ['class="button tips wpi-admin-order-create-invoice-btn"'] );
277
  }
278
  }
279
 
@@ -314,7 +314,8 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
314
  $attr .= $str . ' ';
315
  }
316
 
317
- echo '<a title="' . $title . '" href="' . $href . '" ' . $attr . '><button type="button" class="button grant_access">' . $btn_title . '</button></a>';
 
318
  }
319
 
320
  /**
@@ -326,11 +327,11 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
326
 
327
  if( $invoice->exists() ) {
328
  $this->show_invoice_number_info($invoice->get_formatted_date(), $invoice->get_formatted_invoice_number());
329
- $this->show_invoice_button('View invoice', $post->ID, 'view', 'View', ['class="invoice-btn"'] );
330
- $this->show_invoice_button('Cancel invoice', $post->ID, 'cancel', 'Cancel', ['class="invoice-btn"', 'onclick="return confirm(\'Are you sure to delete the invoice?\')"'] );
331
  } else {
332
  $invoice->delete_all_post_meta();
333
- $this->show_invoice_button('Create invoice', $post->ID, 'create', 'Create', ['class="invoice-btn"'] );
334
  }
335
  }
336
  }
273
  public function woocommerce_order_page_action_view_invoice( $order ) {
274
  $invoice = new WPI_Invoice(new WC_Order($order->id), $this->textdomain);
275
  if( $invoice->exists() ) {
276
+ $this->show_invoice_button('View invoice', $order->id, 'view', '', array('class="button tips wpi-admin-order-create-invoice-btn"') );
277
  }
278
  }
279
 
314
  $attr .= $str . ' ';
315
  }
316
 
317
+ $btn = '<a title="' . $title . '" href="' . $href . '" ' . $attr . '><button type="button" class="button grant_access">' . $btn_title . '</button></a>';
318
+ echo $btn;
319
  }
320
 
321
  /**
327
 
328
  if( $invoice->exists() ) {
329
  $this->show_invoice_number_info($invoice->get_formatted_date(), $invoice->get_formatted_invoice_number());
330
+ $this->show_invoice_button('View invoice', $post->ID, 'view', 'View', array('class="invoice-btn"') );
331
+ $this->show_invoice_button('Cancel invoice', $post->ID, 'cancel', 'Cancel', array('class="invoice-btn"', 'onclick="return confirm(\'Are you sure to delete the invoice?\')"' ) );
332
  } else {
333
  $invoice->delete_all_post_meta();
334
+ $this->show_invoice_button('Create invoice', $post->ID, 'create', 'Create', array('class="invoice-btn"') );
335
  }
336
  }
337
  }
admin/classes/wpi-general-settings.php CHANGED
@@ -173,47 +173,56 @@ if ( ! class_exists( 'WPI_General_Settings' ) ) {
173
  $output = array();
174
 
175
  // Validate email type
176
- if ($this->is_valid_str($input['email_type'])) {
177
- $output['email_type'] = $input['email_type'];
178
- } else {
179
- add_settings_error(
180
- esc_attr($this->settings_key),
181
- 'invalid-email-type',
182
- __('Invalid type of Email.', $this->textdomain)
183
- );
 
 
 
184
  }
185
 
186
  // Validate new order email
187
- if ($this->is_valid_int($input['new_order'])) {
188
- $output['new_order'] = $input['new_order'];
189
- } else {
190
- add_settings_error(
191
- esc_attr($this->settings_key),
192
- 'invalid-new-order-email-value',
193
- __('Please don\'t try to change the values.', $this->textdomain)
194
- );
 
 
195
  }
196
 
197
  // Validate new order email
198
- if ($this->validate_checkbox($input['email_it_in'])) {
199
- $output['email_it_in'] = $input['email_it_in'];
200
- } else {
201
- add_settings_error(
202
- esc_attr($this->settings_key),
203
- 'invalid-email-it-in-value',
204
- __('Please don\'t try to change the values.', $this->textdomain)
205
- );
 
 
206
  }
207
 
208
  // Validate Email
209
- if (is_email(sanitize_email($input['email_it_in_account']))) {
210
- $output['email_it_in_account'] = $input['email_it_in_account'];
211
- } else {
212
- add_settings_error(
213
- esc_attr($this->settings_key),
214
- 'invalid-email',
215
- __('Invalid Email address.', $this->textdomain)
216
- );
 
 
217
  }
218
 
219
  return $output;
173
  $output = array();
174
 
175
  // Validate email type
176
+
177
+ if ( isset( $input['email_type'] ) ) {
178
+ if ($this->is_valid_str($input['email_type'])) {
179
+ $output['email_type'] = $input['email_type'];
180
+ } else {
181
+ add_settings_error(
182
+ esc_attr($this->settings_key),
183
+ 'invalid-email-type',
184
+ __('Invalid type of Email.', $this->textdomain)
185
+ );
186
+ }
187
  }
188
 
189
  // Validate new order email
190
+ if ( isset( $input['new_order'] ) ) {
191
+ if ($this->is_valid_int($input['new_order'])) {
192
+ $output['new_order'] = $input['new_order'];
193
+ } else {
194
+ add_settings_error(
195
+ esc_attr($this->settings_key),
196
+ 'invalid-new-order-email-value',
197
+ __('Please don\'t try to change the values.', $this->textdomain)
198
+ );
199
+ }
200
  }
201
 
202
  // Validate new order email
203
+ if ( isset( $input['email_it_in'] ) ) {
204
+ if( $this->validate_checkbox($input['email_it_in']) ) {
205
+ $output['email_it_in'] = $input['email_it_in'];
206
+ } else {
207
+ add_settings_error(
208
+ esc_attr($this->settings_key),
209
+ 'invalid-email-it-in-value',
210
+ __('Please don\'t try to change the values.', $this->textdomain)
211
+ );
212
+ }
213
  }
214
 
215
  // Validate Email
216
+ if( isset( $input['email_it_in_account'] ) && $input['email_it_in_account'] != "" ) {
217
+ if (is_email(sanitize_email($input['email_it_in_account']))) {
218
+ $output['email_it_in_account'] = $input['email_it_in_account'];
219
+ } else {
220
+ add_settings_error(
221
+ esc_attr($this->settings_key),
222
+ 'invalid-email',
223
+ __('Invalid Email address.', $this->textdomain)
224
+ );
225
+ }
226
  }
227
 
228
  return $output;
admin/classes/wpi-template-settings.php CHANGED
@@ -467,38 +467,44 @@ if ( ! class_exists( 'WPI_Template_Settings' ) ) {
467
  $output = array();
468
 
469
  // Validate template id
470
- if ($this->is_valid_int($input['template_id'])) {
471
- $output['template_id'] = $input['template_id'];
472
- } else {
473
- add_settings_error(
474
- esc_attr($this->settings_key),
475
- 'invalid-template-value',
476
- __('Invalid template.', $this->textdomain)
477
- );
 
 
478
  }
479
 
480
  // Validate color theme.
481
- if (is_string($this->is_valid_hex_color($input['color_theme']))) {
482
- $output['color_theme'] = $this->is_valid_hex_color($input['color_theme']);
483
- } else if ($this->is_valid_hex_color($input['color_theme'])) {
484
- $output['color_theme'] = $input['color_theme'];
485
- } else {
486
- add_settings_error(
487
- esc_attr($this->settings_key),
488
- 'invalid-color-hex',
489
- __('Invalid color theme code.', $this->textdomain)
490
- );
 
 
491
  }
492
 
493
  // Validate company name
494
- if ($this->is_valid_str($input['company_name'])) {
495
- $output['company_name'] = $input['company_name'];
496
- } else {
497
- add_settings_error(
498
- esc_attr($this->settings_key),
499
- 'invalid-company-name',
500
- __('Invalid company name.', $this->textdomain)
501
- );
 
 
502
  }
503
 
504
  // Validate company logo
@@ -506,7 +512,12 @@ if ( ! class_exists( 'WPI_Template_Settings' ) ) {
506
 
507
  // Validate textarea's
508
  $ta_errors = 0;
509
- $textarea_values = array('intro_text' => $input['intro_text'], 'company_address' => $input['company_address'], 'company_details' => $input['company_details'], 'terms' => $input['terms']);
 
 
 
 
 
510
  foreach ($textarea_values as $key => $value) {
511
  ($this->validate_textarea($value)) ? $output[$key] = $value : $ta_errors += 1;
512
  }
@@ -520,24 +531,28 @@ if ( ! class_exists( 'WPI_Template_Settings' ) ) {
520
  }
521
 
522
  // Validate next invoice number
523
- if ($this->is_valid_int($input['next_invoice_number'])) {
524
- $output['next_invoice_number'] = $input['next_invoice_number'];
525
- } else {
526
- add_settings_error(
527
- esc_attr($this->settings_key),
528
- 'invalid_next_invoice_number',
529
- __('Invalid (next) invoice number.', $this->textdomain)
530
- );
 
 
531
  }
532
 
533
  // Validate zero digits
534
  $ind_errors = 0;
535
- if ($this->is_valid_int($input['invoice_number_digits'])) {
536
- ($input['invoice_number_digits'] >= 3 && $input['invoice_number_digits'] <= 6)
537
- ? $output['invoice_number_digits'] = $input['invoice_number_digits']
538
- : $ind_errors += 1;
539
- } else {
540
- $ind_errors += 1;
 
 
541
  }
542
 
543
  if ($ind_errors > 0) {
@@ -549,42 +564,51 @@ if ( ! class_exists( 'WPI_Template_Settings' ) ) {
549
  }
550
 
551
  // Validate invoice number prefix and suffix.
552
- $output['invoice_prefix'] = esc_html($input['invoice_prefix']);
553
- $output['invoice_suffix'] = esc_html($input['invoice_suffix']);
 
 
 
 
 
554
 
555
  // Validate invoice number format
556
- if ($this->is_valid_str($input['invoice_format'])) {
557
- if (strpos($input['invoice_format'], '[number]') !== false) {
558
- $output['invoice_format'] = $input['invoice_format'];
 
 
 
 
 
 
 
 
559
  } else {
560
  add_settings_error(
561
  esc_attr($this->settings_key),
562
- 'invalid_invoice_format-1',
563
- __('The [number] placeholder is required as invoice number format.', $this->textdomain)
564
  );
565
  }
566
- } else {
567
- add_settings_error(
568
- esc_attr($this->settings_key),
569
- 'invalid_invoice_format-2',
570
- __('Invalid invoice number format.', $this->textdomain)
571
- );
572
  }
573
 
574
  // Validate all checkboxes
575
  $cb_errors = 0;
576
  $checkbox_values = array(
577
- 'reset_invoice_number' => $input['reset_invoice_number'],
578
- 'show_sku' => $input['show_sku'],
579
- 'show_discount' => $input['show_discount'],
580
- 'show_subtotal' => $input['show_subtotal'],
581
- 'show_tax' => $input['show_tax'],
582
- 'show_shipping' => $input['show_shipping'],
583
- 'show_customer_notes' => $input['show_customer_notes']
584
  );
585
 
586
  foreach ($checkbox_values as $key => $value) {
587
- ($this->validate_checkbox($value)) ? $output[$key] = $value : $output[$key] = 0;
 
 
588
  }
589
 
590
  if ($cb_errors > 0) {
@@ -595,14 +619,16 @@ if ( ! class_exists( 'WPI_Template_Settings' ) ) {
595
  );
596
  }
597
 
598
- if ($this->is_valid_str($input['invoice_date_format'])) {
599
- $output['invoice_date_format'] = $input['invoice_date_format'];
600
- } else {
601
- add_settings_error(
602
- esc_attr($this->settings_key),
603
- 'invalid-date-format',
604
- __('Invalid date format.', $this->textdomain)
605
- );
 
 
606
  }
607
 
608
  return $output;
467
  $output = array();
468
 
469
  // Validate template id
470
+ if( isset( $input['template_id'] ) ) {
471
+ if ($this->is_valid_int($input['template_id'])) {
472
+ $output['template_id'] = $input['template_id'];
473
+ } else {
474
+ add_settings_error(
475
+ esc_attr($this->settings_key),
476
+ 'invalid-template-value',
477
+ __('Invalid template.', $this->textdomain)
478
+ );
479
+ }
480
  }
481
 
482
  // Validate color theme.
483
+ if( isset( $input['color_theme'] ) ) {
484
+ if (is_string($this->is_valid_hex_color($input['color_theme']))) {
485
+ $output['color_theme'] = $this->is_valid_hex_color($input['color_theme']);
486
+ } else if ($this->is_valid_hex_color($input['color_theme'])) {
487
+ $output['color_theme'] = $input['color_theme'];
488
+ } else {
489
+ add_settings_error(
490
+ esc_attr($this->settings_key),
491
+ 'invalid-color-hex',
492
+ __('Invalid color theme code.', $this->textdomain)
493
+ );
494
+ }
495
  }
496
 
497
  // Validate company name
498
+ if( isset( $input['company_name'] ) ) {
499
+ if ($this->is_valid_str($input['company_name'])) {
500
+ $output['company_name'] = $input['company_name'];
501
+ } else {
502
+ add_settings_error(
503
+ esc_attr($this->settings_key),
504
+ 'invalid-company-name',
505
+ __('Invalid company name.', $this->textdomain)
506
+ );
507
+ }
508
  }
509
 
510
  // Validate company logo
512
 
513
  // Validate textarea's
514
  $ta_errors = 0;
515
+ $textarea_values = array(
516
+ 'intro_text' => ( isset( $input['intro_text'] ) ) ? $input['intro_text'] : '',
517
+ 'company_address' => ( isset( $input['company_address'] ) ) ? $input['company_address'] : '',
518
+ 'company_details' => ( isset( $input['company_details'] ) ) ? $input['company_details'] : '',
519
+ 'terms' => ( isset( $input['terms'] ) ) ? $input['terms'] : ''
520
+ );
521
  foreach ($textarea_values as $key => $value) {
522
  ($this->validate_textarea($value)) ? $output[$key] = $value : $ta_errors += 1;
523
  }
531
  }
532
 
533
  // Validate next invoice number
534
+ if( isset( $input['next_invoice_number'] ) ) {
535
+ if ($this->is_valid_int($input['next_invoice_number'])) {
536
+ $output['next_invoice_number'] = $input['next_invoice_number'];
537
+ } else {
538
+ add_settings_error(
539
+ esc_attr($this->settings_key),
540
+ 'invalid_next_invoice_number',
541
+ __('Invalid (next) invoice number.', $this->textdomain)
542
+ );
543
+ }
544
  }
545
 
546
  // Validate zero digits
547
  $ind_errors = 0;
548
+ if( isset( $input['invoice_number_digits'] ) ) {
549
+ if ($this->is_valid_int($input['invoice_number_digits'])) {
550
+ ($input['invoice_number_digits'] >= 3 && $input['invoice_number_digits'] <= 6)
551
+ ? $output['invoice_number_digits'] = $input['invoice_number_digits']
552
+ : $ind_errors += 1;
553
+ } else {
554
+ $ind_errors += 1;
555
+ }
556
  }
557
 
558
  if ($ind_errors > 0) {
564
  }
565
 
566
  // Validate invoice number prefix and suffix.
567
+ if( isset( $input['invoice_prefix'] ) ) {
568
+ $output['invoice_prefix'] = esc_html($input['invoice_prefix']);
569
+ }
570
+
571
+ if( isset( $input['email_it_in_account'] ) ) {
572
+ $output['invoice_suffix'] = esc_html($input['invoice_suffix']);
573
+ }
574
 
575
  // Validate invoice number format
576
+ if( isset( $input['invoice_format'] ) ) {
577
+ if ($this->is_valid_str($input['invoice_format'])) {
578
+ if (strpos($input['invoice_format'], '[number]') !== false) {
579
+ $output['invoice_format'] = $input['invoice_format'];
580
+ } else {
581
+ add_settings_error(
582
+ esc_attr($this->settings_key),
583
+ 'invalid_invoice_format-1',
584
+ __('The [number] placeholder is required as invoice number format.', $this->textdomain)
585
+ );
586
+ }
587
  } else {
588
  add_settings_error(
589
  esc_attr($this->settings_key),
590
+ 'invalid_invoice_format-2',
591
+ __('Invalid invoice number format.', $this->textdomain)
592
  );
593
  }
 
 
 
 
 
 
594
  }
595
 
596
  // Validate all checkboxes
597
  $cb_errors = 0;
598
  $checkbox_values = array(
599
+ 'reset_invoice_number' => ( isset( $input['reset_invoice_number'] ) ) ? $input['reset_invoice_number'] : '',
600
+ 'show_sku' => ( isset( $input['show_sku'] ) ) ? $input['show_sku'] : '',
601
+ 'show_discount' => ( isset( $input['show_discount'] ) ) ? $input['show_discount'] : '',
602
+ 'show_subtotal' => ( isset( $input['show_subtotal'] ) ) ? $input['show_subtotal'] : '',
603
+ 'show_tax' => ( isset( $input['show_tax'] ) ) ? $input['show_tax'] : '',
604
+ 'show_shipping' => ( isset( $input['show_shipping'] ) ) ? $input['show_shipping'] : '',
605
+ 'show_customer_notes' => ( isset( $input['show_customer_notes'] ) ) ? $input['show_customer_notes'] : ''
606
  );
607
 
608
  foreach ($checkbox_values as $key => $value) {
609
+ if( $value != '' ) {
610
+ ($this->validate_checkbox($value)) ? $output[$key] = $value : $output[$key] = 0;
611
+ }
612
  }
613
 
614
  if ($cb_errors > 0) {
619
  );
620
  }
621
 
622
+ if( isset( $input['invoice_date_format'] ) ) {
623
+ if ($this->is_valid_str($input['invoice_date_format'])) {
624
+ $output['invoice_date_format'] = $input['invoice_date_format'];
625
+ } else {
626
+ add_settings_error(
627
+ esc_attr($this->settings_key),
628
+ 'invalid-date-format',
629
+ __('Invalid date format.', $this->textdomain)
630
+ );
631
+ }
632
  }
633
 
634
  return $output;
bootstrap.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * @version 2.0.0
5
  * @package WooCommerce PDF Invoices
6
  * @author baaaaas
7
  *
@@ -9,7 +9,7 @@
9
  * Plugin Name: WooCommerce PDF Invoices
10
  * Plugin URI:
11
  * Description: Generates customized PDF invoices and automatically attaches it to a WooCommerce email type of your choice. Now sending invoices to your Google Drive, Egnyte, Dropbox or OneDrive and it's all FREE!
12
- * Version: 2.0.0
13
  * Author: baaaaas
14
  * Author URI:
15
  * License: GPL-2.0+
1
  <?php
2
 
3
  /**
4
+ * @version 2.0.1
5
  * @package WooCommerce PDF Invoices
6
  * @author baaaaas
7
  *
9
  * Plugin Name: WooCommerce PDF Invoices
10
  * Plugin URI:
11
  * Description: Generates customized PDF invoices and automatically attaches it to a WooCommerce email type of your choice. Now sending invoices to your Google Drive, Egnyte, Dropbox or OneDrive and it's all FREE!
12
+ * Version: 2.0.1
13
  * Author: baaaaas
14
  * Author URI:
15
  * License: GPL-2.0+
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: 3.5
6
  Tested up to: 4.1.1
7
- Stable tag: 2.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -67,6 +67,11 @@ The manual installation method involves downloading our plugin and uploading it
67
 
68
  == Changelog ==
69
 
 
 
 
 
 
70
  = 2.0.0 - March 23, 2015 =
71
 
72
  - Added: Send invoice to your personal cloud storage with emailitin.com
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: 3.5
6
  Tested up to: 4.1.1
7
+ Stable tag: 2.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
67
 
68
  == Changelog ==
69
 
70
+ = 2.0.1 - March 26, 2015 =
71
+
72
+ - Fixed: Validation errors
73
+ - Fixed: Parse error '['
74
+
75
  = 2.0.0 - March 23, 2015 =
76
 
77
  - Added: Send invoice to your personal cloud storage with emailitin.com