Version Description
- Fix: order notes using correct order_id
- Fix: WC3.0 deprecation notice for currency
- Fix: Avoid crashing on PHP5.2 and older
- Fix: Only use PHP MB String when present
- Fix: Remote images
- Fix: Download option
Download this release
Release Info
Developer | pomegranate |
Plugin | WooCommerce PDF Invoices & Packing Slips |
Version | 2.0.2 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.0.2
- includes/class-wcpdf-install.php +309 -0
- includes/class-wcpdf-main.php +2 -1
- includes/class-wcpdf-pdf-maker.php +1 -0
- includes/class-wcpdf-settings.php +17 -0
- includes/documents/abstract-wcpdf-order-document-methods.php +2 -2
- includes/documents/abstract-wcpdf-order-document.php +7 -4
- includes/documents/class-wcpdf-bulk-document.php +2 -2
- readme.txt +15 -4
- woocommerce-pdf-invoices-packingslips.php +3 -279
includes/class-wcpdf-install.php
ADDED
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace WPO\WC\PDF_Invoices;
|
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 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( !class_exists( '\\WPO\\WC\\PDF_Invoices\\Install' ) ) :
|
13 |
+
|
14 |
+
class Install {
|
15 |
+
|
16 |
+
function __construct() {
|
17 |
+
// run lifecycle methods
|
18 |
+
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
19 |
+
add_action( 'wp_loaded', array( $this, 'do_install' ) );
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
/** Lifecycle methods *******************************************************
|
24 |
+
* Because register_activation_hook only runs when the plugin is manually
|
25 |
+
* activated by the user, we're checking the current version against the
|
26 |
+
* version stored in the database
|
27 |
+
****************************************************************************/
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Handles version checking
|
31 |
+
*/
|
32 |
+
public function do_install() {
|
33 |
+
// only install when woocommerce is active
|
34 |
+
if ( !WPO_WCPDF()->is_woocommerce_activated() ) {
|
35 |
+
return;
|
36 |
+
}
|
37 |
+
|
38 |
+
$version_setting = 'wpo_wcpdf_version';
|
39 |
+
$installed_version = get_option( $version_setting );
|
40 |
+
|
41 |
+
// installed version lower than plugin version?
|
42 |
+
if ( version_compare( $installed_version, WPO_WCPDF_VERSION, '<' ) ) {
|
43 |
+
|
44 |
+
if ( ! $installed_version ) {
|
45 |
+
$this->install();
|
46 |
+
} else {
|
47 |
+
$this->upgrade( $installed_version );
|
48 |
+
}
|
49 |
+
|
50 |
+
// new version number
|
51 |
+
update_option( $version_setting, WPO_WCPDF_VERSION );
|
52 |
+
} elseif ( $installed_version && version_compare( $installed_version, WPO_WCPDF_VERSION, '>' ) ) {
|
53 |
+
$this->downgrade( $installed_version );
|
54 |
+
// downgrade version number
|
55 |
+
update_option( $version_setting, WPO_WCPDF_VERSION );
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Plugin install method. Perform any installation tasks here
|
62 |
+
*/
|
63 |
+
protected function install() {
|
64 |
+
// only install when php 5.3 or higher
|
65 |
+
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
66 |
+
return;
|
67 |
+
}
|
68 |
+
|
69 |
+
// check if upgrading from versionless (1.4.14 and older)
|
70 |
+
if ( get_option('wpo_wcpdf_general_settings') ) {
|
71 |
+
$this->upgrade( 'versionless' );
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
|
75 |
+
// Create temp folders
|
76 |
+
$tmp_base = WPO_WCPDF()->main->get_tmp_base();
|
77 |
+
|
78 |
+
// check if tmp folder exists => if not, initialize
|
79 |
+
if ( !@is_dir( $tmp_base ) ) {
|
80 |
+
WPO_WCPDF()->main->init_tmp( $tmp_base );
|
81 |
+
}
|
82 |
+
|
83 |
+
// set default settings
|
84 |
+
$settings_defaults = array(
|
85 |
+
'wpo_wcpdf_settings_general' => array(
|
86 |
+
'download_display' => 'display',
|
87 |
+
'template_path' => WPO_WCPDF()->plugin_path() . '/templates/Simple',
|
88 |
+
// 'currency_font' => '',
|
89 |
+
'paper_size' => 'a4',
|
90 |
+
// 'header_logo' => '',
|
91 |
+
// 'shop_name' => array(),
|
92 |
+
// 'shop_address' => array(),
|
93 |
+
// 'footer' => array(),
|
94 |
+
// 'extra_1' => array(),
|
95 |
+
// 'extra_2' => array(),
|
96 |
+
// 'extra_3' => array(),
|
97 |
+
),
|
98 |
+
'wpo_wcpdf_documents_settings_invoice' => array(
|
99 |
+
'enabled' => 1,
|
100 |
+
// 'attach_to_email_ids' => array(),
|
101 |
+
// 'display_shipping_address' => '',
|
102 |
+
// 'display_email' => '',
|
103 |
+
// 'display_phone' => '',
|
104 |
+
// 'display_date' => '',
|
105 |
+
// 'display_number' => '',
|
106 |
+
// 'number_format' => array(),
|
107 |
+
// 'reset_number_yearly' => '',
|
108 |
+
// 'my_account_buttons' => '',
|
109 |
+
// 'invoice_number_column' => '',
|
110 |
+
// 'disable_free' => '',
|
111 |
+
),
|
112 |
+
'wpo_wcpdf_documents_settings_packing-slip' => array(
|
113 |
+
'enabled' => 1,
|
114 |
+
// 'display_billing_address' => '',
|
115 |
+
// 'display_email' => '',
|
116 |
+
// 'display_phone' => '',
|
117 |
+
),
|
118 |
+
// 'wpo_wcpdf_settings_debug' => array(
|
119 |
+
// 'legacy_mode' => '',
|
120 |
+
// 'enable_debug' => '',
|
121 |
+
// 'html_output' => '',
|
122 |
+
// ),
|
123 |
+
);
|
124 |
+
foreach ($settings_defaults as $option => $defaults) {
|
125 |
+
update_option( $option, $defaults );
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Plugin upgrade method. Perform any required upgrades here
|
131 |
+
*
|
132 |
+
* @param string $installed_version the currently installed ('old') version
|
133 |
+
*/
|
134 |
+
protected function upgrade( $installed_version ) {
|
135 |
+
// only upgrade when php 5.3 or higher
|
136 |
+
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
|
140 |
+
// sync fonts on every upgrade!
|
141 |
+
$tmp_base = WPO_WCPDF()->main->get_tmp_base();
|
142 |
+
|
143 |
+
// check if tmp folder exists => if not, initialize
|
144 |
+
if ( !@is_dir( $tmp_base ) ) {
|
145 |
+
WPO_WCPDF()->main->init_tmp( $tmp_base );
|
146 |
+
} else {
|
147 |
+
$font_path = WPO_WCPDF()->main->get_tmp_path( 'fonts' );
|
148 |
+
WPO_WCPDF()->main->copy_fonts( $font_path );
|
149 |
+
}
|
150 |
+
|
151 |
+
// 1.5.28 update: copy next invoice number to separate setting
|
152 |
+
if ( $installed_version == 'versionless' || version_compare( $installed_version, '1.5.28', '<' ) ) {
|
153 |
+
$template_settings = get_option( 'wpo_wcpdf_template_settings' );
|
154 |
+
$next_invoice_number = isset($template_settings['next_invoice_number'])?$template_settings['next_invoice_number']:'';
|
155 |
+
update_option( 'wpo_wcpdf_next_invoice_number', $next_invoice_number );
|
156 |
+
}
|
157 |
+
|
158 |
+
// 2.0-dev update: reorganize settings
|
159 |
+
if ( $installed_version == 'versionless' || version_compare( $installed_version, '2.0-dev', '<' ) ) {
|
160 |
+
$old_settings = array(
|
161 |
+
'wpo_wcpdf_general_settings' => get_option( 'wpo_wcpdf_general_settings' ),
|
162 |
+
'wpo_wcpdf_template_settings' => get_option( 'wpo_wcpdf_template_settings' ),
|
163 |
+
'wpo_wcpdf_debug_settings' => get_option( 'wpo_wcpdf_debug_settings' ),
|
164 |
+
);
|
165 |
+
|
166 |
+
// combine invoice number formatting in array
|
167 |
+
$old_settings['wpo_wcpdf_template_settings']['invoice_number_formatting'] = array();
|
168 |
+
$format_option_keys = array('padding','suffix','prefix');
|
169 |
+
foreach ($format_option_keys as $format_option_key) {
|
170 |
+
if (isset($old_settings['wpo_wcpdf_template_settings']["invoice_number_formatting_{$format_option_key}"])) {
|
171 |
+
$old_settings['wpo_wcpdf_template_settings']['invoice_number_formatting'][$format_option_key] = $old_settings['wpo_wcpdf_template_settings']["invoice_number_formatting_{$format_option_key}"];
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
// convert abbreviated email_ids
|
176 |
+
if (isset($old_settings['wpo_wcpdf_general_settings']['email_pdf'])) {
|
177 |
+
foreach ($old_settings['wpo_wcpdf_general_settings']['email_pdf'] as $email_id => $value) {
|
178 |
+
if ($email_id == 'completed' || $email_id == 'processing') {
|
179 |
+
$old_settings['wpo_wcpdf_general_settings']['email_pdf']["customer_{$email_id}_order"] = $value;
|
180 |
+
unset($old_settings['wpo_wcpdf_general_settings']['email_pdf'][$email_id]);
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
// Migrate template path
|
186 |
+
// forward slash for consistency/compatibility
|
187 |
+
$template_path = str_replace('\\','/', $old_settings['wpo_wcpdf_template_settings']['template_path']);
|
188 |
+
// strip abspath (forward slashed) if included
|
189 |
+
$template_path = str_replace( str_replace('\\','/', ABSPATH), '', $template_path );
|
190 |
+
// strip pdf subfolder from templates path
|
191 |
+
$template_path = str_replace( '/templates/pdf/', '/templates/', $template_path );
|
192 |
+
$old_settings['wpo_wcpdf_template_settings']['template_path'] = $template_path;
|
193 |
+
|
194 |
+
// map new settings to old
|
195 |
+
$settings_map = array(
|
196 |
+
'wpo_wcpdf_settings_general' => array(
|
197 |
+
'download_display' => array( 'wpo_wcpdf_general_settings' => 'download_display' ),
|
198 |
+
'template_path' => array( 'wpo_wcpdf_template_settings' => 'template_path' ),
|
199 |
+
'currency_font' => array( 'wpo_wcpdf_template_settings' => 'currency_font' ),
|
200 |
+
'paper_size' => array( 'wpo_wcpdf_template_settings' => 'paper_size' ),
|
201 |
+
'header_logo' => array( 'wpo_wcpdf_template_settings' => 'header_logo' ),
|
202 |
+
'shop_name' => array( 'wpo_wcpdf_template_settings' => 'shop_name' ),
|
203 |
+
'shop_address' => array( 'wpo_wcpdf_template_settings' => 'shop_address' ),
|
204 |
+
'footer' => array( 'wpo_wcpdf_template_settings' => 'footer' ),
|
205 |
+
'extra_1' => array( 'wpo_wcpdf_template_settings' => 'extra_1' ),
|
206 |
+
'extra_2' => array( 'wpo_wcpdf_template_settings' => 'extra_2' ),
|
207 |
+
'extra_3' => array( 'wpo_wcpdf_template_settings' => 'extra_3' ),
|
208 |
+
),
|
209 |
+
'wpo_wcpdf_documents_settings_invoice' => array(
|
210 |
+
'attach_to_email_ids' => array( 'wpo_wcpdf_general_settings' => 'email_pdf' ),
|
211 |
+
'display_shipping_address' => array( 'wpo_wcpdf_template_settings' => 'invoice_shipping_address' ),
|
212 |
+
'display_email' => array( 'wpo_wcpdf_template_settings' => 'invoice_email' ),
|
213 |
+
'display_phone' => array( 'wpo_wcpdf_template_settings' => 'invoice_phone' ),
|
214 |
+
'display_date' => array( 'wpo_wcpdf_template_settings' => 'display_date' ),
|
215 |
+
'display_number' => array( 'wpo_wcpdf_template_settings' => 'display_number' ),
|
216 |
+
'number_format' => array( 'wpo_wcpdf_template_settings' => 'invoice_number_formatting' ),
|
217 |
+
'reset_number_yearly' => array( 'wpo_wcpdf_template_settings' => 'yearly_reset_invoice_number' ),
|
218 |
+
'my_account_buttons' => array( 'wpo_wcpdf_general_settings' => 'my_account_buttons' ),
|
219 |
+
'invoice_number_column' => array( 'wpo_wcpdf_general_settings' => 'invoice_number_column' ),
|
220 |
+
'disable_free' => array( 'wpo_wcpdf_general_settings' => 'disable_free' ),
|
221 |
+
),
|
222 |
+
'wpo_wcpdf_documents_settings_packing-slip' => array(
|
223 |
+
'display_billing_address' => array( 'wpo_wcpdf_template_settings' => 'packing_slip_billing_address' ),
|
224 |
+
'display_email' => array( 'wpo_wcpdf_template_settings' => 'packing_slip_email' ),
|
225 |
+
'display_phone' => array( 'wpo_wcpdf_template_settings' => 'packing_slip_phone' ),
|
226 |
+
),
|
227 |
+
'wpo_wcpdf_settings_debug' => array(
|
228 |
+
'enable_debug' => array( 'wpo_wcpdf_debug_settings' => 'enable_debug' ),
|
229 |
+
'html_output' => array( 'wpo_wcpdf_debug_settings' => 'html_output' ),
|
230 |
+
),
|
231 |
+
);
|
232 |
+
|
233 |
+
// walk through map
|
234 |
+
foreach ($settings_map as $new_option => $new_settings_keys) {
|
235 |
+
${$new_option} = array();
|
236 |
+
foreach ($new_settings_keys as $new_key => $old_setting ) {
|
237 |
+
$old_key = reset($old_setting);
|
238 |
+
$old_option = key($old_setting);
|
239 |
+
if (!empty($old_settings[$old_option][$old_key])) {
|
240 |
+
// turn translatable fields into array
|
241 |
+
$translatable_fields = array('shop_name','shop_address','footer','extra_1','extra_2','extra_3');
|
242 |
+
if (in_array($new_key, $translatable_fields)) {
|
243 |
+
${$new_option}[$new_key] = array( 'default' => $old_settings[$old_option][$old_key] );
|
244 |
+
} else {
|
245 |
+
${$new_option}[$new_key] = $old_settings[$old_option][$old_key];
|
246 |
+
}
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
// auto enable invoice & packing slip
|
251 |
+
$enabled = array( 'wpo_wcpdf_documents_settings_invoice', 'wpo_wcpdf_documents_settings_packing-slip' );
|
252 |
+
if ( in_array( $new_option, $enabled ) ) {
|
253 |
+
${$new_option}['enabled'] = 1;
|
254 |
+
}
|
255 |
+
|
256 |
+
// auto enable legacy mode
|
257 |
+
if ( $new_option == 'wpo_wcpdf_settings_debug' ) {
|
258 |
+
${$new_option}['legacy_mode'] = 1;
|
259 |
+
}
|
260 |
+
|
261 |
+
// merge with existing settings
|
262 |
+
${$new_option."_old"} = get_option( $new_option, ${$new_option} ); // second argument loads new as default in case the settings did not exist yet
|
263 |
+
${$new_option} = ${$new_option} + ${$new_option."_old"}; // duplicate options take new options as default
|
264 |
+
|
265 |
+
// store new option values
|
266 |
+
update_option( $new_option, ${$new_option} );
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
// 2.0-beta-2 update: copy next number to separate db store
|
271 |
+
if ( version_compare( $installed_version, '2.0-beta-2', '<' ) ) {
|
272 |
+
// load number store class (just in case)
|
273 |
+
include_once( WPO_WCPDF()->plugin_path() . '/includes/documents/class-wcpdf-sequential-number-store.php' );
|
274 |
+
|
275 |
+
$next_number = get_option( 'wpo_wcpdf_next_invoice_number' );
|
276 |
+
if (!empty($next_number)) {
|
277 |
+
$number_store = new \WPO\WC\PDF_Invoices\Documents\Sequential_Number_Store( 'invoice_number' );
|
278 |
+
$number_store->set_next( (int) $next_number );
|
279 |
+
}
|
280 |
+
// we're not deleting this option yet to make downgrading possible
|
281 |
+
// delete_option( 'wpo_wcpdf_next_invoice_number' ); // clean up after ourselves
|
282 |
+
}
|
283 |
+
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Plugin downgrade method. Perform any required downgrades here
|
288 |
+
*
|
289 |
+
*
|
290 |
+
* @param string $installed_version the currently installed ('old') version (actually higher since this is a downgrade)
|
291 |
+
*/
|
292 |
+
protected function downgrade( $installed_version ) {
|
293 |
+
// make sure fonts match with version: copy from plugin folder
|
294 |
+
$tmp_base = WPO_WCPDF()->main->get_tmp_base();
|
295 |
+
|
296 |
+
// check if tmp folder exists => if not, initialize
|
297 |
+
if ( !@is_dir( $tmp_base ) ) {
|
298 |
+
WPO_WCPDF()->main->init_tmp( $tmp_base );
|
299 |
+
} else {
|
300 |
+
$font_path = WPO_WCPDF()->main->get_tmp_path( 'fonts' );
|
301 |
+
WPO_WCPDF()->main->copy_fonts( $font_path );
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
}
|
306 |
+
|
307 |
+
endif; // class_exists
|
308 |
+
|
309 |
+
return new Install();
|
includes/class-wcpdf-main.php
CHANGED
@@ -186,7 +186,8 @@ class Main {
|
|
186 |
if ( has_action( 'wpo_wcpdf_created_manually' ) ) {
|
187 |
do_action( 'wpo_wcpdf_created_manually', $document->get_pdf(), $document->get_filename() );
|
188 |
}
|
189 |
-
$
|
|
|
190 |
break;
|
191 |
}
|
192 |
} else {
|
186 |
if ( has_action( 'wpo_wcpdf_created_manually' ) ) {
|
187 |
do_action( 'wpo_wcpdf_created_manually', $document->get_pdf(), $document->get_filename() );
|
188 |
}
|
189 |
+
$output_mode = WPO_WCPDF()->settings->get_output_mode( $document_type );
|
190 |
+
$document->output_pdf( $output_mode );
|
191 |
break;
|
192 |
}
|
193 |
} else {
|
includes/class-wcpdf-pdf-maker.php
CHANGED
@@ -37,6 +37,7 @@ class PDF_Maker {
|
|
37 |
$options->setTempDir( WPO_WCPDF()->main->get_tmp_path('dompdf') );
|
38 |
$options->setFontDir( WPO_WCPDF()->main->get_tmp_path('fonts') );
|
39 |
$options->setFontCache( WPO_WCPDF()->main->get_tmp_path('fonts') );
|
|
|
40 |
|
41 |
// instantiate and use the dompdf class
|
42 |
$dompdf = new Dompdf( $options );
|
37 |
$options->setTempDir( WPO_WCPDF()->main->get_tmp_path('dompdf') );
|
38 |
$options->setFontDir( WPO_WCPDF()->main->get_tmp_path('fonts') );
|
39 |
$options->setFontCache( WPO_WCPDF()->main->get_tmp_path('fonts') );
|
40 |
+
$options->setIsRemoteEnabled( true );
|
41 |
|
42 |
// instantiate and use the dompdf class
|
43 |
$dompdf = new Dompdf( $options );
|
includes/class-wcpdf-settings.php
CHANGED
@@ -174,6 +174,23 @@ class Settings {
|
|
174 |
return $output_format;
|
175 |
}
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
public function get_template_path( $document_type = NULL ) {
|
178 |
$template_path = isset( $this->general_settings['template_path'] )?$this->general_settings['template_path']:'';
|
179 |
// forward slash for consistency
|
174 |
return $output_format;
|
175 |
}
|
176 |
|
177 |
+
public function get_output_mode() {
|
178 |
+
if ( isset( WPO_WCPDF()->settings->general_settings['download_display'] ) ) {
|
179 |
+
switch ( WPO_WCPDF()->settings->general_settings['download_display'] ) {
|
180 |
+
case 'display':
|
181 |
+
$output_mode = 'inline';
|
182 |
+
break;
|
183 |
+
case 'download':
|
184 |
+
default:
|
185 |
+
$output_mode = 'download';
|
186 |
+
break;
|
187 |
+
}
|
188 |
+
} else {
|
189 |
+
$output_mode = 'download';
|
190 |
+
}
|
191 |
+
return $output_mode;
|
192 |
+
}
|
193 |
+
|
194 |
public function get_template_path( $document_type = NULL ) {
|
195 |
$template_path = isset( $this->general_settings['template_path'] )?$this->general_settings['template_path']:'';
|
196 |
// forward slash for consistency
|
includes/documents/abstract-wcpdf-order-document-methods.php
CHANGED
@@ -263,7 +263,7 @@ abstract class Order_Document_Methods extends Order_Document {
|
|
263 |
if ( $this->is_refund( $this->order ) ) {
|
264 |
$post_id = $this->get_refund_parent_id( $this->order );
|
265 |
} else {
|
266 |
-
$post_id = $order_id;
|
267 |
}
|
268 |
|
269 |
$args = array(
|
@@ -677,7 +677,7 @@ abstract class Order_Document_Methods extends Order_Document {
|
|
677 |
$tax_string_array[] = sprintf( '%s %s', $tax_amount, $tax->label );
|
678 |
}
|
679 |
} else {
|
680 |
-
$tax_string_array[] = sprintf( '%s %s', wc_price( $this->order->get_total_tax() - $this->order->get_total_tax_refunded(), array( 'currency' => $this->order
|
681 |
}
|
682 |
if ( ! empty( $tax_string_array ) ) {
|
683 |
if ( version_compare( WOOCOMMERCE_VERSION, '2.6', '>=' ) ) {
|
263 |
if ( $this->is_refund( $this->order ) ) {
|
264 |
$post_id = $this->get_refund_parent_id( $this->order );
|
265 |
} else {
|
266 |
+
$post_id = $this->order_id;
|
267 |
}
|
268 |
|
269 |
$args = array(
|
677 |
$tax_string_array[] = sprintf( '%s %s', $tax_amount, $tax->label );
|
678 |
}
|
679 |
} else {
|
680 |
+
$tax_string_array[] = sprintf( '%s %s', wc_price( $this->order->get_total_tax() - $this->order->get_total_tax_refunded(), array( 'currency' => WCX_Order::get_prop( $this->order, 'currency' ) ) ), WC()->countries->tax_or_vat() );
|
681 |
}
|
682 |
if ( ! empty( $tax_string_array ) ) {
|
683 |
if ( version_compare( WOOCOMMERCE_VERSION, '2.6', '>=' ) ) {
|
includes/documents/abstract-wcpdf-order-document.php
CHANGED
@@ -335,7 +335,7 @@ abstract class Order_Document {
|
|
335 |
$document_number = null;
|
336 |
} elseif ( is_array( $value ) ) {
|
337 |
// WCPDF 2.0 number data
|
338 |
-
$document_number = new Document_Number( $value );
|
339 |
} else {
|
340 |
// plain number
|
341 |
$document_number = new Document_Number( $value, $this->get_number_settings(), $this, $order );
|
@@ -520,15 +520,18 @@ abstract class Order_Document {
|
|
520 |
}
|
521 |
|
522 |
// clean up special characters
|
523 |
-
|
|
|
|
|
|
|
524 |
do_action( 'wpo_wcpdf_after_html', $this->get_type(), $this );
|
525 |
|
526 |
return apply_filters( 'wpo_wcpdf_get_html', $html, $this );
|
527 |
}
|
528 |
|
529 |
-
public function output_pdf() {
|
530 |
$pdf = $this->get_pdf();
|
531 |
-
wcpdf_pdf_headers( $this->get_filename(),
|
532 |
echo $pdf;
|
533 |
die();
|
534 |
}
|
335 |
$document_number = null;
|
336 |
} elseif ( is_array( $value ) ) {
|
337 |
// WCPDF 2.0 number data
|
338 |
+
$document_number = new Document_Number( $value, $this->get_number_settings(), $this, $order );
|
339 |
} else {
|
340 |
// plain number
|
341 |
$document_number = new Document_Number( $value, $this->get_number_settings(), $this, $order );
|
520 |
}
|
521 |
|
522 |
// clean up special characters
|
523 |
+
if ( function_exists('utf8_decode') && function_exists('mb_convert_encoding') ) {
|
524 |
+
$html = utf8_decode(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
525 |
+
}
|
526 |
+
|
527 |
do_action( 'wpo_wcpdf_after_html', $this->get_type(), $this );
|
528 |
|
529 |
return apply_filters( 'wpo_wcpdf_get_html', $html, $this );
|
530 |
}
|
531 |
|
532 |
+
public function output_pdf( $output_mode = 'download' ) {
|
533 |
$pdf = $this->get_pdf();
|
534 |
+
wcpdf_pdf_headers( $this->get_filename(), $output_mode, $pdf );
|
535 |
echo $pdf;
|
536 |
die();
|
537 |
}
|
includes/documents/class-wcpdf-bulk-document.php
CHANGED
@@ -89,9 +89,9 @@ class Bulk_Document {
|
|
89 |
return $html;
|
90 |
}
|
91 |
|
92 |
-
public function output_pdf() {
|
93 |
$pdf = $this->get_pdf();
|
94 |
-
wcpdf_pdf_headers( $this->get_filename(),
|
95 |
echo $pdf;
|
96 |
die();
|
97 |
}
|
89 |
return $html;
|
90 |
}
|
91 |
|
92 |
+
public function output_pdf( $output_mode = 'download' ) {
|
93 |
$pdf = $this->get_pdf();
|
94 |
+
wcpdf_pdf_headers( $this->get_filename(), $output_mode, $pdf );
|
95 |
echo $pdf;
|
96 |
die();
|
97 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-
|
|
4 |
Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice, packing slip, export, email, bulk, automatic
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 4.8
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -100,8 +100,20 @@ There's a setting on the Status tab of the settings page that allows you to togg
|
|
100 |
|
101 |
== Changelog ==
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
= 2.0.1 =
|
104 |
-
*
|
|
|
|
|
105 |
* New: Better structured & more advanced settings for documents
|
106 |
* New: Option to enable & disable Packing Slips or Invoices
|
107 |
* New: Invoice number sequence stored separately for improved speed & performance
|
@@ -114,7 +126,6 @@ There's a setting on the Status tab of the settings page that allows you to togg
|
|
114 |
* Fix: Positive prices for refunds
|
115 |
* Fix: Use parent for attributes retrieved for product variations
|
116 |
* Fix: Set content type to PDF for download
|
117 |
-
* Fix: PHP 5.4 issue
|
118 |
|
119 |
= 1.6.6 =
|
120 |
* Feature: Facilitate downgrading from 2.0 (re-installing fonts & resetting version)
|
@@ -561,7 +572,7 @@ There's a setting on the Status tab of the settings page that allows you to togg
|
|
561 |
|
562 |
== Upgrade Notice ==
|
563 |
|
564 |
-
= 2.0.
|
565 |
**2.0 is a BIG update! Make a full site backup before upgrading!**
|
566 |
|
567 |
= 1.6.6 =
|
4 |
Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice, packing slip, export, email, bulk, automatic
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 4.8
|
7 |
+
Stable tag: 2.0.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
100 |
|
101 |
== Changelog ==
|
102 |
|
103 |
+
**2.0 is a BIG update! Make a full site backup before upgrading**
|
104 |
+
|
105 |
+
= 2.0.2 =
|
106 |
+
* Fix: order notes using correct order_id
|
107 |
+
* Fix: WC3.0 deprecation notice for currency
|
108 |
+
* Fix: Avoid crashing on PHP5.2 and older
|
109 |
+
* Fix: Only use PHP MB String when present
|
110 |
+
* Fix: Remote images
|
111 |
+
* Fix: Download option
|
112 |
+
|
113 |
= 2.0.1 =
|
114 |
+
* Fix: PHP 5.4 issue
|
115 |
+
|
116 |
+
= 2.0.0 =
|
117 |
* New: Better structured & more advanced settings for documents
|
118 |
* New: Option to enable & disable Packing Slips or Invoices
|
119 |
* New: Invoice number sequence stored separately for improved speed & performance
|
126 |
* Fix: Positive prices for refunds
|
127 |
* Fix: Use parent for attributes retrieved for product variations
|
128 |
* Fix: Set content type to PDF for download
|
|
|
129 |
|
130 |
= 1.6.6 =
|
131 |
* Feature: Facilitate downgrading from 2.0 (re-installing fonts & resetting version)
|
572 |
|
573 |
== Upgrade Notice ==
|
574 |
|
575 |
+
= 2.0.2 =
|
576 |
**2.0 is a BIG update! Make a full site backup before upgrading!**
|
577 |
|
578 |
= 1.6.6 =
|
woocommerce-pdf-invoices-packingslips.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WooCommerce PDF Invoices & Packing Slips
|
4 |
* Plugin URI: http://www.wpovernight.com
|
5 |
* Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
|
6 |
-
* Version: 2.0.
|
7 |
* Author: Ewout Fernhout
|
8 |
* Author URI: http://www.wpovernight.com
|
9 |
* License: GPLv2 or later
|
@@ -19,7 +19,7 @@ if ( !class_exists( 'WPO_WCPDF' ) ) :
|
|
19 |
|
20 |
class WPO_WCPDF {
|
21 |
|
22 |
-
public $version = '2.0.
|
23 |
public $plugin_basename;
|
24 |
public $legacy_mode;
|
25 |
|
@@ -50,11 +50,6 @@ class WPO_WCPDF {
|
|
50 |
add_filter( 'load_textdomain_mofile', array( $this, 'textdomain_fallback' ), 10, 2 );
|
51 |
add_action( 'plugins_loaded', array( $this, 'load_classes' ), 9 );
|
52 |
add_action( 'in_plugin_update_message-'.$this->plugin_basename, array( $this, 'in_plugin_update_message' ) );
|
53 |
-
|
54 |
-
// run lifecycle methods
|
55 |
-
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
56 |
-
add_action( 'wp_loaded', array( $this, 'do_install' ) );
|
57 |
-
}
|
58 |
}
|
59 |
|
60 |
/**
|
@@ -168,6 +163,7 @@ class WPO_WCPDF {
|
|
168 |
include_once( $this->plugin_path() . '/includes/class-wcpdf-assets.php' );
|
169 |
include_once( $this->plugin_path() . '/includes/class-wcpdf-admin.php' );
|
170 |
include_once( $this->plugin_path() . '/includes/class-wcpdf-frontend.php' );
|
|
|
171 |
|
172 |
// Backwards compatibility with self
|
173 |
include_once( $this->plugin_path() . '/includes/legacy/class-wcpdf-legacy.php' );
|
@@ -245,278 +241,6 @@ class WPO_WCPDF {
|
|
245 |
echo $message;
|
246 |
}
|
247 |
|
248 |
-
/** Lifecycle methods *******************************************************
|
249 |
-
* Because register_activation_hook only runs when the plugin is manually
|
250 |
-
* activated by the user, we're checking the current version against the
|
251 |
-
* version stored in the database
|
252 |
-
****************************************************************************/
|
253 |
-
|
254 |
-
/**
|
255 |
-
* Handles version checking
|
256 |
-
*/
|
257 |
-
public function do_install() {
|
258 |
-
// only install when woocommerce is active
|
259 |
-
if ( !$this->is_woocommerce_activated() ) {
|
260 |
-
return;
|
261 |
-
}
|
262 |
-
|
263 |
-
$version_setting = 'wpo_wcpdf_version';
|
264 |
-
$installed_version = get_option( $version_setting );
|
265 |
-
|
266 |
-
// installed version lower than plugin version?
|
267 |
-
if ( version_compare( $installed_version, WPO_WCPDF_VERSION, '<' ) ) {
|
268 |
-
|
269 |
-
if ( ! $installed_version ) {
|
270 |
-
$this->install();
|
271 |
-
} else {
|
272 |
-
$this->upgrade( $installed_version );
|
273 |
-
}
|
274 |
-
|
275 |
-
// new version number
|
276 |
-
update_option( $version_setting, WPO_WCPDF_VERSION );
|
277 |
-
} elseif ( $installed_version && version_compare( $installed_version, WPO_WCPDF_VERSION, '>' ) ) {
|
278 |
-
$this->downgrade( $installed_version );
|
279 |
-
// downgrade version number
|
280 |
-
update_option( $version_setting, WPO_WCPDF_VERSION );
|
281 |
-
}
|
282 |
-
}
|
283 |
-
|
284 |
-
|
285 |
-
/**
|
286 |
-
* Plugin install method. Perform any installation tasks here
|
287 |
-
*/
|
288 |
-
protected function install() {
|
289 |
-
// check if upgrading from versionless (1.4.14 and older)
|
290 |
-
if ( get_option('wpo_wcpdf_general_settings') ) {
|
291 |
-
$this->upgrade( 'versionless' );
|
292 |
-
return;
|
293 |
-
}
|
294 |
-
|
295 |
-
// Create temp folders
|
296 |
-
$tmp_base = $this->main->get_tmp_base();
|
297 |
-
|
298 |
-
// check if tmp folder exists => if not, initialize
|
299 |
-
if ( !@is_dir( $tmp_base ) ) {
|
300 |
-
$this->main->init_tmp( $tmp_base );
|
301 |
-
}
|
302 |
-
|
303 |
-
// set default settings
|
304 |
-
$settings_defaults = array(
|
305 |
-
'wpo_wcpdf_settings_general' => array(
|
306 |
-
'download_display' => 'display',
|
307 |
-
'template_path' => WPO_WCPDF()->plugin_path() . '/templates/Simple',
|
308 |
-
// 'currency_font' => '',
|
309 |
-
'paper_size' => 'a4',
|
310 |
-
// 'header_logo' => '',
|
311 |
-
// 'shop_name' => array(),
|
312 |
-
// 'shop_address' => array(),
|
313 |
-
// 'footer' => array(),
|
314 |
-
// 'extra_1' => array(),
|
315 |
-
// 'extra_2' => array(),
|
316 |
-
// 'extra_3' => array(),
|
317 |
-
),
|
318 |
-
'wpo_wcpdf_documents_settings_invoice' => array(
|
319 |
-
'enabled' => 1,
|
320 |
-
// 'attach_to_email_ids' => array(),
|
321 |
-
// 'display_shipping_address' => '',
|
322 |
-
// 'display_email' => '',
|
323 |
-
// 'display_phone' => '',
|
324 |
-
// 'display_date' => '',
|
325 |
-
// 'display_number' => '',
|
326 |
-
// 'number_format' => array(),
|
327 |
-
// 'reset_number_yearly' => '',
|
328 |
-
// 'my_account_buttons' => '',
|
329 |
-
// 'invoice_number_column' => '',
|
330 |
-
// 'disable_free' => '',
|
331 |
-
),
|
332 |
-
'wpo_wcpdf_documents_settings_packing-slip' => array(
|
333 |
-
'enabled' => 1,
|
334 |
-
// 'display_billing_address' => '',
|
335 |
-
// 'display_email' => '',
|
336 |
-
// 'display_phone' => '',
|
337 |
-
),
|
338 |
-
// 'wpo_wcpdf_settings_debug' => array(
|
339 |
-
// 'legacy_mode' => '',
|
340 |
-
// 'enable_debug' => '',
|
341 |
-
// 'html_output' => '',
|
342 |
-
// ),
|
343 |
-
);
|
344 |
-
foreach ($settings_defaults as $option => $defaults) {
|
345 |
-
update_option( $option, $defaults );
|
346 |
-
}
|
347 |
-
}
|
348 |
-
|
349 |
-
/**
|
350 |
-
* Plugin upgrade method. Perform any required upgrades here
|
351 |
-
*
|
352 |
-
* @param string $installed_version the currently installed ('old') version
|
353 |
-
*/
|
354 |
-
protected function upgrade( $installed_version ) {
|
355 |
-
// sync fonts on every upgrade!
|
356 |
-
$tmp_base = $this->main->get_tmp_base();
|
357 |
-
|
358 |
-
// check if tmp folder exists => if not, initialize
|
359 |
-
if ( !@is_dir( $tmp_base ) ) {
|
360 |
-
$this->main->init_tmp( $tmp_base );
|
361 |
-
} else {
|
362 |
-
$font_path = $this->main->get_tmp_path( 'fonts' );
|
363 |
-
$this->main->copy_fonts( $font_path );
|
364 |
-
}
|
365 |
-
|
366 |
-
// 1.5.28 update: copy next invoice number to separate setting
|
367 |
-
if ( $installed_version == 'versionless' || version_compare( $installed_version, '1.5.28', '<' ) ) {
|
368 |
-
$template_settings = get_option( 'wpo_wcpdf_template_settings' );
|
369 |
-
$next_invoice_number = isset($template_settings['next_invoice_number'])?$template_settings['next_invoice_number']:'';
|
370 |
-
update_option( 'wpo_wcpdf_next_invoice_number', $next_invoice_number );
|
371 |
-
}
|
372 |
-
|
373 |
-
// 2.0-dev update: reorganize settings
|
374 |
-
if ( $installed_version == 'versionless' || version_compare( $installed_version, '2.0-dev', '<' ) ) {
|
375 |
-
$old_settings = array(
|
376 |
-
'wpo_wcpdf_general_settings' => get_option( 'wpo_wcpdf_general_settings' ),
|
377 |
-
'wpo_wcpdf_template_settings' => get_option( 'wpo_wcpdf_template_settings' ),
|
378 |
-
'wpo_wcpdf_debug_settings' => get_option( 'wpo_wcpdf_debug_settings' ),
|
379 |
-
);
|
380 |
-
|
381 |
-
// combine invoice number formatting in array
|
382 |
-
$old_settings['wpo_wcpdf_template_settings']['invoice_number_formatting'] = array();
|
383 |
-
$format_option_keys = array('padding','suffix','prefix');
|
384 |
-
foreach ($format_option_keys as $format_option_key) {
|
385 |
-
if (isset($old_settings['wpo_wcpdf_template_settings']["invoice_number_formatting_{$format_option_key}"])) {
|
386 |
-
$old_settings['wpo_wcpdf_template_settings']['invoice_number_formatting'][$format_option_key] = $old_settings['wpo_wcpdf_template_settings']["invoice_number_formatting_{$format_option_key}"];
|
387 |
-
}
|
388 |
-
}
|
389 |
-
|
390 |
-
// convert abbreviated email_ids
|
391 |
-
if (isset($old_settings['wpo_wcpdf_general_settings']['email_pdf'])) {
|
392 |
-
foreach ($old_settings['wpo_wcpdf_general_settings']['email_pdf'] as $email_id => $value) {
|
393 |
-
if ($email_id == 'completed' || $email_id == 'processing') {
|
394 |
-
$old_settings['wpo_wcpdf_general_settings']['email_pdf']["customer_{$email_id}_order"] = $value;
|
395 |
-
unset($old_settings['wpo_wcpdf_general_settings']['email_pdf'][$email_id]);
|
396 |
-
}
|
397 |
-
}
|
398 |
-
}
|
399 |
-
|
400 |
-
// Migrate template path
|
401 |
-
// forward slash for consistency/compatibility
|
402 |
-
$template_path = str_replace('\\','/', $old_settings['wpo_wcpdf_template_settings']['template_path']);
|
403 |
-
// strip abspath (forward slashed) if included
|
404 |
-
$template_path = str_replace( str_replace('\\','/', ABSPATH), '', $template_path );
|
405 |
-
// strip pdf subfolder from templates path
|
406 |
-
$template_path = str_replace( '/templates/pdf/', '/templates/', $template_path );
|
407 |
-
$old_settings['wpo_wcpdf_template_settings']['template_path'] = $template_path;
|
408 |
-
|
409 |
-
// map new settings to old
|
410 |
-
$settings_map = array(
|
411 |
-
'wpo_wcpdf_settings_general' => array(
|
412 |
-
'download_display' => array( 'wpo_wcpdf_general_settings' => 'download_display' ),
|
413 |
-
'template_path' => array( 'wpo_wcpdf_template_settings' => 'template_path' ),
|
414 |
-
'currency_font' => array( 'wpo_wcpdf_template_settings' => 'currency_font' ),
|
415 |
-
'paper_size' => array( 'wpo_wcpdf_template_settings' => 'paper_size' ),
|
416 |
-
'header_logo' => array( 'wpo_wcpdf_template_settings' => 'header_logo' ),
|
417 |
-
'shop_name' => array( 'wpo_wcpdf_template_settings' => 'shop_name' ),
|
418 |
-
'shop_address' => array( 'wpo_wcpdf_template_settings' => 'shop_address' ),
|
419 |
-
'footer' => array( 'wpo_wcpdf_template_settings' => 'footer' ),
|
420 |
-
'extra_1' => array( 'wpo_wcpdf_template_settings' => 'extra_1' ),
|
421 |
-
'extra_2' => array( 'wpo_wcpdf_template_settings' => 'extra_2' ),
|
422 |
-
'extra_3' => array( 'wpo_wcpdf_template_settings' => 'extra_3' ),
|
423 |
-
),
|
424 |
-
'wpo_wcpdf_documents_settings_invoice' => array(
|
425 |
-
'attach_to_email_ids' => array( 'wpo_wcpdf_general_settings' => 'email_pdf' ),
|
426 |
-
'display_shipping_address' => array( 'wpo_wcpdf_template_settings' => 'invoice_shipping_address' ),
|
427 |
-
'display_email' => array( 'wpo_wcpdf_template_settings' => 'invoice_email' ),
|
428 |
-
'display_phone' => array( 'wpo_wcpdf_template_settings' => 'invoice_phone' ),
|
429 |
-
'display_date' => array( 'wpo_wcpdf_template_settings' => 'display_date' ),
|
430 |
-
'display_number' => array( 'wpo_wcpdf_template_settings' => 'display_number' ),
|
431 |
-
'number_format' => array( 'wpo_wcpdf_template_settings' => 'invoice_number_formatting' ),
|
432 |
-
'reset_number_yearly' => array( 'wpo_wcpdf_template_settings' => 'yearly_reset_invoice_number' ),
|
433 |
-
'my_account_buttons' => array( 'wpo_wcpdf_general_settings' => 'my_account_buttons' ),
|
434 |
-
'invoice_number_column' => array( 'wpo_wcpdf_general_settings' => 'invoice_number_column' ),
|
435 |
-
'disable_free' => array( 'wpo_wcpdf_general_settings' => 'disable_free' ),
|
436 |
-
),
|
437 |
-
'wpo_wcpdf_documents_settings_packing-slip' => array(
|
438 |
-
'display_billing_address' => array( 'wpo_wcpdf_template_settings' => 'packing_slip_billing_address' ),
|
439 |
-
'display_email' => array( 'wpo_wcpdf_template_settings' => 'packing_slip_email' ),
|
440 |
-
'display_phone' => array( 'wpo_wcpdf_template_settings' => 'packing_slip_phone' ),
|
441 |
-
),
|
442 |
-
'wpo_wcpdf_settings_debug' => array(
|
443 |
-
'enable_debug' => array( 'wpo_wcpdf_debug_settings' => 'enable_debug' ),
|
444 |
-
'html_output' => array( 'wpo_wcpdf_debug_settings' => 'html_output' ),
|
445 |
-
),
|
446 |
-
);
|
447 |
-
|
448 |
-
// walk through map
|
449 |
-
foreach ($settings_map as $new_option => $new_settings_keys) {
|
450 |
-
${$new_option} = array();
|
451 |
-
foreach ($new_settings_keys as $new_key => $old_setting ) {
|
452 |
-
$old_key = reset($old_setting);
|
453 |
-
$old_option = key($old_setting);
|
454 |
-
if (!empty($old_settings[$old_option][$old_key])) {
|
455 |
-
// turn translatable fields into array
|
456 |
-
$translatable_fields = array('shop_name','shop_address','footer','extra_1','extra_2','extra_3');
|
457 |
-
if (in_array($new_key, $translatable_fields)) {
|
458 |
-
${$new_option}[$new_key] = array( 'default' => $old_settings[$old_option][$old_key] );
|
459 |
-
} else {
|
460 |
-
${$new_option}[$new_key] = $old_settings[$old_option][$old_key];
|
461 |
-
}
|
462 |
-
}
|
463 |
-
}
|
464 |
-
|
465 |
-
// auto enable invoice & packing slip
|
466 |
-
$enabled = array( 'wpo_wcpdf_documents_settings_invoice', 'wpo_wcpdf_documents_settings_packing-slip' );
|
467 |
-
if ( in_array( $new_option, $enabled ) ) {
|
468 |
-
${$new_option}['enabled'] = 1;
|
469 |
-
}
|
470 |
-
|
471 |
-
// auto enable legacy mode
|
472 |
-
if ( $new_option == 'wpo_wcpdf_settings_debug' ) {
|
473 |
-
${$new_option}['legacy_mode'] = 1;
|
474 |
-
}
|
475 |
-
|
476 |
-
// merge with existing settings
|
477 |
-
${$new_option."_old"} = get_option( $new_option, ${$new_option} ); // second argument loads new as default in case the settings did not exist yet
|
478 |
-
${$new_option} = ${$new_option} + ${$new_option."_old"}; // duplicate options take new options as default
|
479 |
-
|
480 |
-
// store new option values
|
481 |
-
update_option( $new_option, ${$new_option} );
|
482 |
-
}
|
483 |
-
}
|
484 |
-
|
485 |
-
// 2.0-beta-2 update: copy next number to separate db store
|
486 |
-
if ( version_compare( $installed_version, '2.0-beta-2', '<' ) ) {
|
487 |
-
// load number store class (just in case)
|
488 |
-
include_once( WPO_WCPDF()->plugin_path() . '/includes/documents/class-wcpdf-sequential-number-store.php' );
|
489 |
-
|
490 |
-
$next_number = get_option( 'wpo_wcpdf_next_invoice_number' );
|
491 |
-
if (!empty($next_number)) {
|
492 |
-
$number_store = new \WPO\WC\PDF_Invoices\Documents\Sequential_Number_Store( 'invoice_number' );
|
493 |
-
$number_store->set_next( (int) $next_number );
|
494 |
-
}
|
495 |
-
// we're not deleting this option yet to make downgrading possible
|
496 |
-
// delete_option( 'wpo_wcpdf_next_invoice_number' ); // clean up after ourselves
|
497 |
-
}
|
498 |
-
|
499 |
-
}
|
500 |
-
|
501 |
-
/**
|
502 |
-
* Plugin downgrade method. Perform any required downgrades here
|
503 |
-
*
|
504 |
-
*
|
505 |
-
* @param string $installed_version the currently installed ('old') version (actually higher since this is a downgrade)
|
506 |
-
*/
|
507 |
-
protected function downgrade( $installed_version ) {
|
508 |
-
// make sure fonts match with version: copy from plugin folder
|
509 |
-
$tmp_base = $this->main->get_tmp_base();
|
510 |
-
|
511 |
-
// check if tmp folder exists => if not, initialize
|
512 |
-
if ( !@is_dir( $tmp_base ) ) {
|
513 |
-
$this->main->init_tmp( $tmp_base );
|
514 |
-
} else {
|
515 |
-
$font_path = $this->main->get_tmp_path( 'fonts' );
|
516 |
-
$this->main->copy_fonts( $font_path );
|
517 |
-
}
|
518 |
-
}
|
519 |
-
|
520 |
/**
|
521 |
* Show plugin changes. Code adapted from W3 Total Cache.
|
522 |
*/
|
3 |
* Plugin Name: WooCommerce PDF Invoices & Packing Slips
|
4 |
* Plugin URI: http://www.wpovernight.com
|
5 |
* Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
|
6 |
+
* Version: 2.0.2
|
7 |
* Author: Ewout Fernhout
|
8 |
* Author URI: http://www.wpovernight.com
|
9 |
* License: GPLv2 or later
|
19 |
|
20 |
class WPO_WCPDF {
|
21 |
|
22 |
+
public $version = '2.0.2';
|
23 |
public $plugin_basename;
|
24 |
public $legacy_mode;
|
25 |
|
50 |
add_filter( 'load_textdomain_mofile', array( $this, 'textdomain_fallback' ), 10, 2 );
|
51 |
add_action( 'plugins_loaded', array( $this, 'load_classes' ), 9 );
|
52 |
add_action( 'in_plugin_update_message-'.$this->plugin_basename, array( $this, 'in_plugin_update_message' ) );
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
|
55 |
/**
|
163 |
include_once( $this->plugin_path() . '/includes/class-wcpdf-assets.php' );
|
164 |
include_once( $this->plugin_path() . '/includes/class-wcpdf-admin.php' );
|
165 |
include_once( $this->plugin_path() . '/includes/class-wcpdf-frontend.php' );
|
166 |
+
include_once( $this->plugin_path() . '/includes/class-wcpdf-install.php' );
|
167 |
|
168 |
// Backwards compatibility with self
|
169 |
include_once( $this->plugin_path() . '/includes/legacy/class-wcpdf-legacy.php' );
|
241 |
echo $message;
|
242 |
}
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
/**
|
245 |
* Show plugin changes. Code adapted from W3 Total Cache.
|
246 |
*/
|