5 if ( ! defined(
'GRAVITYVIEW_DIR' ) ) {
14 if ( ! class_exists(
'\GV\Gamajo_Template_Loader' ) ) {
15 require
gravityview()->plugin->dir(
'future/lib/class-gamajo-template-loader.php' );
28 protected $filter_prefix =
'gravityview/template/fields';
34 protected $theme_template_directory =
'gravityview/fields/';
40 protected $plugin_template_directory =
'templates/fields/';
84 $this->source = $source;
86 $this->request = $request;
89 add_filter( $this->filter_prefix .
'_get_template_part', $this->_add_id_specific_templates_callback = self::add_id_specific_templates( $this ), 10, 3 );
91 parent::__construct();
95 remove_filter( $this->filter_prefix .
'_get_template_part', $this->_add_id_specific_templates_callback );;
116 $inputType =
$template->field->inputType;
170 $specifics = array();
172 list( $slug_dir, $slug_name ) = $class::split_slug( $slug,
$name );
176 if ( $is_view && $post ) {
178 $specifics []= sprintf(
'%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID,
$view_id, $field_type, $slug_name );
179 $inputType && $specifics []= sprintf(
'%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID,
$view_id, $inputType, $slug_name );
180 $specifics []= sprintf(
'%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID,
$view_id, $field_type );
181 $inputType && $specifics []= sprintf(
'%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID,
$view_id, $inputType );
182 $specifics []= sprintf(
'%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $field_type, $slug_name );
183 $inputType && $specifics []= sprintf(
'%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $inputType, $slug_name );
184 $specifics []= sprintf(
'%spost-%d-field-%s.php', $slug_dir, $post->ID, $field_type );
185 $inputType && $specifics []= sprintf(
'%spost-%d-field-%s.php', $slug_dir, $post->ID, $inputType );
188 $specifics []= sprintf(
'%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID,
$view_id, $slug_name );
189 $specifics []= sprintf(
'%spost-%d-view-%d-field.php', $slug_dir, $post->ID,
$view_id );
190 $specifics []= sprintf(
'%spost-%d-field-%s.php', $slug_dir, $post->ID, $slug_name );
191 $specifics []= sprintf(
'%spost-%d-field.php', $slug_dir, $post->ID );
198 $specifics []= sprintf(
'%sform-%d-field-%d-%s.php', $slug_dir,
$form_id,
$field_id, $slug_name );
199 $specifics []= sprintf(
'%sform-%d-field-%d.php', $slug_dir,
$form_id,
$field_id );
202 $specifics []= sprintf(
'%sview-%d-field-%d.php', $slug_dir,
$view_id,
$field_id );
207 $specifics []= sprintf(
'%sform-%d-field-%s-%s.php', $slug_dir,
$form_id, $field_type, $slug_name );
208 $inputType && $specifics []= sprintf(
'%sform-%d-field-%s-%s.php', $slug_dir,
$form_id, $inputType, $slug_name );
209 $specifics []= sprintf(
'%sform-%d-field-%s.php', $slug_dir,
$form_id, $field_type );
210 $inputType && $specifics []= sprintf(
'%sform-%d-field-%s.php', $slug_dir,
$form_id, $inputType );
212 $specifics []= sprintf(
'%sview-%d-field-%s-%s.php', $slug_dir,
$view_id, $field_type, $slug_name );
213 $inputType && $specifics []= sprintf(
'%sview-%d-field-%s-%s.php', $slug_dir,
$view_id, $inputType, $slug_name );
214 $specifics []= sprintf(
'%sview-%d-field-%s.php', $slug_dir,
$view_id, $field_type );
215 $inputType && $specifics []= sprintf(
'%sview-%d-field-%s.php', $slug_dir,
$view_id, $inputType );
217 $specifics []= sprintf(
'%sfield-%s-%s.php', $slug_dir, $field_type, $slug_name );
218 $inputType && $specifics []= sprintf(
'%sfield-%s-%s.php', $slug_dir, $inputType, $slug_name );
219 $specifics []= sprintf(
'%sfield-%s.php', $slug_dir, $field_type );
220 $inputType && $specifics []= sprintf(
'%sfield-%s.php', $slug_dir, $inputType );
226 $specifics []= sprintf(
'%sview-%d-field-%s.php', $slug_dir,
$view_id, $slug_name );
227 $specifics []= sprintf(
'%sform-%d-field-%s.php', $slug_dir,
$form_id, $slug_name );
229 $specifics []= sprintf(
'%sview-%d-field.php', $slug_dir,
$view_id );
230 $specifics []= sprintf(
'%sform-%d-field.php', $slug_dir,
$form_id );
237 if ( ! in_array( $field_type, array(
'notes' ) ) ) {
238 $specifics []= sprintf(
'%s.php', $field_type );
239 $specifics []= sprintf(
'fields/%s.php', $field_type );
242 $specifics []= sprintf(
'%sfield-%s.php', $slug_dir, $slug_name );
243 $specifics []= sprintf(
'%sfield.php', $slug_dir );
257 if ( !
$entry = $this->entry->from_field( $this->field ) ) {
258 gravityview()->log->error(
'Entry is invalid for field. Returning empty.' );
265 $source = $this->source;
266 $source_backend = $source ? $source::$backend : null;
269 'field' => $this->field,
273 if ( \
GV\Source::BACKEND_GRAVITYFORMS === $source_backend && ! $this->field instanceof
Internal_Field ) {
280 if ( $errors = ob_get_clean() ) {
281 gravityview()->log->error(
'Errors when calling GFCommon::get_lead_field_display()', array(
'data' => $errors ) );
285 if ( ! $this->field->field instanceof
GF_Field ) {
286 $gf_field = \GF_Fields::create( $this->field->field );
295 if ( ! empty( $this->field->field->adminOnly ) ) {
300 $context = Template_Context::from_template( $this, compact(
'display_value',
'value' ) );
310 $this->push_template_data( apply_filters(
'gravityview/template/field/context', $context ),
'gravityview' );
314 $this->located_template = $this->get_template_part( static::$slug );
330 $output = apply_filters(
'gravityview/field/value/empty',
$output, Template_Context::from_template( $this ) );
332 $context = Template_Context::from_template( $this, compact(
'display_value',
'value' ) );
335 gravityview()->log->info(
'Field template for field #{field_id} loaded: {located_template}', array(
'field_id' => $this->field->ID,
'located_template' => $this->located_template ) );
337 $this->pop_template_data(
'gravityview' );
340 $field_compat = array(
341 'form' => $source_backend == \
GV\Source::BACKEND_GRAVITYFORMS ? $this->source->form : ( $this->view->form ? $this->view->form->form : null ),
342 'field_id' => $this->field->ID,
343 'field' => $this->field->field,
344 'field_settings' => $this->field->as_configuration(),
348 'entry' =>
$entry->as_entry(),
349 'field_type' => $this->field->type,
350 'field_path' => $this->located_template,
363 $pre_link_compat_callback =
function(
$output, $context ) use ( $field_compat ) {
376 $output = apply_filters(
"gravityview_field_entry_value_{$field->type}_pre_link",
$output, $context->entry->as_entry(),
$field->as_configuration(), $field_compat );
378 $output = apply_filters(
'gravityview_field_entry_value_pre_link', $output, $context->entry->as_entry(),
$field->as_configuration(), $field_compat );
385 if ( ! empty(
$field->show_as_link ) && !
\gv_empty( $output,
false,
false ) ) {
386 $link_atts = empty(
$field->new_window ) ? array() : array(
'target' =>
'_blank' );
388 $permalink = $context->entry->get_permalink( $context->view, $context->request );
399 $output = apply_filters(
'gravityview_field_entry_link', $output, $permalink, $context->entry->as_entry(),
$field->as_configuration() );
408 $output = apply_filters(
'gravityview/template/field/entry_link', $output, $permalink, $context );
415 $post_link_compat_callback =
function(
$output, $context ) use ( $field_compat ) {
428 $output = apply_filters(
"gravityview_field_entry_value_{$field->type}",
$output, $context->entry->as_entry(),
$field->as_configuration(), $field_compat );
439 $output = apply_filters(
'gravityview_field_entry_value', $output, $context->entry->as_entry(),
$field->as_configuration(), $field_compat );
449 return apply_filters(
"gravityview/template/field/{$field->type}/output", $output, $context );
468 add_filter(
'gravityview/template/field/output', $pre_link_compat_callback, 5, 2 );
469 add_filter(
'gravityview/template/field/output', $post_link_compat_callback, 9, 2 );
479 echo apply_filters(
"gravityview/template/field/output",
$output, $context );
481 remove_filter(
'gravityview/template/field/output', $pre_link_compat_callback, 5 );
482 remove_filter(
'gravityview/template/field/output', $post_link_compat_callback, 9 );
487 require
gravityview()->plugin->dir(
'future/includes/class-gv-template-field-html.php' );
488 require
gravityview()->plugin->dir(
'future/includes/class-gv-template-field-csv.php' );
If this file is called directly, abort.
If this file is called directly, abort.
__construct(Field $field, View $view=null, Source $source=null, Entry $entry=null, Request $request=null)
Initializer.
static add_id_specific_templates( $template)
Enable granular template overrides based on current post, view, form, field types, etc.
if(! isset( $gravityview)||empty( $gravityview->template)) $template
The entry loop for the list output.
render()
Output some HTML.
gravityview_get_link( $href='', $anchor_text='', $atts=array())
Generate an HTML anchor tag with a list of supported attributes.
If this file is called directly, abort.
static load( $configuration)
Hydrates the legacy context globals as needed.
If this file is called directly, abort.
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()
If this file is called directly, abort.
if(empty( $created_by)) $form_id
If this file is called directly, abort.
If this file is called directly, abort.
If this file is called directly, abort.
gravityview()
The main GravityView wrapper function.
gv_empty( $value, $zero_is_empty=true, $allow_string_booleans=true)
Is the value empty?
If this file is called directly, abort.
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed