GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
register-default-templates.php
Go to the documentation of this file.
1 <?php
2 /**
3  * GravityView default templates and generic template class
4  *
5  * @file register-default-templates.php
6  * @since 2.10
7  * @license GPL2+
8  * @author GravityView <[email protected]>
9  * @link http://gravityview.co
10  * @copyright Copyright 2015, Katz Web Services, Inc.
11  *
12  * @package GravityView
13  */
14 
15 // Load default templates
16 add_action( 'init', 'gravityview_register_default_templates', 11 );
17 
18 /**
19  * Registers the default templates
20  * @return void
21  */
23  /** @define "GRAVITYVIEW_DIR" "../../" */
24 
25  // The abstract class required by all template files.
26  require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-template.php';
27 
28  $path = GRAVITYVIEW_DIR . 'includes/presets/';
29  include_once $path . 'default-table/class-gravityview-default-template-table.php';
30  include_once $path . 'default-list/class-gravityview-default-template-list.php';
31  include_once $path . 'default-edit/class-gravityview-default-template-edit.php';
32  include_once $path . 'business-listings/class-gravityview-preset-business-listings.php';
33  include_once $path . 'business-data/class-gravityview-preset-business-data.php';
34  include_once $path . 'profiles/class-gravityview-preset-profiles.php';
35  include_once $path . 'staff-profiles/class-gravityview-preset-staff-profiles.php';
36  include_once $path . 'website-showcase/class-gravityview-preset-website-showcase.php';
37  include_once $path . 'issue-tracker/class-gravityview-preset-issue-tracker.php';
38  include_once $path . 'resume-board/class-gravityview-preset-resume-board.php';
39  include_once $path . 'job-board/class-gravityview-preset-job-board.php';
40  include_once $path . 'event-listings/class-gravityview-preset-event-listings.php';
41 }
42 
43 
44 // Register after other templates
45 add_action( 'init', 'gravityview_register_placeholder_templates', 2000 );
46 
47 /**
48  * Register the placeholder templates to make it clear what layouts are available
49  *
50  * @since 2.10
51  *
52  * @return void
53  */
55 
56  require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-placeholder-template.php';
57 
58  $placeholders = [
59  'GravityView_DataTables_Template' => [
60  'slug' => 'dt_placeholder',
61  'template_id' => 'datatables_table',
62  'download_id' => 268,
63  'label' => __( 'DataTables Table', 'gv-datatables', 'gk-gravityview' ),
64  'description' => __( 'Display items in a dynamic table powered by DataTables.', 'gk-gravityview' ),
65  'logo' => plugins_url( 'assets/images/templates/logo-datatables.png', GRAVITYVIEW_FILE ),
66  'buy_source' => 'https://www.gravitykit.com/pricing/?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=datatables',
67  'preview' => 'https://try.gravityview.co/demo/view/datatables/?utm_source=plugin&utm_medium=try_demo&utm_campaign=view_type&utm_term=datatables',
68  'license' => esc_html__( 'All Access', 'gk-gravityview' ),
69  'price_id' => 2,
70  'textdomain' => 'gv-datatables|gk-datatables',
71  ],
72  'GravityView_Maps_Template_Map_Default' => [
73  'slug' => 'map_placeholder',
74  'template_id' => 'map',
75  'download_id' => 27,
76  'label' => __( 'Map', 'gravityview-maps', 'gk-gravityview' ),
77  'description' => __( 'Display entries on a map.', 'gk-gravityview' ),
78  'logo' => plugins_url( 'assets/images/templates/default-map.png', GRAVITYVIEW_FILE ),
79  'buy_source' => 'https://www.gravitykit.com/pricing/?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=map',
80  'preview' => 'https://try.gravityview.co/demo/view/map/?utm_source=plugin&utm_medium=try_demo&utm_campaign=view_type&utm_term=map',
81  'license' => esc_html__( 'All Access', 'gk-gravityview' ),
82  'price_id' => 2,
83  'textdomain' => 'gravityview-maps|gk-gravitymaps',
84  ],
85  'GravityView_DIY_Template' => [
86  'slug' => 'diy_placeholder',
87  'template_id' => 'diy',
88  'download_id' => 550152,
89  'label' => _x( 'DIY', 'DIY means "Do It Yourself"', 'gk-gravityview' ),
90  'description' => esc_html__( 'A flexible, powerful layout for designers & developers.', 'gk-gravityview' ),
91  'buy_source' => 'https://www.gravitykit.com/pricing/?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=diy',
92  'logo' => plugins_url( 'assets/images/templates/logo-diy.png', GRAVITYVIEW_FILE ),
93  'preview' => 'https://try.gravityview.co/demo/view/diy/?utm_source=plugin&utm_medium=try_demo&utm_campaign=view_type&utm_term=diy',
94  'license' => esc_html__( 'All Access', 'gk-gravityview' ),
95  'textdomain' => 'gravityview-diy|gk-diy',
96  ],
97  ];
98 
99  if ( ! class_exists( 'GravityKitFoundation' ) ) {
100  return;
101  }
102 
103  $product_manager = GravityKitFoundation::licenses()->product_manager();
104 
105  if ( ! $product_manager ) {
106  return;
107  }
108 
109  try {
110  $products_data = $product_manager->get_products_data( [ 'key_by' => 'id' ] );
111  } catch ( Exception $e ) {
112  $products_data = [];
113  }
114 
115  foreach ( $placeholders as $placeholder ) {
116  if ( GravityKit\GravityView\Foundation\Helpers\Arr::get( $products_data, "{$placeholder['download_id']}.active" ) ) {
117  // Template will be loaded by the extension.
118  continue;
119  }
120 
121  $placeholder['type'] = 'custom';
122  $placeholder['included'] = ! empty( GravityKitFoundation::helpers()->array->get( $products_data, "{$placeholder['download_id']}.licenses" ) );
123 
124  new GravityView_Placeholder_Template( $placeholder['slug'], $placeholder );
125  }
126 }
const GRAVITYVIEW_DIR
"GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory, with trailing slash ...
Definition: gravityview.php:49
const GRAVITYVIEW_FILE
Full path to the GravityView file "GRAVITYVIEW_FILE" "./gravityview.php".
Definition: gravityview.php:40
gravityview_register_placeholder_templates()
Register the placeholder templates to make it clear what layouts are available.
gravityview_register_default_templates()
Registers the default templates.