GravityView  2.10.1
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', '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  *
47  * @return string
48  */
49  public function get_field_input( $form, $value = '', $entry = null, GF_Field_Post_Content $field ) {
50 
51  $id = (int) $field->id;
52  $input_name = "input_{$id}";
53  $class = esc_attr( $field->size );
54  $tabindex = $field->get_tabindex();
55 
56  $editor_settings = array(
57  'editor_class' => "textarea {$class}",
58  'textarea_name' => $input_name,
59  'textarea_rows' => 15,
60  'tabindex' => $tabindex,
61  'media_buttons' => false,
62  'quicktags' => false,
63  'logic_event' => $field->get_conditional_logic_event( 'keyup' ),
64  'placeholder' => $field->get_field_placeholder_attribute(),
65  );
66 
67  /**
68  * @filter `gravityview/edit_entry/post_content/wp_editor_settings` Modify the settings passed to the Post Content wp_editor()
69  * @see wp_editor() For the options available
70  * @since 1.7
71  * @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.
72  */
73  $editor_settings = apply_filters( 'gravityview/edit_entry/post_content/wp_editor_settings', $editor_settings );
74 
75  ob_start();
76  wp_editor( $value, $input_name, $editor_settings );
77  $editor = ob_get_clean();
78 
79  $logic_event = \GV\Utils::get( $editor_settings, 'logic_event' );
80  $placeholder = \GV\Utils::get( $editor_settings, 'placeholder' );
81 
82  /** @internal Instead of using `add_filter('the_editor')` and doing the same thing, it's cleaner here. */
83  $editor = str_replace( '<textarea ', "<textarea {$logic_event} {$placeholder}", $editor );
84 
85  return sprintf( "<div class='ginput_container ginput_container_post_content'>%s</div>", trim( $editor ) );
86  }
87 
88 }
89 
Modify field settings by extending this class.
$icon
$search_operators
$group
__construct()
$class
get_field_input( $form, $value='', $entry=null, GF_Field_Post_Content $field)
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
$field_id
Definition: time.php:17
add_field_support( $key='', &$field_options)
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
$field
Definition: gquiz_grade.php:11