GravityView  2.9.2
The best, easiest way to display Gravity Forms entries on your website.
class-admin-views.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Renders all the metaboxes on Add New / Edit View post type.
4  *
5  * @package GravityView
6  * @license GPL2+
7  * @author GravityView <hello@gravityview.co>
8  * @link http://gravityview.co
9  * @copyright Copyright 2014, Katz Web Services, Inc.
10  *
11  * @since 1.0.0
12  */
13 
14 /** If this file is called directly, abort. */
15 if ( ! defined( 'ABSPATH' ) ) {
16  die;
17 }
18 
20 
21 
22 
23  function __construct() {
24  add_action( 'save_post', array( $this, 'save_postdata' ) );
25 
26  // set the blacklist field types across the entire plugin
27  add_filter( 'gravityview_blacklist_field_types', array( $this, 'default_field_blacklist' ), 10, 2 );
28 
29  // Tooltips
30  add_filter( 'gform_tooltips', array( $this, 'tooltips') );
31 
32  // adding styles and scripts
33  add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles'), 999 );
34  add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict') );
35  add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict') );
36  add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict') );
37  add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict') );
38 
39  add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas'), 10, 4 );
40  add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas'), 10, 3 );
41  add_action( 'gravityview_render_field_pickers', array( $this, 'render_field_pickers'), 10, 2 );
42  add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields'), 10, 2 );
43  add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets') );
44  add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas'), 10, 5 );
45 
46  // @todo check if this hook is needed..
47  //add_action( 'gravityview_render_field_options', array( $this, 'render_field_options'), 10, 9 );
48 
49  // Add Connected Form column
50  add_filter('manage_gravityview_posts_columns' , array( $this, 'add_post_type_columns' ) );
51 
52  add_filter( 'gform_toolbar_menu', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 );
53  add_action( 'gform_form_actions', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 );
54 
55  add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content'), 10, 2 );
56 
57  add_action( 'restrict_manage_posts', array( $this, 'add_view_dropdown' ) );
58 
59  add_action( 'pre_get_posts', array( $this, 'filter_pre_get_posts_by_gravityview_form_id' ) );
60 
61  add_filter( 'gravityview/support_port/localization_data', array( $this, 'suggest_support_articles' ) );
62 
63  }
64 
65  /**
66  * When on the Add/Edit View screen, suggest most popular articles related to that
67  *
68  * @param array $localization_data Data to be passed to the Support Port JS
69  *
70  * @return array
71  */
72  function suggest_support_articles( $localization_data = array() ) {
73 
74  if( ! gravityview()->request->is_view() ) {
75  return $localization_data;
76  }
77 
78  $localization_data['suggest'] = array(
79  '57ef23539033602e61d4a560',
80  '54c67bb9e4b0512429885513',
81  '54c67bb9e4b0512429885512',
82  '54c67bbbe4b07997ea3f3f6b',
83  '54d1a33ae4b086c0c0964ce9',
84  '57ef253c9033602e61d4a563',
85  '552355bfe4b0221aadf2572b',
86  '54c67bcde4b051242988553e',
87  );
88 
89  return $localization_data;
90  }
91 
92  /**
93  * @since 1.15
94  * @param WP_Query $query
95  */
96  public function filter_pre_get_posts_by_gravityview_form_id( &$query ) {
97  global $pagenow;
98 
99  if ( !is_admin() ) {
100  return;
101  }
102 
103  $form_id = isset( $_GET['gravityview_form_id'] ) ? (int) $_GET['gravityview_form_id'] : false;
104 
105  if( 'edit.php' !== $pagenow || ! $form_id || ! isset( $query->query_vars[ 'post_type' ] ) ) {
106  return;
107  }
108 
109  if ( $query->query_vars[ 'post_type' ] == 'gravityview' ) {
110  $query->set( 'meta_query', array(
111  array(
112  'key' => '_gravityview_form_id',
113  'value' => $form_id,
114  )
115  ) );
116  }
117  }
118 
119  function add_view_dropdown() {
120  $current_screen = get_current_screen();
121 
122  if( 'gravityview' !== $current_screen->post_type ) {
123  return;
124  }
125 
127  $current_form = \GV\Utils::_GET( 'gravityview_form_id' );
128  // If there are no forms to select, show no forms.
129  if( !empty( $forms ) ) { ?>
130  <select name="gravityview_form_id" id="gravityview_form_id">
131  <option value="" <?php selected( '', $current_form, true ); ?>><?php esc_html_e( 'All forms', 'gravityview' ); ?></option>
132  <?php foreach( $forms as $form ) { ?>
133  <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option>
134  <?php } ?>
135  </select>
136  <?php }
137  }
138 
139 
140  /**
141  * @deprecated since 1.2
142  * Start using GravityView_Render_Settings::render_setting_row
143  */
144  public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) {
145  _deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' );
147  }
148 
149  /**
150  * @deprecated since 1.2
151  * Start using GravityView_Render_Settings::render_field_option
152  */
153  public static function render_field_option( $name = '', $option, $curr_value = NULL ) {
154  _deprecated_function( 'GravityView_Admin_Views::render_field_option', '1.1.7', 'GravityView_Render_Settings::render_field_option' );
155  return GravityView_Render_Settings::render_field_option( $name, $option, $curr_value );
156  }
157 
158 
159  /**
160  * Add a GravityView menu to the Form Toolbar with connected views
161  * @param array $menu_items Menu items, as set in GFForms::top_toolbar()
162  * @param int $id ID of the current Gravity form
163  * @return array Modified array
164  */
165  public static function gform_toolbar_menu( $menu_items = array(), $id = NULL ) {
166 
167  // Don't show on Trashed forms
168  if( 'trash' === rgget( 'filter') ) {
169  return $menu_items;
170  }
171 
172  $connected_views = gravityview_get_connected_views( $id, array( 'post_status' => 'any' ) );
173 
174  $priority = 0;
175 
176  if( 'form_list' === GFForms::get_page() ) {
177  $priority = 790;
178  }
179 
180  if( empty( $connected_views ) ) {
181 
182  $menu_items['gravityview'] = array(
183  'label' => esc_attr__( 'Create a View', 'gravityview' ),
184  'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>',
185  'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ),
186  'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ),
187  'menu_class' => 'gv_connected_forms gf_form_toolbar_settings',
188  'priority' => $priority,
189  'capabilities' => array( 'edit_gravityviews' ),
190  );
191 
192  return $menu_items;
193  }
194 
195  $sub_menu_items = array();
196  foreach ( (array)$connected_views as $view ) {
197 
198  if( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) {
199  continue;
200  }
201 
202  $label = empty( $view->post_title ) ? sprintf( __('No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title;
203 
204  $sub_menu_items[] = array(
205  'label' => esc_attr( $label ),
206  'url' => admin_url( 'post.php?action=edit&post='.$view->ID ),
207  );
208  }
209 
210  // If there were no items added, then let's create the parent menu
211  if( $sub_menu_items ) {
212 
213  $sub_menu_items[] = array(
214  'label' => esc_attr__( 'Create a View', 'gravityview' ),
215  'link_class' => 'gv-create-view',
216  'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ),
217  'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ),
218  'capabilities' => array( 'edit_gravityviews' ),
219  );
220 
221  // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown
222  $sub_menu_items[] = array(
223  'url' => '#',
224  'label' => '',
225  'menu_class' => 'hidden',
226  'capabilities' => '',
227  );
228 
229  $menu_items['gravityview'] = array(
230  'label' => __( 'Connected Views', 'gravityview' ),
231  'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>',
232  'title' => __( 'GravityView Views using this form as a data source', 'gravityview' ),
233  'url' => '#',
234  'onclick' => 'return false;',
235  'menu_class' => 'gv_connected_forms gf_form_toolbar_settings',
236  'sub_menu_items' => $sub_menu_items,
237  'priority' => $priority,
238  'capabilities' => array( 'edit_gravityviews' ),
239  );
240  }
241 
242  return $menu_items;
243  }
244 
245  /**
246  * List the field types without presentation properties (on a View context)
247  *
248  * @param array $array Existing field types to add to a blacklist
249  * @param string|null $context Context for the blacklist. Default: NULL.
250  * @return array Default blacklist fields merged with existing blacklist fields
251  */
252  function default_field_blacklist( $array = array(), $context = NULL ) {
253 
254  $add = array( 'captcha', 'page' );
255 
256  // Don't allowing editing the following values:
257  if( $context === 'edit' ) {
258  $add[] = 'post_id';
259  }
260 
261  $return = array_merge( $array, $add );
262 
263  return $return;
264  }
265 
266  /**
267  * Add tooltip text for use throughout the UI
268  * @param array $tooltips Array of Gravity Forms tooltips
269  * @return array Modified tooltips array
270  */
271  public function tooltips( $tooltips = array() ) {
272 
273  $gv_tooltips = array();
274 
275  // Generate tooltips for View settings
276  $default_args = \GV\View_Settings::defaults( true );
277 
278  foreach ( $default_args as $key => $arg ) {
279 
280  // If an arg has `tooltip` defined, but it's false, don't display a tooltip
281  if( isset( $arg['tooltip'] ) && empty( $arg['tooltip'] ) ) { continue; }
282 
283  // By default, use `tooltip` if defined.
284  $tooltip = empty( $arg['tooltip'] ) ? NULL : $arg['tooltip'];
285 
286  // Otherwise, use the description as a tooltip.
287  if( empty( $tooltip ) && !empty( $arg['desc'] ) ) {
288  $tooltip = $arg['desc'];
289  }
290 
291  // If there's no tooltip set, continue
292  if( empty( $tooltip ) ) {
293  continue;
294  }
295 
296  // Add the tooltip
297  $gv_tooltips[ 'gv_'.$key ] = array(
298  'title' => $arg['label'],
299  'value' => $tooltip,
300  );
301 
302  }
303 
304  $gv_tooltips['gv_css_merge_tags'] = array(
305  'title' => __('CSS Merge Tags', 'gravityview'),
306  'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>' )
307  );
308 
309  /**
310  * @filter `gravityview_tooltips` The tooltips GravityView adds to the Gravity Forms tooltip array
311  * @param array $gv_tooltips Associative array with unique keys containing array of `title` and `value` keys, as expected by `gform_tooltips` filter
312  * @deprecated Renamed to `gravityview/metaboxes/tooltips`
313  */
314  $gv_tooltips = apply_filters( 'gravityview_tooltips', $gv_tooltips );
315 
316  /**
317  * @filter `gravityview/metaboxes/tooltips` The tooltips GravityView adds to the Gravity Forms tooltip array
318  * @param array $gv_tooltips Associative array with unique keys containing array of `title` and `value` keys, as expected by `gform_tooltips` filter
319  */
320  $gv_tooltips = apply_filters( 'gravityview/metaboxes/tooltips', $gv_tooltips );
321 
322  foreach ( $gv_tooltips as $key => $tooltip ) {
323 
324  $title = empty( $tooltip['title'] ) ? '' : '<h6>'.esc_html( $tooltip['title'] ) .'</h6>';
325 
326  $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip['value'] ) );
327  }
328 
329  return $tooltips;
330  }
331 
332  /**
333  * Add the Data Source information
334  *
335  * @param null $column_name
336  * @param $post_id
337  *
338  * @return void
339  */
340  public function add_custom_column_content( $column_name = NULL, $post_id ) {
341 
342  $output = '';
343 
344  switch ( $column_name ) {
345  case 'gv_template':
346 
347  $template_id = gravityview_get_template_id( $post_id );
348 
349  // All Views should have a connected form. If it doesn't, that's not right.
350  if ( empty( $template_id ) ) {
351  gravityview()->log->error( 'View ID {view_id} does not have a connected template.', array( 'view_id' => $post_id ) );
352  break;
353  }
354 
356 
357  $template = isset( $templates[ $template_id ] ) ? $templates[ $template_id ] : false;
358 
359  // Generate backup if label doesn't exist: `example_name` => `Example Name`
360  $template_id_pretty = ucwords( implode( ' ', explode( '_', $template_id ) ) );
361 
362  $output = $template ? $template['label'] : $template_id_pretty;
363 
364  break;
365 
366  case 'gv_connected_form':
367 
368  $form_id = gravityview_get_form_id( $post_id );
369 
370  // All Views should have a connected form. If it doesn't, that's not right.
371  if ( empty( $form_id ) ) {
372  gravityview()->log->error( 'View ID {view_id} does not have a connected GF form.', array( 'view_id' => $post_id ) );
373  $output = __( 'Not connected.', 'gravityview' );
374  break;
375  }
376 
378 
379  if ( ! $form ) {
380  gravityview()->log->error( 'Connected form not found: Form #{form_id}', array( 'form_id' => $form_id ) );
381 
382  $output = __( 'The connected form can not be found; it may no longer exist.', 'gravityview' );
383  } else {
384  $output = self::get_connected_form_links( $form );
385  }
386 
387  break;
388  }
389 
390  echo $output;
391  }
392 
393 
394  /**
395  * Get HTML links relating to a connected form, like Edit, Entries, Settings, Preview
396  * @param array|int $form Gravity Forms forms array, or the form ID
397  * @param boolean $include_form_link Whether to include the bold name of the form in the output
398  * @return string HTML links
399  */
400  static public function get_connected_form_links( $form, $include_form_link = true ) {
401 
402  // Either the form is empty or the form ID is 0, not yet set.
403  if( empty( $form ) ) {
404  return '';
405  }
406 
407  // The $form is passed as the form ID
408  if( !is_array( $form ) ) {
410  }
411 
412  $form_id = $form['id'];
413  $links = array();
414 
415  if( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) {
416  $form_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&amp;id=%d', $form_id ) );
417  $form_link = '<strong class="gv-form-title">'.gravityview_get_link( $form_url, $form['title'], 'class=row-title' ).'</strong>';
418  $links[] = '<span>'.gravityview_get_link( $form_url, __('Edit Form', 'gravityview') ).'</span>';
419  } else {
420  $form_link = '<strong class="gv-form-title">'. esc_html( $form['title'] ). '</strong>';
421  }
422 
423  if( GVCommon::has_cap( 'gravityforms_view_entries' ) ) {
424  $entries_url = admin_url( sprintf( 'admin.php?page=gf_entries&amp;id=%d', $form_id ) );
425  $links[] = '<span>'.gravityview_get_link( $entries_url, __('Entries', 'gravityview') ).'</span>';
426  }
427 
428  if( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) {
429  $settings_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&amp;view=settings&amp;id=%d', $form_id ) );
430  $links[] = '<span>'.gravityview_get_link( $settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview') ).'</span>';
431  }
432 
433  if( GVCommon::has_cap( array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms") ) ) {
434  $preview_url = site_url( sprintf( '?gf_page=preview&amp;id=%d', $form_id ) );
435  $links[] = '<span>'.gravityview_get_link( $preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview') ).'</span>';
436  }
437 
438  $output = '';
439 
440  if( !empty( $include_form_link ) ) {
441  $output .= $form_link;
442  }
443 
444  /**
445  * @filter `gravityview_connected_form_links` Modify the links shown in the Connected Form links
446  * @since 1.6
447  * @param array $links Links to show
448  * @param array $form Gravity Forms form array
449  */
450  $links = apply_filters( 'gravityview_connected_form_links', $links, $form );
451 
452  $output .= '<div class="row-actions">'. implode( ' | ', $links ) .'</div>';
453 
454  return $output;
455  }
456 
457  /**
458  * Add the Data Source column to the Views page
459  * @param array $columns Columns array
460  */
461  public function add_post_type_columns( $columns ) {
462 
463  // Get the date column and save it for later to add back in.
464  // This adds it after the Data Source column.
465  // This way, we don't need to do array_slice, array_merge, etc.
466  $date = $columns['date'];
467  unset( $columns['date'] );
468 
469  $data_source_required_caps = array(
470  'gravityforms_edit_forms',
471  'gravityforms_view_entries',
472  'gravityforms_edit_settings',
473  'gravityview_view_settings',
474  'gravityforms_create_form',
475  'gravityforms_preview_forms',
476  );
477 
478  if( GVCommon::has_cap( $data_source_required_caps ) ) {
479  $columns['gv_connected_form'] = __( 'Data Source', 'gravityview' );
480  }
481 
482  $columns['gv_template'] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' );
483 
484  // Add the date back in.
485  $columns['date'] = $date;
486 
487  return $columns;
488  }
489 
490  /**
491  * Save View configuration
492  *
493  * @param int $post_id Currently saved Post ID
494  * @return void
495  */
496  function save_postdata( $post_id ) {
497 
498  if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
499  return;
500  }
501 
502  // validate post_type
503  if ( ! isset( $_POST['post_type'] ) || 'gravityview' != $_POST['post_type'] ) {
504  return;
505  }
506 
507  // validate user can edit and save View
508  if ( ! GVCommon::has_cap( 'edit_gravityview', $post_id ) ) {
509  gravityview()->log->error( 'Current user does not have the capability to edit View {view_id}', array( 'view_id' => $post_id, 'data' => wp_get_current_user() ) );
510  return;
511  }
512 
513  gravityview()->log->debug( '[save_postdata] Saving View post type.', array( 'data' => $_POST ) );
514 
515  $statii = array();
516 
517  // check if this is a start fresh View
518  if ( isset( $_POST['gravityview_select_form_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_form_nonce'], 'gravityview_select_form' ) ) {
519 
520  $form_id = !empty( $_POST['gravityview_form_id'] ) ? $_POST['gravityview_form_id'] : '';
521  // save form id
522  $statii['form_id'] = update_post_meta( $post_id, '_gravityview_form_id', $form_id );
523 
524  }
525 
526  if( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii['form_id'] ) ) {
527  gravityview()->log->error( 'Current user does not have the capability to create a new Form.', array( 'data' => wp_get_current_user() ) );
528  return;
529  }
530 
531  // Was this a start fresh?
532  if ( ! empty( $_POST['gravityview_form_id_start_fresh'] ) ) {
533  $statii['start_fresh'] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 );
534  } else {
535  $statii['start_fresh'] = delete_post_meta( $post_id, '_gravityview_start_fresh' );
536  }
537 
538  // Check if we have a template id
539  if ( isset( $_POST['gravityview_select_template_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_template_nonce'], 'gravityview_select_template' ) ) {
540 
541  $template_id = !empty( $_POST['gravityview_directory_template'] ) ? $_POST['gravityview_directory_template'] : '';
542 
543  // now save template id
544  $statii['directory_template'] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id );
545  }
546 
547 
548  // save View Configuration metabox
549  if ( isset( $_POST['gravityview_view_configuration_nonce'] ) && wp_verify_nonce( $_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration' ) ) {
550 
551  // template settings
552  if( empty( $_POST['template_settings'] ) ) {
553  $_POST['template_settings'] = array();
554  }
555  $statii['template_settings'] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST['template_settings'] );
556 
557  // guard against unloaded View configuration page
558  if ( isset( $_POST['gv_fields'] ) && isset( $_POST['gv_fields_done'] ) ) {
559  $fields = array();
560 
561  if ( ! empty( $_POST['gv_fields'] ) ) {
563  }
564 
565  $fields = wp_slash( $fields );
566 
567  $statii['directory_fields'] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields );
568  }
569 
570  // Directory Visible Widgets
571  if( empty( $_POST['widgets'] ) ) {
572  $_POST['widgets'] = array();
573  }
574  $statii['directory_widgets'] = gravityview_set_directory_widgets( $post_id, $_POST['widgets'] );
575 
576  } // end save view configuration
577 
578  /**
579  * @action `gravityview_view_saved` After a View has been saved in the admin
580  * @param int $post_id ID of the View that has been saved
581  * @param array $statii Array of statuses of the post meta saving processes. If saving worked, each key should be mapped to a value of the post ID (`directory_widgets` => `124`). If failed (or didn't change), the value will be false.
582  * @since 1.17.2
583  */
584  do_action('gravityview_view_saved', $post_id, $statii );
585 
586  gravityview()->log->debug( '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array( 'data' => array_map( 'intval', $statii ) ) );
587  }
588 
589  /**
590  * @deprecated 1.1.6
591  */
592  function render_label() {
593  _deprecated_function( 'GravityView_Admin_Views::render_label()', '1.1.6', 'Use the GravityView_Admin_View_Field class instead.' );
594  }
595 
596  /**
597  * Render html for displaying available fields based on a Form ID
598  *
599  * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action
600  *
601  * @param int $form Gravity Forms Form ID (default: '')
602  * @param string $context (default: 'single')
603  *
604  * @return void
605  */
606  function render_available_fields( $form = 0, $context = 'single' ) {
607 
608  // Determine if form is a preset and convert it to an array with fields
609  $form = ( is_string( $form ) && preg_match( '/^preset_/', $form ) ) ? GravityView_Ajax::pre_get_form_fields( $form ) : $form;
610 
611  /**
612  * @filter `gravityview_blacklist_field_types` Modify the types of fields that shouldn't be shown in a View.
613  * @param[in,out] array $blacklist_field_types Array of field types to block for this context.
614  * @param[in] string $context View context ('single', 'directory', or 'edit')
615  */
616  $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array(), $context );
617 
618  if ( ! is_array( $blacklist_field_types ) ) {
619 
620  gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) );
621 
622  $blacklist_field_types = array();
623  }
624 
625  $fields = $this->get_available_fields( $form, $context );
626 
627  $output = '';
628 
629  if( !empty( $fields ) ) {
630 
631  foreach( $fields as $id => $details ) {
632 
633  if( in_array( $details['type'], (array) $blacklist_field_types ) ) {
634  continue;
635  }
636 
637  // Edit mode only allows editing the parent fields, not single inputs.
638  if( $context === 'edit' && ! empty( $details['parent'] ) ) {
639  continue;
640  }
641 
642  $output .= new GravityView_Admin_View_Field( $details['label'], $id, $details, array(), $form );
643 
644  } // End foreach
645  }
646 
647  echo $output;
648 
649  // For the EDIT view we only want to allow the form fields.
650  if( $context === 'edit' ) {
651  return;
652  }
653 
654  $this->render_additional_fields( $form, $context );
655  }
656 
657  /**
658  * Render html for displaying additional fields based on a Form ID
659  *
660  * @param int $form Gravity Forms Form ID (default: '')
661  * @param string $context (default: 'single')
662  * @return void
663  */
664  public function render_additional_fields( $form = 0, $context = 'single' ) {
665 
666  $additional_fields = array(
667  array(
668  'label_text' => '+ ' . __( 'Add All Form Fields', 'gravityview' ),
669  'desc' => __('Insert all the form fields at once.', 'gravityview'),
670  'field_id' => 'all-fields',
671  'label_type' => 'field',
672  'input_type' => null,
673  'field_options' => null,
674  'settings_html' => null,
675  )
676  );
677 
678  /**
679  * @filter `gravityview_additional_fields` non-standard Fields to show at the bottom of the field picker
680  * @param array $additional_fields Associative array of field arrays, with `label_text`, `desc`, `field_id`, `label_type`, `input_type`, `field_options`, and `settings_html` keys
681  */
682  $additional_fields = apply_filters( 'gravityview_additional_fields', $additional_fields );
683 
684  foreach ( (array) $additional_fields as $item ) {
685 
686  // Prevent items from not having index set
687  $item = wp_parse_args( $item, array(
688  'label_text' => null,
689  'field_id' => null,
690  'label_type' => null,
691  'input_type' => null,
692  'field_options' => null,
693  'settings_html' => null,
694  ));
695 
696  // Backward compat.
697  if( !empty( $item['field_options'] ) ) {
698  // Use settings_html from now on.
699  $item['settings_html'] = $item['field_options'];
700  }
701 
702  // Render a label for each of them
703  echo new GravityView_Admin_View_Field( $item['label_text'], $item['field_id'], $item, $settings = array(), $form );
704 
705  }
706 
707  }
708 
709  /**
710  * Retrieve the default fields id, label and type
711  * @param string|array $form form_ID or form object
712  * @param string $zone Either 'single', 'directory', 'header', 'footer'
713  * @return array
714  */
715  function get_entry_default_fields($form, $zone) {
716 
717  $entry_default_fields = array();
718 
719  if( in_array( $zone, array( 'directory', 'single' ) ) ) {
720 
721  $entry_default_fields = array(
722  'id' => array(
723  'label' => __('Entry ID', 'gravityview'),
724  'type' => 'id',
725  'desc' => __('The unique ID of the entry.', 'gravityview'),
726  ),
727  'date_created' => array(
728  'label' => __('Entry Date', 'gravityview'),
729  'desc' => __('The date the entry was created.', 'gravityview'),
730  'type' => 'date_created',
731  ),
732  'date_updated' => array(
733  'label' => __( 'Date Updated', 'gravityview'),
734  'desc' => __('The date the entry was last updated.', 'gravityview'),
735  'type' => 'date_updated',
736  ),
737  'source_url' => array(
738  'label' => __('Source URL', 'gravityview'),
739  'type' => 'source_url',
740  'desc' => __('The URL of the page where the form was submitted.', 'gravityview'),
741  ),
742  'ip' => array(
743  'label' => __('User IP', 'gravityview'),
744  'type' => 'ip',
745  'desc' => __('The IP Address of the user who created the entry.', 'gravityview'),
746  ),
747  'created_by' => array(
748  'label' => __('User', 'gravityview'),
749  'type' => 'created_by',
750  'desc' => __('Details of the logged-in user who created the entry (if any).', 'gravityview'),
751  ),
752 
753  /**
754  * @since 1.7.2
755  */
756  'other_entries' => array(
757  'label' => __('Other Entries', 'gravityview'),
758  'type' => 'other_entries',
759  'desc' => __('Display other entries created by the entry creator.', 'gravityview'),
760  ),
761  );
762 
763  if( 'single' !== $zone) {
764 
765  $entry_default_fields['entry_link'] = array(
766  'label' => __('Link to Entry', 'gravityview'),
767  'desc' => __('A dedicated link to the single entry with customizable text.', 'gravityview'),
768  'type' => 'entry_link',
769  );
770  }
771 
772  } // if not zone directory or single
773 
774  /**
775  * @since 1.2
776  */
777  $entry_default_fields['custom'] = array(
778  'label' => __('Custom Content', 'gravityview'),
779  'type' => 'custom',
780  'desc' => __('Insert custom text or HTML.', 'gravityview'),
781  );
782 
783  /**
784  * @since develop
785  */
786  $entry_default_fields['sequence'] = array(
787  'label' => __('Result Number', 'gravityview'),
788  'type' => 'sequence',
789  'desc' => __('Display a sequential result number for each entry.', 'gravityview'),
790  );
791 
792  /**
793  * @filter `gravityview_entry_default_fields` Modify the default fields for each zone and context
794  * @param array $entry_default_fields Array of fields shown by default
795  * @param string|array $form form_ID or form object
796  * @param string $zone Either 'single', 'directory', 'header', 'footer'
797  */
798  return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone);
799  }
800 
801  /**
802  * Calculate the available fields
803  * @param string|array $form form_ID or form object
804  * @param string $zone Either 'single', 'directory', 'header', 'footer'
805  * @return array fields
806  */
807  function get_available_fields( $form = '', $zone = NULL ) {
808 
809  if( empty( $form ) ) {
810  gravityview()->log->error( '$form is empty' );
811  return array();
812  }
813 
814  // get form fields
815  $fields = gravityview_get_form_fields( $form, true );
816 
817  // get meta fields ( only if form was already created )
818  if( !is_array( $form ) ) {
819  $meta_fields = gravityview_get_entry_meta( $form );
820  } else {
821  $meta_fields = array();
822  }
823 
824  // get default fields
825  $default_fields = $this->get_entry_default_fields( $form, $zone );
826 
827  //merge without loosing the keys
828  $fields = $fields + $meta_fields + $default_fields;
829 
830  // Move Custom Content to top
831  $fields = array( 'custom' => $fields['custom'] ) + $fields;
832 
833  /**
834  * @filter `gravityview/admin/available_fields` Modify the available fields that can be used in a View.
835  * @param[in,out] array $fields The fields.
836  * @param string|array $form form_ID or form object
837  * @param string $zone Either 'single', 'directory', 'header', 'footer'
838  */
839  return apply_filters( 'gravityview/admin/available_fields', $fields, $form, $zone );
840  }
841 
842 
843  /**
844  * Render html for displaying available widgets
845  * @return string html
846  */
848 
849  $widgets = $this->get_registered_widgets();
850 
851  if( !empty( $widgets ) ) {
852 
853  foreach( $widgets as $id => $details ) {
854 
855  echo new GravityView_Admin_View_Widget( $details['label'], $id, $details );
856 
857  }
858  }
859 
860  }
861 
862  /**
863  * Get the list of registered widgets. Each item is used to instantiate a GravityView_Admin_View_Widget object
864  * @deprecated Use \GV\Widget::registered()
865  * @since 1.13.1
866  * @return array
867  */
869  return \GV\Widget::registered();
870  }
871 
872  /**
873  * Generic function to render rows and columns of active areas for widgets & fields
874  * @param string $template_id The current slug of the selected View template
875  * @param string $type Either 'widget' or 'field'
876  * @param string $zone Either 'single', 'directory', 'edit', 'header', 'footer'
877  * @param array $rows The layout structure: rows, columns and areas
878  * @param array $values Saved objects
879  * @return void
880  */
881  function render_active_areas( $template_id, $type, $zone, $rows, $values ) {
882  global $post;
883 
884  if( $type === 'widget' ) {
885  $button_label = __( 'Add Widget', 'gravityview' );
886  } else {
887  $button_label = __( 'Add Field', 'gravityview' );
888  }
889 
890  /**
891  * @internal Don't rely on this filter! This is for internal use and may change.
892  *
893  * @since 2.8.1
894  *
895  * @param string $button_label Text for button: "Add Widget" or "Add Field"
896  * @param array $atts {
897  * @type string $type 'widget' or 'field'
898  * @type string $template_id The current slug of the selected View template
899  * @type string $zone Where is this button being shown? Either 'single', 'directory', 'edit', 'header', 'footer'
900  * }
901  */
902  $button_label = apply_filters( 'gravityview/admin/add_button_label', $button_label, array( 'type' => $type, 'template_id' => $template_id, 'zone' => $zone ) );
903 
904  $available_items = array();
905 
906  $view = \GV\View::from_post( $post );
907  $form_id = null;
908 
909  // if saved values, get available fields to label everyone
910  if( !empty( $values ) && ( !empty( $post->ID ) || !empty( $_POST['template_id'] ) ) ) {
911 
912  if( !empty( $_POST['template_id'] ) ) {
913  $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
914  } else {
915  $form_id = $form = gravityview_get_form_id( $post->ID );
916  }
917 
918  if ( 'field' === $type ) {
919  $available_items[ $form ] = $this->get_available_fields( $form, $zone );
920 
921  $joined_forms = gravityview_get_joined_forms( $post->ID );
922 
923  foreach ( $joined_forms as $form ) {
924  $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone );
925  }
926  } else {
927  $available_items[ $form ] = \GV\Widget::registered();
928  }
929  }
930 
931  foreach( $rows as $row ) :
932  foreach( $row as $col => $areas ) :
933  $column = ($col == '2-2') ? '1-2' : $col; ?>
934 
935  <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>">
936 
937  <?php foreach( $areas as $area ) : ?>
938 
939  <div class="gv-droppable-area" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>">
940  <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>">
941  <?php // render saved fields
942  if( ! empty( $values[ $zone .'_'. $area['areaid'] ] ) ) {
943 
944  foreach( $values[ $zone .'_'. $area['areaid'] ] as $uniqid => $field ) {
945 
946  // Maybe has a form ID
947  $form_id = empty( $field['form_id'] ) ? $form_id : $field['form_id'];
948 
949  $input_type = NULL;
950 
951  if ( $form_id ) {
952  $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ;
953  } else {
954  $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ;
955  }
956 
957  if ( !$original_item ) {
958  gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) );
959 
960  $original_item = $field;
961  } else {
962  $input_type = isset( $original_item['type'] ) ? $original_item['type'] : NULL;
963  }
964 
965  // Field options dialog box
966  $field_options = GravityView_Render_Settings::render_field_options( $form_id, $type, $template_id, $field['id'], $original_item['label'], $zone .'_'. $area['areaid'], $input_type, $uniqid, $field, $zone, $original_item );
967 
968  $item = array(
969  'input_type' => $input_type,
970  'settings_html' => $field_options,
971  'label_type' => $type,
972  );
973 
974  // Merge the values with the current item to pass things like widget descriptions and original field names
975  if ( $original_item ) {
976  $item = wp_parse_args( $item, $original_item );
977  }
978 
979  switch( $type ) {
980  case 'widget':
981  echo new GravityView_Admin_View_Widget( $item['label'], $field['id'], $item, $field );
982  break;
983  default:
984  echo new GravityView_Admin_View_Field( $field['label'], $field['id'], $item, $field, $form_id );
985  }
986  }
987 
988  } // End if zone is not empty ?>
989 
990  <span class="drop-message"><?php echo sprintf( esc_html__('"+ %s" or drag existing %ss here.', 'gravityview'), esc_html( $button_label ), esc_html( $type ) ); ?></span>
991  </div>
992  <div class="gv-droppable-area-action">
993  <button class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>" data-formid="<?php echo $view ? esc_attr( $view->form ? $view->form->ID : '' ) : ''; ?>"><?php echo '+ '.esc_html( $button_label ); ?></button>
994  <p class="gv-droppable-area-title"><strong><?php echo esc_html( $area['title'] ); ?></strong><?php if( !empty( $area['subtitle'] ) ) { ?><span class="gv-droppable-area-subtitle"> &ndash; <?php echo esc_html( $area['subtitle'] ); ?></span><?php } ?></p>
995  </div>
996  </div>
997 
998  <?php endforeach; ?>
999 
1000  </div>
1001  <?php endforeach;
1002  endforeach;
1003  }
1004 
1005  /**
1006  * Render the widget active areas
1007  * @param string $template_id The current slug of the selected View template
1008  * @param string $zone Either 'header' or 'footer'
1009  * @param string $post_id Current Post ID (view)
1010  * @return string html
1011  */
1012  function render_widgets_active_areas( $template_id = '', $zone = '', $post_id = '' ) {
1013 
1014  $default_widget_areas = \GV\Widget::get_default_widget_areas();
1015 
1016  $widgets = array();
1017  if ( ! empty( $post_id ) ) {
1018  if ( 'auto-draft' === get_post_status( $post_id ) ) {
1019  // This is a new View, prefill the widgets
1020  $widgets = array(
1021  'header_top' => array(
1022  substr( md5( microtime( true ) ), 0, 13 ) => array (
1023  'id' => 'search_bar',
1024  'label' => __( 'Search Bar', 'gravityview' ),
1025  'search_layout' => 'horizontal',
1026  'search_clear' => '0',
1027  'search_fields' => '[{"field":"search_all","input":"input_text"}]',
1028  'search_mode' => 'any',
1029  ),
1030  ),
1031  'header_left' => array(
1032  substr( md5( microtime( true ) ), 0, 13 ) => array(
1033  'id' => 'page_info',
1034  'label' => __( 'Show Pagination Info', 'gravityview' ),
1035  ),
1036  ),
1037  'header_right' => array(
1038  substr( md5( microtime( true ) ), 0, 13 ) => array(
1039  'id' => 'page_links',
1040  'label' => __( 'Page Links', 'gravityview' ),
1041  'show_all' => '0',
1042  ),
1043  ),
1044  'footer_right' => array(
1045  substr( md5( microtime( true ) ), 0, 13 ) => array(
1046  'id' => 'page_links',
1047  'label' => __( 'Page Links', 'gravityview' ),
1048  'show_all' => '0',
1049  ),
1050  ),
1051  );
1052 
1053  /**
1054  * @filter `gravityview/view/widgets/default` Modify the default widgets for new Views
1055  * @param[in,out] array $widgets A Widget configuration array
1056  * @param string $zone The widget zone that's being requested
1057  * @param int $post_id The auto-draft post ID
1058  */
1059  $widgets = apply_filters( 'gravityview/view/widgets/default', $widgets, $template_id, $zone, $post_id );
1060  } else {
1061  $widgets = gravityview_get_directory_widgets( $post_id );
1062  }
1063  }
1064 
1065  ob_start();
1066  ?>
1067 
1068  <div class="gv-grid" id="directory-<?php echo $zone; ?>-widgets">
1069  <?php $this->render_active_areas( $template_id, 'widget', $zone, $default_widget_areas, $widgets ); ?>
1070  </div>
1071 
1072  <?php
1073  $output = ob_get_clean();
1074 
1075  echo $output;
1076 
1077  return $output;
1078  }
1079 
1080  /**
1081  * Renders "Add Field" tooltips
1082  *
1083  * @since 2.0.11
1084  *
1085  * @param string $context "directory", "single", or "edit"
1086  * @param array $form_ids (default: array) Array of form IDs
1087  *
1088  * @return void
1089  */
1090  function render_field_pickers( $context = 'directory', $form_ids = array() ) {
1091 
1092  global $post;
1093 
1094  if ( $post ) {
1095  $source_form_id = gravityview_get_form_id( $post->ID );
1096  if ( $source_form_id ) {
1097  $form_ids[] = $source_form_id;
1098  }
1099 
1100  $joined_forms = \GV\View::get_joined_forms( $post->ID );
1101  foreach ( $joined_forms as $joined_form ) {
1102  $form_ids[] = $joined_form->ID;
1103  }
1104  }
1105  foreach ( array_unique( $form_ids ) as $form_id ) {
1106  $filter_field_id = sprintf( 'gv-field-filter-%s-%s', $context, $form_id );
1107 
1108  ?>
1109  <div id="<?php echo esc_html( $context ); ?>-available-fields-<?php echo esc_attr( $form_id ); ?>" class="hide-if-js gv-tooltip">
1110  <span class="close" role="button" aria-label="<?php esc_html_e( 'Close', 'gravityview' ); ?>"><i class="dashicons dashicons-dismiss"></i></span>
1111 
1112  <div class="gv-field-filter-form">
1113  <label class="screen-reader-text" for="<?php echo esc_html( $filter_field_id ); ?>"><?php esc_html_e( 'Filter Fields:', 'gravityview' ); ?></label>
1114  <input type="search" class="widefat gv-field-filter" aria-controls="<?php echo $filter_field_id; ?>" id="<?php echo esc_html( $filter_field_id ); ?>" placeholder="<?php esc_html_e( 'Filter fields by name or label', 'gravityview' ); ?>" />
1115  </div>
1116 
1117  <div id="available-fields-<?php echo $filter_field_id; ?>" aria-live="polite" role="listbox">
1118  <?php do_action( 'gravityview_render_available_fields', $form_id, $context ); ?>
1119  </div>
1120 
1121  <div class="gv-no-results hidden description"><?php esc_html_e( 'No fields were found matching the search.', 'gravityview' ); ?></div>
1122  </div>
1123  <?php
1124  }
1125  }
1126 
1127  /**
1128  * Render the Template Active Areas and configured active fields for a given template id and post id
1129  *
1130  * @param string $template_id (default: '') Template ID, like `default_list`, `default_table`, `preset_business_data`, etc. {@see GravityView_Template::__construct()}
1131  * @param string $post_id (default: '')
1132  * @param string $context (default: 'single')
1133  * @return string HTML of the active areas
1134  */
1135  function render_directory_active_areas( $template_id = '', $context = 'single', $post_id = '', $echo = false ) {
1136  if( empty( $template_id ) ) {
1137  gravityview()->log->debug( '[render_directory_active_areas] {template_id} is empty', array( 'template_id' => $template_id ) );
1138  return '';
1139  }
1140 
1141  /**
1142  * @filter `gravityview_template_active_areas`
1143  * @see GravityView_Template::assign_active_areas()
1144  * @param array $template_areas Empty array, to be filled in by the template class
1145  * @param string $template_id Template ID, like `default_list`, `default_table`, `preset_business_data`, etc. {@see GravityView_Template::__construct()}
1146  * @param string $context Current View context: `directory`, `single`, or `edit` (default: 'single')
1147  */
1148  $template_areas = apply_filters( 'gravityview_template_active_areas', array(), $template_id, $context );
1149 
1150  if( empty( $template_areas ) ) {
1151 
1152  gravityview()->log->debug( '[render_directory_active_areas] No areas defined. Maybe template {template_id} is disabled.', array( 'data' => $template_id ) );
1153  $output = '<div>';
1154  $output .= '<h2 class="description" style="font-size: 16px; margin:0">'. sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>'.$template_id.'</em>' ) .'</h2>';
1155  $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">'.esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview').'</p>';
1156  $output .= '</div>';
1157  } else {
1158 
1159  $fields = '';
1160  if ( ! empty( $post_id ) ) {
1161  $fields = gravityview_get_directory_fields( $post_id );
1162  }
1163 
1164  ob_start();
1165  $this->render_active_areas( $template_id, 'field', $context, $template_areas, $fields );
1166  $output = ob_get_clean();
1167 
1168  }
1169 
1170  if( $echo ) {
1171  echo $output;
1172  }
1173 
1174  return $output;
1175  }
1176 
1177  /**
1178  * Enqueue scripts and styles at Views editor
1179  *
1180  * @param mixed $hook
1181  * @return void
1182  */
1183  static function add_scripts_and_styles( $hook ) {
1184  global $plugin_page, $pagenow;
1185 
1186  $is_widgets_page = ( $pagenow === 'widgets.php' );
1187 
1188  // Add the GV font (with the Astronaut)
1189  wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version );
1190  wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version );
1191 
1192  wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true );
1193 
1194  if( GFForms::get_page() === 'form_list' ) {
1195  wp_enqueue_style( 'gravityview_views_styles' );
1196  return;
1197  }
1198 
1199  // Don't process any scripts below here if it's not a GravityView page.
1200  if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) {
1201  return;
1202  }
1203 
1204  wp_enqueue_script( 'jquery-ui-datepicker' );
1205  wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version );
1206 
1207  $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
1208 
1209  //enqueue scripts
1210  wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version );
1211 
1212  wp_localize_script('gravityview_views_scripts', 'gvGlobals', array(
1213  'cookiepath' => COOKIEPATH,
1214  'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ),
1215  'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ),
1216  'label_viewname' => __( 'Enter View name here', 'gravityview' ),
1217  'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ),
1218  'label_add_search_field' => __( 'Add Search Field', 'gravityview' ),
1219  'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ),
1220  'label_close' => __( 'Close', 'gravityview' ),
1221  'label_cancel' => __( 'Cancel', 'gravityview' ),
1222  'label_continue' => __( 'Continue', 'gravityview' ),
1223  'label_ok' => __( 'Ok', 'gravityview' ),
1224  'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ),
1225  'loading_text' => esc_html__( 'Loading&hellip;', 'gravityview' ),
1226  'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ),
1227  'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ),
1228  'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ),
1229  ));
1230 
1231  wp_enqueue_style( 'gravityview_views_styles' );
1232 
1233  // Enqueue scripts needed for merge tags
1234  self::enqueue_gravity_forms_scripts();
1235  }
1236 
1237  /**
1238  * Enqueue Gravity Forms scripts, needed for Merge Tags
1239  *
1240  * @since 1.0.5-beta
1241  *
1242  * @return void
1243  */
1244  static function enqueue_gravity_forms_scripts() {
1245  GFForms::register_scripts();
1246 
1247  $scripts = array(
1248  'sack',
1249  'gform_gravityforms',
1250  'gform_forms',
1251  'gform_form_admin',
1252  'jquery-ui-autocomplete'
1253  );
1254 
1255  if ( wp_is_mobile() ) {
1256  $scripts[] = 'jquery-touch-punch';
1257  }
1258 
1259  wp_enqueue_script( $scripts );
1260  }
1261 
1262  /**
1263  * Add GravityView scripts and styles to Gravity Forms and GravityView No-Conflict modes
1264  *
1265  * @param array $registered Existing scripts or styles that have been registered (array of the handles)
1266  *
1267  * @return array
1268  */
1269  function register_no_conflict( $registered ) {
1270 
1271  $allowed_dependencies = array();
1272 
1273  $filter = current_filter();
1274 
1275  if ( preg_match( '/script/ism', $filter ) ) {
1276 
1277  $allowed_dependencies = array(
1278  'jquery-ui-core',
1279  'jquery-ui-dialog',
1280  'jquery-ui-tabs',
1281  'jquery-ui-draggable',
1282  'jquery-ui-droppable',
1283  'jquery-ui-sortable',
1284  'jquery-ui-tooltip',
1285  'gravityview_views_scripts',
1286  'gravityview-support',
1287  'gravityview-jquery-cookie',
1288  'gravityview_views_datepicker',
1289  'sack',
1290  'gform_gravityforms',
1291  'gform_forms',
1292  'gform_form_admin',
1293  'jquery-ui-autocomplete'
1294  );
1295 
1296  } elseif ( preg_match( '/style/ism', $filter ) ) {
1297 
1298  $allowed_dependencies = array(
1299  'dashicons',
1300  'wp-jquery-ui-dialog',
1301  'gravityview_views_styles',
1302  'gravityview_global',
1303  'gravityview_views_datepicker'
1304  );
1305  }
1306 
1307  return array_merge( $registered, $allowed_dependencies );
1308  }
1309 
1310 
1311 }
1312 
static _GET( $name, $default=null)
Grab a value from the _GET superglobal or default.
$forms
Definition: data-source.php:19
global $post
Definition: edit-entry.php:7
filter_pre_get_posts_by_gravityview_form_id(&$query)
gravityview_set_directory_widgets( $post_id, $widgets=array())
Set the widgets, as configured for a View.
static render_field_options( $form_id, $field_type, $template_id, $field_id, $field_label, $area, $input_type=NULL, $uniqid='', $current='', $context='single', $item=array())
Render Field Options html (shown through a dialog box)
get_entry_default_fields($form, $zone)
Retrieve the default fields id, label and type.
static registered()
Return all registered widgets.
if(! isset( $gravityview)||empty( $gravityview->template)) $template
The entry loop for the list output.
suggest_support_articles( $localization_data=array())
When on the Add/Edit View screen, suggest most popular articles related to that.
gravityview_get_directory_fields( $post_id, $apply_filter=true)
Get the field configuration for the View.
static render_setting_row( $key='', $current_settings=array(), $override_input=null, $name='template_settings[%s]', $id='gravityview_se_%s')
Output a table row for view settings.
gravityview_get_entry_meta( $form_id, $only_default_column=true)
get extra fields from entry meta
static gform_toolbar_menu( $menu_items=array(), $id=NULL)
Add a GravityView menu to the Form Toolbar with connected views.
static get_connected_form_links( $form, $include_form_link=true)
Get HTML links relating to a connected form, like Edit, Entries, Settings, Preview.
gravityview_get_form( $form_id)
Returns the form object for a given Form ID.
gravityview_get_directory_widgets( $post_id)
Get the widgets, as configured for a View.
static get_default_widget_areas()
Default widget areas.
tooltips( $tooltips=array())
Add tooltip text for use throughout the UI.
gravityview()
Definition: _stubs.php:26
$templates
add_custom_column_content( $column_name=NULL, $post_id)
Add the Data Source information.
If this file is called directly, abort.
render_widgets_active_areas( $template_id='', $zone='', $post_id='')
Render the widget active areas.
gravityview_get_forms( $active=true, $trash=false, $order_by='date_created', $order='ASC')
Alias of GFAPI::get_forms()
new GravityView_Admin_Views
static render_field_option( $name='', $option, $curr_value=NULL)
render_active_areas( $template_id, $type, $zone, $rows, $values)
Generic function to render rows and columns of active areas for widgets & fields. ...
render_directory_active_areas( $template_id='', $context='single', $post_id='', $echo=false)
Render the Template Active Areas and configured active fields for a given template id and post id...
gravityview_get_form_fields( $form='', $add_default_properties=false, $include_parent_field=true)
Return array of fields&#39; id and label, for a given Form ID.
static render_setting_row( $key='', $current_settings=array(), $override_input=null, $name='template_settings[%s]', $id='gravityview_se_%s')
static pre_get_form_fields( $template_id='')
Get the the form fields for a preset (no form created yet)
Definition: class-ajax.php:317
register_no_conflict( $registered)
Add GravityView scripts and styles to Gravity Forms and GravityView No-Conflict modes.
gravityview_get_connected_views( $form_id, $args=array())
Get the views for a particular form.
$current_settings
Definition: edit-entry.php:10
gravityview_get_form_id( $view_id)
Get the connected form ID from a View ID.
add_post_type_columns( $columns)
Add the Data Source column to the Views page.
get_registered_widgets()
Get the list of registered widgets.
const GRAVITYVIEW_FILE
Full path to the GravityView file "GRAVITYVIEW_FILE" "./gravityview.php".
Definition: gravityview.php:31
gravityview_get_registered_templates()
Get all available preset templates.
render_field_pickers( $context='directory', $form_ids=array())
Renders "Add Field" tooltips.
if(empty( $field_settings['email_field'])) $settings
default_field_blacklist( $array=array(), $context=NULL)
List the field types without presentation properties (on a View context)
if(empty( $created_by)) $form_id
_gravityview_process_posted_fields()
Maybe convert jQuery-serialized fields into array, otherwise return $_POST[&#39;fields&#39;] array...
render_available_widgets()
Render html for displaying available widgets.
gravityview_get_template_id( $post_id)
Get the template ID (list, table, datatables, map) for a View.
static get_joined_forms( $post_id)
Get joined forms associated with a view In no particular order.
static defaults( $detailed=false, $group=null)
Retrieve the default View settings.
gravityview_get_joined_forms( $view_id)
Get joined forms associated with a view.
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
static add_scripts_and_styles( $hook)
Enqueue scripts and styles at Views editor.
get_available_fields( $form='', $zone=NULL)
Calculate the available fields.
$current_form
Definition: data-source.php:13
static enqueue_gravity_forms_scripts()
Enqueue Gravity Forms scripts, needed for Merge Tags.
static render_field_option( $name='', $option=array(), $curr_value=NULL)
Handle rendering a field option form element.
static from_post( $post)
Construct a instance from a .
render_available_fields( $form=0, $context='single')
Render html for displaying available fields based on a Form ID.
$field
Definition: gquiz_grade.php:11
save_postdata( $post_id)
Save View configuration.
render_additional_fields( $form=0, $context='single')
Render html for displaying additional fields based on a Form ID.
$title