Version Description
March 26, 2015 =
Fixed: PHP 5.3+ compatibility
Download this release
Release Info
Developer | baaaaas |
Plugin | WooCommerce PDF Invoices |
Version | 2.0.2 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.0.2
- admin/classes/woocommerce-pdf-invoices.php +11 -9
- admin/classes/wpi-settings.php +1 -1
- admin/classes/wpi-template-settings.php +5 -11
- bootstrap.php +2 -2
- includes/classes/wpi-invoice.php +12 -9
- readme.txt +5 -1
admin/classes/woocommerce-pdf-invoices.php
CHANGED
@@ -14,13 +14,13 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
|
|
14 |
* All general user settings
|
15 |
* @var array
|
16 |
*/
|
17 |
-
public $general_settings
|
18 |
|
19 |
/**
|
20 |
* All template user settings
|
21 |
* @var array
|
22 |
*/
|
23 |
-
public $template_settings
|
24 |
|
25 |
/**
|
26 |
* Constant options key
|
@@ -217,10 +217,11 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
|
|
217 |
* @return string
|
218 |
*/
|
219 |
function add_recipient_to_email_headers($headers, $status) {
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
224 |
$headers .= 'BCC: <' . $email_it_in_account . '>' . "\r\n";
|
225 |
}
|
226 |
}
|
@@ -235,8 +236,9 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
|
|
235 |
* @return array
|
236 |
*/
|
237 |
function attach_invoice_to_email( $attachments, $status, $order ) {
|
238 |
-
|
239 |
-
|
|
|
240 |
|
241 |
$invoice = new WPI_Invoice($order, $this->textdomain);
|
242 |
|
@@ -304,7 +306,7 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
|
|
304 |
* @param $btn_title
|
305 |
* @param array $arr
|
306 |
*/
|
307 |
-
private function show_invoice_button($title, $order_id, $wpi_action, $btn_title, $arr =
|
308 |
$title = __( $title, $this->textdomain );
|
309 |
$href = admin_url() . 'post.php?post=' . $order_id . '&action=edit&wpi_action=' . $wpi_action . '&nonce=' . wp_create_nonce($wpi_action);
|
310 |
$btn_title = __( $btn_title, $this->textdomain );
|
14 |
* All general user settings
|
15 |
* @var array
|
16 |
*/
|
17 |
+
public $general_settings;
|
18 |
|
19 |
/**
|
20 |
* All template user settings
|
21 |
* @var array
|
22 |
*/
|
23 |
+
public $template_settings;
|
24 |
|
25 |
/**
|
26 |
* Constant options key
|
217 |
* @return string
|
218 |
*/
|
219 |
function add_recipient_to_email_headers($headers, $status) {
|
220 |
+
$general_settings = (array) $this->general_settings->settings;
|
221 |
+
if( $status == $general_settings['email_type'] ) {
|
222 |
+
if( $general_settings['email_it_in']
|
223 |
+
&& $general_settings['email_it_in_account'] != "" ) {
|
224 |
+
$email_it_in_account = $general_settings['email_it_in_account'];
|
225 |
$headers .= 'BCC: <' . $email_it_in_account . '>' . "\r\n";
|
226 |
}
|
227 |
}
|
236 |
* @return array
|
237 |
*/
|
238 |
function attach_invoice_to_email( $attachments, $status, $order ) {
|
239 |
+
$general_settings = $this->general_settings->settings;
|
240 |
+
if( $status == $general_settings['email_type']
|
241 |
+
|| $general_settings['new_order'] && $status == "new_order" ) {
|
242 |
|
243 |
$invoice = new WPI_Invoice($order, $this->textdomain);
|
244 |
|
306 |
* @param $btn_title
|
307 |
* @param array $arr
|
308 |
*/
|
309 |
+
private function show_invoice_button($title, $order_id, $wpi_action, $btn_title, $arr = array()) {
|
310 |
$title = __( $title, $this->textdomain );
|
311 |
$href = admin_url() . 'post.php?post=' . $order_id . '&action=edit&wpi_action=' . $wpi_action . '&nonce=' . wp_create_nonce($wpi_action);
|
312 |
$btn_title = __( $btn_title, $this->textdomain );
|
admin/classes/wpi-settings.php
CHANGED
@@ -21,7 +21,7 @@ if ( ! class_exists( 'WPI_Settings' ) ) {
|
|
21 |
* For <textarea>.
|
22 |
* @var array
|
23 |
*/
|
24 |
-
private $allowed_tags =
|
25 |
|
26 |
/**
|
27 |
* Validates an email.
|
21 |
* For <textarea>.
|
22 |
* @var array
|
23 |
*/
|
24 |
+
private $allowed_tags = array('<b>', '<i>', '<br>', '<br/>');
|
25 |
|
26 |
/**
|
27 |
* Validates an email.
|
admin/classes/wpi-template-settings.php
CHANGED
@@ -21,7 +21,7 @@ if ( ! class_exists( 'WPI_Template_Settings' ) ) {
|
|
21 |
* @var array
|
22 |
*/
|
23 |
private $defaults = array(
|
24 |
-
'
|
25 |
'color_theme' => '#11B0E7',
|
26 |
'company_name' => '',
|
27 |
'company_logo' => '',
|
@@ -58,7 +58,6 @@ if ( ! class_exists( 'WPI_Template_Settings' ) ) {
|
|
58 |
*/
|
59 |
private $templates = array(
|
60 |
array(
|
61 |
-
'id' => 1,
|
62 |
'name' => 'Micro',
|
63 |
'filename' => 'invoice-micro.php'
|
64 |
)
|
@@ -91,11 +90,6 @@ if ( ! class_exists( 'WPI_Template_Settings' ) ) {
|
|
91 |
public function load_settings() {
|
92 |
$this->settings = (array)get_option($this->settings_key);
|
93 |
$this->settings = array_merge($this->defaults, $this->settings);
|
94 |
-
|
95 |
-
if ($this->settings['template_id'] != "") {
|
96 |
-
$this->settings['template_filename'] = $this->get_template($this->settings['template_id'])['filename'];
|
97 |
-
}
|
98 |
-
|
99 |
update_option($this->settings_key, $this->settings);
|
100 |
}
|
101 |
|
@@ -106,7 +100,7 @@ if ( ! class_exists( 'WPI_Template_Settings' ) ) {
|
|
106 |
{
|
107 |
register_setting($this->settings_key, $this->settings_key, array(&$this, 'validate'));
|
108 |
add_settings_section('section_template', __('Template Settings', $this->textdomain), '', $this->settings_key);
|
109 |
-
add_settings_field('
|
110 |
add_settings_field('color_theme', __('Color theme', $this->textdomain), array(&$this, 'color_theme_option'), $this->settings_key, 'section_template');
|
111 |
add_settings_field('company_name', __('Company name', $this->textdomain), array(&$this, 'company_name_option'), $this->settings_key, 'section_template');
|
112 |
add_settings_field('company_logo', __('Company logo', $this->textdomain), array(&$this, 'company_logo_option'), $this->settings_key, 'section_template');
|
@@ -140,15 +134,15 @@ if ( ! class_exists( 'WPI_Template_Settings' ) ) {
|
|
140 |
/**
|
141 |
* @param $args
|
142 |
*/
|
143 |
-
public function
|
144 |
{
|
145 |
?>
|
146 |
-
<select id="template-type-option" name="<?php echo $this->settings_key; ?>[
|
147 |
<?php
|
148 |
foreach ($args as $template) {
|
149 |
?>
|
150 |
<option
|
151 |
-
value="<?php echo $template['
|
152 |
<?php
|
153 |
}
|
154 |
?>
|
21 |
* @var array
|
22 |
*/
|
23 |
private $defaults = array(
|
24 |
+
'template' => 'invoice-micro.php',
|
25 |
'color_theme' => '#11B0E7',
|
26 |
'company_name' => '',
|
27 |
'company_logo' => '',
|
58 |
*/
|
59 |
private $templates = array(
|
60 |
array(
|
|
|
61 |
'name' => 'Micro',
|
62 |
'filename' => 'invoice-micro.php'
|
63 |
)
|
90 |
public function load_settings() {
|
91 |
$this->settings = (array)get_option($this->settings_key);
|
92 |
$this->settings = array_merge($this->defaults, $this->settings);
|
|
|
|
|
|
|
|
|
|
|
93 |
update_option($this->settings_key, $this->settings);
|
94 |
}
|
95 |
|
100 |
{
|
101 |
register_setting($this->settings_key, $this->settings_key, array(&$this, 'validate'));
|
102 |
add_settings_section('section_template', __('Template Settings', $this->textdomain), '', $this->settings_key);
|
103 |
+
add_settings_field('template', __('Template', $this->textdomain), array(&$this, 'template_option'), $this->settings_key, 'section_template', $this->templates);
|
104 |
add_settings_field('color_theme', __('Color theme', $this->textdomain), array(&$this, 'color_theme_option'), $this->settings_key, 'section_template');
|
105 |
add_settings_field('company_name', __('Company name', $this->textdomain), array(&$this, 'company_name_option'), $this->settings_key, 'section_template');
|
106 |
add_settings_field('company_logo', __('Company logo', $this->textdomain), array(&$this, 'company_logo_option'), $this->settings_key, 'section_template');
|
134 |
/**
|
135 |
* @param $args
|
136 |
*/
|
137 |
+
public function template_option($args)
|
138 |
{
|
139 |
?>
|
140 |
+
<select id="template-type-option" name="<?php echo $this->settings_key; ?>[template]">
|
141 |
<?php
|
142 |
foreach ($args as $template) {
|
143 |
?>
|
144 |
<option
|
145 |
+
value="<?php echo $template['filename']; ?>" <?php selected($this->settings['template'], $template['filename']); ?>><?php echo $template['name']; ?></option>
|
146 |
<?php
|
147 |
}
|
148 |
?>
|
bootstrap.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* @version 2.0.
|
5 |
* @package WooCommerce PDF Invoices
|
6 |
* @author baaaaas
|
7 |
*
|
@@ -9,7 +9,7 @@
|
|
9 |
* Plugin Name: WooCommerce PDF Invoices
|
10 |
* Plugin URI:
|
11 |
* Description: Generates customized PDF invoices and automatically attaches it to a WooCommerce email type of your choice. Now sending invoices to your Google Drive, Egnyte, Dropbox or OneDrive and it's all FREE!
|
12 |
-
* Version: 2.0.
|
13 |
* Author: baaaaas
|
14 |
* Author URI:
|
15 |
* License: GPL-2.0+
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* @version 2.0.2
|
5 |
* @package WooCommerce PDF Invoices
|
6 |
* @author baaaaas
|
7 |
*
|
9 |
* Plugin Name: WooCommerce PDF Invoices
|
10 |
* Plugin URI:
|
11 |
* Description: Generates customized PDF invoices and automatically attaches it to a WooCommerce email type of your choice. Now sending invoices to your Google Drive, Egnyte, Dropbox or OneDrive and it's all FREE!
|
12 |
+
* Version: 2.0.2
|
13 |
* Author: baaaaas
|
14 |
* Author URI:
|
15 |
* License: GPL-2.0+
|
includes/classes/wpi-invoice.php
CHANGED
@@ -11,9 +11,8 @@ if ( ! class_exists( 'WPI_Invoice' ) ) {
|
|
11 |
*/
|
12 |
class WPI_Invoice {
|
13 |
|
14 |
-
|
15 |
* WooCommerce order
|
16 |
-
* @var string
|
17 |
*/
|
18 |
private $order;
|
19 |
|
@@ -70,7 +69,7 @@ if ( ! class_exists( 'WPI_Invoice' ) ) {
|
|
70 |
* @param string $order
|
71 |
* @param $textdomain
|
72 |
*/
|
73 |
-
public function __construct($order
|
74 |
$this->order = $order;
|
75 |
$this->textdomain = $textdomain;
|
76 |
$this->general_settings = (array)get_option('general_settings');
|
@@ -98,7 +97,8 @@ if ( ! class_exists( 'WPI_Invoice' ) ) {
|
|
98 |
$last_year = $this->template_settings['last_invoiced_year'];
|
99 |
|
100 |
if ( !empty( $last_year ) && is_numeric($last_year)) {
|
101 |
-
$
|
|
|
102 |
if ($last_year < $current_year) {
|
103 |
// Set new year as last invoiced year and reset invoice number
|
104 |
return 1;
|
@@ -212,7 +212,7 @@ if ( ! class_exists( 'WPI_Invoice' ) ) {
|
|
212 |
|
213 |
if( $invoice_number_created ) {
|
214 |
// Set the current year as the last invoiced.
|
215 |
-
$this->template_settings['last_invoiced_year'] =
|
216 |
|
217 |
// Get the new invoice number from db.
|
218 |
$this->number = $this->get_invoice_number();
|
@@ -321,10 +321,13 @@ if ( ! class_exists( 'WPI_Invoice' ) ) {
|
|
321 |
<tbody>
|
322 |
<tr>
|
323 |
<td class="border" colspan="2">
|
324 |
-
<?php echo $this->template_settings['terms'];
|
325 |
-
|
|
|
|
|
|
|
326 |
<p>
|
327 |
-
<strong><?php _e('Customer note', $this->textdomain); ?> </strong><?php echo $
|
328 |
</p>
|
329 |
<?php } ?>
|
330 |
</td>
|
@@ -404,7 +407,7 @@ if ( ! class_exists( 'WPI_Invoice' ) ) {
|
|
404 |
* @return string
|
405 |
*/
|
406 |
private function get_template() {
|
407 |
-
return WPI_TEMPLATES_DIR . $this->template_settings['
|
408 |
}
|
409 |
|
410 |
/**
|
11 |
*/
|
12 |
class WPI_Invoice {
|
13 |
|
14 |
+
/*
|
15 |
* WooCommerce order
|
|
|
16 |
*/
|
17 |
private $order;
|
18 |
|
69 |
* @param string $order
|
70 |
* @param $textdomain
|
71 |
*/
|
72 |
+
public function __construct($order, $textdomain) {
|
73 |
$this->order = $order;
|
74 |
$this->textdomain = $textdomain;
|
75 |
$this->general_settings = (array)get_option('general_settings');
|
97 |
$last_year = $this->template_settings['last_invoiced_year'];
|
98 |
|
99 |
if ( !empty( $last_year ) && is_numeric($last_year)) {
|
100 |
+
$date = getdate();
|
101 |
+
$current_year = $date['year'];
|
102 |
if ($last_year < $current_year) {
|
103 |
// Set new year as last invoiced year and reset invoice number
|
104 |
return 1;
|
212 |
|
213 |
if( $invoice_number_created ) {
|
214 |
// Set the current year as the last invoiced.
|
215 |
+
$this->template_settings['last_invoiced_year'] = date("Y");
|
216 |
|
217 |
// Get the new invoice number from db.
|
218 |
$this->number = $this->get_invoice_number();
|
321 |
<tbody>
|
322 |
<tr>
|
323 |
<td class="border" colspan="2">
|
324 |
+
<?php echo $this->template_settings['terms']; ?>
|
325 |
+
<br/>
|
326 |
+
<?php
|
327 |
+
$customer_order_notes = $this->order->get_customer_order_notes();
|
328 |
+
if ( count( $customer_order_notes ) > 0 ) { ?>
|
329 |
<p>
|
330 |
+
<strong><?php _e('Customer note', $this->textdomain); ?> </strong><?php echo $customer_order_notes[0]->comment_content; ?>
|
331 |
</p>
|
332 |
<?php } ?>
|
333 |
</td>
|
407 |
* @return string
|
408 |
*/
|
409 |
private function get_template() {
|
410 |
+
return WPI_TEMPLATES_DIR . $this->template_settings['template'];
|
411 |
}
|
412 |
|
413 |
/**
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link:
|
|
4 |
Tags: woocommerce pdf invoices, invoice, generate, pdf, woocommerce, attachment, email, completed order, customer invoice, processing order, attach, automatic, vat, rate, sequential, number
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 4.1.1
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -67,6 +67,10 @@ The manual installation method involves downloading our plugin and uploading it
|
|
67 |
|
68 |
== Changelog ==
|
69 |
|
|
|
|
|
|
|
|
|
70 |
= 2.0.1 - March 26, 2015 =
|
71 |
|
72 |
- Fixed: Validation errors
|
4 |
Tags: woocommerce pdf invoices, invoice, generate, pdf, woocommerce, attachment, email, completed order, customer invoice, processing order, attach, automatic, vat, rate, sequential, number
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 4.1.1
|
7 |
+
Stable tag: 2.0.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
67 |
|
68 |
== Changelog ==
|
69 |
|
70 |
+
= 2.0.2 - March 26, 2015 =
|
71 |
+
|
72 |
+
- Fixed: PHP 5.3+ compatibility
|
73 |
+
|
74 |
= 2.0.1 - March 26, 2015 =
|
75 |
|
76 |
- Fixed: Validation errors
|