Completed
Push — master ( 207dd4...0cb291 )
by J.D.
13s
created
src/includes/importers/cubepoints.php 1 patch
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -66,36 +66,36 @@  discard block
 block discarded – undo
66 66
 	/**
67 67
 	 * @since 1.0.0
68 68
 	 */
69
-	public function __construct( $name ) {
69
+	public function __construct($name) {
70 70
 
71
-		parent::__construct( $name );
71
+		parent::__construct($name);
72 72
 
73 73
 		$this->components = array(
74 74
 			'points' => array(
75 75
 				'excluded_users' => array(
76
-					'label' => __( 'Excluded users', 'wordpoints-importer' ),
77
-					'function' => array( $this, 'import_excluded_users' ),
76
+					'label' => __('Excluded users', 'wordpoints-importer'),
77
+					'function' => array($this, 'import_excluded_users'),
78 78
 				),
79 79
 				'settings'    => array(
80
-					'label' => __( 'Points Reactions', 'wordpoints-importer' ),
81
-					'description' => __( 'If checked, the settings for the number of points to award for posts, comments, etc. are imported.', 'wordpoints-importer' ),
82
-					'function' => array( $this, 'import_points_settings' ),
80
+					'label' => __('Points Reactions', 'wordpoints-importer'),
81
+					'description' => __('If checked, the settings for the number of points to award for posts, comments, etc. are imported.', 'wordpoints-importer'),
82
+					'function' => array($this, 'import_points_settings'),
83 83
 				),
84 84
 				'user_points' => array(
85
-					'label' => __( 'User points', 'wordpoints-importer' ),
86
-					'function' => array( $this, 'import_user_points' ),
85
+					'label' => __('User points', 'wordpoints-importer'),
86
+					'function' => array($this, 'import_user_points'),
87 87
 				),
88 88
 				'logs' => array(
89
-					'label' => __( 'Points logs', 'wordpoints-importer' ),
90
-					'function' => array( $this, 'import_points_logs' ),
91
-					'can_import' => array( $this, 'can_import_points_logs' ),
89
+					'label' => __('Points logs', 'wordpoints-importer'),
90
+					'function' => array($this, 'import_points_logs'),
91
+					'can_import' => array($this, 'can_import_points_logs'),
92 92
 				),
93 93
 			),
94 94
 			'ranks' => array(
95 95
 				'ranks' => array(
96
-					'label' => __( 'Rank settings', 'wordpoints-importer' ),
97
-					'description' => __( 'If checked, the list of ranks is imported, and users will have the correct ranks assigned to them.', 'wordpoints-importer' ),
98
-					'function' => array( $this, 'import_ranks' ),
96
+					'label' => __('Rank settings', 'wordpoints-importer'),
97
+					'description' => __('If checked, the list of ranks is imported, and users will have the correct ranks assigned to them.', 'wordpoints-importer'),
98
+					'function' => array($this, 'import_ranks'),
99 99
 				),
100 100
 			),
101 101
 		);
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function is_available() {
108 108
 
109
-		if ( ! $this->is_cubepoints_installed() ) {
109
+		if (!$this->is_cubepoints_installed()) {
110 110
 			return new WP_Error(
111 111
 				'cubepoints_not_installed'
112
-				, __( 'CubePoints is not installed', 'wordpoints-importer' )
112
+				, __('CubePoints is not installed', 'wordpoints-importer')
113 113
 			);
114 114
 		}
115 115
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	public function is_cubepoints_installed() {
125 125
 
126
-		return (bool) get_option( 'cp_db_version' );
126
+		return (bool) get_option('cp_db_version');
127 127
 	}
128 128
 
129 129
 	/**
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public function is_cubepoints_active() {
135 135
 
136
-		return function_exists( 'cp_ready' );
136
+		return function_exists('cp_ready');
137 137
 	}
138 138
 
139 139
 	/**
@@ -143,22 +143,22 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	protected function import_excluded_users() {
145 145
 
146
-		$this->feedback->info( __( 'Importing excluded users…', 'wordpoints-importer' ) );
146
+		$this->feedback->info(__('Importing excluded users…', 'wordpoints-importer'));
147 147
 
148
-		$excluded_users = get_option( 'cp_topfilter' );
148
+		$excluded_users = get_option('cp_topfilter');
149 149
 
150
-		if ( ! is_array( $excluded_users ) ) {
151
-			$this->feedback->warning( __( 'No excluded users found.', 'wordpoints-importer' ) );
150
+		if (!is_array($excluded_users)) {
151
+			$this->feedback->warning(__('No excluded users found.', 'wordpoints-importer'));
152 152
 			return;
153 153
 		}
154 154
 
155 155
 		$user_ids = array();
156 156
 
157
-		foreach ( $excluded_users as $user_login ) {
157
+		foreach ($excluded_users as $user_login) {
158 158
 
159
-			$user = get_user_by( 'login', $user_login );
159
+			$user = get_user_by('login', $user_login);
160 160
 
161
-			if ( $user instanceof WP_User ) {
161
+			if ($user instanceof WP_User) {
162 162
 				$user_ids[] = $user->ID;
163 163
 			}
164 164
 		}
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		);
169 169
 
170 170
 		$excluded_user_ids = array_unique(
171
-			array_merge( $excluded_user_ids, $user_ids )
171
+			array_merge($excluded_user_ids, $user_ids)
172 172
 		);
173 173
 
174 174
 		wordpoints_update_maybe_network_option(
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 
179 179
 		$this->feedback->success(
180 180
 			sprintf(
181
-				__( 'Imported %s excluded users.', 'wordpoints-importer' )
182
-				, count( $user_ids )
181
+				__('Imported %s excluded users.', 'wordpoints-importer')
182
+				, count($user_ids)
183 183
 			)
184 184
 		);
185 185
 	}
@@ -191,64 +191,64 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @param array $settings The settings for the points component import.
193 193
 	 */
194
-	protected function import_points_settings( $settings ) {
194
+	protected function import_points_settings($settings) {
195 195
 
196
-		$this->feedback->info( __( 'Importing points reactions…', 'wordpoints-importer' ) );
196
+		$this->feedback->info(__('Importing points reactions…', 'wordpoints-importer'));
197 197
 
198 198
 		$options = array(
199 199
 			'cp_comment_points'     => array(
200 200
 				'event' => 'comment_leave\post',
201
-				'target' => array( 'comment\post', 'author', 'user' ),
201
+				'target' => array('comment\post', 'author', 'user'),
202 202
 				/* translators: The post type name */
203
-				'log_text' => __( 'Comment on a %s.', 'wordpoints-importer' ),
203
+				'log_text' => __('Comment on a %s.', 'wordpoints-importer'),
204 204
 				/* translators: The post type name */
205
-				'description' => __( 'Commenting on a %s.', 'wordpoints-importer' ),
205
+				'description' => __('Commenting on a %s.', 'wordpoints-importer'),
206 206
 				'legacy_log_type' => 'cubepoints-comment',
207 207
 				'legacy_meta_key' => 'comment',
208 208
 			),
209 209
 			'cp_post_points'        => array(
210 210
 				'event' => 'post_publish\post',
211
-				'target' => array( 'post\post', 'author', 'user' ),
211
+				'target' => array('post\post', 'author', 'user'),
212 212
 				/* translators: The post type name */
213
-				'log_text' => __( 'Published a Post.', 'wordpoints-importer' ),
213
+				'log_text' => __('Published a Post.', 'wordpoints-importer'),
214 214
 				/* translators: The post type name */
215
-				'description' => __( 'Publishing a Post.', 'wordpoints-importer' ),
215
+				'description' => __('Publishing a Post.', 'wordpoints-importer'),
216 216
 				'legacy_log_type' => 'cubepoints-post',
217 217
 				'legacy_meta_key' => 'post',
218 218
 				// CubePoints doesn't remove points when a post is deleted.
219
-				'blocker' => array( 'toggle_off' => true ),
220
-				'points_legacy_repeat_blocker' => array( 'toggle_on' => true ),
219
+				'blocker' => array('toggle_off' => true),
220
+				'points_legacy_repeat_blocker' => array('toggle_on' => true),
221 221
 			),
222 222
 			'cp_reg_points'         => array(
223 223
 				'event' => 'user_register',
224
-				'log_text' => __( 'Registration.', 'wordpoints-importer' ),
225
-				'description' => __( 'Registration.', 'wordpoints-importer' ),
224
+				'log_text' => __('Registration.', 'wordpoints-importer'),
225
+				'description' => __('Registration.', 'wordpoints-importer'),
226 226
 				'legacy_log_type' => 'cubepoints-register',
227 227
 			),
228 228
 			'cp_post_author_points' => array(
229 229
 				'event' => 'comment_leave\post',
230
-				'target' => array( 'comment\post', 'post\post', 'post\post', 'author', 'user' ),
230
+				'target' => array('comment\post', 'post\post', 'post\post', 'author', 'user'),
231 231
 				/* translators: The post type name */
232
-				'log_text' => __( 'Received a comment on a %s.', 'wordpoints-importer' ),
232
+				'log_text' => __('Received a comment on a %s.', 'wordpoints-importer'),
233 233
 				/* translators: The post type name */
234
-				'description' => __( 'Receiving a comment on a %s.', 'wordpoints-importer' ),
234
+				'description' => __('Receiving a comment on a %s.', 'wordpoints-importer'),
235 235
 				'legacy_log_type' => 'cubepoints-post_author',
236 236
 				'legacy_meta_key' => 'comment',
237 237
 			),
238 238
 		);
239 239
 
240 240
 		// Don't import this module setting if the module isn't active.
241
-		if ( function_exists( 'cp_module_activated' ) && ! cp_module_activated( 'post_author_points' ) ) {
242
-			unset( $options['cp_post_author_points'] );
241
+		if (function_exists('cp_module_activated') && !cp_module_activated('post_author_points')) {
242
+			unset($options['cp_post_author_points']);
243 243
 		}
244 244
 
245 245
 		$imported = 0;
246 246
 
247
-		foreach ( $options as $option => $hook_settings ) {
247
+		foreach ($options as $option => $hook_settings) {
248 248
 
249
-			$points = get_option( $option );
249
+			$points = get_option($option);
250 250
 
251
-			if ( wordpoints_posint( $points ) ) {
251
+			if (wordpoints_posint($points)) {
252 252
 
253 253
 				$hook_settings['points'] = $points;
254 254
 				$hook_settings['points_type'] = $settings['points_type'];
@@ -256,12 +256,12 @@  discard block
 block discarded – undo
256 256
 				if (
257 257
 					// The CubePoints post points were only awarded for Posts.
258 258
 					'post_publish\post' !== $hook_settings['event']
259
-					&& strpos( $hook_settings['event'], '\post' )
259
+					&& strpos($hook_settings['event'], '\post')
260 260
 				) {
261 261
 
262
-					$post_type_slugs = get_post_types( array( 'public' => true ) );
262
+					$post_type_slugs = get_post_types(array('public' => true));
263 263
 
264
-					foreach ( $post_type_slugs as $post_type_slug ) {
264
+					foreach ($post_type_slugs as $post_type_slug) {
265 265
 
266 266
 						$added = $this->add_points_hook(
267 267
 							$this->format_settings_for_post_type(
@@ -270,13 +270,13 @@  discard block
 block discarded – undo
270 270
 							)
271 271
 						);
272 272
 
273
-						if ( $added ) {
273
+						if ($added) {
274 274
 							$imported++;
275 275
 						}
276 276
 					}
277 277
 
278 278
 				} else {
279
-					if ( $this->add_points_hook( $hook_settings ) ) {
279
+					if ($this->add_points_hook($hook_settings)) {
280 280
 						$imported++;
281 281
 					}
282 282
 				}
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 
285 285
 		} // End foreach ( $options ).
286 286
 
287
-		if ( $this->import_daily_points_hook( $settings ) ) {
287
+		if ($this->import_daily_points_hook($settings)) {
288 288
 			$imported++;
289 289
 		}
290 290
 
291 291
 		$this->feedback->success(
292
-			sprintf( __( 'Imported %s points reactions.', 'wordpoints-importer' ), $imported )
292
+			sprintf(__('Imported %s points reactions.', 'wordpoints-importer'), $imported)
293 293
 		);
294 294
 	}
295 295
 
@@ -302,24 +302,24 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @return bool True if the settings were imported, false otherwise.
304 304
 	 */
305
-	protected function import_daily_points_hook( $settings ) {
305
+	protected function import_daily_points_hook($settings) {
306 306
 
307 307
 		// Don't import this module setting if the module isn't active.
308
-		if ( function_exists( 'cp_module_activated' ) && ! cp_module_activated( 'dailypoints' ) ) {
308
+		if (function_exists('cp_module_activated') && !cp_module_activated('dailypoints')) {
309 309
 			return false;
310 310
 		}
311 311
 
312
-		$points = get_option( 'cp_module_dailypoints_points' );
313
-		$period = get_option( 'cp_module_dailypoints_time' );
312
+		$points = get_option('cp_module_dailypoints_points');
313
+		$period = get_option('cp_module_dailypoints_time');
314 314
 
315
-		if ( ! wordpoints_int( $points ) || ! wordpoints_posint( $period ) ) {
315
+		if (!wordpoints_int($points) || !wordpoints_posint($period)) {
316 316
 			return false;
317 317
 		}
318 318
 
319 319
 		return $this->add_points_hook(
320 320
 			array(
321 321
 				'event' => 'user_visit',
322
-				'target' => array( 'current:user' ),
322
+				'target' => array('current:user'),
323 323
 				'reactor' => 'points_legacy',
324 324
 				'points' => $points,
325 325
 				'points_type' => $settings['points_type'],
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
 					'fire' => array(
328 328
 						array(
329 329
 							'length' => $period,
330
-							'args' => array( array( 'current:user' ) ),
330
+							'args' => array(array('current:user')),
331 331
 							'relative' => true,
332 332
 						),
333 333
 					),
334 334
 				),
335
-				'log_text' => __( 'Visiting the site.', 'wordpoints-importer' ),
336
-				'description' => __( 'Visiting the site.', 'wordpoints-importer' ),
335
+				'log_text' => __('Visiting the site.', 'wordpoints-importer'),
336
+				'description' => __('Visiting the site.', 'wordpoints-importer'),
337 337
 				'points_legacy_reversals' => array(),
338 338
 				'legacy_log_type' => 'cubepoints-dailypoints',
339 339
 			)
@@ -350,22 +350,22 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @return bool True if added successfully, or false on failure.
352 352
 	 */
353
-	private function add_points_hook( $settings = array() ) {
353
+	private function add_points_hook($settings = array()) {
354 354
 
355
-		$reaction_store = wordpoints_hooks()->get_reaction_store( 'points' );
355
+		$reaction_store = wordpoints_hooks()->get_reaction_store('points');
356 356
 
357 357
 		$settings = array_merge(
358 358
 			array(
359
-				'target' => array( 'user' ),
359
+				'target' => array('user'),
360 360
 				'reactor' => 'points_legacy',
361
-				'points_legacy_reversals' => array( 'toggle_off' => 'toggle_on' ),
361
+				'points_legacy_reversals' => array('toggle_off' => 'toggle_on'),
362 362
 			)
363 363
 			, $settings
364 364
 		);
365 365
 
366
-		$reaction = $reaction_store->create_reaction( $settings );
366
+		$reaction = $reaction_store->create_reaction($settings);
367 367
 
368
-		if ( ! $reaction instanceof WordPoints_Hook_ReactionI ) {
368
+		if (!$reaction instanceof WordPoints_Hook_ReactionI) {
369 369
 			return false;
370 370
 		}
371 371
 
@@ -382,24 +382,24 @@  discard block
 block discarded – undo
382 382
 	 *
383 383
 	 * @return array The settings modified for this particular post type.
384 384
 	 */
385
-	protected function format_settings_for_post_type( $post_type, $settings ) {
385
+	protected function format_settings_for_post_type($post_type, $settings) {
386 386
 
387 387
 		$settings['event'] = str_replace(
388 388
 			'\post'
389
-			, '\\' . $post_type
389
+			, '\\'.$post_type
390 390
 			, $settings['event']
391 391
 		);
392 392
 
393 393
 		$settings['target'] = str_replace(
394 394
 			'\post'
395
-			, '\\' . $post_type
395
+			, '\\'.$post_type
396 396
 			, $settings['target']
397 397
 		);
398 398
 
399
-		$labels = get_post_type_labels( get_post_type_object( $post_type ) );
399
+		$labels = get_post_type_labels(get_post_type_object($post_type));
400 400
 
401
-		$settings['log_text'] = sprintf( $settings['log_text'], $labels->singular_name );
402
-		$settings['description'] = sprintf( $settings['description'], $labels->singular_name );
401
+		$settings['log_text'] = sprintf($settings['log_text'], $labels->singular_name);
402
+		$settings['description'] = sprintf($settings['description'], $labels->singular_name);
403 403
 
404 404
 		return $settings;
405 405
 	}
@@ -411,21 +411,21 @@  discard block
 block discarded – undo
411 411
 	 *
412 412
 	 * @param array $settings The settings for the points component import.
413 413
 	 */
414
-	protected function import_user_points( $settings ) {
414
+	protected function import_user_points($settings) {
415 415
 
416
-		$this->feedback->info( __( 'Importing users' points…', 'wordpoints-importer' ) );
416
+		$this->feedback->info(__('Importing users' points…', 'wordpoints-importer'));
417 417
 
418 418
 		// We don't log the import transactions.
419
-		add_filter( 'wordpoints_points_log', '__return_false' );
419
+		add_filter('wordpoints_points_log', '__return_false');
420 420
 
421 421
 		$start = 0;
422 422
 
423 423
 		// We do the import in batches.
424
-		while ( $rows = $this->get_next_user_points_batch( $start ) ) {
424
+		while ($rows = $this->get_next_user_points_batch($start)) {
425 425
 
426
-			$start += count( $rows );
426
+			$start += count($rows);
427 427
 
428
-			foreach ( $rows as $row ) {
428
+			foreach ($rows as $row) {
429 429
 
430 430
 				wordpoints_alter_points(
431 431
 					$row->user_id
@@ -435,12 +435,12 @@  discard block
 block discarded – undo
435 435
 				);
436 436
 			}
437 437
 
438
-			unset( $rows );
438
+			unset($rows);
439 439
 		}
440 440
 
441
-		remove_filter( 'wordpoints_points_log', '__return_false' );
441
+		remove_filter('wordpoints_points_log', '__return_false');
442 442
 
443
-		$this->feedback->success( sprintf( __( 'Imported points for %s users…', 'wordpoints-importer' ), $start ) );
443
+		$this->feedback->success(sprintf(__('Imported points for %s users…', 'wordpoints-importer'), $start));
444 444
 	}
445 445
 
446 446
 	/**
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	 *
453 453
 	 * @return object[]|false The rows, or false.
454 454
 	 */
455
-	protected function get_next_user_points_batch( $start ) {
455
+	protected function get_next_user_points_batch($start) {
456 456
 
457 457
 		global $wpdb;
458 458
 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 			)
470 470
 		); // WPCS: cache OK.
471 471
 
472
-		if ( ! is_array( $rows ) ) {
472
+		if (!is_array($rows)) {
473 473
 			return false;
474 474
 		}
475 475
 
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
 	 */
486 486
 	public function can_import_points_logs() {
487 487
 
488
-		if ( ! $this->is_cubepoints_active() ) {
488
+		if (!$this->is_cubepoints_active()) {
489 489
 
490 490
 			return new WP_Error(
491 491
 				'wordpoints_import_points_logs_cubepoints_inactive'
492
-				, __( 'CubePoints must be active.', 'wordpoints-importer' )
492
+				, __('CubePoints must be active.', 'wordpoints-importer')
493 493
 			);
494 494
 		}
495 495
 
@@ -503,17 +503,17 @@  discard block
 block discarded – undo
503 503
 	 *
504 504
 	 * @param array $settings The import settings for the points component.
505 505
 	 */
506
-	protected function import_points_logs( $settings ) {
506
+	protected function import_points_logs($settings) {
507 507
 
508
-		$this->feedback->info( __( 'Importing points logs…', 'wordpoints-importer' ) );
508
+		$this->feedback->info(__('Importing points logs…', 'wordpoints-importer'));
509 509
 
510 510
 		$start = 0;
511 511
 
512
-		while ( $logs = $this->get_next_points_logs_batch( $start ) ) {
512
+		while ($logs = $this->get_next_points_logs_batch($start)) {
513 513
 
514
-			$start += count( $logs );
514
+			$start += count($logs);
515 515
 
516
-			foreach ( $logs as $log ) {
516
+			foreach ($logs as $log) {
517 517
 
518 518
 				$this->import_points_log(
519 519
 					$log->uid
@@ -524,14 +524,14 @@  discard block
 block discarded – undo
524 524
 						'cubepoints_type' => $log->type,
525 525
 						'cubepoints_data' => $log->data,
526 526
 					)
527
-					, date( 'Y-m-d H:i:s', $log->timestamp )
527
+					, date('Y-m-d H:i:s', $log->timestamp)
528 528
 				);
529 529
 			}
530 530
 
531
-			unset( $logs );
531
+			unset($logs);
532 532
 		}
533 533
 
534
-		$this->feedback->success( sprintf( __( 'Imported %s points log entries.', 'wordpoints-importer' ), $start ) );
534
+		$this->feedback->success(sprintf(__('Imported %s points log entries.', 'wordpoints-importer'), $start));
535 535
 	}
536 536
 
537 537
 	/**
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	 * @param array  $meta        The metadata for this log.
547 547
 	 * @param int    $date        The date the transaction took place.
548 548
 	 */
549
-	protected function import_points_log( $user_id, $points, $points_type, $log_type, $meta, $date ) {
549
+	protected function import_points_log($user_id, $points, $points_type, $log_type, $meta, $date) {
550 550
 
551 551
 		global $wpdb;
552 552
 
@@ -557,54 +557,54 @@  discard block
 block discarded – undo
557 557
 				'points'      => $points,
558 558
 				'points_type' => $points_type,
559 559
 				'log_type'    => $log_type,
560
-				'text'        => $this->render_points_log_text( '', $user_id, $points, $points_type, $log_type, $meta ),
560
+				'text'        => $this->render_points_log_text('', $user_id, $points, $points_type, $log_type, $meta),
561 561
 				'date'        => $date,
562 562
 				'site_id'     => $wpdb->siteid,
563 563
 				'blog_id'     => $wpdb->blogid,
564 564
 			),
565
-			array( '%d', '%d', '%s', '%s', '%s', '%s', '%d', '%d' )
565
+			array('%d', '%d', '%s', '%s', '%s', '%s', '%d', '%d')
566 566
 		);
567 567
 
568
-		if ( false !== $result ) {
568
+		if (false !== $result) {
569 569
 
570 570
 			$log_id = (int) $wpdb->insert_id;
571 571
 
572 572
 			// Set auto_reversed and original_log_id metadata for reversed logs.
573
-			foreach ( $this->reversible_log_types as $reverse_type => $type ) {
573
+			foreach ($this->reversible_log_types as $reverse_type => $type) {
574 574
 
575
-				if ( $meta['cubepoints_type'] === $type ) {
575
+				if ($meta['cubepoints_type'] === $type) {
576 576
 
577 577
 					// Save this log ID for later, in case this log was reversed.
578 578
 					// cubepoints_data will contain the entity ID.
579
-					$this->reversible_log_ids[ $type ][ $meta['cubepoints_data'] ] = $log_id;
579
+					$this->reversible_log_ids[$type][$meta['cubepoints_data']] = $log_id;
580 580
 
581 581
 				} elseif (
582 582
 					$meta['cubepoints_type'] === $reverse_type
583
-					&& isset( $this->reversible_log_ids[ $type ][ $meta['cubepoints_data'] ] )
583
+					&& isset($this->reversible_log_ids[$type][$meta['cubepoints_data']])
584 584
 				) {
585 585
 
586 586
 					// This log was reverses another one. Set the original log ID.
587
-					$meta['original_log_id'] = $this->reversible_log_ids[ $type ][ $meta['cubepoints_data'] ];
587
+					$meta['original_log_id'] = $this->reversible_log_ids[$type][$meta['cubepoints_data']];
588 588
 
589 589
 					// And mark the original as auto_reversed.
590
-					wordpoints_add_points_log_meta( $meta['original_log_id'], 'auto_reversed', $log_id );
590
+					wordpoints_add_points_log_meta($meta['original_log_id'], 'auto_reversed', $log_id);
591 591
 
592 592
 					// No need to keep this info anymore.
593
-					unset( $this->reversible_log_ids[ $type ][ $meta['cubepoints_data'] ] );
593
+					unset($this->reversible_log_ids[$type][$meta['cubepoints_data']]);
594 594
 				}
595 595
 			}
596 596
 
597 597
 			// Set the entity IDs to their own meta keys, for the sake of reversals.
598
-			if ( isset( $this->log_type_entities[ $meta['cubepoints_type'] ] ) ) {
599
-				$meta[ $this->log_type_entities[ $meta['cubepoints_type'] ] ] = $meta['cubepoints_data'];
598
+			if (isset($this->log_type_entities[$meta['cubepoints_type']])) {
599
+				$meta[$this->log_type_entities[$meta['cubepoints_type']]] = $meta['cubepoints_data'];
600 600
 			}
601 601
 
602
-			foreach ( $meta as $meta_key => $meta_value ) {
602
+			foreach ($meta as $meta_key => $meta_value) {
603 603
 
604
-				wordpoints_add_points_log_meta( $log_id, $meta_key, $meta_value );
604
+				wordpoints_add_points_log_meta($log_id, $meta_key, $meta_value);
605 605
 			}
606 606
 
607
-			do_action( 'wordpoints_points_log', $user_id, $points, $points_type, $log_type, $meta, $log_id );
607
+			do_action('wordpoints_points_log', $user_id, $points, $points_type, $log_type, $meta, $log_id);
608 608
 
609 609
 		} // End if ( inserted successfully ).
610 610
 	}
@@ -614,10 +614,10 @@  discard block
 block discarded – undo
614 614
 	 *
615 615
 	 * @since 1.0.0
616 616
 	 */
617
-	public function render_points_log_text( $text, $user_id, $points, $points_type, $log_type, $meta ) {
617
+	public function render_points_log_text($text, $user_id, $points, $points_type, $log_type, $meta) {
618 618
 
619 619
 		ob_start();
620
-		do_action( 'cp_logs_description', $meta['cubepoints_type'], $user_id, $points, $meta['cubepoints_data'] );
620
+		do_action('cp_logs_description', $meta['cubepoints_type'], $user_id, $points, $meta['cubepoints_data']);
621 621
 		return ob_get_clean();
622 622
 	}
623 623
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	 *
631 631
 	 * @return object[]|false The rows from the database.
632 632
 	 */
633
-	protected function get_next_points_logs_batch( $start ) {
633
+	protected function get_next_points_logs_batch($start) {
634 634
 
635 635
 		global $wpdb;
636 636
 
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 			$wpdb->prepare( // WPCS: unprepared SQL OK.
639 639
 				'
640 640
 					SELECT *
641
-					FROM `' . CP_DB . '`
641
+					FROM `' . CP_DB.'`
642 642
 					ORDER BY `id`
643 643
 					LIMIT %d,500
644 644
 				'
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
 			)
647 647
 		); // WPCS: cache OK.
648 648
 
649
-		if ( ! is_array( $logs ) ) {
650
-			$this->feedback->error( __( 'Unable to retrieve the logs from CubePoints…', 'wordpoints-importer' ) );
649
+		if (!is_array($logs)) {
650
+			$this->feedback->error(__('Unable to retrieve the logs from CubePoints…', 'wordpoints-importer'));
651 651
 			return false;
652 652
 		}
653 653
 
@@ -661,24 +661,24 @@  discard block
 block discarded – undo
661 661
 	 *
662 662
 	 * @param array $settings The import settings for the ranks component.
663 663
 	 */
664
-	public function import_ranks( $settings ) {
664
+	public function import_ranks($settings) {
665 665
 
666
-		$this->feedback->info( __( 'Importing ranks…', 'wordpoints-importer' ) );
666
+		$this->feedback->info(__('Importing ranks…', 'wordpoints-importer'));
667 667
 
668
-		$ranks_data = get_option( 'cp_module_ranks_data' );
668
+		$ranks_data = get_option('cp_module_ranks_data');
669 669
 
670
-		if ( empty( $ranks_data ) || ! is_array( $ranks_data ) ) {
671
-			$this->feedback->error( __( 'No ranks found.', 'wordpoints-importer' ) );
670
+		if (empty($ranks_data) || !is_array($ranks_data)) {
671
+			$this->feedback->error(__('No ranks found.', 'wordpoints-importer'));
672 672
 			return;
673 673
 		}
674 674
 
675 675
 		$i = 0;
676 676
 
677 677
 		// The base rank already exists, so we just update it.
678
-		if ( isset( $ranks_data[0] ) ) {
678
+		if (isset($ranks_data[0])) {
679 679
 
680 680
 			wordpoints_update_rank(
681
-				WordPoints_Rank_Groups::get_group( $settings['rank_group'] )->get_rank( 0 )
681
+				WordPoints_Rank_Groups::get_group($settings['rank_group'])->get_rank(0)
682 682
 				, $ranks_data[0]
683 683
 				, 'base'
684 684
 				, $settings['rank_group']
@@ -687,28 +687,28 @@  discard block
 block discarded – undo
687 687
 
688 688
 			$i++;
689 689
 
690
-			unset( $ranks_data[0] );
690
+			unset($ranks_data[0]);
691 691
 		}
692 692
 
693
-		$points_type = substr( $settings['rank_group'], strlen( 'points_type-' ) );
694
-		$rank_type = 'points-' . $points_type;
693
+		$points_type = substr($settings['rank_group'], strlen('points_type-'));
694
+		$rank_type = 'points-'.$points_type;
695 695
 
696
-		ksort( $ranks_data );
696
+		ksort($ranks_data);
697 697
 
698
-		foreach ( $ranks_data as $points => $rank_name ) {
698
+		foreach ($ranks_data as $points => $rank_name) {
699 699
 
700 700
 			wordpoints_add_rank(
701 701
 				$rank_name
702 702
 				, $rank_type
703 703
 				, $settings['rank_group']
704 704
 				, $i
705
-				, array( 'points' => $points, 'points_type' => $points_type )
705
+				, array('points' => $points, 'points_type' => $points_type)
706 706
 			);
707 707
 
708 708
 			$i++;
709 709
 		}
710 710
 
711
-		$this->feedback->success( sprintf( __( 'Imported %s ranks.', 'wordpoints-importer' ), $i ) );
711
+		$this->feedback->success(sprintf(__('Imported %s ranks.', 'wordpoints-importer'), $i));
712 712
 	}
713 713
 }
714 714
 
Please login to merge, or discard this patch.
src/includes/class-importer.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		 *
57 57
 		 * @since 1.0.0
58 58
 		 */
59
-		do_action( 'wordpoints_register_importers' );
59
+		do_action('wordpoints_register_importers');
60 60
 	}
61 61
 
62 62
 	//
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public static function get() {
74 74
 
75
-		if ( ! self::$initialized ) {
75
+		if (!self::$initialized) {
76 76
 			self::init();
77 77
 		}
78 78
 
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 	 *        @type string $name  The name of this importer.
95 95
 	 * }
96 96
 	 */
97
-	public static function register( $slug, array $args ) {
98
-		self::$importers[ $slug ] = $args;
97
+	public static function register($slug, array $args) {
98
+		self::$importers[$slug] = $args;
99 99
 	}
100 100
 
101 101
 	/**
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @param string $slug The slug of the importer to deregister.
107 107
 	 */
108
-	public static function deregister( $slug ) {
109
-		unset( self::$importers[ $slug ] );
108
+	public static function deregister($slug) {
109
+		unset(self::$importers[$slug]);
110 110
 	}
111 111
 
112 112
 	/**
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return bool True if the importer is registered, otherwise false.
120 120
 	 */
121
-	public static function is_registered( $slug ) {
121
+	public static function is_registered($slug) {
122 122
 
123
-		if ( ! self::$initialized ) {
123
+		if (!self::$initialized) {
124 124
 			self::init();
125 125
 		}
126 126
 
127
-		return isset( self::$importers[ $slug ] );
127
+		return isset(self::$importers[$slug]);
128 128
 	}
129 129
 
130 130
 	/**
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return WordPoints_Importer|false The importer, or false if it isn't registered.
138 138
 	 */
139
-	public static function get_importer( $slug ) {
139
+	public static function get_importer($slug) {
140 140
 
141
-		if ( ! self::is_registered( $slug ) ) {
141
+		if (!self::is_registered($slug)) {
142 142
 			return false;
143 143
 		}
144 144
 
145
-		$importer = self::$importers[ $slug ];
145
+		$importer = self::$importers[$slug];
146 146
 
147
-		return new $importer['class']( $importer['name'] );
147
+		return new $importer['class']($importer['name']);
148 148
 	}
149 149
 }
150 150
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @param string $name The name of the importer.
205 205
 	 */
206
-	public function __construct( $name ) {
206
+	public function __construct($name) {
207 207
 
208 208
 		$this->name = $name;
209 209
 	}
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 	 *
218 218
 	 * @return bool True if the component is supported, otherwise false.
219 219
 	 */
220
-	public function supports_component( $component ) {
220
+	public function supports_component($component) {
221 221
 
222
-		return isset( $this->components[ $component ] );
222
+		return isset($this->components[$component]);
223 223
 	}
224 224
 
225 225
 	/**
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return array[] The options for this component.
233 233
 	 */
234
-	public function get_options_for_component( $component ) {
234
+	public function get_options_for_component($component) {
235 235
 
236
-		if ( ! $this->supports_component( $component ) ) {
236
+		if (!$this->supports_component($component)) {
237 237
 			return array();
238 238
 		}
239 239
 
240
-		return $this->components[ $component ];
240
+		return $this->components[$component];
241 241
 	}
242 242
 
243 243
 	/**
@@ -248,23 +248,23 @@  discard block
 block discarded – undo
248 248
 	 * @param array                        $args     The settings for the import.
249 249
 	 * @param WordPoints_Importer_Feedback $feedback The feedback object.
250 250
 	 */
251
-	public function do_import( array $args, $feedback = null ) {
251
+	public function do_import(array $args, $feedback = null) {
252 252
 
253
-		if ( ! ( $feedback instanceof WordPoints_Importer_Feedback ) ) {
253
+		if (!($feedback instanceof WordPoints_Importer_Feedback)) {
254 254
 			$feedback = new WordPoints_Importer_Feedback;
255 255
 		}
256 256
 
257 257
 		$this->feedback = $feedback;
258 258
 
259
-		$this->feedback->info( sprintf( __( 'Importing from %s…', 'wordpoints-importer' ), $this->name ) );
259
+		$this->feedback->info(sprintf(__('Importing from %s…', 'wordpoints-importer'), $this->name));
260 260
 
261 261
 		$this->no_interruptions();
262 262
 
263
-		foreach ( $args as $component => $options ) {
264
-			$this->do_import_for_component( $component, $options );
263
+		foreach ($args as $component => $options) {
264
+			$this->do_import_for_component($component, $options);
265 265
 		}
266 266
 
267
-		$this->feedback->info( __( 'Import complete.', 'wordpoints-importer' ) );
267
+		$this->feedback->info(__('Import complete.', 'wordpoints-importer'));
268 268
 	}
269 269
 
270 270
 	/**
@@ -274,14 +274,14 @@  discard block
 block discarded – undo
274 274
 	 */
275 275
 	protected function no_interruptions() {
276 276
 
277
-		ignore_user_abort( true );
277
+		ignore_user_abort(true);
278 278
 
279 279
 		if (
280 280
 			// Back-compat with WordPoints 2.1.
281
-			function_exists( 'wordpoints_is_function_disabled' )
282
-			&& ! wordpoints_is_function_disabled( 'set_time_limit' )
281
+			function_exists('wordpoints_is_function_disabled')
282
+			&& !wordpoints_is_function_disabled('set_time_limit')
283 283
 		) {
284
-			set_time_limit( 0 );
284
+			set_time_limit(0);
285 285
 		}
286 286
 	}
287 287
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	 *
296 296
 	 * @return bool Whether the settings are valid.
297 297
 	 */
298
-	protected function validate_import_settings( $component, $settings ) {
298
+	protected function validate_import_settings($component, $settings) {
299 299
 
300 300
 		/**
301 301
 		 * Filter whether the settings are valid before importing.
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		 * @param array $settings The settings for this component.
307 307
 		 * @param WordPoints_Importer_Feedback $feedback The feedback object.
308 308
 		 */
309
-		return apply_filters( "wordpoints_import_settings_valid-{$component}", true, $settings, $this->feedback );
309
+		return apply_filters("wordpoints_import_settings_valid-{$component}", true, $settings, $this->feedback);
310 310
 	}
311 311
 
312 312
 	/**
@@ -317,37 +317,37 @@  discard block
 block discarded – undo
317 317
 	 * @param string $component The component to run the import for.
318 318
 	 * @param array  $options   The selected options of what to import.
319 319
 	 */
320
-	protected function do_import_for_component( $component, $options ) {
320
+	protected function do_import_for_component($component, $options) {
321 321
 
322 322
 		$component_data = WordPoints_Components::instance()->get_component(
323 323
 			$component
324 324
 		);
325 325
 
326
-		if ( false === $component_data ) {
327
-			$this->feedback->warning( sprintf( __( 'Skipping %s component—not installed.', 'wordpoints-importer' ), esc_html( $component ) ) );
326
+		if (false === $component_data) {
327
+			$this->feedback->warning(sprintf(__('Skipping %s component—not installed.', 'wordpoints-importer'), esc_html($component)));
328 328
 			return;
329 329
 		}
330 330
 
331
-		if ( true !== $this->supports_component( $component ) ) {
332
-			$this->feedback->warning( sprintf( __( 'Skipping the %s component—not supported.', 'wordpoints-importer' ), $component_data['name'] ) );
331
+		if (true !== $this->supports_component($component)) {
332
+			$this->feedback->warning(sprintf(__('Skipping the %s component—not supported.', 'wordpoints-importer'), $component_data['name']));
333 333
 			return;
334 334
 		}
335 335
 
336 336
 		$settings = array();
337 337
 
338
-		if ( isset( $options['_data'] ) ) {
338
+		if (isset($options['_data'])) {
339 339
 			$settings = $options['_data'];
340
-			unset( $options['_data'] );
340
+			unset($options['_data']);
341 341
 		}
342 342
 
343
-		if ( empty( $options ) || ! $this->validate_import_settings( $component, $settings ) ) {
343
+		if (empty($options) || !$this->validate_import_settings($component, $settings)) {
344 344
 			return;
345 345
 		}
346 346
 
347
-		$this->feedback->info( sprintf( __( 'Importing data to the %s component…', 'wordpoints-importer' ), $component_data['name'] ) );
347
+		$this->feedback->info(sprintf(__('Importing data to the %s component…', 'wordpoints-importer'), $component_data['name']));
348 348
 
349
-		foreach ( $options as $option => $unused ) {
350
-			$this->do_import_for_option( $option, $component, $settings );
349
+		foreach ($options as $option => $unused) {
350
+			$this->do_import_for_option($option, $component, $settings);
351 351
 		}
352 352
 	}
353 353
 
@@ -365,28 +365,28 @@  discard block
 block discarded – undo
365 365
 	 * @param string $component The component this option is for.
366 366
 	 * @param array  $settings  Other settings for this component.
367 367
 	 */
368
-	protected function do_import_for_option( $option, $component, $settings ) {
368
+	protected function do_import_for_option($option, $component, $settings) {
369 369
 
370
-		if ( ! isset( $this->components[ $component ][ $option ] ) ) {
371
-			$this->feedback->warning( sprintf( __( 'Skipping unrecognized import option “%s”…', 'wordpoints-importer' ), $option ) );
370
+		if (!isset($this->components[$component][$option])) {
371
+			$this->feedback->warning(sprintf(__('Skipping unrecognized import option “%s”…', 'wordpoints-importer'), $option));
372 372
 			return;
373 373
 		}
374 374
 
375
-		$option_data = $this->components[ $component ][ $option ];
375
+		$option_data = $this->components[$component][$option];
376 376
 
377 377
 		// Check if we can actually run this option.
378
-		if ( isset( $option_data['can_import'] ) ) {
378
+		if (isset($option_data['can_import'])) {
379 379
 
380
-			$cant_import = call_user_func( $option_data['can_import'], $settings );
380
+			$cant_import = call_user_func($option_data['can_import'], $settings);
381 381
 
382
-			if ( is_wp_error( $cant_import ) ) {
383
-				$this->feedback->warning( sprintf( __( 'Skipping importing %1$s. Reason: %2$s', 'wordpoints-importer' ), $option_data['label'], $cant_import->get_error_message() ) );
382
+			if (is_wp_error($cant_import)) {
383
+				$this->feedback->warning(sprintf(__('Skipping importing %1$s. Reason: %2$s', 'wordpoints-importer'), $option_data['label'], $cant_import->get_error_message()));
384 384
 				return;
385 385
 			}
386 386
 		}
387 387
 
388 388
 		// OK, we can run the import method for this option.
389
-		call_user_func( $option_data['function'], $settings );
389
+		call_user_func($option_data['function'], $settings);
390 390
 	}
391 391
 }
392 392
 
Please login to merge, or discard this patch.
src/admin/admin.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 
17 17
 	add_submenu_page(
18 18
 		wordpoints_get_main_admin_menu()
19
-		,__( 'WordPoints — Import', 'wordpoints-importer' )
20
-		,__( 'Import', 'wordpoints-importer' )
19
+		,__('WordPoints — Import', 'wordpoints-importer')
20
+		,__('Import', 'wordpoints-importer')
21 21
 		,'manage_options'
22 22
 		,'wordpoints_import'
23 23
 		,'wordpoints_import_admin_screen'
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 
26 26
 	add_submenu_page(
27 27
 		'_wordpoints_import' // Fake.
28
-		,__( 'WordPoints — Importing', 'wordpoints-importer' )
29
-		,__( 'Importing', 'wordpoints-importer' )
28
+		,__('WordPoints — Importing', 'wordpoints-importer')
29
+		,__('Importing', 'wordpoints-importer')
30 30
 		,'manage_options'
31 31
 		,'wordpoints_importing'
32 32
 		,'wordpoints_importing_admin_screen'
33 33
 	);
34 34
 }
35
-add_action( 'admin_menu', 'wordpoints_importer_admin_menu' );
36
-add_action( 'network_admin_menu', 'wordpoints_importer_admin_menu' );
35
+add_action('admin_menu', 'wordpoints_importer_admin_menu');
36
+add_action('network_admin_menu', 'wordpoints_importer_admin_menu');
37 37
 
38 38
 /**
39 39
  * Display the importer administration screen.
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @since 1.0.0
49 49
 	 */
50
-	require( dirname( __FILE__ ) . '/screens/import.php' );
50
+	require(dirname(__FILE__).'/screens/import.php');
51 51
 }
52 52
 
53 53
 /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @since 1.0.0
64 64
 	 */
65
-	require( dirname( __FILE__ ) . '/screens/importing.php' );
65
+	require(dirname(__FILE__).'/screens/importing.php');
66 66
 }
67 67
 
68 68
 /**
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
 
75 75
 	$assets_url = wordpoints_modules_url(
76 76
 		'admin/assets'
77
-		, dirname( dirname( __FILE__ ) ) . '/importer.php'
77
+		, dirname(dirname(__FILE__)).'/importer.php'
78 78
 	);
79 79
 
80 80
 	wp_register_style(
81 81
 		'wordpoints-importer-feedback'
82
-		, $assets_url . '/css/feedback.css'
82
+		, $assets_url.'/css/feedback.css'
83 83
 	);
84 84
 }
85
-add_action( 'init', 'wordpoints_importer_register_admin_scripts' );
85
+add_action('init', 'wordpoints_importer_register_admin_scripts');
86 86
 
87 87
 /**
88 88
  * Handle an import request.
@@ -91,43 +91,43 @@  discard block
 block discarded – undo
91 91
  */
92 92
 function wordpoints_importer_do_import() {
93 93
 
94
-	if ( ! defined( 'IFRAME_REQUEST' ) ) {
95
-		define( 'IFRAME_REQUEST', true );
94
+	if (!defined('IFRAME_REQUEST')) {
95
+		define('IFRAME_REQUEST', true);
96 96
 	}
97 97
 
98
-	if ( ! current_user_can( 'manage_options' ) ) {
99
-		wp_die( esc_html__( 'Sorry, you are not allowed to import to WordPoints.', 'wordpoints-importer' ) );
98
+	if (!current_user_can('manage_options')) {
99
+		wp_die(esc_html__('Sorry, you are not allowed to import to WordPoints.', 'wordpoints-importer'));
100 100
 	}
101 101
 
102
-	check_admin_referer( 'wordpoints_import' );
102
+	check_admin_referer('wordpoints_import');
103 103
 
104
-	if ( ! isset( $_GET['importer'] ) ) {
105
-		wp_die( esc_html__( 'No importer selected.', 'wordpoints-importer' ) );
104
+	if (!isset($_GET['importer'])) {
105
+		wp_die(esc_html__('No importer selected.', 'wordpoints-importer'));
106 106
 	}
107 107
 
108 108
 	$importer = WordPoints_Importers::get_importer(
109
-		sanitize_key( $_GET['importer'] )
109
+		sanitize_key($_GET['importer'])
110 110
 	);
111 111
 
112
-	if ( ! ( $importer instanceof WordPoints_Importer ) ) {
113
-		wp_die( esc_html__( 'Importer not installed.', 'wordpoints-importer' ) );
112
+	if (!($importer instanceof WordPoints_Importer)) {
113
+		wp_die(esc_html__('Importer not installed.', 'wordpoints-importer'));
114 114
 	}
115 115
 
116
-	wp_enqueue_style( 'wordpoints-importer-feedback' );
116
+	wp_enqueue_style('wordpoints-importer-feedback');
117 117
 
118 118
 	$args = array();
119 119
 
120
-	if ( isset( $_GET['wordpoints_import'] ) && is_array( $_GET['wordpoints_import'] ) ) {
121
-		$args = wp_unslash( $_GET['wordpoints_import'] ); // WPCS: sanitization OK.
120
+	if (isset($_GET['wordpoints_import']) && is_array($_GET['wordpoints_import'])) {
121
+		$args = wp_unslash($_GET['wordpoints_import']); // WPCS: sanitization OK.
122 122
 	}
123 123
 
124 124
 	iframe_header();
125 125
 
126
-	$importer->do_import( $args );
126
+	$importer->do_import($args);
127 127
 
128 128
 	iframe_footer();
129 129
 }
130
-add_action( 'update-custom_wordpoints_import', 'wordpoints_importer_do_import' );
130
+add_action('update-custom_wordpoints_import', 'wordpoints_importer_do_import');
131 131
 
132 132
 /**
133 133
  * Display a points type dropdown above the points component settings.
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
  */
137 137
 function wordpoints_importer_admin_screen_points_type_select() {
138 138
 
139
-	$args = array( 'name' => 'wordpoints_import[points][_data][points_type]' );
139
+	$args = array('name' => 'wordpoints_import[points][_data][points_type]');
140 140
 
141 141
 	?>
142 142
 
143 143
 	<p>
144 144
 		<label for="wordpoints_import[points][_data][points_type]">
145
-			<?php esc_html_e( 'Import to points type:', 'wordpoints-importer' ); ?>
146
-			<?php wordpoints_points_types_dropdown( $args ); ?>
145
+			<?php esc_html_e('Import to points type:', 'wordpoints-importer'); ?>
146
+			<?php wordpoints_points_types_dropdown($args); ?>
147 147
 		</label>
148 148
 	</p>
149 149
 
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
  *
166 166
  * @return bool Whether the settings are valid.
167 167
  */
168
-function wordpoints_importer_validate_points_type_setting( $valid, $settings, $feedback ) {
168
+function wordpoints_importer_validate_points_type_setting($valid, $settings, $feedback) {
169 169
 
170
-	if ( $valid ) {
170
+	if ($valid) {
171 171
 
172
-		if ( ! isset( $settings['points_type'] ) ) {
173
-			$feedback->warning( __( 'Skipping Points component—no points type specified.', 'wordpoints-importer' ) );
172
+		if (!isset($settings['points_type'])) {
173
+			$feedback->warning(__('Skipping Points component—no points type specified.', 'wordpoints-importer'));
174 174
 			$valid = false;
175
-		} elseif ( ! wordpoints_is_points_type( $settings['points_type'] ) ) {
176
-			$feedback->warning( __( 'Skipping Points component—invalid points type selected.', 'wordpoints-importer' ) );
175
+		} elseif (!wordpoints_is_points_type($settings['points_type'])) {
176
+			$feedback->warning(__('Skipping Points component—invalid points type selected.', 'wordpoints-importer'));
177 177
 			$valid = false;
178 178
 		}
179 179
 	}
@@ -198,20 +198,20 @@  discard block
 block discarded – undo
198 198
 
199 199
 	// See https://github.com/WordPoints/wordpoints/issues/310.
200 200
 	$options = array();
201
-	foreach ( $rank_groups as $rank_group ) {
202
-		$options[ $rank_group->slug ] = $rank_group->name;
201
+	foreach ($rank_groups as $rank_group) {
202
+		$options[$rank_group->slug] = $rank_group->name;
203 203
 	}
204 204
 
205 205
 	$dropdown = new WordPoints_Dropdown_Builder(
206 206
 		$options
207
-		, array( 'name' => 'wordpoints_import[ranks][_data][rank_group]' )
207
+		, array('name' => 'wordpoints_import[ranks][_data][rank_group]')
208 208
 	);
209 209
 
210 210
 	?>
211 211
 
212 212
 	<p>
213 213
 		<label for="wordpoints_import[ranks][_data][rank_group]">
214
-			<?php esc_html_e( 'Import to rank group:', 'wordpoints-importer' ); ?>
214
+			<?php esc_html_e('Import to rank group:', 'wordpoints-importer'); ?>
215 215
 			<?php $dropdown->display(); ?>
216 216
 		</label>
217 217
 	</p>
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
  *
235 235
  * @return bool Whether the settings are valid.
236 236
  */
237
-function wordpoints_importer_validate_rank_group_setting( $valid, $settings, $feedback ) {
237
+function wordpoints_importer_validate_rank_group_setting($valid, $settings, $feedback) {
238 238
 
239
-	if ( $valid ) {
239
+	if ($valid) {
240 240
 
241
-		if ( ! isset( $settings['rank_group'] ) ) {
242
-			$feedback->warning( __( 'Skipping Ranks component—no rank group specified.', 'wordpoints-importer' ) );
241
+		if (!isset($settings['rank_group'])) {
242
+			$feedback->warning(__('Skipping Ranks component—no rank group specified.', 'wordpoints-importer'));
243 243
 			$valid = false;
244
-		} elseif ( ! WordPoints_Rank_Groups::is_group_registered( $settings['rank_group'] ) ) {
245
-			$feedback->warning( __( 'Skipping Ranks component—invalid rank group selected.', 'wordpoints-importer' ) );
244
+		} elseif (!WordPoints_Rank_Groups::is_group_registered($settings['rank_group'])) {
245
+			$feedback->warning(__('Skipping Ranks component—invalid rank group selected.', 'wordpoints-importer'));
246 246
 			$valid = false;
247 247
 		}
248 248
 	}
Please login to merge, or discard this patch.
src/admin/screens/import.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -7,55 +7,55 @@  discard block
 block discarded – undo
7 7
  * @since 1.0.0
8 8
  */
9 9
 
10
-if ( true !== current_user_can( 'manage_options' ) ) {
10
+if (true !== current_user_can('manage_options')) {
11 11
 	wp_die();
12 12
 }
13 13
 
14
-$tabs = array( 'unavailable' => __( 'Unavailable', 'wordpoints-importer' ) );
14
+$tabs = array('unavailable' => __('Unavailable', 'wordpoints-importer'));
15 15
 $unavailable = array();
16 16
 
17
-foreach ( WordPoints_Importers::get() as $slug => $args ) {
17
+foreach (WordPoints_Importers::get() as $slug => $args) {
18 18
 
19
-	$importer = WordPoints_Importers::get_importer( $slug );
19
+	$importer = WordPoints_Importers::get_importer($slug);
20 20
 
21 21
 	$is_available = $importer->is_available();
22 22
 
23
-	if ( is_wp_error( $is_available ) ) {
24
-		$unavailable[ $args['name'] ] = $is_available;
23
+	if (is_wp_error($is_available)) {
24
+		$unavailable[$args['name']] = $is_available;
25 25
 	} else {
26
-		$tabs[ $slug ] = $args['name'];
26
+		$tabs[$slug] = $args['name'];
27 27
 	}
28 28
 }
29 29
 
30
-if ( empty( $unavailable ) ) {
31
-	unset( $tabs['unavailable'] );
30
+if (empty($unavailable)) {
31
+	unset($tabs['unavailable']);
32 32
 }
33 33
 
34
-$current_tab = wordpoints_admin_get_current_tab( $tabs );
34
+$current_tab = wordpoints_admin_get_current_tab($tabs);
35 35
 
36 36
 $components = WordPoints_Components::instance()->get();
37 37
 
38 38
 ?>
39 39
 
40
-<h2><?php esc_html_e( 'WordPoints Importer', 'wordpoints-importer' ); ?></h2>
40
+<h2><?php esc_html_e('WordPoints Importer', 'wordpoints-importer'); ?></h2>
41 41
 
42 42
 <div class="wrap">
43
-	<?php wordpoints_admin_show_tabs( $tabs, false ); ?>
43
+	<?php wordpoints_admin_show_tabs($tabs, false); ?>
44 44
 
45
-	<?php if ( 'unavailable' === $current_tab ) : ?>
45
+	<?php if ('unavailable' === $current_tab) : ?>
46 46
 
47
-		<p><?php esc_html_e( 'The below importers are not currently available.', 'wordpoints-importer' ); ?></p>
47
+		<p><?php esc_html_e('The below importers are not currently available.', 'wordpoints-importer'); ?></p>
48 48
 
49 49
 		<ul>
50
-			<?php foreach ( $unavailable as $name => $error ) : ?>
50
+			<?php foreach ($unavailable as $name => $error) : ?>
51 51
 				<li>
52 52
 					<?php
53 53
 
54 54
 					printf(
55 55
 						/* translators: 1 is an importer name, 2 is the reason that it is unavailable. */
56
-						esc_html__( '%1$s — %2$s', 'wordpoints-importer' )
57
-						, '<strong>' . esc_html( $name ) . '</strong>'
58
-						, esc_html( $error->get_error_message() )
56
+						esc_html__('%1$s — %2$s', 'wordpoints-importer')
57
+						, '<strong>'.esc_html($name).'</strong>'
58
+						, esc_html($error->get_error_message())
59 59
 					);
60 60
 
61 61
 					?>
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
 
66 66
 	<?php else : ?>
67 67
 
68
-		<?php $importer = WordPoints_Importers::get_importer( $current_tab ); ?>
68
+		<?php $importer = WordPoints_Importers::get_importer($current_tab); ?>
69 69
 
70
-		<p><?php esc_html_e( 'Select which items you would like imported.', 'wordpoints-importer' ); ?></p>
70
+		<p><?php esc_html_e('Select which items you would like imported.', 'wordpoints-importer'); ?></p>
71 71
 
72
-		<form method="post" action="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_importing' ) ); ?>">
73
-			<?php foreach ( $components as $slug => $component ) : ?>
72
+		<form method="post" action="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_importing')); ?>">
73
+			<?php foreach ($components as $slug => $component) : ?>
74 74
 
75 75
 				<?php
76 76
 
77
-				if ( ! $importer->supports_component( $slug ) ) {
77
+				if (!$importer->supports_component($slug)) {
78 78
 					continue;
79 79
 				}
80 80
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
 				?>
84 84
 
85
-				<h3><?php echo esc_html( $component['name'] ); ?></h3>
85
+				<h3><?php echo esc_html($component['name']); ?></h3>
86 86
 
87 87
 				<?php
88 88
 
@@ -91,34 +91,34 @@  discard block
 block discarded – undo
91 91
 				 *
92 92
 				 * @since 1.0.0
93 93
 				 */
94
-				do_action( "wordpoints_importer_before_component_options-{$slug}" );
94
+				do_action("wordpoints_importer_before_component_options-{$slug}");
95 95
 
96 96
 				?>
97 97
 
98
-				<?php foreach ( $importer->get_options_for_component( $slug ) as $name => $option ) : ?>
98
+				<?php foreach ($importer->get_options_for_component($slug) as $name => $option) : ?>
99 99
 
100 100
 					<?php
101 101
 
102 102
 					$can_import = true;
103 103
 
104 104
 					// Check if this option is available.
105
-					if ( isset( $option['can_import'] ) ) {
106
-						$can_import = call_user_func( $option['can_import'], array() );
105
+					if (isset($option['can_import'])) {
106
+						$can_import = call_user_func($option['can_import'], array());
107 107
 					}
108 108
 
109 109
 					?>
110 110
 
111
-					<label for="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]">
112
-						<input type="checkbox" value="1" id="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]" name="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]" <?php disabled( is_wp_error( $can_import ), true ); ?> />
113
-						<?php echo esc_html( $option['label'] ); ?>
114
-						<?php if ( is_wp_error( $can_import ) ) : ?>
115
-							&nbsp;&nbsp;<em><?php printf( esc_html__( 'Disabled (%s)', 'wordpoints-importer' ), esc_html( $can_import->get_error_message() ) ); ?></em>
111
+					<label for="wordpoints_import[<?php echo esc_attr($slug); ?>][<?php echo esc_attr($name); ?>]">
112
+						<input type="checkbox" value="1" id="wordpoints_import[<?php echo esc_attr($slug); ?>][<?php echo esc_attr($name); ?>]" name="wordpoints_import[<?php echo esc_attr($slug); ?>][<?php echo esc_attr($name); ?>]" <?php disabled(is_wp_error($can_import), true); ?> />
113
+						<?php echo esc_html($option['label']); ?>
114
+						<?php if (is_wp_error($can_import)) : ?>
115
+							&nbsp;&nbsp;<em><?php printf(esc_html__('Disabled (%s)', 'wordpoints-importer'), esc_html($can_import->get_error_message())); ?></em>
116 116
 						<?php endif; ?>
117 117
 					</label>
118 118
 
119
-					<?php if ( isset( $option['description'] ) ) : ?>
119
+					<?php if (isset($option['description'])) : ?>
120 120
 						<p class="description" style="margin-bottom: 10px; margin-left: 25px;">
121
-							<?php echo esc_html( $option['description'] ); ?>
121
+							<?php echo esc_html($option['description']); ?>
122 122
 						</p>
123 123
 					<?php else : ?>
124 124
 						<br style="margin-bottom: 10px" />
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 
129 129
 			<?php endforeach; ?>
130 130
 
131
-			<input type="hidden" value="<?php echo esc_attr( $current_tab ); ?>" name="importer" />
131
+			<input type="hidden" value="<?php echo esc_attr($current_tab); ?>" name="importer" />
132 132
 
133 133
 			<?php
134 134
 
135
-			if ( ! isset( $supported ) ) {
135
+			if (!isset($supported)) {
136 136
 
137 137
 				esc_html_e(
138 138
 					'This importer does not support any of the installed components.'
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 
142 142
 			} else {
143 143
 
144
-				wp_nonce_field( 'wordpoints_import' );
145
-				submit_button( __( 'Import', 'wordpoints-importer' ) );
144
+				wp_nonce_field('wordpoints_import');
145
+				submit_button(__('Import', 'wordpoints-importer'));
146 146
 			}
147 147
 
148 148
 			?>
Please login to merge, or discard this patch.
src/admin/screens/importing.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,18 +7,18 @@
 block discarded – undo
7 7
  * @since 1.0.0
8 8
  */
9 9
 
10
-if ( true !== current_user_can( 'manage_options' ) ) {
10
+if (true !== current_user_can('manage_options')) {
11 11
 	wp_die();
12 12
 }
13 13
 
14
-check_admin_referer( 'wordpoints_import' );
14
+check_admin_referer('wordpoints_import');
15 15
 
16 16
 ?>
17 17
 
18
-<h2><?php esc_html_e( 'WordPoints Importer', 'wordpoints-importer' ); ?></h2>
18
+<h2><?php esc_html_e('WordPoints Importer', 'wordpoints-importer'); ?></h2>
19 19
 
20 20
 <div class="wrap">
21
-	<p><?php esc_html_e( 'Starting import (this could take a few moments)&hellip;', 'wordpoints-importer' ); ?></p>
21
+	<p><?php esc_html_e('Starting import (this could take a few moments)&hellip;', 'wordpoints-importer'); ?></p>
22 22
 
23
-	<iframe src="<?php echo esc_url( self_admin_url( 'update.php?action=wordpoints_import&' . http_build_query( $_POST ) ) ); ?>" style="width: 100%; height:100%; min-height:850px;"></iframe>
23
+	<iframe src="<?php echo esc_url(self_admin_url('update.php?action=wordpoints_import&'.http_build_query($_POST))); ?>" style="width: 100%; height:100%; min-height:850px;"></iframe>
24 24
 </div>
Please login to merge, or discard this patch.
tests/phpunit/includes/functions.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,27 +14,27 @@  discard block
 block discarded – undo
14 14
  *
15 15
  * @type string
16 16
  */
17
-define( 'WORDPOINTS_IMPORTER_TESTS_DIR', dirname( dirname( __FILE__ ) ) );
17
+define('WORDPOINTS_IMPORTER_TESTS_DIR', dirname(dirname(__FILE__)));
18 18
 
19 19
 // Back-compat with WordPoints 2.1.
20
-if ( class_exists( 'WordPoints_PHPUnit_Bootstrap_Loader' ) ) {
20
+if (class_exists('WordPoints_PHPUnit_Bootstrap_Loader')) {
21 21
 
22 22
 	$loader = WordPoints_PHPUnit_Bootstrap_Loader::instance();
23
-	$loader->add_plugin( 'cubepoints/cubepoints.php' );
23
+	$loader->add_plugin('cubepoints/cubepoints.php');
24 24
 	$loader->add_php_file(
25
-		WORDPOINTS_IMPORTER_TESTS_DIR . '/includes/activate-cubepoints-components.php'
25
+		WORDPOINTS_IMPORTER_TESTS_DIR.'/includes/activate-cubepoints-components.php'
26 26
 		, 'after'
27
-		, array( 'dailypoints', 'post_author_points' )
27
+		, array('dailypoints', 'post_author_points')
28 28
 	);
29 29
 
30
-} elseif ( ! defined( 'WORDPOINTS_MODULE_TESTS_LOADER' ) ) {
30
+} elseif (!defined('WORDPOINTS_MODULE_TESTS_LOADER')) {
31 31
 
32 32
 	/**
33 33
 	 * The function that loads the module for the tests.
34 34
 	 *
35 35
 	 * @since 1.0.0
36 36
 	 */
37
-	define( 'WORDPOINTS_MODULE_TESTS_LOADER', 'wordpoints_importer_tests_manually_load_module' );
37
+	define('WORDPOINTS_MODULE_TESTS_LOADER', 'wordpoints_importer_tests_manually_load_module');
38 38
 }
39 39
 
40 40
 /**
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
  */
46 46
 function wordpoints_importer_tests_manually_load_module() {
47 47
 
48
-	require( WORDPOINTS_IMPORTER_TESTS_DIR . '/../../src/importer.php' );
49
-	require( WORDPOINTS_IMPORTER_TESTS_DIR . '/../../src/admin/admin.php' );
48
+	require(WORDPOINTS_IMPORTER_TESTS_DIR.'/../../src/importer.php');
49
+	require(WORDPOINTS_IMPORTER_TESTS_DIR.'/../../src/admin/admin.php');
50 50
 
51 51
 	wordpoints_importer_tests_manually_load_cubepoints();
52 52
 }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function wordpoints_importer_tests_manually_load_cubepoints() {
61 61
 
62
-	require( WP_PLUGIN_DIR . '/cubepoints/cubepoints.php' );
62
+	require(WP_PLUGIN_DIR.'/cubepoints/cubepoints.php');
63 63
 
64 64
 	cp_activate();
65 65
 
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	// Because of some of the functions are defined outside of the conditional, there
69 69
 	// is no way for us to load the functions later without a fatal error from
70 70
 	// "already defined function".
71
-	cp_module_activation_set( 'dailypoints', 'active' );
72
-	cp_module_activation_set( 'post_author_points', 'active' );
71
+	cp_module_activation_set('dailypoints', 'active');
72
+	cp_module_activation_set('post_author_points', 'active');
73 73
 
74 74
 	// We have to do this manually here after WordPress 4.7.
75 75
 	// https://core.trac.wordpress.org/ticket/38011#comment:3
76 76
 	global $wp_version;
77 77
 
78
-	if ( version_compare( $wp_version, '4.6', '>' ) ) {
78
+	if (version_compare($wp_version, '4.6', '>')) {
79 79
 		cp_modules_include();
80 80
 	}
81 81
 }
Please login to merge, or discard this patch.
tests/phpunit/includes/activate-cubepoints-components.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
  * @since 1.2.1
8 8
  */
9 9
 
10
-foreach ( $data as $module_slug ) {
11
-	cp_module_activation_set( $module_slug, 'active' );
10
+foreach ($data as $module_slug) {
11
+	cp_module_activation_set($module_slug, 'active');
12 12
 }
13 13
 
14 14
 // EOF
Please login to merge, or discard this patch.
tests/phpunit/includes/bootstrap.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,27 +12,27 @@
 block discarded – undo
12 12
  *
13 13
  * @since 1.2.1
14 14
  */
15
-require_once( WORDPOINTS_IMPORTER_TESTS_DIR . '/../../src/admin/admin.php' );
15
+require_once(WORDPOINTS_IMPORTER_TESTS_DIR.'/../../src/admin/admin.php');
16 16
 
17 17
 /**
18 18
  * Feedback object used in the tests.
19 19
  *
20 20
  * @since 1.0.0
21 21
  */
22
-require_once( WORDPOINTS_IMPORTER_TESTS_DIR . '/includes/feedback.php' );
22
+require_once(WORDPOINTS_IMPORTER_TESTS_DIR.'/includes/feedback.php');
23 23
 
24 24
 /**
25 25
  * Mocks used in the tests.
26 26
  *
27 27
  * @since 1.0.0
28 28
  */
29
-require_once( WORDPOINTS_IMPORTER_TESTS_DIR . '/includes/mocks.php' );
29
+require_once(WORDPOINTS_IMPORTER_TESTS_DIR.'/includes/mocks.php');
30 30
 
31 31
 /**
32 32
  * Testcase for testing hooks.
33 33
  *
34 34
  * @since 1.2.0
35 35
  */
36
-require_once( WORDPOINTS_IMPORTER_TESTS_DIR . '/includes/testcases/hook.php' );
36
+require_once(WORDPOINTS_IMPORTER_TESTS_DIR.'/includes/testcases/hook.php');
37 37
 
38 38
 // EOF
Please login to merge, or discard this patch.
tests/phpunit/tests/importers/cubepoints.php 1 patch
Spacing   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 		// These are usually inactive by default. We activate them in the tests
37 37
 		// bootstrap so that they will be fully loaded, but deactivate them here to
38 38
 		// restore default behavior.
39
-		cp_module_activation_set( 'post_author_points', false );
40
-		cp_module_activation_set( 'dailypoints', false );
39
+		cp_module_activation_set('post_author_points', false);
40
+		cp_module_activation_set('dailypoints', false);
41 41
 
42
-		$this->importer = new WordPoints_CubePoints_Importer( 'Test CubePoints' );
42
+		$this->importer = new WordPoints_CubePoints_Importer('Test CubePoints');
43 43
 	}
44 44
 
45 45
 	/**
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function tearDown() {
49 49
 
50
-		WordPoints_Rank_Groups::deregister_group( 'points_type-points' );
51
-		WordPoints_Rank_Types::deregister_type( 'points-points' );
50
+		WordPoints_Rank_Groups::deregister_group('points_type-points');
51
+		WordPoints_Rank_Types::deregister_type('points-points');
52 52
 
53 53
 		parent::tearDown();
54 54
 	}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function test_is_cubepoints_installed() {
64 64
 
65
-		$this->assertTrue( $this->importer->is_cubepoints_installed() );
65
+		$this->assertTrue($this->importer->is_cubepoints_installed());
66 66
 	}
67 67
 
68 68
 	/**
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function test_is_cubepoints_not_installed() {
76 76
 
77
-		delete_option( 'cp_db_version' );
77
+		delete_option('cp_db_version');
78 78
 
79
-		$this->assertFalse( $this->importer->is_cubepoints_installed() );
79
+		$this->assertFalse($this->importer->is_cubepoints_installed());
80 80
 	}
81 81
 
82 82
 	/**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function test_is_cubepoints_is_available() {
90 90
 
91
-		$this->assertTrue( $this->importer->is_available() );
91
+		$this->assertTrue($this->importer->is_available());
92 92
 	}
93 93
 
94 94
 	/**
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function test_is_cubepoints_not_available() {
102 102
 
103
-		delete_option( 'cp_db_version' );
103
+		delete_option('cp_db_version');
104 104
 
105
-		$this->assertWPError( $this->importer->is_available() );
105
+		$this->assertWPError($this->importer->is_available());
106 106
 	}
107 107
 
108 108
 	/**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	public function test_is_cubepoints_active() {
116 116
 
117 117
 		$this->assertEquals(
118
-			function_exists( 'cp_ready' )
118
+			function_exists('cp_ready')
119 119
 			, $this->importer->is_cubepoints_active()
120 120
 		);
121 121
 	}
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function test_import_excluded_users() {
131 131
 
132
-		$user_ids = $this->factory->user->create_many( 3 );
132
+		$user_ids = $this->factory->user->create_many(3);
133 133
 		$user_logins = array();
134 134
 
135
-		foreach ( $user_ids as $user_id ) {
136
-			$user_logins[] = get_userdata( $user_id )->user_login;
135
+		foreach ($user_ids as $user_id) {
136
+			$user_logins[] = get_userdata($user_id)->user_login;
137 137
 		}
138 138
 
139
-		update_option( 'cp_topfilter', $user_logins );
139
+		update_option('cp_topfilter', $user_logins);
140 140
 
141
-		$this->do_points_import( 'excluded_users' );
141
+		$this->do_points_import('excluded_users');
142 142
 
143 143
 		$this->assertEquals(
144 144
 			$user_ids
145
-			, wordpoints_get_excluded_users( 'tests' )
145
+			, wordpoints_get_excluded_users('tests')
146 146
 		);
147 147
 	}
148 148
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public function test_import_excluded_users_none() {
157 157
 
158
-		delete_option( 'cp_topfilter' );
158
+		delete_option('cp_topfilter');
159 159
 
160 160
 		$feedback = new WordPoints_Importer_Tests_Feedback();
161 161
 
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 			array(
164 164
 				'points' => array(
165 165
 					'excluded_users' => '1',
166
-					'_data' => array( 'points_type' => 'points' ),
166
+					'_data' => array('points_type' => 'points'),
167 167
 				),
168 168
 			)
169 169
 			, $feedback
170 170
 		);
171 171
 
172
-		$this->assertCount( 1, $feedback->messages['warning'] );
172
+		$this->assertCount(1, $feedback->messages['warning']);
173 173
 	}
174 174
 
175 175
 	/**
@@ -183,16 +183,16 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	public function test_import_points_settings() {
185 185
 
186
-		update_option( 'cp_comment_points',     10 );
187
-		update_option( 'cp_post_points',        20 );
188
-		update_option( 'cp_reg_points',         50 );
186
+		update_option('cp_comment_points', 10);
187
+		update_option('cp_post_points', 20);
188
+		update_option('cp_reg_points', 50);
189 189
 
190
-		$this->do_points_import( 'settings' );
190
+		$this->do_points_import('settings');
191 191
 
192 192
 		$this->assertHookImported(
193 193
 			array(
194 194
 				'event' => 'comment_leave\post',
195
-				'target' => array( 'comment\post', 'author', 'user' ),
195
+				'target' => array('comment\post', 'author', 'user'),
196 196
 				'reactor' => 'points_legacy',
197 197
 				'points' => 10,
198 198
 				'points_type' => 'points',
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 				'description' => 'Commenting on a Post.',
201 201
 				'legacy_log_type' => 'cubepoints-comment',
202 202
 				'legacy_meta_key' => 'comment',
203
-				'points_legacy_reversals' => array( 'toggle_off' => 'toggle_on' ),
203
+				'points_legacy_reversals' => array('toggle_off' => 'toggle_on'),
204 204
 			)
205 205
 		);
206 206
 
207 207
 		$this->assertHookImported(
208 208
 			array(
209 209
 				'event' => 'comment_leave\page',
210
-				'target' => array( 'comment\page', 'author', 'user' ),
210
+				'target' => array('comment\page', 'author', 'user'),
211 211
 				'reactor' => 'points_legacy',
212 212
 				'points' => 10,
213 213
 				'points_type' => 'points',
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
 				'description' => 'Commenting on a Page.',
216 216
 				'legacy_log_type' => 'cubepoints-comment',
217 217
 				'legacy_meta_key' => 'comment',
218
-				'points_legacy_reversals' => array( 'toggle_off' => 'toggle_on' ),
218
+				'points_legacy_reversals' => array('toggle_off' => 'toggle_on'),
219 219
 			)
220 220
 		);
221 221
 
222 222
 		$this->assertHookImported(
223 223
 			array(
224 224
 				'event' => 'comment_leave\attachment',
225
-				'target' => array( 'comment\attachment', 'author', 'user' ),
225
+				'target' => array('comment\attachment', 'author', 'user'),
226 226
 				'reactor' => 'points_legacy',
227 227
 				'points' => 10,
228 228
 				'points_type' => 'points',
@@ -230,52 +230,52 @@  discard block
 block discarded – undo
230 230
 				'description' => 'Commenting on a Media.',
231 231
 				'legacy_log_type' => 'cubepoints-comment',
232 232
 				'legacy_meta_key' => 'comment',
233
-				'points_legacy_reversals' => array( 'toggle_off' => 'toggle_on' ),
233
+				'points_legacy_reversals' => array('toggle_off' => 'toggle_on'),
234 234
 			)
235 235
 		);
236 236
 
237 237
 		$this->assertHookImported(
238 238
 			array(
239 239
 				'event' => 'post_publish\post',
240
-				'target' => array( 'post\post', 'author', 'user' ),
240
+				'target' => array('post\post', 'author', 'user'),
241 241
 				'reactor' => 'points_legacy',
242 242
 				'points' => 20,
243 243
 				'points_type' => 'points',
244 244
 				'log_text' => 'Published a Post.',
245 245
 				'description' => 'Publishing a Post.',
246
-				'blocker' => array( 'toggle_off' => true ),
246
+				'blocker' => array('toggle_off' => true),
247 247
 				'legacy_log_type' => 'cubepoints-post',
248 248
 				'legacy_meta_key' => 'post',
249
-				'points_legacy_reversals' => array( 'toggle_off' => 'toggle_on' ),
250
-				'points_legacy_repeat_blocker' => array( 'toggle_on' => true ),
249
+				'points_legacy_reversals' => array('toggle_off' => 'toggle_on'),
250
+				'points_legacy_repeat_blocker' => array('toggle_on' => true),
251 251
 			)
252 252
 		);
253 253
 
254
-		$reaction_store = wordpoints_hooks()->get_reaction_store( 'points' );
254
+		$reaction_store = wordpoints_hooks()->get_reaction_store('points');
255 255
 
256 256
 		$this->assertEmpty(
257
-			$reaction_store->get_reactions_to_event( 'post_publish\page' )
257
+			$reaction_store->get_reactions_to_event('post_publish\page')
258 258
 		);
259 259
 
260 260
 		$this->assertEmpty(
261
-			$reaction_store->get_reactions_to_event( 'post_publish\attachment' )
261
+			$reaction_store->get_reactions_to_event('post_publish\attachment')
262 262
 		);
263 263
 
264 264
 		$this->assertEmpty(
265
-			$reaction_store->get_reactions_to_event( 'media_upload' )
265
+			$reaction_store->get_reactions_to_event('media_upload')
266 266
 		);
267 267
 
268 268
 		$this->assertHookImported(
269 269
 			array(
270 270
 				'event' => 'user_register',
271
-				'target' => array( 'user' ),
271
+				'target' => array('user'),
272 272
 				'reactor' => 'points_legacy',
273 273
 				'points' => 50,
274 274
 				'points_type' => 'points',
275 275
 				'log_text' => 'Registration.',
276 276
 				'description' => 'Registration.',
277 277
 				'legacy_log_type' => 'cubepoints-register',
278
-				'points_legacy_reversals' => array( 'toggle_off' => 'toggle_on' ),
278
+				'points_legacy_reversals' => array('toggle_off' => 'toggle_on'),
279 279
 			)
280 280
 		);
281 281
 	}
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	public function test_imported_post_points_hook_does_not_refire() {
291 291
 
292
-		update_option( 'cp_post_points', 20 );
292
+		update_option('cp_post_points', 20);
293 293
 
294 294
 		$user_id = $this->factory->user->create();
295 295
 		$post_id = $this->factory->post->create(
@@ -299,32 +299,32 @@  discard block
 block discarded – undo
299 299
 			)
300 300
 		);
301 301
 
302
-		$this->assertEquals( 120, cp_getPoints( $user_id ) );
302
+		$this->assertEquals(120, cp_getPoints($user_id));
303 303
 
304 304
 		$this->factory->post->update_object(
305 305
 			$post_id
306
-			, array( 'post_status' => 'draft' )
306
+			, array('post_status' => 'draft')
307 307
 		);
308 308
 
309
-		$this->assertEquals( 120, cp_getPoints( $user_id ) );
309
+		$this->assertEquals(120, cp_getPoints($user_id));
310 310
 
311
-		$this->do_points_import( 'settings' );
312
-		$this->do_points_import( 'user_points' );
313
-		$this->do_points_import( 'logs' );
311
+		$this->do_points_import('settings');
312
+		$this->do_points_import('user_points');
313
+		$this->do_points_import('logs');
314 314
 
315 315
 		$this->assertEquals(
316 316
 			120
317
-			, wordpoints_get_points( $user_id, 'points' )
317
+			, wordpoints_get_points($user_id, 'points')
318 318
 		);
319 319
 
320 320
 		$this->factory->post->update_object(
321 321
 			$post_id
322
-			, array( 'post_status' => 'publish' )
322
+			, array('post_status' => 'publish')
323 323
 		);
324 324
 
325 325
 		$this->assertEquals(
326 326
 			120
327
-			, wordpoints_get_points( $user_id, 'points' )
327
+			, wordpoints_get_points($user_id, 'points')
328 328
 		);
329 329
 	}
330 330
 
@@ -338,16 +338,16 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	public function test_import_post_author_points() {
340 340
 
341
-		cp_module_activation_set( 'post_author_points', 'active' );
341
+		cp_module_activation_set('post_author_points', 'active');
342 342
 
343
-		update_option( 'cp_post_author_points', 15 );
343
+		update_option('cp_post_author_points', 15);
344 344
 
345
-		$this->do_points_import( 'settings' );
345
+		$this->do_points_import('settings');
346 346
 
347 347
 		$this->assertHookImported(
348 348
 			array(
349 349
 				'event' => 'comment_leave\post',
350
-				'target' => array( 'comment\post', 'post\post', 'post\post', 'author', 'user' ),
350
+				'target' => array('comment\post', 'post\post', 'post\post', 'author', 'user'),
351 351
 				'reactor' => 'points_legacy',
352 352
 				'points' => 15,
353 353
 				'points_type' => 'points',
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
 				'description' => 'Receiving a comment on a Post.',
356 356
 				'legacy_log_type' => 'cubepoints-post_author',
357 357
 				'legacy_meta_key' => 'comment',
358
-				'points_legacy_reversals' => array( 'toggle_off' => 'toggle_on' ),
358
+				'points_legacy_reversals' => array('toggle_off' => 'toggle_on'),
359 359
 			)
360 360
 		);
361 361
 
362 362
 		$this->assertHookImported(
363 363
 			array(
364 364
 				'event' => 'comment_leave\page',
365
-				'target' => array( 'comment\page', 'post\page', 'post\page', 'author', 'user' ),
365
+				'target' => array('comment\page', 'post\page', 'post\page', 'author', 'user'),
366 366
 				'reactor' => 'points_legacy',
367 367
 				'points' => 15,
368 368
 				'points_type' => 'points',
@@ -370,14 +370,14 @@  discard block
 block discarded – undo
370 370
 				'description' => 'Receiving a comment on a Page.',
371 371
 				'legacy_log_type' => 'cubepoints-post_author',
372 372
 				'legacy_meta_key' => 'comment',
373
-				'points_legacy_reversals' => array( 'toggle_off' => 'toggle_on' ),
373
+				'points_legacy_reversals' => array('toggle_off' => 'toggle_on'),
374 374
 			)
375 375
 		);
376 376
 
377 377
 		$this->assertHookImported(
378 378
 			array(
379 379
 				'event' => 'comment_leave\attachment',
380
-				'target' => array( 'comment\attachment', 'post\attachment', 'post\attachment', 'author', 'user' ),
380
+				'target' => array('comment\attachment', 'post\attachment', 'post\attachment', 'author', 'user'),
381 381
 				'reactor' => 'points_legacy',
382 382
 				'points' => 15,
383 383
 				'points_type' => 'points',
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 				'description' => 'Receiving a comment on a Media.',
386 386
 				'legacy_log_type' => 'cubepoints-post_author',
387 387
 				'legacy_meta_key' => 'comment',
388
-				'points_legacy_reversals' => array( 'toggle_off' => 'toggle_on' ),
388
+				'points_legacy_reversals' => array('toggle_off' => 'toggle_on'),
389 389
 			)
390 390
 		);
391 391
 	}
@@ -400,17 +400,17 @@  discard block
 block discarded – undo
400 400
 	 */
401 401
 	public function test_import_periodic_points() {
402 402
 
403
-		cp_module_activation_set( 'dailypoints', 'active' );
403
+		cp_module_activation_set('dailypoints', 'active');
404 404
 
405
-		update_option( 'cp_module_dailypoints_points', 30 );
406
-		update_option( 'cp_module_dailypoints_time', DAY_IN_SECONDS );
405
+		update_option('cp_module_dailypoints_points', 30);
406
+		update_option('cp_module_dailypoints_time', DAY_IN_SECONDS);
407 407
 
408
-		$this->do_points_import( 'settings' );
408
+		$this->do_points_import('settings');
409 409
 
410 410
 		$this->assertHookImported(
411 411
 			array(
412 412
 				'event' => 'user_visit',
413
-				'target' => array( 'current:user' ),
413
+				'target' => array('current:user'),
414 414
 				'reactor' => 'points_legacy',
415 415
 				'points' => 30,
416 416
 				'points_type' => 'points',
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 					'fire' => array(
421 421
 						array(
422 422
 							'length' => DAY_IN_SECONDS,
423
-							'args' => array( array( 'current:user' ) ),
423
+							'args' => array(array('current:user')),
424 424
 							'relative' => true,
425 425
 						),
426 426
 					),
@@ -441,39 +441,39 @@  discard block
 block discarded – undo
441 441
 	 */
442 442
 	public function test_import_periodic_points_respect_old_periods() {
443 443
 
444
-		if ( version_compare( $GLOBALS['wp_version'], '4.5', '>=' ) ) {
445
-			$this->setExpectedDeprecated( 'get_currentuserinfo' );
444
+		if (version_compare($GLOBALS['wp_version'], '4.5', '>=')) {
445
+			$this->setExpectedDeprecated('get_currentuserinfo');
446 446
 		}
447 447
 
448
-		cp_module_activation_set( 'dailypoints', 'active' );
448
+		cp_module_activation_set('dailypoints', 'active');
449 449
 
450
-		update_option( 'cp_module_dailypoints_points', 30 );
451
-		update_option( 'cp_module_dailypoints_time', DAY_IN_SECONDS );
450
+		update_option('cp_module_dailypoints_points', 30);
451
+		update_option('cp_module_dailypoints_time', DAY_IN_SECONDS);
452 452
 
453 453
 		$user_id = $this->factory->user->create();
454 454
 
455
-		wp_set_current_user( $user_id );
455
+		wp_set_current_user($user_id);
456 456
 
457
-		$this->assertEquals( 100, cp_getPoints( $user_id ) );
457
+		$this->assertEquals(100, cp_getPoints($user_id));
458 458
 
459 459
 		cp_module_dailypoints_checkTimer();
460 460
 
461
-		$this->assertEquals( 130, cp_getPoints( $user_id ) );
461
+		$this->assertEquals(130, cp_getPoints($user_id));
462 462
 
463 463
 		// Running again shouldn't hit again.
464 464
 		cp_module_dailypoints_checkTimer();
465 465
 
466
-		$this->assertEquals( 130, cp_getPoints( $user_id ) );
466
+		$this->assertEquals(130, cp_getPoints($user_id));
467 467
 
468
-		$this->do_points_import( 'settings' );
469
-		$this->do_points_import( 'user_points' );
470
-		$this->do_points_import( 'logs' );
468
+		$this->do_points_import('settings');
469
+		$this->do_points_import('user_points');
470
+		$this->do_points_import('logs');
471 471
 
472
-		$this->assertEquals( 130, wordpoints_get_points( $user_id, 'points' ) );
472
+		$this->assertEquals(130, wordpoints_get_points($user_id, 'points'));
473 473
 
474
-		wordpoints_hooks()->get_sub_app( 'router' )->{'wp,10'}();
474
+		wordpoints_hooks()->get_sub_app('router')->{'wp,10'}();
475 475
 
476
-		$this->assertEquals( 130, wordpoints_get_points( $user_id, 'points' ) );
476
+		$this->assertEquals(130, wordpoints_get_points($user_id, 'points'));
477 477
 
478 478
 		// Fast-forward and try again.
479 479
 		global $wpdb;
@@ -490,40 +490,40 @@  discard block
 block discarded – undo
490 490
 		// Don't go all the way yet.
491 491
 		$updated = $wpdb->update(
492 492
 			$wpdb->wordpoints_points_logs
493
-			, array( 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp', true ) - DAY_IN_SECONDS + HOUR_IN_SECONDS ) )
494
-			, array( 'id' => $id )
495
-			, array( '%s' )
496
-			, array( '%d' )
493
+			, array('date' => date('Y-m-d H:i:s', current_time('timestamp', true) - DAY_IN_SECONDS + HOUR_IN_SECONDS))
494
+			, array('id' => $id)
495
+			, array('%s')
496
+			, array('%d')
497 497
 		);
498 498
 
499
-		$this->assertEquals( 1, $updated );
499
+		$this->assertEquals(1, $updated);
500 500
 
501 501
 		// The periods cache will still hold the old date.
502 502
 		$this->flush_cache();
503 503
 
504
-		wordpoints_hooks()->get_sub_app( 'router' )->{'wp,10'}();
504
+		wordpoints_hooks()->get_sub_app('router')->{'wp,10'}();
505 505
 
506 506
 		// Points should have been awarded again yet.
507
-		$this->assertEquals( 130, wordpoints_get_points( $user_id, 'points' ) );
507
+		$this->assertEquals(130, wordpoints_get_points($user_id, 'points'));
508 508
 
509 509
 		// This time go all the way.
510 510
 		$updated = $wpdb->update(
511 511
 			$wpdb->wordpoints_points_logs
512
-			, array( 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp', true ) - DAY_IN_SECONDS - 1 ) )
513
-			, array( 'id' => $id )
514
-			, array( '%s' )
515
-			, array( '%d' )
512
+			, array('date' => date('Y-m-d H:i:s', current_time('timestamp', true) - DAY_IN_SECONDS - 1))
513
+			, array('id' => $id)
514
+			, array('%s')
515
+			, array('%d')
516 516
 		);
517 517
 
518
-		$this->assertEquals( 1, $updated );
518
+		$this->assertEquals(1, $updated);
519 519
 
520 520
 		// The periods cache will still hold the old date.
521 521
 		$this->flush_cache();
522 522
 
523
-		wordpoints_hooks()->get_sub_app( 'router' )->{'wp,10'}();
523
+		wordpoints_hooks()->get_sub_app('router')->{'wp,10'}();
524 524
 
525 525
 		// Points should have been awarded again.
526
-		$this->assertEquals( 160, wordpoints_get_points( $user_id, 'points' ) );
526
+		$this->assertEquals(160, wordpoints_get_points($user_id, 'points'));
527 527
 	}
528 528
 
529 529
 	/**
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	 */
537 537
 	public function test_import_periods_positive_gmt_offset() {
538 538
 
539
-		update_option( 'gmt_offset', 5 );
539
+		update_option('gmt_offset', 5);
540 540
 
541 541
 		$this->test_import_periodic_points_respect_old_periods();
542 542
 	}
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 	 */
552 552
 	public function test_import_periods_negative_gmt_offset() {
553 553
 
554
-		update_option( 'gmt_offset', -5 );
554
+		update_option('gmt_offset', -5);
555 555
 
556 556
 		$this->test_import_periodic_points_respect_old_periods();
557 557
 	}
@@ -568,17 +568,17 @@  discard block
 block discarded – undo
568 568
 
569 569
 		$user_points = array();
570 570
 
571
-		foreach ( array( 20, 10, 45 ) as $points ) {
571
+		foreach (array(20, 10, 45) as $points) {
572 572
 
573 573
 			$user_id = $this->factory->user->create();
574
-			cp_updatePoints( $user_id, $points );
575
-			$user_points[ $user_id ] = $points;
574
+			cp_updatePoints($user_id, $points);
575
+			$user_points[$user_id] = $points;
576 576
 		}
577 577
 
578
-		$this->do_points_import( 'user_points' );
578
+		$this->do_points_import('user_points');
579 579
 
580
-		foreach ( $user_points as $user_id => $points ) {
581
-			$this->assertEquals( $points, wordpoints_get_points( $user_id, 'points' ) );
580
+		foreach ($user_points as $user_id => $points) {
581
+			$this->assertEquals($points, wordpoints_get_points($user_id, 'points'));
582 582
 		}
583 583
 	}
584 584
 
@@ -594,42 +594,42 @@  discard block
 block discarded – undo
594 594
 	 */
595 595
 	public function test_import_points_logs() {
596 596
 
597
-		remove_action( 'publish_post', 'cp_newPost' );
597
+		remove_action('publish_post', 'cp_newPost');
598 598
 
599 599
 		$user_id = $this->factory->user->create();
600
-		cp_points( 'misc', $user_id, 10, 'Testing things.' );
600
+		cp_points('misc', $user_id, 10, 'Testing things.');
601 601
 
602 602
 		$user_id_2 = $this->factory->user->create();
603 603
 		$post_id = $this->factory->post->create();
604
-		cp_points( 'post', $user_id_2, 25, $post_id );
604
+		cp_points('post', $user_id_2, 25, $post_id);
605 605
 
606
-		$this->do_points_import( 'logs' );
606
+		$this->do_points_import('logs');
607 607
 
608
-		$query = new WordPoints_Points_Logs_Query( array( 'orderby' => 'id' ) );
608
+		$query = new WordPoints_Points_Logs_Query(array('orderby' => 'id'));
609 609
 		$logs = $query->get();
610 610
 
611
-		$this->assertCount( 4, $logs );
611
+		$this->assertCount(4, $logs);
612 612
 
613 613
 		$log = $logs[2];
614 614
 
615
-		$this->assertEquals( $user_id, $log->user_id );
616
-		$this->assertEquals( 10, $log->points );
617
-		$this->assertEquals( 'Testing things.', $log->text );
618
-		$this->assertEquals( 'cubepoints-misc', $log->log_type );
619
-		$this->assertEquals( 'points', $log->points_type );
620
-		$this->assertEquals( 'misc', wordpoints_get_points_log_meta( $log->id, 'cubepoints_type', true ) );
621
-		$this->assertEquals( 'Testing things.', wordpoints_get_points_log_meta( $log->id, 'cubepoints_data', true ) );
615
+		$this->assertEquals($user_id, $log->user_id);
616
+		$this->assertEquals(10, $log->points);
617
+		$this->assertEquals('Testing things.', $log->text);
618
+		$this->assertEquals('cubepoints-misc', $log->log_type);
619
+		$this->assertEquals('points', $log->points_type);
620
+		$this->assertEquals('misc', wordpoints_get_points_log_meta($log->id, 'cubepoints_type', true));
621
+		$this->assertEquals('Testing things.', wordpoints_get_points_log_meta($log->id, 'cubepoints_data', true));
622 622
 
623 623
 		$log = $logs[0];
624 624
 
625
-		$this->assertEquals( $user_id_2, $log->user_id );
626
-		$this->assertEquals( 25, $log->points );
627
-		$this->assertStringMatchesFormat( 'Post on "<a href="%s">Post title %s</a>"', $log->text );
628
-		$this->assertEquals( 'cubepoints-post', $log->log_type );
629
-		$this->assertEquals( 'points', $log->points_type );
630
-		$this->assertEquals( 'post', wordpoints_get_points_log_meta( $log->id, 'cubepoints_type', true ) );
631
-		$this->assertEquals( $post_id, wordpoints_get_points_log_meta( $log->id, 'cubepoints_data', true ) );
632
-		$this->assertEquals( $post_id, wordpoints_get_points_log_meta( $log->id, 'post', true ) );
625
+		$this->assertEquals($user_id_2, $log->user_id);
626
+		$this->assertEquals(25, $log->points);
627
+		$this->assertStringMatchesFormat('Post on "<a href="%s">Post title %s</a>"', $log->text);
628
+		$this->assertEquals('cubepoints-post', $log->log_type);
629
+		$this->assertEquals('points', $log->points_type);
630
+		$this->assertEquals('post', wordpoints_get_points_log_meta($log->id, 'cubepoints_type', true));
631
+		$this->assertEquals($post_id, wordpoints_get_points_log_meta($log->id, 'cubepoints_data', true));
632
+		$this->assertEquals($post_id, wordpoints_get_points_log_meta($log->id, 'post', true));
633 633
 	}
634 634
 
635 635
 	/**
@@ -644,97 +644,97 @@  discard block
 block discarded – undo
644 644
 	 */
645 645
 	public function test_import_points_logs_reversals() {
646 646
 
647
-		remove_action( 'publish_post', 'cp_newPost' );
648
-		remove_action( 'cp_comment_add', 'cp_module_post_author_points_comment_add' );
649
-		remove_action( 'cp_comment_remove', 'cp_module_post_author_points_comment_remove' );
647
+		remove_action('publish_post', 'cp_newPost');
648
+		remove_action('cp_comment_add', 'cp_module_post_author_points_comment_add');
649
+		remove_action('cp_comment_remove', 'cp_module_post_author_points_comment_remove');
650 650
 
651
-		update_option( 'cp_comment_points', 10 );
652
-		update_option( 'cp_del_comment_points', 10 );
651
+		update_option('cp_comment_points', 10);
652
+		update_option('cp_del_comment_points', 10);
653 653
 
654 654
 		$user_id = $this->factory->user->create();
655 655
 		$post_id = $this->factory->post->create();
656 656
 
657 657
 		$comment_id = $this->factory->comment->create(
658
-			array( 'user_id' => $user_id, 'comment_post_ID' => $post_id, 'comment_approved' => 0 )
658
+			array('user_id' => $user_id, 'comment_post_ID' => $post_id, 'comment_approved' => 0)
659 659
 		);
660 660
 
661 661
 		wp_update_comment(
662
-			array( 'comment_ID' => $comment_id, 'comment_approved' => 1 )
662
+			array('comment_ID' => $comment_id, 'comment_approved' => 1)
663 663
 		);
664 664
 
665 665
 		$user_id_2 = $this->factory->user->create();
666 666
 		$comment_id_2 = $this->factory->comment->create(
667
-			array( 'user_id' => $user_id_2, 'comment_post_ID' => $post_id, 'comment_approved' => 0 )
667
+			array('user_id' => $user_id_2, 'comment_post_ID' => $post_id, 'comment_approved' => 0)
668 668
 		);
669 669
 
670 670
 		wp_update_comment(
671
-			array( 'comment_ID' => $comment_id_2, 'comment_approved' => 1 )
671
+			array('comment_ID' => $comment_id_2, 'comment_approved' => 1)
672 672
 		);
673 673
 
674 674
 		// Now reverse the two transactions.
675 675
 		wp_update_comment(
676
-			array( 'comment_ID' => $comment_id, 'comment_approved' => 0 )
676
+			array('comment_ID' => $comment_id, 'comment_approved' => 0)
677 677
 		);
678 678
 
679 679
 		wp_update_comment(
680
-			array( 'comment_ID' => $comment_id_2, 'comment_approved' => 0 )
680
+			array('comment_ID' => $comment_id_2, 'comment_approved' => 0)
681 681
 		);
682 682
 
683
-		$this->do_points_import( 'logs' );
683
+		$this->do_points_import('logs');
684 684
 
685 685
 		$query = new WordPoints_Points_Logs_Query(
686
-			array( 'orderby' => 'id', 'order' => 'ASC' )
686
+			array('orderby' => 'id', 'order' => 'ASC')
687 687
 		);
688 688
 
689 689
 		$logs = $query->get();
690 690
 
691
-		$this->assertCount( 6, $logs );
691
+		$this->assertCount(6, $logs);
692 692
 
693 693
 		// The first log will be for when the first user was created, so we skip it.
694 694
 		$log = $logs[1];
695 695
 
696
-		$this->assertEquals( $user_id, $log->user_id );
697
-		$this->assertEquals( 10, $log->points );
698
-		$this->assertEquals( 'cubepoints-comment', $log->log_type );
699
-		$this->assertEquals( 'points', $log->points_type );
700
-		$this->assertEquals( 'comment', wordpoints_get_points_log_meta( $log->id, 'cubepoints_type', true ) );
701
-		$this->assertEquals( $comment_id, wordpoints_get_points_log_meta( $log->id, 'cubepoints_data', true ) );
702
-		$this->assertEquals( $comment_id, wordpoints_get_points_log_meta( $log->id, 'comment', true ) );
703
-		$this->assertEquals( $logs[4]->id, wordpoints_get_points_log_meta( $log->id, 'auto_reversed', true ) );
696
+		$this->assertEquals($user_id, $log->user_id);
697
+		$this->assertEquals(10, $log->points);
698
+		$this->assertEquals('cubepoints-comment', $log->log_type);
699
+		$this->assertEquals('points', $log->points_type);
700
+		$this->assertEquals('comment', wordpoints_get_points_log_meta($log->id, 'cubepoints_type', true));
701
+		$this->assertEquals($comment_id, wordpoints_get_points_log_meta($log->id, 'cubepoints_data', true));
702
+		$this->assertEquals($comment_id, wordpoints_get_points_log_meta($log->id, 'comment', true));
703
+		$this->assertEquals($logs[4]->id, wordpoints_get_points_log_meta($log->id, 'auto_reversed', true));
704 704
 
705 705
 		// The third log is for when the second user was created, so we skip it, too.
706 706
 		$log = $logs[3];
707 707
 
708
-		$this->assertEquals( $user_id_2, $log->user_id );
709
-		$this->assertEquals( 10, $log->points );
710
-		$this->assertEquals( 'cubepoints-comment', $log->log_type );
711
-		$this->assertEquals( 'points', $log->points_type );
712
-		$this->assertEquals( 'comment', wordpoints_get_points_log_meta( $log->id, 'cubepoints_type', true ) );
713
-		$this->assertEquals( $comment_id_2, wordpoints_get_points_log_meta( $log->id, 'cubepoints_data', true ) );
714
-		$this->assertEquals( $comment_id_2, wordpoints_get_points_log_meta( $log->id, 'comment', true ) );
715
-		$this->assertEquals( $logs[5]->id, wordpoints_get_points_log_meta( $log->id, 'auto_reversed', true ) );
708
+		$this->assertEquals($user_id_2, $log->user_id);
709
+		$this->assertEquals(10, $log->points);
710
+		$this->assertEquals('cubepoints-comment', $log->log_type);
711
+		$this->assertEquals('points', $log->points_type);
712
+		$this->assertEquals('comment', wordpoints_get_points_log_meta($log->id, 'cubepoints_type', true));
713
+		$this->assertEquals($comment_id_2, wordpoints_get_points_log_meta($log->id, 'cubepoints_data', true));
714
+		$this->assertEquals($comment_id_2, wordpoints_get_points_log_meta($log->id, 'comment', true));
715
+		$this->assertEquals($logs[5]->id, wordpoints_get_points_log_meta($log->id, 'auto_reversed', true));
716 716
 
717 717
 		$log = $logs[4];
718 718
 
719
-		$this->assertEquals( $user_id, $log->user_id );
719
+		$this->assertEquals($user_id, $log->user_id);
720 720
 		$this->assertEquals( -10, $log->points );
721
-		$this->assertEquals( 'cubepoints-comment_remove', $log->log_type );
722
-		$this->assertEquals( 'points', $log->points_type );
723
-		$this->assertEquals( 'comment_remove', wordpoints_get_points_log_meta( $log->id, 'cubepoints_type', true ) );
724
-		$this->assertEquals( $comment_id, wordpoints_get_points_log_meta( $log->id, 'cubepoints_data', true ) );
725
-		$this->assertEquals( $comment_id, wordpoints_get_points_log_meta( $log->id, 'comment', true ) );
726
-		$this->assertEquals( $logs[1]->id, wordpoints_get_points_log_meta( $log->id, 'original_log_id', true ) );
721
+		$this->assertEquals('cubepoints-comment_remove', $log->log_type);
722
+		$this->assertEquals('points', $log->points_type);
723
+		$this->assertEquals('comment_remove', wordpoints_get_points_log_meta($log->id, 'cubepoints_type', true));
724
+		$this->assertEquals($comment_id, wordpoints_get_points_log_meta($log->id, 'cubepoints_data', true));
725
+		$this->assertEquals($comment_id, wordpoints_get_points_log_meta($log->id, 'comment', true));
726
+		$this->assertEquals($logs[1]->id, wordpoints_get_points_log_meta($log->id, 'original_log_id', true));
727 727
 
728 728
 		$log = $logs[5];
729 729
 
730
-		$this->assertEquals( $user_id_2, $log->user_id );
730
+		$this->assertEquals($user_id_2, $log->user_id);
731 731
 		$this->assertEquals( -10, $log->points );
732
-		$this->assertEquals( 'cubepoints-comment_remove', $log->log_type );
733
-		$this->assertEquals( 'points', $log->points_type );
734
-		$this->assertEquals( 'comment_remove', wordpoints_get_points_log_meta( $log->id, 'cubepoints_type', true ) );
735
-		$this->assertEquals( $comment_id_2, wordpoints_get_points_log_meta( $log->id, 'cubepoints_data', true ) );
736
-		$this->assertEquals( $comment_id_2, wordpoints_get_points_log_meta( $log->id, 'comment', true ) );
737
-		$this->assertEquals( $logs[3]->id, wordpoints_get_points_log_meta( $log->id, 'original_log_id', true ) );
732
+		$this->assertEquals('cubepoints-comment_remove', $log->log_type);
733
+		$this->assertEquals('points', $log->points_type);
734
+		$this->assertEquals('comment_remove', wordpoints_get_points_log_meta($log->id, 'cubepoints_type', true));
735
+		$this->assertEquals($comment_id_2, wordpoints_get_points_log_meta($log->id, 'cubepoints_data', true));
736
+		$this->assertEquals($comment_id_2, wordpoints_get_points_log_meta($log->id, 'comment', true));
737
+		$this->assertEquals($logs[3]->id, wordpoints_get_points_log_meta($log->id, 'original_log_id', true));
738 738
 	}
739 739
 
740 740
 	/**
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 
749 749
 		update_option(
750 750
 			'cp_module_ranks_data'
751
-			, array( 0 => 'Newbie', 1000 => 'Biggie', 5000 => 'Oldie' )
751
+			, array(0 => 'Newbie', 1000 => 'Biggie', 5000 => 'Oldie')
752 752
 		);
753 753
 
754 754
 		wordpoints_register_points_ranks();
@@ -759,28 +759,28 @@  discard block
 block discarded – undo
759 759
 			array(
760 760
 				'ranks' => array(
761 761
 					'ranks' => '1',
762
-					'_data' => array( 'rank_group' => 'points_type-points' ),
762
+					'_data' => array('rank_group' => 'points_type-points'),
763 763
 				),
764 764
 			)
765 765
 			, $feedback
766 766
 		);
767 767
 
768
-		$this->assertCount( 4, $feedback->messages['info'] );
769
-		$this->assertCount( 1, $feedback->messages['success'] );
768
+		$this->assertCount(4, $feedback->messages['info']);
769
+		$this->assertCount(1, $feedback->messages['success']);
770 770
 
771
-		$group = WordPoints_Rank_Groups::get_group( 'points_type-points' );
771
+		$group = WordPoints_Rank_Groups::get_group('points_type-points');
772 772
 
773
-		$base_rank = wordpoints_get_rank( $group->get_rank( 0 ) );
774
-		$this->assertEquals( 'base', $base_rank->type );
775
-		$this->assertEquals( 'Newbie', $base_rank->name );
773
+		$base_rank = wordpoints_get_rank($group->get_rank(0));
774
+		$this->assertEquals('base', $base_rank->type);
775
+		$this->assertEquals('Newbie', $base_rank->name);
776 776
 
777
-		$second_rank = wordpoints_get_rank( $group->get_rank( 1 ) );
778
-		$this->assertEquals( 1000, $second_rank->points );
779
-		$this->assertEquals( 'Biggie', $second_rank->name );
777
+		$second_rank = wordpoints_get_rank($group->get_rank(1));
778
+		$this->assertEquals(1000, $second_rank->points);
779
+		$this->assertEquals('Biggie', $second_rank->name);
780 780
 
781
-		$third_rank = wordpoints_get_rank( $group->get_rank( 2 ) );
782
-		$this->assertEquals( 5000, $third_rank->points );
783
-		$this->assertEquals( 'Oldie', $third_rank->name );
781
+		$third_rank = wordpoints_get_rank($group->get_rank(2));
782
+		$this->assertEquals(5000, $third_rank->points);
783
+		$this->assertEquals('Oldie', $third_rank->name);
784 784
 	}
785 785
 
786 786
 	/**
@@ -800,14 +800,14 @@  discard block
 block discarded – undo
800 800
 			array(
801 801
 				'ranks' => array(
802 802
 					'ranks' => '1',
803
-					'_data' => array( 'rank_group' => 'points_type-points' ),
803
+					'_data' => array('rank_group' => 'points_type-points'),
804 804
 				),
805 805
 			)
806 806
 			, $feedback
807 807
 		);
808 808
 
809
-		$this->assertCount( 4, $feedback->messages['info'] );
810
-		$this->assertCount( 1, $feedback->messages['error'] );
809
+		$this->assertCount(4, $feedback->messages['info']);
810
+		$this->assertCount(1, $feedback->messages['error']);
811 811
 
812 812
 	}
813 813
 
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 	 *
823 823
 	 * @param string $type The type of points import.
824 824
 	 */
825
-	protected function do_points_import( $type ) {
825
+	protected function do_points_import($type) {
826 826
 
827 827
 		$feedback = new WordPoints_Importer_Tests_Feedback();
828 828
 
@@ -830,14 +830,14 @@  discard block
 block discarded – undo
830 830
 			array(
831 831
 				'points' => array(
832 832
 					$type => '1',
833
-					'_data' => array( 'points_type' => 'points' ),
833
+					'_data' => array('points_type' => 'points'),
834 834
 				),
835 835
 			)
836 836
 			, $feedback
837 837
 		);
838 838
 
839
-		$this->assertCount( 4, $feedback->messages['info'] );
840
-		$this->assertCount( 1, $feedback->messages['success'] );
839
+		$this->assertCount(4, $feedback->messages['info']);
840
+		$this->assertCount(1, $feedback->messages['success']);
841 841
 	}
842 842
 
843 843
 	/**
@@ -850,22 +850,22 @@  discard block
 block discarded – undo
850 850
 	 *
851 851
 	 * @param array $settings The expected reaction settings.
852 852
 	 */
853
-	protected function assertHookImported( $settings ) {
853
+	protected function assertHookImported($settings) {
854 854
 
855
-		$reaction_store = wordpoints_hooks()->get_reaction_store( 'points' );
855
+		$reaction_store = wordpoints_hooks()->get_reaction_store('points');
856 856
 
857
-		$reactions = $reaction_store->get_reactions_to_event( $settings['event'] );
857
+		$reactions = $reaction_store->get_reactions_to_event($settings['event']);
858 858
 
859
-		$this->assertNotEmpty( $reactions );
859
+		$this->assertNotEmpty($reactions);
860 860
 
861
-		foreach ( $reactions as $reaction ) {
862
-			if ( $settings === $reaction->get_all_meta() ) {
863
-				$this->assertEquals( $settings, $reaction->get_all_meta() );
861
+		foreach ($reactions as $reaction) {
862
+			if ($settings === $reaction->get_all_meta()) {
863
+				$this->assertEquals($settings, $reaction->get_all_meta());
864 864
 				return;
865 865
 			}
866 866
 		}
867 867
 
868
-		$this->assertEquals( $settings, $reaction->get_all_meta() );
868
+		$this->assertEquals($settings, $reaction->get_all_meta());
869 869
 	}
870 870
 }
871 871
 
Please login to merge, or discard this patch.