assets
1 year ago
.eslintrc.js
1 year ago
block-asset.php
1 year ago
block-render.php
2 years ago
block-template.php
1 year ago
block-type.php
2 years ago
block.json
1 year ago
block-template.php
105 lines
| 1 | <?php |
| 2 | /** |
| 3 | * input[type="hidden"] template |
| 4 | * |
| 5 | * @var Base $this |
| 6 | * @var array $args |
| 7 | */ |
| 8 | |
| 9 | use Jet_Form_Builder\Blocks\Render\Base; |
| 10 | use Jet_Form_Builder\Classes\Tools; |
| 11 | |
| 12 | // If this file is called directly, abort. |
| 13 | if ( ! defined( 'WPINC' ) ) { |
| 14 | die; |
| 15 | } |
| 16 | |
| 17 | $this->set_value(); |
| 18 | $this->add_attribute( 'placeholder', $args['placeholder'] ); |
| 19 | $this->add_attribute( 'required', $this->block_type->get_required_val() ); |
| 20 | $this->add_attribute( 'name', $this->block_type->get_field_name( $args['name'] ) ); |
| 21 | $this->add_attribute( 'id', $this->block_type->get_field_id( $args ) ); |
| 22 | $this->add_attribute( 'type', $args['field_type'] ); |
| 23 | $this->add_attribute( 'data-field-name', $args['name'] ); |
| 24 | $this->add_attribute( 'class', 'jet-form-builder__field text-field' ); |
| 25 | $this->add_attribute( 'class', $args['class_name'] ); |
| 26 | $this->add_attribute( 'minlength', $this->args['minlength'] ?? '' ); |
| 27 | $this->add_attribute( 'maxlength', $this->args['maxlength'] ?? '' ); |
| 28 | $this->add_attribute( 'data-jfb-sync' ); |
| 29 | |
| 30 | $this->add_attribute( |
| 31 | 'autocomplete', |
| 32 | 'off' === $this->args['autocomplete'] |
| 33 | ? 'off_' . substr( str_shuffle( 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ), 0, 8 ) |
| 34 | : $this->args['autocomplete'] |
| 35 | ); |
| 36 | |
| 37 | |
| 38 | if ( ! empty( $args['enable_input_mask'] ) && ! empty( $args['input_mask'] ) ) { |
| 39 | $this->add_attribute( 'class', 'jet-form-builder__masked-field' ); |
| 40 | |
| 41 | $mask_type = ! empty( $args['mask_type'] ) ? $args['mask_type'] : ''; |
| 42 | |
| 43 | $clear = $this->args['clear_on_submit'] ?? ''; |
| 44 | |
| 45 | if ( $clear ) { |
| 46 | $this->add_attribute( 'data-clear-mask-on-submit', $clear ); |
| 47 | } |
| 48 | |
| 49 | if ( $mask_type ) { |
| 50 | $this->add_attribute( 'data-inputmask', '\'alias\': \'' . esc_attr( $mask_type ) . '\'' ); |
| 51 | $this->add_attribute( 'data-inputmask-inputformat', esc_attr( $args['input_mask'] ) ); |
| 52 | $this->add_attribute( 'data-inputmask-inputmode', 'verbatim' ); |
| 53 | } else { |
| 54 | $this->add_attribute( 'data-inputmask', '\'mask\': \'' . esc_attr( $args['input_mask'] ) . '\'' ); |
| 55 | } |
| 56 | |
| 57 | $mask_placeholder = ! empty( $args['mask_placeholder'] ) ? esc_attr( $args['mask_placeholder'] ) : ''; |
| 58 | |
| 59 | if ( $mask_placeholder ) { |
| 60 | $this->add_attribute( 'data-inputmask-placeholder', $mask_placeholder ); |
| 61 | } |
| 62 | |
| 63 | $mask_visibility = ! empty( $args['mask_visibility'] ) ? $args['mask_visibility'] : 'always'; |
| 64 | |
| 65 | switch ( $mask_visibility ) { |
| 66 | case 'focus': |
| 67 | $this->add_attribute( 'data-inputmask-showmaskonhover', 'false' ); |
| 68 | break; |
| 69 | |
| 70 | case 'hover': |
| 71 | $this->add_attribute( 'data-inputmask-showmaskonhover', 'true' ); |
| 72 | $this->add_attribute( 'data-inputmask-showmaskonfocus', 'true' ); |
| 73 | break; |
| 74 | |
| 75 | default: |
| 76 | $this->add_attribute( 'data-inputmask-clearmaskonlostfocus', 'false' ); |
| 77 | break; |
| 78 | } |
| 79 | } |
| 80 | $show_eye = $this->args['showEye'] ?? false; |
| 81 | $wrap_classes = sprintf( |
| 82 | 'jet-form-builder__field-wrap %s', |
| 83 | $show_eye ? 'has-eye-icon' : '' |
| 84 | ) |
| 85 | |
| 86 | // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped |
| 87 | ?> |
| 88 | <div class="<?php echo esc_attr( trim( $wrap_classes ) ); ?>"> |
| 89 | <?php do_action( 'jet-form-builder/before-field', $this ); ?> |
| 90 | <input <?php $this->render_attributes_string(); ?>> |
| 91 | <?php if ( $show_eye && 'password' === $args['field_type'] ) : ?> |
| 92 | <span |
| 93 | class="jfb-eye-icon seen" |
| 94 | role="button" |
| 95 | tabindex="0" |
| 96 | style="<?php echo Tools::is_editor() ? 'display:none;' : ''; ?>" |
| 97 | > |
| 98 | <?php echo $this->get_seen_icon(); ?> |
| 99 | <?php echo $this->get_unseen_icon(); ?> |
| 100 | </span> |
| 101 | <?php endif; ?> |
| 102 | <?php do_action( 'jet-form-builder/after-field', $this ); ?> |
| 103 | </div> |
| 104 | <?php // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped |
| 105 |