Completed
Push — develop ( d956b3...4d2f7f )
by Zack
08:58
created

GV_License_Handler::validate_license_key()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 30
Code Lines 18

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 30
rs 8.439
cc 5
eloc 18
nc 7
nop 2
1
<?php
2
3
class GV_License_Handler {
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
4
5
	/**
6
	 * @var GravityView_Settings
7
	 */
8
	private $Addon;
9
10
	const name = 'GravityView';
11
12
	const author = 'Katz Web Services, Inc.';
13
	
14
	const url = 'https://gravityview.co';
15
	
16
	const version = GravityView_Plugin::version;
17
18
	/**
19
	 * Post ID on gravityview.co
20
	 * @since 1.15
21
	 */
22
	const item_id = 17;
23
24
	private $EDD_SL_Plugin_Updater;
25
26
	/**
27
	 * @var GV_License_Handler
28
	 */
29
	public static $instance;
30
31
	/**
32
	 * @param GravityView_Settings $GFAddOn
33
	 *
34
	 * @return GV_License_Handler
35
	 */
36
	public static function get_instance( GravityView_Settings $GFAddOn ) {
37
		if( empty( self::$instance ) ) {
38
			self::$instance = new self( $GFAddOn );
39
		}
40
		return self::$instance;
41
	}
42
	
43
	private function __construct( GravityView_Settings $GFAddOn ) {
44
45
		$this->Addon = $GFAddOn;
46
47
		$this->setup_edd();
48
		
49
		$this->add_hooks();
50
	}
51
52
	private function add_hooks() {
53
		add_action( 'wp_ajax_gravityview_license', array( $this, 'license_call' ) );
54
	}
55
56
	function settings_edd_license_activation( $field, $echo ) {
0 ignored issues
show
Unused Code introduced by
The parameter $field is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
57
58
		$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
59
60
		wp_enqueue_script( 'gv-admin-edd-license', GRAVITYVIEW_URL . 'assets/js/admin-edd-license' . $script_debug . '.js', array( 'jquery' ) );
61
62
		$status = trim( $this->Addon->get_app_setting( 'license_key_status' ) );
63
		$key = trim( $this->Addon->get_app_setting( 'license_key' ) );
64
65
		if( !empty( $key ) ) {
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
66
			$response = $this->Addon->get_app_setting( 'license_key_response' );
67
			$response = is_array( $response ) ? (object) $response : json_decode( $response );
68
		} else {
69
			$response = array();
70
		}
71
72
		wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array(
73
			'license_box' => $this->get_license_message( $response )
74
		));
75
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
76
77
		$fields = array(
78
			array(
79
				'name'  => 'edd-activate',
80
				'value' => __('Activate License', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
81
				'data-pending_text' => __('Verifying license&hellip;', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
82
				'data-edd_action' => 'activate_license',
83
				'class' => 'button-primary',
84
			),
85
			array(
86
				'name'  => 'edd-deactivate',
87
				'value' => __('Deactivate License', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
88
				'data-pending_text' => __('Deactivating license&hellip;', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
89
				'data-edd_action' => 'deactivate_license',
90
				'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ),
91
			),
92
			array(
93
				'name'  => 'edd-check',
94
				'value' => __('Check License', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
95
				'data-pending_text' => __('Verifying license&hellip;', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
96
				'title' => 'Check the license before saving it',
97
				'data-edd_action' => 'check_license',
98
				'class' => 'button-secondary',
99
			),
100
		);
101
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
102
103
		$class = 'button gv-edd-action';
104
105
		$class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide';
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
106
107
		$disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled';
108
109
		$submit = '<div class="gv-edd-button-wrapper">';
110
		foreach ( $fields as $field ) {
111
			$field['type'] = 'button';
112
			$field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class;
113
			$field['style'] = 'margin-left: 10px;';
114
			if( $disabled_attribute ) {
115
				$field['disabled'] = $disabled_attribute;
116
			}
117
			$submit .= $this->Addon->settings_submit( $field, $echo );
118
		}
119
		$submit .= '</div>';
120
121
		return $submit;
122
	}
123
124
	/**
125
	 * Include the EDD plugin updater class, if not exists
126
	 * @since 1.7.4
127
	 * @return void
128
	 */
129
	private function setup_edd() {
130
131
		if( !class_exists('EDD_SL_Plugin_Updater') ) {
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
132
			require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
133
		}
134
135
		// setup the updater
136
		$this->EDD_SL_Plugin_Updater = new EDD_SL_Plugin_Updater(
137
			self::url,
138
			GRAVITYVIEW_FILE,
139
			$this->_get_edd_settings()
140
		);
141
142
	}
143
144
	/**
145
	 * Generate the array of settings passed to the EDD license call
146
	 *
147
	 * @since 1.7.4
148
	 *
149
	 * @param string $action The action to send to edd, such as `check_license`
150
	 * @param string $license The license key to have passed to EDD
151
	 *
152
	 * @return array
153
	 */
154
	function _get_edd_settings( $action = '', $license = '' ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
155
156
		// retrieve our license key from the DB
157
		$license_key = empty( $license ) ? trim( $this->Addon->get_app_setting( 'license_key' ) ) : $license;
158
159
		$settings = array(
160
			'version'   => self::version,
161
			'license'   => $license_key,
162
			'item_name' => self::name,
163
			'item_id'   => self::item_id,
164
			'author'    => self::author,
165
			'url'       => home_url(),
166
		);
167
168
		if( !empty( $action ) ) {
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
169
			$settings['edd_action'] = esc_attr( $action );
170
		}
171
172
		$settings = array_map( 'urlencode', $settings );
173
174
		return $settings;
175
	}
176
177
	/**
178
	 * Perform the call
179
	 * @return array|WP_Error
180
	 */
181
	private function _license_get_remote_response( $data, $license = '' ) {
182
183
		$api_params = $this->_get_edd_settings( $data['edd_action'], $license );
184
185
		$url = add_query_arg( $api_params, self::url );
186
187
		$response = wp_remote_get( $url, array(
0 ignored issues
show
introduced by
wp_remote_get is highly discouraged, please use vip_safe_wp_remote_get() instead.
Loading history...
188
			'timeout'   => 15,
189
			'sslverify' => false,
190
		));
191
192
		if ( is_wp_error( $response ) ) {
193
			return array();
194
		}
195
196
		$license_data = json_decode( wp_remote_retrieve_body( $response ) );
197
198
		// Not JSON
199
		if ( empty( $license_data ) ) {
200
201
			delete_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid' );
202
203
			// Change status
204
			return array();
205
		}
206
207
		// Store the license key inside the data array
208
		$license_data->license_key = $license;
209
210
		return $license_data;
211
	}
212
213
	/**
214
	 * Generate the status message displayed in the license field
215
	 *
216
	 * @since 1.7.4
217
	 * @param $license_data
218
	 *
219
	 * @return string
220
	 */
221
	function get_license_message( $license_data ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
222
223
		if( empty( $license_data ) ) {
224
			$class = 'hide';
225
			$message = '';
226
		} else {
227
228
			if( ! empty( $license_data->error ) ) {
229
				$class = 'error';
230
				$string_key = $license_data->license;
231
			} else {
232
				$class = $license_data->license;
233
				$string_key = $license_data->license;
234
			}
235
236
			$message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
237
		}
238
239
		return $this->generate_license_box( $message, $class );
240
	}
241
242
	/**
243
	 * Generate the status message box HTML based on the current status
244
	 *
245
	 * @since 1.7.4
246
	 * @param $message
247
	 * @param string $class
248
	 *
249
	 * @return string
250
	 */
251
	private function generate_license_box( $message, $class = '' ) {
252
253
		$template = '<div id="gv-edd-status" class="gv-edd-message inline %s">%s</div>';
254
255
		$output = sprintf( $template, esc_attr( $class ), $message );
256
257
		return $output;
258
	}
259
260
	/**
261
	 * Perform the call to EDD based on the AJAX call or passed data
262
	 *
263
	 * @since 1.7.4
264
	 *
265
	 * @param array $array {
266
	 * @type string $license The license key
267
	 * @type string $edd_action The EDD action to perform, like `check_license`
268
	 * @type string $field_id The ID of the field to check
269
	 * @type boolean $update Whether to update plugin settings. Prevent updating the data by setting an `update` key to false
270
	 * @type string $format If `object`, return the object of the license data. Else, return the JSON-encoded object
271
	 * }
272
	 *
273
	 * @return mixed|string|void
274
	 */
275
	public function license_call( $array = array() ) {
276
277
		$is_ajax = ( defined('DOING_AJAX') && DOING_AJAX );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
278
		$data = empty( $array ) ? $_POST['data'] : $array;
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_POST
Loading history...
279
		$has_cap = GVCommon::has_cap( 'gravityview_edit_settings' );
280
281
		if ( $is_ajax && empty( $data['license'] ) ) {
282
			die( - 1 );
0 ignored issues
show
Coding Style Compatibility introduced by
The method license_call() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
283
		}
284
285
		// If the user isn't allowed to edit settings, show an error message
286
		if( ! $has_cap ) {
287
			$license_data = new stdClass();
288
			$license_data->error = 'capability';
289
			$license_data->message = $this->get_license_message( $license_data );
290
			$json = json_encode( $license_data );
291
		} else {
292
293
			$license      = esc_attr( rgget( 'license', $data ) );
294
			$license_data = $this->_license_get_remote_response( $data, $license );
295
296
			// Empty is returned when there's an error.
297
			if ( empty( $license_data ) ) {
298
				if ( $is_ajax ) {
299
					exit( json_encode( array() ) );
0 ignored issues
show
Coding Style Compatibility introduced by
The method license_call() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
300
				} else { // Non-ajax call
301
					return json_encode( array() );
302
				}
303
			}
304
305
			$license_data->message = $this->get_license_message( $license_data );
306
307
			$json = json_encode( $license_data );
308
309
			$update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) );
310
311
			$is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX );
312
313
			// Failed is the response from trying to de-activate a license and it didn't work.
314
			// This likely happened because people entered in a different key and clicked "Deactivate",
315
			// meaning to deactivate the original key. We don't want to save this response, since it is
316
			// most likely a mistake.
317
			if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) {
0 ignored issues
show
introduced by
Found "!== '". Use Yoda Condition checks, you must
Loading history...
318
319
				if ( ! empty( $data['field_id'] ) ) {
320
					set_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid', $license_data, DAY_IN_SECONDS );
321
				}
322
323
				$this->license_call_update_settings( $license_data, $data );
324
325
			}
326
		} // End $has_cap
327
328
		if ( $is_ajax ) {
329
			exit( $json );
0 ignored issues
show
Coding Style Compatibility introduced by
The method license_call() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
330
		} else { // Non-ajax call
331
			return ( rgget('format', $data ) === 'object' ) ? $license_data : $json;
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
332
		}
333
	}
334
335
	/**
336
	 * Update the license after fetching it
337
	 * @param object $license_data
338
	 * @return void
339
	 */
340
	private function license_call_update_settings( $license_data, $data ) {
341
342
		// Update option with passed data license
343
		$settings = $this->Addon->get_app_settings();
344
345
        $settings['license_key'] = $license_data->license_key = trim( $data['license'] );
346
		$settings['license_key_status'] = $license_data->license;
347
		$settings['license_key_response'] = (array)$license_data;
0 ignored issues
show
introduced by
No space after closing casting parenthesis is prohibited
Loading history...
348
349
		$this->Addon->update_app_settings( $settings );
350
	}
351
352
	/**
353
	 * URL to direct license renewal, or if license key is not set, then just the account page
354
	 * @since 1.13.1
355
	 * @param  object|null $license_data Object with license data
356
	 * @return string Renewal or account URL
357
	 */
358
	private function get_license_renewal_url( $license_data ) {
359
		$renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key ) : 'https://gravityview.co/account/';
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
360
		return $renew_license_url;
361
	}
362
363
	/**
364
	 * Override the text used in the Redux Framework EDD field extension
365
	 * @param  array|null $status Status to get. If empty, get all strings.
366
	 * @param  object|null $license_data Object with license data
367
	 * @return array          Modified array of content
368
	 */
369
	public function strings( $status = NULL, $license_data = null ) {
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
370
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
371
372
		$strings = array(
373
			'status' => esc_html__('Status', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
374
			'error' => esc_html__('There was an error processing the request.', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
375
			'failed'  => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
376
			'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
377
			'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
378
			'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
379
			'valid' => esc_html__('The license key is valid and active.', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
380
			'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
381
			'missing' => esc_html__('The license key was not defined.', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
382
			'revoked' => esc_html__('This license key has been revoked.', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
383
			'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
384
			'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ),
385
386
			'verifying_license' => esc_html__('Verifying license&hellip;', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
387
			'activate_license' => esc_html__('Activate License', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
388
			'deactivate_license' => esc_html__('Deactivate License', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
389
			'check_license' => esc_html__('Verify License', 'gravityview'),
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
390
		);
391
392
		if( empty( $status ) ) {
393
			return $strings;
394
		}
395
396
		if( isset( $strings[ $status ] ) ) {
397
			return $strings[ $status ];
398
		}
399
400
		return NULL;
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
401
	}
402
403
	public function validate_license_key( $value, $field ) {
404
405
		// No license? No status.
406
		if( empty( $value ) ) {
407
			return NULL;
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
408
		}
409
410
		$response = $this->license_call(array(
411
			'license' => $this->Addon->get_app_setting( 'license_key' ),
412
			'edd_action' => 'check_license',
413
			'field_id' => $field['name'],
414
		));
415
416
		$response = is_string( $response ) ? json_decode( $response, true ) : $response;
417
418
		switch( $response['license'] ) {
419
			case 'valid':
420
				$return = true;
421
				break;
422
			case 'invalid':
423
				$return = false;
424
				//$this->Addon->set_field_error( $field, $response['message'] );
0 ignored issues
show
Unused Code Comprehensibility introduced by
71% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
425
				break;
426
			default:
427
				//$this->Addon->set_field_error( $field, $response['message'] );
0 ignored issues
show
Unused Code Comprehensibility introduced by
71% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
428
				$return = false;
429
		}
430
431
		return $return;
432
	}
433
434
}