| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* @package Redux_Framework |
| 5 |
* @subpackage Fields |
| 6 |
* @access public |
| 7 |
* @global $optname |
| 8 |
* @internal Internal Note string |
| 9 |
* @link http://reduxframework.com |
| 10 |
* @method Test |
| 11 |
* @name $globalvariablename |
| 12 |
* @param string $this->field['test'] This is cool. |
| 13 |
* @param string|boolean $field[default] Default value for this field. |
| 14 |
* @return Test |
| 15 |
* @see ParentClass |
| 16 |
* @since Redux 3.0.9 |
| 17 |
* @todo Still need to fix this! |
| 18 |
* @var string cool |
| 19 |
* @var int notcool |
| 20 |
* @param string[] $options { |
| 21 |
* @type boolean $required Whether this element is required |
| 22 |
* @type string $label The display name for this element |
| 23 |
*/ |
| 24 |
|
| 25 |
// Exit if accessed directly |
| 26 |
if ( ! defined( 'ABSPATH' ) ) { |
| 27 |
exit; |
| 28 |
} |
| 29 |
|
| 30 |
if ( ! class_exists( 'ReduxFramework_textarea' ) ) { |
| 31 |
class ReduxFramework_textarea { |
| 32 |
|
| 33 |
/** |
| 34 |
* Field Constructor. |
| 35 |
* |
| 36 |
* @param $value Constructed by Redux class. Based on the passing in $field['defaults'] value and what is stored in the database. |
| 37 |
* @param $parent ReduxFramework object is passed for easier pointing. |
| 38 |
* |
| 39 |
* @since ReduxFramework 1.0.0 |
| 40 |
* @type string $field [test] Description. Default <value>. Accepts <value>, <value>. |
| 41 |
*/ |
| 42 |
function __construct( $field = array(), $value = '', $parent ) { |
| 43 |
$this->parent = $parent; |
| 44 |
$this->field = $field; |
| 45 |
$this->value = $value; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Field Render Function. |
| 50 |
* Takes the vars and outputs the HTML for the field in the settings |
| 51 |
* |
| 52 |
* @since ReduxFramework 1.0.0 |
| 53 |
* |
| 54 |
* @param array $arr (See above) |
| 55 |
* |
| 56 |
* @return Object A new editor object. |
| 57 |
**/ |
| 58 |
function render() { |
| 59 |
|
| 60 |
$this->field['placeholder'] = isset( $this->field['placeholder'] ) ? $this->field['placeholder'] : ""; |
| 61 |
$this->field['rows'] = isset( $this->field['rows'] ) ? $this->field['rows'] : 6; |
| 62 |
$readonly = ( isset( $this->field['readonly'] ) && $this->field['readonly']) ? ' readonly="readonly"' : ''; |
| 63 |
// The $this->field variables are already escaped in the ReduxFramework Class. |
| 64 |
?> |
| 65 |
<textarea <?php echo $readonly; ?> name="<?php echo esc_attr($this->field['name'] . $this->field['name_suffix']); ?>" id="<?php echo $this->field['id']; ?>-textarea" placeholder="<?php echo esc_attr( $this->field['placeholder'] ); ?>" class="large-text <?php echo esc_attr($this->field['class']); ?>" rows="<?php echo esc_attr($this->field['rows']); ?>"><?php echo esc_textarea( $this->value ); ?></textarea> |
| 66 |
<?php |
| 67 |
} |
| 68 |
|
| 69 |
function sanitize( $field, $value ) { |
| 70 |
if ( ! isset( $value ) || empty( $value ) ) { |
| 71 |
$value = ""; |
| 72 |
} else { |
| 73 |
$value = esc_textarea( $value ); |
| 74 |
} |
| 75 |
|
| 76 |
return $value; |
| 77 |
} |
| 78 |
} |
| 79 |
} |