WooCommerce PDF Invoices - Version 2.3.15

Version Description

  • December 18, 2015 =

  • Added: Shortcode for downloading invoices

  • Added: Option to enable/disable download button on account page

  • Fixed: Invoice number always 1 due to no wp table prefix in query

  • Fixed: Date localization and timestamps

Download this release

Release Info

Developer baaaaas
Plugin Icon 128x128 WooCommerce PDF Invoices
Version 2.3.15
Comparing to
See all releases

Code changes from version 2.3.14 to 2.3.15

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.3.14
7
  * Author: Bas Elbers
8
  * Author URI: http://wcpdfinvoices.com
9
  * License: GPL-2.0+
@@ -19,7 +19,7 @@ function bewpi_plugins_loaded() {
19
 
20
  $wp_upload_dir = wp_upload_dir();
21
 
22
- define( 'BEWPI_VERSION', '2.3.14' );
23
  define( 'BEWPI_URL', plugins_url( '', __FILE__ ) . '/' );
24
  define( 'BEWPI_DIR', plugin_dir_path( __FILE__ ) . '/' );
25
  define( 'BEWPI_TEMPLATES_DIR', plugin_dir_path( __FILE__ ) . 'includes/templates/' );
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.3.15
7
  * Author: Bas Elbers
8
  * Author URI: http://wcpdfinvoices.com
9
  * License: GPL-2.0+
19
 
20
  $wp_upload_dir = wp_upload_dir();
21
 
22
+ define( 'BEWPI_VERSION', '2.3.15' );
23
  define( 'BEWPI_URL', plugins_url( '', __FILE__ ) . '/' );
24
  define( 'BEWPI_DIR', plugin_dir_path( __FILE__ ) . '/' );
25
  define( 'BEWPI_TEMPLATES_DIR', plugin_dir_path( __FILE__ ) . 'includes/templates/' );
includes/abstracts/abstract-bewpi-invoice.php CHANGED
@@ -124,9 +124,9 @@ if ( ! class_exists( 'BEWPI_Abstract_Invoice' ) ) {
124
  // Format number with the number of digits
125
  $digit_str = "%0" . $this->template_options['bewpi_invoice_number_digits'] . "s";
126
  $digitized_invoice_number = sprintf( $digit_str, $this->number );
127
- $year = date('Y');
128
- $y = date('y');
129
- $m = date('m');
130
 
131
  // Format invoice number
132
  $formatted_invoice_number = str_replace(
@@ -143,8 +143,8 @@ if ( ! class_exists( 'BEWPI_Abstract_Invoice' ) ) {
143
  * @return bool|datetime|string
144
  */
145
  public function get_formatted_invoice_date() {
146
- $date_format = $this->template_options['bewpi_date_format'];
147
- return ( !empty( $date_format ) ) ? date_i18n( $date_format, strtotime( date( $date_format ) ) ) : date_i18n( "d-m-Y", strtotime( date( 'd-m-Y' ) ) );
148
  }
149
 
150
  /*
@@ -160,12 +160,12 @@ if ( ! class_exists( 'BEWPI_Abstract_Invoice' ) ) {
160
  }
161
 
162
  $order_date = DateTime::createFromFormat( 'Y-m-d H:i:s', $order_date );
163
- if ( ! empty ( $this->template_options['bewpi_date_format'] ) ) {
164
- $date_format = $this->template_options['bewpi_date_format'];
165
  $formatted_date = $order_date->format( $date_format );
166
  return date_i18n( $date_format, strtotime( $formatted_date ) );
167
  } else {
168
- $formatted_date = $order_date->format( $order_date, "d-m-Y" );
169
  return date_i18n( "d-m-Y", strtotime( $formatted_date ) );
170
  }
171
  }
@@ -211,13 +211,13 @@ if ( ! class_exists( 'BEWPI_Abstract_Invoice' ) ) {
211
  $query = $wpdb->prepare(
212
  "
213
  SELECT max(cast(pm2.meta_value as unsigned)) as last_invoice_number
214
- FROM wp_postmeta pm1 INNER JOIN wp_postmeta pm2 ON pm1.post_id = pm2.post_id
215
  WHERE pm1.meta_key = '%s'
216
  AND pm1.meta_value = %d
217
  AND pm2.meta_key = '%s';
218
  ",
219
  "_bewpi_invoice_year",
220
- (int) date( 'Y' ),
221
  "_bewpi_invoice_number"
222
  );
223
  } else {
@@ -225,7 +225,7 @@ if ( ! class_exists( 'BEWPI_Abstract_Invoice' ) ) {
225
  $query = $wpdb->prepare(
226
  "
227
  SELECT max(cast(pm2.meta_value as unsigned)) as last_invoice_number
228
- FROM wp_postmeta pm1 INNER JOIN wp_postmeta pm2 ON pm1.post_id = pm2.post_id
229
  WHERE pm1.meta_key = '%s' AND pm2.meta_key = '%s';
230
  ",
231
  "_bewpi_invoice_year",
@@ -245,7 +245,7 @@ if ( ! class_exists( 'BEWPI_Abstract_Invoice' ) ) {
245
  $this->number = $this->get_next_invoice_number();
246
  $this->formatted_number = $this->get_formatted_number();
247
  $this->filename = $this->formatted_number . '.pdf';
248
- $this->year = date( 'Y' );
249
  $this->full_path = BEWPI_INVOICES_DIR . (string)$this->year . '/' . $this->filename;
250
 
251
  // check if invoice doesn't already exists in invoice dir
124
  // Format number with the number of digits
125
  $digit_str = "%0" . $this->template_options['bewpi_invoice_number_digits'] . "s";
126
  $digitized_invoice_number = sprintf( $digit_str, $this->number );
127
+ $year = date_i18n( 'Y' );
128
+ $y = date_i18n( 'y' );
129
+ $m = date_i18n( 'm' );
130
 
131
  // Format invoice number
132
  $formatted_invoice_number = str_replace(
143
  * @return bool|datetime|string
144
  */
145
  public function get_formatted_invoice_date() {
146
+ $date_format = $this->template_options[ 'bewpi_date_format' ];
147
+ return ( !empty( $date_format ) ) ? date_i18n( $date_format, current_time( 'timestamp' ) ) : date_i18n( "d-m-Y", current_time( 'timestamp' ) );
148
  }
149
 
150
  /*
160
  }
161
 
162
  $order_date = DateTime::createFromFormat( 'Y-m-d H:i:s', $order_date );
163
+ if ( ! empty ( $this->template_options[ 'bewpi_date_format' ] ) ) {
164
+ $date_format = $this->template_options[ 'bewpi_date_format' ];
165
  $formatted_date = $order_date->format( $date_format );
166
  return date_i18n( $date_format, strtotime( $formatted_date ) );
167
  } else {
168
+ $formatted_date = $order_date->format( 'd-m-Y' );
169
  return date_i18n( "d-m-Y", strtotime( $formatted_date ) );
170
  }
171
  }
211
  $query = $wpdb->prepare(
212
  "
213
  SELECT max(cast(pm2.meta_value as unsigned)) as last_invoice_number
214
+ FROM $wpdb->postmeta pm1 INNER JOIN $wpdb->postmeta pm2 ON pm1.post_id = pm2.post_id
215
  WHERE pm1.meta_key = '%s'
216
  AND pm1.meta_value = %d
217
  AND pm2.meta_key = '%s';
218
  ",
219
  "_bewpi_invoice_year",
220
+ (int) date_i18n( 'Y', current_time( 'timestamp' ) ),
221
  "_bewpi_invoice_number"
222
  );
223
  } else {
225
  $query = $wpdb->prepare(
226
  "
227
  SELECT max(cast(pm2.meta_value as unsigned)) as last_invoice_number
228
+ FROM $wpdb->postmeta pm1 INNER JOIN $wpdb->postmeta pm2 ON pm1.post_id = pm2.post_id
229
  WHERE pm1.meta_key = '%s' AND pm2.meta_key = '%s';
230
  ",
231
  "_bewpi_invoice_year",
245
  $this->number = $this->get_next_invoice_number();
246
  $this->formatted_number = $this->get_formatted_number();
247
  $this->filename = $this->formatted_number . '.pdf';
248
+ $this->year = date_i18n( 'Y', current_time( 'timestamp' ) );
249
  $this->full_path = BEWPI_INVOICES_DIR . (string)$this->year . '/' . $this->filename;
250
 
251
  // check if invoice doesn't already exists in invoice dir
includes/abstracts/abstract-bewpi-setting.php CHANGED
@@ -87,12 +87,15 @@ if ( ! class_exists( 'BEWPI_Abstract_Setting' ) ) {
87
  * @return string|void
88
  */
89
  protected function get_allowed_tags_str() {
90
- ( count( $this->allowed_tags ) > 0 ) ? $str = __( 'Allowed HTML tags: ', 'be-woocommerce-pdf-invoices' ) : $str = '';
91
- foreach ( $this->allowed_tags as $i => $tag ) {
92
- ( $i == count( $this->allowed_tags ) - 1 ) ? $str .= sprintf( '<code>%s</code>.', htmlspecialchars( $tag ) ) : $str .= sprintf( '<code>%s</code> ', htmlspecialchars( $tag ) );
93
  }
94
 
95
- return $str;
 
 
 
96
  }
97
 
98
  public function select_callback( $args ) {
87
  * @return string|void
88
  */
89
  protected function get_allowed_tags_str() {
90
+
91
+ if( empty( $this->allowed_tags ) ) {
92
+ return '';
93
  }
94
 
95
+ $encoded_tags = array_map( 'htmlspecialchars', $this->allowed_tags );
96
+ $tags_string = '<code>' . join( '</code>, <code>', $encoded_tags ) . '</code>';
97
+
98
+ return __( 'Allowed HTML tags: ', 'be-woocommerce-pdf-invoices' ) . $tags_string . '.';
99
  }
100
 
101
  public function select_callback( $args ) {
includes/admin/settings/class-bewpi-admin-settings-general.php CHANGED
@@ -80,27 +80,6 @@ if ( ! class_exists( 'BEWPI_General_Settings' ) ) {
80
  private function the_settings() {
81
  $settings = array(
82
  // General section
83
- array(
84
- 'id' => 'bewpi-view-pdf',
85
- 'name' => $this->prefix . 'view_pdf',
86
- 'title' => __( 'View PDF', 'be-woocommerce-pdf-invoices' ),
87
- 'callback' => array( &$this, 'select_callback' ),
88
- 'page' => $this->settings_key,
89
- 'section' => 'email',
90
- 'type' => 'text',
91
- 'desc' => '',
92
- 'options' => array(
93
- array(
94
- 'name' => __( 'Download', 'be-woocommerce-pdf-invoices' ),
95
- 'value' => 'download'
96
- ),
97
- array(
98
- 'name' => __( 'Open in new browser tab/window', 'be-woocommerce-pdf-invoices' ),
99
- 'value' => 'browser'
100
- )
101
- ),
102
- 'default' => 'download'
103
- ),
104
  array(
105
  'id' => 'bewpi-email-type',
106
  'name' => $this->prefix . 'email_type',
@@ -142,6 +121,40 @@ if ( ! class_exists( 'BEWPI_General_Settings' ) ) {
142
  'class' => 'bewpi-checkbox-option-title',
143
  'default' => 0
144
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  array(
146
  'id' => 'bewpi-email-it-in',
147
  'name' => $this->prefix . 'email_it_in',
@@ -181,6 +194,12 @@ if ( ! class_exists( 'BEWPI_General_Settings' ) ) {
181
  array( &$this, 'email_desc_callback' ),
182
  $this->settings_key
183
  );
 
 
 
 
 
 
184
  add_settings_section(
185
  'cloud_storage',
186
  __( 'Cloud Storage Options', 'be-woocommerce-pdf-invoices' ),
@@ -190,6 +209,7 @@ if ( ! class_exists( 'BEWPI_General_Settings' ) ) {
190
  }
191
 
192
  public function email_desc_callback() { }
 
193
  public function cloud_storage_desc_callback() { printf( __( 'Signup at %s to send invoices to your Dropbox, OneDrive, Google Drive or Egnyte and enter your account below.', 'be-woocommerce-pdf-invoices' ), '<a href="https://emailitin.com">Email It In</a>' ); }
194
 
195
  /**
@@ -222,18 +242,23 @@ if ( ! class_exists( 'BEWPI_General_Settings' ) ) {
222
  * @return mixed|void
223
  */
224
  public function validate_input( $input ) {
225
- $output = array();
226
- foreach ( $input as $key => $value ) :
227
- if ( isset( $input[$key] ) ) :
228
- // Strip all HTML and PHP tags and properly handle quoted strings
229
- $output[$key] = stripslashes( $input[ $key ] );
230
- endif;
231
- endforeach;
 
 
 
 
 
 
232
 
233
  // Sanitize Email
234
- if ( isset( $input['email_it_in_account'] ) ) :
235
  $output['email_it_in_account'] = sanitize_email( $input['email_it_in_account'] );
236
- endif;
237
 
238
  return apply_filters( 'validate_input', $output, $input );
239
  }
80
  private function the_settings() {
81
  $settings = array(
82
  // General section
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  array(
84
  'id' => 'bewpi-email-type',
85
  'name' => $this->prefix . 'email_type',
121
  'class' => 'bewpi-checkbox-option-title',
122
  'default' => 0
123
  ),
124
+ array(
125
+ 'id' => 'bewpi-view-pdf',
126
+ 'name' => $this->prefix . 'view_pdf',
127
+ 'title' => __( 'View PDF', 'be-woocommerce-pdf-invoices' ),
128
+ 'callback' => array( &$this, 'select_callback' ),
129
+ 'page' => $this->settings_key,
130
+ 'section' => 'download',
131
+ 'type' => 'text',
132
+ 'desc' => '',
133
+ 'options' => array(
134
+ array(
135
+ 'name' => __( 'Download', 'be-woocommerce-pdf-invoices' ),
136
+ 'value' => 'download'
137
+ ),
138
+ array(
139
+ 'name' => __( 'Open in new browser tab/window', 'be-woocommerce-pdf-invoices' ),
140
+ 'value' => 'browser'
141
+ )
142
+ ),
143
+ 'default' => 'download'
144
+ ),
145
+ array(
146
+ 'id' => 'bewpi-download-invoice-account',
147
+ 'name' => $this->prefix . 'download_invoice_account',
148
+ 'title' => '',
149
+ 'callback' => array( &$this, 'input_callback' ),
150
+ 'page' => $this->settings_key,
151
+ 'section' => 'download',
152
+ 'type' => 'checkbox',
153
+ 'desc' => __( 'Enable download from account', 'be-woocommerce-pdf-invoices' )
154
+ . __( '<br/><div class="bewpi-notes">Let customers download invoice from account page.</div>', 'be-woocommerce-pdf-invoices' ),
155
+ 'class' => 'bewpi-checkbox-option-title',
156
+ 'default' => 1
157
+ ),
158
  array(
159
  'id' => 'bewpi-email-it-in',
160
  'name' => $this->prefix . 'email_it_in',
194
  array( &$this, 'email_desc_callback' ),
195
  $this->settings_key
196
  );
197
+ add_settings_section(
198
+ 'download',
199
+ __( 'Download Options', 'be-woocommerce-pdf-invoices' ),
200
+ array( &$this, 'download_desc_callback' ),
201
+ $this->settings_key
202
+ );
203
  add_settings_section(
204
  'cloud_storage',
205
  __( 'Cloud Storage Options', 'be-woocommerce-pdf-invoices' ),
209
  }
210
 
211
  public function email_desc_callback() { }
212
+ public function download_desc_callback() {}
213
  public function cloud_storage_desc_callback() { printf( __( 'Signup at %s to send invoices to your Dropbox, OneDrive, Google Drive or Egnyte and enter your account below.', 'be-woocommerce-pdf-invoices' ), '<a href="https://emailitin.com">Email It In</a>' ); }
214
 
215
  /**
242
  * @return mixed|void
243
  */
244
  public function validate_input( $input ) {
245
+ $output = array();
246
+ $the_settings = $this->the_settings();
247
+
248
+ foreach ( $input as $key => $value ) {
249
+ if ( isset( $input[$key] ) )
250
+ $output[$key] = stripslashes( $input[ $key ] ); // Strip all HTML and PHP tags and properly handle quoted strings
251
+ }
252
+
253
+ // Uncheck checkboxes
254
+ foreach ( $the_settings as $setting ) {
255
+ if ( $setting[ 'type' ] === 'checkbox' && ! isset( $input[ $setting[ 'name' ] ] ) )
256
+ $output[ $setting['name'] ] = 0;
257
+ }
258
 
259
  // Sanitize Email
260
+ if ( isset( $input['email_it_in_account'] ) )
261
  $output['email_it_in_account'] = sanitize_email( $input['email_it_in_account'] );
 
262
 
263
  return apply_filters( 'validate_input', $output, $input );
264
  }
includes/be-woocommerce-pdf-invoices.php CHANGED
@@ -78,12 +78,6 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
78
  */
79
  add_filter( 'woocommerce_email_attachments', array( &$this, 'attach_invoice_to_email' ), 99, 3 );
80
 
81
- /**
82
- * AJAX calls to download invoice
83
- */
84
- add_action( 'wp_ajax_bewpi_download_invoice', array( &$this, 'bewpi_download_invoice' ) );
85
- add_action( 'wp_ajax_nopriv_bewpi_download_invoice', array( &$this, 'bewpi_download_invoice' ) );
86
-
87
  /**
88
  * Adds a download link for the pdf invoice on the my account page
89
  */
@@ -151,7 +145,7 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
151
  $invoice = new BEWPI_Invoice( $order->id );
152
 
153
  if ( $invoice->exists() && $invoice->is_download_allowed( $order->post_status ) ) {
154
- $url = admin_url( 'admin-ajax.php?action=bewpi_download_invoice&order_id=' . $order->id . '&nonce=' . wp_create_nonce( 'bewpi_download_invoice' ) );
155
 
156
  $tags = array (
157
  '{formatted_invoice_number}' => $invoice->get_formatted_number(),
@@ -162,7 +156,7 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
162
  foreach ( $tags as $key => $value )
163
  $title = str_replace( $key, $value, $title );
164
 
165
- // example: Download (PDF) Invoice [formatted_invoice_number]
166
  echo '<a href="' . $url . '" alt="' . $title . '">' . $title . '</a>';
167
  }
168
  }
@@ -184,16 +178,17 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
184
  $order_id = $_GET['post'];
185
  $nonce = $_REQUEST['nonce'];
186
 
187
- if ( ! wp_verify_nonce( $nonce, $action ) ) {
188
- die( 'Invalid request' );
189
- }
190
 
191
- if ( empty( $order_id ) ) {
192
- die( 'Invalid order ID' );
193
- }
194
 
195
- $invoice = new BEWPI_Invoice( $order_id );
 
 
196
 
 
197
  switch ( $_GET['bewpi_action'] ) {
198
  case "view":
199
  $invoice->view();
@@ -229,9 +224,9 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
229
  */
230
  private function create_bewpi_dirs() {
231
  // bewpi-invoices
232
- wp_mkdir_p( BEWPI_INVOICES_DIR . date( 'Y' ) . '/' );
233
- copy( BEWPI_DIR . 'tmp/.htaccess', BEWPI_INVOICES_DIR . date( 'Y' ) . '/.htaccess' );
234
- copy( BEWPI_DIR . 'tmp/index.php', BEWPI_INVOICES_DIR . date( 'Y' ) . '/index.php' );
235
 
236
  wp_mkdir_p( BEWPI_CUSTOM_TEMPLATES_INVOICES_DIR . 'simple/' );
237
 
@@ -516,37 +511,26 @@ if ( ! class_exists( 'BE_WooCommerce_PDF_Invoices' ) ) {
516
  }
517
 
518
  /**
519
- * AJAX action to download invoice
520
  */
521
- public function bewpi_download_invoice() {
522
- if ( isset( $_GET['action'] ) && isset( $_GET['order_id'] ) && isset( $_GET['nonce'] ) ) {
523
- $action = $_GET['action'];
524
- $order_id = $_GET['order_id'];
525
- $nonce = $_REQUEST["nonce"];
526
 
527
- if ( ! wp_verify_nonce( $nonce, $action ) )
528
- die( 'Invalid request' );
529
 
530
- if ( empty( $order_id ) )
531
- die( 'Invalid order ID' );
 
532
 
533
- $invoice = new BEWPI_Invoice( $order_id );
534
- $invoice->view();
535
- }
536
- }
537
 
538
- /**
539
- * Display download link on My Account page
540
- */
541
- public function add_my_account_download_pdf_action( $actions, $order ) {
542
- $invoice = new BEWPI_Invoice( $order->id );
543
- if ( $invoice->exists() && $invoice->is_download_allowed( $order->post_status ) ) {
544
- $url = admin_url( 'admin-ajax.php?action=bewpi_download_invoice&order_id=' . $order->id . '&nonce=' . wp_create_nonce( 'bewpi_download_invoice' ) );
545
- $actions['invoice'] = array(
546
- 'url' => $url,
547
- 'name' => sprintf( __( 'Invoice %s (PDF)', 'be-woocommerce-pdf-invoices' ), $invoice->get_formatted_number() )
548
- );
549
- }
550
 
551
  return $actions;
552
  }
78
  */
79
  add_filter( 'woocommerce_email_attachments', array( &$this, 'attach_invoice_to_email' ), 99, 3 );
80
 
 
 
 
 
 
 
81
  /**
82
  * Adds a download link for the pdf invoice on the my account page
83
  */
145
  $invoice = new BEWPI_Invoice( $order->id );
146
 
147
  if ( $invoice->exists() && $invoice->is_download_allowed( $order->post_status ) ) {
148
+ $url = admin_url( 'admin-ajax.php?bewpi_action=view&post=' . $order->id . '&nonce=' . wp_create_nonce( 'view' ) );
149
 
150
  $tags = array (
151
  '{formatted_invoice_number}' => $invoice->get_formatted_number(),
156
  foreach ( $tags as $key => $value )
157
  $title = str_replace( $key, $value, $title );
158
 
159
+ // example: Download (PDF) Invoice {formatted_invoice_number}
160
  echo '<a href="' . $url . '" alt="' . $title . '">' . $title . '</a>';
161
  }
162
  }
178
  $order_id = $_GET['post'];
179
  $nonce = $_REQUEST['nonce'];
180
 
181
+ if ( ! wp_verify_nonce( $nonce, $action ) )
182
+ wp_die( __( 'Invalid request', 'be-woocommerce-pdf-invoices' ) );
 
183
 
184
+ if ( empty( $order_id ) )
185
+ wp_die( __( 'Invalid order ID', 'be-woocommerce-pdf-invoices' ) );
 
186
 
187
+ $is_customer_order = get_post_meta( $order_id, '_customer_user', true );
188
+ if ( ! is_admin() || get_current_user_id() != $is_customer_order )
189
+ wp_die( __( 'Access denied', 'be-woocommerce-pdf-invoices' ) );
190
 
191
+ $invoice = new BEWPI_Invoice( $order_id );
192
  switch ( $_GET['bewpi_action'] ) {
193
  case "view":
194
  $invoice->view();
224
  */
225
  private function create_bewpi_dirs() {
226
  // bewpi-invoices
227
+ wp_mkdir_p( BEWPI_INVOICES_DIR . date_i18n( 'Y' ) . '/' );
228
+ copy( BEWPI_DIR . 'tmp/.htaccess', BEWPI_INVOICES_DIR . date_i18n( 'Y' ) . '/.htaccess' );
229
+ copy( BEWPI_DIR . 'tmp/index.php', BEWPI_INVOICES_DIR . date_i18n( 'Y' ) . '/index.php' );
230
 
231
  wp_mkdir_p( BEWPI_CUSTOM_TEMPLATES_INVOICES_DIR . 'simple/' );
232
 
511
  }
512
 
513
  /**
514
+ * Display download link on My Account page
515
  */
516
+ public function add_my_account_download_pdf_action( $actions, $order ) {
517
+ $general_options = get_option( 'bewpi_general_settings' );
 
 
 
518
 
519
+ if ( ! (bool)$general_options[ 'bewpi_download_invoice_account' ] )
520
+ return $actions;
521
 
522
+ $invoice = new BEWPI_Invoice( $order->id );
523
+ if ( ! $invoice->exists() )
524
+ return $actions;
525
 
526
+ if ( ! $invoice->is_download_allowed( $order->post_status ) )
527
+ return $actions;
 
 
528
 
529
+ $url = admin_url( 'admin-ajax.php?bewpi_action=view&post=' . $order->id . '&nonce=' . wp_create_nonce( 'view' ) );
530
+ $actions[ 'invoice' ] = array(
531
+ 'url' => $url,
532
+ 'name' => sprintf( __( 'Invoice %s (PDF)', 'be-woocommerce-pdf-invoices' ), $invoice->get_formatted_number() )
533
+ );
 
 
 
 
 
 
 
534
 
535
  return $actions;
536
  }
lib/mpdf/config_fonts.php CHANGED
@@ -82,7 +82,7 @@ starting at 1, as they appear in the .ttc file e.g.
82
  ),
83
  */
84
 
85
- $this->fontdata = array(
86
  "dejavusanscondensed" => array(
87
  'R' => "DejaVuSansCondensed.ttf",
88
  'useOTL' => 0xFF,
@@ -105,15 +105,7 @@ $this->fontdata = array(
105
  "amiri" => array(
106
  'R' => "Amiri.ttf"
107
  )
108
- // "lato" => array(
109
- // 'R' => "Lato-Regular.ttf",
110
- // 'B' => "Lato-Bold.ttf",
111
- // 'I' => "Lato-Italic.ttf",
112
- // ),
113
- // "freeserif" => array(
114
- // 'R' => "FreeSerif.ttf",
115
- // ),
116
- );
117
 
118
 
119
  // Add fonts to this array if they contain characters in the SIP or SMP Unicode planes
82
  ),
83
  */
84
 
85
+ $this->fontdata = apply_filters( 'bewpi_ttffonts', array(
86
  "dejavusanscondensed" => array(
87
  'R' => "DejaVuSansCondensed.ttf",
88
  'useOTL' => 0xFF,
105
  "amiri" => array(
106
  'R' => "Amiri.ttf"
107
  )
108
+ ));
 
 
 
 
 
 
 
 
109
 
110
 
111
  // Add fonts to this array if they contain characters in the SIP or SMP Unicode planes
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.3.1
7
- Stable tag: 2.3.14
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -122,8 +122,24 @@ To change the options of the PDF, use below example.
122
  }
123
  add_filter( 'bewpi_mpdf_options', 'custom_bewpi_mpdf_options' );`
124
 
 
 
 
 
 
 
 
 
 
125
  == Changelog ==
126
 
 
 
 
 
 
 
 
127
  = 2.3.14 - December 11, 2015 =
128
 
129
  - Fixed: Fatal errors due to Wordpress 4.4
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.3.1
7
+ Stable tag: 2.3.15
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
122
  }
123
  add_filter( 'bewpi_mpdf_options', 'custom_bewpi_mpdf_options' );`
124
 
125
+ = How to display invoice download button on specific template files? =
126
+ Let customers download there invoices from specific specific template pages by using below shortcode.
127
+
128
+ `echo do_shortcode( '[bewpi-download-invoice title="Download (PDF) Invoice {formatted_invoice_number}" order_id="ORDER_ID"]' );`
129
+
130
+ To use shortcode in WordPress editor:
131
+
132
+ `[bewpi-download-invoice title="Download (PDF) Invoice {formatted_invoice_number}" order_id="ORDER_ID"]`
133
+
134
  == Changelog ==
135
 
136
+ = 2.3.15 - December 18, 2015 =
137
+
138
+ - Added: Shortcode for downloading invoices
139
+ - Added: Option to enable/disable download button on account page
140
+ - Fixed: Invoice number always 1 due to no wp table prefix in query
141
+ - Fixed: Date localization and timestamps
142
+
143
  = 2.3.14 - December 11, 2015 =
144
 
145
  - Fixed: Fatal errors due to Wordpress 4.4