|
@@ -72,7 +72,7 @@ discard block |
|
|
block discarded – undo |
|
72
|
72
|
|
|
73
|
73
|
$disapproved_result = $wpdb->query( $wpdb->prepare( $sql, GravityView_Entry_Approval_Status::DISAPPROVED, '0' ) ); |
|
74
|
74
|
|
|
75
|
|
- if( false === $approved_result || false === $disapproved_result ) { |
|
|
75
|
+ if ( false === $approved_result || false === $disapproved_result ) { |
|
76
|
76
|
gravityview()->log->error( 'There was an error processing the query. {error}', array( 'error' => $wpdb->last_error ) ); |
|
77
|
77
|
} else { |
|
78
|
78
|
// All done: Meta values are migrated |
|
@@ -105,11 +105,11 @@ discard block |
|
|
block discarded – undo |
|
105
|
105
|
$redux_settings = $this->get_redux_settings(); |
|
106
|
106
|
|
|
107
|
107
|
// No need to process |
|
108
|
|
- if( false === $redux_settings ) { |
|
|
108
|
+ if ( false === $redux_settings ) { |
|
109
|
109
|
return; |
|
110
|
110
|
} |
|
111
|
111
|
|
|
112
|
|
- if( empty( $redux_settings['license_key_status'] ) ) { |
|
|
112
|
+ if ( empty( $redux_settings[ 'license_key_status' ] ) ) { |
|
113
|
113
|
$redux_settings = $this->get_redux_license_status( $redux_settings ); |
|
114
|
114
|
} |
|
115
|
115
|
|
|
@@ -123,8 +123,8 @@ discard block |
|
|
block discarded – undo |
|
123
|
123
|
gravityview()->plugin->settings->update( $updated_settings ); |
|
124
|
124
|
|
|
125
|
125
|
// And now remove the previous option, so this is a one-time thing. |
|
126
|
|
- delete_option('gravityview_settings'); |
|
127
|
|
- delete_option('gravityview_settings-transients'); |
|
|
126
|
+ delete_option( 'gravityview_settings' ); |
|
|
127
|
+ delete_option( 'gravityview_settings-transients' ); |
|
128
|
128
|
} |
|
129
|
129
|
|
|
130
|
130
|
/** |
|
@@ -147,9 +147,9 @@ discard block |
|
|
block discarded – undo |
|
147
|
147
|
|
|
148
|
148
|
$license_call = \GV\License_Handler::get()->license_call( $data ); |
|
149
|
149
|
|
|
150
|
|
- if( is_object( $license_call ) && isset( $license_call->license ) ) { |
|
151
|
|
- $redux_settings['license_key_status'] = $license_call->license; |
|
152
|
|
- $redux_settings['license_key_response'] = json_encode( $license_call ); |
|
|
150
|
+ if ( is_object( $license_call ) && isset( $license_call->license ) ) { |
|
|
151
|
+ $redux_settings[ 'license_key_status' ] = $license_call->license; |
|
|
152
|
+ $redux_settings[ 'license_key_response' ] = json_encode( $license_call ); |
|
153
|
153
|
} |
|
154
|
154
|
|
|
155
|
155
|
return $redux_settings; |
|
@@ -163,10 +163,10 @@ discard block |
|
|
block discarded – undo |
|
163
|
163
|
function get_redux_settings() { |
|
164
|
164
|
|
|
165
|
165
|
// Previous settings set by Redux |
|
166
|
|
- $redux_option = get_option('gravityview_settings'); |
|
|
166
|
+ $redux_option = get_option( 'gravityview_settings' ); |
|
167
|
167
|
|
|
168
|
168
|
// No Redux settings? Don't proceed. |
|
169
|
|
- if( false === $redux_option ) { |
|
|
169
|
+ if ( false === $redux_option ) { |
|
170
|
170
|
return false; |
|
171
|
171
|
} |
|
172
|
172
|
|
|
@@ -178,19 +178,19 @@ discard block |
|
|
block discarded – undo |
|
178
|
178
|
|
|
179
|
179
|
if ( $license_array = \GV\Utils::get( $redux_option, 'license' ) ) { |
|
180
|
180
|
|
|
181
|
|
- $redux_settings['license_key'] = $license_key = \GV\Utils::get( $license_array, 'license' ); |
|
|
181
|
+ $redux_settings[ 'license_key' ] = $license_key = \GV\Utils::get( $license_array, 'license' ); |
|
182
|
182
|
|
|
183
|
|
- $redux_last_changed_values = get_option('gravityview_settings-transients'); |
|
|
183
|
+ $redux_last_changed_values = get_option( 'gravityview_settings-transients' ); |
|
184
|
184
|
|
|
185
|
185
|
// This contains the last response for license validation |
|
186
|
|
- if( !empty( $redux_last_changed_values ) && $saved_values = \GV\Utils::get( $redux_last_changed_values, 'changed_values' ) ) { |
|
|
186
|
+ if ( ! empty( $redux_last_changed_values ) && $saved_values = \GV\Utils::get( $redux_last_changed_values, 'changed_values' ) ) { |
|
187
|
187
|
|
|
188
|
188
|
$saved_license = \GV\Utils::get( $saved_values, 'license' ); |
|
189
|
189
|
|
|
190
|
190
|
// Only use the last-saved values if they are for the same license |
|
191
|
|
- if( $saved_license && \GV\Utils::get( $saved_license, 'license' ) === $license_key ) { |
|
192
|
|
- $redux_settings['license_key_status'] = \GV\Utils::get( $saved_license, 'status' ); |
|
193
|
|
- $redux_settings['license_key_response'] = \GV\Utils::get( $saved_license, 'response' ); |
|
|
191
|
+ if ( $saved_license && \GV\Utils::get( $saved_license, 'license' ) === $license_key ) { |
|
|
192
|
+ $redux_settings[ 'license_key_status' ] = \GV\Utils::get( $saved_license, 'status' ); |
|
|
193
|
+ $redux_settings[ 'license_key_response' ] = \GV\Utils::get( $saved_license, 'response' ); |
|
194
|
194
|
} |
|
195
|
195
|
} |
|
196
|
196
|
} |
|
@@ -202,8 +202,8 @@ discard block |
|
|
block discarded – undo |
|
202
|
202
|
/** ---- Migrate from old search widget to new search widget ---- */ |
|
203
|
203
|
function update_search_on_views() { |
|
204
|
204
|
|
|
205
|
|
- if( !class_exists('GravityView_Widget_Search') ) { |
|
206
|
|
- include_once( GRAVITYVIEW_DIR .'includes/extensions/search-widget/class-search-widget.php' ); |
|
|
205
|
+ if ( ! class_exists( 'GravityView_Widget_Search' ) ) { |
|
|
206
|
+ include_once( GRAVITYVIEW_DIR . 'includes/extensions/search-widget/class-search-widget.php' ); |
|
207
|
207
|
} |
|
208
|
208
|
|
|
209
|
209
|
// Loop through all the views |
|
@@ -215,20 +215,20 @@ discard block |
|
|
block discarded – undo |
|
215
|
215
|
|
|
216
|
216
|
$views = get_posts( $query_args ); |
|
217
|
217
|
|
|
218
|
|
- foreach( $views as $view ) { |
|
|
218
|
+ foreach ( $views as $view ) { |
|
219
|
219
|
|
|
220
|
220
|
$widgets = gravityview_get_directory_widgets( $view->ID ); |
|
221
|
221
|
$search_fields = null; |
|
222
|
222
|
|
|
223
|
|
- if( empty( $widgets ) || !is_array( $widgets ) ) { continue; } |
|
|
223
|
+ if ( empty( $widgets ) || ! is_array( $widgets ) ) { continue; } |
|
224
|
224
|
|
|
225
|
225
|
gravityview()->log->debug( '[GravityView_Migrate/update_search_on_views] Loading View ID: {view_id}', array( 'view_id' => $view->ID ) ); |
|
226
|
226
|
|
|
227
|
|
- foreach( $widgets as $area => $ws ) { |
|
228
|
|
- foreach( $ws as $k => $widget ) { |
|
229
|
|
- if( $widget['id'] !== 'search_bar' ) { continue; } |
|
|
227
|
+ foreach ( $widgets as $area => $ws ) { |
|
|
228
|
+ foreach ( $ws as $k => $widget ) { |
|
|
229
|
+ if ( $widget[ 'id' ] !== 'search_bar' ) { continue; } |
|
230
|
230
|
|
|
231
|
|
- if( is_null( $search_fields ) ) { |
|
|
231
|
+ if ( is_null( $search_fields ) ) { |
|
232
|
232
|
$search_fields = $this->get_search_fields( $view->ID ); |
|
233
|
233
|
} |
|
234
|
234
|
|
|
@@ -236,24 +236,24 @@ discard block |
|
|
block discarded – undo |
|
236
|
236
|
// [search_free] => 1 |
|
237
|
237
|
// [search_date] => 1 |
|
238
|
238
|
$search_generic = array(); |
|
239
|
|
- if( !empty( $widget['search_free'] ) ) { |
|
240
|
|
- $search_generic[] = array( 'field' => 'search_all', 'input' => 'input_text' ); |
|
|
239
|
+ if ( ! empty( $widget[ 'search_free' ] ) ) { |
|
|
240
|
+ $search_generic[ ] = array( 'field' => 'search_all', 'input' => 'input_text' ); |
|
241
|
241
|
} |
|
242
|
|
- if( !empty( $widget['search_date'] ) ) { |
|
243
|
|
- $search_generic[] = array( 'field' => 'entry_date', 'input' => 'date' ); |
|
|
242
|
+ if ( ! empty( $widget[ 'search_date' ] ) ) { |
|
|
243
|
+ $search_generic[ ] = array( 'field' => 'entry_date', 'input' => 'date' ); |
|
244
|
244
|
} |
|
245
|
245
|
|
|
246
|
246
|
$search_config = array_merge( $search_generic, $search_fields ); |
|
247
|
247
|
|
|
248
|
248
|
// don't throw '[]' when json_encode an empty array |
|
249
|
|
- if( empty( $search_config ) ) { |
|
|
249
|
+ if ( empty( $search_config ) ) { |
|
250
|
250
|
$search_config = ''; |
|
251
|
251
|
} else { |
|
252
|
252
|
$search_config = json_encode( $search_config ); |
|
253
|
253
|
} |
|
254
|
254
|
|
|
255
|
|
- $widgets[ $area ][ $k ]['search_fields'] = $search_config; |
|
256
|
|
- $widgets[ $area ][ $k ]['search_layout'] = 'horizontal'; |
|
|
255
|
+ $widgets[ $area ][ $k ][ 'search_fields' ] = $search_config; |
|
|
256
|
+ $widgets[ $area ][ $k ][ 'search_layout' ] = 'horizontal'; |
|
257
|
257
|
|
|
258
|
258
|
gravityview()->log->debug( '[GravityView_Migrate/update_search_on_views] Updated Widget: ', array( 'data' => $widgets[ $area ][ $k ] ) ); |
|
259
|
259
|
} |
|
@@ -281,26 +281,26 @@ discard block |
|
|
block discarded – undo |
|
281
|
281
|
// check view fields' settings |
|
282
|
282
|
$fields = gravityview_get_directory_fields( $view_id, false ); |
|
283
|
283
|
|
|
284
|
|
- if( !empty( $fields ) && is_array( $fields ) ) { |
|
|
284
|
+ if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
285
|
285
|
|
|
286
|
|
- foreach( $fields as $t => $fs ) { |
|
|
286
|
+ foreach ( $fields as $t => $fs ) { |
|
287
|
287
|
|
|
288
|
|
- foreach( $fs as $k => $field ) { |
|
|
288
|
+ foreach ( $fs as $k => $field ) { |
|
289
|
289
|
// is field a search_filter ? |
|
290
|
|
- if( empty( $field['search_filter'] ) ) { continue; } |
|
|
290
|
+ if ( empty( $field[ 'search_filter' ] ) ) { continue; } |
|
291
|
291
|
|
|
292
|
292
|
// get field type & calculate the input type (by default) |
|
293
|
|
- $form_field = gravityview_get_field( $form, $field['id'] ); |
|
|
293
|
+ $form_field = gravityview_get_field( $form, $field[ 'id' ] ); |
|
294
|
294
|
|
|
295
|
|
- if( empty( $form_field['type'] ) ) { |
|
|
295
|
+ if ( empty( $form_field[ 'type' ] ) ) { |
|
296
|
296
|
continue; |
|
297
|
297
|
} |
|
298
|
298
|
|
|
299
|
299
|
// depending on the field type assign a group of possible search field types |
|
300
|
|
- $type = GravityView_Widget_Search::get_search_input_types( $field['id'], $form_field['type'] ); |
|
|
300
|
+ $type = GravityView_Widget_Search::get_search_input_types( $field[ 'id' ], $form_field[ 'type' ] ); |
|
301
|
301
|
|
|
302
|
302
|
// add field to config |
|
303
|
|
- $search_fields[] = array( 'field' => $field['id'], 'input' => $type ); |
|
|
303
|
+ $search_fields[ ] = array( 'field' => $field[ 'id' ], 'input' => $type ); |
|
304
|
304
|
|
|
305
|
305
|
} |
|
306
|
306
|
} |