Completed
Push — develop ( 8ca23c...429df8 )
by Zack
06:51
created
includes/extensions/duplicate-entry/class-duplicate-entry.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
 	public function duplicate_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
116 116
 
117 117
 		// Always a link, never a filter, always same window
118
-		unset( $field_options['show_as_link'], $field_options['search_filter'], $field_options['new_window'] );
118
+		unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ], $field_options[ 'new_window' ] );
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	public static function get_duplicate_link( $entry, $view_id, $post_id = null ) {
248 248
 
249
-        $base = GravityView_API::directory_link( $post_id ? : $view_id, true );
249
+        $base = GravityView_API::directory_link( $post_id ?: $view_id, true );
250 250
 
251 251
 		if ( empty( $base ) ) {
252 252
 			gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) );
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
 
256 256
 		$actionurl = add_query_arg( array(
257 257
 			'action'	=> 'duplicate',
258
-			'entry_id'	=> $entry['id'],
258
+			'entry_id'	=> $entry[ 'id' ],
259 259
 			'gvid' => $view_id,
260 260
             'view_id' => $view_id,
261 261
 		), $base );
262 262
 
263
-		return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry['id'] ) ), $actionurl );
263
+		return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry[ 'id' ] ) ), $actionurl );
264 264
 	}
265 265
 
266 266
 	/**
@@ -281,12 +281,12 @@  discard block
 block discarded – undo
281 281
 	public function process_duplicate() {
282 282
 
283 283
 		// If the form is submitted
284
-		if ( ( ! isset( $_GET['action'] ) ) || 'duplicate' !== $_GET['action'] || ( ! isset( $_GET['entry_id'] ) ) ) {
284
+		if ( ( ! isset( $_GET[ 'action' ] ) ) || 'duplicate' !== $_GET[ 'action' ] || ( ! isset( $_GET[ 'entry_id' ] ) ) ) {
285 285
 			return;
286 286
 		}
287 287
 
288 288
 		// Make sure it's a GravityView request
289
-		$valid_nonce_key = wp_verify_nonce( \GV\Utils::_GET( 'duplicate' ), self::get_nonce_key( $_GET['entry_id'] ) );
289
+		$valid_nonce_key = wp_verify_nonce( \GV\Utils::_GET( 'duplicate' ), self::get_nonce_key( $_GET[ 'entry_id' ] ) );
290 290
 
291 291
 		if ( ! $valid_nonce_key ) {
292 292
 			gravityview()->log->debug( 'Duplicate entry not processed: nonce validation failed.' );
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		}
295 295
 
296 296
 		// Get the entry slug
297
-		$entry_slug = esc_attr( $_GET['entry_id'] );
297
+		$entry_slug = esc_attr( $_GET[ 'entry_id' ] );
298 298
 
299 299
 		// See if there's an entry there
300 300
 		$entry = gravityview_get_entry( $entry_slug, true, false );
@@ -388,17 +388,17 @@  discard block
 block discarded – undo
388 388
 			return new WP_Error( 'gravityview-duplicate-entry-missing', __( 'The entry does not exist.', 'gravityview' ) );
389 389
 		}
390 390
 
391
-		$form = GFAPI::get_form( $entry['form_id'] );
391
+		$form = GFAPI::get_form( $entry[ 'form_id' ] );
392 392
 
393
-		$row['id'] = null;
394
-		$row['date_created'] = date( 'Y-m-d H:i:s', time() );
395
-		$row['date_updated'] = $row['date_created'];
396
-		$row['is_starred'] = false;
397
-		$row['is_read'] = false;
398
-		$row['ip'] = rgars( $form, 'personalData/preventIP' ) ? '' : GFFormsModel::get_ip();
399
-		$row['source_url'] = esc_url_raw( remove_query_arg( array( 'action', 'gvid', 'result', 'duplicate', 'entry_id' ) ) );
400
-		$row['user_agent'] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' );
401
-		$row['created_by'] = wp_get_current_user()->ID;
393
+		$row[ 'id' ] = null;
394
+		$row[ 'date_created' ] = date( 'Y-m-d H:i:s', time() );
395
+		$row[ 'date_updated' ] = $row[ 'date_created' ];
396
+		$row[ 'is_starred' ] = false;
397
+		$row[ 'is_read' ] = false;
398
+		$row[ 'ip' ] = rgars( $form, 'personalData/preventIP' ) ? '' : GFFormsModel::get_ip();
399
+		$row[ 'source_url' ] = esc_url_raw( remove_query_arg( array( 'action', 'gvid', 'result', 'duplicate', 'entry_id' ) ) );
400
+		$row[ 'user_agent' ] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' );
401
+		$row[ 'created_by' ] = wp_get_current_user()->ID;
402 402
 
403 403
 		/**
404 404
 		 * @filter `gravityview/entry/duplicate/details` Modify the new entry details before it's created.
@@ -426,15 +426,15 @@  discard block
 block discarded – undo
426 426
 
427 427
 		$save_this_meta = array();
428 428
 		foreach ( $duplicate_meta->get_output() as $m ) {
429
-			$save_this_meta[] = array(
430
-				'meta_key' => $m['meta_key'],
431
-				'meta_value' => $m['meta_value'],
432
-				'item_index' => $m['item_index'],
429
+			$save_this_meta[ ] = array(
430
+				'meta_key' => $m[ 'meta_key' ],
431
+				'meta_value' => $m[ 'meta_value' ],
432
+				'item_index' => $m[ 'item_index' ],
433 433
 			);
434 434
 		}
435 435
 
436 436
 		// Update the row ID for later usage
437
-		$row['id'] = $duplicated_id;
437
+		$row[ 'id' ] = $duplicated_id;
438 438
 
439 439
 		/**
440 440
 		 * @filter `gravityview/entry/duplicate/meta` Modify the new entry meta details.
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 		$save_this_meta = apply_filters( 'gravityview/entry/duplicate/meta', $save_this_meta, $row, $entry );
446 446
 
447 447
 		foreach ( $save_this_meta as $data ) {
448
-			$data['form_id'] = $entry['form_id'];
449
-			$data['entry_id'] = $duplicated_id;
448
+			$data[ 'form_id' ] = $entry[ 'form_id' ];
449
+			$data[ 'entry_id' ] = $duplicated_id;
450 450
 
451 451
 			if ( ! $wpdb->insert( $entry_meta_table, $data ) ) {
452 452
 				return new WP_Error( 'gravityview-duplicate-entry-db-meta', __( 'There was an error duplicating the entry.', 'gravityview' ) );
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
 	public function verify_nonce() {
481 481
 
482 482
 		// No duplicate entry request was made
483
-		if ( empty( $_GET['entry_id'] ) || empty( $_GET['duplicate'] ) ) {
483
+		if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'duplicate' ] ) ) {
484 484
 			return false;
485 485
 		}
486 486
 
487
-		$nonce_key = self::get_nonce_key( $_GET['entry_id'] );
487
+		$nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] );
488 488
 
489
-		$valid = wp_verify_nonce( $_GET['duplicate'], $nonce_key );
489
+		$valid = wp_verify_nonce( $_GET[ 'duplicate' ], $nonce_key );
490 490
 
491 491
 		/**
492 492
 		 * @filter `gravityview/duplicate-entry/verify_nonce` Override Duplicate Entry nonce validation. Return true to declare nonce valid.
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 			return '';
523 523
 		}
524 524
 
525
-		return 'return window.confirm(\''. esc_js( $confirm ) .'\');';
525
+		return 'return window.confirm(\'' . esc_js( $confirm ) . '\');';
526 526
 	}
527 527
 
528 528
 	/**
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	public static function check_user_cap_duplicate_entry( $entry, $field = array(), $view_id = 0 ) {
577 577
 		$current_user = wp_get_current_user();
578 578
 
579
-		$entry_id = isset( $entry['id'] ) ? $entry['id'] : null;
579
+		$entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : null;
580 580
 
581 581
 		// Or if they can duplicate any entries (as defined in Gravity Forms), we're good.
582 582
 		if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gform_full_access', 'gravityview_full_access' ), $entry_id ) ) {
@@ -591,17 +591,17 @@  discard block
 block discarded – undo
591 591
 		if ( ! empty( $field ) ) {
592 592
 
593 593
 			// If capability is not defined, something is not right!
594
-			if ( empty( $field['allow_duplicate_cap'] ) ) {
594
+			if ( empty( $field[ 'allow_duplicate_cap' ] ) ) {
595 595
 
596 596
 				gravityview()->log->error( 'Cannot read duplicate entry field caps', array( 'data' => $field ) );
597 597
 
598 598
 				return false;
599 599
 			}
600 600
 
601
-			if ( GVCommon::has_cap( $field['allow_duplicate_cap'] ) ) {
601
+			if ( GVCommon::has_cap( $field[ 'allow_duplicate_cap' ] ) ) {
602 602
 
603 603
 				// Do not return true if cap is read, as we need to check if the current user created the entry
604
-				if ( 'read' !== $field['allow_duplicate_cap'] ) {
604
+				if ( 'read' !== $field[ 'allow_duplicate_cap' ] ) {
605 605
 					return true;
606 606
 				}
607 607
 
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 
615 615
 		}
616 616
 
617
-		if ( ! isset( $entry['created_by'] ) ) {
617
+		if ( ! isset( $entry[ 'created_by' ] ) ) {
618 618
 
619 619
 			gravityview()->log->error( 'Cannot duplicate entry; entry `created_by` doesn\'t exist.' );
620 620
 
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 		}
640 640
 
641 641
 		// If the logged-in user is the same as the user who created the entry, we're good.
642
-		if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
642
+		if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) {
643 643
 
644 644
 			gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) );
645 645
 
@@ -663,12 +663,12 @@  discard block
 block discarded – undo
663 663
 	 * @return void
664 664
 	 */
665 665
 	public function maybe_display_message( $current_view_id = 0 ) {
666
-		if ( empty( $_GET['status'] ) || ! self::verify_nonce() ) {
666
+		if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) {
667 667
 			return;
668 668
 		}
669 669
 
670 670
 		// Entry wasn't duplicated from current View
671
-		if ( isset( $_GET['view_id'] ) && ( intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) ) {
671
+		if ( isset( $_GET[ 'view_id' ] ) && ( intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) ) {
672 672
 			return;
673 673
 		}
674 674
 
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
 	}
677 677
 
678 678
 	public function display_message() {
679
-		if ( empty( $_GET['status'] ) || empty( $_GET['duplicate'] ) ) {
679
+		if ( empty( $_GET[ 'status' ] ) || empty( $_GET[ 'duplicate' ] ) ) {
680 680
 			return;
681 681
 		}
682 682
 
683
-		$status = esc_attr( $_GET['status'] );
683
+		$status = esc_attr( $_GET[ 'status' ] );
684 684
 		$message_from_url = \GV\Utils::_GET( 'message' );
685 685
 		$message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) );
686 686
 		$class = '';
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 		$message = apply_filters( 'gravityview/duplicate-entry/message', esc_attr( $message ), $status, $message_from_url );
707 707
 
708 708
 		// DISPLAY ERROR/SUCCESS MESSAGE
709
-		echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>';
709
+		echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>';
710 710
 	}
711 711
 
712 712
 	/**
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 		?>
738 738
 		<span class="gv-duplicate">
739 739
 			|
740
-			<a href="<?php echo wp_nonce_url( add_query_arg( 'entry_id', $entry['id'] ), self::get_nonce_key( $entry['id'] ), 'duplicate' ); ?>"><?php esc_html_e( 'Duplicate', 'gravityview' ); ?></a>
740
+			<a href="<?php echo wp_nonce_url( add_query_arg( 'entry_id', $entry[ 'id' ] ), self::get_nonce_key( $entry[ 'id' ] ), 'duplicate' ); ?>"><?php esc_html_e( 'Duplicate', 'gravityview' ); ?></a>
741 741
 		</span>
742 742
 		<?php
743 743
 	}
@@ -759,9 +759,9 @@  discard block
 block discarded – undo
759 759
 
760 760
 		if ( 'success' === \GV\Utils::_GET( 'result' ) ) {
761 761
 			add_filter( 'gform_admin_messages', function( $messages ) {
762
-				$messages = (array) $messages;
762
+				$messages = (array)$messages;
763 763
 
764
-				$messages[] = esc_html__( 'Entry duplicated.', 'gravityview' );
764
+				$messages[ ] = esc_html__( 'Entry duplicated.', 'gravityview' );
765 765
 				return $messages;
766 766
 			} );
767 767
 		}
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 
773 773
 			$check_logs_message = '';
774 774
 
775
-			if( $is_logging_active ) {
775
+			if ( $is_logging_active ) {
776 776
 				$check_logs_message = sprintf( ' <a href="%s">%s</a>',
777 777
 					esc_url( admin_url( 'admin.php?page=gf_settings&subview=gravityformslogging' ) ),
778 778
 					esc_html_x( 'Check the GravityView logs for more information.', 'Error message links to logging page', 'gravityview' )
@@ -780,9 +780,9 @@  discard block
 block discarded – undo
780 780
 			}
781 781
 
782 782
 			add_filter( 'gform_admin_error_messages', function( $messages ) use ( $check_logs_message ) {
783
-				$messages = (array) $messages;
783
+				$messages = (array)$messages;
784 784
 
785
-				$messages[] = esc_html__( 'There was an error duplicating the entry.', 'gravityview' ) . $check_logs_message;
785
+				$messages[ ] = esc_html__( 'There was an error duplicating the entry.', 'gravityview' ) . $check_logs_message;
786 786
 
787 787
 				return $messages;
788 788
 			} );
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-locking.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -67,20 +67,20 @@  discard block
 block discarded – undo
67 67
 		$result = array();
68 68
 		if ( ! $lock_holder_user_id ) {
69 69
 			$this->set_lock( $object_id );
70
-			$result['html']   = __( 'You now have control', 'gravityforms' );
71
-			$result['status'] = 'lock_obtained';
70
+			$result[ 'html' ]   = __( 'You now have control', 'gravityforms' );
71
+			$result[ 'status' ] = 'lock_obtained';
72 72
 		} else {
73 73
 
74
-			if( GVCommon::has_cap( 'gravityforms_edit_entries' ) ) {
74
+			if ( GVCommon::has_cap( 'gravityforms_edit_entries' ) ) {
75 75
 				$user = get_userdata( $lock_holder_user_id );
76
-				$result['html']   = sprintf( __( 'Your request has been sent to %s.', 'gravityforms' ), $user->display_name );
76
+				$result[ 'html' ]   = sprintf( __( 'Your request has been sent to %s.', 'gravityforms' ), $user->display_name );
77 77
 			} else {
78
-				$result['html']   = __( 'Your request has been sent.', 'gravityforms' );
78
+				$result[ 'html' ]   = __( 'Your request has been sent.', 'gravityforms' );
79 79
 			}
80 80
 
81 81
 			$this->update_lock_request_meta( $object_id, $user_id );
82 82
 
83
-			$result['status'] = 'lock_requested';
83
+			$result[ 'status' ] = 'lock_requested';
84 84
 		}
85 85
 
86 86
 		return $result;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			return;
106 106
 		}
107 107
 
108
-		$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET['gform_debug'] ) ? '' : '.min';
108
+		$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET[ 'gform_debug' ] ) ? '' : '.min';
109 109
 		$locking_path = GFCommon::get_base_url() . '/includes/locking/';
110 110
 
111 111
 		wp_enqueue_script( 'gforms_locking', $locking_path . "js/locking{$min}.js", array( 'jquery', 'heartbeat' ), GFCommon::$version );
@@ -114,20 +114,20 @@  discard block
 block discarded – undo
114 114
 		$translations = array_map( 'wp_strip_all_tags', $this->get_strings() );
115 115
 
116 116
 		$strings = array(
117
-			'noResponse'    => $translations['no_response'],
118
-			'requestAgain'  => $translations['request_again'],
119
-			'requestError'  => $translations['request_error'],
120
-			'gainedControl' => $translations['gained_control'],
121
-			'rejected'      => $translations['request_rejected'],
122
-			'pending'       => $translations['request_pending'],
117
+			'noResponse'    => $translations[ 'no_response' ],
118
+			'requestAgain'  => $translations[ 'request_again' ],
119
+			'requestError'  => $translations[ 'request_error' ],
120
+			'gainedControl' => $translations[ 'gained_control' ],
121
+			'rejected'      => $translations[ 'request_rejected' ],
122
+			'pending'       => $translations[ 'request_pending' ],
123 123
 		);
124 124
 
125
-		$lock_user_id = $this->check_lock( $entry['id'] );
125
+		$lock_user_id = $this->check_lock( $entry[ 'id' ] );
126 126
 
127 127
 		$vars = array(
128 128
 			'hasLock'    => ! $lock_user_id ? 1 : 0,
129 129
 			'lockUI'     => $this->get_lock_ui( $lock_user_id ),
130
-			'objectID'   => $entry['id'],
130
+			'objectID'   => $entry[ 'id' ],
131 131
 			'objectType' => 'entry',
132 132
 			'strings'    => $strings,
133 133
 		);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		$hidden = $locked ? '' : ' hidden';
158 158
 		if ( $locked ) {
159 159
 
160
-			if( GVCommon::has_cap( 'gravityforms_edit_entries' ) ) {
160
+			if ( GVCommon::has_cap( 'gravityforms_edit_entries' ) ) {
161 161
 				$avatar = get_avatar( $user->ID, 64 );
162 162
 				$person_editing_text = $user->display_name;
163 163
 			} else {
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 
265 265
 		$current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
266 266
 
267
-		if ( isset( $_GET['get-edit-lock'] ) ) {
267
+		if ( isset( $_GET[ 'get-edit-lock' ] ) ) {
268 268
 			$this->set_lock( $entry_id );
269 269
 			echo '<script>window.location = ' . json_encode( remove_query_arg( 'get-edit-lock', $current_url ) ) . ';</script>';
270 270
 			exit();
271
-		} else if ( isset( $_GET['release-edit-lock'] ) ) {
271
+		} else if ( isset( $_GET[ 'release-edit-lock' ] ) ) {
272 272
 			$this->delete_lock_meta( $entry_id );
273 273
 			$current_url = remove_query_arg( 'edit', $current_url );
274 274
 			echo '<script>window.location = ' . json_encode( remove_query_arg( 'release-edit-lock', $current_url ) ) . ';</script>';
Please login to merge, or discard this patch.