Skip to content

Instantly share code, notes, and snippets.

@jakejackson1
Last active July 20, 2022 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakejackson1/3ea8c558084fe196ae813925f3b6c946 to your computer and use it in GitHub Desktop.
Save jakejackson1/3ea8c558084fe196ae813925f3b6c946 to your computer and use it in GitHub Desktop.
The completed template configuration for our Hello World tutorial, updated for v6
<?php
namespace GFPDF\Templates\Config;
use GFPDF\Helper\Helper_Interface_Config;
use GFPDF\Helper\Helper_Interface_Setup_TearDown;
use GFPDF\Helper\Helper_Abstract_Config_Settings;
/* Exit if accessed directly */
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Hello_World
*
* @package GFPDF\Templates\Config
*
* @Internal See https://docs.gravitypdf.com/v6/developers/template-configuration-and-image for more information about this class
*/
class Hello_World extends Helper_Abstract_Config_Settings implements Helper_Interface_Config, Helper_Interface_Setup_TearDown {
/**
* Runs when the template is initially installed via the PDF Template Manager
*
* @Internal Great for installing custom fonts you've shipped with your template.
* @Internal Recommend creating the directory structure /install/Hello_World/ for bundled fonts
*/
public function setUp() {
}
/**
* Runs when the template is deleted via the PDF Template Manager
*
* @Internal Great for cleaning up any additional directories
*/
public function tearDown() {
}
/**
* Return the templates configuration structure which control what extra fields will be shown in the "Template" tab when configuring a form's PDF.
*
* @return array The array, split into core components and custom fields
*/
public function configuration() {
return [
/* Enable core fields */
'core' => [
'footer' => true,
'background_image' => true,
],
/* Create custom fields to control the look and feel of a template */
'fields' => [
'world_show_meta_data' => [
'id' => 'world_show_meta_data',
'name' => esc_html__( 'Show Meta Data', 'world-pdf-template' ),
'desc' => esc_html__( 'When enabled the user IP, timestamp, user agent and source URL will be included in the PDF.', 'world-pdf-template' ),
'type' => 'radio',
'options' => [
'Yes' => esc_html__( 'Yes', 'world-pdf-template' ),
'No' => esc_html__( 'No', 'world-pdf-template' ),
],
'std' => 'No',
],
],
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment