Version Description
January 30, 2017 =
Improved:
bewpi-install-date
option name by renaming it tobewpi_install_date
.Improved:
_bewpi_on_plugin_update
function to use less database calls and memory. Allocate at least 256MB in order to update to version 2.6+.
Download this release
Release Info
Developer | baaaaas |
Plugin | WooCommerce PDF Invoices |
Version | 2.6.1 |
Comparing to | |
See all releases |
Code changes from version 2.6.0 to 2.6.1
- bootstrap.php +62 -79
- includes/admin/class-bewpi-admin-notices.php +4 -5
- readme.txt +6 -1
bootstrap.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WooCommerce PDF Invoices
|
4 |
* Plugin URI: https://wordpress.org/plugins/woocommerce-pdf-invoices
|
5 |
* Description: Automatically generate and attach customizable PDF Invoices to WooCommerce emails and connect with Dropbox, Google Drive, OneDrive or Egnyte.
|
6 |
-
* Version: 2.6.
|
7 |
* Author: Bas Elbers
|
8 |
* Author URI: http://wcpdfinvoices.com
|
9 |
* License: GPL-2.0+
|
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
16 |
exit;
|
17 |
}
|
18 |
|
19 |
-
define( 'BEWPI_VERSION', '2.6.
|
20 |
|
21 |
/**
|
22 |
* Load WooCommerce PDF Invoices plugin.
|
@@ -41,14 +41,9 @@ add_action( 'plugins_loaded', '_bewpi_load_plugin', 10 );
|
|
41 |
function _bewpi_on_plugin_update() {
|
42 |
if ( get_site_option( 'bewpi_version' ) !== BEWPI_VERSION ) {
|
43 |
|
44 |
-
// update attach to email options.
|
45 |
update_email_type_options();
|
46 |
|
47 |
-
|
48 |
-
create_pdf_path_postmeta();
|
49 |
-
|
50 |
-
// format date postmeta to mysql date.
|
51 |
-
update_date_format_postmeta();
|
52 |
|
53 |
update_site_option( 'bewpi_version', BEWPI_VERSION );
|
54 |
}
|
@@ -88,97 +83,86 @@ function update_email_type_options() {
|
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
-
*
|
92 |
-
*
|
93 |
-
* @since 2.6.0
|
94 |
*/
|
95 |
-
function
|
96 |
-
$template_options = get_option( 'bewpi_template_settings' );
|
97 |
$posts = get_posts( array(
|
98 |
'numberposts' => -1,
|
99 |
'post_type' => 'shop_order',
|
100 |
'post_status' => array_keys( wc_get_order_statuses() ),
|
|
|
101 |
) );
|
102 |
|
103 |
-
|
104 |
-
$pdf_path = get_post_meta( $post->ID, '_bewpi_invoice_pdf_path', true );
|
105 |
-
if ( $pdf_path ) {
|
106 |
-
continue;
|
107 |
-
}
|
108 |
-
|
109 |
-
$invoice_number = get_post_meta( $post->ID, '_bewpi_invoice_number', true );
|
110 |
-
if ( ! $invoice_number ) {
|
111 |
-
continue;
|
112 |
-
}
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
array(
|
123 |
-
$template_options['bewpi_invoice_number_prefix'],
|
124 |
-
$template_options['bewpi_invoice_number_suffix'],
|
125 |
-
$digitized_invoice_number,
|
126 |
-
date_i18n( $date_format, strtotime( $post->post_date ) ),
|
127 |
-
$post->ID,
|
128 |
-
date_i18n( 'Y', strtotime( $post->post_date ) ),
|
129 |
-
date_i18n( 'y', strtotime( $post->post_date ) ),
|
130 |
-
date_i18n( 'm', strtotime( $post->post_date ) ),
|
131 |
-
),
|
132 |
-
$template_options['bewpi_invoice_number_format']
|
133 |
-
);
|
134 |
-
|
135 |
-
// one folder for all invoices.
|
136 |
-
$new_pdf_path = $formatted_invoice_number . '.pdf';
|
137 |
-
if ( (bool) $template_options['bewpi_reset_counter_yearly'] ) {
|
138 |
-
// yearly sub-folders.
|
139 |
-
$invoice_year = get_post_meta( $post->ID, '_bewpi_invoice_year', true );
|
140 |
-
if ( $invoice_year ) {
|
141 |
-
$new_pdf_path = $invoice_year . '/' . $formatted_invoice_number . '.pdf';
|
142 |
-
}
|
143 |
-
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
}
|
148 |
}
|
149 |
}
|
150 |
|
151 |
/**
|
152 |
-
*
|
|
|
|
|
|
|
153 |
*
|
154 |
* @since 2.6.0
|
155 |
*/
|
156 |
-
function
|
157 |
-
$
|
158 |
-
$
|
159 |
-
|
160 |
-
|
161 |
-
'post_status' => array_keys( wc_get_order_statuses() ),
|
162 |
-
) );
|
163 |
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
}
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
|
|
173 |
}
|
|
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
-
|
|
|
|
|
181 |
}
|
|
|
|
|
182 |
}
|
183 |
|
184 |
/**
|
@@ -187,9 +171,8 @@ function update_date_format_postmeta() {
|
|
187 |
* @since 2.5.0
|
188 |
*/
|
189 |
function _bewpi_on_plugin_activation() {
|
190 |
-
// save install
|
191 |
-
|
192 |
-
update_site_option( 'bewpi-install-date', $now->format( 'Y-m-d' ) );
|
193 |
|
194 |
// use transient to display activation admin notice.
|
195 |
set_transient( 'bewpi-admin-notice-activation', true, 30 );
|
3 |
* Plugin Name: WooCommerce PDF Invoices
|
4 |
* Plugin URI: https://wordpress.org/plugins/woocommerce-pdf-invoices
|
5 |
* Description: Automatically generate and attach customizable PDF Invoices to WooCommerce emails and connect with Dropbox, Google Drive, OneDrive or Egnyte.
|
6 |
+
* Version: 2.6.1
|
7 |
* Author: Bas Elbers
|
8 |
* Author URI: http://wcpdfinvoices.com
|
9 |
* License: GPL-2.0+
|
16 |
exit;
|
17 |
}
|
18 |
|
19 |
+
define( 'BEWPI_VERSION', '2.6.1' );
|
20 |
|
21 |
/**
|
22 |
* Load WooCommerce PDF Invoices plugin.
|
41 |
function _bewpi_on_plugin_update() {
|
42 |
if ( get_site_option( 'bewpi_version' ) !== BEWPI_VERSION ) {
|
43 |
|
|
|
44 |
update_email_type_options();
|
45 |
|
46 |
+
update_postmeta();
|
|
|
|
|
|
|
|
|
47 |
|
48 |
update_site_option( 'bewpi_version', BEWPI_VERSION );
|
49 |
}
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
+
* Update postmeta in database.
|
|
|
|
|
87 |
*/
|
88 |
+
function update_postmeta() {
|
|
|
89 |
$posts = get_posts( array(
|
90 |
'numberposts' => -1,
|
91 |
'post_type' => 'shop_order',
|
92 |
'post_status' => array_keys( wc_get_order_statuses() ),
|
93 |
+
'fields' => 'ids',
|
94 |
) );
|
95 |
|
96 |
+
$template_options = get_option( 'bewpi_template_settings' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
+
$date_format = $template_options['bewpi_date_format'];
|
99 |
+
if ( empty( $date_format ) ) {
|
100 |
+
$date_format = (string) get_option( 'date_format' );
|
101 |
+
}
|
102 |
|
103 |
+
foreach ( $posts as $post_id ) {
|
104 |
+
// create pdf path postmeta for all shop orders.
|
105 |
+
create_pdf_path_postmeta( $post_id, $template_options );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
+
// format date postmeta to mysql date.
|
108 |
+
update_date_format_postmeta( $post_id, $date_format );
|
|
|
109 |
}
|
110 |
}
|
111 |
|
112 |
/**
|
113 |
+
* Create full path postmeta for all orders that have a pdf invoice generated.
|
114 |
+
*
|
115 |
+
* @param int $post_id Post ID or WC Order ID.
|
116 |
+
* @param array $template_options User template options.
|
117 |
*
|
118 |
* @since 2.6.0
|
119 |
*/
|
120 |
+
function create_pdf_path_postmeta( $post_id, $template_options ) {
|
121 |
+
$pdf_path = get_post_meta( $post_id, '_bewpi_invoice_pdf_path', true );
|
122 |
+
if ( $pdf_path ) {
|
123 |
+
return;
|
124 |
+
}
|
|
|
|
|
125 |
|
126 |
+
$formatted_invoice_number = get_post_meta( $post_id, '_bewpi_formatted_invoice_number', true );
|
127 |
+
if ( ! $formatted_invoice_number ) {
|
128 |
+
return;
|
129 |
+
}
|
|
|
130 |
|
131 |
+
// one folder for all invoices.
|
132 |
+
$new_pdf_path = $formatted_invoice_number . '.pdf';
|
133 |
+
if ( (bool) $template_options['bewpi_reset_counter_yearly'] ) {
|
134 |
+
// yearly sub-folders.
|
135 |
+
$invoice_year = get_post_meta( $post_id, '_bewpi_invoice_year', true );
|
136 |
+
if ( $invoice_year ) {
|
137 |
+
$new_pdf_path = $invoice_year . '/' . $formatted_invoice_number . '.pdf';
|
138 |
}
|
139 |
+
}
|
140 |
|
141 |
+
if ( file_exists( BEWPI_INVOICES_DIR . $new_pdf_path ) ) {
|
142 |
+
update_post_meta( $post_id, '_bewpi_invoice_pdf_path', $new_pdf_path );
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Format date postmeta to mysql date.
|
148 |
+
*
|
149 |
+
* @param int $post_id Post ID or WC Order ID.
|
150 |
+
* @param string $date_format User option date format.
|
151 |
+
*
|
152 |
+
* @since 2.6.0
|
153 |
+
*/
|
154 |
+
function update_date_format_postmeta( $post_id, $date_format ) {
|
155 |
+
$invoice_date = get_post_meta( $post_id, '_bewpi_invoice_date', true );
|
156 |
+
if ( ! $invoice_date ) {
|
157 |
+
return;
|
158 |
+
}
|
159 |
|
160 |
+
$date = DateTime::createFromFormat( $date_format, $invoice_date );
|
161 |
+
if ( ! $date ) {
|
162 |
+
return;
|
163 |
}
|
164 |
+
|
165 |
+
update_post_meta( $post_id, '_bewpi_invoice_date', $date->format( 'Y-m-d H:i:s' ) );
|
166 |
}
|
167 |
|
168 |
/**
|
171 |
* @since 2.5.0
|
172 |
*/
|
173 |
function _bewpi_on_plugin_activation() {
|
174 |
+
// save install datetime for plugin activation admin notice.
|
175 |
+
update_site_option( 'bewpi_install_date', current_time( 'mysql' ) );
|
|
|
176 |
|
177 |
// use transient to display activation admin notice.
|
178 |
set_transient( 'bewpi-admin-notice-activation', true, 30 );
|
includes/admin/class-bewpi-admin-notices.php
CHANGED
@@ -78,13 +78,12 @@ class BEWPI_Admin_Notices {
|
|
78 |
* @return DateTime|bool
|
79 |
*/
|
80 |
private static function get_install_date() {
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
$install_date = DateTime::createFromFormat( 'Y-m-d', $install_date );
|
85 |
}
|
86 |
|
87 |
-
return
|
88 |
}
|
89 |
|
90 |
/**
|
78 |
* @return DateTime|bool
|
79 |
*/
|
80 |
private static function get_install_date() {
|
81 |
+
if ( version_compare( BEWPI_VERSION, '2.6.1' ) >= 0 ) {
|
82 |
+
// since 2.6.1+ option name changed and date has mysql format.
|
83 |
+
return DateTime::createFromFormat( 'Y-m-d H:i:s', get_site_option( 'bewpi_install_date' ) );
|
|
|
84 |
}
|
85 |
|
86 |
+
return DateTime::createFromFormat( 'Y-m-d', get_site_option( 'bewpi-install-date' ) );
|
87 |
}
|
88 |
|
89 |
/**
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link:
|
|
4 |
Tags: woocommerce pdf invoices, invoice, generate, pdf, woocommerce, attachment, email, completed order, customer invoice, processing order, attach, automatic, vat, rate, sequential, number
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.7
|
7 |
-
Stable tag: 2.6.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -217,6 +217,11 @@ add_filter( 'bewpi_formatted_invoice_number', 'alter_formatted_invoice_number',
|
|
217 |
|
218 |
== Changelog ==
|
219 |
|
|
|
|
|
|
|
|
|
|
|
220 |
= 2.6.0 - January 29, 2017 =
|
221 |
|
222 |
- Added: 'bewpi_formatted_invoice_number_order_date' filter to change format of order date within formatted invoice number.
|
4 |
Tags: woocommerce pdf invoices, invoice, generate, pdf, woocommerce, attachment, email, completed order, customer invoice, processing order, attach, automatic, vat, rate, sequential, number
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.7
|
7 |
+
Stable tag: 2.6.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
217 |
|
218 |
== Changelog ==
|
219 |
|
220 |
+
= 2.6.1 - January 30, 2017 =
|
221 |
+
|
222 |
+
- Improved: `bewpi-install-date` option name by renaming it to `bewpi_install_date`.
|
223 |
+
- Improved: `_bewpi_on_plugin_update` function to use less database calls and memory. Allocate at least 256MB in order to update to version 2.6+.
|
224 |
+
|
225 |
= 2.6.0 - January 29, 2017 =
|
226 |
|
227 |
- Added: 'bewpi_formatted_invoice_number_order_date' filter to change format of order date within formatted invoice number.
|