WooCommerce PDF Invoices & Packing Slips - Version 2.1.4

Version Description

  • Fix: WooCommerce 3.3 action buttons
  • Feature: Added row classes for WooCommerce Composite Products
Download this release

Release Info

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

Code changes from version 2.1.3 to 2.1.4

assets/css/order-styles.css CHANGED
@@ -1,53 +1,58 @@
1
- /* Order list buttons: */
2
- .type-shop_order .column-order_actions a.button.wpo_wcpdf img {
3
- width: 16px;
4
- }
5
-
6
- .widefat .column-pdf_invoice_number {
7
- width: 110px;
8
- }
9
-
10
- @media screen and (max-width: 782px) {
11
- .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) {
12
- display: none;
13
- }
14
- .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-pdf_invoice_number {
15
- padding: 3px 8px 3px 35%
16
- }
17
- }
18
-
19
- #wpo_wcpdf-data-input-box h4 {
20
- font-size: 14px;
21
- line-height: 1.4;
22
- margin: 1.5em 0 0 0;
23
- }
24
-
25
- #wpo_wcpdf-data-input-box p {
26
- margin: 0.5em 0;
27
- }
28
-
29
- #wpo_wcpdf-data-input-box .form-field input {
30
- width: auto;
31
- }
32
-
33
- .wcpdf-data-fields .read-only {
34
- height:auto;
35
- display:block;
36
- }
37
-
38
- .wcpdf-data-fields .editable {
39
- height:auto;
40
- display:none;
41
- }
42
-
43
- /* Edit buttons Invoice, Proforma and Credit */
44
-
45
- .wpo-wcpdf-edit-date-number {
46
- margin-left:20px!important;
47
- opacity:0.5;
48
- }
49
-
50
- .wpo-wcpdf-edit-date-number:hover {
51
- opacity:1;
52
- cursor:pointer;
53
- }
 
 
 
 
 
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 img,
7
+ .type-shop_order .column-order_actions a.button.wpo_wcpdf img {
8
+ width: 16px;
9
+ }
10
+
11
+ .widefat .column-pdf_invoice_number {
12
+ width: 110px;
13
+ }
14
+
15
+ @media screen and (max-width: 782px) {
16
+ .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) {
17
+ display: none;
18
+ }
19
+ .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-pdf_invoice_number {
20
+ padding: 3px 8px 3px 35%
21
+ }
22
+ }
23
+
24
+ #wpo_wcpdf-data-input-box h4 {
25
+ font-size: 14px;
26
+ line-height: 1.4;
27
+ margin: 1.5em 0 0 0;
28
+ }
29
+
30
+ #wpo_wcpdf-data-input-box p {
31
+ margin: 0.5em 0;
32
+ }
33
+
34
+ #wpo_wcpdf-data-input-box .form-field input {
35
+ width: auto;
36
+ }
37
+
38
+ .wcpdf-data-fields .read-only {
39
+ height:auto;
40
+ display:block;
41
+ }
42
+
43
+ .wcpdf-data-fields .editable {
44
+ height:auto;
45
+ display:none;
46
+ }
47
+
48
+ /* Edit buttons Invoice, Proforma and Credit */
49
+
50
+ .wpo-wcpdf-edit-date-number {
51
+ margin-left:20px!important;
52
+ opacity:0.5;
53
+ }
54
+
55
+ .wpo-wcpdf-edit-date-number:hover {
56
+ opacity:1;
57
+ cursor:pointer;
58
+ }
includes/compatibility/class-wcpdf-compatibility-third-party-plugins.php CHANGED
@@ -1,162 +1,198 @@
1
- <?php
2
- namespace WPO\WC\PDF_Invoices\Compatibility;
3
-
4
- use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
5
- use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
6
- use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
7
- use WPO\WC\PDF_Invoices\Compatibility\WC_DateTime;
8
-
9
- defined( 'ABSPATH' ) or exit;
10
-
11
- if ( ! class_exists( '\\WPO\\WC\\PDF_Invoices\\Compatibility\\Third_Party_Plugins' ) ) :
12
-
13
- /**
14
- * Third party plugin compatibility class.
15
- *
16
- * @since 2.0
17
- */
18
- class Third_Party_Plugins {
19
- function __construct() {
20
- // WooCommerce Subscriptions compatibility
21
- if ( class_exists('WC_Subscriptions') ) {
22
- if ( version_compare( \WC_Subscriptions::$version, '2.0', '<' ) ) {
23
- add_action( 'woocommerce_subscriptions_renewal_order_created', array( $this, 'woocommerce_subscriptions_renewal_order_created' ), 10, 4 );
24
- } else {
25
- add_action( 'wcs_renewal_order_created', array( $this, 'wcs_renewal_order_created' ), 10, 2 );
26
- }
27
- }
28
-
29
- // WooCommerce Product Bundles compatibility (add row classes)
30
- if ( class_exists('WC_Bundles') ) {
31
- add_filter( 'wpo_wcpdf_item_row_class', array( $this, 'add_product_bundles_classes' ), 10, 4 );
32
- }
33
-
34
- // WooCommerce Chained Products compatibility (add row classes)
35
- if ( class_exists('SA_WC_Chained_Products') ) {
36
- add_filter( 'wpo_wcpdf_item_row_class', array( $this, 'add_chained_product_class' ), 10, 4 );
37
- }
38
-
39
- // WooCommerce Order Status & Actions Manager emails compatibility
40
- if (class_exists('WC_Custom_Status')) {
41
- add_filter( 'wpo_wcpdf_wc_emails', array( $this, 'wc_order_status_actions_emails' ), 10, 1 );
42
- }
43
-
44
- }
45
-
46
- /**
47
- * Reset invoice data for WooCommerce subscription renewal orders
48
- * https://wordpress.org/support/topic/subscription-renewal-duplicate-invoice-number?replies=6#post-6138110
49
- */
50
- public function woocommerce_subscriptions_renewal_order_created ( $renewal_order, $original_order, $product_id, $new_order_role ) {
51
- $this->reset_invoice_data( $renewal_order );
52
- return $renewal_order;
53
- }
54
-
55
- public function wcs_renewal_order_created ( $renewal_order, $subscription ) {
56
- $this->reset_invoice_data( $renewal_order );
57
- return $renewal_order;
58
- }
59
-
60
- public function reset_invoice_data ( $order ) {
61
- if ( ! is_object( $order ) ) {
62
- $order = wc_get_order( $order );
63
- }
64
- // delete invoice number, invoice date & invoice exists meta
65
- WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_number' );
66
- WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_number_data' );
67
- WCX_Order::delete_meta_data( $order, '_wcpdf_formatted_invoice_number' );
68
- WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_date' );
69
- WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_exists' );
70
- }
71
-
72
- /**
73
- * WooCommerce Product Bundles
74
- * @param string $classes CSS classes for item row (tr)
75
- * @param string $document_type PDF Document type
76
- * @param object $order WC_Order order
77
- * @param int $item_id WooCommerce Item ID
78
- */
79
- public function add_product_bundles_classes ( $classes, $document_type, $order, $item_id = '' ) {
80
- if ( empty($item_id) ) {
81
- // get item id from classes (backwards compatibility fix)
82
- $class_array = explode(' ', $classes);
83
- foreach ($class_array as $class) {
84
- if (is_numeric($class)) {
85
- $item_id = $class;
86
- break;
87
- }
88
- }
89
-
90
- // if still empty, we lost the item id somewhere :(
91
- if (empty($item_id)) {
92
- return $classes;
93
- }
94
- }
95
-
96
- if ( $bundled_by = WCX_Order::get_item_meta( $order, $item_id, '_bundled_by', true ) ) {
97
- $classes = $classes . ' bundled-item';
98
-
99
- // check bundled item visibility
100
- if ( $hidden = WCX_Order::get_item_meta( $order, $item_id, '_bundled_item_hidden', true ) ) {
101
- $classes = $classes . ' hidden';
102
- }
103
-
104
- return $classes;
105
- } elseif ( $bundled_items = WCX_Order::get_item_meta( $order, $item_id, '_bundled_items', true ) ) {
106
- return $classes . ' product-bundle';
107
- }
108
-
109
- return $classes;
110
- }
111
-
112
- /**
113
- * WooCommerce Chanined Products
114
- * @param string $classes CSS classes for item row (tr)
115
- * @param string $document_type PDF Document type
116
- * @param object $order WC_Order order
117
- * @param int $item_id WooCommerce Item ID
118
- */
119
- public function add_chained_product_class ( $classes, $document_type, $order, $item_id = '' ) {
120
- if ( empty($item_id) ) {
121
- // get item id from classes (backwards compatibility fix)
122
- $class_array = explode(' ', $classes);
123
- foreach ($class_array as $class) {
124
- if (is_numeric($class)) {
125
- $item_id = $class;
126
- break;
127
- }
128
- }
129
-
130
- // if still empty, we lost the item id somewhere :(
131
- if (empty($item_id)) {
132
- return $classes;
133
- }
134
- }
135
-
136
- if ( $chained_product_of = WCX_Order::get_item_meta( $order, $item_id, '_chained_product_of', true ) ) {
137
- return $classes . ' chained-product';
138
- }
139
-
140
- return $classes;
141
- }
142
-
143
- /**
144
- * WooCommerce Order Status & Actions Manager emails compatibility
145
- */
146
- public function wc_order_status_actions_emails ( $emails ) {
147
- // get list of custom statuses from WooCommerce Custom Order Status & Actions
148
- // status slug => status name
149
- $custom_statuses = \WC_Custom_Status::get_status_list_names();
150
- // append _email to slug (=email_id) and add to emails list
151
- foreach ($custom_statuses as $status_slug => $status_name) {
152
- $emails[$status_slug.'_email'] = $status_name;
153
- }
154
- return $emails;
155
- }
156
-
157
- }
158
-
159
-
160
- endif; // Class exists check
161
-
162
- return new Third_Party_Plugins();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace WPO\WC\PDF_Invoices\Compatibility;
3
+
4
+ use WPO\WC\PDF_Invoices\Compatibility\WC_Core as WCX;
5
+ use WPO\WC\PDF_Invoices\Compatibility\Order as WCX_Order;
6
+ use WPO\WC\PDF_Invoices\Compatibility\Product as WCX_Product;
7
+ use WPO\WC\PDF_Invoices\Compatibility\WC_DateTime;
8
+
9
+ defined( 'ABSPATH' ) or exit;
10
+
11
+ if ( ! class_exists( '\\WPO\\WC\\PDF_Invoices\\Compatibility\\Third_Party_Plugins' ) ) :
12
+
13
+ /**
14
+ * Third party plugin compatibility class.
15
+ *
16
+ * @since 2.0
17
+ */
18
+ class Third_Party_Plugins {
19
+ function __construct() {
20
+ // WooCommerce Subscriptions compatibility
21
+ if ( class_exists('WC_Subscriptions') ) {
22
+ if ( version_compare( \WC_Subscriptions::$version, '2.0', '<' ) ) {
23
+ add_action( 'woocommerce_subscriptions_renewal_order_created', array( $this, 'woocommerce_subscriptions_renewal_order_created' ), 10, 4 );
24
+ } else {
25
+ add_action( 'wcs_renewal_order_created', array( $this, 'wcs_renewal_order_created' ), 10, 2 );
26
+ }
27
+ }
28
+
29
+ // WooCommerce Product Bundles compatibility (add row classes)
30
+ if ( class_exists('WC_Bundles') ) {
31
+ add_filter( 'wpo_wcpdf_item_row_class', array( $this, 'add_product_bundles_classes' ), 10, 4 );
32
+ }
33
+
34
+ // WooCommerce Chained Products compatibility (add row classes)
35
+ if ( class_exists('SA_WC_Chained_Products') ) {
36
+ add_filter( 'wpo_wcpdf_item_row_class', array( $this, 'add_chained_product_class' ), 10, 4 );
37
+ }
38
+
39
+ // WooCommerce Composite Products compatibility (add row classes)
40
+ if ( class_exists('WC_Composite_Products') ) {
41
+ add_filter( 'wpo_wcpdf_item_row_class', array( $this, 'add_composite_product_class' ), 10, 4 );
42
+ }
43
+
44
+ // WooCommerce Order Status & Actions Manager emails compatibility
45
+ if (class_exists('WC_Custom_Status')) {
46
+ add_filter( 'wpo_wcpdf_wc_emails', array( $this, 'wc_order_status_actions_emails' ), 10, 1 );
47
+ }
48
+
49
+ }
50
+
51
+ /**
52
+ * Reset invoice data for WooCommerce subscription renewal orders
53
+ * https://wordpress.org/support/topic/subscription-renewal-duplicate-invoice-number?replies=6#post-6138110
54
+ */
55
+ public function woocommerce_subscriptions_renewal_order_created ( $renewal_order, $original_order, $product_id, $new_order_role ) {
56
+ $this->reset_invoice_data( $renewal_order );
57
+ return $renewal_order;
58
+ }
59
+
60
+ public function wcs_renewal_order_created ( $renewal_order, $subscription ) {
61
+ $this->reset_invoice_data( $renewal_order );
62
+ return $renewal_order;
63
+ }
64
+
65
+ public function reset_invoice_data ( $order ) {
66
+ if ( ! is_object( $order ) ) {
67
+ $order = wc_get_order( $order );
68
+ }
69
+ // delete invoice number, invoice date & invoice exists meta
70
+ WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_number' );
71
+ WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_number_data' );
72
+ WCX_Order::delete_meta_data( $order, '_wcpdf_formatted_invoice_number' );
73
+ WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_date' );
74
+ WCX_Order::delete_meta_data( $order, '_wcpdf_invoice_exists' );
75
+ }
76
+
77
+ /**
78
+ * WooCommerce Product Bundles
79
+ * @param string $classes CSS classes for item row (tr)
80
+ * @param string $document_type PDF Document type
81
+ * @param object $order WC_Order order
82
+ * @param int $item_id WooCommerce Item ID
83
+ */
84
+ public function add_product_bundles_classes ( $classes, $document_type, $order, $item_id = '' ) {
85
+ $item_id = !empty($item_id) ? $item_id : $this->get_item_id_from_classes( $classes );
86
+ if ( empty($item_id) ) {
87
+ return $classes;
88
+ }
89
+
90
+ if ( $bundled_by = WCX_Order::get_item_meta( $order, $item_id, '_bundled_by', true ) ) {
91
+ $classes = $classes . ' bundled-item';
92
+
93
+ // check bundled item visibility
94
+ if ( $hidden = WCX_Order::get_item_meta( $order, $item_id, '_bundled_item_hidden', true ) ) {
95
+ $classes = $classes . ' hidden';
96
+ }
97
+
98
+ return $classes;
99
+ } elseif ( $bundled_items = WCX_Order::get_item_meta( $order, $item_id, '_bundled_items', true ) ) {
100
+ return $classes . ' product-bundle';
101
+ }
102
+
103
+ return $classes;
104
+ }
105
+
106
+ /**
107
+ * WooCommerce Chanined Products
108
+ * @param string $classes CSS classes for item row (tr)
109
+ * @param string $document_type PDF Document type
110
+ * @param object $order WC_Order order
111
+ * @param int $item_id WooCommerce Item ID
112
+ */
113
+ public function add_chained_product_class ( $classes, $document_type, $order, $item_id = '' ) {
114
+ $item_id = !empty($item_id) ? $item_id : $this->get_item_id_from_classes( $classes );
115
+ if ( empty($item_id) ) {
116
+ return $classes;
117
+ }
118
+
119
+ if ( $chained_product_of = WCX_Order::get_item_meta( $order, $item_id, '_chained_product_of', true ) ) {
120
+ return $classes . ' chained-product';
121
+ }
122
+
123
+ return $classes;
124
+ }
125
+
126
+ /**
127
+ * WooCommerce Composite Products
128
+ * @param string $classes CSS classes for item row (tr)
129
+ * @param string $document_type PDF Document type
130
+ * @param object $order WC_Order order
131
+ * @param int $item_id WooCommerce Item ID
132
+ */
133
+ public function add_composite_product_class ( $classes, $document_type, $order, $item_id = '' ) {
134
+ if ( !function_exists('wc_cp_is_composited_order_item') || !function_exists('wc_cp_is_composite_container_order_item') ) {
135
+ return $classes;
136
+ }
137
+ $item_id = !empty($item_id) ? $item_id : $this->get_item_id_from_classes( $classes );
138
+ if ( empty($item_id) ) {
139
+ return $classes;
140
+ }
141
+
142
+ // get order item object
143
+ $order_items = $order->get_items();
144
+ foreach ($order_items as $order_item_id => $order_item) {
145
+ if ($order_item_id == $item_id) {
146
+ if ( wc_cp_is_composited_order_item( $order_item, $order ) ) {
147
+ $classes .= ' component_table_item';
148
+ } elseif ( wc_cp_is_composite_container_order_item( $order_item ) ) {
149
+ $classes .= ' component_container_table_item';
150
+ }
151
+ break;
152
+ }
153
+ }
154
+
155
+ return $classes;
156
+ }
157
+
158
+ /**
159
+ * Backwards compatibility helper function: try to get item ID from row class
160
+ * @param string $classes CSS classes for item row (tr)
161
+ */
162
+ public function get_item_id_from_classes ( $classes ) {
163
+ $class_array = explode(' ', $classes);
164
+ foreach ($class_array as $class) {
165
+ if (is_numeric($class)) {
166
+ $item_id = $class;
167
+ break;
168
+ }
169
+ }
170
+
171
+ // if still empty, we lost the item id somewhere :(
172
+ if (empty($item_id)) {
173
+ return false;
174
+ } else {
175
+ return $item_id;
176
+ }
177
+ }
178
+
179
+ /**
180
+ * WooCommerce Order Status & Actions Manager emails compatibility
181
+ */
182
+ public function wc_order_status_actions_emails ( $emails ) {
183
+ // get list of custom statuses from WooCommerce Custom Order Status & Actions
184
+ // status slug => status name
185
+ $custom_statuses = \WC_Custom_Status::get_status_list_names();
186
+ // append _email to slug (=email_id) and add to emails list
187
+ foreach ($custom_statuses as $status_slug => $status_name) {
188
+ $emails[$status_slug.'_email'] = $status_name;
189
+ }
190
+ return $emails;
191
+ }
192
+
193
+ }
194
+
195
+
196
+ endif; // Class exists check
197
+
198
+ return new Third_Party_Plugins();
readme.txt CHANGED
@@ -1,230 +1,234 @@
1
- === WooCommerce PDF Invoices & Packing Slips ===
2
- 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: 4.9
7
- Requires PHP: 5.3
8
- Stable tag: 2.1.3
9
- License: GPLv2 or later
10
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
-
12
- Create, print & automatically email PDF invoices & packing slips for WooCommerce orders.
13
-
14
- == Description ==
15
-
16
- This WooCommerce extension automatically adds a PDF invoice to the order confirmation emails sent out to your customers. Includes a basic template (additional templates are available from [WP Overnight](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-premium-templates/)) as well as the possibility to modify/create your own templates. In addition, you can choose to download or print invoices and packing slips from the WooCommerce order admin.
17
-
18
- = Main features =
19
- * Automatically attach invoice PDF to WooCommerce emails of your choice
20
- * Download the PDF invoice / packing slip from the order admin page
21
- * Generate PDF invoices / packings slips in bulk
22
- * **Fully customizable** HTML/CSS invoice templates
23
- * Download invoices from the My Account page
24
- * Sequential invoice numbers - with custom formatting
25
- * **Available in: Czech, Dutch, English, Finnish, French, German, Hungarian, Italian, Japanese (see FAQ for adding custom fonts!), Norwegian, Polish, Romanian, Russian, Slovak, Slovenian, Spanish, Swedish & Ukrainian**
26
-
27
- In addition to this, we offer several premium extensions:
28
-
29
- * Create/email PDF Proforma Invoices, Credit Notes (for Refunds), email Packing Slips & more with [WooCommerce PDF Invoices & Packing Slips Professional](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-professional/)
30
- * Upload all invoices automatically to Dropbox with [WooCommerce PDF Invoices & Packing Slips to Dropbox](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-dropbox/)
31
- * Automatically send new orders or packing slips to your printer, as soon as the customer orders! [WooCommerce Automatic Order Printing](https://www.simbahosting.co.uk/s3/product/woocommerce-automatic-order-printing/?affiliates=2) (from our partners at Simba Hosting)
32
- * More advanced & stylish templates with [WooCommerce PDF Invoices & Packing Slips Premium Templates](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-premium-templates/)
33
-
34
- = Fully customizable =
35
- In addition to a number of default settings (including a custom header/logo) and several layout fields that you can use out of the box, the plugin contains HTML/CSS based templates that allow for customization & full control over the PDF output. Copy the templates to your theme folder and you don't have to worry that your customizations will be overwritten when you update the plugin.
36
-
37
- * Insert customer header image/logo
38
- * Modify shop data / footer / disclaimer etc. on the invoices & packing slips
39
- * Select paper size (Letter or A4)
40
- * Translation ready
41
-
42
- == Installation ==
43
-
44
- = Minimum Requirements =
45
-
46
- * WooCommerce 2.2 or later
47
- * WordPress 3.5 or later
48
-
49
- = Automatic installation =
50
- Automatic installation is the easiest option as WordPress handles the file transfers itself and you don't even need to leave your web browser. To do an automatic install of WooCommerce PDF Invoices & Packing Slips, log in to your WordPress admin panel, navigate to the Plugins menu and click Add New.
51
-
52
- In the search field type "WooCommerce PDF Invoices & Packing Slips" and click Search Plugins. You can install it by simply clicking Install Now. After clicking that link you will be asked if you're sure you want to install the plugin. Click yes and WordPress will automatically complete the installation. After installation has finished, click the 'activate plugin' link.
53
-
54
- = Manual installation via the WordPress interface =
55
- 1. Download the plugin zip file to your computer
56
- 2. Go to the WordPress admin panel menu Plugins > Add New
57
- 3. Choose upload
58
- 4. Upload the plugin zip file, the plugin will now be installed
59
- 5. After installation has finished, click the 'activate plugin' link
60
-
61
- = Manual installation via FTP =
62
- 1. Download the plugin file to your computer and unzip it
63
- 2. Using an FTP program, or your hosting control panel, upload the unzipped plugin folder to your WordPress installation's wp-content/plugins/ directory.
64
- 3. Activate the plugin from the Plugins menu within the WordPress admin.
65
-
66
- == Frequently Asked Questions ==
67
-
68
- = Where can I find the documentation? =
69
-
70
- [WooCommerce PDF Invoices & Packing Slips documentation](http://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/)
71
-
72
- = It's not working! =
73
-
74
- Check out our step by step diagnostic instructions here: https://wordpress.org/support/topic/read-this-first-9/
75
-
76
-
77
-
78
-
79
-
80
- = Where can I find more templates? =
81
-
82
- Go to [wpovernight.com](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-premium-templates/) to checkout more templates! These include templates with more tax details and product thumbnails. Need a custom templates? Contact us at support@wpovernight.com for more information.
83
-
84
- = Can I create/send a proforma invoice or a credit note? =
85
- This is a feature of our Professional extension, which can be found at [wpovernight.com](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-professional/)
86
-
87
- = Can I contribute to the code? =
88
- You're more than welcome! This plugin is hosted on github, where you can post issues or make pull requests.
89
- https://github.com/wpovernight/woocommerce-pdf-invoices-packing-slips
90
-
91
- = How can I display the HTML/CSS source for debugging/developing templates? =
92
- There's a setting on the Status tab of the settings page that allows you to toggle HTML output. Don't forget to turn if off after you're done testing!
93
-
94
-
95
- == Screenshots ==
96
-
97
- 1. Simple invoice PDF
98
- 2. Simple packing slip PDF
99
- 3. Quickly print individual invoices or packing slips from the order list
100
- 4. Print invoices or packing slips in bulk
101
- 5. Attach invoices to any WooCommerce email
102
- 6. Set shop name, address, header logo, etc.
103
-
104
- == Changelog ==
105
-
106
- = 2.1.3 =
107
- * Fix: Fatal PHP error on My Account page.
108
-
109
- = 2.1.2 =
110
- * Feature: New action wpo_wcpdf_init_document
111
- * Fix: Use title getters for my-account and backend buttons
112
- * Fix: Legacy Premium Templates reference
113
- * Tweak: Skip documents overview in settings, default to invoice
114
-
115
- = 2.1.1 =
116
- * Fix: WooCommerce Order Status & Actions Manager emails compatibility
117
- * Feature: sort orders by invoice number column
118
- * Tweak: pass document object to title filters
119
- * Tweak: use title getter in template files (instead of title string)
120
-
121
- = 2.1.0 =
122
- * Feature: WooCommerce Order Status & Actions Manager emails compatibility
123
- * Fix: Better url fallback for images stored in cloud
124
- * Update: dompdf library updated to 0.8.2 - DOMDocument parser set to default again
125
-
126
- = 2.0.15 =
127
- * Fix: Prevent saving invoice number/date from order details page when not edited
128
-
129
- = 2.0.14 =
130
- * Feature: Manually resend specific order emails in WooCommerce 3.2+
131
- * Tweak: Show full size logo preview in settings
132
- * Tweak: Custom field fallback to underscore prefixed meta key
133
- * Dev: added `wpo_wcpdf_before_sequential_number_increment` action
134
-
135
- = 2.0.13 =
136
- * Fix: Minor XSS issue on settings screens by escaping and sanitizing 'tab' & 'section' GET variables. Discovered by Detectify.
137
- * Fix: Pakistani Rupee Symbol
138
- * Feature: Automatically enable extended currency symbol support for currencies not supported by Open Sans
139
- * Dev: added `wpo_wcpdf_document_number_settings` filter
140
-
141
- = 2.0.12 =
142
- * Option: Use different HTML parser (debug settings)
143
-
144
- = 2.0.11 =
145
- * Fix: Improved fonts update routine (now preserves custom fonts)
146
- * Fix: Enable HTML5 parser by default (fixes issues with libxml)
147
- * Tweak: Show both PHP & WP Memory limit in Status tab
148
-
149
- = 2.0.10 =
150
- * Fix: Set invoice number backend button
151
- * Fix: Thumbail paths
152
- * Tweak: Make dompdf options filterable
153
-
154
- = 2.0.9 =
155
- * Feature: use `[invoice_date="ymd"]` in invoice number prefix or suffix to include a specific date format in the invoice number
156
- * Fix: Postmeta table prefix for invoice counter
157
- * Fix: 0% tax rates
158
-
159
- = 2.0.8 =
160
- * Feature: Add support for Bedrock / alternative folder structures
161
- * Dev: Filter for merged documents
162
- * Fix: Better attributes fallback for product variations
163
-
164
- = 2.0.7 =
165
- * Feature: Added button to delete legacy settings
166
- * Feature: Option to enable font subsetting
167
- * Fix: Invoice number sequence for databases with alternative auto_increment_increment settings
168
- * Fix: Fallback function for MB String (mb_stripos)
169
-
170
- = 2.0.6 =
171
- * Feature: Improved third party invoice number filters (`wpo_wcpdf_external_invoice_number_enabled` & `wpo_wcpdf_external_invoice_number`)
172
- * Fix: Underline position for Open Sans font
173
- * Fix: Invoice number auto_increment for servers that restarted frequently
174
- * Fix: Dompdf log file location (preventing open base_dir notices breaking PDF header)
175
- * Fix: 1.6.6 Settings migration duplicates merging
176
- * Tweak: Clear fonts folder when manually reinstalling fonts
177
-
178
- = 2.0.5 =
179
- * Feature: Remove temporary files (Status tab)
180
- * Fix: Page number replacement
181
- * Tweak: Fallback functions for MB String extension
182
- * Tweak: Improved wpo_wcpdf_check_privs usability for my account privileges
183
- * Legacy support: added wc_price alias for format_price method in document
184
-
185
- = 2.0.4 =
186
- * Fix: Apply filters for custom invoice number formatting in document too
187
- * Fix: Parent fallback for missing dates from refunds
188
-
189
- = 2.0.3 =
190
- * Fix: Better support for legacy invoice number filter (`wpo_wcpdf_invoice_number` - replaced by `wpo_wcpdf_formatted_document_number`)
191
- * Fix: Document number formatting fallback to order date if no document date available
192
- * Fix: Updated classmap: PSR loading didn't work on some installations
193
- * Fix: Prevent order notes from all orders showing when document is not loaded properly in filter
194
- * Tweak: Disable deprecation notices during email sending
195
- * Tweak: ignore outdated language packs
196
-
197
- = 2.0.2 =
198
- * Fix: order notes using correct order_id
199
- * Fix: WC3.0 deprecation notice for currency
200
- * Fix: Avoid crashing on PHP5.2 and older
201
- * Fix: Only use PHP MB String when present
202
- * Fix: Remote images
203
- * Fix: Download option
204
-
205
- = 2.0.1 =
206
- * Fix: PHP 5.4 issue
207
-
208
- = 2.0.0 =
209
- * New: Better structured & more advanced settings for documents
210
- * New: Option to enable & disable Packing Slips or Invoices
211
- * New: Invoice number sequence stored separately for improved speed & performance
212
- * New: Completely rewritten codebase for more flexibility & better reliability
213
- * New: Updated PDF library to DOMPDF 0.8
214
- * New: PDF Library made pluggable (by using the `wpo_wcpdf_pdf_maker` filter)
215
- * New: lots of new functions & filters to allow developers to hook into the plugin
216
- * Changed: **$wpo_wcpdf variable is now deprecated** (legacy mode available & automatically enabled on update)
217
- * Fix: Improved PHP 7 & 7.1 support
218
- * Fix: Positive prices for refunds
219
- * Fix: Use parent for attributes retrieved for product variations
220
- * Fix: Set content type to PDF for download
221
-
222
- = 1.6.6 =
223
- * Feature: Facilitate downgrading from 2.0 (re-installing fonts & resetting version)
224
- * Fix: Update currencies font (added Georgian Lari)
225
- * Translations: Added Indonesian
226
-
227
- == Upgrade Notice ==
228
-
229
- = 2.1.1 =
 
 
 
 
230
  2.0 is a BIG update! Make a full site backup before upgrading!
1
+ === WooCommerce PDF Invoices & Packing Slips ===
2
+ 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: 4.9
7
+ Requires PHP: 5.3
8
+ Stable tag: 2.1.4
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ Create, print & automatically email PDF invoices & packing slips for WooCommerce orders.
13
+
14
+ == Description ==
15
+
16
+ This WooCommerce extension automatically adds a PDF invoice to the order confirmation emails sent out to your customers. Includes a basic template (additional templates are available from [WP Overnight](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-premium-templates/)) as well as the possibility to modify/create your own templates. In addition, you can choose to download or print invoices and packing slips from the WooCommerce order admin.
17
+
18
+ = Main features =
19
+ * Automatically attach invoice PDF to WooCommerce emails of your choice
20
+ * Download the PDF invoice / packing slip from the order admin page
21
+ * Generate PDF invoices / packings slips in bulk
22
+ * **Fully customizable** HTML/CSS invoice templates
23
+ * Download invoices from the My Account page
24
+ * Sequential invoice numbers - with custom formatting
25
+ * **Available in: Czech, Dutch, English, Finnish, French, German, Hungarian, Italian, Japanese (see FAQ for adding custom fonts!), Norwegian, Polish, Romanian, Russian, Slovak, Slovenian, Spanish, Swedish & Ukrainian**
26
+
27
+ In addition to this, we offer several premium extensions:
28
+
29
+ * Create/email PDF Proforma Invoices, Credit Notes (for Refunds), email Packing Slips & more with [WooCommerce PDF Invoices & Packing Slips Professional](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-professional/)
30
+ * Upload all invoices automatically to Dropbox with [WooCommerce PDF Invoices & Packing Slips to Dropbox](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-dropbox/)
31
+ * Automatically send new orders or packing slips to your printer, as soon as the customer orders! [WooCommerce Automatic Order Printing](https://www.simbahosting.co.uk/s3/product/woocommerce-automatic-order-printing/?affiliates=2) (from our partners at Simba Hosting)
32
+ * More advanced & stylish templates with [WooCommerce PDF Invoices & Packing Slips Premium Templates](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-premium-templates/)
33
+
34
+ = Fully customizable =
35
+ In addition to a number of default settings (including a custom header/logo) and several layout fields that you can use out of the box, the plugin contains HTML/CSS based templates that allow for customization & full control over the PDF output. Copy the templates to your theme folder and you don't have to worry that your customizations will be overwritten when you update the plugin.
36
+
37
+ * Insert customer header image/logo
38
+ * Modify shop data / footer / disclaimer etc. on the invoices & packing slips
39
+ * Select paper size (Letter or A4)
40
+ * Translation ready
41
+
42
+ == Installation ==
43
+
44
+ = Minimum Requirements =
45
+
46
+ * WooCommerce 2.2 or later
47
+ * WordPress 3.5 or later
48
+
49
+ = Automatic installation =
50
+ Automatic installation is the easiest option as WordPress handles the file transfers itself and you don't even need to leave your web browser. To do an automatic install of WooCommerce PDF Invoices & Packing Slips, log in to your WordPress admin panel, navigate to the Plugins menu and click Add New.
51
+
52
+ In the search field type "WooCommerce PDF Invoices & Packing Slips" and click Search Plugins. You can install it by simply clicking Install Now. After clicking that link you will be asked if you're sure you want to install the plugin. Click yes and WordPress will automatically complete the installation. After installation has finished, click the 'activate plugin' link.
53
+
54
+ = Manual installation via the WordPress interface =
55
+ 1. Download the plugin zip file to your computer
56
+ 2. Go to the WordPress admin panel menu Plugins > Add New
57
+ 3. Choose upload
58
+ 4. Upload the plugin zip file, the plugin will now be installed
59
+ 5. After installation has finished, click the 'activate plugin' link
60
+
61
+ = Manual installation via FTP =
62
+ 1. Download the plugin file to your computer and unzip it
63
+ 2. Using an FTP program, or your hosting control panel, upload the unzipped plugin folder to your WordPress installation's wp-content/plugins/ directory.
64
+ 3. Activate the plugin from the Plugins menu within the WordPress admin.
65
+
66
+ == Frequently Asked Questions ==
67
+
68
+ = Where can I find the documentation? =
69
+
70
+ [WooCommerce PDF Invoices & Packing Slips documentation](http://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/)
71
+
72
+ = It's not working! =
73
+
74
+ Check out our step by step diagnostic instructions here: https://wordpress.org/support/topic/read-this-first-9/
75
+
76
+
77
+
78
+
79
+
80
+ = Where can I find more templates? =
81
+
82
+ Go to [wpovernight.com](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-premium-templates/) to checkout more templates! These include templates with more tax details and product thumbnails. Need a custom templates? Contact us at support@wpovernight.com for more information.
83
+
84
+ = Can I create/send a proforma invoice or a credit note? =
85
+ This is a feature of our Professional extension, which can be found at [wpovernight.com](https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-professional/)
86
+
87
+ = Can I contribute to the code? =
88
+ You're more than welcome! This plugin is hosted on github, where you can post issues or make pull requests.
89
+ https://github.com/wpovernight/woocommerce-pdf-invoices-packing-slips
90
+
91
+ = How can I display the HTML/CSS source for debugging/developing templates? =
92
+ There's a setting on the Status tab of the settings page that allows you to toggle HTML output. Don't forget to turn if off after you're done testing!
93
+
94
+
95
+ == Screenshots ==
96
+
97
+ 1. Simple invoice PDF
98
+ 2. Simple packing slip PDF
99
+ 3. Quickly print individual invoices or packing slips from the order list
100
+ 4. Print invoices or packing slips in bulk
101
+ 5. Attach invoices to any WooCommerce email
102
+ 6. Set shop name, address, header logo, etc.
103
+
104
+ == Changelog ==
105
+
106
+ = 2.1.4 =
107
+ * Fix: WooCommerce 3.3 action buttons
108
+ * Feature: Added row classes for WooCommerce Composite Products
109
+
110
+ = 2.1.3 =
111
+ * Fix: Fatal PHP error on My Account page.
112
+
113
+ = 2.1.2 =
114
+ * Feature: New action wpo_wcpdf_init_document
115
+ * Fix: Use title getters for my-account and backend buttons
116
+ * Fix: Legacy Premium Templates reference
117
+ * Tweak: Skip documents overview in settings, default to invoice
118
+
119
+ = 2.1.1 =
120
+ * Fix: WooCommerce Order Status & Actions Manager emails compatibility
121
+ * Feature: sort orders by invoice number column
122
+ * Tweak: pass document object to title filters
123
+ * Tweak: use title getter in template files (instead of title string)
124
+
125
+ = 2.1.0 =
126
+ * Feature: WooCommerce Order Status & Actions Manager emails compatibility
127
+ * Fix: Better url fallback for images stored in cloud
128
+ * Update: dompdf library updated to 0.8.2 - DOMDocument parser set to default again
129
+
130
+ = 2.0.15 =
131
+ * Fix: Prevent saving invoice number/date from order details page when not edited
132
+
133
+ = 2.0.14 =
134
+ * Feature: Manually resend specific order emails in WooCommerce 3.2+
135
+ * Tweak: Show full size logo preview in settings
136
+ * Tweak: Custom field fallback to underscore prefixed meta key
137
+ * Dev: added `wpo_wcpdf_before_sequential_number_increment` action
138
+
139
+ = 2.0.13 =
140
+ * Fix: Minor XSS issue on settings screens by escaping and sanitizing 'tab' & 'section' GET variables. Discovered by Detectify.
141
+ * Fix: Pakistani Rupee Symbol
142
+ * Feature: Automatically enable extended currency symbol support for currencies not supported by Open Sans
143
+ * Dev: added `wpo_wcpdf_document_number_settings` filter
144
+
145
+ = 2.0.12 =
146
+ * Option: Use different HTML parser (debug settings)
147
+
148
+ = 2.0.11 =
149
+ * Fix: Improved fonts update routine (now preserves custom fonts)
150
+ * Fix: Enable HTML5 parser by default (fixes issues with libxml)
151
+ * Tweak: Show both PHP & WP Memory limit in Status tab
152
+
153
+ = 2.0.10 =
154
+ * Fix: Set invoice number backend button
155
+ * Fix: Thumbail paths
156
+ * Tweak: Make dompdf options filterable
157
+
158
+ = 2.0.9 =
159
+ * Feature: use `[invoice_date="ymd"]` in invoice number prefix or suffix to include a specific date format in the invoice number
160
+ * Fix: Postmeta table prefix for invoice counter
161
+ * Fix: 0% tax rates
162
+
163
+ = 2.0.8 =
164
+ * Feature: Add support for Bedrock / alternative folder structures
165
+ * Dev: Filter for merged documents
166
+ * Fix: Better attributes fallback for product variations
167
+
168
+ = 2.0.7 =
169
+ * Feature: Added button to delete legacy settings
170
+ * Feature: Option to enable font subsetting
171
+ * Fix: Invoice number sequence for databases with alternative auto_increment_increment settings
172
+ * Fix: Fallback function for MB String (mb_stripos)
173
+
174
+ = 2.0.6 =
175
+ * Feature: Improved third party invoice number filters (`wpo_wcpdf_external_invoice_number_enabled` & `wpo_wcpdf_external_invoice_number`)
176
+ * Fix: Underline position for Open Sans font
177
+ * Fix: Invoice number auto_increment for servers that restarted frequently
178
+ * Fix: Dompdf log file location (preventing open base_dir notices breaking PDF header)
179
+ * Fix: 1.6.6 Settings migration duplicates merging
180
+ * Tweak: Clear fonts folder when manually reinstalling fonts
181
+
182
+ = 2.0.5 =
183
+ * Feature: Remove temporary files (Status tab)
184
+ * Fix: Page number replacement
185
+ * Tweak: Fallback functions for MB String extension
186
+ * Tweak: Improved wpo_wcpdf_check_privs usability for my account privileges
187
+ * Legacy support: added wc_price alias for format_price method in document
188
+
189
+ = 2.0.4 =
190
+ * Fix: Apply filters for custom invoice number formatting in document too
191
+ * Fix: Parent fallback for missing dates from refunds
192
+
193
+ = 2.0.3 =
194
+ * Fix: Better support for legacy invoice number filter (`wpo_wcpdf_invoice_number` - replaced by `wpo_wcpdf_formatted_document_number`)
195
+ * Fix: Document number formatting fallback to order date if no document date available
196
+ * Fix: Updated classmap: PSR loading didn't work on some installations
197
+ * Fix: Prevent order notes from all orders showing when document is not loaded properly in filter
198
+ * Tweak: Disable deprecation notices during email sending
199
+ * Tweak: ignore outdated language packs
200
+
201
+ = 2.0.2 =
202
+ * Fix: order notes using correct order_id
203
+ * Fix: WC3.0 deprecation notice for currency
204
+ * Fix: Avoid crashing on PHP5.2 and older
205
+ * Fix: Only use PHP MB String when present
206
+ * Fix: Remote images
207
+ * Fix: Download option
208
+
209
+ = 2.0.1 =
210
+ * Fix: PHP 5.4 issue
211
+
212
+ = 2.0.0 =
213
+ * New: Better structured & more advanced settings for documents
214
+ * New: Option to enable & disable Packing Slips or Invoices
215
+ * New: Invoice number sequence stored separately for improved speed & performance
216
+ * New: Completely rewritten codebase for more flexibility & better reliability
217
+ * New: Updated PDF library to DOMPDF 0.8
218
+ * New: PDF Library made pluggable (by using the `wpo_wcpdf_pdf_maker` filter)
219
+ * New: lots of new functions & filters to allow developers to hook into the plugin
220
+ * Changed: **$wpo_wcpdf variable is now deprecated** (legacy mode available & automatically enabled on update)
221
+ * Fix: Improved PHP 7 & 7.1 support
222
+ * Fix: Positive prices for refunds
223
+ * Fix: Use parent for attributes retrieved for product variations
224
+ * Fix: Set content type to PDF for download
225
+
226
+ = 1.6.6 =
227
+ * Feature: Facilitate downgrading from 2.0 (re-installing fonts & resetting version)
228
+ * Fix: Update currencies font (added Georgian Lari)
229
+ * Translations: Added Indonesian
230
+
231
+ == Upgrade Notice ==
232
+
233
+ = 2.1.4 =
234
  2.0 is a BIG update! Make a full site backup before upgrading!
woocommerce-pdf-invoices-packingslips.php CHANGED
@@ -1,357 +1,357 @@
1
- <?php
2
- /**
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.1.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: 3.2.0
14
- */
15
-
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- exit; // Exit if accessed directly
18
- }
19
-
20
- if ( !class_exists( 'WPO_WCPDF' ) ) :
21
-
22
- class WPO_WCPDF {
23
-
24
- public $version = '2.1.3';
25
- public $plugin_basename;
26
- public $legacy_mode;
27
-
28
- protected static $_instance = null;
29
-
30
- /**
31
- * Main Plugin Instance
32
- *
33
- * Ensures only one instance of plugin is loaded or can be loaded.
34
- */
35
- public static function instance() {
36
- if ( is_null( self::$_instance ) ) {
37
- self::$_instance = new self();
38
- }
39
- return self::$_instance;
40
- }
41
-
42
- /**
43
- * Constructor
44
- */
45
- public function __construct() {
46
- $this->plugin_basename = plugin_basename(__FILE__);
47
-
48
- $this->define( 'WPO_WCPDF_VERSION', $this->version );
49
-
50
- // load the localisation & classes
51
- add_action( 'plugins_loaded', array( $this, 'translations' ) );
52
- add_filter( 'load_textdomain_mofile', array( $this, 'textdomain_fallback' ), 10, 2 );
53
- add_action( 'plugins_loaded', array( $this, 'load_classes' ), 9 );
54
- add_action( 'in_plugin_update_message-'.$this->plugin_basename, array( $this, 'in_plugin_update_message' ) );
55
- }
56
-
57
- /**
58
- * Define constant if not already set
59
- * @param string $name
60
- * @param string|bool $value
61
- */
62
- private function define( $name, $value ) {
63
- if ( ! defined( $name ) ) {
64
- define( $name, $value );
65
- }
66
- }
67
-
68
-
69
- /**
70
- * Load the translation / textdomain files
71
- *
72
- * Note: the first-loaded translation file overrides any following ones if the same translation is present
73
- */
74
- public function translations() {
75
- $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-pdf-invoices-packing-slips' );
76
- $dir = trailingslashit( WP_LANG_DIR );
77
-
78
- $textdomains = array( 'woocommerce-pdf-invoices-packing-slips' );
79
- if ( $this->legacy_mode_enabled() === true ) {
80
- $textdomains[] = 'wpo_wcpdf';
81
- }
82
-
83
- /**
84
- * Frontend/global Locale. Looks in:
85
- *
86
- * - WP_LANG_DIR/woocommerce-pdf-invoices-packing-slips/woocommerce-pdf-invoices-packing-slips-LOCALE.mo
87
- * - WP_LANG_DIR/plugins/woocommerce-pdf-invoices-packing-slips-LOCALE.mo
88
- * - woocommerce-pdf-invoices-packing-slips-pro/languages/woocommerce-pdf-invoices-packing-slips-LOCALE.mo (which if not found falls back to:)
89
- * - WP_LANG_DIR/plugins/woocommerce-pdf-invoices-packing-slips-LOCALE.mo
90
- */
91
- foreach ($textdomains as $textdomain) {
92
- load_textdomain( $textdomain, $dir . 'woocommerce-pdf-invoices-packing-slips/woocommerce-pdf-invoices-packing-slips-' . $locale . '.mo' );
93
- load_textdomain( $textdomain, $dir . 'plugins/woocommerce-pdf-invoices-packing-slips-' . $locale . '.mo' );
94
- load_plugin_textdomain( $textdomain, false, dirname( plugin_basename(__FILE__) ) . '/languages' );
95
- }
96
- }
97
-
98
- /**
99
- * Maintain backwards compatibility with old translation files
100
- * Uses old .mo file if it exists in any of the override locations
101
- */
102
- public function textdomain_fallback( $mofile, $textdomain ) {
103
- $plugin_domain = 'woocommerce-pdf-invoices-packing-slips';
104
- $old_domain = 'wpo_wcpdf';
105
-
106
- if ($textdomain == $old_domain) {
107
- $textdomain = $plugin_domain;
108
- $mofile = str_replace( "{$old_domain}-", "{$textdomain}-", $mofile ); // with trailing dash to target file and not folder
109
- }
110
-
111
- if ( $textdomain === $plugin_domain ) {
112
- $old_mofile = str_replace( "{$textdomain}-", "{$old_domain}-", $mofile ); // with trailing dash to target file and not folder
113
- if ( file_exists( $old_mofile ) ) {
114
- // we have an old override - use it
115
- return $old_mofile;
116
- }
117
-
118
- // prevent loading outdated language packs
119
- $pofile = str_replace('.mo', '.po', $mofile);
120
- if ( file_exists( $pofile ) ) {
121
- // load po file
122
- $podata = file_get_contents($pofile);
123
- // set revision date threshold
124
- $block_before = strtotime( '2017-05-15' );
125
- // read revision date
126
- preg_match('~PO-Revision-Date: (.*?)\\\n~s',$podata,$matches);
127
- if (isset($matches[1])) {
128
- $revision_date = $matches[1];
129
- if ( $revision_timestamp = strtotime($revision_date) ) {
130
- // check if revision is before threshold date
131
- if ( $revision_timestamp < $block_before ) {
132
- // try bundled
133
- $bundled_file = $this->plugin_path() . '/languages/'. basename( $mofile );
134
- if (file_exists($bundled_file)) {
135
- return $bundled_file;
136
- } else {
137
- return '';
138
- }
139
- // delete po & mo file if possible
140
- // @unlink($pofile);
141
- // @unlink($mofile);
142
- }
143
- }
144
- }
145
- }
146
- }
147
-
148
- return $mofile;
149
- }
150
-
151
- /**
152
- * Load the main plugin classes and functions
153
- */
154
- public function includes() {
155
- // WooCommerce compatibility classes
156
- include_once( $this->plugin_path() . '/includes/compatibility/abstract-wc-data-compatibility.php' );
157
- include_once( $this->plugin_path() . '/includes/compatibility/class-wc-date-compatibility.php' );
158
- include_once( $this->plugin_path() . '/includes/compatibility/class-wc-core-compatibility.php' );
159
- include_once( $this->plugin_path() . '/includes/compatibility/class-wc-order-compatibility.php' );
160
- include_once( $this->plugin_path() . '/includes/compatibility/class-wc-product-compatibility.php' );
161
- include_once( $this->plugin_path() . '/includes/compatibility/wc-datetime-functions-compatibility.php' );
162
-
163
- // Third party compatibility
164
- include_once( $this->plugin_path() . '/includes/compatibility/class-wcpdf-compatibility-third-party-plugins.php' );
165
-
166
- // Plugin classes
167
- include_once( $this->plugin_path() . '/includes/wcpdf-functions.php' );
168
- $this->settings = include_once( $this->plugin_path() . '/includes/class-wcpdf-settings.php' );
169
- $this->documents = include_once( $this->plugin_path() . '/includes/class-wcpdf-documents.php' );
170
- $this->main = include_once( $this->plugin_path() . '/includes/class-wcpdf-main.php' );
171
- include_once( $this->plugin_path() . '/includes/class-wcpdf-assets.php' );
172
- include_once( $this->plugin_path() . '/includes/class-wcpdf-admin.php' );
173
- include_once( $this->plugin_path() . '/includes/class-wcpdf-frontend.php' );
174
- include_once( $this->plugin_path() . '/includes/class-wcpdf-install.php' );
175
-
176
- // Backwards compatibility with self
177
- include_once( $this->plugin_path() . '/includes/legacy/class-wcpdf-legacy.php' );
178
- include_once( $this->plugin_path() . '/includes/legacy/class-wcpdf-legacy-deprecated-hooks.php' );
179
-
180
- // PHP MB String fallback functions
181
- include_once( $this->plugin_path() . '/includes/compatibility/mb-string-compatibility.php' );
182
- }
183
-
184
-
185
- /**
186
- * Instantiate classes when woocommerce is activated
187
- */
188
- public function load_classes() {
189
- if ( $this->is_woocommerce_activated() === false ) {
190
- add_action( 'admin_notices', array ( $this, 'need_woocommerce' ) );
191
- return;
192
- }
193
-
194
- if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
195
- add_action( 'admin_notices', array ( $this, 'required_php_version' ) );
196
- return;
197
- }
198
-
199
- // all systems ready - GO!
200
- $this->includes();
201
- }
202
-
203
- /**
204
- * Check if legacy mode is enabled
205
- */
206
- public function legacy_mode_enabled() {
207
- if (!isset($this->legacy_mode)) {
208
- $debug_settings = get_option( 'wpo_wcpdf_settings_debug' );
209
- $this->legacy_mode = isset($debug_settings['legacy_mode']);
210
- }
211
- return $this->legacy_mode;
212
- }
213
-
214
-
215
- /**
216
- * Check if woocommerce is activated
217
- */
218
- public function is_woocommerce_activated() {
219
- $blog_plugins = get_option( 'active_plugins', array() );
220
- $site_plugins = is_multisite() ? (array) maybe_unserialize( get_site_option('active_sitewide_plugins' ) ) : array();
221
-
222
- if ( in_array( 'woocommerce/woocommerce.php', $blog_plugins ) || isset( $site_plugins['woocommerce/woocommerce.php'] ) ) {
223
- return true;
224
- } else {
225
- return false;
226
- }
227
- }
228
-
229
- /**
230
- * WooCommerce not active notice.
231
- *
232
- * @return string Fallack notice.
233
- */
234
-
235
- public function need_woocommerce() {
236
- $error = sprintf( __( 'WooCommerce PDF Invoices & Packing Slips requires %sWooCommerce%s to be installed & activated!' , 'woocommerce-pdf-invoices-packing-slips' ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">', '</a>' );
237
-
238
- $message = '<div class="error"><p>' . $error . '</p></div>';
239
-
240
- echo $message;
241
- }
242
-
243
- /**
244
- * PHP version requirement notice
245
- */
246
-
247
- public function required_php_version() {
248
- $error = __( 'WooCommerce PDF Invoices & Packing Slips requires PHP 5.3 or higher (5.6 or higher recommended).', 'woocommerce-pdf-invoices-packing-slips' );
249
- $how_to_update = __( 'How to update your PHP version', 'woocommerce-pdf-invoices-packing-slips' );
250
- $message = sprintf('<div class="error"><p>%s</p><p><a href="%s">%s</a></p></div>', $error, 'http://docs.wpovernight.com/general/how-to-update-your-php-version/', $how_to_update);
251
-
252
- echo $message;
253
- }
254
-
255
- /**
256
- * Show plugin changes. Code adapted from W3 Total Cache.
257
- */
258
- public function in_plugin_update_message( $args ) {
259
- $transient_name = 'wpo_wcpdf_upgrade_notice_' . $args['Version'];
260
-
261
- if ( false === ( $upgrade_notice = get_transient( $transient_name ) ) ) {
262
- $response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/woocommerce-pdf-invoices-packing-slips/trunk/readme.txt' );
263
-
264
- if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
265
- $upgrade_notice = self::parse_update_notice( $response['body'], $args['new_version'] );
266
- set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS );
267
- }
268
- }
269
-
270
- echo wp_kses_post( $upgrade_notice );
271
- }
272
-
273
- /**
274
- * Parse update notice from readme file.
275
- *
276
- * @param string $content
277
- * @param string $new_version
278
- * @return string
279
- */
280
- private function parse_update_notice( $content, $new_version ) {
281
- // Output Upgrade Notice.
282
- $matches = null;
283
- $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis';
284
- $upgrade_notice = '';
285
-
286
-
287
- if ( preg_match( $regexp, $content, $matches ) ) {
288
- $notices = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) );
289
-
290
- // Convert the full version strings to minor versions.
291
- $notice_version_parts = explode( '.', trim( $matches[1] ) );
292
- $current_version_parts = explode( '.', $this->version );
293
-
294
- if ( 3 !== sizeof( $notice_version_parts ) ) {
295
- return;
296
- }
297
-
298
- $notice_version = $notice_version_parts[0] . '.' . $notice_version_parts[1];
299
- $current_version = $current_version_parts[0] . '.' . $current_version_parts[1];
300
-
301
- // Check the latest stable version and ignore trunk.
302
- if ( version_compare( $current_version, $notice_version, '<' ) ) {
303
-
304
- $upgrade_notice .= '</p><p class="wpo_wcpdf_upgrade_notice">';
305
-
306
- foreach ( $notices as $index => $line ) {
307
- $upgrade_notice .= preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line );
308
- }
309
- }
310
- }
311
-
312
- return wp_kses_post( $upgrade_notice );
313
- }
314
-
315
- /**
316
- * Get the plugin url.
317
- * @return string
318
- */
319
- public function plugin_url() {
320
- return untrailingslashit( plugins_url( '/', __FILE__ ) );
321
- }
322
-
323
- /**
324
- * Get the plugin path.
325
- * @return string
326
- */
327
- public function plugin_path() {
328
- return untrailingslashit( plugin_dir_path( __FILE__ ) );
329
- }
330
-
331
- } // class WPO_WCPDF
332
-
333
- endif; // class_exists
334
-
335
- /**
336
- * Returns the main instance of WooCommerce PDF Invoices & Packing Slips to prevent the need to use globals.
337
- *
338
- * @since 1.6
339
- * @return WPO_WCPDF
340
- */
341
- function WPO_WCPDF() {
342
- return WPO_WCPDF::instance();
343
- }
344
-
345
- WPO_WCPDF(); // load plugin
346
-
347
- // legacy class for plugin detecting
348
- if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
349
- class WooCommerce_PDF_Invoices{
350
- public static $version;
351
-
352
- public function __construct() {
353
- self::$version = WPO_WCPDF()->version;
354
- }
355
- }
356
- new WooCommerce_PDF_Invoices();
357
- }
1
+ <?php
2
+ /**
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.1.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: 3.3.0
14
+ */
15
+
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ exit; // Exit if accessed directly
18
+ }
19
+
20
+ if ( !class_exists( 'WPO_WCPDF' ) ) :
21
+
22
+ class WPO_WCPDF {
23
+
24
+ public $version = '2.1.4';
25
+ public $plugin_basename;
26
+ public $legacy_mode;
27
+
28
+ protected static $_instance = null;
29
+
30
+ /**
31
+ * Main Plugin Instance
32
+ *
33
+ * Ensures only one instance of plugin is loaded or can be loaded.
34
+ */
35
+ public static function instance() {
36
+ if ( is_null( self::$_instance ) ) {
37
+ self::$_instance = new self();
38
+ }
39
+ return self::$_instance;
40
+ }
41
+
42
+ /**
43
+ * Constructor
44
+ */
45
+ public function __construct() {
46
+ $this->plugin_basename = plugin_basename(__FILE__);
47
+
48
+ $this->define( 'WPO_WCPDF_VERSION', $this->version );
49
+
50
+ // load the localisation & classes
51
+ add_action( 'plugins_loaded', array( $this, 'translations' ) );
52
+ add_filter( 'load_textdomain_mofile', array( $this, 'textdomain_fallback' ), 10, 2 );
53
+ add_action( 'plugins_loaded', array( $this, 'load_classes' ), 9 );
54
+ add_action( 'in_plugin_update_message-'.$this->plugin_basename, array( $this, 'in_plugin_update_message' ) );
55
+ }
56
+
57
+ /**
58
+ * Define constant if not already set
59
+ * @param string $name
60
+ * @param string|bool $value
61
+ */
62
+ private function define( $name, $value ) {
63
+ if ( ! defined( $name ) ) {
64
+ define( $name, $value );
65
+ }
66
+ }
67
+
68
+
69
+ /**
70
+ * Load the translation / textdomain files
71
+ *
72
+ * Note: the first-loaded translation file overrides any following ones if the same translation is present
73
+ */
74
+ public function translations() {
75
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-pdf-invoices-packing-slips' );
76
+ $dir = trailingslashit( WP_LANG_DIR );
77
+
78
+ $textdomains = array( 'woocommerce-pdf-invoices-packing-slips' );
79
+ if ( $this->legacy_mode_enabled() === true ) {
80
+ $textdomains[] = 'wpo_wcpdf';
81
+ }
82
+
83
+ /**
84
+ * Frontend/global Locale. Looks in:
85
+ *
86
+ * - WP_LANG_DIR/woocommerce-pdf-invoices-packing-slips/woocommerce-pdf-invoices-packing-slips-LOCALE.mo
87
+ * - WP_LANG_DIR/plugins/woocommerce-pdf-invoices-packing-slips-LOCALE.mo
88
+ * - woocommerce-pdf-invoices-packing-slips-pro/languages/woocommerce-pdf-invoices-packing-slips-LOCALE.mo (which if not found falls back to:)
89
+ * - WP_LANG_DIR/plugins/woocommerce-pdf-invoices-packing-slips-LOCALE.mo
90
+ */
91
+ foreach ($textdomains as $textdomain) {
92
+ load_textdomain( $textdomain, $dir . 'woocommerce-pdf-invoices-packing-slips/woocommerce-pdf-invoices-packing-slips-' . $locale . '.mo' );
93
+ load_textdomain( $textdomain, $dir . 'plugins/woocommerce-pdf-invoices-packing-slips-' . $locale . '.mo' );
94
+ load_plugin_textdomain( $textdomain, false, dirname( plugin_basename(__FILE__) ) . '/languages' );
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Maintain backwards compatibility with old translation files
100
+ * Uses old .mo file if it exists in any of the override locations
101
+ */
102
+ public function textdomain_fallback( $mofile, $textdomain ) {
103
+ $plugin_domain = 'woocommerce-pdf-invoices-packing-slips';
104
+ $old_domain = 'wpo_wcpdf';
105
+
106
+ if ($textdomain == $old_domain) {
107
+ $textdomain = $plugin_domain;
108
+ $mofile = str_replace( "{$old_domain}-", "{$textdomain}-", $mofile ); // with trailing dash to target file and not folder
109
+ }
110
+
111
+ if ( $textdomain === $plugin_domain ) {
112
+ $old_mofile = str_replace( "{$textdomain}-", "{$old_domain}-", $mofile ); // with trailing dash to target file and not folder
113
+ if ( file_exists( $old_mofile ) ) {
114
+ // we have an old override - use it
115
+ return $old_mofile;
116
+ }
117
+
118
+ // prevent loading outdated language packs
119
+ $pofile = str_replace('.mo', '.po', $mofile);
120
+ if ( file_exists( $pofile ) ) {
121
+ // load po file
122
+ $podata = file_get_contents($pofile);
123
+ // set revision date threshold
124
+ $block_before = strtotime( '2017-05-15' );
125
+ // read revision date
126
+ preg_match('~PO-Revision-Date: (.*?)\\\n~s',$podata,$matches);
127
+ if (isset($matches[1])) {
128
+ $revision_date = $matches[1];
129
+ if ( $revision_timestamp = strtotime($revision_date) ) {
130
+ // check if revision is before threshold date
131
+ if ( $revision_timestamp < $block_before ) {
132
+ // try bundled
133
+ $bundled_file = $this->plugin_path() . '/languages/'. basename( $mofile );
134
+ if (file_exists($bundled_file)) {
135
+ return $bundled_file;
136
+ } else {
137
+ return '';
138
+ }
139
+ // delete po & mo file if possible
140
+ // @unlink($pofile);
141
+ // @unlink($mofile);
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ return $mofile;
149
+ }
150
+
151
+ /**
152
+ * Load the main plugin classes and functions
153
+ */
154
+ public function includes() {
155
+ // WooCommerce compatibility classes
156
+ include_once( $this->plugin_path() . '/includes/compatibility/abstract-wc-data-compatibility.php' );
157
+ include_once( $this->plugin_path() . '/includes/compatibility/class-wc-date-compatibility.php' );
158
+ include_once( $this->plugin_path() . '/includes/compatibility/class-wc-core-compatibility.php' );
159
+ include_once( $this->plugin_path() . '/includes/compatibility/class-wc-order-compatibility.php' );
160
+ include_once( $this->plugin_path() . '/includes/compatibility/class-wc-product-compatibility.php' );
161
+ include_once( $this->plugin_path() . '/includes/compatibility/wc-datetime-functions-compatibility.php' );
162
+
163
+ // Third party compatibility
164
+ include_once( $this->plugin_path() . '/includes/compatibility/class-wcpdf-compatibility-third-party-plugins.php' );
165
+
166
+ // Plugin classes
167
+ include_once( $this->plugin_path() . '/includes/wcpdf-functions.php' );
168
+ $this->settings = include_once( $this->plugin_path() . '/includes/class-wcpdf-settings.php' );
169
+ $this->documents = include_once( $this->plugin_path() . '/includes/class-wcpdf-documents.php' );
170
+ $this->main = include_once( $this->plugin_path() . '/includes/class-wcpdf-main.php' );
171
+ include_once( $this->plugin_path() . '/includes/class-wcpdf-assets.php' );
172
+ include_once( $this->plugin_path() . '/includes/class-wcpdf-admin.php' );
173
+ include_once( $this->plugin_path() . '/includes/class-wcpdf-frontend.php' );
174
+ include_once( $this->plugin_path() . '/includes/class-wcpdf-install.php' );
175
+
176
+ // Backwards compatibility with self
177
+ include_once( $this->plugin_path() . '/includes/legacy/class-wcpdf-legacy.php' );
178
+ include_once( $this->plugin_path() . '/includes/legacy/class-wcpdf-legacy-deprecated-hooks.php' );
179
+
180
+ // PHP MB String fallback functions
181
+ include_once( $this->plugin_path() . '/includes/compatibility/mb-string-compatibility.php' );
182
+ }
183
+
184
+
185
+ /**
186
+ * Instantiate classes when woocommerce is activated
187
+ */
188
+ public function load_classes() {
189
+ if ( $this->is_woocommerce_activated() === false ) {
190
+ add_action( 'admin_notices', array ( $this, 'need_woocommerce' ) );
191
+ return;
192
+ }
193
+
194
+ if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
195
+ add_action( 'admin_notices', array ( $this, 'required_php_version' ) );
196
+ return;
197
+ }
198
+
199
+ // all systems ready - GO!
200
+ $this->includes();
201
+ }
202
+
203
+ /**
204
+ * Check if legacy mode is enabled
205
+ */
206
+ public function legacy_mode_enabled() {
207
+ if (!isset($this->legacy_mode)) {
208
+ $debug_settings = get_option( 'wpo_wcpdf_settings_debug' );
209
+ $this->legacy_mode = isset($debug_settings['legacy_mode']);
210
+ }
211
+ return $this->legacy_mode;
212
+ }
213
+
214
+
215
+ /**
216
+ * Check if woocommerce is activated
217
+ */
218
+ public function is_woocommerce_activated() {
219
+ $blog_plugins = get_option( 'active_plugins', array() );
220
+ $site_plugins = is_multisite() ? (array) maybe_unserialize( get_site_option('active_sitewide_plugins' ) ) : array();
221
+
222
+ if ( in_array( 'woocommerce/woocommerce.php', $blog_plugins ) || isset( $site_plugins['woocommerce/woocommerce.php'] ) ) {
223
+ return true;
224
+ } else {
225
+ return false;
226
+ }
227
+ }
228
+
229
+ /**
230
+ * WooCommerce not active notice.
231
+ *
232
+ * @return string Fallack notice.
233
+ */
234
+
235
+ public function need_woocommerce() {
236
+ $error = sprintf( __( 'WooCommerce PDF Invoices & Packing Slips requires %sWooCommerce%s to be installed & activated!' , 'woocommerce-pdf-invoices-packing-slips' ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">', '</a>' );
237
+
238
+ $message = '<div class="error"><p>' . $error . '</p></div>';
239
+
240
+ echo $message;
241
+ }
242
+
243
+ /**
244
+ * PHP version requirement notice
245
+ */
246
+
247
+ public function required_php_version() {
248
+ $error = __( 'WooCommerce PDF Invoices & Packing Slips requires PHP 5.3 or higher (5.6 or higher recommended).', 'woocommerce-pdf-invoices-packing-slips' );
249
+ $how_to_update = __( 'How to update your PHP version', 'woocommerce-pdf-invoices-packing-slips' );
250
+ $message = sprintf('<div class="error"><p>%s</p><p><a href="%s">%s</a></p></div>', $error, 'http://docs.wpovernight.com/general/how-to-update-your-php-version/', $how_to_update);
251
+
252
+ echo $message;
253
+ }
254
+
255
+ /**
256
+ * Show plugin changes. Code adapted from W3 Total Cache.
257
+ */
258
+ public function in_plugin_update_message( $args ) {
259
+ $transient_name = 'wpo_wcpdf_upgrade_notice_' . $args['Version'];
260
+
261
+ if ( false === ( $upgrade_notice = get_transient( $transient_name ) ) ) {
262
+ $response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/woocommerce-pdf-invoices-packing-slips/trunk/readme.txt' );
263
+
264
+ if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
265
+ $upgrade_notice = self::parse_update_notice( $response['body'], $args['new_version'] );
266
+ set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS );
267
+ }
268
+ }
269
+
270
+ echo wp_kses_post( $upgrade_notice );
271
+ }
272
+
273
+ /**
274
+ * Parse update notice from readme file.
275
+ *
276
+ * @param string $content
277
+ * @param string $new_version
278
+ * @return string
279
+ */
280
+ private function parse_update_notice( $content, $new_version ) {
281
+ // Output Upgrade Notice.
282
+ $matches = null;
283
+ $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis';
284
+ $upgrade_notice = '';
285
+
286
+
287
+ if ( preg_match( $regexp, $content, $matches ) ) {
288
+ $notices = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) );
289
+
290
+ // Convert the full version strings to minor versions.
291
+ $notice_version_parts = explode( '.', trim( $matches[1] ) );
292
+ $current_version_parts = explode( '.', $this->version );
293
+
294
+ if ( 3 !== sizeof( $notice_version_parts ) ) {
295
+ return;
296
+ }
297
+
298
+ $notice_version = $notice_version_parts[0] . '.' . $notice_version_parts[1];
299
+ $current_version = $current_version_parts[0] . '.' . $current_version_parts[1];
300
+
301
+ // Check the latest stable version and ignore trunk.
302
+ if ( version_compare( $current_version, $notice_version, '<' ) ) {
303
+
304
+ $upgrade_notice .= '</p><p class="wpo_wcpdf_upgrade_notice">';
305
+
306
+ foreach ( $notices as $index => $line ) {
307
+ $upgrade_notice .= preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line );
308
+ }
309
+ }
310
+ }
311
+
312
+ return wp_kses_post( $upgrade_notice );
313
+ }
314
+
315
+ /**
316
+ * Get the plugin url.
317
+ * @return string
318
+ */
319
+ public function plugin_url() {
320
+ return untrailingslashit( plugins_url( '/', __FILE__ ) );
321
+ }
322
+
323
+ /**
324
+ * Get the plugin path.
325
+ * @return string
326
+ */
327
+ public function plugin_path() {
328
+ return untrailingslashit( plugin_dir_path( __FILE__ ) );
329
+ }
330
+
331
+ } // class WPO_WCPDF
332
+
333
+ endif; // class_exists
334
+
335
+ /**
336
+ * Returns the main instance of WooCommerce PDF Invoices & Packing Slips to prevent the need to use globals.
337
+ *
338
+ * @since 1.6
339
+ * @return WPO_WCPDF
340
+ */
341
+ function WPO_WCPDF() {
342
+ return WPO_WCPDF::instance();
343
+ }
344
+
345
+ WPO_WCPDF(); // load plugin
346
+
347
+ // legacy class for plugin detecting
348
+ if ( !class_exists( 'WooCommerce_PDF_Invoices' ) ) {
349
+ class WooCommerce_PDF_Invoices{
350
+ public static $version;
351
+
352
+ public function __construct() {
353
+ self::$version = WPO_WCPDF()->version;
354
+ }
355
+ }
356
+ new WooCommerce_PDF_Invoices();
357
+ }