@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | add_filter( 'gravityview/sortable/field_blacklist', array( $this, '_filter_sortable_fields' ), 1 ); |
| 116 | 116 | |
| 117 | - if( $this->_custom_merge_tag ) { |
|
| 117 | + if ( $this->_custom_merge_tag ) { |
|
| 118 | 118 | add_filter( 'gform_custom_merge_tags', array( $this, '_filter_gform_custom_merge_tags' ), 10, 4 ); |
| 119 | 119 | add_filter( 'gform_replace_merge_tags', array( $this, '_filter_gform_replace_merge_tags' ), 10, 7 ); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if( 'meta' === $this->group || '' !== $this->default_search_label ) { |
|
| 122 | + if ( 'meta' === $this->group || '' !== $this->default_search_label ) { |
|
| 123 | 123 | add_filter( 'gravityview_search_field_label', array( $this, 'set_default_search_label' ), 10, 3 ); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | function set_default_search_label( $label = '', $gf_field = null, $field = array() ) { |
| 143 | 143 | |
| 144 | - if( $this->name === $field['field'] && '' === $label ) { |
|
| 144 | + if ( $this->name === $field[ 'field' ] && '' === $label ) { |
|
| 145 | 145 | $label = esc_html( $this->default_search_label ); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return string Original text if {_custom_merge_tag} isn't found. Otherwise, replaced text. |
| 164 | 164 | */ |
| 165 | - public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
| 165 | + public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | 168 | * This prevents the gform_replace_merge_tags filter from being called twice, as defined in: |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @see GFCommon::replace_variables_prepopulate() |
| 171 | 171 | * @todo Remove eventually: Gravity Forms fixed this issue in 1.9.14 |
| 172 | 172 | */ |
| 173 | - if( false === $form ) { |
|
| 173 | + if ( false === $form ) { |
|
| 174 | 174 | return $text; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -203,19 +203,19 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
| 205 | 205 | |
| 206 | - foreach( $matches as $match ) { |
|
| 206 | + foreach ( $matches as $match ) { |
|
| 207 | 207 | |
| 208 | - $full_tag = $match[0]; |
|
| 208 | + $full_tag = $match[ 0 ]; |
|
| 209 | 209 | |
| 210 | 210 | // Strip the Merge Tags |
| 211 | - $tag = str_replace( array( '{', '}'), '', $full_tag ); |
|
| 211 | + $tag = str_replace( array( '{', '}' ), '', $full_tag ); |
|
| 212 | 212 | |
| 213 | 213 | // Replace the value from the entry, if exists |
| 214 | - if( isset( $entry[ $tag ] ) ) { |
|
| 214 | + if ( isset( $entry[ $tag ] ) ) { |
|
| 215 | 215 | |
| 216 | 216 | $value = $entry[ $tag ]; |
| 217 | 217 | |
| 218 | - if( is_callable( array( $this, 'get_content') ) ) { |
|
| 218 | + if ( is_callable( array( $this, 'get_content' ) ) ) { |
|
| 219 | 219 | $value = $this->get_content( $value ); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -288,8 +288,8 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | public function _filter_sortable_fields( $not_sortable ) { |
| 290 | 290 | |
| 291 | - if( ! $this->is_sortable ) { |
|
| 292 | - $not_sortable[] = $this->name; |
|
| 291 | + if ( ! $this->is_sortable ) { |
|
| 292 | + $not_sortable[ ] = $this->name; |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | return $not_sortable; |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | 'date_display' => array( |
| 319 | 319 | 'type' => 'text', |
| 320 | 320 | 'label' => __( 'Override Date Format', 'gravityview' ), |
| 321 | - 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview'), '<a href="https://codex.wordpress.org/Formatting_Date_and_Time">', '</a>' ), |
|
| 321 | + 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview' ), '<a href="https://codex.wordpress.org/Formatting_Date_and_Time">', '</a>' ), |
|
| 322 | 322 | /** |
| 323 | 323 | * @filter `gravityview_date_format` Override the date format with a [PHP date format](https://codex.wordpress.org/Formatting_Date_and_Time) |
| 324 | 324 | * @param[in,out] null|string $date_format Date Format (default: null) |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | $options = $this->field_support_options(); |
| 345 | 345 | |
| 346 | - if( isset( $options[ $key ] ) ) { |
|
| 346 | + if ( isset( $options[ $key ] ) ) { |
|
| 347 | 347 | $field_options[ $key ] = $options[ $key ]; |
| 348 | 348 | } |
| 349 | 349 | |
@@ -407,11 +407,11 @@ discard block |
||
| 407 | 407 | $connected_form = rgpost( 'form_id' ); |
| 408 | 408 | |
| 409 | 409 | // Otherwise, get the Form ID from the Post page |
| 410 | - if( empty( $connected_form ) ) { |
|
| 410 | + if ( empty( $connected_form ) ) { |
|
| 411 | 411 | $connected_form = gravityview_get_form_id( get_the_ID() ); |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - if( empty( $connected_form ) ) { |
|
| 414 | + if ( empty( $connected_form ) ) { |
|
| 415 | 415 | do_action( 'gravityview_log_error', sprintf( '%s: Form not found for form ID "%s"', __METHOD__, $connected_form ) ); |
| 416 | 416 | return false; |
| 417 | 417 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function modify_entry_value_workflow_final_status( $output, $entry, $field_settings, $field ) { |
| 43 | 43 | |
| 44 | - if( ! empty( $output ) ) { |
|
| 44 | + if ( ! empty( $output ) ) { |
|
| 45 | 45 | $output = gravity_flow()->translate_status_label( $output ); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | function modify_search_filters( $search_fields = array(), GravityView_Widget_Search $widget, $widget_args = array() ) { |
| 60 | 60 | |
| 61 | 61 | foreach ( $search_fields as & $search_field ) { |
| 62 | - if ( $this->name === $search_field['key'] ) { |
|
| 63 | - $search_field['choices'] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options(); |
|
| 62 | + if ( $this->name === $search_field[ 'key' ] ) { |
|
| 63 | + $search_field[ 'choices' ] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options(); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -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, 'rawurldecode' ); |
| 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 | |
@@ -551,11 +551,11 @@ discard block |
||
| 551 | 551 | 'value' => $value, |
| 552 | 552 | ); |
| 553 | 553 | |
| 554 | - switch ( $form_field['type'] ) { |
|
| 554 | + switch ( $form_field[ 'type' ] ) { |
|
| 555 | 555 | |
| 556 | 556 | case 'select': |
| 557 | 557 | case 'radio': |
| 558 | - $filter['operator'] = 'is'; |
|
| 558 | + $filter[ 'operator' ] = 'is'; |
|
| 559 | 559 | break; |
| 560 | 560 | |
| 561 | 561 | case 'post_category': |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | |
| 570 | 570 | foreach ( $value as $val ) { |
| 571 | 571 | $cat = get_term( $val, 'category' ); |
| 572 | - $filter[] = array( |
|
| 572 | + $filter[ ] = array( |
|
| 573 | 573 | 'key' => $field_id, |
| 574 | 574 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
| 575 | 575 | 'operator' => 'is', |
@@ -588,18 +588,18 @@ discard block |
||
| 588 | 588 | $filter = array(); |
| 589 | 589 | |
| 590 | 590 | foreach ( $value as $val ) { |
| 591 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
| 591 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | break; |
| 595 | 595 | |
| 596 | 596 | case 'checkbox': |
| 597 | 597 | // convert checkbox on/off into the correct search filter |
| 598 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
| 599 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
| 600 | - if ( $input['id'] == $field_id ) { |
|
| 601 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
| 602 | - $filter['operator'] = 'is'; |
|
| 598 | + if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) { |
|
| 599 | + foreach ( $form_field[ 'inputs' ] as $k => $input ) { |
|
| 600 | + if ( $input[ 'id' ] == $field_id ) { |
|
| 601 | + $filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ]; |
|
| 602 | + $filter[ 'operator' ] = 'is'; |
|
| 603 | 603 | break; |
| 604 | 604 | } |
| 605 | 605 | } |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | $filter = array(); |
| 610 | 610 | |
| 611 | 611 | foreach ( $value as $val ) { |
| 612 | - $filter[] = array( |
|
| 612 | + $filter[ ] = array( |
|
| 613 | 613 | 'key' => $field_id, |
| 614 | 614 | 'value' => $val, |
| 615 | 615 | 'operator' => 'is', |
@@ -630,9 +630,9 @@ discard block |
||
| 630 | 630 | foreach ( $words as $word ) { |
| 631 | 631 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
| 632 | 632 | // Keep the same key for each filter |
| 633 | - $filter['value'] = $word; |
|
| 633 | + $filter[ 'value' ] = $word; |
|
| 634 | 634 | // Add a search for the value |
| 635 | - $filters[] = $filter; |
|
| 635 | + $filters[ ] = $filter; |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | |
@@ -659,19 +659,19 @@ discard block |
||
| 659 | 659 | * @since 1.16.3 |
| 660 | 660 | * Safeguard until GF implements '<=' operator |
| 661 | 661 | */ |
| 662 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 662 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 663 | 663 | $operator = '<'; |
| 664 | 664 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - $filter[] = array( |
|
| 667 | + $filter[ ] = array( |
|
| 668 | 668 | 'key' => $field_id, |
| 669 | 669 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
| 670 | 670 | 'operator' => $operator, |
| 671 | 671 | ); |
| 672 | 672 | } |
| 673 | 673 | } else { |
| 674 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 674 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | break; |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | 'ymd_dot' => 'Y.m.d', |
| 703 | 703 | ); |
| 704 | 704 | |
| 705 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 705 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
| 706 | 706 | $format = $datepicker[ $field->dateFormat ]; |
| 707 | 707 | } |
| 708 | 708 | |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | public function add_template_path( $file_paths ) { |
| 734 | 734 | |
| 735 | 735 | // Index 100 is the default GravityView template path. |
| 736 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 736 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
| 737 | 737 | |
| 738 | 738 | return $file_paths; |
| 739 | 739 | } |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | // get configured search fields |
| 759 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 759 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
| 760 | 760 | |
| 761 | 761 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
| 762 | 762 | do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
@@ -770,26 +770,26 @@ discard block |
||
| 770 | 770 | |
| 771 | 771 | $updated_field = $field; |
| 772 | 772 | |
| 773 | - if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) { |
|
| 773 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range' ) ) ) { |
|
| 774 | 774 | $has_date = true; |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | $updated_field = $this->get_search_filter_details( $updated_field ); |
| 778 | 778 | |
| 779 | - error_log("Field:Field = " . print_r($field['field'], true)); |
|
| 779 | + error_log( "Field:Field = " . print_r( $field[ 'field' ], true ) ); |
|
| 780 | 780 | |
| 781 | - switch ( $field['field'] ) { |
|
| 781 | + switch ( $field[ 'field' ] ) { |
|
| 782 | 782 | |
| 783 | 783 | case 'search_all': |
| 784 | - $updated_field['key'] = 'search_all'; |
|
| 785 | - $updated_field['input'] = 'search_all'; |
|
| 786 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 784 | + $updated_field[ 'key' ] = 'search_all'; |
|
| 785 | + $updated_field[ 'input' ] = 'search_all'; |
|
| 786 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 787 | 787 | break; |
| 788 | 788 | |
| 789 | 789 | case 'entry_date': |
| 790 | - $updated_field['key'] = 'entry_date'; |
|
| 791 | - $updated_field['input'] = 'entry_date'; |
|
| 792 | - $updated_field['value'] = array( |
|
| 790 | + $updated_field[ 'key' ] = 'entry_date'; |
|
| 791 | + $updated_field[ 'input' ] = 'entry_date'; |
|
| 792 | + $updated_field[ 'value' ] = array( |
|
| 793 | 793 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
| 794 | 794 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
| 795 | 795 | ); |
@@ -797,16 +797,16 @@ discard block |
||
| 797 | 797 | break; |
| 798 | 798 | |
| 799 | 799 | case 'entry_id': |
| 800 | - $updated_field['key'] = 'entry_id'; |
|
| 801 | - $updated_field['input'] = 'entry_id'; |
|
| 802 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 800 | + $updated_field[ 'key' ] = 'entry_id'; |
|
| 801 | + $updated_field[ 'input' ] = 'entry_id'; |
|
| 802 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 803 | 803 | break; |
| 804 | 804 | |
| 805 | 805 | case 'created_by': |
| 806 | - $updated_field['key'] = 'created_by'; |
|
| 807 | - $updated_field['name'] = 'gv_by'; |
|
| 808 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 809 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
| 806 | + $updated_field[ 'key' ] = 'created_by'; |
|
| 807 | + $updated_field[ 'name' ] = 'gv_by'; |
|
| 808 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 809 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
| 810 | 810 | break; |
| 811 | 811 | } |
| 812 | 812 | |
@@ -824,16 +824,16 @@ discard block |
||
| 824 | 824 | */ |
| 825 | 825 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
| 826 | 826 | |
| 827 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 827 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
| 828 | 828 | |
| 829 | 829 | /** @since 1.14 */ |
| 830 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 830 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
| 831 | 831 | |
| 832 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 832 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 833 | 833 | |
| 834 | 834 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
| 835 | 835 | |
| 836 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 836 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
| 837 | 837 | |
| 838 | 838 | if ( $has_date ) { |
| 839 | 839 | // enqueue datepicker stuff only if needed! |
@@ -855,10 +855,10 @@ discard block |
||
| 855 | 855 | public static function get_search_class( $custom_class = '' ) { |
| 856 | 856 | $gravityview_view = GravityView_View::getInstance(); |
| 857 | 857 | |
| 858 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
| 858 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
| 859 | 859 | |
| 860 | - if ( ! empty( $custom_class ) ) { |
|
| 861 | - $search_class .= ' '.$custom_class; |
|
| 860 | + if ( ! empty( $custom_class ) ) { |
|
| 861 | + $search_class .= ' ' . $custom_class; |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | /** |
@@ -900,11 +900,11 @@ discard block |
||
| 900 | 900 | |
| 901 | 901 | $label = rgget( 'label', $field ); |
| 902 | 902 | |
| 903 | - if( '' === $label ) { |
|
| 903 | + if ( '' === $label ) { |
|
| 904 | 904 | |
| 905 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 905 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
| 906 | 906 | |
| 907 | - switch( $field['field'] ) { |
|
| 907 | + switch ( $field[ 'field' ] ) { |
|
| 908 | 908 | case 'search_all': |
| 909 | 909 | $label = __( 'Search Entries:', 'gravityview' ); |
| 910 | 910 | break; |
@@ -916,10 +916,10 @@ discard block |
||
| 916 | 916 | break; |
| 917 | 917 | default: |
| 918 | 918 | // If this is a field input, not a field |
| 919 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 919 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
| 920 | 920 | |
| 921 | 921 | // Get the label for the field in question, which returns an array |
| 922 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 922 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
| 923 | 923 | |
| 924 | 924 | // Get the item with the `label` key |
| 925 | 925 | $values = wp_list_pluck( $items, 'label' ); |
@@ -958,32 +958,32 @@ discard block |
||
| 958 | 958 | $form = $gravityview_view->getForm(); |
| 959 | 959 | |
| 960 | 960 | // for advanced field ids (eg, first name / last name ) |
| 961 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 961 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
| 962 | 962 | |
| 963 | 963 | // get searched value from $_GET/$_POST (string or array) |
| 964 | 964 | $value = $this->rgget_or_rgpost( $name ); |
| 965 | 965 | |
| 966 | 966 | // get form field details |
| 967 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 967 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
| 968 | 968 | |
| 969 | 969 | $filter = array( |
| 970 | - 'key' => $field['field'], |
|
| 970 | + 'key' => $field[ 'field' ], |
|
| 971 | 971 | 'name' => $name, |
| 972 | 972 | 'label' => self::get_field_label( $field, $form_field ), |
| 973 | - 'input' => $field['input'], |
|
| 973 | + 'input' => $field[ 'input' ], |
|
| 974 | 974 | 'value' => $value, |
| 975 | - 'type' => $form_field['type'], |
|
| 975 | + 'type' => $form_field[ 'type' ], |
|
| 976 | 976 | ); |
| 977 | 977 | |
| 978 | 978 | // collect choices |
| 979 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 980 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
| 981 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 982 | - $filter['choices'] = $form_field['choices']; |
|
| 979 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
| 980 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
| 981 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
| 982 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 986 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 985 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
| 986 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | return $filter; |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | |
| 1008 | 1008 | $choices = array(); |
| 1009 | 1009 | foreach ( $users as $user ) { |
| 1010 | - $choices[] = array( |
|
| 1010 | + $choices[ ] = array( |
|
| 1011 | 1011 | 'value' => $user->ID, |
| 1012 | 1012 | 'text' => $user->display_name, |
| 1013 | 1013 | ); |
@@ -1062,7 +1062,7 @@ discard block |
||
| 1062 | 1062 | */ |
| 1063 | 1063 | public function add_datepicker_js_dependency( $js_dependencies ) { |
| 1064 | 1064 | |
| 1065 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
| 1065 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
| 1066 | 1066 | |
| 1067 | 1067 | return $js_dependencies; |
| 1068 | 1068 | } |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | 'isRTL' => is_rtl(), |
| 1107 | 1107 | ), $view_data ); |
| 1108 | 1108 | |
| 1109 | - $localizations['datepicker'] = $datepicker_settings; |
|
| 1109 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
| 1110 | 1110 | |
| 1111 | 1111 | return $localizations; |
| 1112 | 1112 | |
@@ -1135,7 +1135,7 @@ discard block |
||
| 1135 | 1135 | * @return void |
| 1136 | 1136 | */ |
| 1137 | 1137 | private function maybe_enqueue_flexibility() { |
| 1138 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 1138 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
| 1139 | 1139 | wp_enqueue_script( 'gv-flexibility' ); |
| 1140 | 1140 | } |
| 1141 | 1141 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
| 1158 | 1158 | |
| 1159 | 1159 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 1160 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1160 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1161 | 1161 | |
| 1162 | 1162 | /** |
| 1163 | 1163 | * @filter `gravityview_search_datepicker_class` |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | parent::add_hooks(); |
| 35 | 35 | |
| 36 | - add_filter( 'gravityview/search/searchable_fields', array( $this, 'modify_search_bar_fields_dropdown'), 10, 2 ); |
|
| 36 | + add_filter( 'gravityview/search/searchable_fields', array( $this, 'modify_search_bar_fields_dropdown' ), 10, 2 ); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public static function get_status_options( $form_id = 0, $status_key = 'workflow_final_status' ) { |
| 54 | 54 | |
| 55 | - if( empty( $form_id ) ) { |
|
| 55 | + if ( empty( $form_id ) ) { |
|
| 56 | 56 | $form_id = GravityView_View::getInstance()->getFormId(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $entry_meta = gravity_flow()->get_entry_meta( array(), $form_id ); |
| 60 | 60 | |
| 61 | - return (array) rgars( $entry_meta, $status_key . '/filter/choices' ); |
|
| 61 | + return (array)rgars( $entry_meta, $status_key . '/filter/choices' ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $workflow_steps = $GFlow->get_steps(); |
| 82 | 82 | |
| 83 | - if( $workflow_steps ) { |
|
| 83 | + if ( $workflow_steps ) { |
|
| 84 | 84 | |
| 85 | 85 | foreach ( $workflow_steps as $step ) { |
| 86 | 86 | |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | ); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - $fields['workflow_step'] = array( |
|
| 95 | + $fields[ 'workflow_step' ] = array( |
|
| 96 | 96 | 'label' => esc_html__( 'Workflow Step', 'gravityview' ), |
| 97 | 97 | 'type' => 'select', |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - $fields['workflow_final_status'] = array( |
|
| 100 | + $fields[ 'workflow_final_status' ] = array( |
|
| 101 | 101 | 'label' => esc_html__( 'Workflow Status', 'gravityview' ), |
| 102 | 102 | 'type' => 'select', |
| 103 | 103 | ); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $return = $input_type; |
| 47 | 47 | |
| 48 | - if( 'survey' === $field_type ) { |
|
| 48 | + if ( 'survey' === $field_type ) { |
|
| 49 | 49 | $return = 'select'; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | public function fix_survey_fields( $fields ) { |
| 66 | 66 | |
| 67 | 67 | /** @var GF_Field $field */ |
| 68 | - foreach( $fields as &$field ) { |
|
| 69 | - if( 'survey' === $field->type ) { |
|
| 68 | + foreach ( $fields as &$field ) { |
|
| 69 | + if ( 'survey' === $field->type ) { |
|
| 70 | 70 | $field->allowsPrepopulate = true; |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | 84 | function add_render_hooks() { |
| 85 | - add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10, 3 ); |
|
| 85 | + add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10, 3 ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @return void |
| 96 | 96 | */ |
| 97 | 97 | function remove_render_hooks() { |
| 98 | - remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10 ); |
|
| 98 | + remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10 ); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function fix_survey_field_value( $value, $field, $name ) { |
| 115 | 115 | |
| 116 | - if( 'survey' === $field->type ) { |
|
| 116 | + if ( 'survey' === $field->type ) { |
|
| 117 | 117 | |
| 118 | - $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry(); |
|
| 118 | + $entry = GravityView_Edit_Entry::getInstance()->instances[ 'render' ]->get_entry(); |
|
| 119 | 119 | |
| 120 | 120 | // We need to run through each survey row until we find a match for expected values |
| 121 | 121 | foreach ( $entry as $field_id => $field_value ) { |
@@ -124,11 +124,11 @@ discard block |
||
| 124 | 124 | continue; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
| 127 | + if ( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
| 128 | 128 | list( $row_val, $col_val ) = explode( ':', $field_value, 2 ); |
| 129 | 129 | |
| 130 | 130 | // If the $name matches the $row_val, we are processing the correct row |
| 131 | - if( $row_val === $name ) { |
|
| 131 | + if ( $row_val === $name ) { |
|
| 132 | 132 | $value = $field_value; |
| 133 | 133 | break; |
| 134 | 134 | } |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | private function __construct() {} |
| 86 | 86 | |
| 87 | 87 | private function initialize() { |
| 88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
| 88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
| 89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
| 90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
| 90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
| 91 | 91 | |
| 92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
| 93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -234,15 +234,15 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | $this->context_view_id = $view_id; |
| 236 | 236 | |
| 237 | - } elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
| 237 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
| 238 | 238 | /** |
| 239 | 239 | * used on a has_multiple_views context |
| 240 | 240 | * @see GravityView_API::entry_link |
| 241 | 241 | * @see GravityView_View_Data::getInstance()->has_multiple_views() |
| 242 | 242 | */ |
| 243 | - $this->context_view_id = $_GET['gvid']; |
|
| 243 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
| 244 | 244 | |
| 245 | - } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
| 245 | + } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
| 246 | 246 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
| 247 | 247 | $this->context_view_id = array_pop( $array_keys ); |
| 248 | 248 | unset( $array_keys ); |
@@ -277,23 +277,23 @@ discard block |
||
| 277 | 277 | global $wp_rewrite; |
| 278 | 278 | |
| 279 | 279 | $is_front_page = ( $query->is_home || $query->is_page ); |
| 280 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
| 281 | - $front_page_id = get_option('page_on_front'); |
|
| 280 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
| 281 | + $front_page_id = get_option( 'page_on_front' ); |
|
| 282 | 282 | |
| 283 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
| 283 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
| 284 | 284 | |
| 285 | 285 | // Force to be an array, potentially a query string ( entry=16 ) |
| 286 | 286 | $_query = wp_parse_args( $query->query ); |
| 287 | 287 | |
| 288 | 288 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
| 289 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
| 290 | - unset( $_query['pagename'] ); |
|
| 289 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
| 290 | + unset( $_query[ 'pagename' ] ); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // this is where will break from core wordpress |
| 294 | 294 | $ignore = array( 'preview', 'page', 'paged', 'cpage' ); |
| 295 | 295 | foreach ( $wp_rewrite->endpoints as $endpoint ) { |
| 296 | - $ignore[] = $endpoint[1]; |
|
| 296 | + $ignore[ ] = $endpoint[ 1 ]; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // Modify the query if: |
@@ -302,21 +302,21 @@ discard block |
||
| 302 | 302 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
| 303 | 303 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
| 304 | 304 | |
| 305 | - $qv =& $query->query_vars; |
|
| 305 | + $qv = & $query->query_vars; |
|
| 306 | 306 | |
| 307 | 307 | // Prevent redirect when on the single entry endpoint |
| 308 | - if( self::is_single_entry() ) { |
|
| 308 | + if ( self::is_single_entry() ) { |
|
| 309 | 309 | add_filter( 'redirect_canonical', '__return_false' ); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $query->is_page = true; |
| 313 | 313 | $query->is_home = false; |
| 314 | - $qv['page_id'] = $front_page_id; |
|
| 314 | + $qv[ 'page_id' ] = $front_page_id; |
|
| 315 | 315 | |
| 316 | 316 | // Correct <!--nextpage--> for page_on_front |
| 317 | - if ( ! empty( $qv['paged'] ) ) { |
|
| 318 | - $qv['page'] = $qv['paged']; |
|
| 319 | - unset( $qv['paged'] ); |
|
| 317 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
| 318 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
| 319 | + unset( $qv[ 'paged' ] ); |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | global $post; |
| 335 | 335 | |
| 336 | 336 | // If in admin and NOT AJAX request, get outta here. |
| 337 | - if ( GravityView_Plugin::is_admin() ) { |
|
| 337 | + if ( GravityView_Plugin::is_admin() ) { |
|
| 338 | 338 | return; |
| 339 | 339 | } |
| 340 | 340 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
| 348 | 348 | |
| 349 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
| 349 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
| 350 | 350 | $this->setPostId( $post_id ); |
| 351 | 351 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
| 352 | 352 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | |
| 383 | 383 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
| 384 | 384 | |
| 385 | - if( 'post' === $search_method ) { |
|
| 385 | + if ( 'post' === $search_method ) { |
|
| 386 | 386 | $get = $_POST; |
| 387 | 387 | } else { |
| 388 | 388 | $get = $_GET; |
@@ -438,20 +438,20 @@ discard block |
||
| 438 | 438 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
| 439 | 439 | * @param array $entry Current entry |
| 440 | 440 | */ |
| 441 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
| 441 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
| 442 | 442 | |
| 443 | 443 | if ( ! $apply_outside_loop ) { |
| 444 | 444 | return $title; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | // User reported WooCommerce doesn't pass two args. |
| 448 | - if ( empty( $passed_post_id ) ) { |
|
| 448 | + if ( empty( $passed_post_id ) ) { |
|
| 449 | 449 | return $title; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | // Don't modify the title for anything other than the current view/post. |
| 453 | 453 | // This is true for embedded shortcodes and Views. |
| 454 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
| 454 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
| 455 | 455 | return $title; |
| 456 | 456 | } |
| 457 | 457 | |
@@ -461,19 +461,19 @@ discard block |
||
| 461 | 461 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
| 462 | 462 | } else { |
| 463 | 463 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
| 464 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
| 464 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
| 465 | 465 | $view_meta = $view_data; |
| 466 | 466 | break; |
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
| 471 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
| 472 | 472 | |
| 473 | - $title = $view_meta['atts']['single_title']; |
|
| 473 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
| 474 | 474 | |
| 475 | 475 | // We are allowing HTML in the fields, so no escaping the output |
| 476 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
| 476 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
| 477 | 477 | |
| 478 | 478 | $title = do_shortcode( $title ); |
| 479 | 479 | } |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | public function render_view( $passed_args ) { |
| 575 | 575 | |
| 576 | 576 | // validate attributes |
| 577 | - if ( empty( $passed_args['id'] ) ) { |
|
| 577 | + if ( empty( $passed_args[ 'id' ] ) ) { |
|
| 578 | 578 | do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args ); |
| 579 | 579 | return null; |
| 580 | 580 | } |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | return null; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - $view_id = $passed_args['id']; |
|
| 599 | + $view_id = $passed_args[ 'id' ]; |
|
| 600 | 600 | |
| 601 | 601 | $view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args ); |
| 602 | 602 | |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | $passed_args = array_filter( $passed_args, 'strlen' ); |
| 610 | 610 | |
| 611 | 611 | //Override shortcode args over View template settings |
| 612 | - $atts = wp_parse_args( $passed_args, $view_data['atts'] ); |
|
| 612 | + $atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] ); |
|
| 613 | 613 | |
| 614 | 614 | do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts ); |
| 615 | 615 | |
@@ -632,14 +632,14 @@ discard block |
||
| 632 | 632 | * @since 1.15 |
| 633 | 633 | * @since 1.17.2 Added check for if a user has no caps but is logged in (member of multisite, but not any site). Treat as if logged-out. |
| 634 | 634 | */ |
| 635 | - if( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 635 | + if ( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 636 | 636 | |
| 637 | 637 | do_action( 'gravityview_log_debug', sprintf( '%s Returning: View %d is not visible by current user.', __METHOD__, $view_id ) ); |
| 638 | 638 | |
| 639 | 639 | return null; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - if( $this->isGravityviewPostType() ) { |
|
| 642 | + if ( $this->isGravityviewPostType() ) { |
|
| 643 | 643 | |
| 644 | 644 | /** |
| 645 | 645 | * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode? |
@@ -651,9 +651,9 @@ discard block |
||
| 651 | 651 | */ |
| 652 | 652 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view_id ); |
| 653 | 653 | |
| 654 | - $embed_only = ! empty( $atts['embed_only'] ); |
|
| 654 | + $embed_only = ! empty( $atts[ 'embed_only' ] ); |
|
| 655 | 655 | |
| 656 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
| 656 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
| 657 | 657 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 658 | 658 | } |
| 659 | 659 | } |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | |
| 669 | 669 | $gravityview_view = new GravityView_View( $view_data ); |
| 670 | 670 | |
| 671 | - $post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId(); |
|
| 671 | + $post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : $this->getPostId(); |
|
| 672 | 672 | |
| 673 | 673 | $gravityview_view->setPostId( $post_id ); |
| 674 | 674 | |
@@ -678,20 +678,20 @@ discard block |
||
| 678 | 678 | do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' ); |
| 679 | 679 | |
| 680 | 680 | //fetch template and slug |
| 681 | - $view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' ); |
|
| 681 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'directory' ); |
|
| 682 | 682 | |
| 683 | 683 | do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug ); |
| 684 | 684 | |
| 685 | 685 | /** |
| 686 | 686 | * Disable fetching initial entries for views that don't need it (DataTables) |
| 687 | 687 | */ |
| 688 | - $get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true ); |
|
| 688 | + $get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true ); |
|
| 689 | 689 | |
| 690 | 690 | /** |
| 691 | 691 | * Hide View data until search is performed |
| 692 | 692 | * @since 1.5.4 |
| 693 | 693 | */ |
| 694 | - if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) { |
|
| 694 | + if ( ! empty( $atts[ 'hide_until_searched' ] ) && ! $this->isSearch() ) { |
|
| 695 | 695 | $gravityview_view->setHideUntilSearched( true ); |
| 696 | 696 | $get_entries = false; |
| 697 | 697 | } |
@@ -699,23 +699,23 @@ discard block |
||
| 699 | 699 | |
| 700 | 700 | if ( $get_entries ) { |
| 701 | 701 | |
| 702 | - if ( ! empty( $atts['sort_columns'] ) ) { |
|
| 702 | + if ( ! empty( $atts[ 'sort_columns' ] ) ) { |
|
| 703 | 703 | // add filter to enable column sorting |
| 704 | - add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 ); |
|
| 704 | + add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 ); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - $view_entries = self::get_view_entries( $atts, $view_data['form_id'] ); |
|
| 707 | + $view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] ); |
|
| 708 | 708 | |
| 709 | - do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) ); |
|
| 709 | + do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) ); |
|
| 710 | 710 | |
| 711 | 711 | } else { |
| 712 | 712 | |
| 713 | 713 | $view_entries = array( 'count' => null, 'entries' => null, 'paging' => null ); |
| 714 | 714 | |
| 715 | - do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' ); |
|
| 715 | + do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' ); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - $gravityview_view->setPaging( $view_entries['paging'] ); |
|
| 718 | + $gravityview_view->setPaging( $view_entries[ 'paging' ] ); |
|
| 719 | 719 | $gravityview_view->setContext( 'directory' ); |
| 720 | 720 | $sections = array( 'header', 'body', 'footer' ); |
| 721 | 721 | |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | * @action `gravityview_render_entry_{View ID}` Before rendering a single entry for a specific View ID |
| 730 | 730 | * @since 1.17 |
| 731 | 731 | */ |
| 732 | - do_action( 'gravityview_render_entry_'.$view_data['id'] ); |
|
| 732 | + do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] ); |
|
| 733 | 733 | |
| 734 | 734 | $entry = $this->getEntry(); |
| 735 | 735 | |
@@ -756,20 +756,20 @@ discard block |
||
| 756 | 756 | // We're in single view, but the view being processed is not the same view the single entry belongs to. |
| 757 | 757 | // important: do not remove this as it prevents fake attempts of displaying entries from other views/forms |
| 758 | 758 | if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) { |
| 759 | - do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id ); |
|
| 759 | + do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: ' . $view_id ); |
|
| 760 | 760 | return null; |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | //fetch template and slug |
| 764 | - $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' ); |
|
| 764 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'single' ); |
|
| 765 | 765 | do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug ); |
| 766 | 766 | |
| 767 | 767 | //fetch entry detail |
| 768 | - $view_entries['count'] = 1; |
|
| 769 | - $view_entries['entries'][] = $entry; |
|
| 770 | - do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] ); |
|
| 768 | + $view_entries[ 'count' ] = 1; |
|
| 769 | + $view_entries[ 'entries' ][ ] = $entry; |
|
| 770 | + do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] ); |
|
| 771 | 771 | |
| 772 | - $back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null; |
|
| 772 | + $back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null; |
|
| 773 | 773 | |
| 774 | 774 | // set back link label |
| 775 | 775 | $gravityview_view->setBackLinkLabel( $back_link_label ); |
@@ -779,11 +779,11 @@ discard block |
||
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | // add template style |
| 782 | - self::add_style( $view_data['template_id'] ); |
|
| 782 | + self::add_style( $view_data[ 'template_id' ] ); |
|
| 783 | 783 | |
| 784 | 784 | // Prepare to render view and set vars |
| 785 | - $gravityview_view->setEntries( $view_entries['entries'] ); |
|
| 786 | - $gravityview_view->setTotalEntries( $view_entries['count'] ); |
|
| 785 | + $gravityview_view->setEntries( $view_entries[ 'entries' ] ); |
|
| 786 | + $gravityview_view->setTotalEntries( $view_entries[ 'count' ] ); |
|
| 787 | 787 | |
| 788 | 788 | // If Edit |
| 789 | 789 | if ( 'edit' === gravityview_get_context() ) { |
@@ -796,11 +796,11 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | } else { |
| 798 | 798 | // finaly we'll render some html |
| 799 | - $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] ); |
|
| 799 | + $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data[ 'template_id' ] ); |
|
| 800 | 800 | |
| 801 | 801 | do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections ); |
| 802 | 802 | foreach ( $sections as $section ) { |
| 803 | - do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' ); |
|
| 803 | + do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' ); |
|
| 804 | 804 | $gravityview_view->render( $view_slug, $section, false ); |
| 805 | 805 | } |
| 806 | 806 | } |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | $datetime_format = 'Y-m-d H:i:s'; |
| 855 | 855 | $search_is_outside_view_bounds = false; |
| 856 | 856 | |
| 857 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
| 857 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
| 858 | 858 | |
| 859 | 859 | $search_date = strtotime( $search_criteria[ $key ] ); |
| 860 | 860 | |
@@ -882,14 +882,14 @@ discard block |
||
| 882 | 882 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
| 883 | 883 | |
| 884 | 884 | // Then we override the search and re-set the start date |
| 885 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
| 885 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
| 886 | 886 | } |
| 887 | 887 | } |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
| 890 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
| 891 | 891 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
| 892 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
| 892 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
| 893 | 893 | do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria ); |
| 894 | 894 | } |
| 895 | 895 | } |
@@ -907,9 +907,9 @@ discard block |
||
| 907 | 907 | */ |
| 908 | 908 | public static function process_search_only_approved( $args, $search_criteria ) { |
| 909 | 909 | |
| 910 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
| 911 | - $search_criteria['field_filters'][] = array( 'key' => 'is_approved', 'value' => 'Approved' ); |
|
| 912 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
| 910 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
| 911 | + $search_criteria[ 'field_filters' ][ ] = array( 'key' => 'is_approved', 'value' => 'Approved' ); |
|
| 912 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
| 913 | 913 | |
| 914 | 914 | do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria ); |
| 915 | 915 | } |
@@ -933,12 +933,12 @@ discard block |
||
| 933 | 933 | */ |
| 934 | 934 | public static function is_entry_approved( $entry, $args = array() ) { |
| 935 | 935 | |
| 936 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
| 936 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
| 937 | 937 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
| 938 | 938 | return true; |
| 939 | 939 | } |
| 940 | 940 | |
| 941 | - $is_approved = gform_get_meta( $entry['id'], 'is_approved' ); |
|
| 941 | + $is_approved = gform_get_meta( $entry[ 'id' ], 'is_approved' ); |
|
| 942 | 942 | |
| 943 | 943 | if ( $is_approved ) { |
| 944 | 944 | return true; |
@@ -976,26 +976,26 @@ discard block |
||
| 976 | 976 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria ); |
| 977 | 977 | |
| 978 | 978 | // implicity search |
| 979 | - if ( ! empty( $args['search_value'] ) ) { |
|
| 979 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
| 980 | 980 | |
| 981 | 981 | // Search operator options. Options: `is` or `contains` |
| 982 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
| 982 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
| 983 | 983 | |
| 984 | - $search_criteria['field_filters'][] = array( |
|
| 984 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 985 | 985 | 'key' => rgget( 'search_field', $args ), // The field ID to search |
| 986 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
| 986 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
| 987 | 987 | 'operator' => $operator, |
| 988 | 988 | ); |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | - if( $search_criteria !== $original_search_criteria ) { |
|
| 991 | + if ( $search_criteria !== $original_search_criteria ) { |
|
| 992 | 992 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria ); |
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | // Handle setting date range |
| 996 | 996 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
| 997 | 997 | |
| 998 | - if( $search_criteria !== $original_search_criteria ) { |
|
| 998 | + if ( $search_criteria !== $original_search_criteria ) { |
|
| 999 | 999 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria ); |
| 1000 | 1000 | } |
| 1001 | 1001 | |
@@ -1006,7 +1006,7 @@ discard block |
||
| 1006 | 1006 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
| 1007 | 1007 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
| 1008 | 1008 | */ |
| 1009 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
| 1009 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
| 1010 | 1010 | |
| 1011 | 1011 | return $search_criteria; |
| 1012 | 1012 | } |
@@ -1052,16 +1052,16 @@ discard block |
||
| 1052 | 1052 | $search_criteria = self::get_search_criteria( $args, $form_id ); |
| 1053 | 1053 | |
| 1054 | 1054 | // Paging & offset |
| 1055 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : apply_filters( 'gravityview_default_page_size', 25 ); |
|
| 1055 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : apply_filters( 'gravityview_default_page_size', 25 ); |
|
| 1056 | 1056 | |
| 1057 | 1057 | if ( -1 === $page_size ) { |
| 1058 | 1058 | $page_size = PHP_INT_MAX; |
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | - if ( isset( $args['offset'] ) ) { |
|
| 1062 | - $offset = intval( $args['offset'] ); |
|
| 1061 | + if ( isset( $args[ 'offset' ] ) ) { |
|
| 1062 | + $offset = intval( $args[ 'offset' ] ); |
|
| 1063 | 1063 | } else { |
| 1064 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
| 1064 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
| 1065 | 1065 | $offset = ( $curr_page - 1 ) * $page_size; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | 'search_criteria' => $search_criteria, |
| 1080 | 1080 | 'sorting' => $sorting, |
| 1081 | 1081 | 'paging' => $paging, |
| 1082 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
| 1082 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
| 1083 | 1083 | ); |
| 1084 | 1084 | |
| 1085 | 1085 | /** |
@@ -1104,7 +1104,7 @@ discard block |
||
| 1104 | 1104 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
| 1105 | 1105 | * @param array $args View configuration args. |
| 1106 | 1106 | */ |
| 1107 | - $parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id ); |
|
| 1107 | + $parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id ); |
|
| 1108 | 1108 | |
| 1109 | 1109 | do_action( 'gravityview_log_debug', __METHOD__ . ': $parameters passed to gravityview_get_entries(): ', $parameters ); |
| 1110 | 1110 | |
@@ -1144,8 +1144,8 @@ discard block |
||
| 1144 | 1144 | */ |
| 1145 | 1145 | public static function updateViewSorting( $args, $form_id ) { |
| 1146 | 1146 | $sorting = array(); |
| 1147 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' ); |
|
| 1148 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' ); |
|
| 1147 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' ); |
|
| 1148 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' ); |
|
| 1149 | 1149 | |
| 1150 | 1150 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
| 1151 | 1151 | |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | |
| 1186 | 1186 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
| 1187 | 1187 | |
| 1188 | - switch ( $sort_field['type'] ) { |
|
| 1188 | + switch ( $sort_field[ 'type' ] ) { |
|
| 1189 | 1189 | |
| 1190 | 1190 | case 'address': |
| 1191 | 1191 | // Sorting by full address |
@@ -1202,7 +1202,7 @@ discard block |
||
| 1202 | 1202 | */ |
| 1203 | 1203 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
| 1204 | 1204 | |
| 1205 | - switch( strtolower( $address_part ) ){ |
|
| 1205 | + switch ( strtolower( $address_part ) ) { |
|
| 1206 | 1206 | case 'street': |
| 1207 | 1207 | $sort_field_id .= '.1'; |
| 1208 | 1208 | break; |
@@ -1282,7 +1282,7 @@ discard block |
||
| 1282 | 1282 | */ |
| 1283 | 1283 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
| 1284 | 1284 | |
| 1285 | - if ( empty( $single_entry ) ){ |
|
| 1285 | + if ( empty( $single_entry ) ) { |
|
| 1286 | 1286 | return false; |
| 1287 | 1287 | } else { |
| 1288 | 1288 | return $single_entry; |
@@ -1309,7 +1309,7 @@ discard block |
||
| 1309 | 1309 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
| 1310 | 1310 | * @since 1.15 |
| 1311 | 1311 | */ |
| 1312 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 1312 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 1313 | 1313 | continue; |
| 1314 | 1314 | } |
| 1315 | 1315 | |
@@ -1318,19 +1318,19 @@ discard block |
||
| 1318 | 1318 | $css_dependencies = array(); |
| 1319 | 1319 | |
| 1320 | 1320 | // If the thickbox is enqueued, add dependencies |
| 1321 | - if ( ! empty( $data['atts']['lightbox'] ) ) { |
|
| 1321 | + if ( ! empty( $data[ 'atts' ][ 'lightbox' ] ) ) { |
|
| 1322 | 1322 | |
| 1323 | 1323 | /** |
| 1324 | 1324 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
| 1325 | 1325 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
| 1326 | 1326 | */ |
| 1327 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
| 1327 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
| 1328 | 1328 | |
| 1329 | 1329 | /** |
| 1330 | 1330 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
| 1331 | 1331 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
| 1332 | 1332 | */ |
| 1333 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
| 1333 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | /** |
@@ -1338,25 +1338,25 @@ discard block |
||
| 1338 | 1338 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
| 1339 | 1339 | * @since 1.15 |
| 1340 | 1340 | */ |
| 1341 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
| 1342 | - $css_dependencies[] = 'dashicons'; |
|
| 1341 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
| 1342 | + $css_dependencies[ ] = 'dashicons'; |
|
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | 1345 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
| 1346 | 1346 | |
| 1347 | 1347 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 1348 | 1348 | |
| 1349 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
| 1349 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
| 1350 | 1350 | |
| 1351 | 1351 | wp_enqueue_script( 'gravityview-fe-view' ); |
| 1352 | 1352 | |
| 1353 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
| 1353 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
| 1354 | 1354 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | 1357 | $this->enqueue_default_style( $css_dependencies ); |
| 1358 | 1358 | |
| 1359 | - self::add_style( $data['template_id'] ); |
|
| 1359 | + self::add_style( $data[ 'template_id' ] ); |
|
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | 1362 | if ( 'wp_print_footer_scripts' === current_filter() ) { |
@@ -1418,7 +1418,7 @@ discard block |
||
| 1418 | 1418 | } elseif ( empty( $template_id ) ) { |
| 1419 | 1419 | do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' ); |
| 1420 | 1420 | } else { |
| 1421 | - do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) ); |
|
| 1421 | + do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) ); |
|
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | 1424 | } |
@@ -1443,11 +1443,11 @@ discard block |
||
| 1443 | 1443 | * Not a table-based template; don't add sort icons |
| 1444 | 1444 | * @since 1.12 |
| 1445 | 1445 | */ |
| 1446 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
| 1446 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
| 1447 | 1447 | return $label; |
| 1448 | 1448 | } |
| 1449 | 1449 | |
| 1450 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
| 1450 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
| 1451 | 1451 | return $label; |
| 1452 | 1452 | } |
| 1453 | 1453 | |
@@ -1455,29 +1455,29 @@ discard block |
||
| 1455 | 1455 | |
| 1456 | 1456 | $class = 'gv-sort'; |
| 1457 | 1457 | |
| 1458 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
| 1458 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
| 1459 | 1459 | |
| 1460 | 1460 | $sort_args = array( |
| 1461 | - 'sort' => $field['id'], |
|
| 1461 | + 'sort' => $field[ 'id' ], |
|
| 1462 | 1462 | 'dir' => 'asc', |
| 1463 | 1463 | ); |
| 1464 | 1464 | |
| 1465 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
| 1465 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
| 1466 | 1466 | //toggle sorting direction. |
| 1467 | - if ( 'asc' === $sorting['direction'] ) { |
|
| 1468 | - $sort_args['dir'] = 'desc'; |
|
| 1467 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
| 1468 | + $sort_args[ 'dir' ] = 'desc'; |
|
| 1469 | 1469 | $class .= ' gv-icon-sort-desc'; |
| 1470 | 1470 | } else { |
| 1471 | - $sort_args['dir'] = 'asc'; |
|
| 1471 | + $sort_args[ 'dir' ] = 'asc'; |
|
| 1472 | 1472 | $class .= ' gv-icon-sort-asc'; |
| 1473 | 1473 | } |
| 1474 | 1474 | } else { |
| 1475 | 1475 | $class .= ' gv-icon-caret-up-down'; |
| 1476 | 1476 | } |
| 1477 | 1477 | |
| 1478 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
| 1478 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
| 1479 | 1479 | |
| 1480 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
| 1480 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
| 1481 | 1481 | |
| 1482 | 1482 | } |
| 1483 | 1483 | |
@@ -1495,7 +1495,7 @@ discard block |
||
| 1495 | 1495 | |
| 1496 | 1496 | $field_type = $field_id; |
| 1497 | 1497 | |
| 1498 | - if( is_numeric( $field_id ) ) { |
|
| 1498 | + if ( is_numeric( $field_id ) ) { |
|
| 1499 | 1499 | $field = GFFormsModel::get_field( $form, $field_id ); |
| 1500 | 1500 | $field_type = $field->type; |
| 1501 | 1501 | } |
@@ -1518,7 +1518,7 @@ discard block |
||
| 1518 | 1518 | return false; |
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
| 1521 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
| 1522 | 1522 | |
| 1523 | 1523 | } |
| 1524 | 1524 | |
@@ -119,16 +119,16 @@ discard block |
||
| 119 | 119 | function load() { |
| 120 | 120 | |
| 121 | 121 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 122 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 122 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 123 | 123 | |
| 124 | 124 | // Don't display an embedded form when editing an entry |
| 125 | 125 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
| 126 | 126 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
| 127 | 127 | |
| 128 | 128 | // Stop Gravity Forms processing what is ours! |
| 129 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
| 129 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
| 130 | 130 | |
| 131 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 131 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 132 | 132 | |
| 133 | 133 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
| 134 | 134 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 140 | 140 | |
| 141 | 141 | // Add fields expected by GFFormDisplay::validate() |
| 142 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 142 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | * @return void |
| 155 | 155 | */ |
| 156 | 156 | function prevent_render_form() { |
| 157 | - if( $this->is_edit_entry() ) { |
|
| 158 | - if( 'wp_head' === current_filter() ) { |
|
| 157 | + if ( $this->is_edit_entry() ) { |
|
| 158 | + if ( 'wp_head' === current_filter() ) { |
|
| 159 | 159 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 160 | 160 | } else { |
| 161 | 161 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -170,10 +170,10 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | function prevent_maybe_process_form() { |
| 172 | 172 | |
| 173 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 173 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 174 | 174 | |
| 175 | - if( $this->is_edit_entry_submission() && $this->verify_nonce() ) { |
|
| 176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 175 | + if ( $this->is_edit_entry_submission() && $this->verify_nonce() ) { |
|
| 176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function is_edit_entry() { |
| 185 | 185 | |
| 186 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
| 186 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
| 187 | 187 | |
| 188 | 188 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 189 | 189 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @return boolean |
| 195 | 195 | */ |
| 196 | 196 | public function is_edit_entry_submission() { |
| 197 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 197 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -205,15 +205,15 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | |
| 207 | 207 | $entries = $gravityview_view->getEntries(); |
| 208 | - self::$original_entry = $entries[0]; |
|
| 209 | - $this->entry = $entries[0]; |
|
| 208 | + self::$original_entry = $entries[ 0 ]; |
|
| 209 | + $this->entry = $entries[ 0 ]; |
|
| 210 | 210 | |
| 211 | 211 | self::$original_form = $gravityview_view->getForm(); |
| 212 | 212 | $this->form = $gravityview_view->getForm(); |
| 213 | 213 | $this->form_id = $gravityview_view->getFormId(); |
| 214 | 214 | $this->view_id = $gravityview_view->getViewId(); |
| 215 | 215 | |
| 216 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 216 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | |
@@ -233,12 +233,12 @@ discard block |
||
| 233 | 233 | $this->setup_vars(); |
| 234 | 234 | |
| 235 | 235 | // Multiple Views embedded, don't proceed if nonce fails |
| 236 | - if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
| 236 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // Sorry, you're not allowed here. |
| 241 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
| 241 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
| 242 | 242 | return; |
| 243 | 243 | } |
| 244 | 244 | |
@@ -258,9 +258,9 @@ discard block |
||
| 258 | 258 | function print_scripts() { |
| 259 | 259 | $gravityview_view = GravityView_View::getInstance(); |
| 260 | 260 | |
| 261 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 261 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 262 | 262 | |
| 263 | - GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false); |
|
| 263 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 264 | 264 | |
| 265 | 265 | // Sack is required for images |
| 266 | 266 | wp_print_scripts( array( 'sack', 'gform_gravityforms' ) ); |
@@ -272,32 +272,32 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | function process_save() { |
| 274 | 274 | |
| 275 | - if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 275 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 276 | 276 | return; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // Make sure the entry, view, and form IDs are all correct |
| 280 | 280 | $valid = $this->verify_nonce(); |
| 281 | 281 | |
| 282 | - if( !$valid ) { |
|
| 283 | - do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
| 282 | + if ( ! $valid ) { |
|
| 283 | + do_action( 'gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
| 284 | 284 | return; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 288 | - do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
| 287 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 288 | + do_action( 'gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
| 289 | 289 | return; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 292 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 293 | 293 | |
| 294 | 294 | $this->process_save_process_files( $this->form_id ); |
| 295 | 295 | |
| 296 | 296 | $this->validate(); |
| 297 | 297 | |
| 298 | - if( $this->is_valid ) { |
|
| 298 | + if ( $this->is_valid ) { |
|
| 299 | 299 | |
| 300 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' ); |
|
| 300 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' ); |
|
| 301 | 301 | |
| 302 | 302 | /** |
| 303 | 303 | * @hack This step is needed to unset the adminOnly from form fields, to add the calculation fields |
@@ -307,12 +307,12 @@ discard block |
||
| 307 | 307 | /** |
| 308 | 308 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 309 | 309 | */ |
| 310 | - unset( $_GET['page'] ); |
|
| 310 | + unset( $_GET[ 'page' ] ); |
|
| 311 | 311 | |
| 312 | 312 | GFFormsModel::save_lead( $form, $this->entry ); |
| 313 | 313 | |
| 314 | 314 | // If there's a post associated with the entry, process post fields |
| 315 | - if( !empty( $this->entry['post_id'] ) ) { |
|
| 315 | + if ( ! empty( $this->entry[ 'post_id' ] ) ) { |
|
| 316 | 316 | $this->maybe_update_post_fields( $form ); |
| 317 | 317 | } |
| 318 | 318 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * @param array $form Gravity Forms form array |
| 328 | 328 | * @param string $entry_id Numeric ID of the entry that was updated |
| 329 | 329 | */ |
| 330 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] ); |
|
| 330 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ] ); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | } // process_save |
@@ -361,11 +361,11 @@ discard block |
||
| 361 | 361 | * @return mixed |
| 362 | 362 | */ |
| 363 | 363 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 364 | - if( ! $this->is_edit_entry() ) { |
|
| 364 | + if ( ! $this->is_edit_entry() ) { |
|
| 365 | 365 | return $plupload_init; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 368 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 369 | 369 | |
| 370 | 370 | return $plupload_init; |
| 371 | 371 | } |
@@ -379,19 +379,19 @@ discard block |
||
| 379 | 379 | |
| 380 | 380 | $form = $this->form; |
| 381 | 381 | |
| 382 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 382 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 383 | 383 | |
| 384 | 384 | // Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 385 | 385 | // @since 1.16.3 |
| 386 | - if( $field->has_calculation() ) { |
|
| 387 | - unset( $form['fields'][ $k ] ); |
|
| 386 | + if ( $field->has_calculation() ) { |
|
| 387 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | $field->adminOnly = false; |
| 391 | 391 | |
| 392 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 393 | - foreach( $field->inputs as $key => $input ) { |
|
| 394 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 392 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 393 | + foreach ( $field->inputs as $key => $input ) { |
|
| 394 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -405,20 +405,20 @@ discard block |
||
| 405 | 405 | $update = false; |
| 406 | 406 | |
| 407 | 407 | // get the most up to date entry values |
| 408 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 408 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 409 | 409 | |
| 410 | - if( !empty( $this->fields_with_calculation ) ) { |
|
| 410 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
| 411 | 411 | $update = true; |
| 412 | 412 | foreach ( $this->fields_with_calculation as $calc_field ) { |
| 413 | 413 | $inputs = $calc_field->get_entry_inputs(); |
| 414 | 414 | if ( is_array( $inputs ) ) { |
| 415 | 415 | foreach ( $inputs as $input ) { |
| 416 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 417 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 416 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 417 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 418 | 418 | } |
| 419 | 419 | } else { |
| 420 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 421 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 420 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
| 421 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
@@ -428,16 +428,16 @@ discard block |
||
| 428 | 428 | if ( ! empty( $this->total_fields ) ) { |
| 429 | 429 | $update = true; |
| 430 | 430 | foreach ( $this->total_fields as $total_field ) { |
| 431 | - $input_name = 'input_' . str_replace( '.', '_', $total_field->id); |
|
| 432 | - $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry['id'], $entry ); |
|
| 431 | + $input_name = 'input_' . str_replace( '.', '_', $total_field->id ); |
|
| 432 | + $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if( $update ) { |
|
| 436 | + if ( $update ) { |
|
| 437 | 437 | |
| 438 | 438 | $return_entry = GFAPI::update_entry( $entry ); |
| 439 | 439 | |
| 440 | - if( is_wp_error( $return_entry ) ) { |
|
| 440 | + if ( is_wp_error( $return_entry ) ) { |
|
| 441 | 441 | do_action( 'gravityview_log_error', 'Updating the entry calculation and total fields failed', $return_entry ); |
| 442 | 442 | } else { |
| 443 | 443 | do_action( 'gravityview_log_debug', 'Updating the entry calculation and total fields succeeded' ); |
@@ -468,18 +468,18 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | $input_name = 'input_' . $field_id; |
| 470 | 470 | |
| 471 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 471 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 472 | 472 | |
| 473 | 473 | // We have a new image |
| 474 | 474 | |
| 475 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 475 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 476 | 476 | |
| 477 | 477 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 478 | 478 | $img_url = rgar( $ary, 0 ); |
| 479 | 479 | |
| 480 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 481 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 482 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 480 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 481 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 482 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 483 | 483 | |
| 484 | 484 | $image_meta = array( |
| 485 | 485 | 'post_excerpt' => $img_caption, |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 490 | 490 | if ( ! empty( $img_title ) ) { |
| 491 | - $image_meta['post_title'] = $img_title; |
|
| 491 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | /** |
@@ -503,22 +503,22 @@ discard block |
||
| 503 | 503 | set_post_thumbnail( $post_id, $media_id ); |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - } elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) { |
|
| 506 | + } elseif ( ! empty( $_POST[ $input_name ] ) && is_array( $value ) ) { |
|
| 507 | 507 | |
| 508 | 508 | // Same image although the image title, caption or description might have changed |
| 509 | 509 | |
| 510 | 510 | $ary = array(); |
| 511 | - if( ! empty( $entry[ $field_id ] ) ) { |
|
| 511 | + if ( ! empty( $entry[ $field_id ] ) ) { |
|
| 512 | 512 | $ary = is_array( $entry[ $field_id ] ) ? $entry[ $field_id ] : explode( '|:|', $entry[ $field_id ] ); |
| 513 | 513 | } |
| 514 | 514 | $img_url = rgar( $ary, 0 ); |
| 515 | 515 | |
| 516 | 516 | // is this really the same image or something went wrong ? |
| 517 | - if( $img_url === $_POST[ $input_name ] ) { |
|
| 517 | + if ( $img_url === $_POST[ $input_name ] ) { |
|
| 518 | 518 | |
| 519 | - $img_title = rgar( $value, $field_id .'.1' ); |
|
| 520 | - $img_caption = rgar( $value, $field_id .'.4' ); |
|
| 521 | - $img_description = rgar( $value, $field_id .'.7' ); |
|
| 519 | + $img_title = rgar( $value, $field_id . '.1' ); |
|
| 520 | + $img_caption = rgar( $value, $field_id . '.4' ); |
|
| 521 | + $img_description = rgar( $value, $field_id . '.7' ); |
|
| 522 | 522 | |
| 523 | 523 | $value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : ''; |
| 524 | 524 | |
@@ -558,11 +558,11 @@ discard block |
||
| 558 | 558 | */ |
| 559 | 559 | private function maybe_update_post_fields( $form ) { |
| 560 | 560 | |
| 561 | - $post_id = $this->entry['post_id']; |
|
| 561 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 562 | 562 | |
| 563 | 563 | // Security check |
| 564 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 565 | - do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id ); |
|
| 564 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 565 | + do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id ); |
|
| 566 | 566 | return; |
| 567 | 567 | } |
| 568 | 568 | |
@@ -574,25 +574,25 @@ discard block |
||
| 574 | 574 | |
| 575 | 575 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 576 | 576 | |
| 577 | - if( ! $field ) { |
|
| 577 | + if ( ! $field ) { |
|
| 578 | 578 | continue; |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 581 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 582 | 582 | |
| 583 | 583 | // Get the value of the field, including $_POSTed value |
| 584 | 584 | $value = RGFormsModel::get_field_value( $field ); |
| 585 | 585 | |
| 586 | 586 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 587 | 587 | $entry_tmp = $this->entry; |
| 588 | - $entry_tmp["{$field_id}"] = $value; |
|
| 588 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 589 | 589 | |
| 590 | - switch( $field->type ) { |
|
| 590 | + switch ( $field->type ) { |
|
| 591 | 591 | |
| 592 | 592 | case 'post_title': |
| 593 | 593 | $post_title = $value; |
| 594 | - if( rgar( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 595 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 594 | + if ( rgar( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 595 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 596 | 596 | } |
| 597 | 597 | $updated_post->post_title = $post_title; |
| 598 | 598 | $updated_post->post_name = $post_title; |
@@ -601,8 +601,8 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | case 'post_content': |
| 603 | 603 | $post_content = $value; |
| 604 | - if( rgar( $form, 'postContentTemplateEnabled' ) ) { |
|
| 605 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 604 | + if ( rgar( $form, 'postContentTemplateEnabled' ) ) { |
|
| 605 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 606 | 606 | } |
| 607 | 607 | $updated_post->post_content = $post_content; |
| 608 | 608 | unset( $post_content ); |
@@ -616,19 +616,19 @@ discard block |
||
| 616 | 616 | case 'post_category': |
| 617 | 617 | break; |
| 618 | 618 | case 'post_custom_field': |
| 619 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 619 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 620 | 620 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | $input_type = RGFormsModel::get_input_type( $field ); |
| 624 | 624 | |
| 625 | 625 | // Only certain custom field types are supported |
| 626 | - switch( $input_type ) { |
|
| 626 | + switch ( $input_type ) { |
|
| 627 | 627 | case 'fileupload': |
| 628 | 628 | case 'list': |
| 629 | 629 | case 'multiselect': |
| 630 | - if( ! is_string( $value ) ) { |
|
| 631 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 630 | + if ( ! is_string( $value ) ) { |
|
| 631 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 632 | 632 | } |
| 633 | 633 | // break; left intentionally out |
| 634 | 634 | default: |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | // update entry after |
| 647 | - $this->entry["{$field_id}"] = $value; |
|
| 647 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 648 | 648 | |
| 649 | 649 | $update_entry = true; |
| 650 | 650 | |
@@ -653,25 +653,25 @@ discard block |
||
| 653 | 653 | |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - if( $update_entry ) { |
|
| 656 | + if ( $update_entry ) { |
|
| 657 | 657 | |
| 658 | 658 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 659 | 659 | |
| 660 | - if( is_wp_error( $return_entry ) ) { |
|
| 660 | + if ( is_wp_error( $return_entry ) ) { |
|
| 661 | 661 | do_action( 'gravityview_log_error', 'Updating the entry post fields failed', array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ); |
| 662 | 662 | } else { |
| 663 | - do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' ); |
|
| 663 | + do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded' ); |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | $return_post = wp_update_post( $updated_post, true ); |
| 669 | 669 | |
| 670 | - if( is_wp_error( $return_post ) ) { |
|
| 670 | + if ( is_wp_error( $return_post ) ) { |
|
| 671 | 671 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 672 | 672 | do_action( 'gravityview_log_error', 'Updating the post content failed', compact( 'updated_post', 'return_post' ) ); |
| 673 | 673 | } else { |
| 674 | - do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post ); |
|
| 674 | + do_action( 'gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded', $updated_post ); |
|
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 702 | 702 | |
| 703 | 703 | // replace conditional shortcodes |
| 704 | - if( $do_shortcode ) { |
|
| 704 | + if ( $do_shortcode ) { |
|
| 705 | 705 | $output = do_shortcode( $output ); |
| 706 | 706 | } |
| 707 | 707 | |
@@ -720,18 +720,18 @@ discard block |
||
| 720 | 720 | */ |
| 721 | 721 | function after_update() { |
| 722 | 722 | |
| 723 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 724 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] ); |
|
| 723 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 724 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ] ); |
|
| 725 | 725 | |
| 726 | 726 | // Re-define the entry now that we've updated it. |
| 727 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 727 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 728 | 728 | |
| 729 | 729 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
| 730 | 730 | |
| 731 | 731 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 732 | 732 | // we have just updated. |
| 733 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 734 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 733 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 734 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | $this->entry = $entry; |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | |
| 750 | 750 | <div class="gv-edit-entry-wrapper"><?php |
| 751 | 751 | |
| 752 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 752 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 753 | 753 | |
| 754 | 754 | /** |
| 755 | 755 | * Fixes weird wpautop() issue |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 766 | 766 | * @param GravityView_Edit_Entry_Render $this This object |
| 767 | 767 | */ |
| 768 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 768 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 769 | 769 | |
| 770 | 770 | echo esc_attr( $edit_entry_title ); |
| 771 | 771 | ?></span> |
@@ -805,20 +805,20 @@ discard block |
||
| 805 | 805 | */ |
| 806 | 806 | private function maybe_print_message() { |
| 807 | 807 | |
| 808 | - if( rgpost('action') === 'update' ) { |
|
| 808 | + if ( rgpost( 'action' ) === 'update' ) { |
|
| 809 | 809 | |
| 810 | 810 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
| 811 | 811 | |
| 812 | - if( ! $this->is_valid ){ |
|
| 812 | + if ( ! $this->is_valid ) { |
|
| 813 | 813 | |
| 814 | 814 | // Keeping this compatible with Gravity Forms. |
| 815 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 816 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 815 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 816 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 817 | 817 | |
| 818 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 818 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 819 | 819 | |
| 820 | 820 | } else { |
| 821 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
| 821 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
| 822 | 822 | |
| 823 | 823 | /** |
| 824 | 824 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | * @param array $entry Gravity Forms entry array |
| 829 | 829 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 830 | 830 | */ |
| 831 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 831 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 832 | 832 | |
| 833 | 833 | echo GVCommon::generate_notice( $message ); |
| 834 | 834 | } |
@@ -852,24 +852,24 @@ discard block |
||
| 852 | 852 | */ |
| 853 | 853 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 854 | 854 | |
| 855 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 856 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 855 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 856 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 857 | 857 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
| 858 | 858 | |
| 859 | 859 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
| 860 | 860 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 861 | 861 | |
| 862 | - add_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value'), 10, 3 ); |
|
| 862 | + add_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value' ), 10, 3 ); |
|
| 863 | 863 | |
| 864 | 864 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 865 | - unset( $_GET['page'] ); |
|
| 865 | + unset( $_GET[ 'page' ] ); |
|
| 866 | 866 | |
| 867 | 867 | // TODO: Verify multiple-page forms |
| 868 | 868 | // TODO: Product fields are not editable |
| 869 | 869 | |
| 870 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 870 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 871 | 871 | |
| 872 | - remove_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value'), 10 ); |
|
| 872 | + remove_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value' ), 10 ); |
|
| 873 | 873 | remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
| 874 | 874 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 875 | 875 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | */ |
| 903 | 903 | function fix_survey_fields_value( $value, $field, $name ) { |
| 904 | 904 | |
| 905 | - if( 'survey' === $field->type ) { |
|
| 905 | + if ( 'survey' === $field->type ) { |
|
| 906 | 906 | |
| 907 | 907 | // We need to run through each survey row until we find a match for expected values |
| 908 | 908 | foreach ( $this->entry as $field_id => $field_value ) { |
@@ -911,11 +911,11 @@ discard block |
||
| 911 | 911 | continue; |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | - if( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
| 914 | + if ( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
| 915 | 915 | list( $row_val, $col_val ) = explode( ':', $field_value, 2 ); |
| 916 | 916 | |
| 917 | 917 | // If the $name matches the $row_val, we are processing the correct row |
| 918 | - if( $row_val === $name ) { |
|
| 918 | + if ( $row_val === $name ) { |
|
| 919 | 919 | $value = $field_value; |
| 920 | 920 | break; |
| 921 | 921 | } |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | * @return string |
| 937 | 937 | */ |
| 938 | 938 | public function render_form_buttons() { |
| 939 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 939 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | |
@@ -956,17 +956,17 @@ discard block |
||
| 956 | 956 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 957 | 957 | |
| 958 | 958 | // In case we have validated the form, use it to inject the validation results into the form render |
| 959 | - if( isset( $this->form_after_validation ) ) { |
|
| 959 | + if ( isset( $this->form_after_validation ) ) { |
|
| 960 | 960 | $form = $this->form_after_validation; |
| 961 | 961 | } else { |
| 962 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 962 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | $form = $this->filter_conditional_logic( $form ); |
| 966 | 966 | |
| 967 | 967 | // for now we don't support Save and Continue feature. |
| 968 | - if( ! self::$supports_save_and_continue ) { |
|
| 969 | - unset( $form['save'] ); |
|
| 968 | + if ( ! self::$supports_save_and_continue ) { |
|
| 969 | + unset( $form[ 'save' ] ); |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | return $form; |
@@ -987,29 +987,29 @@ discard block |
||
| 987 | 987 | */ |
| 988 | 988 | function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 989 | 989 | |
| 990 | - if( GFCommon::is_post_field( $field ) ) { |
|
| 990 | + if ( GFCommon::is_post_field( $field ) ) { |
|
| 991 | 991 | |
| 992 | 992 | $message = null; |
| 993 | 993 | |
| 994 | 994 | // First, make sure they have the capability to edit the post. |
| 995 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 995 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 996 | 996 | |
| 997 | 997 | /** |
| 998 | 998 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 999 | 999 | * @param string $message The existing "You don't have permission..." text |
| 1000 | 1000 | */ |
| 1001 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1001 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1002 | 1002 | |
| 1003 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1003 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1004 | 1004 | /** |
| 1005 | 1005 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1006 | 1006 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1007 | 1007 | */ |
| 1008 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1008 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | - if( $message ) { |
|
| 1012 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1011 | + if ( $message ) { |
|
| 1012 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1013 | 1013 | } |
| 1014 | 1014 | } |
| 1015 | 1015 | |
@@ -1034,8 +1034,8 @@ discard block |
||
| 1034 | 1034 | |
| 1035 | 1035 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1036 | 1036 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1037 | - if( |
|
| 1038 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1037 | + if ( |
|
| 1038 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1039 | 1039 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1040 | 1040 | || ! empty( $field_content ) |
| 1041 | 1041 | || in_array( $field->type, array( 'honeypot' ) ) |
@@ -1045,8 +1045,8 @@ discard block |
||
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | // Turn on Admin-style display for file upload fields only |
| 1048 | - if( 'fileupload' === $field->type ) { |
|
| 1049 | - $_GET['page'] = 'gf_entries'; |
|
| 1048 | + if ( 'fileupload' === $field->type ) { |
|
| 1049 | + $_GET[ 'page' ] = 'gf_entries'; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1073,12 +1073,12 @@ discard block |
||
| 1073 | 1073 | * @param mixed $field_value field value used to populate the input |
| 1074 | 1074 | * @param GF_Field $field Gravity Forms field object |
| 1075 | 1075 | */ |
| 1076 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field ); |
|
| 1076 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field ); |
|
| 1077 | 1077 | |
| 1078 | 1078 | // Prevent any PHP warnings, like undefined index |
| 1079 | 1079 | ob_start(); |
| 1080 | 1080 | |
| 1081 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1081 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1082 | 1082 | /** @var GF_Field $gv_field */ |
| 1083 | 1083 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1084 | 1084 | } else { |
@@ -1089,7 +1089,7 @@ discard block |
||
| 1089 | 1089 | // If there was output, it's an error |
| 1090 | 1090 | $warnings = ob_get_clean(); |
| 1091 | 1091 | |
| 1092 | - if( !empty( $warnings ) ) { |
|
| 1092 | + if ( ! empty( $warnings ) ) { |
|
| 1093 | 1093 | do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value ); |
| 1094 | 1094 | } |
| 1095 | 1095 | |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | * We need the fileupload html field to render with the proper id |
| 1099 | 1099 | * ( <li id="field_80_16" ... > ) |
| 1100 | 1100 | */ |
| 1101 | - unset( $_GET['page'] ); |
|
| 1101 | + unset( $_GET[ 'page' ] ); |
|
| 1102 | 1102 | |
| 1103 | 1103 | return $return; |
| 1104 | 1104 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1122 | 1122 | |
| 1123 | 1123 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1124 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1124 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1125 | 1125 | |
| 1126 | 1126 | $field_value = array(); |
| 1127 | 1127 | |
@@ -1130,10 +1130,10 @@ discard block |
||
| 1130 | 1130 | |
| 1131 | 1131 | foreach ( (array)$field->inputs as $input ) { |
| 1132 | 1132 | |
| 1133 | - $input_id = strval( $input['id'] ); |
|
| 1133 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1134 | 1134 | |
| 1135 | 1135 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1136 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1136 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1137 | 1137 | $allow_pre_populated = false; |
| 1138 | 1138 | } |
| 1139 | 1139 | |
@@ -1141,7 +1141,7 @@ discard block |
||
| 1141 | 1141 | |
| 1142 | 1142 | $pre_value = $field->get_value_submission( array(), false ); |
| 1143 | 1143 | |
| 1144 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1144 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1145 | 1145 | |
| 1146 | 1146 | } else { |
| 1147 | 1147 | |
@@ -1152,13 +1152,13 @@ discard block |
||
| 1152 | 1152 | |
| 1153 | 1153 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1154 | 1154 | // or pre-populated value if not empty and set to override saved value |
| 1155 | - $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1155 | + $field_value = ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1156 | 1156 | |
| 1157 | 1157 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1158 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1158 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1159 | 1159 | $categories = array(); |
| 1160 | 1160 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1161 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1161 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1162 | 1162 | } |
| 1163 | 1163 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1164 | 1164 | } |
@@ -1183,12 +1183,12 @@ discard block |
||
| 1183 | 1183 | */ |
| 1184 | 1184 | function gform_pre_validation( $form ) { |
| 1185 | 1185 | |
| 1186 | - if( ! $this->verify_nonce() ) { |
|
| 1186 | + if ( ! $this->verify_nonce() ) { |
|
| 1187 | 1187 | return $form; |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | // Fix PHP warning regarding undefined index. |
| 1191 | - foreach ( $form['fields'] as &$field) { |
|
| 1191 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1192 | 1192 | |
| 1193 | 1193 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1194 | 1194 | // expects certain field array items to be set. |
@@ -1201,7 +1201,7 @@ discard block |
||
| 1201 | 1201 | $field['emailConfirmEnabled'] = ''; |
| 1202 | 1202 | }*/ |
| 1203 | 1203 | |
| 1204 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1204 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1205 | 1205 | |
| 1206 | 1206 | /** |
| 1207 | 1207 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1215,37 +1215,37 @@ discard block |
||
| 1215 | 1215 | // Set the previous value |
| 1216 | 1216 | $entry = $this->get_entry(); |
| 1217 | 1217 | |
| 1218 | - $input_name = 'input_'.$field->id; |
|
| 1219 | - $form_id = $form['id']; |
|
| 1218 | + $input_name = 'input_' . $field->id; |
|
| 1219 | + $form_id = $form[ 'id' ]; |
|
| 1220 | 1220 | |
| 1221 | 1221 | $value = NULL; |
| 1222 | 1222 | |
| 1223 | 1223 | // Use the previous entry value as the default. |
| 1224 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1224 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1225 | 1225 | $value = $entry[ $field->id ]; |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | // If this is a single upload file |
| 1229 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1230 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1231 | - $value = $file_path['url']; |
|
| 1229 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1230 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1231 | + $value = $file_path[ 'url' ]; |
|
| 1232 | 1232 | |
| 1233 | 1233 | } else { |
| 1234 | 1234 | |
| 1235 | 1235 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1236 | 1236 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1237 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1237 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1238 | 1238 | |
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | - if( rgar($field, "multipleFiles") ) { |
|
| 1241 | + if ( rgar( $field, "multipleFiles" ) ) { |
|
| 1242 | 1242 | |
| 1243 | 1243 | // If there are fresh uploads, process and merge them. |
| 1244 | 1244 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1245 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1245 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1246 | 1246 | $value = empty( $value ) ? '[]' : $value; |
| 1247 | 1247 | $value = stripslashes_deep( $value ); |
| 1248 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1248 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | 1251 | } else { |
@@ -1263,14 +1263,14 @@ discard block |
||
| 1263 | 1263 | |
| 1264 | 1264 | case 'number': |
| 1265 | 1265 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1266 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1267 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1266 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1267 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1268 | 1268 | } |
| 1269 | 1269 | break; |
| 1270 | 1270 | case 'captcha': |
| 1271 | 1271 | // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php |
| 1272 | - $_POST['recaptcha_challenge_field'] = NULL; |
|
| 1273 | - $_POST['recaptcha_response_field'] = NULL; |
|
| 1272 | + $_POST[ 'recaptcha_challenge_field' ] = NULL; |
|
| 1273 | + $_POST[ 'recaptcha_response_field' ] = NULL; |
|
| 1274 | 1274 | break; |
| 1275 | 1275 | } |
| 1276 | 1276 | |
@@ -1306,7 +1306,7 @@ discard block |
||
| 1306 | 1306 | * You can enter whatever you want! |
| 1307 | 1307 | * We try validating, and customize the results using `self::custom_validation()` |
| 1308 | 1308 | */ |
| 1309 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1309 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1310 | 1310 | |
| 1311 | 1311 | // Needed by the validate funtion |
| 1312 | 1312 | $failed_validation_page = NULL; |
@@ -1314,14 +1314,14 @@ discard block |
||
| 1314 | 1314 | |
| 1315 | 1315 | // Prevent entry limit from running when editing an entry, also |
| 1316 | 1316 | // prevent form scheduling from preventing editing |
| 1317 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1317 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1318 | 1318 | |
| 1319 | 1319 | // Hide fields depending on Edit Entry settings |
| 1320 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1320 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1321 | 1321 | |
| 1322 | 1322 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1323 | 1323 | |
| 1324 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1324 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | |
@@ -1338,13 +1338,13 @@ discard block |
||
| 1338 | 1338 | */ |
| 1339 | 1339 | function custom_validation( $validation_results ) { |
| 1340 | 1340 | |
| 1341 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
| 1341 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
| 1342 | 1342 | |
| 1343 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 1343 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 1344 | 1344 | |
| 1345 | 1345 | $gv_valid = true; |
| 1346 | 1346 | |
| 1347 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1347 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1348 | 1348 | |
| 1349 | 1349 | $value = RGFormsModel::get_field_value( $field ); |
| 1350 | 1350 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1357,35 +1357,35 @@ discard block |
||
| 1357 | 1357 | case 'post_image': |
| 1358 | 1358 | |
| 1359 | 1359 | // in case nothing is uploaded but there are already files saved |
| 1360 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1360 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1361 | 1361 | $field->failed_validation = false; |
| 1362 | 1362 | unset( $field->validation_message ); |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1366 | - if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { |
|
| 1366 | + if ( rgobj( $field, 'maxFiles' ) && rgobj( $field, 'multipleFiles' ) ) { |
|
| 1367 | 1367 | |
| 1368 | 1368 | $input_name = 'input_' . $field->id; |
| 1369 | 1369 | //uploaded |
| 1370 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1370 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1371 | 1371 | |
| 1372 | 1372 | //existent |
| 1373 | 1373 | $entry = $this->get_entry(); |
| 1374 | 1374 | $value = NULL; |
| 1375 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1375 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1376 | 1376 | $value = json_decode( $entry[ $field->id ], true ); |
| 1377 | 1377 | } |
| 1378 | 1378 | |
| 1379 | 1379 | // count uploaded files and existent entry files |
| 1380 | 1380 | $count_files = count( $file_names ) + count( $value ); |
| 1381 | 1381 | |
| 1382 | - if( $count_files > $field->maxFiles ) { |
|
| 1382 | + if ( $count_files > $field->maxFiles ) { |
|
| 1383 | 1383 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1384 | 1384 | $field->failed_validation = 1; |
| 1385 | 1385 | $gv_valid = false; |
| 1386 | 1386 | |
| 1387 | 1387 | // in case of error make sure the newest upload files are removed from the upload input |
| 1388 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1388 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1389 | 1389 | } |
| 1390 | 1390 | |
| 1391 | 1391 | } |
@@ -1396,7 +1396,7 @@ discard block |
||
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | // This field has failed validation. |
| 1399 | - if( !empty( $field->failed_validation ) ) { |
|
| 1399 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1400 | 1400 | |
| 1401 | 1401 | do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) ); |
| 1402 | 1402 | |
@@ -1414,32 +1414,32 @@ discard block |
||
| 1414 | 1414 | } |
| 1415 | 1415 | |
| 1416 | 1416 | // You can't continue inside a switch, so we do it after. |
| 1417 | - if( empty( $field->failed_validation ) ) { |
|
| 1417 | + if ( empty( $field->failed_validation ) ) { |
|
| 1418 | 1418 | continue; |
| 1419 | 1419 | } |
| 1420 | 1420 | |
| 1421 | 1421 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1422 | 1422 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1423 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1423 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1424 | 1424 | |
| 1425 | 1425 | $entry = $this->get_entry(); |
| 1426 | 1426 | |
| 1427 | 1427 | // If the value of the entry is the same as the stored value |
| 1428 | 1428 | // Then we can assume it's not a duplicate, it's the same. |
| 1429 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1429 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1430 | 1430 | //if value submitted was not changed, then don't validate |
| 1431 | 1431 | $field->failed_validation = false; |
| 1432 | 1432 | |
| 1433 | 1433 | unset( $field->validation_message ); |
| 1434 | 1434 | |
| 1435 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
| 1435 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
| 1436 | 1436 | |
| 1437 | 1437 | continue; |
| 1438 | 1438 | } |
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | 1441 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1442 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1442 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1443 | 1443 | unset( $field->validation_message ); |
| 1444 | 1444 | $field->validation_message = false; |
| 1445 | 1445 | continue; |
@@ -1451,12 +1451,12 @@ discard block |
||
| 1451 | 1451 | |
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1454 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1455 | 1455 | |
| 1456 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
| 1456 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
| 1457 | 1457 | |
| 1458 | 1458 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1459 | - $this->form_after_validation = $validation_results['form']; |
|
| 1459 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1460 | 1460 | |
| 1461 | 1461 | return $validation_results; |
| 1462 | 1462 | } |
@@ -1469,7 +1469,7 @@ discard block |
||
| 1469 | 1469 | */ |
| 1470 | 1470 | public function get_entry() { |
| 1471 | 1471 | |
| 1472 | - if( empty( $this->entry ) ) { |
|
| 1472 | + if ( empty( $this->entry ) ) { |
|
| 1473 | 1473 | // Get the database value of the entry that's being edited |
| 1474 | 1474 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1475 | 1475 | } |
@@ -1496,13 +1496,13 @@ discard block |
||
| 1496 | 1496 | $properties = GravityView_View_Data::getInstance()->get_fields( $view_id ); |
| 1497 | 1497 | |
| 1498 | 1498 | // If edit tab not yet configured, show all fields |
| 1499 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1499 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1500 | 1500 | |
| 1501 | 1501 | // Show hidden fields as text fields |
| 1502 | 1502 | $form = $this->fix_survey_fields( $form ); |
| 1503 | 1503 | |
| 1504 | 1504 | // Hide fields depending on admin settings |
| 1505 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1505 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1506 | 1506 | |
| 1507 | 1507 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1508 | 1508 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1532,7 +1532,7 @@ discard block |
||
| 1532 | 1532 | private function fix_survey_fields( $form ) { |
| 1533 | 1533 | |
| 1534 | 1534 | /** @var GF_Field $field */ |
| 1535 | - foreach( $form['fields'] as &$field ) { |
|
| 1535 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1536 | 1536 | $field->allowsPrepopulate = true; |
| 1537 | 1537 | } |
| 1538 | 1538 | |
@@ -1553,7 +1553,7 @@ discard block |
||
| 1553 | 1553 | */ |
| 1554 | 1554 | private function filter_fields( $fields, $configured_fields ) { |
| 1555 | 1555 | |
| 1556 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1556 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1557 | 1557 | return $fields; |
| 1558 | 1558 | } |
| 1559 | 1559 | |
@@ -1570,13 +1570,13 @@ discard block |
||
| 1570 | 1570 | */ |
| 1571 | 1571 | $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) ); |
| 1572 | 1572 | |
| 1573 | - if( $hide_product_fields ) { |
|
| 1574 | - $field_type_blacklist[] = 'option'; |
|
| 1575 | - $field_type_blacklist[] = 'quantity'; |
|
| 1576 | - $field_type_blacklist[] = 'product'; |
|
| 1577 | - $field_type_blacklist[] = 'total'; |
|
| 1578 | - $field_type_blacklist[] = 'shipping'; |
|
| 1579 | - $field_type_blacklist[] = 'calculation'; |
|
| 1573 | + if ( $hide_product_fields ) { |
|
| 1574 | + $field_type_blacklist[ ] = 'option'; |
|
| 1575 | + $field_type_blacklist[ ] = 'quantity'; |
|
| 1576 | + $field_type_blacklist[ ] = 'product'; |
|
| 1577 | + $field_type_blacklist[ ] = 'total'; |
|
| 1578 | + $field_type_blacklist[ ] = 'shipping'; |
|
| 1579 | + $field_type_blacklist[ ] = 'calculation'; |
|
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | 1582 | // First, remove blacklist or calculation fields |
@@ -1584,24 +1584,24 @@ discard block |
||
| 1584 | 1584 | |
| 1585 | 1585 | // Remove the fields that have calculation properties and keep them to be used later |
| 1586 | 1586 | // @since 1.16.2 |
| 1587 | - if( $field->has_calculation() ) { |
|
| 1588 | - $this->fields_with_calculation[] = $field; |
|
| 1587 | + if ( $field->has_calculation() ) { |
|
| 1588 | + $this->fields_with_calculation[ ] = $field; |
|
| 1589 | 1589 | // don't remove the calculation fields on form render. |
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | 1592 | // process total field after all fields have been saved |
| 1593 | 1593 | if ( $field->type == 'total' ) { |
| 1594 | - $this->total_fields[] = $field; |
|
| 1594 | + $this->total_fields[ ] = $field; |
|
| 1595 | 1595 | unset( $fields[ $key ] ); |
| 1596 | 1596 | } |
| 1597 | 1597 | |
| 1598 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1598 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1599 | 1599 | unset( $fields[ $key ] ); |
| 1600 | 1600 | } |
| 1601 | 1601 | } |
| 1602 | 1602 | |
| 1603 | 1603 | // The Edit tab has not been configured, so we return all fields by default. |
| 1604 | - if( empty( $configured_fields ) ) { |
|
| 1604 | + if ( empty( $configured_fields ) ) { |
|
| 1605 | 1605 | return $fields; |
| 1606 | 1606 | } |
| 1607 | 1607 | |
@@ -1611,8 +1611,8 @@ discard block |
||
| 1611 | 1611 | /** @var GF_Field $field */ |
| 1612 | 1612 | foreach ( $fields as $field ) { |
| 1613 | 1613 | |
| 1614 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1615 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1614 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1615 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1616 | 1616 | break; |
| 1617 | 1617 | } |
| 1618 | 1618 | |
@@ -1635,14 +1635,14 @@ discard block |
||
| 1635 | 1635 | |
| 1636 | 1636 | $return_field = $field; |
| 1637 | 1637 | |
| 1638 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1638 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1639 | 1639 | $return_field->label = ''; |
| 1640 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1641 | - $return_field->label = $field_setting['custom_label']; |
|
| 1640 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1641 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1642 | 1642 | } |
| 1643 | 1643 | |
| 1644 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1645 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1644 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1645 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1646 | 1646 | } |
| 1647 | 1647 | |
| 1648 | 1648 | /** |
@@ -1680,16 +1680,16 @@ discard block |
||
| 1680 | 1680 | */ |
| 1681 | 1681 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1682 | 1682 | |
| 1683 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1684 | - foreach( $fields as $k => $field ) { |
|
| 1685 | - if( $field->adminOnly ) { |
|
| 1683 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1684 | + foreach ( $fields as $k => $field ) { |
|
| 1685 | + if ( $field->adminOnly ) { |
|
| 1686 | 1686 | unset( $fields[ $k ] ); |
| 1687 | 1687 | } |
| 1688 | 1688 | } |
| 1689 | 1689 | return $fields; |
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | - foreach( $fields as &$field ) { |
|
| 1692 | + foreach ( $fields as &$field ) { |
|
| 1693 | 1693 | $field->adminOnly = false; |
| 1694 | 1694 | } |
| 1695 | 1695 | |
@@ -1716,16 +1716,16 @@ discard block |
||
| 1716 | 1716 | */ |
| 1717 | 1717 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 1718 | 1718 | |
| 1719 | - if( $use_conditional_logic ) { |
|
| 1719 | + if ( $use_conditional_logic ) { |
|
| 1720 | 1720 | return $form; |
| 1721 | 1721 | } |
| 1722 | 1722 | |
| 1723 | - foreach( $form['fields'] as &$field ) { |
|
| 1723 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1724 | 1724 | /* @var GF_Field $field */ |
| 1725 | 1725 | $field->conditionalLogic = null; |
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | - unset( $form['button']['conditionalLogic'] ); |
|
| 1728 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 1729 | 1729 | |
| 1730 | 1730 | return $form; |
| 1731 | 1731 | |
@@ -1742,7 +1742,7 @@ discard block |
||
| 1742 | 1742 | */ |
| 1743 | 1743 | function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 1744 | 1744 | |
| 1745 | - if( ! $this->is_edit_entry() ) { |
|
| 1745 | + if ( ! $this->is_edit_entry() ) { |
|
| 1746 | 1746 | return $has_conditional_logic; |
| 1747 | 1747 | } |
| 1748 | 1748 | |
@@ -1773,44 +1773,44 @@ discard block |
||
| 1773 | 1773 | * 2. There are two entries embedded using oEmbed |
| 1774 | 1774 | * 3. One of the entries has just been saved |
| 1775 | 1775 | */ |
| 1776 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 1776 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 1777 | 1777 | |
| 1778 | 1778 | $error = true; |
| 1779 | 1779 | |
| 1780 | 1780 | } |
| 1781 | 1781 | |
| 1782 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 1782 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 1783 | 1783 | |
| 1784 | 1784 | $error = true; |
| 1785 | 1785 | |
| 1786 | - } elseif( ! $this->verify_nonce() ) { |
|
| 1786 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 1787 | 1787 | |
| 1788 | 1788 | /** |
| 1789 | 1789 | * If the Entry is embedded, there may be two entries on the same page. |
| 1790 | 1790 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 1791 | 1791 | */ |
| 1792 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1792 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1793 | 1793 | $error = true; |
| 1794 | 1794 | } else { |
| 1795 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 1795 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 1796 | 1796 | } |
| 1797 | 1797 | |
| 1798 | 1798 | } |
| 1799 | 1799 | |
| 1800 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1801 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 1800 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1801 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | - if( $this->entry['status'] === 'trash' ) { |
|
| 1805 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1804 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 1805 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | 1808 | // No errors; everything's fine here! |
| 1809 | - if( empty( $error ) ) { |
|
| 1809 | + if ( empty( $error ) ) { |
|
| 1810 | 1810 | return true; |
| 1811 | 1811 | } |
| 1812 | 1812 | |
| 1813 | - if( $echo && $error !== true ) { |
|
| 1813 | + if ( $echo && $error !== true ) { |
|
| 1814 | 1814 | |
| 1815 | 1815 | $error = esc_html( $error ); |
| 1816 | 1816 | |
@@ -1818,13 +1818,13 @@ discard block |
||
| 1818 | 1818 | * @since 1.9 |
| 1819 | 1819 | */ |
| 1820 | 1820 | if ( ! empty( $this->entry ) ) { |
| 1821 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 1821 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 1822 | 1822 | } |
| 1823 | 1823 | |
| 1824 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 1824 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 1825 | 1825 | } |
| 1826 | 1826 | |
| 1827 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
| 1827 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
| 1828 | 1828 | |
| 1829 | 1829 | return false; |
| 1830 | 1830 | } |
@@ -1841,20 +1841,20 @@ discard block |
||
| 1841 | 1841 | |
| 1842 | 1842 | $error = NULL; |
| 1843 | 1843 | |
| 1844 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 1845 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 1844 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 1845 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 1846 | 1846 | } |
| 1847 | 1847 | |
| 1848 | 1848 | // No errors; everything's fine here! |
| 1849 | - if( empty( $error ) ) { |
|
| 1849 | + if ( empty( $error ) ) { |
|
| 1850 | 1850 | return true; |
| 1851 | 1851 | } |
| 1852 | 1852 | |
| 1853 | - if( $echo ) { |
|
| 1854 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 1853 | + if ( $echo ) { |
|
| 1854 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
| 1857 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
| 1858 | 1858 | |
| 1859 | 1859 | return false; |
| 1860 | 1860 | |
@@ -1872,15 +1872,15 @@ discard block |
||
| 1872 | 1872 | private function check_user_cap_edit_field( $field ) { |
| 1873 | 1873 | |
| 1874 | 1874 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 1875 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 1875 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 1876 | 1876 | return true; |
| 1877 | 1877 | } |
| 1878 | 1878 | |
| 1879 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 1879 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 1880 | 1880 | |
| 1881 | 1881 | // If the field has custom editing capaibilities set, check those |
| 1882 | - if( $field_cap ) { |
|
| 1883 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 1882 | + if ( $field_cap ) { |
|
| 1883 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 1884 | 1884 | } |
| 1885 | 1885 | |
| 1886 | 1886 | return false; |
@@ -1894,17 +1894,17 @@ discard block |
||
| 1894 | 1894 | public function verify_nonce() { |
| 1895 | 1895 | |
| 1896 | 1896 | // Verify form submitted for editing single |
| 1897 | - if( $this->is_edit_entry_submission() ) { |
|
| 1897 | + if ( $this->is_edit_entry_submission() ) { |
|
| 1898 | 1898 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 1899 | 1899 | } |
| 1900 | 1900 | |
| 1901 | 1901 | // Verify |
| 1902 | - else if( ! $this->is_edit_entry() ) { |
|
| 1902 | + else if ( ! $this->is_edit_entry() ) { |
|
| 1903 | 1903 | $valid = false; |
| 1904 | 1904 | } |
| 1905 | 1905 | |
| 1906 | 1906 | else { |
| 1907 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 1907 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 1908 | 1908 | } |
| 1909 | 1909 | |
| 1910 | 1910 | /** |