@@ -24,16 +24,16 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 26 | 26 | |
| 27 | - unset( $field_options['search_filter'] ); |
|
| 27 | + unset( $field_options[ 'search_filter' ] ); |
|
| 28 | 28 | |
| 29 | - if( 'edit' === $context ) { |
|
| 29 | + if ( 'edit' === $context ) { |
|
| 30 | 30 | return $field_options; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - $add_options['link_to_file'] = array( |
|
| 33 | + $add_options[ 'link_to_file' ] = array( |
|
| 34 | 34 | 'type' => 'checkbox', |
| 35 | 35 | 'label' => __( 'Display as a Link:', 'gravityview' ), |
| 36 | - 'desc' => __('Display the uploaded files as links, rather than embedded content.', 'gravityview'), |
|
| 36 | + 'desc' => __( 'Display the uploaded files as links, rather than embedded content.', 'gravityview' ), |
|
| 37 | 37 | 'value' => false, |
| 38 | 38 | 'merge_tags' => false, |
| 39 | 39 | ); |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | $base_id = null; |
| 120 | 120 | |
| 121 | 121 | $is_single = gravityview_get_context() === 'single'; |
| 122 | - $lightbox = ! empty( $gravityview_view->atts['lightbox'] ); |
|
| 122 | + $lightbox = ! empty( $gravityview_view->atts[ 'lightbox' ] ); |
|
| 123 | 123 | $field_compat = $gravityview_view->getCurrentField(); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $output_arr = array(); |
| 127 | 127 | |
| 128 | 128 | // Get an array of file paths for the field. |
| 129 | - $file_paths = \GV\Utils::get( $field , 'multipleFiles' ) ? json_decode( $value ) : array( $value ); |
|
| 129 | + $file_paths = \GV\Utils::get( $field, 'multipleFiles' ) ? json_decode( $value ) : array( $value ); |
|
| 130 | 130 | |
| 131 | 131 | // The $value JSON was probably truncated; let's check lead_detail_long. |
| 132 | 132 | if ( ! is_array( $file_paths ) ) { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $rendered = null; |
| 146 | 146 | |
| 147 | 147 | // If the site is HTTPS, use HTTPS |
| 148 | - if ( function_exists('set_url_scheme') ) { |
|
| 148 | + if ( function_exists( 'set_url_scheme' ) ) { |
|
| 149 | 149 | $file_path = set_url_scheme( $file_path ); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | $file_path_info = pathinfo( $file_path ); |
| 157 | 157 | |
| 158 | 158 | // If pathinfo() gave us the extension of the file, run the switch statement using that. |
| 159 | - $extension = empty( $file_path_info['extension'] ) ? NULL : strtolower( $file_path_info['extension'] ); |
|
| 160 | - $basename = $file_path_info['basename']; |
|
| 159 | + $extension = empty( $file_path_info[ 'extension' ] ) ? NULL : strtolower( $file_path_info[ 'extension' ] ); |
|
| 160 | + $basename = $file_path_info[ 'basename' ]; |
|
| 161 | 161 | |
| 162 | 162 | // Get the secure download URL |
| 163 | 163 | $is_secure = false; |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | $audio_settings = apply_filters( 'gravityview_audio_settings', array( |
| 196 | 196 | 'src' => $insecure_file_path, // Needs to be insecure path so WP can parse extension |
| 197 | - 'class' => 'wp-audio-shortcode gv-audio gv-field-id-'.$field_settings['id'] |
|
| 197 | + 'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings[ 'id' ] |
|
| 198 | 198 | ), $context ); |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | $video_settings = apply_filters( 'gravityview_video_settings', array( |
| 232 | 232 | 'src' => $insecure_file_path, // Needs to be insecure path so WP can parse extension |
| 233 | - 'class' => 'wp-video-shortcode gv-video gv-field-id-'.$field_settings['id'] |
|
| 233 | + 'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings[ 'id' ] |
|
| 234 | 234 | ), $context ); |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -262,13 +262,13 @@ discard block |
||
| 262 | 262 | } else if ( in_array( $extension, array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ) ) ) { |
| 263 | 263 | $image_atts = array( |
| 264 | 264 | 'src' => $file_path, |
| 265 | - 'class' => 'gv-image gv-field-id-' . $field_settings['id'], |
|
| 266 | - 'alt' => $field_settings['label'], |
|
| 265 | + 'class' => 'gv-image gv-field-id-' . $field_settings[ 'id' ], |
|
| 266 | + 'alt' => $field_settings[ 'label' ], |
|
| 267 | 267 | 'width' => ( $is_single ? null : 250 ) |
| 268 | 268 | ); |
| 269 | 269 | |
| 270 | 270 | if ( $is_secure ) { |
| 271 | - $image_atts['validate_src'] = false; |
|
| 271 | + $image_atts[ 'validate_src' ] = false; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $image = new GravityView_Image( $image_atts ); |
| 285 | 285 | |
| 286 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
| 286 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * @filter `gravityview/fields/fileupload/allow_insecure_lightbox` Allow insecure links to be shown for the lighbox. |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | */ |
| 295 | 295 | $override_security = apply_filters( 'gravityview/fields/fileupload/allow_insecure_lightbox', false, $file_path, $field_settings, $context ); |
| 296 | 296 | |
| 297 | - if ( $lightbox && empty( $field_settings['show_as_link'] ) && ( ! $is_secure || $override_security ) ) { |
|
| 297 | + if ( $lightbox && empty( $field_settings[ 'show_as_link' ] ) && ( ! $is_secure || $override_security ) ) { |
|
| 298 | 298 | $lightbox_link_atts = array( |
| 299 | 299 | 'rel' => sprintf( "%s-%s", $gv_class, $entry_slug ), |
| 300 | 300 | 'class' => 'thickbox', |
| 301 | 301 | ); |
| 302 | 302 | |
| 303 | 303 | if ( $override_security ) { |
| 304 | - $image_atts['src'] = $insecure_file_path; |
|
| 304 | + $image_atts[ 'src' ] = $insecure_file_path; |
|
| 305 | 305 | $image = new GravityView_Image( $image_atts ); |
| 306 | 306 | $file_path = $insecure_file_path; |
| 307 | 307 | // :( a kitten died somewhere |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // Show as link should render the image regardless. |
| 316 | - if ( ! empty( $field_settings['show_as_link'] ) ) { |
|
| 316 | + if ( ! empty( $field_settings[ 'show_as_link' ] ) ) { |
|
| 317 | 317 | $text = $rendered; |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $disable_wrapped_link = apply_filters( 'gravityview/fields/fileupload/disable_link', false, $field_compat, $context ); |
| 331 | 331 | |
| 332 | 332 | // Output textualized content where |
| 333 | - if ( ! $disable_wrapped_link && ( ! empty( $field_settings['link_to_file'] ) || ! empty( $field_settings['show_as_link'] ) ) ) { |
|
| 333 | + if ( ! $disable_wrapped_link && ( ! empty( $field_settings[ 'link_to_file' ] ) || ! empty( $field_settings[ 'show_as_link' ] ) ) ) { |
|
| 334 | 334 | /** |
| 335 | 335 | * Modify the link text (defaults to the file name) |
| 336 | 336 | * |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | $content = apply_filters( 'gravityview/fields/fileupload/link_content', $text, $field_compat, $context ); |
| 345 | 345 | |
| 346 | - if ( empty( $field_settings['show_as_link'] ) ) { |
|
| 346 | + if ( empty( $field_settings[ 'show_as_link' ] ) ) { |
|
| 347 | 347 | /** |
| 348 | 348 | * @filter `gravityview/fields/fileupload/link_atts` Modify the link attributes for a file upload field |
| 349 | 349 | * @param array|string $link_atts Array or attributes string |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | $content = empty( $rendered ) ? $text : $rendered; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $output_arr[] = array( |
|
| 362 | + $output_arr[ ] = array( |
|
| 363 | 363 | 'file_path' => $file_path, |
| 364 | 364 | 'content' => $content |
| 365 | 365 | ); |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | $form = false; |
| 127 | 127 | |
| 128 | - if( $entry ) { |
|
| 129 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
| 128 | + if ( $entry ) { |
|
| 129 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | return $form; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - return (bool) $has_transaction_data; |
|
| 205 | + return (bool)$has_transaction_data; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
| 242 | 242 | |
| 243 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
| 243 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
| 244 | 244 | |
| 245 | 245 | return $result; |
| 246 | 246 | } |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
| 259 | 259 | */ |
| 260 | - public static function get_forms( $active = true, $trash = false ) { |
|
| 260 | + public static function get_forms( $active = true, $trash = false ) { |
|
| 261 | 261 | $forms = array(); |
| 262 | 262 | if ( class_exists( 'GFAPI' ) ) { |
| 263 | - if( 'any' === $active ) { |
|
| 263 | + if ( 'any' === $active ) { |
|
| 264 | 264 | $active_forms = GFAPI::get_forms( true, $trash ); |
| 265 | 265 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
| 266 | 266 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | $has_post_fields = false; |
| 292 | 292 | |
| 293 | 293 | if ( $form ) { |
| 294 | - foreach ( $form['fields'] as $field ) { |
|
| 295 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
| 296 | - $fields["{$field['id']}"] = array( |
|
| 294 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 295 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
| 296 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
| 297 | 297 | 'label' => \GV\Utils::get( $field, 'label' ), |
| 298 | 298 | 'parent' => null, |
| 299 | 299 | 'type' => \GV\Utils::get( $field, 'type' ), |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | ); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
| 306 | - foreach ( $field['inputs'] as $input ) { |
|
| 305 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
| 306 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
| 307 | 307 | |
| 308 | - if( ! empty( $input['isHidden'] ) ) { |
|
| 308 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
| 309 | 309 | continue; |
| 310 | 310 | } |
| 311 | 311 | |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | * @hack |
| 314 | 314 | * In case of email/email confirmation, the input for email has the same id as the parent field |
| 315 | 315 | */ |
| 316 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
| 316 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
| 317 | 317 | continue; |
| 318 | 318 | } |
| 319 | - $fields["{$input['id']}"] = array( |
|
| 319 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
| 320 | 320 | 'label' => \GV\Utils::get( $input, 'label' ), |
| 321 | 321 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
| 322 | 322 | 'parent' => $field, |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | |
| 331 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 331 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
| 332 | 332 | $has_product_fields = true; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @since 1.7 |
| 343 | 343 | */ |
| 344 | 344 | if ( $has_post_fields ) { |
| 345 | - $fields['post_id'] = array( |
|
| 345 | + $fields[ 'post_id' ] = array( |
|
| 346 | 346 | 'label' => __( 'Post ID', 'gravityview' ), |
| 347 | 347 | 'type' => 'post_id', |
| 348 | 348 | ); |
@@ -355,11 +355,11 @@ discard block |
||
| 355 | 355 | foreach ( $payment_fields as $payment_field ) { |
| 356 | 356 | |
| 357 | 357 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
| 358 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 358 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 359 | 359 | continue; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $fields["{$payment_field->name}"] = array( |
|
| 362 | + $fields[ "{$payment_field->name}" ] = array( |
|
| 363 | 363 | 'label' => $payment_field->label, |
| 364 | 364 | 'desc' => $payment_field->description, |
| 365 | 365 | 'type' => $payment_field->name, |
@@ -391,9 +391,9 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | $fields = array(); |
| 393 | 393 | |
| 394 | - foreach ( $extra_fields as $key => $field ){ |
|
| 395 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
| 396 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
| 394 | + foreach ( $extra_fields as $key => $field ) { |
|
| 395 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
| 396 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | |
@@ -433,33 +433,33 @@ discard block |
||
| 433 | 433 | 'search_criteria' => null, |
| 434 | 434 | 'sorting' => null, |
| 435 | 435 | 'paging' => null, |
| 436 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
| 436 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
| 437 | 437 | 'context_view_id' => null, |
| 438 | 438 | ); |
| 439 | 439 | |
| 440 | 440 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
| 441 | 441 | |
| 442 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
| 443 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 442 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 443 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
| 444 | 444 | |
| 445 | 445 | if ( ! is_array( $filter ) ) { |
| 446 | 446 | continue; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // By default, we want searches to be wildcard for each field. |
| 450 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 450 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 451 | 451 | |
| 452 | 452 | /** |
| 453 | 453 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
| 454 | 454 | * @param string $operator Existing search operator |
| 455 | 455 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 456 | 456 | */ |
| 457 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 457 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | // don't send just the [mode] without any field filter. |
| 461 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
| 462 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
| 461 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 462 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | } |
@@ -470,33 +470,33 @@ discard block |
||
| 470 | 470 | * Prepare date formats to be in Gravity Forms DB format; |
| 471 | 471 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
| 472 | 472 | */ |
| 473 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
| 473 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
| 474 | 474 | |
| 475 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
| 475 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
| 476 | 476 | |
| 477 | 477 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
| 478 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
| 478 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 479 | 479 | |
| 480 | 480 | if ( $date ) { |
| 481 | 481 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
| 482 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 482 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 483 | 483 | } else { |
| 484 | - gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) ); |
|
| 484 | + gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) ); |
|
| 485 | 485 | |
| 486 | 486 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
| 487 | - unset( $criteria['search_criteria'][ $key ] ); |
|
| 487 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - if ( empty( $criteria['context_view_id'] ) ) { |
|
| 492 | + if ( empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 493 | 493 | // Calculate the context view id and send it to the advanced filter |
| 494 | 494 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
| 495 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 495 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 496 | 496 | } else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
| 497 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 497 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 498 | 498 | } else if ( 'delete' === GFForms::get( 'action' ) ) { |
| 499 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
| 499 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * @param array $form_ids Forms to search |
| 507 | 507 | * @param int $view_id ID of the view being used to search |
| 508 | 508 | */ |
| 509 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
| 509 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
| 510 | 510 | |
| 511 | 511 | return (array)$criteria; |
| 512 | 512 | } |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | /** Reduce # of database calls */ |
| 542 | 542 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
| 543 | 543 | |
| 544 | - if ( ! empty( $criteria['cache'] ) ) { |
|
| 544 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
| 545 | 545 | |
| 546 | 546 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
| 547 | 547 | |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | |
| 550 | 550 | // Still update the total count when using cached results |
| 551 | 551 | if ( ! is_null( $total ) ) { |
| 552 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
| 552 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | $return = $entries; |
@@ -571,9 +571,9 @@ discard block |
||
| 571 | 571 | $entries = apply_filters_ref_array( 'gravityview_before_get_entries', array( null, $criteria, $passed_criteria, &$total ) ); |
| 572 | 572 | |
| 573 | 573 | // No entries returned from gravityview_before_get_entries |
| 574 | - if( is_null( $entries ) ) { |
|
| 574 | + if ( is_null( $entries ) ) { |
|
| 575 | 575 | |
| 576 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
| 576 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
| 577 | 577 | |
| 578 | 578 | if ( is_wp_error( $entries ) ) { |
| 579 | 579 | gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) ); |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
| 587 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
| 588 | 588 | |
| 589 | 589 | // Cache results |
| 590 | 590 | $Cache->set( $entries, 'entries' ); |
@@ -693,12 +693,12 @@ discard block |
||
| 693 | 693 | */ |
| 694 | 694 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
| 695 | 695 | |
| 696 | - if( $check_entry_display ) { |
|
| 696 | + if ( $check_entry_display ) { |
|
| 697 | 697 | // Is the entry allowed |
| 698 | 698 | $entry = self::check_entry_display( $entry ); |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - if( is_wp_error( $entry ) ) { |
|
| 701 | + if ( is_wp_error( $entry ) ) { |
|
| 702 | 702 | gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) ); |
| 703 | 703 | return false; |
| 704 | 704 | } |
@@ -732,12 +732,12 @@ discard block |
||
| 732 | 732 | |
| 733 | 733 | $value = false; |
| 734 | 734 | |
| 735 | - if( 'context' === $val1 ) { |
|
| 735 | + if ( 'context' === $val1 ) { |
|
| 736 | 736 | |
| 737 | 737 | $matching_contexts = array( $val2 ); |
| 738 | 738 | |
| 739 | 739 | // We allow for non-standard contexts. |
| 740 | - switch( $val2 ) { |
|
| 740 | + switch ( $val2 ) { |
|
| 741 | 741 | // Check for either single or edit |
| 742 | 742 | case 'singular': |
| 743 | 743 | $matching_contexts = array( 'single', 'edit' ); |
@@ -780,18 +780,18 @@ discard block |
||
| 780 | 780 | $json_val_1 = json_decode( $val1, true ); |
| 781 | 781 | $json_val_2 = json_decode( $val2, true ); |
| 782 | 782 | |
| 783 | - if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
| 783 | + if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
| 784 | 784 | |
| 785 | 785 | $json_in = false; |
| 786 | - $json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 ); |
|
| 787 | - $json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 ); |
|
| 786 | + $json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 ); |
|
| 787 | + $json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 ); |
|
| 788 | 788 | |
| 789 | 789 | // For JSON, we want to compare as "in" or "not in" rather than "contains" |
| 790 | 790 | foreach ( $json_val_1 as $item_1 ) { |
| 791 | 791 | foreach ( $json_val_2 as $item_2 ) { |
| 792 | 792 | $json_in = self::matches_operation( $item_1, $item_2, 'is' ); |
| 793 | 793 | |
| 794 | - if( $json_in ) { |
|
| 794 | + if ( $json_in ) { |
|
| 795 | 795 | break 2; |
| 796 | 796 | } |
| 797 | 797 | } |
@@ -843,10 +843,10 @@ discard block |
||
| 843 | 843 | public static function check_entry_display( $entry, $view = null ) { |
| 844 | 844 | |
| 845 | 845 | if ( ! $entry || is_wp_error( $entry ) ) { |
| 846 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
| 846 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - if ( empty( $entry['form_id'] ) ) { |
|
| 849 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
| 850 | 850 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
| 851 | 851 | } |
| 852 | 852 | |
@@ -854,55 +854,55 @@ discard block |
||
| 854 | 854 | 'context_view_id' => $view ? $view->ID : null, |
| 855 | 855 | ) ); |
| 856 | 856 | |
| 857 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
| 857 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
| 858 | 858 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No search criteria found:', array( 'data' => $criteria ) ); |
| 859 | 859 | return $entry; |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | // Make sure the current View is connected to the same form as the Entry |
| 863 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
| 864 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
| 863 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 864 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
| 865 | 865 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
| 866 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
| 867 | - return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
| 866 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
| 867 | + return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - $search_criteria = $criteria['search_criteria']; |
|
| 871 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
| 872 | 872 | |
| 873 | 873 | // check entry status |
| 874 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
| 875 | - return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
| 874 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
| 875 | + return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | // check entry date |
| 879 | 879 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
| 880 | 880 | |
| 881 | 881 | // field_filters |
| 882 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
| 882 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
| 883 | 883 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No field filters criteria found:', array( 'data' => $search_criteria ) ); |
| 884 | 884 | return $entry; |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - $filters = $search_criteria['field_filters']; |
|
| 887 | + $filters = $search_criteria[ 'field_filters' ]; |
|
| 888 | 888 | |
| 889 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
| 889 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
| 890 | 890 | |
| 891 | - $mode = $mode ? : 'all'; // If mode is an empty string, assume it's 'all' |
|
| 891 | + $mode = $mode ?: 'all'; // If mode is an empty string, assume it's 'all' |
|
| 892 | 892 | |
| 893 | 893 | // Prevent the mode from being processed below |
| 894 | - unset( $filters['mode'] ); |
|
| 894 | + unset( $filters[ 'mode' ] ); |
|
| 895 | 895 | |
| 896 | - $form = self::get_form( $entry['form_id'] ); |
|
| 896 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
| 897 | 897 | |
| 898 | 898 | foreach ( $filters as $filter ) { |
| 899 | 899 | |
| 900 | - if ( ! isset( $filter['key'] ) ) { |
|
| 900 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
| 901 | 901 | gravityview()->log->debug( '[apply_filters_to_entry] Filter key not set: {filter}', array( 'filter' => $filter ) ); |
| 902 | 902 | continue; |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - $k = $filter['key']; |
|
| 905 | + $k = $filter[ 'key' ]; |
|
| 906 | 906 | |
| 907 | 907 | $field = self::get_field( $form, $k ); |
| 908 | 908 | |
@@ -910,14 +910,14 @@ discard block |
||
| 910 | 910 | $field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; |
| 911 | 911 | $field = $k; |
| 912 | 912 | } else { |
| 913 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 913 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 914 | 914 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
| 915 | 915 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? \GV\Utils::get( $field_value, $k ) : $field_value; |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
| 918 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
| 919 | 919 | |
| 920 | - $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
| 920 | + $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
| 921 | 921 | |
| 922 | 922 | // Any match is all we need to know |
| 923 | 923 | if ( $is_value_match && 'any' === $mode ) { |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | |
| 927 | 927 | // Any failed match is a total fail |
| 928 | 928 | if ( ! $is_value_match && 'all' === $mode ) { |
| 929 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
| 929 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
| 930 | 930 | } |
| 931 | 931 | } |
| 932 | 932 | |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved: all conditions were met' ); |
| 937 | 937 | return $entry; |
| 938 | 938 | } else { |
| 939 | - return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 939 | + return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | } |
@@ -977,18 +977,18 @@ discard block |
||
| 977 | 977 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 978 | 978 | * @see GFCommon::format_date() for original code |
| 979 | 979 | */ |
| 980 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 980 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 981 | 981 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
| 982 | 982 | |
| 983 | - $format = \GV\Utils::get( $atts, 'format' ); |
|
| 984 | - $is_human = ! empty( $atts['human'] ); |
|
| 985 | - $is_diff = ! empty( $atts['diff'] ); |
|
| 986 | - $is_raw = ! empty( $atts['raw'] ); |
|
| 987 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
| 988 | - $include_time = ! empty( $atts['time'] ); |
|
| 983 | + $format = \GV\Utils::get( $atts, 'format' ); |
|
| 984 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
| 985 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
| 986 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
| 987 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
| 988 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
| 989 | 989 | |
| 990 | 990 | // If we're using time diff, we want to have a different default format |
| 991 | - if( empty( $format ) ) { |
|
| 991 | + if ( empty( $format ) ) { |
|
| 992 | 992 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
| 993 | 993 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
| 994 | 994 | } |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | // If raw was specified, don't modify the stored value |
| 997 | 997 | if ( $is_raw ) { |
| 998 | 998 | $formatted_date = $date_string; |
| 999 | - } elseif( $is_timestamp ) { |
|
| 999 | + } elseif ( $is_timestamp ) { |
|
| 1000 | 1000 | $formatted_date = $date_local_timestamp; |
| 1001 | 1001 | } elseif ( $is_diff ) { |
| 1002 | 1002 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | |
| 1031 | 1031 | $label = \GV\Utils::get( $field, 'label' ); |
| 1032 | 1032 | |
| 1033 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 1033 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 1034 | 1034 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
| 1035 | 1035 | } |
| 1036 | 1036 | |
@@ -1058,7 +1058,7 @@ discard block |
||
| 1058 | 1058 | $form = GFAPI::get_form( $form ); |
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 1061 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 1062 | 1062 | return GFFormsModel::get_field( $form, $field_id ); |
| 1063 | 1063 | } else { |
| 1064 | 1064 | return null; |
@@ -1105,19 +1105,19 @@ discard block |
||
| 1105 | 1105 | $shortcodes = array(); |
| 1106 | 1106 | |
| 1107 | 1107 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 1108 | - if ( empty( $matches ) ){ |
|
| 1108 | + if ( empty( $matches ) ) { |
|
| 1109 | 1109 | return false; |
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | foreach ( $matches as $shortcode ) { |
| 1113 | - if ( $tag === $shortcode[2] ) { |
|
| 1113 | + if ( $tag === $shortcode[ 2 ] ) { |
|
| 1114 | 1114 | |
| 1115 | 1115 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 1116 | - $shortcodes[] = $shortcode; |
|
| 1116 | + $shortcodes[ ] = $shortcode; |
|
| 1117 | 1117 | |
| 1118 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 1119 | - foreach( $results as $result ) { |
|
| 1120 | - $shortcodes[] = $result; |
|
| 1118 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
| 1119 | + foreach ( $results as $result ) { |
|
| 1120 | + $shortcodes[ ] = $result; |
|
| 1121 | 1121 | } |
| 1122 | 1122 | } |
| 1123 | 1123 | } |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | 'post_type' => 'gravityview', |
| 1150 | 1150 | 'posts_per_page' => 100, |
| 1151 | 1151 | 'meta_key' => '_gravityview_form_id', |
| 1152 | - 'meta_value' => (int) $form_id, |
|
| 1152 | + 'meta_value' => (int)$form_id, |
|
| 1153 | 1153 | ); |
| 1154 | 1154 | $args = wp_parse_args( $args, $defaults ); |
| 1155 | 1155 | $views = get_posts( $args ); |
@@ -1161,21 +1161,21 @@ discard block |
||
| 1161 | 1161 | |
| 1162 | 1162 | $data = unserialize( $view->meta_value ); |
| 1163 | 1163 | |
| 1164 | - if( ! $data || ! is_array( $data ) ) { |
|
| 1164 | + if ( ! $data || ! is_array( $data ) ) { |
|
| 1165 | 1165 | continue; |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | foreach ( $data as $datum ) { |
| 1169 | - if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) { |
|
| 1170 | - $joined_forms[] = $view->post_id; |
|
| 1169 | + if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) { |
|
| 1170 | + $joined_forms[ ] = $view->post_id; |
|
| 1171 | 1171 | } |
| 1172 | 1172 | } |
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | 1175 | if ( $joined_forms ) { |
| 1176 | - $joined_args = array( |
|
| 1176 | + $joined_args = array( |
|
| 1177 | 1177 | 'post_type' => 'gravityview', |
| 1178 | - 'posts_per_page' => $args['posts_per_page'], |
|
| 1178 | + 'posts_per_page' => $args[ 'posts_per_page' ], |
|
| 1179 | 1179 | 'post__in' => $joined_forms, |
| 1180 | 1180 | ); |
| 1181 | 1181 | $views = array_merge( $views, get_posts( $joined_args ) ); |
@@ -1331,7 +1331,7 @@ discard block |
||
| 1331 | 1331 | |
| 1332 | 1332 | $directory_widgets = wp_parse_args( $view_widgets, $defaults ); |
| 1333 | 1333 | |
| 1334 | - if( $json_decode ) { |
|
| 1334 | + if ( $json_decode ) { |
|
| 1335 | 1335 | $directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' ); |
| 1336 | 1336 | } |
| 1337 | 1337 | |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | * @return string html |
| 1348 | 1348 | */ |
| 1349 | 1349 | public static function get_sortable_fields( $formid, $current = '' ) { |
| 1350 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1350 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
| 1351 | 1351 | |
| 1352 | 1352 | if ( empty( $formid ) ) { |
| 1353 | 1353 | return $output; |
@@ -1360,11 +1360,11 @@ discard block |
||
| 1360 | 1360 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
| 1361 | 1361 | |
| 1362 | 1362 | foreach ( $fields as $id => $field ) { |
| 1363 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1363 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1364 | 1364 | continue; |
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1367 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
| 1368 | 1368 | } |
| 1369 | 1369 | } |
| 1370 | 1370 | |
@@ -1399,9 +1399,9 @@ discard block |
||
| 1399 | 1399 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1400 | 1400 | |
| 1401 | 1401 | // TODO: Convert to using array_filter |
| 1402 | - foreach( $fields as $id => $field ) { |
|
| 1402 | + foreach ( $fields as $id => $field ) { |
|
| 1403 | 1403 | |
| 1404 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1404 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1405 | 1405 | unset( $fields[ $id ] ); |
| 1406 | 1406 | } |
| 1407 | 1407 | } |
@@ -1442,14 +1442,14 @@ discard block |
||
| 1442 | 1442 | * @param int|array $field field key or field array |
| 1443 | 1443 | * @return boolean |
| 1444 | 1444 | */ |
| 1445 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1445 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1446 | 1446 | |
| 1447 | 1447 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
| 1448 | 1448 | $form = self::get_form( $form ); |
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | 1451 | // If entry meta, it's a string. Otherwise, numeric |
| 1452 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1452 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1453 | 1453 | $type = $field; |
| 1454 | 1454 | } else { |
| 1455 | 1455 | $type = self::get_field_type( $form, $field ); |
@@ -1463,9 +1463,9 @@ discard block |
||
| 1463 | 1463 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
| 1464 | 1464 | |
| 1465 | 1465 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1466 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1467 | - if( true === $gv_field->is_numeric ) { |
|
| 1468 | - $numeric_types[] = $gv_field->is_numeric; |
|
| 1466 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1467 | + if ( true === $gv_field->is_numeric ) { |
|
| 1468 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
| 1469 | 1469 | } |
| 1470 | 1470 | } |
| 1471 | 1471 | |
@@ -1615,18 +1615,18 @@ discard block |
||
| 1615 | 1615 | $final_atts = array_filter( $final_atts ); |
| 1616 | 1616 | |
| 1617 | 1617 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1618 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1619 | - $final_atts['href'] = $href; |
|
| 1618 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
| 1619 | + $final_atts[ 'href' ] = $href; |
|
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1622 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
| 1623 | 1623 | |
| 1624 | 1624 | /** |
| 1625 | 1625 | * Fix potential security issue with target=_blank |
| 1626 | 1626 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
| 1627 | 1627 | */ |
| 1628 | - if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
| 1629 | - $final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1628 | + if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
| 1629 | + $final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | 1632 | // Sort the attributes alphabetically, to help testing |
@@ -1638,7 +1638,7 @@ discard block |
||
| 1638 | 1638 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
| 1639 | 1639 | } |
| 1640 | 1640 | |
| 1641 | - if( '' !== $output ) { |
|
| 1641 | + if ( '' !== $output ) { |
|
| 1642 | 1642 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
| 1643 | 1643 | } |
| 1644 | 1644 | |
@@ -1665,7 +1665,7 @@ discard block |
||
| 1665 | 1665 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
| 1666 | 1666 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
| 1667 | 1667 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
| 1668 | - $merged[] = $value; |
|
| 1668 | + $merged[ ] = $value; |
|
| 1669 | 1669 | } else { |
| 1670 | 1670 | $merged[ $key ] = $value; |
| 1671 | 1671 | } |
@@ -1698,7 +1698,7 @@ discard block |
||
| 1698 | 1698 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1699 | 1699 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1700 | 1700 | */ |
| 1701 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1701 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1702 | 1702 | |
| 1703 | 1703 | return get_users( $get_users_settings ); |
| 1704 | 1704 | } |
@@ -1718,11 +1718,11 @@ discard block |
||
| 1718 | 1718 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
| 1719 | 1719 | |
| 1720 | 1720 | // If $cap is defined, only show notice if user has capability |
| 1721 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1721 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1722 | 1722 | return ''; |
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1725 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | 1728 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * Try subkeys after split. |
| 92 | 92 | */ |
| 93 | 93 | if ( count( $parts = explode( '/', $key, 2 ) ) > 1 ) { |
| 94 | - return self::get( self::get( $array, $parts[0] ), $parts[1], $default ); |
|
| 94 | + return self::get( self::get( $array, $parts[ 0 ] ), $parts[ 1 ], $default ); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | return $default; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public static function gf_query_debug( $query ) { |
| 146 | 146 | $introspect = $query->_introspect(); |
| 147 | 147 | return array( |
| 148 | - 'where' => $query->_where_unwrap( $introspect['where'] ) |
|
| 148 | + 'where' => $query->_where_unwrap( $introspect[ 'where' ] ) |
|
| 149 | 149 | ); |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -115,16 +115,16 @@ discard block |
||
| 115 | 115 | function load() { |
| 116 | 116 | |
| 117 | 117 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 118 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 118 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 119 | 119 | |
| 120 | 120 | // Don't display an embedded form when editing an entry |
| 121 | 121 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
| 122 | 122 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
| 123 | 123 | |
| 124 | 124 | // Stop Gravity Forms processing what is ours! |
| 125 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
| 125 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
| 126 | 126 | |
| 127 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 127 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 128 | 128 | |
| 129 | 129 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
| 130 | 130 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 136 | 136 | |
| 137 | 137 | // Add fields expected by GFFormDisplay::validate() |
| 138 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 138 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 139 | 139 | |
| 140 | 140 | // Fix multiselect value for GF 2.2 |
| 141 | 141 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | * @return void |
| 153 | 153 | */ |
| 154 | 154 | public function prevent_render_form() { |
| 155 | - if( $this->is_edit_entry() ) { |
|
| 156 | - if( 'wp_head' === current_filter() ) { |
|
| 155 | + if ( $this->is_edit_entry() ) { |
|
| 156 | + if ( 'wp_head' === current_filter() ) { |
|
| 157 | 157 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 158 | 158 | } else { |
| 159 | 159 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -168,13 +168,13 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function prevent_maybe_process_form() { |
| 170 | 170 | |
| 171 | - if( ! empty( $_POST ) ) { |
|
| 171 | + if ( ! empty( $_POST ) ) { |
|
| 172 | 172 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if( $this->is_edit_entry_submission() ) { |
|
| 176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 175 | + if ( $this->is_edit_entry_submission() ) { |
|
| 176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function is_edit_entry() { |
| 186 | 186 | |
| 187 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
| 187 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
| 188 | 188 | |
| 189 | 189 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @return boolean |
| 196 | 196 | */ |
| 197 | 197 | public function is_edit_entry_submission() { |
| 198 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 198 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | $entries = $gravityview_view->getEntries(); |
| 211 | - self::$original_entry = $entries[0]; |
|
| 212 | - $this->entry = $entries[0]; |
|
| 211 | + self::$original_entry = $entries[ 0 ]; |
|
| 212 | + $this->entry = $entries[ 0 ]; |
|
| 213 | 213 | |
| 214 | 214 | self::$original_form = $gravityview_view->getForm(); |
| 215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $this->view_id = $gravityview_view->getViewId(); |
| 218 | 218 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
| 219 | 219 | |
| 220 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 220 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | private function print_scripts() { |
| 269 | 269 | $gravityview_view = GravityView_View::getInstance(); |
| 270 | 270 | |
| 271 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 271 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 272 | 272 | |
| 273 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
| 273 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 274 | 274 | |
| 275 | 275 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
| 276 | 276 | |
@@ -286,19 +286,19 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | private function process_save( $gv_data ) { |
| 288 | 288 | |
| 289 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 289 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 290 | 290 | return; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // Make sure the entry, view, and form IDs are all correct |
| 294 | 294 | $valid = $this->verify_nonce(); |
| 295 | 295 | |
| 296 | - if ( !$valid ) { |
|
| 296 | + if ( ! $valid ) { |
|
| 297 | 297 | gravityview()->log->error( 'Nonce validation failed.' ); |
| 298 | 298 | return; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 301 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 302 | 302 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
| 303 | 303 | return; |
| 304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | $this->validate(); |
| 311 | 311 | |
| 312 | - if( $this->is_valid ) { |
|
| 312 | + if ( $this->is_valid ) { |
|
| 313 | 313 | |
| 314 | 314 | gravityview()->log->debug( 'Submission is valid.' ); |
| 315 | 315 | |
@@ -321,22 +321,22 @@ discard block |
||
| 321 | 321 | /** |
| 322 | 322 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 323 | 323 | */ |
| 324 | - unset( $_GET['page'] ); |
|
| 324 | + unset( $_GET[ 'page' ] ); |
|
| 325 | 325 | |
| 326 | - $date_created = $this->entry['date_created']; |
|
| 326 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | 329 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 330 | 330 | * @since 1.17.2 |
| 331 | 331 | */ |
| 332 | - unset( $this->entry['date_created'] ); |
|
| 332 | + unset( $this->entry[ 'date_created' ] ); |
|
| 333 | 333 | |
| 334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
| 335 | 335 | |
| 336 | 336 | // Delete the values for hidden inputs |
| 337 | 337 | $this->unset_hidden_field_values(); |
| 338 | 338 | |
| 339 | - $this->entry['date_created'] = $date_created; |
|
| 339 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 340 | 340 | |
| 341 | 341 | // Process calculation fields |
| 342 | 342 | $this->update_calculation_fields(); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * @param GravityView_Edit_Entry_Render $this This object |
| 362 | 362 | * @param GravityView_View_Data $gv_data The View data |
| 363 | 363 | */ |
| 364 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
| 364 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 365 | 365 | |
| 366 | 366 | } else { |
| 367 | 367 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -389,16 +389,16 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
| 391 | 391 | |
| 392 | - if( ! $unset_hidden_field_values ) { |
|
| 392 | + if ( ! $unset_hidden_field_values ) { |
|
| 393 | 393 | return; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 397 | 397 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 398 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 398 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 399 | 399 | } else { |
| 400 | 400 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 401 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 401 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** No file is being uploaded. */ |
| 482 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 482 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 483 | 483 | /** So return the original upload */ |
| 484 | 484 | return $entry[ $input_id ]; |
| 485 | 485 | } |
@@ -497,11 +497,11 @@ discard block |
||
| 497 | 497 | * @return mixed |
| 498 | 498 | */ |
| 499 | 499 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 500 | - if( ! $this->is_edit_entry() ) { |
|
| 500 | + if ( ! $this->is_edit_entry() ) { |
|
| 501 | 501 | return $plupload_init; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 504 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 505 | 505 | |
| 506 | 506 | return $plupload_init; |
| 507 | 507 | } |
@@ -516,27 +516,27 @@ discard block |
||
| 516 | 516 | $form = $this->form; |
| 517 | 517 | |
| 518 | 518 | /** @var GF_Field $field */ |
| 519 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 519 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 520 | 520 | |
| 521 | 521 | /** |
| 522 | 522 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 523 | 523 | * @since 1.16.3 |
| 524 | 524 | * @var GF_Field $field |
| 525 | 525 | */ |
| 526 | - if( $field->has_calculation() ) { |
|
| 527 | - unset( $form['fields'][ $k ] ); |
|
| 526 | + if ( $field->has_calculation() ) { |
|
| 527 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | $field->adminOnly = false; |
| 531 | 531 | |
| 532 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 533 | - foreach( $field->inputs as $key => $input ) { |
|
| 534 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 532 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 533 | + foreach ( $field->inputs as $key => $input ) { |
|
| 534 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 539 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 540 | 540 | |
| 541 | 541 | return $form; |
| 542 | 542 | } |
@@ -548,14 +548,14 @@ discard block |
||
| 548 | 548 | $update = false; |
| 549 | 549 | |
| 550 | 550 | // get the most up to date entry values |
| 551 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 551 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 552 | 552 | |
| 553 | 553 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 554 | 554 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 555 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, meta_key FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
| 555 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, meta_key FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
| 556 | 556 | } else { |
| 557 | 557 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 558 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
| 558 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | if ( ! empty( $this->fields_with_calculation ) ) { |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | $inputs = $field->get_entry_inputs(); |
| 565 | 565 | if ( is_array( $inputs ) ) { |
| 566 | 566 | foreach ( $inputs as $input ) { |
| 567 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
| 567 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
| 568 | 568 | } |
| 569 | 569 | } else { |
| 570 | 570 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $field->id ); |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | return; |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 589 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 590 | 590 | |
| 591 | 591 | foreach ( array( 'score', 'percent', 'grade', 'is_pass' ) as $meta ) { |
| 592 | 592 | GFQuiz::get_instance()->update_entry_meta( "gfquiz_$meta", $entry, self::$original_form ); |
@@ -616,19 +616,19 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | $input_name = 'input_' . $field_id; |
| 618 | 618 | |
| 619 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 619 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 620 | 620 | |
| 621 | 621 | // We have a new image |
| 622 | 622 | |
| 623 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 623 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 624 | 624 | |
| 625 | 625 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 626 | 626 | $ary = stripslashes_deep( $ary ); |
| 627 | 627 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 628 | 628 | |
| 629 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 630 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 631 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 629 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 630 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 631 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 632 | 632 | |
| 633 | 633 | $image_meta = array( |
| 634 | 634 | 'post_excerpt' => $img_caption, |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | |
| 638 | 638 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 639 | 639 | if ( ! empty( $img_title ) ) { |
| 640 | - $image_meta['post_title'] = $img_title; |
|
| 640 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -695,15 +695,15 @@ discard block |
||
| 695 | 695 | */ |
| 696 | 696 | private function maybe_update_post_fields( $form ) { |
| 697 | 697 | |
| 698 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 698 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 699 | 699 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
| 700 | 700 | return; |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | - $post_id = $this->entry['post_id']; |
|
| 703 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 704 | 704 | |
| 705 | 705 | // Security check |
| 706 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 706 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 707 | 707 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
| 708 | 708 | return; |
| 709 | 709 | } |
@@ -716,25 +716,25 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 718 | 718 | |
| 719 | - if( ! $field ) { |
|
| 719 | + if ( ! $field ) { |
|
| 720 | 720 | continue; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 723 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 724 | 724 | |
| 725 | 725 | // Get the value of the field, including $_POSTed value |
| 726 | 726 | $value = RGFormsModel::get_field_value( $field ); |
| 727 | 727 | |
| 728 | 728 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 729 | 729 | $entry_tmp = $this->entry; |
| 730 | - $entry_tmp["{$field_id}"] = $value; |
|
| 730 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 731 | 731 | |
| 732 | - switch( $field->type ) { |
|
| 732 | + switch ( $field->type ) { |
|
| 733 | 733 | |
| 734 | 734 | case 'post_title': |
| 735 | 735 | $post_title = $value; |
| 736 | 736 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
| 737 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 737 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 738 | 738 | } |
| 739 | 739 | $updated_post->post_title = $post_title; |
| 740 | 740 | $updated_post->post_name = $post_title; |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | case 'post_content': |
| 745 | 745 | $post_content = $value; |
| 746 | 746 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
| 747 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 747 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 748 | 748 | } |
| 749 | 749 | $updated_post->post_content = $post_content; |
| 750 | 750 | unset( $post_content ); |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | $value = $value[ $field_id ]; |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 765 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 766 | 766 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 767 | 767 | } |
| 768 | 768 | |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | // update entry after |
| 783 | - $this->entry["{$field_id}"] = $value; |
|
| 783 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 784 | 784 | |
| 785 | 785 | $update_entry = true; |
| 786 | 786 | |
@@ -789,11 +789,11 @@ discard block |
||
| 789 | 789 | |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | - if( $update_entry ) { |
|
| 792 | + if ( $update_entry ) { |
|
| 793 | 793 | |
| 794 | 794 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 795 | 795 | |
| 796 | - if( is_wp_error( $return_entry ) ) { |
|
| 796 | + if ( is_wp_error( $return_entry ) ) { |
|
| 797 | 797 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
| 798 | 798 | } else { |
| 799 | 799 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | |
| 804 | 804 | $return_post = wp_update_post( $updated_post, true ); |
| 805 | 805 | |
| 806 | - if( is_wp_error( $return_post ) ) { |
|
| 806 | + if ( is_wp_error( $return_post ) ) { |
|
| 807 | 807 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 808 | 808 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
| 809 | 809 | } else { |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | $input_type = RGFormsModel::get_input_type( $field ); |
| 826 | 826 | |
| 827 | 827 | // Only certain custom field types are supported |
| 828 | - switch( $input_type ) { |
|
| 828 | + switch ( $input_type ) { |
|
| 829 | 829 | case 'fileupload': |
| 830 | 830 | case 'list': |
| 831 | 831 | case 'multiselect': |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 863 | 863 | |
| 864 | 864 | // replace conditional shortcodes |
| 865 | - if( $do_shortcode ) { |
|
| 865 | + if ( $do_shortcode ) { |
|
| 866 | 866 | $output = do_shortcode( $output ); |
| 867 | 867 | } |
| 868 | 868 | |
@@ -881,19 +881,19 @@ discard block |
||
| 881 | 881 | */ |
| 882 | 882 | private function after_update() { |
| 883 | 883 | |
| 884 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 885 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
| 884 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 885 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 886 | 886 | |
| 887 | 887 | // Re-define the entry now that we've updated it. |
| 888 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 888 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 889 | 889 | |
| 890 | 890 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
| 891 | 891 | |
| 892 | 892 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 893 | 893 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 894 | 894 | // we have just updated. |
| 895 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 896 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 895 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 896 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 897 | 897 | } |
| 898 | 898 | } |
| 899 | 899 | |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | |
| 913 | 913 | <div class="gv-edit-entry-wrapper"><?php |
| 914 | 914 | |
| 915 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 915 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 916 | 916 | |
| 917 | 917 | /** |
| 918 | 918 | * Fixes weird wpautop() issue |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 929 | 929 | * @param GravityView_Edit_Entry_Render $this This object |
| 930 | 930 | */ |
| 931 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 931 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 932 | 932 | |
| 933 | 933 | echo esc_attr( $edit_entry_title ); |
| 934 | 934 | ?></span> |
@@ -978,16 +978,16 @@ discard block |
||
| 978 | 978 | |
| 979 | 979 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
| 980 | 980 | |
| 981 | - if( ! $this->is_valid ){ |
|
| 981 | + if ( ! $this->is_valid ) { |
|
| 982 | 982 | |
| 983 | 983 | // Keeping this compatible with Gravity Forms. |
| 984 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 985 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 984 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 985 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 986 | 986 | |
| 987 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 987 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 988 | 988 | |
| 989 | 989 | } else { |
| 990 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 990 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
| 991 | 991 | |
| 992 | 992 | /** |
| 993 | 993 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -997,7 +997,7 @@ discard block |
||
| 997 | 997 | * @param array $entry Gravity Forms entry array |
| 998 | 998 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 999 | 999 | */ |
| 1000 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 1000 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 1001 | 1001 | |
| 1002 | 1002 | echo GVCommon::generate_notice( $message ); |
| 1003 | 1003 | } |
@@ -1021,21 +1021,21 @@ discard block |
||
| 1021 | 1021 | */ |
| 1022 | 1022 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 1023 | 1023 | |
| 1024 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1025 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1024 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1025 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1026 | 1026 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1027 | 1027 | |
| 1028 | 1028 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
| 1029 | 1029 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1030 | 1030 | |
| 1031 | 1031 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1032 | - unset( $_GET['page'] ); |
|
| 1032 | + unset( $_GET[ 'page' ] ); |
|
| 1033 | 1033 | |
| 1034 | 1034 | // TODO: Verify multiple-page forms |
| 1035 | 1035 | |
| 1036 | 1036 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1037 | 1037 | |
| 1038 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1038 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1039 | 1039 | |
| 1040 | 1040 | ob_get_clean(); |
| 1041 | 1041 | |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | * @return string |
| 1062 | 1062 | */ |
| 1063 | 1063 | public function render_form_buttons() { |
| 1064 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1064 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | 1067 | |
@@ -1081,10 +1081,10 @@ discard block |
||
| 1081 | 1081 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1082 | 1082 | |
| 1083 | 1083 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1084 | - if( isset( $this->form_after_validation ) ) { |
|
| 1084 | + if ( isset( $this->form_after_validation ) ) { |
|
| 1085 | 1085 | $form = $this->form_after_validation; |
| 1086 | 1086 | } else { |
| 1087 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1087 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | $form = $this->filter_conditional_logic( $form ); |
@@ -1092,8 +1092,8 @@ discard block |
||
| 1092 | 1092 | $form = $this->prefill_conditional_logic( $form ); |
| 1093 | 1093 | |
| 1094 | 1094 | // for now we don't support Save and Continue feature. |
| 1095 | - if( ! self::$supports_save_and_continue ) { |
|
| 1096 | - unset( $form['save'] ); |
|
| 1095 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1096 | + unset( $form[ 'save' ] ); |
|
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | 1099 | $form = $this->unselect_default_values( $form ); |
@@ -1116,31 +1116,31 @@ discard block |
||
| 1116 | 1116 | */ |
| 1117 | 1117 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1118 | 1118 | |
| 1119 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
| 1119 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
| 1120 | 1120 | return $field_content; |
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | $message = null; |
| 1124 | 1124 | |
| 1125 | 1125 | // First, make sure they have the capability to edit the post. |
| 1126 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1126 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1127 | 1127 | |
| 1128 | 1128 | /** |
| 1129 | 1129 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1130 | 1130 | * @param string $message The existing "You don't have permission..." text |
| 1131 | 1131 | */ |
| 1132 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1132 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1133 | 1133 | |
| 1134 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1134 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1135 | 1135 | /** |
| 1136 | 1136 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1137 | 1137 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1138 | 1138 | */ |
| 1139 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1139 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | - if( $message ) { |
|
| 1143 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1142 | + if ( $message ) { |
|
| 1143 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | 1146 | return $field_content; |
@@ -1164,8 +1164,8 @@ discard block |
||
| 1164 | 1164 | |
| 1165 | 1165 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1166 | 1166 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1167 | - if( |
|
| 1168 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1167 | + if ( |
|
| 1168 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1169 | 1169 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1170 | 1170 | && ! GFCommon::is_product_field( $field->type ) |
| 1171 | 1171 | || ! empty( $field_content ) |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | $return = null; |
| 1186 | 1186 | |
| 1187 | 1187 | /** @var GravityView_Field $gv_field */ |
| 1188 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1188 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1189 | 1189 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1190 | 1190 | } else { |
| 1191 | 1191 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1194,7 +1194,7 @@ discard block |
||
| 1194 | 1194 | // If there was output, it's an error |
| 1195 | 1195 | $warnings = ob_get_clean(); |
| 1196 | 1196 | |
| 1197 | - if( !empty( $warnings ) ) { |
|
| 1197 | + if ( ! empty( $warnings ) ) { |
|
| 1198 | 1198 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1199 | 1199 | } |
| 1200 | 1200 | |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1220 | 1220 | |
| 1221 | 1221 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1222 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1222 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1223 | 1223 | |
| 1224 | 1224 | $field_value = array(); |
| 1225 | 1225 | |
@@ -1228,10 +1228,10 @@ discard block |
||
| 1228 | 1228 | |
| 1229 | 1229 | foreach ( (array)$field->inputs as $input ) { |
| 1230 | 1230 | |
| 1231 | - $input_id = strval( $input['id'] ); |
|
| 1231 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1232 | 1232 | |
| 1233 | 1233 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1234 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1234 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1235 | 1235 | $allow_pre_populated = false; |
| 1236 | 1236 | } |
| 1237 | 1237 | |
@@ -1239,7 +1239,7 @@ discard block |
||
| 1239 | 1239 | |
| 1240 | 1240 | $pre_value = $field->get_value_submission( array(), false ); |
| 1241 | 1241 | |
| 1242 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1242 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1243 | 1243 | |
| 1244 | 1244 | } else { |
| 1245 | 1245 | |
@@ -1250,13 +1250,13 @@ discard block |
||
| 1250 | 1250 | |
| 1251 | 1251 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1252 | 1252 | // or pre-populated value if not empty and set to override saved value |
| 1253 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1253 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1254 | 1254 | |
| 1255 | 1255 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1256 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1256 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1257 | 1257 | $categories = array(); |
| 1258 | 1258 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1259 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1259 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1262 | 1262 | } |
@@ -1284,7 +1284,7 @@ discard block |
||
| 1284 | 1284 | * @param GF_Field $field Gravity Forms field object |
| 1285 | 1285 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1286 | 1286 | */ |
| 1287 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1287 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1288 | 1288 | |
| 1289 | 1289 | return $field_value; |
| 1290 | 1290 | } |
@@ -1301,12 +1301,12 @@ discard block |
||
| 1301 | 1301 | */ |
| 1302 | 1302 | public function gform_pre_validation( $form ) { |
| 1303 | 1303 | |
| 1304 | - if( ! $this->verify_nonce() ) { |
|
| 1304 | + if ( ! $this->verify_nonce() ) { |
|
| 1305 | 1305 | return $form; |
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | 1308 | // Fix PHP warning regarding undefined index. |
| 1309 | - foreach ( $form['fields'] as &$field) { |
|
| 1309 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1310 | 1310 | |
| 1311 | 1311 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1312 | 1312 | // expects certain field array items to be set. |
@@ -1314,7 +1314,7 @@ discard block |
||
| 1314 | 1314 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1317 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1318 | 1318 | |
| 1319 | 1319 | /** |
| 1320 | 1320 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1328,26 +1328,26 @@ discard block |
||
| 1328 | 1328 | // Set the previous value |
| 1329 | 1329 | $entry = $this->get_entry(); |
| 1330 | 1330 | |
| 1331 | - $input_name = 'input_'.$field->id; |
|
| 1332 | - $form_id = $form['id']; |
|
| 1331 | + $input_name = 'input_' . $field->id; |
|
| 1332 | + $form_id = $form[ 'id' ]; |
|
| 1333 | 1333 | |
| 1334 | 1334 | $value = NULL; |
| 1335 | 1335 | |
| 1336 | 1336 | // Use the previous entry value as the default. |
| 1337 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1337 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1338 | 1338 | $value = $entry[ $field->id ]; |
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | // If this is a single upload file |
| 1342 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1343 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1344 | - $value = $file_path['url']; |
|
| 1342 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1343 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1344 | + $value = $file_path[ 'url' ]; |
|
| 1345 | 1345 | |
| 1346 | 1346 | } else { |
| 1347 | 1347 | |
| 1348 | 1348 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1349 | 1349 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1350 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1350 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1351 | 1351 | |
| 1352 | 1352 | } |
| 1353 | 1353 | |
@@ -1355,10 +1355,10 @@ discard block |
||
| 1355 | 1355 | |
| 1356 | 1356 | // If there are fresh uploads, process and merge them. |
| 1357 | 1357 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1358 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1358 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1359 | 1359 | $value = empty( $value ) ? '[]' : $value; |
| 1360 | 1360 | $value = stripslashes_deep( $value ); |
| 1361 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1361 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | } else { |
@@ -1376,8 +1376,8 @@ discard block |
||
| 1376 | 1376 | |
| 1377 | 1377 | case 'number': |
| 1378 | 1378 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1379 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1380 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1379 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1380 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1381 | 1381 | } |
| 1382 | 1382 | break; |
| 1383 | 1383 | } |
@@ -1414,7 +1414,7 @@ discard block |
||
| 1414 | 1414 | * You can enter whatever you want! |
| 1415 | 1415 | * We try validating, and customize the results using `self::custom_validation()` |
| 1416 | 1416 | */ |
| 1417 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1417 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1418 | 1418 | |
| 1419 | 1419 | // Needed by the validate funtion |
| 1420 | 1420 | $failed_validation_page = NULL; |
@@ -1422,14 +1422,14 @@ discard block |
||
| 1422 | 1422 | |
| 1423 | 1423 | // Prevent entry limit from running when editing an entry, also |
| 1424 | 1424 | // prevent form scheduling from preventing editing |
| 1425 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1425 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1426 | 1426 | |
| 1427 | 1427 | // Hide fields depending on Edit Entry settings |
| 1428 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1428 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1429 | 1429 | |
| 1430 | 1430 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1431 | 1431 | |
| 1432 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1432 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | 1435 | |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | |
| 1453 | 1453 | $gv_valid = true; |
| 1454 | 1454 | |
| 1455 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1455 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1456 | 1456 | |
| 1457 | 1457 | $value = RGFormsModel::get_field_value( $field ); |
| 1458 | 1458 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1465,35 +1465,35 @@ discard block |
||
| 1465 | 1465 | case 'post_image': |
| 1466 | 1466 | |
| 1467 | 1467 | // in case nothing is uploaded but there are already files saved |
| 1468 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1468 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1469 | 1469 | $field->failed_validation = false; |
| 1470 | 1470 | unset( $field->validation_message ); |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1474 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1474 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
| 1475 | 1475 | |
| 1476 | 1476 | $input_name = 'input_' . $field->id; |
| 1477 | 1477 | //uploaded |
| 1478 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1478 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1479 | 1479 | |
| 1480 | 1480 | //existent |
| 1481 | 1481 | $entry = $this->get_entry(); |
| 1482 | 1482 | $value = NULL; |
| 1483 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1483 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1484 | 1484 | $value = json_decode( $entry[ $field->id ], true ); |
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | // count uploaded files and existent entry files |
| 1488 | 1488 | $count_files = count( $file_names ) + count( $value ); |
| 1489 | 1489 | |
| 1490 | - if( $count_files > $field->maxFiles ) { |
|
| 1490 | + if ( $count_files > $field->maxFiles ) { |
|
| 1491 | 1491 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1492 | 1492 | $field->failed_validation = 1; |
| 1493 | 1493 | $gv_valid = false; |
| 1494 | 1494 | |
| 1495 | 1495 | // in case of error make sure the newest upload files are removed from the upload input |
| 1496 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1496 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | 1499 | } |
@@ -1504,7 +1504,7 @@ discard block |
||
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | 1506 | // This field has failed validation. |
| 1507 | - if( !empty( $field->failed_validation ) ) { |
|
| 1507 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1508 | 1508 | |
| 1509 | 1509 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1510 | 1510 | |
@@ -1522,19 +1522,19 @@ discard block |
||
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | 1524 | // You can't continue inside a switch, so we do it after. |
| 1525 | - if( empty( $field->failed_validation ) ) { |
|
| 1525 | + if ( empty( $field->failed_validation ) ) { |
|
| 1526 | 1526 | continue; |
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1530 | 1530 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1531 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1531 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1532 | 1532 | |
| 1533 | 1533 | $entry = $this->get_entry(); |
| 1534 | 1534 | |
| 1535 | 1535 | // If the value of the entry is the same as the stored value |
| 1536 | 1536 | // Then we can assume it's not a duplicate, it's the same. |
| 1537 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1537 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1538 | 1538 | //if value submitted was not changed, then don't validate |
| 1539 | 1539 | $field->failed_validation = false; |
| 1540 | 1540 | |
@@ -1547,7 +1547,7 @@ discard block |
||
| 1547 | 1547 | } |
| 1548 | 1548 | |
| 1549 | 1549 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1550 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1550 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1551 | 1551 | unset( $field->validation_message ); |
| 1552 | 1552 | $field->validation_message = false; |
| 1553 | 1553 | continue; |
@@ -1559,12 +1559,12 @@ discard block |
||
| 1559 | 1559 | |
| 1560 | 1560 | } |
| 1561 | 1561 | |
| 1562 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1562 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1563 | 1563 | |
| 1564 | 1564 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1565 | 1565 | |
| 1566 | 1566 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1567 | - $this->form_after_validation = $validation_results['form']; |
|
| 1567 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1568 | 1568 | |
| 1569 | 1569 | return $validation_results; |
| 1570 | 1570 | } |
@@ -1577,7 +1577,7 @@ discard block |
||
| 1577 | 1577 | */ |
| 1578 | 1578 | public function get_entry() { |
| 1579 | 1579 | |
| 1580 | - if( empty( $this->entry ) ) { |
|
| 1580 | + if ( empty( $this->entry ) ) { |
|
| 1581 | 1581 | // Get the database value of the entry that's being edited |
| 1582 | 1582 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1583 | 1583 | } |
@@ -1609,10 +1609,10 @@ discard block |
||
| 1609 | 1609 | } |
| 1610 | 1610 | |
| 1611 | 1611 | // If edit tab not yet configured, show all fields |
| 1612 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1612 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1613 | 1613 | |
| 1614 | 1614 | // Hide fields depending on admin settings |
| 1615 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1615 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1616 | 1616 | |
| 1617 | 1617 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1618 | 1618 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1644,7 +1644,7 @@ discard block |
||
| 1644 | 1644 | */ |
| 1645 | 1645 | private function filter_fields( $fields, $configured_fields ) { |
| 1646 | 1646 | |
| 1647 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1647 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1648 | 1648 | return $fields; |
| 1649 | 1649 | } |
| 1650 | 1650 | |
@@ -1657,18 +1657,18 @@ discard block |
||
| 1657 | 1657 | |
| 1658 | 1658 | // Remove the fields that have calculation properties and keep them to be used later |
| 1659 | 1659 | // @since 1.16.2 |
| 1660 | - if( $field->has_calculation() ) { |
|
| 1661 | - $this->fields_with_calculation[] = $field; |
|
| 1660 | + if ( $field->has_calculation() ) { |
|
| 1661 | + $this->fields_with_calculation[ ] = $field; |
|
| 1662 | 1662 | // don't remove the calculation fields on form render. |
| 1663 | 1663 | } |
| 1664 | 1664 | |
| 1665 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1665 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1666 | 1666 | unset( $fields[ $key ] ); |
| 1667 | 1667 | } |
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | 1670 | // The Edit tab has not been configured, so we return all fields by default. |
| 1671 | - if( empty( $configured_fields ) ) { |
|
| 1671 | + if ( empty( $configured_fields ) ) { |
|
| 1672 | 1672 | return array_values( $fields ); |
| 1673 | 1673 | } |
| 1674 | 1674 | |
@@ -1677,8 +1677,8 @@ discard block |
||
| 1677 | 1677 | |
| 1678 | 1678 | /** @var GF_Field $field */ |
| 1679 | 1679 | foreach ( $fields as $field ) { |
| 1680 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1681 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1680 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1681 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1682 | 1682 | break; |
| 1683 | 1683 | } |
| 1684 | 1684 | |
@@ -1701,14 +1701,14 @@ discard block |
||
| 1701 | 1701 | |
| 1702 | 1702 | $return_field = $field; |
| 1703 | 1703 | |
| 1704 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1704 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1705 | 1705 | $return_field->label = ''; |
| 1706 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1707 | - $return_field->label = $field_setting['custom_label']; |
|
| 1706 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1707 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1708 | 1708 | } |
| 1709 | 1709 | |
| 1710 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1711 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1710 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1711 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | /** |
@@ -1746,16 +1746,16 @@ discard block |
||
| 1746 | 1746 | */ |
| 1747 | 1747 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1748 | 1748 | |
| 1749 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1750 | - foreach( $fields as $k => $field ) { |
|
| 1751 | - if( $field->adminOnly ) { |
|
| 1749 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1750 | + foreach ( $fields as $k => $field ) { |
|
| 1751 | + if ( $field->adminOnly ) { |
|
| 1752 | 1752 | unset( $fields[ $k ] ); |
| 1753 | 1753 | } |
| 1754 | 1754 | } |
| 1755 | 1755 | return array_values( $fields ); |
| 1756 | 1756 | } |
| 1757 | 1757 | |
| 1758 | - foreach( $fields as &$field ) { |
|
| 1758 | + foreach ( $fields as &$field ) { |
|
| 1759 | 1759 | $field->adminOnly = false; |
| 1760 | 1760 | } |
| 1761 | 1761 | |
@@ -1776,7 +1776,7 @@ discard block |
||
| 1776 | 1776 | */ |
| 1777 | 1777 | private function unselect_default_values( $form ) { |
| 1778 | 1778 | |
| 1779 | - foreach ( $form['fields'] as &$field ) { |
|
| 1779 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1780 | 1780 | |
| 1781 | 1781 | if ( empty( $field->choices ) ) { |
| 1782 | 1782 | continue; |
@@ -1784,7 +1784,7 @@ discard block |
||
| 1784 | 1784 | |
| 1785 | 1785 | foreach ( $field->choices as &$choice ) { |
| 1786 | 1786 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1787 | - $choice['isSelected'] = false; |
|
| 1787 | + $choice[ 'isSelected' ] = false; |
|
| 1788 | 1788 | } |
| 1789 | 1789 | } |
| 1790 | 1790 | } |
@@ -1809,22 +1809,22 @@ discard block |
||
| 1809 | 1809 | */ |
| 1810 | 1810 | function prefill_conditional_logic( $form ) { |
| 1811 | 1811 | |
| 1812 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1812 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1813 | 1813 | return $form; |
| 1814 | 1814 | } |
| 1815 | 1815 | |
| 1816 | 1816 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 1817 | 1817 | /** @var GF_Field $field */ |
| 1818 | - foreach ( $form['fields'] as &$field ) { |
|
| 1818 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1819 | 1819 | |
| 1820 | - if( 'checkbox' === $field->type ) { |
|
| 1820 | + if ( 'checkbox' === $field->type ) { |
|
| 1821 | 1821 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1822 | - $input_id = $input['id']; |
|
| 1822 | + $input_id = $input[ 'id' ]; |
|
| 1823 | 1823 | $choice = $field->choices[ $key ]; |
| 1824 | 1824 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 1825 | 1825 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 1826 | - if( $match ) { |
|
| 1827 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1826 | + if ( $match ) { |
|
| 1827 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 1828 | 1828 | } |
| 1829 | 1829 | } |
| 1830 | 1830 | } else { |
@@ -1832,15 +1832,15 @@ discard block |
||
| 1832 | 1832 | // We need to run through each field to set the default values |
| 1833 | 1833 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1834 | 1834 | |
| 1835 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1835 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1836 | 1836 | |
| 1837 | - if( 'list' === $field->type ) { |
|
| 1837 | + if ( 'list' === $field->type ) { |
|
| 1838 | 1838 | $list_rows = maybe_unserialize( $field_value ); |
| 1839 | 1839 | |
| 1840 | 1840 | $list_field_value = array(); |
| 1841 | - foreach ( (array) $list_rows as $row ) { |
|
| 1842 | - foreach ( (array) $row as $column ) { |
|
| 1843 | - $list_field_value[] = $column; |
|
| 1841 | + foreach ( (array)$list_rows as $row ) { |
|
| 1842 | + foreach ( (array)$row as $column ) { |
|
| 1843 | + $list_field_value[ ] = $column; |
|
| 1844 | 1844 | } |
| 1845 | 1845 | } |
| 1846 | 1846 | |
@@ -1875,16 +1875,16 @@ discard block |
||
| 1875 | 1875 | */ |
| 1876 | 1876 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 1877 | 1877 | |
| 1878 | - if( $use_conditional_logic ) { |
|
| 1878 | + if ( $use_conditional_logic ) { |
|
| 1879 | 1879 | return $form; |
| 1880 | 1880 | } |
| 1881 | 1881 | |
| 1882 | - foreach( $form['fields'] as &$field ) { |
|
| 1882 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1883 | 1883 | /* @var GF_Field $field */ |
| 1884 | 1884 | $field->conditionalLogic = null; |
| 1885 | 1885 | } |
| 1886 | 1886 | |
| 1887 | - unset( $form['button']['conditionalLogic'] ); |
|
| 1887 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 1888 | 1888 | |
| 1889 | 1889 | return $form; |
| 1890 | 1890 | |
@@ -1901,7 +1901,7 @@ discard block |
||
| 1901 | 1901 | */ |
| 1902 | 1902 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 1903 | 1903 | |
| 1904 | - if( ! $this->is_edit_entry() ) { |
|
| 1904 | + if ( ! $this->is_edit_entry() ) { |
|
| 1905 | 1905 | return $has_conditional_logic; |
| 1906 | 1906 | } |
| 1907 | 1907 | |
@@ -1933,44 +1933,44 @@ discard block |
||
| 1933 | 1933 | * 2. There are two entries embedded using oEmbed |
| 1934 | 1934 | * 3. One of the entries has just been saved |
| 1935 | 1935 | */ |
| 1936 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 1936 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 1937 | 1937 | |
| 1938 | 1938 | $error = true; |
| 1939 | 1939 | |
| 1940 | 1940 | } |
| 1941 | 1941 | |
| 1942 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 1942 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 1943 | 1943 | |
| 1944 | 1944 | $error = true; |
| 1945 | 1945 | |
| 1946 | - } elseif( ! $this->verify_nonce() ) { |
|
| 1946 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 1947 | 1947 | |
| 1948 | 1948 | /** |
| 1949 | 1949 | * If the Entry is embedded, there may be two entries on the same page. |
| 1950 | 1950 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 1951 | 1951 | */ |
| 1952 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1952 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1953 | 1953 | $error = true; |
| 1954 | 1954 | } else { |
| 1955 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 1955 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | 1958 | } |
| 1959 | 1959 | |
| 1960 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1961 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 1960 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1961 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 1962 | 1962 | } |
| 1963 | 1963 | |
| 1964 | - if( $this->entry['status'] === 'trash' ) { |
|
| 1965 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1964 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 1965 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1966 | 1966 | } |
| 1967 | 1967 | |
| 1968 | 1968 | // No errors; everything's fine here! |
| 1969 | - if( empty( $error ) ) { |
|
| 1969 | + if ( empty( $error ) ) { |
|
| 1970 | 1970 | return true; |
| 1971 | 1971 | } |
| 1972 | 1972 | |
| 1973 | - if( $echo && $error !== true ) { |
|
| 1973 | + if ( $echo && $error !== true ) { |
|
| 1974 | 1974 | |
| 1975 | 1975 | $error = esc_html( $error ); |
| 1976 | 1976 | |
@@ -1978,10 +1978,10 @@ discard block |
||
| 1978 | 1978 | * @since 1.9 |
| 1979 | 1979 | */ |
| 1980 | 1980 | if ( ! empty( $this->entry ) ) { |
| 1981 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 1981 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 1984 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2001,17 +2001,17 @@ discard block |
||
| 2001 | 2001 | |
| 2002 | 2002 | $error = NULL; |
| 2003 | 2003 | |
| 2004 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2005 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 2004 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2005 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 2006 | 2006 | } |
| 2007 | 2007 | |
| 2008 | 2008 | // No errors; everything's fine here! |
| 2009 | - if( empty( $error ) ) { |
|
| 2009 | + if ( empty( $error ) ) { |
|
| 2010 | 2010 | return true; |
| 2011 | 2011 | } |
| 2012 | 2012 | |
| 2013 | - if( $echo ) { |
|
| 2014 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2013 | + if ( $echo ) { |
|
| 2014 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2015 | 2015 | } |
| 2016 | 2016 | |
| 2017 | 2017 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2032,14 +2032,14 @@ discard block |
||
| 2032 | 2032 | private function check_user_cap_edit_field( $field ) { |
| 2033 | 2033 | |
| 2034 | 2034 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2035 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2035 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2036 | 2036 | return true; |
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2039 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2040 | 2040 | |
| 2041 | - if( $field_cap ) { |
|
| 2042 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2041 | + if ( $field_cap ) { |
|
| 2042 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2043 | 2043 | } |
| 2044 | 2044 | |
| 2045 | 2045 | return false; |
@@ -2053,17 +2053,17 @@ discard block |
||
| 2053 | 2053 | public function verify_nonce() { |
| 2054 | 2054 | |
| 2055 | 2055 | // Verify form submitted for editing single |
| 2056 | - if( $this->is_edit_entry_submission() ) { |
|
| 2056 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2057 | 2057 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2058 | 2058 | } |
| 2059 | 2059 | |
| 2060 | 2060 | // Verify |
| 2061 | - else if( ! $this->is_edit_entry() ) { |
|
| 2061 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2062 | 2062 | $valid = false; |
| 2063 | 2063 | } |
| 2064 | 2064 | |
| 2065 | 2065 | else { |
| 2066 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2066 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2067 | 2067 | } |
| 2068 | 2068 | |
| 2069 | 2069 | /** |
@@ -29,11 +29,11 @@ |
||
| 29 | 29 | $KWS_GF_Change_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
| 30 | 30 | |
| 31 | 31 | // Now, no validation is required in the methods; let's hook in. |
| 32 | - remove_action('admin_init', array( $KWS_GF_Change_Lead_Creator, 'set_screen_mode' ) ); |
|
| 32 | + remove_action( 'admin_init', array( $KWS_GF_Change_Lead_Creator, 'set_screen_mode' ) ); |
|
| 33 | 33 | |
| 34 | - remove_action("gform_entry_info", array( $KWS_GF_Change_Lead_Creator, 'add_select' ), 10 ); |
|
| 34 | + remove_action( "gform_entry_info", array( $KWS_GF_Change_Lead_Creator, 'add_select' ), 10 ); |
|
| 35 | 35 | |
| 36 | - remove_action("gform_after_update_entry", array( $KWS_GF_Change_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
| 36 | + remove_action( "gform_after_update_entry", array( $KWS_GF_Change_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -10,17 +10,17 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * @since 1.5.1 |
| 12 | 12 | */ |
| 13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
| 13 | + add_action( 'gform_user_registered', array( $this, 'assign_new_user_to_lead' ), 10, 4 ); |
|
| 14 | 14 | |
| 15 | 15 | // ONLY ADMIN FROM HERE ON. |
| 16 | - if( !is_admin() ) { return; } |
|
| 16 | + if ( ! is_admin() ) { return; } |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
| 20 | 20 | * @since 1.7.4 |
| 21 | 21 | * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
| 22 | 22 | */ |
| 23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
| 23 | + if ( apply_filters( 'gravityview_disable_change_entry_creator', false ) ) { |
|
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | * Use `init` to fix bbPress warning |
| 29 | 29 | * @see https://bbpress.trac.wordpress.org/ticket/2309 |
| 30 | 30 | */ |
| 31 | - add_action('init', array( $this, 'load'), 100 ); |
|
| 31 | + add_action( 'init', array( $this, 'load' ), 100 ); |
|
| 32 | 32 | |
| 33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
| 33 | + add_action( 'plugins_loaded', array( $this, 'prevent_conflicts' ) ); |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
@@ -56,20 +56,20 @@ discard block |
||
| 56 | 56 | $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
| 57 | 57 | |
| 58 | 58 | // If filter returns false, do not process |
| 59 | - if( empty( $assign_to_lead ) ) { |
|
| 59 | + if ( empty( $assign_to_lead ) ) { |
|
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
| 64 | - $result = RGFormsModel::update_entry_property( (int) $entry['id'], 'created_by', (int) $user_id, false, true ); |
|
| 64 | + $result = RGFormsModel::update_entry_property( (int)$entry[ 'id' ], 'created_by', (int)$user_id, false, true ); |
|
| 65 | 65 | |
| 66 | 66 | if ( false === $result ) { |
| 67 | - $status = __('Error', 'gravityview'); |
|
| 67 | + $status = __( 'Error', 'gravityview' ); |
|
| 68 | 68 | global $wpdb; |
| 69 | 69 | $note = sprintf( '%s: Failed to assign User ID #%d as the entry creator (Last database error: "%s")', $status, $user_id, $wpdb->last_error ); |
| 70 | 70 | } else { |
| 71 | - $status = __('Success', 'gravityview'); |
|
| 72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
| 71 | + $status = __( 'Success', 'gravityview' ); |
|
| 72 | + $note = sprintf( _x( '%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview' ), $status, $user_id ); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | gravityview()->log->debug( 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - {note}', array( 'note' => $note ) ); |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | * @since 1.21.5 |
| 80 | 80 | * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
| 81 | 81 | */ |
| 82 | - if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
| 82 | + if ( apply_filters( 'gravityview_disable_change_entry_creator_note', false ) ) { |
|
| 83 | 83 | return; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
| 86 | + GravityView_Entry_Notes::add_note( $entry[ 'id' ], -1, 'GravityView', $note, 'gravityview' ); |
|
| 87 | 87 | |
| 88 | 88 | } |
| 89 | 89 | |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | // Plugin that was provided here: |
| 97 | 97 | // @link https://gravityview.co/support/documentation/201991205/ |
| 98 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
| 99 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
| 98 | + remove_action( "gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
| 99 | + remove_action( "gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
| 100 | 100 | |
| 101 | 101 | } |
| 102 | 102 | |
@@ -107,26 +107,26 @@ discard block |
||
| 107 | 107 | function load() { |
| 108 | 108 | |
| 109 | 109 | // Does GF exist? |
| 110 | - if( !class_exists('GFCommon') ) { |
|
| 110 | + if ( ! class_exists( 'GFCommon' ) ) { |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | // Can the user edit entries? |
| 115 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
| 115 | + if ( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // If screen mode isn't set, then we're in the wrong place. |
| 120 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
| 120 | + if ( empty( $_REQUEST[ 'screen_mode' ] ) ) { |
|
| 121 | 121 | return; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // Now, no validation is required in the methods; let's hook in. |
| 125 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
| 125 | + add_action( 'admin_init', array( &$this, 'set_screen_mode' ) ); |
|
| 126 | 126 | |
| 127 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
| 127 | + add_action( "gform_entry_info", array( &$this, 'add_select' ), 10, 2 ); |
|
| 128 | 128 | |
| 129 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
| 129 | + add_action( "gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2 ); |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
@@ -137,8 +137,8 @@ discard block |
||
| 137 | 137 | function set_screen_mode() { |
| 138 | 138 | |
| 139 | 139 | // If $_GET['screen_mode'] is set to edit, set $_POST value |
| 140 | - if( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
| 141 | - $_POST["screen_mode"] = 'edit'; |
|
| 140 | + if ( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
| 141 | + $_POST[ "screen_mode" ] = 'edit'; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | } |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | * @param int $entry_id Entry ID |
| 150 | 150 | * @return void |
| 151 | 151 | */ |
| 152 | - function update_entry_creator($form, $entry_id) { |
|
| 152 | + function update_entry_creator( $form, $entry_id ) { |
|
| 153 | 153 | global $current_user; |
| 154 | 154 | |
| 155 | 155 | // Update the entry |
| 156 | - $created_by = absint( \GV\Utils::_POST( 'created_by') ); |
|
| 156 | + $created_by = absint( \GV\Utils::_POST( 'created_by' ) ); |
|
| 157 | 157 | |
| 158 | 158 | RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
| 159 | 159 | |
@@ -161,30 +161,30 @@ discard block |
||
| 161 | 161 | $originally_created_by = \GV\Utils::_POST( 'originally_created_by' ); |
| 162 | 162 | |
| 163 | 163 | // If there's no owner and there didn't used to be, keep going |
| 164 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
| 164 | + if ( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
| 165 | 165 | return; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // If the values have changed |
| 169 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
| 169 | + if ( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
| 170 | 170 | |
| 171 | - $user_data = get_userdata($current_user->ID); |
|
| 171 | + $user_data = get_userdata( $current_user->ID ); |
|
| 172 | 172 | |
| 173 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
| 173 | + $user_format = _x( '%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview' ); |
|
| 174 | 174 | |
| 175 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
| 175 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview' ); |
|
| 176 | 176 | |
| 177 | - if( !empty( $originally_created_by ) ) { |
|
| 178 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
| 177 | + if ( ! empty( $originally_created_by ) ) { |
|
| 178 | + $originally_created_by_user_data = get_userdata( $originally_created_by ); |
|
| 179 | 179 | $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if( !empty( $created_by ) ) { |
|
| 183 | - $created_by_user_data = get_userdata($created_by); |
|
| 182 | + if ( ! empty( $created_by ) ) { |
|
| 183 | + $created_by_user_data = get_userdata( $created_by ); |
|
| 184 | 184 | $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
| 187 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __( 'Changed entry creator from %s to %s', 'gravityview' ), $original_name, $created_by_name ), 'note' ); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | } |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | * @param array $entry GF entry array |
| 196 | 196 | * @return void |
| 197 | 197 | */ |
| 198 | - function add_select($form_id, $entry ) { |
|
| 198 | + function add_select( $form_id, $entry ) { |
|
| 199 | 199 | |
| 200 | - if( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
| 200 | + if ( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
| 201 | 201 | return; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -216,23 +216,23 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $output = '<label for="change_created_by">'; |
| 219 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
| 219 | + $output .= esc_html__( 'Change Entry Creator:', 'gravityview' ); |
|
| 220 | 220 | $output .= '</label>'; |
| 221 | 221 | |
| 222 | 222 | // If there are users who are not being shown, show a warning. |
| 223 | 223 | // TODO: Use AJAX instead of <select> |
| 224 | 224 | $count_users = count_users(); |
| 225 | - if( sizeof( $users ) < $count_users['total_users'] ) { |
|
| 225 | + if ( sizeof( $users ) < $count_users[ 'total_users' ] ) { |
|
| 226 | 226 | $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
| 230 | - $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
| 231 | - foreach($users as $user) { |
|
| 232 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
| 230 | + $output .= '<option value="' . selected( $entry[ 'created_by' ], '0', false ) . '"> — ' . esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview' ) . ' — </option>'; |
|
| 231 | + foreach ( $users as $user ) { |
|
| 232 | + $output .= '<option value="' . $user->ID . '"' . selected( $entry[ 'created_by' ], $user->ID, false ) . '>' . esc_attr( $user->display_name . ' (' . $user->user_nicename . ')' ) . '</option>'; |
|
| 233 | 233 | } |
| 234 | 234 | $output .= '</select>'; |
| 235 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
| 235 | + $output .= '<input name="originally_created_by" value="' . esc_attr( $entry[ 'created_by' ] ) . '" type="hidden" />'; |
|
| 236 | 236 | |
| 237 | 237 | unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
| 238 | 238 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | 'type' => 'radio', |
| 65 | 65 | 'full_width' => true, |
| 66 | 66 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
| 67 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
| 67 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
| 68 | 68 | 'value' => 'any', |
| 69 | 69 | 'class' => 'hide-if-js', |
| 70 | 70 | 'options' => array( |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
| 88 | 88 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
| 89 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
| 89 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
| 90 | 90 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
| 91 | 91 | |
| 92 | 92 | // ajax - get the searchable fields |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 228 | 228 | $script_source = empty( $script_min ) ? '/source' : ''; |
| 229 | 229 | |
| 230 | - 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 ); |
|
| 230 | + 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 ); |
|
| 231 | 231 | |
| 232 | 232 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
| 233 | 233 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
| 250 | 250 | */ |
| 251 | 251 | public function register_no_conflict( $allowed ) { |
| 252 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
| 252 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
| 253 | 253 | return $allowed; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -262,24 +262,24 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | public static function get_searchable_fields() { |
| 264 | 264 | |
| 265 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 265 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 266 | 266 | exit( '0' ); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | $form = ''; |
| 270 | 270 | |
| 271 | 271 | // Fetch the form for the current View |
| 272 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
| 272 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
| 273 | 273 | |
| 274 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 274 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
| 275 | 275 | |
| 276 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
| 276 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
| 277 | 277 | |
| 278 | - $form = (int) $_POST['formid']; |
|
| 278 | + $form = (int)$_POST[ 'formid' ]; |
|
| 279 | 279 | |
| 280 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 280 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 281 | 281 | |
| 282 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 282 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 283 | 283 | |
| 284 | 284 | } |
| 285 | 285 | |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | 331 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
| 332 | - $custom_fields['is_approved'] = array( |
|
| 332 | + $custom_fields[ 'is_approved' ] = array( |
|
| 333 | 333 | 'text' => esc_html__( 'Is Approved', 'gravityview' ), |
| 334 | 334 | 'type' => 'boolean', |
| 335 | 335 | ); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 339 | - $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'] ); |
|
| 338 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 339 | + $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' ] ); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | // Get fields with sub-inputs and no parent |
@@ -358,13 +358,13 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | foreach ( $fields as $id => $field ) { |
| 360 | 360 | |
| 361 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 361 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 362 | 362 | continue; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
| 365 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
| 366 | 366 | |
| 367 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
| 367 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
| 388 | 388 | |
| 389 | 389 | // @todo - This needs to be improved - many fields have . including products and addresses |
| 390 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 390 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 391 | 391 | $input_type = 'boolean'; // on/off checkbox |
| 392 | 392 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
| 393 | 393 | $input_type = 'multi'; //multiselect |
@@ -431,19 +431,19 @@ discard block |
||
| 431 | 431 | $post_id = 0; |
| 432 | 432 | |
| 433 | 433 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
| 434 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
| 435 | - $post_id = absint( $widget_args['post_id'] ); |
|
| 434 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
| 435 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
| 436 | 436 | } |
| 437 | 437 | // We're in the WordPress Widget context, and the base View ID should be used |
| 438 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
| 439 | - $post_id = absint( $widget_args['view_id'] ); |
|
| 438 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
| 439 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | $args = gravityview_get_permalink_query_args( $post_id ); |
| 443 | 443 | |
| 444 | 444 | // Add hidden fields to the search form |
| 445 | 445 | foreach ( $args as $key => $value ) { |
| 446 | - $search_fields[] = array( |
|
| 446 | + $search_fields[ ] = array( |
|
| 447 | 447 | 'name' => $key, |
| 448 | 448 | 'input' => 'hidden', |
| 449 | 449 | 'value' => $value, |
@@ -482,22 +482,22 @@ discard block |
||
| 482 | 482 | /** |
| 483 | 483 | * Include the sidebar Widgets. |
| 484 | 484 | */ |
| 485 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
| 485 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
| 486 | 486 | |
| 487 | 487 | foreach ( $widgets as $widget ) { |
| 488 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
| 489 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
| 488 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
| 489 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
| 490 | 490 | foreach ( $_fields as $field ) { |
| 491 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
| 491 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
| 492 | 492 | } |
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
| 498 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
| 498 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
| 499 | 499 | foreach ( $_fields as $field ) { |
| 500 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
| 500 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
| 501 | 501 | } |
| 502 | 502 | } |
| 503 | 503 | } |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - if( 'post' === $this->search_method ) { |
|
| 530 | + if ( 'post' === $this->search_method ) { |
|
| 531 | 531 | $get = $_POST; |
| 532 | 532 | } else { |
| 533 | 533 | $get = $_GET; |
@@ -546,14 +546,14 @@ discard block |
||
| 546 | 546 | $get = gv_map_deep( $get, 'rawurldecode' ); |
| 547 | 547 | |
| 548 | 548 | // Make sure array key is set up |
| 549 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
| 549 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
| 550 | 550 | |
| 551 | 551 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
| 552 | 552 | |
| 553 | 553 | // add free search |
| 554 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
| 554 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
| 555 | 555 | |
| 556 | - $search_all_value = trim( $get['gv_search'] ); |
|
| 556 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
| 557 | 557 | |
| 558 | 558 | /** |
| 559 | 559 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | foreach ( $words as $word ) { |
| 581 | - $search_criteria['field_filters'][] = array( |
|
| 581 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 582 | 582 | 'key' => null, // The field ID to search |
| 583 | 583 | 'value' => $word, // The value to search |
| 584 | 584 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -591,14 +591,14 @@ discard block |
||
| 591 | 591 | /** |
| 592 | 592 | * Get and normalize the dates according to the input format. |
| 593 | 593 | */ |
| 594 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
| 595 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
| 594 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
| 595 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
| 596 | 596 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
| 601 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
| 600 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
| 601 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
| 602 | 602 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
| 603 | 603 | } |
| 604 | 604 | } |
@@ -633,22 +633,22 @@ discard block |
||
| 633 | 633 | */ |
| 634 | 634 | if ( ! empty( $curr_start ) ) { |
| 635 | 635 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
| 636 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 636 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | if ( ! empty( $curr_end ) ) { |
| 640 | 640 | // Fast-forward 24 hour on the end time |
| 641 | 641 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
| 642 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 643 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
| 644 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
| 642 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 643 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
| 644 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
| 645 | 645 | } |
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | // search for a specific entry ID |
| 650 | 650 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
| 651 | - $search_criteria['field_filters'][] = array( |
|
| 651 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 652 | 652 | 'key' => 'id', |
| 653 | 653 | 'value' => absint( $get[ 'gv_id' ] ), |
| 654 | 654 | 'operator' => '=', |
@@ -657,41 +657,41 @@ discard block |
||
| 657 | 657 | |
| 658 | 658 | // search for a specific Created_by ID |
| 659 | 659 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
| 660 | - $search_criteria['field_filters'][] = array( |
|
| 660 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 661 | 661 | 'key' => 'created_by', |
| 662 | - 'value' => $get['gv_by'], |
|
| 662 | + 'value' => $get[ 'gv_by' ], |
|
| 663 | 663 | 'operator' => '=', |
| 664 | 664 | ); |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | // Get search mode passed in URL |
| 668 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
| 668 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
| 669 | 669 | |
| 670 | 670 | // get the other search filters |
| 671 | 671 | foreach ( $get as $key => $value ) { |
| 672 | 672 | |
| 673 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
| 673 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
| 674 | 674 | continue; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
| 678 | 678 | |
| 679 | 679 | // could return simple filter or multiple filters |
| 680 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
| 680 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
| 681 | 681 | continue; |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
| 685 | 685 | |
| 686 | - if ( isset( $filter[0]['value'] ) ) { |
|
| 687 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
| 686 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
| 687 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
| 688 | 688 | |
| 689 | 689 | // if date range type, set search mode to ALL |
| 690 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 690 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 691 | 691 | $mode = 'all'; |
| 692 | 692 | } |
| 693 | - } elseif( !empty( $filter ) ) { |
|
| 694 | - $search_criteria['field_filters'][] = $filter; |
|
| 693 | + } elseif ( ! empty( $filter ) ) { |
|
| 694 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
| 695 | 695 | } |
| 696 | 696 | } |
| 697 | 697 | |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | * @since 1.5.1 |
| 701 | 701 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
| 702 | 702 | */ |
| 703 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 703 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 704 | 704 | |
| 705 | 705 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
| 706 | 706 | |
@@ -725,15 +725,15 @@ discard block |
||
| 725 | 725 | */ |
| 726 | 726 | $search_criteria = $this->filter_entries( array(), null, array( 'id' => $view->ID ), true /** force search_criteria */ ); |
| 727 | 727 | |
| 728 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
| 728 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
| 729 | 729 | return; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | $widgets = $view->widgets->by_id( $this->widget_id ); |
| 733 | 733 | if ( $widgets->count() ) { |
| 734 | - $widget = $widgets->all()[0]; |
|
| 734 | + $widget = $widgets->all()[ 0 ]; |
|
| 735 | 735 | foreach ( $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) as $search_field ) { |
| 736 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
| 736 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
| 737 | 737 | $created_by_text_mode = true; |
| 738 | 738 | } |
| 739 | 739 | } |
@@ -741,19 +741,19 @@ discard block |
||
| 741 | 741 | |
| 742 | 742 | $extra_conditions = array(); |
| 743 | 743 | |
| 744 | - foreach ( $search_criteria['field_filters'] as &$filter ) { |
|
| 744 | + foreach ( $search_criteria[ 'field_filters' ] as &$filter ) { |
|
| 745 | 745 | if ( ! is_array( $filter ) ) { |
| 746 | 746 | continue; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | // Construct a manual query for unapproved statuses |
| 750 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, $filter['value'] ) ) { |
|
| 751 | - $_tmp_query = new GF_Query( $view->form->ID, array( |
|
| 750 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, $filter[ 'value' ] ) ) { |
|
| 751 | + $_tmp_query = new GF_Query( $view->form->ID, array( |
|
| 752 | 752 | 'field_filters' => array( |
| 753 | 753 | array( |
| 754 | 754 | 'operator' => 'in', |
| 755 | 755 | 'key' => 'is_approved', |
| 756 | - 'value' => $filter['value'], |
|
| 756 | + 'value' => $filter[ 'value' ], |
|
| 757 | 757 | ), |
| 758 | 758 | array( |
| 759 | 759 | 'operator' => 'is', |
@@ -765,17 +765,17 @@ discard block |
||
| 765 | 765 | ) ); |
| 766 | 766 | $_tmp_query_parts = $_tmp_query->_introspect(); |
| 767 | 767 | |
| 768 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
| 768 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
| 769 | 769 | |
| 770 | 770 | $filter = false; |
| 771 | 771 | continue; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | // Construct manual query for text mode creator search |
| 775 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
| 776 | - $extra_conditions[] = new class( $filter, $view ) extends \GF_Query_Condition { |
|
| 775 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
| 776 | + $extra_conditions[ ] = new class( $filter, $view ) extends \GF_Query_Condition { |
|
| 777 | 777 | public function __construct( $filter, $view ) { |
| 778 | - $this->value = $filter['value']; |
|
| 778 | + $this->value = $filter[ 'value' ]; |
|
| 779 | 779 | $this->view = $view; |
| 780 | 780 | } |
| 781 | 781 | |
@@ -809,11 +809,11 @@ discard block |
||
| 809 | 809 | $conditions = array(); |
| 810 | 810 | |
| 811 | 811 | foreach ( $user_fields as $user_field ) { |
| 812 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 812 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | foreach ( $user_meta_fields as $meta_field ) { |
| 816 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 816 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |
@@ -829,11 +829,11 @@ discard block |
||
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | // By default, we want searches to be wildcard for each field. |
| 832 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 832 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 833 | 833 | |
| 834 | 834 | // For multichoice, let's have an in (OR) search. |
| 835 | - if ( is_array( $filter['value'] ) ) { |
|
| 836 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
| 835 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
| 836 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
@@ -841,10 +841,10 @@ discard block |
||
| 841 | 841 | * @param string $operator Existing search operator |
| 842 | 842 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 843 | 843 | */ |
| 844 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 844 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - $search_criteria['field_filters'] = array_filter( $search_criteria['field_filters'] ); |
|
| 847 | + $search_criteria[ 'field_filters' ] = array_filter( $search_criteria[ 'field_filters' ] ); |
|
| 848 | 848 | |
| 849 | 849 | /** |
| 850 | 850 | * Parse the filter criteria to generate the needed |
@@ -857,12 +857,12 @@ discard block |
||
| 857 | 857 | /** |
| 858 | 858 | * Grab the current clauses. We'll be combining them shortly. |
| 859 | 859 | */ |
| 860 | - $query_parts = $query->_introspect(); |
|
| 860 | + $query_parts = $query->_introspect(); |
|
| 861 | 861 | |
| 862 | 862 | /** |
| 863 | 863 | * Combine the parts as a new WHERE clause. |
| 864 | 864 | */ |
| 865 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'], $_tmp_query_parts['where'] ), $extra_conditions ) ); |
|
| 865 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ], $_tmp_query_parts[ 'where' ] ), $extra_conditions ) ); |
|
| 866 | 866 | $query->where( $where ); |
| 867 | 867 | } |
| 868 | 868 | |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | $field_id = str_replace( 'filter_', '', $key ); |
| 886 | 886 | |
| 887 | 887 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
| 888 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
| 888 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
| 889 | 889 | $field_id = str_replace( '_', '.', $field_id ); |
| 890 | 890 | } |
| 891 | 891 | |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | |
| 921 | 921 | case 'select': |
| 922 | 922 | case 'radio': |
| 923 | - $filter['operator'] = 'is'; |
|
| 923 | + $filter[ 'operator' ] = 'is'; |
|
| 924 | 924 | break; |
| 925 | 925 | |
| 926 | 926 | case 'post_category': |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | |
| 935 | 935 | foreach ( $value as $val ) { |
| 936 | 936 | $cat = get_term( $val, 'category' ); |
| 937 | - $filter[] = array( |
|
| 937 | + $filter[ ] = array( |
|
| 938 | 938 | 'key' => $filter_key, |
| 939 | 939 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
| 940 | 940 | 'operator' => 'is', |
@@ -953,7 +953,7 @@ discard block |
||
| 953 | 953 | $filter = array(); |
| 954 | 954 | |
| 955 | 955 | foreach ( $value as $val ) { |
| 956 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
| 956 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | break; |
@@ -962,9 +962,9 @@ discard block |
||
| 962 | 962 | // convert checkbox on/off into the correct search filter |
| 963 | 963 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
| 964 | 964 | foreach ( $form_field->inputs as $k => $input ) { |
| 965 | - if ( $input['id'] == $filter_key ) { |
|
| 966 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
| 967 | - $filter['operator'] = 'is'; |
|
| 965 | + if ( $input[ 'id' ] == $filter_key ) { |
|
| 966 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
| 967 | + $filter[ 'operator' ] = 'is'; |
|
| 968 | 968 | break; |
| 969 | 969 | } |
| 970 | 970 | } |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | $filter = array(); |
| 975 | 975 | |
| 976 | 976 | foreach ( $value as $val ) { |
| 977 | - $filter[] = array( |
|
| 977 | + $filter[ ] = array( |
|
| 978 | 978 | 'key' => $filter_key, |
| 979 | 979 | 'value' => $val, |
| 980 | 980 | 'operator' => 'is', |
@@ -995,9 +995,9 @@ discard block |
||
| 995 | 995 | foreach ( $words as $word ) { |
| 996 | 996 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
| 997 | 997 | // Keep the same key for each filter |
| 998 | - $filter['value'] = $word; |
|
| 998 | + $filter[ 'value' ] = $word; |
|
| 999 | 999 | // Add a search for the value |
| 1000 | - $filters[] = $filter; |
|
| 1000 | + $filters[ ] = $filter; |
|
| 1001 | 1001 | } |
| 1002 | 1002 | } |
| 1003 | 1003 | |
@@ -1011,19 +1011,19 @@ discard block |
||
| 1011 | 1011 | |
| 1012 | 1012 | foreach ( $searchable_fields as $searchable_field ) { |
| 1013 | 1013 | |
| 1014 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
| 1014 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
| 1015 | 1015 | continue; |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | // Only exact-match dropdowns, not text search |
| 1019 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
| 1019 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
| 1020 | 1020 | continue; |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
| 1024 | 1024 | |
| 1025 | 1025 | if ( 4 === $input_id ) { |
| 1026 | - $filter['operator'] = 'is'; |
|
| 1026 | + $filter[ 'operator' ] = 'is'; |
|
| 1027 | 1027 | }; |
| 1028 | 1028 | } |
| 1029 | 1029 | } |
@@ -1050,12 +1050,12 @@ discard block |
||
| 1050 | 1050 | * @since 1.16.3 |
| 1051 | 1051 | * Safeguard until GF implements '<=' operator |
| 1052 | 1052 | */ |
| 1053 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 1053 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 1054 | 1054 | $operator = '<'; |
| 1055 | 1055 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | - $filter[] = array( |
|
| 1058 | + $filter[ ] = array( |
|
| 1059 | 1059 | 'key' => $filter_key, |
| 1060 | 1060 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
| 1061 | 1061 | 'operator' => $operator, |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | } |
| 1064 | 1064 | } else { |
| 1065 | 1065 | $date = $value; |
| 1066 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
| 1066 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | break; |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | 'ymd_dot' => 'Y.m.d', |
| 1095 | 1095 | ); |
| 1096 | 1096 | |
| 1097 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 1097 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
| 1098 | 1098 | $format = $datepicker[ $field->dateFormat ]; |
| 1099 | 1099 | } |
| 1100 | 1100 | |
@@ -1131,7 +1131,7 @@ discard block |
||
| 1131 | 1131 | public function add_template_path( $file_paths ) { |
| 1132 | 1132 | |
| 1133 | 1133 | // Index 100 is the default GravityView template path. |
| 1134 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 1134 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
| 1135 | 1135 | |
| 1136 | 1136 | return $file_paths; |
| 1137 | 1137 | } |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | $has_date = false; |
| 1151 | 1151 | |
| 1152 | 1152 | foreach ( $search_fields as $k => $field ) { |
| 1153 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 1153 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 1154 | 1154 | $has_date = true; |
| 1155 | 1155 | break; |
| 1156 | 1156 | } |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | // get configured search fields |
| 1180 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 1180 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
| 1181 | 1181 | |
| 1182 | 1182 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
| 1183 | 1183 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1192,41 +1192,41 @@ discard block |
||
| 1192 | 1192 | |
| 1193 | 1193 | $updated_field = $this->get_search_filter_details( $updated_field ); |
| 1194 | 1194 | |
| 1195 | - switch ( $field['field'] ) { |
|
| 1195 | + switch ( $field[ 'field' ] ) { |
|
| 1196 | 1196 | |
| 1197 | 1197 | case 'search_all': |
| 1198 | - $updated_field['key'] = 'search_all'; |
|
| 1199 | - $updated_field['input'] = 'search_all'; |
|
| 1200 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 1198 | + $updated_field[ 'key' ] = 'search_all'; |
|
| 1199 | + $updated_field[ 'input' ] = 'search_all'; |
|
| 1200 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 1201 | 1201 | break; |
| 1202 | 1202 | |
| 1203 | 1203 | case 'entry_date': |
| 1204 | - $updated_field['key'] = 'entry_date'; |
|
| 1205 | - $updated_field['input'] = 'entry_date'; |
|
| 1206 | - $updated_field['value'] = array( |
|
| 1204 | + $updated_field[ 'key' ] = 'entry_date'; |
|
| 1205 | + $updated_field[ 'input' ] = 'entry_date'; |
|
| 1206 | + $updated_field[ 'value' ] = array( |
|
| 1207 | 1207 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
| 1208 | 1208 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
| 1209 | 1209 | ); |
| 1210 | 1210 | break; |
| 1211 | 1211 | |
| 1212 | 1212 | case 'entry_id': |
| 1213 | - $updated_field['key'] = 'entry_id'; |
|
| 1214 | - $updated_field['input'] = 'entry_id'; |
|
| 1215 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 1213 | + $updated_field[ 'key' ] = 'entry_id'; |
|
| 1214 | + $updated_field[ 'input' ] = 'entry_id'; |
|
| 1215 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 1216 | 1216 | break; |
| 1217 | 1217 | |
| 1218 | 1218 | case 'created_by': |
| 1219 | - $updated_field['key'] = 'created_by'; |
|
| 1220 | - $updated_field['name'] = 'gv_by'; |
|
| 1221 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 1222 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
| 1219 | + $updated_field[ 'key' ] = 'created_by'; |
|
| 1220 | + $updated_field[ 'name' ] = 'gv_by'; |
|
| 1221 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 1222 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
| 1223 | 1223 | break; |
| 1224 | 1224 | |
| 1225 | 1225 | case 'is_approved': |
| 1226 | - $updated_field['key'] = 'is_approved'; |
|
| 1227 | - $updated_field['input'] = 'checkbox'; |
|
| 1228 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
| 1229 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
| 1226 | + $updated_field[ 'key' ] = 'is_approved'; |
|
| 1227 | + $updated_field[ 'input' ] = 'checkbox'; |
|
| 1228 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
| 1229 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
| 1230 | 1230 | break; |
| 1231 | 1231 | } |
| 1232 | 1232 | |
@@ -1245,16 +1245,16 @@ discard block |
||
| 1245 | 1245 | */ |
| 1246 | 1246 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
| 1247 | 1247 | |
| 1248 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 1248 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
| 1249 | 1249 | |
| 1250 | 1250 | /** @since 1.14 */ |
| 1251 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 1251 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
| 1252 | 1252 | |
| 1253 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 1253 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 1254 | 1254 | |
| 1255 | 1255 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
| 1256 | 1256 | |
| 1257 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 1257 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
| 1258 | 1258 | |
| 1259 | 1259 | if ( $this->has_date_field( $search_fields ) ) { |
| 1260 | 1260 | // enqueue datepicker stuff only if needed! |
@@ -1276,10 +1276,10 @@ discard block |
||
| 1276 | 1276 | public static function get_search_class( $custom_class = '' ) { |
| 1277 | 1277 | $gravityview_view = GravityView_View::getInstance(); |
| 1278 | 1278 | |
| 1279 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
| 1279 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
| 1280 | 1280 | |
| 1281 | - if ( ! empty( $custom_class ) ) { |
|
| 1282 | - $search_class .= ' '.$custom_class; |
|
| 1281 | + if ( ! empty( $custom_class ) ) { |
|
| 1282 | + $search_class .= ' ' . $custom_class; |
|
| 1283 | 1283 | } |
| 1284 | 1284 | |
| 1285 | 1285 | /** |
@@ -1323,9 +1323,9 @@ discard block |
||
| 1323 | 1323 | |
| 1324 | 1324 | if ( ! $label ) { |
| 1325 | 1325 | |
| 1326 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 1326 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
| 1327 | 1327 | |
| 1328 | - switch( $field['field'] ) { |
|
| 1328 | + switch ( $field[ 'field' ] ) { |
|
| 1329 | 1329 | case 'search_all': |
| 1330 | 1330 | $label = __( 'Search Entries:', 'gravityview' ); |
| 1331 | 1331 | break; |
@@ -1337,10 +1337,10 @@ discard block |
||
| 1337 | 1337 | break; |
| 1338 | 1338 | default: |
| 1339 | 1339 | // If this is a field input, not a field |
| 1340 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 1340 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
| 1341 | 1341 | |
| 1342 | 1342 | // Get the label for the field in question, which returns an array |
| 1343 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 1343 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
| 1344 | 1344 | |
| 1345 | 1345 | // Get the item with the `label` key |
| 1346 | 1346 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1379,32 +1379,32 @@ discard block |
||
| 1379 | 1379 | $form = $gravityview_view->getForm(); |
| 1380 | 1380 | |
| 1381 | 1381 | // for advanced field ids (eg, first name / last name ) |
| 1382 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 1382 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
| 1383 | 1383 | |
| 1384 | 1384 | // get searched value from $_GET/$_POST (string or array) |
| 1385 | 1385 | $value = $this->rgget_or_rgpost( $name ); |
| 1386 | 1386 | |
| 1387 | 1387 | // get form field details |
| 1388 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 1388 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
| 1389 | 1389 | |
| 1390 | 1390 | $filter = array( |
| 1391 | - 'key' => $field['field'], |
|
| 1391 | + 'key' => $field[ 'field' ], |
|
| 1392 | 1392 | 'name' => $name, |
| 1393 | 1393 | 'label' => self::get_field_label( $field, $form_field ), |
| 1394 | - 'input' => $field['input'], |
|
| 1394 | + 'input' => $field[ 'input' ], |
|
| 1395 | 1395 | 'value' => $value, |
| 1396 | - 'type' => $form_field['type'], |
|
| 1396 | + 'type' => $form_field[ 'type' ], |
|
| 1397 | 1397 | ); |
| 1398 | 1398 | |
| 1399 | 1399 | // collect choices |
| 1400 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 1401 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
| 1402 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 1403 | - $filter['choices'] = $form_field['choices']; |
|
| 1400 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
| 1401 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
| 1402 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
| 1403 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 1407 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 1406 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
| 1407 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | 1410 | return $filter; |
@@ -1428,7 +1428,7 @@ discard block |
||
| 1428 | 1428 | |
| 1429 | 1429 | $choices = array(); |
| 1430 | 1430 | foreach ( $users as $user ) { |
| 1431 | - $choices[] = array( |
|
| 1431 | + $choices[ ] = array( |
|
| 1432 | 1432 | 'value' => $user->ID, |
| 1433 | 1433 | 'text' => $user->display_name, |
| 1434 | 1434 | ); |
@@ -1448,9 +1448,9 @@ discard block |
||
| 1448 | 1448 | |
| 1449 | 1449 | $choices = array(); |
| 1450 | 1450 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
| 1451 | - $choices[] = array( |
|
| 1452 | - 'value' => $status['value'], |
|
| 1453 | - 'text' => $status['label'], |
|
| 1451 | + $choices[ ] = array( |
|
| 1452 | + 'value' => $status[ 'value' ], |
|
| 1453 | + 'text' => $status[ 'label' ], |
|
| 1454 | 1454 | ); |
| 1455 | 1455 | } |
| 1456 | 1456 | |
@@ -1502,7 +1502,7 @@ discard block |
||
| 1502 | 1502 | */ |
| 1503 | 1503 | public function add_datepicker_js_dependency( $js_dependencies ) { |
| 1504 | 1504 | |
| 1505 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
| 1505 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
| 1506 | 1506 | |
| 1507 | 1507 | return $js_dependencies; |
| 1508 | 1508 | } |
@@ -1546,7 +1546,7 @@ discard block |
||
| 1546 | 1546 | 'isRTL' => is_rtl(), |
| 1547 | 1547 | ), $view_data ); |
| 1548 | 1548 | |
| 1549 | - $localizations['datepicker'] = $datepicker_settings; |
|
| 1549 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
| 1550 | 1550 | |
| 1551 | 1551 | return $localizations; |
| 1552 | 1552 | |
@@ -1573,7 +1573,7 @@ discard block |
||
| 1573 | 1573 | * @return void |
| 1574 | 1574 | */ |
| 1575 | 1575 | private function maybe_enqueue_flexibility() { |
| 1576 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 1576 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
| 1577 | 1577 | wp_enqueue_script( 'gv-flexibility' ); |
| 1578 | 1578 | } |
| 1579 | 1579 | } |
@@ -1595,7 +1595,7 @@ discard block |
||
| 1595 | 1595 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
| 1596 | 1596 | |
| 1597 | 1597 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 1598 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1598 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1599 | 1599 | |
| 1600 | 1600 | /** |
| 1601 | 1601 | * @filter `gravityview_search_datepicker_class` |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $supports = array( 'title', 'revisions' ); |
| 109 | 109 | |
| 110 | 110 | if ( $is_hierarchical ) { |
| 111 | - $supports[] = 'page-attributes'; |
|
| 111 | + $supports[ ] = 'page-attributes'; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -210,11 +210,11 @@ discard block |
||
| 210 | 210 | $rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' ); |
| 211 | 211 | |
| 212 | 212 | add_filter( 'query_vars', function( $query_vars ) { |
| 213 | - $query_vars[] = 'csv'; |
|
| 213 | + $query_vars[ ] = 'csv'; |
|
| 214 | 214 | return $query_vars; |
| 215 | 215 | } ); |
| 216 | 216 | |
| 217 | - if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) { |
|
| 217 | + if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) { |
|
| 218 | 218 | call_user_func_array( 'add_rewrite_rule', $rule ); |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -283,13 +283,13 @@ discard block |
||
| 283 | 283 | return $content; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
| 286 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * Editing a single entry. |
| 290 | 290 | */ |
| 291 | 291 | if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
| 292 | - if ( $entry['status'] != 'active' ) { |
|
| 292 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 293 | 293 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
| 294 | 294 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 295 | 295 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 303 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 303 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 304 | 304 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
| 305 | 305 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 306 | 306 | } |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * Viewing a single entry. |
| 314 | 314 | */ |
| 315 | 315 | } else if ( $entry = $request->is_entry( $view->form ? $view->form->ID : 0 ) ) { |
| 316 | - if ( $entry['status'] != 'active' ) { |
|
| 316 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 317 | 317 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
| 318 | 318 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 319 | 319 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 327 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 327 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 328 | 328 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
| 329 | 329 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 330 | 330 | } |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column ); |
| 499 | 499 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column ); |
| 500 | 500 | |
| 501 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
| 501 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | return $joins; |
@@ -540,10 +540,10 @@ discard block |
||
| 540 | 540 | |
| 541 | 541 | list( $join, $join_column, $join_on, $join_on_column ) = $meta; |
| 542 | 542 | |
| 543 | - $forms_ids [] = GF_Form::by_id( $join_on ); |
|
| 543 | + $forms_ids [ ] = GF_Form::by_id( $join_on ); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - return ( !empty( $forms_ids) ) ? $forms_ids : null; |
|
| 546 | + return ( ! empty( $forms_ids ) ) ? $forms_ids : null; |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | if ( ! $view->form ) { |
| 582 | 582 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
| 583 | 583 | 'view_id' => $view->ID, |
| 584 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
| 584 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
| 585 | 585 | ) ); |
| 586 | 586 | } |
| 587 | 587 | |
@@ -814,34 +814,33 @@ discard block |
||
| 814 | 814 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
| 815 | 815 | */ |
| 816 | 816 | $parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID ); |
| 817 | - $parameters['context_view_id'] = $this->ID; |
|
| 817 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
| 818 | 818 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
| 819 | 819 | |
| 820 | 820 | if ( $request instanceof REST\Request ) { |
| 821 | 821 | $atts = $this->settings->as_atts(); |
| 822 | 822 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
| 823 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
| 823 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
| 824 | 824 | ) ); |
| 825 | - $parameters['paging'] = $paging_parameters['paging']; |
|
| 825 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
| 829 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
| 828 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
| 830 | 829 | |
| 831 | 830 | /** |
| 832 | 831 | * Cleanup duplicate field_filter parameters to simplify the query. |
| 833 | 832 | */ |
| 834 | 833 | $unique_field_filters = array(); |
| 835 | - foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) { |
|
| 834 | + foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) { |
|
| 836 | 835 | if ( 'mode' === $key ) { |
| 837 | - $unique_field_filters['mode'] = $filter; |
|
| 836 | + $unique_field_filters[ 'mode' ] = $filter; |
|
| 838 | 837 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
| 839 | - $unique_field_filters[] = $filter; |
|
| 838 | + $unique_field_filters[ ] = $filter; |
|
| 840 | 839 | } |
| 841 | 840 | } |
| 842 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
| 841 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
| 843 | 842 | |
| 844 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
| 843 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 845 | 844 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
| 846 | 845 | } |
| 847 | 846 | |
@@ -849,10 +848,10 @@ discard block |
||
| 849 | 848 | /** |
| 850 | 849 | * New \GF_Query stuff :) |
| 851 | 850 | */ |
| 852 | - $query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
| 851 | + $query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
| 853 | 852 | |
| 854 | - $query->limit( $parameters['paging']['page_size'] ) |
|
| 855 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
| 853 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
| 854 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
| 856 | 855 | |
| 857 | 856 | /** |
| 858 | 857 | * Any joins? |
@@ -894,15 +893,15 @@ discard block |
||
| 894 | 893 | } ); |
| 895 | 894 | } else { |
| 896 | 895 | $entries = $this->form->entries |
| 897 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
| 896 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
| 898 | 897 | ->offset( $this->settings->get( 'offset' ) ) |
| 899 | - ->limit( $parameters['paging']['page_size'] ) |
|
| 898 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
| 900 | 899 | ->page( $page ); |
| 901 | 900 | |
| 902 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
| 901 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
| 903 | 902 | $field = new \GV\Field(); |
| 904 | - $field->ID = $parameters['sorting']['key']; |
|
| 905 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
| 903 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
| 904 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
| 906 | 905 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
| 907 | 906 | } |
| 908 | 907 | } |
@@ -40,17 +40,17 @@ discard block |
||
| 40 | 40 | public static function is_value_match( $field_value, $target_value, $operation = 'is', $source_field = null, $rule = null, $form = null ) { |
| 41 | 41 | |
| 42 | 42 | if ( 'date_created' === $source_field ) { |
| 43 | - $field_value = is_int( $field_value )? $field_value : strtotime( $field_value ); |
|
| 44 | - $target_value = is_int( $target_value )? $target_value : strtotime( $target_value ); |
|
| 43 | + $field_value = is_int( $field_value ) ? $field_value : strtotime( $field_value ); |
|
| 44 | + $target_value = is_int( $target_value ) ? $target_value : strtotime( $target_value ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | if ( $source_field instanceof GF_Field && $source_field->type == 'date' ) { |
| 48 | - $field_value = is_int( $field_value )? $field_value : strtotime( $field_value ); |
|
| 49 | - $target_value = is_int( $target_value )? $target_value : strtotime( $target_value ); |
|
| 48 | + $field_value = is_int( $field_value ) ? $field_value : strtotime( $field_value ); |
|
| 49 | + $target_value = is_int( $target_value ) ? $target_value : strtotime( $target_value ); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | if ( in_array( $operation, array( 'in', 'not_in' ) ) ) { |
| 53 | - return GVCommon::matches_operation( (array) $field_value, (array) $target_value, $operation ); |
|
| 53 | + return GVCommon::matches_operation( (array)$field_value, (array)$target_value, $operation ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | return parent::is_value_match( $field_value, $target_value, $operation, $source_field, $rule, $form ); |
@@ -74,18 +74,18 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $post_data = self::get_post_fields( $form, $entry ); |
| 76 | 76 | |
| 77 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
| 77 | + $media = get_attached_media( 'image', $entry[ 'post_id' ] ); |
|
| 78 | 78 | |
| 79 | 79 | $post_images = array(); |
| 80 | 80 | |
| 81 | 81 | foreach ( $media as $media_item ) { |
| 82 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
| 83 | - if( |
|
| 82 | + foreach ( (array)$post_data[ 'images' ] as $post_data_item ) { |
|
| 83 | + if ( |
|
| 84 | 84 | \GV\Utils::get( $post_data_item, 'title' ) === $media_item->post_title && |
| 85 | 85 | \GV\Utils::get( $post_data_item, 'description' ) === $media_item->post_content && |
| 86 | 86 | \GV\Utils::get( $post_data_item, 'caption' ) === $media_item->post_excerpt |
| 87 | 87 | ) { |
| 88 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
| 88 | + $post_images[ "{$post_data_item[ 'field_id' ]}" ] = $media_item->ID; |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * If the method changes to public, use Gravity Forms' method |
| 114 | 114 | * @todo: If/when the method is public, remove the unneeded copied code. |
| 115 | 115 | */ |
| 116 | - if( $reflection->isPublic() ) { |
|
| 116 | + if ( $reflection->isPublic() ) { |
|
| 117 | 117 | return parent::get_post_fields( $form, $entry ); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * If the method changes to public, use Gravity Forms' method |
| 141 | 141 | * @todo: If/when the method is public, remove the unneeded copied code. |
| 142 | 142 | */ |
| 143 | - if( $reflection->isPublic() ) { |
|
| 143 | + if ( $reflection->isPublic() ) { |
|
| 144 | 144 | return parent::copy_post_image( $url, $post_id ); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * If the method changes to public, use Gravity Forms' method |
| 176 | 176 | * @todo: If/when the method is public, remove the unneeded copied code. |
| 177 | 177 | */ |
| 178 | - if( $reflection->isPublic() ) { |
|
| 178 | + if ( $reflection->isPublic() ) { |
|
| 179 | 179 | return parent::media_handle_upload( $url, $post_id, $post_data ); |
| 180 | 180 | } |
| 181 | 181 | |