@@ -60,8 +60,8 @@ discard block  | 
                                                    ||
| 60 | 60 | |
| 61 | 61 |  			if ( 'address' === \GV\Utils::get( $search_field, 'type' ) ) { | 
                                                        
| 62 | 62 | |
| 63 | - $field_id = intval( floor( $search_field['key'] ) );  | 
                                                        |
| 64 | - $input_id = gravityview_get_input_id_from_id( $search_field['key'] );  | 
                                                        |
| 63 | + $field_id = intval( floor( $search_field[ 'key' ] ) );  | 
                                                        |
| 64 | + $input_id = gravityview_get_input_id_from_id( $search_field[ 'key' ] );  | 
                                                        |
| 65 | 65 | $form = GravityView_View::getInstance()->getForm();  | 
                                                        
| 66 | 66 | |
| 67 | 67 | /** @var GF_Field_Address $address_field */  | 
                                                        
@@ -70,7 +70,7 @@ discard block  | 
                                                    ||
| 70 | 70 | $choices = array();  | 
                                                        
| 71 | 71 | |
| 72 | 72 | $method_name = 'get_choices_' . self::get_input_type_from_input_id( $input_id );  | 
                                                        
| 73 | -				if( method_exists( $this, $method_name ) ) { | 
                                                        |
| 73 | +				if ( method_exists( $this, $method_name ) ) { | 
                                                        |
| 74 | 74 | /**  | 
                                                        
| 75 | 75 | * @uses GravityView_Field_Address::get_choices_country()  | 
                                                        
| 76 | 76 | * @uses GravityView_Field_Address::get_choices_state()  | 
                                                        
@@ -78,12 +78,12 @@ discard block  | 
                                                    ||
| 78 | 78 |  					$choices = $this->{$method_name}( $address_field, $form ); | 
                                                        
| 79 | 79 | }  | 
                                                        
| 80 | 80 | |
| 81 | -				if( ! empty( $choices ) ) { | 
                                                        |
| 82 | - $search_field['choices'] = $choices;  | 
                                                        |
| 83 | - $search_field['type'] = \GV\Utils::get( $search_field, 'input');  | 
                                                        |
| 81 | +				if ( ! empty( $choices ) ) { | 
                                                        |
| 82 | + $search_field[ 'choices' ] = $choices;  | 
                                                        |
| 83 | + $search_field[ 'type' ] = \GV\Utils::get( $search_field, 'input' );  | 
                                                        |
| 84 | 84 |  				} else { | 
                                                        
| 85 | - $search_field['type'] = 'text';  | 
                                                        |
| 86 | - $search_field['input'] = 'input_text';  | 
                                                        |
| 85 | + $search_field[ 'type' ] = 'text';  | 
                                                        |
| 86 | + $search_field[ 'input' ] = 'input_text';  | 
                                                        |
| 87 | 87 | }  | 
                                                        
| 88 | 88 | }  | 
                                                        
| 89 | 89 | }  | 
                                                        
@@ -109,7 +109,7 @@ discard block  | 
                                                    ||
| 109 | 109 | $country_choices = array();  | 
                                                        
| 110 | 110 | |
| 111 | 111 |  		foreach ( $countries as $key => $country ) { | 
                                                        
| 112 | - $country_choices[] = array(  | 
                                                        |
| 112 | + $country_choices[ ] = array(  | 
                                                        |
| 113 | 113 | 'value' => $country,  | 
                                                        
| 114 | 114 | 'text' => $country,  | 
                                                        
| 115 | 115 | );  | 
                                                        
@@ -134,7 +134,7 @@ discard block  | 
                                                    ||
| 134 | 134 | */  | 
                                                        
| 135 | 135 |  	private function get_choices_state( $address_field, $form ) { | 
                                                        
| 136 | 136 | |
| 137 | - $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form['id'] ) : $address_field->addressType;  | 
                                                        |
| 137 | + $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form[ 'id' ] ) : $address_field->addressType;  | 
                                                        |
| 138 | 138 | |
| 139 | 139 | $state_choices = array();  | 
                                                        
| 140 | 140 | |
@@ -146,8 +146,8 @@ discard block  | 
                                                    ||
| 146 | 146 | $states = GFCommon::get_canadian_provinces();  | 
                                                        
| 147 | 147 | break;  | 
                                                        
| 148 | 148 | default:  | 
                                                        
| 149 | - $address_types = $address_field->get_address_types( $form['id'] );  | 
                                                        |
| 150 | - $states = empty( $address_types[ $address_type ]['states'] ) ? array() : $address_types[ $address_type ]['states'];  | 
                                                        |
| 149 | + $address_types = $address_field->get_address_types( $form[ 'id' ] );  | 
                                                        |
| 150 | + $states = empty( $address_types[ $address_type ][ 'states' ] ) ? array() : $address_types[ $address_type ][ 'states' ];  | 
                                                        |
| 151 | 151 | break;  | 
                                                        
| 152 | 152 | }  | 
                                                        
| 153 | 153 | |
@@ -156,19 +156,19 @@ discard block  | 
                                                    ||
| 156 | 156 | $state_subchoices = array();  | 
                                                        
| 157 | 157 | |
| 158 | 158 |  				foreach ( $state as $substate ) { | 
                                                        
| 159 | - $state_subchoices[] = array(  | 
                                                        |
| 159 | + $state_subchoices[ ] = array(  | 
                                                        |
| 160 | 160 | 'value' => $substate,  | 
                                                        
| 161 | 161 | 'text' => $substate,  | 
                                                        
| 162 | 162 | );  | 
                                                        
| 163 | 163 | }  | 
                                                        
| 164 | 164 | |
| 165 | - $state_choices[] = array(  | 
                                                        |
| 165 | + $state_choices[ ] = array(  | 
                                                        |
| 166 | 166 | 'text' => $key,  | 
                                                        
| 167 | 167 | 'value' => $state_subchoices,  | 
                                                        
| 168 | 168 | );  | 
                                                        
| 169 | 169 | |
| 170 | 170 |  			} else { | 
                                                        
| 171 | - $state_choices[] = array(  | 
                                                        |
| 171 | + $state_choices[ ] = array(  | 
                                                        |
| 172 | 172 | 'value' => $state,  | 
                                                        
| 173 | 173 | 'text' => $state,  | 
                                                        
| 174 | 174 | );  | 
                                                        
@@ -192,13 +192,13 @@ discard block  | 
                                                    ||
| 192 | 192 | // Use the same inputs as the "text" input type allows  | 
                                                        
| 193 | 193 | $text_inputs = \GV\Utils::get( $input_types, 'text' );  | 
                                                        
| 194 | 194 | |
| 195 | - $input_types['street'] = $text_inputs;  | 
                                                        |
| 196 | - $input_types['street2'] = $text_inputs;  | 
                                                        |
| 197 | - $input_types['city'] = $text_inputs;  | 
                                                        |
| 195 | + $input_types[ 'street' ] = $text_inputs;  | 
                                                        |
| 196 | + $input_types[ 'street2' ] = $text_inputs;  | 
                                                        |
| 197 | + $input_types[ 'city' ] = $text_inputs;  | 
                                                        |
| 198 | 198 | |
| 199 | - $input_types['state'] = array( 'select', 'radio', 'link' ) + $text_inputs;  | 
                                                        |
| 200 | - $input_types['zip'] = array( 'input_text' );  | 
                                                        |
| 201 | - $input_types['country'] = array( 'select', 'radio', 'link' ) + $text_inputs;  | 
                                                        |
| 199 | + $input_types[ 'state' ] = array( 'select', 'radio', 'link' ) + $text_inputs;  | 
                                                        |
| 200 | + $input_types[ 'zip' ] = array( 'input_text' );  | 
                                                        |
| 201 | + $input_types[ 'country' ] = array( 'select', 'radio', 'link' ) + $text_inputs;  | 
                                                        |
| 202 | 202 | |
| 203 | 203 | return $input_types;  | 
                                                        
| 204 | 204 | }  | 
                                                        
@@ -219,10 +219,10 @@ discard block  | 
                                                    ||
| 219 | 219 | // Is this search field for an input (eg: 4.2) or the whole address field (eg: 4)?  | 
                                                        
| 220 | 220 | $input_id = gravityview_get_input_id_from_id( $field_id );  | 
                                                        
| 221 | 221 | |
| 222 | -		if( 'address' === $field_type && $input_id ) { | 
                                                        |
| 222 | +		if ( 'address' === $field_type && $input_id ) { | 
                                                        |
| 223 | 223 | |
| 224 | 224 | // If the input ID matches an expected address input, set to that. Otherwise, keep existing input type.  | 
                                                        
| 225 | -			if( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { | 
                                                        |
| 225 | +			if ( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { | 
                                                        |
| 226 | 226 | $input_type = $address_field_name;  | 
                                                        
| 227 | 227 | }  | 
                                                        
| 228 | 228 | }  | 
                                                        
@@ -271,20 +271,20 @@ discard block  | 
                                                    ||
| 271 | 271 |  	function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { | 
                                                        
| 272 | 272 | |
| 273 | 273 | // If this is NOT the full address field, return default options.  | 
                                                        
| 274 | -		if( floor( $field_id ) !== floatval( $field_id ) ) { | 
                                                        |
| 274 | +		if ( floor( $field_id ) !== floatval( $field_id ) ) { | 
                                                        |
| 275 | 275 | return $field_options;  | 
                                                        
| 276 | 276 | }  | 
                                                        
| 277 | 277 | |
| 278 | -		if( 'edit' === $context ) { | 
                                                        |
| 278 | +		if ( 'edit' === $context ) { | 
                                                        |
| 279 | 279 | return $field_options;  | 
                                                        
| 280 | 280 | }  | 
                                                        
| 281 | 281 | |
| 282 | 282 | $add_options = array();  | 
                                                        
| 283 | 283 | |
| 284 | - $add_options['show_map_link'] = array(  | 
                                                        |
| 284 | + $add_options[ 'show_map_link' ] = array(  | 
                                                        |
| 285 | 285 | 'type' => 'checkbox',  | 
                                                        
| 286 | 286 | 'label' => __( 'Show Map Link:', 'gravityview' ),  | 
                                                        
| 287 | -			'desc' => __('Display a "Map It" link below the address', 'gravityview'), | 
                                                        |
| 287 | + 'desc' => __( 'Display a "Map It" link below the address', 'gravityview' ),  | 
                                                        |
| 288 | 288 | 'value' => true,  | 
                                                        
| 289 | 289 | 'merge_tags' => false,  | 
                                                        
| 290 | 290 | );  | 
                                                        
@@ -10,14 +10,14 @@ discard block  | 
                                                    ||
| 10 | 10 | $search_field = $gravityview_view->search_field;  | 
                                                        
| 11 | 11 | |
| 12 | 12 | // Make sure that there are choices to display  | 
                                                        
| 13 | -if( empty( $search_field['choices'] ) ) { | 
                                                        |
| 13 | +if ( empty( $search_field[ 'choices' ] ) ) { | 
                                                        |
| 14 | 14 | gravityview()->log->debug( 'search-field-select.php - No choices for field' );  | 
                                                        
| 15 | 15 | return;  | 
                                                        
| 16 | 16 | }  | 
                                                        
| 17 | 17 | |
| 18 | -if( is_array( $search_field['value'] ) ) { | 
                                                        |
| 18 | +if ( is_array( $search_field[ 'value' ] ) ) { | 
                                                        |
| 19 | 19 | gravityview()->log->debug( 'search-field-select.php - Array values passed; using first value.' );  | 
                                                        
| 20 | - $search_field['value'] = reset( $search_field['value'] );  | 
                                                        |
| 20 | + $search_field[ 'value' ] = reset( $search_field[ 'value' ] );  | 
                                                        |
| 21 | 21 | }  | 
                                                        
| 22 | 22 | |
| 23 | 23 | /**  | 
                                                        
@@ -26,26 +26,26 @@ discard block  | 
                                                    ||
| 26 | 26 | * @param string $default_option Default: `—` (—)  | 
                                                        
| 27 | 27 | * @param string $field_type Field type: "select" or "multiselect"  | 
                                                        
| 28 | 28 | */  | 
                                                        
| 29 | -$default_option = apply_filters('gravityview/extension/search/select_default', '—', 'select' ); | 
                                                        |
| 29 | +$default_option = apply_filters( 'gravityview/extension/search/select_default', '—', 'select' );  | 
                                                        |
| 30 | 30 | |
| 31 | 31 | ?>  | 
                                                        
| 32 | 32 | <div class="gv-search-box gv-search-field-select">  | 
                                                        
| 33 | -	<?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?> | 
                                                        |
| 34 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label>  | 
                                                        |
| 33 | +	<?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { ?> | 
                                                        |
| 34 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label>  | 
                                                        |
| 35 | 35 | <?php } ?>  | 
                                                        
| 36 | 36 | <p>  | 
                                                        
| 37 | - <select name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>">  | 
                                                        |
| 38 | - <option value="" <?php gv_selected( '', $search_field['value'], true ); ?>><?php echo esc_html( $default_option ); ?></option>  | 
                                                        |
| 37 | + <select name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>">  | 
                                                        |
| 38 | + <option value="" <?php gv_selected( '', $search_field[ 'value' ], true ); ?>><?php echo esc_html( $default_option ); ?></option>  | 
                                                        |
| 39 | 39 | <?php  | 
                                                        
| 40 | - foreach( $search_field['choices'] as $choice ) : ?>  | 
                                                        |
| 41 | - <?php if ( is_array( $choice['value'] ) ): ?>  | 
                                                        |
| 42 | - <optgroup label="<?php echo esc_attr( $choice['text'] ); ?>">  | 
                                                        |
| 43 | - <?php foreach ( $choice['value'] as $subchoice ): ?>  | 
                                                        |
| 44 | - <option value="<?php echo esc_attr( $subchoice['value'] ); ?>"><?php echo esc_html( $subchoice['text'] ); ?></option>  | 
                                                        |
| 40 | + foreach ( $search_field[ 'choices' ] as $choice ) : ?>  | 
                                                        |
| 41 | + <?php if ( is_array( $choice[ 'value' ] ) ): ?>  | 
                                                        |
| 42 | + <optgroup label="<?php echo esc_attr( $choice[ 'text' ] ); ?>">  | 
                                                        |
| 43 | + <?php foreach ( $choice[ 'value' ] as $subchoice ): ?>  | 
                                                        |
| 44 | + <option value="<?php echo esc_attr( $subchoice[ 'value' ] ); ?>"><?php echo esc_html( $subchoice[ 'text' ] ); ?></option>  | 
                                                        |
| 45 | 45 | <?php endforeach; ?>  | 
                                                        
| 46 | 46 | </optgroup>  | 
                                                        
| 47 | 47 | <?php else: ?>  | 
                                                        
| 48 | - <option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $search_field['value'] ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option>  | 
                                                        |
| 48 | + <option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php gv_selected( esc_attr( $choice[ 'value' ] ), esc_attr( $search_field[ 'value' ] ), true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option>  | 
                                                        |
| 49 | 49 | <?php endif; ?>  | 
                                                        
| 50 | 50 | <?php endforeach; ?>  | 
                                                        
| 51 | 51 | </select>  | 
                                                        
@@ -44,8 +44,11 @@  | 
                                                    ||
| 44 | 44 | <option value="<?php echo esc_attr( $subchoice['value'] ); ?>"><?php echo esc_html( $subchoice['text'] ); ?></option>  | 
                                                        
| 45 | 45 | <?php endforeach; ?>  | 
                                                        
| 46 | 46 | </optgroup>  | 
                                                        
| 47 | - <?php else: ?>  | 
                                                        |
| 48 | - <option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $search_field['value'] ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option>  | 
                                                        |
| 47 | +				<?php else { | 
                                                        |
| 48 | + : ?>  | 
                                                        |
| 49 | + <option value="<?php echo esc_attr( $choice['value'] );  | 
                                                        |
| 50 | +}  | 
                                                        |
| 51 | +?>" <?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $search_field['value'] ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option>  | 
                                                        |
| 49 | 52 | <?php endif; ?>  | 
                                                        
| 50 | 53 | <?php endforeach; ?>  | 
                                                        
| 51 | 54 | </select>  |