@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | public function duplicate_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
115 | 115 | |
116 | 116 | // Always a link, never a filter, always same window |
117 | - unset( $field_options['show_as_link'], $field_options['search_filter'], $field_options['new_window'] ); |
|
117 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ], $field_options[ 'new_window' ] ); |
|
118 | 118 | |
119 | 119 | |
120 | 120 | // Duplicate Entry link should only appear to visitors capable of editing entries |
121 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
121 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
122 | 122 | |
123 | - $add_option['duplicate_link'] = array( |
|
123 | + $add_option[ 'duplicate_link' ] = array( |
|
124 | 124 | 'type' => 'text', |
125 | 125 | 'label' => __( 'Duplicate Link Text', 'gravityview' ), |
126 | 126 | 'desc' => NULL, |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | 'merge_tags' => true, |
129 | 129 | ); |
130 | 130 | |
131 | - $field_options['allow_duplicate_cap'] = array( |
|
131 | + $field_options[ 'allow_duplicate_cap' ] = array( |
|
132 | 132 | 'type' => 'select', |
133 | 133 | 'label' => __( 'Allow the following users to duplicate the entry:', 'gravityview' ), |
134 | 134 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | public function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
156 | 156 | |
157 | 157 | if ( 'edit' !== $zone ) { |
158 | - $entry_default_fields['duplicate_link'] = array( |
|
158 | + $entry_default_fields[ 'duplicate_link' ] = array( |
|
159 | 159 | 'label' => __( 'Duplicate Entry', 'gravityview' ), |
160 | 160 | 'type' => 'duplicate_link', |
161 | 161 | 'desc' => __( 'A link to duplicate the entry. Respects the Duplicate Entry permissions.', 'gravityview' ), |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function add_available_field( $available_fields = array() ) { |
178 | 178 | |
179 | - $available_fields['duplicate_link'] = array( |
|
179 | + $available_fields[ 'duplicate_link' ] = array( |
|
180 | 180 | 'label_text' => __( 'Duplicate Entry', 'gravityview' ), |
181 | 181 | 'field_id' => 'duplicate_link', |
182 | 182 | 'label_type' => 'field', |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | if ( 'duplicate_link' === $field_id ) { |
210 | 210 | |
211 | 211 | // Remove other built-in caps. |
212 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['duplicate_others_posts'] ); |
|
212 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'duplicate_others_posts' ] ); |
|
213 | 213 | |
214 | - $caps['read'] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
214 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | return $caps; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | public static function get_duplicate_link( $entry, $view_id, $post_id = null ) { |
261 | 261 | self::getInstance()->set_entry( $entry ); |
262 | 262 | |
263 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
263 | + $base = GravityView_API::directory_link( $post_id ?: $view_id, true ); |
|
264 | 264 | |
265 | 265 | if ( empty( $base ) ) { |
266 | 266 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | |
270 | 270 | $actionurl = add_query_arg( array( |
271 | 271 | 'action' => 'duplicate', |
272 | - 'entry_id' => $entry['id'], |
|
272 | + 'entry_id' => $entry[ 'id' ], |
|
273 | 273 | 'gvid' => $view_id, |
274 | 274 | 'view_id' => $view_id, |
275 | 275 | ), $base ); |
276 | 276 | |
277 | - return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry['id'] ) ), $actionurl ); |
|
277 | + return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry[ 'id' ] ) ), $actionurl ); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | public function process_duplicate() { |
296 | 296 | |
297 | 297 | // If the form is submitted |
298 | - if ( ! isset( $_GET['action'] ) || 'duplicate' !== $_GET['action'] || ! isset( $_GET['entry_id'] ) ) { |
|
298 | + if ( ! isset( $_GET[ 'action' ] ) || 'duplicate' !== $_GET[ 'action' ] || ! isset( $_GET[ 'entry_id' ] ) ) { |
|
299 | 299 | return; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Make sure it's a GravityView request |
303 | - $valid_nonce_key = wp_verify_nonce( \GV\Utils::_GET( 'duplicate' ), self::get_nonce_key( $_GET['entry_id'] ) ); |
|
303 | + $valid_nonce_key = wp_verify_nonce( \GV\Utils::_GET( 'duplicate' ), self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
304 | 304 | |
305 | 305 | if ( ! $valid_nonce_key ) { |
306 | 306 | gravityview()->log->debug( 'Duplicate entry not processed: nonce validation failed.' ); |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | // Get the entry slug |
311 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
311 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
312 | 312 | |
313 | 313 | // See if there's an entry there |
314 | 314 | $entry = gravityview_get_entry( $entry_slug, true, false ); |
@@ -402,15 +402,15 @@ discard block |
||
402 | 402 | return new WP_Error( 'gravityview-duplicate-entry-missing', __( 'The entry does not exist.', 'gravityview' ) ); |
403 | 403 | } |
404 | 404 | |
405 | - $row['id'] = null; |
|
406 | - $row['date_created'] = date( 'Y-m-d H:i:s', time() ); |
|
407 | - $row['date_updated'] = $row['date_created']; |
|
408 | - $row['is_starred'] = false; |
|
409 | - $row['is_read'] = false; |
|
410 | - $row['ip'] = GFFormsModel::get_ip(); |
|
411 | - $row['source_url'] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
412 | - $row['user_agent'] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
413 | - $row['created_by'] = wp_get_current_user()->ID; |
|
405 | + $row[ 'id' ] = null; |
|
406 | + $row[ 'date_created' ] = date( 'Y-m-d H:i:s', time() ); |
|
407 | + $row[ 'date_updated' ] = $row[ 'date_created' ]; |
|
408 | + $row[ 'is_starred' ] = false; |
|
409 | + $row[ 'is_read' ] = false; |
|
410 | + $row[ 'ip' ] = GFFormsModel::get_ip(); |
|
411 | + $row[ 'source_url' ] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
412 | + $row[ 'user_agent' ] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
413 | + $row[ 'created_by' ] = wp_get_current_user()->ID; |
|
414 | 414 | |
415 | 415 | /** |
416 | 416 | * @filter `gravityview/entry/duplicate/details` Modify the new entry details before it's created. |
@@ -438,15 +438,15 @@ discard block |
||
438 | 438 | |
439 | 439 | $save_this_meta = array(); |
440 | 440 | foreach ( $duplicate_meta->get_output() as $m ) { |
441 | - $save_this_meta[] = array( |
|
442 | - 'meta_key' => $m['meta_key'], |
|
443 | - 'meta_value' => $m['meta_value'], |
|
444 | - 'item_index' => $m['item_index'], |
|
441 | + $save_this_meta[ ] = array( |
|
442 | + 'meta_key' => $m[ 'meta_key' ], |
|
443 | + 'meta_value' => $m[ 'meta_value' ], |
|
444 | + 'item_index' => $m[ 'item_index' ], |
|
445 | 445 | ); |
446 | 446 | } |
447 | 447 | |
448 | 448 | // Update the row ID for later usage |
449 | - $row['id'] = $duplicated_id; |
|
449 | + $row[ 'id' ] = $duplicated_id; |
|
450 | 450 | |
451 | 451 | /** |
452 | 452 | * @filter `gravityview/entry/duplicate/meta` Modify the new entry meta details. |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | $save_this_meta = apply_filters( 'gravityview/entry/duplicate/meta', $save_this_meta, $row, $entry ); |
458 | 458 | |
459 | 459 | foreach ( $save_this_meta as $data ) { |
460 | - $data['form_id'] = $entry['form_id']; |
|
461 | - $data['entry_id'] = $duplicated_id; |
|
460 | + $data[ 'form_id' ] = $entry[ 'form_id' ]; |
|
461 | + $data[ 'entry_id' ] = $duplicated_id; |
|
462 | 462 | |
463 | 463 | if ( ! $wpdb->insert( $entry_meta_table, $data ) ) { |
464 | 464 | return new WP_Error( 'gravityview-duplicate-entry-db-meta', __( 'There was an error duplicating the entry.', 'gravityview' ) ); |
@@ -492,13 +492,13 @@ discard block |
||
492 | 492 | public function verify_nonce() { |
493 | 493 | |
494 | 494 | // No duplicate entry request was made |
495 | - if ( empty( $_GET['entry_id'] ) || empty( $_GET['duplicate'] ) ) { |
|
495 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'duplicate' ] ) ) { |
|
496 | 496 | return false; |
497 | 497 | } |
498 | 498 | |
499 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
499 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
500 | 500 | |
501 | - $valid = wp_verify_nonce( $_GET['duplicate'], $nonce_key ); |
|
501 | + $valid = wp_verify_nonce( $_GET[ 'duplicate' ], $nonce_key ); |
|
502 | 502 | |
503 | 503 | /** |
504 | 504 | * @filter `gravityview/duplicate-entry/verify_nonce` Override Duplicate Entry nonce validation. Return true to declare nonce valid. |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | return ''; |
535 | 535 | } |
536 | 536 | |
537 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
537 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | /** |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | public static function check_user_cap_duplicate_entry( $entry, $field = array(), $view_id = 0 ) { |
589 | 589 | $current_user = wp_get_current_user(); |
590 | 590 | |
591 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL; |
|
591 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL; |
|
592 | 592 | |
593 | 593 | // Or if they can duplicate any entries (as defined in Gravity Forms), we're good. |
594 | 594 | if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gform_full_access', 'gravityview_full_access' ), $entry_id ) ) { |
@@ -603,17 +603,17 @@ discard block |
||
603 | 603 | if ( ! empty( $field ) ) { |
604 | 604 | |
605 | 605 | // If capability is not defined, something is not right! |
606 | - if ( empty( $field['allow_duplicate_cap'] ) ) { |
|
606 | + if ( empty( $field[ 'allow_duplicate_cap' ] ) ) { |
|
607 | 607 | |
608 | 608 | gravityview()->log->error( 'Cannot read duplicate entry field caps', array( 'data' => $field ) ); |
609 | 609 | |
610 | 610 | return false; |
611 | 611 | } |
612 | 612 | |
613 | - if ( GVCommon::has_cap( $field['allow_duplicate_cap'] ) ) { |
|
613 | + if ( GVCommon::has_cap( $field[ 'allow_duplicate_cap' ] ) ) { |
|
614 | 614 | |
615 | 615 | // Do not return true if cap is read, as we need to check if the current user created the entry |
616 | - if ( 'read' !== $field['allow_duplicate_cap'] ) { |
|
616 | + if ( 'read' !== $field[ 'allow_duplicate_cap' ] ) { |
|
617 | 617 | return true; |
618 | 618 | } |
619 | 619 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | |
627 | 627 | } |
628 | 628 | |
629 | - if ( ! isset( $entry['created_by'] ) ) { |
|
629 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
630 | 630 | |
631 | 631 | gravityview()->log->error( 'Cannot duplicate entry; entry `created_by` doesn\'t exist.' ); |
632 | 632 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | } |
652 | 652 | |
653 | 653 | // If the logged-in user is the same as the user who created the entry, we're good. |
654 | - if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
654 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
655 | 655 | |
656 | 656 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
657 | 657 | |
@@ -676,16 +676,16 @@ discard block |
||
676 | 676 | */ |
677 | 677 | public function display_message( $current_view_id = 0 ) { |
678 | 678 | |
679 | - if ( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
679 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
680 | 680 | return; |
681 | 681 | } |
682 | 682 | |
683 | 683 | // Entry wasn't duplicated from current View |
684 | - if ( isset( $_GET['view_id'] ) && ( intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) ) { |
|
684 | + if ( isset( $_GET[ 'view_id' ] ) && ( intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) ) { |
|
685 | 685 | return; |
686 | 686 | } |
687 | 687 | |
688 | - $status = esc_attr( $_GET['status'] ); |
|
688 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
689 | 689 | $message_from_url = \GV\Utils::_GET( 'message' ); |
690 | 690 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
691 | 691 | $class = ''; |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | $message = apply_filters( 'gravityview/duplicate-entry/message', esc_attr( $message ), $status, $message_from_url ); |
712 | 712 | |
713 | 713 | // DISPLAY ERROR/SUCCESS MESSAGE |
714 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
714 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
715 | 715 | } |
716 | 716 | |
717 | 717 |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | $gravityview_view = GravityView_View::getInstance(); |
10 | 10 | |
11 | 11 | $visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' ); |
12 | -$show_notes_logged_out = ( ! empty( $visibility_settings['view'] ) && ! empty( $visibility_settings['view_loggedout'] ) ); |
|
12 | +$show_notes_logged_out = ( ! empty( $visibility_settings[ 'view' ] ) && ! empty( $visibility_settings[ 'view_loggedout' ] ) ); |
|
13 | 13 | |
14 | -if( ! GVCommon::has_cap( array( 'gravityview_view_entry_notes', 'gravityview_add_entry_notes', 'gravityview_delete_entry_notes' ) ) && ! $show_notes_logged_out ) { |
|
14 | +if ( ! GVCommon::has_cap( array( 'gravityview_view_entry_notes', 'gravityview_add_entry_notes', 'gravityview_delete_entry_notes' ) ) && ! $show_notes_logged_out ) { |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
@@ -25,20 +25,20 @@ discard block |
||
25 | 25 | do_action( 'gravityview/field/notes/scripts' ); |
26 | 26 | |
27 | 27 | $entry = $gravityview_view->getCurrentEntry(); |
28 | -$notes = (array) GravityView_Entry_Notes::get_notes( $entry['id'] ); |
|
28 | +$notes = (array)GravityView_Entry_Notes::get_notes( $entry[ 'id' ] ); |
|
29 | 29 | $strings = GravityView_Field_Notes::strings(); |
30 | -$entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
30 | +$entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
31 | 31 | |
32 | -$show_add = ! empty( $visibility_settings['add'] ); |
|
33 | -$show_delete = ( ! empty( $visibility_settings['delete'] ) && GVCommon::has_cap( 'gravityview_delete_entry_notes' ) ); |
|
34 | -$show_notes = $show_notes_logged_out || ( ! empty( $visibility_settings['view'] ) && GVCommon::has_cap( 'gravityview_view_entry_notes' ) ); |
|
32 | +$show_add = ! empty( $visibility_settings[ 'add' ] ); |
|
33 | +$show_delete = ( ! empty( $visibility_settings[ 'delete' ] ) && GVCommon::has_cap( 'gravityview_delete_entry_notes' ) ); |
|
34 | +$show_notes = $show_notes_logged_out || ( ! empty( $visibility_settings[ 'view' ] ) && GVCommon::has_cap( 'gravityview_view_entry_notes' ) ); |
|
35 | 35 | |
36 | 36 | $container_class = ( sizeof( $notes ) > 0 ? 'gv-has-notes' : 'gv-no-notes' ); |
37 | 37 | $container_class .= $show_notes ? ' gv-show-notes' : ' gv-hide-notes'; |
38 | 38 | ?> |
39 | 39 | <div class="gv-notes <?php echo $container_class; ?>"> |
40 | 40 | <?php |
41 | - if( $show_notes ) { |
|
41 | + if ( $show_notes ) { |
|
42 | 42 | ?> |
43 | 43 | <form method="post" class="gv-notes-list"> |
44 | 44 | <?php if ( $show_delete ) { wp_nonce_field( 'gv_delete_notes_' . $entry_slug, 'gv_delete_notes' ); } ?> |
@@ -46,21 +46,21 @@ discard block |
||
46 | 46 | <input type="hidden" name="action" value="gv_delete_notes" /> |
47 | 47 | <input type="hidden" name="entry-slug" value="<?php echo esc_attr( $entry_slug ); ?>" /> |
48 | 48 | <table> |
49 | - <caption><?php echo $strings['caption']; ?></caption> |
|
49 | + <caption><?php echo $strings[ 'caption' ]; ?></caption> |
|
50 | 50 | <?php |
51 | 51 | if ( $show_delete ) { |
52 | 52 | ?> |
53 | 53 | <thead> |
54 | 54 | <tr> |
55 | 55 | <th colspan="2"> |
56 | - <label><input type="checkbox" value="" class="gv-notes-toggle" title="<?php echo $strings['toggle-notes']; ?>"><span class="screen-reader-text"><?php echo $strings['toggle-notes']; ?></span></label> |
|
57 | - <button type="submit" class="button button-small gv-notes-delete"><?php echo $strings['delete']; ?></button> |
|
56 | + <label><input type="checkbox" value="" class="gv-notes-toggle" title="<?php echo $strings[ 'toggle-notes' ]; ?>"><span class="screen-reader-text"><?php echo $strings[ 'toggle-notes' ]; ?></span></label> |
|
57 | + <button type="submit" class="button button-small gv-notes-delete"><?php echo $strings[ 'delete' ]; ?></button> |
|
58 | 58 | </th> |
59 | 59 | </tr> |
60 | 60 | </thead> |
61 | 61 | <?php } ?> |
62 | 62 | <tbody> |
63 | - <tr class="gv-notes-no-notes"><td colspan="2"><?php echo $strings['no-notes']; ?></td></tr> |
|
63 | + <tr class="gv-notes-no-notes"><td colspan="2"><?php echo $strings[ 'no-notes' ]; ?></td></tr> |
|
64 | 64 | <?php |
65 | 65 | foreach ( $notes as $note ) { |
66 | 66 | echo GravityView_Field_Notes::display_note( $note, $show_delete ); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | <?php |
74 | 74 | } // End if can view notes |
75 | 75 | |
76 | - if( $show_add ) { |
|
76 | + if ( $show_add ) { |
|
77 | 77 | echo do_shortcode( '[gv_note_add]' ); |
78 | 78 | } |
79 | 79 | ?> |
@@ -135,16 +135,16 @@ discard block |
||
135 | 135 | function load() { |
136 | 136 | |
137 | 137 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
138 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
138 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
139 | 139 | |
140 | 140 | // Don't display an embedded form when editing an entry |
141 | 141 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
142 | 142 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
143 | 143 | |
144 | 144 | // Stop Gravity Forms processing what is ours! |
145 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
145 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
146 | 146 | |
147 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
147 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
148 | 148 | |
149 | 149 | add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 ); |
150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
156 | 156 | |
157 | 157 | // Add fields expected by GFFormDisplay::validate() |
158 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
158 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
159 | 159 | |
160 | 160 | // Fix multiselect value for GF 2.2 |
161 | 161 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @return void |
173 | 173 | */ |
174 | 174 | public function prevent_render_form() { |
175 | - if( $this->is_edit_entry() ) { |
|
176 | - if( 'wp_head' === current_filter() ) { |
|
175 | + if ( $this->is_edit_entry() ) { |
|
176 | + if ( 'wp_head' === current_filter() ) { |
|
177 | 177 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
178 | 178 | } else { |
179 | 179 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function prevent_maybe_process_form() { |
190 | 190 | |
191 | - if( ! $this->is_edit_entry_submission() ) { |
|
191 | + if ( ! $this->is_edit_entry_submission() ) { |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | |
195 | 195 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' ); |
196 | 196 | |
197 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
198 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
197 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
198 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function is_edit_entry() { |
206 | 206 | |
207 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
207 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
208 | 208 | |
209 | 209 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
210 | 210 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @return boolean |
216 | 216 | */ |
217 | 217 | public function is_edit_entry_submission() { |
218 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
218 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -228,16 +228,16 @@ discard block |
||
228 | 228 | |
229 | 229 | |
230 | 230 | $entries = $gravityview_view->getEntries(); |
231 | - self::$original_entry = $entries[0]; |
|
232 | - $this->entry = $entries[0]; |
|
231 | + self::$original_entry = $entries[ 0 ]; |
|
232 | + $this->entry = $entries[ 0 ]; |
|
233 | 233 | |
234 | 234 | self::$original_form = $gravityview_view->getForm(); |
235 | 235 | $this->form = $gravityview_view->getForm(); |
236 | - $this->form_id = $this->entry['form_id']; |
|
236 | + $this->form_id = $this->entry[ 'form_id' ]; |
|
237 | 237 | $this->view_id = $gravityview_view->getViewId(); |
238 | 238 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
239 | 239 | |
240 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
240 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | private function print_scripts() { |
297 | 297 | $gravityview_view = GravityView_View::getInstance(); |
298 | 298 | |
299 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
299 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
300 | 300 | |
301 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
301 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
302 | 302 | |
303 | 303 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
304 | 304 | |
@@ -314,19 +314,19 @@ discard block |
||
314 | 314 | */ |
315 | 315 | private function process_save( $gv_data ) { |
316 | 316 | |
317 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
317 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
318 | 318 | return; |
319 | 319 | } |
320 | 320 | |
321 | 321 | // Make sure the entry, view, and form IDs are all correct |
322 | 322 | $valid = $this->verify_nonce(); |
323 | 323 | |
324 | - if ( !$valid ) { |
|
324 | + if ( ! $valid ) { |
|
325 | 325 | gravityview()->log->error( 'Nonce validation failed.' ); |
326 | 326 | return; |
327 | 327 | } |
328 | 328 | |
329 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
329 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
330 | 330 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
331 | 331 | return; |
332 | 332 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | |
338 | 338 | $this->validate(); |
339 | 339 | |
340 | - if( $this->is_valid ) { |
|
340 | + if ( $this->is_valid ) { |
|
341 | 341 | |
342 | 342 | gravityview()->log->debug( 'Submission is valid.' ); |
343 | 343 | |
@@ -349,15 +349,15 @@ discard block |
||
349 | 349 | /** |
350 | 350 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
351 | 351 | */ |
352 | - unset( $_GET['page'] ); |
|
352 | + unset( $_GET[ 'page' ] ); |
|
353 | 353 | |
354 | - $date_created = $this->entry['date_created']; |
|
354 | + $date_created = $this->entry[ 'date_created' ]; |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
358 | 358 | * @since 1.17.2 |
359 | 359 | */ |
360 | - unset( $this->entry['date_created'] ); |
|
360 | + unset( $this->entry[ 'date_created' ] ); |
|
361 | 361 | |
362 | 362 | /** |
363 | 363 | * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | * @param GravityView_Edit_Entry_Render $this This object |
368 | 368 | * @param GravityView_View_Data $gv_data The View data |
369 | 369 | */ |
370 | - do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
370 | + do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
371 | 371 | |
372 | 372 | GFFormsModel::save_lead( $form, $this->entry ); |
373 | 373 | |
374 | 374 | // Delete the values for hidden inputs |
375 | 375 | $this->unset_hidden_field_values(); |
376 | 376 | |
377 | - $this->entry['date_created'] = $date_created; |
|
377 | + $this->entry[ 'date_created' ] = $date_created; |
|
378 | 378 | |
379 | 379 | // Process calculation fields |
380 | 380 | $this->update_calculation_fields(); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param GravityView_Edit_Entry_Render $this This object |
400 | 400 | * @param GravityView_View_Data $gv_data The View data |
401 | 401 | */ |
402 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
402 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
403 | 403 | |
404 | 404 | } else { |
405 | 405 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | |
436 | 436 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
437 | 437 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
438 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
438 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
439 | 439 | } else { |
440 | 440 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
441 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
441 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -456,11 +456,11 @@ discard block |
||
456 | 456 | |
457 | 457 | $empty_value = $field->get_value_save_entry( |
458 | 458 | is_array( $field->get_entry_inputs() ) ? array() : '', |
459 | - $this->form, '', $this->entry['id'], $this->entry |
|
459 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
460 | 460 | ); |
461 | 461 | |
462 | 462 | if ( $field->has_calculation() ) { |
463 | - $this->unset_hidden_calculations[] = $field->id; // Unset |
|
463 | + $this->unset_hidden_calculations[ ] = $field->id; // Unset |
|
464 | 464 | $empty_value = ''; |
465 | 465 | } |
466 | 466 | |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | private function preset_approval_fields() { |
490 | 490 | $has_approved_field = false; |
491 | 491 | |
492 | - foreach ( self::$original_form['fields'] as $field ) { |
|
492 | + foreach ( self::$original_form[ 'fields' ] as $field ) { |
|
493 | 493 | if ( $field->gravityview_approved ) { |
494 | 494 | $has_approved_field = true; |
495 | 495 | break; |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | |
503 | 503 | $is_field_hidden = true; |
504 | 504 | |
505 | - foreach ( $this->form['fields'] as $field ) { |
|
505 | + foreach ( $this->form[ 'fields' ] as $field ) { |
|
506 | 506 | if ( $field->gravityview_approved ) { |
507 | 507 | $is_field_hidden = false; |
508 | 508 | break; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | |
528 | 528 | remove_filter( 'gravityview/approve_entries/update_unapproved_meta', array( $this, 'prevent_update_unapproved_meta' ), 9 ); |
529 | 529 | |
530 | - if ( ! $value = gform_get_meta( $entry['id'], 'is_approved' ) ) { |
|
530 | + if ( ! $value = gform_get_meta( $entry[ 'id' ], 'is_approved' ) ) { |
|
531 | 531 | |
532 | 532 | $value = GravityView_Entry_Approval_Status::UNAPPROVED; |
533 | 533 | |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | } |
593 | 593 | |
594 | 594 | /** No file is being uploaded. */ |
595 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
595 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
596 | 596 | /** So return the original upload, with $value as backup (it can be empty during edit form rendering) */ |
597 | 597 | return rgar( $entry, $input_id, $value ); |
598 | 598 | } |
@@ -610,11 +610,11 @@ discard block |
||
610 | 610 | * @return mixed |
611 | 611 | */ |
612 | 612 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
613 | - if( ! $this->is_edit_entry() ) { |
|
613 | + if ( ! $this->is_edit_entry() ) { |
|
614 | 614 | return $plupload_init; |
615 | 615 | } |
616 | 616 | |
617 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
617 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
618 | 618 | |
619 | 619 | return $plupload_init; |
620 | 620 | } |
@@ -629,27 +629,27 @@ discard block |
||
629 | 629 | $form = $this->filter_conditional_logic( $this->form ); |
630 | 630 | |
631 | 631 | /** @var GF_Field $field */ |
632 | - foreach( $form['fields'] as $k => &$field ) { |
|
632 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
633 | 633 | |
634 | 634 | /** |
635 | 635 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
636 | 636 | * @since 1.16.3 |
637 | 637 | * @var GF_Field $field |
638 | 638 | */ |
639 | - if( $field->has_calculation() ) { |
|
640 | - unset( $form['fields'][ $k ] ); |
|
639 | + if ( $field->has_calculation() ) { |
|
640 | + unset( $form[ 'fields' ][ $k ] ); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | $field->adminOnly = false; |
644 | 644 | |
645 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
646 | - foreach( $field->inputs as $key => $input ) { |
|
647 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
645 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
646 | + foreach ( $field->inputs as $key => $input ) { |
|
647 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | } |
651 | 651 | |
652 | - $form['fields'] = array_values( $form['fields'] ); |
|
652 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
653 | 653 | |
654 | 654 | return $form; |
655 | 655 | } |
@@ -661,14 +661,14 @@ discard block |
||
661 | 661 | $update = false; |
662 | 662 | |
663 | 663 | // get the most up to date entry values |
664 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
664 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
665 | 665 | |
666 | 666 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
667 | 667 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
668 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
668 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
669 | 669 | } else { |
670 | 670 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
671 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
671 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | |
@@ -685,24 +685,24 @@ discard block |
||
685 | 685 | $inputs = $field->get_entry_inputs(); |
686 | 686 | if ( is_array( $inputs ) ) { |
687 | 687 | foreach ( $inputs as $input ) { |
688 | - list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
688 | + list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
689 | 689 | |
690 | 690 | if ( 'product' === $field->type ) { |
691 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
691 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
692 | 692 | |
693 | 693 | // Only allow quantity to be set if it's allowed to be edited |
694 | 694 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
695 | 695 | } else { // otherwise set to what it previously was |
696 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
696 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
697 | 697 | } |
698 | 698 | } else { |
699 | 699 | // Set to what it previously was if it's not editable |
700 | 700 | if ( ! in_array( $field_id, $allowed_fields ) ) { |
701 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
701 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | |
705 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
705 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
706 | 706 | } |
707 | 707 | } else { |
708 | 708 | // Set to what it previously was if it's not editable |
@@ -742,19 +742,19 @@ discard block |
||
742 | 742 | |
743 | 743 | $input_name = 'input_' . $field_id; |
744 | 744 | |
745 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
745 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
746 | 746 | |
747 | 747 | // We have a new image |
748 | 748 | |
749 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
749 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
750 | 750 | |
751 | 751 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
752 | 752 | $ary = stripslashes_deep( $ary ); |
753 | 753 | $img_url = \GV\Utils::get( $ary, 0 ); |
754 | 754 | |
755 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
756 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
757 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
755 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
756 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
757 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
758 | 758 | |
759 | 759 | $image_meta = array( |
760 | 760 | 'post_excerpt' => $img_caption, |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | |
764 | 764 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
765 | 765 | if ( ! empty( $img_title ) ) { |
766 | - $image_meta['post_title'] = $img_title; |
|
766 | + $image_meta[ 'post_title' ] = $img_title; |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | /** |
@@ -821,15 +821,15 @@ discard block |
||
821 | 821 | */ |
822 | 822 | private function maybe_update_post_fields( $form ) { |
823 | 823 | |
824 | - if( empty( $this->entry['post_id'] ) ) { |
|
824 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
825 | 825 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
826 | 826 | return; |
827 | 827 | } |
828 | 828 | |
829 | - $post_id = $this->entry['post_id']; |
|
829 | + $post_id = $this->entry[ 'post_id' ]; |
|
830 | 830 | |
831 | 831 | // Security check |
832 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
832 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
833 | 833 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
834 | 834 | return; |
835 | 835 | } |
@@ -842,25 +842,25 @@ discard block |
||
842 | 842 | |
843 | 843 | $field = RGFormsModel::get_field( $form, $field_id ); |
844 | 844 | |
845 | - if( ! $field ) { |
|
845 | + if ( ! $field ) { |
|
846 | 846 | continue; |
847 | 847 | } |
848 | 848 | |
849 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
849 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
850 | 850 | |
851 | 851 | // Get the value of the field, including $_POSTed value |
852 | 852 | $value = RGFormsModel::get_field_value( $field ); |
853 | 853 | |
854 | 854 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
855 | 855 | $entry_tmp = $this->entry; |
856 | - $entry_tmp["{$field_id}"] = $value; |
|
856 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
857 | 857 | |
858 | - switch( $field->type ) { |
|
858 | + switch ( $field->type ) { |
|
859 | 859 | |
860 | 860 | case 'post_title': |
861 | 861 | $post_title = $value; |
862 | 862 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
863 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
863 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
864 | 864 | } |
865 | 865 | $updated_post->post_title = $post_title; |
866 | 866 | $updated_post->post_name = $post_title; |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | case 'post_content': |
871 | 871 | $post_content = $value; |
872 | 872 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
873 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
873 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
874 | 874 | } |
875 | 875 | $updated_post->post_content = $post_content; |
876 | 876 | unset( $post_content ); |
@@ -888,11 +888,11 @@ discard block |
||
888 | 888 | $value = $value[ $field_id ]; |
889 | 889 | } |
890 | 890 | |
891 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
891 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
892 | 892 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
893 | 893 | } |
894 | 894 | |
895 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
895 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
896 | 896 | |
897 | 897 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
898 | 898 | break; |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | } |
905 | 905 | |
906 | 906 | // update entry after |
907 | - $this->entry["{$field_id}"] = $value; |
|
907 | + $this->entry[ "{$field_id}" ] = $value; |
|
908 | 908 | |
909 | 909 | $update_entry = true; |
910 | 910 | |
@@ -913,11 +913,11 @@ discard block |
||
913 | 913 | |
914 | 914 | } |
915 | 915 | |
916 | - if( $update_entry ) { |
|
916 | + if ( $update_entry ) { |
|
917 | 917 | |
918 | 918 | $return_entry = GFAPI::update_entry( $this->entry ); |
919 | 919 | |
920 | - if( is_wp_error( $return_entry ) ) { |
|
920 | + if ( is_wp_error( $return_entry ) ) { |
|
921 | 921 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
922 | 922 | } else { |
923 | 923 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | |
928 | 928 | $return_post = wp_update_post( $updated_post, true ); |
929 | 929 | |
930 | - if( is_wp_error( $return_post ) ) { |
|
930 | + if ( is_wp_error( $return_post ) ) { |
|
931 | 931 | $return_post->add_data( $updated_post, '$updated_post' ); |
932 | 932 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
933 | 933 | } else { |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
962 | 962 | |
963 | 963 | // replace conditional shortcodes |
964 | - if( $do_shortcode ) { |
|
964 | + if ( $do_shortcode ) { |
|
965 | 965 | $output = do_shortcode( $output ); |
966 | 966 | } |
967 | 967 | |
@@ -980,19 +980,19 @@ discard block |
||
980 | 980 | */ |
981 | 981 | private function after_update() { |
982 | 982 | |
983 | - do_action( 'gform_after_update_entry', self::$original_form, $this->entry['id'], self::$original_entry ); |
|
984 | - do_action( "gform_after_update_entry_{$this->form['id']}", self::$original_form, $this->entry['id'], self::$original_entry ); |
|
983 | + do_action( 'gform_after_update_entry', self::$original_form, $this->entry[ 'id' ], self::$original_entry ); |
|
984 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", self::$original_form, $this->entry[ 'id' ], self::$original_entry ); |
|
985 | 985 | |
986 | 986 | // Re-define the entry now that we've updated it. |
987 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
987 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
988 | 988 | |
989 | 989 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
990 | 990 | |
991 | 991 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
992 | 992 | // We need to clear the cache because Gravity Forms caches the field values, which |
993 | 993 | // we have just updated. |
994 | - foreach ($this->form['fields'] as $key => $field) { |
|
995 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
994 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
995 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
996 | 996 | } |
997 | 997 | } |
998 | 998 | |
@@ -1002,11 +1002,11 @@ discard block |
||
1002 | 1002 | * @since develop |
1003 | 1003 | */ |
1004 | 1004 | if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) { |
1005 | - $feeds = GFAPI::get_feeds( null, $entry['form_id'] ); |
|
1005 | + $feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] ); |
|
1006 | 1006 | if ( ! is_wp_error( $feeds ) ) { |
1007 | 1007 | $registered_feeds = array(); |
1008 | 1008 | foreach ( GFAddOn::get_registered_addons() as $registered_feed ) { |
1009 | - if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
1009 | + if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
1010 | 1010 | if ( method_exists( $registered_feed, 'get_instance' ) ) { |
1011 | 1011 | $registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) ); |
1012 | 1012 | $registered_feeds[ $registered_feed->get_slug() ] = $registered_feed; |
@@ -1014,8 +1014,8 @@ discard block |
||
1014 | 1014 | } |
1015 | 1015 | } |
1016 | 1016 | foreach ( $feeds as $feed ) { |
1017 | - if ( in_array( $feed['id'], $allowed_feeds ) ) { |
|
1018 | - if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) { |
|
1017 | + if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) { |
|
1018 | + if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) { |
|
1019 | 1019 | $returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form ); |
1020 | 1020 | if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) { |
1021 | 1021 | $entry = $returned_entry; |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | |
1046 | 1046 | <div class="gv-edit-entry-wrapper"><?php |
1047 | 1047 | |
1048 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
1048 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
1049 | 1049 | |
1050 | 1050 | /** |
1051 | 1051 | * Fixes weird wpautop() issue |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | * @param string $edit_entry_title Modify the "Edit Entry" title |
1062 | 1062 | * @param GravityView_Edit_Entry_Render $this This object |
1063 | 1063 | */ |
1064 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1064 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
1065 | 1065 | |
1066 | 1066 | echo esc_attr( $edit_entry_title ); |
1067 | 1067 | ?></span> |
@@ -1127,18 +1127,18 @@ discard block |
||
1127 | 1127 | */ |
1128 | 1128 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1129 | 1129 | |
1130 | - $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
|
1130 | + $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels[ 'submit' ]; |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
1134 | 1134 | |
1135 | - if( ! $this->is_valid ){ |
|
1135 | + if ( ! $this->is_valid ) { |
|
1136 | 1136 | |
1137 | 1137 | // Keeping this compatible with Gravity Forms. |
1138 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
1139 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
1138 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
1139 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
1140 | 1140 | |
1141 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
1141 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
1142 | 1142 | |
1143 | 1143 | } elseif ( false === $this->is_paged_submitted ) { |
1144 | 1144 | // Paged form that hasn't been submitted on the last page yet |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | * @param int $view_id View ID |
1152 | 1152 | * @param array $entry Gravity Forms entry array |
1153 | 1153 | */ |
1154 | - $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message , $this->view_id, $this->entry ); |
|
1154 | + $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message, $this->view_id, $this->entry ); |
|
1155 | 1155 | |
1156 | 1156 | echo GVCommon::generate_notice( $message ); |
1157 | 1157 | } else { |
@@ -1163,23 +1163,23 @@ discard block |
||
1163 | 1163 | |
1164 | 1164 | case '0': |
1165 | 1165 | $redirect_url = $back_link; |
1166 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1166 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
1167 | 1167 | break; |
1168 | 1168 | |
1169 | 1169 | case '1': |
1170 | 1170 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
1171 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1171 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1172 | 1172 | break; |
1173 | 1173 | |
1174 | 1174 | case '2': |
1175 | 1175 | $redirect_url = $edit_redirect_url; |
1176 | 1176 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
1177 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1177 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1178 | 1178 | break; |
1179 | 1179 | |
1180 | 1180 | case '': |
1181 | 1181 | default: |
1182 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1182 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
1183 | 1183 | break; |
1184 | 1184 | } |
1185 | 1185 | |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | * @param array $entry Gravity Forms entry array |
1196 | 1196 | * @param string $back_link URL to return to the original entry. @since 1.6 |
1197 | 1197 | */ |
1198 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
1198 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
1199 | 1199 | |
1200 | 1200 | echo GVCommon::generate_notice( $message ); |
1201 | 1201 | } |
@@ -1219,8 +1219,8 @@ discard block |
||
1219 | 1219 | */ |
1220 | 1220 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1221 | 1221 | |
1222 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1223 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1222 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1223 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1224 | 1224 | add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1225 | 1225 | add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
1226 | 1226 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
@@ -1229,14 +1229,14 @@ discard block |
||
1229 | 1229 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1230 | 1230 | |
1231 | 1231 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1232 | - unset( $_GET['page'] ); |
|
1232 | + unset( $_GET[ 'page' ] ); |
|
1233 | 1233 | |
1234 | 1234 | $this->show_next_button = false; |
1235 | 1235 | $this->show_previous_button = false; |
1236 | 1236 | |
1237 | 1237 | // TODO: Verify multiple-page forms |
1238 | 1238 | if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) { |
1239 | - if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form['id'], 0 ) ) ) { |
|
1239 | + if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form[ 'id' ], 0 ) ) ) { |
|
1240 | 1240 | |
1241 | 1241 | $labels = array( |
1242 | 1242 | 'cancel' => __( 'Cancel', 'gravityview' ), |
@@ -1255,20 +1255,20 @@ discard block |
||
1255 | 1255 | */ |
1256 | 1256 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1257 | 1257 | |
1258 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
|
1259 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true; |
|
1258 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form; |
|
1259 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true; |
|
1260 | 1260 | |
1261 | - if ( \GV\Utils::_POST( 'save' ) === $labels['next'] ) { |
|
1261 | + if ( \GV\Utils::_POST( 'save' ) === $labels[ 'next' ] ) { |
|
1262 | 1262 | $last_page = \GFFormDisplay::get_max_page_number( $this->form ); |
1263 | 1263 | |
1264 | 1264 | while ( ++$page_number < $last_page && RGFormsModel::is_page_hidden( $this->form, $page_number, \GV\Utils::_POST( 'gform_field_values' ) ) ) { |
1265 | 1265 | } // Advance to next visible page |
1266 | - } elseif ( \GV\Utils::_POST( 'save' ) === $labels['previous'] ) { |
|
1266 | + } elseif ( \GV\Utils::_POST( 'save' ) === $labels[ 'previous' ] ) { |
|
1267 | 1267 | while ( --$page_number > 1 && RGFormsModel::is_page_hidden( $this->form, $page_number, \GV\Utils::_POST( 'gform_field_values' ) ) ) { |
1268 | 1268 | } // Advance to next visible page |
1269 | 1269 | } |
1270 | 1270 | |
1271 | - GFFormDisplay::$submission[ $this->form['id'] ]['page_number'] = $page_number; |
|
1271 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number; |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | if ( ( $page_number = intval( $page_number ) ) < 2 ) { |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | |
1295 | 1295 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1296 | 1296 | |
1297 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1297 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1298 | 1298 | |
1299 | 1299 | ob_get_clean(); |
1300 | 1300 | |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | * @return string |
1323 | 1323 | */ |
1324 | 1324 | public function render_form_buttons() { |
1325 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1325 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | |
@@ -1341,15 +1341,15 @@ discard block |
||
1341 | 1341 | */ |
1342 | 1342 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1343 | 1343 | |
1344 | - if( $form['id'] != $this->form_id ) { |
|
1344 | + if ( $form[ 'id' ] != $this->form_id ) { |
|
1345 | 1345 | return $form; |
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | // In case we have validated the form, use it to inject the validation results into the form render |
1349 | - if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) { |
|
1349 | + if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) { |
|
1350 | 1350 | $form = $this->form_after_validation; |
1351 | 1351 | } else { |
1352 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1352 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1353 | 1353 | } |
1354 | 1354 | |
1355 | 1355 | $form = $this->filter_conditional_logic( $form ); |
@@ -1357,8 +1357,8 @@ discard block |
||
1357 | 1357 | $form = $this->prefill_conditional_logic( $form ); |
1358 | 1358 | |
1359 | 1359 | // for now we don't support Save and Continue feature. |
1360 | - if( ! self::$supports_save_and_continue ) { |
|
1361 | - unset( $form['save'] ); |
|
1360 | + if ( ! self::$supports_save_and_continue ) { |
|
1361 | + unset( $form[ 'save' ] ); |
|
1362 | 1362 | } |
1363 | 1363 | |
1364 | 1364 | $form = $this->unselect_default_values( $form ); |
@@ -1381,31 +1381,31 @@ discard block |
||
1381 | 1381 | */ |
1382 | 1382 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1383 | 1383 | |
1384 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
1384 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
1385 | 1385 | return $field_content; |
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | $message = null; |
1389 | 1389 | |
1390 | 1390 | // First, make sure they have the capability to edit the post. |
1391 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1391 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1392 | 1392 | |
1393 | 1393 | /** |
1394 | 1394 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1395 | 1395 | * @param string $message The existing "You don't have permission..." text |
1396 | 1396 | */ |
1397 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1397 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1398 | 1398 | |
1399 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1399 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1400 | 1400 | /** |
1401 | 1401 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1402 | 1402 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1403 | 1403 | */ |
1404 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1404 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1405 | 1405 | } |
1406 | 1406 | |
1407 | - if( $message ) { |
|
1408 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1407 | + if ( $message ) { |
|
1408 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | return $field_content; |
@@ -1429,8 +1429,8 @@ discard block |
||
1429 | 1429 | |
1430 | 1430 | // If the form has been submitted, then we don't need to pre-fill the values, |
1431 | 1431 | // Except for fileupload type and when a field input is overridden- run always!! |
1432 | - if( |
|
1433 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1432 | + if ( |
|
1433 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1434 | 1434 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1435 | 1435 | && ! GFCommon::is_product_field( $field->type ) |
1436 | 1436 | || ! empty( $field_content ) |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | $return = null; |
1451 | 1451 | |
1452 | 1452 | /** @var GravityView_Field $gv_field */ |
1453 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1453 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1454 | 1454 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1455 | 1455 | } else { |
1456 | 1456 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | // If there was output, it's an error |
1460 | 1460 | $warnings = ob_get_clean(); |
1461 | 1461 | |
1462 | - if( !empty( $warnings ) ) { |
|
1462 | + if ( ! empty( $warnings ) ) { |
|
1463 | 1463 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1464 | 1464 | } |
1465 | 1465 | |
@@ -1484,7 +1484,7 @@ discard block |
||
1484 | 1484 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1485 | 1485 | |
1486 | 1486 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1487 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1487 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1488 | 1488 | |
1489 | 1489 | $field_value = array(); |
1490 | 1490 | |
@@ -1493,10 +1493,10 @@ discard block |
||
1493 | 1493 | |
1494 | 1494 | foreach ( (array)$field->inputs as $input ) { |
1495 | 1495 | |
1496 | - $input_id = strval( $input['id'] ); |
|
1496 | + $input_id = strval( $input[ 'id' ] ); |
|
1497 | 1497 | |
1498 | 1498 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1499 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1499 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1500 | 1500 | $allow_pre_populated = false; |
1501 | 1501 | } |
1502 | 1502 | |
@@ -1504,7 +1504,7 @@ discard block |
||
1504 | 1504 | |
1505 | 1505 | $pre_value = $field->get_value_submission( array(), false ); |
1506 | 1506 | |
1507 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1507 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1508 | 1508 | |
1509 | 1509 | } else { |
1510 | 1510 | |
@@ -1515,13 +1515,13 @@ discard block |
||
1515 | 1515 | |
1516 | 1516 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1517 | 1517 | // or pre-populated value if not empty and set to override saved value |
1518 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1518 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1519 | 1519 | |
1520 | 1520 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1521 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1521 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1522 | 1522 | $categories = array(); |
1523 | 1523 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1524 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1524 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1525 | 1525 | } |
1526 | 1526 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1527 | 1527 | } |
@@ -1549,7 +1549,7 @@ discard block |
||
1549 | 1549 | * @param GF_Field $field Gravity Forms field object |
1550 | 1550 | * @param GravityView_Edit_Entry_Render $this Current object |
1551 | 1551 | */ |
1552 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1552 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1553 | 1553 | |
1554 | 1554 | return $field_value; |
1555 | 1555 | } |
@@ -1566,12 +1566,12 @@ discard block |
||
1566 | 1566 | */ |
1567 | 1567 | public function gform_pre_validation( $form ) { |
1568 | 1568 | |
1569 | - if( ! $this->verify_nonce() ) { |
|
1569 | + if ( ! $this->verify_nonce() ) { |
|
1570 | 1570 | return $form; |
1571 | 1571 | } |
1572 | 1572 | |
1573 | 1573 | // Fix PHP warning regarding undefined index. |
1574 | - foreach ( $form['fields'] as &$field) { |
|
1574 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1575 | 1575 | |
1576 | 1576 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1577 | 1577 | // expects certain field array items to be set. |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1580 | 1580 | } |
1581 | 1581 | |
1582 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1582 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1583 | 1583 | |
1584 | 1584 | /** |
1585 | 1585 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1593,26 +1593,26 @@ discard block |
||
1593 | 1593 | // Set the previous value |
1594 | 1594 | $entry = $this->get_entry(); |
1595 | 1595 | |
1596 | - $input_name = 'input_'.$field->id; |
|
1597 | - $form_id = $form['id']; |
|
1596 | + $input_name = 'input_' . $field->id; |
|
1597 | + $form_id = $form[ 'id' ]; |
|
1598 | 1598 | |
1599 | 1599 | $value = NULL; |
1600 | 1600 | |
1601 | 1601 | // Use the previous entry value as the default. |
1602 | - if( isset( $entry[ $field->id ] ) ) { |
|
1602 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1603 | 1603 | $value = $entry[ $field->id ]; |
1604 | 1604 | } |
1605 | 1605 | |
1606 | 1606 | // If this is a single upload file |
1607 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1608 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1609 | - $value = $file_path['url']; |
|
1607 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1608 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1609 | + $value = $file_path[ 'url' ]; |
|
1610 | 1610 | |
1611 | 1611 | } else { |
1612 | 1612 | |
1613 | 1613 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1614 | 1614 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1615 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1615 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1616 | 1616 | |
1617 | 1617 | } |
1618 | 1618 | |
@@ -1620,10 +1620,10 @@ discard block |
||
1620 | 1620 | |
1621 | 1621 | // If there are fresh uploads, process and merge them. |
1622 | 1622 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1623 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1623 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1624 | 1624 | $value = empty( $value ) ? '[]' : $value; |
1625 | 1625 | $value = stripslashes_deep( $value ); |
1626 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1626 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1627 | 1627 | } |
1628 | 1628 | |
1629 | 1629 | } else { |
@@ -1641,8 +1641,8 @@ discard block |
||
1641 | 1641 | |
1642 | 1642 | case 'number': |
1643 | 1643 | // Fix "undefined index" issue at line 1286 in form_display.php |
1644 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1645 | - $_POST['input_'.$field->id ] = NULL; |
|
1644 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1645 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1646 | 1646 | } |
1647 | 1647 | break; |
1648 | 1648 | } |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | * You can enter whatever you want! |
1680 | 1680 | * We try validating, and customize the results using `self::custom_validation()` |
1681 | 1681 | */ |
1682 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1682 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1683 | 1683 | |
1684 | 1684 | // Needed by the validate funtion |
1685 | 1685 | $failed_validation_page = NULL; |
@@ -1687,14 +1687,14 @@ discard block |
||
1687 | 1687 | |
1688 | 1688 | // Prevent entry limit from running when editing an entry, also |
1689 | 1689 | // prevent form scheduling from preventing editing |
1690 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1690 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1691 | 1691 | |
1692 | 1692 | // Hide fields depending on Edit Entry settings |
1693 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1693 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1694 | 1694 | |
1695 | 1695 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1696 | 1696 | |
1697 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1697 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1698 | 1698 | } |
1699 | 1699 | |
1700 | 1700 | |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | |
1718 | 1718 | $gv_valid = true; |
1719 | 1719 | |
1720 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1720 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1721 | 1721 | |
1722 | 1722 | $value = RGFormsModel::get_field_value( $field ); |
1723 | 1723 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1730,22 +1730,22 @@ discard block |
||
1730 | 1730 | case 'post_image': |
1731 | 1731 | |
1732 | 1732 | // in case nothing is uploaded but there are already files saved |
1733 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1733 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1734 | 1734 | $field->failed_validation = false; |
1735 | 1735 | unset( $field->validation_message ); |
1736 | 1736 | } |
1737 | 1737 | |
1738 | 1738 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1739 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1739 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1740 | 1740 | |
1741 | 1741 | $input_name = 'input_' . $field->id; |
1742 | 1742 | //uploaded |
1743 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1743 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1744 | 1744 | |
1745 | 1745 | //existent |
1746 | 1746 | $entry = $this->get_entry(); |
1747 | 1747 | $value = NULL; |
1748 | - if( isset( $entry[ $field->id ] ) ) { |
|
1748 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1749 | 1749 | $value = json_decode( $entry[ $field->id ], true ); |
1750 | 1750 | } |
1751 | 1751 | |
@@ -1753,13 +1753,13 @@ discard block |
||
1753 | 1753 | $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
1754 | 1754 | ( is_array( $value ) ? count( $value ) : 0 ); |
1755 | 1755 | |
1756 | - if( $count_files > $field->maxFiles ) { |
|
1756 | + if ( $count_files > $field->maxFiles ) { |
|
1757 | 1757 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1758 | 1758 | $field->failed_validation = 1; |
1759 | 1759 | $gv_valid = false; |
1760 | 1760 | |
1761 | 1761 | // in case of error make sure the newest upload files are removed from the upload input |
1762 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1762 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1763 | 1763 | } |
1764 | 1764 | |
1765 | 1765 | } |
@@ -1770,7 +1770,7 @@ discard block |
||
1770 | 1770 | } |
1771 | 1771 | |
1772 | 1772 | // This field has failed validation. |
1773 | - if( !empty( $field->failed_validation ) ) { |
|
1773 | + if ( ! empty( $field->failed_validation ) ) { |
|
1774 | 1774 | |
1775 | 1775 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1776 | 1776 | |
@@ -1788,19 +1788,19 @@ discard block |
||
1788 | 1788 | } |
1789 | 1789 | |
1790 | 1790 | // You can't continue inside a switch, so we do it after. |
1791 | - if( empty( $field->failed_validation ) ) { |
|
1791 | + if ( empty( $field->failed_validation ) ) { |
|
1792 | 1792 | continue; |
1793 | 1793 | } |
1794 | 1794 | |
1795 | 1795 | // checks if the No Duplicates option is not validating entry against itself, since |
1796 | 1796 | // we're editing a stored entry, it would also assume it's a duplicate. |
1797 | - if( !empty( $field->noDuplicates ) ) { |
|
1797 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1798 | 1798 | |
1799 | 1799 | $entry = $this->get_entry(); |
1800 | 1800 | |
1801 | 1801 | // If the value of the entry is the same as the stored value |
1802 | 1802 | // Then we can assume it's not a duplicate, it's the same. |
1803 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1803 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1804 | 1804 | //if value submitted was not changed, then don't validate |
1805 | 1805 | $field->failed_validation = false; |
1806 | 1806 | |
@@ -1813,7 +1813,7 @@ discard block |
||
1813 | 1813 | } |
1814 | 1814 | |
1815 | 1815 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1816 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1816 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1817 | 1817 | unset( $field->validation_message ); |
1818 | 1818 | $field->validation_message = false; |
1819 | 1819 | continue; |
@@ -1825,12 +1825,12 @@ discard block |
||
1825 | 1825 | |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - $validation_results['is_valid'] = $gv_valid; |
|
1828 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1829 | 1829 | |
1830 | 1830 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1831 | 1831 | |
1832 | 1832 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1833 | - $this->form_after_validation = $validation_results['form']; |
|
1833 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1834 | 1834 | |
1835 | 1835 | return $validation_results; |
1836 | 1836 | } |
@@ -1843,7 +1843,7 @@ discard block |
||
1843 | 1843 | */ |
1844 | 1844 | public function get_entry() { |
1845 | 1845 | |
1846 | - if( empty( $this->entry ) ) { |
|
1846 | + if ( empty( $this->entry ) ) { |
|
1847 | 1847 | // Get the database value of the entry that's being edited |
1848 | 1848 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1849 | 1849 | } |
@@ -1875,10 +1875,10 @@ discard block |
||
1875 | 1875 | } |
1876 | 1876 | |
1877 | 1877 | // If edit tab not yet configured, show all fields |
1878 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1878 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1879 | 1879 | |
1880 | 1880 | // Hide fields depending on admin settings |
1881 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1881 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1882 | 1882 | |
1883 | 1883 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1884 | 1884 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1911,7 +1911,7 @@ discard block |
||
1911 | 1911 | */ |
1912 | 1912 | private function filter_fields( $fields, $configured_fields ) { |
1913 | 1913 | |
1914 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1914 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1915 | 1915 | return $fields; |
1916 | 1916 | } |
1917 | 1917 | |
@@ -1928,12 +1928,12 @@ discard block |
||
1928 | 1928 | |
1929 | 1929 | // Remove the fields that have calculation properties and keep them to be used later |
1930 | 1930 | // @since 1.16.2 |
1931 | - if( $field->has_calculation() ) { |
|
1932 | - $this->fields_with_calculation[] = $field; |
|
1931 | + if ( $field->has_calculation() ) { |
|
1932 | + $this->fields_with_calculation[ ] = $field; |
|
1933 | 1933 | // don't remove the calculation fields on form render. |
1934 | 1934 | } |
1935 | 1935 | |
1936 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1936 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1937 | 1937 | unset( $fields[ $key ] ); |
1938 | 1938 | } |
1939 | 1939 | } |
@@ -1951,7 +1951,7 @@ discard block |
||
1951 | 1951 | continue; // Same |
1952 | 1952 | } |
1953 | 1953 | |
1954 | - $out_fields[] = $field; |
|
1954 | + $out_fields[ ] = $field; |
|
1955 | 1955 | } |
1956 | 1956 | |
1957 | 1957 | return array_values( $out_fields ); |
@@ -1962,8 +1962,8 @@ discard block |
||
1962 | 1962 | |
1963 | 1963 | /** @var GF_Field $field */ |
1964 | 1964 | foreach ( $fields as $field ) { |
1965 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1966 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1965 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1966 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1967 | 1967 | break; |
1968 | 1968 | } |
1969 | 1969 | |
@@ -1986,14 +1986,14 @@ discard block |
||
1986 | 1986 | |
1987 | 1987 | $return_field = $field; |
1988 | 1988 | |
1989 | - if( empty( $field_setting['show_label'] ) ) { |
|
1989 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1990 | 1990 | $return_field->label = ''; |
1991 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1992 | - $return_field->label = $field_setting['custom_label']; |
|
1991 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1992 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1993 | 1993 | } |
1994 | 1994 | |
1995 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1996 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1995 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1996 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1997 | 1997 | } |
1998 | 1998 | |
1999 | 1999 | /** |
@@ -2031,16 +2031,16 @@ discard block |
||
2031 | 2031 | */ |
2032 | 2032 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
2033 | 2033 | |
2034 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2035 | - foreach( $fields as $k => $field ) { |
|
2036 | - if( $field->adminOnly ) { |
|
2034 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
2035 | + foreach ( $fields as $k => $field ) { |
|
2036 | + if ( $field->adminOnly ) { |
|
2037 | 2037 | unset( $fields[ $k ] ); |
2038 | 2038 | } |
2039 | 2039 | } |
2040 | 2040 | return array_values( $fields ); |
2041 | 2041 | } |
2042 | 2042 | |
2043 | - foreach( $fields as &$field ) { |
|
2043 | + foreach ( $fields as &$field ) { |
|
2044 | 2044 | $field->adminOnly = false; |
2045 | 2045 | } |
2046 | 2046 | |
@@ -2061,7 +2061,7 @@ discard block |
||
2061 | 2061 | */ |
2062 | 2062 | private function unselect_default_values( $form ) { |
2063 | 2063 | |
2064 | - foreach ( $form['fields'] as &$field ) { |
|
2064 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2065 | 2065 | |
2066 | 2066 | if ( empty( $field->choices ) ) { |
2067 | 2067 | continue; |
@@ -2069,7 +2069,7 @@ discard block |
||
2069 | 2069 | |
2070 | 2070 | foreach ( $field->choices as &$choice ) { |
2071 | 2071 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
2072 | - $choice['isSelected'] = false; |
|
2072 | + $choice[ 'isSelected' ] = false; |
|
2073 | 2073 | } |
2074 | 2074 | } |
2075 | 2075 | } |
@@ -2094,22 +2094,22 @@ discard block |
||
2094 | 2094 | */ |
2095 | 2095 | function prefill_conditional_logic( $form ) { |
2096 | 2096 | |
2097 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
2097 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
2098 | 2098 | return $form; |
2099 | 2099 | } |
2100 | 2100 | |
2101 | 2101 | // Have Conditional Logic pre-fill fields as if the data were default values |
2102 | 2102 | /** @var GF_Field $field */ |
2103 | - foreach ( $form['fields'] as &$field ) { |
|
2103 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2104 | 2104 | |
2105 | - if( 'checkbox' === $field->type ) { |
|
2105 | + if ( 'checkbox' === $field->type ) { |
|
2106 | 2106 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
2107 | - $input_id = $input['id']; |
|
2107 | + $input_id = $input[ 'id' ]; |
|
2108 | 2108 | $choice = $field->choices[ $key ]; |
2109 | 2109 | $value = \GV\Utils::get( $this->entry, $input_id ); |
2110 | 2110 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
2111 | - if( $match ) { |
|
2112 | - $field->choices[ $key ]['isSelected'] = true; |
|
2111 | + if ( $match ) { |
|
2112 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
2113 | 2113 | } |
2114 | 2114 | } |
2115 | 2115 | } else { |
@@ -2117,15 +2117,15 @@ discard block |
||
2117 | 2117 | // We need to run through each field to set the default values |
2118 | 2118 | foreach ( $this->entry as $field_id => $field_value ) { |
2119 | 2119 | |
2120 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2120 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2121 | 2121 | |
2122 | - if( 'list' === $field->type ) { |
|
2122 | + if ( 'list' === $field->type ) { |
|
2123 | 2123 | $list_rows = maybe_unserialize( $field_value ); |
2124 | 2124 | |
2125 | 2125 | $list_field_value = array(); |
2126 | - foreach ( (array) $list_rows as $row ) { |
|
2127 | - foreach ( (array) $row as $column ) { |
|
2128 | - $list_field_value[] = $column; |
|
2126 | + foreach ( (array)$list_rows as $row ) { |
|
2127 | + foreach ( (array)$row as $column ) { |
|
2128 | + $list_field_value[ ] = $column; |
|
2129 | 2129 | } |
2130 | 2130 | } |
2131 | 2131 | |
@@ -2158,32 +2158,32 @@ discard block |
||
2158 | 2158 | * @see https://github.com/gravityview/GravityView/issues/840 |
2159 | 2159 | * @since develop |
2160 | 2160 | */ |
2161 | - $the_form = GFAPI::get_form( $form['id'] ); |
|
2161 | + $the_form = GFAPI::get_form( $form[ 'id' ] ); |
|
2162 | 2162 | $editable_ids = array(); |
2163 | - foreach ( $form['fields'] as $field ) { |
|
2164 | - $editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context |
|
2163 | + foreach ( $form[ 'fields' ] as $field ) { |
|
2164 | + $editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context |
|
2165 | 2165 | } |
2166 | 2166 | $remove_conditions_rule = array(); |
2167 | - foreach ( $the_form['fields'] as $field ) { |
|
2168 | - if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) { |
|
2169 | - foreach ( $field->conditionalLogic['rules'] as $i => $rule ) { |
|
2170 | - if ( ! in_array( $rule['fieldId'], $editable_ids ) ) { |
|
2167 | + foreach ( $the_form[ 'fields' ] as $field ) { |
|
2168 | + if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) { |
|
2169 | + foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) { |
|
2170 | + if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) { |
|
2171 | 2171 | /** |
2172 | 2172 | * This conditional field is not editable in this View. |
2173 | 2173 | * We need to remove the rule, but only if it matches. |
2174 | 2174 | */ |
2175 | - if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) { |
|
2175 | + if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) { |
|
2176 | 2176 | $value = $_field->get_value_export( $this->entry ); |
2177 | - } elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) { |
|
2178 | - $value = $this->entry[ $rule['fieldId'] ]; |
|
2177 | + } elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) { |
|
2178 | + $value = $this->entry[ $rule[ 'fieldId' ] ]; |
|
2179 | 2179 | } else { |
2180 | - $value = gform_get_meta( $this->entry['id'], $rule['fieldId'] ); |
|
2180 | + $value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] ); |
|
2181 | 2181 | } |
2182 | 2182 | |
2183 | - $match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] ); |
|
2183 | + $match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] ); |
|
2184 | 2184 | |
2185 | 2185 | if ( $match ) { |
2186 | - $remove_conditions_rule[] = array( $field['id'], $i ); |
|
2186 | + $remove_conditions_rule[ ] = array( $field[ 'id' ], $i ); |
|
2187 | 2187 | } |
2188 | 2188 | } |
2189 | 2189 | } |
@@ -2191,21 +2191,21 @@ discard block |
||
2191 | 2191 | } |
2192 | 2192 | |
2193 | 2193 | if ( $remove_conditions_rule ) { |
2194 | - foreach ( $form['fields'] as &$field ) { |
|
2194 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2195 | 2195 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2196 | 2196 | |
2197 | 2197 | list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
2198 | 2198 | |
2199 | - if ( $field['id'] == $rule_field_id ) { |
|
2200 | - unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
|
2201 | - gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) ); |
|
2199 | + if ( $field[ 'id' ] == $rule_field_id ) { |
|
2200 | + unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] ); |
|
2201 | + gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) ); |
|
2202 | 2202 | } |
2203 | 2203 | } |
2204 | 2204 | } |
2205 | 2205 | } |
2206 | 2206 | |
2207 | 2207 | /** Normalize the indices... */ |
2208 | - $form['fields'] = array_values( $form['fields'] ); |
|
2208 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
2209 | 2209 | |
2210 | 2210 | /** |
2211 | 2211 | * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields? |
@@ -2215,16 +2215,16 @@ discard block |
||
2215 | 2215 | */ |
2216 | 2216 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
2217 | 2217 | |
2218 | - if( $use_conditional_logic ) { |
|
2218 | + if ( $use_conditional_logic ) { |
|
2219 | 2219 | return $form; |
2220 | 2220 | } |
2221 | 2221 | |
2222 | - foreach( $form['fields'] as &$field ) { |
|
2222 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2223 | 2223 | /* @var GF_Field $field */ |
2224 | 2224 | $field->conditionalLogic = null; |
2225 | 2225 | } |
2226 | 2226 | |
2227 | - unset( $form['button']['conditionalLogic'] ); |
|
2227 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
2228 | 2228 | |
2229 | 2229 | return $form; |
2230 | 2230 | |
@@ -2241,7 +2241,7 @@ discard block |
||
2241 | 2241 | */ |
2242 | 2242 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
2243 | 2243 | |
2244 | - if( ! $this->is_edit_entry() ) { |
|
2244 | + if ( ! $this->is_edit_entry() ) { |
|
2245 | 2245 | return $has_conditional_logic; |
2246 | 2246 | } |
2247 | 2247 | |
@@ -2273,44 +2273,44 @@ discard block |
||
2273 | 2273 | * 2. There are two entries embedded using oEmbed |
2274 | 2274 | * 3. One of the entries has just been saved |
2275 | 2275 | */ |
2276 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
2276 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
2277 | 2277 | |
2278 | 2278 | $error = true; |
2279 | 2279 | |
2280 | 2280 | } |
2281 | 2281 | |
2282 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
2282 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
2283 | 2283 | |
2284 | 2284 | $error = true; |
2285 | 2285 | |
2286 | - } elseif( ! $this->verify_nonce() ) { |
|
2286 | + } elseif ( ! $this->verify_nonce() ) { |
|
2287 | 2287 | |
2288 | 2288 | /** |
2289 | 2289 | * If the Entry is embedded, there may be two entries on the same page. |
2290 | 2290 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
2291 | 2291 | */ |
2292 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2292 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2293 | 2293 | $error = true; |
2294 | 2294 | } else { |
2295 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
2295 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
2296 | 2296 | } |
2297 | 2297 | |
2298 | 2298 | } |
2299 | 2299 | |
2300 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2301 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
2300 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2301 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
2302 | 2302 | } |
2303 | 2303 | |
2304 | - if( $this->entry['status'] === 'trash' ) { |
|
2305 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2304 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
2305 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2306 | 2306 | } |
2307 | 2307 | |
2308 | 2308 | // No errors; everything's fine here! |
2309 | - if( empty( $error ) ) { |
|
2309 | + if ( empty( $error ) ) { |
|
2310 | 2310 | return true; |
2311 | 2311 | } |
2312 | 2312 | |
2313 | - if( $echo && $error !== true ) { |
|
2313 | + if ( $echo && $error !== true ) { |
|
2314 | 2314 | |
2315 | 2315 | $error = esc_html( $error ); |
2316 | 2316 | |
@@ -2318,10 +2318,10 @@ discard block |
||
2318 | 2318 | * @since 1.9 |
2319 | 2319 | */ |
2320 | 2320 | if ( ! empty( $this->entry ) ) { |
2321 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
2321 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
2322 | 2322 | } |
2323 | 2323 | |
2324 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
2324 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
2325 | 2325 | } |
2326 | 2326 | |
2327 | 2327 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2341,17 +2341,17 @@ discard block |
||
2341 | 2341 | |
2342 | 2342 | $error = NULL; |
2343 | 2343 | |
2344 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2345 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
2344 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2345 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
2346 | 2346 | } |
2347 | 2347 | |
2348 | 2348 | // No errors; everything's fine here! |
2349 | - if( empty( $error ) ) { |
|
2349 | + if ( empty( $error ) ) { |
|
2350 | 2350 | return true; |
2351 | 2351 | } |
2352 | 2352 | |
2353 | - if( $echo ) { |
|
2354 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
2353 | + if ( $echo ) { |
|
2354 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
2355 | 2355 | } |
2356 | 2356 | |
2357 | 2357 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2372,14 +2372,14 @@ discard block |
||
2372 | 2372 | private function check_user_cap_edit_field( $field ) { |
2373 | 2373 | |
2374 | 2374 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
2375 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2375 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2376 | 2376 | return true; |
2377 | 2377 | } |
2378 | 2378 | |
2379 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
2379 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
2380 | 2380 | |
2381 | - if( $field_cap ) { |
|
2382 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
2381 | + if ( $field_cap ) { |
|
2382 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
2383 | 2383 | } |
2384 | 2384 | |
2385 | 2385 | return false; |
@@ -2393,17 +2393,17 @@ discard block |
||
2393 | 2393 | public function verify_nonce() { |
2394 | 2394 | |
2395 | 2395 | // Verify form submitted for editing single |
2396 | - if( $this->is_edit_entry_submission() ) { |
|
2396 | + if ( $this->is_edit_entry_submission() ) { |
|
2397 | 2397 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2398 | 2398 | } |
2399 | 2399 | |
2400 | 2400 | // Verify |
2401 | - else if( ! $this->is_edit_entry() ) { |
|
2401 | + else if ( ! $this->is_edit_entry() ) { |
|
2402 | 2402 | $valid = false; |
2403 | 2403 | } |
2404 | 2404 | |
2405 | 2405 | else { |
2406 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2406 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2407 | 2407 | } |
2408 | 2408 | |
2409 | 2409 | /** |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | |
50 | 50 | $post_types = get_post_types(); |
51 | 51 | |
52 | - foreach( $post_types as $post_type ) { |
|
52 | + foreach ( $post_types as $post_type ) { |
|
53 | 53 | $post_type_rewrite = get_post_type_object( $post_type )->rewrite; |
54 | 54 | |
55 | 55 | if ( $slug = \GV\Utils::get( $post_type_rewrite, 'slug' ) ) { |
56 | - $reserved_slugs[] = $slug; |
|
56 | + $reserved_slugs[ ] = $slug; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -89,8 +89,7 @@ discard block |
||
89 | 89 | $tab = __( 'Edit Entry', 'gravityview' ); |
90 | 90 | $context = 'edit'; |
91 | 91 | break; |
92 | - case ( $gravityview->request->is_entry( $gravityview->view->form ? $gravityview->view->form->ID : 0 ) ): |
|
93 | - $tab = __( 'Single Entry', 'gravityview' ); |
|
92 | + case ( $gravityview->request->is_entry( $gravityview->view->form ? $gravityview->view->form->ID : 0 ) ) : $tab = __( 'Single Entry', 'gravityview' ); |
|
94 | 93 | $context = 'single'; |
95 | 94 | break; |
96 | 95 | default: |
@@ -110,7 +109,7 @@ discard block |
||
110 | 109 | $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
111 | 110 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
112 | 111 | |
113 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
112 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
114 | 113 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
115 | 114 | |
116 | 115 | echo \GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $gravityview->view->ID ); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | $is_table_layout = preg_match( '/table/ism', $template_id ); |
32 | 32 | |
33 | - if( 'field' === $field_type ) { |
|
33 | + if ( 'field' === $field_type ) { |
|
34 | 34 | |
35 | 35 | // Default options - fields |
36 | 36 | $field_options = array( |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | 'custom_class' => array( |
50 | 50 | 'type' => 'text', |
51 | 51 | 'label' => __( 'Custom CSS Class:', 'gravityview' ), |
52 | - 'desc' => __( 'This class will be added to the field container', 'gravityview'), |
|
52 | + 'desc' => __( 'This class will be added to the field container', 'gravityview' ), |
|
53 | 53 | 'value' => '', |
54 | 54 | 'merge_tags' => true, |
55 | 55 | 'tooltip' => 'gv_css_merge_tags', |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | ); |
71 | 71 | |
72 | 72 | // Match Table as well as DataTables |
73 | - if( $is_table_layout && 'directory' === $context ) { |
|
74 | - $field_options['width'] = array( |
|
73 | + if ( $is_table_layout && 'directory' === $context ) { |
|
74 | + $field_options[ 'width' ] = array( |
|
75 | 75 | 'type' => 'number', |
76 | - 'label' => __('Percent Width', 'gravityview'), |
|
77 | - 'desc' => __( 'Leave blank for column width to be based on the field content.', 'gravityview'), |
|
76 | + 'label' => __( 'Percent Width', 'gravityview' ), |
|
77 | + 'desc' => __( 'Leave blank for column width to be based on the field content.', 'gravityview' ), |
|
78 | 78 | 'class' => 'code widefat', |
79 | 79 | 'value' => '', |
80 | 80 | ); |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | 'manage_options' => __( 'Administrator', 'gravityview' ), |
130 | 130 | ); |
131 | 131 | |
132 | - if( is_multisite() ) { |
|
133 | - $select_cap_choices['manage_network'] = __('Multisite Super Admin', 'gravityview' ); |
|
132 | + if ( is_multisite() ) { |
|
133 | + $select_cap_choices[ 'manage_network' ] = __( 'Multisite Super Admin', 'gravityview' ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param string $context Optional. What context are we in? Example: `single` or `directory` |
144 | 144 | * @param string $input_type Optional. (textarea, list, select, etc.) |
145 | 145 | */ |
146 | - $select_cap_choices = apply_filters('gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type ); |
|
146 | + $select_cap_choices = apply_filters( 'gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type ); |
|
147 | 147 | |
148 | 148 | return $select_cap_choices; |
149 | 149 | } |
@@ -171,27 +171,27 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public static function render_field_options( $form_id, $field_type, $template_id, $field_id, $field_label, $area, $input_type = NULL, $uniqid = '', $current = '', $context = 'single', $item = array() ) { |
173 | 173 | |
174 | - if( empty( $uniqid ) ) { |
|
174 | + if ( empty( $uniqid ) ) { |
|
175 | 175 | //generate a unique field id |
176 | - $uniqid = uniqid('', false); |
|
176 | + $uniqid = uniqid( '', false ); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | // get field/widget options |
180 | 180 | $options = self::get_default_field_options( $field_type, $template_id, $field_id, $context, $input_type, $form_id ); |
181 | 181 | |
182 | 182 | // two different post arrays, depending of the field type |
183 | - $name_prefix = $field_type .'s' .'['. $area .']['. $uniqid .']'; |
|
183 | + $name_prefix = $field_type . 's' . '[' . $area . '][' . $uniqid . ']'; |
|
184 | 184 | |
185 | 185 | // build output |
186 | 186 | $output = ''; |
187 | - $output .= '<input type="hidden" class="field-key" name="'. $name_prefix .'[id]" value="'. esc_attr( $field_id ) .'">'; |
|
188 | - $output .= '<input type="hidden" class="field-label" name="'. $name_prefix .'[label]" value="'. esc_attr( $field_label ) .'">'; |
|
187 | + $output .= '<input type="hidden" class="field-key" name="' . $name_prefix . '[id]" value="' . esc_attr( $field_id ) . '">'; |
|
188 | + $output .= '<input type="hidden" class="field-label" name="' . $name_prefix . '[label]" value="' . esc_attr( $field_label ) . '">'; |
|
189 | 189 | if ( $form_id ) { |
190 | - $output .= '<input type="hidden" class="field-form-id" name="'. $name_prefix .'[form_id]" value="'. esc_attr( $form_id ) .'">'; |
|
190 | + $output .= '<input type="hidden" class="field-form-id" name="' . $name_prefix . '[form_id]" value="' . esc_attr( $form_id ) . '">'; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | // If there are no options, return what we got. |
194 | - if(empty($options)) { |
|
194 | + if ( empty( $options ) ) { |
|
195 | 195 | |
196 | 196 | // This is here for checking if the output is empty in render_label() |
197 | 197 | $output .= '<!-- No Options -->'; |
@@ -199,33 +199,33 @@ discard block |
||
199 | 199 | return $output; |
200 | 200 | } |
201 | 201 | |
202 | - $output .= '<div class="gv-dialog-options" title="'. esc_attr( sprintf( __( 'Options: %s', 'gravityview' ) , strip_tags( html_entity_decode( $field_label ) ) ) ) .'">'; |
|
202 | + $output .= '<div class="gv-dialog-options" title="' . esc_attr( sprintf( __( 'Options: %s', 'gravityview' ), strip_tags( html_entity_decode( $field_label ) ) ) ) . '">'; |
|
203 | 203 | |
204 | 204 | /** |
205 | 205 | * @since 1.8 |
206 | 206 | */ |
207 | - if( !empty( $item['subtitle'] ) ) { |
|
208 | - $output .= '<div class="subtitle">' . $item['subtitle'] . '</div>'; |
|
207 | + if ( ! empty( $item[ 'subtitle' ] ) ) { |
|
208 | + $output .= '<div class="subtitle">' . $item[ 'subtitle' ] . '</div>'; |
|
209 | 209 | } |
210 | 210 | |
211 | - foreach( $options as $key => $option ) { |
|
211 | + foreach ( $options as $key => $option ) { |
|
212 | 212 | |
213 | 213 | $value = isset( $current[ $key ] ) ? $current[ $key ] : NULL; |
214 | 214 | |
215 | - $field_output = self::render_field_option( $name_prefix . '['. $key .']' , $option, $value); |
|
215 | + $field_output = self::render_field_option( $name_prefix . '[' . $key . ']', $option, $value ); |
|
216 | 216 | |
217 | 217 | // The setting is empty |
218 | - if( empty( $field_output ) ) { |
|
218 | + if ( empty( $field_output ) ) { |
|
219 | 219 | continue; |
220 | 220 | } |
221 | 221 | |
222 | - switch( $option['type'] ) { |
|
222 | + switch ( $option[ 'type' ] ) { |
|
223 | 223 | // Hide hidden fields |
224 | 224 | case 'hidden': |
225 | - $output .= '<div class="gv-setting-container gv-setting-container-'. esc_attr( $key ) . ' screen-reader-text">'. $field_output . '</div>'; |
|
225 | + $output .= '<div class="gv-setting-container gv-setting-container-' . esc_attr( $key ) . ' screen-reader-text">' . $field_output . '</div>'; |
|
226 | 226 | break; |
227 | 227 | default: |
228 | - $output .= '<div class="gv-setting-container gv-setting-container-'. esc_attr( $key ) . '">'. $field_output .'</div>'; |
|
228 | + $output .= '<div class="gv-setting-container gv-setting-container-' . esc_attr( $key ) . '">' . $field_output . '</div>'; |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -254,17 +254,17 @@ discard block |
||
254 | 254 | * @deprecated setting index 'default' was replaced by 'value' |
255 | 255 | * @see GravityView_FieldType::get_field_defaults |
256 | 256 | */ |
257 | - if( !empty( $option['default'] ) && empty( $option['value'] ) ) { |
|
258 | - $option['value'] = $option['default']; |
|
259 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting '. $name .' details' ); |
|
257 | + if ( ! empty( $option[ 'default' ] ) && empty( $option[ 'value' ] ) ) { |
|
258 | + $option[ 'value' ] = $option[ 'default' ]; |
|
259 | + _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting ' . $name . ' details' ); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | // prepare to render option field type |
263 | - if( isset( $option['type'] ) ) { |
|
263 | + if ( isset( $option[ 'type' ] ) ) { |
|
264 | 264 | |
265 | 265 | $type_class = self::load_type_class( $option ); |
266 | 266 | |
267 | - if( class_exists( $type_class ) ) { |
|
267 | + if ( class_exists( $type_class ) ) { |
|
268 | 268 | |
269 | 269 | /** @var GravityView_FieldType $render_type */ |
270 | 270 | $render_type = new $type_class( $name, $option, $curr_value ); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @param[in,out] string $output field class name |
282 | 282 | * @param[in] array $option option field data |
283 | 283 | */ |
284 | - $output = apply_filters( "gravityview/option/output/{$option['type']}" , $output, $option ); |
|
284 | + $output = apply_filters( "gravityview/option/output/{$option[ 'type' ]}", $output, $option ); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | } // isset option[type] |
@@ -316,27 +316,27 @@ discard block |
||
316 | 316 | * @deprecated setting index 'name' was replaced by 'label' |
317 | 317 | * @see GravityView_FieldType::get_field_defaults |
318 | 318 | */ |
319 | - if( isset( $setting['name'] ) && empty( $setting['label'] ) ) { |
|
320 | - $setting['label'] = $setting['name']; |
|
321 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '. $key .' details' ); |
|
319 | + if ( isset( $setting[ 'name' ] ) && empty( $setting[ 'label' ] ) ) { |
|
320 | + $setting[ 'label' ] = $setting[ 'name' ]; |
|
321 | + _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting ' . $key . ' details' ); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | $name = esc_attr( sprintf( $name, $key ) ); |
325 | - $setting['id'] = esc_attr( sprintf( $id, $key ) ); |
|
326 | - $setting['tooltip'] = 'gv_' . $key; |
|
325 | + $setting[ 'id' ] = esc_attr( sprintf( $id, $key ) ); |
|
326 | + $setting[ 'tooltip' ] = 'gv_' . $key; |
|
327 | 327 | |
328 | 328 | // Use default if current setting isn't set. |
329 | - $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting['value']; |
|
329 | + $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting[ 'value' ]; |
|
330 | 330 | |
331 | 331 | // default setting type = text |
332 | - $setting['type'] = empty( $setting['type'] ) ? 'text' : $setting['type']; |
|
332 | + $setting[ 'type' ] = empty( $setting[ 'type' ] ) ? 'text' : $setting[ 'type' ]; |
|
333 | 333 | |
334 | 334 | // merge tags |
335 | - if( !isset( $setting['merge_tags'] ) ) { |
|
336 | - if( $setting['type'] === 'text' ) { |
|
337 | - $setting['merge_tags'] = true; |
|
335 | + if ( ! isset( $setting[ 'merge_tags' ] ) ) { |
|
336 | + if ( $setting[ 'type' ] === 'text' ) { |
|
337 | + $setting[ 'merge_tags' ] = true; |
|
338 | 338 | } else { |
339 | - $setting['merge_tags'] = false; |
|
339 | + $setting[ 'merge_tags' ] = false; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | |
345 | 345 | // render the setting |
346 | 346 | $type_class = self::load_type_class( $setting ); |
347 | - if( class_exists( $type_class ) ) { |
|
347 | + if ( class_exists( $type_class ) ) { |
|
348 | 348 | /** @var GravityView_FieldType $render_type */ |
349 | 349 | $render_type = new $type_class( $name, $setting, $curr_value ); |
350 | 350 | ob_start(); |
@@ -353,25 +353,25 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | // Check if setting is specific for a template |
356 | - if( !empty( $setting['show_in_template'] ) ) { |
|
357 | - if( !is_array( $setting['show_in_template'] ) ) { |
|
358 | - $setting['show_in_template'] = array( $setting['show_in_template'] ); |
|
356 | + if ( ! empty( $setting[ 'show_in_template' ] ) ) { |
|
357 | + if ( ! is_array( $setting[ 'show_in_template' ] ) ) { |
|
358 | + $setting[ 'show_in_template' ] = array( $setting[ 'show_in_template' ] ); |
|
359 | 359 | } |
360 | - $show_if = ' data-show-if="'. implode( ' ', $setting['show_in_template'] ).'"'; |
|
360 | + $show_if = ' data-show-if="' . implode( ' ', $setting[ 'show_in_template' ] ) . '"'; |
|
361 | 361 | } else { |
362 | 362 | $show_if = ''; |
363 | 363 | } |
364 | 364 | |
365 | - if( ! empty( $setting['requires'] ) ) { |
|
366 | - $show_if .= sprintf( ' data-requires="%s"', $setting['requires'] ); |
|
365 | + if ( ! empty( $setting[ 'requires' ] ) ) { |
|
366 | + $show_if .= sprintf( ' data-requires="%s"', $setting[ 'requires' ] ); |
|
367 | 367 | } |
368 | 368 | |
369 | - if( ! empty( $setting['requires_not'] ) ) { |
|
370 | - $show_if .= sprintf( ' data-requires-not="%s"', $setting['requires_not'] ); |
|
369 | + if ( ! empty( $setting[ 'requires_not' ] ) ) { |
|
370 | + $show_if .= sprintf( ' data-requires-not="%s"', $setting[ 'requires_not' ] ); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | // output |
374 | - echo '<tr valign="top" '. $show_if .'>' . $output . '</tr>'; |
|
374 | + echo '<tr valign="top" ' . $show_if . '>' . $output . '</tr>'; |
|
375 | 375 | |
376 | 376 | } |
377 | 377 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | */ |
384 | 384 | public static function load_type_class( $field = NULL ) { |
385 | 385 | |
386 | - if( empty( $field['type'] ) ) { |
|
386 | + if ( empty( $field[ 'type' ] ) ) { |
|
387 | 387 | return NULL; |
388 | 388 | } |
389 | 389 | |
@@ -392,19 +392,19 @@ discard block |
||
392 | 392 | * @param string $class_suffix field class suffix; `GravityView_FieldType_{$class_suffix}` |
393 | 393 | * @param array $field field data |
394 | 394 | */ |
395 | - $type_class = apply_filters( "gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_' . $field['type'], $field ); |
|
395 | + $type_class = apply_filters( "gravityview/setting/class/{$field[ 'type' ]}", 'GravityView_FieldType_' . $field[ 'type' ], $field ); |
|
396 | 396 | |
397 | - if( !class_exists( $type_class ) ) { |
|
397 | + if ( ! class_exists( $type_class ) ) { |
|
398 | 398 | |
399 | 399 | /** |
400 | 400 | * @filter `gravityview/setting/class_file/{field_type}` |
401 | 401 | * @param string $field_type_include_path field class file path |
402 | 402 | * @param array $field field data |
403 | 403 | */ |
404 | - $class_file = apply_filters( "gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field['type']}.php", $field ); |
|
404 | + $class_file = apply_filters( "gravityview/setting/class_file/{$field[ 'type' ]}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field[ 'type' ]}.php", $field ); |
|
405 | 405 | |
406 | - if( $class_file ) { |
|
407 | - if( file_exists( $class_file ) ) { |
|
406 | + if ( $class_file ) { |
|
407 | + if ( file_exists( $class_file ) ) { |
|
408 | 408 | require_once( $class_file ); |
409 | 409 | } |
410 | 410 | } |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | |
430 | 430 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_checkbox::render_input' ); |
431 | 431 | |
432 | - $output = '<input name="'. esc_attr( $name ) .'" type="hidden" value="0">'; |
|
433 | - $output .= '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="checkbox" value="1" '. checked( $current, '1', false ) .' >'; |
|
432 | + $output = '<input name="' . esc_attr( $name ) . '" type="hidden" value="0">'; |
|
433 | + $output .= '<input name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" type="checkbox" value="1" ' . checked( $current, '1', false ) . ' >'; |
|
434 | 434 | |
435 | 435 | return $output; |
436 | 436 | } |
@@ -450,22 +450,22 @@ discard block |
||
450 | 450 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_text::render_input' ); |
451 | 451 | |
452 | 452 | // Show the merge tags if the field is a list view |
453 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
453 | + $is_list = ( preg_match( '/_list-/ism', $name ) ); |
|
454 | 454 | |
455 | 455 | // Or is a single entry view |
456 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
456 | + $is_single = ( preg_match( '/single_/ism', $name ) ); |
|
457 | 457 | $show = ( $is_single || $is_list ); |
458 | 458 | |
459 | 459 | $class = ''; |
460 | 460 | // and $add_merge_tags is not false |
461 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
461 | + if ( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
462 | 462 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
463 | 463 | } |
464 | 464 | |
465 | - $class .= !empty( $args['class'] ) ? $args['class'] : 'widefat'; |
|
466 | - $type = !empty( $args['type'] ) ? $args['type'] : 'text'; |
|
465 | + $class .= ! empty( $args[ 'class' ] ) ? $args[ 'class' ] : 'widefat'; |
|
466 | + $type = ! empty( $args[ 'type' ] ) ? $args[ 'type' ] : 'text'; |
|
467 | 467 | |
468 | - return '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="'.esc_attr($type).'" value="'. esc_attr( $current ) .'" class="'.esc_attr( $class ).'">'; |
|
468 | + return '<input name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" type="' . esc_attr( $type ) . '" value="' . esc_attr( $current ) . '" class="' . esc_attr( $class ) . '">'; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -482,21 +482,21 @@ discard block |
||
482 | 482 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_textarea::render_input' ); |
483 | 483 | |
484 | 484 | // Show the merge tags if the field is a list view |
485 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
485 | + $is_list = ( preg_match( '/_list-/ism', $name ) ); |
|
486 | 486 | |
487 | 487 | // Or is a single entry view |
488 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
488 | + $is_single = ( preg_match( '/single_/ism', $name ) ); |
|
489 | 489 | $show = ( $is_single || $is_list ); |
490 | 490 | |
491 | 491 | $class = ''; |
492 | 492 | // and $add_merge_tags is not false |
493 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
493 | + if ( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
494 | 494 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
495 | 495 | } |
496 | 496 | |
497 | - $class .= !empty( $args['class'] ) ? 'widefat '.$args['class'] : 'widefat'; |
|
497 | + $class .= ! empty( $args[ 'class' ] ) ? 'widefat ' . $args[ 'class' ] : 'widefat'; |
|
498 | 498 | |
499 | - return '<textarea name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" class="'.esc_attr( $class ).'">'. esc_textarea( $current ) .'</textarea>'; |
|
499 | + return '<textarea name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . '">' . esc_textarea( $current ) . '</textarea>'; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | |
513 | 513 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_select::render_input' ); |
514 | 514 | |
515 | - $output = '<select name="'. $name .'" id="'. $id .'">'; |
|
516 | - foreach( $choices as $value => $label ) { |
|
517 | - $output .= '<option value="'. esc_attr( $value ) .'" '. selected( $value, $current, false ) .'>'. esc_html( $label ) .'</option>'; |
|
515 | + $output = '<select name="' . $name . '" id="' . $id . '">'; |
|
516 | + foreach ( $choices as $value => $label ) { |
|
517 | + $output .= '<option value="' . esc_attr( $value ) . '" ' . selected( $value, $current, false ) . '>' . esc_html( $label ) . '</option>'; |
|
518 | 518 | } |
519 | 519 | $output .= '</select>'; |
520 | 520 |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected $form_id; |
46 | 46 | |
47 | - function __construct( $title = '', $item_id, $item = array(), $settings = array(), $form_id = null) { |
|
47 | + function __construct( $title = '', $item_id, $item = array(), $settings = array(), $form_id = null ) { |
|
48 | 48 | |
49 | 49 | // Backward compat |
50 | - if ( ! empty( $item['type'] ) ) { |
|
51 | - $item['input_type'] = $item['type']; |
|
52 | - unset( $item['type'] ); |
|
50 | + if ( ! empty( $item[ 'type' ] ) ) { |
|
51 | + $item[ 'input_type' ] = $item[ 'type' ]; |
|
52 | + unset( $item[ 'type' ] ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | if ( $admin_label = \GV\Utils::get( $settings, 'admin_label' ) ) { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->id = $item_id; |
76 | 76 | $this->form_id = $form_id; |
77 | 77 | $this->settings = $settings; |
78 | - $this->label_type = $item['label_type']; |
|
78 | + $this->label_type = $item[ 'label_type' ]; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | |
120 | 120 | foreach ( $field_info_items as $item ) { |
121 | 121 | |
122 | - if( \GV\Utils::get( $item, 'hide_in_picker', false ) ) { |
|
122 | + if ( \GV\Utils::get( $item, 'hide_in_picker', false ) ) { |
|
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | |
126 | - $class = isset( $item['class'] ) ? sanitize_html_class( $item['class'] ) . ' description' : 'description'; |
|
126 | + $class = isset( $item[ 'class' ] ) ? sanitize_html_class( $item[ 'class' ] ) . ' description' : 'description'; |
|
127 | 127 | // Add the title in case the value's long, in which case, it'll be truncated by CSS. |
128 | 128 | $output .= '<span class="' . $class . '">'; |
129 | - $output .= esc_html( $item['value'] ); |
|
129 | + $output .= esc_html( $item[ 'value' ] ); |
|
130 | 130 | $output .= '</span>'; |
131 | 131 | } |
132 | 132 | |
@@ -154,21 +154,21 @@ discard block |
||
154 | 154 | |
155 | 155 | // $settings_html will just be hidden inputs if empty. Otherwise, it'll have an <ul>. Ugly hack, I know. |
156 | 156 | // TODO: Un-hack this |
157 | - $hide_settings_link = ( empty( $this->item['settings_html'] ) || strpos( $this->item['settings_html'], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : ''; |
|
157 | + $hide_settings_link = ( empty( $this->item[ 'settings_html' ] ) || strpos( $this->item[ 'settings_html' ], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : ''; |
|
158 | 158 | $settings_link = sprintf( '<a href="#settings" class="dashicons-admin-generic dashicons %s" title="%s"></a>', $hide_settings_link, esc_attr( $settings_title ) ); |
159 | 159 | |
160 | 160 | // Should we show the icon that the field is being used as a link to single entry? |
161 | - $hide_show_as_link_class = empty( $this->settings['show_as_link'] ) ? 'hide-if-js' : ''; |
|
161 | + $hide_show_as_link_class = empty( $this->settings[ 'show_as_link' ] ) ? 'hide-if-js' : ''; |
|
162 | 162 | $show_as_link = '<span class="dashicons dashicons-admin-links ' . $hide_show_as_link_class . '" title="' . esc_attr( $single_link_title ) . '"></span>'; |
163 | 163 | |
164 | 164 | // When a field label is empty, use the Field ID |
165 | 165 | $label = empty( $this->title ) ? sprintf( _x( 'Field #%s (No Label)', 'Label in field picker for empty label', 'gravityview' ), $this->id ) : $this->title; |
166 | 166 | |
167 | 167 | // If there's a custom label, and show label is checked, use that as the field heading |
168 | - if ( ! empty( $this->settings['custom_label'] ) && ! empty( $this->settings['show_label'] ) ) { |
|
169 | - $label = $this->settings['custom_label']; |
|
170 | - } else if ( ! empty( $this->item['customLabel'] ) ) { |
|
171 | - $label = $this->item['customLabel']; |
|
168 | + if ( ! empty( $this->settings[ 'custom_label' ] ) && ! empty( $this->settings[ 'show_label' ] ) ) { |
|
169 | + $label = $this->settings[ 'custom_label' ]; |
|
170 | + } else if ( ! empty( $this->item[ 'customLabel' ] ) ) { |
|
171 | + $label = $this->item[ 'customLabel' ]; |
|
172 | 172 | } |
173 | 173 | $label = esc_attr( $label ); |
174 | 174 | |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | |
177 | 177 | $output .= '<h5 class="selectable gfield field-id-' . esc_attr( $this->id ) . '">'; |
178 | 178 | |
179 | - if ( ! empty( $this->item['parent'] ) ) { |
|
180 | - $label .= ' <small>(' . esc_attr( $this->item['parent']['label'] ) . ')</small>'; |
|
179 | + if ( ! empty( $this->item[ 'parent' ] ) ) { |
|
180 | + $label .= ' <small>(' . esc_attr( $this->item[ 'parent' ][ 'label' ] ) . ')</small>'; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // Name of field / widget |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | |
194 | 194 | $output .= '</h5>'; |
195 | 195 | |
196 | - $container_class = ! empty( $this->item['parent'] ) ? ' gv-child-field' : ''; |
|
197 | - $data_form_id = ! empty( $this->form_id ) ? 'data-formid="' . esc_attr( $this->form_id ) . '"' : ''; |
|
196 | + $container_class = ! empty( $this->item[ 'parent' ] ) ? ' gv-child-field' : ''; |
|
197 | + $data_form_id = ! empty( $this->form_id ) ? 'data-formid="' . esc_attr( $this->form_id ) . '"' : ''; |
|
198 | 198 | |
199 | - $output = '<div data-fieldid="' . esc_attr( $this->id ) . '" ' . $data_form_id . ' data-inputtype="' . esc_attr( $this->item['input_type'] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item['settings_html'] . '</div>'; |
|
199 | + $output = '<div data-fieldid="' . esc_attr( $this->id ) . '" ' . $data_form_id . ' data-inputtype="' . esc_attr( $this->item[ 'input_type' ] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item[ 'settings_html' ] . '</div>'; |
|
200 | 200 | |
201 | 201 | return $output; |
202 | 202 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | private function __construct() {} |
86 | 86 | |
87 | 87 | private function initialize() { |
88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
91 | 91 | |
92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | |
237 | 237 | $this->context_view_id = $view_id; |
238 | 238 | |
239 | - } elseif ( isset( $_GET['gvid'] ) && $multiple_views ) { |
|
239 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $multiple_views ) { |
|
240 | 240 | /** |
241 | 241 | * used on a has_multiple_views context |
242 | 242 | * @see GravityView_API::entry_link |
243 | 243 | */ |
244 | - $this->context_view_id = $_GET['gvid']; |
|
244 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
245 | 245 | |
246 | 246 | } elseif ( ! $multiple_views ) { |
247 | 247 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | global $wp_rewrite; |
279 | 279 | |
280 | 280 | $is_front_page = ( $query->is_home || $query->is_page ); |
281 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
282 | - $front_page_id = get_option('page_on_front'); |
|
281 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
282 | + $front_page_id = get_option( 'page_on_front' ); |
|
283 | 283 | |
284 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
284 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
285 | 285 | |
286 | 286 | // Force to be an array, potentially a query string ( entry=16 ) |
287 | 287 | $_query = wp_parse_args( $query->query ); |
288 | 288 | |
289 | 289 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
290 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
291 | - unset( $_query['pagename'] ); |
|
290 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
291 | + unset( $_query[ 'pagename' ] ); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // this is where will break from core wordpress |
295 | 295 | /** @internal Don't use this filter; it will be unnecessary soon - it's just a patch for specific use case */ |
296 | 296 | $ignore = apply_filters( 'gravityview/internal/ignored_endpoints', array( 'preview', 'page', 'paged', 'cpage' ), $query ); |
297 | 297 | $endpoints = \GV\Utils::get( $wp_rewrite, 'endpoints' ); |
298 | - foreach ( (array) $endpoints as $endpoint ) { |
|
299 | - $ignore[] = $endpoint[1]; |
|
298 | + foreach ( (array)$endpoints as $endpoint ) { |
|
299 | + $ignore[ ] = $endpoint[ 1 ]; |
|
300 | 300 | } |
301 | 301 | unset( $endpoints ); |
302 | 302 | |
@@ -306,21 +306,21 @@ discard block |
||
306 | 306 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
307 | 307 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
308 | 308 | |
309 | - $qv =& $query->query_vars; |
|
309 | + $qv = & $query->query_vars; |
|
310 | 310 | |
311 | 311 | // Prevent redirect when on the single entry endpoint |
312 | - if( self::is_single_entry() ) { |
|
312 | + if ( self::is_single_entry() ) { |
|
313 | 313 | add_filter( 'redirect_canonical', '__return_false' ); |
314 | 314 | } |
315 | 315 | |
316 | 316 | $query->is_page = true; |
317 | 317 | $query->is_home = false; |
318 | - $qv['page_id'] = $front_page_id; |
|
318 | + $qv[ 'page_id' ] = $front_page_id; |
|
319 | 319 | |
320 | 320 | // Correct <!--nextpage--> for page_on_front |
321 | - if ( ! empty( $qv['paged'] ) ) { |
|
322 | - $qv['page'] = $qv['paged']; |
|
323 | - unset( $qv['paged'] ); |
|
321 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
322 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
323 | + unset( $qv[ 'paged' ] ); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
352 | 352 | |
353 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
353 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
354 | 354 | $this->setPostId( $post_id ); |
355 | 355 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
356 | 356 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | |
387 | 387 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
388 | 388 | |
389 | - if( 'post' === $search_method ) { |
|
389 | + if ( 'post' === $search_method ) { |
|
390 | 390 | $get = $_POST; |
391 | 391 | } else { |
392 | 392 | $get = $_GET; |
@@ -443,20 +443,20 @@ discard block |
||
443 | 443 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
444 | 444 | * @param array $entry Current entry |
445 | 445 | */ |
446 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
446 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
447 | 447 | |
448 | 448 | if ( ! $apply_outside_loop ) { |
449 | 449 | return $title; |
450 | 450 | } |
451 | 451 | |
452 | 452 | // User reported WooCommerce doesn't pass two args. |
453 | - if ( empty( $passed_post_id ) ) { |
|
453 | + if ( empty( $passed_post_id ) ) { |
|
454 | 454 | return $title; |
455 | 455 | } |
456 | 456 | |
457 | 457 | // Don't modify the title for anything other than the current view/post. |
458 | 458 | // This is true for embedded shortcodes and Views. |
459 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
459 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
460 | 460 | return $title; |
461 | 461 | } |
462 | 462 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
469 | 469 | } else { |
470 | 470 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
471 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
471 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
472 | 472 | $view_meta = $view_data; |
473 | 473 | break; |
474 | 474 | } |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | } |
477 | 477 | |
478 | 478 | /** Deprecated stuff in the future. See the branch above. */ |
479 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
479 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
480 | 480 | |
481 | - $title = $view_meta['atts']['single_title']; |
|
481 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
482 | 482 | |
483 | 483 | // We are allowing HTML in the fields, so no escaping the output |
484 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
484 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
485 | 485 | |
486 | 486 | $title = do_shortcode( $title ); |
487 | 487 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | $context = GravityView_View::getInstance()->getContext(); |
554 | 554 | |
555 | - switch( $context ) { |
|
555 | + switch ( $context ) { |
|
556 | 556 | case 'directory': |
557 | 557 | $tab = __( 'Multiple Entries', 'gravityview' ); |
558 | 558 | break; |
@@ -566,12 +566,12 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | |
569 | - $title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
569 | + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
570 | 570 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) ); |
571 | - $action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); |
|
571 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
|
572 | 572 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
573 | 573 | |
574 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url(plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
574 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
575 | 575 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
576 | 576 | |
577 | 577 | echo GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $view_id ); |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view->ID ); |
620 | 620 | $embed_only = $view->settings->get( 'embed_only' ); |
621 | 621 | |
622 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
622 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
623 | 623 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
624 | 624 | } |
625 | 625 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | $datetime_format = 'Y-m-d H:i:s'; |
667 | 667 | $search_is_outside_view_bounds = false; |
668 | 668 | |
669 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
669 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
670 | 670 | |
671 | 671 | $search_date = strtotime( $search_criteria[ $key ] ); |
672 | 672 | |
@@ -694,14 +694,14 @@ discard block |
||
694 | 694 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
695 | 695 | |
696 | 696 | // Then we override the search and re-set the start date |
697 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
697 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | } |
701 | 701 | |
702 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
702 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
703 | 703 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
704 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
704 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
705 | 705 | gravityview()->log->error( 'Invalid search: the start date is after the end date.', array( 'data' => $return_search_criteria ) ); |
706 | 706 | } |
707 | 707 | } |
@@ -720,19 +720,19 @@ discard block |
||
720 | 720 | public static function process_search_only_approved( $args, $search_criteria ) { |
721 | 721 | |
722 | 722 | /** @since 1.19 */ |
723 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
723 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
724 | 724 | gravityview()->log->debug( 'User can moderate entries; showing all approval statuses' ); |
725 | 725 | return $search_criteria; |
726 | 726 | } |
727 | 727 | |
728 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
728 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
729 | 729 | |
730 | - $search_criteria['field_filters'][] = array( |
|
730 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
731 | 731 | 'key' => GravityView_Entry_Approval::meta_key, |
732 | 732 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
733 | 733 | ); |
734 | 734 | |
735 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
735 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
736 | 736 | |
737 | 737 | gravityview()->log->debug( '[process_search_only_approved] Search Criteria if show only approved: ', array( 'data' => $search_criteria ) ); |
738 | 738 | } |
@@ -759,18 +759,18 @@ discard block |
||
759 | 759 | */ |
760 | 760 | public static function is_entry_approved( $entry, $args = array() ) { |
761 | 761 | |
762 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
762 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
763 | 763 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
764 | 764 | return true; |
765 | 765 | } |
766 | 766 | |
767 | 767 | /** @since 1.19 */ |
768 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
768 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
769 | 769 | gravityview()->log->debug( 'User can moderate entries, so entry is approved for viewing' ); |
770 | 770 | return true; |
771 | 771 | } |
772 | 772 | |
773 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
773 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
774 | 774 | |
775 | 775 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
776 | 776 | } |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | * Compatibility with filters hooking in `gravityview_search_criteria` instead of `gravityview_fe_search_criteria`. |
795 | 795 | */ |
796 | 796 | $criteria = apply_filters( 'gravityview_search_criteria', array(), array( $form_id ), \GV\Utils::get( $args, 'id' ) ); |
797 | - $search_criteria = isset( $criteria['search_criteria'] ) ? $criteria['search_criteria'] : array( 'field_filters' => array() ); |
|
797 | + $search_criteria = isset( $criteria[ 'search_criteria' ] ) ? $criteria[ 'search_criteria' ] : array( 'field_filters' => array() ); |
|
798 | 798 | |
799 | 799 | /** |
800 | 800 | * @filter `gravityview_fe_search_criteria` Modify the search criteria |
@@ -810,29 +810,29 @@ discard block |
||
810 | 810 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', array( 'data' =>$search_criteria ) ); |
811 | 811 | |
812 | 812 | // implicity search |
813 | - if ( ! empty( $args['search_value'] ) ) { |
|
813 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
814 | 814 | |
815 | 815 | // Search operator options. Options: `is` or `contains` |
816 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
816 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
817 | 817 | |
818 | - $search_criteria['field_filters'][] = array( |
|
818 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
819 | 819 | 'key' => \GV\Utils::_GET( 'search_field', \GV\Utils::get( $args, 'search_field' ) ), // The field ID to search |
820 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
820 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
821 | 821 | 'operator' => $operator, |
822 | 822 | ); |
823 | 823 | |
824 | 824 | // Lock search mode to "all" with implicit presearch filter. |
825 | - $search_criteria['field_filters']['mode'] = 'all'; |
|
825 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; |
|
826 | 826 | } |
827 | 827 | |
828 | - if( $search_criteria !== $original_search_criteria ) { |
|
828 | + if ( $search_criteria !== $original_search_criteria ) { |
|
829 | 829 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after implicity search: ', array( 'data' => $search_criteria ) ); |
830 | 830 | } |
831 | 831 | |
832 | 832 | // Handle setting date range |
833 | 833 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
834 | 834 | |
835 | - if( $search_criteria !== $original_search_criteria ) { |
|
835 | + if ( $search_criteria !== $original_search_criteria ) { |
|
836 | 836 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after date params: ', array( 'data' => $search_criteria ) ); |
837 | 837 | } |
838 | 838 | |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
844 | 844 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
845 | 845 | */ |
846 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
846 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
847 | 847 | |
848 | 848 | return $search_criteria; |
849 | 849 | } |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | 'search_criteria' => $search_criteria, |
957 | 957 | 'sorting' => self::updateViewSorting( $args, $form_id ), |
958 | 958 | 'paging' => $paging, |
959 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
959 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
960 | 960 | ); |
961 | 961 | |
962 | 962 | /** |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
982 | 982 | * @param array $args View configuration args. |
983 | 983 | */ |
984 | - $parameters = apply_filters( 'gravityview_get_entries_'.\GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
984 | + $parameters = apply_filters( 'gravityview_get_entries_' . \GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
985 | 985 | |
986 | 986 | gravityview()->log->debug( '$parameters passed to gravityview_get_entries(): ', array( 'data' => $parameters ) ); |
987 | 987 | |
@@ -1006,17 +1006,17 @@ discard block |
||
1006 | 1006 | $default_page_size = apply_filters( 'gravityview_default_page_size', 25 ); |
1007 | 1007 | |
1008 | 1008 | // Paging & offset |
1009 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size; |
|
1009 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size; |
|
1010 | 1010 | |
1011 | 1011 | if ( -1 === $page_size ) { |
1012 | 1012 | $page_size = PHP_INT_MAX; |
1013 | 1013 | } |
1014 | 1014 | |
1015 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
1015 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
1016 | 1016 | $offset = ( $curr_page - 1 ) * $page_size; |
1017 | 1017 | |
1018 | - if ( ! empty( $args['offset'] ) ) { |
|
1019 | - $offset += intval( $args['offset'] ); |
|
1018 | + if ( ! empty( $args[ 'offset' ] ) ) { |
|
1019 | + $offset += intval( $args[ 'offset' ] ); |
|
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | $paging = array( |
@@ -1041,11 +1041,11 @@ discard block |
||
1041 | 1041 | public static function updateViewSorting( $args, $form_id ) { |
1042 | 1042 | $sorting = array(); |
1043 | 1043 | |
1044 | - $has_values = isset( $_GET['sort'] ); |
|
1044 | + $has_values = isset( $_GET[ 'sort' ] ); |
|
1045 | 1045 | |
1046 | - if ( $has_values && is_array( $_GET['sort'] ) ) { |
|
1047 | - $sorts = array_keys( $_GET['sort'] ); |
|
1048 | - $dirs = array_values( $_GET['sort'] ); |
|
1046 | + if ( $has_values && is_array( $_GET[ 'sort' ] ) ) { |
|
1047 | + $sorts = array_keys( $_GET[ 'sort' ] ); |
|
1048 | + $dirs = array_values( $_GET[ 'sort' ] ); |
|
1049 | 1049 | |
1050 | 1050 | if ( $has_values = array_filter( $dirs ) ) { |
1051 | 1051 | $sort_field_id = end( $sorts ); |
@@ -1054,11 +1054,11 @@ discard block |
||
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | if ( ! isset( $sort_field_id ) ) { |
1057 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : \GV\Utils::get( $args, 'sort_field' ); |
|
1057 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : \GV\Utils::get( $args, 'sort_field' ); |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | if ( ! isset( $sort_direction ) ) { |
1061 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1061 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | if ( is_array( $sort_field_id ) ) { |
@@ -1090,10 +1090,10 @@ discard block |
||
1090 | 1090 | $form = GFAPI::get_form( $form_id ); |
1091 | 1091 | |
1092 | 1092 | // Get the first GF_Field field ID, set as the key for entry randomization |
1093 | - if ( ! empty( $form['fields'] ) ) { |
|
1093 | + if ( ! empty( $form[ 'fields' ] ) ) { |
|
1094 | 1094 | |
1095 | 1095 | /** @var GF_Field $field */ |
1096 | - foreach ( $form['fields'] as $field ) { |
|
1096 | + foreach ( $form[ 'fields' ] as $field ) { |
|
1097 | 1097 | if ( ! is_a( $field, 'GF_Field' ) ) { |
1098 | 1098 | continue; |
1099 | 1099 | } |
@@ -1138,7 +1138,7 @@ discard block |
||
1138 | 1138 | if ( is_array( $sort_field_id ) ) { |
1139 | 1139 | $modified_ids = array(); |
1140 | 1140 | foreach ( $sort_field_id as $_sort_field_id ) { |
1141 | - $modified_ids []= self::_override_sorting_id_by_field_type( $_sort_field_id, $form_id ); |
|
1141 | + $modified_ids [ ] = self::_override_sorting_id_by_field_type( $_sort_field_id, $form_id ); |
|
1142 | 1142 | } |
1143 | 1143 | return $modified_ids; |
1144 | 1144 | } |
@@ -1147,11 +1147,11 @@ discard block |
||
1147 | 1147 | |
1148 | 1148 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
1149 | 1149 | |
1150 | - if( ! $sort_field ) { |
|
1150 | + if ( ! $sort_field ) { |
|
1151 | 1151 | return $sort_field_id; |
1152 | 1152 | } |
1153 | 1153 | |
1154 | - switch ( $sort_field['type'] ) { |
|
1154 | + switch ( $sort_field[ 'type' ] ) { |
|
1155 | 1155 | |
1156 | 1156 | case 'address': |
1157 | 1157 | // Sorting by full address |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | */ |
1169 | 1169 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
1170 | 1170 | |
1171 | - switch( strtolower( $address_part ) ){ |
|
1171 | + switch ( strtolower( $address_part ) ) { |
|
1172 | 1172 | case 'street': |
1173 | 1173 | $sort_field_id .= '.1'; |
1174 | 1174 | break; |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | if ( ! class_exists( '\GV\Entry' ) ) { |
1242 | 1242 | |
1243 | 1243 | // Not using gravityview()->log->error(), since that may not exist yet either! |
1244 | - do_action( 'gravityview_log_error', '\GV\Entry not defined yet. Backtrace: ' . wp_debug_backtrace_summary() ); |
|
1244 | + do_action( 'gravityview_log_error', '\GV\Entry not defined yet. Backtrace: ' . wp_debug_backtrace_summary() ); |
|
1245 | 1245 | |
1246 | 1246 | return null; |
1247 | 1247 | } |
@@ -1258,7 +1258,7 @@ discard block |
||
1258 | 1258 | */ |
1259 | 1259 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
1260 | 1260 | |
1261 | - if ( empty( $single_entry ) ){ |
|
1261 | + if ( empty( $single_entry ) ) { |
|
1262 | 1262 | return false; |
1263 | 1263 | } else { |
1264 | 1264 | return $single_entry; |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | $views = $this->getGvOutputData()->get_views(); |
1281 | 1281 | |
1282 | 1282 | foreach ( $views as $view_id => $data ) { |
1283 | - $view = \GV\View::by_id( $data['id'] ); |
|
1283 | + $view = \GV\View::by_id( $data[ 'id' ] ); |
|
1284 | 1284 | $view_id = $view->ID; |
1285 | 1285 | $template_id = gravityview_get_template_id( $view->ID ); |
1286 | 1286 | $data = $view->as_data(); |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
1290 | 1290 | * @since 1.15 |
1291 | 1291 | */ |
1292 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1292 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1293 | 1293 | continue; |
1294 | 1294 | } |
1295 | 1295 | |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | * @param \GV\View The View. |
1322 | 1322 | */ |
1323 | 1323 | apply_filters( 'gravityview_lightbox_script', $js_dependency, $view ); |
1324 | - $js_dependencies[] = $js_dependency; |
|
1324 | + $js_dependencies[ ] = $js_dependency; |
|
1325 | 1325 | |
1326 | 1326 | if ( ! empty( $wp_filter[ 'gravity_view_lightbox_style' ] ) ) { |
1327 | 1327 | gravityview()->log->warning( 'gravity_view_lightbox_style filter is deprecated use gravityview_lightbox_style instead' ); |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | * @param \GV\View The View. |
1341 | 1341 | */ |
1342 | 1342 | $css_dependency = apply_filters( 'gravityview_lightbox_style', $css_dependency, $view ); |
1343 | - $css_dependencies[] = $css_dependency; |
|
1343 | + $css_dependencies[ ] = $css_dependency; |
|
1344 | 1344 | } |
1345 | 1345 | |
1346 | 1346 | /** |
@@ -1348,19 +1348,19 @@ discard block |
||
1348 | 1348 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
1349 | 1349 | * @since 1.15 |
1350 | 1350 | */ |
1351 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
1352 | - $css_dependencies[] = 'dashicons'; |
|
1351 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
1352 | + $css_dependencies[ ] = 'dashicons'; |
|
1353 | 1353 | } |
1354 | 1354 | |
1355 | 1355 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
1356 | 1356 | |
1357 | 1357 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
1358 | 1358 | |
1359 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
1359 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
1360 | 1360 | |
1361 | 1361 | wp_enqueue_script( 'gravityview-fe-view' ); |
1362 | 1362 | |
1363 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
1363 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
1364 | 1364 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
1365 | 1365 | } |
1366 | 1366 | |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | public static function add_style( $template_id ) { |
1424 | 1424 | |
1425 | 1425 | if ( ! empty( $template_id ) && wp_style_is( 'gravityview_style_' . $template_id, 'registered' ) ) { |
1426 | - gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1426 | + gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1427 | 1427 | wp_enqueue_style( 'gravityview_style_' . $template_id ); |
1428 | 1428 | } elseif ( empty( $template_id ) ) { |
1429 | 1429 | gravityview()->log->error( 'Cannot add template style; template_id is empty' ); |
@@ -1454,11 +1454,11 @@ discard block |
||
1454 | 1454 | * Not a table-based template; don't add sort icons |
1455 | 1455 | * @since 1.12 |
1456 | 1456 | */ |
1457 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1457 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1458 | 1458 | return $label; |
1459 | 1459 | } |
1460 | 1460 | |
1461 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
1461 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
1462 | 1462 | return $label; |
1463 | 1463 | } |
1464 | 1464 | |
@@ -1466,29 +1466,29 @@ discard block |
||
1466 | 1466 | |
1467 | 1467 | $class = 'gv-sort'; |
1468 | 1468 | |
1469 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
1469 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
1470 | 1470 | |
1471 | 1471 | $sort_args = array( |
1472 | - 'sort' => $field['id'], |
|
1472 | + 'sort' => $field[ 'id' ], |
|
1473 | 1473 | 'dir' => 'asc', |
1474 | 1474 | ); |
1475 | 1475 | |
1476 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
1476 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
1477 | 1477 | //toggle sorting direction. |
1478 | - if ( 'asc' === $sorting['direction'] ) { |
|
1479 | - $sort_args['dir'] = 'desc'; |
|
1478 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
1479 | + $sort_args[ 'dir' ] = 'desc'; |
|
1480 | 1480 | $class .= ' gv-icon-sort-desc'; |
1481 | 1481 | } else { |
1482 | - $sort_args['dir'] = 'asc'; |
|
1482 | + $sort_args[ 'dir' ] = 'asc'; |
|
1483 | 1483 | $class .= ' gv-icon-sort-asc'; |
1484 | 1484 | } |
1485 | 1485 | } else { |
1486 | 1486 | $class .= ' gv-icon-caret-up-down'; |
1487 | 1487 | } |
1488 | 1488 | |
1489 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
1489 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
1490 | 1490 | |
1491 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
1491 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
1492 | 1492 | |
1493 | 1493 | } |
1494 | 1494 | |
@@ -1506,7 +1506,7 @@ discard block |
||
1506 | 1506 | |
1507 | 1507 | $field_type = $field_id; |
1508 | 1508 | |
1509 | - if( is_numeric( $field_id ) ) { |
|
1509 | + if ( is_numeric( $field_id ) ) { |
|
1510 | 1510 | $field = GFFormsModel::get_field( $form, $field_id ); |
1511 | 1511 | $field_type = $field ? $field->type : $field_id; |
1512 | 1512 | } |
@@ -1529,7 +1529,7 @@ discard block |
||
1529 | 1529 | return false; |
1530 | 1530 | } |
1531 | 1531 | |
1532 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1532 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1533 | 1533 | |
1534 | 1534 | } |
1535 | 1535 |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | * @since 1.0 |
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | - add_action( 'admin_menu', array( $this, 'admin_menus'), 200 ); |
|
36 | + add_action( 'admin_menu', array( $this, 'admin_menus' ), 200 ); |
|
37 | 37 | add_action( 'admin_head', array( $this, 'admin_head' ) ); |
38 | - add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
39 | - add_filter( 'gravityview_is_admin_page', array( $this, 'is_dashboard_page'), 10, 2 ); |
|
38 | + add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
39 | + add_filter( 'gravityview_is_admin_page', array( $this, 'is_dashboard_page' ), 10, 2 ); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | // Add help page to GravityView menu |
53 | 53 | add_submenu_page( |
54 | 54 | 'edit.php?post_type=gravityview', |
55 | - __('GravityView: Getting Started', 'gravityview'), |
|
56 | - __('Getting Started', 'gravityview'), |
|
55 | + __( 'GravityView: Getting Started', 'gravityview' ), |
|
56 | + __( 'Getting Started', 'gravityview' ), |
|
57 | 57 | $this->minimum_capability, |
58 | 58 | 'gv-getting-started', |
59 | 59 | array( $this, 'getting_started_screen' ) |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return boolean $is_page True: yep; false: nope |
88 | 88 | */ |
89 | - public function is_dashboard_page($is_page = false, $hook = NULL) { |
|
89 | + public function is_dashboard_page( $is_page = false, $hook = NULL ) { |
|
90 | 90 | global $plugin_page; |
91 | 91 | |
92 | - if($is_page) { return $is_page; } |
|
92 | + if ( $is_page ) { return $is_page; } |
|
93 | 93 | |
94 | 94 | return in_array( $plugin_page, array( 'gv-about', 'gv-credits', 'gv-getting-started' ) ); |
95 | 95 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-credits' ); |
108 | 108 | remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-changelog' ); |
109 | 109 | |
110 | - if( !$this->is_dashboard_page() ) { return; } |
|
110 | + if ( ! $this->is_dashboard_page() ) { return; } |
|
111 | 111 | |
112 | 112 | ?> |
113 | 113 | <style type="text/css" media="screen" xmlns="http://www.w3.org/1999/html"> |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | // Don't fetch -beta, etc. |
132 | 132 | list( $display_version ) = explode( '-', GravityView_Plugin::version ); |
133 | 133 | |
134 | - $selected = !empty( $plugin_page ) ? $plugin_page : 'gv-getting-started'; |
|
134 | + $selected = ! empty( $plugin_page ) ? $plugin_page : 'gv-getting-started'; |
|
135 | 135 | |
136 | 136 | echo gravityview_get_floaty( 132 ); |
137 | 137 | ?> |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | <div class="about-text"><?php esc_html_e( 'Thank you for installing GravityView. Beautifully display your Gravity Forms entries.', 'gravityview' ); ?></div> |
141 | 141 | |
142 | 142 | <h2 class="nav-tab-wrapper clear"> |
143 | - <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-getting-started', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
143 | + <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-getting-started', 'post_type' => 'gravityview' ), 'edit.php' ) ) ); ?>"> |
|
144 | 144 | <?php _e( "Getting Started", 'gravityview' ); ?> |
145 | 145 | </a> |
146 | - <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-changelog', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
146 | + <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-changelog', 'post_type' => 'gravityview' ), 'edit.php' ) ) ); ?>"> |
|
147 | 147 | <?php _e( "List of Changes", 'gravityview' ); ?> |
148 | 148 | </a> |
149 | - <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-credits', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
149 | + <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-credits', 'post_type' => 'gravityview' ), 'edit.php' ) ) ); ?>"> |
|
150 | 150 | <?php _e( 'Credits', 'gravityview' ); ?> |
151 | 151 | </a> |
152 | 152 | </h2> |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | <h3>Create a View</h3> |
182 | 182 | |
183 | 183 | <ol class="ol-decimal"> |
184 | - <li>Go to <a href="<?php echo admin_url('post-new.php?post_type=gravityview'); ?>">Views > New View</a></li> |
|
184 | + <li>Go to <a href="<?php echo admin_url( 'post-new.php?post_type=gravityview' ); ?>">Views > New View</a></li> |
|
185 | 185 | <li>Select <strong>an existing form’s entries</strong> as a source for this view.</li> |
186 | 186 | <li>Select the type of View you would like to create. There are two core types of Views: <strong>Table</strong> and <strong>Listing</strong>. |
187 | 187 | <ul class="ul-square"> |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | </ul> |
482 | 482 | |
483 | 483 | <h4><?php esc_attr_e( 'Want to contribute?', 'gravityview' ); ?></h4> |
484 | - <p><?php echo sprintf( esc_attr__( 'If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview'), '<a href="https://github.com/katzwebservices/GravityView">', '</a>' ); ?></p> |
|
484 | + <p><?php echo sprintf( esc_attr__( 'If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview' ), '<a href="https://github.com/katzwebservices/GravityView">', '</a>' ); ?></p> |
|
485 | 485 | </div> |
486 | 486 | </div> |
487 | 487 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | global $plugin_page; |
525 | 525 | |
526 | 526 | // Bail if we're just editing the plugin |
527 | - if( $plugin_page === 'plugin-editor.php' ) { return; } |
|
527 | + if ( $plugin_page === 'plugin-editor.php' ) { return; } |
|
528 | 528 | |
529 | 529 | // Bail if no activation redirect |
530 | 530 | if ( ! get_transient( '_gv_activation_redirect' ) ) { return; } |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | $upgrade = get_option( 'gv_version_upgraded_from' ); |
536 | 536 | |
537 | 537 | // Don't do anything if they've already seen the new version info |
538 | - if( $upgrade === GravityView_Plugin::version ) { |
|
538 | + if ( $upgrade === GravityView_Plugin::version ) { |
|
539 | 539 | return; |
540 | 540 | } |
541 | 541 | |
@@ -543,10 +543,10 @@ discard block |
||
543 | 543 | update_option( 'gv_version_upgraded_from', GravityView_Plugin::version ); |
544 | 544 | |
545 | 545 | // Bail if activating from network, or bulk |
546 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { return; } |
|
546 | + if ( is_network_admin() || isset( $_GET[ 'activate-multi' ] ) ) { return; } |
|
547 | 547 | |
548 | 548 | // First time install |
549 | - if( ! $upgrade ) { |
|
549 | + if ( ! $upgrade ) { |
|
550 | 550 | wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-getting-started' ) ); exit; |
551 | 551 | } |
552 | 552 | // Update |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'type' => 'radio', |
65 | 65 | 'full_width' => true, |
66 | 66 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
67 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
67 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
68 | 68 | 'value' => 'any', |
69 | 69 | 'class' => 'hide-if-js', |
70 | 70 | 'options' => array( |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
85 | 85 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
86 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
86 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
87 | 87 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
88 | 88 | |
89 | 89 | // ajax - get the searchable fields |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
228 | 228 | $script_source = empty( $script_min ) ? '/source' : ''; |
229 | 229 | |
230 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
230 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
231 | 231 | |
232 | 232 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
233 | 233 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
250 | 250 | */ |
251 | 251 | public function register_no_conflict( $allowed ) { |
252 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
252 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
253 | 253 | return $allowed; |
254 | 254 | } |
255 | 255 | |
@@ -262,20 +262,20 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public static function get_searchable_fields() { |
264 | 264 | |
265 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
265 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
266 | 266 | exit( '0' ); |
267 | 267 | } |
268 | 268 | |
269 | 269 | $form = ''; |
270 | 270 | |
271 | 271 | // Fetch the form for the current View |
272 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
272 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
273 | 273 | |
274 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
274 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
275 | 275 | |
276 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
276 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
277 | 277 | |
278 | - $form = (int) $_POST['formid']; |
|
278 | + $form = (int)$_POST[ 'formid' ]; |
|
279 | 279 | |
280 | 280 | } |
281 | 281 | |
@@ -325,14 +325,14 @@ discard block |
||
325 | 325 | ); |
326 | 326 | |
327 | 327 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
328 | - $custom_fields['is_approved'] = array( |
|
328 | + $custom_fields[ 'is_approved' ] = array( |
|
329 | 329 | 'text' => esc_html__( 'Approval Status', 'gravityview' ), |
330 | 330 | 'type' => 'multi', |
331 | 331 | ); |
332 | 332 | } |
333 | 333 | |
334 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
335 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
334 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
335 | + $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] ); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | // Get fields with sub-inputs and no parent |
@@ -354,13 +354,13 @@ discard block |
||
354 | 354 | |
355 | 355 | foreach ( $fields as $id => $field ) { |
356 | 356 | |
357 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
357 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
358 | 358 | continue; |
359 | 359 | } |
360 | 360 | |
361 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
361 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
362 | 362 | |
363 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
363 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
384 | 384 | |
385 | 385 | // @todo - This needs to be improved - many fields have . including products and addresses |
386 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
386 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
387 | 387 | $input_type = 'boolean'; // on/off checkbox |
388 | 388 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
389 | 389 | $input_type = 'multi'; //multiselect |
@@ -429,19 +429,19 @@ discard block |
||
429 | 429 | $post_id = 0; |
430 | 430 | |
431 | 431 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
432 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
433 | - $post_id = absint( $widget_args['post_id'] ); |
|
432 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
433 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
434 | 434 | } |
435 | 435 | // We're in the WordPress Widget context, and the base View ID should be used |
436 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
437 | - $post_id = absint( $widget_args['view_id'] ); |
|
436 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
437 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | $args = gravityview_get_permalink_query_args( $post_id ); |
441 | 441 | |
442 | 442 | // Add hidden fields to the search form |
443 | 443 | foreach ( $args as $key => $value ) { |
444 | - $search_fields[] = array( |
|
444 | + $search_fields[ ] = array( |
|
445 | 445 | 'name' => $key, |
446 | 446 | 'input' => 'hidden', |
447 | 447 | 'value' => $value, |
@@ -480,28 +480,28 @@ discard block |
||
480 | 480 | /** |
481 | 481 | * Include the sidebar Widgets. |
482 | 482 | */ |
483 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
483 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
484 | 484 | |
485 | 485 | foreach ( $widgets as $widget ) { |
486 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
487 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
486 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
487 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
488 | 488 | foreach ( $_fields as $field ) { |
489 | - if ( empty( $field['form_id'] ) ) { |
|
490 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
489 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
490 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
491 | 491 | } |
492 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
492 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | } |
496 | 496 | } |
497 | 497 | |
498 | 498 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
499 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
499 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
500 | 500 | foreach ( $_fields as $field ) { |
501 | - if ( empty( $field['form_id'] ) ) { |
|
502 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
501 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
502 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
503 | 503 | } |
504 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
504 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
505 | 505 | } |
506 | 506 | } |
507 | 507 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
540 | 540 | } |
541 | 541 | |
542 | - if( 'post' === $this->search_method ) { |
|
542 | + if ( 'post' === $this->search_method ) { |
|
543 | 543 | $get = $_POST; |
544 | 544 | } else { |
545 | 545 | $get = $_GET; |
@@ -558,15 +558,15 @@ discard block |
||
558 | 558 | $get = gv_map_deep( $get, 'rawurldecode' ); |
559 | 559 | |
560 | 560 | // Make sure array key is set up |
561 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
561 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
562 | 562 | |
563 | 563 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
564 | 564 | $searchable_field_objects = $this->get_view_searchable_fields( $view, true ); |
565 | 565 | |
566 | 566 | // add free search |
567 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
567 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
568 | 568 | |
569 | - $search_all_value = trim( $get['gv_search'] ); |
|
569 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
570 | 570 | |
571 | 571 | /** |
572 | 572 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | } |
592 | 592 | |
593 | 593 | foreach ( $words as $word ) { |
594 | - $search_criteria['field_filters'][] = array( |
|
594 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
595 | 595 | 'key' => null, // The field ID to search |
596 | 596 | 'value' => $word, // The value to search |
597 | 597 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -604,14 +604,14 @@ discard block |
||
604 | 604 | /** |
605 | 605 | * Get and normalize the dates according to the input format. |
606 | 606 | */ |
607 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
608 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
607 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
608 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
609 | 609 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
610 | 610 | } |
611 | 611 | } |
612 | 612 | |
613 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
614 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
613 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
614 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
615 | 615 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
616 | 616 | } |
617 | 617 | } |
@@ -646,22 +646,22 @@ discard block |
||
646 | 646 | */ |
647 | 647 | if ( ! empty( $curr_start ) ) { |
648 | 648 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
649 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
649 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | if ( ! empty( $curr_end ) ) { |
653 | 653 | // Fast-forward 24 hour on the end time |
654 | 654 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
655 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
656 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
657 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
655 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
656 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
657 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
658 | 658 | } |
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
662 | 662 | // search for a specific entry ID |
663 | 663 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
664 | - $search_criteria['field_filters'][] = array( |
|
664 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
665 | 665 | 'key' => 'id', |
666 | 666 | 'value' => absint( $get[ 'gv_id' ] ), |
667 | 667 | 'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ), |
@@ -670,20 +670,20 @@ discard block |
||
670 | 670 | |
671 | 671 | // search for a specific Created_by ID |
672 | 672 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
673 | - $search_criteria['field_filters'][] = array( |
|
673 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
674 | 674 | 'key' => 'created_by', |
675 | - 'value' => $get['gv_by'], |
|
675 | + 'value' => $get[ 'gv_by' ], |
|
676 | 676 | 'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ), |
677 | 677 | ); |
678 | 678 | } |
679 | 679 | |
680 | 680 | // Get search mode passed in URL |
681 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
681 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
682 | 682 | |
683 | 683 | // get the other search filters |
684 | 684 | foreach ( $get as $key => $value ) { |
685 | 685 | |
686 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
686 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
687 | 687 | continue; // Not a filter, or empty |
688 | 688 | } |
689 | 689 | |
@@ -697,19 +697,19 @@ discard block |
||
697 | 697 | continue; |
698 | 698 | } |
699 | 699 | |
700 | - if ( ! isset( $filter['operator'] ) ) { |
|
701 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
700 | + if ( ! isset( $filter[ 'operator' ] ) ) { |
|
701 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
702 | 702 | } |
703 | 703 | |
704 | - if ( isset( $filter[0]['value'] ) ) { |
|
705 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
704 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
705 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
706 | 706 | |
707 | 707 | // if date range type, set search mode to ALL |
708 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
708 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
709 | 709 | $mode = 'all'; |
710 | 710 | } |
711 | - } elseif( !empty( $filter ) ) { |
|
712 | - $search_criteria['field_filters'][] = $filter; |
|
711 | + } elseif ( ! empty( $filter ) ) { |
|
712 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | * @since 1.5.1 |
719 | 719 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
720 | 720 | */ |
721 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
721 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
722 | 722 | |
723 | 723 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
724 | 724 | |
@@ -752,19 +752,19 @@ discard block |
||
752 | 752 | |
753 | 753 | $query_class = $view->get_query_class(); |
754 | 754 | |
755 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
755 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
756 | 756 | return; |
757 | 757 | } |
758 | 758 | |
759 | 759 | $widgets = $view->widgets->by_id( $this->widget_id ); |
760 | 760 | if ( $widgets->count() ) { |
761 | 761 | $widgets = $widgets->all(); |
762 | - $widget = $widgets[0]; |
|
762 | + $widget = $widgets[ 0 ]; |
|
763 | 763 | |
764 | 764 | $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ); |
765 | 765 | |
766 | - foreach ( (array) $search_fields as $search_field ) { |
|
767 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
766 | + foreach ( (array)$search_fields as $search_field ) { |
|
767 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
768 | 768 | $created_by_text_mode = true; |
769 | 769 | } |
770 | 770 | } |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | $extra_conditions = array(); |
774 | 774 | $mode = 'any'; |
775 | 775 | |
776 | - foreach ( $search_criteria['field_filters'] as &$filter ) { |
|
776 | + foreach ( $search_criteria[ 'field_filters' ] as &$filter ) { |
|
777 | 777 | if ( ! is_array( $filter ) ) { |
778 | 778 | if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) { |
779 | 779 | $mode = $filter; |
@@ -782,13 +782,13 @@ discard block |
||
782 | 782 | } |
783 | 783 | |
784 | 784 | // Construct a manual query for unapproved statuses |
785 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { |
|
786 | - $_tmp_query = new $query_class( $view->form->ID, array( |
|
785 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) { |
|
786 | + $_tmp_query = new $query_class( $view->form->ID, array( |
|
787 | 787 | 'field_filters' => array( |
788 | 788 | array( |
789 | 789 | 'operator' => 'in', |
790 | 790 | 'key' => 'is_approved', |
791 | - 'value' => (array) $filter['value'], |
|
791 | + 'value' => (array)$filter[ 'value' ], |
|
792 | 792 | ), |
793 | 793 | array( |
794 | 794 | 'operator' => 'is', |
@@ -800,30 +800,30 @@ discard block |
||
800 | 800 | ) ); |
801 | 801 | $_tmp_query_parts = $_tmp_query->_introspect(); |
802 | 802 | |
803 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
803 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
804 | 804 | |
805 | 805 | $filter = false; |
806 | 806 | continue; |
807 | 807 | } |
808 | 808 | |
809 | 809 | // Construct manual query for text mode creator search |
810 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
811 | - $extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
810 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
811 | + $extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
812 | 812 | $filter = false; |
813 | 813 | continue; |
814 | 814 | } |
815 | 815 | |
816 | 816 | // By default, we want searches to be wildcard for each field. |
817 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
817 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
818 | 818 | |
819 | 819 | // For multichoice, let's have an in (OR) search. |
820 | - if ( is_array( $filter['value'] ) ) { |
|
821 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
820 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
821 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | // Default form with joins functionality |
825 | - if ( empty( $filter['form_id'] ) ) { |
|
826 | - $filter['form_id'] = $view->form ? $view->form->ID : 0; |
|
825 | + if ( empty( $filter[ 'form_id' ] ) ) { |
|
826 | + $filter[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | /** |
@@ -833,28 +833,28 @@ discard block |
||
833 | 833 | * @since develop |
834 | 834 | * @param \GV\View $view The View we're operating on. |
835 | 835 | */ |
836 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view ); |
|
836 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view ); |
|
837 | 837 | } |
838 | 838 | |
839 | - if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) { |
|
839 | + if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) { |
|
840 | 840 | $date_criteria = array(); |
841 | 841 | |
842 | - if ( isset( $search_criteria['start_date'] ) ) { |
|
843 | - $date_criteria['start_date'] = $search_criteria['start_date']; |
|
842 | + if ( isset( $search_criteria[ 'start_date' ] ) ) { |
|
843 | + $date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ]; |
|
844 | 844 | } |
845 | 845 | |
846 | - if ( isset( $search_criteria['end_date'] ) ) { |
|
847 | - $date_criteria['end_date'] = $search_criteria['end_date']; |
|
846 | + if ( isset( $search_criteria[ 'end_date' ] ) ) { |
|
847 | + $date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ]; |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | $_tmp_query = new $query_class( $view->form->ID, $date_criteria ); |
851 | 851 | $_tmp_query_parts = $_tmp_query->_introspect(); |
852 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
852 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | $search_conditions = array(); |
856 | 856 | |
857 | - if ( $filters = array_filter( $search_criteria['field_filters'] ) ) { |
|
857 | + if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) { |
|
858 | 858 | foreach ( $filters as &$filter ) { |
859 | 859 | if ( ! is_array( $filter ) ) { |
860 | 860 | continue; |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | * code by reusing what's inside GF_Query already as they |
867 | 867 | * take care of many small things like forcing numeric, etc. |
868 | 868 | */ |
869 | - $_tmp_query = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
869 | + $_tmp_query = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
870 | 870 | $_tmp_query_parts = $_tmp_query->_introspect(); |
871 | - $search_condition = $_tmp_query_parts['where']; |
|
871 | + $search_condition = $_tmp_query_parts[ 'where' ]; |
|
872 | 872 | |
873 | - if ( empty( $filter['key'] ) && $search_condition->expressions ) { |
|
874 | - $search_conditions[] = $search_condition; |
|
873 | + if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) { |
|
874 | + $search_conditions[ ] = $search_condition; |
|
875 | 875 | } else { |
876 | 876 | $left = $search_condition->left; |
877 | 877 | $alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' ); |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | $on = $_join->join_on; |
882 | 882 | $join = $_join->join; |
883 | 883 | |
884 | - $search_conditions[] = GF_Query_Condition::_or( |
|
884 | + $search_conditions[ ] = GF_Query_Condition::_or( |
|
885 | 885 | // Join |
886 | 886 | new GF_Query_Condition( |
887 | 887 | new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ), |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | ); |
898 | 898 | } |
899 | 899 | } else { |
900 | - $search_conditions[] = new GF_Query_Condition( |
|
900 | + $search_conditions[ ] = new GF_Query_Condition( |
|
901 | 901 | new GF_Query_Column( $left->field_id, $left->source, $alias ), |
902 | 902 | $search_condition->operator, |
903 | 903 | $search_condition->right |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | /** |
920 | 920 | * Combine the parts as a new WHERE clause. |
921 | 921 | */ |
922 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) ); |
|
922 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) ); |
|
923 | 923 | $query->where( $where ); |
924 | 924 | } |
925 | 925 | |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | $field_id = str_replace( 'filter_', '', $key ); |
943 | 943 | |
944 | 944 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
945 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
945 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
946 | 946 | $field_id = str_replace( '_', '.', $field_id ); |
947 | 947 | } |
948 | 948 | |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | // form is in searchable fields |
1000 | 1000 | $found = false; |
1001 | 1001 | foreach ( $searchable_fields as $field ) { |
1002 | - if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) { |
|
1002 | + if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) { |
|
1003 | 1003 | $found = true; |
1004 | 1004 | break; |
1005 | 1005 | } |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | |
1040 | 1040 | case 'select': |
1041 | 1041 | case 'radio': |
1042 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1042 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1043 | 1043 | break; |
1044 | 1044 | |
1045 | 1045 | case 'post_category': |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | |
1054 | 1054 | foreach ( $value as $val ) { |
1055 | 1055 | $cat = get_term( $val, 'category' ); |
1056 | - $filter[] = array( |
|
1056 | + $filter[ ] = array( |
|
1057 | 1057 | 'key' => $field_id, |
1058 | 1058 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
1059 | 1059 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | $filter = array(); |
1073 | 1073 | |
1074 | 1074 | foreach ( $value as $val ) { |
1075 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
1075 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | break; |
@@ -1081,9 +1081,9 @@ discard block |
||
1081 | 1081 | // convert checkbox on/off into the correct search filter |
1082 | 1082 | if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
1083 | 1083 | foreach ( $form_field->inputs as $k => $input ) { |
1084 | - if ( $input['id'] == $field_id ) { |
|
1085 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
1086 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1084 | + if ( $input[ 'id' ] == $field_id ) { |
|
1085 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
1086 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1087 | 1087 | break; |
1088 | 1088 | } |
1089 | 1089 | } |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | $filter = array(); |
1094 | 1094 | |
1095 | 1095 | foreach ( $value as $val ) { |
1096 | - $filter[] = array( |
|
1096 | + $filter[ ] = array( |
|
1097 | 1097 | 'key' => $field_id, |
1098 | 1098 | 'value' => $val, |
1099 | 1099 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1114,9 +1114,9 @@ discard block |
||
1114 | 1114 | foreach ( $words as $word ) { |
1115 | 1115 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
1116 | 1116 | // Keep the same key for each filter |
1117 | - $filter['value'] = $word; |
|
1117 | + $filter[ 'value' ] = $word; |
|
1118 | 1118 | // Add a search for the value |
1119 | - $filters[] = $filter; |
|
1119 | + $filters[ ] = $filter; |
|
1120 | 1120 | } |
1121 | 1121 | } |
1122 | 1122 | |
@@ -1130,19 +1130,19 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | foreach ( $searchable_fields as $searchable_field ) { |
1132 | 1132 | |
1133 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
1133 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
1134 | 1134 | continue; |
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | // Only exact-match dropdowns, not text search |
1138 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
1138 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
1139 | 1139 | continue; |
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
1143 | 1143 | |
1144 | 1144 | if ( 4 === $input_id ) { |
1145 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1145 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1146 | 1146 | }; |
1147 | 1147 | } |
1148 | 1148 | } |
@@ -1169,12 +1169,12 @@ discard block |
||
1169 | 1169 | * @since 1.16.3 |
1170 | 1170 | * Safeguard until GF implements '<=' operator |
1171 | 1171 | */ |
1172 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1172 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1173 | 1173 | $operator = '<'; |
1174 | 1174 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
1175 | 1175 | } |
1176 | 1176 | |
1177 | - $filter[] = array( |
|
1177 | + $filter[ ] = array( |
|
1178 | 1178 | 'key' => $field_id, |
1179 | 1179 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
1180 | 1180 | 'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ), |
@@ -1182,8 +1182,8 @@ discard block |
||
1182 | 1182 | } |
1183 | 1183 | } else { |
1184 | 1184 | $date = $value; |
1185 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1186 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1185 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1186 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | break; |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | 'ymd_dot' => 'Y.m.d', |
1215 | 1215 | ); |
1216 | 1216 | |
1217 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
1217 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
1218 | 1218 | $format = $datepicker[ $field->dateFormat ]; |
1219 | 1219 | } |
1220 | 1220 | |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | public function add_template_path( $file_paths ) { |
1252 | 1252 | |
1253 | 1253 | // Index 100 is the default GravityView template path. |
1254 | - $file_paths[102] = self::$file . 'templates/'; |
|
1254 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1255 | 1255 | |
1256 | 1256 | return $file_paths; |
1257 | 1257 | } |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | $has_date = false; |
1271 | 1271 | |
1272 | 1272 | foreach ( $search_fields as $k => $field ) { |
1273 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1273 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1274 | 1274 | $has_date = true; |
1275 | 1275 | break; |
1276 | 1276 | } |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | // get configured search fields |
1300 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1300 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1301 | 1301 | |
1302 | 1302 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1303 | 1303 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1313,40 +1313,40 @@ discard block |
||
1313 | 1313 | |
1314 | 1314 | $updated_field = $this->get_search_filter_details( $updated_field, $context ); |
1315 | 1315 | |
1316 | - switch ( $field['field'] ) { |
|
1316 | + switch ( $field[ 'field' ] ) { |
|
1317 | 1317 | |
1318 | 1318 | case 'search_all': |
1319 | - $updated_field['key'] = 'search_all'; |
|
1320 | - $updated_field['input'] = 'search_all'; |
|
1321 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1319 | + $updated_field[ 'key' ] = 'search_all'; |
|
1320 | + $updated_field[ 'input' ] = 'search_all'; |
|
1321 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1322 | 1322 | break; |
1323 | 1323 | |
1324 | 1324 | case 'entry_date': |
1325 | - $updated_field['key'] = 'entry_date'; |
|
1326 | - $updated_field['input'] = 'entry_date'; |
|
1327 | - $updated_field['value'] = array( |
|
1325 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1326 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1327 | + $updated_field[ 'value' ] = array( |
|
1328 | 1328 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1329 | 1329 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1330 | 1330 | ); |
1331 | 1331 | break; |
1332 | 1332 | |
1333 | 1333 | case 'entry_id': |
1334 | - $updated_field['key'] = 'entry_id'; |
|
1335 | - $updated_field['input'] = 'entry_id'; |
|
1336 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1334 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1335 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1336 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1337 | 1337 | break; |
1338 | 1338 | |
1339 | 1339 | case 'created_by': |
1340 | - $updated_field['key'] = 'created_by'; |
|
1341 | - $updated_field['name'] = 'gv_by'; |
|
1342 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1343 | - $updated_field['choices'] = self::get_created_by_choices( $view ); |
|
1340 | + $updated_field[ 'key' ] = 'created_by'; |
|
1341 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1342 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1343 | + $updated_field[ 'choices' ] = self::get_created_by_choices( $view ); |
|
1344 | 1344 | break; |
1345 | 1345 | |
1346 | 1346 | case 'is_approved': |
1347 | - $updated_field['key'] = 'is_approved'; |
|
1348 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1349 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
1347 | + $updated_field[ 'key' ] = 'is_approved'; |
|
1348 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1349 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
1350 | 1350 | break; |
1351 | 1351 | } |
1352 | 1352 | |
@@ -1367,16 +1367,16 @@ discard block |
||
1367 | 1367 | |
1368 | 1368 | $gravityview_view->permalink_fields = $this->add_no_permalink_fields( array(), $this, $widget_args ); |
1369 | 1369 | |
1370 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1370 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1371 | 1371 | |
1372 | 1372 | /** @since 1.14 */ |
1373 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1373 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1374 | 1374 | |
1375 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1375 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1376 | 1376 | |
1377 | 1377 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1378 | 1378 | |
1379 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1379 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1380 | 1380 | |
1381 | 1381 | if ( $this->has_date_field( $search_fields ) ) { |
1382 | 1382 | // enqueue datepicker stuff only if needed! |
@@ -1398,10 +1398,10 @@ discard block |
||
1398 | 1398 | public static function get_search_class( $custom_class = '' ) { |
1399 | 1399 | $gravityview_view = GravityView_View::getInstance(); |
1400 | 1400 | |
1401 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1401 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1402 | 1402 | |
1403 | - if ( ! empty( $custom_class ) ) { |
|
1404 | - $search_class .= ' '.$custom_class; |
|
1403 | + if ( ! empty( $custom_class ) ) { |
|
1404 | + $search_class .= ' ' . $custom_class; |
|
1405 | 1405 | } |
1406 | 1406 | |
1407 | 1407 | /** |
@@ -1445,9 +1445,9 @@ discard block |
||
1445 | 1445 | |
1446 | 1446 | if ( ! $label ) { |
1447 | 1447 | |
1448 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1448 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1449 | 1449 | |
1450 | - switch( $field['field'] ) { |
|
1450 | + switch ( $field[ 'field' ] ) { |
|
1451 | 1451 | case 'search_all': |
1452 | 1452 | $label = __( 'Search Entries:', 'gravityview' ); |
1453 | 1453 | break; |
@@ -1459,10 +1459,10 @@ discard block |
||
1459 | 1459 | break; |
1460 | 1460 | default: |
1461 | 1461 | // If this is a field input, not a field |
1462 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1462 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1463 | 1463 | |
1464 | 1464 | // Get the label for the field in question, which returns an array |
1465 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1465 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1466 | 1466 | |
1467 | 1467 | // Get the item with the `label` key |
1468 | 1468 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1503,35 +1503,35 @@ discard block |
||
1503 | 1503 | $form = $gravityview_view->getForm(); |
1504 | 1504 | |
1505 | 1505 | // for advanced field ids (eg, first name / last name ) |
1506 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1506 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1507 | 1507 | |
1508 | 1508 | // get searched value from $_GET/$_POST (string or array) |
1509 | 1509 | $value = $this->rgget_or_rgpost( $name ); |
1510 | 1510 | |
1511 | 1511 | // get form field details |
1512 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1512 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1513 | 1513 | |
1514 | 1514 | $filter = array( |
1515 | - 'key' => $field['field'], |
|
1515 | + 'key' => $field[ 'field' ], |
|
1516 | 1516 | 'name' => $name, |
1517 | 1517 | 'label' => self::get_field_label( $field, $form_field ), |
1518 | - 'input' => $field['input'], |
|
1518 | + 'input' => $field[ 'input' ], |
|
1519 | 1519 | 'value' => $value, |
1520 | - 'type' => $form_field['type'], |
|
1520 | + 'type' => $form_field[ 'type' ], |
|
1521 | 1521 | ); |
1522 | 1522 | |
1523 | 1523 | // collect choices |
1524 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1525 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1526 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1527 | - $filter['choices'] = $form_field['choices']; |
|
1524 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1525 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1526 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1527 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1528 | 1528 | } |
1529 | 1529 | |
1530 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1531 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1530 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1531 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | - if ( ! empty( $filter['choices'] ) ) { |
|
1534 | + if ( ! empty( $filter[ 'choices' ] ) ) { |
|
1535 | 1535 | /** |
1536 | 1536 | * @filter `gravityview/search/sieve_choices` Only output used choices for this field. |
1537 | 1537 | * @param[in,out] bool Yes or no. |
@@ -1539,7 +1539,7 @@ discard block |
||
1539 | 1539 | * @param \GV\Context The context. |
1540 | 1540 | */ |
1541 | 1541 | if ( apply_filters( 'gravityview/search/sieve_choices', false, $field, $context ) ) { |
1542 | - $filter['choices'] = $this->sieve_filter_choices( $filter, $context ); |
|
1542 | + $filter[ 'choices' ] = $this->sieve_filter_choices( $filter, $context ); |
|
1543 | 1543 | } |
1544 | 1544 | } |
1545 | 1545 | |
@@ -1568,11 +1568,11 @@ discard block |
||
1568 | 1568 | * @return array The filter choices. |
1569 | 1569 | */ |
1570 | 1570 | private function sieve_filter_choices( $filter, $context ) { |
1571 | - if ( empty( $filter['key'] ) || empty( $filter['choices'] ) ) { |
|
1571 | + if ( empty( $filter[ 'key' ] ) || empty( $filter[ 'choices' ] ) ) { |
|
1572 | 1572 | return $filter; // @todo Populate plugins might give us empty choices |
1573 | 1573 | } |
1574 | 1574 | |
1575 | - if ( ! is_numeric( $filter['key'] ) ) { |
|
1575 | + if ( ! is_numeric( $filter[ 'key' ] ) ) { |
|
1576 | 1576 | return $filter; |
1577 | 1577 | } |
1578 | 1578 | |
@@ -1582,29 +1582,29 @@ discard block |
||
1582 | 1582 | |
1583 | 1583 | $table = GFFormsModel::get_entry_meta_table_name(); |
1584 | 1584 | |
1585 | - $key_like = $wpdb->esc_like( $filter['key'] ) . '.%'; |
|
1585 | + $key_like = $wpdb->esc_like( $filter[ 'key' ] ) . '.%'; |
|
1586 | 1586 | |
1587 | 1587 | switch ( \GV\Utils::get( $filter, 'type' ) ): |
1588 | 1588 | case 'post_category': |
1589 | 1589 | $choices = $wpdb->get_col( $wpdb->prepare( |
1590 | 1590 | "SELECT DISTINCT SUBSTRING_INDEX(meta_value, ':', 1) FROM $table WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d", |
1591 | - $key_like, $filter['key'], $form_id |
|
1591 | + $key_like, $filter[ 'key' ], $form_id |
|
1592 | 1592 | ) ); |
1593 | 1593 | break; |
1594 | 1594 | default: |
1595 | 1595 | $choices = $wpdb->get_col( $wpdb->prepare( |
1596 | 1596 | "SELECT DISTINCT meta_value FROM $table WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d", |
1597 | - $key_like, $filter['key'], $form_id |
|
1597 | + $key_like, $filter[ 'key' ], $form_id |
|
1598 | 1598 | ) ); |
1599 | 1599 | |
1600 | - if ( ( $field = gravityview_get_field( $form_id, $filter['key'] ) ) && 'json' === $field->storageType ) { |
|
1600 | + if ( ( $field = gravityview_get_field( $form_id, $filter[ 'key' ] ) ) && 'json' === $field->storageType ) { |
|
1601 | 1601 | $choices = array_map( 'json_decode', $choices ); |
1602 | 1602 | $_choices_array = array(); |
1603 | 1603 | foreach ( $choices as $choice ) { |
1604 | 1604 | if ( is_array( $choice ) ) { |
1605 | 1605 | $_choices_array = array_merge( $_choices_array, $choice ); |
1606 | 1606 | } else { |
1607 | - $_choices_array []= $choice; |
|
1607 | + $_choices_array [ ] = $choice; |
|
1608 | 1608 | } |
1609 | 1609 | } |
1610 | 1610 | $choices = array_unique( $_choices_array ); |
@@ -1614,9 +1614,9 @@ discard block |
||
1614 | 1614 | endswitch; |
1615 | 1615 | |
1616 | 1616 | $filter_choices = array(); |
1617 | - foreach ( $filter['choices'] as $choice ) { |
|
1618 | - if ( in_array( $choice['text'], $choices, true ) || in_array( $choice['value'], $choices, true ) ) { |
|
1619 | - $filter_choices[] = $choice; |
|
1617 | + foreach ( $filter[ 'choices' ] as $choice ) { |
|
1618 | + if ( in_array( $choice[ 'text' ], $choices, true ) || in_array( $choice[ 'value' ], $choices, true ) ) { |
|
1619 | + $filter_choices[ ] = $choice; |
|
1620 | 1620 | } |
1621 | 1621 | } |
1622 | 1622 | |
@@ -1651,7 +1651,7 @@ discard block |
||
1651 | 1651 | * @param \GV\View $view The view. |
1652 | 1652 | */ |
1653 | 1653 | $text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view ); |
1654 | - $choices[] = array( |
|
1654 | + $choices[ ] = array( |
|
1655 | 1655 | 'value' => $user->ID, |
1656 | 1656 | 'text' => $text, |
1657 | 1657 | ); |
@@ -1671,9 +1671,9 @@ discard block |
||
1671 | 1671 | |
1672 | 1672 | $choices = array(); |
1673 | 1673 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
1674 | - $choices[] = array( |
|
1675 | - 'value' => $status['value'], |
|
1676 | - 'text' => $status['label'], |
|
1674 | + $choices[ ] = array( |
|
1675 | + 'value' => $status[ 'value' ], |
|
1676 | + 'text' => $status[ 'label' ], |
|
1677 | 1677 | ); |
1678 | 1678 | } |
1679 | 1679 | |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | */ |
1726 | 1726 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1727 | 1727 | |
1728 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1728 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1729 | 1729 | |
1730 | 1730 | return $js_dependencies; |
1731 | 1731 | } |
@@ -1769,7 +1769,7 @@ discard block |
||
1769 | 1769 | 'isRTL' => is_rtl(), |
1770 | 1770 | ), $view_data ); |
1771 | 1771 | |
1772 | - $localizations['datepicker'] = $datepicker_settings; |
|
1772 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1773 | 1773 | |
1774 | 1774 | return $localizations; |
1775 | 1775 | |
@@ -1796,7 +1796,7 @@ discard block |
||
1796 | 1796 | * @return void |
1797 | 1797 | */ |
1798 | 1798 | private function maybe_enqueue_flexibility() { |
1799 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1799 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1800 | 1800 | wp_enqueue_script( 'gv-flexibility' ); |
1801 | 1801 | } |
1802 | 1802 | } |
@@ -1818,7 +1818,7 @@ discard block |
||
1818 | 1818 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1819 | 1819 | |
1820 | 1820 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1821 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1821 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1822 | 1822 | |
1823 | 1823 | /** |
1824 | 1824 | * @filter `gravityview_search_datepicker_class` |
@@ -1897,7 +1897,7 @@ discard block |
||
1897 | 1897 | public function add_preview_inputs() { |
1898 | 1898 | global $wp; |
1899 | 1899 | |
1900 | - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { |
|
1900 | + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { |
|
1901 | 1901 | return; |
1902 | 1902 | } |
1903 | 1903 | |
@@ -1949,7 +1949,7 @@ discard block |
||
1949 | 1949 | */ |
1950 | 1950 | class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition { |
1951 | 1951 | public function __construct( $filter, $view ) { |
1952 | - $this->value = $filter['value']; |
|
1952 | + $this->value = $filter[ 'value' ]; |
|
1953 | 1953 | $this->view = $view; |
1954 | 1954 | } |
1955 | 1955 | |
@@ -1981,11 +1981,11 @@ discard block |
||
1981 | 1981 | $conditions = array(); |
1982 | 1982 | |
1983 | 1983 | foreach ( $user_fields as $user_field ) { |
1984 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1984 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1985 | 1985 | } |
1986 | 1986 | |
1987 | 1987 | foreach ( $user_meta_fields as $meta_field ) { |
1988 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1988 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1989 | 1989 | } |
1990 | 1990 | |
1991 | 1991 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |