Merge pull request #4810 from vayurobins/master

Added description parameter to the woocommerce_form_field function
This commit is contained in:
Mike Jolley 2014-05-22 10:20:44 +01:00
commit b4b015d916
1 changed files with 49 additions and 10 deletions

View File

@ -1580,6 +1580,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
$defaults = array(
'type' => 'text',
'label' => '',
'description' => '',
'placeholder' => '',
'maxlength' => false,
'required' => false,
@ -1639,6 +1640,9 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
$field .= '<input type="hidden" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" value="' . current( array_keys($countries ) ) . '" ' . implode( ' ', $custom_attributes ) . ' class="country_to_state" />';
if ( $args['description'] )
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
$field .= '</p>' . $after;
} else {
@ -1655,6 +1659,9 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
$field .= '<noscript><input type="submit" name="woocommerce_checkout_update_totals" value="' . __( 'Update country', 'woocommerce' ) . '" /></noscript>';
if ( $args['description'] )
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
$field .= '</p>' . $after;
}
@ -1687,6 +1694,10 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label'] . $required . '</label>';
$field .= '<input type="hidden" class="hidden" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" value="" ' . implode( ' ', $custom_attributes ) . ' placeholder="' . esc_attr( $args['placeholder'] ) . '" />';
if ( $args['description'] )
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
$field .= '</p>' . $after;
} elseif ( is_array( $states ) ) {
@ -1702,6 +1713,10 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
$field .= '<option value="' . esc_attr( $ckey ) . '" '.selected( $value, $ckey, false ) .'>'.__( $cvalue, 'woocommerce' ) .'</option>';
$field .= '</select>';
if ( $args['description'] )
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
$field .= '</p>' . $after;
} else {
@ -1711,6 +1726,10 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
$field .= '<input type="text" class="input-text ' . implode( ' ', $args['input_class'] ) .'" value="' . esc_attr( $value ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
if ( $args['description'] )
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
$field .= '</p>' . $after;
}
@ -1723,16 +1742,24 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
$field .= '<textarea name="' . esc_attr( $key ) . '" class="input-text ' . implode( ' ', $args['input_class'] ) .'" id="' . esc_attr( $key ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '"' . ( empty( $args['custom_attributes']['rows'] ) ? ' rows="2"' : '' ) . ( empty( $args['custom_attributes']['cols'] ) ? ' cols="5"' : '' ) . implode( ' ', $custom_attributes ) . '>'. esc_textarea( $value ) .'</textarea>
</p>' . $after;
$field .= '<textarea name="' . esc_attr( $key ) . '" class="input-text ' . implode( ' ', $args['input_class'] ) .'" id="' . esc_attr( $key ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '"' . ( empty( $args['custom_attributes']['rows'] ) ? ' rows="2"' : '' ) . ( empty( $args['custom_attributes']['cols'] ) ? ' cols="5"' : '' ) . implode( ' ', $custom_attributes ) . '>'. esc_textarea( $value ) .'</textarea>';
if ( $args['description'] )
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
$field .= '</p>' . $after;
break;
case "checkbox" :
$field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">
<input type="' . esc_attr( $args['type'] ) . '" class="input-checkbox" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" value="1" '.checked( $value, 1, false ) .' />
<label for="' . esc_attr( $key ) . '" class="checkbox ' . implode( ' ', $args['label_class'] ) .'" ' . implode( ' ', $custom_attributes ) . '>' . $args['label'] . $required . '</label>
</p>' . $after;
<label for="' . esc_attr( $key ) . '" class="checkbox ' . implode( ' ', $args['label_class'] ) .'" ' . implode( ' ', $custom_attributes ) . '>' . $args['label'] . $required . '</label>';
if ( $args['description'] )
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
$field .= '</p>' . $after;
break;
case "password" :
@ -1742,8 +1769,12 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
$field .= '<input type="password" class="input-text ' . implode( ' ', $args['input_class'] ) .'" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />
</p>' . $after;
$field .= '<input type="password" class="input-text ' . implode( ' ', $args['input_class'] ) .'" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
if ( $args['description'] )
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
$field .= '</p>' . $after;
break;
case "text" :
@ -1753,8 +1784,12 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label'] . $required . '</label>';
$field .= '<input type="text" class="input-text ' . implode( ' ', $args['input_class'] ) .'" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" '.$args['maxlength'].' value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />
</p>' . $after;
$field .= '<input type="text" class="input-text ' . implode( ' ', $args['input_class'] ) .'" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" '.$args['maxlength'].' value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
if ( $args['description'] )
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
$field .= '</p>' . $after;
break;
case "select" :
@ -1772,8 +1807,12 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
$field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" class="select" ' . implode( ' ', $custom_attributes ) . '>
' . $options . '
</select>
</p>' . $after;
</select>';
if ( $args['description'] )
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
$field .= '</p>' . $after;
break;
default :