customs
1 year ago
holders
1 year ago
checkbox.php
1 year ago
color-and-opacity.php
1 year ago
color.php
1 year ago
datepicker-range.php
1 year ago
dropdown-and-colors.php
1 year ago
dropdown.php
1 year ago
font.php
1 year ago
google-font.php
1 year ago
gradient.php
1 year ago
hidden.php
1 year ago
index.php
3 years ago
integer.php
1 year ago
list.php
1 year ago
multiple-textbox.php
1 year ago
paddings-editor.php
1 year ago
pattern.php
1 year ago
radio-colors.php
1 year ago
radio.php
1 year ago
textarea.php
1 year ago
textbox.php
1 year ago
url.php
1 year ago
wp-editor.php
1 year ago
textarea.php
86 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Textarea Control |
| 5 | * |
| 6 | * Main options: |
| 7 | * name => a name of the control |
| 8 | * value => a value to show in the control |
| 9 | * default => a default value of the control if the "value" option is not specified |
| 10 | * |
| 11 | * @author Alex Kovalev <alex.kovalevv@gmail.com> |
| 12 | * @copyright (c) 2018, Webcraftic Ltd |
| 13 | * |
| 14 | * @package factory-forms |
| 15 | * @since 1.0.0 |
| 16 | */ |
| 17 | |
| 18 | // Exit if accessed directly |
| 19 | if( !defined('ABSPATH') ) { |
| 20 | exit; |
| 21 | } |
| 22 | |
| 23 | if( !class_exists('Wbcr_FactoryForms480_TextareaControl') ) { |
| 24 | |
| 25 | class Wbcr_FactoryForms480_TextareaControl extends Wbcr_FactoryForms480_Control { |
| 26 | |
| 27 | public $type = 'textarea'; |
| 28 | |
| 29 | /** |
| 30 | * Returns a submit value of the control by a given name. |
| 31 | * |
| 32 | * @since 1.0.0 |
| 33 | * @return mixed |
| 34 | */ |
| 35 | public function getSubmitValue($name, $subName) |
| 36 | { |
| 37 | $name_on_form = $this->getNameOnForm($name); |
| 38 | |
| 39 | $raw_value = isset($_POST[$name_on_form]) |
| 40 | ? $_POST[$name_on_form] |
| 41 | : null; |
| 42 | |
| 43 | $value = $raw_value; |
| 44 | |
| 45 | if( is_array($value) ) { |
| 46 | $value = array_map('sanitize_textarea_field', $value); |
| 47 | $value = implode(',', $value); |
| 48 | } else { |
| 49 | $value = sanitize_textarea_field($value); |
| 50 | } |
| 51 | |
| 52 | return $this->filterValue($value, $raw_value); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Preparing html attributes before rendering html of the control. |
| 57 | * |
| 58 | * @since 1.0.0 |
| 59 | * @return void |
| 60 | */ |
| 61 | protected function beforeHtml() |
| 62 | { |
| 63 | $name_on_form = $this->getNameOnForm(); |
| 64 | $height = (int)$this->getOption('height', 100); |
| 65 | |
| 66 | $this->addCssClass('form-control'); |
| 67 | $this->addHtmlAttr('name', $name_on_form); |
| 68 | $this->addHtmlAttr('id', $name_on_form); |
| 69 | $this->addHtmlAttr('style', 'min-height:' . $height . 'px'); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Shows the html markup of the control. |
| 74 | * |
| 75 | * @since 1.0.0 |
| 76 | * @return void |
| 77 | */ |
| 78 | public function html() |
| 79 | { |
| 80 | ?> |
| 81 | <textarea <?php $this->attrs(); ?>><?php echo esc_textarea(strval($this->getValue())); ?></textarea> |
| 82 | <?php |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 |