GravityView
2.17
The best, easiest way to display Gravity Forms entries on your website.
includes
fields
class-gravityview-field-post-custom-field.php
Go to the documentation of this file.
1
<?php
2
/**
3
* @file class-gravityview-field-post-custom-field.php
4
* @package GravityView
5
* @subpackage includes\fields
6
*/
7
8
class
GravityView_Field_Post_Custom_Field
extends
GravityView_Field
{
9
10
var
$name
=
'post_custom_field'
;
11
12
var
$is_searchable
=
true
;
13
14
/**
15
* @var array $search_operators Custom fields are text, but can be any format (including JSON)
16
*/
17
var
$search_operators
= array(
'contains'
,
'is'
,
'isnot'
);
18
19
/**
20
* @see GF_Field_Post_Custom_Field
21
*/
22
var
$_gf_field_class_name
=
'GF_Field_Post_Custom_Field'
;
23
24
var
$group
=
'post'
;
25
26
var
$icon
=
'dashicons-admin-generic'
;
27
28
public
function
__construct
() {
29
$this->label = esc_html__(
'Post Custom Field'
,
'gk-gravityview'
);
30
parent::__construct();
31
32
$this->
add_hooks
();
33
}
34
35
/**
36
* Add hooks for the field
37
*
38
* @since 1.17
39
*
40
* @return void
41
*/
42
private
function
add_hooks
() {
43
add_filter(
'gravityview/edit_entry/field_value_post_custom_field'
, array( $this,
'edit_entry_field_value'
), 10, 2 );
44
}
45
46
/**
47
* Fix "List" Field Type pre-population of content in Edit Entry mode
48
*
49
* @since 1.17
50
*
51
* @param mixed $field_value field value used to populate the input
52
* @param GF_Field $field Gravity Forms field object
53
*
54
* @return mixed If a List input for Custom Field, returns JSON-decoded value. Otherwise, original value.
55
*/
56
public
function
edit_entry_field_value
(
$field_value
,
$field
) {
57
58
if
(
'list'
===
$field
->inputType ) {
59
$field_value
= is_string(
$field_value
) ? json_decode(
$field_value
,
true
) :
$field_value
;
60
61
if
( ! is_array(
$field_value
) ) {
62
gravityview
()->log->error(
'"List" Custom Field value not an array or string.'
, array(
'data'
=> compact(
'field_value'
,
'field'
) ) );
63
}
64
}
65
66
return
$field_value
;
67
}
68
69
}
70
71
new
GravityView_Field_Post_Custom_Field
;
GravityView_Field
Modify field settings by extending this class.
Definition:
class-gravityview-field.php:11
GravityView_Field_Post_Custom_Field
new GravityView_Field_Post_Custom_Field
Definition:
class-gravityview-field-post-custom-field.php:71
GravityView_Field_Post_Custom_Field\$search_operators
$search_operators
Definition:
class-gravityview-field-post-custom-field.php:17
GravityView_Field_Post_Custom_Field\$icon
$icon
Definition:
class-gravityview-field-post-custom-field.php:26
GravityView_Field_Post_Custom_Field\add_hooks
add_hooks()
Add hooks for the field.
Definition:
class-gravityview-field-post-custom-field.php:42
$field
$field
Definition:
search-field-chainedselect.php:29
GravityView_Field_Post_Custom_Field\$is_searchable
$is_searchable
Definition:
class-gravityview-field-post-custom-field.php:12
GravityView_Field_Post_Custom_Field\$_gf_field_class_name
$_gf_field_class_name
Definition:
class-gravityview-field-post-custom-field.php:22
GravityView_Field_Post_Custom_Field\__construct
__construct()
Definition:
class-gravityview-field-post-custom-field.php:28
gravityview
gravityview()
The main GravityView wrapper function.
Definition:
future/gravityview.php:26
GravityView_Field_Post_Custom_Field\edit_entry_field_value
edit_entry_field_value( $field_value, $field)
Fix "List" Field Type pre-population of content in Edit Entry mode.
Definition:
class-gravityview-field-post-custom-field.php:56
GravityView_Field_Post_Custom_Field\$name
$name
Definition:
class-gravityview-field-post-custom-field.php:10
GravityView_Field_Post_Custom_Field\$group
$group
Definition:
class-gravityview-field-post-custom-field.php:24
$field_value
$field_value
Definition:
checkbox.php:24
GravityView_Field_Post_Custom_Field
Definition:
class-gravityview-field-post-custom-field.php:8