GFPDFHelperFieldsField_Post_Content

Controls the display and output of a Gravity Form field.

Defined (1)

The class is defined in the following location(s).

/src/helper/fields/Field_Post_Content.php  
  1. class Field_Post_Content extends Helper_Abstract_Fields { 
  2.  
  3. /** 
  4. * Check the appropriate variables are parsed in send to the parent construct 
  5. * @param object $field The GF_Field_* Object 
  6. * @param array $entry The Gravity Forms Entry 
  7. * @param \GFPDF\Helper\Helper_Abstract_Form $gform 
  8. * @param \GFPDF\Helper\Helper_Misc $misc 
  9. * @throws Exception 
  10. * @since 4.0 
  11. */ 
  12. public function __construct( $field, $entry, Helper_Abstract_Form $gform, Helper_Misc $misc ) { 
  13.  
  14. if ( ! is_object( $field ) || ! $field instanceof GF_Field_Post_Content ) { 
  15. throw new Exception( '$field needs to be in instance of GF_Field_Post_Content' ); 
  16.  
  17. /** call our parent method */ 
  18. parent::__construct( $field, $entry, $gform, $misc ); 
  19.  
  20. /** 
  21. * Display the HTML version of this field 
  22. * @param string $value 
  23. * @param bool $label 
  24. * @return string 
  25. * @since 4.0 
  26. */ 
  27. public function html( $value = '', $label = true ) { 
  28. $value = $this->value(); 
  29.  
  30. return parent::html( $value ); 
  31.  
  32. /** 
  33. * Get the standard GF value of this field 
  34. * @return string|array 
  35. * @since 4.0 
  36. */ 
  37. public function value() { 
  38. if ( $this->has_cache() ) { 
  39. return $this->cache(); 
  40.  
  41. $value = $this->get_value(); 
  42.  
  43. if ( isset( $this->field->useRichTextEditor ) && true === $this->field->useRichTextEditor ) { 
  44. $html = wp_kses_post( $value ); 
  45. } else { 
  46. $html = nl2br( esc_html( $value ) ); 
  47.  
  48. $this->cache( $html ); 
  49.  
  50. return $this->cache();