Completed
Pull Request — master (#822)
by Zack
35:06 queued 31:16
created
includes/class-oembed.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -211,6 +211,7 @@
 block discarded – undo
211 211
 	 * @var $view_id
212 212
 	 *
213 213
 	 * @see render_handler
214
+	 * @param string $url
214 215
 	 */
215 216
 	private function set_vars( $matches, $attr, $url, $rawattr ) {
216 217
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	static function getInstance() {
44 44
 
45
-		if( empty( self::$instance ) ) {
45
+		if ( empty( self::$instance ) ) {
46 46
 			self::$instance = new self;
47 47
 
48 48
 			self::$instance->initialize();
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		// Catch either
95 95
 		$match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})";
96 96
 
97
-		return '#'.$match_regex.'#i';
97
+		return '#' . $match_regex . '#i';
98 98
 	}
99 99
 
100 100
 	/**
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$post_id = url_to_postid( $url );
115 115
 
116
-		if( empty( $post_id ) ) {
116
+		if ( empty( $post_id ) ) {
117 117
 
118 118
 			$args = array(
119 119
 				'post_status' => 'publish',
120 120
 				'name' => $slug,
121
-				'post_type' => array('any', 'gravityview'),
121
+				'post_type' => array( 'any', 'gravityview' ),
122 122
 			);
123 123
 
124 124
 			$posts = get_posts( $args );
125 125
 
126
-			if( !empty( $posts ) ) {
127
-				$post_id = $posts[0]->ID;
126
+			if ( ! empty( $posts ) ) {
127
+				$post_id = $posts[ 0 ]->ID;
128 128
 			}
129 129
 		}
130 130
 
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
 	public function render_handler( $matches, $attr, $url, $rawattr ) {
158 158
 
159 159
 		// If not using permalinks, re-assign values for matching groups
160
-		if( !empty( $matches['entry_slug2'] ) ) {
161
-			$matches['is_cpt'] = $matches['is_cpt2'];
162
-			$matches['slug'] = $matches['slug2'];
163
-			$matches['entry_slug'] = $matches['entry_slug2'];
164
-			unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] );
160
+		if ( ! empty( $matches[ 'entry_slug2' ] ) ) {
161
+			$matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ];
162
+			$matches[ 'slug' ] = $matches[ 'slug2' ];
163
+			$matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ];
164
+			unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] );
165 165
 		}
166 166
 
167 167
 		// No Entry was found
168
-		if( empty( $matches['entry_slug'] ) ) {
168
+		if ( empty( $matches[ 'entry_slug' ] ) ) {
169 169
 
170
-			do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches );
170
+			do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches );
171 171
 
172 172
 			return '';
173 173
 		}
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 		// Setup the data used
178 178
 		$this->set_vars( $matches, $attr, $url, $rawattr );
179 179
 
180
-		if( is_admin() && !$this->is_full_oembed_preview ) {
180
+		if ( is_admin() && ! $this->is_full_oembed_preview ) {
181 181
 			$return = $this->render_admin( $matches, $attr, $url, $rawattr );
182 182
 		} else {
183 183
 
184
-			if( $this->is_full_oembed_preview ) {
184
+			if ( $this->is_full_oembed_preview ) {
185 185
 				$return .= $this->generate_preview_notice();
186 186
 			}
187 187
 
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	private function generate_preview_notice() {
201 201
 		$floaty = GravityView_Admin::get_floaty();
202 202
 		$title = esc_html__( 'This will look better when it is embedded.', 'gravityview' );
203
-		$message = esc_html__('Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview');
204
-		return '<div class="updated notice">'. $floaty. '<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>';
203
+		$message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' );
204
+		return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>';
205 205
 	}
206 206
 
207 207
 	/**
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	private function set_vars( $matches, $attr, $url, $rawattr ) {
216 216
 
217
-		$this->entry_id = $matches['entry_slug'];
217
+		$this->entry_id = $matches[ 'entry_slug' ];
218 218
 
219
-		$post_id = $this->get_postid_from_url_and_slug( $url, $matches['slug'] );
219
+		$post_id = $this->get_postid_from_url_and_slug( $url, $matches[ 'slug' ] );
220 220
 
221 221
 		// The URL didn't have the View Custom Post Type structure.
222
-		if( empty( $matches['is_cpt'] ) || $matches['is_cpt'] !== 'gravityview' ) {
222
+		if ( empty( $matches[ 'is_cpt' ] ) || $matches[ 'is_cpt' ] !== 'gravityview' ) {
223 223
 
224
-			do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches );
224
+			do_action( 'gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches );
225 225
 
226 226
 			$this->view_id = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id );
227 227
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		}
233 233
 
234 234
 		// The inline content has $_POST['type'] set to "embed", while the "Add Media" modal doesn't set that.
235
-		$this->is_full_oembed_preview = ( isset( $_POST['action'] ) && $_POST['action'] === 'parse-embed' && !isset( $_POST['type'] ) );
235
+		$this->is_full_oembed_preview = ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] === 'parse-embed' && ! isset( $_POST[ 'type' ] ) );
236 236
 	}
237 237
 
238 238
 	/**
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 		// Floaty the astronaut
251 251
 		$image = GravityView_Admin::get_floaty();
252 252
 
253
-		$embed_heading = sprintf( esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id );
253
+		$embed_heading = sprintf( esc_html__( 'Embed Entry %d', 'gravityview' ), $this->entry_id );
254 254
 
255
-		$embed_text = sprintf( esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id );
255
+		$embed_text = sprintf( esc_html__( 'This entry will be displayed as it is configured in View %d', 'gravityview' ), $this->view_id );
256 256
 
257 257
 		return '
258 258
 		<div class="loading-placeholder" style="background-color:#e6f0f5;">
259
-			<h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image.$embed_heading.'</h3>
259
+			<h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image . $embed_heading . '</h3>
260 260
 			<p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">
261
-				'.$embed_text.'
261
+				'.$embed_text . '
262 262
 			</p>
263 263
 			<br style="clear: both;">
264 264
 		</div>';
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
 	private function render_frontend( $matches, $attr, $url, $rawattr ) {
314 314
 
315 315
 		// If it's already been parsed, don't re-output it.
316
-		if( !empty( $this->output[ $this->entry_id ] ) ) {
316
+		if ( ! empty( $this->output[ $this->entry_id ] ) ) {
317 317
 			return $this->output[ $this->entry_id ];
318 318
 		}
319 319
 
320 320
 		$entry_output = $this->generate_entry_output();
321 321
 
322 322
 		// Wrap a container div around the output to allow for custom styling
323
-		$output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output );
323
+		$output = sprintf( '<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-' . $this->entry_id . '">%s</div>', $entry_output );
324 324
 
325 325
 		/**
326 326
 		 * @filter `gravityview/oembed/entry` Filter the output of the oEmbed entry embed
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		 *  @var string $url The original URL that was matched by the regex. \n
334 334
 		 *  @var array $rawattr The original unmodified attributes.
335 335
 		 */
336
-		$output = apply_filters('gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) );
336
+		$output = apply_filters( 'gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) );
337 337
 
338 338
 		unset( $entry_output );
339 339
 
Please login to merge, or discard this patch.
includes/extensions/delete-entry/class-delete-entry.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -170,7 +170,6 @@
 block discarded – undo
170 170
 	 *
171 171
 	 * @since 1.5.1
172 172
 	 * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
173
-	 * @param  string      $field_type  Type of field options to render (`field` or `widget`)
174 173
 	 * @param  string      $template_id Table slug
175 174
 	 * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
176 175
 	 * @param  string      $context     What context are we in? Example: `single` or `directory`
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 		self::getInstance()->set_entry( $entry );
230 230
 
231
-        $base = GravityView_API::directory_link( $post_id, true );
231
+		$base = GravityView_API::directory_link( $post_id, true );
232 232
 
233 233
 		if( empty( $base ) ) {
234 234
 			do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id );
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 		// Use the slug instead of the ID for consistent security
239 239
 		$entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry );
240 240
 
241
-        $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;
241
+		$view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;
242 242
 
243 243
 		$actionurl = add_query_arg( array(
244 244
 			'action'	=> 'delete',
245 245
 			'entry_id'		=> $entry_slug,
246 246
 			'gvid' => $view_id,
247
-            'view_id' => $view_id,
247
+			'view_id' => $view_id,
248 248
 		), $base );
249 249
 
250 250
 		$url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' );
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 				 * @action `gravityview/delete-entry/deleted` Triggered when an entry is deleted
416 416
 				 * @since 1.16.4
417 417
 				 * @param  int $entry_id ID of the Gravity Forms entry
418
-				*/
418
+				 */
419 419
 				do_action( 'gravityview/delete-entry/deleted', $entry_id );
420 420
 			}
421 421
 
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 
43 43
 		add_action( 'wp', array( $this, 'process_delete' ), 10000 );
44 44
 
45
-		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field'), 10, 3 );
45
+		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
46 46
 
47 47
 		add_action( 'gravityview_before', array( $this, 'display_message' ) );
48 48
 
49 49
 		// For the Delete Entry Link, you don't want visible to all users.
50
-		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps'), 10, 5 );
50
+		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
51 51
 
52 52
 		// Modify the field options based on the name of the field type
53 53
 		add_filter( 'gravityview_template_delete_link_options', array( $this, 'delete_link_field_options' ), 10, 5 );
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 		// add template path to check for field
56 56
 		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
57 57
 
58
-		add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button'), 10, 3 );
58
+		add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button' ), 10, 3 );
59 59
 
60
-		add_action ( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 );
61
-		add_action ( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 );
60
+		add_action( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 );
61
+		add_action( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 );
62 62
 	}
63 63
 
64 64
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	static function getInstance() {
71 71
 
72
-		if( empty( self::$instance ) ) {
72
+		if ( empty( self::$instance ) ) {
73 73
 			self::$instance = new self;
74 74
 		}
75 75
 
@@ -105,20 +105,20 @@  discard block
 block discarded – undo
105 105
 	function delete_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
106 106
 
107 107
 		// Always a link, never a filter
108
-		unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
+		unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] );
109 109
 
110 110
 		// Delete Entry link should only appear to visitors capable of editing entries
111
-		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
+		unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
112 112
 
113
-		$add_option['delete_link'] = array(
113
+		$add_option[ 'delete_link' ] = array(
114 114
 			'type' => 'text',
115 115
 			'label' => __( 'Delete Link Text', 'gravityview' ),
116 116
 			'desc' => NULL,
117
-			'value' => __('Delete Entry', 'gravityview'),
117
+			'value' => __( 'Delete Entry', 'gravityview' ),
118 118
 			'merge_tags' => true,
119 119
 		);
120 120
 
121
-		$field_options['allow_edit_cap'] = array(
121
+		$field_options[ 'allow_edit_cap' ] = array(
122 122
 			'type' => 'select',
123 123
 			'label' => __( 'Allow the following users to delete the entry:', 'gravityview' ),
124 124
 			'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
144 144
 
145
-		if( 'edit' !== $zone ) {
146
-			$entry_default_fields['delete_link'] = array(
145
+		if ( 'edit' !== $zone ) {
146
+			$entry_default_fields[ 'delete_link' ] = array(
147 147
 				'label' => __( 'Delete Entry', 'gravityview' ),
148 148
 				'type'  => 'delete_link',
149 149
 				'desc'  => __( 'A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview' ),
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	function add_available_field( $available_fields = array() ) {
162 162
 
163
-		$available_fields['delete_link'] = array(
163
+		$available_fields[ 'delete_link' ] = array(
164 164
 			'label_text' => __( 'Delete Entry', 'gravityview' ),
165 165
 			'field_id' => 'delete_link',
166 166
 			'label_type' => 'field',
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
 		$caps = $visibility_caps;
189 189
 
190 190
 		// If we're configuring fields in the edit context, we want a limited selection
191
-		if( $field_id === 'delete_link' ) {
191
+		if ( $field_id === 'delete_link' ) {
192 192
 
193 193
 			// Remove other built-in caps.
194
-			unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
194
+			unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] );
195 195
 
196
-			$caps['read'] = _x('Entry Creator', 'User capability', 'gravityview');
196
+			$caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' );
197 197
 		}
198 198
 
199 199
 		return $caps;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 * @param [type] $entry [description]
207 207
 	 */
208 208
 	function set_entry( $entry = null ) {
209
-		$this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry;
209
+		$this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[ 0 ] : $entry;
210 210
 	}
211 211
 
212 212
 	/**
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 
237 237
         $base = GravityView_API::directory_link( $post_id, true );
238 238
 
239
-		if( empty( $base ) ) {
240
-			do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id );
239
+		if ( empty( $base ) ) {
240
+			do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: ' . $post_id );
241 241
 			return NULL;
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
         $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;
248 248
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
             'view_id' => $view_id,
254 254
 		), $base );
255 255
 
256
-		$url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' );
256
+		$url = wp_nonce_url( $actionurl, 'delete_' . $entry_slug, 'delete' );
257 257
 
258 258
 		return $url;
259 259
 	}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	function add_delete_button( $form = array(), $entry = array(), $view_id = NULL ) {
271 271
 
272 272
 		// Only show the link to those who are allowed to see it.
273
-		if( !self::check_user_cap_delete_entry( $entry ) ) {
273
+		if ( ! self::check_user_cap_delete_entry( $entry ) ) {
274 274
 			return;
275 275
 		}
276 276
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 		$show_delete_button = apply_filters( 'gravityview/delete-entry/show-delete-button', true );
282 282
 
283 283
 		// If the button is hidden by the filter, don't show.
284
-		if( !$show_delete_button ) {
284
+		if ( ! $show_delete_button ) {
285 285
 			return;
286 286
 		}
287 287
 
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
 	function process_delete() {
312 312
 
313 313
 		// If the form is submitted
314
-		if( isset( $_GET['action'] ) && 'delete' === $_GET['action'] && isset( $_GET['entry_id'] ) ) {
314
+		if ( isset( $_GET[ 'action' ] ) && 'delete' === $_GET[ 'action' ] && isset( $_GET[ 'entry_id' ] ) ) {
315 315
 
316 316
 			// Make sure it's a GravityView request
317
-			$valid_nonce_key = wp_verify_nonce( $_GET['delete'], self::get_nonce_key( $_GET['entry_id'] ) );
317
+			$valid_nonce_key = wp_verify_nonce( $_GET[ 'delete' ], self::get_nonce_key( $_GET[ 'entry_id' ] ) );
318 318
 
319
-			if( ! $valid_nonce_key ) {
320
-				do_action('gravityview_log_debug', __METHOD__ . ' Delete entry not processed: nonce validation failed.' );
319
+			if ( ! $valid_nonce_key ) {
320
+				do_action( 'gravityview_log_debug', __METHOD__ . ' Delete entry not processed: nonce validation failed.' );
321 321
 				return;
322 322
 			}
323 323
 
324 324
 			// Get the entry slug
325
-			$entry_slug = esc_attr( $_GET['entry_id'] );
325
+			$entry_slug = esc_attr( $_GET[ 'entry_id' ] );
326 326
 
327 327
 			// See if there's an entry there
328 328
 			$entry = gravityview_get_entry( $entry_slug );
329 329
 
330
-			if( $entry ) {
330
+			if ( $entry ) {
331 331
 
332 332
 				$has_permission = $this->user_can_delete_entry( $entry );
333 333
 
334
-				if( is_wp_error( $has_permission ) ) {
334
+				if ( is_wp_error( $has_permission ) ) {
335 335
 
336 336
 					$messages = array(
337 337
 						'message' => urlencode( $has_permission->get_error_message() ),
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 					// Delete the entry
344 344
 					$delete_response = $this->delete_or_trash_entry( $entry );
345 345
 
346
-					if( is_wp_error( $delete_response ) ) {
346
+					if ( is_wp_error( $delete_response ) ) {
347 347
 
348 348
 						$messages = array(
349 349
 							'message' => urlencode( $delete_response->get_error_message() ),
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 
363 363
 			} else {
364 364
 
365
-				do_action('gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug '. $entry_slug );
365
+				do_action( 'gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug ' . $entry_slug );
366 366
 
367 367
 				$messages = array(
368
-					'message' => urlencode( __('The entry does not exist.', 'gravityview') ),
368
+					'message' => urlencode( __( 'The entry does not exist.', 'gravityview' ) ),
369 369
 					'status' => 'error',
370 370
 				);
371 371
 			}
@@ -405,18 +405,18 @@  discard block
 block discarded – undo
405 405
 	 */
406 406
 	private function delete_or_trash_entry( $entry ) {
407 407
 
408
-		$entry_id = $entry['id'];
408
+		$entry_id = $entry[ 'id' ];
409 409
 		
410 410
 		$mode = $this->get_delete_mode();
411 411
 
412
-		if( 'delete' === $mode ) {
412
+		if ( 'delete' === $mode ) {
413 413
 
414 414
 			do_action( 'gravityview_log_debug', __METHOD__ . ' Starting delete entry: ', $entry_id );
415 415
 
416 416
 			// Delete the entry
417 417
 			$delete_response = GFAPI::delete_entry( $entry_id );
418 418
 
419
-			if( ! is_wp_error( $delete_response ) ) {
419
+			if ( ! is_wp_error( $delete_response ) ) {
420 420
 				$delete_response = 'deleted';
421 421
 
422 422
 				/**
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 			$trashed = GFAPI::update_entry_property( $entry_id, 'status', 'trash' );
438 438
 			new GravityView_Cache;
439 439
 
440
-			if( ! $trashed ) {
441
-				$delete_response = new WP_Error( 'trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview' ) );
440
+			if ( ! $trashed ) {
441
+				$delete_response = new WP_Error( 'trash_entry_failed', __( 'Moving the entry to the trash failed.', 'gravityview' ) );
442 442
 			} else {
443 443
 
444 444
 				/**
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 	public function process_connected_posts( $entry_id = 0, $entry = array() ) {
470 470
 
471 471
 		// The entry had no connected post
472
-		if( empty( $entry['post_id'] ) ) {
472
+		if ( empty( $entry[ 'post_id' ] ) ) {
473 473
 			return;
474 474
 		}
475 475
 
@@ -480,22 +480,22 @@  discard block
 block discarded – undo
480 480
 		 */
481 481
 		$delete_post = apply_filters( 'gravityview/delete-entry/delete-connected-post', true );
482 482
 		
483
-		if( false === $delete_post ) {
483
+		if ( false === $delete_post ) {
484 484
 			return;
485 485
 		}
486 486
 
487 487
 		$action = current_action();
488 488
 
489
-		if( 'gravityview/delete-entry/deleted' === $action ) {
490
-			$result = wp_delete_post( $entry['post_id'], true );
489
+		if ( 'gravityview/delete-entry/deleted' === $action ) {
490
+			$result = wp_delete_post( $entry[ 'post_id' ], true );
491 491
 		} else {
492
-			$result = wp_trash_post( $entry['post_id'] );
492
+			$result = wp_trash_post( $entry[ 'post_id' ] );
493 493
 		}
494 494
 
495
-		if( false === $result ) {
496
-			do_action( 'gravityview_log_error', __METHOD__ . ' (called by '.$action.'): Error processing the Post connected to the entry.', $entry );
495
+		if ( false === $result ) {
496
+			do_action( 'gravityview_log_error', __METHOD__ . ' (called by ' . $action . '): Error processing the Post connected to the entry.', $entry );
497 497
 		} else {
498
-			do_action( 'gravityview_log_debug', __METHOD__ . ' (called by '.$action.'): Successfully processed Post connected to the entry.', $entry );
498
+			do_action( 'gravityview_log_debug', __METHOD__ . ' (called by ' . $action . '): Successfully processed Post connected to the entry.', $entry );
499 499
 		}
500 500
 	}
501 501
 
@@ -508,13 +508,13 @@  discard block
 block discarded – undo
508 508
 	public function verify_nonce() {
509 509
 
510 510
 		// No delete entry request was made
511
-		if( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) {
511
+		if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'delete' ] ) ) {
512 512
 			return false;
513 513
 		}
514 514
 
515
-		$nonce_key = self::get_nonce_key( $_GET['entry_id'] );
515
+		$nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] );
516 516
 
517
-		$valid = wp_verify_nonce( $_GET['delete'], $nonce_key );
517
+		$valid = wp_verify_nonce( $_GET[ 'delete' ], $nonce_key );
518 518
 
519 519
 		/**
520 520
 		 * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid.
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	 */
537 537
 	public static function get_confirm_dialog() {
538 538
 
539
-		$confirm = __('Are you sure you want to delete this entry? This cannot be undone.', 'gravityview');
539
+		$confirm = __( 'Are you sure you want to delete this entry? This cannot be undone.', 'gravityview' );
540 540
 
541 541
 		/**
542 542
 		 * @filter `gravityview/delete-entry/confirm-text` Modify the Delete Entry Javascript confirmation text
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		 */
545 545
 		$confirm = apply_filters( 'gravityview/delete-entry/confirm-text', $confirm );
546 546
 
547
-		return 'return window.confirm(\''. esc_js( $confirm ) .'\');';
547
+		return 'return window.confirm(\'' . esc_js( $confirm ) . '\');';
548 548
 	}
549 549
 
550 550
 	/**
@@ -562,16 +562,16 @@  discard block
 block discarded – undo
562 562
 
563 563
 		$error = NULL;
564 564
 
565
-		if( ! $this->verify_nonce() ) {
566
-			$error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview');
565
+		if ( ! $this->verify_nonce() ) {
566
+			$error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview' );
567 567
 		}
568 568
 
569
-		if( ! self::check_user_cap_delete_entry( $entry ) ) {
570
-			$error = __( 'You do not have permission to delete this entry.', 'gravityview');
569
+		if ( ! self::check_user_cap_delete_entry( $entry ) ) {
570
+			$error = __( 'You do not have permission to delete this entry.', 'gravityview' );
571 571
 		}
572 572
 
573
-		if( $entry['status'] === 'trash' ) {
574
-			if( 'trash' === $this->get_delete_mode() ) {
573
+		if ( $entry[ 'status' ] === 'trash' ) {
574
+			if ( 'trash' === $this->get_delete_mode() ) {
575 575
 				$error = __( 'The entry is already in the trash.', 'gravityview' );
576 576
 			} else {
577 577
 				$error = __( 'You cannot delete the entry; it is already in the trash.', 'gravityview' );
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
 		}
580 580
 
581 581
 		// No errors; everything's fine here!
582
-		if( empty( $error ) ) {
582
+		if ( empty( $error ) ) {
583 583
 			return true;
584 584
 		}
585 585
 
586
-		do_action('gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error );
586
+		do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error );
587 587
 
588 588
 		return new WP_Error( 'gravityview-delete-entry-permissions', $error );
589 589
 	}
@@ -605,32 +605,32 @@  discard block
 block discarded – undo
605 605
 
606 606
 		$current_user = wp_get_current_user();
607 607
 
608
-		$entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL;
608
+		$entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL;
609 609
 
610 610
 		// Or if they can delete any entries (as defined in Gravity Forms), we're good.
611
-		if( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) {
611
+		if ( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) {
612 612
 
613
-			do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' );
613
+			do_action( 'gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' );
614 614
 
615 615
 			return true;
616 616
 		}
617 617
 
618 618
 
619 619
 		// If field options are passed, check if current user can view the link
620
-		if( !empty( $field ) ) {
620
+		if ( ! empty( $field ) ) {
621 621
 
622 622
 			// If capability is not defined, something is not right!
623
-			if( empty( $field['allow_edit_cap'] ) ) {
623
+			if ( empty( $field[ 'allow_edit_cap' ] ) ) {
624 624
 
625 625
 				do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Cannot read delete entry field caps', $field );
626 626
 
627 627
 				return false;
628 628
 			}
629 629
 
630
-			if( GVCommon::has_cap( $field['allow_edit_cap'] ) ) {
630
+			if ( GVCommon::has_cap( $field[ 'allow_edit_cap' ] ) ) {
631 631
 
632 632
 				// Do not return true if cap is read, as we need to check if the current user created the entry
633
-				if( $field['allow_edit_cap'] !== 'read' ) {
633
+				if ( $field[ 'allow_edit_cap' ] !== 'read' ) {
634 634
 					return true;
635 635
 				}
636 636
 
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 
644 644
 		}
645 645
 
646
-		if( !isset( $entry['created_by'] ) ) {
646
+		if ( ! isset( $entry[ 'created_by' ] ) ) {
647 647
 
648
-			do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.');
648
+			do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.' );
649 649
 
650 650
 			return false;
651 651
 		}
@@ -653,24 +653,24 @@  discard block
 block discarded – undo
653 653
 		$view_id = empty( $view_id ) ? $gravityview_view->getViewId() : $view_id;
654 654
 
655 655
 		// Only checks user_delete view option if view is already set
656
-		if( $view_id ) {
656
+		if ( $view_id ) {
657 657
 
658 658
 			$current_view = gravityview_get_current_view_data( $view_id );
659 659
 
660
-			$user_delete = isset( $current_view['atts']['user_delete'] ) ? $current_view['atts']['user_delete'] : false;
660
+			$user_delete = isset( $current_view[ 'atts' ][ 'user_delete' ] ) ? $current_view[ 'atts' ][ 'user_delete' ] : false;
661 661
 
662
-			if( empty( $user_delete ) ) {
662
+			if ( empty( $user_delete ) ) {
663 663
 
664
-				do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' );
664
+				do_action( 'gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' );
665 665
 
666 666
 				return false;
667 667
 			}
668 668
 		}
669 669
 
670 670
 		// If the logged-in user is the same as the user who created the entry, we're good.
671
-		if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
671
+		if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) {
672 672
 
673
-			do_action('gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) );
673
+			do_action( 'gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) );
674 674
 
675 675
 			return true;
676 676
 		}
@@ -693,31 +693,31 @@  discard block
 block discarded – undo
693 693
 	 */
694 694
 	public function display_message( $current_view_id = 0 ) {
695 695
 
696
-		if( empty( $_GET['status'] ) || ! self::verify_nonce() ) {
696
+		if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) {
697 697
 			return;
698 698
 		}
699 699
 
700 700
 		// Entry wasn't deleted from current View
701
-		if( intval( $_GET['gvid'] ) !== intval( $current_view_id ) ) {
701
+		if ( intval( $_GET[ 'gvid' ] ) !== intval( $current_view_id ) ) {
702 702
 			return;
703 703
 		}
704 704
 
705
-		$status = esc_attr( $_GET['status'] );
706
-		$message_from_url = rgget('message');
705
+		$status = esc_attr( $_GET[ 'status' ] );
706
+		$message_from_url = rgget( 'message' );
707 707
 		$message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) );
708 708
 		$class = '';
709 709
 
710 710
 		switch ( $status ) {
711 711
 			case 'error':
712 712
 				$class = ' gv-error error';
713
-				$error_message = __('There was an error deleting the entry: %s', 'gravityview');
713
+				$error_message = __( 'There was an error deleting the entry: %s', 'gravityview' );
714 714
 				$message = sprintf( $error_message, $message_from_url );
715 715
 				break;
716 716
 			case 'trashed':
717
-				$message = __('The entry was successfully moved to the trash.', 'gravityview');
717
+				$message = __( 'The entry was successfully moved to the trash.', 'gravityview' );
718 718
 				break;
719 719
 			default:
720
-				$message = __('The entry was successfully deleted.', 'gravityview');
720
+				$message = __( 'The entry was successfully deleted.', 'gravityview' );
721 721
 				break;
722 722
 		}
723 723
 
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 		$message = apply_filters( 'gravityview/delete-entry/message', esc_attr( $message ), $status, $message_from_url );
732 732
 
733 733
 		// DISPLAY ERROR/SUCCESS MESSAGE
734
-		echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>';
734
+		echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>';
735 735
 	}
736 736
 
737 737
 
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-admin.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,6 @@
 block discarded – undo
69 69
      * Change wording for the Edit context to read Entry Creator
70 70
      *
71 71
      * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
-     * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73 72
      * @param  string      $template_id Table slug
74 73
      * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75 74
      * @param  string      $context     What context are we in? Example: `single` or `directory`
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -10,175 +10,175 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 if ( ! defined( 'WPINC' ) ) {
13
-    die;
13
+	die;
14 14
 }
15 15
 
16 16
 
17 17
 class GravityView_Edit_Entry_Admin {
18 18
 
19
-    protected $loader;
19
+	protected $loader;
20 20
 
21
-    function __construct( GravityView_Edit_Entry $loader ) {
22
-        $this->loader = $loader;
23
-    }
21
+	function __construct( GravityView_Edit_Entry $loader ) {
22
+		$this->loader = $loader;
23
+	}
24 24
 
25
-    function load() {
26
-
27
-        if( !is_admin() ) {
28
-            return;
29
-        }
30
-
31
-        // Add Edit Link as a default field, outside those set in the Gravity Form form
32
-        add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
33
-
34
-        // For the Edit Entry Link, you don't want visible to all users.
35
-        add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
25
+	function load() {
26
+
27
+		if( !is_admin() ) {
28
+			return;
29
+		}
30
+
31
+		// Add Edit Link as a default field, outside those set in the Gravity Form form
32
+		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
33
+
34
+		// For the Edit Entry Link, you don't want visible to all users.
35
+		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
36 36
 
37
-        // Modify the field options based on the name of the field type
38
-        add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
37
+		// Modify the field options based on the name of the field type
38
+		add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
39 39
 
40
-        // add tooltips
41
-        add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
42
-
43
-        // custom fields' options for zone EDIT
44
-        add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
45
-    }
46
-
47
-    /**
48
-     * Add Edit Link as a default field, outside those set in the Gravity Form form
49
-     * @param array $entry_default_fields Existing fields
50
-     * @param  string|array $form form_ID or form object
51
-     * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
52
-     */
53
-    function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54
-
55
-        if( $zone !== 'edit' ) {
56
-
57
-            $entry_default_fields['edit_link'] = array(
58
-                'label' => __('Edit Entry', 'gravityview'),
59
-                'type' => 'edit_link',
60
-                'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
61
-            );
62
-
63
-        }
64
-
65
-        return $entry_default_fields;
66
-    }
67
-
68
-    /**
69
-     * Change wording for the Edit context to read Entry Creator
70
-     *
71
-     * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
-     * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73
-     * @param  string      $template_id Table slug
74
-     * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75
-     * @param  string      $context     What context are we in? Example: `single` or `directory`
76
-     * @param  string      $input_type  (textarea, list, select, etc.)
77
-     * @return array                   Array of field options with `label`, `value`, `type`, `default` keys
78
-     */
79
-    function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
80
-
81
-        $caps = $visibility_caps;
82
-
83
-        // If we're configuring fields in the edit context, we want a limited selection
84
-        if( $context === 'edit' ) {
85
-
86
-            // Remove other built-in caps.
87
-            unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
88
-
89
-            $caps['read'] = _x('Entry Creator','User capability', 'gravityview');
90
-        }
91
-
92
-        return $caps;
93
-    }
94
-
95
-    /**
96
-     * Add "Edit Link Text" setting to the edit_link field settings
97
-     * @param  [type] $field_options [description]
98
-     * @param  [type] $template_id   [description]
99
-     * @param  [type] $field_id      [description]
100
-     * @param  [type] $context       [description]
101
-     * @param  [type] $input_type    [description]
102
-     * @return [type]                [description]
103
-     */
104
-    function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105
-
106
-        // Always a link, never a filter
107
-        unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
-
109
-        // Edit Entry link should only appear to visitors capable of editing entries
110
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
-
112
-        $add_option['edit_link'] = array(
113
-            'type' => 'text',
114
-            'label' => __( 'Edit Link Text', 'gravityview' ),
115
-            'desc' => NULL,
116
-            'value' => __('Edit Entry', 'gravityview'),
117
-            'merge_tags' => true,
118
-        );
119
-
120
-        return array_merge( $add_option, $field_options );
121
-    }
122
-
123
-    /**
124
-     * Add tooltips
125
-     * @param  array $tooltips Existing tooltips
126
-     * @return array           Modified tooltips
127
-     */
128
-    function tooltips( $tooltips ) {
129
-
130
-        $return = $tooltips;
131
-
132
-        $return['allow_edit_cap'] = array(
133
-            'title' => __('Limiting Edit Access', 'gravityview'),
134
-            'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
135
-        );
136
-
137
-        return $return;
138
-    }
139
-
140
-    /**
141
-     * Manipulate the fields' options for the EDIT ENTRY screen
142
-     * @param  [type] $field_options [description]
143
-     * @param  [type] $template_id   [description]
144
-     * @param  [type] $field_id      [description]
145
-     * @param  [type] $context       [description]
146
-     * @param  [type] $input_type    [description]
147
-     * @return [type]                [description]
148
-     */
149
-    function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150
-
151
-        // We only want to modify the settings for the edit context
152
-        if( 'edit' !== $context ) {
153
-
154
-            /**
155
-             * @since 1.8.4
156
-             */
157
-            $field_options['new_window'] = array(
158
-                'type' => 'checkbox',
159
-                'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160
-                'value' => false,
161
-            );
162
-
163
-            return $field_options;
164
-        }
165
-
166
-        //  Entry field is only for logged in users
167
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
168
-
169
-        $add_options = array(
170
-            'allow_edit_cap' => array(
171
-                'type' => 'select',
172
-                'label' => __( 'Make field editable to:', 'gravityview' ),
173
-                'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
174
-                'tooltip' => 'allow_edit_cap',
175
-                'class' => 'widefat',
176
-                'value' => 'read', // Default: entry creator
177
-            ),
178
-        );
179
-
180
-        return array_merge( $field_options, $add_options );
181
-    }
40
+		// add tooltips
41
+		add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
42
+
43
+		// custom fields' options for zone EDIT
44
+		add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
45
+	}
46
+
47
+	/**
48
+	 * Add Edit Link as a default field, outside those set in the Gravity Form form
49
+	 * @param array $entry_default_fields Existing fields
50
+	 * @param  string|array $form form_ID or form object
51
+	 * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
52
+	 */
53
+	function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54
+
55
+		if( $zone !== 'edit' ) {
56
+
57
+			$entry_default_fields['edit_link'] = array(
58
+				'label' => __('Edit Entry', 'gravityview'),
59
+				'type' => 'edit_link',
60
+				'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
61
+			);
62
+
63
+		}
64
+
65
+		return $entry_default_fields;
66
+	}
67
+
68
+	/**
69
+	 * Change wording for the Edit context to read Entry Creator
70
+	 *
71
+	 * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
+	 * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73
+	 * @param  string      $template_id Table slug
74
+	 * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75
+	 * @param  string      $context     What context are we in? Example: `single` or `directory`
76
+	 * @param  string      $input_type  (textarea, list, select, etc.)
77
+	 * @return array                   Array of field options with `label`, `value`, `type`, `default` keys
78
+	 */
79
+	function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
80
+
81
+		$caps = $visibility_caps;
82
+
83
+		// If we're configuring fields in the edit context, we want a limited selection
84
+		if( $context === 'edit' ) {
85
+
86
+			// Remove other built-in caps.
87
+			unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
88
+
89
+			$caps['read'] = _x('Entry Creator','User capability', 'gravityview');
90
+		}
91
+
92
+		return $caps;
93
+	}
94
+
95
+	/**
96
+	 * Add "Edit Link Text" setting to the edit_link field settings
97
+	 * @param  [type] $field_options [description]
98
+	 * @param  [type] $template_id   [description]
99
+	 * @param  [type] $field_id      [description]
100
+	 * @param  [type] $context       [description]
101
+	 * @param  [type] $input_type    [description]
102
+	 * @return [type]                [description]
103
+	 */
104
+	function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105
+
106
+		// Always a link, never a filter
107
+		unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
+
109
+		// Edit Entry link should only appear to visitors capable of editing entries
110
+		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
+
112
+		$add_option['edit_link'] = array(
113
+			'type' => 'text',
114
+			'label' => __( 'Edit Link Text', 'gravityview' ),
115
+			'desc' => NULL,
116
+			'value' => __('Edit Entry', 'gravityview'),
117
+			'merge_tags' => true,
118
+		);
119
+
120
+		return array_merge( $add_option, $field_options );
121
+	}
122
+
123
+	/**
124
+	 * Add tooltips
125
+	 * @param  array $tooltips Existing tooltips
126
+	 * @return array           Modified tooltips
127
+	 */
128
+	function tooltips( $tooltips ) {
129
+
130
+		$return = $tooltips;
131
+
132
+		$return['allow_edit_cap'] = array(
133
+			'title' => __('Limiting Edit Access', 'gravityview'),
134
+			'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
135
+		);
136
+
137
+		return $return;
138
+	}
139
+
140
+	/**
141
+	 * Manipulate the fields' options for the EDIT ENTRY screen
142
+	 * @param  [type] $field_options [description]
143
+	 * @param  [type] $template_id   [description]
144
+	 * @param  [type] $field_id      [description]
145
+	 * @param  [type] $context       [description]
146
+	 * @param  [type] $input_type    [description]
147
+	 * @return [type]                [description]
148
+	 */
149
+	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150
+
151
+		// We only want to modify the settings for the edit context
152
+		if( 'edit' !== $context ) {
153
+
154
+			/**
155
+			 * @since 1.8.4
156
+			 */
157
+			$field_options['new_window'] = array(
158
+				'type' => 'checkbox',
159
+				'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160
+				'value' => false,
161
+			);
162
+
163
+			return $field_options;
164
+		}
165
+
166
+		//  Entry field is only for logged in users
167
+		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
168
+
169
+		$add_options = array(
170
+			'allow_edit_cap' => array(
171
+				'type' => 'select',
172
+				'label' => __( 'Make field editable to:', 'gravityview' ),
173
+				'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
174
+				'tooltip' => 'allow_edit_cap',
175
+				'class' => 'widefat',
176
+				'value' => 'read', // Default: entry creator
177
+			),
178
+		);
179
+
180
+		return array_merge( $field_options, $add_options );
181
+	}
182 182
 
183 183
 
184 184
 } // end class
185 185
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     function load() {
26 26
 
27
-        if( !is_admin() ) {
27
+        if ( ! is_admin() ) {
28 28
             return;
29 29
         }
30 30
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
39 39
 
40 40
         // add tooltips
41
-        add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
41
+        add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) );
42 42
 
43 43
         // custom fields' options for zone EDIT
44 44
         add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
      */
53 53
     function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54 54
 
55
-        if( $zone !== 'edit' ) {
55
+        if ( $zone !== 'edit' ) {
56 56
 
57
-            $entry_default_fields['edit_link'] = array(
58
-                'label' => __('Edit Entry', 'gravityview'),
57
+            $entry_default_fields[ 'edit_link' ] = array(
58
+                'label' => __( 'Edit Entry', 'gravityview' ),
59 59
                 'type' => 'edit_link',
60
-                'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
60
+                'desc'	=> __( 'A link to edit the entry. Visible based on View settings.', 'gravityview' ),
61 61
             );
62 62
 
63 63
         }
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
         $caps = $visibility_caps;
82 82
 
83 83
         // If we're configuring fields in the edit context, we want a limited selection
84
-        if( $context === 'edit' ) {
84
+        if ( $context === 'edit' ) {
85 85
 
86 86
             // Remove other built-in caps.
87
-            unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
87
+            unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] );
88 88
 
89
-            $caps['read'] = _x('Entry Creator','User capability', 'gravityview');
89
+            $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' );
90 90
         }
91 91
 
92 92
         return $caps;
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
     function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105 105
 
106 106
         // Always a link, never a filter
107
-        unset( $field_options['show_as_link'], $field_options['search_filter'] );
107
+        unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] );
108 108
 
109 109
         // Edit Entry link should only appear to visitors capable of editing entries
110
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
110
+        unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
111 111
 
112
-        $add_option['edit_link'] = array(
112
+        $add_option[ 'edit_link' ] = array(
113 113
             'type' => 'text',
114 114
             'label' => __( 'Edit Link Text', 'gravityview' ),
115 115
             'desc' => NULL,
116
-            'value' => __('Edit Entry', 'gravityview'),
116
+            'value' => __( 'Edit Entry', 'gravityview' ),
117 117
             'merge_tags' => true,
118 118
         );
119 119
 
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 
130 130
         $return = $tooltips;
131 131
 
132
-        $return['allow_edit_cap'] = array(
133
-            'title' => __('Limiting Edit Access', 'gravityview'),
134
-            'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
132
+        $return[ 'allow_edit_cap' ] = array(
133
+            'title' => __( 'Limiting Edit Access', 'gravityview' ),
134
+            'value' => __( 'Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview' ),
135 135
         );
136 136
 
137 137
         return $return;
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
     function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150 150
 
151 151
         // We only want to modify the settings for the edit context
152
-        if( 'edit' !== $context ) {
152
+        if ( 'edit' !== $context ) {
153 153
 
154 154
             /**
155 155
              * @since 1.8.4
156 156
              */
157
-            $field_options['new_window'] = array(
157
+            $field_options[ 'new_window' ] = array(
158 158
                 'type' => 'checkbox',
159 159
                 'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160 160
                 'value' => false,
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         }
165 165
 
166 166
         //  Entry field is only for logged in users
167
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
167
+        unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
168 168
 
169 169
         $add_options = array(
170 170
             'allow_edit_cap' => array(
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-user-registration.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
      * @since 1.11
58 58
      *
59 59
      * @param array $form Gravity Forms form array
60
-     * @param string $entry_id Gravity Forms entry ID
60
+     * @param integer $entry_id Gravity Forms entry ID
61 61
      * @return void
62 62
      */
63 63
     public function update_user( $form = array(), $entry_id = 0 ) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -171,11 +171,13 @@
 block discarded – undo
171 171
         $public_display['nickname']  = $profileuser->nickname;
172 172
         $public_display['username']  = $profileuser->user_login;
173 173
 
174
-        if ( !empty($profileuser->first_name) )
175
-            $public_display['firstname'] = $profileuser->first_name;
174
+        if ( !empty($profileuser->first_name) ) {
175
+                    $public_display['firstname'] = $profileuser->first_name;
176
+        }
176 177
 
177
-        if ( !empty($profileuser->last_name) )
178
-            $public_display['lastname'] = $profileuser->last_name;
178
+        if ( !empty($profileuser->last_name) ) {
179
+                    $public_display['lastname'] = $profileuser->last_name;
180
+        }
179 181
 
180 182
         if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
181 183
             $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
Please login to merge, or discard this patch.
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 if ( ! defined( 'WPINC' ) ) {
14
-    die;
14
+	die;
15 15
 }
16 16
 
17 17
 /**
@@ -22,253 +22,253 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * @var GravityView_Edit_Entry
24 24
 	 */
25
-    protected $loader;
25
+	protected $loader;
26 26
 
27
-    /**
28
-     * @var WP_User|null Temporary storage used by restore_user_details()
29
-     */
30
-    private $_user_before_update = null;
27
+	/**
28
+	 * @var WP_User|null Temporary storage used by restore_user_details()
29
+	 */
30
+	private $_user_before_update = null;
31 31
 
32
-    function __construct( GravityView_Edit_Entry $loader ) {
33
-        $this->loader = $loader;
34
-    }
32
+	function __construct( GravityView_Edit_Entry $loader ) {
33
+		$this->loader = $loader;
34
+	}
35 35
 
36 36
 	/**
37 37
 	 * @since 1.11
38 38
 	 */
39 39
 	public function load() {
40 40
 		add_action( 'wp', array( $this, 'add_hooks' ), 10 );
41
-    }
41
+	}
42 42
 
43 43
 	/**
44 44
 	 * Add hooks to trigger updating the user
45 45
 	 *
46 46
 	 * @since 1.18
47 47
 	 */
48
-    public function add_hooks() {
49
-
50
-	    /**
51
-	     * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated?
52
-	     * @since 1.11
53
-	     * @param boolean $boolean Whether to trigger update on user registration (default: true)
54
-	     */
55
-	    if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
56
-
57
-	    	add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
58
-
59
-		    // last resort in case the current user display name don't match any of the defaults
60
-		    add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
61
-	    }
62
-    }
63
-
64
-    /**
65
-     * Update the WordPress user profile based on the GF User Registration create feed
66
-     *
67
-     * @since 1.11
68
-     *
69
-     * @param array $form Gravity Forms form array
70
-     * @param string $entry_id Gravity Forms entry ID
71
-     * @return void
72
-     */
73
-    public function update_user( $form = array(), $entry_id = 0 ) {
74
-
75
-        if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) {
76
-            return;
77
-        }
78
-
79
-        /** @var GF_User_Registration $gf_user_registration */
80
-        $gf_user_registration = GF_User_Registration::get_instance();
81
-
82
-        $entry = GFAPI::get_entry( $entry_id );
83
-
84
-	    /**
85
-	     * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
86
-	     * @since 1.11
87
-	     * @param array $entry Gravity Forms entry
88
-	     * @param array $form Gravity Forms form
89
-	     */
90
-        $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form );
91
-
92
-        $config = $gf_user_registration->get_single_submission_feed( $entry, $form );
93
-
94
-        /**
95
-         * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
96
-         * @since 1.15
97
-         * @param[in,out] boolean $preserve_role Preserve current user role Default: true
98
-         * @param[in] array $config Gravity Forms User Registration feed configuration for the form
99
-         * @param[in] array $form Gravity Forms form array
100
-         * @param[in] array $entry Gravity Forms entry being edited
101
-         */
102
-        $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
103
-
104
-        if( $preserve_role ) {
105
-            $config['meta']['role'] = 'gfur_preserve_role';
106
-        }
107
-
108
-        /**
109
-         * Make sure the current display name is not changed with the update user method.
110
-         * @since 1.15
111
-         */
112
-        $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
113
-
114
-
115
-        /**
116
-         * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
117
-         * @since 1.14
118
-         * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
119
-         * @param[in] array $form Gravity Forms form array
120
-         * @param[in] array $entry Gravity Forms entry being edited
121
-         */
122
-        $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
123
-
124
-
125
-        // Make sure the feed is active
126
-	    if ( ! rgar( $config, 'is_active', false ) ) {
48
+	public function add_hooks() {
49
+
50
+		/**
51
+		 * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated?
52
+		 * @since 1.11
53
+		 * @param boolean $boolean Whether to trigger update on user registration (default: true)
54
+		 */
55
+		if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
56
+
57
+			add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
58
+
59
+			// last resort in case the current user display name don't match any of the defaults
60
+			add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
61
+		}
62
+	}
63
+
64
+	/**
65
+	 * Update the WordPress user profile based on the GF User Registration create feed
66
+	 *
67
+	 * @since 1.11
68
+	 *
69
+	 * @param array $form Gravity Forms form array
70
+	 * @param string $entry_id Gravity Forms entry ID
71
+	 * @return void
72
+	 */
73
+	public function update_user( $form = array(), $entry_id = 0 ) {
74
+
75
+		if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) {
76
+			return;
77
+		}
78
+
79
+		/** @var GF_User_Registration $gf_user_registration */
80
+		$gf_user_registration = GF_User_Registration::get_instance();
81
+
82
+		$entry = GFAPI::get_entry( $entry_id );
83
+
84
+		/**
85
+		 * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
86
+		 * @since 1.11
87
+		 * @param array $entry Gravity Forms entry
88
+		 * @param array $form Gravity Forms form
89
+		 */
90
+		$entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form );
91
+
92
+		$config = $gf_user_registration->get_single_submission_feed( $entry, $form );
93
+
94
+		/**
95
+		 * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
96
+		 * @since 1.15
97
+		 * @param[in,out] boolean $preserve_role Preserve current user role Default: true
98
+		 * @param[in] array $config Gravity Forms User Registration feed configuration for the form
99
+		 * @param[in] array $form Gravity Forms form array
100
+		 * @param[in] array $entry Gravity Forms entry being edited
101
+		 */
102
+		$preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
103
+
104
+		if( $preserve_role ) {
105
+			$config['meta']['role'] = 'gfur_preserve_role';
106
+		}
107
+
108
+		/**
109
+		 * Make sure the current display name is not changed with the update user method.
110
+		 * @since 1.15
111
+		 */
112
+		$config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
113
+
114
+
115
+		/**
116
+		 * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
117
+		 * @since 1.14
118
+		 * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
119
+		 * @param[in] array $form Gravity Forms form array
120
+		 * @param[in] array $entry Gravity Forms entry being edited
121
+		 */
122
+		$config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
123
+
124
+
125
+		// Make sure the feed is active
126
+		if ( ! rgar( $config, 'is_active', false ) ) {
127 127
 			return;
128
-	    }
129
-
130
-	    // If an Update feed, make sure the conditions are met.
131
-	    if( rgars( $config, 'meta/feedType' ) === 'update' ) {
132
-	    	if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
133
-			    return;
134
-		    }
135
-	    }
136
-
137
-        // The priority is set to 3 so that default priority (10) will still override it
138
-        add_filter( 'send_password_change_email', '__return_false', 3 );
139
-        add_filter( 'send_email_change_email', '__return_false', 3 );
140
-
141
-        // Trigger the User Registration update user method
142
-        $gf_user_registration->update_user( $entry, $form, $config );
143
-
144
-        remove_filter( 'send_password_change_email', '__return_false', 3 );
145
-        remove_filter( 'send_email_change_email', '__return_false', 3 );
146
-
147
-    }
148
-
149
-    /**
150
-     * Calculate the user display name format
151
-     *
152
-     * @since 1.15
153
-     *
154
-     * @param int $user_id WP User ID
155
-     * @return string Display name format as used inside Gravity Forms User Registration
156
-     */
157
-    public function match_current_display_name( $user_id ) {
158
-
159
-        $user = get_userdata( $user_id );
160
-
161
-        $names = $this->generate_display_names( $user );
162
-
163
-        $format = array_search( $user->display_name, $names, true );
164
-
165
-        // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
166
-        //   trigger last resort method at the 'gform_user_updated' hook
167
-        if( false === $format || 'nickname' === $format ) {
168
-            $this->_user_before_update = $user;
169
-            $format = 'nickname';
170
-        }
171
-
172
-        return $format;
173
-
174
-    }
175
-
176
-    /**
177
-     * Generate an array of all the user display names possibilities
178
-     *
179
-     * @since 1.15
180
-     *
181
-     * @param object $profileuser WP_User object
182
-     * @return array List all the possible display names for a certain User object
183
-     */
184
-    public function generate_display_names( $profileuser ) {
185
-
186
-        $public_display = array();
187
-        $public_display['nickname']  = $profileuser->nickname;
188
-        $public_display['username']  = $profileuser->user_login;
189
-
190
-        if ( !empty($profileuser->first_name) )
191
-            $public_display['firstname'] = $profileuser->first_name;
192
-
193
-        if ( !empty($profileuser->last_name) )
194
-            $public_display['lastname'] = $profileuser->last_name;
195
-
196
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
197
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
198
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
199
-        }
200
-
201
-        $public_display = array_map( 'trim', $public_display );
202
-        $public_display = array_unique( $public_display );
203
-
204
-        return $public_display;
205
-    }
206
-
207
-
208
-    /**
209
-     * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
210
-     *
211
-     * @see GFUser::update_user()
212
-     * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
213
-     * @param array $config Gravity Forms User Registration Addon form feed configuration
214
-     * @param array $entry The Gravity Forms entry that was just updated
215
-     * @param string $password User password
216
-     * @return void
217
-     */
218
-    public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
219
-
220
-        /**
221
-         * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
222
-         * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
223
-         * @since 1.14.4
224
-         * @param boolean $restore_display_name Restore Display Name? Default: true
225
-         */
226
-        $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
227
-
228
-        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
229
-
230
-        /**
231
-         * Don't restore display name:
232
-         *   - either disabled,
233
-         *   - or it is an Update feed (we only care about Create feed)
234
-         *   - or we don't need as we found the correct format before updating user.
235
-         * @since 1.14.4
236
-         */
237
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
238
-            return;
239
-        }
240
-
241
-        $user_after_update = get_userdata( $user_id );
242
-
243
-        $restored_user = $user_after_update;
244
-
245
-	    // Restore previous display_name
246
-        $restored_user->display_name = $this->_user_before_update->display_name;
247
-
248
-	    // Don't have WP update the password.
249
-	    unset( $restored_user->data->user_pass, $restored_user->user_pass );
250
-
251
-        /**
252
-         * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
253
-         * @since 1.14
254
-         * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
255
-         * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
256
-         * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
257
-         * @param array   $entry The Gravity Forms entry that was just updated
258
-         */
259
-        $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
260
-
261
-        $updated = wp_update_user( $restored_user );
262
-
263
-        if( is_wp_error( $updated ) ) {
264
-            do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
265
-        } else {
266
-            do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
267
-        }
268
-
269
-        $this->_user_before_update = null;
270
-
271
-        unset( $updated, $restored_user, $user_after_update );
272
-    }
128
+		}
129
+
130
+		// If an Update feed, make sure the conditions are met.
131
+		if( rgars( $config, 'meta/feedType' ) === 'update' ) {
132
+			if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
133
+				return;
134
+			}
135
+		}
136
+
137
+		// The priority is set to 3 so that default priority (10) will still override it
138
+		add_filter( 'send_password_change_email', '__return_false', 3 );
139
+		add_filter( 'send_email_change_email', '__return_false', 3 );
140
+
141
+		// Trigger the User Registration update user method
142
+		$gf_user_registration->update_user( $entry, $form, $config );
143
+
144
+		remove_filter( 'send_password_change_email', '__return_false', 3 );
145
+		remove_filter( 'send_email_change_email', '__return_false', 3 );
146
+
147
+	}
148
+
149
+	/**
150
+	 * Calculate the user display name format
151
+	 *
152
+	 * @since 1.15
153
+	 *
154
+	 * @param int $user_id WP User ID
155
+	 * @return string Display name format as used inside Gravity Forms User Registration
156
+	 */
157
+	public function match_current_display_name( $user_id ) {
158
+
159
+		$user = get_userdata( $user_id );
160
+
161
+		$names = $this->generate_display_names( $user );
162
+
163
+		$format = array_search( $user->display_name, $names, true );
164
+
165
+		// In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
166
+		//   trigger last resort method at the 'gform_user_updated' hook
167
+		if( false === $format || 'nickname' === $format ) {
168
+			$this->_user_before_update = $user;
169
+			$format = 'nickname';
170
+		}
171
+
172
+		return $format;
173
+
174
+	}
175
+
176
+	/**
177
+	 * Generate an array of all the user display names possibilities
178
+	 *
179
+	 * @since 1.15
180
+	 *
181
+	 * @param object $profileuser WP_User object
182
+	 * @return array List all the possible display names for a certain User object
183
+	 */
184
+	public function generate_display_names( $profileuser ) {
185
+
186
+		$public_display = array();
187
+		$public_display['nickname']  = $profileuser->nickname;
188
+		$public_display['username']  = $profileuser->user_login;
189
+
190
+		if ( !empty($profileuser->first_name) )
191
+			$public_display['firstname'] = $profileuser->first_name;
192
+
193
+		if ( !empty($profileuser->last_name) )
194
+			$public_display['lastname'] = $profileuser->last_name;
195
+
196
+		if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
197
+			$public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
198
+			$public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
199
+		}
200
+
201
+		$public_display = array_map( 'trim', $public_display );
202
+		$public_display = array_unique( $public_display );
203
+
204
+		return $public_display;
205
+	}
206
+
207
+
208
+	/**
209
+	 * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
210
+	 *
211
+	 * @see GFUser::update_user()
212
+	 * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
213
+	 * @param array $config Gravity Forms User Registration Addon form feed configuration
214
+	 * @param array $entry The Gravity Forms entry that was just updated
215
+	 * @param string $password User password
216
+	 * @return void
217
+	 */
218
+	public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
219
+
220
+		/**
221
+		 * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
222
+		 * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
223
+		 * @since 1.14.4
224
+		 * @param boolean $restore_display_name Restore Display Name? Default: true
225
+		 */
226
+		$restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
227
+
228
+		$is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
229
+
230
+		/**
231
+		 * Don't restore display name:
232
+		 *   - either disabled,
233
+		 *   - or it is an Update feed (we only care about Create feed)
234
+		 *   - or we don't need as we found the correct format before updating user.
235
+		 * @since 1.14.4
236
+		 */
237
+		if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
238
+			return;
239
+		}
240
+
241
+		$user_after_update = get_userdata( $user_id );
242
+
243
+		$restored_user = $user_after_update;
244
+
245
+		// Restore previous display_name
246
+		$restored_user->display_name = $this->_user_before_update->display_name;
247
+
248
+		// Don't have WP update the password.
249
+		unset( $restored_user->data->user_pass, $restored_user->user_pass );
250
+
251
+		/**
252
+		 * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
253
+		 * @since 1.14
254
+		 * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
255
+		 * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
256
+		 * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
257
+		 * @param array   $entry The Gravity Forms entry that was just updated
258
+		 */
259
+		$restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
260
+
261
+		$updated = wp_update_user( $restored_user );
262
+
263
+		if( is_wp_error( $updated ) ) {
264
+			do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
265
+		} else {
266
+			do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
267
+		}
268
+
269
+		$this->_user_before_update = null;
270
+
271
+		unset( $updated, $restored_user, $user_after_update );
272
+	}
273 273
 
274 274
 } //end class
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	     * @since 1.11
53 53
 	     * @param boolean $boolean Whether to trigger update on user registration (default: true)
54 54
 	     */
55
-	    if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
55
+	    if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
56 56
 
57
-	    	add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
57
+	    	add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 );
58 58
 
59 59
 		    // last resort in case the current user display name don't match any of the defaults
60 60
 		    add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function update_user( $form = array(), $entry_id = 0 ) {
74 74
 
75
-        if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) {
75
+        if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) {
76 76
             return;
77 77
         }
78 78
 
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
          */
102 102
         $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
103 103
 
104
-        if( $preserve_role ) {
105
-            $config['meta']['role'] = 'gfur_preserve_role';
104
+        if ( $preserve_role ) {
105
+            $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role';
106 106
         }
107 107
 
108 108
         /**
109 109
          * Make sure the current display name is not changed with the update user method.
110 110
          * @since 1.15
111 111
          */
112
-        $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
112
+        $config[ 'meta' ][ 'displayname' ] = $this->match_current_display_name( $entry[ 'created_by' ] );
113 113
 
114 114
 
115 115
         /**
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	    }
129 129
 
130 130
 	    // If an Update feed, make sure the conditions are met.
131
-	    if( rgars( $config, 'meta/feedType' ) === 'update' ) {
132
-	    	if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
131
+	    if ( rgars( $config, 'meta/feedType' ) === 'update' ) {
132
+	    	if ( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
133 133
 			    return;
134 134
 		    }
135 135
 	    }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
         // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
166 166
         //   trigger last resort method at the 'gform_user_updated' hook
167
-        if( false === $format || 'nickname' === $format ) {
167
+        if ( false === $format || 'nickname' === $format ) {
168 168
             $this->_user_before_update = $user;
169 169
             $format = 'nickname';
170 170
         }
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
     public function generate_display_names( $profileuser ) {
185 185
 
186 186
         $public_display = array();
187
-        $public_display['nickname']  = $profileuser->nickname;
188
-        $public_display['username']  = $profileuser->user_login;
187
+        $public_display[ 'nickname' ]  = $profileuser->nickname;
188
+        $public_display[ 'username' ]  = $profileuser->user_login;
189 189
 
190
-        if ( !empty($profileuser->first_name) )
191
-            $public_display['firstname'] = $profileuser->first_name;
190
+        if ( ! empty( $profileuser->first_name ) )
191
+            $public_display[ 'firstname' ] = $profileuser->first_name;
192 192
 
193
-        if ( !empty($profileuser->last_name) )
194
-            $public_display['lastname'] = $profileuser->last_name;
193
+        if ( ! empty( $profileuser->last_name ) )
194
+            $public_display[ 'lastname' ] = $profileuser->last_name;
195 195
 
196
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
197
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
198
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
196
+        if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
197
+            $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name;
198
+            $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name;
199 199
         }
200 200
 
201 201
         $public_display = array_map( 'trim', $public_display );
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
          */
226 226
         $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
227 227
 
228
-        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
228
+        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'update' );
229 229
 
230 230
         /**
231 231
          * Don't restore display name:
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
          *   - or we don't need as we found the correct format before updating user.
235 235
          * @since 1.14.4
236 236
          */
237
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
237
+        if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
238 238
             return;
239 239
         }
240 240
 
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 
261 261
         $updated = wp_update_user( $restored_user );
262 262
 
263
-        if( is_wp_error( $updated ) ) {
264
-            do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
263
+        if ( is_wp_error( $updated ) ) {
264
+            do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
265 265
         } else {
266
-            do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
266
+            do_action( 'gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
267 267
         }
268 268
 
269 269
         $this->_user_before_update = null;
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,6 +65,9 @@  discard block
 block discarded – undo
65 65
     }
66 66
 
67 67
 
68
+    /**
69
+     * @param string $component
70
+     */
68 71
     private function load_components( $component ) {
69 72
 
70 73
         $dir = trailingslashit( self::$file );
@@ -141,7 +144,7 @@  discard block
 block discarded – undo
141 144
      * "You can edit this post from the post page" fields, for example.
142 145
      *
143 146
      * @param $entry array Gravity Forms entry object
144
-     * @param $view_id int GravityView view id
147
+     * @param integer $view_id int GravityView view id
145 148
      * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
146 149
      * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
147 150
      * @return string
Please login to merge, or discard this patch.
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -18,80 +18,80 @@  discard block
 block discarded – undo
18 18
 
19 19
 class GravityView_Edit_Entry {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
21
+	/**
22
+	 * @var string
23
+	 */
24 24
 	static $file;
25 25
 
26 26
 	static $instance;
27 27
 
28
-    /**
29
-     * Component instances.
30
-     * @var array
31
-     */
32
-    public $instances = array();
28
+	/**
29
+	 * Component instances.
30
+	 * @var array
31
+	 */
32
+	public $instances = array();
33 33
 
34 34
 
35 35
 	function __construct() {
36 36
 
37
-        self::$file = plugin_dir_path( __FILE__ );
37
+		self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
40
-            $this->load_components( 'admin' );
41
-        }
39
+		if( is_admin() ) {
40
+			$this->load_components( 'admin' );
41
+		}
42 42
 
43 43
 
44
-        $this->load_components( 'render' );
44
+		$this->load_components( 'render' );
45 45
 
46
-        // If GF User Registration Add-on exists
47
-        $this->load_components( 'user-registration' );
46
+		// If GF User Registration Add-on exists
47
+		$this->load_components( 'user-registration' );
48 48
 
49
-        $this->add_hooks();
49
+		$this->add_hooks();
50 50
 
51 51
 		// Process hooks for addons that may or may not be present
52 52
 		$this->addon_specific_hooks();
53 53
 	}
54 54
 
55 55
 
56
-    static function getInstance() {
56
+	static function getInstance() {
57 57
 
58
-        if( empty( self::$instance ) ) {
59
-            self::$instance = new GravityView_Edit_Entry;
60
-        }
58
+		if( empty( self::$instance ) ) {
59
+			self::$instance = new GravityView_Edit_Entry;
60
+		}
61 61
 
62
-        return self::$instance;
63
-    }
62
+		return self::$instance;
63
+	}
64 64
 
65 65
 
66
-    private function load_components( $component ) {
66
+	private function load_components( $component ) {
67 67
 
68
-        $dir = trailingslashit( self::$file );
68
+		$dir = trailingslashit( self::$file );
69 69
 
70
-        $filename  = $dir . 'class-edit-entry-' . $component . '.php';
71
-        $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
70
+		$filename  = $dir . 'class-edit-entry-' . $component . '.php';
71
+		$classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
72 72
 
73
-        // Loads component and pass extension's instance so that component can
74
-        // talk each other.
75
-        require_once $filename;
76
-        $this->instances[ $component ] = new $classname( $this );
77
-        $this->instances[ $component ]->load();
73
+		// Loads component and pass extension's instance so that component can
74
+		// talk each other.
75
+		require_once $filename;
76
+		$this->instances[ $component ] = new $classname( $this );
77
+		$this->instances[ $component ]->load();
78 78
 
79
-    }
79
+	}
80 80
 
81
-    private function add_hooks() {
81
+	private function add_hooks() {
82 82
 
83
-        // Add front-end access to Gravity Forms delete file action
84
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') );
83
+		// Add front-end access to Gravity Forms delete file action
84
+		add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') );
85 85
 
86
-        // Make sure this hook is run for non-admins
87
-        add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') );
86
+		// Make sure this hook is run for non-admins
87
+		add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') );
88 88
 
89
-        add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
89
+		add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
90 90
 
91
-        // add template path to check for field
92
-        add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
91
+		// add template path to check for field
92
+		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
93 93
 
94
-    }
94
+	}
95 95
 
96 96
 	/**
97 97
 	 * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin
@@ -105,75 +105,75 @@  discard block
 block discarded – undo
105 105
 
106 106
 	}
107 107
 
108
-    /**
109
-     * Include this extension templates path
110
-     * @param array $file_paths List of template paths ordered
111
-     */
112
-    public function add_template_path( $file_paths ) {
113
-
114
-        // Index 100 is the default GravityView template path.
115
-        $file_paths[ 110 ] = self::$file;
116
-
117
-        return $file_paths;
118
-    }
119
-
120
-    /**
121
-     *
122
-     * Return a well formatted nonce key according to GravityView Edit Entry protocol
123
-     *
124
-     * @param $view_id int GravityView view id
125
-     * @param $form_id int Gravity Forms form id
126
-     * @param $entry_id int Gravity Forms entry id
127
-     * @return string
128
-     */
129
-    public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
130
-        return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
131
-    }
132
-
133
-
134
-    /**
135
-     * The edit entry link creates a secure link with a nonce
136
-     *
137
-     * It also mimics the URL structure Gravity Forms expects to have so that
138
-     * it formats the display of the edit form like it does in the backend, like
139
-     * "You can edit this post from the post page" fields, for example.
140
-     *
141
-     * @param $entry array Gravity Forms entry object
142
-     * @param $view_id int GravityView view id
143
-     * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
144
-     * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
145
-     * @return string
146
-     */
147
-    public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
148
-
149
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
150
-
151
-        $base = gv_entry_link( $entry, $post_id );
152
-
153
-        $url = add_query_arg( array(
154
-            'page' => 'gf_entries', // Needed for GFForms::get_page()
155
-            'view' => 'entry', // Needed for GFForms::get_page()
156
-            'edit' => wp_create_nonce( $nonce_key )
157
-        ), $base );
158
-
159
-	    /**
160
-	     * Allow passing params to dynamically populate entry with values
161
-	     * @since 1.9.2
162
-	     */
163
-	    if( !empty( $field_values ) ) {
164
-
165
-		    if( is_array( $field_values ) ) {
166
-			    // If already an array, no parse_str() needed
167
-			    $params = $field_values;
168
-		    } else {
169
-			    parse_str( $field_values, $params );
170
-		    }
171
-
172
-		    $url = add_query_arg( $params, $url );
173
-	    }
174
-
175
-        return $url;
176
-    }
108
+	/**
109
+	 * Include this extension templates path
110
+	 * @param array $file_paths List of template paths ordered
111
+	 */
112
+	public function add_template_path( $file_paths ) {
113
+
114
+		// Index 100 is the default GravityView template path.
115
+		$file_paths[ 110 ] = self::$file;
116
+
117
+		return $file_paths;
118
+	}
119
+
120
+	/**
121
+	 *
122
+	 * Return a well formatted nonce key according to GravityView Edit Entry protocol
123
+	 *
124
+	 * @param $view_id int GravityView view id
125
+	 * @param $form_id int Gravity Forms form id
126
+	 * @param $entry_id int Gravity Forms entry id
127
+	 * @return string
128
+	 */
129
+	public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
130
+		return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
131
+	}
132
+
133
+
134
+	/**
135
+	 * The edit entry link creates a secure link with a nonce
136
+	 *
137
+	 * It also mimics the URL structure Gravity Forms expects to have so that
138
+	 * it formats the display of the edit form like it does in the backend, like
139
+	 * "You can edit this post from the post page" fields, for example.
140
+	 *
141
+	 * @param $entry array Gravity Forms entry object
142
+	 * @param $view_id int GravityView view id
143
+	 * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
144
+	 * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
145
+	 * @return string
146
+	 */
147
+	public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
148
+
149
+		$nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
150
+
151
+		$base = gv_entry_link( $entry, $post_id );
152
+
153
+		$url = add_query_arg( array(
154
+			'page' => 'gf_entries', // Needed for GFForms::get_page()
155
+			'view' => 'entry', // Needed for GFForms::get_page()
156
+			'edit' => wp_create_nonce( $nonce_key )
157
+		), $base );
158
+
159
+		/**
160
+		 * Allow passing params to dynamically populate entry with values
161
+		 * @since 1.9.2
162
+		 */
163
+		if( !empty( $field_values ) ) {
164
+
165
+			if( is_array( $field_values ) ) {
166
+				// If already an array, no parse_str() needed
167
+				$params = $field_values;
168
+			} else {
169
+				parse_str( $field_values, $params );
170
+			}
171
+
172
+			$url = add_query_arg( $params, $url );
173
+		}
174
+
175
+		return $url;
176
+	}
177 177
 
178 178
 
179 179
 	/**
@@ -209,81 +209,81 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 
212
-    /**
213
-     * checks if user has permissions to edit a specific entry
214
-     *
215
-     * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
216
-     *
217
-     * @param  array $entry Gravity Forms entry array
218
-     * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}
219
-     * @return bool
220
-     */
221
-    public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) {
212
+	/**
213
+	 * checks if user has permissions to edit a specific entry
214
+	 *
215
+	 * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
216
+	 *
217
+	 * @param  array $entry Gravity Forms entry array
218
+	 * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}
219
+	 * @return bool
220
+	 */
221
+	public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) {
222 222
 
223
-        // No permission by default
224
-        $user_can_edit = false;
223
+		// No permission by default
224
+		$user_can_edit = false;
225 225
 
226
-        // If they can edit any entries (as defined in Gravity Forms)
227
-        // Or if they can edit other people's entries
228
-        // Then we're good.
229
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
226
+		// If they can edit any entries (as defined in Gravity Forms)
227
+		// Or if they can edit other people's entries
228
+		// Then we're good.
229
+		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
230 230
 
231
-            do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.');
231
+			do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.');
232 232
 
233
-            $user_can_edit = true;
233
+			$user_can_edit = true;
234 234
 
235
-        } else if( !isset( $entry['created_by'] ) ) {
235
+		} else if( !isset( $entry['created_by'] ) ) {
236 236
 
237
-            do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
237
+			do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
238 238
 
239
-            $user_can_edit = false;
239
+			$user_can_edit = false;
240 240
 
241
-        } else {
241
+		} else {
242 242
 
243
-            // get user_edit setting
244
-            if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
245
-                // if View ID not specified or is the current view
246
-                $user_edit = GravityView_View::getInstance()->getAtts('user_edit');
247
-            } else {
248
-                // in case is specified and not the current view
249
-                $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
250
-            }
243
+			// get user_edit setting
244
+			if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
245
+				// if View ID not specified or is the current view
246
+				$user_edit = GravityView_View::getInstance()->getAtts('user_edit');
247
+			} else {
248
+				// in case is specified and not the current view
249
+				$user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
250
+			}
251 251
 
252
-            $current_user = wp_get_current_user();
252
+			$current_user = wp_get_current_user();
253 253
 
254
-            // User edit is disabled
255
-            if( empty( $user_edit ) ) {
254
+			// User edit is disabled
255
+			if( empty( $user_edit ) ) {
256 256
 
257
-                do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' );
257
+				do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' );
258 258
 
259
-                $user_can_edit = false;
260
-            }
259
+				$user_can_edit = false;
260
+			}
261 261
 
262
-            // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
263
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
262
+			// User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
263
+			else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
264 264
 
265
-                do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) );
265
+				do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) );
266 266
 
267
-                $user_can_edit = true;
267
+				$user_can_edit = true;
268 268
 
269
-            } else if( ! is_user_logged_in() ) {
269
+			} else if( ! is_user_logged_in() ) {
270 270
 
271
-                do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' );
272
-            }
271
+				do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' );
272
+			}
273 273
 
274
-        }
274
+		}
275 275
 
276
-        /**
277
-         * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
278
-         * @since 1.15 Added `$entry` and `$view_id` parameters
279
-         * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
280
-         * @param[in] array $entry Gravity Forms entry array {@since 1.15}
281
-         * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
282
-         */
283
-        $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
276
+		/**
277
+		 * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
278
+		 * @since 1.15 Added `$entry` and `$view_id` parameters
279
+		 * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
280
+		 * @param[in] array $entry Gravity Forms entry array {@since 1.15}
281
+		 * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
282
+		 */
283
+		$user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
284 284
 
285
-        return (bool)$user_can_edit;
286
-    }
285
+		return (bool)$user_can_edit;
286
+	}
287 287
 
288 288
 
289 289
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
         self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
39
+        if ( is_admin() ) {
40 40
             $this->load_components( 'admin' );
41 41
         }
42 42
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     static function getInstance() {
57 57
 
58
-        if( empty( self::$instance ) ) {
58
+        if ( empty( self::$instance ) ) {
59 59
             self::$instance = new GravityView_Edit_Entry;
60 60
         }
61 61
 
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
     private function add_hooks() {
82 82
 
83 83
         // Add front-end access to Gravity Forms delete file action
84
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') );
84
+        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file' ) );
85 85
 
86 86
         // Make sure this hook is run for non-admins
87
-        add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') );
87
+        add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file' ) );
88 88
 
89 89
         add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
90 90
 
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	private function addon_specific_hooks() {
101 101
 
102
-		if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) {
103
-			add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script'));
102
+		if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) {
103
+			add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) );
104 104
 		}
105 105
 
106 106
 	}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
148 148
 
149
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
149
+        $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] );
150 150
 
151 151
         $base = gv_entry_link( $entry, $post_id );
152 152
 
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 	     * Allow passing params to dynamically populate entry with values
161 161
 	     * @since 1.9.2
162 162
 	     */
163
-	    if( !empty( $field_values ) ) {
163
+	    if ( ! empty( $field_values ) ) {
164 164
 
165
-		    if( is_array( $field_values ) ) {
165
+		    if ( is_array( $field_values ) ) {
166 166
 			    // If already an array, no parse_str() needed
167 167
 			    $params = $field_values;
168 168
 		    } else {
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public function modify_field_blacklist( $fields = array(), $context = NULL ) {
186 186
 
187
-		if( empty( $context ) || $context !== 'edit' ) {
187
+		if ( empty( $context ) || $context !== 'edit' ) {
188 188
 			return $fields;
189 189
 		}
190 190
 
@@ -226,24 +226,24 @@  discard block
 block discarded – undo
226 226
         // If they can edit any entries (as defined in Gravity Forms)
227 227
         // Or if they can edit other people's entries
228 228
         // Then we're good.
229
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
229
+        if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) {
230 230
 
231
-            do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.');
231
+            do_action( 'gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.' );
232 232
 
233 233
             $user_can_edit = true;
234 234
 
235
-        } else if( !isset( $entry['created_by'] ) ) {
235
+        } else if ( ! isset( $entry[ 'created_by' ] ) ) {
236 236
 
237
-            do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
237
+            do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.' );
238 238
 
239 239
             $user_can_edit = false;
240 240
 
241 241
         } else {
242 242
 
243 243
             // get user_edit setting
244
-            if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
244
+            if ( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
245 245
                 // if View ID not specified or is the current view
246
-                $user_edit = GravityView_View::getInstance()->getAtts('user_edit');
246
+                $user_edit = GravityView_View::getInstance()->getAtts( 'user_edit' );
247 247
             } else {
248 248
                 // in case is specified and not the current view
249 249
                 $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
@@ -252,21 +252,21 @@  discard block
 block discarded – undo
252 252
             $current_user = wp_get_current_user();
253 253
 
254 254
             // User edit is disabled
255
-            if( empty( $user_edit ) ) {
255
+            if ( empty( $user_edit ) ) {
256 256
 
257
-                do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' );
257
+                do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' );
258 258
 
259 259
                 $user_can_edit = false;
260 260
             }
261 261
 
262 262
             // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
263
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
263
+            else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) {
264 264
 
265
-                do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) );
265
+                do_action( 'gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) );
266 266
 
267 267
                 $user_can_edit = true;
268 268
 
269
-            } else if( ! is_user_logged_in() ) {
269
+            } else if ( ! is_user_logged_in() ) {
270 270
 
271 271
                 do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' );
272 272
             }
Please login to merge, or discard this patch.
plugin-and-theme-hooks/abstract-gravityview-plugin-and-theme-hooks.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -169,7 +169,6 @@
 block discarded – undo
169 169
 	 *
170 170
 	 * @since 1.15.2
171 171
 	 *
172
-	 * @param array $handles Array of meta keys to check for existence of shortcodes
173 172
 	 * @param int $post_id The ID being checked by GravityView
174 173
 	 *
175 174
 	 * @return array Meta key array, merged with existing meta keys
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	private function maybe_add_hooks() {
92 92
 		$class_exists = $this->class_name && class_exists( $this->class_name );
93 93
 		$function_exists = $this->function_name && function_exists( $this->function_name );
94
-		$constant_defined = $this->constant_name && defined("{$this->constant_name}");
94
+		$constant_defined = $this->constant_name && defined( "{$this->constant_name}" );
95 95
 
96
-		if( $class_exists || $function_exists || $constant_defined ) {
96
+		if ( $class_exists || $function_exists || $constant_defined ) {
97 97
 			$this->add_hooks();
98 98
 		}
99 99
 	}
@@ -104,19 +104,19 @@  discard block
 block discarded – undo
104 104
 	 * @return void
105 105
 	 */
106 106
 	protected function add_hooks() {
107
-		if( $this->content_meta_keys ) {
107
+		if ( $this->content_meta_keys ) {
108 108
 			add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 2 );
109 109
 		}
110 110
 
111
-		if( $this->script_handles ) {
111
+		if ( $this->script_handles ) {
112 112
 			add_filter( 'gravityview_noconflict_scripts', array( $this, 'merge_noconflict_scripts' ) );
113 113
 		}
114 114
 
115
-		if( $this->style_handles ) {
115
+		if ( $this->style_handles ) {
116 116
 			add_filter( 'gravityview_noconflict_styles', array( $this, 'merge_noconflict_styles' ) );
117 117
 		}
118 118
 
119
-		if( $this->post_type_support ) {
119
+		if ( $this->post_type_support ) {
120 120
 			add_filter( 'gravityview_post_type_support', array( $this, 'merge_post_type_support' ), 10, 2 );
121 121
 		}
122 122
 	}
Please login to merge, or discard this patch.
includes/widgets/class-gravityview-widget.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -51,6 +51,9 @@
 block discarded – undo
51 51
 	// hold widget View options
52 52
 	private $widget_options;
53 53
 
54
+	/**
55
+	 * @param string $widget_id
56
+	 */
54 57
 	function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) {
55 58
 
56 59
 
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -116,12 +116,12 @@
 block discarded – undo
116 116
 		return $settings;
117 117
 	}
118 118
 
119
-    /**
120
-     * @return string
121
-     */
122
-    public function get_widget_id() {
123
-        return $this->widget_id;
124
-    }
119
+	/**
120
+	 * @return string
121
+	 */
122
+	public function get_widget_id() {
123
+		return $this->widget_id;
124
+	}
125 125
 
126 126
 	/**
127 127
 	 * Get the widget settings
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	// hold widget View options
52 52
 	private $widget_options;
53 53
 
54
-	function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) {
54
+	function __construct( $widget_label, $widget_id, $defaults = array(), $settings = array() ) {
55 55
 
56 56
 
57 57
 		/**
58 58
 		 * The shortcode name is set to the lowercase name of the widget class, unless overridden by the class specifying a different value for $shortcode_name
59 59
 		 * @var string
60 60
 		 */
61
-		$this->shortcode_name = !isset( $this->shortcode_name ) ? strtolower( get_class($this) ) : $this->shortcode_name;
61
+		$this->shortcode_name = ! isset( $this->shortcode_name ) ? strtolower( get_class( $this ) ) : $this->shortcode_name;
62 62
 
63 63
 		$this->widget_label = $widget_label;
64 64
 		$this->widget_id = $widget_id;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		$this->settings = wp_parse_args( $settings, $this->settings );
70 70
 
71 71
 		// register widgets to be listed in the View Configuration
72
-		add_filter( 'gravityview_register_directory_widgets', array( $this, 'register_widget') );
72
+		add_filter( 'gravityview_register_directory_widgets', array( $this, 'register_widget' ) );
73 73
 
74 74
 		// widget options
75 75
 		add_filter( 'gravityview_template_widget_options', array( $this, 'assign_widget_options' ), 10, 3 );
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 		add_action( "gravityview_render_widget_{$widget_id}", array( $this, 'render_frontend' ), 10, 1 );
79 79
 
80 80
 		// register shortcodes
81
-		add_action( 'wp', array( $this, 'add_shortcode') );
81
+		add_action( 'wp', array( $this, 'add_shortcode' ) );
82 82
 
83 83
 		// Use shortcodes in text widgets.
84
-		add_filter('widget_text', array( $this, 'maybe_do_shortcode' ) );
84
+		add_filter( 'widget_text', array( $this, 'maybe_do_shortcode' ) );
85 85
 	}
86 86
 
87 87
 
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
 		 * @param boolean $enable_custom_class False by default. Return true if you want to enable.
100 100
 		 * @param GravityView_Widget $this Current instance of GravityView_Widget
101 101
 		 */
102
-		$enable_custom_class = apply_filters('gravityview/widget/enable_custom_class', false, $this );
102
+		$enable_custom_class = apply_filters( 'gravityview/widget/enable_custom_class', false, $this );
103 103
 
104
-		if( $enable_custom_class ) {
104
+		if ( $enable_custom_class ) {
105 105
 
106
-			$settings['custom_class'] = array(
106
+			$settings[ 'custom_class' ] = array(
107 107
 				'type' => 'text',
108 108
 				'label' => __( 'Custom CSS Class:', 'gravityview' ),
109
-				'desc' => __( 'This class will be added to the widget container', 'gravityview'),
109
+				'desc' => __( 'This class will be added to the widget container', 'gravityview' ),
110 110
 				'value' => '',
111 111
 				'merge_tags' => true,
112 112
 			);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @return array|null   Settings array; NULL if not set
129 129
 	 */
130 130
 	public function get_settings() {
131
-		return !empty( $this->settings ) ? $this->settings : NULL;
131
+		return ! empty( $this->settings ) ? $this->settings : NULL;
132 132
 	}
133 133
 
134 134
 	/**
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	public function get_setting( $key ) {
140 140
 		$setting = NULL;
141 141
 
142
-		if( isset( $this->settings ) && is_array( $this->settings ) ) {
142
+		if ( isset( $this->settings ) && is_array( $this->settings ) ) {
143 143
 			$setting = isset( $this->settings[ $key ] ) ? $this->settings[ $key ] : NULL;
144 144
 		}
145 145
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	function maybe_do_shortcode( $text, $widget = NULL ) {
156 156
 
157
-		if( !empty( $this->shortcode_name ) && has_shortcode( $text, $this->shortcode_name ) ) {
157
+		if ( ! empty( $this->shortcode_name ) && has_shortcode( $text, $this->shortcode_name ) ) {
158 158
 			return do_shortcode( $text );
159 159
 		}
160 160
 
@@ -176,28 +176,28 @@  discard block
 block discarded – undo
176 176
 	function add_shortcode( $run_on_singular = true ) {
177 177
 		global $post;
178 178
 
179
-		if( GravityView_Plugin::is_admin() ) { return; }
179
+		if ( GravityView_Plugin::is_admin() ) { return; }
180 180
 
181
-		if( empty( $this->shortcode_name ) ) { return; }
181
+		if ( empty( $this->shortcode_name ) ) { return; }
182 182
 
183 183
 		// If the widget shouldn't output on single entries, don't show it
184
-		if( empty( $this->show_on_single ) && class_exists('GravityView_frontend') && GravityView_frontend::is_single_entry() ) {
185
-			do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: Skipping; set to not run on single entry.', get_class($this)) );
184
+		if ( empty( $this->show_on_single ) && class_exists( 'GravityView_frontend' ) && GravityView_frontend::is_single_entry() ) {
185
+			do_action( 'gravityview_log_debug', sprintf( '%s[add_shortcode]: Skipping; set to not run on single entry.', get_class( $this ) ) );
186 186
 
187 187
 			add_shortcode( $this->shortcode_name, '__return_null' );
188 188
 			return;
189 189
 		}
190 190
 
191 191
 
192
-		if( !has_gravityview_shortcode( $post ) ) {
192
+		if ( ! has_gravityview_shortcode( $post ) ) {
193 193
 
194
-			do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class($this)) );
194
+			do_action( 'gravityview_log_debug', sprintf( '%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class( $this ) ) );
195 195
 
196 196
 			add_shortcode( $this->shortcode_name, '__return_null' );
197 197
 			return;
198 198
 		}
199 199
 
200
-		add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode') );
200
+		add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode' ) );
201 201
 	}
202 202
 
203 203
 	/**
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	function register_widget( $widgets ) {
209 209
 		$widgets[ $this->widget_id ] = array(
210
-			'label' => $this->widget_label ,
210
+			'label' => $this->widget_label,
211 211
 			'description' => $this->widget_description,
212 212
 			'subtitle' => $this->widget_subtitle,
213 213
 		);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 */
225 225
 	public function assign_widget_options( $options = array(), $template = '', $widget = '' ) {
226 226
 
227
-		if( $this->widget_id === $widget ) {
227
+		if ( $this->widget_id === $widget ) {
228 228
 			$options = array_merge( $options, $this->settings );
229 229
 		}
230 230
 
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return void
239 239
 	 */
240
-	public function render_frontend( $widget_args, $content = '', $context = '') {
240
+	public function render_frontend( $widget_args, $content = '', $context = '' ) {
241 241
 		// to be defined by child class
242
-		if( !$this->pre_render_frontend() ) {
242
+		if ( ! $this->pre_render_frontend() ) {
243 243
 			return;
244 244
 		}
245 245
 	}
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 	public function pre_render_frontend() {
252 252
 		$gravityview_view = GravityView_View::getInstance();
253 253
 
254
-		if( empty( $gravityview_view ) ) {
255
-			do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this)) );
254
+		if ( empty( $gravityview_view ) ) {
255
+			do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class( $this ) ) );
256 256
 			return false;
257 257
 		}
258 258
 
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 		 */
264 264
 		$hide_until_search = apply_filters( 'gravityview/widget/hide_until_searched', $gravityview_view->hide_until_searched, $this );
265 265
 
266
-		if( $hide_until_search ) {
267
-			do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: Hide View data until search is performed', get_class($this)) );
266
+		if ( $hide_until_search ) {
267
+			do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: Hide View data until search is performed', get_class( $this ) ) );
268 268
 			return false;
269 269
 		}
270 270
 
Please login to merge, or discard this patch.
gravityview.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' );
313 313
 
314 314
 
315
-        /**
316
-         * When an entry is created, check if we need to update the custom slug meta
317
-         * todo: move this to its own class..
318
-         */
319
-        add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
315
+		/**
316
+		 * When an entry is created, check if we need to update the custom slug meta
317
+		 * todo: move this to its own class..
318
+		 */
319
+		add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
320 320
 
321 321
 		/**
322 322
 		 * @action `gravityview_include_frontend_actions` Triggered after all GravityView frontend files are loaded
@@ -347,34 +347,34 @@  discard block
 block discarded – undo
347 347
 
348 348
 	/** DEBUG */
349 349
 
350
-    /**
351
-     * Logs messages using Gravity Forms logging add-on
352
-     * @param  string $message log message
353
-     * @param mixed $data Additional data to display
354
-     * @return void
355
-     */
356
-    public static function log_debug( $message, $data = null ){
357
-	    /**
358
-	     * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
359
-	     * @param string $message Message to display
360
-	     * @param mixed $data Supporting data to print alongside it
361
-	     */
362
-    	do_action( 'gravityview_log_debug', $message, $data );
363
-    }
364
-
365
-    /**
366
-     * Logs messages using Gravity Forms logging add-on
367
-     * @param  string $message log message
368
-     * @return void
369
-     */
370
-    public static function log_error( $message, $data = null ){
371
-	    /**
372
-	     * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
373
-	     * @param string $message Error message to display
374
-	     * @param mixed $data Supporting data to print alongside it
375
-	     */
376
-    	do_action( 'gravityview_log_error', $message, $data );
377
-    }
350
+	/**
351
+	 * Logs messages using Gravity Forms logging add-on
352
+	 * @param  string $message log message
353
+	 * @param mixed $data Additional data to display
354
+	 * @return void
355
+	 */
356
+	public static function log_debug( $message, $data = null ){
357
+		/**
358
+		 * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
359
+		 * @param string $message Message to display
360
+		 * @param mixed $data Supporting data to print alongside it
361
+		 */
362
+		do_action( 'gravityview_log_debug', $message, $data );
363
+	}
364
+
365
+	/**
366
+	 * Logs messages using Gravity Forms logging add-on
367
+	 * @param  string $message log message
368
+	 * @return void
369
+	 */
370
+	public static function log_error( $message, $data = null ){
371
+		/**
372
+		 * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
373
+		 * @param string $message Error message to display
374
+		 * @param mixed $data Supporting data to print alongside it
375
+		 */
376
+		do_action( 'gravityview_log_error', $message, $data );
377
+	}
378 378
 
379 379
 } // end class GravityView_Plugin
380 380
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
      * @param mixed $data Additional data to display
352 352
      * @return void
353 353
      */
354
-    public static function log_debug( $message, $data = null ){
354
+    public static function log_debug( $message, $data = null ) {
355 355
 	    /**
356 356
 	     * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
357 357
 	     * @param string $message Message to display
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
      * @param  string $message log message
366 366
      * @return void
367 367
      */
368
-    public static function log_error( $message, $data = null ){
368
+    public static function log_error( $message, $data = null ) {
369 369
 	    /**
370 370
 	     * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
371 371
 	     * @param string $message Error message to display
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public static function getInstance() {
74 74
 
75
-		if( empty( self::$instance ) ) {
75
+		if ( empty( self::$instance ) ) {
76 76
 			self::$instance = new self;
77 77
 		}
78 78
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
 		self::require_files();
85 85
 
86
-		if( ! GravityView_Compatibility::is_valid() ) {
86
+		if ( ! GravityView_Compatibility::is_valid() ) {
87 87
 			return;
88 88
 		}
89 89
 
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	private static function require_files() {
100 100
 		require_once( GRAVITYVIEW_DIR . 'includes/helper-functions.php' );
101
-		require_once( GRAVITYVIEW_DIR . 'includes/class-common.php');
102
-		require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php');
101
+		require_once( GRAVITYVIEW_DIR . 'includes/class-common.php' );
102
+		require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php' );
103 103
 		require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-compatibility.php' );
104 104
 		require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-roles-capabilities.php' );
105 105
 		require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-notices.php' );
106
-		require_once( GRAVITYVIEW_DIR .'includes/class-admin.php' );
107
-		require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php');
108
-		require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php');
106
+		require_once( GRAVITYVIEW_DIR . 'includes/class-admin.php' );
107
+		require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php' );
108
+		require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php' );
109 109
 	}
110 110
 
111 111
 	/**
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
 		}
139 139
 
140 140
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-approval-status.php' );
141
-		include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-approval.php' );
141
+		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-approval.php' );
142 142
 
143
-		include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-notes.php' );
144
-		include_once( GRAVITYVIEW_DIR .'includes/load-plugin-and-theme-hooks.php' );
143
+		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-notes.php' );
144
+		include_once( GRAVITYVIEW_DIR . 'includes/load-plugin-and-theme-hooks.php' );
145 145
 
146 146
 		// Load Extensions
147 147
 		// @todo: Convert to a scan of the directory or a method where this all lives
148
-		include_once( GRAVITYVIEW_DIR .'includes/extensions/edit-entry/class-edit-entry.php' );
149
-		include_once( GRAVITYVIEW_DIR .'includes/extensions/delete-entry/class-delete-entry.php' );
150
-		include_once( GRAVITYVIEW_DIR .'includes/extensions/entry-notes/class-gravityview-field-notes.php' );
148
+		include_once( GRAVITYVIEW_DIR . 'includes/extensions/edit-entry/class-edit-entry.php' );
149
+		include_once( GRAVITYVIEW_DIR . 'includes/extensions/delete-entry/class-delete-entry.php' );
150
+		include_once( GRAVITYVIEW_DIR . 'includes/extensions/entry-notes/class-gravityview-field-notes.php' );
151 151
 
152 152
 		// Load WordPress Widgets
153
-		include_once( GRAVITYVIEW_DIR .'includes/wordpress-widgets/register-wordpress-widgets.php' );
153
+		include_once( GRAVITYVIEW_DIR . 'includes/wordpress-widgets/register-wordpress-widgets.php' );
154 154
 
155 155
 		// Load GravityView Widgets
156
-		include_once( GRAVITYVIEW_DIR .'includes/widgets/register-gravityview-widgets.php' );
156
+		include_once( GRAVITYVIEW_DIR . 'includes/widgets/register-gravityview-widgets.php' );
157 157
 
158 158
 		// Add oEmbed
159 159
 		include_once( GRAVITYVIEW_DIR . 'includes/class-oembed.php' );
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 		include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' );
167 167
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-bar.php' );
168 168
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-list.php' );
169
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php'); /** @since 1.8.4 */
169
+		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php' ); /** @since 1.8.4 */
170 170
 		include_once( GRAVITYVIEW_DIR . 'includes/class-data.php' );
171 171
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-shortcode.php' );
172 172
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-link-shortcode.php' );
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @return bool
182 182
 	 */
183 183
 	public static function is_network_activated() {
184
-		return is_multisite() && ( function_exists('is_plugin_active_for_network') && is_plugin_active_for_network( 'gravityview/gravityview.php' ) );
184
+		return is_multisite() && ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'gravityview/gravityview.php' ) );
185 185
 	}
186 186
 
187 187
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 * @since 1.7.5.1
247 247
 	 */
248 248
 	public static function include_widget_class() {
249
-		include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' );
249
+		include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget.php' );
250 250
 	}
251 251
 
252 252
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		}
269 269
 		if ( ! $loaded ) {
270 270
 			$locale = apply_filters( 'plugin_locale', get_locale(), 'gravityview' );
271
-			$mofile = dirname( __FILE__ ) . '/languages/gravityview-'. $locale .'.mo';
271
+			$mofile = dirname( __FILE__ ) . '/languages/gravityview-' . $locale . '.mo';
272 272
 			load_textdomain( 'gravityview', $mofile );
273 273
 		}
274 274
 
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	public function frontend_actions( $force = false ) {
301 301
 
302
-		if( self::is_admin() && ! $force ) { return; }
302
+		if ( self::is_admin() && ! $force ) { return; }
303 303
 
304 304
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-image.php' );
305
-		include_once( GRAVITYVIEW_DIR .'includes/class-template.php' );
306
-		include_once( GRAVITYVIEW_DIR .'includes/class-api.php' );
307
-		include_once( GRAVITYVIEW_DIR .'includes/class-frontend-views.php' );
305
+		include_once( GRAVITYVIEW_DIR . 'includes/class-template.php' );
306
+		include_once( GRAVITYVIEW_DIR . 'includes/class-api.php' );
307
+		include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' );
308 308
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' );
309 309
 
310 310
 
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 	 */
330 330
 	public static function get_default_widget_areas() {
331 331
 		$default_areas = array(
332
-			array( '1-1' => array( array( 'areaid' => 'top', 'title' => __('Top', 'gravityview' ) , 'subtitle' => '' ) ) ),
333
-			array( '1-2' => array( array( 'areaid' => 'left', 'title' => __('Left', 'gravityview') , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __('Right', 'gravityview') , 'subtitle' => '' ) ) ),
332
+			array( '1-1' => array( array( 'areaid' => 'top', 'title' => __( 'Top', 'gravityview' ), 'subtitle' => '' ) ) ),
333
+			array( '1-2' => array( array( 'areaid' => 'left', 'title' => __( 'Left', 'gravityview' ), 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __( 'Right', 'gravityview' ), 'subtitle' => '' ) ) ),
334 334
 		);
335 335
 
336 336
 		/**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
      * @param mixed $data Additional data to display
349 349
      * @return void
350 350
      */
351
-    public static function log_debug( $message, $data = null ){
351
+    public static function log_debug( $message, $data = null ) {
352 352
 	    /**
353 353
 	     * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
354 354
 	     * @param string $message Message to display
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
      * @param  string $message log message
363 363
      * @return void
364 364
      */
365
-    public static function log_error( $message, $data = null ){
365
+    public static function log_error( $message, $data = null ) {
366 366
 	    /**
367 367
 	     * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
368 368
 	     * @param string $message Error message to display
@@ -373,4 +373,4 @@  discard block
 block discarded – undo
373 373
 
374 374
 } // end class GravityView_Plugin
375 375
 
376
-add_action('plugins_loaded', array('GravityView_Plugin', 'getInstance'), 1);
376
+add_action( 'plugins_loaded', array( 'GravityView_Plugin', 'getInstance' ), 1 );
Please login to merge, or discard this patch.
includes/admin/field-types/type_hidden.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 			return;
16 16
 		}
17 17
 
18
-        $class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
18
+		$class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
19 19
 
20 20
 		?>
21 21
 		<input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="hidden" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>" />
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@
 block discarded – undo
10 10
 
11 11
 	function render_input( $override_input = null ) {
12 12
 
13
-		if( isset( $override_input ) ) {
13
+		if ( isset( $override_input ) ) {
14 14
 			echo $override_input;
15 15
 			return;
16 16
 		}
17 17
 
18
-        $class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
18
+        $class = ! empty( $this->field[ 'class' ] ) ? $this->field[ 'class' ] : 'widefat';
19 19
 
20 20
 		?>
21 21
 		<input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="hidden" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>" />
Please login to merge, or discard this patch.