GravityView  2.17
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) \GV\Utils::_GET( 'form_id', gravityview_get_form_id( $post->ID ) );
14 
15 // If form is in trash or not existing, show error
17 
18 // check for available gravity forms
19 $forms = gravityview_get_forms('any', false, 'title' );
20 
21 /**
22  * @param int $current_form Form currently selected in the View (0 if none selected)
23  * @param array $forms Array of active forms, not in trash
24  * @since 1.22.1
25  */
26 do_action( 'gravityview/metaboxes/data-source/before', $current_form, $forms );
27 
28 ?>
29 <label for="gravityview_form_id" ><?php esc_html_e( 'Where would you like the data to come from for this View?', 'gk-gravityview' ); ?></label>
30 
31 <p>
32  <?php
33 
34  if ( empty( $current_form ) && GVCommon::has_cap( 'gravityforms_create_form' ) ) {
35  ?>
36  <a class="button button-primary" href="#gv_start_fresh" title="<?php esc_attr_e( 'Use a Form Preset', 'gk-gravityview' ); ?>"><?php esc_html_e( 'Use a Form Preset', 'gk-gravityview' ); ?></a>
37 
38  <?php if( !empty( $forms ) ) { ?>
39  <span>&nbsp;<?php esc_html_e( 'or use an existing form', 'gk-gravityview' ); ?>&nbsp;</span>
40  <?php }
41  }
42 
43  // If there are no forms to select, show no forms.
44  if( !empty( $forms ) ) { ?>
45  <select name="gravityview_form_id" id="gravityview_form_id">
46  <option value="" <?php selected( '', $current_form, true ); ?>>&mdash; <?php esc_html_e( 'list of forms', 'gk-gravityview' ); ?> &mdash;</option>
47  <?php foreach( $forms as $form ) { ?>
48  <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option>
49  <?php } ?>
50  </select>
51  <?php } else { ?>
52  <select name="gravityview_form_id" id="gravityview_form_id" class="hidden"><option selected="selected" value=""></option></select>
53  <?php } ?>
54 
55  &nbsp;<button class="button button-primary" <?php if( empty( $current_form ) ) { echo 'style="display:none;"'; } ?> id="gv_switch_view_button" title="<?php esc_attr_e( 'Switch View', 'gk-gravityview' ); ?>"><?php esc_html_e( 'Switch View Type', 'gk-gravityview' ); ?></button>
56 </p>
57 
58 <?php // confirm dialog box ?>
59 <div id="gravityview_change_form_dialog" class="gv-dialog-options gv-dialog-warning" title="<?php esc_attr_e( 'Attention', 'gk-gravityview' ); ?>">
60  <p><?php esc_html_e( 'Changing the form will reset your field configuration. Changes will be permanent once you save the View.', 'gk-gravityview' ); ?></p>
61 </div>
62 
63 <?php // confirm template dialog box ?>
64 <div id="gravityview_switch_template_dialog" class="gv-dialog-options gv-dialog-warning" title="<?php esc_attr_e( 'Attention', 'gk-gravityview' ); ?>">
65  <p><?php esc_html_e( 'Changing the View Type will reset your field configuration. Changes will be permanent once you save the View.', 'gk-gravityview' ); ?></p>
66 </div>
67 
68 <?php // confirm template dialog box ?>
69  <div id="gravityview_select_preset_dialog" class="gv-dialog-options gv-dialog-warning" title="<?php esc_attr_e( 'Attention', 'gk-gravityview' ); ?>">
70  <p><?php esc_html_e( 'Using a preset will reset your field configuration. Changes will be permanent once you save the View.', 'gk-gravityview' ); ?></p>
71  </div>
72 
73 <?php // no js notice ?>
74 <div class="error hide-if-js">
75  <p><?php esc_html_e( 'GravityView requires Javascript to be enabled.', 'gk-gravityview' ); ?></p>
76 </div>
77 
78 <?php
79 // hidden field to keep track of start fresh state ?>
80 <input type="hidden" id="gravityview_form_id_start_fresh" name="gravityview_form_id_start_fresh" value="0" />
81 
82 <?php
83 
84 /**
85  * @param int $current_form Form currently selected in the View (0 if none selected)
86  * @param array $forms Array of active forms, not in trash
87  * @since 1.22.1
88  */
89 do_action( 'gravityview/metaboxes/data-source/after', $current_form, $forms );
$forms
Definition: data-source.php:19
global $post
Definition: delete-entry.php:7
if(gravityview() ->plugin->is_GF_25()) $form
gravityview_get_forms( $active=true, $trash=false, $order_by='date_created', $order='ASC')
Alias of GFAPI::get_forms()
gravityview_get_form_id( $view_id)
Get the connected form ID from a View ID.
static connected_form_warning( $form_id=0)
Display error HTML in Edit View when the form is in the trash or no longer exists in Gravity Forms...
Definition: class-admin.php:84
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
$current_form
Definition: data-source.php:13