Completed
Push — master ( e9e0b4...cbda97 )
by J.D.
03:49
created
src/components/points/admin/includes/functions.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 	wp_register_style(
26 26
 		'wordpoints-admin-points-hooks'
27 27
 		, "{$assets_url}/css/hooks{$suffix}.css"
28
-		, array( 'dashicons' )
28
+		, array('dashicons')
29 29
 		, WORDPOINTS_VERSION
30 30
 	);
31 31
 
32 32
 	$styles = wp_styles();
33
-	$styles->add_data( 'wordpoints-admin-points-hooks', 'rtl', 'replace' );
33
+	$styles->add_data('wordpoints-admin-points-hooks', 'rtl', 'replace');
34 34
 
35
-	if ( $suffix ) {
36
-		$styles->add_data( 'wordpoints-admin-points-hooks', 'suffix', $suffix );
35
+	if ($suffix) {
36
+		$styles->add_data('wordpoints-admin-points-hooks', 'suffix', $suffix);
37 37
 	}
38 38
 
39 39
 	// JS
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	wp_register_script(
42 42
 		'wordpoints-admin-points-types'
43 43
 		, "{$assets_url}/js/points-types{$suffix}.js"
44
-		, array( 'backbone', 'jquery-ui-dialog', 'wp-util' )
44
+		, array('backbone', 'jquery-ui-dialog', 'wp-util')
45 45
 		, WORDPOINTS_VERSION
46 46
 	);
47 47
 
@@ -49,25 +49,25 @@  discard block
 block discarded – undo
49 49
 		'wordpoints-admin-points-types'
50 50
 		, 'WordPointsPointsTypesL10n'
51 51
 		, array(
52
-			'confirmDelete' => esc_html__( 'Are you sure that you want to delete this points type? This will delete all logs, event reactions, and other data associated with this points type.', 'wordpoints' )
53
-				. ' ' . esc_html__( 'Once a points type has been deleted, you cannot bring it back.', 'wordpoints' ),
54
-			'confirmTitle'  => esc_html__( 'Are you sure?', 'wordpoints' ),
55
-			'deleteText'    => esc_html__( 'Delete', 'wordpoints' ),
56
-			'cancelText'    => esc_html__( 'Cancel', 'wordpoints' ),
52
+			'confirmDelete' => esc_html__('Are you sure that you want to delete this points type? This will delete all logs, event reactions, and other data associated with this points type.', 'wordpoints')
53
+				. ' ' . esc_html__('Once a points type has been deleted, you cannot bring it back.', 'wordpoints'),
54
+			'confirmTitle'  => esc_html__('Are you sure?', 'wordpoints'),
55
+			'deleteText'    => esc_html__('Delete', 'wordpoints'),
56
+			'cancelText'    => esc_html__('Cancel', 'wordpoints'),
57 57
 		)
58 58
 	);
59 59
 
60 60
 	wp_register_script(
61 61
 		'wordpoints-hooks-reactor-points'
62 62
 		, "{$assets_url}/js/hooks/reactors/points{$manifested_suffix}.js"
63
-		, array( 'wordpoints-hooks-views' )
63
+		, array('wordpoints-hooks-views')
64 64
 		, WORDPOINTS_VERSION
65 65
 	);
66 66
 
67 67
 	wp_register_script(
68 68
 		'wordpoints-admin-points-hooks'
69 69
 		, "{$assets_url}/js/hooks{$suffix}.js"
70
-		, array( 'jquery', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-dialog' )
70
+		, array('jquery', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-dialog')
71 71
 		, WORDPOINTS_VERSION
72 72
 	);
73 73
 }
@@ -85,22 +85,22 @@  discard block
 block discarded – undo
85 85
 	$wordpoints_menu = wordpoints_get_main_admin_menu();
86 86
 
87 87
 	/** @var WordPoints_Admin_Screens $admin_screens */
88
-	$admin_screens = wordpoints_apps()->get_sub_app( 'admin' )->get_sub_app(
88
+	$admin_screens = wordpoints_apps()->get_sub_app('admin')->get_sub_app(
89 89
 		'screen'
90 90
 	);
91 91
 
92 92
 	// Hooks page.
93 93
 	$id = add_submenu_page(
94 94
 		$wordpoints_menu
95
-		, __( 'WordPoints — Points Types', 'wordpoints' )
96
-		, __( 'Points Types', 'wordpoints' )
95
+		, __('WordPoints — Points Types', 'wordpoints')
96
+		, __('Points Types', 'wordpoints')
97 97
 		, 'manage_options'
98 98
 		, 'wordpoints_points_types'
99
-		, array( $admin_screens, 'display' )
99
+		, array($admin_screens, 'display')
100 100
 	);
101 101
 
102
-	if ( $id ) {
103
-		$admin_screens->register( $id, 'WordPoints_Points_Admin_Screen_Points_Types' );
102
+	if ($id) {
103
+		$admin_screens->register($id, 'WordPoints_Points_Admin_Screen_Points_Types');
104 104
 	}
105 105
 
106 106
 	// Remove the old hooks screen if not needed.
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 
114 114
 	// If all of the registered hooks have been imported and disabled, then there is
115 115
 	// no need to keep the old hooks screen.
116
-	if ( array_diff_key( $hooks, $disabled_hooks ) ) {
116
+	if (array_diff_key($hooks, $disabled_hooks)) {
117 117
 		// Legacy hooks page.
118 118
 		add_submenu_page(
119 119
 			$wordpoints_menu
120
-			,__( 'WordPoints — Points Hooks', 'wordpoints' )
121
-			,__( 'Points Hooks', 'wordpoints' )
120
+			,__('WordPoints — Points Hooks', 'wordpoints')
121
+			,__('Points Hooks', 'wordpoints')
122 122
 			,'manage_options'
123 123
 			,'wordpoints_points_hooks'
124 124
 			,'wordpoints_points_admin_screen_hooks'
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	// Logs page.
129 129
 	add_submenu_page(
130 130
 		$wordpoints_menu
131
-		,__( 'WordPoints — Points Logs', 'wordpoints' )
132
-		,__( 'Points Logs', 'wordpoints' )
131
+		,__('WordPoints — Points Logs', 'wordpoints')
132
+		,__('Points Logs', 'wordpoints')
133 133
 		,'manage_options'
134 134
 		,'wordpoints_points_logs'
135 135
 		,'wordpoints_points_admin_screen_logs'
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
  */
144 144
 function wordpoints_points_admin_screen_hooks() {
145 145
 
146
-	if ( isset( $_GET['edithook'] ) || isset( $_POST['savehook'] ) || isset( $_POST['removehook'] ) ) { // WPCS: CSRF OK.
146
+	if (isset($_GET['edithook']) || isset($_POST['savehook']) || isset($_POST['removehook'])) { // WPCS: CSRF OK.
147 147
 
148 148
 		// - We're doing this without AJAX (JS).
149 149
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
  */
207 207
 function wordpoints_no_js_points_hooks_save() {
208 208
 
209
-	if ( ! isset( $_POST['savehook'] ) && ! isset( $_POST['removehook'] ) ) { // WPCS: CSRF OK.
209
+	if ( ! isset($_POST['savehook']) && ! isset($_POST['removehook'])) { // WPCS: CSRF OK.
210 210
 		return;
211 211
 	}
212 212
 
@@ -230,25 +230,25 @@  discard block
 block discarded – undo
230 230
  *
231 231
  * @return string Options for this screen.
232 232
  */
233
-function wordpoints_admin_points_hooks_screen_options( $screen_options, $screen ) {
233
+function wordpoints_admin_points_hooks_screen_options($screen_options, $screen) {
234 234
 
235 235
 	$path = 'admin.php?page=wordpoints_points_hooks';
236 236
 
237
-	switch ( $screen->id ) {
237
+	switch ($screen->id) {
238 238
 
239 239
 		case 'wordpoints_page_wordpoints_points_hooks':
240
-			$url = admin_url( $path );
240
+			$url = admin_url($path);
241 241
 			// Fall through.
242 242
 
243 243
 		case 'wordpoints_page_wordpoints_points_hooks-network':
244
-			if ( ! isset( $url ) ) {
245
-				$url = network_admin_url( $path );
244
+			if ( ! isset($url)) {
245
+				$url = network_admin_url($path);
246 246
 			}
247 247
 
248
-			$screen_options = '<p><a id="access-on" href="' . esc_url( wp_nonce_url( $url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce' ) ) . '&amp;accessibility-mode=on">'
249
-			                  . esc_html__( 'Enable accessibility mode', 'wordpoints' )
250
-			                  . '</a><a id="access-off" href="' . esc_url( wp_nonce_url( $url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce' ) ) . '&amp;accessibility-mode=off">'
251
-			                  . esc_html__( 'Disable accessibility mode', 'wordpoints' ) . "</a></p>\n";
248
+			$screen_options = '<p><a id="access-on" href="' . esc_url(wp_nonce_url($url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce')) . '&amp;accessibility-mode=on">'
249
+			                  . esc_html__('Enable accessibility mode', 'wordpoints')
250
+			                  . '</a><a id="access-off" href="' . esc_url(wp_nonce_url($url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce')) . '&amp;accessibility-mode=off">'
251
+			                  . esc_html__('Disable accessibility mode', 'wordpoints') . "</a></p>\n";
252 252
 			break;
253 253
 	}
254 254
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
  *
267 267
  * @return string The classes, with 'wordpoints_hooks_access' added.
268 268
  */
269
-function wordpoints_points_hooks_access_body_class( $classes ) {
269
+function wordpoints_points_hooks_access_body_class($classes) {
270 270
 
271 271
 	return "{$classes} wordpoints_hooks_access ";
272 272
 }
@@ -282,29 +282,29 @@  discard block
 block discarded – undo
282 282
  * @param array                  $instance The settings for this hook instance.
283 283
  * @param WordPoints_Points_Hook $hook     The points hook object.
284 284
  */
285
-function wordpoints_points_hook_description_form( $has_form, $instance, $hook ) {
285
+function wordpoints_points_hook_description_form($has_form, $instance, $hook) {
286 286
 
287
-	$description = ( isset( $instance['_description'] ) ) ? $instance['_description'] : '';
287
+	$description = (isset($instance['_description'])) ? $instance['_description'] : '';
288 288
 
289 289
 	?>
290 290
 
291
-	<?php if ( $has_form ) : ?>
291
+	<?php if ($has_form) : ?>
292 292
 		<hr />
293 293
 	<?php else : ?>
294 294
 		<br />
295 295
 	<?php endif; ?>
296 296
 
297 297
 	<div class="hook-instance-description">
298
-		<label for="<?php $hook->the_field_id( '_description' ); ?>"><?php echo esc_html_x( 'Description (optional):', 'points hook', 'wordpoints' ); ?></label>
299
-		<input type="text" id="<?php $hook->the_field_id( '_description' ); ?>" name="<?php $hook->the_field_name( '_description' ); ?>" class="widefat" value="<?php echo esc_attr( $description ); ?>" />
298
+		<label for="<?php $hook->the_field_id('_description'); ?>"><?php echo esc_html_x('Description (optional):', 'points hook', 'wordpoints'); ?></label>
299
+		<input type="text" id="<?php $hook->the_field_id('_description'); ?>" name="<?php $hook->the_field_name('_description'); ?>" class="widefat" value="<?php echo esc_attr($description); ?>" />
300 300
 		<p class="description">
301 301
 			<?php
302 302
 
303 303
 			echo esc_html(
304 304
 				sprintf(
305 305
 					// translators: Default points hook description.
306
-					_x( 'Default: %s', 'points hook description', 'wordpoints' )
307
-					, $hook->get_description( 'generated' )
306
+					_x('Default: %s', 'points hook description', 'wordpoints')
307
+					, $hook->get_description('generated')
308 308
 				)
309 309
 			);
310 310
 
@@ -326,44 +326,44 @@  discard block
 block discarded – undo
326 326
  *
327 327
  * @param WP_User $user The user object for the user being edited.
328 328
  */
329
-function wordpoints_points_profile_options( $user ) {
329
+function wordpoints_points_profile_options($user) {
330 330
 
331
-	if ( current_user_can( 'set_wordpoints_points', $user->ID ) ) {
331
+	if (current_user_can('set_wordpoints_points', $user->ID)) {
332 332
 
333 333
 		?>
334 334
 
335 335
 		</table>
336 336
 
337
-		<h2><?php esc_html_e( 'WordPoints', 'wordpoints' ); ?></h2>
338
-		<p><?php esc_html_e( "If you would like to change the value for a type of points, enter the desired value in the text field, and check the checkbox beside it. If you don't check the checkbox, the change will not be saved. To provide a reason for the change, fill out the text field below.", 'wordpoints' ); ?></p>
339
-		<lable><?php esc_html_e( 'Reason', 'wordpoints' ); ?> <input type="text" name="wordpoints_set_reason" />
337
+		<h2><?php esc_html_e('WordPoints', 'wordpoints'); ?></h2>
338
+		<p><?php esc_html_e("If you would like to change the value for a type of points, enter the desired value in the text field, and check the checkbox beside it. If you don't check the checkbox, the change will not be saved. To provide a reason for the change, fill out the text field below.", 'wordpoints'); ?></p>
339
+		<lable><?php esc_html_e('Reason', 'wordpoints'); ?> <input type="text" name="wordpoints_set_reason" />
340 340
 		<table class="form-table">
341 341
 
342 342
 		<?php
343 343
 
344
-		wp_nonce_field( 'wordpoints_points_set_profile', 'wordpoints_points_set_nonce' );
344
+		wp_nonce_field('wordpoints_points_set_profile', 'wordpoints_points_set_nonce');
345 345
 
346
-		foreach ( wordpoints_get_points_types() as $slug => $type ) {
346
+		foreach (wordpoints_get_points_types() as $slug => $type) {
347 347
 
348
-			$points = wordpoints_get_points( $user->ID, $slug );
348
+			$points = wordpoints_get_points($user->ID, $slug);
349 349
 
350 350
 			?>
351 351
 
352 352
 			<tr>
353
-				<th scope="row"><?php echo esc_html( $type['name'] ); ?></th>
353
+				<th scope="row"><?php echo esc_html($type['name']); ?></th>
354 354
 				<td>
355
-					<input type="hidden" name="<?php echo esc_attr( "wordpoints_points_old-{$slug}" ); ?>" value="<?php echo esc_attr( $points ); ?>" />
356
-					<input type="number" name="<?php echo esc_attr( "wordpoints_points-{$slug}" ); ?>" value="<?php echo esc_attr( $points ); ?>" autocomplete="off" />
357
-					<input type="checkbox" value="1" name="<?php echo esc_attr( "wordpoints_points_set-{$slug}" ); ?>" />
355
+					<input type="hidden" name="<?php echo esc_attr("wordpoints_points_old-{$slug}"); ?>" value="<?php echo esc_attr($points); ?>" />
356
+					<input type="number" name="<?php echo esc_attr("wordpoints_points-{$slug}"); ?>" value="<?php echo esc_attr($points); ?>" autocomplete="off" />
357
+					<input type="checkbox" value="1" name="<?php echo esc_attr("wordpoints_points_set-{$slug}"); ?>" />
358 358
 					<?php // translators: Number of points. ?>
359
-					<span><?php echo esc_html( sprintf( __( '(current: %s)', 'wordpoints' ), $points ) ); ?></span>
359
+					<span><?php echo esc_html(sprintf(__('(current: %s)', 'wordpoints'), $points)); ?></span>
360 360
 				</td>
361 361
 			</tr>
362 362
 
363 363
 			<?php
364 364
 		}
365 365
 
366
-	} elseif ( defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) {
366
+	} elseif (defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE) {
367 367
 
368 368
 		/**
369 369
 		 * My points admin profile heading.
@@ -377,20 +377,20 @@  discard block
 block discarded – undo
377 377
 		 *
378 378
 		 * @param string $heading The text for the heading.
379 379
 		 */
380
-		$heading = apply_filters( 'wordpoints_profile_points_heading', __( 'My Points', 'wordpoints' ) );
380
+		$heading = apply_filters('wordpoints_profile_points_heading', __('My Points', 'wordpoints'));
381 381
 
382 382
 		?>
383 383
 
384 384
 		</table>
385 385
 
386
-		<h2><?php echo esc_html( $heading ); ?></h2>
386
+		<h2><?php echo esc_html($heading); ?></h2>
387 387
 
388 388
 		<table>
389 389
 		<tbody>
390
-		<?php foreach ( wordpoints_get_points_types() as $slug => $type ) : ?>
390
+		<?php foreach (wordpoints_get_points_types() as $slug => $type) : ?>
391 391
 			<tr>
392
-				<th scope="row" style="text-align: left;"><?php echo esc_html( $type['name'] ); ?></th>
393
-				<td style="text-align: right;"><?php wordpoints_display_points( $user->ID, $slug, 'profile_page' ); ?></td>
392
+				<th scope="row" style="text-align: left;"><?php echo esc_html($type['name']); ?></th>
393
+				<td style="text-align: right;"><?php wordpoints_display_points($user->ID, $slug, 'profile_page'); ?></td>
394 394
 			</tr>
395 395
 		<?php endforeach; ?>
396 396
 		</tbody>
@@ -412,39 +412,39 @@  discard block
 block discarded – undo
412 412
  *
413 413
  * @return void
414 414
  */
415
-function wordpoints_points_profile_options_update( $user_id ) {
415
+function wordpoints_points_profile_options_update($user_id) {
416 416
 
417
-	if ( ! current_user_can( 'set_wordpoints_points', $user_id ) ) {
417
+	if ( ! current_user_can('set_wordpoints_points', $user_id)) {
418 418
 		return;
419 419
 	}
420 420
 
421 421
 	if (
422
-		! isset( $_POST['wordpoints_points_set_nonce'], $_POST['wordpoints_set_reason'] )
423
-		|| ! wordpoints_verify_nonce( 'wordpoints_points_set_nonce', 'wordpoints_points_set_profile', null, 'post' )
422
+		! isset($_POST['wordpoints_points_set_nonce'], $_POST['wordpoints_set_reason'])
423
+		|| ! wordpoints_verify_nonce('wordpoints_points_set_nonce', 'wordpoints_points_set_profile', null, 'post')
424 424
 	) {
425 425
 		return;
426 426
 	}
427 427
 
428
-	foreach ( wordpoints_get_points_types() as $slug => $type ) {
428
+	foreach (wordpoints_get_points_types() as $slug => $type) {
429 429
 
430 430
 		if (
431 431
 			isset(
432
-				$_POST[ "wordpoints_points_set-{$slug}" ]
433
-				, $_POST[ "wordpoints_points-{$slug}" ]
434
-				, $_POST[ "wordpoints_points_old-{$slug}" ]
432
+				$_POST["wordpoints_points_set-{$slug}"]
433
+				, $_POST["wordpoints_points-{$slug}"]
434
+				, $_POST["wordpoints_points_old-{$slug}"]
435 435
 			)
436
-			&& false !== wordpoints_int( $_POST[ "wordpoints_points-{$slug}" ] )
437
-			&& false !== wordpoints_int( $_POST[ "wordpoints_points_old-{$slug}" ] )
436
+			&& false !== wordpoints_int($_POST["wordpoints_points-{$slug}"])
437
+			&& false !== wordpoints_int($_POST["wordpoints_points_old-{$slug}"])
438 438
 		) {
439 439
 
440 440
 			wordpoints_alter_points(
441 441
 				$user_id
442
-				, (int) $_POST[ "wordpoints_points-{$slug}" ] - (int) $_POST[ "wordpoints_points_old-{$slug}" ]
442
+				, (int) $_POST["wordpoints_points-{$slug}"] - (int) $_POST["wordpoints_points_old-{$slug}"]
443 443
 				, $slug
444 444
 				, 'profile_edit'
445 445
 				, array(
446 446
 					'user_id' => get_current_user_id(),
447
-					'reason' => sanitize_text_field( wp_unslash( $_POST['wordpoints_set_reason'] ) ),
447
+					'reason' => sanitize_text_field(wp_unslash($_POST['wordpoints_set_reason'])),
448 448
 				)
449 449
 			);
450 450
 		}
@@ -466,22 +466,22 @@  discard block
 block discarded – undo
466 466
 		'selected'         => wordpoints_get_default_points_type(),
467 467
 		'id'               => 'default_points_type',
468 468
 		'name'             => 'default_points_type',
469
-		'show_option_none' => __( 'No default', 'wordpoints' ),
469
+		'show_option_none' => __('No default', 'wordpoints'),
470 470
 	);
471 471
 
472 472
 	?>
473 473
 
474
-	<h3><?php esc_html_e( 'Default Points Type', 'wordpoints' ); ?></h3>
475
-	<p><?php esc_html_e( 'You can optionally set one points type to be the default. The default points type will, for example, be used by shortcodes when no type is specified. This is also useful if you only have one type of points.', 'wordpoints' ); ?></p>
474
+	<h3><?php esc_html_e('Default Points Type', 'wordpoints'); ?></h3>
475
+	<p><?php esc_html_e('You can optionally set one points type to be the default. The default points type will, for example, be used by shortcodes when no type is specified. This is also useful if you only have one type of points.', 'wordpoints'); ?></p>
476 476
 	<table class="form-table">
477 477
 		<tbody>
478 478
 			<tr>
479 479
 				<th>
480
-					<label for="default_points_type"><?php esc_html_e( 'Default', 'wordpoints' ); ?></label>
480
+					<label for="default_points_type"><?php esc_html_e('Default', 'wordpoints'); ?></label>
481 481
 				</th>
482 482
 				<td>
483
-					<?php wordpoints_points_types_dropdown( $dropdown_args ); ?>
484
-					<?php wp_nonce_field( 'wordpoints_default_points_type', 'wordpoints_default_points_type_nonce' ); ?>
483
+					<?php wordpoints_points_types_dropdown($dropdown_args); ?>
484
+					<?php wp_nonce_field('wordpoints_default_points_type', 'wordpoints_default_points_type_nonce'); ?>
485 485
 				</td>
486 486
 			</tr>
487 487
 		</tbody>
@@ -500,19 +500,19 @@  discard block
 block discarded – undo
500 500
 function wordpoints_points_admin_settings_save() {
501 501
 
502 502
 	if (
503
-		isset( $_POST['default_points_type'] )
504
-		&& wordpoints_verify_nonce( 'wordpoints_default_points_type_nonce', 'wordpoints_default_points_type', null, 'post' )
503
+		isset($_POST['default_points_type'])
504
+		&& wordpoints_verify_nonce('wordpoints_default_points_type_nonce', 'wordpoints_default_points_type', null, 'post')
505 505
 	) {
506 506
 
507
-		$points_type = sanitize_key( $_POST['default_points_type'] );
507
+		$points_type = sanitize_key($_POST['default_points_type']);
508 508
 
509
-		if ( '-1' === $points_type ) {
509
+		if ('-1' === $points_type) {
510 510
 
511
-			wordpoints_update_maybe_network_option( 'wordpoints_default_points_type', '' );
511
+			wordpoints_update_maybe_network_option('wordpoints_default_points_type', '');
512 512
 
513
-		} elseif ( wordpoints_is_points_type( $points_type ) ) {
513
+		} elseif (wordpoints_is_points_type($points_type)) {
514 514
 
515
-			wordpoints_update_maybe_network_option( 'wordpoints_default_points_type', $points_type );
515
+			wordpoints_update_maybe_network_option('wordpoints_default_points_type', $points_type);
516 516
 		}
517 517
 	}
518 518
 }
@@ -527,16 +527,16 @@  discard block
 block discarded – undo
527 527
 function wordpoints_points_admin_notices() {
528 528
 
529 529
 	if (
530
-		( ! isset( $_GET['page'] ) || 'wordpoints_points_types' !== $_GET['page'] )
531
-		&& current_user_can( 'manage_wordpoints_points_types' )
530
+		( ! isset($_GET['page']) || 'wordpoints_points_types' !== $_GET['page'])
531
+		&& current_user_can('manage_wordpoints_points_types')
532 532
 		&& ! wordpoints_get_points_types()
533 533
 	) {
534 534
 
535 535
 		wordpoints_show_admin_message(
536 536
 			sprintf(
537 537
 				// translators: URL of Points Types admin screen.
538
-				__( 'Welcome to WordPoints! Get started by <a href="%s">creating a points type</a>.', 'wordpoints' )
539
-				, esc_url( self_admin_url( 'admin.php?page=wordpoints_points_types' ) )
538
+				__('Welcome to WordPoints! Get started by <a href="%s">creating a points type</a>.', 'wordpoints')
539
+				, esc_url(self_admin_url('admin.php?page=wordpoints_points_types'))
540 540
 			)
541 541
 			, 'info'
542 542
 		);
Please login to merge, or discard this patch.
src/components/points/admin/classes/screen/points/types.php 1 patch
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @since 2.1.0
79 79
 	 */
80 80
 	protected function get_title() {
81
-		return _x( 'Points Types', 'page title', 'wordpoints' );
81
+		return _x('Points Types', 'page title', 'wordpoints');
82 82
 	}
83 83
 
84 84
 	/**
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 
89 89
 		parent::hooks();
90 90
 
91
-		add_action( 'add_meta_boxes', array( $this, 'add_points_settings_meta_box' ) );
92
-		add_action( 'add_meta_boxes', array( $this, 'add_points_logs_meta_box' ) );
93
-		add_action( 'add_meta_boxes', array( $this, 'add_event_meta_boxes' ) );
91
+		add_action('add_meta_boxes', array($this, 'add_points_settings_meta_box'));
92
+		add_action('add_meta_boxes', array($this, 'add_points_logs_meta_box'));
93
+		add_action('add_meta_boxes', array($this, 'add_event_meta_boxes'));
94 94
 	}
95 95
 
96 96
 	/**
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public function enqueue_scripts() {
100 100
 
101
-		wp_enqueue_style( 'wordpoints-hooks-admin' );
101
+		wp_enqueue_style('wordpoints-hooks-admin');
102 102
 
103
-		wp_enqueue_script( 'postbox' );
104
-		wp_enqueue_script( 'wordpoints-admin-points-types' );
103
+		wp_enqueue_script('postbox');
104
+		wp_enqueue_script('wordpoints-admin-points-types');
105 105
 
106 106
 		wordpoints_hooks_ui_setup_script_data();
107 107
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 					.addClass( 'closed' );
122 122
 
123 123
 				postboxes.add_postbox_toggles(
124
-					<?php echo wp_json_encode( $this->id ); ?>
124
+					<?php echo wp_json_encode($this->id); ?>
125 125
 				);
126 126
 			} );
127 127
 		</script>
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	public function add_points_settings_meta_box() {
138 138
 
139
-		if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) {
139
+		if ( ! current_user_can('manage_wordpoints_points_types')) {
140 140
 			return;
141 141
 		}
142 142
 
143 143
 		add_meta_box(
144 144
 			'settings'
145
-			, __( 'Settings', 'wordpoints' )
146
-			, array( $this, 'display_points_settings_meta_box' )
145
+			, __('Settings', 'wordpoints')
146
+			, array($this, 'display_points_settings_meta_box')
147 147
 			, $this->id
148 148
 			, 'side'
149 149
 			, 'default'
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function add_points_logs_meta_box() {
159 159
 
160
-		if ( ! $this->current_points_type ) {
160
+		if ( ! $this->current_points_type) {
161 161
 			return;
162 162
 		}
163 163
 
164 164
 		add_meta_box(
165 165
 			'logs'
166
-			, __( 'Logs', 'wordpoints' )
167
-			, array( $this, 'display_points_logs_meta_box' )
166
+			, __('Logs', 'wordpoints')
167
+			, array($this, 'display_points_logs_meta_box')
168 168
 			, $this->id
169 169
 			, 'side'
170 170
 			, 'default'
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	public function display_points_settings_meta_box() {
180 180
 
181
-		if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) {
181
+		if ( ! current_user_can('manage_wordpoints_points_types')) {
182 182
 			return;
183 183
 		}
184 184
 
@@ -186,12 +186,12 @@  discard block
 block discarded – undo
186 186
 
187 187
 		$add_new = 0;
188 188
 
189
-		$points_type = wordpoints_get_points_type( $slug );
189
+		$points_type = wordpoints_get_points_type($slug);
190 190
 
191
-		if ( ! $points_type ) {
191
+		if ( ! $points_type) {
192 192
 
193 193
 			$points_type = array();
194
-			$add_new     = wp_create_nonce( 'wordpoints_add_new_points_type' );
194
+			$add_new     = wp_create_nonce('wordpoints_add_new_points_type');
195 195
 		}
196 196
 
197 197
 		$points_type = array_merge(
@@ -206,32 +206,32 @@  discard block
 block discarded – undo
206 206
 		?>
207 207
 
208 208
 		<form method="post">
209
-			<?php if ( is_wordpoints_network_active() && ! is_network_admin() ) : ?>
209
+			<?php if (is_wordpoints_network_active() && ! is_network_admin()) : ?>
210 210
 				<div class="notice notice-info inline">
211 211
 					<p>
212
-						<?php if ( $slug ) : ?>
213
-							<?php esc_html_e( 'Changes to this points type&#8217;s settings will affect all sites on this network.', 'wordpoints' ) ?>
212
+						<?php if ($slug) : ?>
213
+							<?php esc_html_e('Changes to this points type&#8217;s settings will affect all sites on this network.', 'wordpoints') ?>
214 214
 						<?php else : ?>
215
-							<?php esc_html_e( 'The new points type will be global across all sites on this network.', 'wordpoints' ) ?>
215
+							<?php esc_html_e('The new points type will be global across all sites on this network.', 'wordpoints') ?>
216 216
 						<?php endif; ?>
217 217
 					</p>
218 218
 				</div>
219 219
 			<?php endif; ?>
220 220
 
221
-			<?php if ( $slug ) : ?>
221
+			<?php if ($slug) : ?>
222 222
 				<p>
223 223
 					<span class="wordpoints-points-slug">
224 224
 						<em>
225 225
 							<?php
226 226
 
227 227
 							// translators: Points type slug.
228
-							echo esc_html( sprintf( __( 'Slug: %s', 'wordpoints' ), $slug ) );
228
+							echo esc_html(sprintf(__('Slug: %s', 'wordpoints'), $slug));
229 229
 
230 230
 							?>
231 231
 						</em>
232 232
 					</span>
233 233
 				</p>
234
-				<?php wp_nonce_field( "wordpoints_update_points_type-$slug", 'update_points_type' ); ?>
234
+				<?php wp_nonce_field("wordpoints_update_points_type-$slug", 'update_points_type'); ?>
235 235
 			<?php endif; ?>
236 236
 
237 237
 			<?php
@@ -245,45 +245,45 @@  discard block
 block discarded – undo
245 245
 			 *
246 246
 			 * @param string $points_type The slug of the points type.
247 247
 			 */
248
-			do_action( 'wordpoints_points_type_form_top', $slug );
248
+			do_action('wordpoints_points_type_form_top', $slug);
249 249
 
250
-			if ( $add_new ) {
250
+			if ($add_new) {
251 251
 
252 252
 				// Mark the prefix and suffix optional on the add new form.
253
-				$prefix = _x( 'Prefix (optional):', 'points type', 'wordpoints' );
254
-				$suffix = _x( 'Suffix (optional):', 'points type', 'wordpoints' );
253
+				$prefix = _x('Prefix (optional):', 'points type', 'wordpoints');
254
+				$suffix = _x('Suffix (optional):', 'points type', 'wordpoints');
255 255
 
256 256
 			} else {
257 257
 
258
-				$prefix = _x( 'Prefix:', 'points type', 'wordpoints' );
259
-				$suffix = _x( 'Suffix:', 'points type', 'wordpoints' );
258
+				$prefix = _x('Prefix:', 'points type', 'wordpoints');
259
+				$suffix = _x('Suffix:', 'points type', 'wordpoints');
260 260
 			}
261 261
 
262 262
 			?>
263 263
 
264 264
 			<p>
265 265
 				<label
266
-					for="points-name-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html_x( 'Name:', 'points type', 'wordpoints' ); ?></label>
266
+					for="points-name-<?php echo esc_attr($slug); ?>"><?php echo esc_html_x('Name:', 'points type', 'wordpoints'); ?></label>
267 267
 				<input class="widefat" type="text"
268
-				       id="points-name-<?php echo esc_attr( $slug ); ?>"
268
+				       id="points-name-<?php echo esc_attr($slug); ?>"
269 269
 				       name="points-name"
270
-				       value="<?php echo esc_attr( $points_type['name'] ); ?>"/>
270
+				       value="<?php echo esc_attr($points_type['name']); ?>"/>
271 271
 			</p>
272 272
 			<p>
273 273
 				<label
274
-					for="points-prefix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $prefix ); ?></label>
274
+					for="points-prefix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($prefix); ?></label>
275 275
 				<input class="widefat" type="text"
276
-				       id="points-prefix-<?php echo esc_attr( $slug ); ?>"
276
+				       id="points-prefix-<?php echo esc_attr($slug); ?>"
277 277
 				       name="points-prefix"
278
-				       value="<?php echo esc_attr( $points_type['prefix'] ); ?>"/>
278
+				       value="<?php echo esc_attr($points_type['prefix']); ?>"/>
279 279
 			</p>
280 280
 			<p>
281 281
 				<label
282
-					for="points-suffix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $suffix ); ?></label>
282
+					for="points-suffix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($suffix); ?></label>
283 283
 				<input class="widefat" type="text"
284
-				       id="points-suffix-<?php echo esc_attr( $slug ); ?>"
284
+				       id="points-suffix-<?php echo esc_attr($slug); ?>"
285 285
 				       name="points-suffix"
286
-				       value="<?php echo esc_attr( $points_type['suffix'] ); ?>"/>
286
+				       value="<?php echo esc_attr($points_type['suffix']); ?>"/>
287 287
 			</p>
288 288
 
289 289
 			<?php
@@ -297,28 +297,28 @@  discard block
 block discarded – undo
297 297
 			 *
298 298
 			 * @param string $points_type The slug of the points type.
299 299
 			 */
300
-			do_action( 'wordpoints_points_type_form_bottom', $slug );
300
+			do_action('wordpoints_points_type_form_bottom', $slug);
301 301
 
302 302
 			?>
303 303
 
304 304
 			<input type="hidden" name="points-slug"
305
-			       value="<?php echo esc_attr( $slug ); ?>"/>
305
+			       value="<?php echo esc_attr($slug); ?>"/>
306 306
 			<input type="hidden" name="add_new" class="add_new"
307
-			       value="<?php echo esc_attr( $add_new ); ?>"/>
307
+			       value="<?php echo esc_attr($add_new); ?>"/>
308 308
 
309 309
 			<div class="hook-control-actions">
310 310
 				<div class="alignleft">
311 311
 					<?php
312 312
 
313
-					if ( ! $add_new ) {
314
-						wp_nonce_field( "wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce' );
315
-						submit_button( _x( 'Delete', 'points type', 'wordpoints' ), 'delete', 'delete-points-type', false, array( 'id' => "delete_points_type-{$slug}" ) );
313
+					if ( ! $add_new) {
314
+						wp_nonce_field("wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce');
315
+						submit_button(_x('Delete', 'points type', 'wordpoints'), 'delete', 'delete-points-type', false, array('id' => "delete_points_type-{$slug}"));
316 316
 					}
317 317
 
318 318
 					?>
319 319
 				</div>
320 320
 				<div class="alignright">
321
-					<?php submit_button( _x( 'Save', 'points type', 'wordpoints' ), 'button-primary hook-control-save right', 'save-points-type', false, array( 'id' => "points-{$slug}-save" ) ); ?>
321
+					<?php submit_button(_x('Save', 'points type', 'wordpoints'), 'button-primary hook-control-save right', 'save-points-type', false, array('id' => "points-{$slug}-save")); ?>
322 322
 					<span class="spinner"></span>
323 323
 				</div>
324 324
 				<br class="clear"/>
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 
338 338
 		?>
339 339
 
340
-		<a href="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_points_logs&tab=' . $this->current_points_type ) ); ?>">
341
-			<?php esc_html_e( 'Go to the logs for this points type.', 'wordpoints' ); ?>
340
+		<a href="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_points_logs&tab=' . $this->current_points_type)); ?>">
341
+			<?php esc_html_e('Go to the logs for this points type.', 'wordpoints'); ?>
342 342
 		</a>
343 343
 
344 344
 		<?php
@@ -351,22 +351,22 @@  discard block
 block discarded – undo
351 351
 	 */
352 352
 	public function add_event_meta_boxes() {
353 353
 
354
-		if ( ! $this->current_points_type ) {
354
+		if ( ! $this->current_points_type) {
355 355
 			return;
356 356
 		}
357 357
 
358
-		$events_app       = $this->hooks->get_sub_app( 'events' );
359
-		$this->event_args = $events_app->get_sub_app( 'args' );
358
+		$events_app       = $this->hooks->get_sub_app('events');
359
+		$this->event_args = $events_app->get_sub_app('args');
360 360
 
361
-		$this->reaction_store = wordpoints_hooks()->get_reaction_store( 'points' );
361
+		$this->reaction_store = wordpoints_hooks()->get_reaction_store('points');
362 362
 
363
-		if ( ! $this->reaction_store ) {
363
+		if ( ! $this->reaction_store) {
364 364
 			return;
365 365
 		}
366 366
 
367 367
 		/** @var WordPoints_Hook_ReactorI $reactor */
368
-		$reactor = $this->hooks->get_sub_app( 'reactors' )->get( 'points' );
369
-		$reactor_action_types = array_fill_keys( $reactor->get_action_types(), true );
368
+		$reactor = $this->hooks->get_sub_app('reactors')->get('points');
369
+		$reactor_action_types = array_fill_keys($reactor->get_action_types(), true);
370 370
 
371 371
 		$event_action_types = wordpoints_hooks_ui_get_script_data_event_action_types();
372 372
 
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
 			, $this->current_points_type
392 392
 		);
393 393
 
394
-		foreach ( $events as $slug => $event ) {
394
+		foreach ($events as $slug => $event) {
395 395
 
396 396
 			if (
397 397
 				! array_intersect_key(
398
-					$event_action_types[ $slug ]
398
+					$event_action_types[$slug]
399 399
 					, $reactor_action_types
400 400
 				)
401 401
 			) {
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 			add_meta_box(
406 406
 				"{$this->current_points_type}-{$slug}"
407 407
 				, $event->get_title()
408
-				, array( $this, 'display_event_meta_box' )
408
+				, array($this, 'display_event_meta_box')
409 409
 				, $this->id
410 410
 				, 'events'
411 411
 				, 'default'
@@ -426,50 +426,50 @@  discard block
 block discarded – undo
426 426
 	 * @param array $points_type The points type this meta-box relates to.
427 427
 	 * @param array $meta_box    The data the meta-box was created with.
428 428
 	 */
429
-	public function display_event_meta_box( $points_type, $meta_box ) {
429
+	public function display_event_meta_box($points_type, $meta_box) {
430 430
 
431 431
 		$event_slug = $meta_box['args']['slug'];
432 432
 
433 433
 		$data = array();
434 434
 
435
-		foreach ( $this->reaction_store->get_reactions_to_event( $event_slug ) as $id => $reaction ) {
436
-			if ( $reaction->get_meta( 'points_type' ) === $this->current_points_type ) {
435
+		foreach ($this->reaction_store->get_reactions_to_event($event_slug) as $id => $reaction) {
436
+			if ($reaction->get_meta('points_type') === $this->current_points_type) {
437 437
 				$data[] = WordPoints_Admin_Ajax_Hooks::prepare_hook_reaction(
438 438
 					$reaction
439 439
 				);
440 440
 			}
441 441
 		}
442 442
 
443
-		$event_data = array( 'args' => array() );
443
+		$event_data = array('args' => array());
444 444
 
445
-		foreach ( $this->event_args->get_children( $event_slug ) as $slug => $arg ) {
445
+		foreach ($this->event_args->get_children($event_slug) as $slug => $arg) {
446 446
 
447
-			$event_data['args'][ $slug ] = array(
447
+			$event_data['args'][$slug] = array(
448 448
 				'slug' => $slug,
449 449
 			);
450 450
 
451
-			if ( $arg instanceof WordPoints_Hook_ArgI ) {
452
-				$event_data['args'][ $slug ]['title'] = $arg->get_title();
453
-				$event_data['args'][ $slug ]['is_stateful'] = $arg->is_stateful();
451
+			if ($arg instanceof WordPoints_Hook_ArgI) {
452
+				$event_data['args'][$slug]['title'] = $arg->get_title();
453
+				$event_data['args'][$slug]['is_stateful'] = $arg->is_stateful();
454 454
 			}
455 455
 		}
456 456
 
457 457
 		?>
458 458
 
459 459
 		<script>
460
-			WordPointsHooksAdminData.events[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $event_data ); ?>;
461
-			WordPointsHooksAdminData.reactions[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $data ); ?>;
460
+			WordPointsHooksAdminData.events[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($event_data); ?>;
461
+			WordPointsHooksAdminData.reactions[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($data); ?>;
462 462
 		</script>
463 463
 
464 464
 		<div class="wordpoints-hook-reaction-group-container">
465 465
 			<p class="description wordpoints-hook-reaction-group-description">
466
-				<?php echo esc_html( $meta_box['args']['event']->get_description() ); ?>
466
+				<?php echo esc_html($meta_box['args']['event']->get_description()); ?>
467 467
 			</p>
468 468
 
469 469
 			<div class="wordpoints-hook-reaction-group"
470
-				data-wordpoints-hooks-hook-event="<?php echo esc_attr( $event_slug ); ?>"
471
-				data-wordpoints-hooks-points-type="<?php echo esc_attr( $this->current_points_type ); ?>"
472
-				data-wordpoints-hooks-create-nonce="<?php echo esc_attr( WordPoints_Admin_Ajax_Hooks::get_create_nonce( $this->reaction_store ) ); ?>"
470
+				data-wordpoints-hooks-hook-event="<?php echo esc_attr($event_slug); ?>"
471
+				data-wordpoints-hooks-points-type="<?php echo esc_attr($this->current_points_type); ?>"
472
+				data-wordpoints-hooks-create-nonce="<?php echo esc_attr(WordPoints_Admin_Ajax_Hooks::get_create_nonce($this->reaction_store)); ?>"
473 473
 				data-wordpoints-hooks-reaction-store="points"
474 474
 				data-wordpoints-hooks-reactor="points">
475 475
 			</div>
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 
485 485
 			<div class="controls">
486 486
 				<button type="button" class="button-primary add-reaction">
487
-					<?php esc_html_e( 'Add New Reaction', 'wordpoints' ); ?>
487
+					<?php esc_html_e('Add New Reaction', 'wordpoints'); ?>
488 488
 				</button>
489 489
 			</div>
490 490
 		</div>
@@ -504,19 +504,19 @@  discard block
 block discarded – undo
504 504
 		// Show a tab for each points type.
505 505
 		$tabs = array();
506 506
 
507
-		foreach ( $points_types as $slug => $settings ) {
508
-			$tabs[ $slug ] = $settings['name'];
507
+		foreach ($points_types as $slug => $settings) {
508
+			$tabs[$slug] = $settings['name'];
509 509
 		}
510 510
 
511
-		$tabs['add-new'] = __( 'Add New', 'wordpoints' );
511
+		$tabs['add-new'] = __('Add New', 'wordpoints');
512 512
 
513
-		$tab = wordpoints_admin_get_current_tab( $tabs );
513
+		$tab = wordpoints_admin_get_current_tab($tabs);
514 514
 
515
-		if ( 'add-new' !== $tab ) {
515
+		if ('add-new' !== $tab) {
516 516
 			$this->current_points_type = $tab;
517 517
 		}
518 518
 
519
-		do_action( 'add_meta_boxes', $this->id );
519
+		do_action('add_meta_boxes', $this->id);
520 520
 
521 521
 		$this->tabs = $tabs;
522 522
 	}
@@ -528,19 +528,19 @@  discard block
 block discarded – undo
528 528
 	 */
529 529
 	public function save_points_type() {
530 530
 
531
-		if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) {
531
+		if ( ! current_user_can('manage_wordpoints_points_types')) {
532 532
 			return;
533 533
 		}
534 534
 
535
-		if ( isset( $_POST['save-points-type'] ) ) { // WPCS: CSRF OK
535
+		if (isset($_POST['save-points-type'])) { // WPCS: CSRF OK
536 536
 
537
-			if ( ! empty( $_POST['add_new'] ) ) { // WPCS: CSRF OK
537
+			if ( ! empty($_POST['add_new'])) { // WPCS: CSRF OK
538 538
 				$this->add_points_type();
539 539
 			} else {
540 540
 				$this->update_points_type();
541 541
 			}
542 542
 
543
-		} elseif ( ! empty( $_POST['delete-points-type'] ) ) { // WPCS: CSRF OK
543
+		} elseif ( ! empty($_POST['delete-points-type'])) { // WPCS: CSRF OK
544 544
 
545 545
 			$this->delete_points_type();
546 546
 		}
@@ -557,21 +557,21 @@  discard block
 block discarded – undo
557 557
 
558 558
 		$settings = array();
559 559
 
560
-		if ( isset( $_POST['points-name'] ) ) { // WPCS: CSRF OK
560
+		if (isset($_POST['points-name'])) { // WPCS: CSRF OK
561 561
 			$settings['name'] = trim(
562
-				sanitize_text_field( wp_unslash( $_POST['points-name'] ) ) // WPCS: CSRF OK
562
+				sanitize_text_field(wp_unslash($_POST['points-name'])) // WPCS: CSRF OK
563 563
 			);
564 564
 		}
565 565
 
566
-		if ( isset( $_POST['points-prefix'] ) ) { // WPCS: CSRF OK
566
+		if (isset($_POST['points-prefix'])) { // WPCS: CSRF OK
567 567
 			$settings['prefix'] = ltrim(
568
-				sanitize_text_field( wp_unslash( $_POST['points-prefix'] ) ) // WPCS: CSRF OK
568
+				sanitize_text_field(wp_unslash($_POST['points-prefix'])) // WPCS: CSRF OK
569 569
 			);
570 570
 		}
571 571
 
572
-		if ( isset( $_POST['points-suffix'] ) ) { // WPCS: CSRF OK
572
+		if (isset($_POST['points-suffix'])) { // WPCS: CSRF OK
573 573
 			$settings['suffix'] = rtrim(
574
-				sanitize_text_field( wp_unslash( $_POST['points-suffix'] ) ) // WPCS: CSRF OK
574
+				sanitize_text_field(wp_unslash($_POST['points-suffix'])) // WPCS: CSRF OK
575 575
 			);
576 576
 		}
577 577
 
@@ -589,52 +589,52 @@  discard block
 block discarded – undo
589 589
 			! wordpoints_verify_nonce(
590 590
 				'update_points_type'
591 591
 				, 'wordpoints_update_points_type-%s'
592
-				, array( 'points-slug' )
592
+				, array('points-slug')
593 593
 				, 'post'
594 594
 			)
595
-			|| ! isset( $_POST['points-slug'] )
595
+			|| ! isset($_POST['points-slug'])
596 596
 		) {
597 597
 			return;
598 598
 		}
599 599
 
600 600
 		$settings = $this->get_points_type_settings();
601 601
 
602
-		if ( empty( $settings['name'] ) ) {
602
+		if (empty($settings['name'])) {
603 603
 
604 604
 			add_settings_error(
605 605
 				'points-name'
606 606
 				, 'wordpoints_points_type_update'
607
-				, __( 'Error: points type name cannot be empty.', 'wordpoints' )
607
+				, __('Error: points type name cannot be empty.', 'wordpoints')
608 608
 			);
609 609
 
610 610
 			return;
611 611
 		}
612 612
 
613
-		$points_type = sanitize_key( $_POST['points-slug'] );
613
+		$points_type = sanitize_key($_POST['points-slug']);
614 614
 
615
-		$old_settings = wordpoints_get_points_type( $points_type );
615
+		$old_settings = wordpoints_get_points_type($points_type);
616 616
 
617
-		if ( false === $old_settings ) {
617
+		if (false === $old_settings) {
618 618
 
619 619
 			add_settings_error(
620 620
 				''
621 621
 				, 'wordpoints_points_type_update'
622
-				, __( 'Error: failed updating points type.', 'wordpoints' )
622
+				, __('Error: failed updating points type.', 'wordpoints')
623 623
 			);
624 624
 
625 625
 			return;
626 626
 		}
627 627
 
628
-		if ( is_array( $old_settings ) ) {
629
-			$settings = array_merge( $old_settings, $settings );
628
+		if (is_array($old_settings)) {
629
+			$settings = array_merge($old_settings, $settings);
630 630
 		}
631 631
 
632
-		if ( ! wordpoints_update_points_type( $points_type, $settings ) ) {
632
+		if ( ! wordpoints_update_points_type($points_type, $settings)) {
633 633
 
634 634
 			add_settings_error(
635 635
 				''
636 636
 				, 'wordpoints_points_type_update'
637
-				, __( 'Error: failed updating points type.', 'wordpoints' )
637
+				, __('Error: failed updating points type.', 'wordpoints')
638 638
 			);
639 639
 
640 640
 		} else {
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 			add_settings_error(
643 643
 				''
644 644
 				, 'wordpoints_points_type_update'
645
-				, __( 'Points type updated.', 'wordpoints' )
645
+				, __('Points type updated.', 'wordpoints')
646 646
 				, 'updated'
647 647
 			);
648 648
 		}
@@ -668,14 +668,14 @@  discard block
 block discarded – undo
668 668
 
669 669
 		$settings = $this->get_points_type_settings();
670 670
 
671
-		$slug = wordpoints_add_points_type( $settings );
671
+		$slug = wordpoints_add_points_type($settings);
672 672
 
673
-		if ( ! $slug ) {
673
+		if ( ! $slug) {
674 674
 
675 675
 			add_settings_error(
676 676
 				''
677 677
 				, 'wordpoints_points_type_create'
678
-				, __( 'Please choose a unique name for this points type.', 'wordpoints' )
678
+				, __('Please choose a unique name for this points type.', 'wordpoints')
679 679
 			);
680 680
 
681 681
 		} else {
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 			add_settings_error(
686 686
 				''
687 687
 				, 'wordpoints_points_type_create'
688
-				, __( 'Points type created.', 'wordpoints' )
688
+				, __('Points type created.', 'wordpoints')
689 689
 				, 'updated'
690 690
 			);
691 691
 		}
@@ -702,22 +702,22 @@  discard block
 block discarded – undo
702 702
 			wordpoints_verify_nonce(
703 703
 				'delete-points-type-nonce'
704 704
 				, 'wordpoints_delete_points_type-%s'
705
-				, array( 'points-slug' )
705
+				, array('points-slug')
706 706
 				, 'post'
707 707
 			)
708
-			&& isset( $_POST['points-slug'] )
708
+			&& isset($_POST['points-slug'])
709 709
 		) {
710 710
 
711 711
 			if (
712 712
 				wordpoints_delete_points_type(
713
-					sanitize_key( $_POST['points-slug'] )
713
+					sanitize_key($_POST['points-slug'])
714 714
 				)
715 715
 			) {
716 716
 
717 717
 				add_settings_error(
718 718
 					''
719 719
 					, 'wordpoints_points_type_delete'
720
-					, __( 'Points type deleted.', 'wordpoints' )
720
+					, __('Points type deleted.', 'wordpoints')
721 721
 					, 'updated'
722 722
 				);
723 723
 
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 				add_settings_error(
727 727
 					''
728 728
 					, 'wordpoints_points_type_delete'
729
-					, __( 'Error while deleting.', 'wordpoints' )
729
+					, __('Error while deleting.', 'wordpoints')
730 730
 				);
731 731
 			}
732 732
 		}
@@ -742,18 +742,18 @@  discard block
 block discarded – undo
742 742
 		 *
743 743
 		 * @since 2.1.0
744 744
 		 */
745
-		do_action( 'wordpoints_admin_points_events_head' );
745
+		do_action('wordpoints_admin_points_events_head');
746 746
 
747
-		if ( is_network_admin() ) {
748
-			$title = __( 'Network Events', 'wordpoints' );
749
-			$description = __( 'Add reactions to these events to award points whenever they take place on this network.', 'wordpoints' );
747
+		if (is_network_admin()) {
748
+			$title = __('Network Events', 'wordpoints');
749
+			$description = __('Add reactions to these events to award points whenever they take place on this network.', 'wordpoints');
750 750
 		} else {
751
-			$title = __( 'Events', 'wordpoints' );
752
-			$description = __( 'Add reactions to these events to award points whenever they take place on this site.', 'wordpoints' );
751
+			$title = __('Events', 'wordpoints');
752
+			$description = __('Add reactions to these events to award points whenever they take place on this site.', 'wordpoints');
753 753
 		}
754 754
 
755
-		if ( isset( $this->current_points_type ) ) {
756
-			$points_type = wordpoints_get_points_type( $this->current_points_type );
755
+		if (isset($this->current_points_type)) {
756
+			$points_type = wordpoints_get_points_type($this->current_points_type);
757 757
 			$points_type['slug'] = $this->current_points_type;
758 758
 		} else {
759 759
 			$points_type = false;
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
 		<div class="wordpoints-points-type-meta-box-wrap">
765 765
 
766 766
 				<form>
767
-					<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
768
-					<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
767
+					<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
768
+					<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
769 769
 				</form>
770 770
 
771 771
 				<div id="poststuff">
@@ -773,23 +773,23 @@  discard block
 block discarded – undo
773 773
 					<div id="post-body" class="metabox-holder columns-<?php echo 1 === (int) get_current_screen()->get_columns() ? '1' : '2'; ?>">
774 774
 
775 775
 						<div id="postbox-container-1" class="postbox-container">
776
-							<?php do_meta_boxes( $this->id, 'side', $points_type ); ?>
776
+							<?php do_meta_boxes($this->id, 'side', $points_type); ?>
777 777
 						</div>
778 778
 
779
-						<?php if ( isset( $this->current_points_type ) ) : ?>
779
+						<?php if (isset($this->current_points_type)) : ?>
780 780
 							<div class="wordpoints-hook-events-heading">
781
-								<h2><?php echo esc_html( $title ); ?></h2>
781
+								<h2><?php echo esc_html($title); ?></h2>
782 782
 								<p class="description">
783
-									<?php echo esc_html( $description ); ?>
783
+									<?php echo esc_html($description); ?>
784 784
 									<?php
785 785
 
786 786
 									echo wp_kses(
787 787
 										sprintf(
788 788
 											// translators: URL of points reactions user docs on WordPoints.org.
789
-											__( 'You can learn more about how they work from <a href="%s">the user guide on WordPoints.org</a>.', 'wordpoints' )
789
+											__('You can learn more about how they work from <a href="%s">the user guide on WordPoints.org</a>.', 'wordpoints')
790 790
 											, 'https://wordpoints.org/user-guide/points-reactions/'
791 791
 										)
792
-										, array( 'a' => array( 'href' => true, 'target' => true ) )
792
+										, array('a' => array('href' => true, 'target' => true))
793 793
 									);
794 794
 
795 795
 									?>
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 							</div>
798 798
 
799 799
 							<div id="postbox-container-2" class="postbox-container">
800
-								<?php do_meta_boxes( $this->id, 'events', $points_type ); ?>
800
+								<?php do_meta_boxes($this->id, 'events', $points_type); ?>
801 801
 							</div>
802 802
 						<?php endif; ?>
803 803
 
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 		 *
817 817
 		 * @since 2.1.0
818 818
 		 */
819
-		do_action( 'wordpoints_admin_points_events_foot' );
819
+		do_action('wordpoints_admin_points_events_foot');
820 820
 	}
821 821
 }
822 822
 
Please login to merge, or discard this patch.