@@ -10,22 +10,22 @@ |
||
10 | 10 | $search_field = $gravityview_view->search_field; |
11 | 11 | |
12 | 12 | // Make sure that there are choices to display |
13 | -if( empty( $search_field['choices'] ) ) { |
|
14 | - do_action('gravityview_log_debug', 'search-field-checkbox.php - No choices for field' ); |
|
13 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
14 | + do_action( 'gravityview_log_debug', 'search-field-checkbox.php - No choices for field' ); |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | 18 | ?> |
19 | 19 | <div class="gv-search-box gv-search-field-checkbox"> |
20 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?> |
|
21 | - <label for=search-box-<?php echo esc_attr( $search_field['name'] ); ?>><?php echo esc_html( $search_field['label'] ); ?></label> |
|
20 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { ?> |
|
21 | + <label for=search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
22 | 22 | <?php } ?> |
23 | 23 | <p> |
24 | - <?php foreach( $search_field['choices'] as $choice ) { ?> |
|
24 | + <?php foreach ( $search_field[ 'choices' ] as $choice ) { ?> |
|
25 | 25 | |
26 | - <label for="search-box-<?php echo sanitize_html_class( $search_field['name'].$choice['value'].$choice['text'] ); ?>" class="gv-check-radio"> |
|
27 | - <input type="checkbox" name="<?php echo esc_attr( $search_field['name'] ); ?>[]" value="<?php echo esc_attr( $choice['value'] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field['name'].$choice['value'].$choice['text'] ); ?>" <?php gv_selected( $choice['value'], $search_field['value'], true, 'checked' ); ?>> |
|
28 | - <?php echo esc_html( $choice['text'] ); ?> |
|
26 | + <label for="search-box-<?php echo sanitize_html_class( $search_field[ 'name' ] . $choice[ 'value' ] . $choice[ 'text' ] ); ?>" class="gv-check-radio"> |
|
27 | + <input type="checkbox" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>[]" value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field[ 'name' ] . $choice[ 'value' ] . $choice[ 'text' ] ); ?>" <?php gv_selected( $choice[ 'value' ], $search_field[ 'value' ], true, 'checked' ); ?>> |
|
28 | + <?php echo esc_html( $choice[ 'text' ] ); ?> |
|
29 | 29 | </label> |
30 | 30 | |
31 | 31 | <?php } ?> |
@@ -7,17 +7,17 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
12 | -$name = $gravityview_view->search_field['name']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | +$name = $gravityview_view->search_field[ 'name' ]; |
|
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class="gv-search-box gv-search-date gv-search-date-range"> |
16 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
17 | - <label for="search-box-<?php echo esc_attr( $name ).'-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
16 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
17 | + <label for="search-box-<?php echo esc_attr( $name ) . '-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
18 | 18 | <?php } ?> |
19 | 19 | <p> |
20 | - <input name="<?php echo esc_attr( $name ).'[start]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo $value['start']; ?>"> |
|
21 | - <input name="<?php echo esc_attr( $name ).'[end]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo $value['end']; ?>"> |
|
20 | + <input name="<?php echo esc_attr( $name ) . '[start]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'Start date', 'gravityview' ); ?>" value="<?php echo $value[ 'start' ]; ?>"> |
|
21 | + <input name="<?php echo esc_attr( $name ) . '[end]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'End date', 'gravityview' ); ?>" value="<?php echo $value[ 'end' ]; ?>"> |
|
22 | 22 | </p> |
23 | 23 | </div> |
24 | 24 | \ No newline at end of file |
@@ -10,10 +10,10 @@ |
||
10 | 10 | |
11 | 11 | ?> |
12 | 12 | <div class="gv-search-box gv-search-field-text"> |
13 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?> |
|
14 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label> |
|
13 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { ?> |
|
14 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
15 | 15 | <?php } ?> |
16 | 16 | <p> |
17 | - <input type="text" name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" value="<?php echo esc_attr( $search_field['value'] ); ?>"> |
|
17 | + <input type="text" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="<?php echo esc_attr( $search_field[ 'value' ] ); ?>"> |
|
18 | 18 | </p> |
19 | 19 | </div> |
20 | 20 | \ No newline at end of file |
@@ -7,14 +7,14 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class="gv-search-box gv-search-field-text gv-search-field-search_all"> |
16 | 16 | <div class="gv-search"> |
17 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
17 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
18 | 18 | <label for="gv_search_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
19 | 19 | <?php } ?> |
20 | 20 | <p><input type="text" name="gv_search" id="gv_search_<?php echo $view_id; ?>" value="<?php echo $value; ?>" /></p> |
@@ -12,8 +12,8 @@ |
||
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class="gv-search-box gv-search-field-single_checkbox"> |
15 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" class="gv-check-radio"> |
|
16 | - <input type="checkbox" name="<?php echo esc_attr( $search_field['name'] ); ?>" value="1" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" <?php checked( '1', $search_field['value'], true ); ?>> |
|
17 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { echo esc_html( $search_field['label'] ); } ?> |
|
15 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" class="gv-check-radio"> |
|
16 | + <input type="checkbox" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="1" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" <?php checked( '1', $search_field[ 'value' ], true ); ?>> |
|
17 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { echo esc_html( $search_field[ 'label' ] ); } ?> |
|
18 | 18 | </label> |
19 | 19 | </div> |
20 | 20 | \ No newline at end of file |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | 'type' => 'radio', |
64 | 64 | 'full_width' => true, |
65 | 65 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
66 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
66 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
67 | 67 | 'value' => 'any', |
68 | 68 | 'class' => 'hide-if-js', |
69 | 69 | 'options' => array( |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
87 | 87 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
88 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
88 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
89 | 89 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
90 | 90 | |
91 | 91 | // ajax - get the searchable fields |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
222 | 222 | $script_source = empty( $script_min ) ? '/source' : ''; |
223 | 223 | |
224 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version ); |
|
224 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version ); |
|
225 | 225 | |
226 | 226 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
227 | 227 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
244 | 244 | */ |
245 | 245 | public function register_no_conflict( $allowed ) { |
246 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
246 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
247 | 247 | return $allowed; |
248 | 248 | } |
249 | 249 | |
@@ -256,24 +256,24 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public static function get_searchable_fields() { |
258 | 258 | |
259 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
259 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
260 | 260 | exit( '0' ); |
261 | 261 | } |
262 | 262 | |
263 | 263 | $form = ''; |
264 | 264 | |
265 | 265 | // Fetch the form for the current View |
266 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
266 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
267 | 267 | |
268 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
268 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
269 | 269 | |
270 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
270 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
271 | 271 | |
272 | - $form = (int) $_POST['formid']; |
|
272 | + $form = (int)$_POST[ 'formid' ]; |
|
273 | 273 | |
274 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
274 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
275 | 275 | |
276 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
276 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
277 | 277 | |
278 | 278 | } |
279 | 279 | |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | ) |
319 | 319 | ); |
320 | 320 | |
321 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
322 | - $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'] ); |
|
321 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
322 | + $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' ] ); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | // Get fields with sub-inputs and no parent |
@@ -341,13 +341,13 @@ discard block |
||
341 | 341 | |
342 | 342 | foreach ( $fields as $id => $field ) { |
343 | 343 | |
344 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
344 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
345 | 345 | continue; |
346 | 346 | } |
347 | 347 | |
348 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
348 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
349 | 349 | |
350 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
350 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
371 | 371 | |
372 | 372 | // @todo - This needs to be improved - many fields have . including products and addresses |
373 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
373 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
374 | 374 | $input_type = 'boolean'; // on/off checkbox |
375 | 375 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
376 | 376 | $input_type = 'multi'; //multiselect |
@@ -414,19 +414,19 @@ discard block |
||
414 | 414 | $post_id = 0; |
415 | 415 | |
416 | 416 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
417 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
418 | - $post_id = absint( $widget_args['post_id'] ); |
|
417 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
418 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
419 | 419 | } |
420 | 420 | // We're in the WordPress Widget context, and the base View ID should be used |
421 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
422 | - $post_id = absint( $widget_args['view_id'] ); |
|
421 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
422 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | $args = gravityview_get_permalink_query_args( $post_id ); |
426 | 426 | |
427 | 427 | // Add hidden fields to the search form |
428 | 428 | foreach ( $args as $key => $value ) { |
429 | - $search_fields[] = array( |
|
429 | + $search_fields[ ] = array( |
|
430 | 430 | 'name' => $key, |
431 | 431 | 'input' => 'hidden', |
432 | 432 | 'value' => $value, |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | */ |
448 | 448 | public function filter_entries( $search_criteria ) { |
449 | 449 | |
450 | - if( 'post' === $this->search_method ) { |
|
450 | + if ( 'post' === $this->search_method ) { |
|
451 | 451 | $get = $_POST; |
452 | 452 | } else { |
453 | 453 | $get = $_GET; |
@@ -464,12 +464,12 @@ discard block |
||
464 | 464 | $get = gv_map_deep( $get, 'rawurldecode' ); |
465 | 465 | |
466 | 466 | // Make sure array key is set up |
467 | - $search_criteria['field_filters'] = rgar( $search_criteria, 'field_filters', array() ); |
|
467 | + $search_criteria[ 'field_filters' ] = rgar( $search_criteria, 'field_filters', array() ); |
|
468 | 468 | |
469 | 469 | // add free search |
470 | - if ( ! empty( $get['gv_search'] ) ) { |
|
470 | + if ( ! empty( $get[ 'gv_search' ] ) ) { |
|
471 | 471 | |
472 | - $search_all_value = trim( $get['gv_search'] ); |
|
472 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
473 | 473 | |
474 | 474 | /** |
475 | 475 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | */ |
479 | 479 | $split_words = apply_filters( 'gravityview/search-all-split-words', true ); |
480 | 480 | |
481 | - if( $split_words ) { |
|
481 | + if ( $split_words ) { |
|
482 | 482 | |
483 | 483 | // Search for a piece |
484 | 484 | $words = explode( ' ', $search_all_value ); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | } |
495 | 495 | |
496 | 496 | foreach ( $words as $word ) { |
497 | - $search_criteria['field_filters'][] = array( |
|
497 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
498 | 498 | 'key' => null, // The field ID to search |
499 | 499 | 'value' => $word, // The value to search |
500 | 500 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | } |
504 | 504 | |
505 | 505 | //start date & end date |
506 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
507 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
506 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
507 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
508 | 508 | |
509 | 509 | /** |
510 | 510 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -519,16 +519,16 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries) |
521 | 521 | */ |
522 | - if( !empty( $curr_start ) ) { |
|
523 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
522 | + if ( ! empty( $curr_start ) ) { |
|
523 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
524 | 524 | } |
525 | - if( !empty( $curr_end ) ) { |
|
526 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
525 | + if ( ! empty( $curr_end ) ) { |
|
526 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | // search for a specific entry ID |
530 | 530 | if ( ! empty( $get[ 'gv_id' ] ) ) { |
531 | - $search_criteria['field_filters'][] = array( |
|
531 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
532 | 532 | 'key' => 'id', |
533 | 533 | 'value' => absint( $get[ 'gv_id' ] ), |
534 | 534 | 'operator' => '=', |
@@ -537,36 +537,36 @@ discard block |
||
537 | 537 | |
538 | 538 | // search for a specific Created_by ID |
539 | 539 | if ( ! empty( $get[ 'gv_by' ] ) ) { |
540 | - $search_criteria['field_filters'][] = array( |
|
540 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
541 | 541 | 'key' => 'created_by', |
542 | - 'value' => absint( $get['gv_by'] ), |
|
542 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
543 | 543 | 'operator' => '=', |
544 | 544 | ); |
545 | 545 | } |
546 | 546 | |
547 | 547 | |
548 | 548 | // Get search mode passed in URL |
549 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
549 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
550 | 550 | |
551 | 551 | // get the other search filters |
552 | 552 | foreach ( $get as $key => $value ) { |
553 | 553 | |
554 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
554 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
555 | 555 | continue; |
556 | 556 | } |
557 | 557 | |
558 | 558 | // could return simple filter or multiple filters |
559 | 559 | $filter = $this->prepare_field_filter( $key, $value ); |
560 | 560 | |
561 | - if ( isset( $filter[0]['value'] ) ) { |
|
562 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
561 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
562 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
563 | 563 | |
564 | 564 | // if date range type, set search mode to ALL |
565 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
565 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
566 | 566 | $mode = 'all'; |
567 | 567 | } |
568 | - } elseif( !empty( $filter ) ) { |
|
569 | - $search_criteria['field_filters'][] = $filter; |
|
568 | + } elseif ( ! empty( $filter ) ) { |
|
569 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @since 1.5.1 |
576 | 576 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
577 | 577 | */ |
578 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
578 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
579 | 579 | |
580 | 580 | do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
581 | 581 | |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | $field_id = str_replace( 'filter_', '', $key ); |
602 | 602 | |
603 | 603 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
604 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
604 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
605 | 605 | $field_id = str_replace( '_', '.', $field_id ); |
606 | 606 | } |
607 | 607 | |
@@ -615,11 +615,11 @@ discard block |
||
615 | 615 | 'value' => $value, |
616 | 616 | ); |
617 | 617 | |
618 | - switch ( $form_field['type'] ) { |
|
618 | + switch ( $form_field[ 'type' ] ) { |
|
619 | 619 | |
620 | 620 | case 'select': |
621 | 621 | case 'radio': |
622 | - $filter['operator'] = 'is'; |
|
622 | + $filter[ 'operator' ] = 'is'; |
|
623 | 623 | break; |
624 | 624 | |
625 | 625 | case 'post_category': |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | |
634 | 634 | foreach ( $value as $val ) { |
635 | 635 | $cat = get_term( $val, 'category' ); |
636 | - $filter[] = array( |
|
636 | + $filter[ ] = array( |
|
637 | 637 | 'key' => $field_id, |
638 | 638 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
639 | 639 | 'operator' => 'is', |
@@ -652,18 +652,18 @@ discard block |
||
652 | 652 | $filter = array(); |
653 | 653 | |
654 | 654 | foreach ( $value as $val ) { |
655 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
655 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | break; |
659 | 659 | |
660 | 660 | case 'checkbox': |
661 | 661 | // convert checkbox on/off into the correct search filter |
662 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
663 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
664 | - if ( $input['id'] == $field_id ) { |
|
665 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
666 | - $filter['operator'] = 'is'; |
|
662 | + if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) { |
|
663 | + foreach ( $form_field[ 'inputs' ] as $k => $input ) { |
|
664 | + if ( $input[ 'id' ] == $field_id ) { |
|
665 | + $filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ]; |
|
666 | + $filter[ 'operator' ] = 'is'; |
|
667 | 667 | break; |
668 | 668 | } |
669 | 669 | } |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | $filter = array(); |
674 | 674 | |
675 | 675 | foreach ( $value as $val ) { |
676 | - $filter[] = array( |
|
676 | + $filter[ ] = array( |
|
677 | 677 | 'key' => $field_id, |
678 | 678 | 'value' => $val, |
679 | 679 | 'operator' => 'is', |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | foreach ( $words as $word ) { |
695 | 695 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
696 | 696 | // Keep the same key for each filter |
697 | - $filter['value'] = $word; |
|
697 | + $filter[ 'value' ] = $word; |
|
698 | 698 | // Add a search for the value |
699 | - $filters[] = $filter; |
|
699 | + $filters[ ] = $filter; |
|
700 | 700 | } |
701 | 701 | } |
702 | 702 | |
@@ -723,19 +723,19 @@ discard block |
||
723 | 723 | * @since 1.16.3 |
724 | 724 | * Safeguard until GF implements '<=' operator |
725 | 725 | */ |
726 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
726 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
727 | 727 | $operator = '<'; |
728 | 728 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
729 | 729 | } |
730 | 730 | |
731 | - $filter[] = array( |
|
731 | + $filter[ ] = array( |
|
732 | 732 | 'key' => $field_id, |
733 | 733 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
734 | 734 | 'operator' => $operator, |
735 | 735 | ); |
736 | 736 | } |
737 | 737 | } else { |
738 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
738 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | break; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | 'ymd_dot' => 'Y.m.d', |
767 | 767 | ); |
768 | 768 | |
769 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
769 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
770 | 770 | $format = $datepicker[ $field->dateFormat ]; |
771 | 771 | } |
772 | 772 | |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | public function add_template_path( $file_paths ) { |
798 | 798 | |
799 | 799 | // Index 100 is the default GravityView template path. |
800 | - $file_paths[102] = self::$file . 'templates/'; |
|
800 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
801 | 801 | |
802 | 802 | return $file_paths; |
803 | 803 | } |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | $has_date = false; |
817 | 817 | |
818 | 818 | foreach ( $search_fields as $k => $field ) { |
819 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
819 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
820 | 820 | $has_date = true; |
821 | 821 | break; |
822 | 822 | } |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | } |
844 | 844 | |
845 | 845 | // get configured search fields |
846 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
846 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
847 | 847 | |
848 | 848 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
849 | 849 | do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
@@ -858,34 +858,34 @@ discard block |
||
858 | 858 | |
859 | 859 | $updated_field = $this->get_search_filter_details( $updated_field ); |
860 | 860 | |
861 | - switch ( $field['field'] ) { |
|
861 | + switch ( $field[ 'field' ] ) { |
|
862 | 862 | |
863 | 863 | case 'search_all': |
864 | - $updated_field['key'] = 'search_all'; |
|
865 | - $updated_field['input'] = 'search_all'; |
|
866 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
864 | + $updated_field[ 'key' ] = 'search_all'; |
|
865 | + $updated_field[ 'input' ] = 'search_all'; |
|
866 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
867 | 867 | break; |
868 | 868 | |
869 | 869 | case 'entry_date': |
870 | - $updated_field['key'] = 'entry_date'; |
|
871 | - $updated_field['input'] = 'entry_date'; |
|
872 | - $updated_field['value'] = array( |
|
870 | + $updated_field[ 'key' ] = 'entry_date'; |
|
871 | + $updated_field[ 'input' ] = 'entry_date'; |
|
872 | + $updated_field[ 'value' ] = array( |
|
873 | 873 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
874 | 874 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
875 | 875 | ); |
876 | 876 | break; |
877 | 877 | |
878 | 878 | case 'entry_id': |
879 | - $updated_field['key'] = 'entry_id'; |
|
880 | - $updated_field['input'] = 'entry_id'; |
|
881 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
879 | + $updated_field[ 'key' ] = 'entry_id'; |
|
880 | + $updated_field[ 'input' ] = 'entry_id'; |
|
881 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
882 | 882 | break; |
883 | 883 | |
884 | 884 | case 'created_by': |
885 | - $updated_field['key'] = 'created_by'; |
|
886 | - $updated_field['name'] = 'gv_by'; |
|
887 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
888 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
885 | + $updated_field[ 'key' ] = 'created_by'; |
|
886 | + $updated_field[ 'name' ] = 'gv_by'; |
|
887 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
888 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
889 | 889 | break; |
890 | 890 | } |
891 | 891 | |
@@ -903,16 +903,16 @@ discard block |
||
903 | 903 | */ |
904 | 904 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
905 | 905 | |
906 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
906 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
907 | 907 | |
908 | 908 | /** @since 1.14 */ |
909 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
909 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
910 | 910 | |
911 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
911 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
912 | 912 | |
913 | 913 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
914 | 914 | |
915 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
915 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
916 | 916 | |
917 | 917 | if ( $this->has_date_field( $search_fields ) ) { |
918 | 918 | // enqueue datepicker stuff only if needed! |
@@ -934,10 +934,10 @@ discard block |
||
934 | 934 | public static function get_search_class( $custom_class = '' ) { |
935 | 935 | $gravityview_view = GravityView_View::getInstance(); |
936 | 936 | |
937 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
937 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
938 | 938 | |
939 | - if ( ! empty( $custom_class ) ) { |
|
940 | - $search_class .= ' '.$custom_class; |
|
939 | + if ( ! empty( $custom_class ) ) { |
|
940 | + $search_class .= ' ' . $custom_class; |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | /** |
@@ -979,11 +979,11 @@ discard block |
||
979 | 979 | |
980 | 980 | $label = rgget( 'label', $field ); |
981 | 981 | |
982 | - if( '' === $label ) { |
|
982 | + if ( '' === $label ) { |
|
983 | 983 | |
984 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
984 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
985 | 985 | |
986 | - switch( $field['field'] ) { |
|
986 | + switch ( $field[ 'field' ] ) { |
|
987 | 987 | case 'search_all': |
988 | 988 | $label = __( 'Search Entries:', 'gravityview' ); |
989 | 989 | break; |
@@ -995,10 +995,10 @@ discard block |
||
995 | 995 | break; |
996 | 996 | default: |
997 | 997 | // If this is a field input, not a field |
998 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
998 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
999 | 999 | |
1000 | 1000 | // Get the label for the field in question, which returns an array |
1001 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1001 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1002 | 1002 | |
1003 | 1003 | // Get the item with the `label` key |
1004 | 1004 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1037,32 +1037,32 @@ discard block |
||
1037 | 1037 | $form = $gravityview_view->getForm(); |
1038 | 1038 | |
1039 | 1039 | // for advanced field ids (eg, first name / last name ) |
1040 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1040 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1041 | 1041 | |
1042 | 1042 | // get searched value from $_GET/$_POST (string or array) |
1043 | 1043 | $value = $this->rgget_or_rgpost( $name ); |
1044 | 1044 | |
1045 | 1045 | // get form field details |
1046 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1046 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1047 | 1047 | |
1048 | 1048 | $filter = array( |
1049 | - 'key' => $field['field'], |
|
1049 | + 'key' => $field[ 'field' ], |
|
1050 | 1050 | 'name' => $name, |
1051 | 1051 | 'label' => self::get_field_label( $field, $form_field ), |
1052 | - 'input' => $field['input'], |
|
1052 | + 'input' => $field[ 'input' ], |
|
1053 | 1053 | 'value' => $value, |
1054 | - 'type' => $form_field['type'], |
|
1054 | + 'type' => $form_field[ 'type' ], |
|
1055 | 1055 | ); |
1056 | 1056 | |
1057 | 1057 | // collect choices |
1058 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1059 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1060 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1061 | - $filter['choices'] = $form_field['choices']; |
|
1058 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1059 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1060 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1061 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1065 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1064 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1065 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | return $filter; |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | |
1087 | 1087 | $choices = array(); |
1088 | 1088 | foreach ( $users as $user ) { |
1089 | - $choices[] = array( |
|
1089 | + $choices[ ] = array( |
|
1090 | 1090 | 'value' => $user->ID, |
1091 | 1091 | 'text' => $user->display_name, |
1092 | 1092 | ); |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | */ |
1142 | 1142 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1143 | 1143 | |
1144 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1144 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1145 | 1145 | |
1146 | 1146 | return $js_dependencies; |
1147 | 1147 | } |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | 'isRTL' => is_rtl(), |
1186 | 1186 | ), $view_data ); |
1187 | 1187 | |
1188 | - $localizations['datepicker'] = $datepicker_settings; |
|
1188 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1189 | 1189 | |
1190 | 1190 | return $localizations; |
1191 | 1191 | |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | * @return void |
1215 | 1215 | */ |
1216 | 1216 | private function maybe_enqueue_flexibility() { |
1217 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1217 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1218 | 1218 | wp_enqueue_script( 'gv-flexibility' ); |
1219 | 1219 | } |
1220 | 1220 | } |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1237 | 1237 | |
1238 | 1238 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1239 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1239 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1240 | 1240 | |
1241 | 1241 | /** |
1242 | 1242 | * @filter `gravityview_search_datepicker_class` |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | * @param mixed $field_id Field ID or Field array |
329 | 329 | * @return string field type |
330 | 330 | */ |
331 | -function gravityview_get_field_type( $form = null , $field_id = '' ) { |
|
332 | - return GVCommon::get_field_type( $form, $field_id ); |
|
331 | +function gravityview_get_field_type( $form = null, $field_id = '' ) { |
|
332 | + return GVCommon::get_field_type( $form, $field_id ); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * @return string HTML of the output. Empty string if $view_id is empty. |
343 | 343 | */ |
344 | 344 | function get_gravityview( $view_id = '', $atts = array() ) { |
345 | - if( !empty( $view_id ) ) { |
|
346 | - $atts['id'] = $view_id; |
|
345 | + if ( ! empty( $view_id ) ) { |
|
346 | + $atts[ 'id' ] = $view_id; |
|
347 | 347 | $args = wp_parse_args( $atts, defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? \GV\View_Settings::defaults() : GravityView_View_Data::get_default_args() ); |
348 | 348 | $GravityView_frontend = GravityView_frontend::getInstance(); |
349 | 349 | $GravityView_frontend->setGvOutputData( GravityView_View_Data::getInstance( $view_id ) ); |
@@ -386,19 +386,19 @@ discard block |
||
386 | 386 | */ |
387 | 387 | function gravityview_view_has_single_checkbox_or_radio( $form, $view_fields ) { |
388 | 388 | |
389 | - if( class_exists('GFFormsModel') && $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
389 | + if ( class_exists( 'GFFormsModel' ) && $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
390 | 390 | |
391 | 391 | /** @var GF_Field_Radio|GF_Field_Checkbox $form_field */ |
392 | - foreach( $form_fields as $form_field ) { |
|
392 | + foreach ( $form_fields as $form_field ) { |
|
393 | 393 | $field_id = $form_field->id; |
394 | - foreach( $view_fields as $zone ) { |
|
394 | + foreach ( $view_fields as $zone ) { |
|
395 | 395 | |
396 | 396 | // ACF compatibility; ACF-added fields aren't arrays |
397 | 397 | if ( ! is_array( $zone ) ) { continue; } |
398 | 398 | |
399 | - foreach( $zone as $field ) { |
|
399 | + foreach ( $zone as $field ) { |
|
400 | 400 | // If it's an input, not the parent and the parent ID matches a checkbox or radio |
401 | - if( ( strpos( $field['id'], '.' ) > 0 ) && floor( $field['id'] ) === floor( $field_id ) ) { |
|
401 | + if ( ( strpos( $field[ 'id' ], '.' ) > 0 ) && floor( $field[ 'id' ] ) === floor( $field_id ) ) { |
|
402 | 402 | return true; |
403 | 403 | } |
404 | 404 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | * @since 1.0 |
35 | 35 | */ |
36 | 36 | public function __construct() { |
37 | - add_action( 'admin_menu', array( $this, 'admin_menus'), 200 ); |
|
37 | + add_action( 'admin_menu', array( $this, 'admin_menus' ), 200 ); |
|
38 | 38 | add_action( 'admin_head', array( $this, 'admin_head' ) ); |
39 | - add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
40 | - add_filter( 'gravityview_is_admin_page', array( $this, 'is_dashboard_page'), 10, 2 ); |
|
39 | + add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
40 | + add_filter( 'gravityview_is_admin_page', array( $this, 'is_dashboard_page' ), 10, 2 ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | // Add help page to GravityView menu |
54 | 54 | add_submenu_page( |
55 | 55 | 'edit.php?post_type=gravityview', |
56 | - __('GravityView: Getting Started', 'gravityview'), |
|
57 | - __('Getting Started', 'gravityview'), |
|
56 | + __( 'GravityView: Getting Started', 'gravityview' ), |
|
57 | + __( 'Getting Started', 'gravityview' ), |
|
58 | 58 | $this->minimum_capability, |
59 | 59 | 'gv-getting-started', |
60 | 60 | array( $this, 'getting_started_screen' ) |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return boolean $is_page True: yep; false: nope |
89 | 89 | */ |
90 | - public function is_dashboard_page($is_page = false, $hook = NULL) { |
|
90 | + public function is_dashboard_page( $is_page = false, $hook = NULL ) { |
|
91 | 91 | global $plugin_page; |
92 | 92 | |
93 | - if($is_page) { return $is_page; } |
|
93 | + if ( $is_page ) { return $is_page; } |
|
94 | 94 | |
95 | 95 | return in_array( $plugin_page, array( 'gv-about', 'gv-credits', 'gv-getting-started' ) ); |
96 | 96 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-credits' ); |
109 | 109 | remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-changelog' ); |
110 | 110 | |
111 | - if( !$this->is_dashboard_page() ) { return; } |
|
111 | + if ( ! $this->is_dashboard_page() ) { return; } |
|
112 | 112 | |
113 | 113 | ?> |
114 | 114 | <style type="text/css" media="screen" xmlns="http://www.w3.org/1999/html"> |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | // Don't fetch -beta, etc. |
133 | 133 | list( $display_version ) = explode( '-', GravityView_Plugin::version ); |
134 | 134 | |
135 | - $selected = !empty( $plugin_page ) ? $plugin_page : 'gv-getting-started'; |
|
135 | + $selected = ! empty( $plugin_page ) ? $plugin_page : 'gv-getting-started'; |
|
136 | 136 | |
137 | 137 | echo gravityview_get_floaty( 132 ); |
138 | 138 | ?> |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | <div class="about-text"><?php esc_html_e( 'Thank you for installing GravityView. Beautifully display your Gravity Forms entries.', 'gravityview' ); ?></div> |
142 | 142 | |
143 | 143 | <h2 class="nav-tab-wrapper clear"> |
144 | - <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-getting-started', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
144 | + <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-getting-started', 'post_type' => 'gravityview' ), 'edit.php' ) ) ); ?>"> |
|
145 | 145 | <?php _e( "Getting Started", 'gravityview' ); ?> |
146 | 146 | </a> |
147 | - <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-changelog', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
147 | + <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-changelog', 'post_type' => 'gravityview' ), 'edit.php' ) ) ); ?>"> |
|
148 | 148 | <?php _e( "List of Changes", 'gravityview' ); ?> |
149 | 149 | </a> |
150 | - <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-credits', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
150 | + <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-credits', 'post_type' => 'gravityview' ), 'edit.php' ) ) ); ?>"> |
|
151 | 151 | <?php _e( 'Credits', 'gravityview' ); ?> |
152 | 152 | </a> |
153 | 153 | </h2> |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | <h3>Create a View</h3> |
183 | 183 | |
184 | 184 | <ol class="ol-decimal"> |
185 | - <li>Go to <a href="<?php echo admin_url('post-new.php?post_type=gravityview'); ?>">Views > New View</a></li> |
|
185 | + <li>Go to <a href="<?php echo admin_url( 'post-new.php?post_type=gravityview' ); ?>">Views > New View</a></li> |
|
186 | 186 | <li>If you want to <strong>create a new form</strong>, click the "Use a Form Preset" button</li> |
187 | 187 | <li>If you want to <strong>use an existing form’s entries</strong>, select from the dropdown.</li> |
188 | 188 | <li>Select the type of View you would like to create. There are two core types of Views: <strong>Table</strong> and <strong>Listing</strong>. |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | </ul> |
465 | 465 | |
466 | 466 | <h4><?php esc_attr_e( 'Want to contribute?', 'gravityview' ); ?></h4> |
467 | - <p><?php echo sprintf( esc_attr__( 'If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview'), '<a href="https://github.com/katzwebservices/GravityView">', '</a>' ); ?></p> |
|
467 | + <p><?php echo sprintf( esc_attr__( 'If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview' ), '<a href="https://github.com/katzwebservices/GravityView">', '</a>' ); ?></p> |
|
468 | 468 | </div> |
469 | 469 | </div> |
470 | 470 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | global $plugin_page; |
508 | 508 | |
509 | 509 | // Bail if we're just editing the plugin |
510 | - if( $plugin_page === 'plugin-editor.php' ) { return; } |
|
510 | + if ( $plugin_page === 'plugin-editor.php' ) { return; } |
|
511 | 511 | |
512 | 512 | // Bail if no activation redirect |
513 | 513 | if ( ! get_transient( '_gv_activation_redirect' ) ) { return; } |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | $upgrade = get_option( 'gv_version_upgraded_from' ); |
519 | 519 | |
520 | 520 | // Don't do anything if they've already seen the new version info |
521 | - if( $upgrade === GravityView_Plugin::version ) { |
|
521 | + if ( $upgrade === GravityView_Plugin::version ) { |
|
522 | 522 | return; |
523 | 523 | } |
524 | 524 | |
@@ -526,10 +526,10 @@ discard block |
||
526 | 526 | update_option( 'gv_version_upgraded_from', GravityView_Plugin::version ); |
527 | 527 | |
528 | 528 | // Bail if activating from network, or bulk |
529 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { return; } |
|
529 | + if ( is_network_admin() || isset( $_GET[ 'activate-multi' ] ) ) { return; } |
|
530 | 530 | |
531 | 531 | // First time install |
532 | - if( ! $upgrade ) { |
|
532 | + if ( ! $upgrade ) { |
|
533 | 533 | wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-getting-started' ) ); exit; |
534 | 534 | } |
535 | 535 | // Update |
@@ -63,18 +63,18 @@ discard block |
||
63 | 63 | |
64 | 64 | add_shortcode( 'gv_note_add', array( 'GravityView_Field_Notes', 'get_add_note_part' ) ); |
65 | 65 | |
66 | - add_action( 'wp', array( $this, 'maybe_delete_notes'), 1000 ); |
|
67 | - add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
68 | - add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
66 | + add_action( 'wp', array( $this, 'maybe_delete_notes' ), 1000 ); |
|
67 | + add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
68 | + add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
69 | 69 | |
70 | - add_action( 'wp', array( $this, 'maybe_add_note'), 1000 ); |
|
71 | - add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note') ); |
|
72 | - add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note') ); |
|
70 | + add_action( 'wp', array( $this, 'maybe_add_note' ), 1000 ); |
|
71 | + add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
72 | + add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
73 | 73 | |
74 | 74 | // add template path to check for field |
75 | 75 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
76 | 76 | |
77 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
77 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
78 | 78 | add_action( 'gravityview/field/notes/scripts', array( $this, 'enqueue_scripts' ) ); |
79 | 79 | |
80 | 80 | add_filter( 'gravityview_entry_default_fields', array( $this, 'add_entry_default_field' ), 10, 3 ); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function add_entry_default_field( $entry_default_fields, $form, $zone ) { |
98 | 98 | |
99 | - if( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
100 | - $entry_default_fields['notes'] = array( |
|
99 | + if ( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
100 | + $entry_default_fields[ 'notes' ] = array( |
|
101 | 101 | 'label' => __( 'Entry Notes', 'gravityview' ), |
102 | 102 | 'type' => 'notes', |
103 | 103 | 'desc' => __( 'Display, add, and delete notes for an entry.', 'gravityview' ), |
@@ -130,23 +130,23 @@ discard block |
||
130 | 130 | public function enqueue_scripts() { |
131 | 131 | global $wp_actions; |
132 | 132 | |
133 | - if( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
133 | + if ( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
134 | 134 | wp_enqueue_style( 'gravityview-notes' ); |
135 | 135 | wp_enqueue_script( 'gravityview-notes' ); |
136 | 136 | } |
137 | 137 | |
138 | - if( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
138 | + if ( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
139 | 139 | |
140 | 140 | $strings = self::strings(); |
141 | 141 | |
142 | 142 | wp_localize_script( 'gravityview-notes', 'GVNotes', array( |
143 | 143 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
144 | 144 | 'text' => array( |
145 | - 'processing' => $strings['processing'], |
|
146 | - 'delete_confirm' => $strings['delete-confirm'], |
|
147 | - 'note_added' => $strings['added-note'], |
|
148 | - 'error_invalid' => $strings['error-invalid'], |
|
149 | - 'error_empty_note' => $strings['error-empty-note'], |
|
145 | + 'processing' => $strings[ 'processing' ], |
|
146 | + 'delete_confirm' => $strings[ 'delete-confirm' ], |
|
147 | + 'note_added' => $strings[ 'added-note' ], |
|
148 | + 'error_invalid' => $strings[ 'error-invalid' ], |
|
149 | + 'error_empty_note' => $strings[ 'error-empty-note' ], |
|
150 | 150 | ), |
151 | 151 | ) ); |
152 | 152 | } |
@@ -163,26 +163,26 @@ discard block |
||
163 | 163 | */ |
164 | 164 | function maybe_add_note() { |
165 | 165 | |
166 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
166 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
167 | 167 | do_action( 'gravityview_log_error', __METHOD__ . ': The user isnt allowed to add entry notes.' ); |
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | - if( ! isset( $_POST['action'] ) ) { |
|
171 | + if ( ! isset( $_POST[ 'action' ] ) ) { |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
175 | - if( 'gv_note_add' === $_POST['action'] ) { |
|
175 | + if ( 'gv_note_add' === $_POST[ 'action' ] ) { |
|
176 | 176 | |
177 | 177 | $post = wp_unslash( $_POST ); |
178 | 178 | |
179 | - if( $this->doing_ajax ) { |
|
180 | - parse_str( $post['data'], $data ); |
|
179 | + if ( $this->doing_ajax ) { |
|
180 | + parse_str( $post[ 'data' ], $data ); |
|
181 | 181 | } else { |
182 | 182 | $data = $post; |
183 | 183 | } |
184 | 184 | |
185 | - $this->process_add_note( (array) $data ); |
|
185 | + $this->process_add_note( (array)$data ); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
@@ -209,23 +209,23 @@ discard block |
||
209 | 209 | $error = false; |
210 | 210 | $success = false; |
211 | 211 | |
212 | - if( empty( $data['entry-slug'] ) ) { |
|
212 | + if ( empty( $data[ 'entry-slug' ] ) ) { |
|
213 | 213 | |
214 | - $error = self::strings('error-invalid'); |
|
214 | + $error = self::strings( 'error-invalid' ); |
|
215 | 215 | do_action( 'gravityview_log_error', __METHOD__ . ': The note is missing an Entry ID.' ); |
216 | 216 | |
217 | 217 | } else { |
218 | 218 | |
219 | - $valid = wp_verify_nonce( $data['gv_note_add'], 'gv_note_add_' . $data['entry-slug'] ); |
|
219 | + $valid = wp_verify_nonce( $data[ 'gv_note_add' ], 'gv_note_add_' . $data[ 'entry-slug' ] ); |
|
220 | 220 | |
221 | 221 | $has_cap = GVCommon::has_cap( 'gravityview_add_entry_notes' ); |
222 | 222 | |
223 | - if( ! $has_cap ) { |
|
223 | + if ( ! $has_cap ) { |
|
224 | 224 | $error = self::strings( 'error-cap-add' ); |
225 | 225 | do_action( 'gravityview_log_error', __METHOD__ . ': Adding a note failed: the user does not have the "gravityview_add_entry_notes" capability.' ); |
226 | 226 | } elseif ( $valid ) { |
227 | 227 | |
228 | - $entry = gravityview_get_entry( $data['entry-slug'], true, false ); |
|
228 | + $entry = gravityview_get_entry( $data[ 'entry-slug' ], true, false ); |
|
229 | 229 | |
230 | 230 | $added = $this->add_note( $entry, $data ); |
231 | 231 | |
@@ -243,22 +243,22 @@ discard block |
||
243 | 243 | $this->maybe_send_entry_notes( $note, $entry, $data ); |
244 | 244 | |
245 | 245 | if ( $note ) { |
246 | - $success = self::display_note( $note, ! empty( $data['show-delete'] ) ); |
|
247 | - do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact('note', 'data') ); |
|
246 | + $success = self::display_note( $note, ! empty( $data[ 'show-delete' ] ) ); |
|
247 | + do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact( 'note', 'data' ) ); |
|
248 | 248 | } else { |
249 | - $error = self::strings('error-add-note'); |
|
250 | - do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact('note', 'data') ); |
|
249 | + $error = self::strings( 'error-add-note' ); |
|
250 | + do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact( 'note', 'data' ) ); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | } else { |
254 | - $error = self::strings('error-invalid'); |
|
254 | + $error = self::strings( 'error-invalid' ); |
|
255 | 255 | do_action( 'gravityview_log_error', __METHOD__ . ': Nonce validation failed; the note was not created' ); |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | 259 | |
260 | - if( $this->doing_ajax ) { |
|
261 | - if( $success ) { |
|
260 | + if ( $this->doing_ajax ) { |
|
261 | + if ( $success ) { |
|
262 | 262 | wp_send_json_success( array( 'html' => $success ) ); |
263 | 263 | } else { |
264 | 264 | $error = $error ? $error : self::strings( 'error-invalid' ); |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | return; |
285 | 285 | } |
286 | 286 | |
287 | - if ( isset( $_POST['action'] ) && 'gv_delete_notes' === $_POST['action'] ) { |
|
287 | + if ( isset( $_POST[ 'action' ] ) && 'gv_delete_notes' === $_POST[ 'action' ] ) { |
|
288 | 288 | |
289 | 289 | $post = wp_unslash( $_POST ); |
290 | 290 | if ( $this->doing_ajax ) { |
291 | - parse_str( $post['data'], $data ); |
|
291 | + parse_str( $post[ 'data' ], $data ); |
|
292 | 292 | } else { |
293 | 293 | $data = $post; |
294 | 294 | } |
@@ -319,18 +319,18 @@ discard block |
||
319 | 319 | */ |
320 | 320 | function process_delete_notes( $data ) { |
321 | 321 | |
322 | - $valid = wp_verify_nonce( $data['gv_delete_notes'], 'gv_delete_notes_' . $data['entry-slug'] ); |
|
322 | + $valid = wp_verify_nonce( $data[ 'gv_delete_notes' ], 'gv_delete_notes_' . $data[ 'entry-slug' ] ); |
|
323 | 323 | $has_cap = GVCommon::has_cap( 'gravityview_delete_entry_notes' ); |
324 | 324 | $success = false; |
325 | 325 | |
326 | 326 | if ( $valid && $has_cap ) { |
327 | - GravityView_Entry_Notes::delete_notes( $data['note'] ); |
|
327 | + GravityView_Entry_Notes::delete_notes( $data[ 'note' ] ); |
|
328 | 328 | $success = true; |
329 | 329 | } |
330 | 330 | |
331 | - if( $this->doing_ajax ) { |
|
331 | + if ( $this->doing_ajax ) { |
|
332 | 332 | |
333 | - if( $success ) { |
|
333 | + if ( $success ) { |
|
334 | 334 | wp_send_json_success(); |
335 | 335 | } else { |
336 | 336 | if ( ! $valid ) { |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | |
364 | 364 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
365 | 365 | |
366 | - unset( $field_options['show_as_link'] ); |
|
366 | + unset( $field_options[ 'show_as_link' ] ); |
|
367 | 367 | |
368 | 368 | $notes_options = array( |
369 | 369 | 'notes' => array( |
370 | 370 | 'type' => 'checkboxes', |
371 | - 'label' => __('Note Settings', 'gravityview'), |
|
372 | - 'desc' => sprintf( _x('Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
371 | + 'label' => __( 'Note Settings', 'gravityview' ), |
|
372 | + 'desc' => sprintf( _x( 'Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
373 | 373 | 'options' => array( |
374 | 374 | 'view' => array( |
375 | 375 | 'label' => __( 'Display notes?', 'gravityview' ), |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | 'processing' => __( 'Processing…', 'gravityview' ), |
422 | 422 | 'other-email' => __( 'Other email address', 'gravityview' ), |
423 | 423 | 'email-label' => __( 'Email address', 'gravityview' ), |
424 | - 'email-placeholder' => _x('[email protected]', 'Example email address used as a placeholder', 'gravityview'), |
|
424 | + 'email-placeholder' => _x( '[email protected]', 'Example email address used as a placeholder', 'gravityview' ), |
|
425 | 425 | 'subject-label' => __( 'Subject', 'gravityview' ), |
426 | 426 | 'subject' => __( 'Email subject', 'gravityview' ), |
427 | 427 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | $strings = gv_map_deep( apply_filters( 'gravityview/field/notes/strings', $strings ), 'esc_html' ); |
443 | 443 | |
444 | - if( $key ) { |
|
444 | + if ( $key ) { |
|
445 | 445 | return isset( $strings[ $key ] ) ? $strings[ $key ] : ''; |
446 | 446 | } |
447 | 447 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | */ |
461 | 461 | static public function display_note( $note, $show_delete = false ) { |
462 | 462 | |
463 | - if( ! is_object( $note ) ) { |
|
463 | + if ( ! is_object( $note ) ) { |
|
464 | 464 | return ''; |
465 | 465 | } |
466 | 466 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $note_row = ob_get_clean(); |
502 | 502 | |
503 | 503 | $replacements = array( |
504 | - '{note_id}' => $note_content['note_id'], |
|
504 | + '{note_id}' => $note_content[ 'note_id' ], |
|
505 | 505 | '{row_class}' => 'gv-note', |
506 | 506 | '{note_detail}' => $note_detail_html |
507 | 507 | ); |
@@ -533,13 +533,13 @@ discard block |
||
533 | 533 | |
534 | 534 | $user_data = get_userdata( $current_user->ID ); |
535 | 535 | |
536 | - $note_content = trim( $data['gv-note-content'] ); |
|
536 | + $note_content = trim( $data[ 'gv-note-content' ] ); |
|
537 | 537 | |
538 | - if( empty( $note_content ) ) { |
|
538 | + if ( empty( $note_content ) ) { |
|
539 | 539 | return new WP_Error( 'gv-add-note-empty', __( 'The note is empty.', 'gravityview' ) ); |
540 | 540 | } |
541 | 541 | |
542 | - $return = GravityView_Entry_Notes::add_note( $entry['id'], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
542 | + $return = GravityView_Entry_Notes::add_note( $entry[ 'id' ], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
543 | 543 | |
544 | 544 | return $return; |
545 | 545 | } |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | */ |
556 | 556 | public static function get_add_note_part() { |
557 | 557 | |
558 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
558 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
559 | 559 | do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to add entry notes ("gravityview_add_entry_notes").' ); |
560 | 560 | return ''; |
561 | 561 | } |
@@ -571,19 +571,19 @@ discard block |
||
571 | 571 | |
572 | 572 | $visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' ); |
573 | 573 | $entry = $gravityview_view->getCurrentEntry(); |
574 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
574 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
575 | 575 | $nonce_field = wp_nonce_field( 'gv_note_add_' . $entry_slug, 'gv_note_add', false, false ); |
576 | 576 | |
577 | 577 | // Only generate the dropdown if the field settings allow it |
578 | 578 | $email_fields = ''; |
579 | - if( ! empty( $visibility_settings['email'] ) ) { |
|
579 | + if ( ! empty( $visibility_settings[ 'email' ] ) ) { |
|
580 | 580 | $email_fields = self::get_note_email_fields( $entry_slug ); |
581 | 581 | } |
582 | 582 | |
583 | 583 | $add_note_html = str_replace( '{entry_slug}', $entry_slug, $add_note_html ); |
584 | 584 | $add_note_html = str_replace( '{nonce_field}', $nonce_field, $add_note_html ); |
585 | - $add_note_html = str_replace( '{show_delete}', intval( $visibility_settings['delete'] ), $add_note_html ); |
|
586 | - $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
585 | + $add_note_html = str_replace( '{show_delete}', intval( $visibility_settings[ 'delete' ] ), $add_note_html ); |
|
586 | + $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
587 | 587 | $add_note_html = str_replace( '{url}', esc_url_raw( add_query_arg( array() ) ), $add_note_html ); |
588 | 588 | |
589 | 589 | return $add_note_html; |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | $note_emails = array(); |
609 | 609 | |
610 | 610 | foreach ( $email_fields as $email_field ) { |
611 | - if ( ! empty( $entry["{$email_field->id}"] ) && is_email( $entry["{$email_field->id}"] ) ) { |
|
612 | - $note_emails[] = $entry["{$email_field->id}"]; |
|
611 | + if ( ! empty( $entry[ "{$email_field->id}" ] ) && is_email( $entry[ "{$email_field->id}" ] ) ) { |
|
612 | + $note_emails[ ] = $entry[ "{$email_field->id}" ]; |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | */ |
622 | 622 | $note_emails = apply_filters( 'gravityview/field/notes/emails', $note_emails, $entry ); |
623 | 623 | |
624 | - return (array) $note_emails; |
|
624 | + return (array)$note_emails; |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | /** |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | */ |
638 | 638 | private static function get_note_email_fields( $entry_slug = '' ) { |
639 | 639 | |
640 | - if( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
640 | + if ( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
641 | 641 | do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to email entry notes ("gravityview_email_entry_notes").' ); |
642 | 642 | return ''; |
643 | 643 | } |
@@ -659,27 +659,27 @@ discard block |
||
659 | 659 | |
660 | 660 | if ( ! empty( $note_emails ) || $include_custom ) { ?> |
661 | 661 | <div class="gv-note-email-container"> |
662 | - <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings['also-email']; ?></label> |
|
662 | + <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings[ 'also-email' ]; ?></label> |
|
663 | 663 | <select class="gv-note-email-to" name="gv-note-to" id="gv-note-email-to-<?php echo $entry_slug_esc; ?>"> |
664 | - <option value=""><?php echo $strings['also-email']; ?></option> |
|
664 | + <option value=""><?php echo $strings[ 'also-email' ]; ?></option> |
|
665 | 665 | <?php foreach ( $note_emails as $email ) { |
666 | 666 | ?> |
667 | 667 | <option value="<?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></option> |
668 | 668 | <?php } |
669 | - if( $include_custom ) { ?> |
|
670 | - <option value="custom"><?php echo self::strings('other-email'); ?></option> |
|
669 | + if ( $include_custom ) { ?> |
|
670 | + <option value="custom"><?php echo self::strings( 'other-email' ); ?></option> |
|
671 | 671 | <?php } ?> |
672 | 672 | </select> |
673 | 673 | <fieldset class="gv-note-to-container"> |
674 | - <?php if( $include_custom ) { ?> |
|
674 | + <?php if ( $include_custom ) { ?> |
|
675 | 675 | <div class='gv-note-to-custom-container'> |
676 | - <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings['email-label']; ?></label> |
|
677 | - <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings['email-placeholder']; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
676 | + <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'email-label' ]; ?></label> |
|
677 | + <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings[ 'email-placeholder' ]; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
678 | 678 | </div> |
679 | 679 | <?php } ?> |
680 | 680 | <div class='gv-note-subject-container'> |
681 | - <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings['subject-label']; ?></label> |
|
682 | - <input type="text" name="gv-note-subject" placeholder="<?php echo $strings['subject']; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
681 | + <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'subject-label' ]; ?></label> |
|
682 | + <input type="text" name="gv-note-subject" placeholder="<?php echo $strings[ 'subject' ]; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
683 | 683 | </div> |
684 | 684 | </fieldset> |
685 | 685 | </div> |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | */ |
703 | 703 | private function maybe_send_entry_notes( $note = false, $entry, $data ) { |
704 | 704 | |
705 | - if( ! $note || ! GVCommon::has_cap('gravityview_email_entry_notes') ) { |
|
705 | + if ( ! $note || ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
706 | 706 | do_action( 'gravityview_log_debug', __METHOD__ . ': User doesnt have "gravityview_email_entry_notes" cap, or $note is empty', $note ); |
707 | 707 | return; |
708 | 708 | } |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | do_action( 'gravityview_log_debug', __METHOD__ . ': $data', $data ); |
711 | 711 | |
712 | 712 | //emailing notes if configured |
713 | - if ( ! empty( $data['gv-note-to'] ) ) { |
|
713 | + if ( ! empty( $data[ 'gv-note-to' ] ) ) { |
|
714 | 714 | |
715 | 715 | $default_data = array( |
716 | 716 | 'gv-note-to' => '', |
@@ -720,11 +720,11 @@ discard block |
||
720 | 720 | 'current-url' => '', |
721 | 721 | ); |
722 | 722 | |
723 | - $current_user = wp_get_current_user(); |
|
723 | + $current_user = wp_get_current_user(); |
|
724 | 724 | $email_data = wp_parse_args( $data, $default_data ); |
725 | 725 | |
726 | - $from = $current_user->user_email; |
|
727 | - $to = $email_data['gv-note-to']; |
|
726 | + $from = $current_user->user_email; |
|
727 | + $to = $email_data[ 'gv-note-to' ]; |
|
728 | 728 | |
729 | 729 | /** |
730 | 730 | * Documented in get_note_email_fields |
@@ -732,8 +732,8 @@ discard block |
||
732 | 732 | */ |
733 | 733 | $include_custom = apply_filters( 'gravityview/field/notes/custom-email', true ); |
734 | 734 | |
735 | - if( 'custom' === $to && $include_custom ) { |
|
736 | - $to = $email_data['gv-note-to-custom']; |
|
735 | + if ( 'custom' === $to && $include_custom ) { |
|
736 | + $to = $email_data[ 'gv-note-to-custom' ]; |
|
737 | 737 | do_action( 'gravityview_log_debug', __METHOD__ . ': Sending note to a custom email address: ' . $to ); |
738 | 738 | } |
739 | 739 | |
@@ -744,13 +744,13 @@ discard block |
||
744 | 744 | |
745 | 745 | $bcc = false; |
746 | 746 | $reply_to = $from; |
747 | - $subject = trim( $email_data['gv-note-subject'] ); |
|
747 | + $subject = trim( $email_data[ 'gv-note-subject' ] ); |
|
748 | 748 | |
749 | 749 | // We use empty() here because GF uses empty to check against, too. `0` isn't a valid subject to GF |
750 | 750 | $subject = empty( $subject ) ? self::strings( 'default-email-subject' ) : $subject; |
751 | - $message = $email_data['gv-note-content']; |
|
751 | + $message = $email_data[ 'gv-note-content' ]; |
|
752 | 752 | $email_footer = self::strings( 'email-footer' ); |
753 | - $from_name = $current_user->display_name; |
|
753 | + $from_name = $current_user->display_name; |
|
754 | 754 | $message_format = 'html'; |
755 | 755 | |
756 | 756 | /** |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | |
782 | 782 | GVCommon::send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, '', $entry, false ); |
783 | 783 | |
784 | - $form = isset( $entry['form_id'] ) ? GFAPI::get_form( $entry['form_id'] ) : array(); |
|
784 | + $form = isset( $entry[ 'form_id' ] ) ? GFAPI::get_form( $entry[ 'form_id' ] ) : array(); |
|
785 | 785 | |
786 | 786 | /** |
787 | 787 | * @see https://www.gravityhelp.com/documentation/article/10146-2/ It's here for compatibility with Gravity Forms |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | |
808 | 808 | $output = ''; |
809 | 809 | |
810 | - if( ! empty( $email_footer ) ) { |
|
810 | + if ( ! empty( $email_footer ) ) { |
|
811 | 811 | $url = rgar( $email_data, 'current-url' ); |
812 | 812 | $url = html_entity_decode( $url ); |
813 | 813 | $url = site_url( $url ); |