Add this code to Your Plugin
-
Please add this code to your plugin (contact-form-7-city-field-extension.php), because without it the plugin doesn’t recognize –> placeholder=”something”
/*This is already there --> $value = (string) reset( $tag->values );*/ if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) { $atts['placeholder'] = $value; $value = ''; }
It would be like this:
/* * CityFieldText Shortcode */ function wpcf7_cityfield_shortcode_handler( $tag ) { $tag = new WPCF7_FormTag( $tag ); if ( empty( $tag->name ) ) return ''; $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type, 'wpcf7cfe-cityfield' ); if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } $atts = array(); $atts['size'] = $tag->get_size_option( '40' ); $atts['maxlength'] = $tag->get_maxlength_option(); $atts['minlength'] = $tag->get_minlength_option(); if ( $atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength'] ) { unset( $atts['maxlength'], $atts['minlength'] ); } $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = 'autocomplete'; $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true ); if ( $tag->has_option( 'readonly' ) ) $atts['readonly'] = 'readonly'; if ( $tag->is_required() ) $atts['aria-required'] = 'true'; $atts['aria-invalid'] = $validation_error ? 'true' : 'false'; $value = (string) reset( $tag->values ); <strong> if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) { $atts['placeholder'] = $value; $value = ''; }</strong> $atts['type'] = 'text'; $atts['name'] = $tag->name; $atts = wpcf7_format_atts( $atts ); $html = sprintf( '<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>', sanitize_html_class( $tag->name ), $atts, $validation_error ); return $html; }
- The topic ‘Add this code to Your Plugin’ is closed to new replies.