Gravity PDF - Version 3.5.4

Version Description

  • Bug - Fixed issue with incorrect PDF name showing on the entry details page
  • Bug - Fixed issue with custom fonts being inaccessible without manually reinstalling after upgrading.
  • Housekeeping - Added in two new filters to modify the $mpdf object. 'gfpdfe_mpdf_class' and 'gfpdfe_mpdf_class_pre_render' (replaces the gfpdfe_pre_render_pdf filter).
Download this release

Release Info

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

Code changes from version 3.5.3 to 3.5.4

README.txt CHANGED
@@ -1,407 +1,412 @@
1
- === Plugin Name ===
2
- Contributors: blueliquiddesigns
3
- Donate link: http://www.gravityformspdfextended.com
4
- Tags: gravity, forms, pdf, automation, attachment
5
- Requires at least: 3.5
6
- Tested up to: 3.9
7
- Stable tag: 3.5.3
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Gravity Forms PDF Extended allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission.
12
-
13
- == Description ==
14
-
15
- Gravity Forms PDF Extended is a powerful developer tool for creating PDF documents using form data captured from Gravity Forms. While the software is targeted at web developers, we've attempted to make it user friendly for hobbyists and DIY business owners. The basic setup can be done in minutes, and there is a huge array of options to configure the PDF as you see fit.
16
-
17
- **Gravity Form Features**
18
-
19
- * Save PDF File on user submission of a Gravity Form so it can be attached to a notification
20
- * Customise the PDF template without affecting the core Gravity Form Plugin
21
- * Multiple PDF Templates
22
- * Custom PDF Name
23
- * Output individual form fields in the template - like MERGETAGS.
24
- * View and download a PDF via the administrator interface or after a user submits their form
25
- * Works with Gravity Forms Signature Add-On
26
-
27
- **PDF Features**
28
-
29
- Along with the above, the PDF software includes powerful feature such as:
30
-
31
- * Language Support - almost all languages are supported including RTL (right to left) languages like Arabic, Hebrew and CJK languages - Chinese, Japanese and Korean.
32
- * HTML Page Numbering
33
- * Odd and even paging with mirrored margins (most commonly used in printing).
34
- * Nested Tables
35
- * Text-justification and hyphenation
36
- * Table of Contents
37
- * Index
38
- * Bookmarks
39
- * Watermarks
40
- * Password protection
41
- * UTF-8 encoded HTML
42
- * Better system resource handling
43
-
44
- **Server Requirements**
45
-
46
- 1. PHP 5+
47
- 2. MB String
48
- 3. GD Library
49
- 4. RAM: Recommended: 128MB. Minimum: 64MB.
50
-
51
- *Note:* We've had clients report slow PDF generation times and problems meeting the RAM requirements on cheap shared web hosting. If you experience these problems [we recommend you look into WP Engine's managed hosting platform](http://www.shareasale.com/r.cfm?B=398776&U=955815&M=41388&urllink=) as our software works correctly out of the box.
52
-
53
- **Software Requirements**
54
-
55
- 1. [Purchase and install Gravity Forms](https://www.e-junkie.com/ecom/gb.php?cl=54585&c=ib&aff=235154)
56
- 2. Wordpress 3.5+
57
- 3. Gravity Forms 1.7+
58
-
59
- **Documentation and Support**
60
-
61
- To view the Development Documentation head to [http://www.gravityformspdfextended.com/documentation/](http://www.gravityformspdfextended.com/documentation/). If you need support with the plugin please post a topic in our [support forums](http://gravityformspdfextended.com/support/gravity-forms-pdf-extended/).
62
-
63
- == Installation ==
64
-
65
- 1. Upload this plugin to your website and activate it
66
- 2. Head to Forms -> Settings -> PDF to initialise the plugin.
67
- 3. Create a form in Gravity Forms and configure notifications
68
- 4. Get the Form ID and follow the steps below in [the configuration section](http://gravityformspdfextended.com/documentation-v3-x-x/installation-and-configuration/)
69
- 5. Modify the PDF template file ([see the advanced templating section in the documentation](http://gravityformspdfextended.com/documentation-v3-x-x/templates/)) inside your active theme's PDF_EXTENDED_TEMPLATES/ folder.
70
-
71
-
72
- == Frequently Asked Questions ==
73
-
74
- All FAQs can be [viewed on the Gravity Forms PDF Extended website](http://gravityformspdfextended.com/faq/category/developers/).
75
-
76
- == Screenshots ==
77
-
78
- 1. The View PDF button is avaliable for each Gravity Form entry
79
- 2. Multiple PDFs can be assigned to a form and is also avaliable on the detailed entry view.
80
- 3. The configuration.php file allows you to easily assign PDFs to Gravity Forms
81
-
82
- == Changelog ==
83
-
84
- = 3.5.3 =
85
- * Bug - Mergetags braces ({}) were being encoded before conversion
86
- * Bug - Fixed issue with empty string being passed to array filter
87
- * Housekeeping - Enabled mergetag usage in the pdf_password and pdf_master_password configuration options
88
- * Housekeeping - Correctly call $wpdb->prepare so the variables in are in the second argument
89
-
90
- = 3.5.2 =
91
- * Bug - Initialisation folder .htaccess file was preventing template.css from being loaded by the default templates.
92
-
93
- = 3.5.1 =
94
- * Bug - Fixed issue with core fonts Arial/Helvetica, Times/Times New Roman and Courier not displaying in the PDF.
95
- * Bug - Fixed display issues for multiple PDFs on the details admin entry page
96
- * Housekeeping - Made the details entry page PDF view consistent for single or multiple PDFs
97
- * Housekeeping - Ensured all javascript files are minified and are correctly being used
98
- * Housekeeping - Remove legacy notices from mPDF package
99
-
100
- = 3.5.0 =
101
- * Feature - No longer need to reinitialise every time the software is updated.
102
- * Feature - Add auto-initialiser on initial installation for sites that have direct write access to their server files
103
- * Feature - Add auto-initialiser on initial installation across entire multisite network for sites who have direct write access to their server files.
104
- * Feature - Add auto-PDF_EXTENDED_TEMPLATE theme syncer for sites that have direct write access to their server files
105
- * Feature - Correctly added language support. The .PO file is located in the /language/ folder if anyone would like to do a translation.
106
-
107
- * Housekeeping - Restrict initialisation process to 64MB or greater to counter problems with users reporting a 'white screen' when running in a low-RAM environment.
108
- * Housekeeping - Refractor the admin notices code
109
- * Housekeeping - Create responsive PDF settings page
110
- * Housekeeping - Minify CSS and Javascript files
111
- * Housekeeping - Remove FontAwesome fonts from package and use Wordpress' build-in 'dashicons'
112
- * Housekeeping - Refine action and error messages
113
- * Housekeeping - Update initialisation tab copy for both pre- and post- initialisation
114
- * Housekeeping - Use Gravity Forms get_ip() function instead of custom function
115
- * Housekeeping - The in-built support form uses SSL once again (disabled in the past due to some servers being unable to verify the certificate).
116
-
117
- * Bug - When testing write permissions, file_exist() is throwing false positives for some users which would generate a warning when unlink() is called. Hide warning using '@'.
118
-
119
- = 3.4.1 =
120
- * Bug - Fix typo that effected sites running PHP5.2 or below.
121
-
122
- = 3.4.0.3 =
123
- * Bug - Define array_replace_recursive() if it doesn't exist, as it is PHP 5.3 only.
124
-
125
- = 3.4.0.2 =
126
- * Housekeeping - Wrapped the View PDF and Download buttons in correct language functions - _e()
127
- * Bug - Fix problem displaying the signature field
128
- * Bug - Fix notice errors with new 'save' PDF hook
129
-
130
- = 3.4.0.1 =
131
- * Housekeeping - Add commas on the last line of every config node in the configuration.php file
132
- * Housekeeping - Fix up initialisation error messages
133
- * Bug - Fix up mPDF bugs - soft hyphens, watermarks over SVG images, inline CSS bug
134
-
135
- = 3.4.0 =
136
- * Feature - Added auto-print prompt ability when you add &print=1 to the PDF URL (see https://gravityformspdfextended.com/documentation-v3-x-x/display-pdf-in-browser/ for details)
137
- * Feature - Added ability to rotate absolute positioned text 180 degrees (previously only 90 and -90). Note: feature in beta
138
- * Feature - Backup all template files that are overridden when initialising to a folder inside PDF_EXTENDED_TEMPLATE
139
- * Feature - Added SSH initialisation support
140
- * Feature - Allow MERGETAGS to be used in all PDF templates, including default template (but only in the HTML field).
141
- * Feature - Updated mPDF to 3.7.1
142
- * Feature - Enable text/image watermark support. Added new example template example-watermark09.php showing off its usage (see http://gravityformspdfextended.com/documentation-v3-x-x/templates/watermarks/)
143
- * Feature - Added full survey, poll and quiz support to both the default template and $form_data (see http://gravityformspdfextended.com/documentation-v3-x-x/accessing-survey-poll-quiz-data/)
144
- * Feature - Shortcodes will now be processed in all templates, including default template (but only in the HTML field).
145
- * Feature - Added 'save' configuration option so PDFs are saved to the local disk when 'notifications' aren't enabled.
146
- * Feature - Added 'dpi' configuration option to modify the PDF image DPI. Default 96dpi. Use 300dpi for printing.
147
- * Feature - Added PDF/A1-b compliance option. Enable with 'pdfa1b' => true. See http://mpdf1.com/manual/index.php?tid=420&searchstring=pdf/a1-b for more details.
148
- * Feature - Added PDF/X1-a compliance option. Enable with 'pdfx1a' => true. See http://mpdf1.com/manual/index.php?tid=481&searchstring=pdf/x-1a for more details.
149
- * Feature - Added new constant option 'PDF_REPACK_FONT' which when enabled may improve function with some PostScript printers (disabled by default). Existing sites will need to add define('PDF_REPACK_FONT', true); to the bottom of their configuration.php file.
150
- * Feature - Added a sleuth of new hooks and filters for developers. See https://gravityformspdfextended.com/documentation-v3-x-x/filters-and-hooks/ for examples.
151
- * Feature - Added $form_data['form_description'] key to $form_data array
152
- * Feature - Update $form_data['products'] array key to field ID
153
- * Feature - Added survey Likert output function for custom templates (much like the product table function). It can be used with the following command 'echo GFPDFEntryDetails::get_likert($form, $lead, $field_id);' where $field_id is substituted for the form field ID.
154
- * Feature - Added field descriptions to the $form_data array under the $form_data['field_descriptions'] key.
155
- * Feature - Added pre and post PDF generation filters and actions to pdf-render.php. These include gfpdfe_pre_render_pdf, gfpdfe_pdf_output_type, gfpdfe_pdf_filename and gfpdf_post_pdf_save.
156
- * Feature: $form_data['signature'] et al. keys now contain the signature width and height attributes
157
-
158
- * Housekeeping - Ensure the form and lead IDs are correctly passed throughout the render functions.
159
- * Housekeeping - Update settings page link to match new Gravity Forms URL structure
160
- * Housekeeping - Check if $lead['gfsurvey_score'] exists before assigning to $form_data array
161
- * Housekeeping - Removed table and font checksum debugging from mPDF when WP_DEBUG enabled as they produced inaccurate results.
162
- * Housekeeping - Fixed up mPDF logging location when WP_DEBUG enabled. Files now stored in wp-content/themes/Active_Theme_Folder/PDF_EXTENDED_TEMPLATE/output/ folder.
163
- * Housekeeping - Removed API logging locally when WP_DEBUG is enabled.
164
- * Housekeeping - Increase API timeout interval as some overseas users reported timeout issues
165
- * Housekeeping - Modified mPDF functions Image() and purify_utf8_text() to validate the input data so we don't have to do it every time through the template.
166
- * Housekeeping - Added ability to not re-deploy every update (not enabled this release as template files were all updated)
167
- * Housekeeping - Additional checks on load to see if any of the required file/folder structure is missing. If so, re-initilise.
168
- * Housekeeping - Save resources and turn off automatic rtl identification. Users must set the RTL option when configuring form
169
- * Housekeeping - Turn off mPDFs packTableData setting, decreasing processing time when working with large tables.
170
- * Housekeeping - $gf_pdf_default_configuration options now merge down into existing PDF nodes, instead of applying to only unassigned forms. $gf_pdf_config settings override any in $gf_pdf_default_configuration
171
- * Housekeeping - Center aligned Survey Likery field results
172
- * Housekeeping - Partially refactored the pdf-entry-detail.php code
173
- * Housekeeping - All default and example templates have been tidied. This won't affect custom templates.
174
- * Housekeeping - Set the gform_notification order number to 100 which will prevent other functions (example snippets from Gravity Forms, for instance) from overridding the attached PDF.
175
- * Housekeeping - Fix spelling mistake on initialising fonts
176
- * Housekeeping - Remove wpautop() function from Gravity Form HTML output, which was applied before rendering and was messing up the HTML markup.
177
- * Housekeeping - Remove empty list rows from the $form_data['list'] array in single and multi-column lists.
178
- * Housekeeping - Apply same CSS styles (padding, border and line height) to HTML fields as done to form values in default templates
179
- * Housekeeping - Replaced arbitrary wrapper IDs in the default templates with the actual field ID
180
-
181
- * Bug - Fixed signature rendering issue when custom signature size was being used
182
- * Bug - Fixed static error types in helper/install-update-manager.php file.
183
- * Bug - Fixed redeployment error message which wasn't showing correctly
184
- * Bug - Fixed issue with PDF not attaching to notification using Paypal's delayed notification feature
185
- * Bug - Fixed strict standard warning about calling GFPDF_Settings::settings_page();
186
- * Bug - Fixed strict standard warning about calling GFPDFEntryDetail::pdf_get_lead_field_display();
187
- * Bug - Fixed issue with Gravity Form Post Category field causing fatal error generating PDF
188
- * Bug - Fixed number field formatting issue when displaying on PDF.
189
- * Bug - Do additional check for PHP's MB_String regex functions before initialising ti prevent errors after initialising
190
- * Bug - Fixed problem with multiple nodes assigned to a form using the same template
191
- * Bug - Fixed path to fallback templates when not found
192
- * Bug - Fixed problem with master password setting to user password
193
-
194
-
195
- = 3.3.4 =
196
- * Bug - Fixed issue linking to PDF from front end
197
- * Housekeeping - Removed autoredirect to initialisation page
198
-
199
- = 3.3.3 =
200
- * Bug - Correctly call javascript to control admin area 'View PDFs' drop down
201
- * Bug - Some users still reported incorrect RAM. Convert MB/KB/GB values to M/K/G as per the PHP documentation.
202
- * Housekeeping - Show initilisation prompt on all admin area pages instead of only on the Gravity Forms pages
203
-
204
- = 3.3.2.1 =
205
- * Bug - Incorrectly showing assigned RAM to website
206
-
207
- = 3.3.2 =
208
- * Bug - Some hosts reported SSL certificate errors when using the support API. Disabled HTTPS for further investigation. Using hash-based verification for authentication.
209
- * Housekeeping - Forgot to disable API debug feature after completing beta
210
-
211
- = 3.3.1 =
212
- * Bug - $form_data['list'] was mapped using an incremental key instead of via the field ID
213
-
214
- = 3.3.0 =
215
- * Feature - Overhauled the initialisation process so that the software better reviews the host for potential problems before initialisation. This should help debug issues and make users aware there could be a problem before they begin using the software.
216
- * Feature - Overhauled the settings page to make it easier to access features of the software
217
- * Feature - Added a Support tab to the settings page which allows users to securely (over HTTPS) submit a support ticket to the Gravity Form PDF Extended support desk
218
- * Feature - Changed select, multiselect and radio fields so that the default templates use the name rather than the value. $form_data now also includes the name and values for all these fields.
219
- * Feature - $form_data now includes all miscellaneous lead information in the $form_data['misc'] array.
220
- * Feature - $form_data now contains 24 and 12 hour time of entry submission.
221
- * Feature - Added localisation support
222
- * Compatibility - Added new multi-upload support which was added in Gravity Forms 1.8.
223
- * Bug - Added 'aid' parametre to the PDF url when multiple configuration nodes present on a single form
224
- * Bug - Fixed issue when Gravity Forms in No Conflict Mode
225
- * Bug - Font config.php's array keys now in lower case
226
- * Housekeeping - Moved all initialisation files to a folder called 'initialisation'.
227
- * Housekeeping - Renamed the configuration.php file in the plugin folder to configuration.php.example to alleviate confusion for developers who unwittingly modify the plugin configuration file instead of the file in their active theme's PDF_EXTENDED_TEMPLATE folder.
228
- * Housekeeping - Updated the plugin file system to a more MVC-style approach, with model and view folders.
229
- * Housekeeping - Removed ability to directly access default and example template files.
230
- * Housekeeping - Fixed PHP notices in default templates related to the default template-only configuration options
231
- * Housekeeping - Update core styles to match Wordpress 3.8/Gravity Forms 1.8.
232
- * Housekeeping - Updated header/footer examples to use @page in example.
233
-
234
- = 3.2.0 =
235
- * Feature - Can now view multiple PDFs assigned to a single form via the admin area. Note: You must provide a unique 'filename' parameter in configuration.php for multiple PDFs assigned to a single form.
236
- * Feature - You can exclude a field from the default templates using the class name 'exclude'. See our [FAQ topic](http://gravityformspdfextended.com/faq/can-exclude-field-showing-pdf/) for more details.
237
- * Bug - Fixed issue viewing own PDF entry when logged in as anything lower than editor.
238
- * Bug - Fixed data return bug in pdf-entry-details.php that was preventing all data returning correctly.
239
- * Bug - Fixed PHP Warning when using products with no options
240
- * Bug - Fixed issue with invalid characters being added to the PDF filename. Most notably the date mergetag.
241
- * Bug - Limit filename length to 150 characters which should work on the majority of web servers.
242
- * Bug - Fixed problem sending duplicate PDF when using mass resend notification feature
243
- * Depreciated - Removed GF_FORM_ID and GF_LEAD_ID constants which were used in v2.x.x of the software. Ensure you follow [v2.x.x upgrade guide](http://gravityformspdfextended.com/documentation-v3-x-x/v3-0-0-migration-guide/) to your templates before upgrading.
244
-
245
- = 3.1.4 =
246
- * Bug - Fixed issue with plugin breaking website's when the Gravity Forms plugin wasn't activated.
247
- * Housekeeping - The plugin now only supports Gravity Forms 1.7 or higher and Wordpress 3.5 or higher.
248
- * Housekeeping - PDF template files can no longer be accessed directly. Instead, add &html=1 to the end of your URL when viewing a PDF.
249
- * Extension - Added additional filters to allow the lead ID and notifications to be overridden.
250
-
251
- = 3.1.3 =
252
- * Feature - Added signature_details_id to $form_data array which maps a signatures field ID to the array.
253
- * Extension - Added pre-PDF generator filter for use with extensions.
254
- * Bug - Fixed issue with quotes in entry data breaking custom templates.
255
- * Bug - Fixed issue with the plugin not correctly using the new default configuration template, if set.
256
- * Bug - Fixed issue with signature not being removed correctly when only testing with file_exists(). Added second is_dir() test.
257
- * Bug - Fixed issue with empty signature field not displaying when option 'default-show-empty' is set.
258
- * Bug - Fixed initialisation prompt issue when the MPDF package wasn't unpacked.
259
-
260
- = 3.1.2 =
261
- * Feature - Added list array, file path, form ID and lead ID to $form_data array in custom templates
262
- * Bug - Fixed initialisation prompt issue when updating plugin
263
- * Bug - Fixed window.open issue which prevented a new window from opening when viewing a PDF in the admin area
264
- * Bug - Fixed issue with product dropdown and radio button data showing the value instead of the name field.
265
- * Bug - Fixed incorrect URL pointing to signature in $form_data
266
-
267
- = 3.1.1 =
268
- * Bug - Users whose server only supports FTP file manipulation using the WP_Filesystem API moved the files into the wrong directory due to FTP usually being rooted to the Wordpress home directory. To fix this the plugin attempts to determine the FTP directory, otherwise assumes it is the WP base directory.
269
- * Bug - Initialisation error message was being called but the success message was also showing.
270
-
271
- = 3.1.0 =
272
- * Feature - Added defaults to configuration.php which allows users to define the default PDF settings for all Gravity Forms. See the [installation and configuration documentation](http://gravityformspdfextended.com/documentation-v3-x-x/installation-and-configuration/#default-configuration-options) for more details.
273
- * Feature - Added three new configuration options 'default-show-html', 'default-show-empty' and 'default-show-page-names' which allow different display options to the three default templates. See the [installation and configuration documentation](http://gravityformspdfextended.com/documentation-v3-x-x/installation-and-configuration/#default-template-only) for more details.
274
- * Feature - Added filter hooks 'gfpdfe_pdf_name' and 'gfpdfe_template' which allows developers to further modify a PDF name and template file, respectively, outside of the configuration.php. This is useful if you have a special case naming convention based on user input. See [http://gravityformspdfextended.com/filters-and-hooks/](http://gravityformspdfextended.com/filters-and-hooks/) for more details about using these filters.
275
- * Feature - Custom font support. Any .ttf font file added to the PDF_EXTENDED_TEMPLATE/fonts/ folder will be automatically installed once the plugin has been initialised. Users also have the option to just initialise the fonts via the settings page. See the [font/language documentation ](http://gravityformspdfextended.com/documentation-v3-x-x/language-support/#installing-fonts) for details.
276
- * Compatability - Use Gravity Forms get_upload_root() and get_upload_url_root() instead of hard coding the signature upload directory in pdf-entry-detail.php
277
- * Compatability - Changed depreciated functions get_themes() and get_theme() to wp_get_theme() (added in Wordpress v3.4).
278
- * Compatability - The plugin now needs to be initialised on fresh installation and upgrade. This allows us to use the WP_Filesystem API for file manipulation.
279
- * Compatability - Automatic copying of PDF_EXTENDED_TEMPLATE folder on a theme change was removed in favour of a user prompt. This allows us to take advantage of the WP_Filesystem API.
280
- * Compatability - Added Wordpress compatibility checker (minimum now 3.4 or higher).
281
- * Bug - Removed ZipArchive in favour of Wordpress's WP_Filesystem API unzip_file() command. Some users reported the plugin would stop their entire website working if this extension wasn't installed.
282
- * Bug - Fixed Gravity Forms compatibility checker which wouldn't return the correct response.
283
- * Bug - Fixed minor bug in pdf.php when using static call 'self' in add_filter hook. Changed to class name.
284
- * Bug - Removed PHP notice about $even variable not being defined in pdf-entry-detail.php
285
- * Bug - Prevent code from continuing to excecute after sending header redirect.
286
-
287
- = 3.0.2 =
288
- * Backwards Compatibility - While PHP 5.3 has was released a number of years ago it seems a number of hosts do not currently offer this version to their clients. In the interest of backwards compatibility we've re-written the plugin to again work with PHP 5+.
289
- * Signature / Image Display Bug - All URLs have been converted to a path so images should now display correctly in PDF.
290
-
291
- = 3.0.1 =
292
- * Bug - Fixed issue that caused website to become unresponsive when Gravity Forms was disabled or upgraded
293
- * Bug - New HTML fields weren't being displayed in $form_data array
294
- * Feature - Options for default templates to disable HTML fields or empty fields (or both)
295
-
296
- = 3.0.0 =
297
- As of Gravity Forms PDF Extended v3.0.0 we have removed the DOMPDF package from our plugin and integrated the more advanced mPDF system. Along with a new HTML to PDF generator, we've rewritten the entire plugin's base code to make it more user friendly to both hobbyists and rock star web developers. Configuration time is cut in half and advanced features like adding security features is now accessible to users who have little experience with PHP.
298
-
299
- New Features include:
300
-
301
- * Language Support - almost all languages are supported including RTL (right to left) languages like Arabic and Hebrew and CJK languages - Chinese, Japanese and Korean.
302
- * HTML Page Numbering
303
- * Odd and even paging with mirrored margins (most commonly used in printing).
304
- * Nested Tables
305
- * Text-justification and hyphenation
306
- * Table of Contents
307
- * Index
308
- * Bookmarks
309
- * Watermarks
310
- * Password protection
311
- * UTF-8 encoded HTML
312
- * Better system resource handling
313
-
314
- A new HTML to PDF package wasn't the only change to this edition of the software. We have rewritten the entire configuration system and made it super easy to get the software up and running.
315
-
316
- Users will no longer place code in their active theme's functions.php file. Instead, configuration will happen in a new file called configuration.php, inside the PDF_EXTENDED_TEMPLATES folder (in your active theme).
317
-
318
- Other changes include
319
- * Improved security - further restrictions were placed on non-administrators viewing template files.
320
- * $form_data array tidied up - images won't be wrapped in anchor tags.
321
-
322
- For more details [view the 3.x.x online documentation](http://gravityformspdfextended.com/documentation-v3-x-x/introduction/).
323
-
324
- = 2.2.3 =
325
- * Bug - Fixed mb_string error in the updated DOMPDF package.
326
-
327
- = 2.2.2 =
328
- * DOMPDF - We updated to the latest version of DOMPDF - DOMPDF 0.6.0 beta 3.
329
- * DOMPDF - We've enabled font subsetting by default which should help limit the increased PDF size when using DejaVu Sans (or any other font).
330
-
331
- = 2.2.1 =
332
- * Bug - Fixed HTML error which caused list items to distort on PDF
333
-
334
- = 2.2.0 =
335
- * Compatibility - Ensure compatibility with Gravity Forms 1.7. We've updated the functions.php code and remove gform_user_notification_attachments and gform_admin_notification_attachments hooks which are now depreciated. Functions gform_pdf_create and gform_add_attachment have been removed and replaced with gfpdfe_create_and_attach_pdf(). See upgrade documentation for details.
336
- * Enhancement - Added deployment code switch so the template redeployment feature can be turned on and off. This release doesn't require redeployment.
337
- * Enhancement - PDF_Generator() variables were getting long and complex so the third variable is now an array which will pass all the optional arguments. The new 1.7 compatible functions.php code includes this method by default. For backwards compatibility the function will still work with the variable structure prior to 2.2.0.
338
- * Bug - Fixed error generated by legacy code in the function PDF_processing() which is located in render_to_pdf.php.
339
- * Bug - Images and stylesheets will now try and be accessed with a local path instead of a URL. It fixes problem where some hosts were preventing read access from a URL. No template changes are required.
340
-
341
- = 2.1.1 =
342
- * Bug - Signatures stopped displaying after 2.1.0 update. Fixed issue.
343
- * Bug - First time install code now won't execute if already have configuration variables in database
344
-
345
- = 2.1.0 =
346
-
347
- * Feature - Product table can now be accessed directly through custom templates by running GFPDFEntryDetail::product_table($form, $lead);. See documentation for more details.
348
- * Feature - Update screen will ask you if you want to deploy new template files, instead of overriding your modified versions.
349
- * Feature - Product subtotal, shipping and total have been added to $form_data['field'] array to make it easier to work with product details in the custom template.
350
- * Feature - Added two new default template files. One displays field and name in two rows (like you see when viewing an entry in the admin area) and the other removes all styling. See documentation on use.
351
- * Security - Tightened PDF template security so that custom templates couldn't be automatically generated by just anyone. Now only logged in users with the correct privileges and the user who submitted the form (matched against IP) can auto generate a PDF. See documentation on usage.
352
- * Depreciated - Removed form data that was added directly to the $form_data array instead of $form_data['field'] array. Users upgrading will need to update their custom templates if not using field data from the $form_data[�field'] array. If using $form_data['field'] in your custom template this won't affect you.
353
- * Bug - Fixed problem with default template not showing and displaying a timeout error. Removed table tags and replaced with divs that are styled appropriately.
354
- * Bug - The new plugin theme folder will successfully create when upgrading. You won't have to deactivate and reactivate to get it working.
355
- * Bug - some installs had plugins that included the function mb_string which is also included in DOMPDF. DOMPDF will now check if the function exists before creating it.
356
- * Bug - Remove empty signature field from the default template.
357
- * Bug - fixed problem with redirecting to login screen even when logged in while accessing template file through the browser window directly.
358
- * Bug - fixed error where sample template would reimport itself automatically even after deleting it. Will now only reimport if any important changes to template need to be viewed straight after an update.
359
- * Bug - Moved render_to_pdf.php constants to pdf.php so we can use the constants in the core files. Was previously generating an error.
360
- * Housekeeping - Cleaned up core template files, moved functions into classes and added more in-file documentation.
361
- * Housekeeping - moved install/upgrade code from pdf.php to installation-update-manager.php
362
- * Housekeeping - changed pdf-entry-detail.php class name from GFEntryDetail to GFPDFEntryDetail to remove compatibility problems with Gravity Forms.
363
- * Housekeeping - created pdf-settings.php file to house the settings page code.
364
-
365
- = 2.0.1 =
366
- * Fixed Signature bug when checking if image file exists using URL instead of filesystem path
367
- * Fixed PHP Constants Notice
368
-
369
- = 2.0.0 =
370
- * Moved templates to active theme folder to prevent custom themes being removed on upgrade
371
- * Allow PDFs to be saved using a custom name
372
- * Fixed WP_Error bug when image/css file cannot be found
373
- * Upgraded to latest version of DOMPDF
374
- * Removed auto-load form bug which would see multiple instances of the example form loaded
375
- * Created a number of constants to allow easier developer modification
376
- * Plugin/Support moved to dedicated website.
377
- * Pro/Business package offers the ability to write fields on an existing PDF.
378
-
379
- = 1.2.3 =
380
- * Fixed $wpdb->prepare error
381
-
382
- = 1.2.2 =
383
- * Fixed bug with tempalte shipping method MERGETAGS
384
- * Fixed bug where attachment wasn't being sent
385
- * Fixed problem when all_url_fopen was turned off on server and failed to retreive remote images. Now uses WP_HTTP class.
386
-
387
- = 1.2.1 =
388
- * Fixed path to custom css file included in PDF template
389
-
390
- = 1.2.0 =
391
- * Template files moved to the plugin's template folder
392
- * Sample Form installed so developers have a working example to modify
393
- * Fixed bug when using WordPress in another directory to the site
394
-
395
- = 1.1.0 =
396
- * Now compatible with Gravity Forms Signature Add-On
397
- * Moved the field data functions out side of the Gravity Forms core so users can freely style their form information (located in pdf-entry-detail.php)
398
- * Simplified the field data output
399
- * Fixed bug when using product information
400
-
401
- = 1.0.0 =
402
- * First release.
403
-
404
- == Upgrade Notice ==
405
-
406
- = 3.4.0.1 =
407
- mPDF upgrade. Full Survey, Poll and Quiz support. Paypal Delayed notifications support. Enhanced $form_data array. More filters and hooks for developers.
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: blueliquiddesigns
3
+ Donate link: http://www.gravityformspdfextended.com
4
+ Tags: gravity, forms, pdf, automation, attachment
5
+ Requires at least: 3.5
6
+ Tested up to: 4.0
7
+ Stable tag: 3.5.4
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Gravity Forms PDF Extended allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission.
12
+
13
+ == Description ==
14
+
15
+ Gravity Forms PDF Extended is a powerful developer tool for creating PDF documents using form data captured from Gravity Forms. While the software is targeted at web developers, we've attempted to make it user friendly for hobbyists and DIY business owners. The basic setup can be done in minutes, and there is a huge array of options to configure the PDF as you see fit.
16
+
17
+ **Gravity Form Features**
18
+
19
+ * Save PDF File on user submission of a Gravity Form so it can be attached to a notification
20
+ * Customise the PDF template without affecting the core Gravity Form Plugin
21
+ * Multiple PDF Templates
22
+ * Custom PDF Name
23
+ * Output individual form fields in the template - like MERGETAGS.
24
+ * View and download a PDF via the administrator interface or after a user submits their form
25
+ * Works with Gravity Forms Signature Add-On
26
+
27
+ **PDF Features**
28
+
29
+ Along with the above, the PDF software includes powerful feature such as:
30
+
31
+ * Language Support - almost all languages are supported including RTL (right to left) languages like Arabic, Hebrew and CJK languages - Chinese, Japanese and Korean.
32
+ * HTML Page Numbering
33
+ * Odd and even paging with mirrored margins (most commonly used in printing).
34
+ * Nested Tables
35
+ * Text-justification and hyphenation
36
+ * Table of Contents
37
+ * Index
38
+ * Bookmarks
39
+ * Watermarks
40
+ * Password protection
41
+ * UTF-8 encoded HTML
42
+ * Better system resource handling
43
+
44
+ **Server Requirements**
45
+
46
+ 1. PHP 5+
47
+ 2. MB String
48
+ 3. GD Library
49
+ 4. RAM: Recommended: 128MB. Minimum: 64MB.
50
+
51
+ *Note:* We've had clients report slow PDF generation times and problems meeting the RAM requirements on cheap shared web hosting. If you experience these problems [we recommend you look into WP Engine's managed hosting platform](http://www.shareasale.com/r.cfm?B=398776&U=955815&M=41388&urllink=) as our software works correctly out of the box.
52
+
53
+ **Software Requirements**
54
+
55
+ 1. [Purchase and install Gravity Forms](https://www.e-junkie.com/ecom/gb.php?cl=54585&c=ib&aff=235154)
56
+ 2. Wordpress 3.5+
57
+ 3. Gravity Forms 1.7+
58
+
59
+ **Documentation and Support**
60
+
61
+ To view the Development Documentation head to [http://www.gravityformspdfextended.com/documentation/](http://www.gravityformspdfextended.com/documentation/). If you need support with the plugin please post a topic in our [support forums](http://gravityformspdfextended.com/support/gravity-forms-pdf-extended/).
62
+
63
+ == Installation ==
64
+
65
+ 1. Upload this plugin to your website and activate it
66
+ 2. Head to Forms -> Settings -> PDF to initialise the plugin.
67
+ 3. Create a form in Gravity Forms and configure notifications
68
+ 4. Get the Form ID and follow the steps below in [the configuration section](http://gravityformspdfextended.com/documentation-v3-x-x/installation-and-configuration/)
69
+ 5. Modify the PDF template file ([see the advanced templating section in the documentation](http://gravityformspdfextended.com/documentation-v3-x-x/templates/)) inside your active theme's PDF_EXTENDED_TEMPLATES/ folder.
70
+
71
+
72
+ == Frequently Asked Questions ==
73
+
74
+ All FAQs can be [viewed on the Gravity Forms PDF Extended website](http://gravityformspdfextended.com/faq/category/developers/).
75
+
76
+ == Screenshots ==
77
+
78
+ 1. The View PDF button is avaliable for each Gravity Form entry
79
+ 2. Multiple PDFs can be assigned to a form and is also avaliable on the detailed entry view.
80
+ 3. The configuration.php file allows you to easily assign PDFs to Gravity Forms
81
+
82
+ == Changelog ==
83
+
84
+ = 3.5.4 =
85
+ * Bug - Fixed issue with incorrect PDF name showing on the entry details page
86
+ * Bug - Fixed issue with custom fonts being inaccessible without manually reinstalling after upgrading.
87
+ * Housekeeping - Added in two new filters to modify the $mpdf object. 'gfpdfe_mpdf_class' and 'gfpdfe_mpdf_class_pre_render' (replaces the gfpdfe_pre_render_pdf filter).
88
+
89
+ = 3.5.3 =
90
+ * Bug - Mergetags braces ({}) were being encoded before conversion
91
+ * Bug - Fixed issue with empty string being passed to array filter
92
+ * Housekeeping - Enabled mergetag usage in the pdf_password and pdf_master_password configuration options
93
+ * Housekeeping - Correctly call $wpdb->prepare so the variables in are in the second argument
94
+
95
+ = 3.5.2 =
96
+ * Bug - Initialisation folder .htaccess file was preventing template.css from being loaded by the default templates.
97
+
98
+ = 3.5.1 =
99
+ * Bug - Fixed issue with core fonts Arial/Helvetica, Times/Times New Roman and Courier not displaying in the PDF.
100
+ * Bug - Fixed display issues for multiple PDFs on the details admin entry page
101
+ * Housekeeping - Made the details entry page PDF view consistent for single or multiple PDFs
102
+ * Housekeeping - Ensured all javascript files are minified and are correctly being used
103
+ * Housekeeping - Remove legacy notices from mPDF package
104
+
105
+ = 3.5.0 =
106
+ * Feature - No longer need to reinitialise every time the software is updated.
107
+ * Feature - Add auto-initialiser on initial installation for sites that have direct write access to their server files
108
+ * Feature - Add auto-initialiser on initial installation across entire multisite network for sites who have direct write access to their server files.
109
+ * Feature - Add auto-PDF_EXTENDED_TEMPLATE theme syncer for sites that have direct write access to their server files
110
+ * Feature - Correctly added language support. The .PO file is located in the /language/ folder if anyone would like to do a translation.
111
+
112
+ * Housekeeping - Restrict initialisation process to 64MB or greater to counter problems with users reporting a 'white screen' when running in a low-RAM environment.
113
+ * Housekeeping - Refractor the admin notices code
114
+ * Housekeeping - Create responsive PDF settings page
115
+ * Housekeeping - Minify CSS and Javascript files
116
+ * Housekeeping - Remove FontAwesome fonts from package and use Wordpress' build-in 'dashicons'
117
+ * Housekeeping - Refine action and error messages
118
+ * Housekeeping - Update initialisation tab copy for both pre- and post- initialisation
119
+ * Housekeeping - Use Gravity Forms get_ip() function instead of custom function
120
+ * Housekeeping - The in-built support form uses SSL once again (disabled in the past due to some servers being unable to verify the certificate).
121
+
122
+ * Bug - When testing write permissions, file_exist() is throwing false positives for some users which would generate a warning when unlink() is called. Hide warning using '@'.
123
+
124
+ = 3.4.1 =
125
+ * Bug - Fix typo that effected sites running PHP5.2 or below.
126
+
127
+ = 3.4.0.3 =
128
+ * Bug - Define array_replace_recursive() if it doesn't exist, as it is PHP 5.3 only.
129
+
130
+ = 3.4.0.2 =
131
+ * Housekeeping - Wrapped the View PDF and Download buttons in correct language functions - _e()
132
+ * Bug - Fix problem displaying the signature field
133
+ * Bug - Fix notice errors with new 'save' PDF hook
134
+
135
+ = 3.4.0.1 =
136
+ * Housekeeping - Add commas on the last line of every config node in the configuration.php file
137
+ * Housekeeping - Fix up initialisation error messages
138
+ * Bug - Fix up mPDF bugs - soft hyphens, watermarks over SVG images, inline CSS bug
139
+
140
+ = 3.4.0 =
141
+ * Feature - Added auto-print prompt ability when you add &print=1 to the PDF URL (see https://gravityformspdfextended.com/documentation-v3-x-x/display-pdf-in-browser/ for details)
142
+ * Feature - Added ability to rotate absolute positioned text 180 degrees (previously only 90 and -90). Note: feature in beta
143
+ * Feature - Backup all template files that are overridden when initialising to a folder inside PDF_EXTENDED_TEMPLATE
144
+ * Feature - Added SSH initialisation support
145
+ * Feature - Allow MERGETAGS to be used in all PDF templates, including default template (but only in the HTML field).
146
+ * Feature - Updated mPDF to 3.7.1
147
+ * Feature - Enable text/image watermark support. Added new example template example-watermark09.php showing off its usage (see http://gravityformspdfextended.com/documentation-v3-x-x/templates/watermarks/)
148
+ * Feature - Added full survey, poll and quiz support to both the default template and $form_data (see http://gravityformspdfextended.com/documentation-v3-x-x/accessing-survey-poll-quiz-data/)
149
+ * Feature - Shortcodes will now be processed in all templates, including default template (but only in the HTML field).
150
+ * Feature - Added 'save' configuration option so PDFs are saved to the local disk when 'notifications' aren't enabled.
151
+ * Feature - Added 'dpi' configuration option to modify the PDF image DPI. Default 96dpi. Use 300dpi for printing.
152
+ * Feature - Added PDF/A1-b compliance option. Enable with 'pdfa1b' => true. See http://mpdf1.com/manual/index.php?tid=420&searchstring=pdf/a1-b for more details.
153
+ * Feature - Added PDF/X1-a compliance option. Enable with 'pdfx1a' => true. See http://mpdf1.com/manual/index.php?tid=481&searchstring=pdf/x-1a for more details.
154
+ * Feature - Added new constant option 'PDF_REPACK_FONT' which when enabled may improve function with some PostScript printers (disabled by default). Existing sites will need to add define('PDF_REPACK_FONT', true); to the bottom of their configuration.php file.
155
+ * Feature - Added a sleuth of new hooks and filters for developers. See https://gravityformspdfextended.com/documentation-v3-x-x/filters-and-hooks/ for examples.
156
+ * Feature - Added $form_data['form_description'] key to $form_data array
157
+ * Feature - Update $form_data['products'] array key to field ID
158
+ * Feature - Added survey Likert output function for custom templates (much like the product table function). It can be used with the following command 'echo GFPDFEntryDetails::get_likert($form, $lead, $field_id);' where $field_id is substituted for the form field ID.
159
+ * Feature - Added field descriptions to the $form_data array under the $form_data['field_descriptions'] key.
160
+ * Feature - Added pre and post PDF generation filters and actions to pdf-render.php. These include gfpdfe_pre_render_pdf, gfpdfe_pdf_output_type, gfpdfe_pdf_filename and gfpdf_post_pdf_save.
161
+ * Feature: $form_data['signature'] et al. keys now contain the signature width and height attributes
162
+
163
+ * Housekeeping - Ensure the form and lead IDs are correctly passed throughout the render functions.
164
+ * Housekeeping - Update settings page link to match new Gravity Forms URL structure
165
+ * Housekeeping - Check if $lead['gfsurvey_score'] exists before assigning to $form_data array
166
+ * Housekeeping - Removed table and font checksum debugging from mPDF when WP_DEBUG enabled as they produced inaccurate results.
167
+ * Housekeeping - Fixed up mPDF logging location when WP_DEBUG enabled. Files now stored in wp-content/themes/Active_Theme_Folder/PDF_EXTENDED_TEMPLATE/output/ folder.
168
+ * Housekeeping - Removed API logging locally when WP_DEBUG is enabled.
169
+ * Housekeeping - Increase API timeout interval as some overseas users reported timeout issues
170
+ * Housekeeping - Modified mPDF functions Image() and purify_utf8_text() to validate the input data so we don't have to do it every time through the template.
171
+ * Housekeeping - Added ability to not re-deploy every update (not enabled this release as template files were all updated)
172
+ * Housekeeping - Additional checks on load to see if any of the required file/folder structure is missing. If so, re-initilise.
173
+ * Housekeeping - Save resources and turn off automatic rtl identification. Users must set the RTL option when configuring form
174
+ * Housekeeping - Turn off mPDFs packTableData setting, decreasing processing time when working with large tables.
175
+ * Housekeeping - $gf_pdf_default_configuration options now merge down into existing PDF nodes, instead of applying to only unassigned forms. $gf_pdf_config settings override any in $gf_pdf_default_configuration
176
+ * Housekeeping - Center aligned Survey Likery field results
177
+ * Housekeeping - Partially refactored the pdf-entry-detail.php code
178
+ * Housekeeping - All default and example templates have been tidied. This won't affect custom templates.
179
+ * Housekeeping - Set the gform_notification order number to 100 which will prevent other functions (example snippets from Gravity Forms, for instance) from overridding the attached PDF.
180
+ * Housekeeping - Fix spelling mistake on initialising fonts
181
+ * Housekeeping - Remove wpautop() function from Gravity Form HTML output, which was applied before rendering and was messing up the HTML markup.
182
+ * Housekeeping - Remove empty list rows from the $form_data['list'] array in single and multi-column lists.
183
+ * Housekeeping - Apply same CSS styles (padding, border and line height) to HTML fields as done to form values in default templates
184
+ * Housekeeping - Replaced arbitrary wrapper IDs in the default templates with the actual field ID
185
+
186
+ * Bug - Fixed signature rendering issue when custom signature size was being used
187
+ * Bug - Fixed static error types in helper/install-update-manager.php file.
188
+ * Bug - Fixed redeployment error message which wasn't showing correctly
189
+ * Bug - Fixed issue with PDF not attaching to notification using Paypal's delayed notification feature
190
+ * Bug - Fixed strict standard warning about calling GFPDF_Settings::settings_page();
191
+ * Bug - Fixed strict standard warning about calling GFPDFEntryDetail::pdf_get_lead_field_display();
192
+ * Bug - Fixed issue with Gravity Form Post Category field causing fatal error generating PDF
193
+ * Bug - Fixed number field formatting issue when displaying on PDF.
194
+ * Bug - Do additional check for PHP's MB_String regex functions before initialising ti prevent errors after initialising
195
+ * Bug - Fixed problem with multiple nodes assigned to a form using the same template
196
+ * Bug - Fixed path to fallback templates when not found
197
+ * Bug - Fixed problem with master password setting to user password
198
+
199
+
200
+ = 3.3.4 =
201
+ * Bug - Fixed issue linking to PDF from front end
202
+ * Housekeeping - Removed autoredirect to initialisation page
203
+
204
+ = 3.3.3 =
205
+ * Bug - Correctly call javascript to control admin area 'View PDFs' drop down
206
+ * Bug - Some users still reported incorrect RAM. Convert MB/KB/GB values to M/K/G as per the PHP documentation.
207
+ * Housekeeping - Show initilisation prompt on all admin area pages instead of only on the Gravity Forms pages
208
+
209
+ = 3.3.2.1 =
210
+ * Bug - Incorrectly showing assigned RAM to website
211
+
212
+ = 3.3.2 =
213
+ * Bug - Some hosts reported SSL certificate errors when using the support API. Disabled HTTPS for further investigation. Using hash-based verification for authentication.
214
+ * Housekeeping - Forgot to disable API debug feature after completing beta
215
+
216
+ = 3.3.1 =
217
+ * Bug - $form_data['list'] was mapped using an incremental key instead of via the field ID
218
+
219
+ = 3.3.0 =
220
+ * Feature - Overhauled the initialisation process so that the software better reviews the host for potential problems before initialisation. This should help debug issues and make users aware there could be a problem before they begin using the software.
221
+ * Feature - Overhauled the settings page to make it easier to access features of the software
222
+ * Feature - Added a Support tab to the settings page which allows users to securely (over HTTPS) submit a support ticket to the Gravity Form PDF Extended support desk
223
+ * Feature - Changed select, multiselect and radio fields so that the default templates use the name rather than the value. $form_data now also includes the name and values for all these fields.
224
+ * Feature - $form_data now includes all miscellaneous lead information in the $form_data['misc'] array.
225
+ * Feature - $form_data now contains 24 and 12 hour time of entry submission.
226
+ * Feature - Added localisation support
227
+ * Compatibility - Added new multi-upload support which was added in Gravity Forms 1.8.
228
+ * Bug - Added 'aid' parametre to the PDF url when multiple configuration nodes present on a single form
229
+ * Bug - Fixed issue when Gravity Forms in No Conflict Mode
230
+ * Bug - Font config.php's array keys now in lower case
231
+ * Housekeeping - Moved all initialisation files to a folder called 'initialisation'.
232
+ * Housekeeping - Renamed the configuration.php file in the plugin folder to configuration.php.example to alleviate confusion for developers who unwittingly modify the plugin configuration file instead of the file in their active theme's PDF_EXTENDED_TEMPLATE folder.
233
+ * Housekeeping - Updated the plugin file system to a more MVC-style approach, with model and view folders.
234
+ * Housekeeping - Removed ability to directly access default and example template files.
235
+ * Housekeeping - Fixed PHP notices in default templates related to the default template-only configuration options
236
+ * Housekeeping - Update core styles to match Wordpress 3.8/Gravity Forms 1.8.
237
+ * Housekeeping - Updated header/footer examples to use @page in example.
238
+
239
+ = 3.2.0 =
240
+ * Feature - Can now view multiple PDFs assigned to a single form via the admin area. Note: You must provide a unique 'filename' parameter in configuration.php for multiple PDFs assigned to a single form.
241
+ * Feature - You can exclude a field from the default templates using the class name 'exclude'. See our [FAQ topic](http://gravityformspdfextended.com/faq/can-exclude-field-showing-pdf/) for more details.
242
+ * Bug - Fixed issue viewing own PDF entry when logged in as anything lower than editor.
243
+ * Bug - Fixed data return bug in pdf-entry-details.php that was preventing all data returning correctly.
244
+ * Bug - Fixed PHP Warning when using products with no options
245
+ * Bug - Fixed issue with invalid characters being added to the PDF filename. Most notably the date mergetag.
246
+ * Bug - Limit filename length to 150 characters which should work on the majority of web servers.
247
+ * Bug - Fixed problem sending duplicate PDF when using mass resend notification feature
248
+ * Depreciated - Removed GF_FORM_ID and GF_LEAD_ID constants which were used in v2.x.x of the software. Ensure you follow [v2.x.x upgrade guide](http://gravityformspdfextended.com/documentation-v3-x-x/v3-0-0-migration-guide/) to your templates before upgrading.
249
+
250
+ = 3.1.4 =
251
+ * Bug - Fixed issue with plugin breaking website's when the Gravity Forms plugin wasn't activated.
252
+ * Housekeeping - The plugin now only supports Gravity Forms 1.7 or higher and Wordpress 3.5 or higher.
253
+ * Housekeeping - PDF template files can no longer be accessed directly. Instead, add &html=1 to the end of your URL when viewing a PDF.
254
+ * Extension - Added additional filters to allow the lead ID and notifications to be overridden.
255
+
256
+ = 3.1.3 =
257
+ * Feature - Added signature_details_id to $form_data array which maps a signatures field ID to the array.
258
+ * Extension - Added pre-PDF generator filter for use with extensions.
259
+ * Bug - Fixed issue with quotes in entry data breaking custom templates.
260
+ * Bug - Fixed issue with the plugin not correctly using the new default configuration template, if set.
261
+ * Bug - Fixed issue with signature not being removed correctly when only testing with file_exists(). Added second is_dir() test.
262
+ * Bug - Fixed issue with empty signature field not displaying when option 'default-show-empty' is set.
263
+ * Bug - Fixed initialisation prompt issue when the MPDF package wasn't unpacked.
264
+
265
+ = 3.1.2 =
266
+ * Feature - Added list array, file path, form ID and lead ID to $form_data array in custom templates
267
+ * Bug - Fixed initialisation prompt issue when updating plugin
268
+ * Bug - Fixed window.open issue which prevented a new window from opening when viewing a PDF in the admin area
269
+ * Bug - Fixed issue with product dropdown and radio button data showing the value instead of the name field.
270
+ * Bug - Fixed incorrect URL pointing to signature in $form_data
271
+
272
+ = 3.1.1 =
273
+ * Bug - Users whose server only supports FTP file manipulation using the WP_Filesystem API moved the files into the wrong directory due to FTP usually being rooted to the Wordpress home directory. To fix this the plugin attempts to determine the FTP directory, otherwise assumes it is the WP base directory.
274
+ * Bug - Initialisation error message was being called but the success message was also showing.
275
+
276
+ = 3.1.0 =
277
+ * Feature - Added defaults to configuration.php which allows users to define the default PDF settings for all Gravity Forms. See the [installation and configuration documentation](http://gravityformspdfextended.com/documentation-v3-x-x/installation-and-configuration/#default-configuration-options) for more details.
278
+ * Feature - Added three new configuration options 'default-show-html', 'default-show-empty' and 'default-show-page-names' which allow different display options to the three default templates. See the [installation and configuration documentation](http://gravityformspdfextended.com/documentation-v3-x-x/installation-and-configuration/#default-template-only) for more details.
279
+ * Feature - Added filter hooks 'gfpdfe_pdf_name' and 'gfpdfe_template' which allows developers to further modify a PDF name and template file, respectively, outside of the configuration.php. This is useful if you have a special case naming convention based on user input. See [http://gravityformspdfextended.com/filters-and-hooks/](http://gravityformspdfextended.com/filters-and-hooks/) for more details about using these filters.
280
+ * Feature - Custom font support. Any .ttf font file added to the PDF_EXTENDED_TEMPLATE/fonts/ folder will be automatically installed once the plugin has been initialised. Users also have the option to just initialise the fonts via the settings page. See the [font/language documentation ](http://gravityformspdfextended.com/documentation-v3-x-x/language-support/#installing-fonts) for details.
281
+ * Compatability - Use Gravity Forms get_upload_root() and get_upload_url_root() instead of hard coding the signature upload directory in pdf-entry-detail.php
282
+ * Compatability - Changed depreciated functions get_themes() and get_theme() to wp_get_theme() (added in Wordpress v3.4).
283
+ * Compatability - The plugin now needs to be initialised on fresh installation and upgrade. This allows us to use the WP_Filesystem API for file manipulation.
284
+ * Compatability - Automatic copying of PDF_EXTENDED_TEMPLATE folder on a theme change was removed in favour of a user prompt. This allows us to take advantage of the WP_Filesystem API.
285
+ * Compatability - Added Wordpress compatibility checker (minimum now 3.4 or higher).
286
+ * Bug - Removed ZipArchive in favour of Wordpress's WP_Filesystem API unzip_file() command. Some users reported the plugin would stop their entire website working if this extension wasn't installed.
287
+ * Bug - Fixed Gravity Forms compatibility checker which wouldn't return the correct response.
288
+ * Bug - Fixed minor bug in pdf.php when using static call 'self' in add_filter hook. Changed to class name.
289
+ * Bug - Removed PHP notice about $even variable not being defined in pdf-entry-detail.php
290
+ * Bug - Prevent code from continuing to excecute after sending header redirect.
291
+
292
+ = 3.0.2 =
293
+ * Backwards Compatibility - While PHP 5.3 has was released a number of years ago it seems a number of hosts do not currently offer this version to their clients. In the interest of backwards compatibility we've re-written the plugin to again work with PHP 5+.
294
+ * Signature / Image Display Bug - All URLs have been converted to a path so images should now display correctly in PDF.
295
+
296
+ = 3.0.1 =
297
+ * Bug - Fixed issue that caused website to become unresponsive when Gravity Forms was disabled or upgraded
298
+ * Bug - New HTML fields weren't being displayed in $form_data array
299
+ * Feature - Options for default templates to disable HTML fields or empty fields (or both)
300
+
301
+ = 3.0.0 =
302
+ As of Gravity Forms PDF Extended v3.0.0 we have removed the DOMPDF package from our plugin and integrated the more advanced mPDF system. Along with a new HTML to PDF generator, we've rewritten the entire plugin's base code to make it more user friendly to both hobbyists and rock star web developers. Configuration time is cut in half and advanced features like adding security features is now accessible to users who have little experience with PHP.
303
+
304
+ New Features include:
305
+
306
+ * Language Support - almost all languages are supported including RTL (right to left) languages like Arabic and Hebrew and CJK languages - Chinese, Japanese and Korean.
307
+ * HTML Page Numbering
308
+ * Odd and even paging with mirrored margins (most commonly used in printing).
309
+ * Nested Tables
310
+ * Text-justification and hyphenation
311
+ * Table of Contents
312
+ * Index
313
+ * Bookmarks
314
+ * Watermarks
315
+ * Password protection
316
+ * UTF-8 encoded HTML
317
+ * Better system resource handling
318
+
319
+ A new HTML to PDF package wasn't the only change to this edition of the software. We have rewritten the entire configuration system and made it super easy to get the software up and running.
320
+
321
+ Users will no longer place code in their active theme's functions.php file. Instead, configuration will happen in a new file called configuration.php, inside the PDF_EXTENDED_TEMPLATES folder (in your active theme).
322
+
323
+ Other changes include
324
+ * Improved security - further restrictions were placed on non-administrators viewing template files.
325
+ * $form_data array tidied up - images won't be wrapped in anchor tags.
326
+
327
+ For more details [view the 3.x.x online documentation](http://gravityformspdfextended.com/documentation-v3-x-x/introduction/).
328
+
329
+ = 2.2.3 =
330
+ * Bug - Fixed mb_string error in the updated DOMPDF package.
331
+
332
+ = 2.2.2 =
333
+ * DOMPDF - We updated to the latest version of DOMPDF - DOMPDF 0.6.0 beta 3.
334
+ * DOMPDF - We've enabled font subsetting by default which should help limit the increased PDF size when using DejaVu Sans (or any other font).
335
+
336
+ = 2.2.1 =
337
+ * Bug - Fixed HTML error which caused list items to distort on PDF
338
+
339
+ = 2.2.0 =
340
+ * Compatibility - Ensure compatibility with Gravity Forms 1.7. We've updated the functions.php code and remove gform_user_notification_attachments and gform_admin_notification_attachments hooks which are now depreciated. Functions gform_pdf_create and gform_add_attachment have been removed and replaced with gfpdfe_create_and_attach_pdf(). See upgrade documentation for details.
341
+ * Enhancement - Added deployment code switch so the template redeployment feature can be turned on and off. This release doesn't require redeployment.
342
+ * Enhancement - PDF_Generator() variables were getting long and complex so the third variable is now an array which will pass all the optional arguments. The new 1.7 compatible functions.php code includes this method by default. For backwards compatibility the function will still work with the variable structure prior to 2.2.0.
343
+ * Bug - Fixed error generated by legacy code in the function PDF_processing() which is located in render_to_pdf.php.
344
+ * Bug - Images and stylesheets will now try and be accessed with a local path instead of a URL. It fixes problem where some hosts were preventing read access from a URL. No template changes are required.
345
+
346
+ = 2.1.1 =
347
+ * Bug - Signatures stopped displaying after 2.1.0 update. Fixed issue.
348
+ * Bug - First time install code now won't execute if already have configuration variables in database
349
+
350
+ = 2.1.0 =
351
+
352
+ * Feature - Product table can now be accessed directly through custom templates by running GFPDFEntryDetail::product_table($form, $lead);. See documentation for more details.
353
+ * Feature - Update screen will ask you if you want to deploy new template files, instead of overriding your modified versions.
354
+ * Feature - Product subtotal, shipping and total have been added to $form_data['field'] array to make it easier to work with product details in the custom template.
355
+ * Feature - Added two new default template files. One displays field and name in two rows (like you see when viewing an entry in the admin area) and the other removes all styling. See documentation on use.
356
+ * Security - Tightened PDF template security so that custom templates couldn't be automatically generated by just anyone. Now only logged in users with the correct privileges and the user who submitted the form (matched against IP) can auto generate a PDF. See documentation on usage.
357
+ * Depreciated - Removed form data that was added directly to the $form_data array instead of $form_data['field'] array. Users upgrading will need to update their custom templates if not using field data from the $form_data[�field'] array. If using $form_data['field'] in your custom template this won't affect you.
358
+ * Bug - Fixed problem with default template not showing and displaying a timeout error. Removed table tags and replaced with divs that are styled appropriately.
359
+ * Bug - The new plugin theme folder will successfully create when upgrading. You won't have to deactivate and reactivate to get it working.
360
+ * Bug - some installs had plugins that included the function mb_string which is also included in DOMPDF. DOMPDF will now check if the function exists before creating it.
361
+ * Bug - Remove empty signature field from the default template.
362
+ * Bug - fixed problem with redirecting to login screen even when logged in while accessing template file through the browser window directly.
363
+ * Bug - fixed error where sample template would reimport itself automatically even after deleting it. Will now only reimport if any important changes to template need to be viewed straight after an update.
364
+ * Bug - Moved render_to_pdf.php constants to pdf.php so we can use the constants in the core files. Was previously generating an error.
365
+ * Housekeeping - Cleaned up core template files, moved functions into classes and added more in-file documentation.
366
+ * Housekeeping - moved install/upgrade code from pdf.php to installation-update-manager.php
367
+ * Housekeeping - changed pdf-entry-detail.php class name from GFEntryDetail to GFPDFEntryDetail to remove compatibility problems with Gravity Forms.
368
+ * Housekeeping - created pdf-settings.php file to house the settings page code.
369
+
370
+ = 2.0.1 =
371
+ * Fixed Signature bug when checking if image file exists using URL instead of filesystem path
372
+ * Fixed PHP Constants Notice
373
+
374
+ = 2.0.0 =
375
+ * Moved templates to active theme folder to prevent custom themes being removed on upgrade
376
+ * Allow PDFs to be saved using a custom name
377
+ * Fixed WP_Error bug when image/css file cannot be found
378
+ * Upgraded to latest version of DOMPDF
379
+ * Removed auto-load form bug which would see multiple instances of the example form loaded
380
+ * Created a number of constants to allow easier developer modification
381
+ * Plugin/Support moved to dedicated website.
382
+ * Pro/Business package offers the ability to write fields on an existing PDF.
383
+
384
+ = 1.2.3 =
385
+ * Fixed $wpdb->prepare error
386
+
387
+ = 1.2.2 =
388
+ * Fixed bug with tempalte shipping method MERGETAGS
389
+ * Fixed bug where attachment wasn't being sent
390
+ * Fixed problem when all_url_fopen was turned off on server and failed to retreive remote images. Now uses WP_HTTP class.
391
+
392
+ = 1.2.1 =
393
+ * Fixed path to custom css file included in PDF template
394
+
395
+ = 1.2.0 =
396
+ * Template files moved to the plugin's template folder
397
+ * Sample Form installed so developers have a working example to modify
398
+ * Fixed bug when using WordPress in another directory to the site
399
+
400
+ = 1.1.0 =
401
+ * Now compatible with Gravity Forms Signature Add-On
402
+ * Moved the field data functions out side of the Gravity Forms core so users can freely style their form information (located in pdf-entry-detail.php)
403
+ * Simplified the field data output
404
+ * Fixed bug when using product information
405
+
406
+ = 1.0.0 =
407
+ * First release.
408
+
409
+ == Upgrade Notice ==
410
+
411
+ = 3.4.0.1 =
412
+ mPDF upgrade. Full Survey, Poll and Quiz support. Paypal Delayed notifications support. Enhanced $form_data array. More filters and hooks for developers.
helper/installation-update-manager.php CHANGED
@@ -1,535 +1,520 @@
1
- <?php
2
-
3
- /**
4
- * Plugin: Gravity Forms PDF Extended
5
- * File: install-update-manager.php
6
- *
7
- * This file handles the installation and update code that ensures the plugin will be supported.
8
- */
9
-
10
- /**
11
- * Check to see if Gravity Forms version is supported
12
- */
13
-
14
- class GFPDF_InstallUpdater
15
- {
16
-
17
- public static function check_filesystem_api()
18
- {
19
- global $gfpdfe_data;
20
- $access_type = get_filesystem_method();
21
-
22
- $gfpdfe_data->automated = false;
23
- if($access_type === 'direct')
24
- {
25
- $gfpdfe_data->automated = true;
26
- }
27
- }
28
-
29
- /*
30
- * Check if we can automatically deploy the software
31
- * We use WP Filesystem API to initialise.
32
- * Check if we have direct write control to the filesystem. If so, automatically deploy
33
- * without asking the user. This will make upgrades much simplier.
34
- */
35
- public static function maybe_deploy()
36
- {
37
- global $gfpdfe_data;
38
- /*
39
- * Check if we have a 'direct' method, that the software isn't fully installed and we aren't trying to manually initialise
40
- */
41
-
42
- if($gfpdfe_data->automated === true && $gfpdfe_data->is_initialised === false && !rgpost('upgrade') && get_option('gfpdfe_automated_install') != 'installing')
43
- {
44
-
45
- /*
46
- * Initialise all multisites if a super admin is logged in
47
- */
48
- if(is_multisite() && is_super_admin())
49
- {
50
- self::run_multisite_deployment();
51
- }
52
- else
53
- {
54
- if(self::do_deploy())
55
- {
56
- /*
57
- * Output successfull automated installation message
58
- */
59
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_auto_deploy_success'));
60
- }
61
- }
62
- }
63
- }
64
-
65
- /*
66
- * Initialise all multsites in one fowl swoop
67
- */
68
- public static function run_multisite_deployment()
69
- {
70
- global $gfpdfe_data;
71
-
72
- /* add additional check incase someone doesn't call this correctly */
73
- if(!is_multisite())
74
- return false;
75
-
76
- /*
77
- * Get multisites which aren't deleted
78
- */
79
- $sites = wp_get_sites(array('deleted' => 0));
80
-
81
- if(sizeof($sites) > 0)
82
- {
83
-
84
- $success = true;
85
- $problem = array();
86
- foreach($sites as $site)
87
- {
88
- switch_to_blog( (int) $site['blog_id'] );
89
-
90
- /*
91
- * Test if the blog has gravity forms and PDF Extended active
92
- * If so, we can initialise
93
- */
94
- $gravityforms = 'gravityforms/gravityforms.php'; /* have to hardcode the folder name is they don't set it in a constant or variable */
95
- $pdfextended = GF_PDF_EXTENDED_PLUGIN_BASENAME; /* no need to hardcode the basename here */
96
-
97
- if( (is_plugin_active_for_network($gravityforms) && is_plugin_active_for_network($pdfextended)) ||
98
- (is_plugin_active($gravityforms) && is_plugin_active($pdfextended))
99
- )
100
- {
101
- /* run our deployment and output any problems */
102
- $deploy = self::do_deploy();
103
- if($deploy === false)
104
- {
105
- $success = false;
106
- $problem[] = $site;
107
- }
108
- else if ($deploy === 'false')
109
- {
110
- /*
111
- * Asking for the access details so we can write to the server
112
- * Exit early
113
- */
114
- return $deploy;
115
- }
116
- }
117
- restore_current_blog();
118
- }
119
-
120
- if(!$success)
121
- {
122
- $gfpdfe_data->network_error = $problem;
123
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_auto_deploy_network_failure'));
124
- }
125
- else
126
- {
127
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_network_deploy_success'));
128
- }
129
- }
130
- }
131
-
132
- /*
133
- * Used to automatically deploy the software
134
- * Regular initialisation (via the settings page) will call pdf_extended_activate() directly.
135
- */
136
- private static function do_deploy()
137
- {
138
- update_option('gfpdfe_automated_install', 'installing');
139
- return self::pdf_extended_activate();
140
- }
141
-
142
- /*
143
- * Different filesystems (FTP/SSH) might have a different ABSPATH than the 'direct' method
144
- * due to being rooted to a specific folder.
145
- * The $wp_filesystem->abspath() corrects this behaviour.
146
- */
147
- private static function get_base_dir($path)
148
- {
149
- global $wp_filesystem;
150
- return str_replace(ABSPATH, $wp_filesystem->abspath(), $path);
151
- }
152
-
153
- /**
154
- * Install everything required
155
- */
156
- public static function pdf_extended_activate()
157
- {
158
- /*
159
- * Initialise the Wordpress Filesystem API
160
- */
161
- if(PDF_Common::initialise_WP_filesystem_API(array('gfpdf_deploy', 'overwrite'), 'pdf-extended-filesystem') === false)
162
- {
163
- return 'false';
164
- }
165
-
166
- /*
167
- * If we got here we should have $wp_filesystem available
168
- */
169
- global $wp_filesystem, $gfpdfe_data;
170
-
171
- /*
172
- * Set the correct paths
173
- * FTP and SSH could be rooted to the wordpress base directory
174
- * use $wp_filesystem->abspath(); function to fix any issues
175
- */
176
- $directory = self::get_base_dir(PDF_PLUGIN_DIR);
177
- $template_directory = self::get_base_dir(PDF_TEMPLATE_LOCATION);
178
- $template_save_directory = self::get_base_dir(PDF_SAVE_LOCATION);
179
- $template_font_directory = self::get_base_dir(PDF_FONT_LOCATION);
180
-
181
- /**
182
- * If PDF_TEMPLATE_LOCATION already exists then we will remove the old template files so we can redeploy the new ones
183
- */
184
- if($wp_filesystem->exists($template_directory) && isset($_POST['overwrite']))
185
- {
186
- /*
187
- * Create a backup folder and move all the files there
188
- */
189
- $backup_folder = 'INIT_BACKUP_' . date('Y-m-d_G-i') . '/';
190
- $do_backup = false;
191
- if($wp_filesystem->mkdir($template_directory . $backup_folder ))
192
- {
193
- $do_backup = true;
194
- }
195
-
196
-
197
- /* read all file names into array and unlink from active theme template folder */
198
- foreach(glob($directory.'initialisation/templates/*') as $file) {
199
- $path_parts = pathinfo($file);
200
- if($wp_filesystem->exists($template_directory.$path_parts['basename']))
201
- {
202
- if(!$do_backup)
203
- {
204
- $wp_filesystem->delete($template_directory.$path_parts['basename']);
205
- continue;
206
- }
207
- $wp_filesystem->move($template_directory.$path_parts['basename'], $template_directory . $backup_folder . $path_parts['basename']);
208
- }
209
- }
210
- }
211
-
212
- /* create new directory in active themes folder*/
213
- if(!$wp_filesystem->is_dir($template_directory))
214
- {
215
- if($wp_filesystem->mkdir($template_directory) === false)
216
- {
217
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_template_dir_err'));
218
- return false;
219
- }
220
- }
221
-
222
- if(!$wp_filesystem->is_dir($template_save_directory))
223
- {
224
- /* create new directory in active themes folder*/
225
- if($wp_filesystem->mkdir($template_save_directory) === false)
226
- {
227
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_template_dir_err'));
228
- return false;
229
- }
230
- }
231
-
232
- if(!$wp_filesystem->is_dir($template_font_directory))
233
- {
234
- /* create new directory in active themes folder*/
235
- if($wp_filesystem->mkdir($template_font_directory) === false)
236
- {
237
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_template_dir_err'));
238
- return false;
239
- }
240
- }
241
-
242
- /*
243
- * Copy entire template folder over to PDF_TEMPLATE_LOCATION
244
- */
245
- self::pdf_extended_copy_directory( $directory . 'initialisation/templates', $template_directory, false );
246
-
247
- if(!$wp_filesystem->exists($template_directory .'configuration.php'))
248
- {
249
- /* copy template files to new directory */
250
- if(!$wp_filesystem->copy($directory .'initialisation/configuration.php.example', $template_directory.'configuration.php'))
251
- {
252
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_template_dir_err'));
253
- return false;
254
- }
255
- }
256
-
257
- if(!$wp_filesystem->exists($template_save_directory.'.htaccess'))
258
- {
259
- if(!$wp_filesystem->put_contents($template_save_directory.'.htaccess', 'deny from all'))
260
- {
261
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_template_dir_err'));
262
- return false;
263
- }
264
- }
265
-
266
- if(self::install_fonts($directory, $template_directory, $template_font_directory) !== true)
267
- {
268
- return false;
269
- }
270
-
271
- /*
272
- * Update system to ensure everything is installed correctly.
273
- */
274
- self::db_init();
275
-
276
- return true;
277
- }
278
-
279
- /*
280
- * Normalize the database options related to initialisation
281
- */
282
- public static function db_init()
283
- {
284
- global $gfpdfe_data;
285
-
286
- update_option('gf_pdf_extended_installed', 'installed');
287
- delete_option('gfpdfe_switch_theme');
288
- delete_option('gfpdfe_automated_install');
289
- GFPDF_Settings::$model->check_compatibility();
290
- }
291
-
292
- public static function initialise_fonts()
293
- {
294
- /*
295
- * Initialise the Wordpress Filesystem API
296
- */
297
- if(PDF_Common::initialise_WP_filesystem_API(array('gfpdf_deploy'), 'pdf-extended-fonts') === false)
298
- {
299
- return false;
300
- }
301
-
302
- /*
303
- * If we got here we should have $wp_filesystem available
304
- */
305
- global $wp_filesystem, $gfpdfe_data;
306
-
307
- /*
308
- * We need to set up some filesystem compatibility checkes to work with the different server file management types
309
- * Most notably is the FTP options, but SSH may be effected too
310
- */
311
- $directory = self::get_base_dir(PDF_PLUGIN_DIR);
312
- $template_directory = self::get_base_dir(PDF_TEMPLATE_LOCATION);
313
- $template_font_directory = self::get_base_dir(PDF_FONT_LOCATION);
314
-
315
- if(self::install_fonts($directory, $template_directory, $template_font_directory) === true)
316
- {
317
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_font_install_success'));
318
- }
319
- return true;
320
- }
321
-
322
- private static function install_fonts($directory, $template_directory, $fonts_location)
323
- {
324
-
325
- global $wp_filesystem, $gfpdfe_data;
326
- $write_to_file = '<?php
327
-
328
- if(!defined("PDF_EXTENDED_VERSION"))
329
- {
330
- return;
331
- }
332
-
333
- ';
334
-
335
- /*
336
- * Search the font folder for .ttf files. If found, move them to the mPDF font folder
337
- * and write the configuration file
338
- */
339
-
340
- /* read all file names into array and unlink from active theme template folder */
341
- foreach(glob($fonts_location.'/*.[tT][tT][fF]') as $file) {
342
-
343
- $path_parts = pathinfo($file);
344
-
345
- /*
346
- * Check if the files already exist in the mPDF font folder
347
- */
348
- if(!$wp_filesystem->exists($directory . 'mPDF/ttfonts/' . $path_parts['basename']))
349
- {
350
- /*
351
- * copy ttf file to the mPDF font folder
352
- */
353
- if($wp_filesystem->copy($file, $directory . 'mPDF/ttfonts/' . $path_parts['basename']) === false)
354
- {
355
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_font_err'));
356
- return false;
357
- }
358
- }
359
-
360
- /*
361
- * Generate configuration information in preparation to write to file
362
- */
363
- $write_to_file .= '
364
- $this->fontdata[\''.strtolower($path_parts['filename']).'\'] = array(
365
- \'R\' => \''.$path_parts['basename'].'\'
366
- );';
367
-
368
- }
369
-
370
- /*
371
- * Remove the old configuration file and put the contents of $write_to_file in a font configuration file
372
- */
373
- $wp_filesystem->delete($template_directory.'fonts/config.php');
374
- if($wp_filesystem->put_contents($template_directory.'fonts/config.php', $write_to_file) === false)
375
- {
376
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_font_config_err'));
377
- return false;
378
- }
379
-
380
- return true;
381
- }
382
-
383
- /*
384
- * When switching themes copy over current active theme's PDF_EXTENDED_TEMPLATES (if it exists) to new theme folder
385
- */
386
- public static function gf_pdf_on_switch_theme($old_theme_name, $old_theme_object) {
387
-
388
- /*
389
- * We will store the old pdf dir and new pdf directory and prompt the user to copy the PDF_EXTENDED_TEMPLATES folder
390
- */
391
- $previous_theme_directory = $old_theme_object->get_stylesheet_directory();
392
-
393
- $current_theme_array = wp_get_theme();
394
- $current_theme_directory = $current_theme_array->get_stylesheet_directory();
395
-
396
- /*
397
- * Add the save folder name to the end of the paths
398
- */
399
- $old_pdf_path = $previous_theme_directory . '/' . PDF_SAVE_FOLDER;
400
- $new_pdf_path = $current_theme_directory . '/' . PDF_SAVE_FOLDER;
401
-
402
- update_option('gfpdfe_switch_theme', array('old' => $old_pdf_path, 'new' => $new_pdf_path));
403
-
404
- /* add action to check if we can auto sync */
405
- /* filesystem API isn't avaliable during this action (too early) */
406
- add_action('admin_init', array('GFPDF_InstallUpdater', 'maybe_autosync'));
407
- }
408
-
409
- public static function maybe_autosync()
410
- {
411
- global $gfpdfe_data;
412
- self::check_filesystem_api();
413
-
414
- if($gfpdfe_data->automated === true)
415
- {
416
- $theme_switch = get_option('gfpdfe_switch_theme');
417
- self::do_theme_switch($theme_switch['old'], $theme_switch['new']);
418
- }
419
- }
420
-
421
- /*
422
- * Check if a theme switch has been made recently
423
- * If it has then prompt the user to move the files
424
- */
425
- public static function check_theme_switch()
426
- {
427
- global $gfpdfe_data;
428
-
429
- $theme_switch = get_option('gfpdfe_switch_theme');
430
-
431
- if(isset($theme_switch['old']) && isset($theme_switch['new']))
432
- {
433
- /*
434
- * Add admin notification hook to move the files
435
- */
436
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'do_theme_switch_notice'));
437
- return true;
438
- }
439
- return false;
440
- }
441
-
442
-
443
- /*
444
- * The after_switch_theme hook is too early in the initialisation to use request_filesystem_credentials()
445
- * so we have to call this function at a later inteval
446
- */
447
- public static function do_theme_switch($previous_pdf_path, $current_pdf_path)
448
- {
449
- /*
450
- * Prepare for calling the WP Filesystem
451
- * It only allows post data to be added so we have to manually assign them
452
- */
453
- $_POST['previous_pdf_path'] = $previous_pdf_path;
454
- $_POST['current_pdf_path'] = $current_pdf_path;
455
-
456
- /*
457
- * Initialise the Wordpress Filesystem API
458
- */
459
- if(PDF_Common::initialise_WP_filesystem_API(array('previous_pdf_path', 'current_pdf_path'), 'gfpdfe_sync_now') === false)
460
- {
461
- return 'false';
462
- }
463
-
464
- /*
465
- * If we got here we should have $wp_filesystem available
466
- */
467
- global $wp_filesystem, $gfpdfe_data;
468
-
469
- /*
470
- * Convert paths for SSH/FTP users who are rooted to a directory along the server absolute path
471
- */
472
- $previous_pdf_path = self::get_base_dir($previous_pdf_path);
473
- $current_pdf_path = self::get_base_dir($current_pdf_path);
474
-
475
- if($wp_filesystem->is_dir($previous_pdf_path))
476
- {
477
- self::pdf_extended_copy_directory( $previous_pdf_path, $current_pdf_path, true, true );
478
-
479
- /*
480
- * Remove the options key that triggers the switch theme function
481
- */
482
- delete_option('gfpdfe_switch_theme');
483
- add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_theme_sync_success'));
484
-
485
- /*
486
- * Show success message to user
487
- */
488
- return true;
489
- }
490
- return false;
491
- }
492
-
493
- /*
494
- * Allows you to copy entire folder structures to new location
495
- */
496
- public static function pdf_extended_copy_directory( $source, $destination, $copy_base = true, $delete_destination = false )
497
- {
498
- global $wp_filesystem;
499
-
500
- if ( $wp_filesystem->is_dir( $source ) )
501
- {
502
- if($delete_destination === true)
503
- {
504
- /*
505
- * To ensure everything stays in sync we will remove the destination file structure
506
- */
507
- $wp_filesystem->delete($destination, true);
508
- }
509
-
510
- if($copy_base === true)
511
- {
512
- $wp_filesystem->mkdir( $destination );
513
- }
514
- $directory = $wp_filesystem->dirlist( $source );
515
-
516
- foreach($directory as $name => $data)
517
- {
518
-
519
- $PathDir = $source . '/' . $name;
520
-
521
- if ( $wp_filesystem->is_dir( $PathDir ) )
522
- {
523
- self::pdf_extended_copy_directory( $PathDir, $destination . '/' . $name );
524
- continue;
525
- }
526
- $wp_filesystem->copy( $PathDir, $destination . '/' . $name );
527
- }
528
-
529
- }
530
- else
531
- {
532
- $wp_filesystem->copy( $source, $destination );
533
- }
534
- }
535
- }
1
+ <?php
2
+
3
+ /**
4
+ * Plugin: Gravity Forms PDF Extended
5
+ * File: install-update-manager.php
6
+ *
7
+ * This file handles the installation and update code that ensures the plugin will be supported.
8
+ */
9
+
10
+ /**
11
+ * Check to see if Gravity Forms version is supported
12
+ */
13
+
14
+ class GFPDF_InstallUpdater
15
+ {
16
+
17
+ public static function check_filesystem_api()
18
+ {
19
+ global $gfpdfe_data;
20
+ $access_type = get_filesystem_method();
21
+
22
+ $gfpdfe_data->automated = false;
23
+ if($access_type === 'direct')
24
+ {
25
+ $gfpdfe_data->automated = true;
26
+ }
27
+ }
28
+
29
+ /*
30
+ * Check if we can automatically deploy the software
31
+ * We use WP Filesystem API to initialise.
32
+ * Check if we have direct write control to the filesystem. If so, automatically deploy
33
+ * without asking the user. This will make upgrades much simplier.
34
+ */
35
+ public static function maybe_deploy()
36
+ {
37
+ global $gfpdfe_data;
38
+ /*
39
+ * Check if we have a 'direct' method, that the software isn't fully installed and we aren't trying to manually initialise
40
+ */
41
+
42
+ if($gfpdfe_data->automated === true && $gfpdfe_data->is_initialised === false && !rgpost('upgrade') && get_option('gfpdfe_automated_install') != 'installing')
43
+ {
44
+
45
+ /*
46
+ * Initialise all multisites if a super admin is logged in
47
+ */
48
+ if(is_multisite() && is_super_admin())
49
+ {
50
+ self::run_multisite_deployment();
51
+ }
52
+ else
53
+ {
54
+ if(self::do_deploy())
55
+ {
56
+ /*
57
+ * Output successfull automated installation message
58
+ */
59
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_auto_deploy_success'));
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ /*
66
+ * Initialise all multsites in one fowl swoop
67
+ */
68
+ public static function run_multisite_deployment()
69
+ {
70
+ global $gfpdfe_data;
71
+
72
+ /* add additional check incase someone doesn't call this correctly */
73
+ if(!is_multisite())
74
+ return false;
75
+
76
+ /*
77
+ * Get multisites which aren't deleted
78
+ */
79
+ $sites = wp_get_sites(array('deleted' => 0));
80
+
81
+ if(sizeof($sites) > 0)
82
+ {
83
+
84
+ $success = true;
85
+ $problem = array();
86
+ foreach($sites as $site)
87
+ {
88
+ switch_to_blog( (int) $site['blog_id'] );
89
+
90
+ /*
91
+ * Test if the blog has gravity forms and PDF Extended active
92
+ * If so, we can initialise
93
+ */
94
+ $gravityforms = 'gravityforms/gravityforms.php'; /* have to hardcode the folder name is they don't set it in a constant or variable */
95
+ $pdfextended = GF_PDF_EXTENDED_PLUGIN_BASENAME; /* no need to hardcode the basename here */
96
+
97
+ if( (is_plugin_active_for_network($gravityforms) && is_plugin_active_for_network($pdfextended)) ||
98
+ (is_plugin_active($gravityforms) && is_plugin_active($pdfextended))
99
+ )
100
+ {
101
+ /* run our deployment and output any problems */
102
+ $deploy = self::do_deploy();
103
+ if($deploy === false)
104
+ {
105
+ $success = false;
106
+ $problem[] = $site;
107
+ }
108
+ else if ($deploy === 'false')
109
+ {
110
+ /*
111
+ * Asking for the access details so we can write to the server
112
+ * Exit early
113
+ */
114
+ return $deploy;
115
+ }
116
+ }
117
+ restore_current_blog();
118
+ }
119
+
120
+ if(!$success)
121
+ {
122
+ $gfpdfe_data->network_error = $problem;
123
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_auto_deploy_network_failure'));
124
+ }
125
+ else
126
+ {
127
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_network_deploy_success'));
128
+ }
129
+ }
130
+ }
131
+
132
+ /*
133
+ * Used to automatically deploy the software
134
+ * Regular initialisation (via the settings page) will call pdf_extended_activate() directly.
135
+ */
136
+ private static function do_deploy()
137
+ {
138
+ update_option('gfpdfe_automated_install', 'installing');
139
+ return self::pdf_extended_activate();
140
+ }
141
+
142
+ /*
143
+ * Different filesystems (FTP/SSH) might have a different ABSPATH than the 'direct' method
144
+ * due to being rooted to a specific folder.
145
+ * The $wp_filesystem->abspath() corrects this behaviour.
146
+ */
147
+ private static function get_base_dir($path)
148
+ {
149
+ global $wp_filesystem;
150
+ return str_replace(ABSPATH, $wp_filesystem->abspath(), $path);
151
+ }
152
+
153
+ /**
154
+ * Install everything required
155
+ */
156
+ public static function pdf_extended_activate()
157
+ {
158
+ /*
159
+ * Initialise the Wordpress Filesystem API
160
+ */
161
+ if(PDF_Common::initialise_WP_filesystem_API(array('gfpdf_deploy', 'overwrite'), 'pdf-extended-filesystem') === false)
162
+ {
163
+ return 'false';
164
+ }
165
+
166
+ /*
167
+ * If we got here we should have $wp_filesystem available
168
+ */
169
+ global $wp_filesystem, $gfpdfe_data;
170
+
171
+ /*
172
+ * Set the correct paths
173
+ * FTP and SSH could be rooted to the wordpress base directory
174
+ * use $wp_filesystem->abspath(); function to fix any issues
175
+ */
176
+ $directory = self::get_base_dir(PDF_PLUGIN_DIR);
177
+ $template_directory = self::get_base_dir(PDF_TEMPLATE_LOCATION);
178
+ $template_save_directory = self::get_base_dir(PDF_SAVE_LOCATION);
179
+ $template_font_directory = self::get_base_dir(PDF_FONT_LOCATION);
180
+
181
+ /**
182
+ * If PDF_TEMPLATE_LOCATION already exists then we will remove the old template files so we can redeploy the new ones
183
+ */
184
+ if($wp_filesystem->exists($template_directory) && isset($_POST['overwrite']))
185
+ {
186
+ /*
187
+ * Create a backup folder and move all the files there
188
+ */
189
+ $backup_folder = 'INIT_BACKUP_' . date('Y-m-d_G-i') . '/';
190
+ $do_backup = false;
191
+ if($wp_filesystem->mkdir($template_directory . $backup_folder ))
192
+ {
193
+ $do_backup = true;
194
+ }
195
+
196
+
197
+ /* read all file names into array and unlink from active theme template folder */
198
+ foreach(glob($directory.'initialisation/templates/*') as $file) {
199
+ $path_parts = pathinfo($file);
200
+ if($wp_filesystem->exists($template_directory.$path_parts['basename']))
201
+ {
202
+ if(!$do_backup)
203
+ {
204
+ $wp_filesystem->delete($template_directory.$path_parts['basename']);
205
+ continue;
206
+ }
207
+ $wp_filesystem->move($template_directory.$path_parts['basename'], $template_directory . $backup_folder . $path_parts['basename']);
208
+ }
209
+ }
210
+ }
211
+
212
+ /* create new directory in active themes folder*/
213
+ if(!$wp_filesystem->is_dir($template_directory))
214
+ {
215
+ if($wp_filesystem->mkdir($template_directory) === false)
216
+ {
217
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_template_dir_err'));
218
+ return false;
219
+ }
220
+ }
221
+
222
+ if(!$wp_filesystem->is_dir($template_save_directory))
223
+ {
224
+ /* create new directory in active themes folder*/
225
+ if($wp_filesystem->mkdir($template_save_directory) === false)
226
+ {
227
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_template_dir_err'));
228
+ return false;
229
+ }
230
+ }
231
+
232
+ if(!$wp_filesystem->is_dir($template_font_directory))
233
+ {
234
+ /* create new directory in active themes folder*/
235
+ if($wp_filesystem->mkdir($template_font_directory) === false)
236
+ {
237
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_template_dir_err'));
238
+ return false;
239
+ }
240
+ }
241
+
242
+ /*
243
+ * Copy entire template folder over to PDF_TEMPLATE_LOCATION
244
+ */
245
+ self::pdf_extended_copy_directory( $directory . 'initialisation/templates', $template_directory, false );
246
+
247
+ if(!$wp_filesystem->exists($template_directory .'configuration.php'))
248
+ {
249
+ /* copy template files to new directory */
250
+ if(!$wp_filesystem->copy($directory .'initialisation/configuration.php.example', $template_directory.'configuration.php'))
251
+ {
252
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_template_dir_err'));
253
+ return false;
254
+ }
255
+ }
256
+
257
+ if(!$wp_filesystem->exists($template_save_directory.'.htaccess'))
258
+ {
259
+ if(!$wp_filesystem->put_contents($template_save_directory.'.htaccess', 'deny from all'))
260
+ {
261
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_template_dir_err'));
262
+ return false;
263
+ }
264
+ }
265
+
266
+ if(self::install_fonts($directory, $template_directory, $template_font_directory) !== true)
267
+ {
268
+ return false;
269
+ }
270
+
271
+ /*
272
+ * Update system to ensure everything is installed correctly.
273
+ */
274
+ self::db_init();
275
+
276
+ return true;
277
+ }
278
+
279
+ /*
280
+ * Normalize the database options related to initialisation
281
+ */
282
+ public static function db_init()
283
+ {
284
+ global $gfpdfe_data;
285
+
286
+ update_option('gf_pdf_extended_installed', 'installed');
287
+ delete_option('gfpdfe_switch_theme');
288
+ delete_option('gfpdfe_automated_install');
289
+ GFPDF_Settings::$model->check_compatibility();
290
+ }
291
+
292
+ public static function initialise_fonts()
293
+ {
294
+ /*
295
+ * Initialise the Wordpress Filesystem API
296
+ */
297
+ if(PDF_Common::initialise_WP_filesystem_API(array('gfpdf_deploy'), 'pdf-extended-fonts') === false)
298
+ {
299
+ return false;
300
+ }
301
+
302
+ /*
303
+ * If we got here we should have $wp_filesystem available
304
+ */
305
+ global $wp_filesystem, $gfpdfe_data;
306
+
307
+ /*
308
+ * We need to set up some filesystem compatibility checkes to work with the different server file management types
309
+ * Most notably is the FTP options, but SSH may be effected too
310
+ */
311
+ $directory = self::get_base_dir(PDF_PLUGIN_DIR);
312
+ $template_directory = self::get_base_dir(PDF_TEMPLATE_LOCATION);
313
+ $template_font_directory = self::get_base_dir(PDF_FONT_LOCATION);
314
+
315
+ if(self::install_fonts($directory, $template_directory, $template_font_directory) === true)
316
+ {
317
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_font_install_success'));
318
+ }
319
+ return true;
320
+ }
321
+
322
+ private static function install_fonts($directory, $template_directory, $fonts_location)
323
+ {
324
+
325
+ global $wp_filesystem, $gfpdfe_data;
326
+ $write_to_file = '<?php
327
+
328
+ if(!defined("PDF_EXTENDED_VERSION"))
329
+ {
330
+ return;
331
+ }
332
+
333
+ ';
334
+
335
+ /*
336
+ * Search the font folder for .ttf files. If found, move them to the mPDF font folder
337
+ * and write the configuration file
338
+ */
339
+
340
+ /* read all file names into array and unlink from active theme template folder */
341
+ foreach(glob($fonts_location.'/*.[tT][tT][fF]') as $file) {
342
+
343
+ $path_parts = pathinfo($file);
344
+
345
+ /*
346
+ * Generate configuration information in preparation to write to file
347
+ */
348
+ $write_to_file .= '
349
+ $this->fontdata[\''.strtolower($path_parts['filename']).'\'] = array(
350
+ \'R\' => \''.$path_parts['basename'].'\'
351
+ );';
352
+
353
+ }
354
+
355
+ /*
356
+ * Remove the old configuration file and put the contents of $write_to_file in a font configuration file
357
+ */
358
+ $wp_filesystem->delete($template_directory.'fonts/config.php');
359
+ if($wp_filesystem->put_contents($template_directory.'fonts/config.php', $write_to_file) === false)
360
+ {
361
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_font_config_err'));
362
+ return false;
363
+ }
364
+
365
+ return true;
366
+ }
367
+
368
+ /*
369
+ * When switching themes copy over current active theme's PDF_EXTENDED_TEMPLATES (if it exists) to new theme folder
370
+ */
371
+ public static function gf_pdf_on_switch_theme($old_theme_name, $old_theme_object) {
372
+
373
+ /*
374
+ * We will store the old pdf dir and new pdf directory and prompt the user to copy the PDF_EXTENDED_TEMPLATES folder
375
+ */
376
+ $previous_theme_directory = $old_theme_object->get_stylesheet_directory();
377
+
378
+ $current_theme_array = wp_get_theme();
379
+ $current_theme_directory = $current_theme_array->get_stylesheet_directory();
380
+
381
+ /*
382
+ * Add the save folder name to the end of the paths
383
+ */
384
+ $old_pdf_path = $previous_theme_directory . '/' . PDF_SAVE_FOLDER;
385
+ $new_pdf_path = $current_theme_directory . '/' . PDF_SAVE_FOLDER;
386
+
387
+ update_option('gfpdfe_switch_theme', array('old' => $old_pdf_path, 'new' => $new_pdf_path));
388
+
389
+ /* add action to check if we can auto sync */
390
+ /* filesystem API isn't avaliable during this action (too early) */
391
+ add_action('admin_init', array('GFPDF_InstallUpdater', 'maybe_autosync'));
392
+ }
393
+
394
+ public static function maybe_autosync()
395
+ {
396
+ global $gfpdfe_data;
397
+ self::check_filesystem_api();
398
+
399
+ if($gfpdfe_data->automated === true)
400
+ {
401
+ $theme_switch = get_option('gfpdfe_switch_theme');
402
+ self::do_theme_switch($theme_switch['old'], $theme_switch['new']);
403
+ }
404
+ }
405
+
406
+ /*
407
+ * Check if a theme switch has been made recently
408
+ * If it has then prompt the user to move the files
409
+ */
410
+ public static function check_theme_switch()
411
+ {
412
+ global $gfpdfe_data;
413
+
414
+ $theme_switch = get_option('gfpdfe_switch_theme');
415
+
416
+ if(isset($theme_switch['old']) && isset($theme_switch['new']))
417
+ {
418
+ /*
419
+ * Add admin notification hook to move the files
420
+ */
421
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'do_theme_switch_notice'));
422
+ return true;
423
+ }
424
+ return false;
425
+ }
426
+
427
+
428
+ /*
429
+ * The after_switch_theme hook is too early in the initialisation to use request_filesystem_credentials()
430
+ * so we have to call this function at a later inteval
431
+ */
432
+ public static function do_theme_switch($previous_pdf_path, $current_pdf_path)
433
+ {
434
+ /*
435
+ * Prepare for calling the WP Filesystem
436
+ * It only allows post data to be added so we have to manually assign them
437
+ */
438
+ $_POST['previous_pdf_path'] = $previous_pdf_path;
439
+ $_POST['current_pdf_path'] = $current_pdf_path;
440
+
441
+ /*
442
+ * Initialise the Wordpress Filesystem API
443
+ */
444
+ if(PDF_Common::initialise_WP_filesystem_API(array('previous_pdf_path', 'current_pdf_path'), 'gfpdfe_sync_now') === false)
445
+ {
446
+ return 'false';
447
+ }
448
+
449
+ /*
450
+ * If we got here we should have $wp_filesystem available
451
+ */
452
+ global $wp_filesystem, $gfpdfe_data;
453
+
454
+ /*
455
+ * Convert paths for SSH/FTP users who are rooted to a directory along the server absolute path
456
+ */
457
+ $previous_pdf_path = self::get_base_dir($previous_pdf_path);
458
+ $current_pdf_path = self::get_base_dir($current_pdf_path);
459
+
460
+ if($wp_filesystem->is_dir($previous_pdf_path))
461
+ {
462
+ self::pdf_extended_copy_directory( $previous_pdf_path, $current_pdf_path, true, true );
463
+
464
+ /*
465
+ * Remove the options key that triggers the switch theme function
466
+ */
467
+ delete_option('gfpdfe_switch_theme');
468
+ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_theme_sync_success'));
469
+
470
+ /*
471
+ * Show success message to user
472
+ */
473
+ return true;
474
+ }
475
+ return false;
476
+ }
477
+
478
+ /*
479
+ * Allows you to copy entire folder structures to new location
480
+ */
481
+ public static function pdf_extended_copy_directory( $source, $destination, $copy_base = true, $delete_destination = false )
482
+ {
483
+ global $wp_filesystem;
484
+
485
+ if ( $wp_filesystem->is_dir( $source ) )
486
+ {
487
+ if($delete_destination === true)
488
+ {
489
+ /*
490
+ * To ensure everything stays in sync we will remove the destination file structure
491
+ */
492
+ $wp_filesystem->delete($destination, true);
493
+ }
494
+
495
+ if($copy_base === true)
496
+ {
497
+ $wp_filesystem->mkdir( $destination );
498
+ }
499
+ $directory = $wp_filesystem->dirlist( $source );
500
+
501
+ foreach($directory as $name => $data)
502
+ {
503
+
504
+ $PathDir = $source . '/' . $name;
505
+
506
+ if ( $wp_filesystem->is_dir( $PathDir ) )
507
+ {
508
+ self::pdf_extended_copy_directory( $PathDir, $destination . '/' . $name );
509
+ continue;
510
+ }
511
+ $wp_filesystem->copy( $PathDir, $destination . '/' . $name );
512
+ }
513
+
514
+ }
515
+ else
516
+ {
517
+ $wp_filesystem->copy( $source, $destination );
518
+ }
519
+ }
520
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
helper/notices.php CHANGED
@@ -75,18 +75,7 @@ class GFPDF_Notices
75
 
76
  self::notice($msg);
77
 
78
- }
79
-
80
- public static function gf_pdf_font_err()
81
- {
82
- $prefix = self::autoprefix();
83
- $suffix = self::autosuffix();
84
-
85
- $msg = $prefix . __('There was a problem installing the font files. Check the file permissions in the plugin folder and try again.', 'pdfextended') . $suffix;
86
-
87
- self::error($msg);
88
-
89
- }
90
 
91
  public static function gf_pdf_font_config_err()
92
  {
75
 
76
  self::notice($msg);
77
 
78
+ }
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  public static function gf_pdf_font_config_err()
81
  {
helper/pdf-configuration-indexer.php CHANGED
@@ -1,354 +1,354 @@
1
- <?php
2
-
3
- /**
4
- * Class: PDFGenerator
5
- * Plugin: Gravity Forms PDF Extended
6
- * Usage: assign options from user configuration file, automatically attach PDFs to specified Gravity Forms, and view PDF from admin area.
7
- */
8
-
9
- class PDFGenerator
10
- {
11
-
12
- /*
13
- * Set default values for forms not assigned a PDF
14
- */
15
- public static $default = array(
16
- 'template' => 'default-template.php',
17
- 'pdf_size' => 'a4',
18
- 'orientation' => 'portrait',
19
- 'rtf' => false,
20
- 'security' => false
21
- );
22
-
23
- public static $allowed_privileges = array('copy', 'print', 'modify', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-highres');
24
-
25
- public $configuration = array();
26
-
27
- /*
28
- * Switch to verify if configuration file exists.
29
- * If not, user is using old functions.php method and we
30
- * don't want to interfere with it.
31
- */
32
- public $disabled = false;
33
-
34
- /*
35
- * The index holds the form_id and configuration key in $this->configuration
36
- * so each form knows
37
- */
38
- public $index = array();
39
-
40
- public function __construct()
41
- {
42
-
43
- /*
44
- * Do configuration pre-processing
45
- */
46
-
47
- /*
48
- * Check if user configuration file exists
49
- * If not disable $configuration and $index.
50
- */
51
- if(!file_exists(PDF_TEMPLATE_LOCATION.'configuration.php'))
52
- {
53
- $this->disabled = true;
54
- return;
55
- }
56
- else
57
- {
58
- /*
59
- * Include the configuration file and set up the configuration variable.
60
- */
61
- require(PDF_TEMPLATE_LOCATION.'configuration.php');
62
- /*
63
- * $gf_pdf_config included from configuration.php file
64
- */
65
- $this->configuration = (isset($gf_pdf_config)) ? $gf_pdf_config : array();
66
-
67
- /*
68
- * Merge down the default configuration options
69
- */
70
- foreach($this->configuration as &$node)
71
- {
72
- $node = $this->merge_defaults($node);
73
- }
74
- }
75
-
76
- $this->pdf_config();
77
- }
78
-
79
- /**
80
- * Merge the configuration node with the default options, ensuring the config node takes precendent
81
- * @param array $config the configuration node from $gfpdf->configuration()
82
- * @return array Merged default/node configuration options
83
- */
84
- private function merge_defaults($config)
85
- {
86
- global $gf_pdf_default_configuration;
87
-
88
- /*
89
- * If the default settings are set we'll merge them into the configuration index
90
- */
91
- if(is_array($gf_pdf_default_configuration) && sizeof($gf_pdf_default_configuration) > 0)
92
- {
93
- $config = array_replace_recursive($gf_pdf_default_configuration, $config);
94
- }
95
-
96
- return $config;
97
- }
98
-
99
- /*
100
- * Run through user configuration and set PDF options
101
- */
102
- private function pdf_config()
103
- {
104
- if(sizeof($this->configuration) == 0)
105
- {
106
- return;
107
- }
108
-
109
- $this->set_form_pdfs();
110
- }
111
-
112
-
113
- /*
114
- * Set the configuration index so it's faster to access template configuration information
115
- */
116
- private function set_form_pdfs()
117
- {
118
- foreach($this->configuration as $key => $config)
119
- {
120
- if(!is_array($config['form_id']))
121
- {
122
- $this->assign_index($config['form_id'], $key);
123
- }
124
- else
125
- {
126
- foreach($config['form_id'] as $id)
127
- {
128
- $this->assign_index($id, $key);
129
- }
130
- }
131
-
132
- }
133
- }
134
-
135
- /*
136
- * Check to see if ID is valid
137
- * If so, assign ID => key to index
138
- */
139
- public function assign_index($id, $key)
140
- {
141
- $id = (int) $id;
142
- if($id !== 0)
143
- {
144
- /*
145
- * Assign the outter array with the form ID and the value as the configuration key
146
- */
147
- $this->index[$id][] = $key;
148
- }
149
- }
150
-
151
- /*
152
- * Searches the index for the configuration key
153
- * Return: form PDF configuration
154
- */
155
- public function get_config($id)
156
- {
157
- return (isset($this->index[$id])) ? $this->index[$id] : false;
158
- }
159
-
160
- /*
161
- * Searches the index for the configuration key and once found return the real configuration
162
- * Return: form PDF configuration
163
- */
164
- public function get_config_data($form_id, $return_all = false)
165
- {
166
- if(!isset($this->index[$form_id]))
167
- {
168
- return false;
169
- }
170
-
171
- $index = $this->index[$form_id];
172
- /*
173
- * Because we now allow multiple PDF templates per form we need a way to get the correct PDF settings
174
- * To do this we use the $_GET variable 'aid'
175
- * If 'aid' is not found we will pull the first entry
176
- * Note: 'aid' has been incremented by 1 so 'aid' === 0 is never found
177
- */
178
- if(isset($_GET['aid']) && (int) $_GET['aid'] > 0)
179
- {
180
- $aid = (int) $_GET['aid'] - 1;
181
- return $this->configuration[$index[$aid]];
182
- }
183
-
184
- /*
185
- * No valid configuration file found so pull the default
186
- */
187
- return $this->configuration[$index[0]];
188
- }
189
-
190
- /**
191
- * Replaced get_config_data in default tempaltes to only return the default-only configuration options
192
- * @param integer $form_id form ID
193
- * @return array Default template configuration options
194
- */
195
- public function get_default_config_data($form_id)
196
- {
197
- $config = $this->pull_config_data($form_id);
198
-
199
- /* get the default template values and return in array */
200
- $show_html_fields = (isset($config['default-show-html']) && $config['default-show-html'] == 1) ? true : false;
201
- $show_empty_fields = (isset($config['default-show-empty']) && $config['default-show-empty'] == 1) ? true : false;
202
- $show_page_names = (isset($config['default-show-page-names']) && $config['default-show-page-names'] == 1) ? true : false;
203
-
204
- return array(
205
- 'html_field' => $show_html_fields,
206
- 'empty_field' => $show_empty_fields,
207
- 'page_names' => $show_page_names,
208
- );
209
- }
210
-
211
- /**
212
- * Get the configuration information based on the form ID
213
- * If multiple nodes assigned to form look for $_GET['aid']
214
- * @param integer $form_id ID of the form
215
- * @return array configuration node
216
- */
217
- private function pull_config_data($form_id)
218
- {
219
- if(!isset($this->index[$form_id]))
220
- {
221
- return false;
222
- }
223
-
224
- $index = $this->index[$form_id];
225
- /*
226
- * Because we now allow multiple PDF templates per form we need a way to get the correct PDF settings
227
- * To do this we use the $_GET variable 'aid'
228
- * If 'aid' is not found we will pull the first entry
229
- * Note: 'aid' has been incremented by 1 so 'aid' === 0 is never found
230
- */
231
- if(isset($_GET['aid']) && (int) $_GET['aid'] > 0)
232
- {
233
- $aid = (int) $_GET['aid'] - 1;
234
- return $this->configuration[$index[$aid]];
235
- }
236
-
237
- /*
238
- * No valid configuration file found so pull the default
239
- */
240
- return $this->configuration[$index[0]];
241
- }
242
-
243
- /*
244
- * Search for the template from a given form id
245
- * Return: the first template found for the form
246
- */
247
- public function get_template($form_id, $return_all = false)
248
- {
249
- global $gf_pdf_default_configuration;
250
-
251
- $template = '';
252
-
253
- /* Set the default template based on if the default is set */
254
- $default_template = self::$default['template'];
255
-
256
- if(is_array($gf_pdf_default_configuration) && sizeof($gf_pdf_default_configuration) > 0 && isset($gf_pdf_default_configuration['template']) )
257
- {
258
- $default_template = $gf_pdf_default_configuration['template'];
259
- }
260
-
261
- if(isset($this->index[$form_id]))
262
-
263
- { /*
264
- * Show all PDF nodes
265
- */
266
- if($return_all === true && sizeof($this->index[$form_id]) > 1)
267
- {
268
-
269
- $templates = array();
270
- foreach($this->index[$form_id] as $id)
271
- {
272
- $templates[$id] = array(
273
- 'template' => (isset($this->configuration[$id]['template'])) ? $this->configuration[$id]['template'] : $default_template,
274
- 'filename' => (isset($this->configuration[$id]['filename'])) ? $this->configuration[$id]['filename'] : PDF_Common::get_pdf_filename($form_id, '{entry_id}')
275
- );
276
- }
277
- return $templates;
278
- }
279
-
280
- /*
281
- * Check if PDF template is avaliable
282
- */
283
- if(isset($this->configuration[$this->index[$form_id][0]]['template']))
284
- {
285
- $user_template = (isset($_GET['template'])) ? $_GET['template'] : '';
286
- $match = false;
287
-
288
- foreach($this->index[$form_id] as $index)
289
- {
290
- if($this->configuration[$index]['template'] === $user_template)
291
- {
292
- $match = true;
293
- }
294
- }
295
-
296
- $template = ($match === true) ? $user_template : $this->configuration[$this->index[$form_id][0]]['template'];
297
- }
298
-
299
- if(strlen($template) == 0)
300
- {
301
- $template = $default_template;
302
- }
303
- return $template;
304
- }
305
-
306
- if( (strlen($template) == 0) && (GFPDF_SET_DEFAULT_TEMPLATE === true))
307
- {
308
-
309
- /*
310
- * Check if a default configuration is defined
311
- */
312
- return $default_template;
313
- }
314
- else
315
- {
316
- return false;
317
- }
318
-
319
- }
320
-
321
- public function get_pdf_name($index, $form_id = false, $lead_id = false)
322
- {
323
- if(isset($this->configuration[$index]['filename']))
324
- {
325
- return PDF_Common::validate_pdf_name($this->configuration[$index]['filename'], $form_id, $lead_id);
326
- }
327
- else
328
- {
329
- return PDF_Common::validate_pdf_name(PDF_Common::get_pdf_filename($form_id, $lead_id), $form_id, $lead_id);
330
- }
331
- }
332
-
333
- public function validate_privileges($privs)
334
- {
335
- if(!is_array($privs))
336
- {
337
- return array();
338
- }
339
-
340
- $new_privs = array_filter($privs, array($this, 'array_filter_privilages'));
341
-
342
- return $new_privs;
343
- }
344
-
345
- private function array_filter_privilages($i)
346
- {
347
- if(in_array($i, PDFGenerator::$allowed_privileges))
348
- {
349
- return true;
350
- }
351
- return false;
352
- }
353
-
354
- }
1
+ <?php
2
+
3
+ /**
4
+ * Class: PDFGenerator
5
+ * Plugin: Gravity Forms PDF Extended
6
+ * Usage: assign options from user configuration file, automatically attach PDFs to specified Gravity Forms, and view PDF from admin area.
7
+ */
8
+
9
+ class PDFGenerator
10
+ {
11
+
12
+ /*
13
+ * Set default values for forms not assigned a PDF
14
+ */
15
+ public static $default = array(
16
+ 'template' => 'default-template.php',
17
+ 'pdf_size' => 'a4',
18
+ 'orientation' => 'portrait',
19
+ 'rtf' => false,
20
+ 'security' => false
21
+ );
22
+
23
+ public static $allowed_privileges = array('copy', 'print', 'modify', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-highres');
24
+
25
+ public $configuration = array();
26
+
27
+ /*
28
+ * Switch to verify if configuration file exists.
29
+ * If not, user is using old functions.php method and we
30
+ * don't want to interfere with it.
31
+ */
32
+ public $disabled = false;
33
+
34
+ /*
35
+ * The index holds the form_id and configuration key in $this->configuration
36
+ * so each form knows
37
+ */
38
+ public $index = array();
39
+
40
+ public function __construct()
41
+ {
42
+
43
+ /*
44
+ * Do configuration pre-processing
45
+ */
46
+
47
+ /*
48
+ * Check if user configuration file exists
49
+ * If not disable $configuration and $index.
50
+ */
51
+ if(!file_exists(PDF_TEMPLATE_LOCATION.'configuration.php'))
52
+ {
53
+ $this->disabled = true;
54
+ return;
55
+ }
56
+ else
57
+ {
58
+ /*
59
+ * Include the configuration file and set up the configuration variable.
60
+ */
61
+ require(PDF_TEMPLATE_LOCATION.'configuration.php');
62
+ /*
63
+ * $gf_pdf_config included from configuration.php file
64
+ */
65
+ $this->configuration = (isset($gf_pdf_config)) ? $gf_pdf_config : array();
66
+
67
+ /*
68
+ * Merge down the default configuration options
69
+ */
70
+ foreach($this->configuration as &$node)
71
+ {
72
+ $node = $this->merge_defaults($node);
73
+ }
74
+ }
75
+
76
+ $this->pdf_config();
77
+ }
78
+
79
+ /**
80
+ * Merge the configuration node with the default options, ensuring the config node takes precendent
81
+ * @param array $config the configuration node from $gfpdf->configuration()
82
+ * @return array Merged default/node configuration options
83
+ */
84
+ private function merge_defaults($config)
85
+ {
86
+ global $gf_pdf_default_configuration;
87
+
88
+ /*
89
+ * If the default settings are set we'll merge them into the configuration index
90
+ */
91
+ if(is_array($gf_pdf_default_configuration) && sizeof($gf_pdf_default_configuration) > 0)
92
+ {
93
+ $config = array_replace_recursive($gf_pdf_default_configuration, $config);
94
+ }
95
+
96
+ return $config;
97
+ }
98
+
99
+ /*
100
+ * Run through user configuration and set PDF options
101
+ */
102
+ private function pdf_config()
103
+ {
104
+ if(sizeof($this->configuration) == 0)
105
+ {
106
+ return;
107
+ }
108
+
109
+ $this->set_form_pdfs();
110
+ }
111
+
112
+
113
+ /*
114
+ * Set the configuration index so it's faster to access template configuration information
115
+ */
116
+ private function set_form_pdfs()
117
+ {
118
+ foreach($this->configuration as $key => $config)
119
+ {
120
+ if(!is_array($config['form_id']))
121
+ {
122
+ $this->assign_index($config['form_id'], $key);
123
+ }
124
+ else
125
+ {
126
+ foreach($config['form_id'] as $id)
127
+ {
128
+ $this->assign_index($id, $key);
129
+ }
130
+ }
131
+
132
+ }
133
+ }
134
+
135
+ /*
136
+ * Check to see if ID is valid
137
+ * If so, assign ID => key to index
138
+ */
139
+ public function assign_index($id, $key)
140
+ {
141
+ $id = (int) $id;
142
+ if($id !== 0)
143
+ {
144
+ /*
145
+ * Assign the outter array with the form ID and the value as the configuration key
146
+ */
147
+ $this->index[$id][] = $key;
148
+ }
149
+ }
150
+
151
+ /*
152
+ * Searches the index for the configuration key
153
+ * Return: form PDF configuration
154
+ */
155
+ public function get_config($id)
156
+ {
157
+ return (isset($this->index[$id])) ? $this->index[$id] : false;
158
+ }
159
+
160
+ /*
161
+ * Searches the index for the configuration key and once found return the real configuration
162
+ * Return: form PDF configuration
163
+ */
164
+ public function get_config_data($form_id, $return_all = false)
165
+ {
166
+ if(!isset($this->index[$form_id]))
167
+ {
168
+ return false;
169
+ }
170
+
171
+ $index = $this->index[$form_id];
172
+ /*
173
+ * Because we now allow multiple PDF templates per form we need a way to get the correct PDF settings
174
+ * To do this we use the $_GET variable 'aid'
175
+ * If 'aid' is not found we will pull the first entry
176
+ * Note: 'aid' has been incremented by 1 so 'aid' === 0 is never found
177
+ */
178
+ if(isset($_GET['aid']) && (int) $_GET['aid'] > 0)
179
+ {
180
+ $aid = (int) $_GET['aid'] - 1;
181
+ return $this->configuration[$index[$aid]];
182
+ }
183
+
184
+ /*
185
+ * No valid configuration file found so pull the default
186
+ */
187
+ return $this->configuration[$index[0]];
188
+ }
189
+
190
+ /**
191
+ * Replaced get_config_data in default tempaltes to only return the default-only configuration options
192
+ * @param integer $form_id form ID
193
+ * @return array Default template configuration options
194
+ */
195
+ public function get_default_config_data($form_id)
196
+ {
197
+ $config = $this->pull_config_data($form_id);
198
+
199
+ /* get the default template values and return in array */
200
+ $show_html_fields = (isset($config['default-show-html']) && $config['default-show-html'] == 1) ? true : false;
201
+ $show_empty_fields = (isset($config['default-show-empty']) && $config['default-show-empty'] == 1) ? true : false;
202
+ $show_page_names = (isset($config['default-show-page-names']) && $config['default-show-page-names'] == 1) ? true : false;
203
+
204
+ return array(
205
+ 'html_field' => $show_html_fields,
206
+ 'empty_field' => $show_empty_fields,
207
+ 'page_names' => $show_page_names,
208
+ );
209
+ }
210
+
211
+ /**
212
+ * Get the configuration information based on the form ID
213
+ * If multiple nodes assigned to form look for $_GET['aid']
214
+ * @param integer $form_id ID of the form
215
+ * @return array configuration node
216
+ */
217
+ private function pull_config_data($form_id)
218
+ {
219
+ if(!isset($this->index[$form_id]))
220
+ {
221
+ return false;
222
+ }
223
+
224
+ $index = $this->index[$form_id];
225
+ /*
226
+ * Because we now allow multiple PDF templates per form we need a way to get the correct PDF settings
227
+ * To do this we use the $_GET variable 'aid'
228
+ * If 'aid' is not found we will pull the first entry
229
+ * Note: 'aid' has been incremented by 1 so 'aid' === 0 is never found
230
+ */
231
+ if(isset($_GET['aid']) && (int) $_GET['aid'] > 0)
232
+ {
233
+ $aid = (int) $_GET['aid'] - 1;
234
+ return $this->configuration[$index[$aid]];
235
+ }
236
+
237
+ /*
238
+ * No valid configuration file found so pull the default
239
+ */
240
+ return $this->configuration[$index[0]];
241
+ }
242
+
243
+ /*
244
+ * Search for the template from a given form id
245
+ * Return: the first template found for the form
246
+ */
247
+ public function get_template($form_id, $return_all = false)
248
+ {
249
+ global $gf_pdf_default_configuration;
250
+
251
+ $template = '';
252
+
253
+ /* Set the default template based on if the default is set */
254
+ $default_template = self::$default['template'];
255
+
256
+ if(is_array($gf_pdf_default_configuration) && sizeof($gf_pdf_default_configuration) > 0 && isset($gf_pdf_default_configuration['template']) )
257
+ {
258
+ $default_template = $gf_pdf_default_configuration['template'];
259
+ }
260
+
261
+ if(isset($this->index[$form_id]))
262
+
263
+ { /*
264
+ * Show all PDF nodes
265
+ */
266
+ if($return_all === true && sizeof($this->index[$form_id]) > 1)
267
+ {
268
+
269
+ $templates = array();
270
+ foreach($this->index[$form_id] as $id)
271
+ {
272
+ $templates[$id] = array(
273
+ 'template' => (isset($this->configuration[$id]['template'])) ? $this->configuration[$id]['template'] : $default_template,
274
+ 'filename' => (isset($this->configuration[$id]['filename'])) ? $this->configuration[$id]['filename'] : PDF_Common::get_pdf_filename($form_id, '{entry_id}')
275
+ );
276
+ }
277
+ return $templates;
278
+ }
279
+
280
+ /*
281
+ * Check if PDF template is avaliable
282
+ */
283
+ if(isset($this->configuration[$this->index[$form_id][0]]['template']))
284
+ {
285
+ $user_template = (isset($_GET['template'])) ? $_GET['template'] : '';
286
+ $match = false;
287
+
288
+ foreach($this->index[$form_id] as $index)
289
+ {
290
+ if($this->configuration[$index]['template'] === $user_template)
291
+ {
292
+ $match = true;
293
+ }
294
+ }
295
+
296
+ $template = ($match === true) ? $user_template : $this->configuration[$this->index[$form_id][0]]['template'];
297
+ }
298
+
299
+ if(strlen($template) == 0)
300
+ {
301
+ $template = $default_template;
302
+ }
303
+ return $template;
304
+ }
305
+
306
+ if( (strlen($template) == 0) && (GFPDF_SET_DEFAULT_TEMPLATE === true))
307
+ {
308
+
309
+ /*
310
+ * Check if a default configuration is defined
311
+ */
312
+ return $default_template;
313
+ }
314
+ else
315
+ {
316
+ return false;
317
+ }
318
+
319
+ }
320
+
321
+ public function get_pdf_name($index, $form_id = false, $lead_id = false)
322
+ {
323
+ if(isset($this->configuration[$index]['filename']))
324
+ {
325
+ return PDF_Common::validate_pdf_name($this->configuration[$index]['filename'], $form_id, $lead_id);
326
+ }
327
+ else
328
+ {
329
+ return PDF_Common::validate_pdf_name(PDF_Common::get_pdf_filename($form_id, $lead_id), $form_id, $lead_id);
330
+ }
331
+ }
332
+
333
+ public function validate_privileges($privs)
334
+ {
335
+ if(!is_array($privs))
336
+ {
337
+ return array();
338
+ }
339
+
340
+ $new_privs = array_filter($privs, array($this, 'array_filter_privilages'));
341
+
342
+ return $new_privs;
343
+ }
344
+
345
+ private function array_filter_privilages($i)
346
+ {
347
+ if(in_array($i, PDFGenerator::$allowed_privileges))
348
+ {
349
+ return true;
350
+ }
351
+ return false;
352
+ }
353
+
354
+ }
helper/pdf-render.php CHANGED
@@ -1,305 +1,316 @@
1
- <?php
2
-
3
-
4
- class PDFRender
5
- {
6
- /**
7
- * Outputs a PDF entry from a Gravity Form
8
- * var $form_id integer: The form id
9
- * var $lead_id integer: The entry id
10
- * var $output string: either view, save or download
11
- * save will save a copy of the PDF to the server using the PDF_SAVE_LOCATION constant
12
- * var $return boolean: if set to true
13
- * it will return the path of the saved PDF
14
- * var $template string: if you want to use multiple PDF templates - name of the template file
15
- * var $pdfname string: allows you to pass a custom PDF name to the generator e.g. 'Application Form.pdf' (ensure .pdf is appended to the filename)
16
- * var $fpdf boolean: custom hook to allow the FPDF engine to generate PDFs instead of DOMPDF. Premium Paid Feature.
17
- */
18
- public function PDF_Generator($form_id, $lead_id, $arguments = array())
19
- {
20
- /*
21
- * Because we merged the create and attach functions we need a measure to only run this function once per session per lead id.
22
- */
23
- static $pdf_creator = array();
24
-
25
- /*
26
- * Set user-variable to output HTML instead of PDF
27
- */
28
- $html = (isset($_GET['html'])) ? (int) $_GET['html'] : 0;
29
-
30
- /*
31
- * Join the form and lead IDs together to get the real ID
32
- */
33
- $id = $form_id . $lead_id;
34
-
35
- /*
36
- * PDF_Generator was becoming too cluttered so store all the variables in an array
37
- */
38
- $filename = $arguments['pdfname'];
39
- $template = $arguments['template'];
40
- $output = (isset($arguments['output']) && strlen($arguments['output']) > 0) ? $arguments['output'] : 'save';
41
-
42
- /*
43
- * Check if the PDF exists and if this function has already run this season
44
- */
45
- if(in_array($lead_id, $pdf_creator) && file_exists(PDF_SAVE_LOCATION.$id.'/'. $filename))
46
- {
47
- /*
48
- * Don't generate a new PDF, use the existing one
49
- */
50
- return PDF_SAVE_LOCATION.$id.'/'. $filename;
51
- }
52
-
53
- /*
54
- * Add lead to PDF creation tracker
55
- */
56
- $pdf_creator[] = $lead_id;
57
-
58
- /*
59
- * Add filter before we load the template file so we can stop the main process
60
- * Used in premium plugins
61
- * return true to cancel, otherwise run.
62
- */
63
- $return = apply_filters("gfpdfe_pre_load_template", $form_id, $lead_id, $template, $id, $output, $filename, $arguments);
64
-
65
- if($return !== true)
66
- {
67
- /*
68
- * Get the template HTML file
69
- * v3.4.0 allows mergetags to be used in PDF templates
70
- */
71
- $raw_entry = $this->load_entry_data($form_id, $lead_id, $template);
72
- $entry = apply_filters("gfpdfe_pdf_template_{$form_id}", apply_filters('gfpdfe_pdf_template', $raw_entry, $form_id, $lead_id, $arguments), $lead_id, $arguments);
73
-
74
- /*
75
- * Output HTML version and return if user requested a HTML version
76
- */
77
- if($html === 1)
78
- {
79
- echo $entry;
80
- exit;
81
- }
82
-
83
- /*
84
- * If successfully got the entry then run the processor
85
- */
86
- if(strlen($entry) > 0)
87
- {
88
- return $this->PDF_processing($entry, $filename, $id, $output, $arguments, $form_id, $lead_id);
89
- }
90
-
91
- return false;
92
- }
93
- /*
94
- * Used in extensions to return the name of the PDF file when attaching to notifications
95
- */
96
- return apply_filters('gfpdfe_return_pdf_path', $form_id, $lead_id);
97
- }
98
-
99
- /**
100
- * Loads the Gravity Form output script (actually the print preview)
101
- */
102
- private function load_entry_data($form_id, $lead_id, $template)
103
- {
104
- /* set up contstants for gravity forms to use so we can override the security on the printed version */
105
- if(file_exists(PDF_TEMPLATE_LOCATION.$template))
106
- {
107
- return PDF_Common::get_html_template(PDF_TEMPLATE_LOCATION.$template);
108
- }
109
- else
110
- {
111
- /*
112
- * Check if template file exists in the plugin's core template folder
113
- */
114
- if(file_exists(PDF_PLUGIN_DIR."templates/" . $template))
115
- {
116
- return PDF_Common::get_html_template(PDF_PLUGIN_DIR."initialisation/templates/" . $template);
117
- }
118
- /*
119
- * If template not found then we will resort to the default template.
120
- */
121
- else
122
- {
123
- return PDF_Common::get_html_template(PDF_PLUGIN_DIR."initialisation/templates/" . PDFGenerator::$default['template']);
124
- }
125
- }
126
- }
127
-
128
-
129
- /**
130
- * Creates the PDF and does a specific output (see PDF_Generator function above for $output variable types)
131
- */
132
- public function PDF_processing($html, $filename, $id, $output = 'view', $arguments, $form_id, $lead_id)
133
- {
134
- /*
135
- * DOMPDF replaced with mPDF in v3.0.0
136
- * Check which version of mpdf we are calling
137
- * Full, Lite or Tiny
138
- */
139
- if(!class_exists('mPDF'))
140
- {
141
- if(defined('PDF_ENABLE_MPDF_TINY') && PDF_ENABLE_MPDF_TINY === true)
142
- {
143
- include PDF_PLUGIN_DIR .'/mPDF/mpdf-extra-lite.php';
144
- }
145
- elseif(defined('PDF_ENABLE_MPDF_LITE') && PDF_ENABLE_MPDF_LITE === true)
146
- {
147
- include PDF_PLUGIN_DIR .'/mPDF/mpdf-lite.php';
148
- }
149
- else
150
- {
151
- include PDF_PLUGIN_DIR .'/mPDF/mpdf.php';
152
- }
153
- }
154
-
155
- /*
156
- * Initialise class and set the paper size and orientation
157
- */
158
- $paper_size = $arguments['pdf_size'];
159
-
160
- if(!is_array($paper_size))
161
- {
162
- $orientation = ($arguments['orientation'] == 'landscape') ? '-L' : '';
163
- $paper_size = $paper_size.$orientation;
164
- }
165
- else
166
- {
167
- $orientation = ($arguments['orientation'] == 'landscape') ? 'L' : 'P';
168
- }
169
-
170
- $mpdf = new mPDF('', $paper_size, 0, '', 15, 15, 16, 16, 9, 9, $orientation);
171
-
172
- /*
173
- * Display PDF is full-page mode which allows the entire PDF page to be viewed
174
- * Normally PDF is zoomed right in.
175
- */
176
- $mpdf->SetDisplayMode('fullpage');
177
-
178
- /*
179
- * Automatically detect fonts and substitue as needed
180
- */
181
- $mpdf->SetAutoFont(AUTOFONT_ALL);
182
- (defined('PDF_DISABLE_FONT_SUBSTITUTION') && PDF_DISABLE_FONT_SUBSTITUTION === false) ? $mpdf->useSubstitutions = true : $mpdf->useSubstitutions = false;
183
-
184
- /*
185
- * Set Creator Meta Data
186
- */
187
- $mpdf->SetCreator('Gravity Forms PDF Extended v'. PDF_EXTENDED_VERSION.'. http://gravityformspdfextended.com');
188
-
189
- /*
190
- * Set PDF DPI if added to configuration node
191
- */
192
- if($arguments['dpi'] !== false)
193
- {
194
- /* TEXT DPI dramatically decreases the text size. As text is a vector element of the document we will only be concerned with the image DPI for the moment */
195
- /*$mpdf->dpi = $arguments['dpi'];*/
196
- $mpdf->img_dpi = $arguments['dpi'];
197
- }
198
-
199
- /*
200
- * Set RTL languages at user request
201
- */
202
- if($arguments['rtl'] === true)
203
- {
204
- $mpdf->SetDirectionality('rtl');
205
- }
206
-
207
- /*
208
- * Set up security if user requested
209
- */
210
- if($arguments['security'] === true && $arguments['pdfa1b'] === false && $arguments['pdfx1a'] === false )
211
- {
212
- $password = (strlen($arguments['pdf_password']) > 0) ? $arguments['pdf_password'] : '';
213
- $master_password = (strlen($arguments['pdf_master_password']) > 0) ? $arguments['pdf_master_password'] : null;
214
- $pdf_privileges = (is_array($arguments['pdf_privileges'])) ? $arguments['pdf_privileges'] : array();
215
-
216
- $mpdf->SetProtection($pdf_privileges, $password, $master_password, 128);
217
- }
218
-
219
- /* PDF/A1-b support added in v3.4.0 */
220
- if($arguments['pdfa1b'] === true)
221
- {
222
- $mpdf->PDFA = true;
223
- $mpdf->PDFAauto = true;
224
- }
225
- else if($arguments['pdfx1a'] === true) /* PDF/X-1a support added in v3.4.0 */
226
- {
227
- $mpdf->PDFX = true;
228
- $mpdf->PDFXauto = true;
229
- }
230
-
231
- /*
232
- * Check if we should auto prompt to print the document on open
233
- */
234
- if(isset($_GET['print']))
235
- {
236
- $mpdf->SetJS('this.print();');
237
- }
238
-
239
-
240
- /* load HTML block */
241
- $mpdf->WriteHTML($html);
242
-
243
- /*
244
- * Add pre-render/save filter so PDF can be manipulated further
245
- */
246
- $mpdf = apply_filters('gfpdfe_pre_render_pdf', $mpdf, $form_id, $lead_id, $arguments, $output, $filename);
247
- $output = apply_filters('gfpdfe_pdf_output_type', $output);
248
- $filename = apply_filters('gfpdfe_pdf_filename', $filename);
249
-
250
- switch($output)
251
- {
252
- case 'download':
253
- $mpdf->Output($filename, 'D');
254
- exit;
255
- break;
256
-
257
- case 'view':
258
- $mpdf->Output($filename, 'I');
259
- exit;
260
- break;
261
-
262
- case 'save':
263
- /*
264
- * PDF wasn't writing to file with the F method - http://mpdf1.com/manual/index.php?tid=125
265
- * Return as a string and write to file manually
266
- */
267
- $pdf = $mpdf->Output('', 'S');
268
- $filename = $this->savePDF($pdf, $filename, $id);
269
-
270
- do_action('gfpdf_post_pdf_save', $form_id, $lead_id, $arguments, $filename);
271
-
272
- return $filename;
273
- break;
274
- }
275
- }
276
-
277
-
278
- /**
279
- * Creates the PDF and does a specific output (see PDF_Generator function above for $output variable types)
280
- * var $dompdf Object
281
- */
282
- public function savePDF($pdf, $filename, $id)
283
- {
284
- /* create unique folder for PDFs */
285
- if(!is_dir(PDF_SAVE_LOCATION.$id))
286
- {
287
- if(!mkdir(PDF_SAVE_LOCATION.$id))
288
- {
289
- trigger_error('Could not create PDF folder in '. PDF_SAVE_LOCATION.$id, E_USER_WARNING);
290
- return;
291
- }
292
- }
293
-
294
- $pdf_save = PDF_SAVE_LOCATION.$id.'/'. $filename;
295
-
296
- if(!file_put_contents($pdf_save, $pdf))
297
- {
298
- trigger_error('Could not save PDF to '. $pdf_save, E_USER_WARNING);
299
- return;
300
- }
301
-
302
- return $pdf_save;
303
- }
304
- }
305
-
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class PDFRender
5
+ {
6
+ /**
7
+ * Outputs a PDF entry from a Gravity Form
8
+ * var $form_id integer: The form id
9
+ * var $lead_id integer: The entry id
10
+ * var $output string: either view, save or download
11
+ * save will save a copy of the PDF to the server using the PDF_SAVE_LOCATION constant
12
+ * var $return boolean: if set to true
13
+ * it will return the path of the saved PDF
14
+ * var $template string: if you want to use multiple PDF templates - name of the template file
15
+ * var $pdfname string: allows you to pass a custom PDF name to the generator e.g. 'Application Form.pdf' (ensure .pdf is appended to the filename)
16
+ * var $fpdf boolean: custom hook to allow the FPDF engine to generate PDFs instead of DOMPDF. Premium Paid Feature.
17
+ */
18
+ public function PDF_Generator($form_id, $lead_id, $arguments = array())
19
+ {
20
+ /*
21
+ * Because we merged the create and attach functions we need a measure to only run this function once per session per lead id.
22
+ */
23
+ static $pdf_creator = array();
24
+
25
+ /*
26
+ * Set user-variable to output HTML instead of PDF
27
+ */
28
+ $html = (isset($_GET['html'])) ? (int) $_GET['html'] : 0;
29
+
30
+ /*
31
+ * Join the form and lead IDs together to get the real ID
32
+ */
33
+ $id = $form_id . $lead_id;
34
+
35
+ /*
36
+ * PDF_Generator was becoming too cluttered so store all the variables in an array
37
+ */
38
+ $filename = $arguments['pdfname'];
39
+ $template = $arguments['template'];
40
+ $output = (isset($arguments['output']) && strlen($arguments['output']) > 0) ? $arguments['output'] : 'save';
41
+
42
+ /*
43
+ * Check if the PDF exists and if this function has already run this season
44
+ */
45
+ if(in_array($lead_id, $pdf_creator) && file_exists(PDF_SAVE_LOCATION.$id.'/'. $filename))
46
+ {
47
+ /*
48
+ * Don't generate a new PDF, use the existing one
49
+ */
50
+ return PDF_SAVE_LOCATION.$id.'/'. $filename;
51
+ }
52
+
53
+ /*
54
+ * Add lead to PDF creation tracker
55
+ */
56
+ $pdf_creator[] = $lead_id;
57
+
58
+ /*
59
+ * Add filter before we load the template file so we can stop the main process
60
+ * Used in premium plugins
61
+ * return true to cancel, otherwise run.
62
+ */
63
+ $return = apply_filters("gfpdfe_pre_load_template", $form_id, $lead_id, $template, $id, $output, $filename, $arguments);
64
+
65
+ if($return !== true)
66
+ {
67
+ /*
68
+ * Get the template HTML file
69
+ * v3.4.0 allows mergetags to be used in PDF templates
70
+ */
71
+ $raw_entry = $this->load_entry_data($form_id, $lead_id, $template);
72
+ $entry = apply_filters("gfpdfe_pdf_template_{$form_id}", apply_filters('gfpdfe_pdf_template', $raw_entry, $form_id, $lead_id, $arguments), $lead_id, $arguments);
73
+
74
+ /*
75
+ * Output HTML version and return if user requested a HTML version
76
+ */
77
+ if($html === 1)
78
+ {
79
+ echo $entry;
80
+ exit;
81
+ }
82
+
83
+ /*
84
+ * If successfully got the entry then run the processor
85
+ */
86
+ if(strlen($entry) > 0)
87
+ {
88
+ return $this->PDF_processing($entry, $filename, $id, $output, $arguments, $form_id, $lead_id);
89
+ }
90
+
91
+ return false;
92
+ }
93
+ /*
94
+ * Used in extensions to return the name of the PDF file when attaching to notifications
95
+ */
96
+ return apply_filters('gfpdfe_return_pdf_path', $form_id, $lead_id);
97
+ }
98
+
99
+ /**
100
+ * Loads the Gravity Form output script (actually the print preview)
101
+ */
102
+ private function load_entry_data($form_id, $lead_id, $template)
103
+ {
104
+ /* set up contstants for gravity forms to use so we can override the security on the printed version */
105
+ if(file_exists(PDF_TEMPLATE_LOCATION.$template))
106
+ {
107
+ return PDF_Common::get_html_template(PDF_TEMPLATE_LOCATION.$template);
108
+ }
109
+ else
110
+ {
111
+ /*
112
+ * Check if template file exists in the plugin's core template folder
113
+ */
114
+ if(file_exists(PDF_PLUGIN_DIR."templates/" . $template))
115
+ {
116
+ return PDF_Common::get_html_template(PDF_PLUGIN_DIR."initialisation/templates/" . $template);
117
+ }
118
+ /*
119
+ * If template not found then we will resort to the default template.
120
+ */
121
+ else
122
+ {
123
+ return PDF_Common::get_html_template(PDF_PLUGIN_DIR."initialisation/templates/" . PDFGenerator::$default['template']);
124
+ }
125
+ }
126
+ }
127
+
128
+
129
+ /**
130
+ * Creates the PDF and does a specific output (see PDF_Generator function above for $output variable types)
131
+ */
132
+ public function PDF_processing($html, $filename, $id, $output = 'view', $arguments, $form_id, $lead_id)
133
+ {
134
+ /*
135
+ * DOMPDF replaced with mPDF in v3.0.0
136
+ * Check which version of mpdf we are calling
137
+ * Full, Lite or Tiny
138
+ */
139
+ if(!class_exists('mPDF'))
140
+ {
141
+ if(defined('PDF_ENABLE_MPDF_TINY') && PDF_ENABLE_MPDF_TINY === true)
142
+ {
143
+ include PDF_PLUGIN_DIR .'/mPDF/mpdf-extra-lite.php';
144
+ }
145
+ elseif(defined('PDF_ENABLE_MPDF_LITE') && PDF_ENABLE_MPDF_LITE === true)
146
+ {
147
+ include PDF_PLUGIN_DIR .'/mPDF/mpdf-lite.php';
148
+ }
149
+ else
150
+ {
151
+ include PDF_PLUGIN_DIR .'/mPDF/mpdf.php';
152
+ }
153
+ }
154
+
155
+ /*
156
+ * Initialise class and set the paper size and orientation
157
+ */
158
+ $paper_size = $arguments['pdf_size'];
159
+
160
+ if(!is_array($paper_size))
161
+ {
162
+ $orientation = ($arguments['orientation'] == 'landscape') ? '-L' : '';
163
+ $paper_size = $paper_size.$orientation;
164
+ }
165
+ else
166
+ {
167
+ $orientation = ($arguments['orientation'] == 'landscape') ? 'L' : 'P';
168
+ }
169
+
170
+ $mpdf = new mPDF('', $paper_size, 0, '', 15, 15, 16, 16, 9, 9, $orientation);
171
+
172
+ /*
173
+ * Add filter to allow the $mpdf object to be modified right after the class is created.
174
+ * Because $mpdf is a class it is automatically passed by reference and doesn't need to be assigned
175
+ */
176
+ apply_filters('gfpdfe_mpdf_class', $mpdf, $form_id, $lead_id, $arguments, $output, $filename);
177
+
178
+ /*
179
+ * Display PDF is full-page mode which allows the entire PDF page to be viewed
180
+ * Normally PDF is zoomed right in.
181
+ */
182
+ $mpdf->SetDisplayMode('fullpage');
183
+
184
+ /*
185
+ * Automatically detect fonts and substitue as needed
186
+ */
187
+ $mpdf->SetAutoFont(AUTOFONT_ALL);
188
+ (defined('PDF_DISABLE_FONT_SUBSTITUTION') && PDF_DISABLE_FONT_SUBSTITUTION === false) ? $mpdf->useSubstitutions = true : $mpdf->useSubstitutions = false;
189
+
190
+ /*
191
+ * Set Creator Meta Data
192
+ */
193
+ $mpdf->SetCreator('Gravity Forms PDF Extended v'. PDF_EXTENDED_VERSION.'. http://gravityformspdfextended.com');
194
+
195
+ /*
196
+ * Set PDF DPI if added to configuration node
197
+ */
198
+ if($arguments['dpi'] !== false)
199
+ {
200
+ /* TEXT DPI dramatically decreases the text size. As text is a vector element of the document we will only be concerned with the image DPI for the moment */
201
+ /*$mpdf->dpi = $arguments['dpi'];*/
202
+ $mpdf->img_dpi = $arguments['dpi'];
203
+ }
204
+
205
+ /*
206
+ * Set RTL languages at user request
207
+ */
208
+ if($arguments['rtl'] === true)
209
+ {
210
+ $mpdf->SetDirectionality('rtl');
211
+ }
212
+
213
+ /*
214
+ * Set up security if user requested
215
+ */
216
+ if($arguments['security'] === true && $arguments['pdfa1b'] === false && $arguments['pdfx1a'] === false )
217
+ {
218
+ $password = (strlen($arguments['pdf_password']) > 0) ? $arguments['pdf_password'] : '';
219
+ $master_password = (strlen($arguments['pdf_master_password']) > 0) ? $arguments['pdf_master_password'] : null;
220
+ $pdf_privileges = (is_array($arguments['pdf_privileges'])) ? $arguments['pdf_privileges'] : array();
221
+
222
+ $mpdf->SetProtection($pdf_privileges, $password, $master_password, 128);
223
+ }
224
+
225
+ /* PDF/A1-b support added in v3.4.0 */
226
+ if($arguments['pdfa1b'] === true)
227
+ {
228
+ $mpdf->PDFA = true;
229
+ $mpdf->PDFAauto = true;
230
+ }
231
+ else if($arguments['pdfx1a'] === true) /* PDF/X-1a support added in v3.4.0 */
232
+ {
233
+ $mpdf->PDFX = true;
234
+ $mpdf->PDFXauto = true;
235
+ }
236
+
237
+ /*
238
+ * Check if we should auto prompt to print the document on open
239
+ */
240
+ if(isset($_GET['print']))
241
+ {
242
+ $mpdf->SetJS('this.print();');
243
+ }
244
+
245
+
246
+ /* load HTML block */
247
+ $mpdf->WriteHTML($html);
248
+
249
+ /*
250
+ * Allow the $mpdf object to be modified now all the settings have been applied
251
+ */
252
+ apply_filters('gfpdfe_mpdf_class_pre_render', $mpdf, $form_id, $lead_id, $arguments, $output, $filename);
253
+ apply_filters('gfpdfe_pre_render_pdf', $mpdf, $form_id, $lead_id, $arguments, $output, $filename); /* left in for backwards compatiblity */
254
+
255
+ /*
256
+ * Add pre-render/save filter so PDF can be manipulated further
257
+ */
258
+ $output = apply_filters('gfpdfe_pdf_output_type', $output);
259
+ $filename = apply_filters('gfpdfe_pdf_filename', $filename);
260
+
261
+ switch($output)
262
+ {
263
+ case 'download':
264
+ $mpdf->Output($filename, 'D');
265
+ exit;
266
+ break;
267
+
268
+ case 'view':
269
+ $mpdf->Output($filename, 'I');
270
+ exit;
271
+ break;
272
+
273
+ case 'save':
274
+ /*
275
+ * PDF wasn't writing to file with the F method - http://mpdf1.com/manual/index.php?tid=125
276
+ * Return as a string and write to file manually
277
+ */
278
+ $pdf = $mpdf->Output('', 'S');
279
+ $filename = $this->savePDF($pdf, $filename, $id);
280
+
281
+ do_action('gfpdf_post_pdf_save', $form_id, $lead_id, $arguments, $filename);
282
+
283
+ return $filename;
284
+ break;
285
+ }
286
+ }
287
+
288
+
289
+ /**
290
+ * Creates the PDF and does a specific output (see PDF_Generator function above for $output variable types)
291
+ * var $dompdf Object
292
+ */
293
+ public function savePDF($pdf, $filename, $id)
294
+ {
295
+ /* create unique folder for PDFs */
296
+ if(!is_dir(PDF_SAVE_LOCATION.$id))
297
+ {
298
+ if(!mkdir(PDF_SAVE_LOCATION.$id))
299
+ {
300
+ trigger_error('Could not create PDF folder in '. PDF_SAVE_LOCATION.$id, E_USER_WARNING);
301
+ return;
302
+ }
303
+ }
304
+
305
+ $pdf_save = PDF_SAVE_LOCATION.$id.'/'. $filename;
306
+
307
+ if(!file_put_contents($pdf_save, $pdf))
308
+ {
309
+ trigger_error('Could not save PDF to '. $pdf_save, E_USER_WARNING);
310
+ return;
311
+ }
312
+
313
+ return $pdf_save;
314
+ }
315
+ }
316
+
mPDF/mpdf-extra-lite.php CHANGED
@@ -2393,7 +2393,16 @@ function AddFont($family,$style='') {
2393
  }
2394
  if (!$ttffile) {
2395
  $ttffile = _MPDF_TTFONTPATH.$this->fontdata[$family][$stylekey];
2396
- if (!file_exists($ttffile)) { die("mPDF Error - cannot find TTF TrueType font file - ".$ttffile); }
 
 
 
 
 
 
 
 
 
2397
  }
2398
  $ttfstat = stat($ttffile);
2399
 
2393
  }
2394
  if (!$ttffile) {
2395
  $ttffile = _MPDF_TTFONTPATH.$this->fontdata[$family][$stylekey];
2396
+ if (!file_exists($ttffile)) {
2397
+ /*
2398
+ * Try load in the font file from the PDF_TEMPLATE
2399
+ */
2400
+ $ttffile = PDF_TEMPLATE_LOCATION . 'fonts/' . $this->fontdata[$family][$stylekey];
2401
+ if(!file_exists($ttffile))
2402
+ {
2403
+ die("mPDF Error - cannot find TTF TrueType font file - ".$ttffile);
2404
+ }
2405
+ }
2406
  }
2407
  $ttfstat = stat($ttffile);
2408
 
mPDF/mpdf-lite.php CHANGED
@@ -2719,7 +2719,16 @@ function AddFont($family,$style='') {
2719
  }
2720
  if (!$ttffile) {
2721
  $ttffile = _MPDF_TTFONTPATH.$this->fontdata[$family][$stylekey];
2722
- if (!file_exists($ttffile)) { die("mPDF Error - cannot find TTF TrueType font file - ".$ttffile); }
 
 
 
 
 
 
 
 
 
2723
  }
2724
  $ttfstat = stat($ttffile);
2725
 
2719
  }
2720
  if (!$ttffile) {
2721
  $ttffile = _MPDF_TTFONTPATH.$this->fontdata[$family][$stylekey];
2722
+ if (!file_exists($ttffile)) {
2723
+ /*
2724
+ * Try load in the font file from the PDF_TEMPLATE
2725
+ */
2726
+ $ttffile = PDF_TEMPLATE_LOCATION . 'fonts/' . $this->fontdata[$family][$stylekey];
2727
+ if(!file_exists($ttffile))
2728
+ {
2729
+ die("mPDF Error - cannot find TTF TrueType font file - ".$ttffile);
2730
+ }
2731
+ }
2732
  }
2733
  $ttfstat = stat($ttffile);
2734
 
mPDF/mpdf.php CHANGED
@@ -3024,7 +3024,16 @@ function AddFont($family,$style='') {
3024
  }
3025
  if (!$ttffile) {
3026
  $ttffile = _MPDF_TTFONTPATH.$this->fontdata[$family][$stylekey];
3027
- if (!file_exists($ttffile)) { die("mPDF Error - cannot find TTF TrueType font file - ".$ttffile); }
 
 
 
 
 
 
 
 
 
3028
  }
3029
  $ttfstat = stat($ttffile);
3030
 
3024
  }
3025
  if (!$ttffile) {
3026
  $ttffile = _MPDF_TTFONTPATH.$this->fontdata[$family][$stylekey];
3027
+ if (!file_exists($ttffile)) {
3028
+ /*
3029
+ * Try load in the font file from the PDF_TEMPLATE
3030
+ */
3031
+ $ttffile = PDF_TEMPLATE_LOCATION . 'fonts/' . $this->fontdata[$family][$stylekey];
3032
+ if(!file_exists($ttffile))
3033
+ {
3034
+ die("mPDF Error - cannot find TTF TrueType font file - ".$ttffile);
3035
+ }
3036
+ }
3037
  }
3038
  $ttfstat = stat($ttffile);
3039
 
model/pdf.php CHANGED
@@ -112,7 +112,8 @@ class GFPDF_Core_Model
112
 
113
  if(!is_array($templates))
114
  {
115
- $templates = array(array('template' => $templates));
 
116
  }
117
 
118
  ?>
112
 
113
  if(!is_array($templates))
114
  {
115
+ $index = $gfpdf->index[$form_id];
116
+ $templates = array($index[0] => array('template' => $templates));
117
  }
118
 
119
  ?>
pdf.php CHANGED
@@ -1,429 +1,429 @@
1
- <?php
2
-
3
- /*
4
- Plugin Name: Gravity Forms PDF Extended
5
- Plugin URI: http://www.gravityformspdfextended.com
6
- Description: Gravity Forms PDF Extended 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.5.3
8
- Author: Blue Liquid Designs
9
- Author URI: http://www.blueliquiddesigns.com.au
10
-
11
- ------------------------------------------------------------------------
12
-
13
- This program is free software; you can redistribute it and/or modify
14
- it under the terms of the GNU General Public License as published by
15
- the Free Software Foundation; either version 2 of the License, or
16
- (at your option) any later version.
17
-
18
- This program is distributed in the hope that it will be useful,
19
- but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- GNU General Public License for more details.
22
- */
23
-
24
- /*
25
- * As PDFs can't be generated if notices are displaying, turn off error reporting to the screen if not in debug mode.
26
- * Production servers should already have this done.
27
- */
28
- if(WP_DEBUG !== true)
29
- {
30
- error_reporting(0);
31
- }
32
-
33
- /*
34
- * Define our constants
35
- */
36
- define('PDF_EXTENDED_VERSION', '3.5.3');
37
- define('GF_PDF_EXTENDED_SUPPORTED_VERSION', '1.7');
38
- define('GF_PDF_EXTENDED_WP_SUPPORTED_VERSION', '3.5');
39
- define('GF_PDF_EXTENDED_PHP_SUPPORTED_VERSION', '5');
40
-
41
- define('PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
42
- define('PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ));
43
- define("PDF_SETTINGS_URL", site_url() .'/wp-admin/admin.php?page=gf_settings&subview=PDF');
44
- define('PDF_SAVE_FOLDER', 'PDF_EXTENDED_TEMPLATES');
45
- define('PDF_SAVE_LOCATION', get_stylesheet_directory().'/'.PDF_SAVE_FOLDER.'/output/');
46
- define('PDF_FONT_LOCATION', get_stylesheet_directory().'/'.PDF_SAVE_FOLDER.'/fonts/');
47
- define('PDF_TEMPLATE_LOCATION', get_stylesheet_directory().'/'.PDF_SAVE_FOLDER.'/');
48
- define('PDF_TEMPLATE_URL_LOCATION', get_stylesheet_directory_uri().'/'. PDF_SAVE_FOLDER .'/');
49
- define('GF_PDF_EXTENDED_PLUGIN_BASENAME', plugin_basename(__FILE__));
50
-
51
- /*
52
- * Include the core helper files
53
- */
54
- include PDF_PLUGIN_DIR . 'helper/api.php';
55
- include PDF_PLUGIN_DIR . 'helper/data.php';
56
- include PDF_PLUGIN_DIR . 'helper/notices.php';
57
- include PDF_PLUGIN_DIR . 'helper/pdf-configuration-indexer.php';
58
- include PDF_PLUGIN_DIR . 'helper/installation-update-manager.php';
59
-
60
- /*
61
- * Initialise our data helper class
62
- */
63
- global $gfpdfe_data;
64
- $gfpdfe_data = new GFPDFE_DATA();
65
-
66
- include PDF_PLUGIN_DIR . 'pdf-settings.php';
67
- include PDF_PLUGIN_DIR . 'helper/pdf-common.php';
68
-
69
- /*
70
- * Initiate the class after Gravity Forms has been loaded using the init hook.
71
- */
72
- add_action('init', array('GFPDF_Core', 'pdf_init'));
73
- add_action('wp_ajax_support_request', array('GFPDF_Settings_Model', 'gfpdf_support_request'));
74
-
75
-
76
- class GFPDF_Core extends PDFGenerator
77
- {
78
- public $render;
79
- static $model;
80
-
81
- /*
82
- * Main Controller
83
- * First function fired when plugin is loaded
84
- * Determines if the plugin can run or not
85
- */
86
- public static function pdf_init()
87
- {
88
- global $gfpdfe_data;
89
-
90
- /*
91
- * Set the notice type
92
- */
93
- self::set_notice_type();
94
-
95
- /*
96
- * Add localisation support
97
- */
98
- load_plugin_textdomain(GF_PDF_EXTENDED_PLUGIN_BASENAME, false, PDF_PLUGIN_DIR . 'resources/languages/' );
99
-
100
- /*
101
- * Call our Settings class which will do our compatibility processing
102
- */
103
- $gfpdfe_data->settingsClass = new GFPDF_Settings();
104
-
105
- /*
106
- * We'll initialise our model which will do any function checks ect
107
- */
108
- include PDF_PLUGIN_DIR . 'model/pdf.php';
109
- self::$model = new GFPDF_Core_Model();
110
-
111
- /*
112
- * Check for any major compatibility issues early
113
- */
114
- if(self::$model->check_major_compatibility() === false)
115
- {
116
- /*
117
- * Major compatibility errors (WP version, Gravity Forms or PHP errors)
118
- * Exit to prevent conflicts
119
- */
120
- return;
121
- }
122
-
123
- /*
124
- * Some functions are required to monitor changes in the admin area
125
- * and ensure the plugin functions smoothly
126
- */
127
- add_action('admin_init', array('GFPDF_Core', 'fully_loaded_admin'), 9999); /* run later than usual to give our auto initialiser a chance to fire */
128
- add_action('after_switch_theme', array('GFPDF_InstallUpdater', 'gf_pdf_on_switch_theme'), 10, 2); /* listen for a theme chance and sync our PDF_EXTENDED_TEMPLATE folder */
129
-
130
- /*
131
- * Only load the plugin if the following requirements are met:
132
- * - Load on Gravity Forms Admin pages
133
- * - Load if requesting PDF file
134
- * - Load if on Gravity Form page on the front end
135
- * - Load if receiving Paypal IPN
136
- */
137
- if( ( is_admin() && isset($_GET['page']) && (substr($_GET['page'], 0, 3) === 'gf_') ) ||
138
- ( isset($_GET['gf_pdf']) ) ||
139
- ( RGForms::get("page") == "gf_paypal_ipn") ||
140
- ( isset($_POST["gform_submit"]) && GFPDF_Core_Model::valid_gravity_forms() ||
141
- ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset($_POST['action']) && isset($_POST['gf_resend_notifications'])) )
142
- )
143
- {
144
- /*
145
- * Initialise the core class which will load the __construct() function
146
- */
147
- global $gfpdf;
148
- $gfpdf = new GFPDF_Core();
149
- }
150
-
151
- return;
152
-
153
- }
154
-
155
- public function __construct()
156
- {
157
- global $gfpdfe_data;
158
-
159
- /*
160
- * Include the core files
161
- */
162
- include PDF_PLUGIN_DIR . 'helper/pdf-render.php';
163
- include PDF_PLUGIN_DIR . 'helper/pdf-entry-detail.php';
164
-
165
- /*
166
- * Set up the PDF configuration and indexer
167
- * Accessed through $this->configuration and $this->index.
168
- */
169
- parent::__construct();
170
-
171
- /*
172
- * Run our scripts and add the settings page to the admin area
173
- */
174
- add_action('admin_init', array($this, 'gfe_admin_init'), 9);
175
-
176
- /*
177
- * Ensure the system is fully installed
178
- * We run this after the 'settings' page has been set up (above)
179
- */
180
- if(GFPDF_Core_Model::is_fully_installed() === false)
181
- {
182
- return;
183
- }
184
-
185
- /*
186
- * Add our main hooks
187
- */
188
- add_action('gform_entries_first_column_actions', array('GFPDF_Core_Model', 'pdf_link'), 10, 4);
189
- add_action("gform_entry_info", array('GFPDF_Core_Model', 'detail_pdf_link'), 10, 2);
190
- add_action('wp', array('GFPDF_Core_Model', 'process_exterior_pages'));
191
-
192
-
193
- /*
194
- * Apply default filters
195
- */
196
- add_filter('gfpdfe_pdf_template', array('PDF_Common', 'do_mergetags'), 10, 3); /* convert mergetags in PDF template automatically */
197
- add_filter('gfpdfe_pdf_template', 'do_shortcode', 10, 1); /* convert shortcodes in PDF template automatically */
198
-
199
- /* Check if on the entries page and output javascript */
200
- if(is_admin() && rgget('page') == 'gf_entries')
201
- {
202
- wp_enqueue_script( 'gfpdfeentries', PDF_PLUGIN_URL . 'resources/javascript/entries-admin.min.js', array('jquery') );
203
- }
204
-
205
- /*
206
- * Register render class
207
- */
208
- $this->render = new PDFRender();
209
-
210
- /*
211
- * Run the notifications filter / save action hook if the web server can write to the output folder
212
- */
213
- if($gfpdfe_data->can_write_output_dir === true)
214
- {
215
- add_action('gform_after_submission', array('GFPDF_Core_Model', 'gfpdfe_save_pdf'), 10, 2);
216
- add_filter('gform_notification', array('GFPDF_Core_Model', 'gfpdfe_create_and_attach_pdf'), 100, 3); /* ensure it's called later than standard so the attachment array isn't overridden */
217
- }
218
-
219
- }
220
-
221
- /*
222
- * Do processes that require Wordpress Admin to be fully loaded
223
- */
224
- public static function fully_loaded_admin()
225
- {
226
-
227
- global $gfpdfe_data;
228
-
229
- /*
230
- * Don't run initialiser if we cannot...
231
- */
232
- if($gfpdfe_data->allow_initilisation === false)
233
- {
234
- /*
235
- * Prompt user about a server configuration problem
236
- */
237
- add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_server_problem_detected"));
238
- return false;
239
- }
240
-
241
- /*
242
- * Check if we have direct write access to the server
243
- */
244
- GFPDF_InstallUpdater::check_filesystem_api();
245
-
246
- /*
247
- * Check if we can automatically deploy the software.
248
- * 90% of sites should be able to do this as they will have 'direct' write abilities
249
- * to their server files.
250
- */
251
- GFPDF_InstallUpdater::maybe_deploy();
252
-
253
- /*
254
- * Check if we need to deploy the software
255
- */
256
- self::check_deployment();
257
-
258
- /*
259
- * Check if the user has switched themes and they haven't yet prompt user to copy over directory structure
260
- * If the plugin has just initialised we won't check for a theme swap as initialisation will reset this value
261
- */
262
- if(!rgpost('upgrade'))
263
- {
264
- GFPDF_InstallUpdater::check_theme_switch();
265
- }
266
- }
267
-
268
- /*
269
- * Depending on what page we are on, we need to fire different notices
270
- * We've added our own custom notice to the settings page as some functions fire later than the normal 'admin_notices' action
271
- */
272
- private static function set_notice_type()
273
- {
274
- global $gfpdfe_data;
275
-
276
- if(PDF_Common::is_settings())
277
- {
278
- $gfpdfe_data->notice_type = 'gfpdfe_notices';
279
- }
280
- else if (is_multisite() && is_network_admin())
281
- {
282
- $gfpdfe_data->notice_type = 'network_admin_notices';
283
- }
284
- else
285
- {
286
- $gfpdfe_data->notice_type = 'admin_notices';
287
- }
288
- }
289
-
290
- /*
291
- * Check if the software needs to be deployed/redeployed
292
- */
293
- public static function check_deployment()
294
- {
295
-
296
- global $gfpdfe_data;
297
-
298
- /*
299
- * Check if client is using the automated installer
300
- * If installer has issues or client cannot use auto installer (using FTP/SSH ect) then run the usual
301
- * initialisation messages.
302
- */
303
- if($gfpdfe_data->automated === true && $gfpdfe_data->fresh_install === true & get_option('gfpdfe_automated_install') != 'installing')
304
- {
305
- return;
306
- }
307
-
308
- /*
309
- * Check if GF PDF Extended is correctly installed. If not we'll run the installer.
310
- */
311
- $theme_switch = get_option('gfpdfe_switch_theme');
312
-
313
- if( (
314
- (get_option('gf_pdf_extended_installed') != 'installed')
315
- ) && (!rgpost('upgrade') )
316
- && (empty($theme_switch['old']) )
317
- )
318
- {
319
- /*
320
- * Prompt user to initialise plugin
321
- */
322
- add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_not_deployed_fresh"));
323
- }
324
- elseif( (
325
- ( !is_dir(PDF_TEMPLATE_LOCATION)) ||
326
- ( !file_exists(PDF_TEMPLATE_LOCATION . 'configuration.php') ) ||
327
- ( !is_dir(PDF_SAVE_LOCATION) )
328
- )
329
- && (!rgpost('upgrade'))
330
- && (empty($theme_switch['old']) )
331
-
332
- )
333
- {
334
-
335
- /*
336
- * Prompt user that a problem was detected and they need to redeploy
337
- */
338
- add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_problem_detected"));
339
- }
340
- }
341
-
342
- /**
343
- * Add our scripts and settings page to the admin area
344
- */
345
- function gfe_admin_init()
346
- {
347
-
348
- /*
349
- * Configure the settings page
350
- */
351
- wp_enqueue_style( 'pdfextended-admin-styles', PDF_PLUGIN_URL . 'resources/css/admin-styles.min.css', array('dashicons'), '1.1' );
352
- wp_enqueue_script( 'pdfextended-settings-script', PDF_PLUGIN_URL . 'resources/javascript/admin.min.js' );
353
-
354
- /*
355
- * Register our scripts/styles with Gravity Forms to prevent them being removed in no conflict mode
356
- */
357
- add_filter('gform_noconflict_scripts', array('GFPDF_Core', 'register_gravityform_scripts'));
358
- add_filter('gform_noconflict_styles', array('GFPDF_Core', 'register_gravityform_styles'));
359
-
360
- add_filter('gform_tooltips', array('GFPDF_Notices', 'add_tooltips'));
361
-
362
- GFPDF_Settings::settings_page();
363
-
364
- }
365
-
366
- /*
367
- * Register our scripts with Gravity Forms so they aren't removed when no conflict mode is active
368
- */
369
- public static function register_gravityform_scripts($scripts)
370
- {
371
- $scripts[] = 'pdfextended-settings-script';
372
- $scripts[] = 'gfpdfeentries';
373
-
374
- return $scripts;
375
- }
376
-
377
- /*
378
- * Register our styles with Gravity Forms so they aren't removed when no conflict mode is active
379
- */
380
- public static function register_gravityform_styles($styles)
381
- {
382
- $styles[] = 'pdfextended-admin-styles';
383
-
384
- return $styles;
385
- }
386
-
387
- }
388
-
389
- /*
390
- * array_replace_recursive was added in PHP5.3
391
- * Add fallback support for those with a version lower than this
392
- * and Wordpress still supports PHP5.0 to PHP5.2
393
- */
394
- if (!function_exists('array_replace_recursive'))
395
- {
396
- function array_replace_recursive()
397
- {
398
- // Get array arguments
399
- $arrays = func_get_args();
400
-
401
- // Define the original array
402
- $original = array_shift($arrays);
403
-
404
- // Loop through arrays
405
- foreach ($arrays as $array)
406
- {
407
- // Loop through array key/value pairs
408
- foreach ($array as $key => $value)
409
- {
410
- // Value is an array
411
- if (is_array($value))
412
- {
413
- // Traverse the array; replace or add result to original array
414
- $original[$key] = array_replace_recursive($original[$key], $array[$key]);
415
- }
416
-
417
- // Value is not an array
418
- else
419
- {
420
- // Replace or add current value to original array
421
- $original[$key] = $value;
422
- }
423
- }
424
- }
425
-
426
- // Return the joined array
427
- return $original;
428
- }
429
- }
1
+ <?php
2
+
3
+ /*
4
+ Plugin Name: Gravity Forms PDF Extended
5
+ Plugin URI: http://www.gravityformspdfextended.com
6
+ Description: Gravity Forms PDF Extended 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.5.4
8
+ Author: Blue Liquid Designs
9
+ Author URI: http://www.blueliquiddesigns.com.au
10
+
11
+ ------------------------------------------------------------------------
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License as published by
15
+ the Free Software Foundation; either version 2 of the License, or
16
+ (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+ */
23
+
24
+ /*
25
+ * As PDFs can't be generated if notices are displaying, turn off error reporting to the screen if not in debug mode.
26
+ * Production servers should already have this done.
27
+ */
28
+ if(WP_DEBUG !== true)
29
+ {
30
+ error_reporting(0);
31
+ }
32
+
33
+ /*
34
+ * Define our constants
35
+ */
36
+ define('PDF_EXTENDED_VERSION', '3.5.4');
37
+ define('GF_PDF_EXTENDED_SUPPORTED_VERSION', '1.7');
38
+ define('GF_PDF_EXTENDED_WP_SUPPORTED_VERSION', '3.5');
39
+ define('GF_PDF_EXTENDED_PHP_SUPPORTED_VERSION', '5');
40
+
41
+ define('PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
42
+ define('PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ));
43
+ define("PDF_SETTINGS_URL", site_url() .'/wp-admin/admin.php?page=gf_settings&subview=PDF');
44
+ define('PDF_SAVE_FOLDER', 'PDF_EXTENDED_TEMPLATES');
45
+ define('PDF_SAVE_LOCATION', get_stylesheet_directory().'/'.PDF_SAVE_FOLDER.'/output/');
46
+ define('PDF_FONT_LOCATION', get_stylesheet_directory().'/'.PDF_SAVE_FOLDER.'/fonts/');
47
+ define('PDF_TEMPLATE_LOCATION', get_stylesheet_directory().'/'.PDF_SAVE_FOLDER.'/');
48
+ define('PDF_TEMPLATE_URL_LOCATION', get_stylesheet_directory_uri().'/'. PDF_SAVE_FOLDER .'/');
49
+ define('GF_PDF_EXTENDED_PLUGIN_BASENAME', plugin_basename(__FILE__));
50
+
51
+ /*
52
+ * Include the core helper files
53
+ */
54
+ include PDF_PLUGIN_DIR . 'helper/api.php';
55
+ include PDF_PLUGIN_DIR . 'helper/data.php';
56
+ include PDF_PLUGIN_DIR . 'helper/notices.php';
57
+ include PDF_PLUGIN_DIR . 'helper/pdf-configuration-indexer.php';
58
+ include PDF_PLUGIN_DIR . 'helper/installation-update-manager.php';
59
+
60
+ /*
61
+ * Initialise our data helper class
62
+ */
63
+ global $gfpdfe_data;
64
+ $gfpdfe_data = new GFPDFE_DATA();
65
+
66
+ include PDF_PLUGIN_DIR . 'pdf-settings.php';
67
+ include PDF_PLUGIN_DIR . 'helper/pdf-common.php';
68
+
69
+ /*
70
+ * Initiate the class after Gravity Forms has been loaded using the init hook.
71
+ */
72
+ add_action('init', array('GFPDF_Core', 'pdf_init'));
73
+ add_action('wp_ajax_support_request', array('GFPDF_Settings_Model', 'gfpdf_support_request'));
74
+
75
+
76
+ class GFPDF_Core extends PDFGenerator
77
+ {
78
+ public $render;
79
+ static $model;
80
+
81
+ /*
82
+ * Main Controller
83
+ * First function fired when plugin is loaded
84
+ * Determines if the plugin can run or not
85
+ */
86
+ public static function pdf_init()
87
+ {
88
+ global $gfpdfe_data;
89
+
90
+ /*
91
+ * Set the notice type
92
+ */
93
+ self::set_notice_type();
94
+
95
+ /*
96
+ * Add localisation support
97
+ */
98
+ load_plugin_textdomain(GF_PDF_EXTENDED_PLUGIN_BASENAME, false, PDF_PLUGIN_DIR . 'resources/languages/' );
99
+
100
+ /*
101
+ * Call our Settings class which will do our compatibility processing
102
+ */
103
+ $gfpdfe_data->settingsClass = new GFPDF_Settings();
104
+
105
+ /*
106
+ * We'll initialise our model which will do any function checks ect
107
+ */
108
+ include PDF_PLUGIN_DIR . 'model/pdf.php';
109
+ self::$model = new GFPDF_Core_Model();
110
+
111
+ /*
112
+ * Check for any major compatibility issues early
113
+ */
114
+ if(self::$model->check_major_compatibility() === false)
115
+ {
116
+ /*
117
+ * Major compatibility errors (WP version, Gravity Forms or PHP errors)
118
+ * Exit to prevent conflicts
119
+ */
120
+ return;
121
+ }
122
+
123
+ /*
124
+ * Some functions are required to monitor changes in the admin area
125
+ * and ensure the plugin functions smoothly
126
+ */
127
+ add_action('admin_init', array('GFPDF_Core', 'fully_loaded_admin'), 9999); /* run later than usual to give our auto initialiser a chance to fire */
128
+ add_action('after_switch_theme', array('GFPDF_InstallUpdater', 'gf_pdf_on_switch_theme'), 10, 2); /* listen for a theme chance and sync our PDF_EXTENDED_TEMPLATE folder */
129
+
130
+ /*
131
+ * Only load the plugin if the following requirements are met:
132
+ * - Load on Gravity Forms Admin pages
133
+ * - Load if requesting PDF file
134
+ * - Load if on Gravity Form page on the front end
135
+ * - Load if receiving Paypal IPN
136
+ */
137
+ if( ( is_admin() && isset($_GET['page']) && (substr($_GET['page'], 0, 3) === 'gf_') ) ||
138
+ ( isset($_GET['gf_pdf']) ) ||
139
+ ( RGForms::get("page") == "gf_paypal_ipn") ||
140
+ ( isset($_POST["gform_submit"]) && GFPDF_Core_Model::valid_gravity_forms() ||
141
+ ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset($_POST['action']) && isset($_POST['gf_resend_notifications'])) )
142
+ )
143
+ {
144
+ /*
145
+ * Initialise the core class which will load the __construct() function
146
+ */
147
+ global $gfpdf;
148
+ $gfpdf = new GFPDF_Core();
149
+ }
150
+
151
+ return;
152
+
153
+ }
154
+
155
+ public function __construct()
156
+ {
157
+ global $gfpdfe_data;
158
+
159
+ /*
160
+ * Include the core files
161
+ */
162
+ include PDF_PLUGIN_DIR . 'helper/pdf-render.php';
163
+ include PDF_PLUGIN_DIR . 'helper/pdf-entry-detail.php';
164
+
165
+ /*
166
+ * Set up the PDF configuration and indexer
167
+ * Accessed through $this->configuration and $this->index.
168
+ */
169
+ parent::__construct();
170
+
171
+ /*
172
+ * Run our scripts and add the settings page to the admin area
173
+ */
174
+ add_action('admin_init', array($this, 'gfe_admin_init'), 9);
175
+
176
+ /*
177
+ * Ensure the system is fully installed
178
+ * We run this after the 'settings' page has been set up (above)
179
+ */
180
+ if(GFPDF_Core_Model::is_fully_installed() === false)
181
+ {
182
+ return;
183
+ }
184
+
185
+ /*
186
+ * Add our main hooks
187
+ */
188
+ add_action('gform_entries_first_column_actions', array('GFPDF_Core_Model', 'pdf_link'), 10, 4);
189
+ add_action("gform_entry_info", array('GFPDF_Core_Model', 'detail_pdf_link'), 10, 2);
190
+ add_action('wp', array('GFPDF_Core_Model', 'process_exterior_pages'));
191
+
192
+
193
+ /*
194
+ * Apply default filters
195
+ */
196
+ add_filter('gfpdfe_pdf_template', array('PDF_Common', 'do_mergetags'), 10, 3); /* convert mergetags in PDF template automatically */
197
+ add_filter('gfpdfe_pdf_template', 'do_shortcode', 10, 1); /* convert shortcodes in PDF template automatically */
198
+
199
+ /* Check if on the entries page and output javascript */
200
+ if(is_admin() && rgget('page') == 'gf_entries')
201
+ {
202
+ wp_enqueue_script( 'gfpdfeentries', PDF_PLUGIN_URL . 'resources/javascript/entries-admin.min.js', array('jquery') );
203
+ }
204
+
205
+ /*
206
+ * Register render class
207
+ */
208
+ $this->render = new PDFRender();
209
+
210
+ /*
211
+ * Run the notifications filter / save action hook if the web server can write to the output folder
212
+ */
213
+ if($gfpdfe_data->can_write_output_dir === true)
214
+ {
215
+ add_action('gform_after_submission', array('GFPDF_Core_Model', 'gfpdfe_save_pdf'), 10, 2);
216
+ add_filter('gform_notification', array('GFPDF_Core_Model', 'gfpdfe_create_and_attach_pdf'), 100, 3); /* ensure it's called later than standard so the attachment array isn't overridden */
217
+ }
218
+
219
+ }
220
+
221
+ /*
222
+ * Do processes that require Wordpress Admin to be fully loaded
223
+ */
224
+ public static function fully_loaded_admin()
225
+ {
226
+
227
+ global $gfpdfe_data;
228
+
229
+ /*
230
+ * Don't run initialiser if we cannot...
231
+ */
232
+ if($gfpdfe_data->allow_initilisation === false)
233
+ {
234
+ /*
235
+ * Prompt user about a server configuration problem
236
+ */
237
+ add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_server_problem_detected"));
238
+ return false;
239
+ }
240
+
241
+ /*
242
+ * Check if we have direct write access to the server
243
+ */
244
+ GFPDF_InstallUpdater::check_filesystem_api();
245
+
246
+ /*
247
+ * Check if we can automatically deploy the software.
248
+ * 90% of sites should be able to do this as they will have 'direct' write abilities
249
+ * to their server files.
250
+ */
251
+ GFPDF_InstallUpdater::maybe_deploy();
252
+
253
+ /*
254
+ * Check if we need to deploy the software
255
+ */
256
+ self::check_deployment();
257
+
258
+ /*
259
+ * Check if the user has switched themes and they haven't yet prompt user to copy over directory structure
260
+ * If the plugin has just initialised we won't check for a theme swap as initialisation will reset this value
261
+ */
262
+ if(!rgpost('upgrade'))
263
+ {
264
+ GFPDF_InstallUpdater::check_theme_switch();
265
+ }
266
+ }
267
+
268
+ /*
269
+ * Depending on what page we are on, we need to fire different notices
270
+ * We've added our own custom notice to the settings page as some functions fire later than the normal 'admin_notices' action
271
+ */
272
+ private static function set_notice_type()
273
+ {
274
+ global $gfpdfe_data;
275
+
276
+ if(PDF_Common::is_settings())
277
+ {
278
+ $gfpdfe_data->notice_type = 'gfpdfe_notices';
279
+ }
280
+ else if (is_multisite() && is_network_admin())
281
+ {
282
+ $gfpdfe_data->notice_type = 'network_admin_notices';
283
+ }
284
+ else
285
+ {
286
+ $gfpdfe_data->notice_type = 'admin_notices';
287
+ }
288
+ }
289
+
290
+ /*
291
+ * Check if the software needs to be deployed/redeployed
292
+ */
293
+ public static function check_deployment()
294
+ {
295
+
296
+ global $gfpdfe_data;
297
+
298
+ /*
299
+ * Check if client is using the automated installer
300
+ * If installer has issues or client cannot use auto installer (using FTP/SSH ect) then run the usual
301
+ * initialisation messages.
302
+ */
303
+ if($gfpdfe_data->automated === true && $gfpdfe_data->fresh_install === true & get_option('gfpdfe_automated_install') != 'installing')
304
+ {
305
+ return;
306
+ }
307
+
308
+ /*
309
+ * Check if GF PDF Extended is correctly installed. If not we'll run the installer.
310
+ */
311
+ $theme_switch = get_option('gfpdfe_switch_theme');
312
+
313
+ if( (
314
+ (get_option('gf_pdf_extended_installed') != 'installed')
315
+ ) && (!rgpost('upgrade') )
316
+ && (empty($theme_switch['old']) )
317
+ )
318
+ {
319
+ /*
320
+ * Prompt user to initialise plugin
321
+ */
322
+ add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_not_deployed_fresh"));
323
+ }
324
+ elseif( (
325
+ ( !is_dir(PDF_TEMPLATE_LOCATION)) ||
326
+ ( !file_exists(PDF_TEMPLATE_LOCATION . 'configuration.php') ) ||
327
+ ( !is_dir(PDF_SAVE_LOCATION) )
328
+ )
329
+ && (!rgpost('upgrade'))
330
+ && (empty($theme_switch['old']) )
331
+
332
+ )
333
+ {
334
+
335
+ /*
336
+ * Prompt user that a problem was detected and they need to redeploy
337
+ */
338
+ add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_problem_detected"));
339
+ }
340
+ }
341
+
342
+ /**
343
+ * Add our scripts and settings page to the admin area
344
+ */
345
+ function gfe_admin_init()
346
+ {
347
+
348
+ /*
349
+ * Configure the settings page
350
+ */
351
+ wp_enqueue_style( 'pdfextended-admin-styles', PDF_PLUGIN_URL . 'resources/css/admin-styles.min.css', array('dashicons'), '1.1' );
352
+ wp_enqueue_script( 'pdfextended-settings-script', PDF_PLUGIN_URL . 'resources/javascript/admin.min.js' );
353
+
354
+ /*
355
+ * Register our scripts/styles with Gravity Forms to prevent them being removed in no conflict mode
356
+ */
357
+ add_filter('gform_noconflict_scripts', array('GFPDF_Core', 'register_gravityform_scripts'));
358
+ add_filter('gform_noconflict_styles', array('GFPDF_Core', 'register_gravityform_styles'));
359
+
360
+ add_filter('gform_tooltips', array('GFPDF_Notices', 'add_tooltips'));
361
+
362
+ GFPDF_Settings::settings_page();
363
+
364
+ }
365
+
366
+ /*
367
+ * Register our scripts with Gravity Forms so they aren't removed when no conflict mode is active
368
+ */
369
+ public static function register_gravityform_scripts($scripts)
370
+ {
371
+ $scripts[] = 'pdfextended-settings-script';
372
+ $scripts[] = 'gfpdfeentries';
373
+
374
+ return $scripts;
375
+ }
376
+
377
+ /*
378
+ * Register our styles with Gravity Forms so they aren't removed when no conflict mode is active
379
+ */
380
+ public static function register_gravityform_styles($styles)
381
+ {
382
+ $styles[] = 'pdfextended-admin-styles';
383
+
384
+ return $styles;
385
+ }
386
+
387
+ }
388
+
389
+ /*
390
+ * array_replace_recursive was added in PHP5.3
391
+ * Add fallback support for those with a version lower than this
392
+ * and Wordpress still supports PHP5.0 to PHP5.2
393
+ */
394
+ if (!function_exists('array_replace_recursive'))
395
+ {
396
+ function array_replace_recursive()
397
+ {
398
+ // Get array arguments
399
+ $arrays = func_get_args();
400
+
401
+ // Define the original array
402
+ $original = array_shift($arrays);
403
+
404
+ // Loop through arrays
405
+ foreach ($arrays as $array)
406
+ {
407
+ // Loop through array key/value pairs
408
+ foreach ($array as $key => $value)
409
+ {
410
+ // Value is an array
411
+ if (is_array($value))
412
+ {
413
+ // Traverse the array; replace or add result to original array
414
+ $original[$key] = array_replace_recursive($original[$key], $array[$key]);
415
+ }
416
+
417
+ // Value is not an array
418
+ else
419
+ {
420
+ // Replace or add current value to original array
421
+ $original[$key] = $value;
422
+ }
423
+ }
424
+ }
425
+
426
+ // Return the joined array
427
+ return $original;
428
+ }
429
+ }
view/templates/settings/changelog.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
 
3
  /*
4
- <li>Template: Changelog
5
- <li>Module: Settings Page
6
  *
7
  */
8
 
@@ -21,8 +21,15 @@
21
  <p><strong>Current Version: <?php echo PDF_EXTENDED_VERSION; ?></strong></p>
22
 
23
  <h3><?php echo PDF_EXTENDED_VERSION; ?></h3>
 
 
 
 
 
24
 
25
 
 
 
26
  <ul>
27
  <li>Bug - Mergetags braces ({}) were being encoded before conversion</li>
28
  <li>Bug - Fixed issue with empty string being passed to array filter</li>
1
  <?php
2
 
3
  /*
4
+ Template: Changelog
5
+ Module: Settings Page
6
  *
7
  */
8
 
21
  <p><strong>Current Version: <?php echo PDF_EXTENDED_VERSION; ?></strong></p>
22
 
23
  <h3><?php echo PDF_EXTENDED_VERSION; ?></h3>
24
+ <ul>
25
+ <li>Bug - Fixed issue with incorrect PDF name showing on the entry details page</li>
26
+ <li>Bug - Fixed issue with custom fonts being inaccessible without manually reinstalling after upgrading.</li>
27
+ <li>Housekeeping - Added in two new filters to modify the $mpdf object. 'gfpdfe_mpdf_class' and 'gfpdfe_mpdf_class_pre_render' (replaces the gfpdfe_pre_render_pdf filter).</li>
28
+ </ul>
29
 
30
 
31
+ <h3>3.5.3</h3>
32
+
33
  <ul>
34
  <li>Bug - Mergetags braces ({}) were being encoded before conversion</li>
35
  <li>Bug - Fixed issue with empty string being passed to array filter</li>