@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | var $name = 'radio'; |
11 | 11 | |
12 | - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); |
|
12 | + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); |
|
13 | 13 | |
14 | 14 | var $_gf_field_class_name = 'GF_Field_Radio'; |
15 | 15 | |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | // Set the $_field_id var |
39 | 39 | $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type ); |
40 | 40 | |
41 | - if( $this->is_choice_value_enabled() ) { |
|
42 | - $field_options['choice_display'] = array( |
|
41 | + if ( $this->is_choice_value_enabled() ) { |
|
42 | + $field_options[ 'choice_display' ] = array( |
|
43 | 43 | 'type' => 'radio', |
44 | 44 | 'value' => 'value', |
45 | 45 | 'label' => __( 'What should be displayed:', 'gravityview' ), |
@@ -38,8 +38,8 @@ |
||
38 | 38 | // Set the $_field_id var |
39 | 39 | $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type ); |
40 | 40 | |
41 | - if( $this->is_choice_value_enabled() ) { |
|
42 | - $field_options['choice_display'] = array( |
|
41 | + if ( $this->is_choice_value_enabled() ) { |
|
42 | + $field_options[ 'choice_display' ] = array( |
|
43 | 43 | 'type' => 'radio', |
44 | 44 | 'value' => 'value', |
45 | 45 | 'label' => __( 'What should be displayed:', 'gravityview' ), |
@@ -48,25 +48,25 @@ |
||
48 | 48 | |
49 | 49 | $quiz_fields = GFAPI::get_fields_by_type( $form, 'quiz' ); |
50 | 50 | |
51 | - if( ! empty( $quiz_fields ) ) { |
|
51 | + if ( ! empty( $quiz_fields ) ) { |
|
52 | 52 | |
53 | - $fields['gquiz_score'] = array( |
|
53 | + $fields[ 'gquiz_score' ] = array( |
|
54 | 54 | 'label' => __( 'Quiz Score Total', 'gravityview' ), |
55 | 55 | 'type' => 'quiz_score', |
56 | 56 | 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
57 | 57 | ); |
58 | - $fields['gquiz_percent'] = array( |
|
58 | + $fields[ 'gquiz_percent' ] = array( |
|
59 | 59 | 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
60 | 60 | 'type' => 'quiz_percent', |
61 | 61 | 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
62 | 62 | ); |
63 | - $fields['gquiz_grade'] = array( |
|
63 | + $fields[ 'gquiz_grade' ] = array( |
|
64 | 64 | /* translators: This is a field type used by the Gravity Forms Quiz Addon. "A" is 100-90, "B" is 89-80, "C" is 79-70, etc. */ |
65 | 65 | 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
66 | 66 | 'type' => 'quiz_grade', |
67 | 67 | 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
68 | 68 | ); |
69 | - $fields['gquiz_is_pass'] = array( |
|
69 | + $fields[ 'gquiz_is_pass' ] = array( |
|
70 | 70 | 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
71 | 71 | 'type' => 'quiz_is_pass', |
72 | 72 | 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | |
237 | 237 | if ( $add_default_properties && ! empty( $field->inputs ) ) { |
238 | 238 | foreach ( $field->inputs as $input ) { |
239 | - /** |
|
240 | - * @hack |
|
241 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
242 | - */ |
|
239 | + /** |
|
240 | + * @hack |
|
241 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
242 | + */ |
|
243 | 243 | if( 'email' === $field->type && false === strpos( $input['id'], '.' ) ) { |
244 | - continue; |
|
245 | - } |
|
244 | + continue; |
|
245 | + } |
|
246 | 246 | $fields["{$input['id']}"] = array( |
247 | 247 | 'label' => rgar( $input, 'label' ), |
248 | 248 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
420 | 420 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
421 | 421 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
422 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
422 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
423 | 423 | $criteria['context_view_id'] = null; |
424 | 424 | } |
425 | 425 | |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | ), |
1149 | 1149 | ); |
1150 | 1150 | |
1151 | - $fields = $date_created + $fields; |
|
1151 | + $fields = $date_created + $fields; |
|
1152 | 1152 | |
1153 | 1153 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1154 | 1154 | |
@@ -1160,13 +1160,13 @@ discard block |
||
1160 | 1160 | } |
1161 | 1161 | } |
1162 | 1162 | |
1163 | - /** |
|
1164 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1165 | - * @since 1.12 |
|
1166 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1167 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1168 | - */ |
|
1169 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1163 | + /** |
|
1164 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1165 | + * @since 1.12 |
|
1166 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1167 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1168 | + */ |
|
1169 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1170 | 1170 | |
1171 | 1171 | return $fields; |
1172 | 1172 | } |
@@ -1449,17 +1449,17 @@ discard block |
||
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | |
1452 | - /** |
|
1453 | - * Display updated/error notice |
|
1454 | - * |
|
1455 | - * @param string $notice text/HTML of notice |
|
1456 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1457 | - * |
|
1458 | - * @return string |
|
1459 | - */ |
|
1460 | - public static function generate_notice( $notice, $class = '' ) { |
|
1461 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1462 | - } |
|
1452 | + /** |
|
1453 | + * Display updated/error notice |
|
1454 | + * |
|
1455 | + * @param string $notice text/HTML of notice |
|
1456 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1457 | + * |
|
1458 | + * @return string |
|
1459 | + */ |
|
1460 | + public static function generate_notice( $notice, $class = '' ) { |
|
1461 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1462 | + } |
|
1463 | 1463 | |
1464 | 1464 | /** |
1465 | 1465 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | |
265 | - if( GFCommon::is_product_field( $field->type ) ){ |
|
265 | + if( GFCommon::is_product_field( $field->type ) ) { |
|
266 | 266 | $has_product_fields = true; |
267 | 267 | } |
268 | 268 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | $fields = array(); |
324 | 324 | |
325 | - foreach ( $extra_fields as $key => $field ){ |
|
325 | + foreach ( $extra_fields as $key => $field ) { |
|
326 | 326 | if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
327 | 327 | $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
328 | 328 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | * @return GF_Field|null Gravity Forms field object, or NULL: Gravity Forms GFFormsModel does not exist or field at $field_id doesn't exist. |
889 | 889 | */ |
890 | 890 | public static function get_field( $form, $field_id ) { |
891 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
891 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
892 | 892 | return GFFormsModel::get_field( $form, $field_id ); |
893 | 893 | } else { |
894 | 894 | return null; |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | $shortcodes = array(); |
936 | 936 | |
937 | 937 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
938 | - if ( empty( $matches ) ){ |
|
938 | + if ( empty( $matches ) ) { |
|
939 | 939 | return false; |
940 | 940 | } |
941 | 941 |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * Return array of fields' id and label, for a given Form ID |
210 | 210 | * |
211 | 211 | * @access public |
212 | - * @param string|array $form_id (default: '') or $form object |
|
212 | + * @param string|array $form (default: '') or $form object |
|
213 | 213 | * @param bool $add_default_properties |
214 | 214 | * @param bool $include_parent_field |
215 | 215 | * @return array |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | * |
851 | 851 | * @param array $form Gravity Forms form array |
852 | 852 | * @param string $field_id ID of the field. If an input, full input ID (like `1.3`) |
853 | - * @param string|array $field_value Raw value of the field. |
|
853 | + * @param string $field_value Raw value of the field. |
|
854 | 854 | * @return string |
855 | 855 | */ |
856 | 856 | public static function get_field_label( $form = array(), $field_id = '', $field_value = '' ) { |
@@ -1503,9 +1503,9 @@ discard block |
||
1503 | 1503 | * @param string $message Message body (required) |
1504 | 1504 | * @param string $from_name Displayed name of the sender |
1505 | 1505 | * @param string $message_format If "html", sent text as `text/html`. Otherwise, `text/plain`. Default: "html". |
1506 | - * @param string|array $attachments Optional. Files to attach. {@see wp_mail()} for usage. Default: "". |
|
1506 | + * @param string $attachments Optional. Files to attach. {@see wp_mail()} for usage. Default: "". |
|
1507 | 1507 | * @param array|false $entry Gravity Forms entry array, related to the email. Default: false. |
1508 | - * @param array|false $notification Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. |
|
1508 | + * @param boolean $notification Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. |
|
1509 | 1509 | */ |
1510 | 1510 | public static function send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '', $entry = false, $notification = false ) { |
1511 | 1511 |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $entry = self::get_entry( $entry_slug, true ); |
126 | 126 | |
127 | - $form = self::get_form( $entry['form_id'] ); |
|
127 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
128 | 128 | |
129 | 129 | return $form; |
130 | 130 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
184 | 184 | |
185 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
185 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
186 | 186 | |
187 | 187 | return $result; |
188 | 188 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
199 | 199 | */ |
200 | - public static function get_forms( $active = true, $trash = false ) { |
|
200 | + public static function get_forms( $active = true, $trash = false ) { |
|
201 | 201 | $forms = array(); |
202 | 202 | if ( class_exists( 'GFAPI' ) ) { |
203 | 203 | $forms = GFAPI::get_forms( $active, $trash ); |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | $has_post_fields = false; |
226 | 226 | |
227 | 227 | if ( $form ) { |
228 | - foreach ( $form['fields'] as $field ) { |
|
228 | + foreach ( $form[ 'fields' ] as $field ) { |
|
229 | 229 | |
230 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
231 | - $fields["{$field->id}"] = array( |
|
230 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
231 | + $fields[ "{$field->id}" ] = array( |
|
232 | 232 | 'label' => rgar( $field, 'label' ), |
233 | 233 | 'parent' => null, |
234 | 234 | 'type' => rgar( $field, 'type' ), |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | * @hack |
244 | 244 | * In case of email/email confirmation, the input for email has the same id as the parent field |
245 | 245 | */ |
246 | - if( 'email' === $field->type && false === strpos( $input['id'], '.' ) ) { |
|
246 | + if ( 'email' === $field->type && false === strpos( $input[ 'id' ], '.' ) ) { |
|
247 | 247 | continue; |
248 | 248 | } |
249 | - $fields["{$input['id']}"] = array( |
|
249 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
250 | 250 | 'label' => rgar( $input, 'label' ), |
251 | 251 | 'customLabel' => rgar( $input, 'customLabel' ), |
252 | 252 | 'parent' => $field, |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | |
261 | - if( GFCommon::is_product_field( $field->type ) ){ |
|
261 | + if ( GFCommon::is_product_field( $field->type ) ) { |
|
262 | 262 | $has_product_fields = true; |
263 | 263 | } |
264 | 264 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @since 1.7 |
273 | 273 | */ |
274 | 274 | if ( $has_post_fields ) { |
275 | - $fields['post_id'] = array( |
|
275 | + $fields[ 'post_id' ] = array( |
|
276 | 276 | 'label' => __( 'Post ID', 'gravityview' ), |
277 | 277 | 'type' => 'post_id', |
278 | 278 | ); |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | $payment_fields = GravityView_Fields::get_all( 'pricing' ); |
284 | 284 | |
285 | 285 | foreach ( $payment_fields as $payment_field ) { |
286 | - if( isset( $fields["{$payment_field->name}"] ) ) { |
|
286 | + if ( isset( $fields[ "{$payment_field->name}" ] ) ) { |
|
287 | 287 | continue; |
288 | 288 | } |
289 | - $fields["{$payment_field->name}"] = array( |
|
289 | + $fields[ "{$payment_field->name}" ] = array( |
|
290 | 290 | 'label' => $payment_field->label, |
291 | 291 | 'desc' => $payment_field->description, |
292 | 292 | 'type' => $payment_field->name, |
@@ -318,9 +318,9 @@ discard block |
||
318 | 318 | |
319 | 319 | $fields = array(); |
320 | 320 | |
321 | - foreach ( $extra_fields as $key => $field ){ |
|
322 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
323 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
321 | + foreach ( $extra_fields as $key => $field ) { |
|
322 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
323 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -360,32 +360,32 @@ discard block |
||
360 | 360 | 'search_criteria' => null, |
361 | 361 | 'sorting' => null, |
362 | 362 | 'paging' => null, |
363 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
363 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ), |
|
364 | 364 | ); |
365 | 365 | |
366 | 366 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
367 | 367 | |
368 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
369 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
368 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
369 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
370 | 370 | |
371 | 371 | if ( ! is_array( $filter ) ) { |
372 | 372 | continue; |
373 | 373 | } |
374 | 374 | |
375 | 375 | // By default, we want searches to be wildcard for each field. |
376 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
376 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
377 | 377 | |
378 | 378 | /** |
379 | 379 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
380 | 380 | * @param string $operator Existing search operator |
381 | 381 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
382 | 382 | */ |
383 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
383 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | // don't send just the [mode] without any field filter. |
387 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
388 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
387 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
388 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | } |
@@ -396,21 +396,21 @@ discard block |
||
396 | 396 | * Prepare date formats to be in Gravity Forms DB format; |
397 | 397 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
398 | 398 | */ |
399 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
399 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
400 | 400 | |
401 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
401 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
402 | 402 | |
403 | 403 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
404 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
404 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
405 | 405 | |
406 | 406 | if ( $date ) { |
407 | 407 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
408 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
408 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
409 | 409 | } else { |
410 | 410 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
411 | - unset( $criteria['search_criteria'][ $key ] ); |
|
411 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
412 | 412 | |
413 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
413 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 | } |
@@ -418,12 +418,12 @@ discard block |
||
418 | 418 | |
419 | 419 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
420 | 420 | if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
421 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
421 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
422 | 422 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
423 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
424 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
423 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
424 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
425 | 425 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
426 | - $criteria['context_view_id'] = null; |
|
426 | + $criteria[ 'context_view_id' ] = null; |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param array $form_ids Forms to search |
433 | 433 | * @param int $view_id ID of the view being used to search |
434 | 434 | */ |
435 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
435 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
436 | 436 | |
437 | 437 | return (array)$criteria; |
438 | 438 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | /** Reduce # of database calls */ |
464 | 464 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
465 | 465 | |
466 | - if ( ! empty( $criteria['cache'] ) ) { |
|
466 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
467 | 467 | |
468 | 468 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
469 | 469 | |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | |
472 | 472 | // Still update the total count when using cached results |
473 | 473 | if ( ! is_null( $total ) ) { |
474 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
474 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | $return = $entries; |
@@ -491,9 +491,9 @@ discard block |
||
491 | 491 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
492 | 492 | |
493 | 493 | // No entries returned from gravityview_before_get_entries |
494 | - if( is_null( $entries ) ) { |
|
494 | + if ( is_null( $entries ) ) { |
|
495 | 495 | |
496 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
496 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
497 | 497 | |
498 | 498 | if ( is_wp_error( $entries ) ) { |
499 | 499 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | } |
503 | 503 | } |
504 | 504 | |
505 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
505 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
506 | 506 | |
507 | 507 | // Cache results |
508 | 508 | $Cache->set( $entries, 'entries' ); |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | */ |
590 | 590 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
591 | 591 | |
592 | - if( $check_entry_display ) { |
|
592 | + if ( $check_entry_display ) { |
|
593 | 593 | // Is the entry allowed |
594 | 594 | $entry = self::check_entry_display( $entry ); |
595 | 595 | } |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | |
623 | 623 | $value = false; |
624 | 624 | |
625 | - if( 'context' === $val1 ) { |
|
625 | + if ( 'context' === $val1 ) { |
|
626 | 626 | |
627 | 627 | $matching_contexts = array( $val2 ); |
628 | 628 | |
629 | 629 | // We allow for non-standard contexts. |
630 | - switch( $val2 ) { |
|
630 | + switch ( $val2 ) { |
|
631 | 631 | // Check for either single or edit |
632 | 632 | case 'singular': |
633 | 633 | $matching_contexts = array( 'single', 'edit' ); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | return false; |
688 | 688 | } |
689 | 689 | |
690 | - if ( empty( $entry['form_id'] ) ) { |
|
690 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
691 | 691 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
692 | 692 | return false; |
693 | 693 | } |
@@ -695,26 +695,26 @@ discard block |
||
695 | 695 | $criteria = self::calculate_get_entries_criteria(); |
696 | 696 | |
697 | 697 | // Make sure the current View is connected to the same form as the Entry |
698 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
699 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
698 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
699 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
700 | 700 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
701 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
702 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
701 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
702 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
703 | 703 | return false; |
704 | 704 | } |
705 | 705 | } |
706 | 706 | |
707 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
707 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
708 | 708 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
709 | 709 | return $entry; |
710 | 710 | } |
711 | 711 | |
712 | - $search_criteria = $criteria['search_criteria']; |
|
712 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
713 | 713 | unset( $criteria ); |
714 | 714 | |
715 | 715 | // check entry status |
716 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
717 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
716 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
717 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
718 | 718 | return false; |
719 | 719 | } |
720 | 720 | |
@@ -722,37 +722,37 @@ discard block |
||
722 | 722 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
723 | 723 | |
724 | 724 | // field_filters |
725 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
725 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
726 | 726 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
727 | 727 | return $entry; |
728 | 728 | } |
729 | 729 | |
730 | - $filters = $search_criteria['field_filters']; |
|
730 | + $filters = $search_criteria[ 'field_filters' ]; |
|
731 | 731 | unset( $search_criteria ); |
732 | 732 | |
733 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
734 | - unset( $filters['mode'] ); |
|
733 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
734 | + unset( $filters[ 'mode' ] ); |
|
735 | 735 | |
736 | - $form = self::get_form( $entry['form_id'] ); |
|
736 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
737 | 737 | |
738 | 738 | foreach ( $filters as $filter ) { |
739 | 739 | |
740 | - if ( ! isset( $filter['key'] ) ) { |
|
740 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
741 | 741 | continue; |
742 | 742 | } |
743 | 743 | |
744 | - $k = $filter['key']; |
|
744 | + $k = $filter[ 'key' ]; |
|
745 | 745 | |
746 | 746 | if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
747 | 747 | $field_value = $entry[ $k ]; |
748 | 748 | $field = null; |
749 | 749 | } else { |
750 | 750 | $field = self::get_field( $form, $k ); |
751 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
751 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
752 | 752 | } |
753 | 753 | |
754 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
755 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
754 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
755 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
756 | 756 | |
757 | 757 | // verify if we are already free to go! |
758 | 758 | if ( ! $is_value_match && 'all' === $mode ) { |
@@ -810,18 +810,18 @@ discard block |
||
810 | 810 | * Gravity Forms code to adjust date to locally-configured Time Zone |
811 | 811 | * @see GFCommon::format_date() for original code |
812 | 812 | */ |
813 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
813 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
814 | 814 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
815 | 815 | |
816 | - $format = rgar( $atts, 'format' ); |
|
817 | - $is_human = ! empty( $atts['human'] ); |
|
818 | - $is_diff = ! empty( $atts['diff'] ); |
|
819 | - $is_raw = ! empty( $atts['raw'] ); |
|
820 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
821 | - $include_time = ! empty( $atts['time'] ); |
|
816 | + $format = rgar( $atts, 'format' ); |
|
817 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
818 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
819 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
820 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
821 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
822 | 822 | |
823 | 823 | // If we're using time diff, we want to have a different default format |
824 | - if( empty( $format ) ) { |
|
824 | + if ( empty( $format ) ) { |
|
825 | 825 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
826 | 826 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
827 | 827 | } |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | // If raw was specified, don't modify the stored value |
830 | 830 | if ( $is_raw ) { |
831 | 831 | $formatted_date = $date_string; |
832 | - } elseif( $is_timestamp ) { |
|
832 | + } elseif ( $is_timestamp ) { |
|
833 | 833 | $formatted_date = $date_local_timestamp; |
834 | 834 | } elseif ( $is_diff ) { |
835 | 835 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | |
864 | 864 | $label = rgar( $field, 'label' ); |
865 | 865 | |
866 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
866 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
867 | 867 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
868 | 868 | } |
869 | 869 | |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | * @return GF_Field|null Gravity Forms field object, or NULL: Gravity Forms GFFormsModel does not exist or field at $field_id doesn't exist. |
885 | 885 | */ |
886 | 886 | public static function get_field( $form, $field_id ) { |
887 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
887 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
888 | 888 | return GFFormsModel::get_field( $form, $field_id ); |
889 | 889 | } else { |
890 | 890 | return null; |
@@ -931,19 +931,19 @@ discard block |
||
931 | 931 | $shortcodes = array(); |
932 | 932 | |
933 | 933 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
934 | - if ( empty( $matches ) ){ |
|
934 | + if ( empty( $matches ) ) { |
|
935 | 935 | return false; |
936 | 936 | } |
937 | 937 | |
938 | 938 | foreach ( $matches as $shortcode ) { |
939 | - if ( $tag === $shortcode[2] ) { |
|
939 | + if ( $tag === $shortcode[ 2 ] ) { |
|
940 | 940 | |
941 | 941 | // Changed this to $shortcode instead of true so we get the parsed atts. |
942 | - $shortcodes[] = $shortcode; |
|
942 | + $shortcodes[ ] = $shortcode; |
|
943 | 943 | |
944 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
945 | - foreach( $results as $result ) { |
|
946 | - $shortcodes[] = $result; |
|
944 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
945 | + foreach ( $results as $result ) { |
|
946 | + $shortcodes[ ] = $result; |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | } |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | public static function get_directory_fields( $post_id, $apply_filter = true ) { |
1088 | 1088 | $fields = get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
1089 | 1089 | |
1090 | - if( $apply_filter ) { |
|
1090 | + if ( $apply_filter ) { |
|
1091 | 1091 | /** |
1092 | 1092 | * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
1093 | 1093 | * @since 1.6.5 |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | * @return string html |
1111 | 1111 | */ |
1112 | 1112 | public static function get_sortable_fields( $formid, $current = '' ) { |
1113 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1113 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1114 | 1114 | |
1115 | 1115 | if ( empty( $formid ) ) { |
1116 | 1116 | return $output; |
@@ -1123,11 +1123,11 @@ discard block |
||
1123 | 1123 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1124 | 1124 | |
1125 | 1125 | foreach ( $fields as $id => $field ) { |
1126 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1126 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1127 | 1127 | continue; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1130 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1131 | 1131 | } |
1132 | 1132 | } |
1133 | 1133 | |
@@ -1162,9 +1162,9 @@ discard block |
||
1162 | 1162 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1163 | 1163 | |
1164 | 1164 | // TODO: Convert to using array_filter |
1165 | - foreach( $fields as $id => $field ) { |
|
1165 | + foreach ( $fields as $id => $field ) { |
|
1166 | 1166 | |
1167 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1167 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1168 | 1168 | unset( $fields[ $id ] ); |
1169 | 1169 | } |
1170 | 1170 | } |
@@ -1205,14 +1205,14 @@ discard block |
||
1205 | 1205 | * @param int|array $field field key or field array |
1206 | 1206 | * @return boolean |
1207 | 1207 | */ |
1208 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1208 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1209 | 1209 | |
1210 | 1210 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1211 | 1211 | $form = self::get_form( $form ); |
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | // If entry meta, it's a string. Otherwise, numeric |
1215 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1215 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1216 | 1216 | $type = $field; |
1217 | 1217 | } else { |
1218 | 1218 | $type = self::get_field_type( $form, $field ); |
@@ -1226,9 +1226,9 @@ discard block |
||
1226 | 1226 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1227 | 1227 | |
1228 | 1228 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1229 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1230 | - if( true === $gv_field->is_numeric ) { |
|
1231 | - $numeric_types[] = $gv_field->is_numeric; |
|
1229 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1230 | + if ( true === $gv_field->is_numeric ) { |
|
1231 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1232 | 1232 | } |
1233 | 1233 | } |
1234 | 1234 | |
@@ -1378,18 +1378,18 @@ discard block |
||
1378 | 1378 | $final_atts = array_filter( $final_atts ); |
1379 | 1379 | |
1380 | 1380 | // If the href wasn't passed as an attribute, use the value passed to the function |
1381 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1382 | - $final_atts['href'] = $href; |
|
1381 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1382 | + $final_atts[ 'href' ] = $href; |
|
1383 | 1383 | } |
1384 | 1384 | |
1385 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1385 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1386 | 1386 | |
1387 | 1387 | /** |
1388 | 1388 | * Fix potential security issue with target=_blank |
1389 | 1389 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1390 | 1390 | */ |
1391 | - if( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
1392 | - $final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1391 | + if ( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
1392 | + $final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | // Sort the attributes alphabetically, to help testing |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1402 | 1402 | } |
1403 | 1403 | |
1404 | - if( '' !== $output ) { |
|
1404 | + if ( '' !== $output ) { |
|
1405 | 1405 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1406 | 1406 | } |
1407 | 1407 | |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1429 | 1429 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1430 | 1430 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1431 | - $merged[] = $value; |
|
1431 | + $merged[ ] = $value; |
|
1432 | 1432 | } else { |
1433 | 1433 | $merged[ $key ] = $value; |
1434 | 1434 | } |
@@ -1461,7 +1461,7 @@ discard block |
||
1461 | 1461 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1462 | 1462 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1463 | 1463 | */ |
1464 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1464 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1465 | 1465 | |
1466 | 1466 | return get_users( $get_users_settings ); |
1467 | 1467 | } |
@@ -1476,7 +1476,7 @@ discard block |
||
1476 | 1476 | * @return string |
1477 | 1477 | */ |
1478 | 1478 | public static function generate_notice( $notice, $class = '' ) { |
1479 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1479 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | /** |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * |
50 | 50 | * @return string If a custom field label isn't set, return the field label for the password field |
51 | 51 | */ |
52 | - function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){ |
|
52 | + function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) { |
|
53 | 53 | |
54 | 54 | // If using a custom label, no need to fetch the parent label |
55 | 55 | if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { |
@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return string If a custom field label isn't set, return the field label for the password field |
51 | 51 | */ |
52 | - function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){ |
|
52 | + function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) { |
|
53 | 53 | |
54 | 54 | // If using a custom label, no need to fetch the parent label |
55 | - if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { |
|
55 | + if ( ! is_numeric( $field[ 'id' ] ) || ! empty( $field[ 'custom_label' ] ) ) { |
|
56 | 56 | return $label; |
57 | 57 | } |
58 | 58 | |
59 | - $field_object = GFFormsModel::get_field( $form, $field['id'] ); |
|
59 | + $field_object = GFFormsModel::get_field( $form, $field[ 'id' ] ); |
|
60 | 60 | |
61 | - if( $field_object && 'password' === $field_object->type ) { |
|
62 | - $label = $field['label']; |
|
61 | + if ( $field_object && 'password' === $field_object->type ) { |
|
62 | + $label = $field[ 'label' ]; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return $label; |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | function add_form_fields( $fields = array(), $form = array(), $include_parent_field = true ) { |
80 | 80 | |
81 | 81 | foreach ( $fields as $key => $field ) { |
82 | - if( 'password' === $field['type'] ) { |
|
82 | + if ( 'password' === $field[ 'type' ] ) { |
|
83 | 83 | |
84 | 84 | // The Enter Password input |
85 | - if( floor( $key ) === floatval( $key ) ) { |
|
85 | + if ( floor( $key ) === floatval( $key ) ) { |
|
86 | 86 | |
87 | - if( ! empty( $field['parent'] ) ) { |
|
88 | - $field['label'] = $field['parent']->label; |
|
89 | - $field['adminOnly'] = $field['parent']->adminOnly; |
|
90 | - $field['adminLabel'] = $field['parent']->adminLabel; |
|
87 | + if ( ! empty( $field[ 'parent' ] ) ) { |
|
88 | + $field[ 'label' ] = $field[ 'parent' ]->label; |
|
89 | + $field[ 'adminOnly' ] = $field[ 'parent' ]->adminOnly; |
|
90 | + $field[ 'adminLabel' ] = $field[ 'parent' ]->adminLabel; |
|
91 | 91 | // Don't show as a child input |
92 | - unset( $field['parent'] ); |
|
92 | + unset( $field[ 'parent' ] ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $fields[ $key ] = $field; |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | 'slug' => 'edit', |
25 | 25 | 'type' => 'internal', |
26 | 26 | 'label' => __( 'Edit Table', 'gravityview' ), |
27 | - 'description' => __('Display items in a table view.', 'gravityview'), |
|
28 | - 'logo' => plugins_url('includes/presets/default-table/logo-default-table.png', GRAVITYVIEW_FILE), |
|
27 | + 'description' => __( 'Display items in a table view.', 'gravityview' ), |
|
28 | + 'logo' => plugins_url( 'includes/presets/default-table/logo-default-table.png', GRAVITYVIEW_FILE ), |
|
29 | 29 | 'css_source' => gravityview_css_url( 'table-view.css', GRAVITYVIEW_DIR . 'templates/css/' ), |
30 | 30 | ); |
31 | 31 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | '1-1' => array( |
43 | 43 | array( |
44 | 44 | 'areaid' => 'edit-fields', |
45 | - 'title' => __('Visible Edit Fields', 'gravityview' ) |
|
45 | + 'title' => __( 'Visible Edit Fields', 'gravityview' ) |
|
46 | 46 | ) |
47 | 47 | ) |
48 | 48 | ) |
@@ -36,7 +36,6 @@ |
||
36 | 36 | * @since 1.16.4 |
37 | 37 | * @since 1.17 Moved to GravityView_Plugin_Hooks_Gravity_Forms_Survey class |
38 | 38 | * |
39 | - * @param array $form |
|
40 | 39 | * |
41 | 40 | * @return array Form, with all fields set to `allowsPrepopulate => true` |
42 | 41 | */ |
@@ -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 | } |
@@ -7,133 +7,133 @@ |
||
7 | 7 | |
8 | 8 | class GravityView_GFFormsModel extends GFFormsModel { |
9 | 9 | |
10 | - /** |
|
11 | - * Given information provided in an entry, get array of media IDs |
|
12 | - * |
|
13 | - * This is necessary because GF doesn't expect to need to update post images, only to create them. |
|
14 | - * |
|
15 | - * @see GFFormsModel::create_post() |
|
16 | - * |
|
17 | - * @since 1.17 |
|
18 | - * |
|
19 | - * @param array $form Gravity Forms form array |
|
20 | - * @param array $entry Gravity Forms entry array |
|
21 | - * |
|
22 | - * @return array Array of "Field ID" => "Media IDs" |
|
23 | - */ |
|
24 | - public static function get_post_field_images( $form, $entry ) { |
|
25 | - |
|
26 | - $post_data = self::get_post_fields( $form, $entry ); |
|
27 | - |
|
28 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
29 | - |
|
30 | - $post_images = array(); |
|
31 | - |
|
32 | - foreach ( $media as $media_item ) { |
|
33 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
34 | - if( |
|
35 | - rgar( $post_data_item, 'title' ) === $media_item->post_title && |
|
36 | - rgar( $post_data_item, 'description' ) === $media_item->post_content && |
|
37 | - rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
|
38 | - ) { |
|
39 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
40 | - } |
|
41 | - } |
|
42 | - } |
|
43 | - |
|
44 | - return $post_images; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Alias of GFFormsModel::get_post_fields(); just making it public |
|
49 | - * |
|
50 | - * @see GFFormsModel::get_post_fields() |
|
51 | - * |
|
52 | - * @since 1.17 |
|
53 | - * |
|
54 | - * @param array $form Gravity Forms form array |
|
55 | - * @param array $entry Gravity Forms entry array |
|
56 | - * |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public static function get_post_fields( $form, $entry ) { |
|
60 | - |
|
61 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' ); |
|
62 | - |
|
63 | - /** |
|
64 | - * If the method changes to public, use Gravity Forms' method |
|
65 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
66 | - */ |
|
67 | - if( $reflection->isPublic() ) { |
|
68 | - return parent::get_post_fields( $form, $entry ); |
|
69 | - } |
|
70 | - |
|
71 | - // It was private; let's make it public |
|
72 | - $reflection->setAccessible( true ); |
|
73 | - |
|
74 | - return $reflection->invoke( new GFFormsModel, $form, $entry ); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
79 | - * |
|
80 | - * @since 1.16.2 |
|
81 | - * |
|
82 | - * @param string $url URL of the post image to update |
|
83 | - * @param int $post_id ID of the post image to update |
|
84 | - * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
85 | - */ |
|
86 | - public static function copy_post_image( $url, $post_id ) { |
|
87 | - |
|
88 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
89 | - |
|
90 | - /** |
|
91 | - * If the method changes to public, use Gravity Forms' method |
|
92 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
93 | - */ |
|
94 | - if( $reflection->isPublic() ) { |
|
95 | - return parent::copy_post_image( $url, $post_id ); |
|
96 | - } |
|
97 | - |
|
98 | - // It was private; let's make it public |
|
99 | - $reflection->setAccessible( true ); |
|
100 | - |
|
101 | - return $reflection->invoke( new GFFormsModel, $url, $post_id ); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
106 | - * |
|
107 | - * Note: The method became public in GF 1.9.17.7 |
|
108 | - * |
|
109 | - * @see GFFormsModel::media_handle_upload |
|
110 | - * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
111 | - * |
|
112 | - * @uses copy_post_image |
|
113 | - * @uses wp_insert_attachment |
|
114 | - * @uses wp_update_attachment_metadata |
|
115 | - * |
|
116 | - * @param string $url URL of the post image to update |
|
117 | - * @param int $post_id ID of the post image to update |
|
118 | - * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys. |
|
119 | - * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
120 | - */ |
|
121 | - public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
122 | - |
|
123 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
124 | - |
|
125 | - /** |
|
126 | - * If the method changes to public, use Gravity Forms' method |
|
127 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
128 | - */ |
|
129 | - if( $reflection->isPublic() ) { |
|
130 | - return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
131 | - } |
|
132 | - |
|
133 | - // It was private; let's make it public |
|
134 | - $reflection->setAccessible( true ); |
|
135 | - |
|
136 | - return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data ); |
|
137 | - } |
|
10 | + /** |
|
11 | + * Given information provided in an entry, get array of media IDs |
|
12 | + * |
|
13 | + * This is necessary because GF doesn't expect to need to update post images, only to create them. |
|
14 | + * |
|
15 | + * @see GFFormsModel::create_post() |
|
16 | + * |
|
17 | + * @since 1.17 |
|
18 | + * |
|
19 | + * @param array $form Gravity Forms form array |
|
20 | + * @param array $entry Gravity Forms entry array |
|
21 | + * |
|
22 | + * @return array Array of "Field ID" => "Media IDs" |
|
23 | + */ |
|
24 | + public static function get_post_field_images( $form, $entry ) { |
|
25 | + |
|
26 | + $post_data = self::get_post_fields( $form, $entry ); |
|
27 | + |
|
28 | + $media = get_attached_media( 'image', $entry['post_id'] ); |
|
29 | + |
|
30 | + $post_images = array(); |
|
31 | + |
|
32 | + foreach ( $media as $media_item ) { |
|
33 | + foreach( (array) $post_data['images'] as $post_data_item ) { |
|
34 | + if( |
|
35 | + rgar( $post_data_item, 'title' ) === $media_item->post_title && |
|
36 | + rgar( $post_data_item, 'description' ) === $media_item->post_content && |
|
37 | + rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
|
38 | + ) { |
|
39 | + $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
40 | + } |
|
41 | + } |
|
42 | + } |
|
43 | + |
|
44 | + return $post_images; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Alias of GFFormsModel::get_post_fields(); just making it public |
|
49 | + * |
|
50 | + * @see GFFormsModel::get_post_fields() |
|
51 | + * |
|
52 | + * @since 1.17 |
|
53 | + * |
|
54 | + * @param array $form Gravity Forms form array |
|
55 | + * @param array $entry Gravity Forms entry array |
|
56 | + * |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public static function get_post_fields( $form, $entry ) { |
|
60 | + |
|
61 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' ); |
|
62 | + |
|
63 | + /** |
|
64 | + * If the method changes to public, use Gravity Forms' method |
|
65 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
66 | + */ |
|
67 | + if( $reflection->isPublic() ) { |
|
68 | + return parent::get_post_fields( $form, $entry ); |
|
69 | + } |
|
70 | + |
|
71 | + // It was private; let's make it public |
|
72 | + $reflection->setAccessible( true ); |
|
73 | + |
|
74 | + return $reflection->invoke( new GFFormsModel, $form, $entry ); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
79 | + * |
|
80 | + * @since 1.16.2 |
|
81 | + * |
|
82 | + * @param string $url URL of the post image to update |
|
83 | + * @param int $post_id ID of the post image to update |
|
84 | + * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
85 | + */ |
|
86 | + public static function copy_post_image( $url, $post_id ) { |
|
87 | + |
|
88 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
89 | + |
|
90 | + /** |
|
91 | + * If the method changes to public, use Gravity Forms' method |
|
92 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
93 | + */ |
|
94 | + if( $reflection->isPublic() ) { |
|
95 | + return parent::copy_post_image( $url, $post_id ); |
|
96 | + } |
|
97 | + |
|
98 | + // It was private; let's make it public |
|
99 | + $reflection->setAccessible( true ); |
|
100 | + |
|
101 | + return $reflection->invoke( new GFFormsModel, $url, $post_id ); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
106 | + * |
|
107 | + * Note: The method became public in GF 1.9.17.7 |
|
108 | + * |
|
109 | + * @see GFFormsModel::media_handle_upload |
|
110 | + * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
111 | + * |
|
112 | + * @uses copy_post_image |
|
113 | + * @uses wp_insert_attachment |
|
114 | + * @uses wp_update_attachment_metadata |
|
115 | + * |
|
116 | + * @param string $url URL of the post image to update |
|
117 | + * @param int $post_id ID of the post image to update |
|
118 | + * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys. |
|
119 | + * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
120 | + */ |
|
121 | + public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
122 | + |
|
123 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
124 | + |
|
125 | + /** |
|
126 | + * If the method changes to public, use Gravity Forms' method |
|
127 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
128 | + */ |
|
129 | + if( $reflection->isPublic() ) { |
|
130 | + return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
131 | + } |
|
132 | + |
|
133 | + // It was private; let's make it public |
|
134 | + $reflection->setAccessible( true ); |
|
135 | + |
|
136 | + return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data ); |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
140 | 140 | \ No newline at end of file |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | |
26 | 26 | $post_data = self::get_post_fields( $form, $entry ); |
27 | 27 | |
28 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
28 | + $media = get_attached_media( 'image', $entry[ 'post_id' ] ); |
|
29 | 29 | |
30 | 30 | $post_images = array(); |
31 | 31 | |
32 | 32 | foreach ( $media as $media_item ) { |
33 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
34 | - if( |
|
33 | + foreach ( (array)$post_data[ 'images' ] as $post_data_item ) { |
|
34 | + if ( |
|
35 | 35 | rgar( $post_data_item, 'title' ) === $media_item->post_title && |
36 | 36 | rgar( $post_data_item, 'description' ) === $media_item->post_content && |
37 | 37 | rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
38 | 38 | ) { |
39 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
39 | + $post_images[ "{$post_data_item[ 'field_id' ]}" ] = $media_item->ID; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * If the method changes to public, use Gravity Forms' method |
65 | 65 | * @todo: If/when the method is public, remove the unneeded copied code. |
66 | 66 | */ |
67 | - if( $reflection->isPublic() ) { |
|
67 | + if ( $reflection->isPublic() ) { |
|
68 | 68 | return parent::get_post_fields( $form, $entry ); |
69 | 69 | } |
70 | 70 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * If the method changes to public, use Gravity Forms' method |
92 | 92 | * @todo: If/when the method is public, remove the unneeded copied code. |
93 | 93 | */ |
94 | - if( $reflection->isPublic() ) { |
|
94 | + if ( $reflection->isPublic() ) { |
|
95 | 95 | return parent::copy_post_image( $url, $post_id ); |
96 | 96 | } |
97 | 97 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * If the method changes to public, use Gravity Forms' method |
127 | 127 | * @todo: If/when the method is public, remove the unneeded copied code. |
128 | 128 | */ |
129 | - if( $reflection->isPublic() ) { |
|
129 | + if ( $reflection->isPublic() ) { |
|
130 | 130 | return parent::media_handle_upload( $url, $post_id, $post_data ); |
131 | 131 | } |
132 | 132 |
@@ -47,7 +47,7 @@ |
||
47 | 47 | function edit_entry_fix_hidden_fields( $fields ) { |
48 | 48 | |
49 | 49 | /** @var GF_Field $field */ |
50 | - foreach( $fields as &$field ) { |
|
50 | + foreach ( $fields as &$field ) { |
|
51 | 51 | if ( 'hidden' === $field->type ) { |
52 | 52 | |
53 | 53 | // Replace GF_Field_Hidden with GF_Field_Text, copying all the data from $field |