@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - if( ! is_admin() ) { return; } |
|
21 | + if ( ! is_admin() ) { return; } |
|
22 | 22 | |
23 | 23 | $this->add_hooks(); |
24 | 24 | } |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | */ |
33 | 33 | private function add_hooks() { |
34 | 34 | //Hooks for no-conflict functionality |
35 | - add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000); |
|
36 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9); |
|
35 | + add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000 ); |
|
36 | + add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9 ); |
|
37 | 37 | |
38 | - add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000); |
|
39 | - add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11); |
|
40 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1); |
|
41 | - add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1); |
|
38 | + add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000 ); |
|
39 | + add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11 ); |
|
40 | + add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1 ); |
|
41 | + add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1 ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | function no_conflict_scripts() { |
52 | 52 | global $wp_scripts; |
53 | 53 | |
54 | - if( ! gravityview()->request->is_admin( '', null ) ) { |
|
54 | + if ( ! gravityview()->request->is_admin( '', null ) ) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | 58 | $no_conflict_mode = gravityview()->plugin->settings->get( 'no-conflict-mode' ); |
59 | 59 | |
60 | - if( empty( $no_conflict_mode ) ) { |
|
60 | + if ( empty( $no_conflict_mode ) ) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | function no_conflict_styles() { |
117 | 117 | global $wp_styles; |
118 | 118 | |
119 | - if( ! gravityview()->request->is_admin( '', null ) ) { |
|
119 | + if ( ! gravityview()->request->is_admin( '', null ) ) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | 123 | // Dequeue other jQuery styles even if no-conflict is off. |
124 | 124 | // Terrible-looking tabs help no one. |
125 | - if( !empty( $wp_styles->registered ) ) { |
|
126 | - foreach ($wp_styles->registered as $key => $style) { |
|
127 | - if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
125 | + if ( ! empty( $wp_styles->registered ) ) { |
|
126 | + foreach ( $wp_styles->registered as $key => $style ) { |
|
127 | + if ( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
128 | 128 | wp_dequeue_style( $key ); |
129 | 129 | } |
130 | 130 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $no_conflict_mode = gravityview()->plugin->settings->get( 'no-conflict-mode' ); |
134 | 134 | |
135 | 135 | // If no conflict is off, jQuery will suffice. |
136 | - if( empty( $no_conflict_mode ) ) { |
|
136 | + if ( empty( $no_conflict_mode ) ) { |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | /** |
162 | 162 | * @action `gravityview_remove_conflicts_after` Runs after no-conflict styles are removed. You can re-add styles here. |
163 | 163 | */ |
164 | - do_action('gravityview_remove_conflicts_after'); |
|
164 | + do_action( 'gravityview_remove_conflicts_after' ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | |
195 | 195 | //reset queue |
196 | 196 | $queue = array(); |
197 | - foreach( $wp_objects->queue as $object ) { |
|
198 | - if( in_array( $object, $required_objects ) || preg_match( $allow_regex, $object ) ) { |
|
199 | - $queue[] = $object; |
|
197 | + foreach ( $wp_objects->queue as $object ) { |
|
198 | + if ( in_array( $object, $required_objects ) || preg_match( $allow_regex, $object ) ) { |
|
199 | + $queue[ ] = $object; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | $wp_objects->queue = $queue; |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | |
206 | 206 | //unregistering scripts |
207 | 207 | $registered = array(); |
208 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
209 | - if( in_array( $handle, $required_objects ) || preg_match( $allow_regex, $handle ) ){ |
|
208 | + foreach ( $wp_objects->registered as $handle => $script_registration ) { |
|
209 | + if ( in_array( $handle, $required_objects ) || preg_match( $allow_regex, $handle ) ) { |
|
210 | 210 | $registered[ $handle ] = $script_registration; |
211 | 211 | } |
212 | 212 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @param array $registered [description] |
222 | 222 | * @param array $scripts [description] |
223 | 223 | */ |
224 | - private function add_script_dependencies($registered, $scripts) { |
|
224 | + private function add_script_dependencies( $registered, $scripts ) { |
|
225 | 225 | |
226 | 226 | //gets all dependent scripts linked to the $scripts array passed |
227 | 227 | do { |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $deps = isset( $registered[ $script ] ) && is_array( $registered[ $script ]->deps ) ? $registered[ $script ]->deps : array(); |
231 | 231 | foreach ( $deps as $dep ) { |
232 | 232 | if ( ! in_array( $dep, $scripts ) && ! in_array( $dep, $dependents ) ) { |
233 | - $dependents[] = $dep; |
|
233 | + $dependents[ ] = $dep; |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | ); |
107 | 107 | |
108 | 108 | if ( ! empty( $action ) ) { |
109 | - $settings['edd_action'] = esc_attr( $action ); |
|
109 | + $settings[ 'edd_action' ] = esc_attr( $action ); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | return array_map( 'urlencode', $settings ); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // If doing ajax, get outta here. |
129 | - if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST('action') ) ) { |
|
129 | + if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST( 'action' ) ) ) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | 'format' => 'json', |
174 | 174 | ) ); |
175 | 175 | |
176 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
176 | + if ( $is_ajax && empty( $data[ 'license' ] ) ) { |
|
177 | 177 | die( -1 ); |
178 | 178 | } |
179 | 179 | |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | |
202 | 202 | $json = json_encode( $license_data ); |
203 | 203 | |
204 | - $update_license = Utils::get( $data, 'update' ) || 'gravityview_license' === Utils::_POST('action'); |
|
204 | + $update_license = Utils::get( $data, 'update' ) || 'gravityview_license' === Utils::_POST( 'action' ); |
|
205 | 205 | |
206 | 206 | $is_check_action_button = ( 'check_license' === Utils::get( $data, 'edd_action' ) && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
207 | 207 | |
208 | - do_action('gravityview/admin_installer/delete_downloads_data', true ); |
|
208 | + do_action( 'gravityview/admin_installer/delete_downloads_data', true ); |
|
209 | 209 | |
210 | 210 | if ( $is_check_action_button ) { |
211 | 211 | delete_transient( self::status_transient_key ); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | // most likely a mistake. |
217 | 217 | } else if ( $license_data->license !== 'failed' && $update_license ) { |
218 | 218 | |
219 | - if ( ! empty( $data['field_id'] ) ) { |
|
219 | + if ( ! empty( $data[ 'field_id' ] ) ) { |
|
220 | 220 | set_transient( self::status_transient_key, $license_data, DAY_IN_SECONDS ); |
221 | 221 | } |
222 | 222 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $class = 'hide'; |
245 | 245 | $message = ''; |
246 | 246 | } else { |
247 | - if( ! empty( $license_data->error ) ) { |
|
247 | + if ( ! empty( $license_data->error ) ) { |
|
248 | 248 | $class = 'error'; |
249 | 249 | $string_key = $license_data->error; |
250 | 250 | } else { $class = $license_data->license; |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public function license_details( $response = array() ) { |
270 | 270 | |
271 | - $response = (array) $response; |
|
271 | + $response = (array)$response; |
|
272 | 272 | |
273 | 273 | $return = ''; |
274 | 274 | $wrapper = '<span class="gv-license-details" aria-live="polite" aria-busy="false">%s</span>'; |
275 | 275 | |
276 | - if ( ! empty( $response['license_key'] ) ) { |
|
276 | + if ( ! empty( $response[ 'license_key' ] ) ) { |
|
277 | 277 | $return .= '<h3>' . rtrim( esc_html__( 'License Details:', 'gravityview' ), ':' ) . '</h3>'; |
278 | 278 | |
279 | 279 | if ( in_array( Utils::get( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | |
285 | - $return .= $this->strings( $response['license'], $response ); |
|
286 | - } elseif ( ! empty( $response['license_name'] ) ) { |
|
285 | + $return .= $this->strings( $response[ 'license' ], $response ); |
|
286 | + } elseif ( ! empty( $response[ 'license_name' ] ) ) { |
|
287 | 287 | $response_keys = array( |
288 | 288 | 'license_name' => '', |
289 | 289 | 'license_limit' => '', |
@@ -298,22 +298,22 @@ discard block |
||
298 | 298 | $response = wp_parse_args( $response, $response_keys ); |
299 | 299 | |
300 | 300 | $login_link_class = gravityview()->plugin->is_GF_25() ? 'button button-outline outline' : 'text-link'; |
301 | - $renews_on = ( 'lifetime' === $response['expires'] ) ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response['expires'] ) - DAY_IN_SECONDS ) ); |
|
302 | - $login_link = sprintf( '<a href="%s" class="gv-access-account ' . $login_link_class . '" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response['customer_email'] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
303 | - $local_text = ( ! empty( $response['is_local'] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
304 | - $license_limit = empty( $response['license_limit'] ) ? __( 'Unlimited', 'gravityview' ) : (int) $response['license_limit']; |
|
301 | + $renews_on = ( 'lifetime' === $response[ 'expires' ] ) ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response[ 'expires' ] ) - DAY_IN_SECONDS ) ); |
|
302 | + $login_link = sprintf( '<a href="%s" class="gv-access-account ' . $login_link_class . '" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response[ 'customer_email' ] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
303 | + $local_text = ( ! empty( $response[ 'is_local' ] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
304 | + $license_limit = empty( $response[ 'license_limit' ] ) ? __( 'Unlimited', 'gravityview' ) : (int)$response[ 'license_limit' ]; |
|
305 | 305 | |
306 | 306 | |
307 | 307 | $details = array( |
308 | - 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), '<span class="gv-license-detail">' . esc_html( $response['license_name'] ) . '</span>' ), |
|
309 | - 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), '<span class="gv-license-detail">' . esc_html__( $response['customer_name'], 'gravityview' ), esc_html__( $response['customer_email'], 'gravityview' ) ) . '</span>' . $renews_on . $login_link, |
|
310 | - 'activations' => sprintf( str_replace( '%d', '%s', esc_html__( 'Activations: %d of %s sites', 'gravityview' ) ), '<span class="gv-license-detail">' . intval( $response['site_count'] ), esc_html( $license_limit ) ) . '</span>' . $local_text, |
|
311 | - 'upgrade' => $this->get_upgrade_html( $response['upgrades'] ), |
|
308 | + 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), '<span class="gv-license-detail">' . esc_html( $response[ 'license_name' ] ) . '</span>' ), |
|
309 | + 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), '<span class="gv-license-detail">' . esc_html__( $response[ 'customer_name' ], 'gravityview' ), esc_html__( $response[ 'customer_email' ], 'gravityview' ) ) . '</span>' . $renews_on . $login_link, |
|
310 | + 'activations' => sprintf( str_replace( '%d', '%s', esc_html__( 'Activations: %d of %s sites', 'gravityview' ) ), '<span class="gv-license-detail">' . intval( $response[ 'site_count' ] ), esc_html( $license_limit ) ) . '</span>' . $local_text, |
|
311 | + 'upgrade' => $this->get_upgrade_html( $response[ 'upgrades' ] ), |
|
312 | 312 | ); |
313 | 313 | |
314 | - if ( ! empty( $response['error'] ) && 'expired' === $response['error'] ) { |
|
315 | - unset( $details['upgrade'] ); |
|
316 | - $details['licensed_to'] .= '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
314 | + if ( ! empty( $response[ 'error' ] ) && 'expired' === $response[ 'error' ] ) { |
|
315 | + unset( $details[ 'upgrade' ] ); |
|
316 | + $details[ 'licensed_to' ] .= '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | $return .= '<ul>'; |
@@ -345,20 +345,20 @@ discard block |
||
345 | 345 | if ( ! empty( $upgrades ) ) { |
346 | 346 | |
347 | 347 | $locale_parts = explode( '_', get_locale() ); |
348 | - $is_english = ( 'en' === $locale_parts[0] ); |
|
348 | + $is_english = ( 'en' === $locale_parts[ 0 ] ); |
|
349 | 349 | |
350 | 350 | $output .= '<h4>' . esc_html__( 'Upgrades available:', 'gravityview' ) . '</h4>'; |
351 | 351 | $output .= '<ul>'; |
352 | 352 | |
353 | 353 | foreach ( $upgrades as $upgrade_id => $upgrade ) { |
354 | - $upgrade = (object) $upgrade; |
|
354 | + $upgrade = (object)$upgrade; |
|
355 | 355 | |
356 | 356 | $anchor_text = sprintf( esc_html_x( 'Upgrade to %1$s for %2$s', '1: GravityView upgrade name, 2: Cost of upgrade', 'gravityview' ), esc_attr( $upgrade->name ), esc_attr( $upgrade->price ) ); |
357 | 357 | |
358 | 358 | if ( $is_english && isset( $upgrade->description ) ) { |
359 | 359 | $message = esc_html( $upgrade->description ); |
360 | 360 | } else { |
361 | - switch( $upgrade->price_id ) { |
|
361 | + switch ( $upgrade->price_id ) { |
|
362 | 362 | // Interstellar |
363 | 363 | case 1: |
364 | 364 | default: |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | 'invalid_item_id' => esc_html__( 'This license key does not have access to this plugin.', 'gravityview' ), |
438 | 438 | 'missing' => esc_html__( 'The license key entered is invalid.', 'gravityview' ), // Missing is "the license couldn't be found", not "you submitted an empty license" |
439 | 439 | 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ), |
440 | - 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
440 | + 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="' . esc_url( $this->get_license_renewal_url( $license_data ) ) . '">', '</a>' ), |
|
441 | 441 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
442 | 442 | 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ), |
443 | 443 | 'activate_license' => esc_html__( 'Activate License', 'gravityview' ), |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | |
466 | 466 | if ( ! empty( $license_data->renewal_url ) ) { |
467 | 467 | $renew_license_url = $license_data->renewal_url; |
468 | - } elseif( ! empty( $license_data->license_key ) ) { |
|
468 | + } elseif ( ! empty( $license_data->license_key ) ) { |
|
469 | 469 | $renew_license_url = sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s', $license_data->license_key ); |
470 | 470 | } else { |
471 | 471 | $renew_license_url = 'https://gravityview.co/account/'; |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | * @return array|\WP_Error |
483 | 483 | */ |
484 | 484 | private function _license_get_remote_response( $data, $license = '' ) { |
485 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
485 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license ); |
|
486 | 486 | |
487 | 487 | $url = add_query_arg( $api_params, self::url ); |
488 | 488 | |
@@ -522,9 +522,9 @@ discard block |
||
522 | 522 | private function license_call_update_settings( $license_data, $data ) { |
523 | 523 | $settings = array(); |
524 | 524 | |
525 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
526 | - $settings['license_key_status'] = $license_data->license; |
|
527 | - $settings['license_key_response'] = (array)$license_data; |
|
525 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] ); |
|
526 | + $settings[ 'license_key_status' ] = $license_data->license; |
|
527 | + $settings[ 'license_key_response' ] = (array)$license_data; |
|
528 | 528 | |
529 | 529 | $this->settings->set( $settings ); |
530 | 530 | } |
@@ -544,9 +544,9 @@ discard block |
||
544 | 544 | $status = trim( $this->settings->get( 'license_key_status' ) ); |
545 | 545 | $key = trim( $this->settings->get( 'license_key' ) ); |
546 | 546 | |
547 | - if ( !empty( $key ) ) { |
|
547 | + if ( ! empty( $key ) ) { |
|
548 | 548 | $response = $this->settings->get( 'license_key_response' ); |
549 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
549 | + $response = is_array( $response ) ? (object)$response : json_decode( $response ); |
|
550 | 550 | } else { |
551 | 551 | $response = array(); |
552 | 552 | } |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | |
590 | 590 | $submit = '<div class="gv-edd-button-wrapper">'; |
591 | 591 | foreach ( $fields as $field ) { |
592 | - $field['type'] = 'button'; |
|
593 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
594 | - $field['style'] = 'margin-left: 10px;'; |
|
595 | - if( $disabled_attribute ) { |
|
596 | - $field['disabled'] = $disabled_attribute; |
|
592 | + $field[ 'type' ] = 'button'; |
|
593 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class; |
|
594 | + $field[ 'style' ] = 'margin-left: 10px;'; |
|
595 | + if ( $disabled_attribute ) { |
|
596 | + $field[ 'disabled' ] = $disabled_attribute; |
|
597 | 597 | } |
598 | 598 | $submit .= $this->settings->as_html( $field, $echo ); |
599 | 599 | } |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | 'url' => home_url(), |
672 | 672 | 'site_data' => $this->get_site_data(), |
673 | 673 | ), |
674 | - )); |
|
674 | + ) ); |
|
675 | 675 | |
676 | 676 | // make sure the response came back okay |
677 | 677 | if ( is_wp_error( $response ) ) { |
@@ -701,45 +701,45 @@ discard block |
||
701 | 701 | $theme_data = wp_get_theme(); |
702 | 702 | $theme = $theme_data->Name . ' ' . $theme_data->Version; |
703 | 703 | |
704 | - $data['gv_version'] = Plugin::$version; |
|
705 | - $data['php_version'] = phpversion(); |
|
706 | - $data['wp_version'] = get_bloginfo( 'version' ); |
|
707 | - $data['gf_version'] = \GFForms::$version; |
|
708 | - $data['server'] = Utils::get( $_SERVER, 'SERVER_SOFTWARE' ); |
|
709 | - $data['multisite'] = is_multisite(); |
|
710 | - $data['theme'] = $theme; |
|
711 | - $data['url'] = home_url(); |
|
712 | - $data['license_key'] = $this->settings->get( 'license_key' ); |
|
713 | - $data['beta'] = $this->settings->get( 'beta' ); |
|
704 | + $data[ 'gv_version' ] = Plugin::$version; |
|
705 | + $data[ 'php_version' ] = phpversion(); |
|
706 | + $data[ 'wp_version' ] = get_bloginfo( 'version' ); |
|
707 | + $data[ 'gf_version' ] = \GFForms::$version; |
|
708 | + $data[ 'server' ] = Utils::get( $_SERVER, 'SERVER_SOFTWARE' ); |
|
709 | + $data[ 'multisite' ] = is_multisite(); |
|
710 | + $data[ 'theme' ] = $theme; |
|
711 | + $data[ 'url' ] = home_url(); |
|
712 | + $data[ 'license_key' ] = $this->settings->get( 'license_key' ); |
|
713 | + $data[ 'beta' ] = $this->settings->get( 'beta' ); |
|
714 | 714 | |
715 | 715 | // View Data |
716 | 716 | $gravityview_posts = wp_count_posts( 'gravityview', 'readable' ); |
717 | 717 | |
718 | - $data['view_count'] = null; |
|
719 | - $data['view_first'] = null; |
|
720 | - $data['view_latest'] = null; |
|
718 | + $data[ 'view_count' ] = null; |
|
719 | + $data[ 'view_first' ] = null; |
|
720 | + $data[ 'view_latest' ] = null; |
|
721 | 721 | |
722 | 722 | if ( $gravityview_posts->publish ) { |
723 | - $data['view_count'] = $gravityview_posts->publish; |
|
723 | + $data[ 'view_count' ] = $gravityview_posts->publish; |
|
724 | 724 | |
725 | 725 | $first = get_posts( 'numberposts=1&post_type=gravityview&post_status=publish&order=ASC' ); |
726 | 726 | $latest = get_posts( 'numberposts=1&post_type=gravityview&post_status=publish&order=DESC' ); |
727 | 727 | |
728 | 728 | if ( $first = array_shift( $first ) ) { |
729 | - $data['view_first'] = $first->post_date; |
|
729 | + $data[ 'view_first' ] = $first->post_date; |
|
730 | 730 | } |
731 | 731 | if ( $latest = array_pop( $latest ) ) { |
732 | - $data['view_latest'] = $latest->post_date; |
|
732 | + $data[ 'view_latest' ] = $latest->post_date; |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
736 | 736 | // Form counts |
737 | 737 | if ( class_exists( 'GFFormsModel' ) ) { |
738 | 738 | $form_data = \GFFormsModel::get_form_count(); |
739 | - $data['forms_total'] = Utils::get( $form_data, 'total', 0 ); |
|
740 | - $data['forms_active'] = Utils::get( $form_data, 'active', 0 ); |
|
741 | - $data['forms_inactive'] = Utils::get( $form_data, 'inactive', 0 ); |
|
742 | - $data['forms_trash'] = Utils::get( $form_data, 'inactive', 0 ); |
|
739 | + $data[ 'forms_total' ] = Utils::get( $form_data, 'total', 0 ); |
|
740 | + $data[ 'forms_active' ] = Utils::get( $form_data, 'active', 0 ); |
|
741 | + $data[ 'forms_inactive' ] = Utils::get( $form_data, 'inactive', 0 ); |
|
742 | + $data[ 'forms_trash' ] = Utils::get( $form_data, 'inactive', 0 ); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | // Retrieve current plugin information |
@@ -747,13 +747,13 @@ discard block |
||
747 | 747 | include ABSPATH . '/wp-admin/includes/plugin.php'; |
748 | 748 | } |
749 | 749 | |
750 | - $data['integrations'] = self::get_related_plugins_and_extensions(); |
|
751 | - $data['active_plugins'] = get_option( 'active_plugins', array() ); |
|
752 | - $data['inactive_plugins'] = array(); |
|
753 | - $data['locale'] = get_locale(); |
|
750 | + $data[ 'integrations' ] = self::get_related_plugins_and_extensions(); |
|
751 | + $data[ 'active_plugins' ] = get_option( 'active_plugins', array() ); |
|
752 | + $data[ 'inactive_plugins' ] = array(); |
|
753 | + $data[ 'locale' ] = get_locale(); |
|
754 | 754 | |
755 | 755 | // Validate request on the GV server |
756 | - $data['hash'] = 'gv_version.url.locale:' . sha1( $data['gv_version'] . $data['url'] . $data['locale'] ); |
|
756 | + $data[ 'hash' ] = 'gv_version.url.locale:' . sha1( $data[ 'gv_version' ] . $data[ 'url' ] . $data[ 'locale' ] ); |
|
757 | 757 | |
758 | 758 | return $data; |
759 | 759 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | |
784 | 784 | $plugin_data = get_plugin_data( $active_plugin ); |
785 | 785 | |
786 | - $extensions[] = sprintf( '%s %s', $plugin_data['Name'], $plugin_data['Version'] ); |
|
786 | + $extensions[ ] = sprintf( '%s %s', $plugin_data[ 'Name' ], $plugin_data[ 'Version' ] ); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | if ( ! empty( $extensions ) ) { |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | $tab = wp_parse_args( $tab_settings, $tab_defaults ); |
181 | 181 | |
182 | 182 | // Force the screen to be GravityView |
183 | - $tab['screen'] = 'gravityview'; |
|
183 | + $tab[ 'screen' ] = 'gravityview'; |
|
184 | 184 | |
185 | 185 | if ( class_exists( 'GravityView_Metabox_Tab' ) ) { |
186 | - $metabox = new \GravityView_Metabox_Tab( $tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args'] ); |
|
186 | + $metabox = new \GravityView_Metabox_Tab( $tab[ 'id' ], $tab[ 'title' ], $tab[ 'file' ], $tab[ 'icon-class' ], $tab[ 'callback' ], $tab[ 'callback_args' ] ); |
|
187 | 187 | \GravityView_Metabox_Tabs::add( $metabox ); |
188 | 188 | } else { |
189 | - add_meta_box( 'gravityview_' . $tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority'] ); |
|
189 | + add_meta_box( 'gravityview_' . $tab[ 'id' ], $tab[ 'title' ], $tab[ 'callback' ], $tab[ 'screen' ], $tab[ 'context' ], $tab[ 'priority' ] ); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | */ |
212 | 212 | protected function is_extension_supported() { |
213 | 213 | |
214 | - self::$is_compatible = is_array( self::$is_compatible ) ? self::$is_compatible : array( get_called_class() => (bool) self::$is_compatible ); |
|
214 | + self::$is_compatible = is_array( self::$is_compatible ) ? self::$is_compatible : array( get_called_class() => (bool)self::$is_compatible ); |
|
215 | 215 | |
216 | 216 | if ( ! function_exists( 'gravityview' ) ) { |
217 | 217 | $message = sprintf( __( 'Could not activate the %s Extension; GravityView is not active.', 'gravityview' ), esc_html( $this->_title ) ); |
218 | - } else if ( false === version_compare( Plugin::$version, $this->_min_gravityview_version , ">=" ) ) { |
|
219 | - $message = sprintf( __( 'The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), esc_html( $this->_title ), '<tt>'.$this->_min_gravityview_version.'</tt>' ); |
|
220 | - } else if ( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version , ">=" ) ) { |
|
221 | - $message = sprintf( __( 'The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), esc_html( $this->_title ), '<tt>'.$this->_min_php_version.'</tt>' ); |
|
218 | + } else if ( false === version_compare( Plugin::$version, $this->_min_gravityview_version, ">=" ) ) { |
|
219 | + $message = sprintf( __( 'The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), esc_html( $this->_title ), '<tt>' . $this->_min_gravityview_version . '</tt>' ); |
|
220 | + } else if ( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version, ">=" ) ) { |
|
221 | + $message = sprintf( __( 'The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), esc_html( $this->_title ), '<tt>' . $this->_min_php_version . '</tt>' ); |
|
222 | 222 | } else if ( ! empty( $this->_max_gravityview_version ) && false === version_compare( $this->_max_gravityview_version, Plugin::$version, ">" ) ) { |
223 | 223 | $message = sprintf( __( 'The %s Extension is not compatible with this version of GravityView. Please update the Extension to the latest version.', 'gravityview' ), esc_html( $this->_title ) ); |
224 | 224 | } else { |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | |
259 | 259 | $locale = get_locale(); |
260 | 260 | |
261 | - if ( function_exists('get_user_locale') && is_admin() ) { |
|
261 | + if ( function_exists( 'get_user_locale' ) && is_admin() ) { |
|
262 | 262 | $locale = get_user_locale(); |
263 | 263 | } |
264 | 264 | |
265 | 265 | // Traditional WordPress plugin locale filter |
266 | - $locale = apply_filters( 'plugin_locale', $locale, $this->_text_domain ); |
|
266 | + $locale = apply_filters( 'plugin_locale', $locale, $this->_text_domain ); |
|
267 | 267 | |
268 | 268 | $mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale ); |
269 | 269 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | public function settings() { |
292 | 292 | |
293 | 293 | // If doing ajax, get outta here. |
294 | - if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST('action') ) ) { |
|
294 | + if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST( 'action' ) ) ) { |
|
295 | 295 | return; |
296 | 296 | } |
297 | 297 | |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | 'version' => $this->_version, // current version number |
315 | 315 | 'license' => \GV\Utils::get( $license, 'license_key', \GV\Utils::get( $license, 'license', null ) ), |
316 | 316 | 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
317 | - 'item_name' => $this->_title, // name of this plugin |
|
318 | - 'author' => strip_tags( $this->_author ), // author of this plugin |
|
317 | + 'item_name' => $this->_title, // name of this plugin |
|
318 | + 'author' => strip_tags( $this->_author ), // author of this plugin |
|
319 | 319 | 'php_version' => phpversion(), |
320 | 320 | 'wp_version' => get_bloginfo( 'version' ), |
321 | 321 | 'gv_version' => \GV\Plugin::$version, |
@@ -347,16 +347,16 @@ discard block |
||
347 | 347 | */ |
348 | 348 | public static function add_notice( $notice = array() ) { |
349 | 349 | |
350 | - if ( is_array( $notice ) && empty( $notice['message'] ) ) { |
|
350 | + if ( is_array( $notice ) && empty( $notice[ 'message' ] ) ) { |
|
351 | 351 | gravityview()->log->error( 'Notice not set', array( 'data' => $notice ) ); |
352 | 352 | return; |
353 | 353 | } else if ( is_string( $notice ) ) { |
354 | 354 | $notice = array( 'message' => $notice ); |
355 | 355 | } |
356 | 356 | |
357 | - $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; |
|
357 | + $notice[ 'class' ] = empty( $notice[ 'class' ] ) ? 'error' : $notice[ 'class' ]; |
|
358 | 358 | |
359 | - self::$admin_notices []= $notice; |
|
359 | + self::$admin_notices [ ] = $notice; |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | foreach ( self::$admin_notices as $key => $notice ) { |
373 | - echo '<div id="message" class="'. esc_attr( $notice['class'] ).'">'; |
|
374 | - echo wpautop( $notice['message'] ); |
|
373 | + echo '<div id="message" class="' . esc_attr( $notice[ 'class' ] ) . '">'; |
|
374 | + echo wpautop( $notice[ 'message' ] ); |
|
375 | 375 | echo '<div class="clear"></div>'; |
376 | 376 | echo '</div>'; |
377 | 377 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | // autoload-classmap.php @generated by Strauss |
4 | 4 | |
5 | -$trustedlogin = dirname(__FILE__); |
|
5 | +$trustedlogin = dirname( __FILE__ ); |
|
6 | 6 | |
7 | 7 | return array( |
8 | 8 | 'GravityView\Psr\Log\LoggerAwareTrait' => $trustedlogin . '/psr/log/Psr/Log/LoggerAwareTrait.php', |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | $this->plugin_file = $_plugin_file; |
50 | 50 | $this->name = plugin_basename( $_plugin_file ); |
51 | 51 | $this->slug = basename( $_plugin_file, '.php' ); |
52 | - $this->version = $_api_data['version']; |
|
53 | - $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; |
|
54 | - $this->beta = ! empty( $this->api_data['beta'] ) ? true : false; |
|
52 | + $this->version = $_api_data[ 'version' ]; |
|
53 | + $this->wp_override = isset( $_api_data[ 'wp_override' ] ) ? (bool)$_api_data[ 'wp_override' ] : false; |
|
54 | + $this->beta = ! empty( $this->api_data[ 'beta' ] ) ? true : false; |
|
55 | 55 | $this->failed_request_cache_key = 'edd_sl_failed_http_' . md5( $this->api_url ); |
56 | 56 | |
57 | 57 | $edd_plugin_data[ $this->slug ] = $this->api_data; |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | printf( |
230 | 230 | /* translators: the plugin name. */ |
231 | 231 | esc_html__( 'There is a new version of %1$s available.', 'gravityview' ), |
232 | - esc_html( $plugin['Name'] ) |
|
232 | + esc_html( $plugin[ 'Name' ] ) |
|
233 | 233 | ); |
234 | 234 | |
235 | 235 | if ( ! current_user_can( 'update_plugins' ) ) { |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | * @return array |
275 | 275 | */ |
276 | 276 | private function get_active_plugins() { |
277 | - $active_plugins = (array) get_option( 'active_plugins' ); |
|
278 | - $active_network_plugins = (array) get_site_option( 'active_sitewide_plugins' ); |
|
277 | + $active_plugins = (array)get_option( 'active_plugins' ); |
|
278 | + $active_network_plugins = (array)get_site_option( 'active_sitewide_plugins' ); |
|
279 | 279 | |
280 | 280 | return array_merge( $active_plugins, array_keys( $active_network_plugins ) ); |
281 | 281 | } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | public function http_request_args( $args, $url ) { |
394 | 394 | |
395 | 395 | if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
396 | - $args['sslverify'] = $this->verify_ssl(); |
|
396 | + $args[ 'sslverify' ] = $this->verify_ssl(); |
|
397 | 397 | } |
398 | 398 | return $args; |
399 | 399 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | private function api_request( $_action, $_data ) { |
414 | 414 | $data = array_merge( $this->api_data, $_data ); |
415 | 415 | |
416 | - if ( $data['slug'] !== $this->slug ) { |
|
416 | + if ( $data[ 'slug' ] !== $this->slug ) { |
|
417 | 417 | return; |
418 | 418 | } |
419 | 419 | |
@@ -477,15 +477,15 @@ discard block |
||
477 | 477 | */ |
478 | 478 | public function show_changelog() { |
479 | 479 | |
480 | - if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' !== $_REQUEST['edd_sl_action'] ) { |
|
480 | + if ( empty( $_REQUEST[ 'edd_sl_action' ] ) || 'view_plugin_changelog' !== $_REQUEST[ 'edd_sl_action' ] ) { |
|
481 | 481 | return; |
482 | 482 | } |
483 | 483 | |
484 | - if ( empty( $_REQUEST['plugin'] ) ) { |
|
484 | + if ( empty( $_REQUEST[ 'plugin' ] ) ) { |
|
485 | 485 | return; |
486 | 486 | } |
487 | 487 | |
488 | - if ( empty( $_REQUEST['slug'] ) || $this->slug !== $_REQUEST['slug'] ) { |
|
488 | + if ( empty( $_REQUEST[ 'slug' ] ) || $this->slug !== $_REQUEST[ 'slug' ] ) { |
|
489 | 489 | return; |
490 | 490 | } |
491 | 491 | |
@@ -496,8 +496,8 @@ discard block |
||
496 | 496 | $version_info = $this->get_repo_api_data(); |
497 | 497 | if ( isset( $version_info->sections ) ) { |
498 | 498 | $sections = $this->convert_object_to_array( $version_info->sections ); |
499 | - if ( ! empty( $sections['changelog'] ) ) { |
|
500 | - echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>'; |
|
499 | + if ( ! empty( $sections[ 'changelog' ] ) ) { |
|
500 | + echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections[ 'changelog' ] ) . '</div>'; |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
@@ -512,12 +512,12 @@ discard block |
||
512 | 512 | private function get_version_from_remote() { |
513 | 513 | $api_params = array( |
514 | 514 | 'edd_action' => 'get_version', |
515 | - 'license' => ! empty( $this->api_data['license'] ) ? $this->api_data['license'] : '', |
|
516 | - 'item_name' => isset( $this->api_data['item_name'] ) ? $this->api_data['item_name'] : false, |
|
517 | - 'item_id' => isset( $this->api_data['item_id'] ) ? $this->api_data['item_id'] : false, |
|
518 | - 'version' => isset( $this->api_data['version'] ) ? $this->api_data['version'] : false, |
|
515 | + 'license' => ! empty( $this->api_data[ 'license' ] ) ? $this->api_data[ 'license' ] : '', |
|
516 | + 'item_name' => isset( $this->api_data[ 'item_name' ] ) ? $this->api_data[ 'item_name' ] : false, |
|
517 | + 'item_id' => isset( $this->api_data[ 'item_id' ] ) ? $this->api_data[ 'item_id' ] : false, |
|
518 | + 'version' => isset( $this->api_data[ 'version' ] ) ? $this->api_data[ 'version' ] : false, |
|
519 | 519 | 'slug' => $this->slug, |
520 | - 'author' => $this->api_data['author'], |
|
520 | + 'author' => $this->api_data[ 'author' ], |
|
521 | 521 | 'url' => home_url(), |
522 | 522 | 'beta' => $this->beta, |
523 | 523 | 'php_version' => phpversion(), |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | |
567 | 567 | if ( ! empty( $request->sections ) ) { |
568 | 568 | foreach ( $request->sections as $key => $section ) { |
569 | - $request->$key = (array) $section; |
|
569 | + $request->$key = (array)$section; |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | |
@@ -588,17 +588,17 @@ discard block |
||
588 | 588 | $cache = get_option( $cache_key ); |
589 | 589 | |
590 | 590 | // Cache is expired |
591 | - if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { |
|
591 | + if ( empty( $cache[ 'timeout' ] ) || time() > $cache[ 'timeout' ] ) { |
|
592 | 592 | return false; |
593 | 593 | } |
594 | 594 | |
595 | 595 | // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point. |
596 | - $cache['value'] = json_decode( $cache['value'] ); |
|
597 | - if ( ! empty( $cache['value']->icons ) ) { |
|
598 | - $cache['value']->icons = (array) $cache['value']->icons; |
|
596 | + $cache[ 'value' ] = json_decode( $cache[ 'value' ] ); |
|
597 | + if ( ! empty( $cache[ 'value' ]->icons ) ) { |
|
598 | + $cache[ 'value' ]->icons = (array)$cache[ 'value' ]->icons; |
|
599 | 599 | } |
600 | 600 | |
601 | - return $cache['value']; |
|
601 | + return $cache[ 'value' ]; |
|
602 | 602 | |
603 | 603 | } |
604 | 604 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | update_option( $cache_key, $data, 'no' ); |
623 | 623 | |
624 | 624 | // Delete the duplicate option |
625 | - delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) ); |
|
625 | + delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data[ 'license' ] . $this->beta ) ) ); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * @return bool |
633 | 633 | */ |
634 | 634 | private function verify_ssl() { |
635 | - return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
635 | + return (bool)apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @return string |
643 | 643 | */ |
644 | 644 | private function get_cache_key() { |
645 | - $string = $this->slug . $this->api_data['license'] . $this->beta; |
|
645 | + $string = $this->slug . $this->api_data[ 'license' ] . $this->beta; |
|
646 | 646 | |
647 | 647 | return 'edd_sl_' . md5( serialize( $string ) ); |
648 | 648 | } |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | |
79 | 79 | $non_gv_modifiers = array_diff( $modifiers, array_keys( $gv_modifiers ) ); |
80 | 80 | |
81 | - $return = $field->get_value_merge_tag( $value, '', array( 'currency' => '' ), array(), implode( '', $non_gv_modifiers ), $raw_value, false, false, 'text', false); |
|
81 | + $return = $field->get_value_merge_tag( $value, '', array( 'currency' => '' ), array(), implode( '', $non_gv_modifiers ), $raw_value, false, false, 'text', false ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | foreach ( $modifiers as $passed_modifier ) { |
85 | 85 | |
86 | - foreach( $gv_modifiers as $gv_modifier => $method ) { |
|
86 | + foreach ( $gv_modifiers as $gv_modifier => $method ) { |
|
87 | 87 | |
88 | 88 | // Uses ^ to only match the first modifier, to enforce same order as passed by GF |
89 | 89 | preg_match( '/^' . $gv_modifier . '/ism', $passed_modifier, $matches ); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | private static function modifier_timestamp( $raw_value, $matches ) { |
134 | 134 | |
135 | - if( empty( $matches[0] ) ) { |
|
135 | + if ( empty( $matches[ 0 ] ) ) { |
|
136 | 136 | return $raw_value; |
137 | 137 | } |
138 | 138 | |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private static function modifier_maxwords( $raw_value, $matches, $field = null ) { |
163 | 163 | |
164 | - if( ! is_string( $raw_value ) || empty( $matches[1] ) || ! function_exists( 'wp_trim_words' ) ) { |
|
164 | + if ( ! is_string( $raw_value ) || empty( $matches[ 1 ] ) || ! function_exists( 'wp_trim_words' ) ) { |
|
165 | 165 | return $raw_value; |
166 | 166 | } |
167 | 167 | |
168 | - $max = intval( $matches[1] ); |
|
168 | + $max = intval( $matches[ 1 ] ); |
|
169 | 169 | |
170 | 170 | $more_placeholder = '[GVMORE]'; |
171 | 171 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | private static function modifier_explode( $raw_value, $matches, $value, $field = null ) { |
235 | 235 | |
236 | 236 | // For JSON-encoded arrays |
237 | - if( $json_array = json_decode( $raw_value, true ) ) { |
|
237 | + if ( $json_array = json_decode( $raw_value, true ) ) { |
|
238 | 238 | return implode( ' ', $json_array ); |
239 | 239 | } |
240 | 240 | |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | */ |
256 | 256 | private static function modifier_strings( $raw_value, $matches, $value = '', $field = null ) { |
257 | 257 | |
258 | - if( empty( $matches[0] ) ) { |
|
258 | + if ( empty( $matches[ 0 ] ) ) { |
|
259 | 259 | return $raw_value; |
260 | 260 | } |
261 | 261 | |
262 | 262 | $return = $raw_value; |
263 | 263 | |
264 | - switch( $matches[0] ) { |
|
264 | + switch ( $matches[ 0 ] ) { |
|
265 | 265 | case 'urlencode': |
266 | 266 | $return = urlencode( $raw_value ); |
267 | 267 | break; |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | * @internal Fixed $form['title'] in Gravity Forms |
349 | 349 | * @see https://github.com/gravityforms/gravityforms/pull/27/files |
350 | 350 | */ |
351 | - $form['title'] = isset( $form['title'] ) ? $form['title'] : ''; |
|
352 | - $form['id'] = isset( $form['id'] ) ? $form['id'] : ''; |
|
353 | - $form['fields'] = isset( $form['fields'] ) ? $form['fields'] : array(); |
|
351 | + $form[ 'title' ] = isset( $form[ 'title' ] ) ? $form[ 'title' ] : ''; |
|
352 | + $form[ 'id' ] = isset( $form[ 'id' ] ) ? $form[ 'id' ] : ''; |
|
353 | + $form[ 'fields' ] = isset( $form[ 'fields' ] ) ? $form[ 'fields' ] : array(); |
|
354 | 354 | |
355 | 355 | return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format, $aux_data ); |
356 | 356 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | |
443 | 443 | $site_url = get_site_url(); |
444 | 444 | |
445 | - if( $url_encode ) { |
|
445 | + if ( $url_encode ) { |
|
446 | 446 | $site_url = urlencode( $site_url ); |
447 | 447 | } |
448 | 448 | |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | // Is there is {gv_entry_link} or {gv_entry_link:[post id]} or {gv_entry_link:[post id]:[action]} merge tag? |
470 | 470 | preg_match_all( "/{gv_entry_link(?:\:(\d+)\:?(.*?))?}/ism", $original_text, $matches, PREG_SET_ORDER ); |
471 | 471 | |
472 | - if( empty( $matches ) ) { |
|
472 | + if ( empty( $matches ) ) { |
|
473 | 473 | return $original_text; |
474 | 474 | } |
475 | 475 | |
@@ -490,18 +490,18 @@ discard block |
||
490 | 490 | * } |
491 | 491 | */ |
492 | 492 | foreach ( $matches as $match ) { |
493 | - $full_tag = $match[0]; |
|
493 | + $full_tag = $match[ 0 ]; |
|
494 | 494 | |
495 | 495 | $link_args = array( |
496 | 496 | 'return' => 'url', |
497 | - 'entry_id' => $entry['id'], |
|
497 | + 'entry_id' => $entry[ 'id' ], |
|
498 | 498 | 'post_id' => \GV\Utils::get( $match, 1, null ), |
499 | 499 | 'action' => \GV\Utils::get( $match, 2, 'read' ), |
500 | 500 | ); |
501 | 501 | |
502 | 502 | $entry_link = $Shortcode->read_shortcode( $link_args, null, 'gv_entry_link_merge_tag' ); |
503 | 503 | |
504 | - if( $url_encode ) { |
|
504 | + if ( $url_encode ) { |
|
505 | 505 | $entry_link = urlencode( $entry_link ); |
506 | 506 | } |
507 | 507 | |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | 'diff' => in_array( 'diff', $exploded ), // {date_created:diff} |
540 | 540 | 'raw' => in_array( 'raw', $exploded ), // {date_created:raw} |
541 | 541 | 'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp} |
542 | - 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
542 | + 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
543 | 543 | ); |
544 | 544 | |
545 | 545 | $formatted_date = GVCommon::format_date( $date_created, $atts ); |
@@ -616,8 +616,8 @@ discard block |
||
616 | 616 | return $original_text; |
617 | 617 | } |
618 | 618 | |
619 | - foreach ( (array) $matches as $match ) { |
|
620 | - $full_tag = $match[0]; |
|
619 | + foreach ( (array)$matches as $match ) { |
|
620 | + $full_tag = $match[ 0 ]; |
|
621 | 621 | $modifier = \GV\Utils::get( $match, 2, 'permalink' ); |
622 | 622 | |
623 | 623 | $replacement = false; |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $replacement = esc_html( $replacement ); |
636 | 636 | } |
637 | 637 | |
638 | - if( $url_encode ) { |
|
638 | + if ( $url_encode ) { |
|
639 | 639 | $replacement = urlencode( $replacement ); |
640 | 640 | } |
641 | 641 | |
@@ -675,14 +675,14 @@ discard block |
||
675 | 675 | preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER ); |
676 | 676 | |
677 | 677 | // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user) |
678 | - if( empty( $matches ) ) { |
|
678 | + if ( empty( $matches ) ) { |
|
679 | 679 | return $text; |
680 | 680 | } |
681 | 681 | |
682 | 682 | foreach ( $matches as $match ) { |
683 | 683 | |
684 | - $full_tag = $match[0]; |
|
685 | - $property = $match[1]; |
|
684 | + $full_tag = $match[ 0 ]; |
|
685 | + $property = $match[ 1 ]; |
|
686 | 686 | |
687 | 687 | $value = stripslashes_deep( \GV\Utils::_GET( $property ) ); |
688 | 688 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | * @since 1.15 |
707 | 707 | * @param bool $esc_html Whether to esc_html() the value. Default: `true` |
708 | 708 | */ |
709 | - $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
709 | + $esc_html = apply_filters( 'gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
710 | 710 | |
711 | 711 | $value = $esc_html ? esc_html( $value ) : $value; |
712 | 712 | |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | * @param array $form Gravity Forms form array |
718 | 718 | * @param array $entry Entry array |
719 | 719 | */ |
720 | - $value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
720 | + $value = apply_filters( 'gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
721 | 721 | |
722 | 722 | $text = str_replace( $full_tag, $value, $text ); |
723 | 723 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | $is_table_layout = preg_match( '/table/ism', $template_id ); |
55 | 55 | |
56 | - if( 'field' === $field_type ) { |
|
56 | + if ( 'field' === $field_type ) { |
|
57 | 57 | |
58 | 58 | // Default options - fields |
59 | 59 | $field_options = array( |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | ); |
106 | 106 | |
107 | 107 | // Match Table as well as DataTables |
108 | - if( $is_table_layout && 'directory' === $context ) { |
|
109 | - $field_options['width'] = array( |
|
108 | + if ( $is_table_layout && 'directory' === $context ) { |
|
109 | + $field_options[ 'width' ] = array( |
|
110 | 110 | 'type' => 'number', |
111 | - 'label' => __('Percent Width', 'gravityview'), |
|
112 | - 'desc' => __( 'Leave blank for column width to be based on the field content.', 'gravityview'), |
|
111 | + 'label' => __( 'Percent Width', 'gravityview' ), |
|
112 | + 'desc' => __( 'Leave blank for column width to be based on the field content.', 'gravityview' ), |
|
113 | 113 | 'class' => 'code widefat', |
114 | 114 | 'value' => '', |
115 | 115 | 'priority' => 200, |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | // Remove suffix ":" from the labels to standardize style. Using trim() instead of rtrim() for i18n. |
123 | 123 | foreach ( $field_options as $key => $field_option ) { |
124 | - $field_options[ $key ]['label'] = trim( $field_option['label'], ':' ); |
|
124 | + $field_options[ $key ][ 'label' ] = trim( $field_option[ 'label' ], ':' ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | */ |
147 | 147 | $field_options = apply_filters( "gravityview_template_{$input_type}_options", $field_options, $template_id, $field_id, $context, $input_type, $form_id ); |
148 | 148 | |
149 | - if ( 'directory' === $context && isset( $field_options['show_as_link'] ) && ! isset( $field_options['new_window'] ) ) { |
|
150 | - $field_options['new_window'] = array( |
|
149 | + if ( 'directory' === $context && isset( $field_options[ 'show_as_link' ] ) && ! isset( $field_options[ 'new_window' ] ) ) { |
|
150 | + $field_options[ 'new_window' ] = array( |
|
151 | 151 | 'type' => 'checkbox', |
152 | 152 | 'label' => __( 'Open link in a new tab or window?', 'gravityview' ), |
153 | 153 | 'value' => false, |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | switch ( $key ) { |
169 | 169 | case 'show_as_link': |
170 | 170 | $_group = 'display'; |
171 | - $field_option['priority'] = 100; |
|
171 | + $field_option[ 'priority' ] = 100; |
|
172 | 172 | break; |
173 | 173 | default: |
174 | 174 | $_group = \GV\Utils::get( $field_option, 'group', 'display' ); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | $field_options = array(); |
186 | - foreach ( self::get_field_groups() as $group_key => $group_name ) { |
|
186 | + foreach ( self::get_field_groups() as $group_key => $group_name ) { |
|
187 | 187 | $field_options[ $group_key ] = \GV\Utils::get( $option_groups, $group_key, array() ); |
188 | 188 | } |
189 | 189 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | return 0; |
215 | 215 | } |
216 | 216 | |
217 | - return ( $a_priority < $b_priority ) ? - 1 : 1; |
|
217 | + return ( $a_priority < $b_priority ) ? -1 : 1; |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | 'manage_options' => __( 'Administrator', 'gravityview' ), |
240 | 240 | ); |
241 | 241 | |
242 | - if( is_multisite() ) { |
|
243 | - $select_cap_choices['manage_network'] = __('Multisite Super Admin', 'gravityview' ); |
|
242 | + if ( is_multisite() ) { |
|
243 | + $select_cap_choices[ 'manage_network' ] = __( 'Multisite Super Admin', 'gravityview' ); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @param string $context Optional. What context are we in? Example: `single` or `directory` |
254 | 254 | * @param string $input_type Optional. (textarea, list, select, etc.) |
255 | 255 | */ |
256 | - $select_cap_choices = apply_filters('gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type ); |
|
256 | + $select_cap_choices = apply_filters( 'gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type ); |
|
257 | 257 | |
258 | 258 | return $select_cap_choices; |
259 | 259 | } |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | */ |
281 | 281 | public static function render_field_options( $form_id, $field_type, $template_id, $field_id, $field_label, $area, $input_type = NULL, $uniqid = '', $current = '', $context = 'single', $item = array() ) { |
282 | 282 | |
283 | - if( empty( $uniqid ) ) { |
|
283 | + if ( empty( $uniqid ) ) { |
|
284 | 284 | //generate a unique field id |
285 | - $uniqid = uniqid('', false); |
|
285 | + $uniqid = uniqid( '', false ); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | $grouped = ( 'field' === $field_type ); |
@@ -290,24 +290,24 @@ discard block |
||
290 | 290 | // get field/widget options |
291 | 291 | $option_groups = self::get_default_field_options( $field_type, $template_id, $field_id, $context, $input_type, $form_id, $grouped ); |
292 | 292 | |
293 | - if( ! $grouped ) { |
|
293 | + if ( ! $grouped ) { |
|
294 | 294 | $option_groups = array( $option_groups ); |
295 | 295 | } |
296 | 296 | |
297 | 297 | $option_groups = array_filter( $option_groups ); |
298 | 298 | |
299 | 299 | // two different post arrays, depending of the field type |
300 | - $name_prefix = $field_type .'s' .'['. $area .']['. $uniqid .']'; |
|
300 | + $name_prefix = $field_type . 's' . '[' . $area . '][' . $uniqid . ']'; |
|
301 | 301 | |
302 | 302 | // build output |
303 | - $hidden_fields = '<input type="hidden" class="field-key" name="'. $name_prefix .'[id]" value="'. esc_attr( $field_id ) .'">'; |
|
304 | - $hidden_fields .= '<input type="hidden" class="field-label" name="'. $name_prefix .'[label]" value="'. esc_attr( $field_label ) .'">'; |
|
303 | + $hidden_fields = '<input type="hidden" class="field-key" name="' . $name_prefix . '[id]" value="' . esc_attr( $field_id ) . '">'; |
|
304 | + $hidden_fields .= '<input type="hidden" class="field-label" name="' . $name_prefix . '[label]" value="' . esc_attr( $field_label ) . '">'; |
|
305 | 305 | |
306 | 306 | $form_title = ''; |
307 | 307 | if ( $form_id ) { |
308 | - $hidden_fields .= '<input type="hidden" class="field-form-id" name="'. $name_prefix .'[form_id]" value="'. esc_attr( $form_id ) .'">'; |
|
308 | + $hidden_fields .= '<input type="hidden" class="field-form-id" name="' . $name_prefix . '[form_id]" value="' . esc_attr( $form_id ) . '">'; |
|
309 | 309 | $form = GVCommon::get_form( $form_id ); |
310 | - $form_title = $form['title']; |
|
310 | + $form_title = $form[ 'title' ]; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | // If there are no options, return what we got. |
@@ -315,14 +315,14 @@ discard block |
||
315 | 315 | return $hidden_fields . '<!-- No Options -->'; // The HTML comment is here for checking if the output is empty in render_label() |
316 | 316 | } |
317 | 317 | |
318 | - $settings_title = esc_attr( sprintf( __( '%s Settings', 'gravityview' ) , strip_tags( html_entity_decode( $field_label ) ) ) ); |
|
318 | + $settings_title = esc_attr( sprintf( __( '%s Settings', 'gravityview' ), strip_tags( html_entity_decode( $field_label ) ) ) ); |
|
319 | 319 | |
320 | 320 | $field_details = ''; |
321 | 321 | |
322 | 322 | // Get the pretty name for the input type |
323 | 323 | $gv_field = GravityView_Fields::get( $input_type ); |
324 | 324 | |
325 | - if( $gv_field ) { |
|
325 | + if ( $gv_field ) { |
|
326 | 326 | $input_type_label = $gv_field->label; |
327 | 327 | } else { |
328 | 328 | $input_type_label = $input_type; |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | if ( $grouped ) { |
339 | - $group_name = rgar( self::get_field_groups(), $group_key, '' ); |
|
339 | + $group_name = rgar( self::get_field_groups(), $group_key, '' ); |
|
340 | 340 | $field_settings .= '<fieldset class="item-settings-group item-settings-group-' . esc_attr( $group_key ) . '">'; |
341 | 341 | $field_settings .= '<legend>' . esc_attr( $group_name ) . '</legend>'; |
342 | 342 | } |
@@ -353,15 +353,15 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | $show_if = ''; |
356 | - if ( ! empty( $option['requires'] ) ) { |
|
357 | - $show_if .= sprintf( ' data-requires="%s"', $option['requires'] ); |
|
356 | + if ( ! empty( $option[ 'requires' ] ) ) { |
|
357 | + $show_if .= sprintf( ' data-requires="%s"', $option[ 'requires' ] ); |
|
358 | 358 | } |
359 | 359 | |
360 | - if ( ! empty( $option['requires_not'] ) ) { |
|
361 | - $show_if .= sprintf( ' data-requires-not="%s"', $option['requires_not'] ); |
|
360 | + if ( ! empty( $option[ 'requires_not' ] ) ) { |
|
361 | + $show_if .= sprintf( ' data-requires-not="%s"', $option[ 'requires_not' ] ); |
|
362 | 362 | } |
363 | 363 | |
364 | - switch ( $option['type'] ) { |
|
364 | + switch ( $option[ 'type' ] ) { |
|
365 | 365 | // Hide hidden fields |
366 | 366 | case 'hidden': |
367 | 367 | $field_settings .= '<div class="gv-setting-container gv-setting-container-' . esc_attr( $key ) . ' screen-reader-text">' . $field_output . '</div>'; |
@@ -379,30 +379,30 @@ discard block |
||
379 | 379 | $item_details = ''; |
380 | 380 | $subtitle = ''; |
381 | 381 | |
382 | - if( 'field' === $field_type ) { |
|
383 | - $subtitle = ! empty( $item['subtitle'] ) ? '<div class="subtitle">' . $item['subtitle'] . '</div>' : ''; |
|
382 | + if ( 'field' === $field_type ) { |
|
383 | + $subtitle = ! empty( $item[ 'subtitle' ] ) ? '<div class="subtitle">' . $item[ 'subtitle' ] . '</div>' : ''; |
|
384 | 384 | |
385 | 385 | $item_details .= ' |
386 | 386 | <div class="gv-field-details--container"> |
387 | - <label class="gv-field-details--toggle">' . esc_html__( 'Field Details', 'gravityview' ) .' <i class="dashicons dashicons-arrow-right"></i></label> |
|
387 | + <label class="gv-field-details--toggle">' . esc_html__( 'Field Details', 'gravityview' ) . ' <i class="dashicons dashicons-arrow-right"></i></label> |
|
388 | 388 | <section class="gv-field-details gv-field-details--closed">'; |
389 | 389 | |
390 | 390 | if ( $field_id && is_numeric( $field_id ) ) { |
391 | 391 | $item_details .= ' |
392 | 392 | <div class="gv-field-detail gv-field-detail--field"> |
393 | - <span class="gv-field-detail--label">' . esc_html__( 'Field ID', 'gravityview' ) .'</span><span class="gv-field-detail--value">#{{field_id}}</span> |
|
393 | + <span class="gv-field-detail--label">' . esc_html__( 'Field ID', 'gravityview' ) . '</span><span class="gv-field-detail--value">#{{field_id}}</span> |
|
394 | 394 | </div>'; |
395 | 395 | } |
396 | 396 | |
397 | 397 | $item_details .= ' |
398 | 398 | <div class="gv-field-detail gv-field-detail--type"> |
399 | - <span class="gv-field-detail--label">' . esc_html_x( 'Type', 'The type of field being configured (eg: "Single Line Text")', 'gravityview' ) .'</span><span class="gv-field-detail--value">{{input_type_label}}</span> |
|
399 | + <span class="gv-field-detail--label">' . esc_html_x( 'Type', 'The type of field being configured (eg: "Single Line Text")', 'gravityview' ) . '</span><span class="gv-field-detail--value">{{input_type_label}}</span> |
|
400 | 400 | </div>'; |
401 | 401 | |
402 | - if( $form_id ) { |
|
402 | + if ( $form_id ) { |
|
403 | 403 | $item_details .= ' |
404 | 404 | <div class="gv-field-detail gv-field-detail--form"> |
405 | - <span class="gv-field-detail--label">' . esc_html__( 'Form', 'gravityview' ) .'</span><span class="gv-field-detail--value">{{form_title}} (#{{form_id}})</span> |
|
405 | + <span class="gv-field-detail--label">' . esc_html__( 'Form', 'gravityview' ) . '</span><span class="gv-field-detail--value">{{form_title}} (#{{form_id}})</span> |
|
406 | 406 | </div>'; |
407 | 407 | } |
408 | 408 | $item_details .= ' |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | </div>'; |
411 | 411 | } else { |
412 | 412 | $widget_details_content = rgar( $item, 'description', '' ); |
413 | - if ( ! empty( $item['subtitle'] ) ) { |
|
414 | - $widget_details_content .= ( '' !== $widget_details_content ) ? "\n\n" . $item['subtitle'] : $item['subtitle']; |
|
413 | + if ( ! empty( $item[ 'subtitle' ] ) ) { |
|
414 | + $widget_details_content .= ( '' !== $widget_details_content ) ? "\n\n" . $item[ 'subtitle' ] : $item[ 'subtitle' ]; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | // Intentionally not escaping to allow HTML. |
@@ -467,17 +467,17 @@ discard block |
||
467 | 467 | * @deprecated setting index 'default' was replaced by 'value' |
468 | 468 | * @see GravityView_FieldType::get_field_defaults |
469 | 469 | */ |
470 | - if( !empty( $option['default'] ) && empty( $option['value'] ) ) { |
|
471 | - $option['value'] = $option['default']; |
|
472 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting '. $name .' details' ); |
|
470 | + if ( ! empty( $option[ 'default' ] ) && empty( $option[ 'value' ] ) ) { |
|
471 | + $option[ 'value' ] = $option[ 'default' ]; |
|
472 | + _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting ' . $name . ' details' ); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | // prepare to render option field type |
476 | - if( isset( $option['type'] ) ) { |
|
476 | + if ( isset( $option[ 'type' ] ) ) { |
|
477 | 477 | |
478 | 478 | $type_class = self::load_type_class( $option ); |
479 | 479 | |
480 | - if( class_exists( $type_class ) ) { |
|
480 | + if ( class_exists( $type_class ) ) { |
|
481 | 481 | |
482 | 482 | /** @type GravityView_FieldType $render_type */ |
483 | 483 | $render_type = new $type_class( $name, $option, $curr_value ); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @param string $output field class name |
495 | 495 | * @param array $option option field data |
496 | 496 | */ |
497 | - $output = apply_filters( "gravityview/option/output/{$option['type']}" , $output, $option ); |
|
497 | + $output = apply_filters( "gravityview/option/output/{$option[ 'type' ]}", $output, $option ); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | } // isset option[type] |
@@ -529,27 +529,27 @@ discard block |
||
529 | 529 | * @deprecated setting index 'name' was replaced by 'label' |
530 | 530 | * @see GravityView_FieldType::get_field_defaults |
531 | 531 | */ |
532 | - if( isset( $setting['name'] ) && empty( $setting['label'] ) ) { |
|
533 | - $setting['label'] = $setting['name']; |
|
534 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '. $key .' details' ); |
|
532 | + if ( isset( $setting[ 'name' ] ) && empty( $setting[ 'label' ] ) ) { |
|
533 | + $setting[ 'label' ] = $setting[ 'name' ]; |
|
534 | + _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting ' . $key . ' details' ); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | $name = esc_attr( sprintf( $name, $key ) ); |
538 | - $setting['id'] = esc_attr( sprintf( $id, $key ) ); |
|
539 | - $setting['tooltip'] = 'gv_' . $key; |
|
538 | + $setting[ 'id' ] = esc_attr( sprintf( $id, $key ) ); |
|
539 | + $setting[ 'tooltip' ] = 'gv_' . $key; |
|
540 | 540 | |
541 | 541 | // Use default if current setting isn't set. |
542 | - $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting['value']; |
|
542 | + $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting[ 'value' ]; |
|
543 | 543 | |
544 | 544 | // default setting type = text |
545 | - $setting['type'] = empty( $setting['type'] ) ? 'text' : $setting['type']; |
|
545 | + $setting[ 'type' ] = empty( $setting[ 'type' ] ) ? 'text' : $setting[ 'type' ]; |
|
546 | 546 | |
547 | 547 | // merge tags |
548 | - if( !isset( $setting['merge_tags'] ) ) { |
|
549 | - if( $setting['type'] === 'text' ) { |
|
550 | - $setting['merge_tags'] = true; |
|
548 | + if ( ! isset( $setting[ 'merge_tags' ] ) ) { |
|
549 | + if ( $setting[ 'type' ] === 'text' ) { |
|
550 | + $setting[ 'merge_tags' ] = true; |
|
551 | 551 | } else { |
552 | - $setting['merge_tags'] = false; |
|
552 | + $setting[ 'merge_tags' ] = false; |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | |
558 | 558 | // render the setting |
559 | 559 | $type_class = self::load_type_class( $setting ); |
560 | - if( class_exists( $type_class ) ) { |
|
560 | + if ( class_exists( $type_class ) ) { |
|
561 | 561 | /** @type GravityView_FieldType $render_type */ |
562 | 562 | $render_type = new $type_class( $name, $setting, $curr_value ); |
563 | 563 | ob_start(); |
@@ -566,25 +566,25 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | // Check if setting is specific for a template |
569 | - if( !empty( $setting['show_in_template'] ) ) { |
|
570 | - if( !is_array( $setting['show_in_template'] ) ) { |
|
571 | - $setting['show_in_template'] = array( $setting['show_in_template'] ); |
|
569 | + if ( ! empty( $setting[ 'show_in_template' ] ) ) { |
|
570 | + if ( ! is_array( $setting[ 'show_in_template' ] ) ) { |
|
571 | + $setting[ 'show_in_template' ] = array( $setting[ 'show_in_template' ] ); |
|
572 | 572 | } |
573 | - $show_if = ' data-show-if="'. implode( ' ', $setting['show_in_template'] ).'"'; |
|
573 | + $show_if = ' data-show-if="' . implode( ' ', $setting[ 'show_in_template' ] ) . '"'; |
|
574 | 574 | } else { |
575 | 575 | $show_if = ''; |
576 | 576 | } |
577 | 577 | |
578 | - if( ! empty( $setting['requires'] ) ) { |
|
579 | - $show_if .= sprintf( ' data-requires="%s"', $setting['requires'] ); |
|
578 | + if ( ! empty( $setting[ 'requires' ] ) ) { |
|
579 | + $show_if .= sprintf( ' data-requires="%s"', $setting[ 'requires' ] ); |
|
580 | 580 | } |
581 | 581 | |
582 | - if( ! empty( $setting['requires_not'] ) ) { |
|
583 | - $show_if .= sprintf( ' data-requires-not="%s"', $setting['requires_not'] ); |
|
582 | + if ( ! empty( $setting[ 'requires_not' ] ) ) { |
|
583 | + $show_if .= sprintf( ' data-requires-not="%s"', $setting[ 'requires_not' ] ); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | // output |
587 | - echo '<tr style="vertical-align: top;" '. $show_if .'>' . $output . '</tr>'; |
|
587 | + echo '<tr style="vertical-align: top;" ' . $show_if . '>' . $output . '</tr>'; |
|
588 | 588 | |
589 | 589 | } |
590 | 590 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | */ |
597 | 597 | public static function load_type_class( $field = NULL ) { |
598 | 598 | |
599 | - if( empty( $field['type'] ) ) { |
|
599 | + if ( empty( $field[ 'type' ] ) ) { |
|
600 | 600 | return NULL; |
601 | 601 | } |
602 | 602 | |
@@ -605,9 +605,9 @@ discard block |
||
605 | 605 | * @param string $class_suffix field class suffix; `GravityView_FieldType_{$class_suffix}` |
606 | 606 | * @param array $field field data |
607 | 607 | */ |
608 | - $type_class = apply_filters( "gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_' . $field['type'], $field ); |
|
608 | + $type_class = apply_filters( "gravityview/setting/class/{$field[ 'type' ]}", 'GravityView_FieldType_' . $field[ 'type' ], $field ); |
|
609 | 609 | |
610 | - if( class_exists( $type_class ) ) { |
|
610 | + if ( class_exists( $type_class ) ) { |
|
611 | 611 | return $type_class; |
612 | 612 | } |
613 | 613 | |
@@ -616,9 +616,9 @@ discard block |
||
616 | 616 | * @param string $field_type_include_path field class file path |
617 | 617 | * @param array $field field data |
618 | 618 | */ |
619 | - $class_file = apply_filters( "gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field['type']}.php", $field ); |
|
619 | + $class_file = apply_filters( "gravityview/setting/class_file/{$field[ 'type' ]}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field[ 'type' ]}.php", $field ); |
|
620 | 620 | |
621 | - if( $class_file && file_exists( $class_file ) ) { |
|
621 | + if ( $class_file && file_exists( $class_file ) ) { |
|
622 | 622 | require_once( $class_file ); |
623 | 623 | } |
624 | 624 | |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | |
641 | 641 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_checkbox::render_input' ); |
642 | 642 | |
643 | - $output = '<input name="'. esc_attr( $name ) .'" type="hidden" value="0">'; |
|
644 | - $output .= '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="checkbox" value="1" '. checked( $current, '1', false ) .' >'; |
|
643 | + $output = '<input name="' . esc_attr( $name ) . '" type="hidden" value="0">'; |
|
644 | + $output .= '<input name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" type="checkbox" value="1" ' . checked( $current, '1', false ) . ' >'; |
|
645 | 645 | |
646 | 646 | return $output; |
647 | 647 | } |
@@ -661,22 +661,22 @@ discard block |
||
661 | 661 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_text::render_input' ); |
662 | 662 | |
663 | 663 | // Show the merge tags if the field is a list view |
664 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
664 | + $is_list = ( preg_match( '/_list-/ism', $name ) ); |
|
665 | 665 | |
666 | 666 | // Or is a single entry view |
667 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
667 | + $is_single = ( preg_match( '/single_/ism', $name ) ); |
|
668 | 668 | $show = ( $is_single || $is_list ); |
669 | 669 | |
670 | 670 | $class = ''; |
671 | 671 | // and $add_merge_tags is not false |
672 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
672 | + if ( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
673 | 673 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
674 | 674 | } |
675 | 675 | |
676 | - $class .= !empty( $args['class'] ) ? $args['class'] : 'widefat'; |
|
677 | - $type = !empty( $args['type'] ) ? $args['type'] : 'text'; |
|
676 | + $class .= ! empty( $args[ 'class' ] ) ? $args[ 'class' ] : 'widefat'; |
|
677 | + $type = ! empty( $args[ 'type' ] ) ? $args[ 'type' ] : 'text'; |
|
678 | 678 | |
679 | - return '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="'.esc_attr($type).'" value="'. esc_attr( $current ) .'" class="'.esc_attr( $class ).'">'; |
|
679 | + return '<input name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" type="' . esc_attr( $type ) . '" value="' . esc_attr( $current ) . '" class="' . esc_attr( $class ) . '">'; |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -693,21 +693,21 @@ discard block |
||
693 | 693 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_textarea::render_input' ); |
694 | 694 | |
695 | 695 | // Show the merge tags if the field is a list view |
696 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
696 | + $is_list = ( preg_match( '/_list-/ism', $name ) ); |
|
697 | 697 | |
698 | 698 | // Or is a single entry view |
699 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
699 | + $is_single = ( preg_match( '/single_/ism', $name ) ); |
|
700 | 700 | $show = ( $is_single || $is_list ); |
701 | 701 | |
702 | 702 | $class = ''; |
703 | 703 | // and $add_merge_tags is not false |
704 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
704 | + if ( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
705 | 705 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
706 | 706 | } |
707 | 707 | |
708 | - $class .= !empty( $args['class'] ) ? 'widefat '.$args['class'] : 'widefat'; |
|
708 | + $class .= ! empty( $args[ 'class' ] ) ? 'widefat ' . $args[ 'class' ] : 'widefat'; |
|
709 | 709 | |
710 | - return '<textarea name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" class="'.esc_attr( $class ).'">'. esc_textarea( $current ) .'</textarea>'; |
|
710 | + return '<textarea name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . '">' . esc_textarea( $current ) . '</textarea>'; |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | /** |
@@ -723,9 +723,9 @@ discard block |
||
723 | 723 | |
724 | 724 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_select::render_input' ); |
725 | 725 | |
726 | - $output = '<select name="'. $name .'" id="'. $id .'">'; |
|
727 | - foreach( $choices as $value => $label ) { |
|
728 | - $output .= '<option value="'. esc_attr( $value ) .'" '. selected( $value, $current, false ) .'>'. esc_html( $label ) .'</option>'; |
|
726 | + $output = '<select name="' . $name . '" id="' . $id . '">'; |
|
727 | + foreach ( $choices as $value => $label ) { |
|
728 | + $output .= '<option value="' . esc_attr( $value ) . '" ' . selected( $value, $current, false ) . '>' . esc_html( $label ) . '</option>'; |
|
729 | 729 | } |
730 | 730 | $output .= '</select>'; |
731 | 731 |
@@ -152,17 +152,17 @@ discard block |
||
152 | 152 | |
153 | 153 | add_filter( 'gravityview/sortable/field_blocklist', array( $this, '_filter_sortable_fields' ), 1 ); |
154 | 154 | |
155 | - if( $this->entry_meta_key ) { |
|
155 | + if ( $this->entry_meta_key ) { |
|
156 | 156 | add_filter( 'gform_entry_meta', array( $this, 'add_entry_meta' ) ); |
157 | 157 | add_filter( 'gravityview/common/sortable_fields', array( $this, 'add_sortable_field' ), 10, 2 ); |
158 | 158 | } |
159 | 159 | |
160 | - if( $this->_custom_merge_tag ) { |
|
160 | + if ( $this->_custom_merge_tag ) { |
|
161 | 161 | add_filter( 'gform_custom_merge_tags', array( $this, '_filter_gform_custom_merge_tags' ), 10, 4 ); |
162 | 162 | add_filter( 'gform_replace_merge_tags', array( $this, '_filter_gform_replace_merge_tags' ), 10, 7 ); |
163 | 163 | } |
164 | 164 | |
165 | - if( 'meta' === $this->group || '' !== $this->default_search_label ) { |
|
165 | + if ( 'meta' === $this->group || '' !== $this->default_search_label ) { |
|
166 | 166 | add_filter( 'gravityview_search_field_label', array( $this, 'set_default_search_label' ), 10, 3 ); |
167 | 167 | } |
168 | 168 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * Auto-assign label from Gravity Forms label, if exists |
171 | 171 | * @since 1.20 |
172 | 172 | */ |
173 | - if( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) { |
|
173 | + if ( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) { |
|
174 | 174 | $this->label = ucfirst( GF_Fields::get( $this->name )->get_form_editor_field_title() ); |
175 | 175 | } |
176 | 176 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | 'type' => $this->name |
217 | 217 | ); |
218 | 218 | |
219 | - $fields["{$this->entry_meta_key}"] = $added_field; |
|
219 | + $fields[ "{$this->entry_meta_key}" ] = $added_field; |
|
220 | 220 | |
221 | 221 | return $fields; |
222 | 222 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | function set_default_search_label( $label = '', $gf_field = null, $field = array() ) { |
238 | 238 | |
239 | - if( $this->name === $field['field'] && '' === $label ) { |
|
239 | + if ( $this->name === $field[ 'field' ] && '' === $label ) { |
|
240 | 240 | $label = esc_html( $this->default_search_label ); |
241 | 241 | } |
242 | 242 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return string Original text if {_custom_merge_tag} isn't found. Otherwise, replaced text. |
259 | 259 | */ |
260 | - public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
260 | + public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
261 | 261 | |
262 | 262 | // Is there is field merge tag? Strip whitespace off the ned, too. |
263 | 263 | preg_match_all( '/{' . preg_quote( $this->_custom_merge_tag ) . ':?(.*?)(?:\s)?}/ism', $text, $matches, PREG_SET_ORDER ); |
@@ -290,19 +290,19 @@ discard block |
||
290 | 290 | */ |
291 | 291 | public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
292 | 292 | |
293 | - foreach( $matches as $match ) { |
|
293 | + foreach ( $matches as $match ) { |
|
294 | 294 | |
295 | - $full_tag = $match[0]; |
|
295 | + $full_tag = $match[ 0 ]; |
|
296 | 296 | |
297 | 297 | // Strip the Merge Tags |
298 | - $tag = str_replace( array( '{', '}'), '', $full_tag ); |
|
298 | + $tag = str_replace( array( '{', '}' ), '', $full_tag ); |
|
299 | 299 | |
300 | 300 | // Replace the value from the entry, if exists |
301 | - if( isset( $entry[ $tag ] ) ) { |
|
301 | + if ( isset( $entry[ $tag ] ) ) { |
|
302 | 302 | |
303 | 303 | $value = $entry[ $tag ]; |
304 | 304 | |
305 | - if( is_callable( array( $this, 'get_content') ) ) { |
|
305 | + if ( is_callable( array( $this, 'get_content' ) ) ) { |
|
306 | 306 | $value = $this->get_content( $value ); |
307 | 307 | } |
308 | 308 | |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function _filter_sortable_fields( $not_sortable ) { |
377 | 377 | |
378 | - if( ! $this->is_sortable ) { |
|
379 | - $not_sortable[] = $this->name; |
|
378 | + if ( ! $this->is_sortable ) { |
|
379 | + $not_sortable[ ] = $this->name; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | return $not_sortable; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | */ |
394 | 394 | function add_entry_meta( $entry_meta ) { |
395 | 395 | |
396 | - if( ! isset( $entry_meta["{$this->entry_meta_key}"] ) ) { |
|
396 | + if ( ! isset( $entry_meta[ "{$this->entry_meta_key}" ] ) ) { |
|
397 | 397 | |
398 | 398 | $added_meta = array( |
399 | 399 | 'label' => $this->label, |
@@ -402,13 +402,13 @@ discard block |
||
402 | 402 | ); |
403 | 403 | |
404 | 404 | if ( $this->entry_meta_update_callback && is_callable( $this->entry_meta_update_callback ) ) { |
405 | - $added_meta['update_entry_meta_callback'] = $this->entry_meta_update_callback; |
|
405 | + $added_meta[ 'update_entry_meta_callback' ] = $this->entry_meta_update_callback; |
|
406 | 406 | } |
407 | 407 | |
408 | - $entry_meta["{$this->entry_meta_key}"] = $added_meta; |
|
408 | + $entry_meta[ "{$this->entry_meta_key}" ] = $added_meta; |
|
409 | 409 | |
410 | 410 | } else { |
411 | - gravityview()->log->error( 'Entry meta already set: {meta_key}', array( 'meta_key' => $this->entry_meta_key, 'data' => $entry_meta["{$this->entry_meta_key}"] ) ); |
|
411 | + gravityview()->log->error( 'Entry meta already set: {meta_key}', array( 'meta_key' => $this->entry_meta_key, 'data' => $entry_meta[ "{$this->entry_meta_key}" ] ) ); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | return $entry_meta; |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | 'date_display' => array( |
444 | 444 | 'type' => 'text', |
445 | 445 | 'label' => __( 'Override Date Format', 'gravityview' ), |
446 | - 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview'), '<a href="https://wordpress.org/support/article/formatting-date-and-time/" rel="external">', '</a>' ), |
|
446 | + 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview' ), '<a href="https://wordpress.org/support/article/formatting-date-and-time/" rel="external">', '</a>' ), |
|
447 | 447 | /** |
448 | 448 | * @filter `gravityview_date_format` Override the date format with a [PHP date format](https://codex.wordpress.org/Formatting_Date_and_Time) |
449 | 449 | * @param null|string $date_format Date Format (default: null) |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | |
480 | 480 | $options = $this->field_support_options(); |
481 | 481 | |
482 | - if( isset( $options[ $key ] ) ) { |
|
482 | + if ( isset( $options[ $key ] ) ) { |
|
483 | 483 | $field_options[ $key ] = $options[ $key ]; |
484 | 484 | } |
485 | 485 | |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | $connected_form = \GV\Utils::_POST( 'form_id' ); |
544 | 544 | |
545 | 545 | // Otherwise, get the Form ID from the Post page |
546 | - if( empty( $connected_form ) ) { |
|
546 | + if ( empty( $connected_form ) ) { |
|
547 | 547 | $connected_form = gravityview_get_form_id( get_the_ID() ); |
548 | 548 | } |
549 | 549 | |
550 | - if( empty( $connected_form ) ) { |
|
550 | + if ( empty( $connected_form ) ) { |
|
551 | 551 | gravityview()->log->error( 'Form not found for form ID "{form_id}"', array( 'form_id' => $connected_form ) ); |
552 | 552 | return false; |
553 | 553 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'search_clear' => array( |
56 | 56 | 'type' => 'checkbox', |
57 | 57 | 'label' => __( 'Show Clear button', 'gravityview' ), |
58 | - 'desc' => __( 'When a search is performed, display a button that removes all search values.', 'gravityview'), |
|
58 | + 'desc' => __( 'When a search is performed, display a button that removes all search values.', 'gravityview' ), |
|
59 | 59 | 'value' => true, |
60 | 60 | ), |
61 | 61 | 'search_fields' => array( |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | 'type' => 'radio', |
69 | 69 | 'full_width' => true, |
70 | 70 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
71 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
71 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
72 | 72 | 'value' => 'any', |
73 | 73 | 'class' => 'hide-if-js', |
74 | 74 | 'options' => array( |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
89 | 89 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
90 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
90 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
91 | 91 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
92 | 92 | |
93 | 93 | // ajax - get the searchable fields |
@@ -123,19 +123,19 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function add_reserved_args( $args ) { |
125 | 125 | |
126 | - $args[] = 'gv_search'; |
|
127 | - $args[] = 'gv_start'; |
|
128 | - $args[] = 'gv_end'; |
|
129 | - $args[] = 'gv_id'; |
|
130 | - $args[] = 'gv_by'; |
|
131 | - $args[] = 'mode'; |
|
126 | + $args[ ] = 'gv_search'; |
|
127 | + $args[ ] = 'gv_start'; |
|
128 | + $args[ ] = 'gv_end'; |
|
129 | + $args[ ] = 'gv_id'; |
|
130 | + $args[ ] = 'gv_by'; |
|
131 | + $args[ ] = 'mode'; |
|
132 | 132 | |
133 | - $get = (array) $_GET; |
|
133 | + $get = (array)$_GET; |
|
134 | 134 | |
135 | 135 | // If the fields being searched as reserved; not to be considered user-passed variables |
136 | 136 | foreach ( $get as $key => $value ) { |
137 | 137 | if ( $key !== $this->convert_request_key_to_filter_key( $key ) ) { |
138 | - $args[] = $key; |
|
138 | + $args[ ] = $key; |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
260 | 260 | $script_source = empty( $script_min ) ? '/source' : ''; |
261 | 261 | |
262 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
262 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
263 | 263 | |
264 | 264 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
265 | 265 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
282 | 282 | */ |
283 | 283 | public function register_no_conflict( $allowed ) { |
284 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
284 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
285 | 285 | return $allowed; |
286 | 286 | } |
287 | 287 | |
@@ -293,24 +293,24 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public static function get_searchable_fields() { |
295 | 295 | |
296 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
296 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
297 | 297 | exit( '0' ); |
298 | 298 | } |
299 | 299 | |
300 | 300 | $form = ''; |
301 | 301 | |
302 | 302 | // Fetch the form for the current View |
303 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
303 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
304 | 304 | |
305 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
305 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
306 | 306 | |
307 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
307 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
308 | 308 | |
309 | - $form = (int) $_POST['formid']; |
|
309 | + $form = (int)$_POST[ 'formid' ]; |
|
310 | 310 | |
311 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
311 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
312 | 312 | |
313 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
313 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
314 | 314 | |
315 | 315 | } |
316 | 316 | |
@@ -360,14 +360,14 @@ discard block |
||
360 | 360 | ); |
361 | 361 | |
362 | 362 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
363 | - $custom_fields['is_approved'] = array( |
|
363 | + $custom_fields[ 'is_approved' ] = array( |
|
364 | 364 | 'text' => esc_html__( 'Approval Status', 'gravityview' ), |
365 | 365 | 'type' => 'multi', |
366 | 366 | ); |
367 | 367 | } |
368 | 368 | |
369 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
370 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
369 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
370 | + $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] ); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | // Get fields with sub-inputs and no parent |
@@ -389,13 +389,13 @@ discard block |
||
389 | 389 | |
390 | 390 | foreach ( $fields as $id => $field ) { |
391 | 391 | |
392 | - if ( in_array( $field['type'], $blocklist_field_types ) ) { |
|
392 | + if ( in_array( $field[ 'type' ], $blocklist_field_types ) ) { |
|
393 | 393 | continue; |
394 | 394 | } |
395 | 395 | |
396 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
396 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
397 | 397 | |
398 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
398 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
419 | 419 | |
420 | 420 | // @todo - This needs to be improved - many fields have . including products and addresses |
421 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
421 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
422 | 422 | $input_type = 'boolean'; // on/off checkbox |
423 | 423 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
424 | 424 | $input_type = 'multi'; //multiselect |
@@ -464,19 +464,19 @@ discard block |
||
464 | 464 | $post_id = 0; |
465 | 465 | |
466 | 466 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
467 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
468 | - $post_id = absint( $widget_args['post_id'] ); |
|
467 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
468 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
469 | 469 | } |
470 | 470 | // We're in the WordPress Widget context, and the base View ID should be used |
471 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
472 | - $post_id = absint( $widget_args['view_id'] ); |
|
471 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
472 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | $args = gravityview_get_permalink_query_args( $post_id ); |
476 | 476 | |
477 | 477 | // Add hidden fields to the search form |
478 | 478 | foreach ( $args as $key => $value ) { |
479 | - $search_fields[] = array( |
|
479 | + $search_fields[ ] = array( |
|
480 | 480 | 'name' => $key, |
481 | 481 | 'input' => 'hidden', |
482 | 482 | 'value' => $value, |
@@ -515,28 +515,28 @@ discard block |
||
515 | 515 | /** |
516 | 516 | * Include the sidebar Widgets. |
517 | 517 | */ |
518 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
518 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
519 | 519 | |
520 | 520 | foreach ( $widgets as $widget ) { |
521 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
522 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
521 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
522 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
523 | 523 | foreach ( $_fields as $field ) { |
524 | - if ( empty( $field['form_id'] ) ) { |
|
525 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
524 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
525 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
526 | 526 | } |
527 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
527 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | } |
531 | 531 | } |
532 | 532 | |
533 | 533 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
534 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
534 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
535 | 535 | foreach ( $_fields as $field ) { |
536 | - if ( empty( $field['form_id'] ) ) { |
|
537 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
536 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
537 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
538 | 538 | } |
539 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
539 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | } |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
583 | 583 | } |
584 | 584 | |
585 | - if( 'post' === $this->search_method ) { |
|
585 | + if ( 'post' === $this->search_method ) { |
|
586 | 586 | $get = $_POST; |
587 | 587 | } else { |
588 | 588 | $get = $_GET; |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | $get = gv_map_deep( $get, 'rawurldecode' ); |
604 | 604 | |
605 | 605 | // Make sure array key is set up |
606 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
606 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
607 | 607 | |
608 | 608 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
609 | 609 | $searchable_field_objects = $this->get_view_searchable_fields( $view, true ); |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | $trim_search_value = apply_filters( 'gravityview/search-trim-input', true ); |
624 | 624 | |
625 | 625 | // add free search |
626 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
626 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
627 | 627 | |
628 | - $search_all_value = $trim_search_value ? trim( $get['gv_search'] ) : $get['gv_search']; |
|
628 | + $search_all_value = $trim_search_value ? trim( $get[ 'gv_search' ] ) : $get[ 'gv_search' ]; |
|
629 | 629 | |
630 | 630 | if ( $split_words ) { |
631 | 631 | // Search for a piece |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | } |
642 | 642 | |
643 | 643 | foreach ( $words as $word ) { |
644 | - $search_criteria['field_filters'][] = array( |
|
644 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
645 | 645 | 'key' => null, // The field ID to search |
646 | 646 | 'value' => $word, // The value to search |
647 | 647 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -654,14 +654,14 @@ discard block |
||
654 | 654 | /** |
655 | 655 | * Get and normalize the dates according to the input format. |
656 | 656 | */ |
657 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
658 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
657 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
658 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
659 | 659 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
660 | 660 | } |
661 | 661 | } |
662 | 662 | |
663 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
664 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
663 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
664 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
665 | 665 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
666 | 666 | } |
667 | 667 | } |
@@ -697,22 +697,22 @@ discard block |
||
697 | 697 | */ |
698 | 698 | if ( ! empty( $curr_start ) ) { |
699 | 699 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
700 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
700 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | if ( ! empty( $curr_end ) ) { |
704 | 704 | // Fast-forward 24 hour on the end time |
705 | 705 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
706 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
707 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
708 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
706 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
707 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
708 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
709 | 709 | } |
710 | 710 | } |
711 | 711 | } |
712 | 712 | |
713 | 713 | // search for a specific entry ID |
714 | 714 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
715 | - $search_criteria['field_filters'][] = array( |
|
715 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
716 | 716 | 'key' => 'id', |
717 | 717 | 'value' => absint( $get[ 'gv_id' ] ), |
718 | 718 | 'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ), |
@@ -721,15 +721,15 @@ discard block |
||
721 | 721 | |
722 | 722 | // search for a specific Created_by ID |
723 | 723 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
724 | - $search_criteria['field_filters'][] = array( |
|
724 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
725 | 725 | 'key' => 'created_by', |
726 | - 'value' => $get['gv_by'], |
|
726 | + 'value' => $get[ 'gv_by' ], |
|
727 | 727 | 'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ), |
728 | 728 | ); |
729 | 729 | } |
730 | 730 | |
731 | 731 | // Get search mode passed in URL |
732 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
732 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
733 | 733 | |
734 | 734 | // get the other search filters |
735 | 735 | foreach ( $get as $key => $value ) { |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | $value = is_array( $value ) ? array_map( 'trim', $value ) : trim( $value ); |
748 | 748 | } |
749 | 749 | |
750 | - if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
750 | + if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
751 | 751 | /** |
752 | 752 | * @filter `gravityview/search/ignore-empty-values` Filter to control if empty field values should be ignored or strictly matched (default: true) |
753 | 753 | * @since 2.14.2.1 |
@@ -778,21 +778,21 @@ discard block |
||
778 | 778 | continue; |
779 | 779 | } |
780 | 780 | |
781 | - if ( ! isset( $filter['operator'] ) ) { |
|
782 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
781 | + if ( ! isset( $filter[ 'operator' ] ) ) { |
|
782 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
783 | 783 | } |
784 | 784 | |
785 | - if ( isset( $filter[0]['value'] ) ) { |
|
786 | - $filter[0]['value'] = $trim_search_value ? trim( $filter[0]['value'] ) : $filter[0]['value']; |
|
785 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
786 | + $filter[ 0 ][ 'value' ] = $trim_search_value ? trim( $filter[ 0 ][ 'value' ] ) : $filter[ 0 ][ 'value' ]; |
|
787 | 787 | |
788 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
788 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
789 | 789 | |
790 | 790 | // if date range type, set search mode to ALL |
791 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
791 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
792 | 792 | $mode = 'all'; |
793 | 793 | } |
794 | - } elseif( !empty( $filter ) ) { |
|
795 | - $search_criteria['field_filters'][] = $filter; |
|
794 | + } elseif ( ! empty( $filter ) ) { |
|
795 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | * @since 1.5.1 |
802 | 802 | * @param string $mode Search mode (`any` vs `all`) |
803 | 803 | */ |
804 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
804 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
805 | 805 | |
806 | 806 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
807 | 807 | |
@@ -835,19 +835,19 @@ discard block |
||
835 | 835 | |
836 | 836 | $query_class = $view->get_query_class(); |
837 | 837 | |
838 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
838 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
839 | 839 | return; |
840 | 840 | } |
841 | 841 | |
842 | 842 | $widgets = $view->widgets->by_id( $this->widget_id ); |
843 | 843 | if ( $widgets->count() ) { |
844 | 844 | $widgets = $widgets->all(); |
845 | - $widget = $widgets[0]; |
|
845 | + $widget = $widgets[ 0 ]; |
|
846 | 846 | |
847 | 847 | $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ); |
848 | 848 | |
849 | - foreach ( (array) $search_fields as $search_field ) { |
|
850 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
849 | + foreach ( (array)$search_fields as $search_field ) { |
|
850 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
851 | 851 | $created_by_text_mode = true; |
852 | 852 | } |
853 | 853 | } |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | $extra_conditions = array(); |
857 | 857 | $mode = 'any'; |
858 | 858 | |
859 | - foreach ( $search_criteria['field_filters'] as $key => &$filter ) { |
|
859 | + foreach ( $search_criteria[ 'field_filters' ] as $key => &$filter ) { |
|
860 | 860 | if ( ! is_array( $filter ) ) { |
861 | 861 | if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) { |
862 | 862 | $mode = $filter; |
@@ -865,13 +865,13 @@ discard block |
||
865 | 865 | } |
866 | 866 | |
867 | 867 | // Construct a manual query for unapproved statuses |
868 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { |
|
869 | - $_tmp_query = new $query_class( $view->form->ID, array( |
|
868 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) { |
|
869 | + $_tmp_query = new $query_class( $view->form->ID, array( |
|
870 | 870 | 'field_filters' => array( |
871 | 871 | array( |
872 | 872 | 'operator' => 'in', |
873 | 873 | 'key' => 'is_approved', |
874 | - 'value' => (array) $filter['value'], |
|
874 | + 'value' => (array)$filter[ 'value' ], |
|
875 | 875 | ), |
876 | 876 | array( |
877 | 877 | 'operator' => 'is', |
@@ -883,30 +883,30 @@ discard block |
||
883 | 883 | ) ); |
884 | 884 | $_tmp_query_parts = $_tmp_query->_introspect(); |
885 | 885 | |
886 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
886 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
887 | 887 | |
888 | 888 | $filter = false; |
889 | 889 | continue; |
890 | 890 | } |
891 | 891 | |
892 | 892 | // Construct manual query for text mode creator search |
893 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
894 | - $extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
893 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
894 | + $extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
895 | 895 | $filter = false; |
896 | 896 | continue; |
897 | 897 | } |
898 | 898 | |
899 | 899 | // By default, we want searches to be wildcard for each field. |
900 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
900 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
901 | 901 | |
902 | 902 | // For multichoice, let's have an in (OR) search. |
903 | - if ( is_array( $filter['value'] ) ) { |
|
904 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
903 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
904 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | // Default form with joins functionality |
908 | - if ( empty( $filter['form_id'] ) ) { |
|
909 | - $filter['form_id'] = $view->form ? $view->form->ID : 0; |
|
908 | + if ( empty( $filter[ 'form_id' ] ) ) { |
|
909 | + $filter[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -916,32 +916,32 @@ discard block |
||
916 | 916 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
917 | 917 | * @param \GV\View $view The View we're operating on. |
918 | 918 | */ |
919 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view ); |
|
919 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view ); |
|
920 | 920 | |
921 | - if ( 'is' !== $filter['operator'] && '' === $filter['value'] ) { |
|
922 | - unset( $search_criteria['field_filters'][ $key ] ); |
|
921 | + if ( 'is' !== $filter[ 'operator' ] && '' === $filter[ 'value' ] ) { |
|
922 | + unset( $search_criteria[ 'field_filters' ][ $key ] ); |
|
923 | 923 | } |
924 | 924 | } |
925 | 925 | |
926 | - if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) { |
|
926 | + if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) { |
|
927 | 927 | $date_criteria = array(); |
928 | 928 | |
929 | - if ( isset( $search_criteria['start_date'] ) ) { |
|
930 | - $date_criteria['start_date'] = $search_criteria['start_date']; |
|
929 | + if ( isset( $search_criteria[ 'start_date' ] ) ) { |
|
930 | + $date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ]; |
|
931 | 931 | } |
932 | 932 | |
933 | - if ( isset( $search_criteria['end_date'] ) ) { |
|
934 | - $date_criteria['end_date'] = $search_criteria['end_date']; |
|
933 | + if ( isset( $search_criteria[ 'end_date' ] ) ) { |
|
934 | + $date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ]; |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | $_tmp_query = new $query_class( $view->form->ID, $date_criteria ); |
938 | 938 | $_tmp_query_parts = $_tmp_query->_introspect(); |
939 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
939 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | $search_conditions = array(); |
943 | 943 | |
944 | - if ( $filters = array_filter( $search_criteria['field_filters'] ) ) { |
|
944 | + if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) { |
|
945 | 945 | foreach ( $filters as &$filter ) { |
946 | 946 | if ( ! is_array( $filter ) ) { |
947 | 947 | continue; |
@@ -953,12 +953,12 @@ discard block |
||
953 | 953 | * code by reusing what's inside GF_Query already as they |
954 | 954 | * take care of many small things like forcing numeric, etc. |
955 | 955 | */ |
956 | - $_tmp_query = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
956 | + $_tmp_query = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
957 | 957 | $_tmp_query_parts = $_tmp_query->_introspect(); |
958 | - $search_condition = $_tmp_query_parts['where']; |
|
958 | + $search_condition = $_tmp_query_parts[ 'where' ]; |
|
959 | 959 | |
960 | - if ( empty( $filter['key'] ) && $search_condition->expressions ) { |
|
961 | - $search_conditions[] = $search_condition; |
|
960 | + if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) { |
|
961 | + $search_conditions[ ] = $search_condition; |
|
962 | 962 | } else { |
963 | 963 | $left = $search_condition->left; |
964 | 964 | |
@@ -970,8 +970,8 @@ discard block |
||
970 | 970 | |
971 | 971 | $value = $reflectionProperty->getValue( $left ); |
972 | 972 | |
973 | - if ( ! empty( $value[0] ) && $value[0] instanceof GF_Query_Column ) { |
|
974 | - $left = $value[0]; |
|
973 | + if ( ! empty( $value[ 0 ] ) && $value[ 0 ] instanceof GF_Query_Column ) { |
|
974 | + $left = $value[ 0 ]; |
|
975 | 975 | } else { |
976 | 976 | continue; |
977 | 977 | } |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | $on = $_join->join_on; |
988 | 988 | $join = $_join->join; |
989 | 989 | |
990 | - $search_conditions[] = GF_Query_Condition::_or( |
|
990 | + $search_conditions[ ] = GF_Query_Condition::_or( |
|
991 | 991 | // Join |
992 | 992 | new GF_Query_Condition( |
993 | 993 | new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ), |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | ); |
1004 | 1004 | } |
1005 | 1005 | } else { |
1006 | - $search_conditions[] = new GF_Query_Condition( |
|
1006 | + $search_conditions[ ] = new GF_Query_Condition( |
|
1007 | 1007 | new GF_Query_Column( $left->field_id, $left->source, $alias ), |
1008 | 1008 | $search_condition->operator, |
1009 | 1009 | $search_condition->right |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | /** |
1026 | 1026 | * Combine the parts as a new WHERE clause. |
1027 | 1027 | */ |
1028 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) ); |
|
1028 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) ); |
|
1029 | 1029 | $query->where( $where ); |
1030 | 1030 | } |
1031 | 1031 | |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | $field_id = str_replace( array( 'filter_', 'input_' ), '', $key ); |
1049 | 1049 | |
1050 | 1050 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
1051 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
1051 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
1052 | 1052 | $field_id = str_replace( '_', '.', $field_id ); |
1053 | 1053 | } |
1054 | 1054 | |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | // form is in searchable fields |
1106 | 1106 | $found = false; |
1107 | 1107 | foreach ( $searchable_fields as $field ) { |
1108 | - if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) { |
|
1108 | + if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) { |
|
1109 | 1109 | $found = true; |
1110 | 1110 | break; |
1111 | 1111 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | |
1146 | 1146 | case 'select': |
1147 | 1147 | case 'radio': |
1148 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1148 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1149 | 1149 | break; |
1150 | 1150 | |
1151 | 1151 | case 'post_category': |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | |
1160 | 1160 | foreach ( $value as $val ) { |
1161 | 1161 | $cat = get_term( $val, 'category' ); |
1162 | - $filter[] = array( |
|
1162 | + $filter[ ] = array( |
|
1163 | 1163 | 'key' => $field_id, |
1164 | 1164 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
1165 | 1165 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | $filter = array(); |
1179 | 1179 | |
1180 | 1180 | foreach ( $value as $val ) { |
1181 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
1181 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | break; |
@@ -1187,9 +1187,9 @@ discard block |
||
1187 | 1187 | // convert checkbox on/off into the correct search filter |
1188 | 1188 | if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
1189 | 1189 | foreach ( $form_field->inputs as $k => $input ) { |
1190 | - if ( $input['id'] == $field_id ) { |
|
1191 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
1192 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1190 | + if ( $input[ 'id' ] == $field_id ) { |
|
1191 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
1192 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1193 | 1193 | break; |
1194 | 1194 | } |
1195 | 1195 | } |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | $filter = array(); |
1200 | 1200 | |
1201 | 1201 | foreach ( $value as $val ) { |
1202 | - $filter[] = array( |
|
1202 | + $filter[ ] = array( |
|
1203 | 1203 | 'key' => $field_id, |
1204 | 1204 | 'value' => $val, |
1205 | 1205 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1220,9 +1220,9 @@ discard block |
||
1220 | 1220 | foreach ( $words as $word ) { |
1221 | 1221 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
1222 | 1222 | // Keep the same key for each filter |
1223 | - $filter['value'] = $word; |
|
1223 | + $filter[ 'value' ] = $word; |
|
1224 | 1224 | // Add a search for the value |
1225 | - $filters[] = $filter; |
|
1225 | + $filters[ ] = $filter; |
|
1226 | 1226 | } |
1227 | 1227 | } |
1228 | 1228 | |
@@ -1236,19 +1236,19 @@ discard block |
||
1236 | 1236 | |
1237 | 1237 | foreach ( $searchable_fields as $searchable_field ) { |
1238 | 1238 | |
1239 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
1239 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
1240 | 1240 | continue; |
1241 | 1241 | } |
1242 | 1242 | |
1243 | 1243 | // Only exact-match dropdowns, not text search |
1244 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
1244 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
1245 | 1245 | continue; |
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
1249 | 1249 | |
1250 | 1250 | if ( 4 === $input_id ) { |
1251 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1251 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1252 | 1252 | }; |
1253 | 1253 | } |
1254 | 1254 | } |
@@ -1276,12 +1276,12 @@ discard block |
||
1276 | 1276 | * @since 1.16.3 |
1277 | 1277 | * Safeguard until GF implements '<=' operator |
1278 | 1278 | */ |
1279 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1279 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1280 | 1280 | $operator = '<'; |
1281 | 1281 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
1282 | 1282 | } |
1283 | 1283 | |
1284 | - $filter[] = array( |
|
1284 | + $filter[ ] = array( |
|
1285 | 1285 | 'key' => $field_id, |
1286 | 1286 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
1287 | 1287 | 'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ), |
@@ -1289,12 +1289,12 @@ discard block |
||
1289 | 1289 | } |
1290 | 1290 | } else { |
1291 | 1291 | $date = $value; |
1292 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1293 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1292 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1293 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1294 | 1294 | } |
1295 | 1295 | |
1296 | - if ('payment_date' === $key) { |
|
1297 | - $filter['operator'] = 'contains'; |
|
1296 | + if ( 'payment_date' === $key ) { |
|
1297 | + $filter[ 'operator' ] = 'contains'; |
|
1298 | 1298 | } |
1299 | 1299 | |
1300 | 1300 | break; |
@@ -1323,7 +1323,7 @@ discard block |
||
1323 | 1323 | 'ymd_dot' => 'Y.m.d', |
1324 | 1324 | ); |
1325 | 1325 | |
1326 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
1326 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
1327 | 1327 | $format = $datepicker[ $field->dateFormat ]; |
1328 | 1328 | } |
1329 | 1329 | |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | public function add_template_path( $file_paths ) { |
1361 | 1361 | |
1362 | 1362 | // Index 100 is the default GravityView template path. |
1363 | - $file_paths[102] = self::$file . 'templates/'; |
|
1363 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1364 | 1364 | |
1365 | 1365 | return $file_paths; |
1366 | 1366 | } |
@@ -1379,7 +1379,7 @@ discard block |
||
1379 | 1379 | $has_date = false; |
1380 | 1380 | |
1381 | 1381 | foreach ( $search_fields as $k => $field ) { |
1382 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1382 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1383 | 1383 | $has_date = true; |
1384 | 1384 | break; |
1385 | 1385 | } |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | $view = \GV\View::by_id( $gravityview_view->view_id ); |
1409 | 1409 | |
1410 | 1410 | // get configured search fields |
1411 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1411 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1412 | 1412 | |
1413 | 1413 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1414 | 1414 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1422,39 +1422,39 @@ discard block |
||
1422 | 1422 | |
1423 | 1423 | $updated_field = $this->get_search_filter_details( $updated_field, $context ); |
1424 | 1424 | |
1425 | - switch ( $field['field'] ) { |
|
1425 | + switch ( $field[ 'field' ] ) { |
|
1426 | 1426 | |
1427 | 1427 | case 'search_all': |
1428 | - $updated_field['key'] = 'search_all'; |
|
1429 | - $updated_field['input'] = 'search_all'; |
|
1430 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1428 | + $updated_field[ 'key' ] = 'search_all'; |
|
1429 | + $updated_field[ 'input' ] = 'search_all'; |
|
1430 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1431 | 1431 | break; |
1432 | 1432 | |
1433 | 1433 | case 'entry_date': |
1434 | - $updated_field['key'] = 'entry_date'; |
|
1435 | - $updated_field['input'] = 'entry_date'; |
|
1436 | - $updated_field['value'] = array( |
|
1434 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1435 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1436 | + $updated_field[ 'value' ] = array( |
|
1437 | 1437 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1438 | 1438 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1439 | 1439 | ); |
1440 | 1440 | break; |
1441 | 1441 | |
1442 | 1442 | case 'entry_id': |
1443 | - $updated_field['key'] = 'entry_id'; |
|
1444 | - $updated_field['input'] = 'entry_id'; |
|
1445 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1443 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1444 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1445 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1446 | 1446 | break; |
1447 | 1447 | |
1448 | 1448 | case 'created_by': |
1449 | - $updated_field['key'] = 'created_by'; |
|
1450 | - $updated_field['name'] = 'gv_by'; |
|
1451 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1449 | + $updated_field[ 'key' ] = 'created_by'; |
|
1450 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1451 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1452 | 1452 | break; |
1453 | 1453 | |
1454 | 1454 | case 'is_approved': |
1455 | - $updated_field['key'] = 'is_approved'; |
|
1456 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1457 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
1455 | + $updated_field[ 'key' ] = 'is_approved'; |
|
1456 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1457 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
1458 | 1458 | break; |
1459 | 1459 | } |
1460 | 1460 | |
@@ -1475,16 +1475,16 @@ discard block |
||
1475 | 1475 | |
1476 | 1476 | $gravityview_view->permalink_fields = $this->add_no_permalink_fields( array(), $this, $widget_args ); |
1477 | 1477 | |
1478 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1478 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1479 | 1479 | |
1480 | 1480 | /** @since 1.14 */ |
1481 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1481 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1482 | 1482 | |
1483 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1483 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1484 | 1484 | |
1485 | 1485 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1486 | 1486 | |
1487 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1487 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1488 | 1488 | |
1489 | 1489 | if ( $this->has_date_field( $search_fields ) ) { |
1490 | 1490 | // enqueue datepicker stuff only if needed! |
@@ -1506,10 +1506,10 @@ discard block |
||
1506 | 1506 | public static function get_search_class( $custom_class = '' ) { |
1507 | 1507 | $gravityview_view = GravityView_View::getInstance(); |
1508 | 1508 | |
1509 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1509 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1510 | 1510 | |
1511 | - if ( ! empty( $custom_class ) ) { |
|
1512 | - $search_class .= ' '.$custom_class; |
|
1511 | + if ( ! empty( $custom_class ) ) { |
|
1512 | + $search_class .= ' ' . $custom_class; |
|
1513 | 1513 | } |
1514 | 1514 | |
1515 | 1515 | /** |
@@ -1560,9 +1560,9 @@ discard block |
||
1560 | 1560 | |
1561 | 1561 | if ( ! $label ) { |
1562 | 1562 | |
1563 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1563 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1564 | 1564 | |
1565 | - switch( $field['field'] ) { |
|
1565 | + switch ( $field[ 'field' ] ) { |
|
1566 | 1566 | case 'search_all': |
1567 | 1567 | $label = __( 'Search Entries:', 'gravityview' ); |
1568 | 1568 | break; |
@@ -1574,10 +1574,10 @@ discard block |
||
1574 | 1574 | break; |
1575 | 1575 | default: |
1576 | 1576 | // If this is a field input, not a field |
1577 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1577 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1578 | 1578 | |
1579 | 1579 | // Get the label for the field in question, which returns an array |
1580 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1580 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1581 | 1581 | |
1582 | 1582 | // Get the item with the `label` key |
1583 | 1583 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1618,13 +1618,13 @@ discard block |
||
1618 | 1618 | $form = $gravityview_view->getForm(); |
1619 | 1619 | |
1620 | 1620 | // for advanced field ids (eg, first name / last name ) |
1621 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1621 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1622 | 1622 | |
1623 | 1623 | // get searched value from $_GET/$_POST (string or array) |
1624 | 1624 | $value = $this->rgget_or_rgpost( $name ); |
1625 | 1625 | |
1626 | 1626 | // get form field details |
1627 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1627 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1628 | 1628 | |
1629 | 1629 | $form_field_type = \GV\Utils::get( $form_field, 'type' ); |
1630 | 1630 | |
@@ -1638,22 +1638,22 @@ discard block |
||
1638 | 1638 | ); |
1639 | 1639 | |
1640 | 1640 | // collect choices |
1641 | - if ( 'post_category' === $form_field_type && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1642 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1643 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1644 | - $filter['choices'] = $form_field['choices']; |
|
1641 | + if ( 'post_category' === $form_field_type && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1642 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1643 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1644 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1645 | 1645 | } |
1646 | 1646 | |
1647 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1648 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1647 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1648 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1649 | 1649 | } |
1650 | 1650 | |
1651 | - if ( 'created_by' === $field['field'] ) { |
|
1652 | - $filter['choices'] = self::get_created_by_choices( $context->view ); |
|
1653 | - $filter['type'] = 'created_by'; |
|
1651 | + if ( 'created_by' === $field[ 'field' ] ) { |
|
1652 | + $filter[ 'choices' ] = self::get_created_by_choices( $context->view ); |
|
1653 | + $filter[ 'type' ] = 'created_by'; |
|
1654 | 1654 | } |
1655 | 1655 | |
1656 | - if ( ! empty( $filter['choices'] ) ) { |
|
1656 | + if ( ! empty( $filter[ 'choices' ] ) ) { |
|
1657 | 1657 | /** |
1658 | 1658 | * @filter `gravityview/search/sieve_choices` Only output used choices for this field. |
1659 | 1659 | * @param bool Yes or no. |
@@ -1661,7 +1661,7 @@ discard block |
||
1661 | 1661 | * @param \GV\Context The context. |
1662 | 1662 | */ |
1663 | 1663 | if ( apply_filters( 'gravityview/search/sieve_choices', false, $field, $context ) ) { |
1664 | - $filter['choices'] = $this->sieve_filter_choices( $filter, $context ); |
|
1664 | + $filter[ 'choices' ] = $this->sieve_filter_choices( $filter, $context ); |
|
1665 | 1665 | } |
1666 | 1666 | } |
1667 | 1667 | |
@@ -1690,12 +1690,12 @@ discard block |
||
1690 | 1690 | * @return array The filter choices. |
1691 | 1691 | */ |
1692 | 1692 | private function sieve_filter_choices( $filter, $context ) { |
1693 | - if ( empty( $filter['key'] ) || empty( $filter['choices'] ) ) { |
|
1693 | + if ( empty( $filter[ 'key' ] ) || empty( $filter[ 'choices' ] ) ) { |
|
1694 | 1694 | return $filter; // @todo Populate plugins might give us empty choices |
1695 | 1695 | } |
1696 | 1696 | |
1697 | 1697 | // Allow only created_by and field-ids to be sieved. |
1698 | - if ( 'created_by' !== $filter['key'] && ! is_numeric( $filter['key'] ) ) { |
|
1698 | + if ( 'created_by' !== $filter[ 'key' ] && ! is_numeric( $filter[ 'key' ] ) ) { |
|
1699 | 1699 | return $filter; |
1700 | 1700 | } |
1701 | 1701 | |
@@ -1706,13 +1706,13 @@ discard block |
||
1706 | 1706 | $entry_table_name = GFFormsModel::get_entry_table_name(); |
1707 | 1707 | $entry_meta_table_name = GFFormsModel::get_entry_meta_table_name(); |
1708 | 1708 | |
1709 | - $key_like = $wpdb->esc_like( $filter['key'] ) . '.%'; |
|
1709 | + $key_like = $wpdb->esc_like( $filter[ 'key' ] ) . '.%'; |
|
1710 | 1710 | |
1711 | 1711 | switch ( \GV\Utils::get( $filter, 'type' ) ): |
1712 | 1712 | case 'post_category': |
1713 | 1713 | $choices = $wpdb->get_col( $wpdb->prepare( |
1714 | 1714 | "SELECT DISTINCT SUBSTRING_INDEX(meta_value, ':', 1) FROM $entry_meta_table_name WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d", |
1715 | - $key_like, $filter['key'], $form_id |
|
1715 | + $key_like, $filter[ 'key' ], $form_id |
|
1716 | 1716 | ) ); |
1717 | 1717 | break; |
1718 | 1718 | case 'created_by': |
@@ -1724,17 +1724,17 @@ discard block |
||
1724 | 1724 | default: |
1725 | 1725 | $choices = $wpdb->get_col( $wpdb->prepare( |
1726 | 1726 | "SELECT DISTINCT meta_value FROM $entry_meta_table_name WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d", |
1727 | - $key_like, $filter['key'], $form_id |
|
1727 | + $key_like, $filter[ 'key' ], $form_id |
|
1728 | 1728 | ) ); |
1729 | 1729 | |
1730 | - if ( ( $field = gravityview_get_field( $form_id, $filter['key'] ) ) && 'json' === $field->storageType ) { |
|
1730 | + if ( ( $field = gravityview_get_field( $form_id, $filter[ 'key' ] ) ) && 'json' === $field->storageType ) { |
|
1731 | 1731 | $choices = array_map( 'json_decode', $choices ); |
1732 | 1732 | $_choices_array = array(); |
1733 | 1733 | foreach ( $choices as $choice ) { |
1734 | 1734 | if ( is_array( $choice ) ) { |
1735 | 1735 | $_choices_array = array_merge( $_choices_array, $choice ); |
1736 | 1736 | } else { |
1737 | - $_choices_array []= $choice; |
|
1737 | + $_choices_array [ ] = $choice; |
|
1738 | 1738 | } |
1739 | 1739 | } |
1740 | 1740 | $choices = array_unique( $_choices_array ); |
@@ -1744,9 +1744,9 @@ discard block |
||
1744 | 1744 | endswitch; |
1745 | 1745 | |
1746 | 1746 | $filter_choices = array(); |
1747 | - foreach ( $filter['choices'] as $choice ) { |
|
1748 | - if ( in_array( $choice['text'], $choices, true ) || in_array( $choice['value'], $choices, true ) ) { |
|
1749 | - $filter_choices[] = $choice; |
|
1747 | + foreach ( $filter[ 'choices' ] as $choice ) { |
|
1748 | + if ( in_array( $choice[ 'text' ], $choices, true ) || in_array( $choice[ 'value' ], $choices, true ) ) { |
|
1749 | + $filter_choices[ ] = $choice; |
|
1750 | 1750 | } |
1751 | 1751 | } |
1752 | 1752 | |
@@ -1781,7 +1781,7 @@ discard block |
||
1781 | 1781 | * @param \GV\View $view The view. |
1782 | 1782 | */ |
1783 | 1783 | $text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view ); |
1784 | - $choices[] = array( |
|
1784 | + $choices[ ] = array( |
|
1785 | 1785 | 'value' => $user->ID, |
1786 | 1786 | 'text' => $text, |
1787 | 1787 | ); |
@@ -1801,9 +1801,9 @@ discard block |
||
1801 | 1801 | |
1802 | 1802 | $choices = array(); |
1803 | 1803 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
1804 | - $choices[] = array( |
|
1805 | - 'value' => $status['value'], |
|
1806 | - 'text' => $status['label'], |
|
1804 | + $choices[ ] = array( |
|
1805 | + 'value' => $status[ 'value' ], |
|
1806 | + 'text' => $status[ 'label' ], |
|
1807 | 1807 | ); |
1808 | 1808 | } |
1809 | 1809 | |
@@ -1855,7 +1855,7 @@ discard block |
||
1855 | 1855 | */ |
1856 | 1856 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1857 | 1857 | |
1858 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1858 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1859 | 1859 | |
1860 | 1860 | return $js_dependencies; |
1861 | 1861 | } |
@@ -1899,7 +1899,7 @@ discard block |
||
1899 | 1899 | 'isRTL' => is_rtl(), |
1900 | 1900 | ), $view_data ); |
1901 | 1901 | |
1902 | - $localizations['datepicker'] = $datepicker_settings; |
|
1902 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1903 | 1903 | |
1904 | 1904 | return $localizations; |
1905 | 1905 | |
@@ -1926,7 +1926,7 @@ discard block |
||
1926 | 1926 | * @return void |
1927 | 1927 | */ |
1928 | 1928 | private function maybe_enqueue_flexibility() { |
1929 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1929 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1930 | 1930 | wp_enqueue_script( 'gv-flexibility' ); |
1931 | 1931 | } |
1932 | 1932 | } |
@@ -1948,7 +1948,7 @@ discard block |
||
1948 | 1948 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1949 | 1949 | |
1950 | 1950 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1951 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1951 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1952 | 1952 | |
1953 | 1953 | /** |
1954 | 1954 | * @filter `gravityview_search_datepicker_class` |
@@ -2027,7 +2027,7 @@ discard block |
||
2027 | 2027 | public function add_preview_inputs() { |
2028 | 2028 | global $wp; |
2029 | 2029 | |
2030 | - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { |
|
2030 | + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { |
|
2031 | 2031 | return; |
2032 | 2032 | } |
2033 | 2033 | |
@@ -2085,7 +2085,7 @@ discard block |
||
2085 | 2085 | */ |
2086 | 2086 | class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition { |
2087 | 2087 | public function __construct( $filter, $view ) { |
2088 | - $this->value = $filter['value']; |
|
2088 | + $this->value = $filter[ 'value' ]; |
|
2089 | 2089 | $this->view = $view; |
2090 | 2090 | } |
2091 | 2091 | |
@@ -2117,11 +2117,11 @@ discard block |
||
2117 | 2117 | $conditions = array(); |
2118 | 2118 | |
2119 | 2119 | foreach ( $user_fields as $user_field ) { |
2120 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2120 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2121 | 2121 | } |
2122 | 2122 | |
2123 | 2123 | foreach ( $user_meta_fields as $meta_field ) { |
2124 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2124 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2125 | 2125 | } |
2126 | 2126 | |
2127 | 2127 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |