@@ -171,7 +171,6 @@ |
||
171 | 171 | * |
172 | 172 | * @since develop |
173 | 173 | * @param array $visibility_caps Array of capabilities to display in field dropdown. |
174 | - * @param string $field_type Type of field options to render (`field` or `widget`) |
|
175 | 174 | * @param string $template_id Table slug |
176 | 175 | * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` |
177 | 176 | * @param string $context What context are we in? Example: `single` or `directory` |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | self::getInstance()->set_entry( $entry ); |
236 | 236 | |
237 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
237 | + $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
238 | 238 | |
239 | 239 | if ( empty( $base ) ) { |
240 | 240 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | 'action' => 'duplicate', |
249 | 249 | 'entry_id' => $entry_slug, |
250 | 250 | 'gvid' => $view_id, |
251 | - 'view_id' => $view_id, |
|
251 | + 'view_id' => $view_id, |
|
252 | 252 | ), $base ); |
253 | 253 | |
254 | 254 | $url = wp_nonce_url( $actionurl, 'duplicate_'.$entry_slug, 'duplicate' ); |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * @since develop |
434 | 434 | * @param array $duplicated_entry The duplicated entry |
435 | 435 | * @param array $entry The original entry |
436 | - */ |
|
436 | + */ |
|
437 | 437 | do_action( 'gravityview/duplicate-entry/duplicated', $duplicated_entry, $entry ); |
438 | 438 | |
439 | 439 | gravityview()->log->debug( 'Duplicate response: {duplicate_response}', array( 'duplicate_response' => $duplicate_response ) ); |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | function duplicate_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
101 | 101 | |
102 | 102 | // Always a link, never a filter |
103 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
103 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
104 | 104 | |
105 | 105 | |
106 | 106 | // Duplicate Entry link should only appear to visitors capable of editing entries |
107 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
107 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
108 | 108 | |
109 | - $add_option['duplicate_link'] = array( |
|
109 | + $add_option[ 'duplicate_link' ] = array( |
|
110 | 110 | 'type' => 'text', |
111 | 111 | 'label' => __( 'Duplicate Link Text', 'gravityview' ), |
112 | 112 | 'desc' => NULL, |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | 'merge_tags' => true, |
115 | 115 | ); |
116 | 116 | |
117 | - $field_options['allow_duplicate_cap'] = array( |
|
117 | + $field_options[ 'allow_duplicate_cap' ] = array( |
|
118 | 118 | 'type' => 'select', |
119 | 119 | 'label' => __( 'Allow the following users to duplicate the entry:', 'gravityview' ), |
120 | 120 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
139 | 139 | |
140 | 140 | if ( 'edit' !== $zone ) { |
141 | - $entry_default_fields['duplicate_link'] = array( |
|
141 | + $entry_default_fields[ 'duplicate_link' ] = array( |
|
142 | 142 | 'label' => __( 'Duplicate Entry', 'gravityview' ), |
143 | 143 | 'type' => 'duplicate_link', |
144 | 144 | 'desc' => __( 'A link to duplicate the entry. Respects the Duplicate Entry permissions.', 'gravityview' ), |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | function add_available_field( $available_fields = array() ) { |
157 | 157 | |
158 | - $available_fields['duplicate_link'] = array( |
|
158 | + $available_fields[ 'duplicate_link' ] = array( |
|
159 | 159 | 'label_text' => __( 'Duplicate Entry', 'gravityview' ), |
160 | 160 | 'field_id' => 'duplicate_link', |
161 | 161 | 'label_type' => 'field', |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | if ( $field_id === 'duplicate_link' ) { |
187 | 187 | |
188 | 188 | // Remove other built-in caps. |
189 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['duplicate_others_posts'] ); |
|
189 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'duplicate_others_posts' ] ); |
|
190 | 190 | |
191 | - $caps['read'] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
191 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | return $caps; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @param [type] $entry [description] |
202 | 202 | */ |
203 | 203 | function set_entry( $entry = null ) { |
204 | - $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry; |
|
204 | + $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[ 0 ] : $entry; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | self::getInstance()->set_entry( $entry ); |
236 | 236 | |
237 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
237 | + $base = GravityView_API::directory_link( $post_id ?: $view_id, true ); |
|
238 | 238 | |
239 | 239 | if ( empty( $base ) ) { |
240 | 240 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | |
244 | 244 | // Use the slug instead of the ID for consistent security |
245 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
245 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
246 | 246 | |
247 | 247 | $actionurl = add_query_arg( array( |
248 | 248 | 'action' => 'duplicate', |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | 'view_id' => $view_id, |
252 | 252 | ), $base ); |
253 | 253 | |
254 | - $url = wp_nonce_url( $actionurl, 'duplicate_'.$entry_slug, 'duplicate' ); |
|
254 | + $url = wp_nonce_url( $actionurl, 'duplicate_' . $entry_slug, 'duplicate' ); |
|
255 | 255 | |
256 | 256 | return $url; |
257 | 257 | } |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | function process_duplicate() { |
273 | 273 | |
274 | 274 | // If the form is submitted |
275 | - if ( ! isset( $_GET['action'] ) || 'duplicate' !== $_GET['action'] || ! isset( $_GET['entry_id'] ) ) { |
|
275 | + if ( ! isset( $_GET[ 'action' ] ) || 'duplicate' !== $_GET[ 'action' ] || ! isset( $_GET[ 'entry_id' ] ) ) { |
|
276 | 276 | return; |
277 | 277 | } |
278 | 278 | |
279 | 279 | // Make sure it's a GravityView request |
280 | - $valid_nonce_key = wp_verify_nonce( $_GET['duplicate'], self::get_nonce_key( $_GET['entry_id'] ) ); |
|
280 | + $valid_nonce_key = wp_verify_nonce( $_GET[ 'duplicate' ], self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
281 | 281 | |
282 | 282 | if ( ! $valid_nonce_key ) { |
283 | 283 | gravityview()->log->debug( 'Duplicate entry not processed: nonce validation failed.' ); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | // Get the entry slug |
288 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
288 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
289 | 289 | |
290 | 290 | // See if there's an entry there |
291 | 291 | $entry = gravityview_get_entry( $entry_slug, true, false ); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | private function duplicate_entry( $entry ) { |
349 | 349 | |
350 | - $entry_id = $entry['id']; |
|
350 | + $entry_id = $entry[ 'id' ]; |
|
351 | 351 | |
352 | 352 | gravityview()->log->debug( 'Starting duplicate entry: {entry_id}', array( 'entry_id' => $entry_id ) ); |
353 | 353 | |
@@ -362,15 +362,15 @@ discard block |
||
362 | 362 | return new WP_Error( 'gravityview-duplicate-entry-missing', __( 'No such entry ID', 'gravityview' ) ); |
363 | 363 | } |
364 | 364 | |
365 | - $row['id'] = null; |
|
366 | - $row['date_created'] = date( 'Y-m-d H:i:s', time() ); |
|
367 | - $row['date_updated'] = $row['date_created']; |
|
368 | - $row['is_starred'] = false; |
|
369 | - $row['is_read'] = false; |
|
370 | - $row['ip'] = GFFormsModel::get_ip(); |
|
371 | - $row['source_url'] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
372 | - $row['user_agent'] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
373 | - $row['created_by'] = wp_get_current_user()->ID; |
|
365 | + $row[ 'id' ] = null; |
|
366 | + $row[ 'date_created' ] = date( 'Y-m-d H:i:s', time() ); |
|
367 | + $row[ 'date_updated' ] = $row[ 'date_created' ]; |
|
368 | + $row[ 'is_starred' ] = false; |
|
369 | + $row[ 'is_read' ] = false; |
|
370 | + $row[ 'ip' ] = GFFormsModel::get_ip(); |
|
371 | + $row[ 'source_url' ] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
372 | + $row[ 'user_agent' ] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
373 | + $row[ 'created_by' ] = wp_get_current_user()->ID; |
|
374 | 374 | |
375 | 375 | /** |
376 | 376 | * @filter `gravityview/entry/duplicate/details` Modify the new entry details before it's created. |
@@ -397,14 +397,14 @@ discard block |
||
397 | 397 | |
398 | 398 | $save_this_meta = array(); |
399 | 399 | foreach ( $duplicate_meta->get_output() as $m ) { |
400 | - $save_this_meta[] = array( |
|
401 | - 'meta_key' => $m['meta_key'], |
|
402 | - 'meta_value' => $m['meta_value'], |
|
403 | - 'item_index' => $m['item_index'], |
|
400 | + $save_this_meta[ ] = array( |
|
401 | + 'meta_key' => $m[ 'meta_key' ], |
|
402 | + 'meta_value' => $m[ 'meta_value' ], |
|
403 | + 'item_index' => $m[ 'item_index' ], |
|
404 | 404 | ); |
405 | 405 | } |
406 | 406 | |
407 | - $row['ID'] = $duplicated_id; |
|
407 | + $row[ 'ID' ] = $duplicated_id; |
|
408 | 408 | |
409 | 409 | /** |
410 | 410 | * @filter `gravityview/entry/duplicate/meta` Modify the new entry meta details. |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | $save_this_meta = apply_filters( 'gravityview/entry/duplicate/meta', $save_this_meta, $row, $entry ); |
416 | 416 | |
417 | 417 | foreach ( $save_this_meta as $data ) { |
418 | - $data['form_id'] = $entry['form_id']; |
|
419 | - $data['entry_id'] = $duplicated_id; |
|
418 | + $data[ 'form_id' ] = $entry[ 'form_id' ]; |
|
419 | + $data[ 'entry_id' ] = $duplicated_id; |
|
420 | 420 | |
421 | 421 | if ( ! $wpdb->insert( $entry_meta_table, $data ) ) { |
422 | 422 | return new WP_Error( 'gravityview-duplicate-entry-db', __( 'Database error', 'gravityview' ) ); |
@@ -449,13 +449,13 @@ discard block |
||
449 | 449 | public function verify_nonce() { |
450 | 450 | |
451 | 451 | // No duplicate entry request was made |
452 | - if ( empty( $_GET['entry_id'] ) || empty( $_GET['duplicate'] ) ) { |
|
452 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'duplicate' ] ) ) { |
|
453 | 453 | return false; |
454 | 454 | } |
455 | 455 | |
456 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
456 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
457 | 457 | |
458 | - $valid = wp_verify_nonce( $_GET['duplicate'], $nonce_key ); |
|
458 | + $valid = wp_verify_nonce( $_GET[ 'duplicate' ], $nonce_key ); |
|
459 | 459 | |
460 | 460 | /** |
461 | 461 | * @filter `gravityview/duplicate-entry/verify_nonce` Override Duplicate Entry nonce validation. Return true to declare nonce valid. |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | */ |
486 | 486 | $confirm = apply_filters( 'gravityview/duplicate-entry/confirm-text', $confirm ); |
487 | 487 | |
488 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
488 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | |
541 | 541 | $current_user = wp_get_current_user(); |
542 | 542 | |
543 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL; |
|
543 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL; |
|
544 | 544 | |
545 | 545 | // Or if they can duplicate any entries (as defined in Gravity Forms), we're good. |
546 | 546 | if ( GVCommon::has_cap( array( 'gravityforms_edit_entries' ), $entry_id ) ) { |
@@ -555,17 +555,17 @@ discard block |
||
555 | 555 | if ( ! empty( $field ) ) { |
556 | 556 | |
557 | 557 | // If capability is not defined, something is not right! |
558 | - if ( empty( $field['allow_duplicate_cap'] ) ) { |
|
558 | + if ( empty( $field[ 'allow_duplicate_cap' ] ) ) { |
|
559 | 559 | |
560 | 560 | gravityview()->log->error( 'Cannot read duplicate entry field caps', array( 'data' => $field ) ); |
561 | 561 | |
562 | 562 | return false; |
563 | 563 | } |
564 | 564 | |
565 | - if ( GVCommon::has_cap( $field['allow_duplicate_cap'] ) ) { |
|
565 | + if ( GVCommon::has_cap( $field[ 'allow_duplicate_cap' ] ) ) { |
|
566 | 566 | |
567 | 567 | // Do not return true if cap is read, as we need to check if the current user created the entry |
568 | - if ( $field['allow_duplicate_cap'] !== 'read' ) { |
|
568 | + if ( $field[ 'allow_duplicate_cap' ] !== 'read' ) { |
|
569 | 569 | return true; |
570 | 570 | } |
571 | 571 | |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | |
579 | 579 | } |
580 | 580 | |
581 | - if ( ! isset( $entry['created_by'] ) ) { |
|
581 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
582 | 582 | |
583 | 583 | gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
584 | 584 | |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | |
591 | 591 | $current_view = gravityview_get_current_view_data( $view_id ); |
592 | 592 | |
593 | - $user_duplicate = isset( $current_view['atts']['user_duplicate'] ) ? $current_view['atts']['user_duplicate'] : false; |
|
593 | + $user_duplicate = isset( $current_view[ 'atts' ][ 'user_duplicate' ] ) ? $current_view[ 'atts' ][ 'user_duplicate' ] : false; |
|
594 | 594 | |
595 | 595 | if ( empty( $user_duplicate ) ) { |
596 | 596 | |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | } |
602 | 602 | |
603 | 603 | // If the logged-in user is the same as the user who created the entry, we're good. |
604 | - if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
604 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
605 | 605 | |
606 | 606 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
607 | 607 | |
@@ -625,16 +625,16 @@ discard block |
||
625 | 625 | */ |
626 | 626 | public function display_message( $current_view_id = 0 ) { |
627 | 627 | |
628 | - if ( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
628 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
629 | 629 | return; |
630 | 630 | } |
631 | 631 | |
632 | 632 | // Entry wasn't duplicateded from current View |
633 | - if ( isset( $_GET['view_id'] ) && intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) { |
|
633 | + if ( isset( $_GET[ 'view_id' ] ) && intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) { |
|
634 | 634 | return; |
635 | 635 | } |
636 | 636 | |
637 | - $status = esc_attr( $_GET['status'] ); |
|
637 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
638 | 638 | $message_from_url = \GV\Utils::_GET( 'message' ); |
639 | 639 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
640 | 640 | $class = ''; |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | $message = apply_filters( 'gravityview/duplicate-entry/message', esc_attr( $message ), $status, $message_from_url ); |
664 | 664 | |
665 | 665 | // DISPLAY ERROR/SUCCESS MESSAGE |
666 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
666 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
667 | 667 | } |
668 | 668 | |
669 | 669 |