GravityView  1.22.6
The best, easiest way to display Gravity Forms entries on your website.
data-source.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @package GravityView
4  * @subpackage Gravityview/admin/metaboxes/views
5  * @since 1.8
6  * @global WP_Post $post
7  */
8 
9 // Use nonce for verification
10 wp_nonce_field( 'gravityview_select_form', 'gravityview_select_form_nonce' );
11 
12 //current value
13 $current_form = (int) rgar( (array) $_GET, 'form_id', gravityview_get_form_id( $post->ID ) );
14 
15 // check for available gravity forms
17 
18 /**
19  * @param int $current_form Form currently selected in the View (0 if none selected)
20  * @param array $forms Array of active forms, not in trash
21  * @since 1.22.1
22  */
23 do_action( 'gravityview/metaboxes/data-source/before', $current_form, $forms );
24 
25 ?>
26 <label for="gravityview_form_id" ><?php esc_html_e( 'Where would you like the data to come from for this View?', 'gravityview' ); ?></label>
27 
28 <p>
29  <?php
30 
31  if ( empty( $current_form ) && GVCommon::has_cap( 'gravityforms_create_form' ) ) {
32  ?>
33  <a class="button button-primary" href="#gv_start_fresh" title="<?php esc_attr_e( 'Use a Form Preset', 'gravityview' ); ?>"><?php esc_html_e( 'Use a Form Preset', 'gravityview' ); ?></a>
34 
35  <?php if( !empty( $forms ) ) { ?>
36  <span>&nbsp;<?php esc_html_e( 'or use an existing form', 'gravityview' ); ?>&nbsp;</span>
37  <?php }
38  }
39 
40  // If there are no forms to select, show no forms.
41  if( !empty( $forms ) ) { ?>
42  <select name="gravityview_form_id" id="gravityview_form_id">
43  <option value="" <?php selected( '', $current_form, true ); ?>>&mdash; <?php esc_html_e( 'list of forms', 'gravityview' ); ?> &mdash;</option>
44  <?php foreach( $forms as $form ) { ?>
45  <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option>
46  <?php } ?>
47  </select>
48  <?php } else { ?>
49  <select name="gravityview_form_id" id="gravityview_form_id" class="hidden"><option selected="selected" value=""></option></select>
50  <?php } ?>
51 
52  &nbsp;<a class="button button-primary" <?php if( empty( $current_form ) ) { echo 'style="display:none;"'; } ?> id="gv_switch_view_button" href="#gv_switch_view" title="<?php esc_attr_e( 'Switch View', 'gravityview' ); ?>"><?php esc_html_e( 'Switch View Type', 'gravityview' ); ?></a>
53 </p>
54 
55 <?php // confirm dialog box ?>
56 <div id="gravityview_form_id_dialog" class="gv-dialog-options gv-dialog-warning" title="<?php esc_attr_e( 'Attention', 'gravityview' ); ?>">
57  <p><?php esc_html_e( 'Changing the form will reset your field configuration. Changes will be permanent once you save the View.', 'gravityview' ); ?></p>
58 </div>
59 
60 <?php // confirm template dialog box ?>
61 <div id="gravityview_switch_template_dialog" class="gv-dialog-options gv-dialog-warning" title="<?php esc_attr_e( 'Attention', 'gravityview' ); ?>">
62  <p><?php esc_html_e( 'Changing the View Type will reset your field configuration. Changes will be permanent once you save the View.', 'gravityview' ); ?></p>
63 </div>
64 
65 <?php // no js notice ?>
66 <div class="error hide-if-js">
67  <p><?php esc_html_e( 'GravityView requires Javascript to be enabled.', 'gravityview' ); ?></p>
68 </div>
69 
70 <?php
71 // hidden field to keep track of start fresh state ?>
72 <input type="hidden" id="gravityview_form_id_start_fresh" name="gravityview_form_id_start_fresh" value="0" />
73 
74 <?php
75 
76 /**
77  * @param int $current_form Form currently selected in the View (0 if none selected)
78  * @param array $forms Array of active forms, not in trash
79  * @since 1.22.1
80  */
81 do_action( 'gravityview/metaboxes/data-source/after', $current_form, $forms );
$forms
Definition: data-source.php:16
gravityview_get_forms( $active=true, $trash=false)
Alias of GFAPI::get_forms()
gravityview_get_form_id( $view_id)
Get the connected form ID from a View ID.
global $post
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
$current_form
Definition: data-source.php:13