Completed
Push — master ( 760553...dce43d )
by J.D.
03:49
created
src/components/points/includes/hooks/registration.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @type array $defaults
25 25
 	 */
26
-	protected $defaults = array( 'points' => 100 );
26
+	protected $defaults = array('points' => 100);
27 27
 
28 28
 	/**
29 29
 	 * Construct the class.
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	public function __construct() {
37 37
 
38 38
 		$this->init(
39
-			_x( 'Registration', 'points hook name', 'wordpoints' )
40
-			, array( 'description' => _x( 'Registering with the site.', 'points hook description', 'wordpoints' ) )
39
+			_x('Registration', 'points hook name', 'wordpoints')
40
+			, array('description' => _x('Registering with the site.', 'points hook description', 'wordpoints'))
41 41
 		);
42 42
 
43
-		add_action( 'user_register', array( $this, 'hook' ) );
44
-		add_filter( 'wordpoints_points_log-register', array( $this, 'logs' ) );
43
+		add_action('user_register', array($this, 'hook'));
44
+		add_filter('wordpoints_points_log-register', array($this, 'logs'));
45 45
 	}
46 46
 
47 47
 	/**
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return void
57 57
 	 */
58
-	public function hook( $user_id ) {
58
+	public function hook($user_id) {
59 59
 
60
-		foreach ( $this->get_instances() as $number => $instance ) {
60
+		foreach ($this->get_instances() as $number => $instance) {
61 61
 
62
-			if ( isset( $instance['points'] ) ) {
63
-				wordpoints_add_points( $user_id, $instance['points'], $this->points_type( $number ), 'register' );
62
+			if (isset($instance['points'])) {
63
+				wordpoints_add_points($user_id, $instance['points'], $this->points_type($number), 'register');
64 64
 			}
65 65
 		}
66 66
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function logs() {
78 78
 
79
-		return _x( 'Registration.', 'points log description', 'wordpoints' );
79
+		return _x('Registration.', 'points log description', 'wordpoints');
80 80
 	}
81 81
 
82 82
 } // class WordPoints_Registration_Points_Hook
Please login to merge, or discard this patch.
src/components/points/includes/apps.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * @param WordPoints_App $components The components app.
18 18
  */
19
-function wordpoints_points_components_app_init( $components ) {
19
+function wordpoints_points_components_app_init($components) {
20 20
 
21 21
 	$apps = $components->sub_apps();
22 22
 
23
-	$apps->register( 'points', 'WordPoints_App' );
23
+	$apps->register('points', 'WordPoints_App');
24 24
 }
25 25
 
26 26
 /**
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @param WordPoints_App $app The points app.
34 34
  */
35
-function wordpoints_points_apps_init( $app ) {
35
+function wordpoints_points_apps_init($app) {
36 36
 
37 37
 	$apps = $app->sub_apps();
38 38
 
39
-	$apps->register( 'logs', 'WordPoints_App' );
39
+	$apps->register('logs', 'WordPoints_App');
40 40
 }
41 41
 
42 42
 /**
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
  *
49 49
  * @param WordPoints_App $app The points logs app.
50 50
  */
51
-function wordpoints_points_logs_apps_init( $app ) {
51
+function wordpoints_points_logs_apps_init($app) {
52 52
 
53 53
 	$apps = $app->sub_apps();
54 54
 
55
-	$apps->register( 'views', 'WordPoints_Class_Registry' );
56
-	$apps->register( 'viewing_restrictions', 'WordPoints_Points_Logs_Viewing_Restrictions' );
55
+	$apps->register('views', 'WordPoints_Class_Registry');
56
+	$apps->register('viewing_restrictions', 'WordPoints_Points_Logs_Viewing_Restrictions');
57 57
 }
58 58
 
59 59
 /**
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
  *
66 66
  * @param WordPoints_Class_RegistryI $views The points log views registry.
67 67
  */
68
-function wordpoints_points_logs_views_init( $views ) {
68
+function wordpoints_points_logs_views_init($views) {
69 69
 
70
-	$views->register( 'table', 'WordPoints_Points_Logs_View_Table' );
70
+	$views->register('table', 'WordPoints_Points_Logs_View_Table');
71 71
 }
72 72
 
73 73
 /**
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
  *
80 80
  * @param WordPoints_Points_Logs_Viewing_Restrictions $restrictions The registry.
81 81
  */
82
-function wordpoints_points_logs_viewing_restrictions_init( $restrictions ) {
82
+function wordpoints_points_logs_viewing_restrictions_init($restrictions) {
83 83
 
84
-	$restrictions->register( 'all', 'hooks', 'WordPoints_Points_Logs_Viewing_Restriction_Hooks' );
84
+	$restrictions->register('all', 'hooks', 'WordPoints_Points_Logs_Viewing_Restriction_Hooks');
85 85
 
86
-	$restrictions->register( 'comment_approve', 'read_comment', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Comment_Post' );
87
-	$restrictions->register( 'comment_received', 'read_comment', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Comment_Post' );
88
-	$restrictions->register( 'post_publish', 'read_post', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Post' );
86
+	$restrictions->register('comment_approve', 'read_comment', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Comment_Post');
87
+	$restrictions->register('comment_received', 'read_comment', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Comment_Post');
88
+	$restrictions->register('post_publish', 'read_post', 'WordPoints_Points_Logs_Viewing_Restriction_Read_Post');
89 89
 }
90 90
 
91 91
 // EOF
Please login to merge, or discard this patch.
src/components/points/admin/admin.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@
 block discarded – undo
22 22
  *
23 23
  * @since 2.1.0
24 24
  */
25
-require_once( WORDPOINTS_DIR . '/components/points/admin/includes/functions.php' );
25
+require_once(WORDPOINTS_DIR . '/components/points/admin/includes/functions.php');
26 26
 
27 27
 /**
28 28
  * Admin-side hooks.
29 29
  *
30 30
  * @since 2.1.0
31 31
  */
32
-require_once( WORDPOINTS_DIR . '/components/points/admin/includes/filters.php' );
32
+require_once(WORDPOINTS_DIR . '/components/points/admin/includes/filters.php');
33 33
 
34 34
 WordPoints_Class_Autoloader::register_dir(
35 35
 	WORDPOINTS_DIR . '/components/points/admin/classes'
Please login to merge, or discard this patch.
src/components/points/admin/classes/screen/points/types.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -211,9 +211,12 @@
 block discarded – undo
211 211
 					<p>
212 212
 						<?php if ( $slug ) : ?>
213 213
 							<?php esc_html_e( 'Changes to this points type&#8217;s settings will affect all sites on this network.', 'wordpoints' ) ?>
214
-						<?php else : ?>
214
+						<?php else {
215
+	: ?>
215 216
 							<?php esc_html_e( 'The new points type will be global across all sites on this network.', 'wordpoints' ) ?>
216
-						<?php endif; ?>
217
+						<?php endif;
218
+}
219
+?>
217 220
 					</p>
218 221
 				</div>
219 222
 			<?php endif; ?>
Please login to merge, or discard this 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.
src/components/points/admin/screens/hooks-load.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -13,58 +13,58 @@
 block discarded – undo
13 13
 $screen->add_help_tab(
14 14
 	array(
15 15
 		'id'      => 'overview',
16
-		'title'   => esc_html__( 'Overview', 'wordpoints' ),
16
+		'title'   => esc_html__('Overview', 'wordpoints'),
17 17
 		'content' =>
18
-			'<p>' . esc_html__( 'Points Hooks let you award users points by &#8220;hooking into&#8221; different actions. They can be hooked to any points type that you have created.', 'wordpoints' ) . '</p>
19
-			<p>' . esc_html__( 'To link a hook to a points type, click on the hook&#8217;s title bar and select a points type, or drag and drop the hook title bars into the desired points type. By default, only the first points type area is expanded. To populate additional points types, click on their title bars to expand them.', 'wordpoints' ) . '</p>
20
-			<p>' . esc_html__( 'The Available Hooks section contains all the hooks you can choose from. Once you add a hook into a points type, it will open to allow you to configure its settings. When you are happy with the hook settings, click the Save button and the hook will begin awarding points. If you click Delete, it will remove the hook.', 'wordpoints' ) . '</p>',
18
+			'<p>' . esc_html__('Points Hooks let you award users points by &#8220;hooking into&#8221; different actions. They can be hooked to any points type that you have created.', 'wordpoints') . '</p>
19
+			<p>' . esc_html__('To link a hook to a points type, click on the hook&#8217;s title bar and select a points type, or drag and drop the hook title bars into the desired points type. By default, only the first points type area is expanded. To populate additional points types, click on their title bars to expand them.', 'wordpoints') . '</p>
20
+			<p>' . esc_html__('The Available Hooks section contains all the hooks you can choose from. Once you add a hook into a points type, it will open to allow you to configure its settings. When you are happy with the hook settings, click the Save button and the hook will begin awarding points. If you click Delete, it will remove the hook.', 'wordpoints') . '</p>',
21 21
 	)
22 22
 );
23 23
 
24 24
 $screen->add_help_tab(
25 25
 	array(
26 26
 		'id'      => 'removing-reusing',
27
-		'title'   => esc_html__( 'Removing and Reusing', 'wordpoints' ),
27
+		'title'   => esc_html__('Removing and Reusing', 'wordpoints'),
28 28
 		'content' =>
29
-			'<p>' . esc_html__( 'If you want to remove the hook but save its setting for possible future use, just drag it into the Inactive Hooks area. You can add them back anytime from there.', 'wordpoints' ) . '</p>
30
-			<p>' . esc_html__( 'Hooks may be used multiple times.', 'wordpoints' ) . '</p>
31
-			<p>' . esc_html__( 'Enabling Accessibility Mode, via Screen Options, allows you to use Add and Edit buttons instead of using drag and drop.', 'wordpoints' ) . '</p>',
29
+			'<p>' . esc_html__('If you want to remove the hook but save its setting for possible future use, just drag it into the Inactive Hooks area. You can add them back anytime from there.', 'wordpoints') . '</p>
30
+			<p>' . esc_html__('Hooks may be used multiple times.', 'wordpoints') . '</p>
31
+			<p>' . esc_html__('Enabling Accessibility Mode, via Screen Options, allows you to use Add and Edit buttons instead of using drag and drop.', 'wordpoints') . '</p>',
32 32
 	)
33 33
 );
34 34
 
35 35
 $screen->set_help_sidebar(
36
-	'<p><strong>' . esc_html__( 'For more information:', 'wordpoints' ) . '</strong></p>
37
-	<p><a href="https://wordpoints.org/user-guide/points-hooks/">' . esc_html__( 'Documentation on Points Hooks', 'wordpoints' ) . '</a></p>
38
-	<p><a href="https://wordpress.org/support/plugin/wordpoints">' . esc_html__( 'Support Forums', 'wordpoints' ) . '</a></p>'
36
+	'<p><strong>' . esc_html__('For more information:', 'wordpoints') . '</strong></p>
37
+	<p><a href="https://wordpoints.org/user-guide/points-hooks/">' . esc_html__('Documentation on Points Hooks', 'wordpoints') . '</a></p>
38
+	<p><a href="https://wordpress.org/support/plugin/wordpoints">' . esc_html__('Support Forums', 'wordpoints') . '</a></p>'
39 39
 );
40 40
 
41
-$accessibility_mode = get_user_setting( 'wordpoints_points_hooks_access' );
41
+$accessibility_mode = get_user_setting('wordpoints_points_hooks_access');
42 42
 
43 43
 if (
44
-	isset( $_GET['accessibility-mode'], $_GET['wordpoints-accessiblity-nonce'] )
45
-	&& wordpoints_verify_nonce( 'wordpoints-accessiblity-nonce', 'wordpoints_points_hooks_accessiblity' )
44
+	isset($_GET['accessibility-mode'], $_GET['wordpoints-accessiblity-nonce'])
45
+	&& wordpoints_verify_nonce('wordpoints-accessiblity-nonce', 'wordpoints_points_hooks_accessiblity')
46 46
 ) {
47 47
 
48
-	$accessibility_mode = ( 'on' === sanitize_key( $_GET['accessibility-mode'] ) ) ? 'on' : 'off';
49
-	set_user_setting( 'wordpoints_points_hooks_access', $accessibility_mode );
48
+	$accessibility_mode = ('on' === sanitize_key($_GET['accessibility-mode'])) ? 'on' : 'off';
49
+	set_user_setting('wordpoints_points_hooks_access', $accessibility_mode);
50 50
 }
51 51
 
52 52
 // Enqueue needed scripts and styles.
53
-if ( 'on' === $accessibility_mode ) {
53
+if ('on' === $accessibility_mode) {
54 54
 
55
-	add_filter( 'admin_body_class', 'wordpoints_points_hooks_access_body_class' );
55
+	add_filter('admin_body_class', 'wordpoints_points_hooks_access_body_class');
56 56
 
57 57
 } else {
58 58
 
59
-	wp_enqueue_style( 'wp-jquery-ui-dialog' );
59
+	wp_enqueue_style('wp-jquery-ui-dialog');
60 60
 
61
-	wp_enqueue_script( 'wordpoints-admin-points-hooks' );
61
+	wp_enqueue_script('wordpoints-admin-points-hooks');
62 62
 
63
-	if ( wp_is_mobile() ) {
64
-		wp_enqueue_script( 'jquery-touch-punch' );
63
+	if (wp_is_mobile()) {
64
+		wp_enqueue_script('jquery-touch-punch');
65 65
 	}
66 66
 }
67 67
 
68
-wp_enqueue_style( 'wordpoints-admin-points-hooks' );
68
+wp_enqueue_style('wordpoints-admin-points-hooks');
69 69
 
70 70
 // EOF
Please login to merge, or discard this patch.
src/components/points/admin/screens/hooks-no-js-load.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -7,122 +7,122 @@
 block discarded – undo
7 7
  * @since 1.2.0
8 8
  */
9 9
 
10
-if ( ! current_user_can( 'manage_options' ) ) {
10
+if ( ! current_user_can('manage_options')) {
11 11
 	return;
12 12
 }
13 13
 
14
-if ( ! isset( $_POST['hook-id'] ) ) {
14
+if ( ! isset($_POST['hook-id'])) {
15 15
 	return;
16 16
 }
17 17
 
18
-$hook_id = sanitize_key( $_POST['hook-id'] );
18
+$hook_id = sanitize_key($_POST['hook-id']);
19 19
 
20
-check_admin_referer( "save-delete-hook-{$hook_id}" );
20
+check_admin_referer("save-delete-hook-{$hook_id}");
21 21
 
22
-$redirect_url = self_admin_url( 'admin.php?page=wordpoints_points_hooks' );
22
+$redirect_url = self_admin_url('admin.php?page=wordpoints_points_hooks');
23 23
 
24
-if ( is_network_admin() ) {
25
-	WordPoints_Points_Hooks::set_network_mode( true );
24
+if (is_network_admin()) {
25
+	WordPoints_Points_Hooks::set_network_mode(true);
26 26
 }
27 27
 
28
-if ( ! isset( $_POST['points_type'], $_POST['id_base'] ) ) {
28
+if ( ! isset($_POST['points_type'], $_POST['id_base'])) {
29 29
 	return;
30 30
 }
31 31
 
32
-$points_type_id = sanitize_key( $_POST['points_type'] );
33
-$id_base        = sanitize_key( $_POST['id_base'] );
32
+$points_type_id = sanitize_key($_POST['points_type']);
33
+$id_base        = sanitize_key($_POST['id_base']);
34 34
 
35 35
 // These are the hooks grouped by points type.
36 36
 $points_types_hooks = WordPoints_Points_Hooks::get_points_types_hooks();
37 37
 
38
-if ( empty( $points_types_hooks ) ) {
38
+if (empty($points_types_hooks)) {
39 39
 	$points_types_hooks = WordPoints_Points_Hooks::get_defaults();
40 40
 }
41 41
 
42
-if ( isset( $points_types_hooks[ $points_type_id ] ) ) {
43
-	$points_type_hooks = $points_types_hooks[ $points_type_id ];
42
+if (isset($points_types_hooks[$points_type_id])) {
43
+	$points_type_hooks = $points_types_hooks[$points_type_id];
44 44
 } else {
45 45
 	$points_type_hooks = array();
46 46
 }
47 47
 
48
-$hook = WordPoints_Points_Hooks::get_handler_by_id_base( $id_base );
48
+$hook = WordPoints_Points_Hooks::get_handler_by_id_base($id_base);
49 49
 
50
-if ( ! empty( $_POST['removehook'] ) ) {
50
+if ( ! empty($_POST['removehook'])) {
51 51
 
52 52
 	// - We are deleting an instance of a hook.
53 53
 
54
-	if ( ! in_array( $hook_id, $points_type_hooks, true ) ) {
54
+	if ( ! in_array($hook_id, $points_type_hooks, true)) {
55 55
 
56 56
 		// The hook isn't hooked to this points type, give an error.
57
-		wp_safe_redirect( $redirect_url . '&error=0' );
57
+		wp_safe_redirect($redirect_url . '&error=0');
58 58
 		exit;
59 59
 	}
60 60
 
61 61
 	// Remove the hook from this points type.
62
-	$points_types_hooks[ $points_type_id ] = array_diff( $points_type_hooks, array( $hook_id ) );
62
+	$points_types_hooks[$points_type_id] = array_diff($points_type_hooks, array($hook_id));
63 63
 
64
-	$hook->delete_callback( $hook_id );
64
+	$hook->delete_callback($hook_id);
65 65
 
66
-} elseif ( ! empty( $_POST['savehook'] ) ) {
66
+} elseif ( ! empty($_POST['savehook'])) {
67 67
 
68 68
 	// - We are saving an instance of a hook.
69 69
 
70
-	$number = isset( $_POST['multi_number'] ) ? (int) $_POST['multi_number'] : '';
70
+	$number = isset($_POST['multi_number']) ? (int) $_POST['multi_number'] : '';
71 71
 
72
-	if ( $number ) {
72
+	if ($number) {
73 73
 
74 74
 		// Search the POST for the instance settings.
75
-		foreach ( $_POST as $key => $val ) {
75
+		foreach ($_POST as $key => $val) {
76 76
 
77
-			if ( is_array( $val ) && preg_match( '/__i__|%i%/', key( $val ) ) ) {
77
+			if (is_array($val) && preg_match('/__i__|%i%/', key($val))) {
78 78
 
79
-				$new_instance = array_shift( $val );
79
+				$new_instance = array_shift($val);
80 80
 				break;
81 81
 			}
82 82
 		}
83 83
 
84 84
 	} else {
85 85
 
86
-		if ( isset( $_POST[ 'hook-' . $id_base ] ) && is_array( $_POST[ 'hook-' . $id_base ] ) ) {
87
-			$new_instance = wp_unslash( reset( $_POST[ 'hook-' . $id_base ] ) ); // WPCS sanitization OK.
86
+		if (isset($_POST['hook-' . $id_base]) && is_array($_POST['hook-' . $id_base])) {
87
+			$new_instance = wp_unslash(reset($_POST['hook-' . $id_base])); // WPCS sanitization OK.
88 88
 		}
89 89
 
90
-		$number = $hook->get_number_by_id( $hook_id );
90
+		$number = $hook->get_number_by_id($hook_id);
91 91
 	}
92 92
 
93
-	if ( ! isset( $new_instance ) || ! is_array( $new_instance ) ) {
93
+	if ( ! isset($new_instance) || ! is_array($new_instance)) {
94 94
 
95 95
 		$new_instance = array();
96 96
 	}
97 97
 
98 98
 	// Update the hook.
99
-	$hook->update_callback( $new_instance, $number );
99
+	$hook->update_callback($new_instance, $number);
100 100
 
101 101
 	// Add hook it to this points type.
102
-	if ( ! in_array( $hook_id, $points_type_hooks ) ) {
102
+	if ( ! in_array($hook_id, $points_type_hooks)) {
103 103
 
104 104
 		$points_type_hooks[] = $hook_id;
105
-		$points_types_hooks[ $points_type_id ] = $points_type_hooks;
105
+		$points_types_hooks[$points_type_id] = $points_type_hooks;
106 106
 	}
107 107
 
108 108
 	// Remove from old points type if it has changed.
109
-	$old_points_type = WordPoints_Points_Hooks::get_points_type( $hook_id );
109
+	$old_points_type = WordPoints_Points_Hooks::get_points_type($hook_id);
110 110
 
111
-	if ( $old_points_type && $old_points_type !== $points_type_id && is_array( $points_types_hooks[ $old_points_type ] ) ) {
111
+	if ($old_points_type && $old_points_type !== $points_type_id && is_array($points_types_hooks[$old_points_type])) {
112 112
 
113
-		$points_types_hooks[ $old_points_type ] = array_diff( $points_types_hooks[ $old_points_type ], array( $hook_id ) );
113
+		$points_types_hooks[$old_points_type] = array_diff($points_types_hooks[$old_points_type], array($hook_id));
114 114
 	}
115 115
 
116 116
 } else {
117 117
 
118
-	wp_safe_redirect( $redirect_url . '&error=0' );
118
+	wp_safe_redirect($redirect_url . '&error=0');
119 119
 	exit;
120 120
 
121 121
 } // End if ( deleting hook ) elseif ( saving hook ) else.
122 122
 
123
-WordPoints_Points_Hooks::save_points_types_hooks( $points_types_hooks );
123
+WordPoints_Points_Hooks::save_points_types_hooks($points_types_hooks);
124 124
 
125
-wp_safe_redirect( $redirect_url . '&message=0' );
125
+wp_safe_redirect($redirect_url . '&message=0');
126 126
 exit;
127 127
 
128 128
 // EOF
Please login to merge, or discard this patch.
src/components/points/admin/screens/hooks-no-js.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -125,8 +125,10 @@
 block discarded – undo
125 125
 			<div class="hook-control-actions">
126 126
 				<?php if ( isset( $_GET['addnew'] ) ) : ?>
127 127
 					<a href="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_points_hooks' ) ); ?>" class="button alignleft"><?php esc_html_e( 'Cancel', 'wordpoints' ); ?></a>
128
-				<?php else :
128
+				<?php else {
129
+	:
129 130
 						submit_button( _x( 'Delete', 'points hook', 'wordpoints' ), 'button alignleft', 'removehook', false );
131
+}
130 132
 					endif;
131 133
 
132 134
 					submit_button( __( 'Save Hook', 'wordpoints' ), 'button-primary alignright', 'savehook', false );
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -7,44 +7,44 @@  discard block
 block discarded – undo
7 7
  * @since 1.0.0
8 8
  */
9 9
 
10
-if ( ! isset( $_GET['edithook'] ) ) {
10
+if ( ! isset($_GET['edithook'])) {
11 11
 	return;
12 12
 }
13 13
 
14
-$hook_id = sanitize_key( $_GET['edithook'] );
14
+$hook_id = sanitize_key($_GET['edithook']);
15 15
 
16 16
 $points_types = wordpoints_get_points_types();
17 17
 
18
-if ( isset( $_GET['addnew'] ) ) {
18
+if (isset($_GET['addnew'])) {
19 19
 
20 20
 	// - We are adding a new points hook.
21 21
 
22 22
 	$points_type = wordpoints_get_default_points_type();
23 23
 
24 24
 	// Default to the first points type.
25
-	if ( ! $points_type ) {
26
-		reset( $points_types );
27
-		$points_type = key( $points_types );
25
+	if ( ! $points_type) {
26
+		reset($points_types);
27
+		$points_type = key($points_types);
28 28
 	}
29 29
 
30
-	if ( ! $points_type ) {
30
+	if ( ! $points_type) {
31 31
 
32
-		wordpoints_show_admin_error( esc_html__( 'You need to add a points type before you can add any hooks.', 'wordpoints' ) );
32
+		wordpoints_show_admin_error(esc_html__('You need to add a points type before you can add any hooks.', 'wordpoints'));
33 33
 		return;
34 34
 	}
35 35
 
36
-	if ( isset( $_GET['base'], $_GET['num'] ) ) {
36
+	if (isset($_GET['base'], $_GET['num'])) {
37 37
 
38 38
 		// Copy minimal info from an existing instance of this hook to a new instance.
39 39
 		$hook = WordPoints_Points_Hooks::get_handler_by_id_base(
40
-			sanitize_key( $_GET['base'] )
40
+			sanitize_key($_GET['base'])
41 41
 		);
42 42
 
43
-		if ( ! $hook ) {
43
+		if ( ! $hook) {
44 44
 
45 45
 			wordpoints_show_admin_error(
46
-				esc_html__( 'Unable to add the points hook, please try again.', 'wordpoints' )
47
-				, array( 'dismissible' => true )
46
+				esc_html__('Unable to add the points hook, please try again.', 'wordpoints')
47
+				, array('dismissible' => true)
48 48
 			);
49 49
 
50 50
 			return;
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
 
53 53
 		$multi_number = (int) $_GET['num'];
54 54
 		$number       = 0;
55
-		$hook_id      = $hook->get_id( $multi_number );
55
+		$hook_id      = $hook->get_id($multi_number);
56 56
 		$_hook        = $hook;
57 57
 		$id_base      = $hook->get_id_base();
58 58
 
59 59
 	} else {
60 60
 
61 61
 		wordpoints_show_admin_error(
62
-			esc_html__( 'Unable to add the points hook, please try again.', 'wordpoints' )
63
-			, array( 'dismissible' => true )
62
+			esc_html__('Unable to add the points hook, please try again.', 'wordpoints')
63
+			, array('dismissible' => true)
64 64
 		);
65 65
 
66 66
 		return;
@@ -70,43 +70,43 @@  discard block
 block discarded – undo
70 70
 
71 71
 	// We are editing an existing points hook.
72 72
 
73
-	$points_type = isset( $_GET['points_type'] ) ? sanitize_key( $_GET['points_type'] ) : '_inactive_hooks';
73
+	$points_type = isset($_GET['points_type']) ? sanitize_key($_GET['points_type']) : '_inactive_hooks';
74 74
 
75
-	$hook = WordPoints_Points_Hooks::get_handler( $hook_id );
75
+	$hook = WordPoints_Points_Hooks::get_handler($hook_id);
76 76
 
77
-	if ( ! $hook ) {
77
+	if ( ! $hook) {
78 78
 
79
-		wordpoints_show_admin_error( esc_html__( 'The hook you have asked to edit could not be found. Please go back and try again.', 'wordpoints' ) );
79
+		wordpoints_show_admin_error(esc_html__('The hook you have asked to edit could not be found. Please go back and try again.', 'wordpoints'));
80 80
 		return;
81 81
 	}
82 82
 
83 83
 	$id_base = $hook->get_id_base();
84 84
 	$multi_number = 0;
85
-	$number = $hook->get_number_by_id( $hook_id );
85
+	$number = $hook->get_number_by_id($hook_id);
86 86
 
87 87
 } // End if ( adding hook ) else { updating hook }.
88 88
 
89
-$name = esc_html( $hook->get_name() );
89
+$name = esc_html($hook->get_name());
90 90
 
91 91
 // Show the hook form.
92 92
 
93 93
 ?>
94 94
 
95 95
 <div class="wrap">
96
-	<h1><?php esc_html_e( 'Points Hooks', 'wordpoints' ); ?></h1>
97
-	<div class="edithook" style="width:<?php echo absint( $hook->get_option( 'width' ) ); ?>px">
96
+	<h1><?php esc_html_e('Points Hooks', 'wordpoints'); ?></h1>
97
+	<div class="edithook" style="width:<?php echo absint($hook->get_option('width')); ?>px">
98 98
 		<?php // translators: Hook name. ?>
99
-		<h2><?php echo esc_html( sprintf( __( 'Hook %s', 'wordpoints' ), $name ) ); ?></h2>
99
+		<h2><?php echo esc_html(sprintf(__('Hook %s', 'wordpoints'), $name)); ?></h2>
100 100
 
101
-		<form action="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_points_hooks' ) ); ?>" method="post">
101
+		<form action="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_points_hooks')); ?>" method="post">
102 102
 			<div class="hook-inside">
103
-				<?php $hook->form_callback( $number ); ?>
103
+				<?php $hook->form_callback($number); ?>
104 104
 			</div>
105 105
 
106
-			<p class="describe"><?php esc_html_e( 'Select the points type to attach this hook to.', 'wordpoints' ); ?></p>
106
+			<p class="describe"><?php esc_html_e('Select the points type to attach this hook to.', 'wordpoints'); ?></p>
107 107
 			<div class="hook-position">
108 108
 				<label for="points_type" class="screen-reader-text">
109
-					<?php esc_html_e( 'Points Type:', 'wordpoints' ); ?>
109
+					<?php esc_html_e('Points Type:', 'wordpoints'); ?>
110 110
 				</label>
111 111
 				<?php
112 112
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 							'name'     => 'points_type',
117 117
 							'id'       => 'points_type',
118 118
 							'class'    => 'widefat',
119
-							'options'  => array( '_inactive_hooks' => __( 'Inactive Hooks', 'wordpoints' ) ),
119
+							'options'  => array('_inactive_hooks' => __('Inactive Hooks', 'wordpoints')),
120 120
 						)
121 121
 					);
122 122
 
@@ -124,19 +124,19 @@  discard block
 block discarded – undo
124 124
 			</div>
125 125
 			<br />
126 126
 			<div class="hook-control-actions">
127
-				<?php if ( isset( $_GET['addnew'] ) ) : ?>
128
-					<a href="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_points_hooks' ) ); ?>" class="button alignleft"><?php esc_html_e( 'Cancel', 'wordpoints' ); ?></a>
127
+				<?php if (isset($_GET['addnew'])) : ?>
128
+					<a href="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_points_hooks')); ?>" class="button alignleft"><?php esc_html_e('Cancel', 'wordpoints'); ?></a>
129 129
 				<?php else :
130
-						submit_button( _x( 'Delete', 'points hook', 'wordpoints' ), 'button alignleft', 'removehook', false );
130
+						submit_button(_x('Delete', 'points hook', 'wordpoints'), 'button alignleft', 'removehook', false);
131 131
 					endif;
132 132
 
133
-					submit_button( __( 'Save Hook', 'wordpoints' ), 'button-primary alignright', 'savehook', false );
133
+					submit_button(__('Save Hook', 'wordpoints'), 'button-primary alignright', 'savehook', false);
134 134
 				?>
135 135
 
136
-				<input type="hidden" name="hook-id" class="hook-id" value="<?php echo esc_attr( $hook_id ); ?>" />
137
-				<input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr( $id_base ); ?>" />
138
-				<input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr( $multi_number ); ?>" />
139
-				<?php wp_nonce_field( "save-delete-hook-{$hook_id}" ); ?>
136
+				<input type="hidden" name="hook-id" class="hook-id" value="<?php echo esc_attr($hook_id); ?>" />
137
+				<input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" />
138
+				<input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" />
139
+				<?php wp_nonce_field("save-delete-hook-{$hook_id}"); ?>
140 140
 				<br class="clear" />
141 141
 			</div>
142 142
 		</form>
Please login to merge, or discard this patch.
src/components/points/admin/includes/filters.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,34 +7,34 @@
 block discarded – undo
7 7
  * @since 2.1.0
8 8
  */
9 9
 
10
-add_action( 'init', 'wordpoints_points_admin_register_scripts' );
10
+add_action('init', 'wordpoints_points_admin_register_scripts');
11 11
 
12
-add_action( 'admin_menu', 'wordpoints_points_admin_menu' );
12
+add_action('admin_menu', 'wordpoints_points_admin_menu');
13 13
 
14
-if ( is_wordpoints_network_active() ) {
15
-	add_action( 'network_admin_menu', 'wordpoints_points_admin_menu' );
14
+if (is_wordpoints_network_active()) {
15
+	add_action('network_admin_menu', 'wordpoints_points_admin_menu');
16 16
 }
17 17
 
18
-add_action( 'load-wordpoints_page_wordpoints_points_hooks', 'wordpoints_admin_points_hooks_help' );
18
+add_action('load-wordpoints_page_wordpoints_points_hooks', 'wordpoints_admin_points_hooks_help');
19 19
 
20
-add_action( 'load-wordpoints_page_wordpoints_points_hooks', 'wordpoints_no_js_points_hooks_save' );
20
+add_action('load-wordpoints_page_wordpoints_points_hooks', 'wordpoints_no_js_points_hooks_save');
21 21
 
22
-add_action( 'screen_settings', 'wordpoints_admin_points_hooks_screen_options', 10, 2 );
22
+add_action('screen_settings', 'wordpoints_admin_points_hooks_screen_options', 10, 2);
23 23
 
24
-add_action( 'wordpoints_in_points_hook_form', 'wordpoints_points_hook_description_form', 10, 3 );
24
+add_action('wordpoints_in_points_hook_form', 'wordpoints_points_hook_description_form', 10, 3);
25 25
 
26
-add_action( 'personal_options', 'wordpoints_points_profile_options', 20 );
26
+add_action('personal_options', 'wordpoints_points_profile_options', 20);
27 27
 
28
-add_action( 'personal_options_update', 'wordpoints_points_profile_options_update' );
29
-add_action( 'edit_user_profile_update', 'wordpoints_points_profile_options_update' );
28
+add_action('personal_options_update', 'wordpoints_points_profile_options_update');
29
+add_action('edit_user_profile_update', 'wordpoints_points_profile_options_update');
30 30
 
31
-add_action( 'wordpoints_admin_settings_top', 'wordpoints_points_admin_settings' );
31
+add_action('wordpoints_admin_settings_top', 'wordpoints_points_admin_settings');
32 32
 
33
-add_action( 'wordpoints_admin_settings_update', 'wordpoints_points_admin_settings_save' );
33
+add_action('wordpoints_admin_settings_update', 'wordpoints_points_admin_settings_save');
34 34
 
35
-add_action( 'admin_notices', 'wordpoints_points_admin_notices' );
35
+add_action('admin_notices', 'wordpoints_points_admin_notices');
36 36
 
37
-add_action( 'wp_ajax_wordpoints-points-hooks-order', 'wordpoints_ajax_points_hooks_order' );
38
-add_action( 'wp_ajax_save-wordpoints-points-hook', 'wordpoints_ajax_save_points_hook' );
37
+add_action('wp_ajax_wordpoints-points-hooks-order', 'wordpoints_ajax_points_hooks_order');
38
+add_action('wp_ajax_save-wordpoints-points-hook', 'wordpoints_ajax_save_points_hook');
39 39
 
40 40
 // EOF
Please login to merge, or discard this patch.
src/components/points/admin/includes/ajax.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -16,61 +16,61 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function wordpoints_ajax_points_hooks_order() {
18 18
 
19
-	if ( check_ajax_referer( 'save-network-wordpoints-points-hooks', 'savehooks', false ) ) {
19
+	if (check_ajax_referer('save-network-wordpoints-points-hooks', 'savehooks', false)) {
20 20
 
21
-		if ( ! current_user_can( 'manage_network_wordpoints_points_hooks' ) ) {
22
-			wp_die( -1, '', array( 'response' => 403 ) );
21
+		if ( ! current_user_can('manage_network_wordpoints_points_hooks')) {
22
+			wp_die( -1, '', array('response' => 403) );
23 23
 		}
24 24
 
25 25
 		// Saving network hooks order, turn on network mode.
26
-		WordPoints_Points_Hooks::set_network_mode( true );
26
+		WordPoints_Points_Hooks::set_network_mode(true);
27 27
 
28
-	} elseif ( check_ajax_referer( 'save-wordpoints-points-hooks', 'savehooks', false ) ) {
28
+	} elseif (check_ajax_referer('save-wordpoints-points-hooks', 'savehooks', false)) {
29 29
 
30
-		if ( ! current_user_can( 'manage_options' ) ) {
31
-			wp_die( -1, '', array( 'response' => 403 ) );
30
+		if ( ! current_user_can('manage_options')) {
31
+			wp_die( -1, '', array('response' => 403) );
32 32
 		}
33 33
 
34 34
 	} else {
35 35
 
36 36
 		// CSRF attack (or, more probably, the user left the browser open too long).
37
-		wp_die( -1, '', array( 'response' => 403 ) );
37
+		wp_die( -1, '', array('response' => 403) );
38 38
 	}
39 39
 
40 40
 	// Save hooks order for all points types.
41
-	if ( ! isset( $_POST['points_types'] ) || ! is_array( $_POST['points_types'] ) ) {
42
-		wp_die( -1, '', array( 'response' => 400 ) );
41
+	if ( ! isset($_POST['points_types']) || ! is_array($_POST['points_types'])) {
42
+		wp_die( -1, '', array('response' => 400) );
43 43
 	}
44 44
 
45 45
 	$points_types_hooks = array();
46 46
 
47
-	foreach ( array_keys( wordpoints_get_points_types() ) as $points_type ) {
47
+	foreach (array_keys(wordpoints_get_points_types()) as $points_type) {
48 48
 
49
-		if ( empty( $_POST['points_types'][ $points_type ] ) ) {
49
+		if (empty($_POST['points_types'][$points_type])) {
50 50
 			continue;
51 51
 		}
52 52
 
53
-		$hooks = sanitize_text_field( wp_unslash( $_POST['points_types'][ $points_type ] ) );
53
+		$hooks = sanitize_text_field(wp_unslash($_POST['points_types'][$points_type]));
54 54
 
55 55
 		$points_type_hooks = array();
56 56
 
57
-		$hooks = explode( ',', $hooks );
57
+		$hooks = explode(',', $hooks);
58 58
 
59
-		foreach ( $hooks as $order => $hook_id ) {
59
+		foreach ($hooks as $order => $hook_id) {
60 60
 
61
-			if ( false === strpos( $hook_id, 'hook-' ) ) {
61
+			if (false === strpos($hook_id, 'hook-')) {
62 62
 				continue;
63 63
 			}
64 64
 
65
-			$points_type_hooks[ $order ] = substr( $hook_id, strpos( $hook_id, '_' ) + 1 );
65
+			$points_type_hooks[$order] = substr($hook_id, strpos($hook_id, '_') + 1);
66 66
 		}
67 67
 
68
-		$points_types_hooks[ $points_type ] = $points_type_hooks;
68
+		$points_types_hooks[$points_type] = $points_type_hooks;
69 69
 	}
70 70
 
71
-	WordPoints_Points_Hooks::save_points_types_hooks( $points_types_hooks );
71
+	WordPoints_Points_Hooks::save_points_types_hooks($points_types_hooks);
72 72
 
73
-	wp_die( 1, '', array( 'response' => 200 ) );
73
+	wp_die(1, '', array('response' => 200));
74 74
 }
75 75
 
76 76
 /**
@@ -83,30 +83,30 @@  discard block
 block discarded – undo
83 83
  */
84 84
 function wordpoints_ajax_save_points_hook() {
85 85
 
86
-	if ( check_ajax_referer( 'save-network-wordpoints-points-hooks', 'savehooks', false ) ) {
86
+	if (check_ajax_referer('save-network-wordpoints-points-hooks', 'savehooks', false)) {
87 87
 
88
-		if ( ! current_user_can( 'manage_network_wordpoints_points_hooks' ) ) {
89
-			wp_die( -1, '', array( 'response' => 403 ) );
88
+		if ( ! current_user_can('manage_network_wordpoints_points_hooks')) {
89
+			wp_die( -1, '', array('response' => 403) );
90 90
 		}
91 91
 
92 92
 		// Saving network hooks, turn on network mode.
93
-		WordPoints_Points_Hooks::set_network_mode( true );
93
+		WordPoints_Points_Hooks::set_network_mode(true);
94 94
 
95
-	} elseif ( check_ajax_referer( 'save-wordpoints-points-hooks', 'savehooks', false ) ) {
95
+	} elseif (check_ajax_referer('save-wordpoints-points-hooks', 'savehooks', false)) {
96 96
 
97
-		if ( ! current_user_can( 'manage_options' ) ) {
98
-			wp_die( -1, '', array( 'response' => 403 ) );
97
+		if ( ! current_user_can('manage_options')) {
98
+			wp_die( -1, '', array('response' => 403) );
99 99
 		}
100 100
 
101 101
 	} else {
102 102
 
103 103
 		// CSRF attack (or, more probably the user left the browser open too long).
104
-		wp_die( -1, '', array( 'response' => 403 ) );
104
+		wp_die( -1, '', array('response' => 403) );
105 105
 	}
106 106
 
107
-	$error = __( 'An error has occurred. Please reload the page and try again.', 'wordpoints' );
107
+	$error = __('An error has occurred. Please reload the page and try again.', 'wordpoints');
108 108
 
109
-	if ( isset( $_POST['points-slug'] ) ) {
109
+	if (isset($_POST['points-slug'])) {
110 110
 
111 111
 		// - We are saving the settings for a points type.
112 112
 
@@ -117,55 +117,55 @@  discard block
 block discarded – undo
117 117
 			, 'Performing CRUD actions on points types using this function is deprecated.'
118 118
 		);
119 119
 
120
-		if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) {
121
-			wp_die( -1, '', array( 'response' => 403 ) );
120
+		if ( ! current_user_can('manage_wordpoints_points_types')) {
121
+			wp_die( -1, '', array('response' => 403) );
122 122
 		}
123 123
 
124 124
 		$settings = array();
125 125
 
126
-		if ( isset( $_POST['points-name'] ) ) {
127
-			$settings['name'] = trim( sanitize_text_field( wp_unslash( $_POST['points-name'] ) ) );
126
+		if (isset($_POST['points-name'])) {
127
+			$settings['name'] = trim(sanitize_text_field(wp_unslash($_POST['points-name'])));
128 128
 		}
129 129
 
130
-		if ( isset( $_POST['points-prefix'] ) ) {
131
-			$settings['prefix'] = ltrim( sanitize_text_field( wp_unslash( $_POST['points-prefix'] ) ) );
130
+		if (isset($_POST['points-prefix'])) {
131
+			$settings['prefix'] = ltrim(sanitize_text_field(wp_unslash($_POST['points-prefix'])));
132 132
 		}
133 133
 
134
-		if ( isset( $_POST['points-suffix'] ) ) {
135
-			$settings['suffix'] = rtrim( sanitize_text_field( wp_unslash( $_POST['points-suffix'] ) ) );
134
+		if (isset($_POST['points-suffix'])) {
135
+			$settings['suffix'] = rtrim(sanitize_text_field(wp_unslash($_POST['points-suffix'])));
136 136
 		}
137 137
 
138
-		$points_type = sanitize_key( $_POST['points-slug'] );
138
+		$points_type = sanitize_key($_POST['points-slug']);
139 139
 
140
-		$old_settings = wordpoints_get_points_type( $points_type );
140
+		$old_settings = wordpoints_get_points_type($points_type);
141 141
 
142
-		if ( false === $old_settings ) {
143
-			wp_die( -1, '', array( 'response' => 200 ) );
142
+		if (false === $old_settings) {
143
+			wp_die( -1, '', array('response' => 200) );
144 144
 		}
145 145
 
146
-		if ( is_array( $old_settings ) ) {
147
-			$settings = array_merge( $old_settings, $settings );
146
+		if (is_array($old_settings)) {
147
+			$settings = array_merge($old_settings, $settings);
148 148
 		}
149 149
 
150
-		if ( ! wordpoints_update_points_type( $points_type, $settings ) ) {
150
+		if ( ! wordpoints_update_points_type($points_type, $settings)) {
151 151
 
152 152
 			// If this fails, show the user a message along with the form.
153
-			echo '<p>' . esc_html__( 'An error has occurred. Please try again.', 'wordpoints' ) . '</p>';
153
+			echo '<p>' . esc_html__('An error has occurred. Please try again.', 'wordpoints') . '</p>';
154 154
 
155
-			WordPoints_Points_Hooks::points_type_form( $points_type, 'none' );
155
+			WordPoints_Points_Hooks::points_type_form($points_type, 'none');
156 156
 		}
157 157
 
158 158
 	} else {
159 159
 
160 160
 		// - We are creating/updating/deleting an instance of a hook.
161 161
 
162
-		if ( ! isset( $_POST['id_base'], $_POST['hook-id'], $_POST['points_type'], $_POST['hook_number'] ) ) {
163
-			wp_die( -1, '', array( 'response' => 400 ) );
162
+		if ( ! isset($_POST['id_base'], $_POST['hook-id'], $_POST['points_type'], $_POST['hook_number'])) {
163
+			wp_die( -1, '', array('response' => 400) );
164 164
 		}
165 165
 
166
-		$id_base        = sanitize_key( $_POST['id_base'] );
167
-		$hook_id        = sanitize_key( $_POST['hook-id'] );
168
-		$points_type_id = sanitize_key( $_POST['points_type'] );
166
+		$id_base        = sanitize_key($_POST['id_base']);
167
+		$hook_id        = sanitize_key($_POST['hook-id']);
168
+		$points_type_id = sanitize_key($_POST['points_type']);
169 169
 		$number         = (int) $_POST['hook_number'];
170 170
 
171 171
 		/*
@@ -174,48 +174,48 @@  discard block
 block discarded – undo
174 174
 		 * created hook, the ID won't have been set when the form was output, so
175 175
 		 * 'hook-id' will be empty, and we'll get the ID from 'multi_number'.
176 176
 		 */
177
-		if ( ! $number ) {
177
+		if ( ! $number) {
178 178
 
179 179
 			// This holds the ID number if the hook is brand new.
180
-			if ( ! isset( $_POST['multi_number'] ) || ! wordpoints_posint( $_POST['multi_number'] ) ) {
181
-				wp_die( '<p>' . esc_html( $error ) . '</p>', '', array( 'response' => 400 ) );
180
+			if ( ! isset($_POST['multi_number']) || ! wordpoints_posint($_POST['multi_number'])) {
181
+				wp_die('<p>' . esc_html($error) . '</p>', '', array('response' => 400));
182 182
 			}
183 183
 
184 184
 			$number  = (int) $_POST['multi_number'];
185 185
 			$hook_id = $id_base . '-' . $number;
186 186
 		}
187 187
 
188
-		$hook = WordPoints_Points_Hooks::get_handler( $hook_id );
188
+		$hook = WordPoints_Points_Hooks::get_handler($hook_id);
189 189
 
190 190
 		$settings = false;
191 191
 
192
-		if ( isset( $_POST[ 'hook-' . $id_base ] ) && is_array( $_POST[ 'hook-' . $id_base ] ) ) {
193
-			$settings = wp_unslash( $_POST[ 'hook-' . $id_base ] ); // WPCS: sanitization OK.
192
+		if (isset($_POST['hook-' . $id_base]) && is_array($_POST['hook-' . $id_base])) {
193
+			$settings = wp_unslash($_POST['hook-' . $id_base]); // WPCS: sanitization OK.
194 194
 		}
195 195
 
196 196
 		$points_types_hooks = WordPoints_Points_Hooks::get_points_types_hooks();
197 197
 
198 198
 		// Get the hooks for this points type.
199
-		$points_type_hooks = ( isset( $points_types_hooks[ $points_type_id ] ) ) ? $points_types_hooks[ $points_type_id ] : array();
199
+		$points_type_hooks = (isset($points_types_hooks[$points_type_id])) ? $points_types_hooks[$points_type_id] : array();
200 200
 
201
-		if ( ! empty( $_POST['delete_hook'] ) ) {
201
+		if ( ! empty($_POST['delete_hook'])) {
202 202
 
203 203
 			// - We are deleting a hook instance.
204 204
 
205
-			if ( false === $hook ) {
206
-				wp_die( '<p>' . esc_html( $error ) . '</p>', '', array( 'response' => 400 ) );
205
+			if (false === $hook) {
206
+				wp_die('<p>' . esc_html($error) . '</p>', '', array('response' => 400));
207 207
 			}
208 208
 
209
-			$hook->delete_callback( $number );
209
+			$hook->delete_callback($number);
210 210
 
211 211
 			// Remove this instance of the hook, and reset the positions (keys).
212
-			$points_types_hooks[ $points_type_id ] = array_diff( $points_type_hooks, array( $hook_id ) );
212
+			$points_types_hooks[$points_type_id] = array_diff($points_type_hooks, array($hook_id));
213 213
 
214
-			WordPoints_Points_Hooks::save_points_types_hooks( $points_types_hooks );
214
+			WordPoints_Points_Hooks::save_points_types_hooks($points_types_hooks);
215 215
 
216
-			wp_die( esc_html( "deleted:{$hook_id}" ), '', array( 'response' => 200 ) );
216
+			wp_die(esc_html("deleted:{$hook_id}"), '', array('response' => 200));
217 217
 
218
-		} elseif ( $settings && false === $hook ) {
218
+		} elseif ($settings && false === $hook) {
219 219
 
220 220
 			// - We are creating a new a new instance of a hook.
221 221
 
@@ -224,36 +224,36 @@  discard block
 block discarded – undo
224 224
 			 * since the hook is new, it hasn't been assigned an ID yet, so we can't
225 225
 			 * just get it from the array of hooks by ID.
226 226
 			 */
227
-			$hook = WordPoints_Points_Hooks::get_handler_by_id_base( $id_base );
227
+			$hook = WordPoints_Points_Hooks::get_handler_by_id_base($id_base);
228 228
 
229
-			$new_instance = reset( $settings );
229
+			$new_instance = reset($settings);
230 230
 
231 231
 			// Save the points types-hooks associations.
232
-			$points_type_hooks[] = $hook->get_id( $number );
233
-			$points_types_hooks[ $points_type_id ] = $points_type_hooks;
234
-			WordPoints_Points_Hooks::save_points_types_hooks( $points_types_hooks );
232
+			$points_type_hooks[] = $hook->get_id($number);
233
+			$points_types_hooks[$points_type_id] = $points_type_hooks;
234
+			WordPoints_Points_Hooks::save_points_types_hooks($points_types_hooks);
235 235
 
236 236
 		} else {
237 237
 
238 238
 			// - We are updating the settings for an instance of a hook.
239 239
 
240
-			if ( false === $hook ) {
241
-				wp_die( '<p>' . esc_html( $error ) . '</p>', '', array( 'response' => 400 ) );
240
+			if (false === $hook) {
241
+				wp_die('<p>' . esc_html($error) . '</p>', '', array('response' => 400));
242 242
 			}
243 243
 
244
-			$new_instance = ( ! empty( $settings ) ) ? reset( $settings ) : array();
244
+			$new_instance = ( ! empty($settings)) ? reset($settings) : array();
245 245
 
246 246
 		} // End if ( deleting ) elseif ( creating ) else { updating }.
247 247
 
248
-		$hook->update_callback( wp_unslash( $new_instance ), $number );
248
+		$hook->update_callback(wp_unslash($new_instance), $number);
249 249
 
250
-		if ( empty( $_POST['add_new'] ) ) {
251
-			$hook->form_callback( $number );
250
+		if (empty($_POST['add_new'])) {
251
+			$hook->form_callback($number);
252 252
 		}
253 253
 
254 254
 	} // End if ( saving points type ) else { deleting/creation/updating hook }.
255 255
 
256
-	wp_die( '', '', array( 'response' => 200 ) );
256
+	wp_die('', '', array('response' => 200));
257 257
 }
258 258
 
259 259
 // EOF
Please login to merge, or discard this patch.