Skip to content

Commit

Permalink
Use a textarea field for the address
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitchantre committed Feb 28, 2018
1 parent 476a0da commit fdfe1d7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions inc/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ function metabox_save( $post_id, $post ) {
function register_event_location_meta() {
register_meta( 'term', 'address', array(
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'sanitize_callback' => 'sanitize_textarea_field',
) );

register_meta( 'term', 'url', array(
Expand All @@ -603,7 +603,7 @@ function event_location_add_address_field() {
?>
<div class="form-field">
<label for="be-event-location-address"><?php esc_html_e( 'Address', 'be-events-calendar' ); ?></label>
<input type="text" name="be_event_location_address" class="be-event-location-address" id="be-event-location-address" value="" />
<textarea name="be_event_location_address" class="be-event-location-address" id="be-event-location-address" rows="4"></textarea>
</div>
<?php
}
Expand All @@ -620,7 +620,7 @@ function event_location_edit_address_field( $term ) {
<th scope="row"><label for="be-event-location-address"><?php esc_html_e( 'Address', 'be-events-calendar' ); ?></label></th>
<td>
<?php wp_nonce_field( basename( __FILE__ ), 'event_location_address_nonce' ); ?>
<input type="text" name="be_event_location_address" class="be-event-location-address" id="be-event-location-address" value="<?php echo esc_attr( $address ); ?>" />
<textarea name="be_event_location_address" class="be-event-location-address" id="be-event-location-address" rows="4"><?php echo esc_html( $address ); ?></textarea>
</td>
</tr>
<?php
Expand All @@ -637,7 +637,7 @@ function event_location_save_address_field( $term_id ) {
}

$old_value = get_term_meta( $term_id, 'address', true );
$new_value = isset( $_POST['be_event_location_address'] ) ? sanitize_text_field( $_POST['be_event_location_address'] ) : '';
$new_value = isset( $_POST['be_event_location_address'] ) ? sanitize_textarea_field( $_POST['be_event_location_address'] ) : '';

if ( $old_value && '' === $new_value ) {
delete_term_meta( $term_id, 'address' );
Expand Down

0 comments on commit fdfe1d7

Please sign in to comment.