fieldset.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
  2. /**
  3. *
  4. * Field: fieldset
  5. *
  6. * @since 1.0.0
  7. * @version 1.0.0
  8. *
  9. */
  10. if ( ! class_exists( 'CSF_Field_fieldset' ) ) {
  11. class CSF_Field_fieldset 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 '<div class="csf-fieldset-content" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
  18. foreach ( $this->field['fields'] as $field ) {
  19. $field_id = ( isset( $field['id'] ) ) ? $field['id'] : '';
  20. $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
  21. $field_value = ( isset( $this->value[$field_id] ) ) ? $this->value[$field_id] : $field_default;
  22. $unique_id = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']' : $this->field['id'];
  23. Sakurairo_CSF::field( $field, $field_value, $unique_id, 'field/fieldset' );
  24. }
  25. echo '</div>';
  26. echo $this->field_after();
  27. }
  28. }
  29. }