Title: Add this code to Your Plugin
Last modified: July 26, 2018

---

# Add this code to Your Plugin

 *  [ds4designs](https://wordpress.org/support/users/ds4designs/)
 * (@ds4designs)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/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;
   
       }
       ```
   
    -  This topic was modified 7 years, 10 months ago by [ds4designs](https://wordpress.org/support/users/ds4designs/).
    -  This topic was modified 7 years, 10 months ago by [ds4designs](https://wordpress.org/support/users/ds4designs/).
    -  This topic was modified 7 years, 10 months ago by [ds4designs](https://wordpress.org/support/users/ds4designs/).

The topic ‘Add this code to Your Plugin’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/contact-form-7-city-field-extension_ffffff.
   svg)
 * [Contact Form 7 City Field Extension](https://wordpress.org/plugins/contact-form-7-city-field-extension/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-city-field-extension/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-city-field-extension/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-city-field-extension/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-city-field-extension/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-city-field-extension/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [ds4designs](https://wordpress.org/support/users/ds4designs/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/add-this-code-to-your-plugin/)
 * Status: not resolved