$value ) { $selected = false; if ( $posted && ! empty( $_POST[$name] ) ) { if ( $multiple && in_array( esc_sql( $value ), (array) $_POST[$name] ) ) $selected = true; if ( ! $multiple && $_POST[$name] == esc_sql( $value ) ) $selected = true; } else { if ( ! $empty_select && in_array( $key + 1, (array) $defaults ) ) $selected = true; } $selected = $selected ? ' selected="selected"' : ''; if ( isset( $labels[$key] ) ) $label = $labels[$key]; else $label = $value; $html .= ''; } if ( $multiple ) $atts .= ' multiple="multiple"'; $html = ''; $html = '' . $html . $validation_error . ''; return $html; } /* Validation filter */ add_filter( 'wpcf7_validate_select', 'wpcf7_select_validation_filter', 10, 2 ); add_filter( 'wpcf7_validate_select*', 'wpcf7_select_validation_filter', 10, 2 ); function wpcf7_select_validation_filter( $result, $tag ) { $type = $tag['type']; $name = $tag['name']; if ( isset( $_POST[$name] ) && is_array( $_POST[$name] ) ) { foreach ( $_POST[$name] as $key => $value ) { if ( '' === $value ) unset( $_POST[$name][$key] ); } } if ( 'select*' == $type ) { 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 ); function wpcf7_add_tag_generator_menu() { wpcf7_add_tag_generator( 'menu', __( 'Drop-down menu', 'wpcf7' ), 'wpcf7-tg-pane-menu', 'wpcf7_tg_pane_menu' ); } function wpcf7_tg_pane_menu( &$contact_form ) { ?>