Gravity PDF - Version 4.0.1

Version Description

  • Fixes PHP notice when viewing PDF and Category field is empty (GH#419)
  • Fixes PHP notice when viewing PDF and custom font directory is empty (GH#416)
  • Fixes Font Manager / Help Search features due to Underscore.js conflict when PHP's depreciated ASP Tags enabled (GH#417)
  • Allows radio and checkbox values to show HTML in PDFs (GH#415)
  • Fixes PDF letter spacing issue with upper and lower case characters (GH#418)
  • Fixes character display problems using core Arial font in PDFs (GH#420)
  • Fixes documentation search error on PDF Help tab (GH#424)
  • Add additional check when cleaning up TMP directory (GH#427)
Download this release

Release Info

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

Code changes from version 4.0 to 4.0.1

README.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://gravitypdf.com/donate-to-plugin/
5
  Tags: gravity, forms, pdf, automation, attachment, email
6
  Requires at least: 4.2
7
  Tested up to: 4.5
8
- Stable tag: 4.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl.txt
11
 
@@ -83,6 +83,16 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
83
 
84
  == Changelog ==
85
 
 
 
 
 
 
 
 
 
 
 
86
  = 4.0 =
87
 
88
  * Minimum PHP version changed from PHP 5.2 to PHP 5.4. ENSURE YOUR WEB SERVER IS COMPATIBLE BEFORE UPDATING (Forms -> Settings -> PDF -> System Status)
5
  Tags: gravity, forms, pdf, automation, attachment, email
6
  Requires at least: 4.2
7
  Tested up to: 4.5
8
+ Stable tag: 4.0.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl.txt
11
 
83
 
84
  == Changelog ==
85
 
86
+ = 4.0.1 =
87
+ * Fixes PHP notice when viewing PDF and Category field is empty (GH#419)
88
+ * Fixes PHP notice when viewing PDF and custom font directory is empty (GH#416)
89
+ * Fixes Font Manager / Help Search features due to Underscore.js conflict when PHP's depreciated ASP Tags enabled (GH#417)
90
+ * Allows radio and checkbox values to show HTML in PDFs (GH#415)
91
+ * Fixes PDF letter spacing issue with upper and lower case characters (GH#418)
92
+ * Fixes character display problems using core Arial font in PDFs (GH#420)
93
+ * Fixes documentation search error on PDF Help tab (GH#424)
94
+ * Add additional check when cleaning up TMP directory (GH#427)
95
+
96
  = 4.0 =
97
 
98
  * Minimum PHP version changed from PHP 5.2 to PHP 5.4. ENSURE YOUR WEB SERVER IS COMPATIBLE BEFORE UPDATING (Forms -> Settings -> PDF -> System Status)
pdf.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Gravity PDF
4
- Version: 4.0
5
  Description: Automatically generate highly-customisable PDF documents using Gravity Forms.
6
  Author: Gravity PDF
7
  Author URI: https://gravitypdf.com
@@ -38,7 +38,7 @@ if ( ! defined( 'ABSPATH' ) ) {
38
  * Set base constants we'll use throughout the plugin
39
  */
40
 
41
- define( 'PDF_EXTENDED_VERSION', '4.0' ); /* the current plugin version */
42
  define( 'PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); /* plugin directory path */
43
  define( 'PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); /* plugin directory url */
44
  define( 'PDF_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); /* the plugin basename */
1
  <?php
2
  /*
3
  Plugin Name: Gravity PDF
4
+ Version: 4.0.1
5
  Description: Automatically generate highly-customisable PDF documents using Gravity Forms.
6
  Author: Gravity PDF
7
  Author URI: https://gravitypdf.com
38
  * Set base constants we'll use throughout the plugin
39
  */
40
 
41
+ define( 'PDF_EXTENDED_VERSION', '4.0.1' ); /* the current plugin version */
42
  define( 'PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); /* plugin directory path */
43
  define( 'PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); /* plugin directory url */
44
  define( 'PDF_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); /* the plugin basename */
src/assets/js/gfpdf-backbone.js CHANGED
@@ -8,6 +8,21 @@
8
 
9
  $(function() {
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  /**
12
  * Handles our Font CRUD Feature
13
  * Allows URLs to TTF and OTF font files to be passed
@@ -314,10 +329,8 @@
314
  this.addRender(font);
315
  }, this);
316
  } else {
317
-
318
  /* Display getting started message to user */
319
- this.$el.html( _.template( $( '#GravityPDFFontsEmpty' ).html() ) );
320
-
321
  }
322
 
323
  /* Return for chaining purposes */
@@ -425,7 +438,7 @@
425
  render: function() {
426
 
427
  /* Set up our Underscore template file */
428
- this.template = _.template( $( this.template ).html() );
429
 
430
  /* Set View Element HTML to our Underscore template, passing in our model */
431
  this.$el.html(this.template({
@@ -1003,7 +1016,7 @@
1003
 
1004
  render: function() {
1005
  /* set up out template */
1006
- this.template = _.template($(this.template).html());
1007
 
1008
  /* show the loading spinner */
1009
  this.showSpinner();
8
 
9
  $(function() {
10
 
11
+ /**
12
+ * To prevent problems with PHP's ASP Short tags (removed in PHP 7) we'll change Underscore's delimiters to be Handlebars-ish:
13
+ * {{= }}, {{- }} or {{ }}
14
+ *
15
+ * @see https://github.com/GravityPDF/gravity-pdf/issues/417
16
+ * @type {{interpolate: RegExp, evaluate: RegExp, escape: RegExp}}
17
+ * @since 4.0.1
18
+ */
19
+ var UnderscoreSettingsOverride = {
20
+ evaluate: /\{\{(.+?)\}\}/gim,
21
+ interpolate: /\{\{=(.+?)\}\}/gim,
22
+ escape: /\{\{-(.+?)\}\}/gim
23
+ };
24
+
25
+
26
  /**
27
  * Handles our Font CRUD Feature
28
  * Allows URLs to TTF and OTF font files to be passed
329
  this.addRender(font);
330
  }, this);
331
  } else {
 
332
  /* Display getting started message to user */
333
+ this.$el.html(_.template($( '#GravityPDFFontsEmpty' ).html(), UnderscoreSettingsOverride));
 
334
  }
335
 
336
  /* Return for chaining purposes */
438
  render: function() {
439
 
440
  /* Set up our Underscore template file */
441
+ this.template = _.template($( this.template ).html(), UnderscoreSettingsOverride);
442
 
443
  /* Set View Element HTML to our Underscore template, passing in our model */
444
  this.$el.html(this.template({
1016
 
1017
  render: function() {
1018
  /* set up out template */
1019
+ this.template = _.template($(this.template).html(), UnderscoreSettingsOverride);
1020
 
1021
  /* show the loading spinner */
1022
  this.showSpinner();
src/assets/js/gfpdf-backbone.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){e(function(){function u(){this.init=function(){this.is_settings()&&this.processSettings()},this.is_settings=function(){return e("#tab_PDF").length},this.processSettings=function(){var u=e(".nav-tab-wrapper a.nav-tab-active:first").text();switch(u){case"Tools":this.tools_settings();break;case"Help":this.help_settings()}},this.help_settings=function(){new i.ContainerView},this.tools_settings=function(){var e=JSON.parse(GFPDF.custom_fonts),u=new t.Collection.Core(e),i=new t.View.Container({collection:u});new t.View.Add({collection:u,container:i})}}var t={Model:{},Collection:{},View:{},Misc:{}};t.Model.Core=Backbone.Model.extend({defaults:{font_name:"",regular:"",bold:"",italics:"",bolditalics:"",disabled:!1},url:GFPDF.ajaxurl,save:function(u,t){var i={emulateHTTP:!0,emulateJSON:!0,data:{action:"gfpdf_font_save",nonce:u.nonce,payload:this.toJSON()}};return e.extend(i,t),Backbone.sync("update",this,i)},destroy:function(u,t){var i={emulateHTTP:!0,emulateJSON:!0,data:{action:"gfpdf_font_delete",nonce:u.nonce,id:this.get("id")}};return e.extend(i,t),Backbone.sync("update",this,i)},validate:function(e,u){var t=new RegExp("^[A-Za-z0-9 ]+$");if(e.font_name.length>0){if(!t.test(e.font_name))return"invalid_characters";this.trigger("valid_name")}return this.validateFonts(e)===!1?"invalid_font":void this.trigger("validation_passed",this)},validateFonts:function(u){var t=!0,i={regular:u.regular,bold:u.bold,italics:u.italics,bolditalics:u.bolditalics};return e.each(i,e.proxy(function(e,u){u.length>0&&this.isValidFile(u)===!1?(t=!1,this.trigger("invalid_font",this,!0,e)):this.trigger("valid_font",this,!1,e)},this)),t},isValidFile:function(e){if(e.length<5)return!1;var u=e.substr(e.length-4).toLowerCase();if(".ttf"===u||".otf"===u){var t=new RegExp(/^[a-z](?:[-a-z0-9\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._~!\$&'\(\)\*\+,;=:@\xA0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F][\uDC00-\uDFFD])))(?:\?(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~!\$&'\(\)\*\+,;=:@\/\?\xA0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E\uDB80-\uDBBE\uDBC0-\uDBFE][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDC00-\uDFFD])*)?(?:\#(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~!\$&'\(\)\*\+,;=:@\/\?\xA0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F][\uDC00-\uDFFD])*)?$/gim);if(t.test(e))return!0}return!1},cssDeclaration:function(e,u,t,i){var n=i.getShortname(u);return'font-family: "'+u+'", '+n+", sans-serif;"},getShortname:function(e){return e=e.toLowerCase(),e=e.replace(" ","")}}),t.Collection.Core=Backbone.Collection.extend({model:t.Model.Core}),t.View.Container=Backbone.View.extend({el:"#font-list",tagName:"ul",initialize:function(e){this.listenTo(this.collection,"add",this.addRender),this.listenTo(this.collection,"remove",this.render),this.render()},render:function(){return this.collection.length>0?(this.$el.empty(),this.collection.each(function(e){this.addRender(e)},this)):this.$el.html(_.template(e("#GravityPDFFontsEmpty").html())),this},addRender:function(e){1===this.collection.length&&this.$el.empty();var u=new t.View.Item({model:e,collection:this.collection});return this.$el.append(u.render().el),this}}),t.View.Item=Backbone.View.extend({template:"#GravityPDFFonts",tagName:"li",events:{"click .font-name":"toggleView","click .delete-font":"deleteModel","submit form":"formSubmission"},initialize:function(){this.modelBinder=new Backbone.ModelBinder,this.listenTo(this.model,"invalid valid_name",this.nameError),this.listenTo(this.model,"invalid_font valid_font",this.fontError),this.listenTo(this.model,"invalid",this.disableSubmitButton),this.listenTo(this.model,"validation_passed",this.enableSubmitButton)},render:function(){return this.template=_.template(e(this.template).html()),this.$el.html(this.template({model:this.model})),this.modelBinder.bind(this.model,this.el,{font_name:[{selector:"[name=font_name]"},{selector:"[name=usage]",converter:this.model.cssDeclaration}],regular:"[name=regular]",bold:"[name=bold]",italics:"[name=italics]",bolditalics:"[name=bolditalics]"},{changeTriggers:{"":"change",".font-name-field":"keyup"},modelSetOptions:{validate:!0}}),this},toggleView:function(u){u.preventDefault(),e(u.currentTarget).next().toggle()},nameError:function(e,u){u&&"invalid_characters"==u?this.$el.find('input[name="font_name"]').css("border-color","red"):this.$el.find('input[name="font_name"]').removeAttr("style")},fontError:function(u,t,i){$input=this.$el.find('input[name="'+i+'"]'),t?($error=e('<span class="gf_settings_description"><label>Only TTF and OTF font files are supported.</label></span>'),$input.hasClass("invalid")||$input.addClass("invalid").next().after($error.clone())):$input.hasClass("invalid")&&$input.removeClass("invalid").next().next().remove()},disableSubmitButton:function(e){this.$el.find(".font-submit button").prop("disabled",!0),e.set("disabled",!0)},enableSubmitButton:function(e){this.$el.find(".font-submit button").prop("disabled",!1),e.set("disabled",!1)},formSubmission:function(u){u.preventDefault();e(u.currentTarget);u.currentTarget.checkValidity()&&this.model.get("disabled")===!1&&(this.addSpinner(),this.removeMessage(),console.log(this.model),this.model.save({nonce:this.$el.find("input[name=wpnonce]").val()},{success:e.proxy(function(e,u,t){this.removeSpinner(),this.displayMessage(GFPDF.update_success),this.model.set(e)},this),error:e.proxy(function(e,u,t){this.removeSpinner(),e.responseJSON.error&&this.displayMessage(e.responseJSON.error,!0)},this)}))},deleteModel:function(u){u.preventDefault();var i=e("#delete-confirm"),n=[{text:GFPDF.pdf_list_delete_confirm,click:e.proxy(function(){i.wpdialog("destroy"),this.model.get("id")?(this.addSpinner(),this.removeMessage(),this.$el.hide(),this.model.destroy({nonce:this.$el.find("input[name=wpnonce]").val()},{success:e.proxy(function(e,u,t){this.removeSpinner(),this.displayMessage(GFPDF.delete_success),this.collection.remove(this.model)},this),error:e.proxy(function(e,u,t){this.removeSpinner(),this.collection.remove(this.model),e.responseJSON.error&&this.displayMessage(e.responseJSON.error,!0)},this)})):this.collection.remove(this.model)},this)},{text:GFPDF.tools_cancel,click:function(){i.wpdialog("destroy")}}];t.Misc.Dialog(i,n,300,175),i.wpdialog("open")},addSpinner:function(){var u=e('<img alt="Loading" src="'+GFPDF.spinnerUrl+'" class="gfpdf-spinner" style="margin-top: 4px;" />');this.$el.find(".font-submit button").after(u)},removeSpinner:function(){this.$el.find(".gfpdf-spinner").remove()},displayMessage:function(u,t){var i=e('<div class="updated notice">');t===!0&&i.addClass("error"),i.html("<p>"+u+"</p>"),this.$el.find("form").before(i)},removeMessage:function(){this.$el.find("div.notice").slideUp(function(){e(this).remove()})}}),t.View.Add=Backbone.View.extend({el:"#font-add-list",events:{click:"addFont"},initialize:function(e){this.container=e.container,this.render()},render:function(){this.$el.html('<i class="fa fa-plus fa-4x"></i><span>Add Font</span>')},addFont:function(e){var u=new t.Model.Core;this.collection.add(u),this.container.$el.find("li:last .font-settings").toggle().find('input[type="text"]:first').focus()}}),t.Misc.Dialog=function(u,t,i,n){u.wpdialog({autoOpen:!1,resizable:!1,draggable:!1,width:i,height:n,modal:!0,dialogClass:"wp-dialog",zIndex:3e5,buttons:t,open:function(){e(this).siblings(".ui-dialog-buttonpane").find("button:eq(1)").focus(),e(".ui-widget-overlay").bind("click",function(){u.wpdialog("close")})}})};var i={};i.SearchModel=Backbone.Model.extend({}),i.SearchCollection=Backbone.Collection.extend({model:i.SearchModel,initialize:function(e,u){this.url=u.url}}),i.ContainerView=Backbone.View.extend({el:"#search-knowledgebase",events:{"keyup #search-help-input":"doSearch","change #search-help-input":"doSearch"},initialize:function(){this.timer=!0,this.render()},render:function(){return this.addSearchBar(),this},addSearchBar:function(){var u=e("<input>").attr("type","text").attr("placeholder"," "+GFPDF.help_search_placeholder).attr("id","search-help-input");this.$el.prepend(u),u.tooltip({items:"input",content:"The search must be more than 3 characters.",tooltipClass:"ui-state-error"}).tooltip("disable"),u.focus()},doSearch:function(u){var t=e(u.currentTarget);window.clearTimeout(this.timer);var i=e.trim(t.val());t.data("currentValue");i.length>3&&t.data("previousValue")!==i?(t.tooltip("disable"),t.data("currentValue",i),this.timer=window.setTimeout(_.bind(function(){this.processSearch(i)},this),500)):i.length<=3&&13==u.keyCode&&t.tooltip("enable").tooltip("open")},processSearch:function(e){console.log("Searching our collection..."),new i.DocsView({s:e})}}),i.MainView=Backbone.View.extend({callAPI:function(e){this.collection.fetch({success:_.bind(this.renderSearch,this),error:_.bind(this.renderSearchError)})},renderSearch:function(e,u){console.log("Rendering Search Results"),this.hideSpinner();var t=this.$el.find(".inside ul");t.html(this.template({collection:this.collection.toJSON(),url:this.url}));var i=t.parent();i.is(":visible")||i.slideDown(500)},renderSearchError:function(e,u){console.log("Search Failed"),console.log(e),console.log(u)},showSpinner:function(){this.$el.find(".spinner").addClass("is-active"),this.$el.is(":visible")||this.$el.slideDown(500)},hideSpinner:function(){this.$el.find(".spinner").removeClass("is-active")}}),i.DocsView=i.MainView.extend({el:"#documentation-api",template:"#GravityPDFSearchResultsDocumentation",initialize:function(e){this.url="https://gravitypdf.com/wp-json/wp/v2/v4_docs/",this.s=e.s,this.render()},render:function(){this.template=_.template(e(this.template).html()),this.showSpinner();var u=encodeURIComponent(this.s),t=this.url+"?search="+u;return this.collection=new i.SearchCollection([],{url:t}),this.callAPI(t),this}});var n=new u;n.init()})}(jQuery);
1
+ !function(e){e(function(){function u(){this.init=function(){this.is_settings()&&this.processSettings()},this.is_settings=function(){return e("#tab_PDF").length},this.processSettings=function(){var u=e(".nav-tab-wrapper a.nav-tab-active:first").text();switch(u){case"Tools":this.tools_settings();break;case"Help":this.help_settings()}},this.help_settings=function(){new n.ContainerView},this.tools_settings=function(){var e=JSON.parse(GFPDF.custom_fonts),u=new i.Collection.Core(e),t=new i.View.Container({collection:u});new i.View.Add({collection:u,container:t})}}var t={evaluate:/\{\{(.+?)\}\}/gim,interpolate:/\{\{=(.+?)\}\}/gim,escape:/\{\{-(.+?)\}\}/gim},i={Model:{},Collection:{},View:{},Misc:{}};i.Model.Core=Backbone.Model.extend({defaults:{font_name:"",regular:"",bold:"",italics:"",bolditalics:"",disabled:!1},url:GFPDF.ajaxurl,save:function(u,t){var i={emulateHTTP:!0,emulateJSON:!0,data:{action:"gfpdf_font_save",nonce:u.nonce,payload:this.toJSON()}};return e.extend(i,t),Backbone.sync("update",this,i)},destroy:function(u,t){var i={emulateHTTP:!0,emulateJSON:!0,data:{action:"gfpdf_font_delete",nonce:u.nonce,id:this.get("id")}};return e.extend(i,t),Backbone.sync("update",this,i)},validate:function(e,u){var t=new RegExp("^[A-Za-z0-9 ]+$");if(e.font_name.length>0){if(!t.test(e.font_name))return"invalid_characters";this.trigger("valid_name")}return this.validateFonts(e)===!1?"invalid_font":void this.trigger("validation_passed",this)},validateFonts:function(u){var t=!0,i={regular:u.regular,bold:u.bold,italics:u.italics,bolditalics:u.bolditalics};return e.each(i,e.proxy(function(e,u){u.length>0&&this.isValidFile(u)===!1?(t=!1,this.trigger("invalid_font",this,!0,e)):this.trigger("valid_font",this,!1,e)},this)),t},isValidFile:function(e){if(e.length<5)return!1;var u=e.substr(e.length-4).toLowerCase();if(".ttf"===u||".otf"===u){var t=new RegExp(/^[a-z](?:[-a-z0-9\+\.])*:(?:\/\/(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~!\$&'\(\)\*\+,;=:\xA0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F][\uDC00-\uDFFD])*@)?(?:\[(?:(?:(?:[0-9a-f]{1,4}:){6}(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|::(?:[0-9a-f]{1,4}:){5}(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|(?:[0-9a-f]{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\(\)\*\+,;=:]+)\]|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}|(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~!\$&'\(\)\*\+,;=@\xA0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F][\uDC00-\uDFFD])*)(?::[0-9]*)?(?:\/(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~!\$&'\(\)\*\+,;=:@\xA0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F][\uDC00-\uDFFD]))*)*|\/(?:(?:(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~!\$&'\(\)\*\+,;=:@\xA0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980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0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F][\uDC00-\uDFFD]))*)*|(?!(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~!\$&'\(\)\*\+,;=:@\xA0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F][\uDC00-\uDFFD])))(?:\?(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~!\$&'\(\)\*\+,;=:@\/\?\xA0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E\uDB80-\uDBBE\uDBC0-\uDBFE][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDC00-\uDFFD])*)?(?:\#(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~!\$&'\(\)\*\+,;=:@\/\?\xA0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB44-\uDB7E][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F][\uDC00-\uDFFD])*)?$/gim);if(t.test(e))return!0}return!1},cssDeclaration:function(e,u,t,i){var n=i.getShortname(u);return'font-family: "'+u+'", '+n+", sans-serif;"},getShortname:function(e){return e=e.toLowerCase(),e=e.replace(" ","")}}),i.Collection.Core=Backbone.Collection.extend({model:i.Model.Core}),i.View.Container=Backbone.View.extend({el:"#font-list",tagName:"ul",initialize:function(e){this.listenTo(this.collection,"add",this.addRender),this.listenTo(this.collection,"remove",this.render),this.render()},render:function(){return this.collection.length>0?(this.$el.empty(),this.collection.each(function(e){this.addRender(e)},this)):this.$el.html(_.template(e("#GravityPDFFontsEmpty").html(),t)),this},addRender:function(e){1===this.collection.length&&this.$el.empty();var u=new i.View.Item({model:e,collection:this.collection});return this.$el.append(u.render().el),this}}),i.View.Item=Backbone.View.extend({template:"#GravityPDFFonts",tagName:"li",events:{"click .font-name":"toggleView","click .delete-font":"deleteModel","submit form":"formSubmission"},initialize:function(){this.modelBinder=new Backbone.ModelBinder,this.listenTo(this.model,"invalid valid_name",this.nameError),this.listenTo(this.model,"invalid_font valid_font",this.fontError),this.listenTo(this.model,"invalid",this.disableSubmitButton),this.listenTo(this.model,"validation_passed",this.enableSubmitButton)},render:function(){return this.template=_.template(e(this.template).html(),t),this.$el.html(this.template({model:this.model})),this.modelBinder.bind(this.model,this.el,{font_name:[{selector:"[name=font_name]"},{selector:"[name=usage]",converter:this.model.cssDeclaration}],regular:"[name=regular]",bold:"[name=bold]",italics:"[name=italics]",bolditalics:"[name=bolditalics]"},{changeTriggers:{"":"change",".font-name-field":"keyup"},modelSetOptions:{validate:!0}}),this},toggleView:function(u){u.preventDefault(),e(u.currentTarget).next().toggle()},nameError:function(e,u){u&&"invalid_characters"==u?this.$el.find('input[name="font_name"]').css("border-color","red"):this.$el.find('input[name="font_name"]').removeAttr("style")},fontError:function(u,t,i){$input=this.$el.find('input[name="'+i+'"]'),t?($error=e('<span class="gf_settings_description"><label>Only TTF and OTF font files are supported.</label></span>'),$input.hasClass("invalid")||$input.addClass("invalid").next().after($error.clone())):$input.hasClass("invalid")&&$input.removeClass("invalid").next().next().remove()},disableSubmitButton:function(e){this.$el.find(".font-submit button").prop("disabled",!0),e.set("disabled",!0)},enableSubmitButton:function(e){this.$el.find(".font-submit button").prop("disabled",!1),e.set("disabled",!1)},formSubmission:function(u){u.preventDefault();e(u.currentTarget);u.currentTarget.checkValidity()&&this.model.get("disabled")===!1&&(this.addSpinner(),this.removeMessage(),console.log(this.model),this.model.save({nonce:this.$el.find("input[name=wpnonce]").val()},{success:e.proxy(function(e,u,t){this.removeSpinner(),this.displayMessage(GFPDF.update_success),this.model.set(e)},this),error:e.proxy(function(e,u,t){this.removeSpinner(),e.responseJSON.error&&this.displayMessage(e.responseJSON.error,!0)},this)}))},deleteModel:function(u){u.preventDefault();var t=e("#delete-confirm"),n=[{text:GFPDF.pdf_list_delete_confirm,click:e.proxy(function(){t.wpdialog("destroy"),this.model.get("id")?(this.addSpinner(),this.removeMessage(),this.$el.hide(),this.model.destroy({nonce:this.$el.find("input[name=wpnonce]").val()},{success:e.proxy(function(e,u,t){this.removeSpinner(),this.displayMessage(GFPDF.delete_success),this.collection.remove(this.model)},this),error:e.proxy(function(e,u,t){this.removeSpinner(),this.collection.remove(this.model),e.responseJSON.error&&this.displayMessage(e.responseJSON.error,!0)},this)})):this.collection.remove(this.model)},this)},{text:GFPDF.tools_cancel,click:function(){t.wpdialog("destroy")}}];i.Misc.Dialog(t,n,300,175),t.wpdialog("open")},addSpinner:function(){var u=e('<img alt="Loading" src="'+GFPDF.spinnerUrl+'" class="gfpdf-spinner" style="margin-top: 4px;" />');this.$el.find(".font-submit button").after(u)},removeSpinner:function(){this.$el.find(".gfpdf-spinner").remove()},displayMessage:function(u,t){var i=e('<div class="updated notice">');t===!0&&i.addClass("error"),i.html("<p>"+u+"</p>"),this.$el.find("form").before(i)},removeMessage:function(){this.$el.find("div.notice").slideUp(function(){e(this).remove()})}}),i.View.Add=Backbone.View.extend({el:"#font-add-list",events:{click:"addFont"},initialize:function(e){this.container=e.container,this.render()},render:function(){this.$el.html('<i class="fa fa-plus fa-4x"></i><span>Add Font</span>')},addFont:function(e){var u=new i.Model.Core;this.collection.add(u),this.container.$el.find("li:last .font-settings").toggle().find('input[type="text"]:first').focus()}}),i.Misc.Dialog=function(u,t,i,n){u.wpdialog({autoOpen:!1,resizable:!1,draggable:!1,width:i,height:n,modal:!0,dialogClass:"wp-dialog",zIndex:3e5,buttons:t,open:function(){e(this).siblings(".ui-dialog-buttonpane").find("button:eq(1)").focus(),e(".ui-widget-overlay").bind("click",function(){u.wpdialog("close")})}})};var n={};n.SearchModel=Backbone.Model.extend({}),n.SearchCollection=Backbone.Collection.extend({model:n.SearchModel,initialize:function(e,u){this.url=u.url}}),n.ContainerView=Backbone.View.extend({el:"#search-knowledgebase",events:{"keyup #search-help-input":"doSearch","change #search-help-input":"doSearch"},initialize:function(){this.timer=!0,this.render()},render:function(){return this.addSearchBar(),this},addSearchBar:function(){var u=e("<input>").attr("type","text").attr("placeholder"," "+GFPDF.help_search_placeholder).attr("id","search-help-input");this.$el.prepend(u),u.tooltip({items:"input",content:"The search must be more than 3 characters.",tooltipClass:"ui-state-error"}).tooltip("disable"),u.focus()},doSearch:function(u){var t=e(u.currentTarget);window.clearTimeout(this.timer);var i=e.trim(t.val());t.data("currentValue");i.length>3&&t.data("previousValue")!==i?(t.tooltip("disable"),t.data("currentValue",i),this.timer=window.setTimeout(_.bind(function(){this.processSearch(i)},this),500)):i.length<=3&&13==u.keyCode&&t.tooltip("enable").tooltip("open")},processSearch:function(e){console.log("Searching our collection..."),new n.DocsView({s:e})}}),n.MainView=Backbone.View.extend({callAPI:function(e){this.collection.fetch({success:_.bind(this.renderSearch,this),error:_.bind(this.renderSearchError)})},renderSearch:function(e,u){console.log("Rendering Search Results"),this.hideSpinner();var t=this.$el.find(".inside ul");t.html(this.template({collection:this.collection.toJSON(),url:this.url}));var i=t.parent();i.is(":visible")||i.slideDown(500)},renderSearchError:function(e,u){console.log("Search Failed"),console.log(e),console.log(u)},showSpinner:function(){this.$el.find(".spinner").addClass("is-active"),this.$el.is(":visible")||this.$el.slideDown(500)},hideSpinner:function(){this.$el.find(".spinner").removeClass("is-active")}}),n.DocsView=n.MainView.extend({el:"#documentation-api",template:"#GravityPDFSearchResultsDocumentation",initialize:function(e){this.url="https://gravitypdf.com/wp-json/wp/v2/v4_docs/",this.s=e.s,this.render()},render:function(){this.template=_.template(e(this.template).html(),t),this.showSpinner();var u=encodeURIComponent(this.s),i=this.url+"?search="+u;return this.collection=new n.SearchCollection([],{url:i}),this.callAPI(i),this}});var D=new u;D.init()})}(jQuery);
src/assets/languages/gravity-forms-pdf-extended.pot CHANGED
@@ -366,124 +366,124 @@ msgstr ""
366
  msgid "Legacy"
367
  msgstr ""
368
 
369
- #: src/helper/abstract/Helper_Abstract_Options.php:1909, src/helper/Helper_PDF_List_Table.php:637
370
  msgctxt "Required"
371
  msgid "needs"
372
  msgstr ""
373
 
374
- #: src/helper/abstract/Helper_Abstract_Options.php:1967
375
  msgid "Template Name"
376
  msgstr ""
377
 
378
- #: src/helper/abstract/Helper_Abstract_Options.php:1969
379
  msgid "Version"
380
  msgstr ""
381
 
382
- #: src/helper/abstract/Helper_Abstract_Options.php:1971
383
  msgid "Description"
384
  msgstr ""
385
 
386
- #: src/helper/abstract/Helper_Abstract_Options.php:1973
387
  msgid "Author"
388
  msgstr ""
389
 
390
- #: src/helper/abstract/Helper_Abstract_Options.php:1975
391
  msgid "Group"
392
  msgstr ""
393
 
394
- #: src/helper/abstract/Helper_Abstract_Options.php:1977, src/helper/Helper_PDF.php:727
395
  msgid "Required PDF Version"
396
  msgstr ""
397
 
398
- #: src/helper/abstract/Helper_Abstract_Options.php:2157
399
  msgid "Unicode"
400
  msgstr ""
401
 
402
- #: src/helper/abstract/Helper_Abstract_Options.php:2185
403
  msgid "Indic"
404
  msgstr ""
405
 
406
- #: src/helper/abstract/Helper_Abstract_Options.php:2195
407
  msgid "Arabic"
408
  msgstr ""
409
 
410
- #: src/helper/abstract/Helper_Abstract_Options.php:2207
411
  msgid "Other"
412
  msgstr ""
413
 
414
- #: src/helper/abstract/Helper_Abstract_Options.php:2311, src/model/Model_Settings.php:619
415
  msgid "User-Defined Fonts"
416
  msgstr ""
417
 
418
- #: src/helper/abstract/Helper_Abstract_Options.php:2449
419
  msgid "Copy"
420
  msgstr ""
421
 
422
- #: src/helper/abstract/Helper_Abstract_Options.php:2451
423
  msgid "Print - Low Resolution"
424
  msgstr ""
425
 
426
- #: src/helper/abstract/Helper_Abstract_Options.php:2453
427
  msgid "Print - High Resolution"
428
  msgstr ""
429
 
430
- #: src/helper/abstract/Helper_Abstract_Options.php:2455
431
  msgid "Modify"
432
  msgstr ""
433
 
434
- #: src/helper/abstract/Helper_Abstract_Options.php:2457
435
  msgid "Annotate"
436
  msgstr ""
437
 
438
- #: src/helper/abstract/Helper_Abstract_Options.php:2459
439
  msgid "Fill Forms"
440
  msgstr ""
441
 
442
- #: src/helper/abstract/Helper_Abstract_Options.php:2461
443
  msgid "Extract"
444
  msgstr ""
445
 
446
- #: src/helper/abstract/Helper_Abstract_Options.php:2463
447
  msgid "Assemble"
448
  msgstr ""
449
 
450
- #: src/helper/abstract/Helper_Abstract_Options.php:2713
451
  msgid "Settings updated."
452
  msgstr ""
453
 
454
- #: src/helper/abstract/Helper_Abstract_Options.php:2951, src/helper/abstract/Helper_Abstract_Options.php:2967, src/helper/abstract/Helper_Abstract_Options.php:2983
455
  msgid "PDF Settings could not be saved. Please enter all required information below."
456
  msgstr ""
457
 
458
- #: src/helper/abstract/Helper_Abstract_Options.php:4047, src/helper/abstract/Helper_Abstract_Options.php:4049
459
  msgid "Select Media"
460
  msgstr ""
461
 
462
- #: src/helper/abstract/Helper_Abstract_Options.php:4051
463
  msgid "Upload File"
464
  msgstr ""
465
 
466
- #: src/helper/abstract/Helper_Abstract_Options.php:4365
467
  msgid "Width"
468
  msgstr ""
469
 
470
- #: src/helper/abstract/Helper_Abstract_Options.php:4367
471
  msgid "Height"
472
  msgstr ""
473
 
474
- #: src/helper/abstract/Helper_Abstract_Options.php:4373
475
  msgid "mm"
476
  msgstr ""
477
 
478
- #: src/helper/abstract/Helper_Abstract_Options.php:4375
479
  msgid "inches"
480
  msgstr ""
481
 
482
- #: src/helper/abstract/Helper_Abstract_Options.php:4495
483
  msgid "The callback used for the %s setting is missing."
484
  msgstr ""
485
 
486
- #: src/helper/abstract/Helper_Abstract_View.php:263
487
  msgid "Cannot find file %s"
488
  msgstr ""
489
 
366
  msgid "Legacy"
367
  msgstr ""
368
 
369
+ #: src/helper/abstract/Helper_Abstract_Options.php:1911, src/helper/Helper_PDF_List_Table.php:637
370
  msgctxt "Required"
371
  msgid "needs"
372
  msgstr ""
373
 
374
+ #: src/helper/abstract/Helper_Abstract_Options.php:1971
375
  msgid "Template Name"
376
  msgstr ""
377
 
378
+ #: src/helper/abstract/Helper_Abstract_Options.php:1973
379
  msgid "Version"
380
  msgstr ""
381
 
382
+ #: src/helper/abstract/Helper_Abstract_Options.php:1975
383
  msgid "Description"
384
  msgstr ""
385
 
386
+ #: src/helper/abstract/Helper_Abstract_Options.php:1977
387
  msgid "Author"
388
  msgstr ""
389
 
390
+ #: src/helper/abstract/Helper_Abstract_Options.php:1979
391
  msgid "Group"
392
  msgstr ""
393
 
394
+ #: src/helper/abstract/Helper_Abstract_Options.php:1981, src/helper/Helper_PDF.php:727
395
  msgid "Required PDF Version"
396
  msgstr ""
397
 
398
+ #: src/helper/abstract/Helper_Abstract_Options.php:2165
399
  msgid "Unicode"
400
  msgstr ""
401
 
402
+ #: src/helper/abstract/Helper_Abstract_Options.php:2193
403
  msgid "Indic"
404
  msgstr ""
405
 
406
+ #: src/helper/abstract/Helper_Abstract_Options.php:2203
407
  msgid "Arabic"
408
  msgstr ""
409
 
410
+ #: src/helper/abstract/Helper_Abstract_Options.php:2215
411
  msgid "Other"
412
  msgstr ""
413
 
414
+ #: src/helper/abstract/Helper_Abstract_Options.php:2319, src/model/Model_Settings.php:619
415
  msgid "User-Defined Fonts"
416
  msgstr ""
417
 
418
+ #: src/helper/abstract/Helper_Abstract_Options.php:2457
419
  msgid "Copy"
420
  msgstr ""
421
 
422
+ #: src/helper/abstract/Helper_Abstract_Options.php:2459
423
  msgid "Print - Low Resolution"
424
  msgstr ""
425
 
426
+ #: src/helper/abstract/Helper_Abstract_Options.php:2461
427
  msgid "Print - High Resolution"
428
  msgstr ""
429
 
430
+ #: src/helper/abstract/Helper_Abstract_Options.php:2463
431
  msgid "Modify"
432
  msgstr ""
433
 
434
+ #: src/helper/abstract/Helper_Abstract_Options.php:2465
435
  msgid "Annotate"
436
  msgstr ""
437
 
438
+ #: src/helper/abstract/Helper_Abstract_Options.php:2467
439
  msgid "Fill Forms"
440
  msgstr ""
441
 
442
+ #: src/helper/abstract/Helper_Abstract_Options.php:2469
443
  msgid "Extract"
444
  msgstr ""
445
 
446
+ #: src/helper/abstract/Helper_Abstract_Options.php:2471
447
  msgid "Assemble"
448
  msgstr ""
449
 
450
+ #: src/helper/abstract/Helper_Abstract_Options.php:2721
451
  msgid "Settings updated."
452
  msgstr ""
453
 
454
+ #: src/helper/abstract/Helper_Abstract_Options.php:2959, src/helper/abstract/Helper_Abstract_Options.php:2975, src/helper/abstract/Helper_Abstract_Options.php:2991
455
  msgid "PDF Settings could not be saved. Please enter all required information below."
456
  msgstr ""
457
 
458
+ #: src/helper/abstract/Helper_Abstract_Options.php:4055, src/helper/abstract/Helper_Abstract_Options.php:4057
459
  msgid "Select Media"
460
  msgstr ""
461
 
462
+ #: src/helper/abstract/Helper_Abstract_Options.php:4059
463
  msgid "Upload File"
464
  msgstr ""
465
 
466
+ #: src/helper/abstract/Helper_Abstract_Options.php:4373
467
  msgid "Width"
468
  msgstr ""
469
 
470
+ #: src/helper/abstract/Helper_Abstract_Options.php:4375
471
  msgid "Height"
472
  msgstr ""
473
 
474
+ #: src/helper/abstract/Helper_Abstract_Options.php:4381
475
  msgid "mm"
476
  msgstr ""
477
 
478
+ #: src/helper/abstract/Helper_Abstract_Options.php:4383
479
  msgid "inches"
480
  msgstr ""
481
 
482
+ #: src/helper/abstract/Helper_Abstract_Options.php:4503
483
  msgid "The callback used for the %s setting is missing."
484
  msgstr ""
485
 
486
+ #: src/helper/abstract/Helper_Abstract_View.php:285
487
  msgid "Cannot find file %s"
488
  msgstr ""
489
 
src/helper/Helper_Migration.php CHANGED
@@ -592,8 +592,11 @@ class Helper_Migration {
592
 
593
  /* Check if there is a fonts directory to migrate from and to */
594
  if ( is_dir( $path . 'fonts' ) && is_dir( $this->data->template_font_location ) ) {
595
- foreach ( glob( $path . 'fonts/' . '*.{otf,ttf,OTF,TTF}', GLOB_BRACE ) as $font ) {
596
- $font_name = basename( $font );
 
 
 
597
  @copy( $font, $this->data->template_font_location . $font_name );
598
  }
599
 
592
 
593
  /* Check if there is a fonts directory to migrate from and to */
594
  if ( is_dir( $path . 'fonts' ) && is_dir( $this->data->template_font_location ) ) {
595
+ $fonts = glob( $path . 'fonts/' . '*.{otf,ttf,OTF,TTF}', GLOB_BRACE );
596
+ $fonts = ( is_array( $fonts ) ) ? $fonts : array();
597
+
598
+ foreach ( $fonts as $font ) {
599
+ $font_name = basename( $font );
600
  @copy( $font, $this->data->template_font_location . $font_name );
601
  }
602
 
src/helper/abstract/Helper_Abstract_Options.php CHANGED
@@ -942,22 +942,24 @@ abstract class Helper_Abstract_Options implements Helper_Interface_Filters {
942
  $templates = array();
943
  $legacy = array();
944
 
945
- foreach ( $template_list as $filename ) {
 
946
 
947
- /* Get the header information to find out what group it's in and if it is compatible with our verison of Gravity PDF */
948
- $info = $this->get_template_headers( $filename );
949
- $file = basename( $filename, '.php' );
950
 
951
- if ( ! empty( $info['template'] ) ) {
952
 
953
- /* Check if template compatible */
954
- if ( ! empty( $info['required_pdf_version'] ) && version_compare( $info['required_pdf_version'], PDF_EXTENDED_VERSION, '>' ) ) {
955
- $info['template'] .= ' (+ ' . _x( 'needs', 'Required', 'gravity-forms-pdf-extended' ) . ' v' . $info['required_pdf_version'] . ')';
956
- }
957
 
958
- $templates[ $info['group'] ][ $file ] = $info['template'];
959
- } else if ( $file !== 'configuration' && $file !== 'configuration.archive' ) { /* exclude legacy configuration file */
960
- $legacy[ $file ] = $this->misc->human_readable( $file );
 
961
  }
962
  }
963
 
@@ -1063,7 +1065,9 @@ abstract class Helper_Abstract_Options implements Helper_Interface_Filters {
1063
  * @since 4.0
1064
  */
1065
  public function get_plugin_pdf_templates() {
1066
- return glob( PDF_PLUGIN_DIR . 'src/templates/*.php' );
 
 
1067
  }
1068
 
1069
 
942
  $templates = array();
943
  $legacy = array();
944
 
945
+ if( is_array( $template_list ) ) {
946
+ foreach ( $template_list as $filename ) {
947
 
948
+ /* Get the header information to find out what group it's in and if it is compatible with our verison of Gravity PDF */
949
+ $info = $this->get_template_headers( $filename );
950
+ $file = basename( $filename, '.php' );
951
 
952
+ if ( ! empty( $info['template'] ) ) {
953
 
954
+ /* Check if template compatible */
955
+ if ( ! empty( $info['required_pdf_version'] ) && version_compare( $info['required_pdf_version'], PDF_EXTENDED_VERSION, '>' ) ) {
956
+ $info['template'] .= ' (+ ' . _x( 'needs', 'Required', 'gravity-forms-pdf-extended' ) . ' v' . $info['required_pdf_version'] . ')';
957
+ }
958
 
959
+ $templates[ $info['group'] ][ $file ] = $info['template'];
960
+ } else if ( $file !== 'configuration' && $file !== 'configuration.archive' ) { /* exclude legacy configuration file */
961
+ $legacy[ $file ] = $this->misc->human_readable( $file );
962
+ }
963
  }
964
  }
965
 
1065
  * @since 4.0
1066
  */
1067
  public function get_plugin_pdf_templates() {
1068
+ $templates = glob( PDF_PLUGIN_DIR . 'src/templates/*.php' );
1069
+
1070
+ return ( is_array( $templates ) ) ? $templates : array();
1071
  }
1072
 
1073
 
src/helper/abstract/Helper_Abstract_View.php CHANGED
@@ -96,6 +96,17 @@ abstract class Helper_Abstract_View extends Helper_Abstract_Model {
96
  return $this->load( $name, $vars );
97
  }
98
 
 
 
 
 
 
 
 
 
 
 
 
99
  /**
100
  * Load a view file based on the filename and type
101
  *
@@ -108,7 +119,7 @@ abstract class Helper_Abstract_View extends Helper_Abstract_Model {
108
  * @since 4.0
109
  */
110
  final protected function load( $filename, $args = array(), $output = true ) {
111
- $path = PDF_PLUGIN_DIR . 'src/view/html/' . $this->view_type . '/' . $filename . '.php';
112
  $args = array_merge( $this->data_cache, $args );
113
 
114
  if ( is_readable( $path ) ) {
96
  return $this->load( $name, $vars );
97
  }
98
 
99
+ /**
100
+ * Get the full path to the current view
101
+ *
102
+ * @return string The path
103
+ *
104
+ * @since 4.0.1
105
+ */
106
+ final public function get_view_dir_path() {
107
+ return PDF_PLUGIN_DIR . 'src/view/html/' . $this->view_type . '/';
108
+ }
109
+
110
  /**
111
  * Load a view file based on the filename and type
112
  *
119
  * @since 4.0
120
  */
121
  final protected function load( $filename, $args = array(), $output = true ) {
122
+ $path = $this->get_view_dir_path() . $filename . '.php';
123
  $args = array_merge( $this->data_cache, $args );
124
 
125
  if ( is_readable( $path ) ) {
src/helper/fields/Field_Checkbox.php CHANGED
@@ -137,8 +137,8 @@ class Field_Checkbox extends Helper_Abstract_Fields {
137
  $html = '<ul class="bulleted checkbox">';
138
  $i = 1;
139
  foreach ( $items as $item ) {
140
- $sanitized_value = $item['value'];
141
- $sanitized_option = ( $value ) ? $sanitized_value : $item['label'];
142
 
143
  $html .= '<li id="field-' . $this->field->id . '-option-' . $i . '">' . $sanitized_option . '</li>';
144
  $i++;
137
  $html = '<ul class="bulleted checkbox">';
138
  $i = 1;
139
  foreach ( $items as $item ) {
140
+ $sanitized_option = ( $value ) ? $item['value'] : $item['label'];
141
+ $sanitized_option = wp_kses_post( wp_specialchars_decode( $sanitized_option, ENT_QUOTES ) );
142
 
143
  $html .= '<li id="field-' . $this->field->id . '-option-' . $i . '">' . $sanitized_option . '</li>';
144
  $i++;
src/helper/fields/Field_Post_Category.php CHANGED
@@ -194,15 +194,23 @@ class Field_Post_Category extends Helper_Abstract_Fields {
194
 
195
  /* Process the category label */
196
  if ( isset( $val['label'] ) ) {
197
- $label = GFCommon::prepare_post_category_value( $val['label'], $this->field );
198
- $val['label'] = ( is_array( $label ) && isset( $label[0] ) ) ? $label[0] : $label;
 
 
 
 
199
  $val['label'] = esc_html( $val['label'] );
200
  }
201
 
202
  /* process the category value */
203
  if ( isset( $val['value'] ) ) {
204
- $id = GFCommon::prepare_post_category_value( $val['value'], $this->field, 'conditional_logic' );
205
- $val['value'] = ( is_array( $id ) && isset( $id[0] ) ) ? $id[0] : $id;
 
 
 
 
206
  $val['value'] = esc_html( $val['value'] );
207
  }
208
  }
194
 
195
  /* Process the category label */
196
  if ( isset( $val['label'] ) ) {
197
+ $val['label'] = GFCommon::prepare_post_category_value( $val['label'], $this->field );
198
+
199
+ if ( is_array( $val['label'] ) ) {
200
+ $val['label'] = ( isset( $val['label'][0] ) ) ? $val['label'][0] : '';
201
+ }
202
+
203
  $val['label'] = esc_html( $val['label'] );
204
  }
205
 
206
  /* process the category value */
207
  if ( isset( $val['value'] ) ) {
208
+ $val['value']= GFCommon::prepare_post_category_value( $val['value'], $this->field, 'conditional_logic' );
209
+
210
+ if ( is_array( $val['value'] ) ) {
211
+ $val['value'] = ( isset( $val['value'][0] ) ) ? $val['value'][0] : '';
212
+ }
213
+
214
  $val['value'] = esc_html( $val['value'] );
215
  }
216
  }
src/helper/fields/Field_Radio.php CHANGED
@@ -89,9 +89,41 @@ class Field_Radio extends Helper_Abstract_Fields {
89
  $data = $this->value();
90
  $output = ( $value ) ? $data['value'] : $data['label'];
91
 
 
 
 
 
 
92
  return parent::html( $output );
93
  }
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  /**
96
  * Return the HTML form data
97
  *
89
  $data = $this->value();
90
  $output = ( $value ) ? $data['value'] : $data['label'];
91
 
92
+ /* Allow HTML if the radio value isn't the "other" option */
93
+ if ( ! $this->is_user_defined_value( $data['value'] ) ) {
94
+ $output = wp_kses_post( wp_specialchars_decode( $output, ENT_QUOTES ) );
95
+ }
96
+
97
  return parent::html( $output );
98
  }
99
 
100
+ /**
101
+ * Checks if the selected Radio button value is defined by the site owner (standard radio options)
102
+ * or by the end user (through the "other" option).
103
+ *
104
+ * @param string $value The user-selected radio button value
105
+ *
106
+ * @return bool Returns true if value is user-defined, or false otherwise
107
+ *
108
+ * @since 4.0.1
109
+ */
110
+ protected function is_user_defined_value( $value ) {
111
+
112
+ /* Check if the field has the "Other" choice enabled */
113
+ if ( ! isset( $this->field->enableOtherChoice ) || true !== $this->field->enableOtherChoice ) {
114
+ return false;
115
+ }
116
+
117
+ /* Loop through the values and check if we have a match */
118
+ foreach ( $this->field->choices as $item ) {
119
+ if ( wp_specialchars_decode( $value, ENT_QUOTES ) === $item['value'] ) {
120
+ return false;
121
+ }
122
+ }
123
+
124
+ return true;
125
+ }
126
+
127
  /**
128
  * Return the HTML form data
129
  *
src/model/Model_PDF.php CHANGED
@@ -1046,7 +1046,7 @@ class Model_PDF extends Helper_Abstract_Model {
1046
  }
1047
 
1048
  /* Check if the file is too old and delete file / directory */
1049
- if ( filemtime( $file ) < time() - $max_file_age ) {
1050
 
1051
  if ( $directory ) {
1052
  $this->misc->rmdir( substr( $file, 0, -1 ) );
@@ -1210,7 +1210,10 @@ class Model_PDF extends Helper_Abstract_Model {
1210
  */
1211
  public function add_unregistered_fonts_to_mPDF( $fonts ) {
1212
 
1213
- foreach ( glob( $this->data->template_font_location . '*.{otf,ttf,OTF,TTF}', GLOB_BRACE ) as $font ) {
 
 
 
1214
 
1215
  /* Get font shortname */
1216
  $font_name = basename( $font );
1046
  }
1047
 
1048
  /* Check if the file is too old and delete file / directory */
1049
+ if ( file_exists( $file ) && filemtime( $file ) < time() - $max_file_age ) {
1050
 
1051
  if ( $directory ) {
1052
  $this->misc->rmdir( substr( $file, 0, -1 ) );
1210
  */
1211
  public function add_unregistered_fonts_to_mPDF( $fonts ) {
1212
 
1213
+ $user_fonts = glob( $this->data->template_font_location . '*.{otf,ttf,OTF,TTF}', GLOB_BRACE );
1214
+ $user_fonts = ( is_array( $user_fonts ) ) ? $user_fonts : array();
1215
+
1216
+ foreach ( $user_fonts as $font ) {
1217
 
1218
  /* Get font shortname */
1219
  $font_name = basename( $font );
src/model/Model_Shortcodes.php CHANGED
@@ -1,427 +1,427 @@
1
- <?php
2
-
3
- namespace GFPDF\Model;
4
-
5
- use GFPDF\Helper\Helper_Abstract_Model;
6
- use GFPDF\Helper\Helper_Abstract_Form;
7
- use GFPDF\Helper\Helper_Abstract_Options;
8
- use GFPDF\Helper\Helper_Misc;
9
-
10
- use Psr\Log\LoggerInterface;
11
-
12
- use GPDFAPI;
13
- use GFCommon;
14
- use GravityView_View;
15
-
16
- /**
17
- * PDF Shortcode Model
18
- *
19
- * @package Gravity PDF
20
- * @copyright Copyright (c) 2016, Blue Liquid Designs
21
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
22
- * @since 4.0
23
- */
24
-
25
- /* Exit if accessed directly */
26
- if ( ! defined( 'ABSPATH' ) ) {
27
- exit;
28
- }
29
-
30
- /*
31
- This file is part of Gravity PDF.
32
-
33
- Gravity PDF – Copyright (C) 2016, Blue Liquid Designs
34
-
35
- This program is free software; you can redistribute it and/or modify
36
- it under the terms of the GNU General Public License as published by
37
- the Free Software Foundation; either version 2 of the License, or
38
- (at your option) any later version.
39
-
40
- This program is distributed in the hope that it will be useful,
41
- but WITHOUT ANY WARRANTY; without even the implied warranty of
42
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43
- GNU General Public License for more details.
44
-
45
- You should have received a copy of the GNU General Public License
46
- along with this program; if not, write to the Free Software
47
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48
- */
49
-
50
- /**
51
- *
52
- * Handles all the PDF Shortcode logic
53
- *
54
- * @since 4.0
55
- */
56
- class Model_Shortcodes extends Helper_Abstract_Model {
57
-
58
- /**
59
- * Holds the abstracted Gravity Forms API specific to Gravity PDF
60
- *
61
- * @var \GFPDF\Helper\Helper_Form
62
- *
63
- * @since 4.0
64
- */
65
- protected $gform;
66
-
67
- /**
68
- * Holds our log class
69
- *
70
- * @var \Monolog\Logger|LoggerInterface
71
- *
72
- * @since 4.0
73
- */
74
- protected $log;
75
-
76
- /**
77
- * Holds our Helper_Abstract_Options / Helper_Options_Fields object
78
- * Makes it easy to access global PDF settings and individual form PDF settings
79
- *
80
- * @var \GFPDF\Helper\Helper_Options_Fields
81
- *
82
- * @since 4.0
83
- */
84
- protected $options;
85
-
86
- /**
87
- * Holds our Helper_Misc object
88
- * Makes it easy to access common methods throughout the plugin
89
- *
90
- * @var \GFPDF\Helper\Helper_Misc
91
- *
92
- * @since 4.0
93
- */
94
- protected $misc;
95
-
96
- /**
97
- * Setup our class by injecting all our dependancies
98
- *
99
- * @param \GFPDF\Helper\Helper_Abstract_Form|\GFPDF\Helper\Helper_Form $gform Our abstracted Gravity Forms helper functions
100
- * @param \Monolog\Logger|LoggerInterface $log Our logger class
101
- * @param \GFPDF\Helper\Helper_Abstract_Options|\GFPDF\Helper\Helper_Options_Fields $options Our options class which allows us to access any settings
102
- *
103
- * @since 4.0
104
- */
105
- public function __construct( Helper_Abstract_Form $gform, LoggerInterface $log, Helper_Abstract_Options $options, Helper_Misc $misc ) {
106
-
107
- /* Assign our internal variables */
108
- $this->gform = $gform;
109
- $this->log = $log;
110
- $this->options = $options;
111
- $this->misc = $misc;
112
- }
113
-
114
- /**
115
- * Generates a direct link to the PDF that should be generated
116
- * If placed in a confirmation the appropriate entry will be displayed.
117
- * A user also has the option to pass in an "entry" parameter to define the entry ID
118
- *
119
- * @param array $attributes The shortcode attributes specified
120
- *
121
- * @return string
122
- *
123
- * @since 4.0
124
- */
125
- public function gravitypdf( $attributes ) {
126
-
127
- $this->log->addNotice( 'Generating Shortcode' );
128
-
129
- $controller = $this->getController();
130
- $has_view_permissions = $this->gform->has_capability( 'gravityforms_view_entries' );
131
-
132
- /* merge in any missing defaults */
133
- $attributes = shortcode_atts( array(
134
- 'id' => '',
135
- 'text' => 'Download PDF',
136
- 'type' => 'download',
137
- 'class' => 'gravitypdf-download-link',
138
- 'classes' => '',
139
- 'entry' => '',
140
- 'print' => '',
141
- ), $attributes, 'gravitypdf' );
142
-
143
- /* See https://gravitypdf.com/documentation/v4/gfpdf_gravityforms_shortcode_attributes/ for more information about this filter */
144
- $attributes = apply_filters( 'gfpdf_gravityforms_shortcode_attributes', $attributes );
145
-
146
- /* Add Shortcake preview support */
147
- if ( defined( 'SHORTCODE_UI_DOING_PREVIEW' ) && SHORTCODE_UI_DOING_PREVIEW === true ) {
148
- $attributes['url'] = '#';
149
-
150
- return $controller->view->display_gravitypdf_shortcode( $attributes );
151
- }
152
-
153
- /* Check if we have an entry ID, otherwise check the GET and POST data */
154
- if ( empty( $attributes['entry'] ) ) {
155
- if ( isset( $_GET['lid'] ) || isset( $_GET['entry'] ) ) {
156
- $attributes['entry'] = ( isset( $_GET['lid'] ) ) ? (int) $_GET['lid'] : (int) $_GET['entry'];
157
- } else {
158
-
159
- /* Only display error to users with appropriate permissions */
160
- if ( $has_view_permissions ) {
161
- return $controller->view->no_entry_id();
162
- }
163
-
164
- return '';
165
- }
166
- }
167
-
168
- /* Check if we have a valid PDF configuration */
169
- $entry = $this->gform->get_entry( $attributes['entry'] );
170
- $config = ( ! is_wp_error( $entry ) ) ? $this->options->get_pdf( $entry['form_id'], $attributes['id'] ) : $entry; /* if invalid entry a WP_Error will be thrown */
171
-
172
- if ( is_wp_error( $config ) ) {
173
-
174
- /* Only display error to users with appropriate permissions */
175
- if ( $has_view_permissions ) {
176
- return $controller->view->invalid_pdf_config();
177
- }
178
-
179
- return '';
180
- }
181
-
182
- /* Check if the PDF is enabled AND the conditional logic (if any) has been met */
183
- if ( $config['active'] !== true ) {
184
- /* Only display error to users with appropriate permissions */
185
- if ( $has_view_permissions ) {
186
- return $controller->view->pdf_not_active();
187
- }
188
-
189
- return '';
190
- }
191
-
192
- if ( isset( $config['conditionalLogic'] ) && ! $this->misc->evaluate_conditional_logic( $config['conditionalLogic'], $entry ) ) {
193
- /* Only display error to users with appropriate permissions */
194
- if ( $has_view_permissions ) {
195
- return $controller->view->conditional_logic_not_met();
196
- }
197
-
198
- return '';
199
- }
200
-
201
- /* Everything looks valid so let's get the URL */
202
- $pdf = new Model_PDF( $this->gform, $this->log, $this->options, GPDFAPI::get_data_class(), GPDFAPI::get_misc_class(), GPDFAPI::get_notice_class() );
203
- $download = ( $attributes['type'] == 'download' ) ? true : false;
204
- $print = ( ! empty( $attributes['print'] ) ) ? true : false;
205
- $attributes['url'] = $pdf->get_pdf_url( $attributes['id'], $attributes['entry'], $download, $print );
206
-
207
- /* generate the markup and return */
208
- $this->log->addNotice( 'Generating Shortcode Markup', array(
209
- 'attr' => $attributes,
210
- ) );
211
-
212
- return $controller->view->display_gravitypdf_shortcode( $attributes );
213
- }
214
-
215
- /**
216
- * Update our Gravity Forms "Text" Confirmation Shortcode to include the current entry ID
217
- *
218
- * @param string $confirmation The confirmation text
219
- * @param array $form The Gravity Form array
220
- * @param array $entry The Gravity Form entry information
221
- *
222
- * @return array The confirmation text
223
- *
224
- * @since 4.0
225
- */
226
- public function gravitypdf_confirmation( $confirmation, $form, $entry ) {
227
-
228
- /* check if confirmation is text-based */
229
- if ( ! is_array( $confirmation ) ) {
230
- $confirmation = $this->add_entry_id_to_shortcode( $confirmation, $entry['id'] );
231
- }
232
-
233
- return $confirmation;
234
- }
235
-
236
- /**
237
- * Update our Gravity Forms Notification Shortcode to include the current entry ID
238
- *
239
- * @param string $notification The confirmation text
240
- * @param array $form The Gravity Form array
241
- * @param array $entry The Gravity Form entry information
242
- *
243
- * @return array The confirmation text
244
- *
245
- * @since 4.0
246
- */
247
- public function gravitypdf_notification( $notification, $form, $entry ) {
248
-
249
- /* check if notification has a 'message' */
250
- if ( isset( $notification['message'] ) ) {
251
- $notification['message'] = $this->add_entry_id_to_shortcode( $notification['message'], $entry['id'] );
252
- }
253
-
254
- return $notification;
255
- }
256
-
257
- /**
258
- * Add basic GravityView support and parse the Custom Content field for the [gravitypdf] shortcode
259
- * This means users can copy and paste our sample shortcode without having to worry about an entry ID being passed.
260
- *
261
- * @param string $html
262
- *
263
- * @return string
264
- *
265
- * @since 4.0
266
- */
267
- public function gravitypdf_gravityview_custom( $html ) {
268
- $gravityview_view = GravityView_View::getInstance();
269
- $entry = $gravityview_view->getCurrentEntry();
270
- return $this->add_entry_id_to_shortcode( $html, $entry['id'] );
271
- }
272
-
273
- /**
274
- * Check for the [gravitypdf] shortcode and add the entry ID to it
275
- *
276
- * @param $string The text to search
277
- * @param $entry_id The entry ID to add to our shortcode
278
- *
279
- * @return string
280
- *
281
- * @since 4.0
282
- */
283
- private function add_entry_id_to_shortcode( $string, $entry_id ) {
284
- /* Check if our shortcode exists and add the entry ID if needed */
285
- $gravitypdf = $this->get_shortcode_information( 'gravitypdf', $string );
286
-
287
- if ( sizeof( $gravitypdf ) > 0 ) {
288
- foreach ( $gravitypdf as $shortcode ) {
289
- /* if the user hasn't explicitely defined an entry to display... */
290
- if ( ! isset( $shortcode['attr']['entry'] ) ) {
291
- /* get the new shortcode information */
292
- $new_shortcode = $this->add_shortcode_attr( $shortcode, 'entry', $entry_id );
293
-
294
- /* update our confirmation message */
295
- $string = str_replace( $shortcode['shortcode'], $new_shortcode['shortcode'], $string );
296
- }
297
- }
298
- }
299
-
300
- return $string;
301
- }
302
-
303
- /**
304
- * Update a shortcode attributes
305
- *
306
- * @param array $code In individual shortcode array pulled in from the $this->get_shortcode_information() function
307
- * @param string $attr The attribute to add / replace
308
- * @param string $value The new attribute value
309
- *
310
- * @return array
311
- *
312
- * @since 4.0
313
- */
314
- public function add_shortcode_attr( $code, $attr, $value ) {
315
- /* if the attribute doesn't already exist... */
316
- if ( ! isset( $code['attr'][ $attr ] ) ) {
317
-
318
- $raw_attr = "{$code['attr_raw']} {$attr}=\"{$value}\"";
319
-
320
- /* if there are no attributes at all we'll need to fix our str replace */
321
- if ( 0 === strlen( $code['attr_raw'] ) ) {
322
- $pattern = '^\[([a-zA-Z]+)';
323
- $code['shortcode'] = preg_replace( "/$pattern/s", "[$1 {$attr}=\"{$value}\"", $code['shortcode'] );
324
- } else {
325
- $code['shortcode'] = str_ireplace( $code['attr_raw'], $raw_attr, $code['shortcode'] );
326
- }
327
-
328
- $code['attr_raw'] = $raw_attr;
329
-
330
- } else { /* replace the current attribute */
331
- $pattern = $attr . '="(.+?)"';
332
- $code['shortcode'] = preg_replace( "/$pattern/si", $attr . '="' . $value . '"', $code['shortcode'] );
333
- $code['attr_raw'] = preg_replace( "/$pattern/si", $attr . '="' . $value . '"', $code['attr_raw'] );
334
- }
335
-
336
- /* Update the actual attribute */
337
- $code['attr'][ $attr ] = $value;
338
-
339
- return $code;
340
- }
341
-
342
- /**
343
- * Check if user is currently submitting a new confirmation redirect URL in the admin area,
344
- * if so replace any shortcodes with a direct link to the PDF (as Gravity Forms correctly validates the URL)
345
- *
346
- * @param array $form Gravity Form Array
347
- *
348
- * @return array
349
- *
350
- * @since 4.0
351
- */
352
- public function gravitypdf_redirect_confirmation( $form ) {
353
-
354
- /* check if the confirmation is currently being saved */
355
- if ( isset( $_POST['form_confirmation_url'] ) ) {
356
-
357
- $this->log->addNotice( 'Process Redirect Confirmation Save', array(
358
- 'form_id' => $form['id'],
359
- 'post' => $_POST,
360
- ) );
361
-
362
- $url = stripslashes_deep( $_POST['form_confirmation_url'] );
363
-
364
- /* check if our shortcode exists and convert it to a URL */
365
- $gravitypdf = $this->get_shortcode_information( 'gravitypdf', $url );
366
-
367
- if ( sizeof( $gravitypdf ) > 0 ) {
368
-
369
- foreach ( $gravitypdf as $code ) {
370
-
371
- /* get the PDF Settings ID */
372
- $pid = ( isset( $code['attr']['id'] ) ) ? $code['attr']['id'] : '';
373
-
374
- if ( ! empty( $pid ) ) {
375
-
376
- /* generate the PDF URL */
377
- $pdf = new Model_PDF( $this->gform, $this->log, $this->options, GPDFAPI::get_data_class(), GPDFAPI::get_misc_class(), GPDFAPI::get_notice_class() );
378
- $download = ( ! isset( $code['attr']['type'] ) || $code['attr']['type'] == 'download' ) ? true : false;
379
- $pdf_url = $pdf->get_pdf_url( $pid, '{entry_id}', $download, false, false );
380
-
381
- /* override the confirmation URL submitted */
382
- $_POST['form_confirmation_url'] = str_replace( $code['shortcode'], $pdf_url, $url );
383
- }
384
- }
385
- }
386
- }
387
-
388
- /* it's a filter so return the $form array */
389
-
390
- return $form;
391
- }
392
-
393
- /**
394
- * Search for any shortcodes in the text and return any matches
395
- *
396
- * @param string $shortcode The shortcode to search for
397
- * @param string $text The text to search in
398
- *
399
- * @return array The shortcode information
400
- *
401
- * @since 4.0
402
- */
403
- public function get_shortcode_information( $shortcode, $text ) {
404
- $shortcodes = array();
405
-
406
- if ( has_shortcode( $text, $shortcode ) ) {
407
-
408
- /* our shortcode exists so parse the shortcode data and return an easy-to-use array */
409
- $pattern = get_shortcode_regex();
410
- preg_match_all( "/$pattern/s", $text, $matches );
411
-
412
- if ( ! empty( $matches ) && isset( $matches[2] ) ) {
413
- foreach ( $matches[2] as $key => $code ) {
414
- if ( $code == $shortcode ) {
415
- $shortcodes[] = array(
416
- 'shortcode' => $matches[0][ $key ],
417
- 'attr_raw' => $matches[3][ $key ],
418
- 'attr' => shortcode_parse_atts( $matches[3][ $key ] ),
419
- );
420
- }
421
- }
422
- }
423
- }
424
-
425
- return $shortcodes;
426
- }
427
- }
1
+ <?php
2
+
3
+ namespace GFPDF\Model;
4
+
5
+ use GFPDF\Helper\Helper_Abstract_Model;
6
+ use GFPDF\Helper\Helper_Abstract_Form;
7
+ use GFPDF\Helper\Helper_Abstract_Options;
8
+ use GFPDF\Helper\Helper_Misc;
9
+
10
+ use Psr\Log\LoggerInterface;
11
+
12
+ use GPDFAPI;
13
+ use GFCommon;
14
+ use GravityView_View;
15
+
16
+ /**
17
+ * PDF Shortcode Model
18
+ *
19
+ * @package Gravity PDF
20
+ * @copyright Copyright (c) 2016, Blue Liquid Designs
21
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
22
+ * @since 4.0
23
+ */
24
+
25
+ /* Exit if accessed directly */
26
+ if ( ! defined( 'ABSPATH' ) ) {
27
+ exit;
28
+ }
29
+
30
+ /*
31
+ This file is part of Gravity PDF.
32
+
33
+ Gravity PDF – Copyright (C) 2016, Blue Liquid Designs
34
+
35
+ This program is free software; you can redistribute it and/or modify
36
+ it under the terms of the GNU General Public License as published by
37
+ the Free Software Foundation; either version 2 of the License, or
38
+ (at your option) any later version.
39
+
40
+ This program is distributed in the hope that it will be useful,
41
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
42
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43
+ GNU General Public License for more details.
44
+
45
+ You should have received a copy of the GNU General Public License
46
+ along with this program; if not, write to the Free Software
47
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48
+ */
49
+
50
+ /**
51
+ *
52
+ * Handles all the PDF Shortcode logic
53
+ *
54
+ * @since 4.0
55
+ */
56
+ class Model_Shortcodes extends Helper_Abstract_Model {
57
+
58
+ /**
59
+ * Holds the abstracted Gravity Forms API specific to Gravity PDF
60
+ *
61
+ * @var \GFPDF\Helper\Helper_Form
62
+ *
63
+ * @since 4.0
64
+ */
65
+ protected $gform;
66
+
67
+ /**
68
+ * Holds our log class
69
+ *
70
+ * @var \Monolog\Logger|LoggerInterface
71
+ *
72
+ * @since 4.0
73
+ */
74
+ protected $log;
75
+
76
+ /**
77
+ * Holds our Helper_Abstract_Options / Helper_Options_Fields object
78
+ * Makes it easy to access global PDF settings and individual form PDF settings
79
+ *
80
+ * @var \GFPDF\Helper\Helper_Options_Fields
81
+ *
82
+ * @since 4.0
83
+ */
84
+ protected $options;
85
+
86
+ /**
87
+ * Holds our Helper_Misc object
88
+ * Makes it easy to access common methods throughout the plugin
89
+ *
90
+ * @var \GFPDF\Helper\Helper_Misc
91
+ *
92
+ * @since 4.0
93
+ */
94
+ protected $misc;
95
+
96
+ /**
97
+ * Setup our class by injecting all our dependancies
98
+ *
99
+ * @param \GFPDF\Helper\Helper_Abstract_Form|\GFPDF\Helper\Helper_Form $gform Our abstracted Gravity Forms helper functions
100
+ * @param \Monolog\Logger|LoggerInterface $log Our logger class
101
+ * @param \GFPDF\Helper\Helper_Abstract_Options|\GFPDF\Helper\Helper_Options_Fields $options Our options class which allows us to access any settings
102
+ *
103
+ * @since 4.0
104
+ */
105
+ public function __construct( Helper_Abstract_Form $gform, LoggerInterface $log, Helper_Abstract_Options $options, Helper_Misc $misc ) {
106
+
107
+ /* Assign our internal variables */
108
+ $this->gform = $gform;
109
+ $this->log = $log;
110
+ $this->options = $options;
111
+ $this->misc = $misc;
112
+ }
113
+
114
+ /**
115
+ * Generates a direct link to the PDF that should be generated
116
+ * If placed in a confirmation the appropriate entry will be displayed.
117
+ * A user also has the option to pass in an "entry" parameter to define the entry ID
118
+ *
119
+ * @param array $attributes The shortcode attributes specified
120
+ *
121
+ * @return string
122
+ *
123
+ * @since 4.0
124
+ */
125
+ public function gravitypdf( $attributes ) {
126
+
127
+ $this->log->addNotice( 'Generating Shortcode' );
128
+
129
+ $controller = $this->getController();
130
+ $has_view_permissions = $this->gform->has_capability( 'gravityforms_view_entries' );
131
+
132
+ /* merge in any missing defaults */
133
+ $attributes = shortcode_atts( array(
134
+ 'id' => '',
135
+ 'text' => 'Download PDF',
136
+ 'type' => 'download',
137
+ 'class' => 'gravitypdf-download-link',
138
+ 'classes' => '',
139
+ 'entry' => '',
140
+ 'print' => '',
141
+ ), $attributes, 'gravitypdf' );
142
+
143
+ /* See https://gravitypdf.com/documentation/v4/gfpdf_gravityforms_shortcode_attributes/ for more information about this filter */
144
+ $attributes = apply_filters( 'gfpdf_gravityforms_shortcode_attributes', $attributes );
145
+
146
+ /* Add Shortcake preview support */
147
+ if ( defined( 'SHORTCODE_UI_DOING_PREVIEW' ) && SHORTCODE_UI_DOING_PREVIEW === true ) {
148
+ $attributes['url'] = '#';
149
+
150
+ return $controller->view->display_gravitypdf_shortcode( $attributes );
151
+ }
152
+
153
+ /* Check if we have an entry ID, otherwise check the GET and POST data */
154
+ if ( empty( $attributes['entry'] ) ) {
155
+ if ( isset( $_GET['lid'] ) || isset( $_GET['entry'] ) ) {
156
+ $attributes['entry'] = ( isset( $_GET['lid'] ) ) ? (int) $_GET['lid'] : (int) $_GET['entry'];
157
+ } else {
158
+
159
+ /* Only display error to users with appropriate permissions */
160
+ if ( $has_view_permissions ) {
161
+ return $controller->view->no_entry_id();
162
+ }
163
+
164
+ return '';
165
+ }
166
+ }
167
+
168
+ /* Check if we have a valid PDF configuration */
169
+ $entry = $this->gform->get_entry( $attributes['entry'] );
170
+ $config = ( ! is_wp_error( $entry ) ) ? $this->options->get_pdf( $entry['form_id'], $attributes['id'] ) : $entry; /* if invalid entry a WP_Error will be thrown */
171
+
172
+ if ( is_wp_error( $config ) ) {
173
+
174
+ /* Only display error to users with appropriate permissions */
175
+ if ( $has_view_permissions ) {
176
+ return $controller->view->invalid_pdf_config();
177
+ }
178
+
179
+ return '';
180
+ }
181
+
182
+ /* Check if the PDF is enabled AND the conditional logic (if any) has been met */
183
+ if ( $config['active'] !== true ) {
184
+ /* Only display error to users with appropriate permissions */
185
+ if ( $has_view_permissions ) {
186
+ return $controller->view->pdf_not_active();
187
+ }
188
+
189
+ return '';
190
+ }
191
+
192
+ if ( isset( $config['conditionalLogic'] ) && ! $this->misc->evaluate_conditional_logic( $config['conditionalLogic'], $entry ) ) {
193
+ /* Only display error to users with appropriate permissions */
194
+ if ( $has_view_permissions ) {
195
+ return $controller->view->conditional_logic_not_met();
196
+ }
197
+
198
+ return '';
199
+ }
200
+
201
+ /* Everything looks valid so let's get the URL */
202
+ $pdf = new Model_PDF( $this->gform, $this->log, $this->options, GPDFAPI::get_data_class(), GPDFAPI::get_misc_class(), GPDFAPI::get_notice_class() );
203
+ $download = ( $attributes['type'] == 'download' ) ? true : false;
204
+ $print = ( ! empty( $attributes['print'] ) ) ? true : false;
205
+ $attributes['url'] = $pdf->get_pdf_url( $attributes['id'], $attributes['entry'], $download, $print );
206
+
207
+ /* generate the markup and return */
208
+ $this->log->addNotice( 'Generating Shortcode Markup', array(
209
+ 'attr' => $attributes,
210
+ ) );
211
+
212
+ return $controller->view->display_gravitypdf_shortcode( $attributes );
213
+ }
214
+
215
+ /**
216
+ * Update our Gravity Forms "Text" Confirmation Shortcode to include the current entry ID
217
+ *
218
+ * @param string $confirmation The confirmation text
219
+ * @param array $form The Gravity Form array
220
+ * @param array $entry The Gravity Form entry information
221
+ *
222
+ * @return array The confirmation text
223
+ *
224
+ * @since 4.0
225
+ */
226
+ public function gravitypdf_confirmation( $confirmation, $form, $entry ) {
227
+
228
+ /* check if confirmation is text-based */
229
+ if ( ! is_array( $confirmation ) ) {
230
+ $confirmation = $this->add_entry_id_to_shortcode( $confirmation, $entry['id'] );
231
+ }
232
+
233
+ return $confirmation;
234
+ }
235
+
236
+ /**
237
+ * Update our Gravity Forms Notification Shortcode to include the current entry ID
238
+ *
239
+ * @param string $notification The confirmation text
240
+ * @param array $form The Gravity Form array
241
+ * @param array $entry The Gravity Form entry information
242
+ *
243
+ * @return array The confirmation text
244
+ *
245
+ * @since 4.0
246
+ */
247
+ public function gravitypdf_notification( $notification, $form, $entry ) {
248
+
249
+ /* check if notification has a 'message' */
250
+ if ( isset( $notification['message'] ) ) {
251
+ $notification['message'] = $this->add_entry_id_to_shortcode( $notification['message'], $entry['id'] );
252
+ }
253
+
254
+ return $notification;
255
+ }
256
+
257
+ /**
258
+ * Add basic GravityView support and parse the Custom Content field for the [gravitypdf] shortcode
259
+ * This means users can copy and paste our sample shortcode without having to worry about an entry ID being passed.
260
+ *
261
+ * @param string $html
262
+ *
263
+ * @return string
264
+ *
265
+ * @since 4.0
266
+ */
267
+ public function gravitypdf_gravityview_custom( $html ) {
268
+ $gravityview_view = GravityView_View::getInstance();
269
+ $entry = $gravityview_view->getCurrentEntry();
270
+ return $this->add_entry_id_to_shortcode( $html, $entry['id'] );
271
+ }
272
+
273
+ /**
274
+ * Check for the [gravitypdf] shortcode and add the entry ID to it
275
+ *
276
+ * @param $string The text to search
277
+ * @param $entry_id The entry ID to add to our shortcode
278
+ *
279
+ * @return string
280
+ *
281
+ * @since 4.0
282
+ */
283
+ private function add_entry_id_to_shortcode( $string, $entry_id ) {
284
+ /* Check if our shortcode exists and add the entry ID if needed */
285
+ $gravitypdf = $this->get_shortcode_information( 'gravitypdf', $string );
286
+
287
+ if ( sizeof( $gravitypdf ) > 0 ) {
288
+ foreach ( $gravitypdf as $shortcode ) {
289
+ /* if the user hasn't explicitely defined an entry to display... */
290
+ if ( ! isset( $shortcode['attr']['entry'] ) ) {
291
+ /* get the new shortcode information */
292
+ $new_shortcode = $this->add_shortcode_attr( $shortcode, 'entry', $entry_id );
293
+
294
+ /* update our confirmation message */
295
+ $string = str_replace( $shortcode['shortcode'], $new_shortcode['shortcode'], $string );
296
+ }
297
+ }
298
+ }
299
+
300
+ return $string;
301
+ }
302
+
303
+ /**
304
+ * Update a shortcode attributes
305
+ *
306
+ * @param array $code In individual shortcode array pulled in from the $this->get_shortcode_information() function
307
+ * @param string $attr The attribute to add / replace
308
+ * @param string $value The new attribute value
309
+ *
310
+ * @return array
311
+ *
312
+ * @since 4.0
313
+ */
314
+ public function add_shortcode_attr( $code, $attr, $value ) {
315
+ /* if the attribute doesn't already exist... */
316
+ if ( ! isset( $code['attr'][ $attr ] ) ) {
317
+
318
+ $raw_attr = "{$code['attr_raw']} {$attr}=\"{$value}\"";
319
+
320
+ /* if there are no attributes at all we'll need to fix our str replace */
321
+ if ( 0 === strlen( $code['attr_raw'] ) ) {
322
+ $pattern = '^\[([a-zA-Z]+)';
323
+ $code['shortcode'] = preg_replace( "/$pattern/s", "[$1 {$attr}=\"{$value}\"", $code['shortcode'] );
324
+ } else {
325
+ $code['shortcode'] = str_ireplace( $code['attr_raw'], $raw_attr, $code['shortcode'] );
326
+ }
327
+
328
+ $code['attr_raw'] = $raw_attr;
329
+
330
+ } else { /* replace the current attribute */
331
+ $pattern = $attr . '="(.+?)"';
332
+ $code['shortcode'] = preg_replace( "/$pattern/si", $attr . '="' . $value . '"', $code['shortcode'] );
333
+ $code['attr_raw'] = preg_replace( "/$pattern/si", $attr . '="' . $value . '"', $code['attr_raw'] );
334
+ }
335
+
336
+ /* Update the actual attribute */
337
+ $code['attr'][ $attr ] = $value;
338
+
339
+ return $code;
340
+ }
341
+
342
+ /**
343
+ * Check if user is currently submitting a new confirmation redirect URL in the admin area,
344
+ * if so replace any shortcodes with a direct link to the PDF (as Gravity Forms correctly validates the URL)
345
+ *
346
+ * @param array $form Gravity Form Array
347
+ *
348
+ * @return array
349
+ *
350
+ * @since 4.0
351
+ */
352
+ public function gravitypdf_redirect_confirmation( $form ) {
353
+
354
+ /* check if the confirmation is currently being saved */
355
+ if ( isset( $_POST['form_confirmation_url'] ) ) {
356
+
357
+ $this->log->addNotice( 'Process Redirect Confirmation Save', array(
358
+ 'form_id' => $form['id'],
359
+ 'post' => $_POST,
360
+ ) );
361
+
362
+ $url = stripslashes_deep( $_POST['form_confirmation_url'] );
363
+
364
+ /* check if our shortcode exists and convert it to a URL */
365
+ $gravitypdf = $this->get_shortcode_information( 'gravitypdf', $url );
366
+
367
+ if ( sizeof( $gravitypdf ) > 0 ) {
368
+
369
+ foreach ( $gravitypdf as $code ) {
370
+
371
+ /* get the PDF Settings ID */
372
+ $pid = ( isset( $code['attr']['id'] ) ) ? $code['attr']['id'] : '';
373
+
374
+ if ( ! empty( $pid ) ) {
375
+
376
+ /* generate the PDF URL */
377
+ $pdf = new Model_PDF( $this->gform, $this->log, $this->options, GPDFAPI::get_data_class(), GPDFAPI::get_misc_class(), GPDFAPI::get_notice_class() );
378
+ $download = ( ! isset( $code['attr']['type'] ) || $code['attr']['type'] == 'download' ) ? true : false;
379
+ $pdf_url = $pdf->get_pdf_url( $pid, '{entry_id}', $download, false, false );
380
+
381
+ /* override the confirmation URL submitted */
382
+ $_POST['form_confirmation_url'] = str_replace( $code['shortcode'], $pdf_url, $url );
383
+ }
384
+ }
385
+ }
386
+ }
387
+
388
+ /* it's a filter so return the $form array */
389
+
390
+ return $form;
391
+ }
392
+
393
+ /**
394
+ * Search for any shortcodes in the text and return any matches
395
+ *
396
+ * @param string $shortcode The shortcode to search for
397
+ * @param string $text The text to search in
398
+ *
399
+ * @return array The shortcode information
400
+ *
401
+ * @since 4.0
402
+ */
403
+ public function get_shortcode_information( $shortcode, $text ) {
404
+ $shortcodes = array();
405
+
406
+ if ( has_shortcode( $text, $shortcode ) ) {
407
+
408
+ /* our shortcode exists so parse the shortcode data and return an easy-to-use array */
409
+ $pattern = get_shortcode_regex();
410
+ preg_match_all( "/$pattern/s", $text, $matches );
411
+
412
+ if ( ! empty( $matches ) && isset( $matches[2] ) ) {
413
+ foreach ( $matches[2] as $key => $code ) {
414
+ if ( $code == $shortcode ) {
415
+ $shortcodes[] = array(
416
+ 'shortcode' => $matches[0][ $key ],
417
+ 'attr_raw' => $matches[3][ $key ],
418
+ 'attr' => shortcode_parse_atts( $matches[3][ $key ] ),
419
+ );
420
+ }
421
+ }
422
+ }
423
+ }
424
+
425
+ return $shortcodes;
426
+ }
427
+ }
src/view/html/Actions/review_plugin.php CHANGED
@@ -1,50 +1,50 @@
1
- <?php
2
-
3
- /**
4
- * The Review Plugin Notice
5
- *
6
- * @package Gravity PDF
7
- * @copyright Copyright (c) 2016, Blue Liquid Designs
8
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since 4.0
10
- */
11
-
12
- /* Exit if accessed directly */
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- /*
18
- This file is part of Gravity PDF.
19
-
20
- Gravity PDF – Copyright (C) 2016, Blue Liquid Designs
21
-
22
- This program is free software; you can redistribute it and/or modify
23
- it under the terms of the GNU General Public License as published by
24
- the Free Software Foundation; either version 2 of the License, or
25
- (at your option) any later version.
26
-
27
- This program is distributed in the hope that it will be useful,
28
- but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
- GNU General Public License for more details.
31
-
32
- You should have received a copy of the GNU General Public License
33
- along with this program; if not, write to the Free Software
34
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
- */
36
-
37
- ?>
38
-
39
- <div style="font-size:15px; line-height: 25px">
40
-
41
- <strong><?php _e( "Hey, we just noticed you've generated your 100th PDF using Gravity PDF!", 'gravity-forms-pdf-extended' ); ?></strong>
42
-
43
- <br>
44
-
45
- <?php printf( __( "If you love how much time you've saved using Gravity PDF then do us a big favour and %sgive it a five-star rating on WordPress.org%s.", 'gravity-forms-pdf-extended' ), '<a href="https://wordpress.org/support/view/plugin-reviews/gravity-forms-pdf-extended">', '</a>' ); ?>
46
-
47
- <br>
48
-
49
- <?php printf( __( '%sOr let your Twitter follows know how good it is%s (or anyone else for that matter).', 'gravity-forms-pdf-extended' ), '<a href="https://goo.gl/07NhJQ">', '</a>' ); ?>
50
- </div>
1
+ <?php
2
+
3
+ /**
4
+ * The Review Plugin Notice
5
+ *
6
+ * @package Gravity PDF
7
+ * @copyright Copyright (c) 2016, Blue Liquid Designs
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 4.0
10
+ */
11
+
12
+ /* Exit if accessed directly */
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /*
18
+ This file is part of Gravity PDF.
19
+
20
+ Gravity PDF – Copyright (C) 2016, Blue Liquid Designs
21
+
22
+ This program is free software; you can redistribute it and/or modify
23
+ it under the terms of the GNU General Public License as published by
24
+ the Free Software Foundation; either version 2 of the License, or
25
+ (at your option) any later version.
26
+
27
+ This program is distributed in the hope that it will be useful,
28
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+ GNU General Public License for more details.
31
+
32
+ You should have received a copy of the GNU General Public License
33
+ along with this program; if not, write to the Free Software
34
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
+ */
36
+
37
+ ?>
38
+
39
+ <div style="font-size:15px; line-height: 25px">
40
+
41
+ <strong><?php _e( "Hey, we just noticed you've generated your 100th PDF using Gravity PDF!", 'gravity-forms-pdf-extended' ); ?></strong>
42
+
43
+ <br>
44
+
45
+ <?php printf( __( "If you love how much time you've saved using Gravity PDF then do us a big favour and %sgive it a five-star rating on WordPress.org%s.", 'gravity-forms-pdf-extended' ), '<a href="https://wordpress.org/support/view/plugin-reviews/gravity-forms-pdf-extended">', '</a>' ); ?>
46
+
47
+ <br>
48
+
49
+ <?php printf( __( '%sOr let your Twitter follows know how good it is%s (or anyone else for that matter).', 'gravity-forms-pdf-extended' ), '<a href="https://goo.gl/07NhJQ">', '</a>' ); ?>
50
+ </div>
src/view/html/Settings/help.php CHANGED
@@ -119,16 +119,16 @@ if ( ! defined( 'ABSPATH' ) ) {
119
  </div><!-- close #pdfextended-settings -->
120
 
121
  <script type="text/template" id="GravityPDFSearchResultsDocumentation">
122
- <% if(collection.length === 0) { %>
123
  <li><?php _e( "It doesn't look like there are any topics related to your issue.", 'gravity-forms-pdf-extended' ); ?></li>
124
- <% } else { %>
125
  <li><h3><?php _e( 'Maybe one of these articles will help...', 'gravity-forms-pdf-extended' ); ?></h3></li>
126
- <% } %>
127
 
128
- <% _.each(collection, function (model) { %>
129
  <li>
130
- <a href="<%= model.link %>"><%= model.title.rendered %></a>
131
- <div class="except"><%= model.excerpt.rendered %></div>
132
  </li>
133
- <% }); %>
134
  </script>
119
  </div><!-- close #pdfextended-settings -->
120
 
121
  <script type="text/template" id="GravityPDFSearchResultsDocumentation">
122
+ {{ if(collection.length === 0) { }}
123
  <li><?php _e( "It doesn't look like there are any topics related to your issue.", 'gravity-forms-pdf-extended' ); ?></li>
124
+ {{ } else { }}
125
  <li><h3><?php _e( 'Maybe one of these articles will help...', 'gravity-forms-pdf-extended' ); ?></h3></li>
126
+ {{ } }}
127
 
128
+ {{ _.each(collection, function (model) { }}
129
  <li>
130
+ <a href="{{= model.link }}">{{= model.title.rendered }}</a>
131
+ <div class="except">{{= model.excerpt.rendered }}</div>
132
  </li>
133
+ {{ }); }}
134
  </script>
src/view/html/Settings/tools.php CHANGED
@@ -106,7 +106,7 @@ if ( ! defined( 'ABSPATH' ) ) {
106
  </script>
107
 
108
  <script type="text/template" id="GravityPDFFonts">
109
- <a href="#" class="font-name"><i class="fa fa-angle-right"></i><span name="font_name"><%- model.get('font_name') %></span></a>
110
  <div class="font-settings" style="display: none">
111
 
112
  <form method="post">
@@ -114,13 +114,13 @@ if ( ! defined( 'ABSPATH' ) ) {
114
 
115
  <div class="font-selector">
116
  <label><?php _e( 'Font Name', 'gravity-forms-pdf-extended' ); ?> <span class="gfield_required">*</span></label>
117
- <input type="text" required="required" value="<%- model.get('font_name') %>" name="font_name" class="regular-text font-name-field">
118
  <span class="gf_settings_description"><label><?php _e( 'Only alphanumeric characters and spaces are accepted.', 'gravity-forms-pdf-extended' ); ?></label></span>
119
  </div>
120
 
121
  <div class="font-selector">
122
  <label><?php _e( 'Regular', 'gravity-forms-pdf-extended' ); ?> <span class="gfield_required">*</span></label>
123
- <input type="text" value="<%- model.get('regular') %>" required="required" name="regular" class="regular-text">
124
  <span>
125
  <input type="button"
126
  data-uploader-button-text="<?php _e( 'Select Font', 'gravity-forms-pdf-extended' ); ?>"
@@ -132,7 +132,7 @@ if ( ! defined( 'ABSPATH' ) ) {
132
 
133
  <div class="font-selector">
134
  <label><?php _e( 'Italics', 'gravity-forms-pdf-extended' ); ?></label>
135
- <input type="text" value="<%- model.get('italics') %>" name="italics" class="regular-text">
136
  <span>
137
  <input type="button"
138
  data-uploader-button-text="<?php _e( 'Select Font', 'gravity-forms-pdf-extended' ); ?>"
@@ -144,7 +144,7 @@ if ( ! defined( 'ABSPATH' ) ) {
144
 
145
  <div class="font-selector">
146
  <label><?php _e( 'Bold', 'gravity-forms-pdf-extended' ); ?></label>
147
- <input type="text" value="<%- model.get('bold') %>" name="bold" class="regular-text">
148
  <span>
149
  <input type="button"
150
  data-uploader-button-text="<?php _e( 'Select Font', 'gravity-forms-pdf-extended' ); ?>"
@@ -156,7 +156,7 @@ if ( ! defined( 'ABSPATH' ) ) {
156
 
157
  <div class="font-selector">
158
  <label><?php _e( 'Bold Italics', 'gravity-forms-pdf-extended' ); ?></label>
159
- <input type="text" value="<%- model.get('bolditalics') %>" name="bolditalics" class="regular-text">
160
  <span>
161
  <input type="button"
162
  data-uploader-button-text="<?php _e( 'Select Font', 'gravity-forms-pdf-extended' ); ?>"
106
  </script>
107
 
108
  <script type="text/template" id="GravityPDFFonts">
109
+ <a href="#" class="font-name"><i class="fa fa-angle-right"></i><span name="font_name">{{- model.get('font_name') }}</span></a>
110
  <div class="font-settings" style="display: none">
111
 
112
  <form method="post">
114
 
115
  <div class="font-selector">
116
  <label><?php _e( 'Font Name', 'gravity-forms-pdf-extended' ); ?> <span class="gfield_required">*</span></label>
117
+ <input type="text" required="required" value="{{- model.get('font_name') }}" name="font_name" class="regular-text font-name-field">
118
  <span class="gf_settings_description"><label><?php _e( 'Only alphanumeric characters and spaces are accepted.', 'gravity-forms-pdf-extended' ); ?></label></span>
119
  </div>
120
 
121
  <div class="font-selector">
122
  <label><?php _e( 'Regular', 'gravity-forms-pdf-extended' ); ?> <span class="gfield_required">*</span></label>
123
+ <input type="text" value="{{- model.get('regular') }}" required="required" name="regular" class="regular-text">
124
  <span>
125
  <input type="button"
126
  data-uploader-button-text="<?php _e( 'Select Font', 'gravity-forms-pdf-extended' ); ?>"
132
 
133
  <div class="font-selector">
134
  <label><?php _e( 'Italics', 'gravity-forms-pdf-extended' ); ?></label>
135
+ <input type="text" value="{{- model.get('italics') }}" name="italics" class="regular-text">
136
  <span>
137
  <input type="button"
138
  data-uploader-button-text="<?php _e( 'Select Font', 'gravity-forms-pdf-extended' ); ?>"
144
 
145
  <div class="font-selector">
146
  <label><?php _e( 'Bold', 'gravity-forms-pdf-extended' ); ?></label>
147
+ <input type="text" value="{{- model.get('bold') }}" name="bold" class="regular-text">
148
  <span>
149
  <input type="button"
150
  data-uploader-button-text="<?php _e( 'Select Font', 'gravity-forms-pdf-extended' ); ?>"
156
 
157
  <div class="font-selector">
158
  <label><?php _e( 'Bold Italics', 'gravity-forms-pdf-extended' ); ?></label>
159
+ <input type="text" value="{{- model.get('bolditalics') }}" name="bolditalics" class="regular-text">
160
  <span>
161
  <input type="button"
162
  data-uploader-button-text="<?php _e( 'Select Font', 'gravity-forms-pdf-extended' ); ?>"
src/view/html/Welcome/welcome.php CHANGED
@@ -1,130 +1,130 @@
1
- <?php
2
-
3
- /**
4
- * Getting Started - Welcome Screen View
5
- *
6
- * @package Gravity PDF
7
- * @copyright Copyright (c) 2016, Blue Liquid Designs
8
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since 4.0
10
- */
11
-
12
- /* Exit if accessed directly */
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- /*
18
- This file is part of Gravity PDF.
19
-
20
- Gravity PDF – Copyright (C) 2016, Blue Liquid Designs
21
-
22
- This program is free software; you can redistribute it and/or modify
23
- it under the terms of the GNU General Public License as published by
24
- the Free Software Foundation; either version 2 of the License, or
25
- (at your option) any later version.
26
-
27
- This program is distributed in the hope that it will be useful,
28
- but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
- GNU General Public License for more details.
31
-
32
- You should have received a copy of the GNU General Public License
33
- along with this program; if not, write to the Free Software
34
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
- */
36
-
37
- ?>
38
-
39
- <div class="wrap about-wrap gfpdf-welcome-screen">
40
- <h1><?php _e( 'Welcome to Gravity PDF', 'gravity-forms-pdf-extended' ); ?></h1>
41
-
42
- <div class="about-text">
43
- <?php _e( "You're just minutes away from producing your first highly-customisable PDF document using Gravity Forms data.", 'gravity-forms-pdf-extended' ); ?>
44
- </div>
45
-
46
- <div class="gfpdf-badge"><?php printf( __( 'Version %s', 'gravity-forms-pdf-extended' ), $args['display_version'] ); ?></div>
47
-
48
- <?php $this->tabs(); ?>
49
-
50
- <div class="feature-section two-col">
51
-
52
- <div class="col">
53
- <h3><?php _e( 'Where to Start?', 'gravity-forms-pdf-extended' ); ?></h3>
54
-
55
- <p>
56
- <?php printf( __( "Your first step is to review %sGravity PDF's General Settings%s which can be found by navigating to %sForms -> Settings -> PDF%s in your WordPress admin area. From here you'll be able to set defaults for paper size, font face, font colour, and select a PDF template – %swe ship with four completely-free layouts%s – which will be used for all new PDFs. There's even an easy-to-use interface for installing custom fonts.", 'gravity-forms-pdf-extended' ), '<a href="' . esc_url( $gfpdf->data->settings_url ) . '">', '</a>', '<code>', '</code>', '<strong>', '</strong>' ); ?>
57
- </p>
58
-
59
- <a href="<?php echo esc_url( $gfpdf->data->settings_url ); ?>" class="button"><?php _e( 'Configure Settings', 'gravity-forms-pdf-extended' ); ?></a>
60
- </div>
61
-
62
- <div class="col">
63
- <img class="gfpdf-image" src="<?php echo esc_url( PDF_PLUGIN_URL . 'src/assets/images/welcome-pdf-settings-page.png' ); ?>">
64
- </div>
65
-
66
- </div>
67
-
68
- <div class="feature-section two-col">
69
-
70
- <div class="col">
71
- <img class="gfpdf-image" src="<?php echo esc_url( PDF_PLUGIN_URL . 'src/assets/images/welcome-individual-pdf-settings.png' ); ?>">
72
- </div>
73
-
74
- <div class="col">
75
- <h3><?php _e( 'Setting up a PDF', 'gravity-forms-pdf-extended' ); ?></h3>
76
-
77
- <p>
78
- <?php printf( __( 'You can setup individual PDF documents from the %sGravity Form "Forms" page%s in your admin area – located at %sForms -> Forms%s in your navigation. A new %sPDF%s option will be avaliable in each forms\' settings section. The only required fields are %sName%s – an internal identifier – and %sFilename%s – the name used when saving and emailing the PDF.', 'gravity-forms-pdf-extended' ), '<a href="' . esc_url( admin_url( 'admin.php?page=gf_edit_forms' ) ) . '">', '</a>', '<code>', '</code>', '<code>', '</code>', '<em>', '</em>', '<em>', '</em>' ); ?>
79
- </p>
80
-
81
- <!-- Output a quick Gravity Forms selector so we can let users get redirected to a PDF form of their choice -->
82
- <?php if ( sizeof( $args['forms'] ) > 0 ): ?>
83
- <form action="<?php echo admin_url( 'admin.php' ); ?>">
84
- <input type="hidden" name="page" value="gf_edit_forms"/>
85
- <input type="hidden" name="view" value="settings"/>
86
- <input type="hidden" name="subview" value="pdf"/>
87
- <input type="hidden" name="pid" value="0"/>
88
-
89
- <p>
90
- <strong><?php _e( 'Select which Form you want to setup first:', 'gravity-forms-pdf-extended' ); ?></strong><br>
91
- <select name="id" class="">
92
- <?php foreach ( $args['forms'] as $form ): ?>
93
- <option value="<?php echo $form['id']; ?>"><?php echo $form['title']; ?></option>
94
- <?php endforeach; ?>
95
- </select>
96
-
97
- <button class="button" style="vertical-align: middle"><?php _e( 'Create a PDF', 'gravity-forms-pdf-extended' ); ?></button>
98
- </p>
99
- </form>
100
- <?php endif; ?>
101
- </div>
102
- </div>
103
-
104
- <div id="gfpdf-mascot-container" class="changelog feature-section three-col">
105
- <div class="col">
106
- <img class="gfpdf-image" src="<?php echo esc_url( PDF_PLUGIN_URL . 'src/assets/images/welcome-download-shortcode.png' ); ?>">
107
-
108
- <h3><?php _e( 'Simple PDF Download Links', 'gravity-forms-pdf-extended' ); ?></h3>
109
-
110
- <p><?php printf( __( 'The %s[gravitypdf]%s shortcode allows you to %seasily place a PDF download link%s on any of the Gravity Forms Confirmation types.', 'gravity-forms-pdf-extended' ), '<code>', '</code>', '<a href="https://gravitypdf.com/documentation/v4/user-shortcodes/">', '</a>' ); ?></p>
111
- </div>
112
- <div class="col">
113
- <img class="gfpdf-image" src="<?php echo esc_url( PDF_PLUGIN_URL . 'src/assets/images/welcome-notification-conditional.png' ); ?>">
114
-
115
- <h3><?php _e( 'Automated PDF Emails', 'gravity-forms-pdf-extended' ); ?></h3>
116
-
117
- <p><?php _e( 'Select a Gravity Form Notification and your PDF will automatically be sent as an attachment. Powerful conditional logic can also be used to determine if a PDF will be included.', 'gravity-forms-pdf-extended' ); ?></p>
118
- </div>
119
- <div class="col last-feature">
120
- <img class="gfpdf-image" src="<?php echo esc_url( PDF_PLUGIN_URL . 'src/assets/images/welcome-manage-fonts.png' ); ?>">
121
-
122
- <h3><?php _e( 'Custom Fonts', 'gravity-forms-pdf-extended' ); ?></h3>
123
-
124
- <p><?php printf( __( 'Make your documents stand out by including your favourite fonts with our %ssimple font manager%s.', 'gravity-forms-pdf-extended' ), '<a href="https://gravitypdf.com/documentation/v4/user-custom-fonts/">', '</a>' ); ?></p>
125
- </div>
126
- </div>
127
-
128
- <?php $this->more(); ?>
129
-
130
- </div>
1
+ <?php
2
+
3
+ /**
4
+ * Getting Started - Welcome Screen View
5
+ *
6
+ * @package Gravity PDF
7
+ * @copyright Copyright (c) 2016, Blue Liquid Designs
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 4.0
10
+ */
11
+
12
+ /* Exit if accessed directly */
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /*
18
+ This file is part of Gravity PDF.
19
+
20
+ Gravity PDF – Copyright (C) 2016, Blue Liquid Designs
21
+
22
+ This program is free software; you can redistribute it and/or modify
23
+ it under the terms of the GNU General Public License as published by
24
+ the Free Software Foundation; either version 2 of the License, or
25
+ (at your option) any later version.
26
+
27
+ This program is distributed in the hope that it will be useful,
28
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+ GNU General Public License for more details.
31
+
32
+ You should have received a copy of the GNU General Public License
33
+ along with this program; if not, write to the Free Software
34
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
+ */
36
+
37
+ ?>
38
+
39
+ <div class="wrap about-wrap gfpdf-welcome-screen">
40
+ <h1><?php _e( 'Welcome to Gravity PDF', 'gravity-forms-pdf-extended' ); ?></h1>
41
+
42
+ <div class="about-text">
43
+ <?php _e( "You're just minutes away from producing your first highly-customisable PDF document using Gravity Forms data.", 'gravity-forms-pdf-extended' ); ?>
44
+ </div>
45
+
46
+ <div class="gfpdf-badge"><?php printf( __( 'Version %s', 'gravity-forms-pdf-extended' ), $args['display_version'] ); ?></div>
47
+
48
+ <?php $this->tabs(); ?>
49
+
50
+ <div class="feature-section two-col">
51
+
52
+ <div class="col">
53
+ <h3><?php _e( 'Where to Start?', 'gravity-forms-pdf-extended' ); ?></h3>
54
+
55
+ <p>
56
+ <?php printf( __( "Your first step is to review %sGravity PDF's General Settings%s which can be found by navigating to %sForms -> Settings -> PDF%s in your WordPress admin area. From here you'll be able to set defaults for paper size, font face, font colour, and select a PDF template – %swe ship with four completely-free layouts%s – which will be used for all new PDFs. There's even an easy-to-use interface for installing custom fonts.", 'gravity-forms-pdf-extended' ), '<a href="' . esc_url( $gfpdf->data->settings_url ) . '">', '</a>', '<code>', '</code>', '<strong>', '</strong>' ); ?>
57
+ </p>
58
+
59
+ <a href="<?php echo esc_url( $gfpdf->data->settings_url ); ?>" class="button"><?php _e( 'Configure Settings', 'gravity-forms-pdf-extended' ); ?></a>
60
+ </div>
61
+
62
+ <div class="col">
63
+ <img class="gfpdf-image" src="<?php echo esc_url( PDF_PLUGIN_URL . 'src/assets/images/welcome-pdf-settings-page.png' ); ?>">
64
+ </div>
65
+
66
+ </div>
67
+
68
+ <div class="feature-section two-col">
69
+
70
+ <div class="col">
71
+ <img class="gfpdf-image" src="<?php echo esc_url( PDF_PLUGIN_URL . 'src/assets/images/welcome-individual-pdf-settings.png' ); ?>">
72
+ </div>
73
+
74
+ <div class="col">
75
+ <h3><?php _e( 'Setting up a PDF', 'gravity-forms-pdf-extended' ); ?></h3>
76
+
77
+ <p>
78
+ <?php printf( __( 'You can setup individual PDF documents from the %sGravity Form "Forms" page%s in your admin area – located at %sForms -> Forms%s in your navigation. A new %sPDF%s option will be avaliable in each forms\' settings section. The only required fields are %sName%s – an internal identifier – and %sFilename%s – the name used when saving and emailing the PDF.', 'gravity-forms-pdf-extended' ), '<a href="' . esc_url( admin_url( 'admin.php?page=gf_edit_forms' ) ) . '">', '</a>', '<code>', '</code>', '<code>', '</code>', '<em>', '</em>', '<em>', '</em>' ); ?>
79
+ </p>
80
+
81
+ <!-- Output a quick Gravity Forms selector so we can let users get redirected to a PDF form of their choice -->
82
+ <?php if ( sizeof( $args['forms'] ) > 0 ): ?>
83
+ <form action="<?php echo admin_url( 'admin.php' ); ?>">
84
+ <input type="hidden" name="page" value="gf_edit_forms"/>
85
+ <input type="hidden" name="view" value="settings"/>
86
+ <input type="hidden" name="subview" value="pdf"/>
87
+ <input type="hidden" name="pid" value="0"/>
88
+
89
+ <p>
90
+ <strong><?php _e( 'Select which Form you want to setup first:', 'gravity-forms-pdf-extended' ); ?></strong><br>
91
+ <select name="id" class="">
92
+ <?php foreach ( $args['forms'] as $form ): ?>
93
+ <option value="<?php echo $form['id']; ?>"><?php echo $form['title']; ?></option>
94
+ <?php endforeach; ?>
95
+ </select>
96
+
97
+ <button class="button" style="vertical-align: middle"><?php _e( 'Create a PDF', 'gravity-forms-pdf-extended' ); ?></button>
98
+ </p>
99
+ </form>
100
+ <?php endif; ?>
101
+ </div>
102
+ </div>
103
+
104
+ <div id="gfpdf-mascot-container" class="changelog feature-section three-col">
105
+ <div class="col">
106
+ <img class="gfpdf-image" src="<?php echo esc_url( PDF_PLUGIN_URL . 'src/assets/images/welcome-download-shortcode.png' ); ?>">
107
+
108
+ <h3><?php _e( 'Simple PDF Download Links', 'gravity-forms-pdf-extended' ); ?></h3>
109
+
110
+ <p><?php printf( __( 'The %s[gravitypdf]%s shortcode allows you to %seasily place a PDF download link%s on any of the Gravity Forms Confirmation types.', 'gravity-forms-pdf-extended' ), '<code>', '</code>', '<a href="https://gravitypdf.com/documentation/v4/user-shortcodes/">', '</a>' ); ?></p>
111
+ </div>
112
+ <div class="col">
113
+ <img class="gfpdf-image" src="<?php echo esc_url( PDF_PLUGIN_URL . 'src/assets/images/welcome-notification-conditional.png' ); ?>">
114
+
115
+ <h3><?php _e( 'Automated PDF Emails', 'gravity-forms-pdf-extended' ); ?></h3>
116
+
117
+ <p><?php _e( 'Select a Gravity Form Notification and your PDF will automatically be sent as an attachment. Powerful conditional logic can also be used to determine if a PDF will be included.', 'gravity-forms-pdf-extended' ); ?></p>
118
+ </div>
119
+ <div class="col last-feature">
120
+ <img class="gfpdf-image" src="<?php echo esc_url( PDF_PLUGIN_URL . 'src/assets/images/welcome-manage-fonts.png' ); ?>">
121
+
122
+ <h3><?php _e( 'Custom Fonts', 'gravity-forms-pdf-extended' ); ?></h3>
123
+
124
+ <p><?php printf( __( 'Make your documents stand out by including your favourite fonts with our %ssimple font manager%s.', 'gravity-forms-pdf-extended' ), '<a href="https://gravitypdf.com/documentation/v4/user-custom-fonts/">', '</a>' ); ?></p>
125
+ </div>
126
+ </div>
127
+
128
+ <?php $this->more(); ?>
129
+
130
+ </div>
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit6cca3b7a84e1de2b67868798ca7adc78::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInite4785973367908d7b3a3cd3f19f387ae::getLoader();
vendor/blueliquiddesigns/mpdf/config.php CHANGED
@@ -230,7 +230,7 @@ $this->img_dpi = 96; // Default dpi to output images if size not defined
230
 
231
  // TEXT SPACING & JUSTIFICATION
232
 
233
- $this->useKerning = true; // Specify whether kerning should be used when CSS font-kerning="auto" used for HTML;
234
  // Also whether kerning should be used in any direct writing e.g. $mpdf->Text();
235
  $this->justifyB4br = true; // In justified text, <BR> does not cause the preceding text to be justified in browsers
236
  // Change to true to force justification (as in MS Word)
230
 
231
  // TEXT SPACING & JUSTIFICATION
232
 
233
+ $this->useKerning = false; // Specify whether kerning should be used when CSS font-kerning="auto" used for HTML;
234
  // Also whether kerning should be used in any direct writing e.g. $mpdf->Text();
235
  $this->justifyB4br = true; // In justified text, <BR> does not cause the preceding text to be justified in browsers
236
  // Change to true to force justification (as in MS Word)
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit6cca3b7a84e1de2b67868798ca7adc78
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit6cca3b7a84e1de2b67868798ca7adc78
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit6cca3b7a84e1de2b67868798ca7adc78', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit6cca3b7a84e1de2b67868798ca7adc78', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -42,14 +42,14 @@ class ComposerAutoloaderInit6cca3b7a84e1de2b67868798ca7adc78
42
 
43
  $includeFiles = require __DIR__ . '/autoload_files.php';
44
  foreach ($includeFiles as $fileIdentifier => $file) {
45
- composerRequire6cca3b7a84e1de2b67868798ca7adc78($fileIdentifier, $file);
46
  }
47
 
48
  return $loader;
49
  }
50
  }
51
 
52
- function composerRequire6cca3b7a84e1de2b67868798ca7adc78($fileIdentifier, $file)
53
  {
54
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
55
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInite4785973367908d7b3a3cd3f19f387ae
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInite4785973367908d7b3a3cd3f19f387ae', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInite4785973367908d7b3a3cd3f19f387ae', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
42
 
43
  $includeFiles = require __DIR__ . '/autoload_files.php';
44
  foreach ($includeFiles as $fileIdentifier => $file) {
45
+ composerRequiree4785973367908d7b3a3cd3f19f387ae($fileIdentifier, $file);
46
  }
47
 
48
  return $loader;
49
  }
50
  }
51
 
52
+ function composerRequiree4785973367908d7b3a3cd3f19f387ae($fileIdentifier, $file)
53
  {
54
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
55
  require $file;
vendor/composer/installed.json CHANGED
@@ -57,12 +57,12 @@
57
  "source": {
58
  "type": "git",
59
  "url": "https://github.com/GravityPDF/mpdf.git",
60
- "reference": "15d57a4c1230b9a2aac5a914b87a8edbbb167041"
61
  },
62
  "dist": {
63
  "type": "zip",
64
- "url": "https://api.github.com/repos/GravityPDF/mpdf/zipball/15d57a4c1230b9a2aac5a914b87a8edbbb167041",
65
- "reference": "15d57a4c1230b9a2aac5a914b87a8edbbb167041",
66
  "shasum": ""
67
  },
68
  "require": {
@@ -76,7 +76,7 @@
76
  "suggest": {
77
  "ext-zlib": "Needed for compression of embedded resources, such as fonts"
78
  },
79
- "time": "2016-05-03 23:37:22",
80
  "type": "library",
81
  "installation-source": "dist",
82
  "autoload": {
57
  "source": {
58
  "type": "git",
59
  "url": "https://github.com/GravityPDF/mpdf.git",
60
+ "reference": "8aa7ca7ec91acb5c5424e1a35205f167e5696e6c"
61
  },
62
  "dist": {
63
  "type": "zip",
64
+ "url": "https://api.github.com/repos/GravityPDF/mpdf/zipball/8aa7ca7ec91acb5c5424e1a35205f167e5696e6c",
65
+ "reference": "8aa7ca7ec91acb5c5424e1a35205f167e5696e6c",
66
  "shasum": ""
67
  },
68
  "require": {
76
  "suggest": {
77
  "ext-zlib": "Needed for compression of embedded resources, such as fonts"
78
  },
79
+ "time": "2016-06-28 04:36:02",
80
  "type": "library",
81
  "installation-source": "dist",
82
  "autoload": {