name = 'email_input'; $this->public = false; $this->label = __( 'Email', 'frontend-admin' ); $this->defaults = array( 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', ); } /* * render_field() * * Create the HTML interface for your field * * @param $field - an array holding all the field's data * * @type action * @since 3.6 * @date 23/01/13 */ function render_field( $field ) { // vars $atts = array(); $keys = array( 'type', 'id', 'class', 'name', 'value', 'placeholder', 'pattern', 'autocomplete' ); $keys2 = array( 'readonly', 'disabled', 'required', 'multiple' ); // atts (value="123") foreach ( $keys as $k ) { if ( isset( $field[ $k ] ) ) { $atts[ $k ] = $field[ $k ]; } } // atts2 (disabled="disabled") foreach ( $keys2 as $k ) { if ( ! empty( $field[ $k ] ) ) { $atts[ $k ] = $k; } } // remove empty atts $atts = acf_clean_atts( $atts ); if( $field['prepend'] ){ ?>
__( 'Default Value', 'frontend-admin' ), 'instructions' => __( 'Appears when creating a new post', 'frontend-admin' ), 'type' => 'text', 'name' => 'default_value', ) ); } /** * Renders the field settings used in the "Presentation" tab. * * @since 6.0 * * @param array $field The field settings array. * @return void */ function render_field_presentation_settings( $field ) { acf_render_field_setting( $field, array( 'label' => __( 'Placeholder Text', 'frontend-admin' ), 'instructions' => __( 'Appears within the input', 'frontend-admin' ), 'type' => 'text', 'name' => 'placeholder', ) ); acf_render_field_setting( $field, array( 'label' => __( 'Prepend', 'frontend-admin' ), 'instructions' => __( 'Appears before the input', 'frontend-admin' ), 'type' => 'text', 'name' => 'prepend', ) ); acf_render_field_setting( $field, array( 'label' => __( 'Append', 'frontend-admin' ), 'instructions' => __( 'Appears after the input', 'frontend-admin' ), 'type' => 'text', 'name' => 'append', ) ); } /** * Validate the email value. If this method returns TRUE, the input value is valid. If * FALSE or a string is returned, the input value is invalid and the user is shown a * notice. If a string is returned, the string is show as the message text. * * @param bool $valid Whether the value is valid. * @param mixed $value The field value. * @param array $field The field array. * @param string $input The request variable name for the inbound field. * * @return bool|string */ public function validate_value( $valid, $value, $field, $input ) { $flags = defined( 'FILTER_FLAG_EMAIL_UNICODE' ) ? FILTER_FLAG_EMAIL_UNICODE : 0; if ( $value && filter_var( wp_unslash( $value ), FILTER_VALIDATE_EMAIL, $flags ) === false ) { return sprintf( /* translators: %s: value */ __( "'%s' is not a valid email address", 'frontend-admin' ), esc_html( $value ) ); } return $valid; } /** * Return the schema array for the REST API. * * @param array $field * @return array */ public function get_rest_schema( array $field ) { $schema = parent::get_rest_schema( $field ); $schema['format'] = 'email'; return $schema; } } endif; // class_exists check