Skip to content

Instantly share code, notes, and snippets.

@jakejackson1 jakejackson1/hello-world.php Secret
Created Sep 21, 2018

Embed
What would you like to do?
The completed template configuration for our Hello World tutorial, updated for v5
<?php
namespace GFPDF\Templates\Config;
use GFPDF\Helper\Helper_Interface_Config;
use GFPDF\Helper\Helper_Interface_Setup_TearDown;
/* Exit if accessed directly */
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Hello_World
*
* @package GFPDF\Templates\Config
*
* @Internal See https://gravitypdf.com/documentation/v5/developer-template-configuration-and-image/ for more information about this class
*/
class Hello_World 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
*
* @since 1.0
*/
public function setUp() {
}
/**
* Runs when the template is deleted via the PDF Template Manager
*
* @Internal Great for cleaning up any additional directories
*
* @since 1.0
*/
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
*
* @since 1.0
*/
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' => __( 'Show Meta Data', 'world-pdf-template' ),
'desc' => __( 'When enabled the user IP, timestamp, user agent and source URL will be included in the PDF.', 'world-pdf-template' ),
'type' => 'radio',
'options' => [
'Yes' => __( 'Yes', 'world-pdf-template' ),
'No' => __( 'No', 'world-pdf-template' ),
],
'std' => 'No',
],
],
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.