@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | add_filter( 'gravityview_field_entry_value_workflow_step', array( $this, 'modify_entry_value_workflow_step' ), 10, 4 ); |
| 39 | 39 | |
| 40 | - add_filter( 'gravityview/search/searchable_fields', array( $this, 'modify_search_fields_workflow_steps'), 10, 2 ); |
|
| 40 | + add_filter( 'gravityview/search/searchable_fields', array( $this, 'modify_search_fields_workflow_steps' ), 10, 2 ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function modify_entry_value_workflow_final_status( $output, $entry, $field_settings, $field ) { |
| 58 | 58 | |
| 59 | - if( ! empty( $output ) ) { |
|
| 59 | + if ( ! empty( $output ) ) { |
|
| 60 | 60 | $output = gravity_flow()->translate_status_label( $output ); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | function modify_entry_value_workflow_step( $output, $entry, $field_settings, $field ) { |
| 81 | 81 | |
| 82 | 82 | // If not set, the entry hasn't started a workflow |
| 83 | - $has_workflow_step = isset( $entry['workflow_step'] ); |
|
| 83 | + $has_workflow_step = isset( $entry[ 'workflow_step' ] ); |
|
| 84 | 84 | |
| 85 | - if( $has_workflow_step ) { |
|
| 85 | + if ( $has_workflow_step ) { |
|
| 86 | 86 | |
| 87 | - $GFlow = new Gravity_Flow_API( $entry['form_id'] ); |
|
| 87 | + $GFlow = new Gravity_Flow_API( $entry[ 'form_id' ] ); |
|
| 88 | 88 | |
| 89 | 89 | if ( $current_step = $GFlow->get_current_step( $entry ) ) { |
| 90 | 90 | $output = esc_html( $current_step->get_name() ); |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | function modify_search_fields_workflow_steps( $fields, $form_id ) { |
| 114 | 114 | |
| 115 | 115 | $GFlow = new Gravity_Flow_API( $form_id ); |
| 116 | - if( $GFlow ): |
|
| 116 | + if ( $GFlow ): |
|
| 117 | 117 | $workflow_steps = $GFlow->get_steps(); |
| 118 | 118 | |
| 119 | - if( $workflow_steps ): |
|
| 119 | + if ( $workflow_steps ): |
|
| 120 | 120 | |
| 121 | 121 | $display_steps = array(); |
| 122 | 122 | |
| 123 | - foreach($workflow_steps as $step): |
|
| 124 | - $display_steps[] = array( "text" => $step->get_name(), "value" => $step->get_id() ); |
|
| 123 | + foreach ( $workflow_steps as $step ): |
|
| 124 | + $display_steps[ ] = array( "text" => $step->get_name(), "value" => $step->get_id() ); |
|
| 125 | 125 | endforeach; |
| 126 | 126 | |
| 127 | 127 | $workflow_step_type = array( |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | ); |
| 133 | 133 | |
| 134 | 134 | |
| 135 | - error_log( print_r( $workflow_step_type, true) ); |
|
| 135 | + error_log( print_r( $workflow_step_type, true ) ); |
|
| 136 | 136 | |
| 137 | - $fields[] = $workflow_step_type; |
|
| 137 | + $fields[ ] = $workflow_step_type; |
|
| 138 | 138 | |
| 139 | 139 | endif; |
| 140 | 140 | |
@@ -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 |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 150 | 150 | $script_source = empty( $script_min ) ? '/source' : ''; |
| 151 | 151 | |
| 152 | - 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 ); |
|
| 152 | + 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 ); |
|
| 153 | 153 | |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
| 205 | 205 | */ |
| 206 | 206 | public function register_no_conflict( $allowed ) { |
| 207 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
| 207 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
| 208 | 208 | return $allowed; |
| 209 | 209 | } |
| 210 | 210 | |
@@ -217,24 +217,24 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public static function get_searchable_fields() { |
| 219 | 219 | |
| 220 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 220 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 221 | 221 | exit( '0' ); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | $form = ''; |
| 225 | 225 | |
| 226 | 226 | // Fetch the form for the current View |
| 227 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
| 227 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
| 228 | 228 | |
| 229 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 229 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
| 230 | 230 | |
| 231 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
| 231 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
| 232 | 232 | |
| 233 | - $form = (int) $_POST['formid']; |
|
| 233 | + $form = (int)$_POST[ 'formid' ]; |
|
| 234 | 234 | |
| 235 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 235 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 236 | 236 | |
| 237 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 237 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 238 | 238 | |
| 239 | 239 | } |
| 240 | 240 | |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | ) |
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 283 | - $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'] ); |
|
| 282 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 283 | + $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' ] ); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Get fields with sub-inputs and no parent |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | foreach ( $fields as $id => $field ) { |
| 304 | 304 | |
| 305 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 305 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 306 | 306 | continue; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
| 309 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
| 310 | 310 | |
| 311 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
| 311 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | public static function get_search_input_types( $id = '', $field_type = null ) { |
| 331 | 331 | |
| 332 | 332 | // @todo - This needs to be improved - many fields have . including products and addresses |
| 333 | - if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
| 333 | + if ( false !== strpos( (string)$id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
| 334 | 334 | $input_type = 'boolean'; // on/off checkbox |
| 335 | 335 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
| 336 | 336 | $input_type = 'multi'; //multiselect |
@@ -372,19 +372,19 @@ discard block |
||
| 372 | 372 | $post_id = 0; |
| 373 | 373 | |
| 374 | 374 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
| 375 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
| 376 | - $post_id = absint( $widget_args['post_id'] ); |
|
| 375 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
| 376 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
| 377 | 377 | } |
| 378 | 378 | // We're in the WordPress Widget context, and the base View ID should be used |
| 379 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
| 380 | - $post_id = absint( $widget_args['view_id'] ); |
|
| 379 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
| 380 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | $args = gravityview_get_permalink_query_args( $post_id ); |
| 384 | 384 | |
| 385 | 385 | // Add hidden fields to the search form |
| 386 | 386 | foreach ( $args as $key => $value ) { |
| 387 | - $search_fields[] = array( |
|
| 387 | + $search_fields[ ] = array( |
|
| 388 | 388 | 'name' => $key, |
| 389 | 389 | 'input' => 'hidden', |
| 390 | 390 | 'value' => $value, |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | public function filter_entries( $search_criteria ) { |
| 407 | 407 | |
| 408 | - if( 'post' === $this->search_method ) { |
|
| 408 | + if ( 'post' === $this->search_method ) { |
|
| 409 | 409 | $get = $_POST; |
| 410 | 410 | } else { |
| 411 | 411 | $get = $_GET; |
@@ -422,15 +422,15 @@ discard block |
||
| 422 | 422 | $get = gv_map_deep( $get, 'urldecode' ); |
| 423 | 423 | |
| 424 | 424 | // add free search |
| 425 | - if ( ! empty( $get['gv_search'] ) ) { |
|
| 425 | + if ( ! empty( $get[ 'gv_search' ] ) ) { |
|
| 426 | 426 | |
| 427 | 427 | // Search for a piece |
| 428 | - $words = explode( ' ', $get['gv_search'] ); |
|
| 428 | + $words = explode( ' ', $get[ 'gv_search' ] ); |
|
| 429 | 429 | |
| 430 | 430 | $words = array_filter( $words ); |
| 431 | 431 | |
| 432 | 432 | foreach ( $words as $word ) { |
| 433 | - $search_criteria['field_filters'][] = array( |
|
| 433 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 434 | 434 | 'key' => null, // The field ID to search |
| 435 | 435 | 'value' => $word, // The value to search |
| 436 | 436 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | //start date & end date |
| 442 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
| 443 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
| 442 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
| 443 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
| 444 | 444 | |
| 445 | 445 | /** |
| 446 | 446 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -455,16 +455,16 @@ discard block |
||
| 455 | 455 | /** |
| 456 | 456 | * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries) |
| 457 | 457 | */ |
| 458 | - if( !empty( $curr_start ) ) { |
|
| 459 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 458 | + if ( ! empty( $curr_start ) ) { |
|
| 459 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 460 | 460 | } |
| 461 | - if( !empty( $curr_end ) ) { |
|
| 462 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 461 | + if ( ! empty( $curr_end ) ) { |
|
| 462 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // search for a specific entry ID |
| 466 | 466 | if ( ! empty( $get[ 'gv_id' ] ) ) { |
| 467 | - $search_criteria['field_filters'][] = array( |
|
| 467 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 468 | 468 | 'key' => 'id', |
| 469 | 469 | 'value' => absint( $get[ 'gv_id' ] ), |
| 470 | 470 | 'operator' => '=', |
@@ -473,36 +473,36 @@ discard block |
||
| 473 | 473 | |
| 474 | 474 | // search for a specific Created_by ID |
| 475 | 475 | if ( ! empty( $get[ 'gv_by' ] ) ) { |
| 476 | - $search_criteria['field_filters'][] = array( |
|
| 476 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 477 | 477 | 'key' => 'created_by', |
| 478 | - 'value' => absint( $get['gv_by'] ), |
|
| 478 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
| 479 | 479 | 'operator' => '=', |
| 480 | 480 | ); |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | |
| 484 | 484 | // Get search mode passed in URL |
| 485 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
| 485 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
| 486 | 486 | |
| 487 | 487 | // get the other search filters |
| 488 | 488 | foreach ( $get as $key => $value ) { |
| 489 | 489 | |
| 490 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
| 490 | + if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[ 0 ] ) ) ) { |
|
| 491 | 491 | continue; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | // could return simple filter or multiple filters |
| 495 | 495 | $filter = $this->prepare_field_filter( $key, $value ); |
| 496 | 496 | |
| 497 | - if ( isset( $filter[0]['value'] ) ) { |
|
| 498 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
| 497 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
| 498 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
| 499 | 499 | |
| 500 | 500 | // if date range type, set search mode to ALL |
| 501 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 501 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 502 | 502 | $mode = 'all'; |
| 503 | 503 | } |
| 504 | - } elseif( !empty( $filter ) ) { |
|
| 505 | - $search_criteria['field_filters'][] = $filter; |
|
| 504 | + } elseif ( ! empty( $filter ) ) { |
|
| 505 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | * @since 1.5.1 |
| 512 | 512 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
| 513 | 513 | */ |
| 514 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 514 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 515 | 515 | |
| 516 | 516 | do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
| 517 | 517 | |
@@ -549,11 +549,11 @@ discard block |
||
| 549 | 549 | 'value' => $value, |
| 550 | 550 | ); |
| 551 | 551 | |
| 552 | - switch ( $form_field['type'] ) { |
|
| 552 | + switch ( $form_field[ 'type' ] ) { |
|
| 553 | 553 | |
| 554 | 554 | case 'select': |
| 555 | 555 | case 'radio': |
| 556 | - $filter['operator'] = 'is'; |
|
| 556 | + $filter[ 'operator' ] = 'is'; |
|
| 557 | 557 | break; |
| 558 | 558 | |
| 559 | 559 | case 'post_category': |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | |
| 568 | 568 | foreach ( $value as $val ) { |
| 569 | 569 | $cat = get_term( $val, 'category' ); |
| 570 | - $filter[] = array( |
|
| 570 | + $filter[ ] = array( |
|
| 571 | 571 | 'key' => $field_id, |
| 572 | 572 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
| 573 | 573 | 'operator' => 'is', |
@@ -586,18 +586,18 @@ discard block |
||
| 586 | 586 | $filter = array(); |
| 587 | 587 | |
| 588 | 588 | foreach ( $value as $val ) { |
| 589 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
| 589 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | break; |
| 593 | 593 | |
| 594 | 594 | case 'checkbox': |
| 595 | 595 | // convert checkbox on/off into the correct search filter |
| 596 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
| 597 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
| 598 | - if ( $input['id'] == $field_id ) { |
|
| 599 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
| 600 | - $filter['operator'] = 'is'; |
|
| 596 | + if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) { |
|
| 597 | + foreach ( $form_field[ 'inputs' ] as $k => $input ) { |
|
| 598 | + if ( $input[ 'id' ] == $field_id ) { |
|
| 599 | + $filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ]; |
|
| 600 | + $filter[ 'operator' ] = 'is'; |
|
| 601 | 601 | break; |
| 602 | 602 | } |
| 603 | 603 | } |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | $filter = array(); |
| 608 | 608 | |
| 609 | 609 | foreach ( $value as $val ) { |
| 610 | - $filter[] = array( |
|
| 610 | + $filter[ ] = array( |
|
| 611 | 611 | 'key' => $field_id, |
| 612 | 612 | 'value' => $val, |
| 613 | 613 | 'operator' => 'is', |
@@ -628,9 +628,9 @@ discard block |
||
| 628 | 628 | foreach ( $words as $word ) { |
| 629 | 629 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
| 630 | 630 | // Keep the same key for each filter |
| 631 | - $filter['value'] = $word; |
|
| 631 | + $filter[ 'value' ] = $word; |
|
| 632 | 632 | // Add a search for the value |
| 633 | - $filters[] = $filter; |
|
| 633 | + $filters[ ] = $filter; |
|
| 634 | 634 | } |
| 635 | 635 | } |
| 636 | 636 | |
@@ -657,19 +657,19 @@ discard block |
||
| 657 | 657 | * @since 1.16.3 |
| 658 | 658 | * Safeguard until GF implements '<=' operator |
| 659 | 659 | */ |
| 660 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 660 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 661 | 661 | $operator = '<'; |
| 662 | 662 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - $filter[] = array( |
|
| 665 | + $filter[ ] = array( |
|
| 666 | 666 | 'key' => $field_id, |
| 667 | 667 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
| 668 | 668 | 'operator' => $operator, |
| 669 | 669 | ); |
| 670 | 670 | } |
| 671 | 671 | } else { |
| 672 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 672 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | break; |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | 'ymd_dot' => 'Y.m.d', |
| 701 | 701 | ); |
| 702 | 702 | |
| 703 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 703 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
| 704 | 704 | $format = $datepicker[ $field->dateFormat ]; |
| 705 | 705 | } |
| 706 | 706 | |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | public function add_template_path( $file_paths ) { |
| 732 | 732 | |
| 733 | 733 | // Index 100 is the default GravityView template path. |
| 734 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 734 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
| 735 | 735 | |
| 736 | 736 | return $file_paths; |
| 737 | 737 | } |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | // get configured search fields |
| 757 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 757 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
| 758 | 758 | |
| 759 | 759 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
| 760 | 760 | do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
@@ -768,27 +768,27 @@ discard block |
||
| 768 | 768 | |
| 769 | 769 | $updated_field = $field; |
| 770 | 770 | |
| 771 | - if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) { |
|
| 771 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range' ) ) ) { |
|
| 772 | 772 | $has_date = true; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | $updated_field = $this->get_search_filter_details( $updated_field ); |
| 776 | 776 | |
| 777 | 777 | |
| 778 | - error_log("Field:Field = " . print_r($field['field'], true)); |
|
| 778 | + error_log( "Field:Field = " . print_r( $field[ 'field' ], true ) ); |
|
| 779 | 779 | |
| 780 | - switch ( $field['field'] ) { |
|
| 780 | + switch ( $field[ 'field' ] ) { |
|
| 781 | 781 | |
| 782 | 782 | case 'search_all': |
| 783 | - $updated_field['key'] = 'search_all'; |
|
| 784 | - $updated_field['input'] = 'search_all'; |
|
| 785 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 783 | + $updated_field[ 'key' ] = 'search_all'; |
|
| 784 | + $updated_field[ 'input' ] = 'search_all'; |
|
| 785 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 786 | 786 | break; |
| 787 | 787 | |
| 788 | 788 | case 'entry_date': |
| 789 | - $updated_field['key'] = 'entry_date'; |
|
| 790 | - $updated_field['input'] = 'entry_date'; |
|
| 791 | - $updated_field['value'] = array( |
|
| 789 | + $updated_field[ 'key' ] = 'entry_date'; |
|
| 790 | + $updated_field[ 'input' ] = 'entry_date'; |
|
| 791 | + $updated_field[ 'value' ] = array( |
|
| 792 | 792 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
| 793 | 793 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
| 794 | 794 | ); |
@@ -796,26 +796,26 @@ discard block |
||
| 796 | 796 | break; |
| 797 | 797 | |
| 798 | 798 | case 'entry_id': |
| 799 | - $updated_field['key'] = 'entry_id'; |
|
| 800 | - $updated_field['input'] = 'entry_id'; |
|
| 801 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 799 | + $updated_field[ 'key' ] = 'entry_id'; |
|
| 800 | + $updated_field[ 'input' ] = 'entry_id'; |
|
| 801 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 802 | 802 | break; |
| 803 | 803 | |
| 804 | 804 | case 'created_by': |
| 805 | - $updated_field['key'] = 'created_by'; |
|
| 806 | - $updated_field['name'] = 'gv_by'; |
|
| 807 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 808 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
| 805 | + $updated_field[ 'key' ] = 'created_by'; |
|
| 806 | + $updated_field[ 'name' ] = 'gv_by'; |
|
| 807 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 808 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
| 809 | 809 | break; |
| 810 | 810 | |
| 811 | 811 | //Hard-coded for test purpose only. |
| 812 | 812 | //Unsure on approach given the need for this to potentially iterate on all custom field types. |
| 813 | 813 | |
| 814 | 814 | case '67': |
| 815 | - $updated_field['key'] = 'workflow_steps'; |
|
| 816 | - $updated_field['name'] = 'gf_steps'; |
|
| 817 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gf_steps' ); |
|
| 818 | - $updated_field['choices'] = array( array( 'text' => 'A', 'value' => 'AValue') ); |
|
| 815 | + $updated_field[ 'key' ] = 'workflow_steps'; |
|
| 816 | + $updated_field[ 'name' ] = 'gf_steps'; |
|
| 817 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gf_steps' ); |
|
| 818 | + $updated_field[ 'choices' ] = array( array( 'text' => 'A', 'value' => 'AValue' ) ); |
|
| 819 | 819 | break; |
| 820 | 820 | } |
| 821 | 821 | |
@@ -833,16 +833,16 @@ discard block |
||
| 833 | 833 | */ |
| 834 | 834 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
| 835 | 835 | |
| 836 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 836 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
| 837 | 837 | |
| 838 | 838 | /** @since 1.14 */ |
| 839 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 839 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
| 840 | 840 | |
| 841 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 841 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 842 | 842 | |
| 843 | 843 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
| 844 | 844 | |
| 845 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 845 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
| 846 | 846 | |
| 847 | 847 | if ( $has_date ) { |
| 848 | 848 | // enqueue datepicker stuff only if needed! |
@@ -864,10 +864,10 @@ discard block |
||
| 864 | 864 | public static function get_search_class( $custom_class = '' ) { |
| 865 | 865 | $gravityview_view = GravityView_View::getInstance(); |
| 866 | 866 | |
| 867 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
| 867 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
| 868 | 868 | |
| 869 | - if ( ! empty( $custom_class ) ) { |
|
| 870 | - $search_class .= ' '.$custom_class; |
|
| 869 | + if ( ! empty( $custom_class ) ) { |
|
| 870 | + $search_class .= ' ' . $custom_class; |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | /** |
@@ -909,11 +909,11 @@ discard block |
||
| 909 | 909 | |
| 910 | 910 | $label = rgget( 'label', $field ); |
| 911 | 911 | |
| 912 | - if( '' === $label ) { |
|
| 912 | + if ( '' === $label ) { |
|
| 913 | 913 | |
| 914 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 914 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
| 915 | 915 | |
| 916 | - switch( $field['field'] ) { |
|
| 916 | + switch ( $field[ 'field' ] ) { |
|
| 917 | 917 | case 'search_all': |
| 918 | 918 | $label = __( 'Search Entries:', 'gravityview' ); |
| 919 | 919 | break; |
@@ -931,10 +931,10 @@ discard block |
||
| 931 | 931 | break; |
| 932 | 932 | default: |
| 933 | 933 | // If this is a field input, not a field |
| 934 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 934 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
| 935 | 935 | |
| 936 | 936 | // Get the label for the field in question, which returns an array |
| 937 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 937 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
| 938 | 938 | |
| 939 | 939 | // Get the item with the `label` key |
| 940 | 940 | $values = wp_list_pluck( $items, 'label' ); |
@@ -971,32 +971,32 @@ discard block |
||
| 971 | 971 | $form = $gravityview_view->getForm(); |
| 972 | 972 | |
| 973 | 973 | // for advanced field ids (eg, first name / last name ) |
| 974 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 974 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
| 975 | 975 | |
| 976 | 976 | // get searched value from $_GET/$_POST (string or array) |
| 977 | 977 | $value = $this->rgget_or_rgpost( $name ); |
| 978 | 978 | |
| 979 | 979 | // get form field details |
| 980 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 980 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
| 981 | 981 | |
| 982 | 982 | $filter = array( |
| 983 | - 'key' => $field['field'], |
|
| 983 | + 'key' => $field[ 'field' ], |
|
| 984 | 984 | 'name' => $name, |
| 985 | 985 | 'label' => self::get_field_label( $field, $form_field ), |
| 986 | - 'input' => $field['input'], |
|
| 986 | + 'input' => $field[ 'input' ], |
|
| 987 | 987 | 'value' => $value, |
| 988 | - 'type' => $form_field['type'], |
|
| 988 | + 'type' => $form_field[ 'type' ], |
|
| 989 | 989 | ); |
| 990 | 990 | |
| 991 | 991 | // collect choices |
| 992 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 993 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
| 994 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 995 | - $filter['choices'] = $form_field['choices']; |
|
| 992 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
| 993 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
| 994 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
| 995 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 999 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 998 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
| 999 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | return $filter; |
@@ -1020,7 +1020,7 @@ discard block |
||
| 1020 | 1020 | |
| 1021 | 1021 | $choices = array(); |
| 1022 | 1022 | foreach ( $users as $user ) { |
| 1023 | - $choices[] = array( |
|
| 1023 | + $choices[ ] = array( |
|
| 1024 | 1024 | 'value' => $user->ID, |
| 1025 | 1025 | 'text' => $user->display_name, |
| 1026 | 1026 | ); |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | */ |
| 1076 | 1076 | public function add_datepicker_js_dependency( $js_dependencies ) { |
| 1077 | 1077 | |
| 1078 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
| 1078 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
| 1079 | 1079 | |
| 1080 | 1080 | return $js_dependencies; |
| 1081 | 1081 | } |
@@ -1119,7 +1119,7 @@ discard block |
||
| 1119 | 1119 | 'isRTL' => is_rtl(), |
| 1120 | 1120 | ), $view_data ); |
| 1121 | 1121 | |
| 1122 | - $localizations['datepicker'] = $datepicker_settings; |
|
| 1122 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
| 1123 | 1123 | |
| 1124 | 1124 | return $localizations; |
| 1125 | 1125 | |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | * @return void |
| 1149 | 1149 | */ |
| 1150 | 1150 | private function maybe_enqueue_flexibility() { |
| 1151 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 1151 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
| 1152 | 1152 | wp_enqueue_script( 'gv-flexibility' ); |
| 1153 | 1153 | } |
| 1154 | 1154 | } |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
| 1171 | 1171 | |
| 1172 | 1172 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 1173 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1173 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1174 | 1174 | |
| 1175 | 1175 | /** |
| 1176 | 1176 | * @filter `gravityview_search_datepicker_class` |