|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @file class-gravityview-field-custom.php |
|
4
|
|
|
* @package GravityView |
|
5
|
|
|
* @subpackage includes\fields |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Add custom options for Code field |
|
10
|
|
|
* @since 1.2 |
|
11
|
|
|
*/ |
|
12
|
|
|
class GravityView_Field_Custom extends GravityView_Field { |
|
13
|
|
|
|
|
14
|
|
|
var $name = 'custom'; |
|
15
|
|
|
|
|
16
|
|
|
var $contexts = array( 'single', 'multiple', 'edit' ); |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var bool |
|
20
|
|
|
* @since 1.15.3 |
|
21
|
|
|
*/ |
|
22
|
|
|
var $is_sortable = false; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var bool |
|
26
|
|
|
* @since 1.15.3 |
|
27
|
|
|
*/ |
|
28
|
|
|
var $is_searchable = false; |
|
29
|
|
|
|
|
30
|
|
|
var $group = 'gravityview'; |
|
31
|
|
|
|
|
32
|
|
|
public function __construct() { |
|
33
|
|
|
$this->label = esc_attr__( 'Custom Content', 'gravityview' ); |
|
34
|
|
|
parent::__construct(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
unset ( $field_options['search_filter'], $field_options['show_as_link'] ); |
|
40
|
|
|
|
|
41
|
|
|
if( 'edit' === $context ) { |
|
42
|
|
|
return $field_options; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$new_fields = array( |
|
46
|
|
|
'content' => array( |
|
47
|
|
|
'type' => 'textarea', |
|
48
|
|
|
'label' => __( 'Custom Content', 'gravityview' ), |
|
49
|
|
|
'desc' => sprintf( __( 'Enter text or HTML. Also supports shortcodes. You can show or hide data using the %s shortcode (%slearn more%s).', 'gravityview' ), '<code>[gvlogic]</code>', '<a href="http://docs.gravityview.co/article/252-gvlogic-shortcode">', '</a>' ), |
|
50
|
|
|
'value' => '', |
|
51
|
|
|
'class' => 'code', |
|
52
|
|
|
'merge_tags' => 'force', |
|
53
|
|
|
'show_all_fields' => true, // Show the `{all_fields}` and `{pricing_fields}` merge tags |
|
54
|
|
|
), |
|
55
|
|
|
'wpautop' => array( |
|
56
|
|
|
'type' => 'checkbox', |
|
57
|
|
|
'label' => __( 'Automatically add paragraphs to content', 'gravityview' ), |
|
58
|
|
|
'tooltip' => __( 'Wrap each block of text in an HTML paragraph tag (recommended for text).', 'gravityview' ), |
|
59
|
|
|
'value' => '', |
|
60
|
|
|
), |
|
61
|
|
|
); |
|
62
|
|
|
|
|
63
|
|
|
return $new_fields + $field_options; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
new GravityView_Field_Custom; |
|
69
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.