field, array(
'max' => 0,
'min' => 0,
'button_title' => '',
) );
$fields = $this->field['fields'];
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique : $this->field['id'];
if( $this->parent && preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->parent ) ) {
echo '
'. esc_html__( 'Error: Nested field id can not be same with another nested field id.', 'bittumb' ) .'
';
} else {
echo $this->field_before();
echo '';
echo '
';
foreach ( $fields as $field ) {
$field_parent = $this->parent .'['. $this->field['id'] .']';
$field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
CSF::field( $field, $field_default, '_nonce', 'field/repeater', $field_parent );
}
echo '
';
echo '
';
echo '
';
echo '';
echo '';
echo '';
echo '
';
echo '
';
echo '
';
echo '';
if( ! empty( $this->value ) ) {
$num = 0;
foreach ( $this->value as $key => $value ) {
echo '
';
echo '
';
foreach ( $fields as $field ) {
$field_parent = $this->parent .'['. $this->field['id'] .']';
$field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']['. $num .']' : $this->field['id'] .'['. $num .']';
$field_value = ( isset( $field['id'] ) && isset( $this->value[$key][$field['id']] ) ) ? $this->value[$key][$field['id']] : '';
CSF::field( $field, $field_value, $field_unique, 'field/repeater', $field_parent );
}
echo '
';
echo '
';
echo '
';
echo '';
echo '';
echo '';
echo '
';
echo '
';
echo '
';
$num++;
}
}
echo '
';
echo ''. esc_html__( 'You can not add more than', 'bittumb' ) .' '. $args['max'] .'
';
echo ''. esc_html__( 'You can not remove less than', 'bittumb' ) .' '. $args['min'] .'
';
echo ''. $args['button_title'] .'';
echo $this->field_after();
}
}
public function enqueue() {
if( ! wp_script_is( 'jquery-ui-sortable' ) ) {
wp_enqueue_script( 'jquery-ui-sortable' );
}
}
}
}