• Hello there… I made a custom module about custom date for your plugin few months ago.

    Used version Versione 3.5.2 of CF7 and was working fine

    here my script… any idea why is bnot working in CF7 3.6 ?????

    <?php
    /**
    ** A base module for the following types of tags:
    ** 	[custom_date] and [custom_date*]		# Date
    **/
    
    /* parte per trovare i mesi in italiano in php */
    
     function mesi_anno2() {
     $mese = array ("Gennaio-", "Febbraio-", "Marzo-", "Aprile-", "Maggio-", "Giugno-", "Luglio-", "Agosto-", "Settembre-", "Ottobre-", "Novembre-", "Dicembre-");
     $str="";
            for($i = 0; $i < 24; $i++) {
            $time = mktime(0, 0, 0, date('n') - $i);
            $str .="<option value=".$mese[(date("n", $time)-1)].date("Y", $time).">".$mese[(date("n", $time)-1)].date("Y", $time)."</option>";
        }
      return $str;
       } 
    
    /* Shortcode handler */
    
     add_action( 'init', 'wpcf7_add_shortcode_custom_date', 5 );
    
    function wpcf7_add_shortcode_custom_date() {
    	wpcf7_add_shortcode( array( 'custom_date', 'custom_date*' ),
    		'wpcf7_custom_date_shortcode_handler', true );
    }
    
    function wpcf7_custom_date_shortcode_handler( $tag ) {
    	$tag = new WPCF7_Shortcode( $tag );
    
    	if ( empty( $tag->name ) )
    		return '';
    
    	$validation_error = wpcf7_get_validation_error( $tag->name );
    
    	$class = wpcf7_form_controls_class( $tag->type );
    
    	if ( $validation_error )
    		$class .= ' wpcf7-not-valid';
    
    	$atts = array();
    
    	$atts['class'] = $tag->get_class_option( $class );
    	$atts['id'] = $tag->get_option( 'id', 'id', true );
    	$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
    
    	if ( $tag->is_required() )
    		$atts['aria-required'] = 'true';
    
    	$defaults = array();
    
    	if ( $matches = $tag->get_first_match_option( '/^default:([0-9_]+)$/' ) )
    		$defaults = explode( '_', $matches[1] );
    
    	$multiple = $tag->has_option( 'multiple' );
    	$include_blank = $tag->has_option( 'include_blank' );
    	$first_as_label = $tag->has_option( 'first_as_label' );
    
    	$name = $tag->name;
    	$values = $tag->values;
    	$labels = $tag->labels;
    
    	$empty_custom_date = empty( $values );
    
    	if ( $empty_custom_date || $include_blank ) {
    		array_unshift( $labels, '---' );
    		array_unshift( $values, '' );
    	} elseif ( $first_as_label ) {
    		$values[0] = '';
    	}
    
    	$html = '';
    
    	$posted = wpcf7_is_posted();
    
    	foreach ( $values as $key => $value ) {
    		$custom_dateed = false;
    
    		if ( $posted && ! empty( $_POST[$name] ) ) {
    			if ( $multiple && in_array( esc_sql( $value ), (array) $_POST[$name] ) )
    				$custom_dateed = true;
    			if ( ! $multiple && $_POST[$name] == esc_sql( $value ) )
    				$custom_dateed = true;
    		} else {
    			if ( ! $empty_custom_date && in_array( $key + 1, (array) $defaults ) )
    				$custom_dateed = true;
    		}
    
    		$item_atts = array(
    			'value' => $value,
    			'custom_dateed' => $custom_dateed ? 'custom_dateed' : '' );
    
    		$item_atts = wpcf7_format_atts( $item_atts );
    
    		$label = isset( $labels[$key] ) ? $labels[$key] : $value;
    
    		$html .= sprintf( '<option %1$s>%2$s</option>',
    			$item_atts, esc_html( $label ) );
    	}
    
    	if ( $multiple )
    		$atts['multiple'] = 'multiple';
    
    	$atts['name'] = $tag->name . ( $multiple ? '[]' : '' );
    
    	$atts = wpcf7_format_atts( $atts );
    
    	$html = sprintf(
    		'<span class="wpcf7-form-control-wrap %1$s"><select %2$s>
    <option value="">---</option>'.mesi_anno2().'</select>%4$s</span>'
     		,
    		$tag->name, $atts, $html, $validation_error );
    
     /*$html = sprintf('<select name="'.$name.'"> <option value="">---</option>'.mesi_anno2().'</select>'  ,
    		$tag->name, $atts, $html, $validation_error );
    */
    	return $html;
    }
    
    /* Validation filter */
    
    add_filter( 'wpcf7_validate_custom_date', 'wpcf7_custom_date_validation_filter', 10, 2 );
    add_filter( 'wpcf7_validate_custom_date*', 'wpcf7_custom_date_validation_filter', 10, 2 );
    
    function wpcf7_custom_date_validation_filter( $result, $tag ) {
    	$tag = new WPCF7_Shortcode( $tag );
    
    	$name = $tag->name;
    
    	if ( isset( $_POST[$name] ) && is_array( $_POST[$name] ) ) {
    		foreach ( $_POST[$name] as $key => $value ) {
    			if ( '' === $value )
    				unset( $_POST[$name][$key] );
    		}
    	}
    
    	if ( $tag->is_required() ) {
    		if ( ! isset( $_POST[$name] )
    		|| empty( $_POST[$name] ) && '0' !== $_POST[$name] ) {
    			$result['valid'] = false;
    			$result['reason'][$name] = wpcf7_get_message( 'invalid_required' );
    		}
    	}
    
    	return $result;
    }
    
    /* Tag generator */
    
    add_action( 'admin_init', 'wpcf7_add_tag_generator_menu', 25 );
    
     ?>

    http://wordpress.org/plugins/contact-form-7/

  • The topic ‘my customized CF7 module is not working with last edition of CF7’ is closed to new replies.