@@ -262,6 +262,8 @@ |
||
262 | 262 | /** |
263 | 263 | * Process the attributes passed to the shortcode. Make sure they're valid |
264 | 264 | * |
265 | + * @param string $content |
|
266 | + * @param string $tag |
|
265 | 267 | * @return array Array of attributes parsed for the shortcode |
266 | 268 | */ |
267 | 269 | private function parse_atts( $atts, $content, $tag ) { |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | $value = $this->get_value( $atts ); |
59 | 59 | |
60 | 60 | if ( false === $operator && is_null( $value ) ) { |
61 | - if ( false !== $atts['if'] ) { // Only-if test |
|
62 | - $match = $authed && ! in_array( strtolower( $atts['if'] ), array( '', '0', 'false', 'no' ) ); |
|
61 | + if ( false !== $atts[ 'if' ] ) { // Only-if test |
|
62 | + $match = $authed && ! in_array( strtolower( $atts[ 'if' ] ), array( '', '0', 'false', 'no' ) ); |
|
63 | 63 | } else { |
64 | 64 | $match = $authed; // Just login test |
65 | 65 | } |
66 | 66 | } else { // Regular test |
67 | - $match = $authed && \GVCommon::matches_operation( $atts['if'], $value, $operator ); |
|
67 | + $match = $authed && \GVCommon::matches_operation( $atts[ 'if' ], $value, $operator ); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $output = $this->get_output( $match, $atts, $content ); |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @return string The output. |
151 | 151 | */ |
152 | 152 | private function get_output( $match, $atts, $content ) { |
153 | - if ( ! $match && ! empty( $atts['else'] ) ) { |
|
154 | - return $atts['else']; // Attributized else is easy :) |
|
153 | + if ( ! $match && ! empty( $atts[ 'else' ] ) ) { |
|
154 | + return $atts[ 'else' ]; // Attributized else is easy :) |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | $if = ''; |
@@ -278,18 +278,18 @@ discard block |
||
278 | 278 | $atts = array_intersect_key( $supplied_atts, $atts ); |
279 | 279 | |
280 | 280 | // Strip whitespace if it's not default false |
281 | - if ( isset( $atts['if'] ) && is_string( $atts['if'] ) ) { |
|
282 | - $atts['if'] = trim( $atts['if'] ); |
|
281 | + if ( isset( $atts[ 'if' ] ) && is_string( $atts[ 'if' ] ) ) { |
|
282 | + $atts[ 'if' ] = trim( $atts[ 'if' ] ); |
|
283 | 283 | } else { |
284 | - $atts['if'] = false; |
|
284 | + $atts[ 'if' ] = false; |
|
285 | 285 | } |
286 | 286 | |
287 | - if ( isset( $atts['logged_in'] ) ) { |
|
287 | + if ( isset( $atts[ 'logged_in' ] ) ) { |
|
288 | 288 | // Truthy |
289 | - if ( in_array( strtolower( $atts['logged_in'] ), array( '0', 'false', 'no' ) ) ) { |
|
290 | - $atts['logged_in'] = false; |
|
289 | + if ( in_array( strtolower( $atts[ 'logged_in' ] ), array( '0', 'false', 'no' ) ) ) { |
|
290 | + $atts[ 'logged_in' ] = false; |
|
291 | 291 | } else { |
292 | - $atts['logged_in'] = true; |
|
292 | + $atts[ 'logged_in' ] = true; |
|
293 | 293 | } |
294 | 294 | } |
295 | 295 |
@@ -58,12 +58,14 @@ discard block |
||
58 | 58 | $value = $this->get_value( $atts ); |
59 | 59 | |
60 | 60 | if ( false === $operator && is_null( $value ) ) { |
61 | - if ( false !== $atts['if'] ) { // Only-if test |
|
61 | + if ( false !== $atts['if'] ) { |
|
62 | +// Only-if test |
|
62 | 63 | $match = $authed && ! in_array( strtolower( $atts['if'] ), array( '', '0', 'false', 'no' ) ); |
63 | 64 | } else { |
64 | 65 | $match = $authed; // Just login test |
65 | 66 | } |
66 | - } else { // Regular test |
|
67 | + } else { |
|
68 | +// Regular test |
|
67 | 69 | $match = $authed && \GVCommon::matches_operation( $atts['if'], $value, $operator ); |
68 | 70 | } |
69 | 71 | |
@@ -160,12 +162,15 @@ discard block |
||
160 | 162 | $opens = 0; // inner opens |
161 | 163 | $found = false; // found split position |
162 | 164 | |
163 | - while ( $content ) { // scan |
|
165 | + while ( $content ) { |
|
166 | +// scan |
|
164 | 167 | |
165 | 168 | if ( ! preg_match( '#(.*?)(\[\/?(gvlogic|else).*?])(.*)#s', $content, $matches ) ) { |
166 | - if ( ! $found ) { // We're still iffing. |
|
169 | + if ( ! $found ) { |
|
170 | +// We're still iffing. |
|
167 | 171 | $if .= $content; |
168 | - } else { // We are elsing |
|
172 | + } else { |
|
173 | +// We are elsing |
|
169 | 174 | $else .= $content; |
170 | 175 | } |
171 | 176 | break; // No more shortcodes |
@@ -173,9 +178,11 @@ discard block |
||
173 | 178 | |
174 | 179 | list( $_, $before_shortcode, $shortcode, $_, $after_shortcode ) = $matches; |
175 | 180 | |
176 | - if ( ! $found ) { // We're still iffing. |
|
181 | + if ( ! $found ) { |
|
182 | +// We're still iffing. |
|
177 | 183 | $if .= $before_shortcode; |
178 | - } else { // We are elsing |
|
184 | + } else { |
|
185 | +// We are elsing |
|
179 | 186 | $else .= $before_shortcode; |
180 | 187 | } |
181 | 188 | |
@@ -199,9 +206,11 @@ discard block |
||
199 | 206 | } |
200 | 207 | |
201 | 208 | // Tack on the shortcode |
202 | - if ( ! $found ) { // We're still iffing. |
|
209 | + if ( ! $found ) { |
|
210 | +// We're still iffing. |
|
203 | 211 | $if .= $shortcode; |
204 | - } else { // We are elsing |
|
212 | + } else { |
|
213 | +// We are elsing |
|
205 | 214 | $else .= $shortcode; |
206 | 215 | } |
207 | 216 | } |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | private function add_hooks() { |
40 | 40 | |
41 | 41 | // in case entry is edited (on admin or frontend) |
42 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
42 | + add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 ); |
|
43 | 43 | |
44 | 44 | // when using the User opt-in field, check on entry submission |
45 | 45 | add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 ); |
46 | 46 | |
47 | 47 | // process ajax approve entry requests |
48 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
48 | + add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) ); |
|
49 | 49 | |
50 | 50 | // autounapprove |
51 | 51 | add_action( 'gravityview/edit_entry/after_update', array( __CLASS__, 'autounapprove' ), 10, 4 ); |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | return; |
95 | 95 | } |
96 | 96 | |
97 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
97 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
98 | 98 | |
99 | 99 | if ( ! $form ) { |
100 | - gravityview()->log->error( 'Form not found at ID #{form_id} for entry #{entry_id}', array( 'form_id' => $entry['form_id'], 'entry_id' => $entry_id ) ); |
|
100 | + gravityview()->log->error( 'Form not found at ID #{form_id} for entry #{entry_id}', array( 'form_id' => $entry[ 'form_id' ], 'entry_id' => $entry_id ) ); |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public static function add_approval_notification_events( $notification_events = array(), $form = array() ) { |
116 | 116 | |
117 | - $notification_events['gravityview/approve_entries/approved'] = 'GravityView - ' . esc_html_x( 'Entry is approved', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
118 | - $notification_events['gravityview/approve_entries/disapproved'] = 'GravityView - ' . esc_html_x( 'Entry is disapproved', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
119 | - $notification_events['gravityview/approve_entries/unapproved'] = 'GravityView - ' . esc_html_x( 'Entry approval is reset', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
120 | - $notification_events['gravityview/approve_entries/updated'] = 'GravityView - ' . esc_html_x( 'Entry approval is changed', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
117 | + $notification_events[ 'gravityview/approve_entries/approved' ] = 'GravityView - ' . esc_html_x( 'Entry is approved', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
118 | + $notification_events[ 'gravityview/approve_entries/disapproved' ] = 'GravityView - ' . esc_html_x( 'Entry is disapproved', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
119 | + $notification_events[ 'gravityview/approve_entries/unapproved' ] = 'GravityView - ' . esc_html_x( 'Entry approval is reset', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
120 | + $notification_events[ 'gravityview/approve_entries/updated' ] = 'GravityView - ' . esc_html_x( 'Entry approval is changed', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
121 | 121 | |
122 | 122 | return $notification_events; |
123 | 123 | } |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public static function get_entry_status( $entry, $value_or_label = 'label' ) { |
137 | 137 | |
138 | - $entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry, true ); |
|
138 | + $entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry, true ); |
|
139 | 139 | |
140 | 140 | $status = gform_get_meta( $entry_id, self::meta_key ); |
141 | 141 | |
142 | 142 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
143 | 143 | |
144 | - if( 'value' === $value_or_label ) { |
|
144 | + if ( 'value' === $value_or_label ) { |
|
145 | 145 | return $status; |
146 | 146 | } |
147 | 147 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $nonce = \GV\Utils::_POST( 'nonce' ); |
180 | 180 | |
181 | 181 | // Valid status |
182 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
182 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
183 | 183 | |
184 | 184 | gravityview()->log->error( 'Invalid approval status', array( 'data' => $_POST ) ); |
185 | 185 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
212 | 212 | |
213 | - $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') ); |
|
213 | + $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) ); |
|
214 | 214 | |
215 | 215 | } |
216 | 216 | |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | // Set default |
275 | - self::update_approved_meta( $entry['id'], $default_status, $entry['form_id'] ); |
|
275 | + self::update_approved_meta( $entry[ 'id' ], $default_status, $entry[ 'form_id' ] ); |
|
276 | 276 | |
277 | 277 | // Then check for if there is an approval column, and use that value instead |
278 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
278 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -289,12 +289,12 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
291 | 291 | |
292 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
292 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
293 | 293 | |
294 | 294 | /** |
295 | 295 | * If the form doesn't contain the approve field, don't assume anything. |
296 | 296 | */ |
297 | - if( empty( $approved_column ) ) { |
|
297 | + if ( empty( $approved_column ) ) { |
|
298 | 298 | return; |
299 | 299 | } |
300 | 300 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | */ |
317 | 317 | $value = apply_filters( 'gravityview/approve_entries/update_unapproved_meta', $value, $form, $entry ); |
318 | 318 | |
319 | - self::update_approved_meta( $entry_id, $value, $form['id'] ); |
|
319 | + self::update_approved_meta( $entry_id, $value, $form[ 'id' ] ); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -334,12 +334,12 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public static function update_bulk( $entries = array(), $approved = 0, $form_id = 0 ) { |
336 | 336 | |
337 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
337 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
338 | 338 | gravityview()->log->error( 'Entries were empty or malformed.', array( 'data' => $entries ) ); |
339 | 339 | return NULL; |
340 | 340 | } |
341 | 341 | |
342 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
342 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
343 | 343 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
344 | 344 | return NULL; |
345 | 345 | } |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | $approved_column_id = self::get_approved_column( $form_id ); |
355 | 355 | |
356 | 356 | $success = true; |
357 | - foreach( $entries as $entry_id ) { |
|
357 | + foreach ( $entries as $entry_id ) { |
|
358 | 358 | $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
359 | 359 | |
360 | - if( ! $update_success ) { |
|
360 | + if ( ! $update_success ) { |
|
361 | 361 | $success = false; |
362 | 362 | } |
363 | 363 | } |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | */ |
382 | 382 | public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) { |
383 | 383 | |
384 | - if( !class_exists( 'GFAPI' ) ) { |
|
384 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
385 | 385 | gravityview()->log->error( 'GFAPI does not exist' ); |
386 | 386 | return false; |
387 | 387 | } |
388 | 388 | |
389 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
389 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
390 | 390 | gravityview()->log->error( 'Not a valid approval value.' ); |
391 | 391 | return false; |
392 | 392 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | // If the form has an Approve/Reject field, update that value |
404 | 404 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
405 | 405 | |
406 | - if( is_wp_error( $result ) ) { |
|
406 | + if ( is_wp_error( $result ) ) { |
|
407 | 407 | gravityview()->log->error( 'Entry approval not updated: {error}', array( 'error' => $result->get_error_message() ) ); |
408 | 408 | return false; |
409 | 409 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | |
416 | 416 | // add note to entry if approval field updating worked or there was no approved field |
417 | 417 | // There's no validation for the meta |
418 | - if( true === $result ) { |
|
418 | + if ( true === $result ) { |
|
419 | 419 | |
420 | 420 | // Add an entry note |
421 | 421 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | |
469 | 469 | $note_id = false; |
470 | 470 | |
471 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
471 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
472 | 472 | |
473 | 473 | $current_user = wp_get_current_user(); |
474 | 474 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | */ |
491 | 491 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
492 | 492 | |
493 | - if( empty( $approvedcolumn ) ) { |
|
493 | + if ( empty( $approvedcolumn ) ) { |
|
494 | 494 | $approvedcolumn = self::get_approved_column( $form_id ); |
495 | 495 | } |
496 | 496 | |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
514 | 514 | |
515 | 515 | $new_value = ''; |
516 | - if( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
516 | + if ( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
517 | 517 | $new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn ); |
518 | 518 | } |
519 | 519 | |
520 | 520 | //update entry |
521 | - $entry["{$approvedcolumn}"] = $new_value; |
|
521 | + $entry[ "{$approvedcolumn}" ] = $new_value; |
|
522 | 522 | |
523 | 523 | /** |
524 | 524 | * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves |
@@ -549,12 +549,12 @@ discard block |
||
549 | 549 | // If the user has enabled a different value than the label (for some reason), use it. |
550 | 550 | // This is highly unlikely |
551 | 551 | if ( is_array( $field->choices ) && ! empty( $field->choices ) ) { |
552 | - return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text']; |
|
552 | + return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ]; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | // Otherwise, fall back on the inputs array |
556 | 556 | if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) { |
557 | - return $field->inputs[0]['label']; |
|
557 | + return $field->inputs[ 0 ][ 'label' ]; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | return null; |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | * @since 1.18 Added "unapproved" |
607 | 607 | * @param int $entry_id ID of the Gravity Forms entry |
608 | 608 | */ |
609 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
609 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -619,11 +619,11 @@ discard block |
||
619 | 619 | */ |
620 | 620 | static public function get_approved_column( $form ) { |
621 | 621 | |
622 | - if( empty( $form ) ) { |
|
622 | + if ( empty( $form ) ) { |
|
623 | 623 | return null; |
624 | 624 | } |
625 | 625 | |
626 | - if( !is_array( $form ) ) { |
|
626 | + if ( ! is_array( $form ) ) { |
|
627 | 627 | $form = GVCommon::get_form( $form ); |
628 | 628 | } |
629 | 629 | |
@@ -633,22 +633,22 @@ discard block |
||
633 | 633 | * @var string $key |
634 | 634 | * @var GF_Field $field |
635 | 635 | */ |
636 | - foreach( $form['fields'] as $key => $field ) { |
|
636 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
637 | 637 | |
638 | 638 | $inputs = $field->get_entry_inputs(); |
639 | 639 | |
640 | - if( !empty( $field->gravityview_approved ) ) { |
|
641 | - if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) { |
|
642 | - $approved_column_id = $inputs[0]['id']; |
|
640 | + if ( ! empty( $field->gravityview_approved ) ) { |
|
641 | + if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) { |
|
642 | + $approved_column_id = $inputs[ 0 ][ 'id' ]; |
|
643 | 643 | break; |
644 | 644 | } |
645 | 645 | } |
646 | 646 | |
647 | 647 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
648 | - if( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
648 | + if ( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
649 | 649 | foreach ( $inputs as $input ) { |
650 | - if ( 'approved' === strtolower( $input['label'] ) ) { |
|
651 | - $approved_column_id = $input['id']; |
|
650 | + if ( 'approved' === strtolower( $input[ 'label' ] ) ) { |
|
651 | + $approved_column_id = $input[ 'id' ]; |
|
652 | 652 | break; |
653 | 653 | } |
654 | 654 | } |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | |
675 | 675 | $view_keys = array_keys( $gv_data->get_views() ); |
676 | 676 | |
677 | - $view = \GV\View::by_id( $view_keys[0] ); |
|
677 | + $view = \GV\View::by_id( $view_keys[ 0 ] ); |
|
678 | 678 | |
679 | 679 | if ( ! $view->settings->get( 'unapprove_edit' ) ) { |
680 | 680 | return; |
@@ -699,11 +699,11 @@ discard block |
||
699 | 699 | return; |
700 | 700 | } |
701 | 701 | |
702 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
702 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
703 | 703 | $approval_status = GravityView_Entry_Approval_Status::UNAPPROVED; |
704 | 704 | } |
705 | 705 | |
706 | - self::update_approved_meta( $entry_id, $approval_status, $form['id'] ); |
|
706 | + self::update_approved_meta( $entry_id, $approval_status, $form[ 'id' ] ); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -741,9 +741,9 @@ discard block |
||
741 | 741 | $choices = GravityView_Entry_Approval_Status::get_all(); |
742 | 742 | |
743 | 743 | return <<<TEMPLATE |
744 | -<a href="#" data-approved="{$choices['approved']['value']}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-approved popover" title="{$choices['approved']['action']}"><span class="screen-reader-text">{$choices['approved']['action']}</span></a> |
|
745 | -<a href="#" data-approved="{$choices['disapproved']['value']}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-disapproved popover" title="{$choices['disapproved']['action']}"><span class="screen-reader-text">{$choices['disapproved']['action']}</span></a> |
|
746 | -<a href="#" data-approved="{$choices['unapproved']['value']}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-unapproved popover" title="{$choices['unapproved']['action']}"><span class="screen-reader-text">{$choices['unapproved']['action']}</span></a> |
|
744 | +<a href="#" data-approved="{$choices[ 'approved' ][ 'value' ]}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-approved popover" title="{$choices[ 'approved' ][ 'action' ]}"><span class="screen-reader-text">{$choices[ 'approved' ][ 'action' ]}</span></a> |
|
745 | +<a href="#" data-approved="{$choices[ 'disapproved' ][ 'value' ]}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-disapproved popover" title="{$choices[ 'disapproved' ][ 'action' ]}"><span class="screen-reader-text">{$choices[ 'disapproved' ][ 'action' ]}</span></a> |
|
746 | +<a href="#" data-approved="{$choices[ 'unapproved' ][ 'value' ]}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-unapproved popover" title="{$choices[ 'unapproved' ][ 'action' ]}"><span class="screen-reader-text">{$choices[ 'unapproved' ][ 'action' ]}</span></a> |
|
747 | 747 | TEMPLATE; |
748 | 748 | } |
749 | 749 | } |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | |
103 | 103 | /** |
104 | 104 | * ID of the current post. May also be ID of the current View. |
105 | - * |
|
106 | - * @since 2.0.13 |
|
107 | 105 | * |
108 | - * @var int |
|
106 | + * @since 2.0.13 |
|
107 | + * |
|
108 | + * @var int |
|
109 | 109 | */ |
110 | 110 | public $post_id; |
111 | 111 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function prevent_maybe_process_form() { |
190 | 190 | |
191 | - if( ! $this->is_edit_entry_submission() ) { |
|
191 | + if( ! $this->is_edit_entry_submission() ) { |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | |
@@ -222,14 +222,14 @@ discard block |
||
222 | 222 | * When Edit entry view is requested setup the vars |
223 | 223 | */ |
224 | 224 | private function setup_vars() { |
225 | - global $post; |
|
225 | + global $post; |
|
226 | 226 | |
227 | 227 | $gravityview_view = GravityView_View::getInstance(); |
228 | 228 | |
229 | 229 | |
230 | 230 | $entries = $gravityview_view->getEntries(); |
231 | - self::$original_entry = $entries[0]; |
|
232 | - $this->entry = $entries[0]; |
|
231 | + self::$original_entry = $entries[0]; |
|
232 | + $this->entry = $entries[0]; |
|
233 | 233 | |
234 | 234 | self::$original_form = $gravityview_view->getForm(); |
235 | 235 | $this->form = $gravityview_view->getForm(); |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | |
372 | 372 | GFFormsModel::save_lead( $form, $this->entry ); |
373 | 373 | |
374 | - // Delete the values for hidden inputs |
|
375 | - $this->unset_hidden_field_values(); |
|
374 | + // Delete the values for hidden inputs |
|
375 | + $this->unset_hidden_field_values(); |
|
376 | 376 | |
377 | 377 | $this->entry['date_created'] = $date_created; |
378 | 378 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | // Perform actions normally performed after updating a lead |
386 | 386 | $this->after_update(); |
387 | 387 | |
388 | - /** |
|
388 | + /** |
|
389 | 389 | * Must be AFTER after_update()! |
390 | 390 | * @see https://github.com/gravityview/GravityView/issues/764 |
391 | 391 | */ |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /** |
395 | 395 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
396 | - * @since 2.1 Added $gv_data parameter |
|
396 | + * @since 2.1 Added $gv_data parameter |
|
397 | 397 | * @param array $form Gravity Forms form array |
398 | 398 | * @param string $entry_id Numeric ID of the entry that was updated |
399 | 399 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @return void |
418 | 418 | */ |
419 | 419 | private function unset_hidden_field_values() { |
420 | - global $wpdb; |
|
420 | + global $wpdb; |
|
421 | 421 | |
422 | 422 | /** |
423 | 423 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
442 | 442 | } |
443 | 443 | |
444 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
444 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
445 | 445 | |
446 | 446 | if ( ! is_numeric( $input_id ) ) { |
447 | 447 | continue; |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | continue; |
452 | 452 | } |
453 | 453 | |
454 | - // Reset fields that are or would be hidden |
|
455 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
454 | + // Reset fields that are or would be hidden |
|
455 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
456 | 456 | |
457 | 457 | $empty_value = $field->get_value_save_entry( |
458 | 458 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -464,16 +464,16 @@ discard block |
||
464 | 464 | $empty_value = ''; |
465 | 465 | } |
466 | 466 | |
467 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
467 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
468 | 468 | |
469 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
469 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
470 | 470 | |
471 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
471 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
472 | 472 | // after submission |
473 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
474 | - $_POST[ $post_input_id ] = ''; |
|
475 | - } |
|
476 | - } |
|
473 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
474 | + $_POST[ $post_input_id ] = ''; |
|
475 | + } |
|
476 | + } |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | |
629 | 629 | $form = $this->filter_conditional_logic( $this->form ); |
630 | 630 | |
631 | - /** @var GF_Field $field */ |
|
631 | + /** @var GF_Field $field */ |
|
632 | 632 | foreach( $form['fields'] as $k => &$field ) { |
633 | 633 | |
634 | 634 | /** |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
646 | 646 | foreach( $field->inputs as $key => $input ) { |
647 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
647 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | } |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | |
685 | 685 | $inputs = $field->get_entry_inputs(); |
686 | 686 | if ( is_array( $inputs ) ) { |
687 | - foreach ( $inputs as $input ) { |
|
687 | + foreach ( $inputs as $input ) { |
|
688 | 688 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
689 | 689 | |
690 | 690 | if ( 'product' === $field->type ) { |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | } |
704 | 704 | |
705 | 705 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
706 | - } |
|
706 | + } |
|
707 | 707 | } else { |
708 | 708 | // Set to what it previously was if it's not editable |
709 | 709 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
750 | 750 | |
751 | 751 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
752 | - $ary = stripslashes_deep( $ary ); |
|
752 | + $ary = stripslashes_deep( $ary ); |
|
753 | 753 | $img_url = \GV\Utils::get( $ary, 0 ); |
754 | 754 | |
755 | 755 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | private function maybe_update_post_fields( $form ) { |
823 | 823 | |
824 | 824 | if( empty( $this->entry['post_id'] ) ) { |
825 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
825 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
826 | 826 | return; |
827 | 827 | } |
828 | 828 | |
@@ -857,49 +857,49 @@ discard block |
||
857 | 857 | |
858 | 858 | switch( $field->type ) { |
859 | 859 | |
860 | - case 'post_title': |
|
861 | - $post_title = $value; |
|
862 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
863 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
864 | - } |
|
865 | - $updated_post->post_title = $post_title; |
|
866 | - $updated_post->post_name = $post_title; |
|
867 | - unset( $post_title ); |
|
868 | - break; |
|
869 | - |
|
870 | - case 'post_content': |
|
871 | - $post_content = $value; |
|
872 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
873 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
874 | - } |
|
875 | - $updated_post->post_content = $post_content; |
|
876 | - unset( $post_content ); |
|
877 | - break; |
|
878 | - case 'post_excerpt': |
|
879 | - $updated_post->post_excerpt = $value; |
|
880 | - break; |
|
881 | - case 'post_tags': |
|
882 | - wp_set_post_tags( $post_id, $value, false ); |
|
883 | - break; |
|
884 | - case 'post_category': |
|
885 | - break; |
|
886 | - case 'post_custom_field': |
|
860 | + case 'post_title': |
|
861 | + $post_title = $value; |
|
862 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
863 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
864 | + } |
|
865 | + $updated_post->post_title = $post_title; |
|
866 | + $updated_post->post_name = $post_title; |
|
867 | + unset( $post_title ); |
|
868 | + break; |
|
869 | + |
|
870 | + case 'post_content': |
|
871 | + $post_content = $value; |
|
872 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
873 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
874 | + } |
|
875 | + $updated_post->post_content = $post_content; |
|
876 | + unset( $post_content ); |
|
877 | + break; |
|
878 | + case 'post_excerpt': |
|
879 | + $updated_post->post_excerpt = $value; |
|
880 | + break; |
|
881 | + case 'post_tags': |
|
882 | + wp_set_post_tags( $post_id, $value, false ); |
|
883 | + break; |
|
884 | + case 'post_category': |
|
885 | + break; |
|
886 | + case 'post_custom_field': |
|
887 | 887 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
888 | 888 | $value = $value[ $field_id ]; |
889 | 889 | } |
890 | 890 | |
891 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
892 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
893 | - } |
|
891 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
892 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
893 | + } |
|
894 | 894 | |
895 | 895 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
896 | 896 | |
897 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
898 | - break; |
|
897 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
898 | + break; |
|
899 | 899 | |
900 | - case 'post_image': |
|
901 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
902 | - break; |
|
900 | + case 'post_image': |
|
901 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
902 | + break; |
|
903 | 903 | |
904 | 904 | } |
905 | 905 | |
@@ -1063,14 +1063,14 @@ discard block |
||
1063 | 1063 | ?><h2 class="gv-edit-entry-title"> |
1064 | 1064 | <span><?php |
1065 | 1065 | |
1066 | - /** |
|
1067 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
1068 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
1069 | - * @param GravityView_Edit_Entry_Render $this This object |
|
1070 | - */ |
|
1071 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1066 | + /** |
|
1067 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
1068 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
1069 | + * @param GravityView_Edit_Entry_Render $this This object |
|
1070 | + */ |
|
1071 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1072 | 1072 | |
1073 | - echo esc_attr( $edit_entry_title ); |
|
1073 | + echo esc_attr( $edit_entry_title ); |
|
1074 | 1074 | ?></span> |
1075 | 1075 | </h2> |
1076 | 1076 | |
@@ -1125,13 +1125,13 @@ discard block |
||
1125 | 1125 | ); |
1126 | 1126 | |
1127 | 1127 | /** |
1128 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1129 | - * @since 1.16.3 |
|
1130 | - * @param array $labels Default button labels associative array |
|
1131 | - * @param array $form The Gravity Forms form |
|
1132 | - * @param array $entry The Gravity Forms entry |
|
1133 | - * @param int $view_id The current View ID |
|
1134 | - */ |
|
1128 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1129 | + * @since 1.16.3 |
|
1130 | + * @param array $labels Default button labels associative array |
|
1131 | + * @param array $form The Gravity Forms form |
|
1132 | + * @param array $entry The Gravity Forms entry |
|
1133 | + * @param int $view_id The current View ID |
|
1134 | + */ |
|
1135 | 1135 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1136 | 1136 | |
1137 | 1137 | $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
@@ -1168,26 +1168,26 @@ discard block |
||
1168 | 1168 | |
1169 | 1169 | switch ( $edit_redirect ) { |
1170 | 1170 | |
1171 | - case '0': |
|
1172 | - $redirect_url = $back_link; |
|
1173 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1174 | - break; |
|
1175 | - |
|
1176 | - case '1': |
|
1177 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1178 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1179 | - break; |
|
1180 | - |
|
1181 | - case '2': |
|
1182 | - $redirect_url = $edit_redirect_url; |
|
1183 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1184 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1185 | - break; |
|
1186 | - |
|
1187 | - case '': |
|
1188 | - default: |
|
1189 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1190 | - break; |
|
1171 | + case '0': |
|
1172 | + $redirect_url = $back_link; |
|
1173 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1174 | + break; |
|
1175 | + |
|
1176 | + case '1': |
|
1177 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1178 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1179 | + break; |
|
1180 | + |
|
1181 | + case '2': |
|
1182 | + $redirect_url = $edit_redirect_url; |
|
1183 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1184 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1185 | + break; |
|
1186 | + |
|
1187 | + case '': |
|
1188 | + default: |
|
1189 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1190 | + break; |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | if ( isset( $redirect_url ) ) { |
@@ -1253,13 +1253,13 @@ discard block |
||
1253 | 1253 | ); |
1254 | 1254 | |
1255 | 1255 | /** |
1256 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1257 | - * @since 1.16.3 |
|
1258 | - * @param array $labels Default button labels associative array |
|
1259 | - * @param array $form The Gravity Forms form |
|
1260 | - * @param array $entry The Gravity Forms entry |
|
1261 | - * @param int $view_id The current View ID |
|
1262 | - */ |
|
1256 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1257 | + * @since 1.16.3 |
|
1258 | + * @param array $labels Default button labels associative array |
|
1259 | + * @param array $form The Gravity Forms form |
|
1260 | + * @param array $entry The Gravity Forms entry |
|
1261 | + * @param int $view_id The current View ID |
|
1262 | + */ |
|
1263 | 1263 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1264 | 1264 | |
1265 | 1265 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1305,7 +1305,7 @@ discard block |
||
1305 | 1305 | |
1306 | 1306 | ob_get_clean(); |
1307 | 1307 | |
1308 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1308 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1309 | 1309 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1310 | 1310 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1311 | 1311 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1365,7 +1365,7 @@ discard block |
||
1365 | 1365 | |
1366 | 1366 | // for now we don't support Save and Continue feature. |
1367 | 1367 | if( ! self::$supports_save_and_continue ) { |
1368 | - unset( $form['save'] ); |
|
1368 | + unset( $form['save'] ); |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | $form = $this->unselect_default_values( $form ); |
@@ -1392,30 +1392,30 @@ discard block |
||
1392 | 1392 | return $field_content; |
1393 | 1393 | } |
1394 | 1394 | |
1395 | - $message = null; |
|
1395 | + $message = null; |
|
1396 | 1396 | |
1397 | - // First, make sure they have the capability to edit the post. |
|
1398 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1397 | + // First, make sure they have the capability to edit the post. |
|
1398 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1399 | 1399 | |
1400 | - /** |
|
1401 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1402 | - * @param string $message The existing "You don't have permission..." text |
|
1403 | - */ |
|
1404 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1400 | + /** |
|
1401 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1402 | + * @param string $message The existing "You don't have permission..." text |
|
1403 | + */ |
|
1404 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1405 | 1405 | |
1406 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1407 | - /** |
|
1408 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1409 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1410 | - */ |
|
1411 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1412 | - } |
|
1406 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1407 | + /** |
|
1408 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1409 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1410 | + */ |
|
1411 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1412 | + } |
|
1413 | 1413 | |
1414 | - if( $message ) { |
|
1415 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1416 | - } |
|
1414 | + if( $message ) { |
|
1415 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1416 | + } |
|
1417 | 1417 | |
1418 | - return $field_content; |
|
1418 | + return $field_content; |
|
1419 | 1419 | } |
1420 | 1420 | |
1421 | 1421 | /** |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | || ! empty( $field_content ) |
1444 | 1444 | || in_array( $field->type, array( 'honeypot' ) ) |
1445 | 1445 | ) { |
1446 | - return $field_content; |
|
1446 | + return $field_content; |
|
1447 | 1447 | } |
1448 | 1448 | |
1449 | 1449 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1451,24 +1451,24 @@ discard block |
||
1451 | 1451 | |
1452 | 1452 | $field_value = $this->get_field_value( $field ); |
1453 | 1453 | |
1454 | - // Prevent any PHP warnings, like undefined index |
|
1455 | - ob_start(); |
|
1454 | + // Prevent any PHP warnings, like undefined index |
|
1455 | + ob_start(); |
|
1456 | 1456 | |
1457 | - $return = null; |
|
1457 | + $return = null; |
|
1458 | 1458 | |
1459 | 1459 | /** @var GravityView_Field $gv_field */ |
1460 | 1460 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1461 | 1461 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1462 | 1462 | } else { |
1463 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1464 | - } |
|
1463 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1464 | + } |
|
1465 | 1465 | |
1466 | - // If there was output, it's an error |
|
1467 | - $warnings = ob_get_clean(); |
|
1466 | + // If there was output, it's an error |
|
1467 | + $warnings = ob_get_clean(); |
|
1468 | 1468 | |
1469 | - if( !empty( $warnings ) ) { |
|
1470 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1471 | - } |
|
1469 | + if( !empty( $warnings ) ) { |
|
1470 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1471 | + } |
|
1472 | 1472 | |
1473 | 1473 | return $return; |
1474 | 1474 | } |
@@ -1503,8 +1503,8 @@ discard block |
||
1503 | 1503 | $input_id = strval( $input['id'] ); |
1504 | 1504 | |
1505 | 1505 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1506 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1507 | - $allow_pre_populated = false; |
|
1506 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1507 | + $allow_pre_populated = false; |
|
1508 | 1508 | } |
1509 | 1509 | |
1510 | 1510 | } |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1529 | 1529 | $categories = array(); |
1530 | 1530 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1531 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1531 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1532 | 1532 | } |
1533 | 1533 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1534 | 1534 | } |
@@ -1538,25 +1538,25 @@ discard block |
||
1538 | 1538 | // if value is empty get the default value if defined |
1539 | 1539 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1540 | 1540 | |
1541 | - /** |
|
1542 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1543 | - * @since 1.11 |
|
1544 | - * @since 1.20 Added third param |
|
1545 | - * @param mixed $field_value field value used to populate the input |
|
1546 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1547 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1548 | - */ |
|
1549 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1550 | - |
|
1551 | - /** |
|
1552 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1553 | - * @since 1.17 |
|
1554 | - * @since 1.20 Added third param |
|
1555 | - * @param mixed $field_value field value used to populate the input |
|
1556 | - * @param GF_Field $field Gravity Forms field object |
|
1557 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1558 | - */ |
|
1559 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1541 | + /** |
|
1542 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1543 | + * @since 1.11 |
|
1544 | + * @since 1.20 Added third param |
|
1545 | + * @param mixed $field_value field value used to populate the input |
|
1546 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1547 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1548 | + */ |
|
1549 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1550 | + |
|
1551 | + /** |
|
1552 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1553 | + * @since 1.17 |
|
1554 | + * @since 1.20 Added third param |
|
1555 | + * @param mixed $field_value field value used to populate the input |
|
1556 | + * @param GF_Field $field Gravity Forms field object |
|
1557 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1558 | + */ |
|
1559 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1560 | 1560 | |
1561 | 1561 | return $field_value; |
1562 | 1562 | } |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1584 | 1584 | // expects certain field array items to be set. |
1585 | 1585 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1586 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1586 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1597,61 +1597,61 @@ discard block |
||
1597 | 1597 | */ |
1598 | 1598 | case 'fileupload': |
1599 | 1599 | |
1600 | - // Set the previous value |
|
1601 | - $entry = $this->get_entry(); |
|
1600 | + // Set the previous value |
|
1601 | + $entry = $this->get_entry(); |
|
1602 | 1602 | |
1603 | - $input_name = 'input_'.$field->id; |
|
1604 | - $form_id = $form['id']; |
|
1603 | + $input_name = 'input_'.$field->id; |
|
1604 | + $form_id = $form['id']; |
|
1605 | 1605 | |
1606 | - $value = NULL; |
|
1606 | + $value = NULL; |
|
1607 | 1607 | |
1608 | - // Use the previous entry value as the default. |
|
1609 | - if( isset( $entry[ $field->id ] ) ) { |
|
1610 | - $value = $entry[ $field->id ]; |
|
1611 | - } |
|
1608 | + // Use the previous entry value as the default. |
|
1609 | + if( isset( $entry[ $field->id ] ) ) { |
|
1610 | + $value = $entry[ $field->id ]; |
|
1611 | + } |
|
1612 | 1612 | |
1613 | - // If this is a single upload file |
|
1614 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1615 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1616 | - $value = $file_path['url']; |
|
1613 | + // If this is a single upload file |
|
1614 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1615 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1616 | + $value = $file_path['url']; |
|
1617 | 1617 | |
1618 | - } else { |
|
1618 | + } else { |
|
1619 | 1619 | |
1620 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1621 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1622 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1620 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1621 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1622 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1623 | 1623 | |
1624 | - } |
|
1624 | + } |
|
1625 | 1625 | |
1626 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1626 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1627 | 1627 | |
1628 | - // If there are fresh uploads, process and merge them. |
|
1629 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1630 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1631 | - $value = empty( $value ) ? '[]' : $value; |
|
1632 | - $value = stripslashes_deep( $value ); |
|
1633 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1634 | - } |
|
1628 | + // If there are fresh uploads, process and merge them. |
|
1629 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1630 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1631 | + $value = empty( $value ) ? '[]' : $value; |
|
1632 | + $value = stripslashes_deep( $value ); |
|
1633 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1634 | + } |
|
1635 | 1635 | |
1636 | - } else { |
|
1636 | + } else { |
|
1637 | 1637 | |
1638 | - // A file already exists when editing an entry |
|
1639 | - // We set this to solve issue when file upload fields are required. |
|
1640 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1638 | + // A file already exists when editing an entry |
|
1639 | + // We set this to solve issue when file upload fields are required. |
|
1640 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1641 | 1641 | |
1642 | - } |
|
1642 | + } |
|
1643 | 1643 | |
1644 | - $this->entry[ $input_name ] = $value; |
|
1645 | - $_POST[ $input_name ] = $value; |
|
1644 | + $this->entry[ $input_name ] = $value; |
|
1645 | + $_POST[ $input_name ] = $value; |
|
1646 | 1646 | |
1647 | - break; |
|
1647 | + break; |
|
1648 | 1648 | |
1649 | 1649 | case 'number': |
1650 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1651 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1652 | - $_POST['input_'.$field->id ] = NULL; |
|
1653 | - } |
|
1654 | - break; |
|
1650 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1651 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1652 | + $_POST['input_'.$field->id ] = NULL; |
|
1653 | + } |
|
1654 | + break; |
|
1655 | 1655 | } |
1656 | 1656 | |
1657 | 1657 | } |
@@ -1736,43 +1736,43 @@ discard block |
||
1736 | 1736 | case 'fileupload' : |
1737 | 1737 | case 'post_image': |
1738 | 1738 | |
1739 | - // in case nothing is uploaded but there are already files saved |
|
1740 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1741 | - $field->failed_validation = false; |
|
1742 | - unset( $field->validation_message ); |
|
1743 | - } |
|
1739 | + // in case nothing is uploaded but there are already files saved |
|
1740 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1741 | + $field->failed_validation = false; |
|
1742 | + unset( $field->validation_message ); |
|
1743 | + } |
|
1744 | 1744 | |
1745 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1746 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1745 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1746 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1747 | 1747 | |
1748 | - $input_name = 'input_' . $field->id; |
|
1749 | - //uploaded |
|
1750 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1748 | + $input_name = 'input_' . $field->id; |
|
1749 | + //uploaded |
|
1750 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1751 | 1751 | |
1752 | - //existent |
|
1753 | - $entry = $this->get_entry(); |
|
1754 | - $value = NULL; |
|
1755 | - if( isset( $entry[ $field->id ] ) ) { |
|
1756 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1757 | - } |
|
1752 | + //existent |
|
1753 | + $entry = $this->get_entry(); |
|
1754 | + $value = NULL; |
|
1755 | + if( isset( $entry[ $field->id ] ) ) { |
|
1756 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1757 | + } |
|
1758 | 1758 | |
1759 | - // count uploaded files and existent entry files |
|
1760 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1761 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
1759 | + // count uploaded files and existent entry files |
|
1760 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1761 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
1762 | 1762 | |
1763 | - if( $count_files > $field->maxFiles ) { |
|
1764 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1765 | - $field->failed_validation = 1; |
|
1766 | - $gv_valid = false; |
|
1763 | + if( $count_files > $field->maxFiles ) { |
|
1764 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1765 | + $field->failed_validation = 1; |
|
1766 | + $gv_valid = false; |
|
1767 | 1767 | |
1768 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1769 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1770 | - } |
|
1768 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1769 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1770 | + } |
|
1771 | 1771 | |
1772 | - } |
|
1772 | + } |
|
1773 | 1773 | |
1774 | 1774 | |
1775 | - break; |
|
1775 | + break; |
|
1776 | 1776 | |
1777 | 1777 | } |
1778 | 1778 | |
@@ -1783,47 +1783,47 @@ discard block |
||
1783 | 1783 | |
1784 | 1784 | switch ( $field_type ) { |
1785 | 1785 | |
1786 | - // Captchas don't need to be re-entered. |
|
1787 | - case 'captcha': |
|
1786 | + // Captchas don't need to be re-entered. |
|
1787 | + case 'captcha': |
|
1788 | 1788 | |
1789 | - // Post Image fields aren't editable, so we un-fail them. |
|
1790 | - case 'post_image': |
|
1791 | - $field->failed_validation = false; |
|
1792 | - unset( $field->validation_message ); |
|
1793 | - break; |
|
1789 | + // Post Image fields aren't editable, so we un-fail them. |
|
1790 | + case 'post_image': |
|
1791 | + $field->failed_validation = false; |
|
1792 | + unset( $field->validation_message ); |
|
1793 | + break; |
|
1794 | 1794 | |
1795 | 1795 | } |
1796 | 1796 | |
1797 | 1797 | // You can't continue inside a switch, so we do it after. |
1798 | 1798 | if( empty( $field->failed_validation ) ) { |
1799 | - continue; |
|
1799 | + continue; |
|
1800 | 1800 | } |
1801 | 1801 | |
1802 | 1802 | // checks if the No Duplicates option is not validating entry against itself, since |
1803 | 1803 | // we're editing a stored entry, it would also assume it's a duplicate. |
1804 | 1804 | if( !empty( $field->noDuplicates ) ) { |
1805 | 1805 | |
1806 | - $entry = $this->get_entry(); |
|
1806 | + $entry = $this->get_entry(); |
|
1807 | 1807 | |
1808 | - // If the value of the entry is the same as the stored value |
|
1809 | - // Then we can assume it's not a duplicate, it's the same. |
|
1810 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1811 | - //if value submitted was not changed, then don't validate |
|
1812 | - $field->failed_validation = false; |
|
1808 | + // If the value of the entry is the same as the stored value |
|
1809 | + // Then we can assume it's not a duplicate, it's the same. |
|
1810 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1811 | + //if value submitted was not changed, then don't validate |
|
1812 | + $field->failed_validation = false; |
|
1813 | 1813 | |
1814 | - unset( $field->validation_message ); |
|
1814 | + unset( $field->validation_message ); |
|
1815 | 1815 | |
1816 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1816 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1817 | 1817 | |
1818 | - continue; |
|
1819 | - } |
|
1818 | + continue; |
|
1819 | + } |
|
1820 | 1820 | } |
1821 | 1821 | |
1822 | 1822 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1823 | 1823 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1824 | - unset( $field->validation_message ); |
|
1825 | - $field->validation_message = false; |
|
1826 | - continue; |
|
1824 | + unset( $field->validation_message ); |
|
1825 | + $field->validation_message = false; |
|
1826 | + continue; |
|
1827 | 1827 | } |
1828 | 1828 | |
1829 | 1829 | $gv_valid = false; |
@@ -1887,8 +1887,8 @@ discard block |
||
1887 | 1887 | // Hide fields depending on admin settings |
1888 | 1888 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1889 | 1889 | |
1890 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1891 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1890 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1891 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1892 | 1892 | |
1893 | 1893 | /** |
1894 | 1894 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1967,11 +1967,11 @@ discard block |
||
1967 | 1967 | // The edit tab has been configured, so we loop through to configured settings |
1968 | 1968 | foreach ( $configured_fields as $configured_field ) { |
1969 | 1969 | |
1970 | - /** @var GF_Field $field */ |
|
1971 | - foreach ( $fields as $field ) { |
|
1970 | + /** @var GF_Field $field */ |
|
1971 | + foreach ( $fields as $field ) { |
|
1972 | 1972 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1973 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1974 | - break; |
|
1973 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1974 | + break; |
|
1975 | 1975 | } |
1976 | 1976 | |
1977 | 1977 | } |
@@ -2027,28 +2027,28 @@ discard block |
||
2027 | 2027 | */ |
2028 | 2028 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
2029 | 2029 | |
2030 | - /** |
|
2030 | + /** |
|
2031 | 2031 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
2032 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
2033 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
2034 | - * @since 1.9.1 |
|
2035 | - * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
2036 | - * @param array $form GF Form array |
|
2037 | - * @param int $view_id View ID |
|
2038 | - */ |
|
2039 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
2040 | - |
|
2041 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2032 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
2033 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
2034 | + * @since 1.9.1 |
|
2035 | + * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
2036 | + * @param array $form GF Form array |
|
2037 | + * @param int $view_id View ID |
|
2038 | + */ |
|
2039 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
2040 | + |
|
2041 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2042 | 2042 | foreach( $fields as $k => $field ) { |
2043 | 2043 | if( $field->adminOnly ) { |
2044 | - unset( $fields[ $k ] ); |
|
2044 | + unset( $fields[ $k ] ); |
|
2045 | 2045 | } |
2046 | 2046 | } |
2047 | 2047 | return array_values( $fields ); |
2048 | 2048 | } |
2049 | 2049 | |
2050 | - foreach( $fields as &$field ) { |
|
2051 | - $field->adminOnly = false; |
|
2050 | + foreach( $fields as &$field ) { |
|
2051 | + $field->adminOnly = false; |
|
2052 | 2052 | } |
2053 | 2053 | |
2054 | 2054 | return $fields; |
@@ -2068,13 +2068,13 @@ discard block |
||
2068 | 2068 | */ |
2069 | 2069 | private function unselect_default_values( $form ) { |
2070 | 2070 | |
2071 | - foreach ( $form['fields'] as &$field ) { |
|
2071 | + foreach ( $form['fields'] as &$field ) { |
|
2072 | 2072 | |
2073 | 2073 | if ( empty( $field->choices ) ) { |
2074 | - continue; |
|
2074 | + continue; |
|
2075 | 2075 | } |
2076 | 2076 | |
2077 | - foreach ( $field->choices as &$choice ) { |
|
2077 | + foreach ( $field->choices as &$choice ) { |
|
2078 | 2078 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
2079 | 2079 | $choice['isSelected'] = false; |
2080 | 2080 | } |
@@ -2111,36 +2111,36 @@ discard block |
||
2111 | 2111 | |
2112 | 2112 | if( 'checkbox' === $field->type ) { |
2113 | 2113 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
2114 | - $input_id = $input['id']; |
|
2115 | - $choice = $field->choices[ $key ]; |
|
2116 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2117 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2118 | - if( $match ) { |
|
2119 | - $field->choices[ $key ]['isSelected'] = true; |
|
2120 | - } |
|
2114 | + $input_id = $input['id']; |
|
2115 | + $choice = $field->choices[ $key ]; |
|
2116 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2117 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2118 | + if( $match ) { |
|
2119 | + $field->choices[ $key ]['isSelected'] = true; |
|
2120 | + } |
|
2121 | 2121 | } |
2122 | 2122 | } else { |
2123 | 2123 | |
2124 | 2124 | // We need to run through each field to set the default values |
2125 | 2125 | foreach ( $this->entry as $field_id => $field_value ) { |
2126 | 2126 | |
2127 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2127 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2128 | 2128 | |
2129 | - if( 'list' === $field->type ) { |
|
2130 | - $list_rows = maybe_unserialize( $field_value ); |
|
2129 | + if( 'list' === $field->type ) { |
|
2130 | + $list_rows = maybe_unserialize( $field_value ); |
|
2131 | 2131 | |
2132 | - $list_field_value = array(); |
|
2133 | - foreach ( (array) $list_rows as $row ) { |
|
2134 | - foreach ( (array) $row as $column ) { |
|
2135 | - $list_field_value[] = $column; |
|
2136 | - } |
|
2137 | - } |
|
2132 | + $list_field_value = array(); |
|
2133 | + foreach ( (array) $list_rows as $row ) { |
|
2134 | + foreach ( (array) $row as $column ) { |
|
2135 | + $list_field_value[] = $column; |
|
2136 | + } |
|
2137 | + } |
|
2138 | 2138 | |
2139 | - $field->defaultValue = serialize( $list_field_value ); |
|
2140 | - } else { |
|
2141 | - $field->defaultValue = $field_value; |
|
2142 | - } |
|
2143 | - } |
|
2139 | + $field->defaultValue = serialize( $list_field_value ); |
|
2140 | + } else { |
|
2141 | + $field->defaultValue = $field_value; |
|
2142 | + } |
|
2143 | + } |
|
2144 | 2144 | } |
2145 | 2145 | } |
2146 | 2146 | } |
@@ -2201,7 +2201,7 @@ discard block |
||
2201 | 2201 | foreach ( $form['fields'] as &$field ) { |
2202 | 2202 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2203 | 2203 | |
2204 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2204 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2205 | 2205 | |
2206 | 2206 | if ( $field['id'] == $rule_field_id ) { |
2207 | 2207 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2252,7 +2252,7 @@ discard block |
||
2252 | 2252 | return $has_conditional_logic; |
2253 | 2253 | } |
2254 | 2254 | |
2255 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2255 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2256 | 2256 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
2257 | 2257 | } |
2258 | 2258 | |
@@ -2319,14 +2319,14 @@ discard block |
||
2319 | 2319 | |
2320 | 2320 | if( $echo && $error !== true ) { |
2321 | 2321 | |
2322 | - $error = esc_html( $error ); |
|
2322 | + $error = esc_html( $error ); |
|
2323 | 2323 | |
2324 | - /** |
|
2325 | - * @since 1.9 |
|
2326 | - */ |
|
2327 | - if ( ! empty( $this->entry ) ) { |
|
2328 | - $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;" ) ); |
|
2329 | - } |
|
2324 | + /** |
|
2325 | + * @since 1.9 |
|
2326 | + */ |
|
2327 | + if ( ! empty( $this->entry ) ) { |
|
2328 | + $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;" ) ); |
|
2329 | + } |
|
2330 | 2330 | |
2331 | 2331 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
2332 | 2332 | } |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | public function duplicate_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
115 | 115 | |
116 | 116 | // Always a link, never a filter, always same window |
117 | - unset( $field_options['show_as_link'], $field_options['search_filter'], $field_options['new_window'] ); |
|
117 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ], $field_options[ 'new_window' ] ); |
|
118 | 118 | |
119 | 119 | |
120 | 120 | // Duplicate Entry link should only appear to visitors capable of editing entries |
121 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
121 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
122 | 122 | |
123 | - $add_option['duplicate_link'] = array( |
|
123 | + $add_option[ 'duplicate_link' ] = array( |
|
124 | 124 | 'type' => 'text', |
125 | 125 | 'label' => __( 'Duplicate Link Text', 'gravityview' ), |
126 | 126 | 'desc' => NULL, |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | 'merge_tags' => true, |
129 | 129 | ); |
130 | 130 | |
131 | - $field_options['allow_duplicate_cap'] = array( |
|
131 | + $field_options[ 'allow_duplicate_cap' ] = array( |
|
132 | 132 | 'type' => 'select', |
133 | 133 | 'label' => __( 'Allow the following users to duplicate the entry:', 'gravityview' ), |
134 | 134 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | public function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
156 | 156 | |
157 | 157 | if ( 'edit' !== $zone ) { |
158 | - $entry_default_fields['duplicate_link'] = array( |
|
158 | + $entry_default_fields[ 'duplicate_link' ] = array( |
|
159 | 159 | 'label' => __( 'Duplicate Entry', 'gravityview' ), |
160 | 160 | 'type' => 'duplicate_link', |
161 | 161 | 'desc' => __( 'A link to duplicate the entry. Respects the Duplicate Entry permissions.', 'gravityview' ), |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function add_available_field( $available_fields = array() ) { |
178 | 178 | |
179 | - $available_fields['duplicate_link'] = array( |
|
179 | + $available_fields[ 'duplicate_link' ] = array( |
|
180 | 180 | 'label_text' => __( 'Duplicate Entry', 'gravityview' ), |
181 | 181 | 'field_id' => 'duplicate_link', |
182 | 182 | 'label_type' => 'field', |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | if ( 'duplicate_link' === $field_id ) { |
210 | 210 | |
211 | 211 | // Remove other built-in caps. |
212 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['duplicate_others_posts'] ); |
|
212 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'duplicate_others_posts' ] ); |
|
213 | 213 | |
214 | - $caps['read'] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
214 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | return $caps; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | public static function get_duplicate_link( $entry, $view_id, $post_id = null ) { |
261 | 261 | self::getInstance()->set_entry( $entry ); |
262 | 262 | |
263 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
263 | + $base = GravityView_API::directory_link( $post_id ?: $view_id, true ); |
|
264 | 264 | |
265 | 265 | if ( empty( $base ) ) { |
266 | 266 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | |
270 | 270 | $actionurl = add_query_arg( array( |
271 | 271 | 'action' => 'duplicate', |
272 | - 'entry_id' => $entry['id'], |
|
272 | + 'entry_id' => $entry[ 'id' ], |
|
273 | 273 | 'gvid' => $view_id, |
274 | 274 | 'view_id' => $view_id, |
275 | 275 | ), $base ); |
276 | 276 | |
277 | - return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry['id'] ) ), $actionurl ); |
|
277 | + return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry[ 'id' ] ) ), $actionurl ); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | public function process_duplicate() { |
296 | 296 | |
297 | 297 | // If the form is submitted |
298 | - if ( ! isset( $_GET['action'] ) || 'duplicate' !== $_GET['action'] || ! isset( $_GET['entry_id'] ) ) { |
|
298 | + if ( ! isset( $_GET[ 'action' ] ) || 'duplicate' !== $_GET[ 'action' ] || ! isset( $_GET[ 'entry_id' ] ) ) { |
|
299 | 299 | return; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Make sure it's a GravityView request |
303 | - $valid_nonce_key = wp_verify_nonce( \GV\Utils::_GET( 'duplicate' ), self::get_nonce_key( $_GET['entry_id'] ) ); |
|
303 | + $valid_nonce_key = wp_verify_nonce( \GV\Utils::_GET( 'duplicate' ), self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
304 | 304 | |
305 | 305 | if ( ! $valid_nonce_key ) { |
306 | 306 | gravityview()->log->debug( 'Duplicate entry not processed: nonce validation failed.' ); |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | // Get the entry slug |
311 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
311 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
312 | 312 | |
313 | 313 | // See if there's an entry there |
314 | 314 | $entry = gravityview_get_entry( $entry_slug, true, false ); |
@@ -402,15 +402,15 @@ discard block |
||
402 | 402 | return new WP_Error( 'gravityview-duplicate-entry-missing', __( 'The entry does not exist.', 'gravityview' ) ); |
403 | 403 | } |
404 | 404 | |
405 | - $row['id'] = null; |
|
406 | - $row['date_created'] = date( 'Y-m-d H:i:s', time() ); |
|
407 | - $row['date_updated'] = $row['date_created']; |
|
408 | - $row['is_starred'] = false; |
|
409 | - $row['is_read'] = false; |
|
410 | - $row['ip'] = GFFormsModel::get_ip(); |
|
411 | - $row['source_url'] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
412 | - $row['user_agent'] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
413 | - $row['created_by'] = wp_get_current_user()->ID; |
|
405 | + $row[ 'id' ] = null; |
|
406 | + $row[ 'date_created' ] = date( 'Y-m-d H:i:s', time() ); |
|
407 | + $row[ 'date_updated' ] = $row[ 'date_created' ]; |
|
408 | + $row[ 'is_starred' ] = false; |
|
409 | + $row[ 'is_read' ] = false; |
|
410 | + $row[ 'ip' ] = GFFormsModel::get_ip(); |
|
411 | + $row[ 'source_url' ] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
412 | + $row[ 'user_agent' ] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
413 | + $row[ 'created_by' ] = wp_get_current_user()->ID; |
|
414 | 414 | |
415 | 415 | /** |
416 | 416 | * @filter `gravityview/entry/duplicate/details` Modify the new entry details before it's created. |
@@ -438,15 +438,15 @@ discard block |
||
438 | 438 | |
439 | 439 | $save_this_meta = array(); |
440 | 440 | foreach ( $duplicate_meta->get_output() as $m ) { |
441 | - $save_this_meta[] = array( |
|
442 | - 'meta_key' => $m['meta_key'], |
|
443 | - 'meta_value' => $m['meta_value'], |
|
444 | - 'item_index' => $m['item_index'], |
|
441 | + $save_this_meta[ ] = array( |
|
442 | + 'meta_key' => $m[ 'meta_key' ], |
|
443 | + 'meta_value' => $m[ 'meta_value' ], |
|
444 | + 'item_index' => $m[ 'item_index' ], |
|
445 | 445 | ); |
446 | 446 | } |
447 | 447 | |
448 | 448 | // Update the row ID for later usage |
449 | - $row['id'] = $duplicated_id; |
|
449 | + $row[ 'id' ] = $duplicated_id; |
|
450 | 450 | |
451 | 451 | /** |
452 | 452 | * @filter `gravityview/entry/duplicate/meta` Modify the new entry meta details. |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | $save_this_meta = apply_filters( 'gravityview/entry/duplicate/meta', $save_this_meta, $row, $entry ); |
458 | 458 | |
459 | 459 | foreach ( $save_this_meta as $data ) { |
460 | - $data['form_id'] = $entry['form_id']; |
|
461 | - $data['entry_id'] = $duplicated_id; |
|
460 | + $data[ 'form_id' ] = $entry[ 'form_id' ]; |
|
461 | + $data[ 'entry_id' ] = $duplicated_id; |
|
462 | 462 | |
463 | 463 | if ( ! $wpdb->insert( $entry_meta_table, $data ) ) { |
464 | 464 | return new WP_Error( 'gravityview-duplicate-entry-db-meta', __( 'There was an error duplicating the entry.', 'gravityview' ) ); |
@@ -492,13 +492,13 @@ discard block |
||
492 | 492 | public function verify_nonce() { |
493 | 493 | |
494 | 494 | // No duplicate entry request was made |
495 | - if ( empty( $_GET['entry_id'] ) || empty( $_GET['duplicate'] ) ) { |
|
495 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'duplicate' ] ) ) { |
|
496 | 496 | return false; |
497 | 497 | } |
498 | 498 | |
499 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
499 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
500 | 500 | |
501 | - $valid = wp_verify_nonce( $_GET['duplicate'], $nonce_key ); |
|
501 | + $valid = wp_verify_nonce( $_GET[ 'duplicate' ], $nonce_key ); |
|
502 | 502 | |
503 | 503 | /** |
504 | 504 | * @filter `gravityview/duplicate-entry/verify_nonce` Override Duplicate Entry nonce validation. Return true to declare nonce valid. |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | return ''; |
535 | 535 | } |
536 | 536 | |
537 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
537 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | /** |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | public static function check_user_cap_duplicate_entry( $entry, $field = array(), $view_id = 0 ) { |
589 | 589 | $current_user = wp_get_current_user(); |
590 | 590 | |
591 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL; |
|
591 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL; |
|
592 | 592 | |
593 | 593 | // Or if they can duplicate any entries (as defined in Gravity Forms), we're good. |
594 | 594 | if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gform_full_access', 'gravityview_full_access' ), $entry_id ) ) { |
@@ -603,17 +603,17 @@ discard block |
||
603 | 603 | if ( ! empty( $field ) ) { |
604 | 604 | |
605 | 605 | // If capability is not defined, something is not right! |
606 | - if ( empty( $field['allow_duplicate_cap'] ) ) { |
|
606 | + if ( empty( $field[ 'allow_duplicate_cap' ] ) ) { |
|
607 | 607 | |
608 | 608 | gravityview()->log->error( 'Cannot read duplicate entry field caps', array( 'data' => $field ) ); |
609 | 609 | |
610 | 610 | return false; |
611 | 611 | } |
612 | 612 | |
613 | - if ( GVCommon::has_cap( $field['allow_duplicate_cap'] ) ) { |
|
613 | + if ( GVCommon::has_cap( $field[ 'allow_duplicate_cap' ] ) ) { |
|
614 | 614 | |
615 | 615 | // Do not return true if cap is read, as we need to check if the current user created the entry |
616 | - if ( 'read' !== $field['allow_duplicate_cap'] ) { |
|
616 | + if ( 'read' !== $field[ 'allow_duplicate_cap' ] ) { |
|
617 | 617 | return true; |
618 | 618 | } |
619 | 619 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | |
627 | 627 | } |
628 | 628 | |
629 | - if ( ! isset( $entry['created_by'] ) ) { |
|
629 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
630 | 630 | |
631 | 631 | gravityview()->log->error( 'Cannot duplicate entry; entry `created_by` doesn\'t exist.' ); |
632 | 632 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | } |
652 | 652 | |
653 | 653 | // If the logged-in user is the same as the user who created the entry, we're good. |
654 | - if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
654 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
655 | 655 | |
656 | 656 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
657 | 657 | |
@@ -676,16 +676,16 @@ discard block |
||
676 | 676 | */ |
677 | 677 | public function display_message( $current_view_id = 0 ) { |
678 | 678 | |
679 | - if ( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
679 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
680 | 680 | return; |
681 | 681 | } |
682 | 682 | |
683 | 683 | // Entry wasn't duplicated from current View |
684 | - if ( isset( $_GET['view_id'] ) && ( intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) ) { |
|
684 | + if ( isset( $_GET[ 'view_id' ] ) && ( intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) ) { |
|
685 | 685 | return; |
686 | 686 | } |
687 | 687 | |
688 | - $status = esc_attr( $_GET['status'] ); |
|
688 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
689 | 689 | $message_from_url = \GV\Utils::_GET( 'message' ); |
690 | 690 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
691 | 691 | $class = ''; |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | $message = apply_filters( 'gravityview/duplicate-entry/message', esc_attr( $message ), $status, $message_from_url ); |
712 | 712 | |
713 | 713 | // DISPLAY ERROR/SUCCESS MESSAGE |
714 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
714 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
715 | 715 | } |
716 | 716 | |
717 | 717 |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | $gravityview_view = GravityView_View::getInstance(); |
10 | 10 | |
11 | 11 | $visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' ); |
12 | -$show_notes_logged_out = ( ! empty( $visibility_settings['view'] ) && ! empty( $visibility_settings['view_loggedout'] ) ); |
|
12 | +$show_notes_logged_out = ( ! empty( $visibility_settings[ 'view' ] ) && ! empty( $visibility_settings[ 'view_loggedout' ] ) ); |
|
13 | 13 | |
14 | -if( ! GVCommon::has_cap( array( 'gravityview_view_entry_notes', 'gravityview_add_entry_notes', 'gravityview_delete_entry_notes' ) ) && ! $show_notes_logged_out ) { |
|
14 | +if ( ! GVCommon::has_cap( array( 'gravityview_view_entry_notes', 'gravityview_add_entry_notes', 'gravityview_delete_entry_notes' ) ) && ! $show_notes_logged_out ) { |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
@@ -25,20 +25,20 @@ discard block |
||
25 | 25 | do_action( 'gravityview/field/notes/scripts' ); |
26 | 26 | |
27 | 27 | $entry = $gravityview_view->getCurrentEntry(); |
28 | -$notes = (array) GravityView_Entry_Notes::get_notes( $entry['id'] ); |
|
28 | +$notes = (array)GravityView_Entry_Notes::get_notes( $entry[ 'id' ] ); |
|
29 | 29 | $strings = GravityView_Field_Notes::strings(); |
30 | -$entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
30 | +$entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
31 | 31 | |
32 | -$show_add = ! empty( $visibility_settings['add'] ); |
|
33 | -$show_delete = ( ! empty( $visibility_settings['delete'] ) && GVCommon::has_cap( 'gravityview_delete_entry_notes' ) ); |
|
34 | -$show_notes = $show_notes_logged_out || ( ! empty( $visibility_settings['view'] ) && GVCommon::has_cap( 'gravityview_view_entry_notes' ) ); |
|
32 | +$show_add = ! empty( $visibility_settings[ 'add' ] ); |
|
33 | +$show_delete = ( ! empty( $visibility_settings[ 'delete' ] ) && GVCommon::has_cap( 'gravityview_delete_entry_notes' ) ); |
|
34 | +$show_notes = $show_notes_logged_out || ( ! empty( $visibility_settings[ 'view' ] ) && GVCommon::has_cap( 'gravityview_view_entry_notes' ) ); |
|
35 | 35 | |
36 | 36 | $container_class = ( sizeof( $notes ) > 0 ? 'gv-has-notes' : 'gv-no-notes' ); |
37 | 37 | $container_class .= $show_notes ? ' gv-show-notes' : ' gv-hide-notes'; |
38 | 38 | ?> |
39 | 39 | <div class="gv-notes <?php echo $container_class; ?>"> |
40 | 40 | <?php |
41 | - if( $show_notes ) { |
|
41 | + if ( $show_notes ) { |
|
42 | 42 | ?> |
43 | 43 | <form method="post" class="gv-notes-list"> |
44 | 44 | <?php if ( $show_delete ) { wp_nonce_field( 'gv_delete_notes_' . $entry_slug, 'gv_delete_notes' ); } ?> |
@@ -46,21 +46,21 @@ discard block |
||
46 | 46 | <input type="hidden" name="action" value="gv_delete_notes" /> |
47 | 47 | <input type="hidden" name="entry-slug" value="<?php echo esc_attr( $entry_slug ); ?>" /> |
48 | 48 | <table> |
49 | - <caption><?php echo $strings['caption']; ?></caption> |
|
49 | + <caption><?php echo $strings[ 'caption' ]; ?></caption> |
|
50 | 50 | <?php |
51 | 51 | if ( $show_delete ) { |
52 | 52 | ?> |
53 | 53 | <thead> |
54 | 54 | <tr> |
55 | 55 | <th colspan="2"> |
56 | - <label><input type="checkbox" value="" class="gv-notes-toggle" title="<?php echo $strings['toggle-notes']; ?>"><span class="screen-reader-text"><?php echo $strings['toggle-notes']; ?></span></label> |
|
57 | - <button type="submit" class="button button-small gv-notes-delete"><?php echo $strings['delete']; ?></button> |
|
56 | + <label><input type="checkbox" value="" class="gv-notes-toggle" title="<?php echo $strings[ 'toggle-notes' ]; ?>"><span class="screen-reader-text"><?php echo $strings[ 'toggle-notes' ]; ?></span></label> |
|
57 | + <button type="submit" class="button button-small gv-notes-delete"><?php echo $strings[ 'delete' ]; ?></button> |
|
58 | 58 | </th> |
59 | 59 | </tr> |
60 | 60 | </thead> |
61 | 61 | <?php } ?> |
62 | 62 | <tbody> |
63 | - <tr class="gv-notes-no-notes"><td colspan="2"><?php echo $strings['no-notes']; ?></td></tr> |
|
63 | + <tr class="gv-notes-no-notes"><td colspan="2"><?php echo $strings[ 'no-notes' ]; ?></td></tr> |
|
64 | 64 | <?php |
65 | 65 | foreach ( $notes as $note ) { |
66 | 66 | echo GravityView_Field_Notes::display_note( $note, $show_delete ); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | <?php |
74 | 74 | } // End if can view notes |
75 | 75 | |
76 | - if( $show_add ) { |
|
76 | + if ( $show_add ) { |
|
77 | 77 | echo do_shortcode( '[gv_note_add]' ); |
78 | 78 | } |
79 | 79 | ?> |