GFPDFHelperHelper_Data

The Gravity PDF GFPDF Helper Data class.

Defined (1)

The class is defined in the following location(s).

/src/helper/Helper_Data.php  
  1. class Helper_Data { 
  2.  
  3. /** 
  4. * Location for the overloaded data 
  5. * @var array 
  6. * @since 4.0 
  7. */ 
  8. private $data = []; 
  9.  
  10. /** 
  11. * PHP Magic Method __set() 
  12. * Run when writing data to inaccessible properties 
  13. * @param string $name Name of the peroperty being interacted with 
  14. * @param mixed $value Data to assign to the $name property 
  15. * @since 4.0 
  16. */ 
  17. public function __set( $name, $value ) { 
  18. $this->data[ $name ] = $value; 
  19.  
  20. /** 
  21. * PHP Magic Method __get() 
  22. * Run when reading data from inaccessible properties 
  23. * @param string $name Name of the property being interacted with 
  24. * @return mixed The data assigned to the $name property is returned 
  25. * @since 4.0 
  26. */ 
  27. public function &__get( $name ) { 
  28. /** Check if we actually have a key matching what was requested */ 
  29. if ( array_key_exists( $name, $this->data ) ) { 
  30. /** key exists, so return */ 
  31. return $this->data[ $name ]; 
  32.  
  33. /** Not found so generate error */ 
  34. $trace = debug_backtrace(); 
  35. trigger_error( 
  36. 'Undefined property via __get(): ' . $name . 
  37. ' in ' . $trace[0]['file'] . 
  38. ' on line ' . $trace[0]['line'],  
  39. E_USER_NOTICE ); 
  40.  
  41. /** because we are returning by reference we need return something that can be referenced */ 
  42. $value = null; 
  43.  
  44. return $value; 
  45.  
  46. /** 
  47. * PHP Magic Method __isset() 
  48. * Triggered when isset() or empty() is called on inaccessible properties 
  49. * @param string $name Name of the property being interacted with 
  50. * @return boolean Whether property exists 
  51. * @since 4.0 
  52. */ 
  53. public function __isset( $name ) { 
  54. return isset( $this->data[ $name ] ); 
  55.  
  56. /** 
  57. * PHP Magic Method __isset() 
  58. * Triggered when unset() is called on inaccessible properties 
  59. * @param string $name Name of the property being interacted with 
  60. * @return void 
  61. * @since 4.0 
  62. */ 
  63. public function __unset( $name ) { 
  64. unset( $this->data[ $name ] ); 
  65.  
  66. /** 
  67. * Set up addon array for use tracking active addons 
  68. * @since 3.8 
  69. */ 
  70. public function set_addon_details() { 
  71. $this->addon = []; 
  72.  
  73. /** 
  74. * Set up any default data that should be stored 
  75. * @return void 
  76. * @since 3.8 
  77. */ 
  78. public function init() { 
  79. $this->set_plugin_titles(); 
  80.  
  81. /** 
  82. * Set up our short title, long title and slug used in settings pages 
  83. * @return void 
  84. * @since 4.0 
  85. */ 
  86. public function set_plugin_titles() { 
  87. $this->short_title = esc_html__( 'PDF', 'gravity-forms-pdf-extended' ); 
  88. $this->title = esc_html__( 'Gravity PDF', 'gravity-forms-pdf-extended' ); 
  89. $this->slug = 'pdf'; 
  90.  
  91. /** 
  92. * A key-value array to be used in a localized script call for our Gravity PDF javascript files 
  93. * @param \GFPDF\Helper\Helper_Abstract_Options $options 
  94. * @param \GFPDF\Helper\Helper_Abstract_Form $gform 
  95. * @return array 
  96. * @since 4.0 
  97. */ 
  98. public function get_localised_script_data( Helper_Abstract_Options $options, Helper_Abstract_Form $gform ) { 
  99.  
  100. $custom_fonts = array_values( $options->get_custom_fonts() ); 
  101.  
  102. /** See https://gravitypdf.com/documentation/v4/gfpdf_localised_script_array/ for more details about this filter */ 
  103.  
  104. return apply_filters( 'gfpdf_localised_script_array', [ 
  105. 'ajaxUrl' => admin_url( 'admin-ajax.php' ),  
  106. 'ajaxNonce' => wp_create_nonce( 'gfpdf_ajax_nonce' ),  
  107. 'currentVersion' => PDF_EXTENDED_VERSION,  
  108. 'pdfWorkingDir' => PDF_TEMPLATE_LOCATION,  
  109. 'customFontData' => json_encode( $custom_fonts ),  
  110.  
  111. 'spinnerUrl' => admin_url( 'images/spinner-2x.gif' ),  
  112. 'spinnerAlt' => esc_html__( 'Loading...', 'gravity-forms-pdf-extended' ),  
  113. 'continue' => esc_html__( 'Continue', 'gravity-forms-pdf-extended' ),  
  114. 'uninstall' => esc_html__( 'Uninstall', 'gravity-forms-pdf-extended' ),  
  115. 'cancel' => esc_html__( 'Cancel', 'gravity-forms-pdf-extended' ),  
  116. 'delete' => esc_html__( 'Delete', 'gravity-forms-pdf-extended' ),  
  117. 'active' => esc_html__( 'Active', 'gravity-forms-pdf-extended' ),  
  118. 'inactive' => esc_html__( 'Inactive', 'gravity-forms-pdf-extended' ),  
  119. 'conditionalText' => esc_html__( 'this PDF if', 'gravity-forms-pdf-extended' ),  
  120. 'enable' => esc_html__( 'Enable', 'gravity-forms-pdf-extended' ),  
  121. 'disable' => esc_html__( 'Disable', 'gravity-forms-pdf-extended' ),  
  122. 'updateSuccess' => esc_html__( 'Successfully Updated', 'gravity-forms-pdf-extended' ),  
  123. 'deleteSuccess' => esc_html__( 'Successfully Deleted', 'gravity-forms-pdf-extended' ),  
  124. 'no' => esc_html__( 'No', 'gravity-forms-pdf-extended' ),  
  125. 'yes' => esc_html__( 'Yes', 'gravity-forms-pdf-extended' ),  
  126. 'standard' => esc_html__( 'Standard', 'gravity-forms-pdf-extended' ),  
  127. 'advanced' => esc_html__( 'Advanced', 'gravity-forms-pdf-extended' ),  
  128. 'select' => esc_html__( 'Select', 'gravity-forms-pdf-extended' ),  
  129. 'version' => esc_html__( 'Version', 'gravity-forms-pdf-extended' ),  
  130. 'group' => esc_html__( 'Group', 'gravity-forms-pdf-extended' ),  
  131. 'tags' => esc_html__( 'Tags', 'gravity-forms-pdf-extended' ),  
  132.  
  133. 'migratingSite' => esc_html__( 'Migrating site #%s', 'gravity-forms-pdf-extended' ),  
  134. 'siteMigrationComplete' => esc_html__( 'Site #%s migration complete.', 'gravity-forms-pdf-extended' ),  
  135. 'migrationError' => esc_html__( 'Migration Error', 'gravity-forms-pdf-extended' ),  
  136. 'siteMigrationErrors' => esc_html__( 'Site #%s migration errors.', 'gravity-forms-pdf-extended' ),  
  137.  
  138. 'addNewTemplate' => esc_html__( 'Add New Template', 'gravity-forms-pdf-extended' ),  
  139. 'showAdvancedOptions' => esc_html__( 'Show Advanced Options...', 'gravity-forms-pdf-extended' ),  
  140. 'hideAdvancedOptions' => esc_html__( 'Hide Advanced Options...', 'gravity-forms-pdf-extended' ),  
  141. 'thisFormHasNoPdfs' => esc_html__( "This form doesn't have any PDFs.", 'gravity-forms-pdf-extended' ),  
  142. 'letsGoCreateOne' => esc_html__( "Let's go create one", 'gravity-forms-pdf-extended' ),  
  143. 'installedPdfs' => esc_html__( 'Installed PDFs', 'gravity-forms-pdf-extended' ),  
  144.  
  145. 'searchPlaceholder' => esc_html__( 'Search the Gravity PDF Knowledgebase...', 'gravity-forms-pdf-extended' ),  
  146.  
  147. 'requiresGravityPdfVersion' => esc_html__( 'Requires Gravity PDF v%s', 'gravity-forms-pdf-extended' ),  
  148. 'templateNotCompatibleWithGravityPdfVersion' => esc_html__( 'This PDF template is not compatible with your version of Gravity PDF. This template required Gravity PDF v%s.', 'gravity-forms-pdf-extended' ),  
  149. 'templateDetails' => esc_html__( 'Template Details', 'gravity-forms-pdf-extended' ),  
  150. 'currentTemplate' => esc_html__( 'Current Template', 'gravity-forms-pdf-extended' ),  
  151. 'showPreviousTemplate' => esc_html__( 'Show previous template', 'gravity-forms-pdf-extended' ),  
  152. 'showNextTemplate' => esc_html__( 'Show next template', 'gravity-forms-pdf-extended' ),  
  153. 'uploadInvalidNotZipFile' => esc_html__( 'Upload is not a valid template. Upload a .zip file.', 'gravity-forms-pdf-extended' ),  
  154. 'uploadInvalidExceedsFileSizeLimit' => esc_html__( 'Upload exceeds the 10MB limit.', 'gravity-forms-pdf-extended' ),  
  155. 'templateSuccessfullyInstalled' => esc_html__( 'Template successfully installed', 'gravity-forms-pdf-extended' ),  
  156. 'templateSuccessfullyUpdated' => esc_html__( 'Template successfully updated', 'gravity-forms-pdf-extended' ),  
  157. 'templateSuccessfullyInstalledUpdated' => esc_html__( 'PDF Template(s) Successfully Installed / Updated', 'gravity-forms-pdf-extended' ),  
  158. 'problemWithTheUpload' => esc_html__( 'There was a problem with the upload. Reload the page and try again.', 'gravity-forms-pdf-extended' ),  
  159. 'doYouWantToDeleteTemplate' => sprintf( esc_html__( "Do you really want to delete this PDF template?%sClick 'Cancel' to go back, 'OK' to confirm the delete.", 'gravity-forms-pdf-extended' ), "\n\n" ),  
  160. 'couldNotDeleteTemplate' => esc_html__( 'Could not delete template.', 'gravity-forms-pdf-extended' ),  
  161. 'templateInstallInstructions' => esc_html__ ( 'If you have a PDF template in .zip format you may install it here. You can also update an existing PDF template (this will override any changes you have made).', 'gravity-forms-pdf-extended' ),  
  162. ] );