WooCommerce PDF Invoices & Packing Slips - Version 2.4.6

Version Description

  • Fix: Locale determination for admins on their own my account page
  • Fix: Action buttons icon alignment in WP5.3+
  • Fix: Add bulk actions via native WP methods
  • Tweak: minimize calls to WooCommerce mailer class when loading settings
Download this release

Release Info

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

Code changes from version 2.4.5 to 2.4.6

assets/css/order-styles-buttons-wc20.css CHANGED
@@ -1,3 +1,3 @@
1
- .type-shop_order .column-order_actions a.button.wpo_wcpdf {
2
- padding: 0 2px;
3
  }
1
+ .type-shop_order .column-order_actions a.button.wpo_wcpdf {
2
+ padding: 0 2px;
3
  }
assets/css/{order-styles-buttons.css → order-styles-buttons-wc38.css} RENAMED
@@ -1,6 +1,6 @@
1
- .type-shop_order .column-order_actions a.button.wpo_wcpdf {
2
- float: left;
3
- width: 26px;
4
- height: 26px;
5
- padding: 3px 2px;
6
  }
1
+ .type-shop_order .column-order_actions a.button.wpo_wcpdf {
2
+ float: left;
3
+ width: 26px;
4
+ height: 26px;
5
+ padding: 3px 2px;
6
  }
assets/css/order-styles-buttons-wc39.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ .type-shop_order .column-order_actions a.button.wpo_wcpdf {
2
+ float: left;
3
+ width: 26px;
4
+ height: 26px;
5
+ padding: 3px 2px;
6
+ }
7
+
8
+ .type-shop_order .column-wc_actions a.button.wpo_wcpdf img {
9
+ margin-top: 3px;
10
+ }
assets/css/order-styles.css CHANGED
@@ -1,79 +1,79 @@
1
- /* Order list buttons: */
2
- .type-shop_order .column-wc_actions a.button.wpo_wcpdf {
3
- padding: 2px !important;
4
- }
5
-
6
- .type-shop_order .column-wc_actions a.button.wpo_wcpdf.exists::after {
7
- content: "\f147";
8
- position:absolute;
9
- font-size:16px;
10
- left:7px;
11
- color:#2aad2a;
12
- }
13
-
14
- .wpo_wcpdf-actions a.button.exists::after {
15
- font-family: Dashicons;
16
- content: "\f147";
17
- font-size: 16px;
18
- margin-left: 4px;
19
- color: #2aad2a;
20
- vertical-align: middle;
21
- }
22
-
23
- .type-shop_order .column-wc_actions a.button.wpo_wcpdf img,
24
- .type-shop_order .column-order_actions a.button.wpo_wcpdf img {
25
- width: 16px;
26
- }
27
-
28
- .widefat .column-pdf_invoice_number {
29
- width: 110px;
30
- }
31
-
32
- @media screen and (max-width: 782px) {
33
- .wp-list-table .column-pdf_invoice_number, .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-pdf_invoice_number:not(.check-column) {
34
- display: none;
35
- }
36
- .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-pdf_invoice_number {
37
- padding: 3px 8px 3px 35%
38
- }
39
- }
40
-
41
- #wpo_wcpdf-data-input-box h4 {
42
- font-size: 14px;
43
- line-height: 1.4;
44
- margin: 1.5em 0 0 0;
45
- }
46
-
47
- #wpo_wcpdf-data-input-box p {
48
- margin: 0.5em 0;
49
- }
50
-
51
- #wpo_wcpdf-data-input-box .form-field input {
52
- width: auto;
53
- }
54
-
55
- .wcpdf-data-fields .read-only {
56
- height:auto;
57
- display:block;
58
- }
59
-
60
- .wcpdf-data-fields .editable {
61
- height:auto;
62
- display:none;
63
- }
64
-
65
- /* Edit buttons Invoice, Proforma and Credit */
66
- .wcpdf-data-fields h4 .dashicons:first-of-type {
67
- margin-left:20px!important;
68
- }
69
-
70
- .dashicons-edit,
71
- .dashicons-trash {
72
- opacity:0.5;
73
- }
74
-
75
- .dashicons-edit:hover,
76
- .dashicons-trash:hover {
77
- opacity:1;
78
- cursor:pointer;
79
- }
1
+ /* Order list buttons: */
2
+ .type-shop_order .column-wc_actions a.button.wpo_wcpdf {
3
+ padding: 2px !important;
4
+ }
5
+
6
+ .type-shop_order .column-wc_actions a.button.wpo_wcpdf.exists::after {
7
+ content: "\f147";
8
+ position:absolute;
9
+ font-size:16px;
10
+ left:7px;
11
+ color:#2aad2a;
12
+ }
13
+
14
+ .wpo_wcpdf-actions a.button.exists::after {
15
+ font-family: Dashicons;
16
+ content: "\f147";
17
+ font-size: 16px;
18
+ margin-left: 4px;
19
+ color: #2aad2a;
20
+ vertical-align: middle;
21
+ }
22
+
23
+ .type-shop_order .column-wc_actions a.button.wpo_wcpdf img,
24
+ .type-shop_order .column-order_actions a.button.wpo_wcpdf img /* legacy: 3.2 & older */ {
25
+ width: 16px;
26
+ }
27
+
28
+ .widefat .column-pdf_invoice_number {
29
+ width: 110px;
30
+ }
31
+
32
+ @media screen and (max-width: 782px) {
33
+ .wp-list-table .column-pdf_invoice_number, .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-pdf_invoice_number:not(.check-column) {
34
+ display: none;
35
+ }
36
+ .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-pdf_invoice_number {
37
+ padding: 3px 8px 3px 35%
38
+ }
39
+ }
40
+
41
+ #wpo_wcpdf-data-input-box h4 {
42
+ font-size: 14px;
43
+ line-height: 1.4;
44
+ margin: 1.5em 0 0 0;
45
+ }
46
+
47
+ #wpo_wcpdf-data-input-box p {
48
+ margin: 0.5em 0;
49
+ }
50
+
51
+ #wpo_wcpdf-data-input-box .form-field input {
52
+ width: auto;
53
+ }
54
+
55
+ .wcpdf-data-fields .read-only {
56
+ height:auto;
57
+ display:block;
58
+ }
59
+
60
+ .wcpdf-data-fields .editable {
61
+ height:auto;
62
+ display:none;
63
+ }
64
+
65
+ /* Edit buttons Invoice, Proforma and Credit */
66
+ .wcpdf-data-fields h4 .dashicons:first-of-type {
67
+ margin-left:20px!important;
68
+ }
69
+
70
+ .dashicons-edit,
71
+ .dashicons-trash {
72
+ opacity:0.5;
73
+ }
74
+
75
+ .dashicons-edit:hover,
76
+ .dashicons-trash:hover {
77
+ opacity:1;
78
+ cursor:pointer;
79
+ }
includes/class-wcpdf-admin.php CHANGED
@@ -17,7 +17,11 @@ class Admin {
17
  add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_invoice_number_column' ), 999 );
18
  add_action( 'manage_shop_order_posts_custom_column', array( $this, 'invoice_number_column_data' ), 2 );
19
  add_action( 'add_meta_boxes_shop_order', array( $this, 'add_meta_boxes' ) );
20
- add_action( 'admin_footer', array( $this, 'bulk_actions' ) );
 
 
 
 
21
  add_filter( 'woocommerce_shop_order_search_fields', array( $this, 'search_fields' ) );
22
 
23
  add_action( 'woocommerce_process_shop_order_meta', array( $this,'save_invoice_number_date' ), 35, 2 );
@@ -420,22 +424,24 @@ class Admin {
420
  }
421
 
422
  /**
423
- * Add actions to menu
424
  */
425
- public function bulk_actions() {
426
- if ( $this->is_order_page() ) {
427
- $bulk_actions = array();
428
- $documents = WPO_WCPDF()->documents->get_documents();
429
- foreach ($documents as $document) {
430
- $bulk_actions[$document->get_type()] = "PDF " . $document->get_title();
431
- }
432
 
433
- $bulk_actions = apply_filters( 'wpo_wcpdf_bulk_actions', $bulk_actions );
434
-
 
 
 
435
  ?>
436
  <script type="text/javascript">
437
  jQuery(document).ready(function() {
438
- <?php foreach ($bulk_actions as $action => $title) { ?>
439
  jQuery('<option>').val('<?php echo $action; ?>').html('<?php echo esc_attr( $title ); ?>').appendTo("select[name='action'], select[name='action2']");
440
  <?php } ?>
441
  });
@@ -444,6 +450,16 @@ class Admin {
444
  }
445
  }
446
 
 
 
 
 
 
 
 
 
 
 
447
  /**
448
  * Save invoice number
449
  */
17
  add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_invoice_number_column' ), 999 );
18
  add_action( 'manage_shop_order_posts_custom_column', array( $this, 'invoice_number_column_data' ), 2 );
19
  add_action( 'add_meta_boxes_shop_order', array( $this, 'add_meta_boxes' ) );
20
+ if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '>=' ) ) {
21
+ add_action( 'bulk_actions-edit-shop_order', array( $this, 'bulk_actions' ), 20 );
22
+ } else {
23
+ add_action( 'admin_footer', array( $this, 'bulk_actions_js' ) );
24
+ }
25
  add_filter( 'woocommerce_shop_order_search_fields', array( $this, 'search_fields' ) );
26
 
27
  add_action( 'woocommerce_process_shop_order_meta', array( $this,'save_invoice_number_date' ), 35, 2 );
424
  }
425
 
426
  /**
427
+ * Add actions to menu, WP3.5+
428
  */
429
+ public function bulk_actions( $actions ) {
430
+ foreach ($this->get_bulk_actions() as $action => $title) {
431
+ $actions[$action] = $title;
432
+ }
433
+ return $actions;
434
+ }
 
435
 
436
+ /**
437
+ * Add actions to menu, legacy method
438
+ */
439
+ public function bulk_actions_js() {
440
+ if ( $this->is_order_page() ) {
441
  ?>
442
  <script type="text/javascript">
443
  jQuery(document).ready(function() {
444
+ <?php foreach ($this->get_bulk_actions() as $action => $title) { ?>
445
  jQuery('<option>').val('<?php echo $action; ?>').html('<?php echo esc_attr( $title ); ?>').appendTo("select[name='action'], select[name='action2']");
446
  <?php } ?>
447
  });
450
  }
451
  }
452
 
453
+ public function get_bulk_actions() {
454
+ $actions = array();
455
+ $documents = WPO_WCPDF()->documents->get_documents();
456
+ foreach ($documents as $document) {
457
+ $actions[$document->get_type()] = "PDF " . $document->get_title();
458
+ }
459
+
460
+ return apply_filters( 'wpo_wcpdf_bulk_actions', $actions );
461
+ }
462
+
463
  /**
464
  * Save invoice number
465
  */
includes/class-wcpdf-assets.php CHANGED
@@ -25,6 +25,7 @@ class Assets {
25
  * Load styles & scripts
26
  */
27
  public function backend_scripts_styles ( $hook ) {
 
28
  if( $this->is_order_page() ) {
29
  // STYLES
30
  wp_enqueue_style( 'thickbox' );
@@ -36,19 +37,30 @@ class Assets {
36
  WPO_WCPDF_VERSION
37
  );
38
 
39
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 ) {
40
- // WC 2.1 or newer (MP6) is used: bigger buttons
 
 
41
  wp_enqueue_style(
42
  'wpo-wcpdf-order-styles-buttons',
43
- WPO_WCPDF()->plugin_url() . '/assets/css/order-styles-buttons.css',
44
  array(),
45
  WPO_WCPDF_VERSION
46
  );
47
- } else {
48
- // legacy WC 2.0 styles
 
49
  wp_enqueue_style(
50
  'wpo-wcpdf-order-styles-buttons',
51
- WPO_WCPDF()->plugin_url() . '/assets/css/order-styles-buttons-wc20.css',
 
 
 
 
 
 
 
 
52
  array(),
53
  WPO_WCPDF_VERSION
54
  );
25
  * Load styles & scripts
26
  */
27
  public function backend_scripts_styles ( $hook ) {
28
+ global $wp_version;
29
  if( $this->is_order_page() ) {
30
  // STYLES
31
  wp_enqueue_style( 'thickbox' );
37
  WPO_WCPDF_VERSION
38
  );
39
 
40
+ $wc_version = defined( 'WC_VERSION' ) ? WC_VERSION : WOOCOMMERCE_VERSION;
41
+
42
+ if ( version_compare( $wc_version, '2.1', '<' ) ) {
43
+ // legacy WC2.0 styles
44
  wp_enqueue_style(
45
  'wpo-wcpdf-order-styles-buttons',
46
+ WPO_WCPDF()->plugin_url() . '/assets/css/order-styles-buttons-wc20.css',
47
  array(),
48
  WPO_WCPDF_VERSION
49
  );
50
+ } elseif ( version_compare( $wc_version, '2.1', '>=' ) && version_compare( $wp_version, '5.3', '<' ) ) {
51
+ // WC2.1 - WC3.2 (MP6) is used: bigger buttons
52
+ // also applied to WC3.3+ but without affect due to .column-order_actions class being deprecated in 3.3+
53
  wp_enqueue_style(
54
  'wpo-wcpdf-order-styles-buttons',
55
+ WPO_WCPDF()->plugin_url() . '/assets/css/order-styles-buttons-wc38.css',
56
+ array(),
57
+ WPO_WCPDF_VERSION
58
+ );
59
+ } elseif ( version_compare( $wp_version, '5.3', '>=' ) ) {
60
+ // WP5.3 or newer is used: realign img inside buttons
61
+ wp_enqueue_style(
62
+ 'wpo-wcpdf-order-styles-buttons',
63
+ WPO_WCPDF()->plugin_url() . '/assets/css/order-styles-buttons-wc39.css',
64
  array(),
65
  WPO_WCPDF_VERSION
66
  );
includes/documents/abstract-wcpdf-order-document.php CHANGED
@@ -752,6 +752,12 @@ abstract class Order_Document {
752
  * @return array $emails list of all email ids/slugs and names
753
  */
754
  public function get_wc_emails() {
 
 
 
 
 
 
755
  // get emails from WooCommerce
756
  if (function_exists('WC')) {
757
  $mailer = WC()->mailer();
752
  * @return array $emails list of all email ids/slugs and names
753
  */
754
  public function get_wc_emails() {
755
+ // only run this in the context of the settings page or setup wizard
756
+ // prevents WPML language mixups
757
+ if ( empty( $_GET['page'] ) || !in_array( $_GET['page'], array('wpo-wcpdf-setup','wpo_wcpdf_options_page') ) ) {
758
+ return array();
759
+ }
760
+
761
  // get emails from WooCommerce
762
  if (function_exists('WC')) {
763
  $mailer = WC()->mailer();
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.3
7
  Requires PHP: 5.3
8
- Stable tag: 2.4.5
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.4.5 =
106
  * Fix: Prevent errors for subscription tax fallback on refunds
107
 
5
  Requires at least: 3.5
6
  Tested up to: 5.3
7
  Requires PHP: 5.3
8
+ Stable tag: 2.4.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
102
 
103
  == Changelog ==
104
 
105
+ = 2.4.6 =
106
+ * Fix: Locale determination for admins on their own my account page
107
+ * Fix: Action buttons icon alignment in WP5.3+
108
+ * Fix: Add bulk actions via native WP methods
109
+ * Tweak: minimize calls to WooCommerce mailer class when loading settings
110
+
111
  = 2.4.5 =
112
  * Fix: Prevent errors for subscription tax fallback on refunds
113
 
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.4.5
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
@@ -21,7 +21,7 @@ if ( !class_exists( 'WPO_WCPDF' ) ) :
21
 
22
  class WPO_WCPDF {
23
 
24
- public $version = '2.4.5';
25
  public $plugin_basename;
26
  public $legacy_mode;
27
 
@@ -72,7 +72,11 @@ class WPO_WCPDF {
72
  * Note: the first-loaded translation file overrides any following ones if the same translation is present
73
  */
74
  public function translations() {
75
- $locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
 
 
 
 
76
  $locale = apply_filters( 'plugin_locale', $locale, 'woocommerce-pdf-invoices-packing-slips' );
77
  $dir = trailingslashit( WP_LANG_DIR );
78
 
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.4.6
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
21
 
22
  class WPO_WCPDF {
23
 
24
+ public $version = '2.4.6';
25
  public $plugin_basename;
26
  public $legacy_mode;
27
 
72
  * Note: the first-loaded translation file overrides any following ones if the same translation is present
73
  */
74
  public function translations() {
75
+ if ( function_exists( 'determine_locale' ) ) { // WP5.0+
76
+ $locale = determine_locale();
77
+ } else {
78
+ $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
79
+ }
80
  $locale = apply_filters( 'plugin_locale', $locale, 'woocommerce-pdf-invoices-packing-slips' );
81
  $dir = trailingslashit( WP_LANG_DIR );
82