textarea.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
  2. /**
  3. *
  4. * Field: textarea
  5. *
  6. * @since 1.0.0
  7. * @version 1.0.0
  8. *
  9. */
  10. if ( ! class_exists( 'CSF_Field_textarea' ) ) {
  11. class CSF_Field_textarea extends CSF_Fields {
  12. public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
  13. parent::__construct( $field, $value, $unique, $where, $parent );
  14. }
  15. public function render() {
  16. echo $this->field_before();
  17. echo $this->shortcoder();
  18. echo '<textarea name="'. esc_attr( $this->field_name() ) .'"'. $this->field_attributes() .'>'. $this->value .'</textarea>';
  19. echo $this->field_after();
  20. }
  21. public function shortcoder() {
  22. if ( ! empty( $this->field['shortcoder'] ) ) {
  23. $instances = ( is_array( $this->field['shortcoder'] ) ) ? $this->field['shortcoder'] : array_filter( (array) $this->field['shortcoder'] );
  24. foreach ( $instances as $instance_key ) {
  25. if ( isset( Sakurairo_CSF::$shortcode_instances[$instance_key] ) ) {
  26. $button_title = Sakurairo_CSF::$shortcode_instances[$instance_key]['button_title'];
  27. echo '<a href="#" class="button button-primary csf-shortcode-button" data-modal-id="'. esc_attr( $instance_key ) .'">'. $button_title .'</a>';
  28. }
  29. }
  30. }
  31. }
  32. }
  33. }