GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
select-template.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @file select-template.php
4  * @package GravityView
5  * @subpackage Gravityview/admin/metaboxes/partials
6  * @global WP_Post $post
7  */
8 
9 global $post;
10 
11 // Use nonce for verification
12 wp_nonce_field( 'gravityview_select_template', 'gravityview_select_template_nonce' );
13 
14 //current value
16 
18 
20 
21 foreach ( GravityKitFoundation::helpers()->core->get_plugins() as $path => $plugin ) {
22  if ( empty( $plugin['TextDomain'] ) ) {
23  continue;
24  }
25 
26  $wp_plugins[ $plugin['TextDomain'] ] = array(
27  'path' => $path,
28  'version' => $plugin['Version'],
29  'activated' => is_plugin_active( $path )
30  );
31 }
32 
33 // current input
34 ?>
35 <input type="hidden" id="gravityview_directory_template" name="gravityview_directory_template" value="<?php echo esc_attr( $current_template ); ?>" />
36 
37 <div class="gv-view-template-notice notice inline error hidden">
38  <p><!-- Contents will be replaced by JavaScript if there is an error --></p>
39 </div>
40 
41 <?php // list all the available templates (type= fresh or custom ) ?>
42 <div class="gv-grid">
43  <?php foreach( $templates as $id => $template ) {
44  $selected = ( $id == $current_template ) ? ' gv-selected' : '';
45  $placeholder = ! empty( $template['buy_source'] );
46  $is_included = ! empty( $template['included'] );
47  $template_text_domain = GravityKit\GravityView\Foundation\Helpers\Arr::get( $template, 'textdomain', '' );
49  $button_text = empty( $plugin_data ) ? esc_html__( 'Install', 'gk-gravityview' ) : esc_html__( 'Activate & Select', 'gk-gravityview' );
50  $button_class = 'gv-layout-' . ( empty( $plugin_data ) ? 'install' : 'activate' );
51  $template_path = isset( $plugin_data['path'] ) ? $plugin_data['path'] : '';
52  $template_id = isset( $template['template_id'] ) ? $template['template_id'] : '';
53  $download_id = isset( $template['download_id'] ) ? $template['download_id'] : '';
54  ?>
55  <div class="gv-grid-col-1-4">
56  <div class="gv-view-types-module<?php echo $selected; if( $placeholder ) { echo ' gv-view-template-placeholder'; } ?>" data-filter="<?php echo esc_attr( $template['type'] ); ?>">
57  <div class="gv-view-types-normal">
58  <img src="<?php echo esc_url( $template['logo'] ); ?>" alt="<?php echo esc_attr( $template['label'] ); ?>">
59  <h5><?php echo esc_html( $template['label'] ); ?></h5>
60  <p class="description"><?php echo esc_html( $template['description'] ); ?></p>
61  </div>
62  <div class="gv-view-types-hover">
63  <div>
64  <?php
65  if( $is_included ) {
66  ?>
67  <p><button class="button button-secondary button-hero <?php echo esc_attr( $button_class ); ?>" rel="internal" data-template-path="<?php echo esc_attr( $template_path ); ?>" data-templateid="<?php echo esc_attr( $template_id ); ?>" data-download-id="<?php echo esc_attr( $download_id ); ?>"><?php echo $button_text; ?></button></p>
68  <?php if( !empty( $template['license'] ) ) { ?>
69  <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gk-gravityview' ), esc_html( str_replace( ' ', '&nbsp;', $template['license'] ) ) ); ?></p>
70  <?php } ?>
71  <?php
72  } elseif( $placeholder ) {
73  $utm_string = '?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=' . urlencode( $template['license'] ) . '&utm_content=' . urlencode( $template['slug'] );
74  ?>
75  <p><a href="<?php echo esc_url( $template['buy_source'] ); ?>" class="button button-primary button-hero" rel="noreferrer noopener external"><?php esc_html_e( 'Buy Now', 'gk-gravityview'); ?></a></p>
76 
77  <?php if( !empty( $template['preview'] ) ) { ?>
78  <p><a href="<?php echo esc_url( $template['preview'] ); ?>" rel="noreferrer noopener external" class="button button-secondary"><i class="dashicons dashicons-external" style="vertical-align: middle;" title="<?php esc_html_e( 'View a live demo of this layout', 'gk-gravityview'); ?>"></i> <?php esc_html_e( 'Try a demo', 'gk-gravityview' ); ?></a></p>
79  <?php } ?>
80 
81  <?php if( ! empty( $template['license'] ) ) { ?>
82  <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gk-gravityview' ), '<a href="https://www.gravitykit.com/pricing/' . esc_attr( $utm_string ) . '" rel="noreferrer noopener external">' . esc_html( str_replace( ' ', '&nbsp;', $template['license'] ) ) . '</a>' ); ?></p>
83  <?php } ?>
84  <?php }
85 
86  if ($placeholder || $is_included) { ?> </div><div class="hidden"> <?php } ?>
87 
88  <p><a href="#gv_select_template" role="button" class="gv_select_template button button-hero button-primary" data-templateid="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Select', 'gk-gravityview'); ?></a></p>
89  <?php if( !empty( $template['preview'] ) ) { ?>
90  <a href="<?php echo esc_url( $template['preview'] ); ?>" rel="external" class="gv-site-preview"><i class="dashicons dashicons-welcome-view-site" title="<?php esc_html_e( 'View a live demo of this preset', 'gk-gravityview'); ?>"></i></a>
91  <?php } ?>
92  </div>
93  </div>
94  </div>
95  </div>
96  <?php } ?>
97 </div>
$wp_plugins
if(! isset( $gravityview)||empty( $gravityview->template)) $template
The entry loop for the list output.
static get( $array, $key, $default=null)
{}
Definition: Arr.php:99
$templates
static get_installed_plugin_by_text_domain( $text_domains_str)
Searches installed plugin by text domain(s) and returns its data.
$current_template
gravityview_get_registered_templates()
Get all available preset templates.
global $post
gravityview_get_template_id( $post_id)
Get the template ID (list, table, datatables, map) for a View.