isset( $raw['maxLength'] ) ? min( 10000, absint( $raw['maxLength'] ) ) : 0, ); } /** {@inheritdoc} */ public function validate( $value, array $field ) { $max = isset( $field['maxLength'] ) ? (int) $field['maxLength'] : 0; if ( $max > 0 && mb_strlen( (string) $value ) > $max ) { /* translators: %d: maximum number of characters. */ return sprintf( __( 'Use %d characters or fewer.', 'fillaro' ), $max ); } return ''; } /** {@inheritdoc} */ public function render_control( array $field, array $ctx ) { $attrs = array_merge( $this->base_attrs( $field, $ctx ), array( 'type' => $this->input_type(), 'value' => is_scalar( $ctx['value'] ) ? (string) $ctx['value'] : '', 'maxlength' => ! empty( $field['maxLength'] ) ? (int) $field['maxLength'] : false, 'autocomplete' => $this->autocomplete(), ), $this->extra_attrs( $field ) ); return 'attrs( $attrs ) . ' />'; } /** * Type-specific input attributes. * * @param array $field Field config. * @return array */ protected function extra_attrs( array $field ) { unset( $field ); return array(); } }