@@ -30,29 +30,29 @@ discard block |
||
30 | 30 | |
31 | 31 | $label = ''; |
32 | 32 | |
33 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
33 | + if ( ! empty( $field[ 'show_label' ] ) || $force_show_label ) { |
|
34 | 34 | |
35 | - $label = $field['label']; |
|
35 | + $label = $field[ 'label' ]; |
|
36 | 36 | |
37 | 37 | // Support Gravity Forms 1.9+ |
38 | - if( class_exists( 'GF_Field' ) ) { |
|
38 | + if ( class_exists( 'GF_Field' ) ) { |
|
39 | 39 | |
40 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
40 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
41 | 41 | |
42 | - if( $field_object ) { |
|
42 | + if ( $field_object ) { |
|
43 | 43 | |
44 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
44 | + $input = GFFormsModel::get_input( $field_object, $field[ 'id' ] ); |
|
45 | 45 | |
46 | 46 | // This is a complex field, with labels on a per-input basis |
47 | - if( $input ) { |
|
47 | + if ( $input ) { |
|
48 | 48 | |
49 | 49 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
50 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
50 | + $label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ]; |
|
51 | 51 | |
52 | 52 | } else { |
53 | 53 | |
54 | 54 | // This is a field with one label |
55 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
55 | + $label = $field_object->get_field_label( true, $field[ 'label' ] ); |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
64 | - if ( !empty( $field['custom_label'] ) ) { |
|
64 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
65 | 65 | |
66 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
66 | + $label = self::replace_variables( $field[ 'custom_label' ], $form, $entry ); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | |
118 | 118 | $width = NULL; |
119 | 119 | |
120 | - if( !empty( $field['width'] ) ) { |
|
121 | - $width = absint( $field['width'] ); |
|
120 | + if ( ! empty( $field[ 'width' ] ) ) { |
|
121 | + $width = absint( $field[ 'width' ] ); |
|
122 | 122 | |
123 | 123 | // If using percentages, limit to 100% |
124 | - if( '%d%%' === $format && $width > 100 ) { |
|
124 | + if ( '%d%%' === $format && $width > 100 ) { |
|
125 | 125 | $width = 100; |
126 | 126 | } |
127 | 127 | |
@@ -144,39 +144,39 @@ discard block |
||
144 | 144 | |
145 | 145 | $classes = array(); |
146 | 146 | |
147 | - if( !empty( $field['custom_class'] ) ) { |
|
147 | + if ( ! empty( $field[ 'custom_class' ] ) ) { |
|
148 | 148 | |
149 | - $custom_class = $field['custom_class']; |
|
149 | + $custom_class = $field[ 'custom_class' ]; |
|
150 | 150 | |
151 | - if( !empty( $entry ) ) { |
|
151 | + if ( ! empty( $entry ) ) { |
|
152 | 152 | |
153 | 153 | // We want the merge tag to be formatted as a class. The merge tag may be |
154 | 154 | // replaced by a multiple-word value that should be output as a single class. |
155 | 155 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
156 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
156 | + add_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
157 | 157 | |
158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
158 | + $custom_class = self::replace_variables( $custom_class, $form, $entry ); |
|
159 | 159 | |
160 | 160 | // And then we want life to return to normal |
161 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
161 | + remove_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // And now we want the spaces to be handled nicely. |
165 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
165 | + $classes[ ] = gravityview_sanitize_html_class( $custom_class ); |
|
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | - if(!empty($field['id'])) { |
|
170 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
171 | - $form_id = '-'.$form['id']; |
|
169 | + if ( ! empty( $field[ 'id' ] ) ) { |
|
170 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
171 | + $form_id = '-' . $form[ 'id' ]; |
|
172 | 172 | } else { |
173 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
173 | + $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
174 | 174 | } |
175 | 175 | |
176 | - $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
|
176 | + $classes[ ] = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
177 | 177 | } |
178 | 178 | |
179 | - return esc_attr(implode(' ', $classes)); |
|
179 | + return esc_attr( implode( ' ', $classes ) ); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -193,16 +193,16 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
195 | 195 | $gravityview_view = GravityView_View::getInstance(); |
196 | - $id = $field['id']; |
|
196 | + $id = $field[ 'id' ]; |
|
197 | 197 | |
198 | 198 | if ( ! empty( $id ) ) { |
199 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
200 | - $form_id = '-' . $form['id']; |
|
199 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
200 | + $form_id = '-' . $form[ 'id' ]; |
|
201 | 201 | } else { |
202 | 202 | $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
203 | 203 | } |
204 | 204 | |
205 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
205 | + $id = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | return esc_attr( $id ); |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public static function field_value( $entry, $field_settings, $format = 'html' ) { |
221 | 221 | |
222 | - if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
222 | + if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) { |
|
223 | 223 | return NULL; |
224 | 224 | } |
225 | 225 | |
226 | 226 | $gravityview_view = GravityView_View::getInstance(); |
227 | 227 | |
228 | - $field_id = $field_settings['id']; |
|
228 | + $field_id = $field_settings[ 'id' ]; |
|
229 | 229 | $form = $gravityview_view->getForm(); |
230 | 230 | $field = gravityview_get_field( $form, $field_id ); |
231 | 231 | |
232 | - if( $field && is_numeric( $field_id ) ) { |
|
232 | + if ( $field && is_numeric( $field_id ) ) { |
|
233 | 233 | // Used as file name of field template in GV. |
234 | 234 | // Don't use RGFormsModel::get_input_type( $field ); we don't care if it's a radio input; we want to know it's a 'quiz' field |
235 | 235 | $field_type = $field->type; |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | // If a Gravity Forms Field is found, get the field display |
243 | - if( $field ) { |
|
243 | + if ( $field ) { |
|
244 | 244 | |
245 | 245 | // Prevent any PHP warnings that may be generated |
246 | 246 | ob_start(); |
247 | 247 | |
248 | - $display_value = GFCommon::get_lead_field_display( $field, $value, $entry["currency"], false, $format ); |
|
248 | + $display_value = GFCommon::get_lead_field_display( $field, $value, $entry[ "currency" ], false, $format ); |
|
249 | 249 | |
250 | 250 | if ( $errors = ob_get_clean() ) { |
251 | 251 | do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors ); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $display_value = apply_filters( "gform_entry_field_value", $display_value, $field, $entry, $form ); |
255 | 255 | |
256 | 256 | // prevent the use of merge_tags for non-admin fields |
257 | - if( !empty( $field->adminOnly ) ) { |
|
257 | + if ( ! empty( $field->adminOnly ) ) { |
|
258 | 258 | $display_value = self::replace_variables( $display_value, $form, $entry ); |
259 | 259 | } |
260 | 260 | } else { |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | // Check whether the field exists in /includes/fields/{$field_type}.php |
266 | 266 | // This can be overridden by user template files. |
267 | - $field_path = $gravityview_view->locate_template("fields/{$field_type}.php"); |
|
267 | + $field_path = $gravityview_view->locate_template( "fields/{$field_type}.php" ); |
|
268 | 268 | |
269 | 269 | // Set the field data to be available in the templates |
270 | 270 | $gravityview_view->setCurrentField( array( |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | 'entry' => $entry, |
279 | 279 | 'field_type' => $field_type, /** {@since 1.6} */ |
280 | 280 | 'field_path' => $field_path, /** {@since 1.16} */ |
281 | - )); |
|
281 | + ) ); |
|
282 | 282 | |
283 | - if( ! empty( $field_path ) ) { |
|
283 | + if ( ! empty( $field_path ) ) { |
|
284 | 284 | |
285 | - do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path ) ); |
|
285 | + do_action( 'gravityview_log_debug', sprintf( '[field_value] Rendering %s', $field_path ) ); |
|
286 | 286 | |
287 | 287 | ob_start(); |
288 | 288 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | } |
299 | 299 | |
300 | 300 | // Get the field settings again so that the field template can override the settings |
301 | - $field_settings = $gravityview_view->getCurrentField('field_settings'); |
|
301 | + $field_settings = $gravityview_view->getCurrentField( 'field_settings' ); |
|
302 | 302 | |
303 | 303 | /** |
304 | 304 | * @filter `gravityview_field_entry_value_{$field_type}_pre_link` Modify the field value output for a field type before Show As Link setting is applied. Example: `gravityview_field_entry_value_number_pre_link` |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example. |
328 | 328 | * |
329 | 329 | */ |
330 | - if( !empty( $field_settings['show_as_link'] ) && ! gv_empty( $output, false, false ) ) { |
|
330 | + if ( ! empty( $field_settings[ 'show_as_link' ] ) && ! gv_empty( $output, false, false ) ) { |
|
331 | 331 | |
332 | - $link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' ); |
|
332 | + $link_atts = empty( $field_settings[ 'new_window' ] ) ? array() : array( 'target' => '_blank' ); |
|
333 | 333 | |
334 | 334 | $output = self::entry_link_html( $entry, $output, $link_atts, $field_settings ); |
335 | 335 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param array $field_settings Settings for the particular GV field |
344 | 344 | * @param array $field Current field being displayed |
345 | 345 | */ |
346 | - $output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
346 | + $output = apply_filters( 'gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
347 | 347 | |
348 | 348 | /** |
349 | 349 | * @filter `gravityview_field_entry_value` Modify the field value output for all field types |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) { |
374 | 374 | |
375 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
375 | + if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) { |
|
376 | 376 | do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry ); |
377 | 377 | return NULL; |
378 | 378 | } |
379 | 379 | |
380 | 380 | $href = self::entry_link( $entry ); |
381 | 381 | |
382 | - if( '' === $href ) { |
|
382 | + if ( '' === $href ) { |
|
383 | 383 | return NULL; |
384 | 384 | } |
385 | 385 | |
@@ -402,19 +402,19 @@ discard block |
||
402 | 402 | * @param boolean $wpautop Apply wpautop() to the output? |
403 | 403 | * @return string HTML of "no results" text |
404 | 404 | */ |
405 | - public static function no_results($wpautop = true) { |
|
405 | + public static function no_results( $wpautop = true ) { |
|
406 | 406 | $gravityview_view = GravityView_View::getInstance(); |
407 | 407 | |
408 | 408 | $is_search = false; |
409 | 409 | |
410 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
410 | + if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
411 | 411 | $is_search = true; |
412 | 412 | } |
413 | 413 | |
414 | - if($is_search) { |
|
415 | - $output = __('This search returned no results.', 'gravityview'); |
|
414 | + if ( $is_search ) { |
|
415 | + $output = __( 'This search returned no results.', 'gravityview' ); |
|
416 | 416 | } else { |
417 | - $output = __('No entries match your request.', 'gravityview'); |
|
417 | + $output = __( 'No entries match your request.', 'gravityview' ); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -422,9 +422,9 @@ discard block |
||
422 | 422 | * @param string $output The existing "No Entries" text |
423 | 423 | * @param boolean $is_search Is the current page a search result, or just a multiple entries screen? |
424 | 424 | */ |
425 | - $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search); |
|
425 | + $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search ); |
|
426 | 426 | |
427 | - return $wpautop ? wpautop($output) : $output; |
|
427 | + return $wpautop ? wpautop( $output ) : $output; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -441,37 +441,37 @@ discard block |
||
441 | 441 | |
442 | 442 | $gravityview_view = GravityView_View::getInstance(); |
443 | 443 | |
444 | - if( empty( $post_id ) ) { |
|
444 | + if ( empty( $post_id ) ) { |
|
445 | 445 | |
446 | 446 | $post_id = false; |
447 | 447 | |
448 | 448 | // DataTables passes the Post ID |
449 | - if( defined('DOING_AJAX') && DOING_AJAX ) { |
|
449 | + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
450 | 450 | |
451 | - $post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false; |
|
451 | + $post_id = isset( $_POST[ 'post_id' ] ) ? (int)$_POST[ 'post_id' ] : false; |
|
452 | 452 | |
453 | 453 | } else { |
454 | 454 | |
455 | 455 | // The Post ID has been passed via the shortcode |
456 | - if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
456 | + if ( ! empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
457 | 457 | |
458 | 458 | $post_id = $gravityview_view->getPostId(); |
459 | 459 | |
460 | 460 | } else { |
461 | 461 | |
462 | 462 | // This is a GravityView post type |
463 | - if( GravityView_frontend::getInstance()->isGravityviewPostType() ) { |
|
463 | + if ( GravityView_frontend::getInstance()->isGravityviewPostType() ) { |
|
464 | 464 | |
465 | 465 | $post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID; |
466 | 466 | |
467 | 467 | } else { |
468 | 468 | |
469 | 469 | // This is an embedded GravityView; use the embedded post's ID as the base. |
470 | - if( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) { |
|
470 | + if ( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) { |
|
471 | 471 | |
472 | 472 | $post_id = $post->ID; |
473 | 473 | |
474 | - } elseif( $gravityview_view->getViewId() ) { |
|
474 | + } elseif ( $gravityview_view->getViewId() ) { |
|
475 | 475 | |
476 | 476 | // The GravityView has been embedded in a widget or in a template, and |
477 | 477 | // is not in the current content. Thus, we defer to the View's own ID. |
@@ -486,40 +486,40 @@ discard block |
||
486 | 486 | } |
487 | 487 | |
488 | 488 | // No post ID, get outta here. |
489 | - if( empty( $post_id ) ) { |
|
489 | + if ( empty( $post_id ) ) { |
|
490 | 490 | return NULL; |
491 | 491 | } |
492 | 492 | |
493 | 493 | // If we've saved the permalink in memory, use it |
494 | 494 | // @since 1.3 |
495 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
495 | + $link = wp_cache_get( 'gv_directory_link_' . $post_id ); |
|
496 | 496 | |
497 | - if( (int) $post_id === (int) get_option( 'page_on_front' ) ) { |
|
497 | + if ( (int)$post_id === (int)get_option( 'page_on_front' ) ) { |
|
498 | 498 | $link = home_url(); |
499 | 499 | } |
500 | 500 | |
501 | - if( empty( $link ) ) { |
|
501 | + if ( empty( $link ) ) { |
|
502 | 502 | |
503 | 503 | $link = get_permalink( $post_id ); |
504 | 504 | |
505 | 505 | // If not yet saved, cache the permalink. |
506 | 506 | // @since 1.3 |
507 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
507 | + wp_cache_set( 'gv_directory_link_' . $post_id, $link ); |
|
508 | 508 | |
509 | 509 | } |
510 | 510 | |
511 | 511 | // Deal with returning to proper pagination for embedded views |
512 | - if( $link && $add_query_args ) { |
|
512 | + if ( $link && $add_query_args ) { |
|
513 | 513 | |
514 | 514 | $args = array(); |
515 | 515 | |
516 | - if( $pagenum = rgget('pagenum') ) { |
|
517 | - $args['pagenum'] = intval( $pagenum ); |
|
516 | + if ( $pagenum = rgget( 'pagenum' ) ) { |
|
517 | + $args[ 'pagenum' ] = intval( $pagenum ); |
|
518 | 518 | } |
519 | 519 | |
520 | - if( $sort = rgget('sort') ) { |
|
521 | - $args['sort'] = $sort; |
|
522 | - $args['dir'] = rgget('dir'); |
|
520 | + if ( $sort = rgget( 'sort' ) ) { |
|
521 | + $args[ 'sort' ] = $sort; |
|
522 | + $args[ 'dir' ] = rgget( 'dir' ); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | $link = add_query_arg( $args, $link ); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | private static function get_custom_entry_slug( $id, $entry = array() ) { |
551 | 551 | |
552 | 552 | // Generate an unique hash to use as the default value |
553 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
553 | + $slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 ); |
|
554 | 554 | |
555 | 555 | /** |
556 | 556 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
562 | 562 | |
563 | 563 | // Make sure we have something - use the original ID as backup. |
564 | - if( empty( $slug ) ) { |
|
564 | + if ( empty( $slug ) ) { |
|
565 | 565 | $slug = $id; |
566 | 566 | } |
567 | 567 | |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
591 | 591 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
592 | 592 | */ |
593 | - $custom = apply_filters('gravityview_custom_entry_slug', false ); |
|
593 | + $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
594 | 594 | |
595 | 595 | // If we're using custom slug... |
596 | 596 | if ( $custom ) { |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | // If it does have a hash set, and the hash is expected, use it. |
605 | 605 | // This check allows users to change the hash structure using the |
606 | 606 | // gravityview_entry_hash filter and have the old hashes expire. |
607 | - if( empty( $value ) || $value !== $hash ) { |
|
608 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Setting hash for entry "'.$id_or_string.'": ' . $hash ); |
|
607 | + if ( empty( $value ) || $value !== $hash ) { |
|
608 | + do_action( 'gravityview_log_debug', __METHOD__ . ' - Setting hash for entry "' . $id_or_string . '": ' . $hash ); |
|
609 | 609 | gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash, rgar( $entry, 'form_id' ) ); |
610 | 610 | } |
611 | 611 | |
@@ -631,15 +631,15 @@ discard block |
||
631 | 631 | * @param boolean $custom Should we process the custom entry slug? |
632 | 632 | */ |
633 | 633 | $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
634 | - if( $custom ) { |
|
634 | + if ( $custom ) { |
|
635 | 635 | // create the gravityview_unique_id and save it |
636 | 636 | |
637 | 637 | // Get the entry hash |
638 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
638 | + $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry ); |
|
639 | 639 | |
640 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Setting hash for entry "'.$entry['id'].'": ' . $hash ); |
|
640 | + do_action( 'gravityview_log_debug', __METHOD__ . ' - Setting hash for entry "' . $entry[ 'id' ] . '": ' . $hash ); |
|
641 | 641 | |
642 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash, rgar( $entry, 'form_id' ) ); |
|
642 | + gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash, rgar( $entry, 'form_id' ) ); |
|
643 | 643 | |
644 | 644 | } |
645 | 645 | } |
@@ -656,14 +656,14 @@ discard block |
||
656 | 656 | */ |
657 | 657 | public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) { |
658 | 658 | |
659 | - if( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
659 | + if ( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
660 | 660 | $entry = GVCommon::get_entry( $entry ); |
661 | - } else if( empty( $entry ) ) { |
|
661 | + } else if ( empty( $entry ) ) { |
|
662 | 662 | $entry = GravityView_frontend::getInstance()->getEntry(); |
663 | 663 | } |
664 | 664 | |
665 | 665 | // Second parameter used to be passed as $field; this makes sure it's not an array |
666 | - if( !is_numeric( $post_id ) ) { |
|
666 | + if ( ! is_numeric( $post_id ) ) { |
|
667 | 667 | $post_id = NULL; |
668 | 668 | } |
669 | 669 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | $directory_link = self::directory_link( $post_id, false ); |
672 | 672 | |
673 | 673 | // No post ID? Get outta here. |
674 | - if( empty( $directory_link ) ) { |
|
674 | + if ( empty( $directory_link ) ) { |
|
675 | 675 | return ''; |
676 | 676 | } |
677 | 677 | |
@@ -682,9 +682,9 @@ discard block |
||
682 | 682 | $query_arg_name = GravityView_Post_Types::get_entry_var_name(); |
683 | 683 | } |
684 | 684 | |
685 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
685 | + $entry_slug = self::get_entry_slug( $entry[ 'id' ], $entry ); |
|
686 | 686 | |
687 | - if( get_option('permalink_structure') && !is_preview() ) { |
|
687 | + if ( get_option( 'permalink_structure' ) && ! is_preview() ) { |
|
688 | 688 | |
689 | 689 | $args = array(); |
690 | 690 | |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | */ |
695 | 695 | $link_parts = explode( '?', $directory_link ); |
696 | 696 | |
697 | - $query = !empty( $link_parts[1] ) ? '?'.$link_parts[1] : ''; |
|
697 | + $query = ! empty( $link_parts[ 1 ] ) ? '?' . $link_parts[ 1 ] : ''; |
|
698 | 698 | |
699 | - $directory_link = trailingslashit( $link_parts[0] ) . $query_arg_name . '/'. $entry_slug .'/' . $query; |
|
699 | + $directory_link = trailingslashit( $link_parts[ 0 ] ) . $query_arg_name . '/' . $entry_slug . '/' . $query; |
|
700 | 700 | |
701 | 701 | } else { |
702 | 702 | |
@@ -706,18 +706,18 @@ discard block |
||
706 | 706 | /** |
707 | 707 | * @since 1.7.3 |
708 | 708 | */ |
709 | - if( $add_directory_args ) { |
|
709 | + if ( $add_directory_args ) { |
|
710 | 710 | |
711 | - if( !empty( $_GET['pagenum'] ) ) { |
|
712 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
711 | + if ( ! empty( $_GET[ 'pagenum' ] ) ) { |
|
712 | + $args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] ); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
716 | 716 | * @since 1.7 |
717 | 717 | */ |
718 | - if( $sort = rgget('sort') ) { |
|
719 | - $args['sort'] = $sort; |
|
720 | - $args['dir'] = rgget('dir'); |
|
718 | + if ( $sort = rgget( 'sort' ) ) { |
|
719 | + $args[ 'sort' ] = $sort; |
|
720 | + $args[ 'dir' ] = rgget( 'dir' ); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | } |
@@ -729,12 +729,12 @@ discard block |
||
729 | 729 | */ |
730 | 730 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
731 | 731 | if ( gravityview()->views->count() > 1 ) { |
732 | - $args['gvid'] = gravityview_get_view_id(); |
|
732 | + $args[ 'gvid' ] = gravityview_get_view_id(); |
|
733 | 733 | } |
734 | 734 | } else { |
735 | 735 | /** Deprecated, do not use has_multiple_views(), please. */ |
736 | 736 | if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
737 | - $args['gvid'] = gravityview_get_view_id(); |
|
737 | + $args[ 'gvid' ] = gravityview_get_view_id(); |
|
738 | 738 | } |
739 | 739 | } |
740 | 740 | |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | } |
754 | 754 | |
755 | 755 | function gv_class( $field, $form = NULL, $entry = array() ) { |
756 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
756 | + return GravityView_API::field_class( $field, $form, $entry ); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | /** |
@@ -775,15 +775,15 @@ discard block |
||
775 | 775 | |
776 | 776 | $default_css_class = ! empty( $view_id ) ? sprintf( 'gv-container gv-container-%d', $view_id ) : 'gv-container'; |
777 | 777 | |
778 | - if( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
778 | + if ( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
779 | 779 | $default_css_class .= ' hidden'; |
780 | 780 | } |
781 | 781 | |
782 | - if( 0 === GravityView_View::getInstance()->getTotalEntries() ) { |
|
782 | + if ( 0 === GravityView_View::getInstance()->getTotalEntries() ) { |
|
783 | 783 | $default_css_class .= ' gv-container-no-results'; |
784 | 784 | } |
785 | 785 | |
786 | - $css_class = trim( $passed_css_class . ' '. $default_css_class ); |
|
786 | + $css_class = trim( $passed_css_class . ' ' . $default_css_class ); |
|
787 | 787 | |
788 | 788 | /** |
789 | 789 | * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | |
795 | 795 | $css_class = gravityview_sanitize_html_class( $css_class ); |
796 | 796 | |
797 | - if( $echo ) { |
|
797 | + if ( $echo ) { |
|
798 | 798 | echo $css_class; |
799 | 799 | } |
800 | 800 | |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | |
806 | 806 | $value = GravityView_API::field_value( $entry, $field ); |
807 | 807 | |
808 | - if( $value === '' ) { |
|
808 | + if ( $value === '' ) { |
|
809 | 809 | /** |
810 | 810 | * @filter `gravityview_empty_value` What to display when a field is empty |
811 | 811 | * @param string $value (empty string) |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | return GravityView_API::entry_link( $entry, $post_id ); |
825 | 825 | } |
826 | 826 | |
827 | -function gv_no_results($wpautop = true) { |
|
827 | +function gv_no_results( $wpautop = true ) { |
|
828 | 828 | return GravityView_API::no_results( $wpautop ); |
829 | 829 | } |
830 | 830 | |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | */ |
846 | 846 | $href = apply_filters( 'gravityview_go_back_url', $href ); |
847 | 847 | |
848 | - if( empty( $href ) ) { return NULL; } |
|
848 | + if ( empty( $href ) ) { return NULL; } |
|
849 | 849 | |
850 | 850 | // calculate link label |
851 | 851 | $gravityview_view = GravityView_View::getInstance(); |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | |
862 | 862 | $link = gravityview_get_link( $href, esc_html( $label ), array( |
863 | 863 | 'data-viewid' => $gravityview_view->getViewId() |
864 | - )); |
|
864 | + ) ); |
|
865 | 865 | |
866 | 866 | return $link; |
867 | 867 | } |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | */ |
881 | 881 | function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
882 | 882 | |
883 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
883 | + if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
884 | 884 | |
885 | 885 | // For the complete field value as generated by Gravity Forms |
886 | 886 | return $display_value; |
@@ -914,16 +914,16 @@ discard block |
||
914 | 914 | $terms = explode( ', ', $value ); |
915 | 915 | } |
916 | 916 | |
917 | - foreach ($terms as $term_name ) { |
|
917 | + foreach ( $terms as $term_name ) { |
|
918 | 918 | |
919 | 919 | // If we're processing a category, |
920 | - if( $taxonomy === 'category' ) { |
|
920 | + if ( $taxonomy === 'category' ) { |
|
921 | 921 | |
922 | 922 | // Use rgexplode to prevent errors if : doesn't exist |
923 | 923 | list( $term_name, $term_id ) = rgexplode( ':', $term_name, 2 ); |
924 | 924 | |
925 | 925 | // The explode was succesful; we have the category ID |
926 | - if( !empty( $term_id )) { |
|
926 | + if ( ! empty( $term_id ) ) { |
|
927 | 927 | $term = get_term_by( 'id', $term_id, $taxonomy ); |
928 | 928 | } else { |
929 | 929 | // We have to fall back to the name |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | } |
937 | 937 | |
938 | 938 | // There's still a tag/category here. |
939 | - if( $term ) { |
|
939 | + if ( $term ) { |
|
940 | 940 | |
941 | 941 | $term_link = get_term_link( $term, $taxonomy ); |
942 | 942 | |
@@ -945,11 +945,11 @@ discard block |
||
945 | 945 | continue; |
946 | 946 | } |
947 | 947 | |
948 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
948 | + $output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
949 | 949 | } |
950 | 950 | } |
951 | 951 | |
952 | - return implode(', ', $output ); |
|
952 | + return implode( ', ', $output ); |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | /** |
@@ -963,8 +963,8 @@ discard block |
||
963 | 963 | |
964 | 964 | $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
965 | 965 | |
966 | - if( empty( $link ) ) { |
|
967 | - return strip_tags( $output); |
|
966 | + if ( empty( $link ) ) { |
|
967 | + return strip_tags( $output ); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | return $output; |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | $fe = GravityView_frontend::getInstance(); |
984 | 984 | |
985 | 985 | // Solve problem when loading content via admin-ajax.php |
986 | - if( ! $fe->getGvOutputData() ) { |
|
986 | + if ( ! $fe->getGvOutputData() ) { |
|
987 | 987 | |
988 | 988 | do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' ); |
989 | 989 | |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | } |
992 | 992 | |
993 | 993 | // Make 100% sure that we're dealing with a properly called situation |
994 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
994 | + if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
995 | 995 | |
996 | 996 | do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() ); |
997 | 997 | |
@@ -1003,8 +1003,8 @@ discard block |
||
1003 | 1003 | return array(); |
1004 | 1004 | } |
1005 | 1005 | return array_combine( |
1006 | - array_map( function ( $view ) { return $view->ID; }, gravityview()->views->all() ), |
|
1007 | - array_map( function ( $view ) { return $view->as_data(); }, gravityview()->views->all() ) |
|
1006 | + array_map( function( $view ) { return $view->ID; }, gravityview()->views->all() ), |
|
1007 | + array_map( function( $view ) { return $view->as_data(); }, gravityview()->views->all() ) |
|
1008 | 1008 | ); |
1009 | 1009 | } |
1010 | 1010 | /** \GravityView_View_Data::get_views is deprecated. */ |
@@ -1099,11 +1099,11 @@ discard block |
||
1099 | 1099 | */ |
1100 | 1100 | $is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false ); |
1101 | 1101 | |
1102 | - if( $is_edit_entry ) { |
|
1102 | + if ( $is_edit_entry ) { |
|
1103 | 1103 | $context = 'edit'; |
1104 | - } else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
1104 | + } else if ( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
1105 | 1105 | $context = 'single'; |
1106 | - } else if( class_exists( 'GravityView_View' ) ) { |
|
1106 | + } else if ( class_exists( 'GravityView_View' ) ) { |
|
1107 | 1107 | $context = GravityView_View::getInstance()->getContext(); |
1108 | 1108 | } |
1109 | 1109 | |
@@ -1131,12 +1131,12 @@ discard block |
||
1131 | 1131 | function gravityview_get_files_array( $value, $gv_class = '' ) { |
1132 | 1132 | /** @define "GRAVITYVIEW_DIR" "../" */ |
1133 | 1133 | |
1134 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
1135 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
1134 | + if ( ! class_exists( 'GravityView_Field' ) ) { |
|
1135 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' ); |
|
1136 | 1136 | } |
1137 | 1137 | |
1138 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1139 | - include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' ); |
|
1138 | + if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1139 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/fileupload.php' ); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | return GravityView_Field_FileUpload::get_files_array( $value, $gv_class ); |
@@ -1214,12 +1214,12 @@ discard block |
||
1214 | 1214 | $args = apply_filters( 'gravityview/field_output/args', $args, $passed_args ); |
1215 | 1215 | |
1216 | 1216 | // Required fields. |
1217 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
1217 | + if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) { |
|
1218 | 1218 | do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args ); |
1219 | 1219 | return ''; |
1220 | 1220 | } |
1221 | 1221 | |
1222 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
1222 | + $entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ]; |
|
1223 | 1223 | |
1224 | 1224 | /** |
1225 | 1225 | * Create the content variables for replacing. |
@@ -1235,37 +1235,37 @@ discard block |
||
1235 | 1235 | 'field_id' => '', |
1236 | 1236 | ); |
1237 | 1237 | |
1238 | - $context['value'] = gv_value( $entry, $args['field'] ); |
|
1238 | + $context[ 'value' ] = gv_value( $entry, $args[ 'field' ] ); |
|
1239 | 1239 | |
1240 | 1240 | // If the value is empty and we're hiding empty, return empty. |
1241 | - if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
1241 | + if ( $context[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) { |
|
1242 | 1242 | return ''; |
1243 | 1243 | } |
1244 | 1244 | |
1245 | - if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
1246 | - $context['value'] = wpautop( $context['value'] ); |
|
1245 | + if ( $context[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) { |
|
1246 | + $context[ 'value' ] = wpautop( $context[ 'value' ] ); |
|
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | // Get width setting, if exists |
1250 | - $context['width'] = GravityView_API::field_width( $args['field'] ); |
|
1250 | + $context[ 'width' ] = GravityView_API::field_width( $args[ 'field' ] ); |
|
1251 | 1251 | |
1252 | 1252 | // If replacing with CSS inline formatting, let's do it. |
1253 | - $context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' ); |
|
1253 | + $context[ 'width:style' ] = GravityView_API::field_width( $args[ 'field' ], 'width:' . $context[ 'width' ] . '%;' ); |
|
1254 | 1254 | |
1255 | 1255 | // Grab the Class using `gv_class` |
1256 | - $context['class'] = gv_class( $args['field'], $args['form'], $entry ); |
|
1257 | - $context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry ); |
|
1256 | + $context[ 'class' ] = gv_class( $args[ 'field' ], $args[ 'form' ], $entry ); |
|
1257 | + $context[ 'field_id' ] = GravityView_API::field_html_attr_id( $args[ 'field' ], $args[ 'form' ], $entry ); |
|
1258 | 1258 | |
1259 | 1259 | // Get field label if needed |
1260 | - if ( ! empty( $args['label_markup'] ) && ! empty( $args['field']['show_label'] ) ) { |
|
1261 | - $context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] ); |
|
1260 | + if ( ! empty( $args[ 'label_markup' ] ) && ! empty( $args[ 'field' ][ 'show_label' ] ) ) { |
|
1261 | + $context[ 'label' ] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args[ 'label_markup' ] ); |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | 1264 | // Default Label value |
1265 | - $context['label_value'] = gv_label( $args['field'], $entry ); |
|
1265 | + $context[ 'label_value' ] = gv_label( $args[ 'field' ], $entry ); |
|
1266 | 1266 | |
1267 | - if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){ |
|
1268 | - $context['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
1267 | + if ( empty( $context[ 'label' ] ) && ! empty( $context[ 'label_value' ] ) ) { |
|
1268 | + $context[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
1269 | 1269 | } |
1270 | 1270 | |
1271 | 1271 | /** |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | * @param string $markup The HTML for the markup |
1275 | 1275 | * @param array $args All args for the field output |
1276 | 1276 | */ |
1277 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args ); |
|
1277 | + $html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args ); |
|
1278 | 1278 | |
1279 | 1279 | /** |
1280 | 1280 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | foreach ( $context as $tag => $value ) { |
1298 | 1298 | |
1299 | 1299 | // If the tag doesn't exist just skip it |
1300 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
1300 | + if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) { |
|
1301 | 1301 | continue; |
1302 | 1302 | } |
1303 | 1303 |