@@ -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 = GravityView_Entry_Notes::get_notes( $entry['id'] ); |
|
28 | +$notes = 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 | ?> |
@@ -63,18 +63,18 @@ discard block |
||
63 | 63 | |
64 | 64 | add_shortcode( 'gv_note_add', array( 'GravityView_Field_Notes', 'get_add_note_part' ) ); |
65 | 65 | |
66 | - add_action( 'wp', array( $this, 'maybe_delete_notes'), 1000 ); |
|
67 | - add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
68 | - add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
66 | + add_action( 'wp', array( $this, 'maybe_delete_notes' ), 1000 ); |
|
67 | + add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
68 | + add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
69 | 69 | |
70 | - add_action( 'wp', array( $this, 'maybe_add_note'), 1000 ); |
|
71 | - add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note') ); |
|
72 | - add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note') ); |
|
70 | + add_action( 'wp', array( $this, 'maybe_add_note' ), 1000 ); |
|
71 | + add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
72 | + add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
73 | 73 | |
74 | 74 | // add template path to check for field |
75 | 75 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
76 | 76 | |
77 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
77 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
78 | 78 | add_action( 'gravityview/field/notes/scripts', array( $this, 'enqueue_scripts' ) ); |
79 | 79 | } |
80 | 80 | |
@@ -100,23 +100,23 @@ discard block |
||
100 | 100 | public function enqueue_scripts() { |
101 | 101 | global $wp_actions; |
102 | 102 | |
103 | - if( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
103 | + if ( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
104 | 104 | wp_enqueue_style( 'gravityview-notes' ); |
105 | 105 | wp_enqueue_script( 'gravityview-notes' ); |
106 | 106 | } |
107 | 107 | |
108 | - if( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
108 | + if ( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
109 | 109 | |
110 | 110 | $strings = self::strings(); |
111 | 111 | |
112 | 112 | wp_localize_script( 'gravityview-notes', 'GVNotes', array( |
113 | 113 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
114 | 114 | 'text' => array( |
115 | - 'processing' => $strings['processing'], |
|
116 | - 'delete_confirm' => $strings['delete-confirm'], |
|
117 | - 'note_added' => $strings['added-note'], |
|
118 | - 'error_invalid' => $strings['error-invalid'], |
|
119 | - 'error_empty_note' => $strings['error-empty-note'], |
|
115 | + 'processing' => $strings[ 'processing' ], |
|
116 | + 'delete_confirm' => $strings[ 'delete-confirm' ], |
|
117 | + 'note_added' => $strings[ 'added-note' ], |
|
118 | + 'error_invalid' => $strings[ 'error-invalid' ], |
|
119 | + 'error_empty_note' => $strings[ 'error-empty-note' ], |
|
120 | 120 | ), |
121 | 121 | ) ); |
122 | 122 | } |
@@ -133,22 +133,22 @@ discard block |
||
133 | 133 | */ |
134 | 134 | function maybe_add_note() { |
135 | 135 | |
136 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
136 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
137 | 137 | do_action( 'gravityview_log_error', __METHOD__ . ': The user isnt allowed to add entry notes.' ); |
138 | 138 | return; |
139 | 139 | } |
140 | 140 | |
141 | - if( 'gv_note_add' === rgpost('action') ) { |
|
141 | + if ( 'gv_note_add' === rgpost( 'action' ) ) { |
|
142 | 142 | |
143 | 143 | $post = wp_unslash( $_POST ); |
144 | 144 | |
145 | - if( $this->doing_ajax ) { |
|
146 | - parse_str( $post['data'], $data ); |
|
145 | + if ( $this->doing_ajax ) { |
|
146 | + parse_str( $post[ 'data' ], $data ); |
|
147 | 147 | } else { |
148 | 148 | $data = $post; |
149 | 149 | } |
150 | 150 | |
151 | - $this->process_add_note( (array) $data ); |
|
151 | + $this->process_add_note( (array)$data ); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -175,23 +175,23 @@ discard block |
||
175 | 175 | $error = false; |
176 | 176 | $success = false; |
177 | 177 | |
178 | - if( empty( $data['entry-slug'] ) ) { |
|
178 | + if ( empty( $data[ 'entry-slug' ] ) ) { |
|
179 | 179 | |
180 | - $error = self::strings('error-invalid'); |
|
180 | + $error = self::strings( 'error-invalid' ); |
|
181 | 181 | do_action( 'gravityview_log_error', __METHOD__ . ': The note is missing an Entry ID.' ); |
182 | 182 | |
183 | 183 | } else { |
184 | 184 | |
185 | - $valid = wp_verify_nonce( $data['gv_note_add'], 'gv_note_add_' . $data['entry-slug'] ); |
|
185 | + $valid = wp_verify_nonce( $data[ 'gv_note_add' ], 'gv_note_add_' . $data[ 'entry-slug' ] ); |
|
186 | 186 | |
187 | 187 | $has_cap = GVCommon::has_cap( 'gravityview_add_entry_notes' ); |
188 | 188 | |
189 | - if( ! $has_cap ) { |
|
189 | + if ( ! $has_cap ) { |
|
190 | 190 | $error = self::strings( 'error-cap-add' ); |
191 | 191 | do_action( 'gravityview_log_error', __METHOD__ . ': Adding a note failed: the user does not have the "gravityview_add_entry_notes" capability.' ); |
192 | 192 | } elseif ( $valid ) { |
193 | 193 | |
194 | - $entry = gravityview_get_entry( $data['entry-slug'], true, false ); |
|
194 | + $entry = gravityview_get_entry( $data[ 'entry-slug' ], true, false ); |
|
195 | 195 | |
196 | 196 | $added = $this->add_note( $entry, $data ); |
197 | 197 | |
@@ -209,22 +209,22 @@ discard block |
||
209 | 209 | $this->maybe_send_entry_notes( $note, $entry, $data ); |
210 | 210 | |
211 | 211 | if ( $note ) { |
212 | - $success = self::display_note( $note, ! empty( $data['show-delete'] ) ); |
|
213 | - do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact('note', 'data') ); |
|
212 | + $success = self::display_note( $note, ! empty( $data[ 'show-delete' ] ) ); |
|
213 | + do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact( 'note', 'data' ) ); |
|
214 | 214 | } else { |
215 | - $error = self::strings('error-add-note'); |
|
216 | - do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact('note', 'data') ); |
|
215 | + $error = self::strings( 'error-add-note' ); |
|
216 | + do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact( 'note', 'data' ) ); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | } else { |
220 | - $error = self::strings('error-invalid'); |
|
220 | + $error = self::strings( 'error-invalid' ); |
|
221 | 221 | do_action( 'gravityview_log_error', __METHOD__ . ': Nonce validation failed; the note was not created' ); |
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | 225 | |
226 | - if( $this->doing_ajax ) { |
|
227 | - if( $success ) { |
|
226 | + if ( $this->doing_ajax ) { |
|
227 | + if ( $success ) { |
|
228 | 228 | wp_send_json_success( array( 'html' => $success ) ); |
229 | 229 | } else { |
230 | 230 | $error = $error ? $error : self::strings( 'error-invalid' ); |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | - if ( isset( $_POST['action'] ) && 'gv_delete_notes' === $_POST['action'] ) { |
|
253 | + if ( isset( $_POST[ 'action' ] ) && 'gv_delete_notes' === $_POST[ 'action' ] ) { |
|
254 | 254 | |
255 | 255 | $post = wp_unslash( $_POST ); |
256 | 256 | if ( $this->doing_ajax ) { |
257 | - parse_str( $post['data'], $data ); |
|
257 | + parse_str( $post[ 'data' ], $data ); |
|
258 | 258 | } else { |
259 | 259 | $data = $post; |
260 | 260 | } |
@@ -285,18 +285,18 @@ discard block |
||
285 | 285 | */ |
286 | 286 | function process_delete_notes( $data ) { |
287 | 287 | |
288 | - $valid = wp_verify_nonce( $data['gv_delete_notes'], 'gv_delete_notes_' . $data['entry-slug'] ); |
|
288 | + $valid = wp_verify_nonce( $data[ 'gv_delete_notes' ], 'gv_delete_notes_' . $data[ 'entry-slug' ] ); |
|
289 | 289 | $has_cap = GVCommon::has_cap( 'gravityview_delete_entry_notes' ); |
290 | 290 | $success = false; |
291 | 291 | |
292 | 292 | if ( $valid && $has_cap ) { |
293 | - GravityView_Entry_Notes::delete_notes( $data['note'] ); |
|
293 | + GravityView_Entry_Notes::delete_notes( $data[ 'note' ] ); |
|
294 | 294 | $success = true; |
295 | 295 | } |
296 | 296 | |
297 | - if( $this->doing_ajax ) { |
|
297 | + if ( $this->doing_ajax ) { |
|
298 | 298 | |
299 | - if( $success ) { |
|
299 | + if ( $success ) { |
|
300 | 300 | wp_send_json_success(); |
301 | 301 | } else { |
302 | 302 | if ( ! $valid ) { |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | |
330 | 330 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
331 | 331 | |
332 | - unset( $field_options['show_as_link'] ); |
|
332 | + unset( $field_options[ 'show_as_link' ] ); |
|
333 | 333 | |
334 | 334 | $notes_options = array( |
335 | 335 | 'notes' => array( |
336 | 336 | 'type' => 'checkboxes', |
337 | - 'label' => __('Note Settings', 'gravityview'), |
|
338 | - 'desc' => sprintf( _x('Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
337 | + 'label' => __( 'Note Settings', 'gravityview' ), |
|
338 | + 'desc' => sprintf( _x( 'Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
339 | 339 | 'options' => array( |
340 | 340 | 'view' => array( |
341 | 341 | 'label' => __( 'Display notes?', 'gravityview' ), |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | 'processing' => __( 'Processing…', 'gravityview' ), |
388 | 388 | 'other-email' => __( 'Other email address', 'gravityview' ), |
389 | 389 | 'email-label' => __( 'Email address', 'gravityview' ), |
390 | - 'email-placeholder' => _x('[email protected]', 'Example email address used as a placeholder', 'gravityview'), |
|
390 | + 'email-placeholder' => _x( '[email protected]', 'Example email address used as a placeholder', 'gravityview' ), |
|
391 | 391 | 'subject-label' => __( 'Subject', 'gravityview' ), |
392 | 392 | 'subject' => __( 'Email subject', 'gravityview' ), |
393 | 393 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | */ |
407 | 407 | $strings = gv_map_deep( apply_filters( 'gravityview/field/notes/strings', $strings ), 'esc_html' ); |
408 | 408 | |
409 | - if( $key ) { |
|
409 | + if ( $key ) { |
|
410 | 410 | return isset( $strings[ $key ] ) ? $strings[ $key ] : ''; |
411 | 411 | } |
412 | 412 | |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | static public function display_note( $note, $show_delete = false ) { |
427 | 427 | |
428 | - if( ! is_object( $note ) ) { |
|
428 | + if ( ! is_object( $note ) ) { |
|
429 | 429 | return ''; |
430 | 430 | } |
431 | 431 | |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | $note_row = ob_get_clean(); |
467 | 467 | |
468 | 468 | $replacements = array( |
469 | - '{note_id}' => $note_content['note_id'], |
|
469 | + '{note_id}' => $note_content[ 'note_id' ], |
|
470 | 470 | '{row_class}' => 'gv-note', |
471 | 471 | '{note_detail}' => $note_detail_html |
472 | 472 | ); |
@@ -498,13 +498,13 @@ discard block |
||
498 | 498 | |
499 | 499 | $user_data = get_userdata( $current_user->ID ); |
500 | 500 | |
501 | - $note_content = trim( $data['gv-note-content'] ); |
|
501 | + $note_content = trim( $data[ 'gv-note-content' ] ); |
|
502 | 502 | |
503 | - if( empty( $note_content ) ) { |
|
503 | + if ( empty( $note_content ) ) { |
|
504 | 504 | return new WP_Error( 'gv-add-note-empty', __( 'The note is empty.', 'gravityview' ) ); |
505 | 505 | } |
506 | 506 | |
507 | - $return = GravityView_Entry_Notes::add_note( $entry['id'], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
507 | + $return = GravityView_Entry_Notes::add_note( $entry[ 'id' ], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
508 | 508 | |
509 | 509 | return $return; |
510 | 510 | } |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | */ |
521 | 521 | public static function get_add_note_part() { |
522 | 522 | |
523 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
523 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
524 | 524 | do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to add entry notes ("gravityview_add_entry_notes").' ); |
525 | 525 | return ''; |
526 | 526 | } |
@@ -533,19 +533,19 @@ discard block |
||
533 | 533 | |
534 | 534 | $visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' ); |
535 | 535 | $entry = $gravityview_view->getCurrentEntry(); |
536 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
536 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
537 | 537 | $nonce_field = wp_nonce_field( 'gv_note_add_' . $entry_slug, 'gv_note_add', false, false ); |
538 | 538 | |
539 | 539 | // Only generate the dropdown if the field settings allow it |
540 | 540 | $email_fields = ''; |
541 | - if( ! empty( $visibility_settings['email'] ) ) { |
|
541 | + if ( ! empty( $visibility_settings[ 'email' ] ) ) { |
|
542 | 542 | $email_fields = self::get_note_email_fields( $entry_slug ); |
543 | 543 | } |
544 | 544 | |
545 | 545 | $add_note_html = str_replace( '{entry_slug}', $entry_slug, $add_note_html ); |
546 | 546 | $add_note_html = str_replace( '{nonce_field}', $nonce_field, $add_note_html ); |
547 | - $add_note_html = str_replace( '{show_delete}', intval( $visibility_settings['delete'] ), $add_note_html ); |
|
548 | - $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
547 | + $add_note_html = str_replace( '{show_delete}', intval( $visibility_settings[ 'delete' ] ), $add_note_html ); |
|
548 | + $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
549 | 549 | |
550 | 550 | return $add_note_html; |
551 | 551 | } |
@@ -569,8 +569,8 @@ discard block |
||
569 | 569 | $note_emails = array(); |
570 | 570 | |
571 | 571 | foreach ( $email_fields as $email_field ) { |
572 | - if ( ! empty( $entry["{$email_field->id}"] ) && is_email( $entry["{$email_field->id}"] ) ) { |
|
573 | - $note_emails[] = $entry["{$email_field->id}"]; |
|
572 | + if ( ! empty( $entry[ "{$email_field->id}" ] ) && is_email( $entry[ "{$email_field->id}" ] ) ) { |
|
573 | + $note_emails[ ] = $entry[ "{$email_field->id}" ]; |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | */ |
583 | 583 | $note_emails = apply_filters( 'gravityview/field/notes/emails', $note_emails, $entry ); |
584 | 584 | |
585 | - return (array) $note_emails; |
|
585 | + return (array)$note_emails; |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | */ |
599 | 599 | private static function get_note_email_fields( $entry_slug = '' ) { |
600 | 600 | |
601 | - if( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
601 | + if ( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
602 | 602 | do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to email entry notes ("gravityview_email_entry_notes").' ); |
603 | 603 | return ''; |
604 | 604 | } |
@@ -620,27 +620,27 @@ discard block |
||
620 | 620 | |
621 | 621 | if ( ! empty( $note_emails ) || $include_custom ) { ?> |
622 | 622 | <div class="gv-note-email-container"> |
623 | - <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings['also-email']; ?></label> |
|
623 | + <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings[ 'also-email' ]; ?></label> |
|
624 | 624 | <select class="gv-note-email-to" name="gv-note-to" id="gv-note-email-to-<?php echo $entry_slug_esc; ?>"> |
625 | - <option value=""><?php echo $strings['also-email']; ?></option> |
|
625 | + <option value=""><?php echo $strings[ 'also-email' ]; ?></option> |
|
626 | 626 | <?php foreach ( $note_emails as $email ) { |
627 | 627 | ?> |
628 | 628 | <option value="<?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></option> |
629 | 629 | <?php } |
630 | - if( $include_custom ) { ?> |
|
631 | - <option value="custom"><?php echo self::strings('other-email'); ?></option> |
|
630 | + if ( $include_custom ) { ?> |
|
631 | + <option value="custom"><?php echo self::strings( 'other-email' ); ?></option> |
|
632 | 632 | <?php } ?> |
633 | 633 | </select> |
634 | 634 | <fieldset class="gv-note-to-container"> |
635 | - <?php if( $include_custom ) { ?> |
|
635 | + <?php if ( $include_custom ) { ?> |
|
636 | 636 | <div class='gv-note-to-custom-container'> |
637 | - <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings['email-label']; ?></label> |
|
638 | - <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings['email-placeholder']; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
637 | + <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'email-label' ]; ?></label> |
|
638 | + <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings[ 'email-placeholder' ]; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
639 | 639 | </div> |
640 | 640 | <?php } ?> |
641 | 641 | <div class='gv-note-subject-container'> |
642 | - <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings['subject-label']; ?></label> |
|
643 | - <input type="text" name="gv-note-subject" placeholder="<?php echo $strings['subject']; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
642 | + <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'subject-label' ]; ?></label> |
|
643 | + <input type="text" name="gv-note-subject" placeholder="<?php echo $strings[ 'subject' ]; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
644 | 644 | </div> |
645 | 645 | </fieldset> |
646 | 646 | </div> |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | */ |
664 | 664 | private function maybe_send_entry_notes( $note = false, $entry, $data ) { |
665 | 665 | |
666 | - if( ! $note || ! GVCommon::has_cap('gravityview_email_entry_notes') ) { |
|
666 | + if ( ! $note || ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
667 | 667 | do_action( 'gravityview_log_debug', __METHOD__ . ': User doesnt have "gravityview_email_entry_notes" cap, or $note is empty', $note ); |
668 | 668 | return; |
669 | 669 | } |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | do_action( 'gravityview_log_debug', __METHOD__ . ': $data', $data ); |
672 | 672 | |
673 | 673 | //emailing notes if configured |
674 | - if ( ! empty( $data['gv-note-to'] ) ) { |
|
674 | + if ( ! empty( $data[ 'gv-note-to' ] ) ) { |
|
675 | 675 | |
676 | 676 | $default_data = array( |
677 | 677 | 'gv-note-to' => '', |
@@ -680,11 +680,11 @@ discard block |
||
680 | 680 | 'gv-note-content' => '', |
681 | 681 | ); |
682 | 682 | |
683 | - $current_user = wp_get_current_user(); |
|
683 | + $current_user = wp_get_current_user(); |
|
684 | 684 | $email_data = wp_parse_args( $data, $default_data ); |
685 | 685 | |
686 | - $from = $current_user->user_email; |
|
687 | - $to = $email_data['gv-note-to']; |
|
686 | + $from = $current_user->user_email; |
|
687 | + $to = $email_data[ 'gv-note-to' ]; |
|
688 | 688 | |
689 | 689 | /** |
690 | 690 | * Documented in get_note_email_fields |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | */ |
693 | 693 | $include_custom = apply_filters( 'gravityview/field/notes/custom-email', true ); |
694 | 694 | |
695 | - if( 'custom' === $to && $include_custom ) { |
|
696 | - $to = $email_data['gv-note-to-custom']; |
|
695 | + if ( 'custom' === $to && $include_custom ) { |
|
696 | + $to = $email_data[ 'gv-note-to-custom' ]; |
|
697 | 697 | do_action( 'gravityview_log_debug', __METHOD__ . ': Sending note to a custom email address: ' . $to ); |
698 | 698 | } |
699 | 699 | |
@@ -704,12 +704,12 @@ discard block |
||
704 | 704 | |
705 | 705 | $bcc = false; |
706 | 706 | $reply_to = $from; |
707 | - $subject = trim( $email_data['gv-note-subject'] ); |
|
707 | + $subject = trim( $email_data[ 'gv-note-subject' ] ); |
|
708 | 708 | |
709 | 709 | // We use empty() here because GF uses empty to check against, too. `0` isn't a valid subject to GF |
710 | 710 | $subject = empty( $subject ) ? self::strings( 'default-email-subject' ) : $subject; |
711 | - $message = $email_data['gv-note-content']; |
|
712 | - $from_name = $current_user->display_name; |
|
711 | + $message = $email_data[ 'gv-note-content' ]; |
|
712 | + $from_name = $current_user->display_name; |
|
713 | 713 | $message_format = 'html'; |
714 | 714 | |
715 | 715 | /** |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | |
725 | 725 | GVCommon::send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, '', $entry, false ); |
726 | 726 | |
727 | - $form = isset( $entry['form_id'] ) ? GFAPI::get_form( $entry['form_id'] ) : array(); |
|
727 | + $form = isset( $entry[ 'form_id' ] ) ? GFAPI::get_form( $entry[ 'form_id' ] ) : array(); |
|
728 | 728 | |
729 | 729 | /** |
730 | 730 | * @see https://www.gravityhelp.com/documentation/article/10146-2/ It's here for compatibility with Gravity Forms |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function get_instance() { |
87 | 87 | |
88 | - if( empty( self::$instance ) ) { |
|
88 | + if ( empty( self::$instance ) ) { |
|
89 | 89 | self::$instance = new self; |
90 | 90 | } |
91 | 91 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | |
119 | 119 | $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
120 | 120 | |
121 | - if( $with_values ) { |
|
121 | + if ( $with_values ) { |
|
122 | 122 | $operators_with_values = array(); |
123 | - foreach( $operators as $key ) { |
|
123 | + foreach ( $operators as $key ) { |
|
124 | 124 | $operators_with_values[ $key ] = ''; |
125 | 125 | } |
126 | 126 | return $operators_with_values; |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | */ |
138 | 138 | function set_operation( $operation = '' ) { |
139 | 139 | |
140 | - if( empty( $operation ) ) { |
|
140 | + if ( empty( $operation ) ) { |
|
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | 144 | $operators = $this->get_operators( false ); |
145 | 145 | |
146 | - if( !in_array( $operation, $operators ) ) { |
|
147 | - do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation ); |
|
146 | + if ( ! in_array( $operation, $operators ) ) { |
|
147 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Attempted to add invalid operation type.', $operation ); |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | */ |
165 | 165 | private function setup_operation_and_comparison() { |
166 | 166 | |
167 | - foreach( $this->atts as $key => $value ) { |
|
167 | + foreach ( $this->atts as $key => $value ) { |
|
168 | 168 | |
169 | 169 | $valid = $this->set_operation( $key ); |
170 | 170 | |
171 | - if( $valid ) { |
|
171 | + if ( $valid ) { |
|
172 | 172 | $this->comparison = $value; |
173 | 173 | return true; |
174 | 174 | } |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | return null; |
192 | 192 | } |
193 | 193 | |
194 | - if( empty( $atts ) ) { |
|
195 | - do_action( 'gravityview_log_error', __METHOD__.' $atts are empty.', $atts ); |
|
194 | + if ( empty( $atts ) ) { |
|
195 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts are empty.', $atts ); |
|
196 | 196 | return null; |
197 | 197 | } |
198 | 198 | |
@@ -203,16 +203,16 @@ discard block |
||
203 | 203 | $this->parse_atts(); |
204 | 204 | |
205 | 205 | // We need an "if" |
206 | - if( false === $this->if ) { |
|
207 | - do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->passed_atts ); |
|
206 | + if ( false === $this->if ) { |
|
207 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts->if is empty.', $this->passed_atts ); |
|
208 | 208 | return null; |
209 | 209 | } |
210 | 210 | |
211 | 211 | $setup = $this->setup_operation_and_comparison(); |
212 | 212 | |
213 | 213 | // We need an operation and comparison value |
214 | - if( ! $setup ) { |
|
215 | - do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts ); |
|
214 | + if ( ! $setup ) { |
|
215 | + do_action( 'gravityview_log_error', __METHOD__ . ' No valid operators were passed.', $this->atts ); |
|
216 | 216 | return null; |
217 | 217 | } |
218 | 218 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | private function get_output() { |
247 | 247 | |
248 | - if( $this->is_match ) { |
|
248 | + if ( $this->is_match ) { |
|
249 | 249 | $output = $this->content; |
250 | 250 | } else { |
251 | 251 | $output = $this->else_content; |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | * @param string $output HTML/text output |
260 | 260 | * @param GVLogic_Shortcode $this This class |
261 | 261 | */ |
262 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
262 | + $output = apply_filters( 'gravityview/gvlogic/output', $output, $this ); |
|
263 | 263 | |
264 | - do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output ); |
|
264 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Output: ', $output ); |
|
265 | 265 | |
266 | 266 | return $output; |
267 | 267 | } |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | |
278 | 278 | $content = explode( '[else]', $this->passed_content ); |
279 | 279 | |
280 | - $this->content = $content[0]; |
|
280 | + $this->content = $content[ 0 ]; |
|
281 | 281 | |
282 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
282 | + $else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL; |
|
283 | 283 | |
284 | - $this->else_content = isset( $content[1] ) ? $content[1] : $else_attr; |
|
284 | + $this->else_content = isset( $content[ 1 ] ) ? $content[ 1 ] : $else_attr; |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | $this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts; |
305 | 305 | |
306 | 306 | // Strip whitespace if it's not default false |
307 | - $this->if = is_string( $this->atts['if'] ) ? trim( $this->atts['if'] ) : false; |
|
307 | + $this->if = is_string( $this->atts[ 'if' ] ) ? trim( $this->atts[ 'if' ] ) : false; |
|
308 | 308 | |
309 | 309 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
310 | - unset( $this->atts['if'] ); |
|
310 | + unset( $this->atts[ 'if' ] ); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | |
43 | 43 | add_action( 'wp', array( $this, 'process_delete' ), 10000 ); |
44 | 44 | |
45 | - add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field'), 10, 3 ); |
|
45 | + add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); |
|
46 | 46 | |
47 | 47 | add_action( 'gravityview_before', array( $this, 'display_message' ) ); |
48 | 48 | |
49 | 49 | // For the Delete Entry Link, you don't want visible to all users. |
50 | - add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps'), 10, 5 ); |
|
50 | + add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 ); |
|
51 | 51 | |
52 | 52 | // Modify the field options based on the name of the field type |
53 | 53 | add_filter( 'gravityview_template_delete_link_options', array( $this, 'delete_link_field_options' ), 10, 5 ); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | // add template path to check for field |
56 | 56 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
57 | 57 | |
58 | - add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button'), 10, 3 ); |
|
58 | + add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button' ), 10, 3 ); |
|
59 | 59 | |
60 | - add_action ( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
61 | - add_action ( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
60 | + add_action( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
61 | + add_action( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | static function getInstance() { |
71 | 71 | |
72 | - if( empty( self::$instance ) ) { |
|
72 | + if ( empty( self::$instance ) ) { |
|
73 | 73 | self::$instance = new self; |
74 | 74 | } |
75 | 75 | |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | function delete_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
106 | 106 | |
107 | 107 | // Always a link, never a filter |
108 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
108 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
109 | 109 | |
110 | 110 | // Delete Entry link should only appear to visitors capable of editing entries |
111 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
111 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
112 | 112 | |
113 | - $add_option['delete_link'] = array( |
|
113 | + $add_option[ 'delete_link' ] = array( |
|
114 | 114 | 'type' => 'text', |
115 | 115 | 'label' => __( 'Delete Link Text', 'gravityview' ), |
116 | 116 | 'desc' => NULL, |
117 | - 'value' => __('Delete Entry', 'gravityview'), |
|
117 | + 'value' => __( 'Delete Entry', 'gravityview' ), |
|
118 | 118 | 'merge_tags' => true, |
119 | 119 | ); |
120 | 120 | |
121 | - $field_options['allow_edit_cap'] = array( |
|
121 | + $field_options[ 'allow_edit_cap' ] = array( |
|
122 | 122 | 'type' => 'select', |
123 | 123 | 'label' => __( 'Allow the following users to delete the entry:', 'gravityview' ), |
124 | 124 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | */ |
143 | 143 | function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
144 | 144 | |
145 | - $entry_default_fields['delete_link'] = array( |
|
146 | - 'label' => __('Delete Entry', 'gravityview'), |
|
145 | + $entry_default_fields[ 'delete_link' ] = array( |
|
146 | + 'label' => __( 'Delete Entry', 'gravityview' ), |
|
147 | 147 | 'type' => 'delete_link', |
148 | - 'desc' => __('A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview'), |
|
148 | + 'desc' => __( 'A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview' ), |
|
149 | 149 | ); |
150 | 150 | |
151 | 151 | return $entry_default_fields; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | function add_available_field( $available_fields = array() ) { |
160 | 160 | |
161 | - $available_fields['delete_link'] = array( |
|
161 | + $available_fields[ 'delete_link' ] = array( |
|
162 | 162 | 'label_text' => __( 'Delete Entry', 'gravityview' ), |
163 | 163 | 'field_id' => 'delete_link', |
164 | 164 | 'label_type' => 'field', |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | $caps = $visibility_caps; |
187 | 187 | |
188 | 188 | // If we're configuring fields in the edit context, we want a limited selection |
189 | - if( $field_id === 'delete_link' ) { |
|
189 | + if ( $field_id === 'delete_link' ) { |
|
190 | 190 | |
191 | 191 | // Remove other built-in caps. |
192 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
192 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] ); |
|
193 | 193 | |
194 | - $caps['read'] = _x('Entry Creator', 'User capability', 'gravityview'); |
|
194 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return $caps; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @param [type] $entry [description] |
205 | 205 | */ |
206 | 206 | function set_entry( $entry = null ) { |
207 | - $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry; |
|
207 | + $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[ 0 ] : $entry; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | |
235 | 235 | $base = GravityView_API::directory_link( $post_id, true ); |
236 | 236 | |
237 | - if( empty( $base ) ) { |
|
238 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id ); |
|
237 | + if ( empty( $base ) ) { |
|
238 | + do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: ' . $post_id ); |
|
239 | 239 | return NULL; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // Use the slug instead of the ID for consistent security |
243 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
243 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
244 | 244 | |
245 | 245 | $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id; |
246 | 246 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | 'view_id' => $view_id, |
252 | 252 | ), $base ); |
253 | 253 | |
254 | - $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' ); |
|
254 | + $url = wp_nonce_url( $actionurl, 'delete_' . $entry_slug, 'delete' ); |
|
255 | 255 | |
256 | 256 | return $url; |
257 | 257 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | function add_delete_button( $form = array(), $entry = array(), $view_id = NULL ) { |
269 | 269 | |
270 | 270 | // Only show the link to those who are allowed to see it. |
271 | - if( !self::check_user_cap_delete_entry( $entry ) ) { |
|
271 | + if ( ! self::check_user_cap_delete_entry( $entry ) ) { |
|
272 | 272 | return; |
273 | 273 | } |
274 | 274 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $show_delete_button = apply_filters( 'gravityview/delete-entry/show-delete-button', true ); |
280 | 280 | |
281 | 281 | // If the button is hidden by the filter, don't show. |
282 | - if( !$show_delete_button ) { |
|
282 | + if ( ! $show_delete_button ) { |
|
283 | 283 | return; |
284 | 284 | } |
285 | 285 | |
@@ -309,27 +309,27 @@ discard block |
||
309 | 309 | function process_delete() { |
310 | 310 | |
311 | 311 | // If the form is submitted |
312 | - if( isset( $_GET['action'] ) && 'delete' === $_GET['action'] && isset( $_GET['entry_id'] ) ) { |
|
312 | + if ( isset( $_GET[ 'action' ] ) && 'delete' === $_GET[ 'action' ] && isset( $_GET[ 'entry_id' ] ) ) { |
|
313 | 313 | |
314 | 314 | // Make sure it's a GravityView request |
315 | - $valid_nonce_key = wp_verify_nonce( $_GET['delete'], self::get_nonce_key( $_GET['entry_id'] ) ); |
|
315 | + $valid_nonce_key = wp_verify_nonce( $_GET[ 'delete' ], self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
316 | 316 | |
317 | - if( ! $valid_nonce_key ) { |
|
318 | - do_action('gravityview_log_debug', __METHOD__ . ' Delete entry not processed: nonce validation failed.' ); |
|
317 | + if ( ! $valid_nonce_key ) { |
|
318 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Delete entry not processed: nonce validation failed.' ); |
|
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Get the entry slug |
323 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
323 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
324 | 324 | |
325 | 325 | // See if there's an entry there |
326 | 326 | $entry = gravityview_get_entry( $entry_slug ); |
327 | 327 | |
328 | - if( $entry ) { |
|
328 | + if ( $entry ) { |
|
329 | 329 | |
330 | 330 | $has_permission = $this->user_can_delete_entry( $entry ); |
331 | 331 | |
332 | - if( is_wp_error( $has_permission ) ) { |
|
332 | + if ( is_wp_error( $has_permission ) ) { |
|
333 | 333 | |
334 | 334 | $messages = array( |
335 | 335 | 'message' => urlencode( $has_permission->get_error_message() ), |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | // Delete the entry |
342 | 342 | $delete_response = $this->delete_or_trash_entry( $entry ); |
343 | 343 | |
344 | - if( is_wp_error( $delete_response ) ) { |
|
344 | + if ( is_wp_error( $delete_response ) ) { |
|
345 | 345 | |
346 | 346 | $messages = array( |
347 | 347 | 'message' => urlencode( $delete_response->get_error_message() ), |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | |
361 | 361 | } else { |
362 | 362 | |
363 | - do_action('gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug '. $entry_slug ); |
|
363 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug ' . $entry_slug ); |
|
364 | 364 | |
365 | 365 | $messages = array( |
366 | - 'message' => urlencode( __('The entry does not exist.', 'gravityview') ), |
|
366 | + 'message' => urlencode( __( 'The entry does not exist.', 'gravityview' ) ), |
|
367 | 367 | 'status' => 'error', |
368 | 368 | ); |
369 | 369 | } |
@@ -403,18 +403,18 @@ discard block |
||
403 | 403 | */ |
404 | 404 | private function delete_or_trash_entry( $entry ) { |
405 | 405 | |
406 | - $entry_id = $entry['id']; |
|
406 | + $entry_id = $entry[ 'id' ]; |
|
407 | 407 | |
408 | 408 | $mode = $this->get_delete_mode(); |
409 | 409 | |
410 | - if( 'delete' === $mode ) { |
|
410 | + if ( 'delete' === $mode ) { |
|
411 | 411 | |
412 | 412 | do_action( 'gravityview_log_debug', __METHOD__ . ' Starting delete entry: ', $entry_id ); |
413 | 413 | |
414 | 414 | // Delete the entry |
415 | 415 | $delete_response = GFAPI::delete_entry( $entry_id ); |
416 | 416 | |
417 | - if( ! is_wp_error( $delete_response ) ) { |
|
417 | + if ( ! is_wp_error( $delete_response ) ) { |
|
418 | 418 | $delete_response = 'deleted'; |
419 | 419 | |
420 | 420 | /** |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | $trashed = GFAPI::update_entry_property( $entry_id, 'status', 'trash' ); |
436 | 436 | new GravityView_Cache; |
437 | 437 | |
438 | - if( ! $trashed ) { |
|
439 | - $delete_response = new WP_Error( 'trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview' ) ); |
|
438 | + if ( ! $trashed ) { |
|
439 | + $delete_response = new WP_Error( 'trash_entry_failed', __( 'Moving the entry to the trash failed.', 'gravityview' ) ); |
|
440 | 440 | } else { |
441 | 441 | |
442 | 442 | /** |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | public function process_connected_posts( $entry_id = 0, $entry = array() ) { |
468 | 468 | |
469 | 469 | // The entry had no connected post |
470 | - if( empty( $entry['post_id'] ) ) { |
|
470 | + if ( empty( $entry[ 'post_id' ] ) ) { |
|
471 | 471 | return; |
472 | 472 | } |
473 | 473 | |
@@ -478,22 +478,22 @@ discard block |
||
478 | 478 | */ |
479 | 479 | $delete_post = apply_filters( 'gravityview/delete-entry/delete-connected-post', true ); |
480 | 480 | |
481 | - if( false === $delete_post ) { |
|
481 | + if ( false === $delete_post ) { |
|
482 | 482 | return; |
483 | 483 | } |
484 | 484 | |
485 | 485 | $action = current_action(); |
486 | 486 | |
487 | - if( 'gravityview/delete-entry/deleted' === $action ) { |
|
488 | - $result = wp_delete_post( $entry['post_id'], true ); |
|
487 | + if ( 'gravityview/delete-entry/deleted' === $action ) { |
|
488 | + $result = wp_delete_post( $entry[ 'post_id' ], true ); |
|
489 | 489 | } else { |
490 | - $result = wp_trash_post( $entry['post_id'] ); |
|
490 | + $result = wp_trash_post( $entry[ 'post_id' ] ); |
|
491 | 491 | } |
492 | 492 | |
493 | - if( false === $result ) { |
|
494 | - do_action( 'gravityview_log_error', __METHOD__ . ' (called by '.$action.'): Error processing the Post connected to the entry.', $entry ); |
|
493 | + if ( false === $result ) { |
|
494 | + do_action( 'gravityview_log_error', __METHOD__ . ' (called by ' . $action . '): Error processing the Post connected to the entry.', $entry ); |
|
495 | 495 | } else { |
496 | - do_action( 'gravityview_log_debug', __METHOD__ . ' (called by '.$action.'): Successfully processed Post connected to the entry.', $entry ); |
|
496 | + do_action( 'gravityview_log_debug', __METHOD__ . ' (called by ' . $action . '): Successfully processed Post connected to the entry.', $entry ); |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
@@ -506,13 +506,13 @@ discard block |
||
506 | 506 | public function verify_nonce() { |
507 | 507 | |
508 | 508 | // No delete entry request was made |
509 | - if( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) { |
|
509 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'delete' ] ) ) { |
|
510 | 510 | return false; |
511 | 511 | } |
512 | 512 | |
513 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
513 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
514 | 514 | |
515 | - $valid = wp_verify_nonce( $_GET['delete'], $nonce_key ); |
|
515 | + $valid = wp_verify_nonce( $_GET[ 'delete' ], $nonce_key ); |
|
516 | 516 | |
517 | 517 | /** |
518 | 518 | * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid. |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | */ |
535 | 535 | public static function get_confirm_dialog() { |
536 | 536 | |
537 | - $confirm = __('Are you sure you want to delete this entry? This cannot be undone.', 'gravityview'); |
|
537 | + $confirm = __( 'Are you sure you want to delete this entry? This cannot be undone.', 'gravityview' ); |
|
538 | 538 | |
539 | 539 | /** |
540 | 540 | * @filter `gravityview/delete-entry/confirm-text` Modify the Delete Entry Javascript confirmation text |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | */ |
543 | 543 | $confirm = apply_filters( 'gravityview/delete-entry/confirm-text', $confirm ); |
544 | 544 | |
545 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
545 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -560,16 +560,16 @@ discard block |
||
560 | 560 | |
561 | 561 | $error = NULL; |
562 | 562 | |
563 | - if( ! $this->verify_nonce() ) { |
|
564 | - $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview'); |
|
563 | + if ( ! $this->verify_nonce() ) { |
|
564 | + $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview' ); |
|
565 | 565 | } |
566 | 566 | |
567 | - if( ! self::check_user_cap_delete_entry( $entry ) ) { |
|
568 | - $error = __( 'You do not have permission to delete this entry.', 'gravityview'); |
|
567 | + if ( ! self::check_user_cap_delete_entry( $entry ) ) { |
|
568 | + $error = __( 'You do not have permission to delete this entry.', 'gravityview' ); |
|
569 | 569 | } |
570 | 570 | |
571 | - if( $entry['status'] === 'trash' ) { |
|
572 | - if( 'trash' === $this->get_delete_mode() ) { |
|
571 | + if ( $entry[ 'status' ] === 'trash' ) { |
|
572 | + if ( 'trash' === $this->get_delete_mode() ) { |
|
573 | 573 | $error = __( 'The entry is already in the trash.', 'gravityview' ); |
574 | 574 | } else { |
575 | 575 | $error = __( 'You cannot delete the entry; it is already in the trash.', 'gravityview' ); |
@@ -577,11 +577,11 @@ discard block |
||
577 | 577 | } |
578 | 578 | |
579 | 579 | // No errors; everything's fine here! |
580 | - if( empty( $error ) ) { |
|
580 | + if ( empty( $error ) ) { |
|
581 | 581 | return true; |
582 | 582 | } |
583 | 583 | |
584 | - do_action('gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error ); |
|
584 | + do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error ); |
|
585 | 585 | |
586 | 586 | return new WP_Error( 'gravityview-delete-entry-permissions', $error ); |
587 | 587 | } |
@@ -603,32 +603,32 @@ discard block |
||
603 | 603 | |
604 | 604 | $current_user = wp_get_current_user(); |
605 | 605 | |
606 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL; |
|
606 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL; |
|
607 | 607 | |
608 | 608 | // Or if they can delete any entries (as defined in Gravity Forms), we're good. |
609 | - if( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { |
|
609 | + if ( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { |
|
610 | 610 | |
611 | - do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' ); |
|
611 | + do_action( 'gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' ); |
|
612 | 612 | |
613 | 613 | return true; |
614 | 614 | } |
615 | 615 | |
616 | 616 | |
617 | 617 | // If field options are passed, check if current user can view the link |
618 | - if( !empty( $field ) ) { |
|
618 | + if ( ! empty( $field ) ) { |
|
619 | 619 | |
620 | 620 | // If capability is not defined, something is not right! |
621 | - if( empty( $field['allow_edit_cap'] ) ) { |
|
621 | + if ( empty( $field[ 'allow_edit_cap' ] ) ) { |
|
622 | 622 | |
623 | 623 | do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Cannot read delete entry field caps', $field ); |
624 | 624 | |
625 | 625 | return false; |
626 | 626 | } |
627 | 627 | |
628 | - if( GVCommon::has_cap( $field['allow_edit_cap'] ) ) { |
|
628 | + if ( GVCommon::has_cap( $field[ 'allow_edit_cap' ] ) ) { |
|
629 | 629 | |
630 | 630 | // Do not return true if cap is read, as we need to check if the current user created the entry |
631 | - if( $field['allow_edit_cap'] !== 'read' ) { |
|
631 | + if ( $field[ 'allow_edit_cap' ] !== 'read' ) { |
|
632 | 632 | return true; |
633 | 633 | } |
634 | 634 | |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | |
642 | 642 | } |
643 | 643 | |
644 | - if( !isset( $entry['created_by'] ) ) { |
|
644 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
645 | 645 | |
646 | - do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.'); |
|
646 | + do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.' ); |
|
647 | 647 | |
648 | 648 | return false; |
649 | 649 | } |
@@ -651,24 +651,24 @@ discard block |
||
651 | 651 | $view_id = empty( $view_id ) ? $gravityview_view->getViewId() : $view_id; |
652 | 652 | |
653 | 653 | // Only checks user_delete view option if view is already set |
654 | - if( $view_id ) { |
|
654 | + if ( $view_id ) { |
|
655 | 655 | |
656 | 656 | $current_view = gravityview_get_current_view_data( $view_id ); |
657 | 657 | |
658 | - $user_delete = isset( $current_view['atts']['user_delete'] ) ? $current_view['atts']['user_delete'] : false; |
|
658 | + $user_delete = isset( $current_view[ 'atts' ][ 'user_delete' ] ) ? $current_view[ 'atts' ][ 'user_delete' ] : false; |
|
659 | 659 | |
660 | - if( empty( $user_delete ) ) { |
|
660 | + if ( empty( $user_delete ) ) { |
|
661 | 661 | |
662 | - do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' ); |
|
662 | + do_action( 'gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' ); |
|
663 | 663 | |
664 | 664 | return false; |
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
668 | 668 | // If the logged-in user is the same as the user who created the entry, we're good. |
669 | - if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
669 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
670 | 670 | |
671 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) ); |
|
671 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) ); |
|
672 | 672 | |
673 | 673 | return true; |
674 | 674 | } |
@@ -691,31 +691,31 @@ discard block |
||
691 | 691 | */ |
692 | 692 | public function display_message( $current_view_id = 0 ) { |
693 | 693 | |
694 | - if( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
694 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
695 | 695 | return; |
696 | 696 | } |
697 | 697 | |
698 | 698 | // Entry wasn't deleted from current View |
699 | - if( intval( $_GET['gvid'] ) !== intval( $current_view_id ) ) { |
|
699 | + if ( intval( $_GET[ 'gvid' ] ) !== intval( $current_view_id ) ) { |
|
700 | 700 | return; |
701 | 701 | } |
702 | 702 | |
703 | - $status = esc_attr( $_GET['status'] ); |
|
704 | - $message_from_url = rgget('message'); |
|
703 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
704 | + $message_from_url = rgget( 'message' ); |
|
705 | 705 | $message_from_url = urldecode( stripslashes_deep( $message_from_url ) ); |
706 | 706 | $class = ''; |
707 | 707 | |
708 | 708 | switch ( $status ) { |
709 | 709 | case 'error': |
710 | 710 | $class = ' gv-error error'; |
711 | - $error_message = __('There was an error deleting the entry: %s', 'gravityview'); |
|
711 | + $error_message = __( 'There was an error deleting the entry: %s', 'gravityview' ); |
|
712 | 712 | $message = sprintf( $error_message, $message_from_url ); |
713 | 713 | break; |
714 | 714 | case 'trashed': |
715 | - $message = __('The entry was successfully moved to the trash.', 'gravityview'); |
|
715 | + $message = __( 'The entry was successfully moved to the trash.', 'gravityview' ); |
|
716 | 716 | break; |
717 | 717 | default: |
718 | - $message = __('The entry was successfully deleted.', 'gravityview'); |
|
718 | + $message = __( 'The entry was successfully deleted.', 'gravityview' ); |
|
719 | 719 | break; |
720 | 720 | } |
721 | 721 | |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | $message = apply_filters( 'gravityview/delete-entry/message', esc_attr( $message ), $status, $message_from_url ); |
730 | 730 | |
731 | 731 | // DISPLAY ERROR/SUCCESS MESSAGE |
732 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
732 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
733 | 733 | } |
734 | 734 | |
735 | 735 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $signature_fields = GFAPI::get_fields_by_type( $form, 'signature' ); |
54 | 54 | |
55 | 55 | foreach ( $signature_fields as $field ) { |
56 | - unset( $_POST["input_{$field->id}"] ); |
|
56 | + unset( $_POST[ "input_{$field->id}" ] ); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -72,19 +72,19 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function edit_entry_field_input( $field_content = '', $field, $value = '', $lead_id = 0, $form_id = 0 ) { |
74 | 74 | |
75 | - $context = function_exists('gravityview_get_context') ? gravityview_get_context() : ''; |
|
75 | + $context = function_exists( 'gravityview_get_context' ) ? gravityview_get_context() : ''; |
|
76 | 76 | |
77 | - if( 'signature' !== $field->type || 'edit' !== $context ) { |
|
77 | + if ( 'signature' !== $field->type || 'edit' !== $context ) { |
|
78 | 78 | return $field_content; |
79 | 79 | } |
80 | 80 | |
81 | 81 | // We need to fetch a fresh version of the entry, since the saved entry hasn't refreshed in GV yet. |
82 | 82 | $entry = GravityView_View::getInstance()->getCurrentEntry(); |
83 | - $entry = GFAPI::get_entry( $entry['id'] ); |
|
83 | + $entry = GFAPI::get_entry( $entry[ 'id' ] ); |
|
84 | 84 | $entry_value = rgar( $entry, $field->id ); |
85 | 85 | |
86 | - $_POST["input_{$field->id}"] = $entry_value; // Used when Edit Entry form *is* submitted |
|
87 | - $_POST["input_{$form_id}_{$field->id}_signature_filename"] = $entry_value; // Used when Edit Entry form *is not* submitted |
|
86 | + $_POST[ "input_{$field->id}" ] = $entry_value; // Used when Edit Entry form *is* submitted |
|
87 | + $_POST[ "input_{$form_id}_{$field->id}_signature_filename" ] = $entry_value; // Used when Edit Entry form *is not* submitted |
|
88 | 88 | |
89 | 89 | return ''; // Return empty string to force using $_POST values instead |
90 | 90 | } |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | /** @var WP_Admin_Bar $wp_admin_bar */ |
38 | 38 | global $wp_admin_bar; |
39 | 39 | |
40 | - if( is_admin() ) { |
|
40 | + if ( is_admin() ) { |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
44 | 44 | $view_data = GravityView_View_Data::getInstance()->get_views(); |
45 | 45 | |
46 | - if( empty( $view_data ) ) { |
|
46 | + if ( empty( $view_data ) ) { |
|
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | 'parent' => 'gravityview', |
81 | 81 | 'title' => __( 'Edit Entry', 'gravityview' ), |
82 | 82 | 'meta' => array( |
83 | - 'title' => sprintf( __( 'Edit Entry %s', 'gravityview' ), GravityView_API::get_entry_slug( $entry['id'], $entry ) ), |
|
83 | + 'title' => sprintf( __( 'Edit Entry %s', 'gravityview' ), GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ) ), |
|
84 | 84 | ), |
85 | - 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry['form_id'], $entry['id'] ) ) ), |
|
85 | + 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry[ 'form_id' ], $entry[ 'id' ] ) ) ), |
|
86 | 86 | ) ); |
87 | 87 | |
88 | 88 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** @var WP_Admin_Bar $wp_admin_bar */ |
99 | 99 | global $wp_admin_bar; |
100 | 100 | |
101 | - if( GVCommon::has_cap( array( 'edit_gravityviews', 'edit_gravityview', 'gravityforms_edit_forms' ) ) ) { |
|
101 | + if ( GVCommon::has_cap( array( 'edit_gravityviews', 'edit_gravityview', 'gravityforms_edit_forms' ) ) ) { |
|
102 | 102 | |
103 | 103 | $view_data = GravityView_View_Data::getInstance(); |
104 | 104 | |
@@ -108,26 +108,26 @@ discard block |
||
108 | 108 | if ( ! empty( $views ) ) { |
109 | 109 | foreach ( $views as $view ) { |
110 | 110 | |
111 | - if( GVCommon::has_cap( 'edit_gravityview', $view['id'] ) ) { |
|
111 | + if ( GVCommon::has_cap( 'edit_gravityview', $view[ 'id' ] ) ) { |
|
112 | 112 | $wp_admin_bar->add_menu( array( |
113 | - 'id' => 'edit-view-' . $view['id'], |
|
113 | + 'id' => 'edit-view-' . $view[ 'id' ], |
|
114 | 114 | 'parent' => 'gravityview', |
115 | 115 | 'title' => __( 'Edit View', 'gravityview' ), |
116 | - 'href' => esc_url_raw( admin_url( sprintf( 'post.php?post=%d&action=edit', $view['id'] ) ) ), |
|
116 | + 'href' => esc_url_raw( admin_url( sprintf( 'post.php?post=%d&action=edit', $view[ 'id' ] ) ) ), |
|
117 | 117 | 'meta' => array( |
118 | - 'title' => sprintf( __( 'Edit View #%d', 'gravityview' ), $view['id'] ), |
|
118 | + 'title' => sprintf( __( 'Edit View #%d', 'gravityview' ), $view[ 'id' ] ), |
|
119 | 119 | ), |
120 | 120 | ) ); |
121 | 121 | } |
122 | 122 | |
123 | - if ( ! empty( $view['form_id'] ) && GVCommon::has_cap( array( 'gravityforms_edit_forms' ), $view['form_id'] ) ) { |
|
123 | + if ( ! empty( $view[ 'form_id' ] ) && GVCommon::has_cap( array( 'gravityforms_edit_forms' ), $view[ 'form_id' ] ) ) { |
|
124 | 124 | $wp_admin_bar->add_menu( array( |
125 | - 'id' => 'edit-form-' . $view['form_id'], |
|
125 | + 'id' => 'edit-form-' . $view[ 'form_id' ], |
|
126 | 126 | 'parent' => 'gravityview', |
127 | 127 | 'title' => __( 'Edit Form', 'gravityview' ), |
128 | - 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $view['form_id'] ) ) ), |
|
128 | + 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $view[ 'form_id' ] ) ) ), |
|
129 | 129 | 'meta' => array( |
130 | - 'title' => sprintf( __( 'Edit Form #%d', 'gravityview' ), $view['form_id'] ), |
|
130 | + 'title' => sprintf( __( 'Edit Form #%d', 'gravityview' ), $view[ 'form_id' ] ), |
|
131 | 131 | ), |
132 | 132 | ) ); |
133 | 133 |
@@ -50,7 +50,7 @@ |
||
50 | 50 | */ |
51 | 51 | public function if_gravityview_return_true( $has_content = false ) { |
52 | 52 | |
53 | - if( ! class_exists( 'GravityView_frontend' ) ) { |
|
53 | + if ( ! class_exists( 'GravityView_frontend' ) ) { |
|
54 | 54 | return $has_content; |
55 | 55 | } |
56 | 56 |
@@ -112,16 +112,16 @@ discard block |
||
112 | 112 | function load() { |
113 | 113 | |
114 | 114 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
115 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
115 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
116 | 116 | |
117 | 117 | // Don't display an embedded form when editing an entry |
118 | 118 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
119 | 119 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
120 | 120 | |
121 | 121 | // Stop Gravity Forms processing what is ours! |
122 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
122 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
123 | 123 | |
124 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
124 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
125 | 125 | |
126 | 126 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
127 | 127 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
133 | 133 | |
134 | 134 | // Add fields expected by GFFormDisplay::validate() |
135 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
135 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
136 | 136 | |
137 | 137 | } |
138 | 138 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @return void |
148 | 148 | */ |
149 | 149 | function prevent_render_form() { |
150 | - if( $this->is_edit_entry() ) { |
|
151 | - if( 'wp_head' === current_filter() ) { |
|
150 | + if ( $this->is_edit_entry() ) { |
|
151 | + if ( 'wp_head' === current_filter() ) { |
|
152 | 152 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
153 | 153 | } else { |
154 | 154 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | */ |
164 | 164 | function prevent_maybe_process_form() { |
165 | 165 | |
166 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
166 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
167 | 167 | |
168 | - if( $this->is_edit_entry_submission() && $this->verify_nonce() ) { |
|
169 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
168 | + if ( $this->is_edit_entry_submission() && $this->verify_nonce() ) { |
|
169 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function is_edit_entry() { |
178 | 178 | |
179 | - $gf_page = function_exists('rgpost') && ( 'entry' === rgget( 'view' ) && isset( $_GET['edit'] ) || rgpost( 'action' ) === 'update' ); |
|
179 | + $gf_page = function_exists( 'rgpost' ) && ( 'entry' === rgget( 'view' ) && isset( $_GET[ 'edit' ] ) || rgpost( 'action' ) === 'update' ); |
|
180 | 180 | |
181 | 181 | return $gf_page; |
182 | 182 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @return boolean |
188 | 188 | */ |
189 | 189 | public function is_edit_entry_submission() { |
190 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
190 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | |
199 | 199 | |
200 | 200 | $entries = $gravityview_view->getEntries(); |
201 | - $this->entry = $entries[0]; |
|
201 | + $this->entry = $entries[ 0 ]; |
|
202 | 202 | |
203 | 203 | $this->original_form = $this->form = $gravityview_view->getForm(); |
204 | 204 | $this->form_id = $gravityview_view->getFormId(); |
205 | 205 | $this->view_id = $gravityview_view->getViewId(); |
206 | 206 | |
207 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
207 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | $this->setup_vars(); |
225 | 225 | |
226 | 226 | // Multiple Views embedded, don't proceed if nonce fails |
227 | - if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
227 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
228 | 228 | return; |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Sorry, you're not allowed here. |
232 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
232 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
233 | 233 | return; |
234 | 234 | } |
235 | 235 | |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | function print_scripts() { |
250 | 250 | $gravityview_view = GravityView_View::getInstance(); |
251 | 251 | |
252 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
252 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
253 | 253 | |
254 | - GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false); |
|
254 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
255 | 255 | |
256 | 256 | // Sack is required for images |
257 | 257 | wp_print_scripts( array( 'sack', 'gform_gravityforms' ) ); |
@@ -263,32 +263,32 @@ discard block |
||
263 | 263 | */ |
264 | 264 | function process_save() { |
265 | 265 | |
266 | - if( empty( $_POST ) ) { |
|
266 | + if ( empty( $_POST ) ) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | 270 | // Make sure the entry, view, and form IDs are all correct |
271 | 271 | $valid = $this->verify_nonce(); |
272 | 272 | |
273 | - if( !$valid ) { |
|
274 | - do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
273 | + if ( ! $valid ) { |
|
274 | + do_action( 'gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
279 | - do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
278 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
279 | + do_action( 'gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
280 | 280 | return; |
281 | 281 | } |
282 | 282 | |
283 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
283 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
284 | 284 | |
285 | 285 | $this->process_save_process_files( $this->form_id ); |
286 | 286 | |
287 | 287 | $this->validate(); |
288 | 288 | |
289 | - if( $this->is_valid ) { |
|
289 | + if ( $this->is_valid ) { |
|
290 | 290 | |
291 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' ); |
|
291 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' ); |
|
292 | 292 | |
293 | 293 | /** |
294 | 294 | * @hack This step is needed to unset the adminOnly from form fields, to add the calculation fields |
@@ -298,12 +298,12 @@ discard block |
||
298 | 298 | /** |
299 | 299 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
300 | 300 | */ |
301 | - unset( $_GET['page'] ); |
|
301 | + unset( $_GET[ 'page' ] ); |
|
302 | 302 | |
303 | 303 | GFFormsModel::save_lead( $form, $this->entry ); |
304 | 304 | |
305 | 305 | // If there's a post associated with the entry, process post fields |
306 | - if( !empty( $this->entry['post_id'] ) ) { |
|
306 | + if ( ! empty( $this->entry[ 'post_id' ] ) ) { |
|
307 | 307 | $this->maybe_update_post_fields( $form ); |
308 | 308 | } |
309 | 309 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @param array $form Gravity Forms form array |
319 | 319 | * @param string $entry_id Numeric ID of the entry that was updated |
320 | 320 | */ |
321 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] ); |
|
321 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ] ); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | } // process_save |
@@ -352,11 +352,11 @@ discard block |
||
352 | 352 | * @return mixed |
353 | 353 | */ |
354 | 354 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
355 | - if( ! $this->is_edit_entry() ) { |
|
355 | + if ( ! $this->is_edit_entry() ) { |
|
356 | 356 | return $plupload_init; |
357 | 357 | } |
358 | 358 | |
359 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
359 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
360 | 360 | |
361 | 361 | return $plupload_init; |
362 | 362 | } |
@@ -370,19 +370,19 @@ discard block |
||
370 | 370 | |
371 | 371 | $form = $this->form; |
372 | 372 | |
373 | - foreach( $form['fields'] as $k => &$field ) { |
|
373 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
374 | 374 | |
375 | 375 | // Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
376 | 376 | // @since 1.16.3 |
377 | - if( $field->has_calculation() ) { |
|
378 | - unset( $form['fields'][ $k ] ); |
|
377 | + if ( $field->has_calculation() ) { |
|
378 | + unset( $form[ 'fields' ][ $k ] ); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | $field->adminOnly = false; |
382 | 382 | |
383 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
384 | - foreach( $field->inputs as $key => $input ) { |
|
385 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
383 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
384 | + foreach ( $field->inputs as $key => $input ) { |
|
385 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
386 | 386 | } |
387 | 387 | } |
388 | 388 | } |
@@ -396,20 +396,20 @@ discard block |
||
396 | 396 | $update = false; |
397 | 397 | |
398 | 398 | // get the most up to date entry values |
399 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
399 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
400 | 400 | |
401 | - if( !empty( $this->fields_with_calculation ) ) { |
|
401 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
402 | 402 | $update = true; |
403 | 403 | foreach ( $this->fields_with_calculation as $calc_field ) { |
404 | 404 | $inputs = $calc_field->get_entry_inputs(); |
405 | 405 | if ( is_array( $inputs ) ) { |
406 | 406 | foreach ( $inputs as $input ) { |
407 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
408 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
407 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
408 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
409 | 409 | } |
410 | 410 | } else { |
411 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
412 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
411 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
412 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -419,16 +419,16 @@ discard block |
||
419 | 419 | if ( ! empty( $this->total_fields ) ) { |
420 | 420 | $update = true; |
421 | 421 | foreach ( $this->total_fields as $total_field ) { |
422 | - $input_name = 'input_' . str_replace( '.', '_', $total_field->id); |
|
423 | - $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry['id'], $entry ); |
|
422 | + $input_name = 'input_' . str_replace( '.', '_', $total_field->id ); |
|
423 | + $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
427 | - if( $update ) { |
|
427 | + if ( $update ) { |
|
428 | 428 | |
429 | 429 | $return_entry = GFAPI::update_entry( $entry ); |
430 | 430 | |
431 | - if( is_wp_error( $return_entry ) ) { |
|
431 | + if ( is_wp_error( $return_entry ) ) { |
|
432 | 432 | do_action( 'gravityview_log_error', 'Updating the entry calculation and total fields failed', $return_entry ); |
433 | 433 | } else { |
434 | 434 | do_action( 'gravityview_log_debug', 'Updating the entry calculation and total fields succeeded' ); |
@@ -460,11 +460,11 @@ discard block |
||
460 | 460 | |
461 | 461 | $updated_categories = array(); |
462 | 462 | |
463 | - if( $append ) { |
|
463 | + if ( $append ) { |
|
464 | 464 | $updated_categories = wp_get_post_categories( $updated_post->ID ); |
465 | 465 | } |
466 | 466 | |
467 | - if( $post_category_fields ) { |
|
467 | + if ( $post_category_fields ) { |
|
468 | 468 | |
469 | 469 | foreach ( $post_category_fields as $field ) { |
470 | 470 | // Get the value of the field, including $_POSTed value |
@@ -501,18 +501,18 @@ discard block |
||
501 | 501 | |
502 | 502 | $input_name = 'input_' . $field_id; |
503 | 503 | |
504 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
504 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
505 | 505 | |
506 | 506 | // We have a new image |
507 | 507 | |
508 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
508 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
509 | 509 | |
510 | 510 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
511 | 511 | $img_url = rgar( $ary, 0 ); |
512 | 512 | |
513 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
514 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
515 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
513 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
514 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
515 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
516 | 516 | |
517 | 517 | $image_meta = array( |
518 | 518 | 'post_excerpt' => $img_caption, |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | |
522 | 522 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
523 | 523 | if ( ! empty( $img_title ) ) { |
524 | - $image_meta['post_title'] = $img_title; |
|
524 | + $image_meta[ 'post_title' ] = $img_title; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | set_post_thumbnail( $post_id, $media_id ); |
537 | 537 | } |
538 | 538 | |
539 | - } elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) { |
|
539 | + } elseif ( ! empty( $_POST[ $input_name ] ) && is_array( $value ) ) { |
|
540 | 540 | |
541 | 541 | // Same image although the image title, caption or description might have changed |
542 | 542 | |
@@ -544,11 +544,11 @@ discard block |
||
544 | 544 | $img_url = rgar( $ary, 0 ); |
545 | 545 | |
546 | 546 | // is this really the same image or something went wrong ? |
547 | - if( $img_url === $_POST[ $input_name ] ) { |
|
547 | + if ( $img_url === $_POST[ $input_name ] ) { |
|
548 | 548 | |
549 | - $img_title = rgar( $value, $field_id .'.1' ); |
|
550 | - $img_caption = rgar( $value, $field_id .'.4' ); |
|
551 | - $img_description = rgar( $value, $field_id .'.7' ); |
|
549 | + $img_title = rgar( $value, $field_id . '.1' ); |
|
550 | + $img_caption = rgar( $value, $field_id . '.4' ); |
|
551 | + $img_description = rgar( $value, $field_id . '.7' ); |
|
552 | 552 | |
553 | 553 | $value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : ''; |
554 | 554 | |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | */ |
589 | 589 | private function maybe_update_post_fields( $form ) { |
590 | 590 | |
591 | - $post_id = $this->entry['post_id']; |
|
591 | + $post_id = $this->entry[ 'post_id' ]; |
|
592 | 592 | |
593 | 593 | // Security check |
594 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
595 | - do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id ); |
|
594 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
595 | + do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id ); |
|
596 | 596 | return; |
597 | 597 | } |
598 | 598 | |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | $updated_post = $original_post = get_post( $post_id ); |
602 | 602 | |
603 | 603 | // get the most up to date entry values |
604 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
604 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
605 | 605 | |
606 | 606 | foreach ( $entry as $field_id => $value ) { |
607 | 607 | |
@@ -609,16 +609,16 @@ discard block |
||
609 | 609 | |
610 | 610 | $field = RGFormsModel::get_field( $form, $field_id ); |
611 | 611 | |
612 | - if( class_exists('GF_Fields') ) { |
|
612 | + if ( class_exists( 'GF_Fields' ) ) { |
|
613 | 613 | $field = GF_Fields::create( $field ); |
614 | 614 | } |
615 | 615 | |
616 | - if( GFCommon::is_post_field( $field ) ) { |
|
616 | + if ( GFCommon::is_post_field( $field ) ) { |
|
617 | 617 | |
618 | 618 | // Get the value of the field, including $_POSTed value |
619 | 619 | $value = RGFormsModel::get_field_value( $field ); |
620 | 620 | |
621 | - switch( $field->type ) { |
|
621 | + switch ( $field->type ) { |
|
622 | 622 | |
623 | 623 | case 'post_title': |
624 | 624 | case 'post_content': |
@@ -636,12 +636,12 @@ discard block |
||
636 | 636 | $custom_field_name = $field->postCustomFieldName; |
637 | 637 | |
638 | 638 | // Only certain custom field types are supported |
639 | - switch( $input_type ) { |
|
639 | + switch ( $input_type ) { |
|
640 | 640 | case 'fileupload': |
641 | 641 | /** @noinspection PhpMissingBreakStatementInspection */ |
642 | 642 | case 'list': |
643 | - if( ! is_string( $value ) ) { |
|
644 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
643 | + if ( ! is_string( $value ) ) { |
|
644 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value ); |
|
645 | 645 | } |
646 | 646 | // break; left intentionally out |
647 | 647 | default: |
@@ -657,12 +657,12 @@ discard block |
||
657 | 657 | } |
658 | 658 | |
659 | 659 | //ignore fields that have not changed |
660 | - if ( $value === rgget( (string) $field_id, $entry ) ) { |
|
660 | + if ( $value === rgget( (string)$field_id, $entry ) ) { |
|
661 | 661 | continue; |
662 | 662 | } |
663 | 663 | |
664 | 664 | // update entry |
665 | - if( 'post_category' !== $field->type ) { |
|
665 | + if ( 'post_category' !== $field->type ) { |
|
666 | 666 | $entry[ strval( $field_id ) ] = $value; |
667 | 667 | } |
668 | 668 | |
@@ -672,14 +672,14 @@ discard block |
||
672 | 672 | |
673 | 673 | } |
674 | 674 | |
675 | - if( $update_entry ) { |
|
675 | + if ( $update_entry ) { |
|
676 | 676 | |
677 | 677 | $return_entry = GFAPI::update_entry( $entry ); |
678 | 678 | |
679 | - if( is_wp_error( $return_entry ) ) { |
|
679 | + if ( is_wp_error( $return_entry ) ) { |
|
680 | 680 | do_action( 'gravityview_log_error', 'Updating the entry post fields failed', $return_entry ); |
681 | 681 | } else { |
682 | - do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' ); |
|
682 | + do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded' ); |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | } |
@@ -688,11 +688,11 @@ discard block |
||
688 | 688 | |
689 | 689 | $return_post = wp_update_post( $updated_post, true ); |
690 | 690 | |
691 | - if( is_wp_error( $return_post ) ) { |
|
691 | + if ( is_wp_error( $return_post ) ) { |
|
692 | 692 | $return_post->add_data( $updated_post, '$updated_post' ); |
693 | 693 | do_action( 'gravityview_log_error', 'Updating the post content failed', $return_post ); |
694 | 694 | } else { |
695 | - do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post ); |
|
695 | + do_action( 'gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded', $updated_post ); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | } |
@@ -709,18 +709,18 @@ discard block |
||
709 | 709 | */ |
710 | 710 | function after_update() { |
711 | 711 | |
712 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'] ); |
|
713 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] ); |
|
712 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ] ); |
|
713 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ] ); |
|
714 | 714 | |
715 | 715 | // Re-define the entry now that we've updated it. |
716 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
716 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
717 | 717 | |
718 | 718 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
719 | 719 | |
720 | 720 | // We need to clear the cache because Gravity Forms caches the field values, which |
721 | 721 | // we have just updated. |
722 | - foreach ($this->form['fields'] as $key => $field) { |
|
723 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
722 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
723 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | $this->entry = $entry; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | |
739 | 739 | <div class="gv-edit-entry-wrapper"><?php |
740 | 740 | |
741 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
741 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
742 | 742 | |
743 | 743 | /** |
744 | 744 | * Fixes weird wpautop() issue |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | * @param string $edit_entry_title Modify the "Edit Entry" title |
755 | 755 | * @param GravityView_Edit_Entry_Render $this This object |
756 | 756 | */ |
757 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
757 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
758 | 758 | |
759 | 759 | echo esc_attr( $edit_entry_title ); |
760 | 760 | ?></span> |
@@ -794,20 +794,20 @@ discard block |
||
794 | 794 | */ |
795 | 795 | private function maybe_print_message() { |
796 | 796 | |
797 | - if( rgpost('action') === 'update' ) { |
|
797 | + if ( rgpost( 'action' ) === 'update' ) { |
|
798 | 798 | |
799 | 799 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
800 | 800 | |
801 | - if( ! $this->is_valid ){ |
|
801 | + if ( ! $this->is_valid ) { |
|
802 | 802 | |
803 | 803 | // Keeping this compatible with Gravity Forms. |
804 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
805 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
804 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
805 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
806 | 806 | |
807 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
807 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
808 | 808 | |
809 | 809 | } else { |
810 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
810 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
811 | 811 | |
812 | 812 | /** |
813 | 813 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | * @param array $entry Gravity Forms entry array |
818 | 818 | * @param string $back_link URL to return to the original entry. @since 1.6 |
819 | 819 | */ |
820 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
820 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
821 | 821 | |
822 | 822 | echo GVCommon::generate_notice( $message ); |
823 | 823 | } |
@@ -834,24 +834,24 @@ discard block |
||
834 | 834 | */ |
835 | 835 | private function render_edit_form() { |
836 | 836 | |
837 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
838 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
837 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
838 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
839 | 839 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
840 | 840 | |
841 | 841 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
842 | 842 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
843 | 843 | |
844 | - add_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value'), 10, 3 ); |
|
844 | + add_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value' ), 10, 3 ); |
|
845 | 845 | |
846 | 846 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
847 | - unset( $_GET['page'] ); |
|
847 | + unset( $_GET[ 'page' ] ); |
|
848 | 848 | |
849 | 849 | // TODO: Verify multiple-page forms |
850 | 850 | // TODO: Product fields are not editable |
851 | 851 | |
852 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
852 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
853 | 853 | |
854 | - remove_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value'), 10 ); |
|
854 | + remove_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value' ), 10 ); |
|
855 | 855 | remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
856 | 856 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
857 | 857 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | */ |
876 | 876 | function fix_survey_fields_value( $value, $field, $name ) { |
877 | 877 | |
878 | - if( 'survey' === $field->type ) { |
|
878 | + if ( 'survey' === $field->type ) { |
|
879 | 879 | |
880 | 880 | // We need to run through each survey row until we find a match for expected values |
881 | 881 | foreach ( $this->entry as $field_id => $field_value ) { |
@@ -884,11 +884,11 @@ discard block |
||
884 | 884 | continue; |
885 | 885 | } |
886 | 886 | |
887 | - if( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
887 | + if ( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
888 | 888 | list( $row_val, $col_val ) = explode( ':', $field_value, 2 ); |
889 | 889 | |
890 | 890 | // If the $name matches the $row_val, we are processing the correct row |
891 | - if( $row_val === $name ) { |
|
891 | + if ( $row_val === $name ) { |
|
892 | 892 | $value = $field_value; |
893 | 893 | break; |
894 | 894 | } |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | * @return string |
910 | 910 | */ |
911 | 911 | public function render_form_buttons() { |
912 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
912 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | |
@@ -929,17 +929,17 @@ discard block |
||
929 | 929 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
930 | 930 | |
931 | 931 | // In case we have validated the form, use it to inject the validation results into the form render |
932 | - if( isset( $this->form_after_validation ) ) { |
|
932 | + if ( isset( $this->form_after_validation ) ) { |
|
933 | 933 | $form = $this->form_after_validation; |
934 | 934 | } else { |
935 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
935 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | $form = $this->filter_conditional_logic( $form ); |
939 | 939 | |
940 | 940 | // for now we don't support Save and Continue feature. |
941 | - if( ! self::$supports_save_and_continue ) { |
|
942 | - unset( $form['save'] ); |
|
941 | + if ( ! self::$supports_save_and_continue ) { |
|
942 | + unset( $form[ 'save' ] ); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | return $form; |
@@ -960,29 +960,29 @@ discard block |
||
960 | 960 | */ |
961 | 961 | function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
962 | 962 | |
963 | - if( GFCommon::is_post_field( $field ) ) { |
|
963 | + if ( GFCommon::is_post_field( $field ) ) { |
|
964 | 964 | |
965 | 965 | $message = null; |
966 | 966 | |
967 | 967 | // First, make sure they have the capability to edit the post. |
968 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
968 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
969 | 969 | |
970 | 970 | /** |
971 | 971 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
972 | 972 | * @param string $message The existing "You don't have permission..." text |
973 | 973 | */ |
974 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
974 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
975 | 975 | |
976 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
976 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
977 | 977 | /** |
978 | 978 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
979 | 979 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
980 | 980 | */ |
981 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
981 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
982 | 982 | } |
983 | 983 | |
984 | - if( $message ) { |
|
985 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
984 | + if ( $message ) { |
|
985 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
986 | 986 | } |
987 | 987 | } |
988 | 988 | |
@@ -1007,8 +1007,8 @@ discard block |
||
1007 | 1007 | |
1008 | 1008 | // If the form has been submitted, then we don't need to pre-fill the values, |
1009 | 1009 | // Except for fileupload type and when a field input is overridden- run always!! |
1010 | - if( |
|
1011 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1010 | + if ( |
|
1011 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1012 | 1012 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1013 | 1013 | || ! empty( $field_content ) |
1014 | 1014 | || GFCommon::is_product_field( $field->type ) // Prevent product fields from appearing editable |
@@ -1017,8 +1017,8 @@ discard block |
||
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | // Turn on Admin-style display for file upload fields only |
1020 | - if( 'fileupload' === $field->type ) { |
|
1021 | - $_GET['page'] = 'gf_entries'; |
|
1020 | + if ( 'fileupload' === $field->type ) { |
|
1021 | + $_GET[ 'page' ] = 'gf_entries'; |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | // Prevent any PHP warnings, like undefined index |
1043 | 1043 | ob_start(); |
1044 | 1044 | |
1045 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1045 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1046 | 1046 | /** @var GF_Field $gv_field */ |
1047 | 1047 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1048 | 1048 | } else { |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | // If there was output, it's an error |
1054 | 1054 | $warnings = ob_get_clean(); |
1055 | 1055 | |
1056 | - if( !empty( $warnings ) ) { |
|
1056 | + if ( ! empty( $warnings ) ) { |
|
1057 | 1057 | do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value ); |
1058 | 1058 | } |
1059 | 1059 | |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | * We need the fileupload html field to render with the proper id |
1063 | 1063 | * ( <li id="field_80_16" ... > ) |
1064 | 1064 | */ |
1065 | - unset( $_GET['page'] ); |
|
1065 | + unset( $_GET[ 'page' ] ); |
|
1066 | 1066 | |
1067 | 1067 | return $return; |
1068 | 1068 | } |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1086 | 1086 | |
1087 | 1087 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1088 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1088 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1089 | 1089 | |
1090 | 1090 | $field_value = array(); |
1091 | 1091 | |
@@ -1094,10 +1094,10 @@ discard block |
||
1094 | 1094 | |
1095 | 1095 | foreach ( (array)$field->inputs as $input ) { |
1096 | 1096 | |
1097 | - $input_id = strval( $input['id'] ); |
|
1097 | + $input_id = strval( $input[ 'id' ] ); |
|
1098 | 1098 | |
1099 | 1099 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1100 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1100 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1101 | 1101 | $allow_pre_populated = false; |
1102 | 1102 | } |
1103 | 1103 | |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | |
1106 | 1106 | $pre_value = $field->get_value_submission( array(), false ); |
1107 | 1107 | |
1108 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1108 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1109 | 1109 | |
1110 | 1110 | } else { |
1111 | 1111 | |
@@ -1116,13 +1116,13 @@ discard block |
||
1116 | 1116 | |
1117 | 1117 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1118 | 1118 | // or pre-populated value if not empty and set to override saved value |
1119 | - $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1119 | + $field_value = ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1120 | 1120 | |
1121 | 1121 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1122 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1122 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1123 | 1123 | $categories = array(); |
1124 | 1124 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1125 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1125 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1126 | 1126 | } |
1127 | 1127 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1128 | 1128 | } |
@@ -1147,12 +1147,12 @@ discard block |
||
1147 | 1147 | */ |
1148 | 1148 | function gform_pre_validation( $form ) { |
1149 | 1149 | |
1150 | - if( ! $this->verify_nonce() ) { |
|
1150 | + if ( ! $this->verify_nonce() ) { |
|
1151 | 1151 | return $form; |
1152 | 1152 | } |
1153 | 1153 | |
1154 | 1154 | // Fix PHP warning regarding undefined index. |
1155 | - foreach ( $form['fields'] as &$field) { |
|
1155 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1156 | 1156 | |
1157 | 1157 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1158 | 1158 | // expects certain field array items to be set. |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | $field['emailConfirmEnabled'] = ''; |
1166 | 1166 | }*/ |
1167 | 1167 | |
1168 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1168 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1169 | 1169 | |
1170 | 1170 | /** |
1171 | 1171 | * 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. |
@@ -1179,37 +1179,37 @@ discard block |
||
1179 | 1179 | // Set the previous value |
1180 | 1180 | $entry = $this->get_entry(); |
1181 | 1181 | |
1182 | - $input_name = 'input_'.$field->id; |
|
1183 | - $form_id = $form['id']; |
|
1182 | + $input_name = 'input_' . $field->id; |
|
1183 | + $form_id = $form[ 'id' ]; |
|
1184 | 1184 | |
1185 | 1185 | $value = NULL; |
1186 | 1186 | |
1187 | 1187 | // Use the previous entry value as the default. |
1188 | - if( isset( $entry[ $field->id ] ) ) { |
|
1188 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1189 | 1189 | $value = $entry[ $field->id ]; |
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | // If this is a single upload file |
1193 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1194 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1195 | - $value = $file_path['url']; |
|
1193 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1194 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1195 | + $value = $file_path[ 'url' ]; |
|
1196 | 1196 | |
1197 | 1197 | } else { |
1198 | 1198 | |
1199 | 1199 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1200 | 1200 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1201 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1201 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1202 | 1202 | |
1203 | 1203 | } |
1204 | 1204 | |
1205 | - if( rgar($field, "multipleFiles") ) { |
|
1205 | + if ( rgar( $field, "multipleFiles" ) ) { |
|
1206 | 1206 | |
1207 | 1207 | // If there are fresh uploads, process and merge them. |
1208 | 1208 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1209 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1209 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1210 | 1210 | $value = empty( $value ) ? '[]' : $value; |
1211 | 1211 | $value = stripslashes_deep( $value ); |
1212 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1212 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | } else { |
@@ -1227,14 +1227,14 @@ discard block |
||
1227 | 1227 | |
1228 | 1228 | case 'number': |
1229 | 1229 | // Fix "undefined index" issue at line 1286 in form_display.php |
1230 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1231 | - $_POST['input_'.$field->id ] = NULL; |
|
1230 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1231 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1232 | 1232 | } |
1233 | 1233 | break; |
1234 | 1234 | case 'captcha': |
1235 | 1235 | // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php |
1236 | - $_POST['recaptcha_challenge_field'] = NULL; |
|
1237 | - $_POST['recaptcha_response_field'] = NULL; |
|
1236 | + $_POST[ 'recaptcha_challenge_field' ] = NULL; |
|
1237 | + $_POST[ 'recaptcha_response_field' ] = NULL; |
|
1238 | 1238 | break; |
1239 | 1239 | } |
1240 | 1240 | |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | * You can enter whatever you want! |
1271 | 1271 | * We try validating, and customize the results using `self::custom_validation()` |
1272 | 1272 | */ |
1273 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1273 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1274 | 1274 | |
1275 | 1275 | // Needed by the validate funtion |
1276 | 1276 | $failed_validation_page = NULL; |
@@ -1278,14 +1278,14 @@ discard block |
||
1278 | 1278 | |
1279 | 1279 | // Prevent entry limit from running when editing an entry, also |
1280 | 1280 | // prevent form scheduling from preventing editing |
1281 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1281 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1282 | 1282 | |
1283 | 1283 | // Hide fields depending on Edit Entry settings |
1284 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1284 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1285 | 1285 | |
1286 | 1286 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1287 | 1287 | |
1288 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1288 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1289 | 1289 | } |
1290 | 1290 | |
1291 | 1291 | |
@@ -1302,13 +1302,13 @@ discard block |
||
1302 | 1302 | */ |
1303 | 1303 | function custom_validation( $validation_results ) { |
1304 | 1304 | |
1305 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
1305 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
1306 | 1306 | |
1307 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
1307 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
1308 | 1308 | |
1309 | 1309 | $gv_valid = true; |
1310 | 1310 | |
1311 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1311 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1312 | 1312 | |
1313 | 1313 | $value = RGFormsModel::get_field_value( $field ); |
1314 | 1314 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1321,35 +1321,35 @@ discard block |
||
1321 | 1321 | case 'post_image': |
1322 | 1322 | |
1323 | 1323 | // in case nothing is uploaded but there are already files saved |
1324 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1324 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1325 | 1325 | $field->failed_validation = false; |
1326 | 1326 | unset( $field->validation_message ); |
1327 | 1327 | } |
1328 | 1328 | |
1329 | 1329 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1330 | - if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { |
|
1330 | + if ( rgobj( $field, 'maxFiles' ) && rgobj( $field, 'multipleFiles' ) ) { |
|
1331 | 1331 | |
1332 | 1332 | $input_name = 'input_' . $field->id; |
1333 | 1333 | //uploaded |
1334 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1334 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1335 | 1335 | |
1336 | 1336 | //existent |
1337 | 1337 | $entry = $this->get_entry(); |
1338 | 1338 | $value = NULL; |
1339 | - if( isset( $entry[ $field->id ] ) ) { |
|
1339 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1340 | 1340 | $value = json_decode( $entry[ $field->id ], true ); |
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | // count uploaded files and existent entry files |
1344 | 1344 | $count_files = count( $file_names ) + count( $value ); |
1345 | 1345 | |
1346 | - if( $count_files > $field->maxFiles ) { |
|
1346 | + if ( $count_files > $field->maxFiles ) { |
|
1347 | 1347 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1348 | 1348 | $field->failed_validation = 1; |
1349 | 1349 | $gv_valid = false; |
1350 | 1350 | |
1351 | 1351 | // in case of error make sure the newest upload files are removed from the upload input |
1352 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1352 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1353 | 1353 | } |
1354 | 1354 | |
1355 | 1355 | } |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | // This field has failed validation. |
1363 | - if( !empty( $field->failed_validation ) ) { |
|
1363 | + if ( ! empty( $field->failed_validation ) ) { |
|
1364 | 1364 | |
1365 | 1365 | do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) ); |
1366 | 1366 | |
@@ -1378,32 +1378,32 @@ discard block |
||
1378 | 1378 | } |
1379 | 1379 | |
1380 | 1380 | // You can't continue inside a switch, so we do it after. |
1381 | - if( empty( $field->failed_validation ) ) { |
|
1381 | + if ( empty( $field->failed_validation ) ) { |
|
1382 | 1382 | continue; |
1383 | 1383 | } |
1384 | 1384 | |
1385 | 1385 | // checks if the No Duplicates option is not validating entry against itself, since |
1386 | 1386 | // we're editing a stored entry, it would also assume it's a duplicate. |
1387 | - if( !empty( $field->noDuplicates ) ) { |
|
1387 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1388 | 1388 | |
1389 | 1389 | $entry = $this->get_entry(); |
1390 | 1390 | |
1391 | 1391 | // If the value of the entry is the same as the stored value |
1392 | 1392 | // Then we can assume it's not a duplicate, it's the same. |
1393 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1393 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1394 | 1394 | //if value submitted was not changed, then don't validate |
1395 | 1395 | $field->failed_validation = false; |
1396 | 1396 | |
1397 | 1397 | unset( $field->validation_message ); |
1398 | 1398 | |
1399 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
1399 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
1400 | 1400 | |
1401 | 1401 | continue; |
1402 | 1402 | } |
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1406 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1406 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1407 | 1407 | unset( $field->validation_message ); |
1408 | 1408 | $field->validation_message = false; |
1409 | 1409 | continue; |
@@ -1415,12 +1415,12 @@ discard block |
||
1415 | 1415 | |
1416 | 1416 | } |
1417 | 1417 | |
1418 | - $validation_results['is_valid'] = $gv_valid; |
|
1418 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1419 | 1419 | |
1420 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
1420 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
1421 | 1421 | |
1422 | 1422 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1423 | - $this->form_after_validation = $validation_results['form']; |
|
1423 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1424 | 1424 | |
1425 | 1425 | return $validation_results; |
1426 | 1426 | } |
@@ -1433,7 +1433,7 @@ discard block |
||
1433 | 1433 | */ |
1434 | 1434 | private function get_entry() { |
1435 | 1435 | |
1436 | - if( empty( $this->entry ) ) { |
|
1436 | + if ( empty( $this->entry ) ) { |
|
1437 | 1437 | // Get the database value of the entry that's being edited |
1438 | 1438 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1439 | 1439 | } |
@@ -1460,7 +1460,7 @@ discard block |
||
1460 | 1460 | $properties = GravityView_View_Data::getInstance()->get_fields( $view_id ); |
1461 | 1461 | |
1462 | 1462 | // If edit tab not yet configured, show all fields |
1463 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1463 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1464 | 1464 | |
1465 | 1465 | // Show hidden fields as text fields |
1466 | 1466 | $form = $this->fix_hidden_fields( $form ); |
@@ -1469,7 +1469,7 @@ discard block |
||
1469 | 1469 | $form = $this->fix_survey_fields( $form ); |
1470 | 1470 | |
1471 | 1471 | // Hide fields depending on admin settings |
1472 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1472 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1473 | 1473 | |
1474 | 1474 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1475 | 1475 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1489,7 +1489,7 @@ discard block |
||
1489 | 1489 | private function fix_survey_fields( $form ) { |
1490 | 1490 | |
1491 | 1491 | /** @var GF_Field $field */ |
1492 | - foreach( $form['fields'] as &$field ) { |
|
1492 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1493 | 1493 | $field->allowsPrepopulate = true; |
1494 | 1494 | } |
1495 | 1495 | |
@@ -1506,11 +1506,11 @@ discard block |
||
1506 | 1506 | private function fix_hidden_fields( $form ) { |
1507 | 1507 | |
1508 | 1508 | /** @var GF_Field $field */ |
1509 | - foreach( $form['fields'] as $key => $field ) { |
|
1510 | - if( 'hidden' === $field->type ) { |
|
1509 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
1510 | + if ( 'hidden' === $field->type ) { |
|
1511 | 1511 | $text_field = new GF_Field_Text( $field ); |
1512 | 1512 | $text_field->type = 'text'; |
1513 | - $form['fields'][ $key ] = $text_field; |
|
1513 | + $form[ 'fields' ][ $key ] = $text_field; |
|
1514 | 1514 | } |
1515 | 1515 | } |
1516 | 1516 | |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | */ |
1532 | 1532 | private function filter_fields( $fields, $configured_fields ) { |
1533 | 1533 | |
1534 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1534 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1535 | 1535 | return $fields; |
1536 | 1536 | } |
1537 | 1537 | |
@@ -1548,13 +1548,13 @@ discard block |
||
1548 | 1548 | */ |
1549 | 1549 | $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) ); |
1550 | 1550 | |
1551 | - if( $hide_product_fields ) { |
|
1552 | - $field_type_blacklist[] = 'option'; |
|
1553 | - $field_type_blacklist[] = 'quantity'; |
|
1554 | - $field_type_blacklist[] = 'product'; |
|
1555 | - $field_type_blacklist[] = 'total'; |
|
1556 | - $field_type_blacklist[] = 'shipping'; |
|
1557 | - $field_type_blacklist[] = 'calculation'; |
|
1551 | + if ( $hide_product_fields ) { |
|
1552 | + $field_type_blacklist[ ] = 'option'; |
|
1553 | + $field_type_blacklist[ ] = 'quantity'; |
|
1554 | + $field_type_blacklist[ ] = 'product'; |
|
1555 | + $field_type_blacklist[ ] = 'total'; |
|
1556 | + $field_type_blacklist[ ] = 'shipping'; |
|
1557 | + $field_type_blacklist[ ] = 'calculation'; |
|
1558 | 1558 | } |
1559 | 1559 | |
1560 | 1560 | // First, remove blacklist or calculation fields |
@@ -1562,24 +1562,24 @@ discard block |
||
1562 | 1562 | |
1563 | 1563 | // Remove the fields that have calculation properties and keep them to be used later |
1564 | 1564 | // @since 1.16.2 |
1565 | - if( $field->has_calculation() ) { |
|
1566 | - $this->fields_with_calculation[] = $field; |
|
1565 | + if ( $field->has_calculation() ) { |
|
1566 | + $this->fields_with_calculation[ ] = $field; |
|
1567 | 1567 | // don't remove the calculation fields on form render. |
1568 | 1568 | } |
1569 | 1569 | |
1570 | 1570 | // process total field after all fields have been saved |
1571 | 1571 | if ( $field->type == 'total' ) { |
1572 | - $this->total_fields[] = $field; |
|
1572 | + $this->total_fields[ ] = $field; |
|
1573 | 1573 | unset( $fields[ $key ] ); |
1574 | 1574 | } |
1575 | 1575 | |
1576 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1576 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1577 | 1577 | unset( $fields[ $key ] ); |
1578 | 1578 | } |
1579 | 1579 | } |
1580 | 1580 | |
1581 | 1581 | // The Edit tab has not been configured, so we return all fields by default. |
1582 | - if( empty( $configured_fields ) ) { |
|
1582 | + if ( empty( $configured_fields ) ) { |
|
1583 | 1583 | return $fields; |
1584 | 1584 | } |
1585 | 1585 | |
@@ -1589,8 +1589,8 @@ discard block |
||
1589 | 1589 | /** @var GF_Field $field */ |
1590 | 1590 | foreach ( $fields as $field ) { |
1591 | 1591 | |
1592 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1593 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1592 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1593 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1594 | 1594 | break; |
1595 | 1595 | } |
1596 | 1596 | |
@@ -1613,14 +1613,14 @@ discard block |
||
1613 | 1613 | |
1614 | 1614 | $return_field = $field; |
1615 | 1615 | |
1616 | - if( empty( $field_setting['show_label'] ) ) { |
|
1616 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1617 | 1617 | $return_field->label = ''; |
1618 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1619 | - $return_field->label = $field_setting['custom_label']; |
|
1618 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1619 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1620 | 1620 | } |
1621 | 1621 | |
1622 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1623 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1622 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1623 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1624 | 1624 | } |
1625 | 1625 | |
1626 | 1626 | /** |
@@ -1658,16 +1658,16 @@ discard block |
||
1658 | 1658 | */ |
1659 | 1659 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1660 | 1660 | |
1661 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1662 | - foreach( $fields as $k => $field ) { |
|
1663 | - if( $field->adminOnly ) { |
|
1661 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1662 | + foreach ( $fields as $k => $field ) { |
|
1663 | + if ( $field->adminOnly ) { |
|
1664 | 1664 | unset( $fields[ $k ] ); |
1665 | 1665 | } |
1666 | 1666 | } |
1667 | 1667 | return $fields; |
1668 | 1668 | } |
1669 | 1669 | |
1670 | - foreach( $fields as &$field ) { |
|
1670 | + foreach ( $fields as &$field ) { |
|
1671 | 1671 | $field->adminOnly = false; |
1672 | 1672 | } |
1673 | 1673 | |
@@ -1694,16 +1694,16 @@ discard block |
||
1694 | 1694 | */ |
1695 | 1695 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1696 | 1696 | |
1697 | - if( $use_conditional_logic ) { |
|
1697 | + if ( $use_conditional_logic ) { |
|
1698 | 1698 | return $form; |
1699 | 1699 | } |
1700 | 1700 | |
1701 | - foreach( $form['fields'] as &$field ) { |
|
1701 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1702 | 1702 | /* @var GF_Field $field */ |
1703 | 1703 | $field->conditionalLogic = null; |
1704 | 1704 | } |
1705 | 1705 | |
1706 | - unset( $form['button']['conditionalLogic'] ); |
|
1706 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1707 | 1707 | |
1708 | 1708 | return $form; |
1709 | 1709 | |
@@ -1720,7 +1720,7 @@ discard block |
||
1720 | 1720 | */ |
1721 | 1721 | function manage_conditional_logic( $has_conditional_logic, $form ) { |
1722 | 1722 | |
1723 | - if( ! $this->is_edit_entry() ) { |
|
1723 | + if ( ! $this->is_edit_entry() ) { |
|
1724 | 1724 | return $has_conditional_logic; |
1725 | 1725 | } |
1726 | 1726 | |
@@ -1751,44 +1751,44 @@ discard block |
||
1751 | 1751 | * 2. There are two entries embedded using oEmbed |
1752 | 1752 | * 3. One of the entries has just been saved |
1753 | 1753 | */ |
1754 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1754 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1755 | 1755 | |
1756 | 1756 | $error = true; |
1757 | 1757 | |
1758 | 1758 | } |
1759 | 1759 | |
1760 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1760 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1761 | 1761 | |
1762 | 1762 | $error = true; |
1763 | 1763 | |
1764 | - } elseif( ! $this->verify_nonce() ) { |
|
1764 | + } elseif ( ! $this->verify_nonce() ) { |
|
1765 | 1765 | |
1766 | 1766 | /** |
1767 | 1767 | * If the Entry is embedded, there may be two entries on the same page. |
1768 | 1768 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1769 | 1769 | */ |
1770 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1770 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1771 | 1771 | $error = true; |
1772 | 1772 | } else { |
1773 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1773 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1774 | 1774 | } |
1775 | 1775 | |
1776 | 1776 | } |
1777 | 1777 | |
1778 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1779 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1778 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1779 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1780 | 1780 | } |
1781 | 1781 | |
1782 | - if( $this->entry['status'] === 'trash' ) { |
|
1783 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1782 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1783 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1784 | 1784 | } |
1785 | 1785 | |
1786 | 1786 | // No errors; everything's fine here! |
1787 | - if( empty( $error ) ) { |
|
1787 | + if ( empty( $error ) ) { |
|
1788 | 1788 | return true; |
1789 | 1789 | } |
1790 | 1790 | |
1791 | - if( $echo && $error !== true ) { |
|
1791 | + if ( $echo && $error !== true ) { |
|
1792 | 1792 | |
1793 | 1793 | $error = esc_html( $error ); |
1794 | 1794 | |
@@ -1796,13 +1796,13 @@ discard block |
||
1796 | 1796 | * @since 1.9 |
1797 | 1797 | */ |
1798 | 1798 | if ( ! empty( $this->entry ) ) { |
1799 | - $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;" ) ); |
|
1799 | + $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;" ) ); |
|
1800 | 1800 | } |
1801 | 1801 | |
1802 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1802 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1803 | 1803 | } |
1804 | 1804 | |
1805 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
1805 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
1806 | 1806 | |
1807 | 1807 | return false; |
1808 | 1808 | } |
@@ -1819,20 +1819,20 @@ discard block |
||
1819 | 1819 | |
1820 | 1820 | $error = NULL; |
1821 | 1821 | |
1822 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1823 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
1822 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1823 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
1824 | 1824 | } |
1825 | 1825 | |
1826 | 1826 | // No errors; everything's fine here! |
1827 | - if( empty( $error ) ) { |
|
1827 | + if ( empty( $error ) ) { |
|
1828 | 1828 | return true; |
1829 | 1829 | } |
1830 | 1830 | |
1831 | - if( $echo ) { |
|
1832 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
1831 | + if ( $echo ) { |
|
1832 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
1833 | 1833 | } |
1834 | 1834 | |
1835 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
1835 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
1836 | 1836 | |
1837 | 1837 | return false; |
1838 | 1838 | |
@@ -1850,15 +1850,15 @@ discard block |
||
1850 | 1850 | private function check_user_cap_edit_field( $field ) { |
1851 | 1851 | |
1852 | 1852 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
1853 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1853 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1854 | 1854 | return true; |
1855 | 1855 | } |
1856 | 1856 | |
1857 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
1857 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
1858 | 1858 | |
1859 | 1859 | // If the field has custom editing capaibilities set, check those |
1860 | - if( $field_cap ) { |
|
1861 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
1860 | + if ( $field_cap ) { |
|
1861 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | return false; |
@@ -1872,17 +1872,17 @@ discard block |
||
1872 | 1872 | public function verify_nonce() { |
1873 | 1873 | |
1874 | 1874 | // Verify form submitted for editing single |
1875 | - if( $this->is_edit_entry_submission() ) { |
|
1875 | + if ( $this->is_edit_entry_submission() ) { |
|
1876 | 1876 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
1877 | 1877 | } |
1878 | 1878 | |
1879 | 1879 | // Verify |
1880 | - else if( ! $this->is_edit_entry() ) { |
|
1880 | + else if ( ! $this->is_edit_entry() ) { |
|
1881 | 1881 | $valid = false; |
1882 | 1882 | } |
1883 | 1883 | |
1884 | 1884 | else { |
1885 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
1885 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
1886 | 1886 | } |
1887 | 1887 | |
1888 | 1888 | /** |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if( ! class_exists('GFAddOn') ) { |
|
3 | +if ( ! class_exists( 'GFAddOn' ) ) { |
|
4 | 4 | return; |
5 | 5 | } |
6 | 6 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function __construct( $prevent_multiple_instances = '' ) { |
77 | 77 | |
78 | - if( $prevent_multiple_instances === 'get_instance' ) { |
|
78 | + if ( $prevent_multiple_instances === 'get_instance' ) { |
|
79 | 79 | return parent::__construct(); |
80 | 80 | } |
81 | 81 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public static function get_instance() { |
89 | 89 | |
90 | - if( empty( self::$instance ) ) { |
|
90 | + if ( empty( self::$instance ) ) { |
|
91 | 91 | self::$instance = new self( 'get_instance' ); |
92 | 92 | } |
93 | 93 | |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | * Prevent Gravity Forms from showing the uninstall tab on the settings page |
111 | 111 | * @hack |
112 | 112 | */ |
113 | - if( $caps === $this->_capabilities_uninstall ) { |
|
113 | + if ( $caps === $this->_capabilities_uninstall ) { |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
117 | - if( empty( $caps ) ) { |
|
117 | + if ( empty( $caps ) ) { |
|
118 | 118 | $caps = array( 'gravityview_full_access' ); |
119 | 119 | } |
120 | 120 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | add_filter( 'gform_addon_app_settings_menu_gravityview', array( $this, 'modify_app_settings_menu_title' ) ); |
138 | 138 | |
139 | 139 | /** @since 1.7.6 */ |
140 | - add_action('network_admin_menu', array( $this, 'add_network_menu' ) ); |
|
140 | + add_action( 'network_admin_menu', array( $this, 'add_network_menu' ) ); |
|
141 | 141 | |
142 | 142 | parent::init_admin(); |
143 | 143 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function modify_app_settings_menu_title( $setting_tabs ) { |
153 | 153 | |
154 | - $setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview'); |
|
154 | + $setting_tabs[ 0 ][ 'label' ] = __( 'GravityView Settings', 'gravityview' ); |
|
155 | 155 | |
156 | 156 | return $setting_tabs; |
157 | 157 | } |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | */ |
169 | 169 | private function _load_license_handler() { |
170 | 170 | |
171 | - if( !empty( $this->License_Handler ) ) { |
|
171 | + if ( ! empty( $this->License_Handler ) ) { |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
175 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gv-license-handler.php'); |
|
175 | + require_once( GRAVITYVIEW_DIR . 'includes/class-gv-license-handler.php' ); |
|
176 | 176 | |
177 | 177 | $this->License_Handler = GV_License_Handler::get_instance( $this ); |
178 | 178 | } |
@@ -184,39 +184,39 @@ discard block |
||
184 | 184 | function license_key_notice() { |
185 | 185 | |
186 | 186 | // Only show on GravityView pages |
187 | - if( ! gravityview_is_admin_page() ) { |
|
187 | + if ( ! gravityview_is_admin_page() ) { |
|
188 | 188 | return; |
189 | 189 | } |
190 | 190 | |
191 | - $license_status = self::getSetting('license_key_status'); |
|
192 | - $license_id = self::getSetting('license_key'); |
|
191 | + $license_status = self::getSetting( 'license_key_status' ); |
|
192 | + $license_id = self::getSetting( 'license_key' ); |
|
193 | 193 | $license_id = empty( $license_id ) ? 'license' : $license_id; |
194 | 194 | |
195 | - $message = esc_html__('Your GravityView license %s. This means you’re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview'); |
|
195 | + $message = esc_html__( 'Your GravityView license %s. This means you’re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * I wanted to remove the period from after the buttons in the string, |
199 | 199 | * but didn't want to mess up the translation strings for the translators. |
200 | 200 | */ |
201 | 201 | $message = mb_substr( $message, 0, mb_strlen( $message ) - 1 ); |
202 | - $title = __('Inactive License', 'gravityview'); |
|
202 | + $title = __( 'Inactive License', 'gravityview' ); |
|
203 | 203 | $status = ''; |
204 | 204 | $update_below = false; |
205 | 205 | $primary_button_link = admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ); |
206 | 206 | switch ( $license_status ) { |
207 | 207 | /** @since 1.17 */ |
208 | 208 | case 'expired': |
209 | - $title = __('Expired License', 'gravityview'); |
|
209 | + $title = __( 'Expired License', 'gravityview' ); |
|
210 | 210 | $status = 'expired'; |
211 | - $message = $this->get_license_handler()->strings( 'expired', self::getSetting('license_key_response') ); |
|
211 | + $message = $this->get_license_handler()->strings( 'expired', self::getSetting( 'license_key_response' ) ); |
|
212 | 212 | break; |
213 | 213 | case 'invalid': |
214 | - $title = __('Invalid License', 'gravityview'); |
|
215 | - $status = __('is invalid', 'gravityview'); |
|
214 | + $title = __( 'Invalid License', 'gravityview' ); |
|
215 | + $status = __( 'is invalid', 'gravityview' ); |
|
216 | 216 | break; |
217 | 217 | case 'deactivated': |
218 | - $status = __('is inactive', 'gravityview'); |
|
219 | - $update_below = __('Activate your license key below.', 'gravityview'); |
|
218 | + $status = __( 'is inactive', 'gravityview' ); |
|
219 | + $update_below = __( 'Activate your license key below.', 'gravityview' ); |
|
220 | 220 | break; |
221 | 221 | /** @noinspection PhpMissingBreakStatementInspection */ |
222 | 222 | case '': |
@@ -224,27 +224,27 @@ discard block |
||
224 | 224 | // break intentionally left blank |
225 | 225 | case 'inactive': |
226 | 226 | case 'site_inactive': |
227 | - $status = __('has not been activated', 'gravityview'); |
|
228 | - $update_below = __('Activate your license key below.', 'gravityview'); |
|
227 | + $status = __( 'has not been activated', 'gravityview' ); |
|
228 | + $update_below = __( 'Activate your license key below.', 'gravityview' ); |
|
229 | 229 | break; |
230 | 230 | } |
231 | - $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice'; |
|
231 | + $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice'; |
|
232 | 232 | |
233 | 233 | // Show a different notice on settings page for inactive licenses (hide the buttons) |
234 | - if( $update_below && gravityview_is_admin_page( '', 'settings' ) ) { |
|
234 | + if ( $update_below && gravityview_is_admin_page( '', 'settings' ) ) { |
|
235 | 235 | $message = sprintf( $message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">' . $update_below . '</a>' ); |
236 | 236 | } else { |
237 | 237 | $message = sprintf( $message, $status, "\n\n" . '<a href="' . $primary_button_link . '" class="button button-primary">', '</a>', '<a href="' . esc_url( $url ) . '" class="button button-secondary">', '</a>' ); |
238 | 238 | } |
239 | 239 | |
240 | - if( !empty( $status ) ) { |
|
240 | + if ( ! empty( $status ) ) { |
|
241 | 241 | GravityView_Admin_Notices::add_notice( array( |
242 | 242 | 'message' => $message, |
243 | 243 | 'class' => 'updated', |
244 | 244 | 'title' => $title, |
245 | 245 | 'cap' => 'gravityview_edit_settings', |
246 | - 'dismiss' => sha1( $license_status.'_'.$license_id ), |
|
247 | - )); |
|
246 | + 'dismiss' => sha1( $license_status . '_' . $license_id ), |
|
247 | + ) ); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | $styles = parent::styles(); |
258 | 258 | |
259 | - $styles[] = array( |
|
259 | + $styles[ ] = array( |
|
260 | 260 | 'handle' => 'gravityview_settings', |
261 | 261 | 'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ), |
262 | 262 | 'version' => GravityView_Plugin::version, |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @return void |
280 | 280 | */ |
281 | 281 | public function add_network_menu() { |
282 | - if( GravityView_Plugin::is_network_activated() ) { |
|
282 | + if ( GravityView_Plugin::is_network_activated() ) { |
|
283 | 283 | add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' ); |
284 | 284 | } |
285 | 285 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * If multisite and not network admin, we don't want the settings to show. |
297 | 297 | * @since 1.7.6 |
298 | 298 | */ |
299 | - $show_submenu = !is_multisite() || is_main_site() || !GravityView_Plugin::is_network_activated() || ( is_network_admin() && GravityView_Plugin::is_network_activated() ); |
|
299 | + $show_submenu = ! is_multisite() || is_main_site() || ! GravityView_Plugin::is_network_activated() || ( is_network_admin() && GravityView_Plugin::is_network_activated() ); |
|
300 | 300 | |
301 | 301 | /** |
302 | 302 | * Override whether to show the Settings menu on a per-blog basis. |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | $show_submenu = apply_filters( 'gravityview/show-settings-menu', $show_submenu ); |
307 | 307 | |
308 | - if( $show_submenu ) { |
|
308 | + if ( $show_submenu ) { |
|
309 | 309 | add_submenu_page( 'edit.php?post_type=gravityview', __( 'Settings', 'gravityview' ), __( 'Settings', 'gravityview' ), $this->_capabilities_app_settings, $this->_slug . '_settings', array( $this, 'app_tab_page' ) ); |
310 | 310 | } |
311 | 311 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | /** |
337 | 337 | * Backward compatibility with Redux |
338 | 338 | */ |
339 | - if( $setting_name === 'license' ) { |
|
339 | + if ( $setting_name === 'license' ) { |
|
340 | 340 | return array( |
341 | 341 | 'license' => parent::get_app_setting( 'license_key' ), |
342 | 342 | 'status' => parent::get_app_setting( 'license_key_status' ), |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | |
401 | 401 | $return = $text . $activation; |
402 | 402 | |
403 | - if( $echo ) { |
|
403 | + if ( $echo ) { |
|
404 | 404 | echo $return; |
405 | 405 | } |
406 | 406 | |
@@ -427,15 +427,15 @@ discard block |
||
427 | 427 | */ |
428 | 428 | public function settings_submit( $field, $echo = true ) { |
429 | 429 | |
430 | - $field['type'] = ( isset($field['type']) && in_array( $field['type'], array('submit','reset','button') ) ) ? $field['type'] : 'submit'; |
|
430 | + $field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], array( 'submit', 'reset', 'button' ) ) ) ? $field[ 'type' ] : 'submit'; |
|
431 | 431 | |
432 | 432 | $attributes = $this->get_field_attributes( $field ); |
433 | 433 | $default_value = rgar( $field, 'value' ) ? rgar( $field, 'value' ) : rgar( $field, 'default_value' ); |
434 | - $value = $this->get_setting( $field['name'], $default_value ); |
|
434 | + $value = $this->get_setting( $field[ 'name' ], $default_value ); |
|
435 | 435 | |
436 | 436 | |
437 | - $attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton'; |
|
438 | - $name = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_'.$field['name']; |
|
437 | + $attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary gfbutton'; |
|
438 | + $name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ]; |
|
439 | 439 | |
440 | 440 | if ( empty( $value ) ) { |
441 | 441 | $value = __( 'Update Settings', 'gravityview' ); |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $attributes = $this->get_field_attributes( $field ); |
445 | 445 | |
446 | 446 | $html = '<input |
447 | - type="' . $field['type'] . '" |
|
447 | + type="' . $field[ 'type' ] . '" |
|
448 | 448 | name="' . esc_attr( $name ) . '" |
449 | 449 | value="' . $value . '" ' . |
450 | 450 | implode( ' ', $attributes ) . |
@@ -466,16 +466,16 @@ discard block |
||
466 | 466 | * @return string |
467 | 467 | */ |
468 | 468 | public function settings_save( $field, $echo = true ) { |
469 | - $field['type'] = 'submit'; |
|
470 | - $field['name'] = 'gform-settings-save'; |
|
471 | - $field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton'; |
|
469 | + $field[ 'type' ] = 'submit'; |
|
470 | + $field[ 'name' ] = 'gform-settings-save'; |
|
471 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] : 'button-primary gfbutton'; |
|
472 | 472 | |
473 | 473 | if ( ! rgar( $field, 'value' ) ) |
474 | - $field['value'] = __( 'Update Settings', 'gravityview' ); |
|
474 | + $field[ 'value' ] = __( 'Update Settings', 'gravityview' ); |
|
475 | 475 | |
476 | 476 | $output = $this->settings_submit( $field, false ); |
477 | 477 | |
478 | - if( $echo ) { |
|
478 | + if ( $echo ) { |
|
479 | 479 | echo $output; |
480 | 480 | } |
481 | 481 | |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | parent::single_setting_label( $field ); |
493 | 493 | |
494 | 494 | // Added by GravityView |
495 | - if ( isset( $field['description'] ) ) { |
|
496 | - echo '<span class="description">'. $field['description'] .'</span>'; |
|
495 | + if ( isset( $field[ 'description' ] ) ) { |
|
496 | + echo '<span class="description">' . $field[ 'description' ] . '</span>'; |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | } |
@@ -555,11 +555,11 @@ discard block |
||
555 | 555 | |
556 | 556 | // If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response), |
557 | 557 | // then we assume it's changed. If it's changed, unset the status and the previous response. |
558 | - if( $local_key !== $response_key ) { |
|
558 | + if ( $local_key !== $response_key ) { |
|
559 | 559 | |
560 | - unset( $posted_settings['license_key_response'] ); |
|
561 | - unset( $posted_settings['license_key_status'] ); |
|
562 | - GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) ); |
|
560 | + unset( $posted_settings[ 'license_key_response' ] ); |
|
561 | + unset( $posted_settings[ 'license_key_status' ] ); |
|
562 | + GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) ); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | return $posted_settings; |
@@ -594,25 +594,25 @@ discard block |
||
594 | 594 | 'label' => __( 'License Key', 'gravityview' ), |
595 | 595 | 'description' => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates & support.', 'gravityview' ), |
596 | 596 | 'type' => 'edd_license', |
597 | - 'data-pending-text' => __('Verifying license…', 'gravityview'), |
|
598 | - 'default_value' => $default_settings['license_key'], |
|
597 | + 'data-pending-text' => __( 'Verifying license…', 'gravityview' ), |
|
598 | + 'default_value' => $default_settings[ 'license_key' ], |
|
599 | 599 | 'class' => ( '' == $this->get_app_setting( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key', |
600 | 600 | ), |
601 | 601 | array( |
602 | 602 | 'name' => 'license_key_response', |
603 | - 'default_value' => $default_settings['license_key_response'], |
|
603 | + 'default_value' => $default_settings[ 'license_key_response' ], |
|
604 | 604 | 'type' => 'hidden', |
605 | 605 | ), |
606 | 606 | array( |
607 | 607 | 'name' => 'license_key_status', |
608 | - 'default_value' => $default_settings['license_key_status'], |
|
608 | + 'default_value' => $default_settings[ 'license_key_status' ], |
|
609 | 609 | 'type' => 'hidden', |
610 | 610 | ), |
611 | 611 | array( |
612 | 612 | 'name' => 'support-email', |
613 | 613 | 'type' => 'text', |
614 | 614 | 'validate' => 'email', |
615 | - 'default_value' => $default_settings['support-email'], |
|
615 | + 'default_value' => $default_settings[ 'support-email' ], |
|
616 | 616 | 'label' => __( 'Support Email', 'gravityview' ), |
617 | 617 | 'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ), |
618 | 618 | 'class' => 'code regular-text', |
@@ -624,44 +624,44 @@ discard block |
||
624 | 624 | 'name' => 'support_port', |
625 | 625 | 'type' => 'radio', |
626 | 626 | 'label' => __( 'Show Support Port?', 'gravityview' ), |
627 | - 'default_value' => $default_settings['support_port'], |
|
627 | + 'default_value' => $default_settings[ 'support_port' ], |
|
628 | 628 | 'horizontal' => 1, |
629 | 629 | 'choices' => array( |
630 | 630 | array( |
631 | - 'label' => _x('Show', 'Setting: Show or Hide', 'gravityview'), |
|
631 | + 'label' => _x( 'Show', 'Setting: Show or Hide', 'gravityview' ), |
|
632 | 632 | 'value' => '1', |
633 | 633 | ), |
634 | 634 | array( |
635 | - 'label' => _x('Hide', 'Setting: Show or Hide', 'gravityview'), |
|
635 | + 'label' => _x( 'Hide', 'Setting: Show or Hide', 'gravityview' ), |
|
636 | 636 | 'value' => '0', |
637 | 637 | ), |
638 | 638 | ), |
639 | - 'tooltip' => '<p><img src="' . esc_url_raw( plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview') . '</p>', |
|
639 | + 'tooltip' => '<p><img src="' . esc_url_raw( plugins_url( 'assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__( 'The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview' ) . '</p>', |
|
640 | 640 | 'description' => __( 'Show the Support Port on GravityView pages?', 'gravityview' ), |
641 | 641 | ), |
642 | 642 | array( |
643 | 643 | 'name' => 'no-conflict-mode', |
644 | 644 | 'type' => 'radio', |
645 | 645 | 'label' => __( 'No-Conflict Mode', 'gravityview' ), |
646 | - 'default_value' => $default_settings['no-conflict-mode'], |
|
646 | + 'default_value' => $default_settings[ 'no-conflict-mode' ], |
|
647 | 647 | 'horizontal' => 1, |
648 | 648 | 'choices' => array( |
649 | 649 | array( |
650 | - 'label' => _x('On', 'Setting: On or off', 'gravityview'), |
|
650 | + 'label' => _x( 'On', 'Setting: On or off', 'gravityview' ), |
|
651 | 651 | 'value' => '1', |
652 | 652 | ), |
653 | 653 | array( |
654 | - 'label' => _x('Off', 'Setting: On or off', 'gravityview'), |
|
654 | + 'label' => _x( 'Off', 'Setting: On or off', 'gravityview' ), |
|
655 | 655 | 'value' => '0', |
656 | 656 | ), |
657 | 657 | ), |
658 | - 'description' => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __('If your Edit View tabs are ugly, enable this setting.', 'gravityview'), |
|
658 | + 'description' => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __( 'If your Edit View tabs are ugly, enable this setting.', 'gravityview' ), |
|
659 | 659 | ), |
660 | 660 | array( |
661 | 661 | 'name' => 'delete-on-uninstall', |
662 | 662 | 'type' => 'radio', |
663 | 663 | 'label' => __( 'Remove Data on Delete?', 'gravityview' ), |
664 | - 'default_value' => $default_settings['delete-on-uninstall'], |
|
664 | + 'default_value' => $default_settings[ 'delete-on-uninstall' ], |
|
665 | 665 | 'horizontal' => 1, |
666 | 666 | 'choices' => array( |
667 | 667 | array( |
@@ -687,20 +687,20 @@ discard block |
||
687 | 687 | * @since 1.7.4 |
688 | 688 | */ |
689 | 689 | foreach ( $fields as &$field ) { |
690 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : rgget('id', $field ); |
|
691 | - $field['label'] = isset( $field['label'] ) ? $field['label'] : rgget('title', $field ); |
|
692 | - $field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : rgget('default', $field ); |
|
693 | - $field['description'] = isset( $field['description'] ) ? $field['description'] : rgget('subtitle', $field ); |
|
690 | + $field[ 'name' ] = isset( $field[ 'name' ] ) ? $field[ 'name' ] : rgget( 'id', $field ); |
|
691 | + $field[ 'label' ] = isset( $field[ 'label' ] ) ? $field[ 'label' ] : rgget( 'title', $field ); |
|
692 | + $field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : rgget( 'default', $field ); |
|
693 | + $field[ 'description' ] = isset( $field[ 'description' ] ) ? $field[ 'description' ] : rgget( 'subtitle', $field ); |
|
694 | 694 | |
695 | - if( $disabled_attribute ) { |
|
696 | - $field['disabled'] = $disabled_attribute; |
|
695 | + if ( $disabled_attribute ) { |
|
696 | + $field[ 'disabled' ] = $disabled_attribute; |
|
697 | 697 | } |
698 | 698 | } |
699 | 699 | |
700 | 700 | |
701 | 701 | $sections = array( |
702 | 702 | array( |
703 | - 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ), |
|
703 | + 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __( 'You are running GravityView version %s', 'gravityview' ), GravityView_Plugin::version ) ), |
|
704 | 704 | 'fields' => $fields, |
705 | 705 | ) |
706 | 706 | ); |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | 'type' => 'save', |
712 | 712 | ); |
713 | 713 | |
714 | - if( $disabled_attribute ) { |
|
715 | - $button['disabled'] = $disabled_attribute; |
|
714 | + if ( $disabled_attribute ) { |
|
715 | + $button[ 'disabled' ] = $disabled_attribute; |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | |
@@ -732,20 +732,20 @@ discard block |
||
732 | 732 | // If there are extensions, add a section for them |
733 | 733 | if ( ! empty( $extension_sections ) ) { |
734 | 734 | |
735 | - if( $disabled_attribute ) { |
|
735 | + if ( $disabled_attribute ) { |
|
736 | 736 | foreach ( $extension_sections as &$section ) { |
737 | - foreach ( $section['fields'] as &$field ) { |
|
738 | - $field['disabled'] = $disabled_attribute; |
|
737 | + foreach ( $section[ 'fields' ] as &$field ) { |
|
738 | + $field[ 'disabled' ] = $disabled_attribute; |
|
739 | 739 | } |
740 | 740 | } |
741 | 741 | } |
742 | 742 | |
743 | - $k = count( $extension_sections ) - 1 ; |
|
744 | - $extension_sections[ $k ]['fields'][] = $button; |
|
743 | + $k = count( $extension_sections ) - 1; |
|
744 | + $extension_sections[ $k ][ 'fields' ][ ] = $button; |
|
745 | 745 | $sections = array_merge( $sections, $extension_sections ); |
746 | 746 | } else { |
747 | 747 | // add the 'update settings' button to the general section |
748 | - $sections[0]['fields'][] = $button; |
|
748 | + $sections[ 0 ][ 'fields' ][ ] = $button; |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | return $sections; |