Gravity PDF - Version 5.1.5

Version Description

  • Housekeeping: Add filter gfpdf_mpdf_post_init_class to interact with mPDF right after the initial Gravity PDF object setup [GH#890]
  • Bug: Fix URL rewrite issue with plugins that use action GET super global [GH#892]
  • Bug: Fix conflict with the SG Optimizer plugin's Minify HTML option [GH#897]
  • Bug: Strip Page Breaks from Headers and Footers to prevent Fatal PHP Error [GH#898]
Download this release

Release Info

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

Code changes from version 5.1.4 to 5.1.5

README.txt CHANGED
@@ -4,8 +4,8 @@ Plugin URI: https://gravitypdf.com/
4
  Donate link: https://gravitypdf.com/donate-to-plugin/
5
  Tags: gravity, forms, pdf, automation, attachment, email
6
  Requires at least: 4.8
7
- Tested up to: 5.1
8
- Stable tag: 5.1.4
9
  Requires PHP: 5.6
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl.txt
@@ -90,6 +90,12 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
90
 
91
  == Changelog ==
92
 
 
 
 
 
 
 
93
  = 5.1.4 =
94
  * Housekeeping: Upgrade Mpdf from 7.1.8 to 7.1.9 https://github.com/mpdf/mpdf/compare/v7.1.8...v7.1.9
95
  * Bug: Ensure correct permissions are set on mPDF tmp directory [GH#874]
4
  Donate link: https://gravitypdf.com/donate-to-plugin/
5
  Tags: gravity, forms, pdf, automation, attachment, email
6
  Requires at least: 4.8
7
+ Tested up to: 5.2
8
+ Stable tag: 5.1.5
9
  Requires PHP: 5.6
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl.txt
90
 
91
  == Changelog ==
92
 
93
+ = 5.1.5 =
94
+ * Housekeeping: Add filter `gfpdf_mpdf_post_init_class` to interact with mPDF right after the initial Gravity PDF object setup [GH#890]
95
+ * Bug: Fix URL rewrite issue with plugins that use `action` GET super global [GH#892]
96
+ * Bug: Fix conflict with the SG Optimizer plugin's Minify HTML option [GH#897]
97
+ * Bug: Strip Page Breaks from Headers and Footers to prevent Fatal PHP Error [GH#898]
98
+
99
  = 5.1.4 =
100
  * Housekeeping: Upgrade Mpdf from 7.1.8 to 7.1.9 https://github.com/mpdf/mpdf/compare/v7.1.8...v7.1.9
101
  * Bug: Ensure correct permissions are set on mPDF tmp directory [GH#874]
pdf.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Gravity PDF
4
- Version: 5.1.4
5
  Description: Automatically generate highly-customisable PDF documents using Gravity Forms.
6
  Author: Gravity PDF
7
  Author URI: https://gravitypdf.com
@@ -37,7 +37,7 @@ if ( ! defined( 'ABSPATH' ) ) {
37
  /*
38
  * Set base constants we'll use throughout the plugin
39
  */
40
- define( 'PDF_EXTENDED_VERSION', '5.1.4' ); /* the current plugin version */
41
  define( 'PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); /* plugin directory path */
42
  define( 'PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); /* plugin directory url */
43
  define( 'PDF_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); /* the plugin basename */
1
  <?php
2
  /*
3
  Plugin Name: Gravity PDF
4
+ Version: 5.1.5
5
  Description: Automatically generate highly-customisable PDF documents using Gravity Forms.
6
  Author: Gravity PDF
7
  Author URI: https://gravitypdf.com
37
  /*
38
  * Set base constants we'll use throughout the plugin
39
  */
40
+ define( 'PDF_EXTENDED_VERSION', '5.1.5' ); /* the current plugin version */
41
  define( 'PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); /* plugin directory path */
42
  define( 'PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); /* plugin directory url */
43
  define( 'PDF_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); /* the plugin basename */
src/assets/languages/gravity-forms-pdf-extended.pot CHANGED
@@ -141,7 +141,7 @@ msgstr ""
141
  msgid "There was a problem uninstalling Gravity PDF. Please try again."
142
  msgstr ""
143
 
144
- #: src/controller/Controller_PDF.php:337, src/view/View_PDF.php:272
145
  msgid "There was a problem generating your PDF"
146
  msgstr ""
147
 
@@ -929,7 +929,7 @@ msgstr ""
929
  msgid "For the best results, use a JPG or non-interlaced 8-Bit PNG that has the same dimensions as the paper size."
930
  msgstr ""
931
 
932
- #: src/helper/Helper_PDF.php:401
933
  msgid "The PDF Template %s requires Gravity PDF version %s. Upgrade to the latest version."
934
  msgstr ""
935
 
@@ -1021,11 +1021,11 @@ msgstr ""
1021
  msgid "Gravity PDF does not have write permission to the %s directory. Contact your web hosting provider to fix the issue."
1022
  msgstr ""
1023
 
1024
- #: src/model/Model_Install.php:483
1025
  msgid "There was a problem removing the Gravity Form \"%s\" PDF configuration. Try delete manually."
1026
  msgstr ""
1027
 
1028
- #: src/model/Model_Install.php:515
1029
  msgid "There was a problem removing the %s directory. Clean up manually via (S)FTP."
1030
  msgstr ""
1031
 
141
  msgid "There was a problem uninstalling Gravity PDF. Please try again."
142
  msgstr ""
143
 
144
+ #: src/controller/Controller_PDF.php:359, src/view/View_PDF.php:272
145
  msgid "There was a problem generating your PDF"
146
  msgstr ""
147
 
929
  msgid "For the best results, use a JPG or non-interlaced 8-Bit PNG that has the same dimensions as the paper size."
930
  msgstr ""
931
 
932
+ #: src/helper/Helper_PDF.php:408
933
  msgid "The PDF Template %s requires Gravity PDF version %s. Upgrade to the latest version."
934
  msgstr ""
935
 
1021
  msgid "Gravity PDF does not have write permission to the %s directory. Contact your web hosting provider to fix the issue."
1022
  msgstr ""
1023
 
1024
+ #: src/model/Model_Install.php:488
1025
  msgid "There was a problem removing the Gravity Form \"%s\" PDF configuration. Try delete manually."
1026
  msgstr ""
1027
 
1028
+ #: src/model/Model_Install.php:520
1029
  msgid "There was a problem removing the %s directory. Clean up manually via (S)FTP."
1030
  msgstr ""
1031
 
src/controller/Controller_PDF.php CHANGED
@@ -210,8 +210,9 @@ class Controller_PDF extends Helper_Abstract_Controller implements Helper_Interf
210
  /* Cleanup filters */
211
  add_filter( 'gform_before_resend_notifications', [ $this->model, 'resend_notification_pdf_cleanup' ], 10, 2 );
212
 
213
- /* GravityView */
214
- add_filter( 'gravityview/internal/ignored_endpoints', [ $this->model, 'fix_gravityview_frontpage_conflict' ] );
 
215
  }
216
 
217
  /**
@@ -289,6 +290,7 @@ class Controller_PDF extends Helper_Abstract_Controller implements Helper_Interf
289
  $GLOBALS['wp']->query_vars['lid'] = $config['lid'];
290
 
291
  /* Send to our model to handle validation / authentication */
 
292
  $results = $this->model->process_pdf( $pid, $config['lid'], $config['action'] );
293
 
294
  /* if error, display to user */
@@ -313,6 +315,26 @@ class Controller_PDF extends Helper_Abstract_Controller implements Helper_Interf
313
  remove_filter( 'safe_style_css', [ $this->view, 'allow_pdf_css' ] );
314
  }
315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  /**
317
  * Output PDF error to user
318
  *
210
  /* Cleanup filters */
211
  add_filter( 'gform_before_resend_notifications', [ $this->model, 'resend_notification_pdf_cleanup' ], 10, 2 );
212
 
213
+ /* Third Party Conflict Fixes */
214
+ add_filter( 'gfpdf_pre_view_or_download_pdf', [ $this, 'sgoptimizer_html_minification_fix' ] );
215
+ add_filter( 'gfpdf_legacy_pre_view_or_download_pdf', [ $this, 'sgoptimizer_html_minification_fix' ] );
216
  }
217
 
218
  /**
290
  $GLOBALS['wp']->query_vars['lid'] = $config['lid'];
291
 
292
  /* Send to our model to handle validation / authentication */
293
+ do_action( 'gfpdf_legacy_pre_view_or_download_pdf', $config['lid'], $pid, $config['action'] );
294
  $results = $this->model->process_pdf( $pid, $config['lid'], $config['action'] );
295
 
296
  /* if error, display to user */
315
  remove_filter( 'safe_style_css', [ $this->view, 'allow_pdf_css' ] );
316
  }
317
 
318
+ /**
319
+ * Disables the Siteground HTML Minifier when generating PDFs for the browser
320
+ *
321
+ * @since 5.1.5
322
+ *
323
+ * @see https://github.com/GravityPDF/gravity-pdf/issues/863
324
+ */
325
+ public function sgoptimizer_html_minification_fix() {
326
+ if ( class_exists( '\SiteGround_Optimizer\Minifier\Minifier' ) ) {
327
+
328
+ /* Remove the shutdown buffer and manually close an open buffers */
329
+ $minifier = \SiteGround_Optimizer\Minifier\Minifier::get_instance();
330
+ remove_action( 'shutdown', [ $minifier, 'end_html_minifier_buffer' ] );
331
+
332
+ while ( ob_get_level() > 0 ) {
333
+ ob_end_flush();
334
+ }
335
+ }
336
+ }
337
+
338
  /**
339
  * Output PDF error to user
340
  *
src/helper/Helper_Misc.php CHANGED
@@ -180,6 +180,8 @@ class Helper_Misc {
180
  *
181
  * 4. Convert any image URLs to local path where applicable
182
  *
 
 
183
  * @param string $html The HTML to parse
184
  *
185
  * @return string
@@ -190,6 +192,10 @@ class Helper_Misc {
190
  $html = trim( wpautop( $html ) );
191
  $html = $this->fix_header_footer_images( $html );
192
 
 
 
 
 
193
  return $html;
194
  }
195
 
180
  *
181
  * 4. Convert any image URLs to local path where applicable
182
  *
183
+ * 5. Strips out page breaks
184
+ *
185
  * @param string $html The HTML to parse
186
  *
187
  * @return string
192
  $html = trim( wpautop( $html ) );
193
  $html = $this->fix_header_footer_images( $html );
194
 
195
+ /* Strip page breaks */
196
+ $html = preg_replace( '/<pagebreak(.+?)?\/?>/', '', $html );
197
+ $html = preg_replace( '/page-break-(before|after):( +)?(always|left|right|auto|avoid)/', '', $html );
198
+
199
  return $html;
200
  }
201
 
src/helper/Helper_PDF.php CHANGED
@@ -239,6 +239,13 @@ class Helper_PDF {
239
  $this->set_pdf_format();
240
  $this->set_pdf_security();
241
  $this->set_display_mode();
 
 
 
 
 
 
 
242
  }
243
 
244
  /**
239
  $this->set_pdf_format();
240
  $this->set_pdf_security();
241
  $this->set_display_mode();
242
+
243
+ /*
244
+ * Allow $mpdf object class to be modified after it is fully initialised
245
+ *
246
+ * See https://gravitypdf.com/documentation/v5/gfpdf_mpdf_post_init_class/ for more details about this filter
247
+ */
248
+ $this->mpdf = apply_filters( 'gfpdf_mpdf_post_init_class', $this->mpdf, $this->form, $this->entry, $this->settings, $this );
249
  }
250
 
251
  /**
src/model/Model_Install.php CHANGED
@@ -380,10 +380,15 @@ class Model_Install extends Helper_Abstract_Model {
380
  * @return array
381
  */
382
  public function register_rewrite_tags( $tags ) {
383
- $tags[] = 'gpdf';
384
- $tags[] = 'pid';
385
- $tags[] = 'lid';
386
- $tags[] = 'action';
 
 
 
 
 
387
 
388
  return $tags;
389
  }
380
  * @return array
381
  */
382
  public function register_rewrite_tags( $tags ) {
383
+ global $wp;
384
+
385
+ /* Conditionally register rewrite tags to prevent conflict with other plugins */
386
+ if ( ! empty( $_GET['gpdf'] ) || ! empty( $_GET['gf_pdf'] ) || strpos( $wp->matched_query, 'gpdf=1' ) === 0 ) {
387
+ $tags[] = 'gpdf';
388
+ $tags[] = 'pid';
389
+ $tags[] = 'lid';
390
+ $tags[] = 'action';
391
+ }
392
 
393
  return $tags;
394
  }
src/model/Model_PDF.php CHANGED
@@ -2049,18 +2049,6 @@ class Model_PDF extends Helper_Abstract_Model {
2049
  return $action;
2050
  }
2051
 
2052
- /**
2053
- * @param array $ignored
2054
- *
2055
- * @since 4.2
2056
- */
2057
- public function fix_gravityview_frontpage_conflict( $ignored ) {
2058
- $ignored[] = 'lid';
2059
- $ignored[] = 'action';
2060
-
2061
- return $ignored;
2062
- }
2063
-
2064
  /**
2065
  * Set the watermark font to the current PDF font
2066
  *
2049
  return $action;
2050
  }
2051
 
 
 
 
 
 
 
 
 
 
 
 
 
2052
  /**
2053
  * Set the watermark font to the current PDF font
2054
  *