Textarea.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. /**
  3. * Class NF_Field_Textarea
  4. */
  5. class NF_Fields_Textarea extends NF_Abstracts_Input
  6. {
  7. protected $_name = 'textarea';
  8. protected $_section = 'common';
  9. protected $_icon = 'paragraph';
  10. protected $_type = 'textarea';
  11. protected $_templates = 'textarea';
  12. protected $_test_value = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.';
  13. protected $_settings = array( 'input_limit_set', 'rte_enable', 'rte_media', 'rte_mobile', 'disable_browser_autocomplete', 'textarea_rte', 'disable_rte_mobile', 'textarea_media', );
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. $this->_nicename = __( 'Paragraph Text', 'ninja-forms' );
  18. $this->_settings[ 'default' ][ 'type' ] = 'textarea';
  19. $this->_settings[ 'placeholder' ][ 'type' ] = 'textarea';
  20. add_filter( 'ninja_forms_subs_export_field_value_' . $this->_name, array( $this, 'filter_csv_value' ), 10, 2 );
  21. }
  22. public function admin_form_element( $id, $value )
  23. {
  24. return "<textarea class='widefat' name='fields[$id]'>$value</textarea>";
  25. }
  26. public function filter_csv_value( $field_value, $field ) {
  27. /*
  28. * sanitize this in case someone tries to inject data that runs in
  29. * Excel and similar apps
  30. * */
  31. if( 0 < strlen($field_value ) ) {
  32. $first_char = substr( $field_value, 0, 1 );
  33. if( in_array( $first_char, array( '=', '@', '+', '-' ) ) ) {
  34. return "'" . $field_value;
  35. }
  36. }
  37. return $field_value;
  38. }
  39. }