1
0

textarea.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. $shortcodes = ( is_array( $this->field['shortcoder'] ) ) ? $this->field['shortcoder'] : array_filter( (array) $this->field['shortcoder'] );
  24. $instances = ( ! empty( Sakurairo_CSF::$shortcode_instances ) ) ? Sakurairo_CSF::$shortcode_instances : array();
  25. if ( ! empty( $shortcodes ) && ! empty( $instances ) ) {
  26. foreach ( $shortcodes as $shortcode ) {
  27. foreach ( $instances as $instance ) {
  28. if ( $instance['modal_id'] === $shortcode ) {
  29. $id = $instance['modal_id'];
  30. $title = $instance['button_title'];
  31. echo '<a href="#" class="button button-primary csf-shortcode-button" data-modal-id="'. esc_attr( $id ) .'">'. esc_html( $title ) .'</a>';
  32. }
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }
  39. }