GravityView  1.22.6
The best, easiest way to display Gravity Forms entries on your website.
class-api.php
Go to the documentation of this file.
1 <?php
2 /**
3  * GravityView template tags API
4  *
5  * @package GravityView
6  * @license GPL2+
7  * @author Katz Web Services, Inc.
8  * @link http://gravityview.co
9  * @copyright Copyright 2014, Katz Web Services, Inc.
10  *
11  * @since 1.0.0
12  */
13 
15 
16  /**
17  * Fetch Field Label
18  *
19  * @access public
20  * @static
21  * @param array $field GravityView field array
22  * @param array $entry Gravity Forms entry array
23  * @param boolean $force_show_label Whether to always show the label, regardless of field settings
24  * @return string
25  */
26  public static function field_label( $field, $entry = array(), $force_show_label = false ) {
28 
29  $form = $gravityview_view->getForm();
30 
31  $label = '';
32 
33  if( !empty( $field['show_label'] ) || $force_show_label ) {
34 
35  $label = $field['label'];
36 
37  // Support Gravity Forms 1.9+
38  if( class_exists( 'GF_Field' ) ) {
39 
40  $field_object = RGFormsModel::get_field( $form, $field['id'] );
41 
42  if( $field_object ) {
43 
44  $input = GFFormsModel::get_input( $field_object, $field['id'] );
45 
46  // This is a complex field, with labels on a per-input basis
47  if( $input ) {
48 
49  // Does the input have a custom label on a per-input basis? Otherwise, default label.
50  $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label'];
51 
52  } else {
53 
54  // This is a field with one label
55  $label = $field_object->get_field_label( true, $field['label'] );
56 
57  }
58 
59  }
60 
61  }
62 
63  // Use Gravity Forms label by default, but if a custom label is defined in GV, use it.
64  if ( !empty( $field['custom_label'] ) ) {
65 
66  $label = self::replace_variables( $field['custom_label'], $form, $entry );
67 
68  }
69 
70  /**
71  * @filter `gravityview_render_after_label` Append content to a field label
72  * @param[in,out] string $appended_content Content you can add after a label. Empty by default.
73  * @param[in] array $field GravityView field array
74  */
75  $label .= apply_filters( 'gravityview_render_after_label', '', $field );
76 
77  } // End $field['show_label']
78 
79  /**
80  * @filter `gravityview/template/field_label` Modify field label output
81  * @since 1.7
82  * @param[in,out] string $label Field label HTML
83  * @param[in] array $field GravityView field array
84  * @param[in] array $form Gravity Forms form array
85  * @param[in] array $entry Gravity Forms entry array
86  */
87  $label = apply_filters( 'gravityview/template/field_label', $label, $field, $form, $entry );
88 
89  return $label;
90  }
91 
92  /**
93  * Alias for GravityView_Merge_Tags::replace_variables()
94  *
95  * @see GravityView_Merge_Tags::replace_variables() Moved in 1.8.4
96  * @since 1.22.4 - Added $nl2br, $format, $aux_data args
97  *
98  * @param string $text Text to replace variables in
99  * @param array $form GF Form array
100  * @param array $entry GF Entry array
101  * @param bool $url_encode Pass return value through `url_encode()`
102  * @param bool $esc_html Pass return value through `esc_html()`
103  * @param bool $nl2br Convert newlines to <br> HTML tags
104  * @param string $format The format requested for the location the merge is being used. Possible values: html, text or url.
105  * @param array $aux_data Additional data to be used to replace merge tags {@see https://www.gravityhelp.com/documentation/article/gform_merge_tag_data/}
106  * @return string Text with variables maybe replaced
107  */
108  public static function replace_variables( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true, $nl2br = true, $format = 'html', $aux_data = array() ) {
109  return GravityView_Merge_Tags::replace_variables( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format, $aux_data );
110  }
111 
112  /**
113  * Get column width from the field setting
114  *
115  * @since 1.9
116  *
117  * @param array $field Array of settings for the field
118  * @param string $format Format for width. "%" (default) will return
119  *
120  * @return string|null If not empty, string in $format format. Otherwise, null.
121  */
122  public static function field_width( $field, $format = '%d%%' ) {
123 
124  $width = NULL;
125 
126  if( !empty( $field['width'] ) ) {
127  $width = absint( $field['width'] );
128 
129  // If using percentages, limit to 100%
130  if( '%d%%' === $format && $width > 100 ) {
131  $width = 100;
132  }
133 
134  $width = sprintf( $format, $width );
135  }
136 
137  return $width;
138  }
139 
140  /**
141  * Fetch Field class
142  *
143  * @access public
144  * @static
145  * @param mixed $field
146  * @return string
147  */
148  public static function field_class( $field, $form = NULL, $entry = NULL ) {
150 
151  $classes = array();
152 
153  if( !empty( $field['custom_class'] ) ) {
154 
155  $custom_class = $field['custom_class'];
156 
157  if( !empty( $entry ) ) {
158 
159  // We want the merge tag to be formatted as a class. The merge tag may be
160  // replaced by a multiple-word value that should be output as a single class.
161  // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
162  add_filter('gform_merge_tag_filter', 'sanitize_html_class');
163 
164  $custom_class = self::replace_variables( $custom_class, $form, $entry);
165 
166  // And then we want life to return to normal
167  remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
168  }
169 
170  // And now we want the spaces to be handled nicely.
171  $classes[] = gravityview_sanitize_html_class( $custom_class );
172 
173  }
174 
175  if(!empty($field['id'])) {
176  if( !empty( $form ) && !empty( $form['id'] ) ) {
177  $form_id = '-'.$form['id'];
178  } else {
179  $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : '';
180  }
181 
182  $classes[] = 'gv-field'.$form_id.'-'.$field['id'];
183  }
184 
185  return esc_attr(implode(' ', $classes));
186  }
187 
188  /**
189  * Fetch Field HTML ID
190  *
191  * @since 1.11
192  *
193  * @access public
194  * @static
195  * @param array $field GravityView field array passed to gravityview_field_output()
196  * @param array $form Gravity Forms form array, if set.
197  * @param array $entry Gravity Forms entry array
198  * @return string Sanitized unique HTML `id` attribute for the field
199  */
200  public static function field_html_attr_id( $field, $form = array(), $entry = array() ) {
202  $id = $field['id'];
203 
204  if ( ! empty( $id ) ) {
205  if ( ! empty( $form ) && ! empty( $form['id'] ) ) {
206  $form_id = '-' . $form['id'];
207  } else {
208  $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : '';
209  }
210 
211  $id = 'gv-field' . $form_id . '-' . $field['id'];
212  }
213 
214  return esc_attr( $id );
215  }
216 
217 
218  /**
219  * Given an entry and a form field id, calculate the entry value for that field.
220  *
221  * @access public
222  * @param array $entry
223  * @param array $field
224  * @return null|string
225  */
226  public static function field_value( $entry, $field_settings, $format = 'html' ) {
227 
228  if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) {
229  return NULL;
230  }
231 
233 
234  $field_id = $field_settings['id'];
235  $form = $gravityview_view->getForm();
237 
238  if( $field && is_numeric( $field_id ) ) {
239  // Used as file name of field template in GV.
240  // Don't use RGFormsModel::get_input_type( $field ); we don't care if it's a radio input; we want to know it's a 'quiz' field
241  $field_type = $field->type;
242  $value = RGFormsModel::get_lead_field_value( $entry, $field );
243  } else {
245  $field_type = $field_id; // Used as file name of field template in GV
246  }
247 
248  // If a Gravity Forms Field is found, get the field display
249  if( $field ) {
250 
251  // Prevent any PHP warnings that may be generated
252  ob_start();
253 
254  $display_value = GFCommon::get_lead_field_display( $field, $value, $entry["currency"], false, $format );
255 
256  if ( $errors = ob_get_clean() ) {
257  do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors );
258  }
259 
260  $display_value = apply_filters( "gform_entry_field_value", $display_value, $field, $entry, $form );
261 
262  // prevent the use of merge_tags for non-admin fields
263  if( !empty( $field->adminOnly ) ) {
264  $display_value = self::replace_variables( $display_value, $form, $entry );
265  }
266  } else {
267  $value = $display_value = rgar( $entry, $field_id );
268  $display_value = $value;
269  }
270 
271  // Check whether the field exists in /includes/fields/{$field_type}.php
272  // This can be overridden by user template files.
273  $field_path = $gravityview_view->locate_template("fields/{$field_type}.php");
274 
275  // Set the field data to be available in the templates
276  $gravityview_view->setCurrentField( array(
277  'form' => $form,
278  'field_id' => $field_id,
279  'field' => $field,
280  'field_settings' => $field_settings,
281  'value' => $value,
282  'display_value' => $display_value,
283  'format' => $format,
284  'entry' => $entry,
285  'field_type' => $field_type, /** {@since 1.6} */
286  'field_path' => $field_path, /** {@since 1.16} */
287  ));
288 
289  if( ! empty( $field_path ) ) {
290 
291  do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path ) );
292 
293  ob_start();
294 
295  load_template( $field_path, false );
296 
297  $output = ob_get_clean();
298 
299  } else {
300 
301  // Backup; the field template doesn't exist.
302  $output = $display_value;
303 
304  }
305 
306  // Get the field settings again so that the field template can override the settings
307  $field_settings = $gravityview_view->getCurrentField('field_settings');
308 
309  /**
310  * @filter `gravityview_field_entry_value_{$field_type}_pre_link` Modify the field value output for a field type before Show As Link setting is applied. Example: `gravityview_field_entry_value_number_pre_link`
311  * @since 1.16
312  * @param string $output HTML value output
313  * @param array $entry The GF entry array
314  * @param array $field_settings Settings for the particular GV field
315  * @param array $field Field array, as fetched from GravityView_View::getCurrentField()
316  */
317  $output = apply_filters( 'gravityview_field_entry_value_' . $field_type . '_pre_link', $output, $entry, $field_settings, $gravityview_view->getCurrentField() );
318 
319  /**
320  * @filter `gravityview_field_entry_value_pre_link` Modify the field value output for a field before Show As Link setting is applied. Example: `gravityview_field_entry_value_pre_link`
321  * @since 1.21.4
322  * @used-by GV_Inline_Edit
323  * @param string $output HTML value output
324  * @param array $entry The GF entry array
325  * @param array $field_settings Settings for the particular GV field
326  * @param array $field Field array, as fetched from GravityView_View::getCurrentField()
327  */
328  $output = apply_filters( 'gravityview_field_entry_value_pre_link', $output, $entry, $field_settings, $gravityview_view->getCurrentField() );
329 
330  /**
331  * Link to the single entry by wrapping the output in an anchor tag
332  *
333  * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example.
334  *
335  */
336  if( !empty( $field_settings['show_as_link'] ) && ! gv_empty( $output, false, false ) ) {
337 
338  $link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' );
339 
340  $output = self::entry_link_html( $entry, $output, $link_atts, $field_settings );
341 
342  }
343 
344  /**
345  * @filter `gravityview_field_entry_value_{$field_type}` Modify the field value output for a field type. Example: `gravityview_field_entry_value_number`
346  * @since 1.6
347  * @param string $output HTML value output
348  * @param array $entry The GF entry array
349  * @param array $field_settings Settings for the particular GV field
350  * @param array $field Current field being displayed
351  */
352  $output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() );
353 
354  /**
355  * @filter `gravityview_field_entry_value` Modify the field value output for all field types
356  * @param string $output HTML value output
357  * @param array $entry The GF entry array
358  * @param array $field_settings Settings for the particular GV field
359  * @param array $field_data {@since 1.6}
360  */
361  $output = apply_filters( 'gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField() );
362 
363  return $output;
364  }
365 
366  /**
367  * Generate an anchor tag that links to an entry.
368  *
369  * @since 1.6
370  * @see GVCommon::get_link_html()
371  *
372  * @param string $anchor_text The text or HTML inside the link
373  * @param array $entry Gravity Forms entry array
374  * @param array|string $passed_tag_atts Attributes to be added to the anchor tag, such as `title` or `rel`.
375  * @param array $field_settings Array of field settings. Optional, but passed to the `gravityview_field_entry_link` filter
376  *
377  * @return string|null Returns HTML for an anchor link. Null if $entry isn't defined or is missing an ID.
378  */
379  public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) {
380 
381  if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) {
382  do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry );
383  return NULL;
384  }
385 
386  $href = self::entry_link( $entry );
387 
388  if( '' === $href ) {
389  return NULL;
390  }
391 
392  $link = gravityview_get_link( $href, $anchor_text, $passed_tag_atts );
393 
394  /**
395  * @filter `gravityview_field_entry_link` Modify the link HTML
396  * @param string $link HTML output of the link
397  * @param string $href URL of the link
398  * @param array $entry The GF entry array
399  * @param array $field_settings Settings for the particular GV field
400  */
401  $output = apply_filters( 'gravityview_field_entry_link', $link, $href, $entry, $field_settings );
402 
403  return $output;
404  }
405 
406  /**
407  * Get the "No Results" text depending on whether there were results.
408  * @param boolean $wpautop Apply wpautop() to the output?
409  * @return string HTML of "no results" text
410  */
411  public static function no_results($wpautop = true) {
413 
414  $is_search = false;
415 
416  if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) {
417  $is_search = true;
418  }
419 
420  if($is_search) {
421  $output = __('This search returned no results.', 'gravityview');
422  } else {
423  $output = __('No entries match your request.', 'gravityview');
424  }
425 
426  /**
427  * @filter `gravitview_no_entries_text` Modify the text displayed when there are no entries.
428  * @param string $output The existing "No Entries" text
429  * @param boolean $is_search Is the current page a search result, or just a multiple entries screen?
430  */
431  $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search);
432 
433  return $wpautop ? wpautop($output) : $output;
434  }
435 
436  /**
437  * Generate a URL to the Directory context
438  *
439  * Uses `wp_cache_get` and `wp_cache_get` (since 1.3) to speed up repeated requests to get permalink, which improves load time. Since we may be doing this hundreds of times per request, it adds up!
440  *
441  * @param int $post_id Post ID
442  * @param boolean $add_query_args Add pagination and sorting arguments
443  * @return string Permalink to multiple entries view
444  */
445  public static function directory_link( $post_id = NULL, $add_query_args = true ) {
446  global $post;
447 
449 
450  if( empty( $post_id ) ) {
451 
452  $post_id = false;
453 
454  // DataTables passes the Post ID
455  if( defined('DOING_AJAX') && DOING_AJAX ) {
456 
457  $post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false;
458 
459  } else {
460 
461  // The Post ID has been passed via the shortcode
462  if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) {
463 
464  $post_id = $gravityview_view->getPostId();
465 
466  } else {
467 
468  // This is a GravityView post type
469  if( GravityView_frontend::getInstance()->isGravityviewPostType() ) {
470 
471  $post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID;
472 
473  } else {
474 
475  // This is an embedded GravityView; use the embedded post's ID as the base.
476  if( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) {
477 
478  $post_id = $post->ID;
479 
480  } elseif( $gravityview_view->getViewId() ) {
481 
482  // The GravityView has been embedded in a widget or in a template, and
483  // is not in the current content. Thus, we defer to the View's own ID.
484  $post_id = $gravityview_view->getViewId();
485 
486  }
487 
488  }
489 
490  }
491  }
492  }
493 
494  // No post ID, get outta here.
495  if( empty( $post_id ) ) {
496  return NULL;
497  }
498 
499  // If we've saved the permalink in memory, use it
500  // @since 1.3
501  $link = wp_cache_get( 'gv_directory_link_'.$post_id );
502 
503  if( (int) $post_id === (int) get_option( 'page_on_front' ) ) {
504  $link = home_url();
505  }
506 
507  if( empty( $link ) ) {
508 
509  $link = get_permalink( $post_id );
510 
511  // If not yet saved, cache the permalink.
512  // @since 1.3
513  wp_cache_set( 'gv_directory_link_'.$post_id, $link );
514 
515  }
516 
517  // Deal with returning to proper pagination for embedded views
518  if( $link && $add_query_args ) {
519 
520  $args = array();
521 
522  if( $pagenum = rgget('pagenum') ) {
523  $args['pagenum'] = intval( $pagenum );
524  }
525 
526  if( $sort = rgget('sort') ) {
527  $args['sort'] = $sort;
528  $args['dir'] = rgget('dir');
529  }
530 
531  $link = add_query_arg( $args, $link );
532  }
533 
534  /**
535  * @filter `gravityview_directory_link` Modify the URL to the View "directory" context
536  * @since 1.19.4
537  * @param string $link URL to the View's "directory" context (Multiple Entries screen)
538  * @param int $post_id ID of the post to link to. If the View is embedded, it is the post or page ID
539  */
540  $link = apply_filters( 'gravityview_directory_link', $link, $post_id );
541 
542  return $link;
543  }
544 
545  /**
546  * Calculate an *unique* hash for an entry based on the entry ID
547  *
548  * This allows you to be more discrete as to the number of the entry - if you don't want users to know that you have made a certain number of sales, for example, or that their entry in the giveaway is entry #3.
549  *
550  * The hashed value MUST be unique, otherwise multiple entries will share the same URL, which leads to obvious problems.
551  *
552  * @param int|string $id Entry ID to generate the hash for.
553  * @param array $entry Entry data passed to provide additional information when generating the hash. Optional - don't rely on it being available.
554  * @return string Hashed unique value for entry
555  */
556  private static function get_custom_entry_slug( $id, $entry = array() ) {
557 
558  // Generate an unique hash to use as the default value
559  $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 );
560 
561  /**
562  * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}`
563  * @param string $hash Existing hash generated by GravityView
564  * @param string $id The entry ID
565  * @param array $entry Entry data array. May be empty.
566  */
567  $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry );
568 
569  // Make sure we have something - use the original ID as backup.
570  if( empty( $slug ) ) {
571  $slug = $id;
572  }
573 
574  return sanitize_title( $slug );
575  }
576 
577  /**
578  * Get the entry slug for the entry. By default, it is the entry ID.
579  *
580  *
581  * @see gravityview_get_entry()
582  * @uses GravityView_API::get_custom_entry_slug() If using custom slug, gets the custom slug value
583  * @since 1.4
584  * @param int|string $id_or_string ID of the entry, or custom slug string
585  * @param array $entry Gravity Forms Entry array, optional. Used only to provide data to customize the `gravityview_entry_slug` filter
586  * @return string Unique slug ID, passed through `sanitize_title()`
587  */
588  public static function get_entry_slug( $id_or_string, $entry = array() ) {
589 
590  /**
591  * Default: use the entry ID as the unique identifier
592  */
593  $slug = $id_or_string;
594 
595  /**
596  * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs.
597  * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default)
598  */
599  $custom = apply_filters('gravityview_custom_entry_slug', false );
600 
601  // If we're using custom slug...
602  if ( $custom ) {
603 
604  // Get the entry hash
605  $hash = self::get_custom_entry_slug( $id_or_string, $entry );
606 
607  // See if the entry already has a hash set
608  $value = gform_get_meta( $id_or_string, 'gravityview_unique_id' );
609 
610  // If it does have a hash set, and the hash is expected, use it.
611  // This check allows users to change the hash structure using the
612  // gravityview_entry_hash filter and have the old hashes expire.
613  if( empty( $value ) || $value !== $hash ) {
614  do_action( 'gravityview_log_debug', __METHOD__ . ' - Setting hash for entry "'.$id_or_string.'": ' . $hash );
615  gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash, rgar( $entry, 'form_id' ) );
616  }
617 
618  $slug = $hash;
619 
620  unset( $value, $hash );
621  }
622 
623  return sanitize_title( $slug );
624  }
625 
626  /**
627  * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta
628  *
629  * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
630  *
631  * @param $entry array Gravity Forms entry object
632  * @param $form array Gravity Forms form object
633  */
634  public static function entry_create_custom_slug( $entry, $form ) {
635  /**
636  * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta
637  * @param boolean $custom Should we process the custom entry slug?
638  */
639  $custom = apply_filters( 'gravityview_custom_entry_slug', false );
640  if( $custom ) {
641  // create the gravityview_unique_id and save it
642 
643  // Get the entry hash
644  $hash = self::get_custom_entry_slug( $entry['id'], $entry );
645 
646  do_action( 'gravityview_log_debug', __METHOD__ . ' - Setting hash for entry "'.$entry['id'].'": ' . $hash );
647 
648  gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash, rgar( $entry, 'form_id' ) );
649 
650  }
651  }
652 
653 
654 
655 
656  /**
657  * return href for single entry
658  * @param array|int $entry Entry array or entry ID
659  * @param int|null $post_id If wanting to define the parent post, pass a post ID
660  * @param boolean $add_directory_args True: Add args to help return to directory; False: only include args required to get to entry {@since 1.7.3}
661  * @return string Link to the entry with the directory parent slug
662  */
663  public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) {
664 
665  if( ! empty( $entry ) && ! is_array( $entry ) ) {
667  } else if( empty( $entry ) ) {
669  }
670 
671  // Second parameter used to be passed as $field; this makes sure it's not an array
672  if( !is_numeric( $post_id ) ) {
673  $post_id = NULL;
674  }
675 
676  // Get the permalink to the View
677  $directory_link = self::directory_link( $post_id, false );
678 
679  // No post ID? Get outta here.
680  if( empty( $directory_link ) ) {
681  return '';
682  }
683 
684  if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
685  $query_arg_name = \GV\Entry::get_endpoint_name();
686  } else {
687  /** Deprecated. Use \GV\Entry::get_endpoint_name instead. */
688  $query_arg_name = GravityView_Post_Types::get_entry_var_name();
689  }
690 
691  $entry_slug = self::get_entry_slug( $entry['id'], $entry );
692 
693  if( get_option('permalink_structure') && !is_preview() ) {
694 
695  $args = array();
696 
697  /**
698  * Make sure the $directory_link doesn't contain any query otherwise it will break when adding the entry slug.
699  * @since 1.16.5
700  */
701  $link_parts = explode( '?', $directory_link );
702 
703  $query = !empty( $link_parts[1] ) ? '?'.$link_parts[1] : '';
704 
705  $directory_link = trailingslashit( $link_parts[0] ) . $query_arg_name . '/'. $entry_slug .'/' . $query;
706 
707  } else {
708 
709  $args = array( $query_arg_name => $entry_slug );
710  }
711 
712  /**
713  * @since 1.7.3
714  */
715  if( $add_directory_args ) {
716 
717  if( !empty( $_GET['pagenum'] ) ) {
718  $args['pagenum'] = intval( $_GET['pagenum'] );
719  }
720 
721  /**
722  * @since 1.7
723  */
724  if( $sort = rgget('sort') ) {
725  $args['sort'] = $sort;
726  $args['dir'] = rgget('dir');
727  }
728 
729  }
730 
731  /**
732  * Check if we have multiple views embedded in the same page and in that case make sure the single entry link
733  * has the view id so that Advanced Filters can be applied correctly when rendering the single view
734  * @see GravityView_frontend::get_context_view_id()
735  */
736  if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
737  if ( gravityview()->views->count() > 1 ) {
738  $args['gvid'] = gravityview_get_view_id();
739  }
740  } else {
741  /** Deprecated, do not use has_multiple_views(), please. */
742  if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) {
743  $args['gvid'] = gravityview_get_view_id();
744  }
745  }
746 
747  return add_query_arg( $args, $directory_link );
748 
749  }
750 
751 
752 }
753 
754 
755 // inside loop functions
756 
757 function gv_label( $field, $entry = NULL ) {
759 }
760 
761 function gv_class( $field, $form = NULL, $entry = array() ) {
763 }
764 
765 /**
766  * Generate a CSS class to be added to the wrapper <div> of a View
767  *
768  * @since 1.5.4
769  * @since 1.16 Added $echo param
770  *
771  * @param string $passed_css_class Default: `gv-container gv-container-{view id}`. If View is hidden until search, adds ` hidden`
772  * @param boolean $echo Whether to echo the output. Default: true
773  *
774  * @return string CSS class, sanitized by gravityview_sanitize_html_class()
775  */
776 function gv_container_class( $passed_css_class = '', $echo = true ) {
777 
778  $passed_css_class = trim( $passed_css_class );
779 
780  $view_id = GravityView_View::getInstance()->getViewId();
781 
782  $default_css_class = ! empty( $view_id ) ? sprintf( 'gv-container gv-container-%d', $view_id ) : 'gv-container';
783 
784  if( GravityView_View::getInstance()->isHideUntilSearched() ) {
785  $default_css_class .= ' hidden';
786  }
787 
788  if( 0 === GravityView_View::getInstance()->getTotalEntries() ) {
789  $default_css_class .= ' gv-container-no-results';
790  }
791 
792  $css_class = trim( $passed_css_class . ' '. $default_css_class );
793 
794  /**
795  * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View
796  * @since 1.5.4
797  * @param[in,out] string $css_class Default: `gv-container gv-container-{view id}`. If View is hidden until search, adds ` hidden`. If the View has no results, adds `gv-container-no-results`
798  */
799  $css_class = apply_filters( 'gravityview/render/container/class', $css_class );
800 
801  $css_class = gravityview_sanitize_html_class( $css_class );
802 
803  if( $echo ) {
804  echo $css_class;
805  }
806 
807  return $css_class;
808 }
809 
810 function gv_value( $entry, $field ) {
811 
813 
814  if( $value === '' ) {
815  /**
816  * @filter `gravityview_empty_value` What to display when a field is empty
817  * @param string $value (empty string)
818  */
819  $value = apply_filters( 'gravityview_empty_value', '' );
820  }
821 
822  return $value;
823 }
824 
825 function gv_directory_link( $post = NULL, $add_pagination = true ) {
826  return GravityView_API::directory_link( $post, $add_pagination );
827 }
828 
829 function gv_entry_link( $entry, $post_id = NULL ) {
830  return GravityView_API::entry_link( $entry, $post_id );
831 }
832 
833 function gv_no_results($wpautop = true) {
834  return GravityView_API::no_results( $wpautop );
835 }
836 
837 /**
838  * Generate HTML for the back link from single entry view
839  * @since 1.0.1
840  * @return string|null If no GV post exists, null. Otherwise, HTML string of back link.
841  */
843 
845 
846  /**
847  * @filter `gravityview_go_back_url` Modify the back link URL
848  * @since 1.17.5
849  * @see gv_directory_link() Generated the original back link
850  * @param string $href Existing label URL
851  */
852  $href = apply_filters( 'gravityview_go_back_url', $href );
853 
854  if( empty( $href ) ) { return NULL; }
855 
856  // calculate link label
858 
859  $label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __( '&larr; Go back', 'gravityview' );
860 
861  /**
862  * @filter `gravityview_go_back_label` Modify the back link text
863  * @since 1.0.9
864  * @param string $label Existing label text
865  */
866  $label = apply_filters( 'gravityview_go_back_label', $label );
867 
868  $link = gravityview_get_link( $href, esc_html( $label ), array(
869  'data-viewid' => $gravityview_view->getViewId()
870  ));
871 
872  return $link;
873 }
874 
875 /**
876  * Handle getting values for complex Gravity Forms fields
877  *
878  * If the field is complex, like a product, the field ID, for example, 11, won't exist. Instead,
879  * it will be 11.1, 11.2, and 11.3. This handles being passed 11 and 11.2 with the same function.
880  *
881  * @since 1.0.4
882  * @param array $entry GF entry array
883  * @param string $field_id [description]
884  * @param string $display_value The value generated by Gravity Forms
885  * @return string Value
886  */
887 function gravityview_get_field_value( $entry, $field_id, $display_value ) {
888 
889  if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) {
890 
891  // For the complete field value as generated by Gravity Forms
892  return $display_value;
893 
894  } else {
895 
896  // For one part of the address (City, ZIP, etc.)
897  return isset( $entry[ $field_id ] ) ? $entry[ $field_id ] : '';
898 
899  }
900 
901 }
902 
903 /**
904  * Take a passed CSV of terms and generate a linked list of terms
905  *
906  * Gravity Forms passes categories as "Name:ID" so we handle that using the ID, which
907  * is more accurate than checking the name, which is more likely to change.
908  *
909  * @param string $value Existing value
910  * @param string $taxonomy Type of term (`post_tag` or `category`)
911  * @return string CSV of linked terms
912  */
913 function gravityview_convert_value_to_term_list( $value, $taxonomy = 'post_tag' ) {
914 
915  $output = array();
916 
917  if ( is_array( $value ) ) {
918  $terms = array_filter( array_values( $value ), 'strlen' );
919  } else {
920  $terms = explode( ', ', $value );
921  }
922 
923  foreach ($terms as $term_name ) {
924 
925  // If we're processing a category,
926  if( $taxonomy === 'category' ) {
927 
928  // Use rgexplode to prevent errors if : doesn't exist
929  list( $term_name, $term_id ) = rgexplode( ':', $term_name, 2 );
930 
931  // The explode was succesful; we have the category ID
932  if( !empty( $term_id )) {
933  $term = get_term_by( 'id', $term_id, $taxonomy );
934  } else {
935  // We have to fall back to the name
936  $term = get_term_by( 'name', $term_name, $taxonomy );
937  }
938 
939  } else {
940  // Use the name of the tag to get the full term information
941  $term = get_term_by( 'name', $term_name, $taxonomy );
942  }
943 
944  // There's still a tag/category here.
945  if( $term ) {
946 
947  $term_link = get_term_link( $term, $taxonomy );
948 
949  // If there was an error, continue to the next term.
950  if ( is_wp_error( $term_link ) ) {
951  continue;
952  }
953 
954  $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) );
955  }
956  }
957 
958  return implode(', ', $output );
959 }
960 
961 /**
962  * Get the links for post_tags and post_category output based on post ID
963  * @param int $post_id The ID of the post
964  * @param boolean $link Add links or no?
965  * @param string $taxonomy Taxonomy of term to fetch.
966  * @return string String with terms
967  */
968 function gravityview_get_the_term_list( $post_id, $link = true, $taxonomy = 'post_tag' ) {
969 
970  $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' );
971 
972  if( empty( $link ) ) {
973  return strip_tags( $output);
974  }
975 
976  return $output;
977 
978 }
979 
980 
981 /**
982  * Get all views processed so far for the current page load
983  *
984  * @see GravityView_View_Data::add_view()
985  * @return array Array of View data, each View data with `id`, `view_id`, `form_id`, `template_id`, `atts`, `fields`, `widgets`, `form` keys.
986  */
988 
990 
991  // Solve problem when loading content via admin-ajax.php
992  if( ! $fe->getGvOutputData() ) {
993 
994  do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' );
995 
996  $fe->parse_content();
997  }
998 
999  // Make 100% sure that we're dealing with a properly called situation
1000  if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) {
1001 
1002  do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() );
1003 
1004  return array();
1005  }
1006 
1007  if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
1008  if ( ! gravityview()->views->count() ) {
1009  return array();
1010  }
1011  return array_combine(
1012  array_map( function ( $view ) { return $view->ID; }, gravityview()->views->all() ),
1013  array_map( function ( $view ) { return $view->as_data(); }, gravityview()->views->all() )
1014  );
1015  }
1016  /** \GravityView_View_Data::get_views is deprecated. */
1017  return $fe->getGvOutputData()->get_views();
1018 }
1019 
1020 /**
1021  * Get data for a specific view
1022  *
1023  * @see GravityView_View_Data::get_view()
1024  * @return array View data with `id`, `view_id`, `form_id`, `template_id`, `atts`, `fields`, `widgets`, `form` keys.
1025  */
1027 
1029 
1030  // If not set, grab the current view ID
1031  if ( empty( $view_id ) ) {
1032  $view_id = $fe->get_context_view_id();
1033  }
1034 
1035  if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
1036  $view = gravityview()->views->get( $view_id );
1037  if ( ! $view ) {
1038  /** Emulate the weird behavior of \GravityView_View_Data::get_view adding a view which wasn't there to begin with. */
1039  gravityview()->views->add( \GV\View::by_id( $view_id ) );
1040  $view = gravityview()->views->get( $view_id );
1041  }
1042  return $view ? $view->as_data() : array();
1043  } else {
1044  if ( ! $fe->getGvOutputData() ) { return array(); }
1045 
1046  return $fe->getGvOutputData()->get_view( $view_id );
1047  }
1048 }
1049 
1050 // Templates' hooks
1052  /**
1053  * @action `gravityview_before` Display content before a View. Used to render widget areas. Rendered outside the View container `<div>`
1054  * @param int $view_id The ID of the View being displayed
1055  */
1056  do_action( 'gravityview_before', gravityview_get_view_id() );
1057 }
1058 
1060  /**
1061  * @action `gravityview_header` Prepend content to the View container `<div>`
1062  * @param int $view_id The ID of the View being displayed
1063  */
1064  do_action( 'gravityview_header', gravityview_get_view_id() );
1065 }
1066 
1068  /**
1069  * @action `gravityview_after` Display content after a View. Used to render footer widget areas. Rendered outside the View container `<div>`
1070  * @param int $view_id The ID of the View being displayed
1071  */
1072  do_action( 'gravityview_footer', gravityview_get_view_id() );
1073 }
1074 
1075 function gravityview_after() {
1076  /**
1077  * @action `gravityview_after` Append content to the View container `<div>`
1078  * @param int $view_id The ID of the View being displayed
1079  */
1080  do_action( 'gravityview_after', gravityview_get_view_id() );
1081 }
1082 
1083 /**
1084  * Get the current View ID being rendered
1085  *
1086  * @global GravityView_View $gravityview_view
1087  * @return string View context "directory" or "single"
1088  */
1090  return GravityView_View::getInstance()->getViewId();
1091 }
1092 
1093 /**
1094  * @global GravityView_View $gravityview_view
1095  * @return string View context "directory", "single", or "edit"
1096  */
1098 
1099  $context = '';
1100 
1101  /**
1102  * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n
1103  * The Edit Entry functionality overrides this value.
1104  * @param boolean $is_edit_entry
1105  */
1106  $is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false );
1107 
1108  if( $is_edit_entry ) {
1109  $context = 'edit';
1110  } else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) {
1111  $context = 'single';
1112  } else if( class_exists( 'GravityView_View' ) ) {
1113  $context = GravityView_View::getInstance()->getContext();
1114  }
1115 
1116  return $context;
1117 }
1118 
1119 
1120 /**
1121  * Return an array of files prepared for output. Wrapper for GravityView_Field_FileUpload::get_files_array()
1122  *
1123  * Processes files by file type and generates unique output for each.
1124  *
1125  * Returns array for each file, with the following keys:
1126  *
1127  * `file_path` => The file path of the file, with a line break
1128  * `html` => The file output HTML formatted
1129  *
1130  * @see GravityView_Field_FileUpload::get_files_array()
1131  *
1132  * @since 1.2
1133  * @param string $value Field value passed by Gravity Forms. String of file URL, or serialized string of file URL array
1134  * @param string $gv_class Field class to add to the output HTML
1135  * @return array Array of file output, with `file_path` and `html` keys (see comments above)
1136  */
1137 function gravityview_get_files_array( $value, $gv_class = '' ) {
1138  /** @define "GRAVITYVIEW_DIR" "../" */
1139 
1140  if( !class_exists( 'GravityView_Field' ) ) {
1141  include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' );
1142  }
1143 
1144  if( !class_exists( 'GravityView_Field_FileUpload' ) ) {
1145  include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' );
1146  }
1147 
1148  return GravityView_Field_FileUpload::get_files_array( $value, $gv_class );
1149 }
1150 
1151 /**
1152  * Generate a mapping link from an address
1153  *
1154  * The address should be plain text with new line (`\n`) or `<br />` line breaks separating sections
1155  *
1156  * @todo use GF's field get_export_value() instead
1157  *
1158  * @see https://gravityview.co/support/documentation/201608159 Read how to modify the link
1159  * @param string $address Address
1160  * @return string URL of link to map of address
1161  */
1162 function gravityview_get_map_link( $address ) {
1163 
1164  $address_qs = str_replace( array( '<br />', "\n" ), ' ', $address ); // Replace \n with spaces
1165  $address_qs = urlencode( $address_qs );
1166 
1167  $url = "https://maps.google.com/maps?q={$address_qs}";
1168 
1169  $link_text = esc_html__( 'Map It', 'gravityview' );
1170 
1171  $link = gravityview_get_link( $url, $link_text, 'class=map-it-link' );
1172 
1173  /**
1174  * @filter `gravityview_map_link` Modify the map link generated. You can use a different mapping service, for example.
1175  * @param[in,out] string $link Map link
1176  * @param[in] string $address Address to generate link for
1177  * @param[in] string $url URL generated by the function
1178  */
1179  $link = apply_filters( 'gravityview_map_link', $link, $address, $url );
1180 
1181  return $link;
1182 }
1183 
1184 
1185 /**
1186  * Output field based on a certain html markup
1187  *
1188  * markup - string to be used on a sprintf statement.
1189  * Use:
1190  * {{label}} - field label
1191  * {{value}} - entry field value
1192  * {{class}} - field class
1193  *
1194  * wpautop - true will filter the value using wpautop function
1195  *
1196  * @since 1.1.5
1197  * @param array $passed_args Associative array with field data. `field` and `form` are required.
1198  * @return string Field output. If empty value and hide empty is true, return empty.
1199  */
1200 function gravityview_field_output( $passed_args ) {
1201  $defaults = array(
1202  'entry' => null,
1203  'field' => null,
1204  'form' => null,
1205  'hide_empty' => true,
1206  'markup' => '<div id="{{ field_id }}" class="{{ class }}">{{label}}{{value}}</div>',
1207  'label_markup' => '',
1208  'wpautop' => false,
1209  'zone_id' => null,
1210  );
1211 
1212  $args = wp_parse_args( $passed_args, $defaults );
1213 
1214  /**
1215  * @filter `gravityview/field_output/args` Modify the args before generation begins
1216  * @since 1.7
1217  * @param array $args Associative array; `field` and `form` is required.
1218  * @param array $passed_args Original associative array with field data. `field` and `form` are required.
1219  */
1220  $args = apply_filters( 'gravityview/field_output/args', $args, $passed_args );
1221 
1222  // Required fields.
1223  if ( empty( $args['field'] ) || empty( $args['form'] ) ) {
1224  do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args );
1225  return '';
1226  }
1227 
1228  $entry = empty( $args['entry'] ) ? array() : $args['entry'];
1229 
1230  /**
1231  * Create the content variables for replacing.
1232  * @since 1.11
1233  */
1234  $context = array(
1235  'value' => '',
1236  'width' => '',
1237  'width:style' => '',
1238  'label' => '',
1239  'label_value' => '',
1240  'class' => '',
1241  'field_id' => '',
1242  );
1243 
1244  $context['value'] = gv_value( $entry, $args['field'] );
1245 
1246  // If the value is empty and we're hiding empty, return empty.
1247  if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) {
1248  return '';
1249  }
1250 
1251  if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) {
1252  $context['value'] = wpautop( $context['value'] );
1253  }
1254 
1255  // Get width setting, if exists
1256  $context['width'] = GravityView_API::field_width( $args['field'] );
1257 
1258  // If replacing with CSS inline formatting, let's do it.
1259  $context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' );
1260 
1261  // Grab the Class using `gv_class`
1262  $context['class'] = gv_class( $args['field'], $args['form'], $entry );
1263  $context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry );
1264 
1265  // Get field label if needed
1266  if ( ! empty( $args['label_markup'] ) && ! empty( $args['field']['show_label'] ) ) {
1267  $context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] );
1268  }
1269 
1270  // Default Label value
1271  $context['label_value'] = gv_label( $args['field'], $entry );
1272 
1273  if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){
1274  $context['label'] = '<span class="gv-field-label">{{ label_value }}</span>';
1275  }
1276 
1277  /**
1278  * @filter `gravityview/field_output/pre_html` Allow Pre filtering of the HTML
1279  * @since 1.11
1280  * @param string $markup The HTML for the markup
1281  * @param array $args All args for the field output
1282  */
1283  $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args );
1284 
1285  /**
1286  * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders
1287  * @since 1.11
1288  * @param string $open_tag Open tag for template content placeholders. Default: `{{`
1289  */
1290  $open_tag = apply_filters( 'gravityview/field_output/open_tag', '{{', $args );
1291 
1292  /**
1293  * @filter `gravityview/field_output/close_tag` Modify the closing tags for the template content placeholders
1294  * @since 1.11
1295  * @param string $close_tag Close tag for template content placeholders. Default: `}}`
1296  */
1297  $close_tag = apply_filters( 'gravityview/field_output/close_tag', '}}', $args );
1298 
1299  /**
1300  * Loop through each of the tags to replace and replace both `{{tag}}` and `{{ tag }}` with the values
1301  * @since 1.11
1302  */
1303  foreach ( $context as $tag => $value ) {
1304 
1305  // If the tag doesn't exist just skip it
1306  if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){
1307  continue;
1308  }
1309 
1310  // Array to search
1311  $search = array(
1312  $open_tag . $tag . $close_tag,
1313  $open_tag . ' ' . $tag . ' ' . $close_tag,
1314  );
1315 
1316  /**
1317  * `gravityview/field_output/context/{$tag}` Allow users to filter content on context
1318  * @since 1.11
1319  * @param string $value The content to be shown instead of the {{tag}} placeholder
1320  * @param array $args Arguments passed to the function
1321  */
1322  $value = apply_filters( 'gravityview/field_output/context/' . $tag, $value, $args );
1323 
1324  // Finally do the replace
1325  $html = str_replace( $search, $value, $html );
1326  }
1327 
1328  /**
1329  * @todo Depricate `gravityview_field_output`
1330  */
1331  $html = apply_filters( 'gravityview_field_output', $html, $args );
1332 
1333  /**
1334  * @filter `gravityview/field_output/html` Modify field HTML output
1335  * @param string $html Existing HTML output
1336  * @param array $args Arguments passed to the function
1337  */
1338  $html = apply_filters( 'gravityview/field_output/html', $html, $args );
1339 
1340  // Just free up a tiny amount of memory
1341  unset( $value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag );
1342 
1343  return $html;
1344 }
gravityview_get_view_id()
Get the current View ID being rendered.
Definition: class-api.php:1089
const GRAVITYVIEW_DIR
"GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory, with trailing slash ...
Definition: gravityview.php:35
$url
Definition: post_image.php:25
gv_value( $entry, $field)
Definition: class-api.php:810
gravityview_get_field_value( $entry, $field_id, $display_value)
Handle getting values for complex Gravity Forms fields.
Definition: class-api.php:887
static getInstance( $passed_post=NULL)
gravityview_get_the_term_list( $post_id, $link=true, $taxonomy='post_tag')
Get the links for post_tags and post_category output based on post ID.
Definition: class-api.php:968
gravityview_field_output( $passed_args)
Output field based on a certain html markup.
Definition: class-api.php:1200
static get_entry_var_name()
Return the query var / end point name for the entry.
gravityview_after()
Definition: class-api.php:1075
static getInstance( $passed_post=NULL)
Definition: class-data.php:164
gravityview_get_map_link( $address)
Generate a mapping link from an address.
Definition: class-api.php:1162
static replace_variables($text, $form=array(), $entry=array(), $url_encode=false, $esc_html=true, $nl2br=true, $format='html', $aux_data=array())
Alias for GFCommon::replace_variables()
if(gv_empty( $field['value'], false, false)) $format
gravityview_footer()
Definition: class-api.php:1067
static get_entry( $entry_slug, $force_allow_ids=false, $check_entry_display=true)
Return a single entry object.
gv_container_class( $passed_css_class='', $echo=true)
Generate a CSS class to be added to the wrapper of a View.
Definition: class-api.php:776
gravityview_get_current_view_data( $view_id=0)
Get data for a specific view.
Definition: class-api.php:1026
$field_settings['content']
Definition: custom.php:27
gravityview_get_link( $href='', $anchor_text='', $atts=array())
Generate an HTML anchor tag with a list of supported attributes.
gv_no_results($wpautop=true)
Definition: class-api.php:833
static get_custom_entry_slug( $id, $entry=array())
Calculate an unique hash for an entry based on the entry ID.
Definition: class-api.php:556
static entry_create_custom_slug( $entry, $form)
If using the entry custom slug feature, make sure the new entries have the custom slug created and sa...
Definition: class-api.php:634
gravityview_back_link()
Generate HTML for the back link from single entry view.
Definition: class-api.php:842
static directory_link( $post_id=NULL, $add_query_args=true)
Generate a URL to the Directory context.
Definition: class-api.php:445
static get_endpoint_name()
Return the endpoint name for a single Entry.
static field_html_attr_id( $field, $form=array(), $entry=array())
Fetch Field HTML ID.
Definition: class-api.php:200
gravityview_get_field( $form, $field_id)
Returns the field details array of a specific form given the field id.
static field_value( $entry, $field_settings, $format='html')
Given an entry and a form field id, calculate the entry value for that field.
Definition: class-api.php:226
static get_associated_field( $gf_field)
Alias for get_instance()
gravityview_header()
Definition: class-api.php:1059
static entry_link( $entry, $post_id=NULL, $add_directory_args=true)
return href for single entry
Definition: class-api.php:663
static is_single_entry()
Verify if user requested a single entry view.
$field_id
Definition: time.php:17
gravityview_convert_value_to_term_list( $value, $taxonomy='post_tag')
Take a passed CSV of terms and generate a linked list of terms.
Definition: class-api.php:913
static field_width( $field, $format='%d%%')
Get column width from the field setting.
Definition: class-api.php:122
gv_label( $field, $entry=NULL)
Definition: class-api.php:757
static replace_variables( $text, $form=array(), $entry=array(), $url_encode=false, $esc_html=true, $nl2br=true, $format='html', $aux_data=array())
Alias for GravityView_Merge_Tags::replace_variables()
Definition: class-api.php:108
gv_class( $field, $form=NULL, $entry=array())
Definition: class-api.php:761
if(empty( $created_by)) $form_id
static get_entry_slug( $id_or_string, $entry=array())
Get the entry slug for the entry.
Definition: class-api.php:588
static no_results($wpautop=true)
Get the "No Results" text depending on whether there were results.
Definition: class-api.php:411
global $post
gravityview()
The main GravityView wrapper function.
gv_entry_link( $entry, $post_id=NULL)
Definition: class-api.php:829
gravityview_get_context()
GravityView_View $gravityview_view
Definition: class-api.php:1097
static field_class( $field, $form=NULL, $entry=NULL)
Fetch Field class.
Definition: class-api.php:148
gv_empty( $value, $zero_is_empty=true, $allow_string_booleans=true)
Is the value empty?
$entry_slug
Definition: notes.php:30
gravityview_get_files_array( $value, $gv_class='')
Return an array of files prepared for output.
Definition: class-api.php:1137
static entry_link_html( $entry=array(), $anchor_text='', $passed_tag_atts=array(), $field_settings=array())
Generate an anchor tag that links to an entry.
Definition: class-api.php:379
$entry
Definition: notes.php:27
gv_directory_link( $post=NULL, $add_pagination=true)
Definition: class-api.php:825
gravityview_before()
Definition: class-api.php:1051
$field
Definition: gquiz_grade.php:11
static field_label( $field, $entry=array(), $force_show_label=false)
Fetch Field Label.
Definition: class-api.php:26
static getInstance()
Get the one true instantiated self.
gravityview_get_current_views()
Get all views processed so far for the current page load.
Definition: class-api.php:987