GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
class-gravityview-field-post-content.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @file class-gravityview-field-post-content.php
4  * @package GravityView
5  * @subpackage includes\fields
6  */
7 
9 
10  var $name = 'post_content';
11 
12  var $is_searchable = true;
13 
14  var $search_operators = array( 'is', 'isnot', 'contains', 'starts_with', 'ends_with' );
15 
16  var $_gf_field_class_name = 'GF_Field_Post_Content';
17 
18  var $group = 'post';
19 
20  var $icon = 'dashicons-editor-alignleft';
21 
22  public function __construct() {
23  $this->label = esc_html__( 'Post Content', 'gk-gravityview' );
24  parent::__construct();
25  }
26 
27  public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
28 
29  unset( $field_options['show_as_link'] );
30 
31  if( 'edit' === $context ) {
32  return $field_options;
33  }
34 
35  $this->add_field_support('dynamic_data', $field_options );
36 
37  return $field_options;
38  }
39 
40  /**
41  * Returns the field inner markup.
42  *
43  * @param array $form The Form Object currently being processed.
44  * @param string|array $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission.
45  * @param null|array $entry Null or the Entry Object currently being edited.
46  * @param null|GF_Field_Post_Content The field being edited.
47  *
48  * @return string
49  */
50  public function get_field_input( $form, $value = '', $entry = null, GF_Field_Post_Content $field = null ) {
51 
52  $id = (int) $field->id;
53  $input_name = "input_{$id}";
54  $class = esc_attr( $field->size );
55  $tabindex = $field->get_tabindex();
56 
57  $editor_settings = array(
58  'editor_class' => "textarea {$class}",
59  'textarea_name' => $input_name,
60  'textarea_rows' => 15,
61  'tabindex' => $tabindex,
62  'media_buttons' => false,
63  'quicktags' => false,
64  'logic_event' => $field->get_conditional_logic_event( 'keyup' ),
65  'placeholder' => $field->get_field_placeholder_attribute(),
66  );
67 
68  /**
69  * @filter `gravityview/edit_entry/post_content/wp_editor_settings` Modify the settings passed to the Post Content wp_editor()
70  * @see wp_editor() For the options available
71  * @since 1.7
72  * @param array $editor_settings Array of settings to be passed to wp_editor(). Note: there are also two additional values in the array: `logic_event` and `placehodler`, added to the textarea HTML by GravityView.
73  */
74  $editor_settings = apply_filters( 'gravityview/edit_entry/post_content/wp_editor_settings', $editor_settings );
75 
76  ob_start();
77  wp_editor( $value, $input_name, $editor_settings );
78  $editor = ob_get_clean();
79 
80  $logic_event = \GV\Utils::get( $editor_settings, 'logic_event' );
81  $placeholder = \GV\Utils::get( $editor_settings, 'placeholder' );
82 
83  /** @internal Instead of using `add_filter('the_editor')` and doing the same thing, it's cleaner here. */
84  $editor = str_replace( '<textarea ', "<textarea {$logic_event} {$placeholder}", $editor );
85 
86  return sprintf( "<div class='ginput_container ginput_container_post_content'>%s</div>", trim( $editor ) );
87  }
88 
89 }
90 
Modify field settings by extending this class.
$icon
$search_operators
$group
__construct()
$class
add_field_support( $key, &$field_options)
get_field_input( $form, $value='', $entry=null, GF_Field_Post_Content $field=null)
Returns the field inner markup.
if(gravityview() ->plugin->is_GF_25()) $form
new GravityView_Field_Post_Content
field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id)
$name
$is_searchable
$_gf_field_class_name
if(empty( $created_by)) $form_id
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
$entry
Definition: notes.php:27
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
Definition: time.php:22