Gravity PDF - Version 3.7.1

Version Description

  • Housekeeping - Allow control over signature width in default template using the 'gfpdfe_signature_width' filter
  • Housekeeping - Add better error checking when migrating PDF template folder
  • Housekeeping - Add unit testing to the directory migration function
  • Bug - Fixed backwards-compatiiblity PHP error when viewing custom PDF templates on Gravity Forms 1.8.3 or below.
  • Bug - Ensure checkbox field names are included in the $form_data array
Download this release

Release Info

Developer Blue Liquid Designs
Plugin Icon 128x128 Gravity PDF
Version 3.7.1
Comparing to
See all releases

Code changes from version 3.7.0 to 3.7.1

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: blueliquiddesigns
3
  Donate link: https://gravitypdf.com
4
  Tags: gravity, forms, pdf, automation, attachment
5
  Requires at least: 3.9
6
- Tested up to: 4.1
7
- Stable tag: 3.7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl.txt
10
 
@@ -88,6 +88,13 @@ All FAQs can be [viewed on the Gravity PDF website](https://gravitypdf.com/#faqs
88
 
89
  == Changelog ==
90
 
 
 
 
 
 
 
 
91
  = 3.7.0 =
92
  * Feature - Added 'default-show-section-content' configuration option. You can now display the section break content in the default template. Note: if this option is enabled and the section break is empty it will still be displayed on the PDF.
93
  * Feature - Added hooks 'gfpdfe_template_location' and 'gfpdfe_template_location_uri' to change PDF template location
@@ -492,5 +499,5 @@ For more details [view the 3.x.x online documentation](https://developer.gravity
492
 
493
  == Upgrade Notice ==
494
 
495
- = 3.6.0 =
496
  WARNING: Minimum WordPress and Gravity Forms versions have been bumped to WordPress 3.9+ and Gravity Forms 1.8+. If you aren't running either version of this software DO NOT UPGRADE.
3
  Donate link: https://gravitypdf.com
4
  Tags: gravity, forms, pdf, automation, attachment
5
  Requires at least: 3.9
6
+ Tested up to: 4.2
7
+ Stable tag: 3.7.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl.txt
10
 
88
 
89
  == Changelog ==
90
 
91
+ = 3.7.1 =
92
+ * Housekeeping - Allow control over signature width in default template using the 'gfpdfe_signature_width' filter
93
+ * Housekeeping - Add better error checking when migrating PDF template folder
94
+ * Housekeeping - Add unit testing to the directory migration function
95
+ * Bug - Fixed backwards-compatiiblity PHP error when viewing custom PDF templates on Gravity Forms 1.8.3 or below.
96
+ * Bug - Ensure checkbox field names are included in the $form_data array
97
+
98
  = 3.7.0 =
99
  * Feature - Added 'default-show-section-content' configuration option. You can now display the section break content in the default template. Note: if this option is enabled and the section break is empty it will still be displayed on the PDF.
100
  * Feature - Added hooks 'gfpdfe_template_location' and 'gfpdfe_template_location_uri' to change PDF template location
499
 
500
  == Upgrade Notice ==
501
 
502
+ = 3.7.0 =
503
  WARNING: Minimum WordPress and Gravity Forms versions have been bumped to WordPress 3.9+ and Gravity Forms 1.8+. If you aren't running either version of this software DO NOT UPGRADE.
helper/installation-update-manager.php CHANGED
@@ -69,7 +69,7 @@ class GFPDF_InstallUpdater
69
 
70
  return $results;
71
  } else {
72
- if (self::do_deploy()) {
73
  /*
74
  * Output successfull automated installation message
75
  */
@@ -202,18 +202,18 @@ class GFPDF_InstallUpdater
202
  */
203
  self::reinitialise_templates($template_directory);
204
 
205
- /* create new directory in uploads folder*/
206
- if (self::create_base_template_dir($base_template_directory) === false) {
207
  return false;
208
  }
209
 
210
  /* create site directory in base template directory */
211
- if (self::create_site_template_dir($template_directory) === false) {
212
  return false;
213
  }
214
 
215
  /* create 'save' output folder */
216
- if (self::create_save_dir($template_save_directory) === false) {
217
  return false;
218
  }
219
 
@@ -223,10 +223,12 @@ class GFPDF_InstallUpdater
223
  }
224
 
225
  /* copy entire template folder over to the template directory */
226
- self::pdf_extended_copy_directory($directory.'initialisation/templates', $template_directory, false);
 
 
227
 
228
  /* copy configuration file over to new directory */
229
- if (self::create_configuration_file($directory, $template_directory) === false) {
230
  return false;
231
  }
232
 
@@ -575,10 +577,17 @@ class GFPDF_InstallUpdater
575
  }
576
 
577
  if ($wp_filesystem->is_dir($previous_pdf_path)) {
578
- if (is_dir($gfpdfe_data->old_template_location)) {
579
- self::pdf_extended_copy_directory($previous_pdf_path, $current_pdf_path, true, true, true); /* swap back to TRUE to delete the theme folder */
 
 
 
 
580
  } elseif (is_dir($gfpdfe_data->old_3_6_template_site_location)) {
581
- self::pdf_extended_copy_directory($previous_pdf_path, $current_pdf_path, true, false, true); /* swap back to TRUE to delete the theme folder */
 
 
 
582
  }
583
 
584
  /*
@@ -590,41 +599,77 @@ class GFPDF_InstallUpdater
590
  return true;
591
  }
592
 
593
- /*
594
  * Allows you to copy entire folder structures to new location
 
 
 
 
 
595
  */
596
  public static function pdf_extended_copy_directory($source, $destination, $copy_base = true, $delete_destination = false, $delete_source = false)
597
  {
598
  global $wp_filesystem;
599
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
600
  if ($wp_filesystem->is_dir($source)) {
601
- if ($delete_destination === true) {
602
  /*
603
  * To ensure everything stays in sync we will remove the destination file structure
604
  */
605
  $wp_filesystem->delete($destination, true);
606
  }
607
 
608
- if ($copy_base === true) {
609
- $wp_filesystem->mkdir($destination);
 
 
610
  }
611
  $directory = $wp_filesystem->dirlist($source);
612
 
613
  foreach ($directory as $name => $data) {
614
- $PathDir = $source.'/'.$name;
615
 
616
- if ($wp_filesystem->is_dir($PathDir)) {
617
- self::pdf_extended_copy_directory($PathDir, $destination.'/'.$name);
 
 
618
  continue;
619
  }
620
- $wp_filesystem->copy($PathDir, $destination.'/'.$name);
 
 
 
 
 
621
  }
622
  } else {
623
  $wp_filesystem->copy($source, $destination);
 
 
 
 
624
  }
625
 
626
  if ($delete_source) {
627
- $wp_filesystem->delete($source, true);
 
 
628
  }
 
 
629
  }
630
  }
69
 
70
  return $results;
71
  } else {
72
+ if (self::do_deploy()) {
73
  /*
74
  * Output successfull automated installation message
75
  */
202
  */
203
  self::reinitialise_templates($template_directory);
204
 
205
+ /* create new directory in uploads folder*/
206
+ if (self::create_base_template_dir($base_template_directory) === false) {
207
  return false;
208
  }
209
 
210
  /* create site directory in base template directory */
211
+ if (self::create_site_template_dir($template_directory) === false) {
212
  return false;
213
  }
214
 
215
  /* create 'save' output folder */
216
+ if (self::create_save_dir($template_save_directory) === false) {
217
  return false;
218
  }
219
 
223
  }
224
 
225
  /* copy entire template folder over to the template directory */
226
+ if(!self::pdf_extended_copy_directory($directory . 'initialisation/templates/', $template_directory, false)) {
227
+ return false;
228
+ }
229
 
230
  /* copy configuration file over to new directory */
231
+ if (self::create_configuration_file($directory, $template_directory) === false) {
232
  return false;
233
  }
234
 
577
  }
578
 
579
  if ($wp_filesystem->is_dir($previous_pdf_path)) {
580
+ if (is_dir($gfpdfe_data->old_template_location)) {
581
+ /* swap back to TRUE to delete the theme folder */
582
+ if(!self::pdf_extended_copy_directory($previous_pdf_path, $current_pdf_path, true, true, true)) {
583
+ return false;
584
+ }
585
+
586
  } elseif (is_dir($gfpdfe_data->old_3_6_template_site_location)) {
587
+ /* swap back to TRUE to delete the theme folder */
588
+ if(!self::pdf_extended_copy_directory($previous_pdf_path, $current_pdf_path, true, false, true)) {
589
+ return false;
590
+ }
591
  }
592
 
593
  /*
599
  return true;
600
  }
601
 
602
+ /**
603
  * Allows you to copy entire folder structures to new location
604
+ * @param String $source The source path that should be copied
605
+ * @param String $destination The destination path where the files should be copied to
606
+ * @param boolean $copy_base Whether to create the base directory at the destination
607
+ * @param boolean $delete_destination Whether to want to remove the destination before copying the files
608
+ * @param boolean $delete_source Once finished copying should we remove the source folder
609
  */
610
  public static function pdf_extended_copy_directory($source, $destination, $copy_base = true, $delete_destination = false, $delete_source = false)
611
  {
612
  global $wp_filesystem;
613
 
614
+ /* ensure source and destination end in a forward slash */
615
+ if(substr($source, -1) != '/') {
616
+ $source .= '/';
617
+ }
618
+
619
+ if(substr($destination, -1) != '/') {
620
+ $destination .= '/';
621
+ }
622
+
623
+ if($wp_filesystem->is_dir($destination) && $wp_filesystem->is_writable($destination) === false)
624
+ {
625
+ return false;
626
+ }
627
+
628
  if ($wp_filesystem->is_dir($source)) {
629
+ if ($delete_destination === true && $wp_filesystem->exists($destination) === true) {
630
  /*
631
  * To ensure everything stays in sync we will remove the destination file structure
632
  */
633
  $wp_filesystem->delete($destination, true);
634
  }
635
 
636
+ if ($copy_base === true && $wp_filesystem->exists($destination) === false) {
637
+ if(!$wp_filesystem->mkdir($destination)) {
638
+ return false;
639
+ }
640
  }
641
  $directory = $wp_filesystem->dirlist($source);
642
 
643
  foreach ($directory as $name => $data) {
644
+ $PathDir = $source.$name;
645
 
646
+ if ($wp_filesystem->is_dir($PathDir) === true) {
647
+ if(!self::pdf_extended_copy_directory($PathDir, $destination.$name)) {
648
+ return false;
649
+ }
650
  continue;
651
  }
652
+ $wp_filesystem->copy($PathDir, $destination.$name);
653
+
654
+ /* verify the file copied correctly */
655
+ if($wp_filesystem->is_file($destination.$name) === false || $wp_filesystem->size($PathDir) != $wp_filesystem->size($destination.$name)) {
656
+ return false;
657
+ }
658
  }
659
  } else {
660
  $wp_filesystem->copy($source, $destination);
661
+ /* verify the file copied correctly */
662
+ if($wp_filesystem->is_file($destination) === false || $wp_filesystem->size($source) != $wp_filesystem->size($destination)) {
663
+ return false;
664
+ }
665
  }
666
 
667
  if ($delete_source) {
668
+ if($wp_filesystem->delete($source, true) === false) {
669
+ return false;
670
+ }
671
  }
672
+
673
+ return true;
674
  }
675
  }
helper/pdf-common.php CHANGED
@@ -289,5 +289,25 @@ class PDF_Common
289
  'baseurl' => $baseurl,
290
  );
291
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  }
293
 
289
  'baseurl' => $baseurl,
290
  );
291
  }
292
+
293
+ /**
294
+ * Add backwards compatibility to users running Gravity Forms 1.8.3 or below
295
+ * which don't have this function built in.
296
+ * Once support is dropped for Gravity Forms 1.8.x this function can be removed.
297
+ * Added in v3.7.1
298
+ * @param Array $currency A currency type
299
+ * @return String Whether currency should be displayed as 'decimal_dot' or 'decimal_comma'
300
+ */
301
+ public static function is_currency_decimal_dot($currency = null) {
302
+ if($currency == null){
303
+ $code = GFCommon::get_currency();
304
+ if(empty($code))
305
+ $code = "USD";
306
+
307
+ $currency = RGCurrency::get_currency($code);
308
+ }
309
+
310
+ return rgar($currency, "decimal_separator") == ".";
311
+ }
312
  }
313
 
helper/pdf-entry-detail.php CHANGED
@@ -207,10 +207,9 @@ if(!class_exists('GFPDFEntryDetail'))
207
  if(file_exists($file) && !is_dir($file))
208
  {
209
  $image_size = getimagesize($file);
210
- $width = $image_size[0] / 4;
211
- $height = $image_size[1] / 4;
212
 
213
- $display_value = '<img src="'. $file .'" alt="Signature" width=" '. $width .'" height="'. $height .'" />';
214
  }
215
 
216
  if($display_value)
@@ -501,6 +500,13 @@ if(!class_exists('GFPDFEntryDetail'))
501
  $form_array['survey']['rating'][$field['id']] = self::get_the_rank($form, $lead, $field, $form_array);
502
  break;
503
 
 
 
 
 
 
 
 
504
  default:
505
 
506
 
@@ -1238,7 +1244,8 @@ if(!class_exists('GFPDFEntryDetail'))
1238
 
1239
  private static function get_product_array($form, $lead, $has_product_fields, $form_array)
1240
  {
1241
- $currency_format = GFCommon::is_currency_decimal_dot() ? 'decimal_dot' : 'decimal_comma';
 
1242
 
1243
  if($has_product_fields) {
1244
  $products = GFCommon::get_product_fields($form, $lead, true);
@@ -1253,9 +1260,7 @@ if(!class_exists('GFPDFEntryDetail'))
1253
  $total = 0;
1254
  $subtotal = 0;
1255
 
1256
-
1257
  foreach($products['products'] as $id => $product) {
1258
-
1259
  $price = GFCommon::to_number($product['price']);
1260
 
1261
  /* add all options to total price */
207
  if(file_exists($file) && !is_dir($file))
208
  {
209
  $image_size = getimagesize($file);
210
+ $width = apply_filters('gfpdfe_signature_width', $image_size[0] / 4, $image_size[0]);
 
211
 
212
+ $display_value = '<img src="'. $file .'" alt="Signature" width=" '. $width .'" />';
213
  }
214
 
215
  if($display_value)
500
  $form_array['survey']['rating'][$field['id']] = self::get_the_rank($form, $lead, $field, $form_array);
501
  break;
502
 
503
+ case 'checkbox':
504
+ /* Only process non-survey checkbox fields */
505
+ if($field['type'] == 'checkbox') {
506
+ $form_array = self::get_the_list($lead, $field, $form_array);
507
+ break;
508
+ }
509
+
510
  default:
511
 
512
 
1244
 
1245
  private static function get_product_array($form, $lead, $has_product_fields, $form_array)
1246
  {
1247
+ $currency_type = (method_exists('GFCommon', 'is_currency_decimal_dot')) ? GFCommon::is_currency_decimal_dot() : PDF_Common::is_currency_decimal_dot();
1248
+ $currency_format = $currency_type ? 'decimal_dot' : 'decimal_comma';
1249
 
1250
  if($has_product_fields) {
1251
  $products = GFCommon::get_product_fields($form, $lead, true);
1260
  $total = 0;
1261
  $subtotal = 0;
1262
 
 
1263
  foreach($products['products'] as $id => $product) {
 
1264
  $price = GFCommon::to_number($product['price']);
1265
 
1266
  /* add all options to total price */
pdf.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Gravity PDF
5
  * Plugin URI: https://gravitypdf.com
6
  * Description: Gravity PDF allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Our Business Plus package also allows you to overlay field onto an existing PDF.
7
- * Version: 3.7.0
8
  * Author: Blue Liquid Designs
9
  * Author URI: http://www.blueliquiddesigns.com.au
10
  */
@@ -41,7 +41,7 @@
41
  /*
42
  * Define our constants
43
  */
44
- define('PDF_EXTENDED_VERSION', '3.7.0');
45
  define('GF_PDF_EXTENDED_SUPPORTED_VERSION', '1.8');
46
  define('GF_PDF_EXTENDED_WP_SUPPORTED_VERSION', '3.9');
47
  define('GF_PDF_EXTENDED_PHP_SUPPORTED_VERSION', '5');
4
  * Plugin Name: Gravity PDF
5
  * Plugin URI: https://gravitypdf.com
6
  * Description: Gravity PDF allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Our Business Plus package also allows you to overlay field onto an existing PDF.
7
+ * Version: 3.7.1
8
  * Author: Blue Liquid Designs
9
  * Author URI: http://www.blueliquiddesigns.com.au
10
  */
41
  /*
42
  * Define our constants
43
  */
44
+ define('PDF_EXTENDED_VERSION', '3.7.1');
45
  define('GF_PDF_EXTENDED_SUPPORTED_VERSION', '1.8');
46
  define('GF_PDF_EXTENDED_WP_SUPPORTED_VERSION', '3.9');
47
  define('GF_PDF_EXTENDED_PHP_SUPPORTED_VERSION', '5');
view/templates/settings/changelog.php CHANGED
@@ -40,7 +40,15 @@
40
  <p><strong>Current Version: <?php echo PDF_EXTENDED_VERSION; ?></strong></p>
41
 
42
  <h3><?php echo PDF_EXTENDED_VERSION; ?></h3>
 
 
 
 
 
 
 
43
 
 
44
  <ul>
45
  <li>Feature - Added 'default-show-section-content' configuration option. You can now display the section break content in the default template. If this option is enabled and the section break is empty it will still be displayed on the PDF. Note: Existing installations will have to reinitialise their templates with the 'Reinstall Default and Example Templates' option enabled.</li>
46
  <li>Feature - Added hooks 'gfpdfe_template_location' and 'gfpdfe_template_location_uri' to change PDF template location</li>
40
  <p><strong>Current Version: <?php echo PDF_EXTENDED_VERSION; ?></strong></p>
41
 
42
  <h3><?php echo PDF_EXTENDED_VERSION; ?></h3>
43
+ <ul>
44
+ <li>Housekeeping - Allow control over signature width in default template using the 'gfpdfe_signature_width' filter</li>
45
+ <li>Housekeeping - Add better error checking when migrating PDF template folder</li>
46
+ <li>Housekeeping - Add unit testing to the directory migration function</li>
47
+ <li>Bug - Fixed backwards-compatiiblity PHP error when viewing custom PDF templates on Gravity Forms 1.8.3 or below.</li>
48
+ <li>Bug - Ensure checkbox field names are included in the $form_data array</li>
49
+ </ul>
50
 
51
+ <h3>3.7.0</h3>
52
  <ul>
53
  <li>Feature - Added 'default-show-section-content' configuration option. You can now display the section break content in the default template. If this option is enabled and the section break is empty it will still be displayed on the PDF. Note: Existing installations will have to reinitialise their templates with the 'Reinstall Default and Example Templates' option enabled.</li>
54
  <li>Feature - Added hooks 'gfpdfe_template_location' and 'gfpdfe_template_location_uri' to change PDF template location</li>