@@ -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,10 +272,10 @@ 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 | |
277 | 277 | // Make sure it's a GravityView request |
278 | - $valid_nonce_key = wp_verify_nonce( $_GET['duplicate'], self::get_nonce_key( $_GET['entry_id'] ) ); |
|
278 | + $valid_nonce_key = wp_verify_nonce( $_GET[ 'duplicate' ], self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
279 | 279 | |
280 | 280 | if ( ! $valid_nonce_key ) { |
281 | 281 | gravityview()->log->debug( 'Duplicate entry not processed: nonce validation failed.' ); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | // Get the entry slug |
286 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
286 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
287 | 287 | |
288 | 288 | // See if there's an entry there |
289 | 289 | $entry = gravityview_get_entry( $entry_slug, true, false ); |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | */ |
349 | 349 | private function duplicate_entry( $entry ) { |
350 | 350 | |
351 | - $entry_id = $entry['id']; |
|
351 | + $entry_id = $entry[ 'id' ]; |
|
352 | 352 | |
353 | 353 | gravityview()->log->debug( 'Starting duplicate entry: {entry_id}', array( 'entry_id' => $entry_id ) ); |
354 | 354 | |
@@ -363,15 +363,15 @@ discard block |
||
363 | 363 | return new WP_Error( 'gravityview-duplicate-entry-missing', __( 'No such entry ID', 'gravityview' ) ); |
364 | 364 | } |
365 | 365 | |
366 | - $row['id'] = null; |
|
367 | - $row['date_created'] = date( 'Y-m-d H:i:s', time() ); |
|
368 | - $row['date_updated'] = $row['date_created']; |
|
369 | - $row['is_starred'] = false; |
|
370 | - $row['is_read'] = false; |
|
371 | - $row['ip'] = GFFormsModel::get_ip(); |
|
372 | - $row['source_url'] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
373 | - $row['user_agent'] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
374 | - $row['created_by'] = wp_get_current_user()->ID; |
|
366 | + $row[ 'id' ] = null; |
|
367 | + $row[ 'date_created' ] = date( 'Y-m-d H:i:s', time() ); |
|
368 | + $row[ 'date_updated' ] = $row[ 'date_created' ]; |
|
369 | + $row[ 'is_starred' ] = false; |
|
370 | + $row[ 'is_read' ] = false; |
|
371 | + $row[ 'ip' ] = GFFormsModel::get_ip(); |
|
372 | + $row[ 'source_url' ] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
373 | + $row[ 'user_agent' ] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
374 | + $row[ 'created_by' ] = wp_get_current_user()->ID; |
|
375 | 375 | |
376 | 376 | /** |
377 | 377 | * @filter `gravityview/entry/duplicate/details` Modify the new entry details before it's created. |
@@ -398,14 +398,14 @@ discard block |
||
398 | 398 | |
399 | 399 | $save_this_meta = array(); |
400 | 400 | foreach ( $duplicate_meta->get_output() as $m ) { |
401 | - $save_this_meta[] = array( |
|
402 | - 'meta_key' => $m['meta_key'], |
|
403 | - 'meta_value' => $m['meta_value'], |
|
404 | - 'item_index' => $m['item_index'], |
|
401 | + $save_this_meta[ ] = array( |
|
402 | + 'meta_key' => $m[ 'meta_key' ], |
|
403 | + 'meta_value' => $m[ 'meta_value' ], |
|
404 | + 'item_index' => $m[ 'item_index' ], |
|
405 | 405 | ); |
406 | 406 | } |
407 | 407 | |
408 | - $row['ID'] = $duplicated_id; |
|
408 | + $row[ 'ID' ] = $duplicated_id; |
|
409 | 409 | |
410 | 410 | /** |
411 | 411 | * @filter `gravityview/entry/duplicate/meta` Modify the new entry meta details. |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | $save_this_meta = apply_filters( 'gravityview/entry/duplicate/meta', $save_this_meta, $row, $entry ); |
417 | 417 | |
418 | 418 | foreach ( $save_this_meta as $data ) { |
419 | - $data['form_id'] = $entry['form_id']; |
|
420 | - $data['entry_id'] = $duplicated_id; |
|
419 | + $data[ 'form_id' ] = $entry[ 'form_id' ]; |
|
420 | + $data[ 'entry_id' ] = $duplicated_id; |
|
421 | 421 | |
422 | 422 | if ( ! $wpdb->insert( $entry_meta_table, $data ) ) { |
423 | 423 | return new WP_Error( 'gravityview-duplicate-entry-db', __( 'Database error', 'gravityview' ) ); |
@@ -450,13 +450,13 @@ discard block |
||
450 | 450 | public function verify_nonce() { |
451 | 451 | |
452 | 452 | // No duplicate entry request was made |
453 | - if ( empty( $_GET['entry_id'] ) || empty( $_GET['duplicate'] ) ) { |
|
453 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'duplicate' ] ) ) { |
|
454 | 454 | return false; |
455 | 455 | } |
456 | 456 | |
457 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
457 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
458 | 458 | |
459 | - $valid = wp_verify_nonce( $_GET['duplicate'], $nonce_key ); |
|
459 | + $valid = wp_verify_nonce( $_GET[ 'duplicate' ], $nonce_key ); |
|
460 | 460 | |
461 | 461 | /** |
462 | 462 | * @filter `gravityview/duplicate-entry/verify_nonce` Override Duplicate Entry nonce validation. Return true to declare nonce valid. |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | */ |
487 | 487 | $confirm = apply_filters( 'gravityview/duplicate-entry/confirm-text', $confirm ); |
488 | 488 | |
489 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
489 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | |
542 | 542 | $current_user = wp_get_current_user(); |
543 | 543 | |
544 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL; |
|
544 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL; |
|
545 | 545 | |
546 | 546 | // Or if they can duplicate any entries (as defined in Gravity Forms), we're good. |
547 | 547 | if ( GVCommon::has_cap( array( 'gravityforms_edit_entries' ), $entry_id ) ) { |
@@ -556,17 +556,17 @@ discard block |
||
556 | 556 | if ( ! empty( $field ) ) { |
557 | 557 | |
558 | 558 | // If capability is not defined, something is not right! |
559 | - if ( empty( $field['allow_duplicate_cap'] ) ) { |
|
559 | + if ( empty( $field[ 'allow_duplicate_cap' ] ) ) { |
|
560 | 560 | |
561 | 561 | gravityview()->log->error( 'Cannot read duplicate entry field caps', array( 'data' => $field ) ); |
562 | 562 | |
563 | 563 | return false; |
564 | 564 | } |
565 | 565 | |
566 | - if ( GVCommon::has_cap( $field['allow_duplicate_cap'] ) ) { |
|
566 | + if ( GVCommon::has_cap( $field[ 'allow_duplicate_cap' ] ) ) { |
|
567 | 567 | |
568 | 568 | // Do not return true if cap is read, as we need to check if the current user created the entry |
569 | - if ( $field['allow_duplicate_cap'] !== 'read' ) { |
|
569 | + if ( $field[ 'allow_duplicate_cap' ] !== 'read' ) { |
|
570 | 570 | return true; |
571 | 571 | } |
572 | 572 | |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | |
580 | 580 | } |
581 | 581 | |
582 | - if ( ! isset( $entry['created_by'] ) ) { |
|
582 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
583 | 583 | |
584 | 584 | gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
585 | 585 | |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | |
592 | 592 | $current_view = gravityview_get_current_view_data( $view_id ); |
593 | 593 | |
594 | - $user_duplicate = isset( $current_view['atts']['user_duplicate'] ) ? $current_view['atts']['user_duplicate'] : false; |
|
594 | + $user_duplicate = isset( $current_view[ 'atts' ][ 'user_duplicate' ] ) ? $current_view[ 'atts' ][ 'user_duplicate' ] : false; |
|
595 | 595 | |
596 | 596 | if ( empty( $user_duplicate ) ) { |
597 | 597 | |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | } |
603 | 603 | |
604 | 604 | // If the logged-in user is the same as the user who created the entry, we're good. |
605 | - if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
605 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
606 | 606 | |
607 | 607 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
608 | 608 | |
@@ -626,16 +626,16 @@ discard block |
||
626 | 626 | */ |
627 | 627 | public function display_message( $current_view_id = 0 ) { |
628 | 628 | |
629 | - if ( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
629 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
630 | 630 | return; |
631 | 631 | } |
632 | 632 | |
633 | 633 | // Entry wasn't duplicateded from current View |
634 | - if ( isset( $_GET['view_id'] ) && intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) { |
|
634 | + if ( isset( $_GET[ 'view_id' ] ) && intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) { |
|
635 | 635 | return; |
636 | 636 | } |
637 | 637 | |
638 | - $status = esc_attr( $_GET['status'] ); |
|
638 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
639 | 639 | $message_from_url = \GV\Utils::_GET( 'message' ); |
640 | 640 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
641 | 641 | $class = ''; |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | $message = apply_filters( 'gravityview/duplicate-entry/message', esc_attr( $message ), $status, $message_from_url ); |
665 | 665 | |
666 | 666 | // DISPLAY ERROR/SUCCESS MESSAGE |
667 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
667 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
668 | 668 | } |
669 | 669 | |
670 | 670 |