Completed
Push — master ( e7ef90...760553 )
by J.D.
03:28
created
src/includes/apps.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wordpoints_apps() {
22 22
 
23
-	if ( ! isset( WordPoints_App::$main ) ) {
24
-		WordPoints_App::$main = new WordPoints_App( 'apps' );
23
+	if ( ! isset(WordPoints_App::$main)) {
24
+		WordPoints_App::$main = new WordPoints_App('apps');
25 25
 	}
26 26
 
27 27
 	return WordPoints_App::$main;
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
  *
37 37
  * @param WordPoints_App $app The main apps app.
38 38
  */
39
-function wordpoints_apps_init( $app ) {
39
+function wordpoints_apps_init($app) {
40 40
 
41 41
 	$apps = $app->sub_apps();
42 42
 
43
-	$apps->register( 'hooks', 'WordPoints_Hooks' );
44
-	$apps->register( 'entities', 'WordPoints_App_Registry' );
45
-	$apps->register( 'data_types', 'WordPoints_Class_Registry' );
46
-	$apps->register( 'components', 'WordPoints_App' );
47
-	$apps->register( 'modules', 'WordPoints_App' );
43
+	$apps->register('hooks', 'WordPoints_Hooks');
44
+	$apps->register('entities', 'WordPoints_App_Registry');
45
+	$apps->register('data_types', 'WordPoints_Class_Registry');
46
+	$apps->register('components', 'WordPoints_App');
47
+	$apps->register('modules', 'WordPoints_App');
48 48
 }
49 49
 
50 50
 /**
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
  * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the
64 64
  *               slug is not dynamic, the value of each of those keys will be false.
65 65
  */
66
-function wordpoints_parse_dynamic_slug( $slug ) {
66
+function wordpoints_parse_dynamic_slug($slug) {
67 67
 
68
-	$parsed = array( 'dynamic' => false, 'generic' => false );
68
+	$parsed = array('dynamic' => false, 'generic' => false);
69 69
 
70
-	$parts = explode( '\\', $slug, 2 );
70
+	$parts = explode('\\', $slug, 2);
71 71
 
72
-	if ( isset( $parts[1] ) ) {
72
+	if (isset($parts[1])) {
73 73
 		$parsed['dynamic'] = $parts[1];
74 74
 		$parsed['generic'] = $parts[0];
75 75
 	}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function wordpoints_get_post_types_for_auto_integration() {
88 88
 
89
-	$post_types = get_post_types( array( 'public' => true ) );
89
+	$post_types = get_post_types(array('public' => true));
90 90
 
91 91
 	/**
92 92
 	 * Filter which post types to automatically integrate with.
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @param string[] $post_types The post type slugs ("names").
97 97
 	 */
98
-	return apply_filters( 'wordpoints_post_types_for_auto_integration', $post_types );
98
+	return apply_filters('wordpoints_post_types_for_auto_integration', $post_types);
99 99
 }
100 100
 
101 101
 //
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
  *
112 112
  * @return false|WordPoints_App The component's app.
113 113
  */
114
-function wordpoints_component( $slug ) {
114
+function wordpoints_component($slug) {
115 115
 
116
-	if ( ! isset( WordPoints_App::$main ) ) {
116
+	if ( ! isset(WordPoints_App::$main)) {
117 117
 		wordpoints_apps();
118 118
 	}
119 119
 
120
-	return WordPoints_App::$main->get_sub_app( 'components' )->get_sub_app( $slug );
120
+	return WordPoints_App::$main->get_sub_app('components')->get_sub_app($slug);
121 121
 }
122 122
 
123 123
 //
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
  *
134 134
  * @return false|WordPoints_App The module's app.
135 135
  */
136
-function wordpoints_module( $slug ) {
136
+function wordpoints_module($slug) {
137 137
 
138
-	if ( ! isset( WordPoints_App::$main ) ) {
138
+	if ( ! isset(WordPoints_App::$main)) {
139 139
 		wordpoints_apps();
140 140
 	}
141 141
 
142
-	return WordPoints_App::$main->get_sub_app( 'modules' )->get_sub_app( $slug );
142
+	return WordPoints_App::$main->get_sub_app('modules')->get_sub_app($slug);
143 143
 }
144 144
 
145 145
 //
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
  */
156 156
 function wordpoints_entities() {
157 157
 
158
-	if ( ! isset( WordPoints_App::$main ) ) {
158
+	if ( ! isset(WordPoints_App::$main)) {
159 159
 		wordpoints_apps();
160 160
 	}
161 161
 
162
-	return WordPoints_App::$main->get_sub_app( 'entities' );
162
+	return WordPoints_App::$main->get_sub_app('entities');
163 163
 }
164 164
 
165 165
 /**
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
  *
172 172
  * @param WordPoints_App_Registry $entities The entities app.
173 173
  */
174
-function wordpoints_entities_app_init( $entities ) {
174
+function wordpoints_entities_app_init($entities) {
175 175
 
176 176
 	$sub_apps = $entities->sub_apps();
177
-	$sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' );
178
-	$sub_apps->register( 'contexts', 'WordPoints_Entity_Contexts' );
179
-	$sub_apps->register( 'restrictions', 'WordPoints_Entity_Restrictions' );
177
+	$sub_apps->register('children', 'WordPoints_Class_Registry_Children');
178
+	$sub_apps->register('contexts', 'WordPoints_Entity_Contexts');
179
+	$sub_apps->register('restrictions', 'WordPoints_Entity_Restrictions');
180 180
 }
181 181
 
182 182
 /**
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
  *
189 189
  * @param WordPoints_Class_RegistryI $contexts The entity context registry.
190 190
  */
191
-function wordpoints_entity_contexts_init( $contexts ) {
191
+function wordpoints_entity_contexts_init($contexts) {
192 192
 
193
-	$contexts->register( 'network', 'WordPoints_Entity_Context_Network' );
194
-	$contexts->register( 'site', 'WordPoints_Entity_Context_Site' );
193
+	$contexts->register('network', 'WordPoints_Entity_Context_Network');
194
+	$contexts->register('site', 'WordPoints_Entity_Context_Site');
195 195
 }
196 196
 
197 197
 /**
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
  *
204 204
  * @param WordPoints_App $restrictions The entity restrictions app.
205 205
  */
206
-function wordpoints_entities_restrictions_app_init( $restrictions ) {
206
+function wordpoints_entities_restrictions_app_init($restrictions) {
207 207
 
208 208
 	$sub_apps = $restrictions->sub_apps();
209
-	$sub_apps->register( 'know', 'WordPoints_Class_Registry_Deep_Multilevel_Slugless' );
210
-	$sub_apps->register( 'view', 'WordPoints_Class_Registry_Deep_Multilevel_Slugless' );
209
+	$sub_apps->register('know', 'WordPoints_Class_Registry_Deep_Multilevel_Slugless');
210
+	$sub_apps->register('view', 'WordPoints_Class_Registry_Deep_Multilevel_Slugless');
211 211
 }
212 212
 
213 213
 /**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
  * @param WordPoints_Class_Registry_Deep_Multilevel $restrictions The restrictions
224 224
  *                                                                registry.
225 225
  */
226
-function wordpoints_entity_restrictions_know_init( $restrictions ) {
226
+function wordpoints_entity_restrictions_know_init($restrictions) {
227 227
 
228 228
 	$restrictions->register(
229 229
 		'unregistered'
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
 		, 'WordPoints_Entity_Restriction_Legacy'
238 238
 	);
239 239
 
240
-	foreach ( wordpoints_get_post_types_for_entities() as $slug ) {
240
+	foreach (wordpoints_get_post_types_for_entities() as $slug) {
241 241
 
242 242
 		$restrictions->register(
243 243
 			'status_nonpublic'
244
-			, array( "post\\$slug" )
244
+			, array("post\\$slug")
245 245
 			, 'WordPoints_Entity_Restriction_Post_Status_Nonpublic'
246 246
 		);
247 247
 
248 248
 		$restrictions->register(
249 249
 			'post_status_nonpublic'
250
-			, array( "comment\\$slug" )
250
+			, array("comment\\$slug")
251 251
 			, 'WordPoints_Entity_Restriction_Comment_Post_Status_Nonpublic'
252 252
 		);
253 253
 	}
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
  * @param WordPoints_Class_Registry_Deep_Multilevel $restrictions The restrictions
264 264
  *                                                                registry.
265 265
  */
266
-function wordpoints_entity_restrictions_view_init( $restrictions ) {
266
+function wordpoints_entity_restrictions_view_init($restrictions) {
267 267
 
268
-	foreach ( wordpoints_get_post_types_for_entities() as $slug ) {
268
+	foreach (wordpoints_get_post_types_for_entities() as $slug) {
269 269
 
270 270
 		$restrictions->register(
271 271
 			'password_protected'
272
-			, array( "post\\$slug", 'content' )
272
+			, array("post\\$slug", 'content')
273 273
 			, 'WordPoints_Entity_Restriction_View_Post_Content_Password_Protected'
274 274
 		);
275 275
 	}
@@ -284,21 +284,21 @@  discard block
 block discarded – undo
284 284
  *
285 285
  * @param WordPoints_App_Registry $entities The entities app.
286 286
  */
287
-function wordpoints_entities_init( $entities ) {
287
+function wordpoints_entities_init($entities) {
288 288
 
289
-	$children = $entities->get_sub_app( 'children' );
289
+	$children = $entities->get_sub_app('children');
290 290
 
291
-	$entities->register( 'user', 'WordPoints_Entity_User' );
292
-	$children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' );
291
+	$entities->register('user', 'WordPoints_Entity_User');
292
+	$children->register('user', 'roles', 'WordPoints_Entity_User_Roles');
293 293
 
294
-	$entities->register( 'user_role', 'WordPoints_Entity_User_Role' );
294
+	$entities->register('user_role', 'WordPoints_Entity_User_Role');
295 295
 
296
-	foreach ( wordpoints_get_post_types_for_entities() as $slug ) {
297
-		wordpoints_register_post_type_entities( $slug );
296
+	foreach (wordpoints_get_post_types_for_entities() as $slug) {
297
+		wordpoints_register_post_type_entities($slug);
298 298
 	}
299 299
 
300 300
 	// Also register entities for any post types that are late to the party.
301
-	add_action( 'registered_post_type', 'wordpoints_register_post_type_entities' );
301
+	add_action('registered_post_type', 'wordpoints_register_post_type_entities');
302 302
 }
303 303
 
304 304
 /**
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 *
320 320
 	 * @param string[] $post_types The post type slugs ("names").
321 321
 	 */
322
-	return apply_filters( 'wordpoints_register_entities_for_post_types', $post_types );
322
+	return apply_filters('wordpoints_register_entities_for_post_types', $post_types);
323 323
 }
324 324
 
325 325
 /**
@@ -331,24 +331,24 @@  discard block
 block discarded – undo
331 331
  *
332 332
  * @param string $slug The slug of the post type.
333 333
  */
334
-function wordpoints_register_post_type_entities( $slug ) {
334
+function wordpoints_register_post_type_entities($slug) {
335 335
 
336 336
 	$entities = wordpoints_entities();
337
-	$children = $entities->get_sub_app( 'children' );
337
+	$children = $entities->get_sub_app('children');
338 338
 
339
-	$entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' );
340
-	$children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' );
339
+	$entities->register("post\\{$slug}", 'WordPoints_Entity_Post');
340
+	$children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author');
341 341
 
342
-	$supports = get_all_post_type_supports( $slug );
342
+	$supports = get_all_post_type_supports($slug);
343 343
 
344
-	if ( isset( $supports['editor'] ) ) {
345
-		$children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' );
344
+	if (isset($supports['editor'])) {
345
+		$children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content');
346 346
 	}
347 347
 
348
-	if ( isset( $supports['comments'] ) ) {
349
-		$entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' );
350
-		$children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' );
351
-		$children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' );
348
+	if (isset($supports['comments'])) {
349
+		$entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment');
350
+		$children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post');
351
+		$children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author');
352 352
 	}
353 353
 
354 354
 	/**
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @param string $slug The slug ("name") of the post type.
360 360
 	 */
361
-	do_action( 'wordpoints_register_post_type_entities', $slug );
361
+	do_action('wordpoints_register_post_type_entities', $slug);
362 362
 }
363 363
 
364 364
 /**
@@ -373,12 +373,12 @@  discard block
 block discarded – undo
373 373
  *
374 374
  * @return bool Whether the user can view this entity.
375 375
  */
376
-function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) {
376
+function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) {
377 377
 
378 378
 	/** @var WordPoints_Entity_Restrictions $restrictions */
379
-	$restrictions = wordpoints_entities()->get_sub_app( 'restrictions' );
380
-	$restriction = $restrictions->get( $entity_id, $entity_slug, 'view' );
381
-	return $restriction->user_can( $user_id );
379
+	$restrictions = wordpoints_entities()->get_sub_app('restrictions');
380
+	$restriction = $restrictions->get($entity_id, $entity_slug, 'view');
381
+	return $restriction->user_can($user_id);
382 382
 }
383 383
 
384 384
 /**
@@ -412,28 +412,28 @@  discard block
 block discarded – undo
412 412
  *                     contexts, indexed by context slug, or false if any of the
413 413
  *                     contexts isn't current.
414 414
  */
415
-function wordpoints_entities_get_current_context_id( $slug ) {
415
+function wordpoints_entities_get_current_context_id($slug) {
416 416
 
417 417
 	$current_context = array();
418 418
 
419 419
 	/** @var WordPoints_Class_Registry $contexts */
420
-	$contexts = wordpoints_entities()->get_sub_app( 'contexts' );
420
+	$contexts = wordpoints_entities()->get_sub_app('contexts');
421 421
 
422
-	while ( $slug ) {
422
+	while ($slug) {
423 423
 
424
-		$context = $contexts->get( $slug );
424
+		$context = $contexts->get($slug);
425 425
 
426
-		if ( ! $context instanceof WordPoints_Entity_Context ) {
426
+		if ( ! $context instanceof WordPoints_Entity_Context) {
427 427
 			return false;
428 428
 		}
429 429
 
430 430
 		$id = $context->get_current_id();
431 431
 
432
-		if ( false === $id ) {
432
+		if (false === $id) {
433 433
 			return false;
434 434
 		}
435 435
 
436
-		$current_context[ $slug ] = $id;
436
+		$current_context[$slug] = $id;
437 437
 
438 438
 		$slug = $context->get_parent_slug();
439 439
 	}
@@ -454,22 +454,22 @@  discard block
 block discarded – undo
454 454
  */
455 455
 function wordpoints_is_network_context() {
456 456
 
457
-	if ( ! is_multisite() ) {
457
+	if ( ! is_multisite()) {
458 458
 		return false;
459 459
 	}
460 460
 
461
-	if ( is_network_admin() ) {
461
+	if (is_network_admin()) {
462 462
 		return true;
463 463
 	}
464 464
 
465 465
 	// See https://core.trac.wordpress.org/ticket/22589
466 466
 	if (
467
-		defined( 'DOING_AJAX' )
467
+		defined('DOING_AJAX')
468 468
 		&& DOING_AJAX
469
-		&& isset( $_SERVER['HTTP_REFERER'] )
469
+		&& isset($_SERVER['HTTP_REFERER'])
470 470
 		&& preg_match(
471
-			'#^' . preg_quote( network_admin_url(), '#' ) . '#i'
472
-			, esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) )
471
+			'#^' . preg_quote(network_admin_url(), '#') . '#i'
472
+			, esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER']))
473 473
 		)
474 474
 	) {
475 475
 		return true;
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 	 *
483 483
 	 * @param bool $in_network_context Whether we are in network context.
484 484
 	 */
485
-	return apply_filters( 'wordpoints_is_network_context', false );
485
+	return apply_filters('wordpoints_is_network_context', false);
486 486
 }
487 487
 
488 488
 //
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
  *
499 499
  * @param WordPoints_Class_RegistryI $data_types The data types registry.
500 500
  */
501
-function wordpoints_data_types_init( $data_types ) {
501
+function wordpoints_data_types_init($data_types) {
502 502
 
503
-	$data_types->register( 'integer', 'WordPoints_Data_Type_Integer' );
504
-	$data_types->register( 'text', 'WordPoints_Data_Type_Text' );
503
+	$data_types->register('integer', 'WordPoints_Data_Type_Integer');
504
+	$data_types->register('text', 'WordPoints_Data_Type_Text');
505 505
 }
506 506
 
507 507
 // EOF
Please login to merge, or discard this patch.
src/includes/hooks.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function wordpoints_hooks() {
18 18
 
19
-	if ( ! isset( WordPoints_App::$main ) ) {
19
+	if ( ! isset(WordPoints_App::$main)) {
20 20
 		wordpoints_apps();
21 21
 	}
22 22
 
23
-	return WordPoints_App::$main->get_sub_app( 'hooks' );
23
+	return WordPoints_App::$main->get_sub_app('hooks');
24 24
 }
25 25
 
26 26
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	// Just accessing this causes it to be initialized. We need to do that so
38 38
 	// the actions will be registered and hooked up. The rest of the API can be
39 39
 	// lazy-loaded as it is needed.
40
-	$hooks->get_sub_app( 'actions' );
40
+	$hooks->get_sub_app('actions');
41 41
 }
42 42
 
43 43
 /**
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
  *
50 50
  * @param WordPoints_Class_Registry_Persistent $extensions The extension registry.
51 51
  */
52
-function wordpoints_hook_extensions_init( $extensions ) {
52
+function wordpoints_hook_extensions_init($extensions) {
53 53
 
54
-	$extensions->register( 'blocker', 'WordPoints_Hook_Extension_Blocker' );
55
-	$extensions->register( 'repeat_blocker', 'WordPoints_Hook_Extension_Repeat_Blocker' );
56
-	$extensions->register( 'reversals', 'WordPoints_Hook_Extension_Reversals' );
57
-	$extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' );
58
-	$extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' );
54
+	$extensions->register('blocker', 'WordPoints_Hook_Extension_Blocker');
55
+	$extensions->register('repeat_blocker', 'WordPoints_Hook_Extension_Repeat_Blocker');
56
+	$extensions->register('reversals', 'WordPoints_Hook_Extension_Reversals');
57
+	$extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions');
58
+	$extensions->register('periods', 'WordPoints_Hook_Extension_Periods');
59 59
 }
60 60
 
61 61
 /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @param WordPoints_Class_Registry_Children $conditions The conditions registry.
69 69
  */
70
-function wordpoints_hook_conditions_init( $conditions ) {
70
+function wordpoints_hook_conditions_init($conditions) {
71 71
 
72 72
 	$conditions->register(
73 73
 		'text'
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
  *
104 104
  * @param WordPoints_Hook_Actions $actions The action registry.
105 105
  */
106
-function wordpoints_hook_actions_init( $actions ) {
106
+function wordpoints_hook_actions_init($actions) {
107 107
 
108 108
 	$actions->register(
109 109
 		'user_register'
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		, array(
112 112
 			'action' => 'user_register',
113 113
 			'data'   => array(
114
-				'arg_index' => array( 'user' => 0 ),
114
+				'arg_index' => array('user' => 0),
115 115
 			),
116 116
 		)
117 117
 	);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		, array(
123 123
 			'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user',
124 124
 			'data'   => array(
125
-				'arg_index' => array( 'user' => 0 ),
125
+				'arg_index' => array('user' => 0),
126 126
 			),
127 127
 		)
128 128
 	);
@@ -148,17 +148,17 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	$post_types = apply_filters_deprecated(
150 150
 		'wordpoints_register_hook_actions_for_post_types'
151
-		, array( $post_types )
151
+		, array($post_types)
152 152
 		, '2.2.0'
153 153
 		, 'wordpoints_register_hook_events_for_post_types'
154 154
 	);
155 155
 
156
-	foreach ( $post_types as $slug ) {
157
-		wordpoints_register_post_type_hook_actions( $slug );
156
+	foreach ($post_types as $slug) {
157
+		wordpoints_register_post_type_hook_actions($slug);
158 158
 	}
159 159
 
160 160
 	// Also register actions for any post types that are late to the party.
161
-	add_action( 'registered_post_type', 'wordpoints_register_post_type_hook_actions' );
161
+	add_action('registered_post_type', 'wordpoints_register_post_type_hook_actions');
162 162
 }
163 163
 
164 164
 /**
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @param string $slug The slug of the post type.
172 172
  */
173
-function wordpoints_register_post_type_hook_actions( $slug ) {
173
+function wordpoints_register_post_type_hook_actions($slug) {
174 174
 
175
-	$actions = wordpoints_hooks()->get_sub_app( 'actions' );
175
+	$actions = wordpoints_hooks()->get_sub_app('actions');
176 176
 
177
-	if ( post_type_supports( $slug, 'comments' ) ) {
177
+	if (post_type_supports($slug, 'comments')) {
178 178
 
179 179
 		$actions->register(
180 180
 			"comment_approve\\{$slug}"
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 			, array(
183 183
 				'action' => 'transition_comment_status',
184 184
 				'data'   => array(
185
-					'arg_index'    => array( "comment\\{$slug}" => 2 ),
186
-					'requirements' => array( 0 => 'approved' ),
185
+					'arg_index'    => array("comment\\{$slug}" => 2),
186
+					'requirements' => array(0 => 'approved'),
187 187
 				),
188 188
 			)
189 189
 		);
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 			, array(
195 195
 				'action' => 'wp_insert_comment',
196 196
 				'data'   => array(
197
-					'arg_index' => array( "comment\\{$slug}" => 1 ),
197
+					'arg_index' => array("comment\\{$slug}" => 1),
198 198
 				),
199 199
 			)
200 200
 		);
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 			, array(
206 206
 				'action' => 'transition_comment_status',
207 207
 				'data'   => array(
208
-					'arg_index'    => array( "comment\\{$slug}" => 2 ),
209
-					'requirements' => array( 1 => 'approved' ),
208
+					'arg_index'    => array("comment\\{$slug}" => 2),
209
+					'requirements' => array(1 => 'approved'),
210 210
 				),
211 211
 			)
212 212
 		);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	} // End if ( post type supports comments ).
215 215
 
216 216
 	// This works for all post types except attachments.
217
-	if ( 'attachment' !== $slug ) {
217
+	if ('attachment' !== $slug) {
218 218
 
219 219
 		$actions->register(
220 220
 			"post_publish\\{$slug}"
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
 			, array(
223 223
 				'action' => 'transition_post_status',
224 224
 				'data'   => array(
225
-					'arg_index'    => array( "post\\{$slug}" => 2 ),
225
+					'arg_index'    => array("post\\{$slug}" => 2),
226 226
 					'requirements' => array(
227 227
 						0 => 'publish',
228
-						1 => array( 'comparator' => '!=', 'value' => 'publish' ),
228
+						1 => array('comparator' => '!=', 'value' => 'publish'),
229 229
 					),
230 230
 				),
231 231
 			)
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 			, array(
238 238
 				'action' => 'transition_post_status',
239 239
 				'data'   => array(
240
-					'arg_index'    => array( "post\\{$slug}" => 2 ),
240
+					'arg_index'    => array("post\\{$slug}" => 2),
241 241
 					'requirements' => array(
242
-						0 => array( 'comparator' => '!=', 'value' => 'publish' ),
242
+						0 => array('comparator' => '!=', 'value' => 'publish'),
243 243
 						1 => 'publish',
244 244
 					),
245 245
 				),
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			, array(
253 253
 				'action' => 'delete_post',
254 254
 				'data'   => array(
255
-					'arg_index' => array( "post\\{$slug}" => 0 ),
255
+					'arg_index' => array("post\\{$slug}" => 0),
256 256
 				),
257 257
 			)
258 258
 		);
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 			, array(
266 266
 				'action' => 'add_attachment',
267 267
 				'data'   => array(
268
-					'arg_index' => array( 'post\attachment' => 0 ),
268
+					'arg_index' => array('post\attachment' => 0),
269 269
 				),
270 270
 			)
271 271
 		);
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		, array(
279 279
 			'action' => 'delete_post',
280 280
 			'data'   => array(
281
-				'arg_index' => array( "post\\{$slug}" => 0 ),
281
+				'arg_index' => array("post\\{$slug}" => 0),
282 282
 			),
283 283
 		)
284 284
 	);
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 *
291 291
 	 * @param string $slug The slug ("name") of the post type.
292 292
 	 */
293
-	do_action( 'wordpoints_register_post_type_hook_actions', $slug );
293
+	do_action('wordpoints_register_post_type_hook_actions', $slug);
294 294
 }
295 295
 
296 296
 /**
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
  *
303 303
  * @param WordPoints_Hook_Events $events The event registry.
304 304
  */
305
-function wordpoints_hook_events_init( $events ) {
305
+function wordpoints_hook_events_init($events) {
306 306
 
307 307
 	$events->register(
308 308
 		'user_register'
@@ -331,12 +331,12 @@  discard block
 block discarded – undo
331 331
 		)
332 332
 	);
333 333
 
334
-	foreach ( wordpoints_get_post_types_for_hook_events() as $slug ) {
335
-		wordpoints_register_post_type_hook_events( $slug );
334
+	foreach (wordpoints_get_post_types_for_hook_events() as $slug) {
335
+		wordpoints_register_post_type_hook_events($slug);
336 336
 	}
337 337
 
338 338
 	// Also register events for any post types that are late to the party.
339
-	add_action( 'registered_post_type', 'wordpoints_register_post_type_hook_events' );
339
+	add_action('registered_post_type', 'wordpoints_register_post_type_hook_events');
340 340
 }
341 341
 
342 342
 /**
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
  *
371 371
  * @param string $slug The slug of the post type.
372 372
  */
373
-function wordpoints_register_post_type_hook_events( $slug ) {
373
+function wordpoints_register_post_type_hook_events($slug) {
374 374
 
375
-	$events = wordpoints_hooks()->get_sub_app( 'events' );
375
+	$events = wordpoints_hooks()->get_sub_app('events');
376 376
 
377
-	if ( 'attachment' === $slug ) {
377
+	if ('attachment' === $slug) {
378 378
 
379 379
 		$events->register(
380 380
 			'media_upload'
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 		);
411 411
 	}
412 412
 
413
-	if ( post_type_supports( $slug, 'comments' ) ) {
413
+	if (post_type_supports($slug, 'comments')) {
414 414
 
415 415
 		$events->register(
416 416
 			"comment_leave\\{$slug}"
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 *
438 438
 	 * @param string $slug The slug ("name") of the post type.
439 439
 	 */
440
-	do_action( 'wordpoints_register_post_type_hook_events', $slug );
440
+	do_action('wordpoints_register_post_type_hook_events', $slug);
441 441
 }
442 442
 
443 443
 /**
@@ -451,36 +451,36 @@  discard block
 block discarded – undo
451 451
  *
452 452
  * @return string The signature arg(s)'s GUID(s), JSON encoded.
453 453
  */
454
-function wordpoints_hooks_get_event_signature_arg_guids_json( WordPoints_Hook_Event_Args $event_args ) {
454
+function wordpoints_hooks_get_event_signature_arg_guids_json(WordPoints_Hook_Event_Args $event_args) {
455 455
 
456 456
 	$entities = $event_args->get_signature_args();
457 457
 
458
-	if ( ! $entities ) {
458
+	if ( ! $entities) {
459 459
 		return '';
460 460
 	}
461 461
 
462 462
 	$the_guids = array();
463 463
 
464
-	foreach ( $entities as $arg_slug => $entity ) {
464
+	foreach ($entities as $arg_slug => $entity) {
465 465
 
466 466
 		$the_guid = $entity->get_the_guid();
467 467
 
468
-		if ( $the_guid ) {
469
-			$the_guids[ $arg_slug ] = $the_guid;
468
+		if ($the_guid) {
469
+			$the_guids[$arg_slug] = $the_guid;
470 470
 		}
471 471
 	}
472 472
 
473
-	if ( ! $the_guids ) {
473
+	if ( ! $the_guids) {
474 474
 		return '';
475 475
 	}
476 476
 
477
-	if ( 1 === count( $the_guids ) ) {
478
-		$the_guids = reset( $the_guids );
477
+	if (1 === count($the_guids)) {
478
+		$the_guids = reset($the_guids);
479 479
 	} else {
480
-		ksort( $the_guids );
480
+		ksort($the_guids);
481 481
 	}
482 482
 
483
-	return wp_json_encode( $the_guids );
483
+	return wp_json_encode($the_guids);
484 484
 }
485 485
 
486 486
 /**
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
  *
496 496
  * @return string The primary arg's GUID, JSON encoded.
497 497
  */
498
-function wordpoints_hooks_get_event_primary_arg_guid_json( WordPoints_Hook_Event_Args $event_args ) {
498
+function wordpoints_hooks_get_event_primary_arg_guid_json(WordPoints_Hook_Event_Args $event_args) {
499 499
 
500 500
 	_deprecated_function(
501 501
 		__FUNCTION__
@@ -505,17 +505,17 @@  discard block
 block discarded – undo
505 505
 
506 506
 	$entity = $event_args->get_primary_arg();
507 507
 
508
-	if ( ! $entity ) {
508
+	if ( ! $entity) {
509 509
 		return '';
510 510
 	}
511 511
 
512 512
 	$the_guid = $entity->get_the_guid();
513 513
 
514
-	if ( ! $the_guid ) {
514
+	if ( ! $the_guid) {
515 515
 		return '';
516 516
 	}
517 517
 
518
-	return wp_json_encode( $the_guid );
518
+	return wp_json_encode($the_guid);
519 519
 }
520 520
 
521 521
 // EOF
Please login to merge, or discard this patch.
src/includes/class-widget.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @deprecated 2.3.0
9 9
  */
10 10
 
11
-_deprecated_file( __FILE__, '2.3.0', 'classes/widget.php' );
11
+_deprecated_file(__FILE__, '2.3.0', 'classes/widget.php');
12 12
 
13 13
 /**
14 14
  * The widget class.
Please login to merge, or discard this patch.
src/includes/class-wordpoints-components.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public static function set_up() {
92 92
 
93
-		if ( isset( self::$instance ) ) {
93
+		if (isset(self::$instance)) {
94 94
 			return;
95 95
 		}
96 96
 
97 97
 		self::$instance = new WordPoints_Components();
98 98
 
99
-		add_action( 'plugins_loaded', array( self::$instance, 'load' ) );
99
+		add_action('plugins_loaded', array(self::$instance, 'load'));
100 100
 	}
101 101
 
102 102
 	/**
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
 		 * @since 1.0.0
135 135
 		 * @since 1.7.0 The components' code isn't loaded until after this hook.
136 136
 		 */
137
-		do_action( 'wordpoints_components_register' );
137
+		do_action('wordpoints_components_register');
138 138
 
139
-		foreach ( $this->get() as $component ) {
139
+		foreach ($this->get() as $component) {
140 140
 
141
-			if ( ! $this->is_active( $component['slug'] ) ) {
141
+			if ( ! $this->is_active($component['slug'])) {
142 142
 				continue;
143 143
 			}
144 144
 
145
-			include_once( $component['file'] );
145
+			include_once($component['file']);
146 146
 		}
147 147
 
148 148
 		/**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		 *
151 151
 		 * @since 1.0.0
152 152
 		 */
153
-		do_action( 'wordpoints_components_loaded' );
153
+		do_action('wordpoints_components_loaded');
154 154
 	}
155 155
 
156 156
 	/**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function get() {
167 167
 
168
-		if ( ! isset( $this->registered ) ) {
168
+		if ( ! isset($this->registered)) {
169 169
 			return false;
170 170
 		}
171 171
 
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return array|false The component, or false if it isn't registered.
183 183
 	 */
184
-	public function get_component( $slug ) {
184
+	public function get_component($slug) {
185 185
 
186
-		if ( ! isset( $this->registered[ $slug ] ) ) {
186
+		if ( ! isset($this->registered[$slug])) {
187 187
 			return false;
188 188
 		}
189 189
 
190
-		return $this->registered[ $slug ];
190
+		return $this->registered[$slug];
191 191
 	}
192 192
 
193 193
 	/**
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return bool True if the component is registered, otherwise false.
217 217
 	 */
218
-	public function is_registered( $slug ) {
218
+	public function is_registered($slug) {
219 219
 
220
-		return isset( $this->registered[ $slug ] );
220
+		return isset($this->registered[$slug]);
221 221
 	}
222 222
 
223 223
 	/**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return bool True, or false if the component's slug has already been registered.
249 249
 	 */
250
-	public function register( $args ) {
250
+	public function register($args) {
251 251
 
252 252
 		$defaults = array(
253 253
 			'slug'          => '',
@@ -261,25 +261,25 @@  discard block
 block discarded – undo
261 261
 			'un_installer'  => null,
262 262
 		);
263 263
 
264
-		$component = array_merge( $defaults, $args );
264
+		$component = array_merge($defaults, $args);
265 265
 
266 266
 		if (
267
-			empty( $component['name'] )
268
-			|| empty( $component['file'] )
269
-			|| empty( $component['slug'] )
270
-			|| $this->is_registered( $component['slug'] )
267
+			empty($component['name'])
268
+			|| empty($component['file'])
269
+			|| empty($component['slug'])
270
+			|| $this->is_registered($component['slug'])
271 271
 		) {
272 272
 			return false;
273 273
 		}
274 274
 
275
-		$this->registered[ $component['slug'] ] = array_intersect_key( $component, $defaults );
275
+		$this->registered[$component['slug']] = array_intersect_key($component, $defaults);
276 276
 
277 277
 		WordPoints_Installables::register(
278 278
 			'component'
279 279
 			, $component['slug']
280 280
 			, array(
281
-				'version'      => $this->registered[ $component['slug'] ]['version'],
282
-				'un_installer' => $this->registered[ $component['slug'] ]['un_installer'],
281
+				'version'      => $this->registered[$component['slug']]['version'],
282
+				'un_installer' => $this->registered[$component['slug']]['un_installer'],
283 283
 				'network_wide' => is_wordpoints_network_active(),
284 284
 			)
285 285
 		);
@@ -296,18 +296,18 @@  discard block
 block discarded – undo
296 296
 	 *
297 297
 	 * @return bool True, even if the component isn't registered.
298 298
 	 */
299
-	public function deregister( $slug ) {
299
+	public function deregister($slug) {
300 300
 
301
-		if ( isset( $this->registered[ $slug ] ) ) {
301
+		if (isset($this->registered[$slug])) {
302 302
 
303 303
 			/**
304 304
 			 * Component being deregistered.
305 305
 			 *
306 306
 			 * @since 1.0.0
307 307
 			 */
308
-			do_action( "wordpoints_component_deregister-{$slug}" );
308
+			do_action("wordpoints_component_deregister-{$slug}");
309 309
 
310
-			unset( $this->registered[ $slug ] );
310
+			unset($this->registered[$slug]);
311 311
 		}
312 312
 
313 313
 		return true;
@@ -330,24 +330,24 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return bool Whether the component was activated.
332 332
 	 */
333
-	public function activate( $slug ) {
333
+	public function activate($slug) {
334 334
 
335
-		if ( ! $this->is_registered( $slug ) ) {
335
+		if ( ! $this->is_registered($slug)) {
336 336
 			return false;
337 337
 		}
338 338
 
339 339
 		// If this component isn't already active, activate it.
340
-		if ( ! $this->is_active( $slug ) ) {
340
+		if ( ! $this->is_active($slug)) {
341 341
 
342
-			$this->active[ $slug ] = 1;
342
+			$this->active[$slug] = 1;
343 343
 
344
-			if ( ! wordpoints_update_maybe_network_option( 'wordpoints_active_components', $this->active ) ) {
344
+			if ( ! wordpoints_update_maybe_network_option('wordpoints_active_components', $this->active)) {
345 345
 				return false;
346 346
 			}
347 347
 
348
-			include_once( $this->registered[ $slug ]['file'] );
348
+			include_once($this->registered[$slug]['file']);
349 349
 
350
-			WordPoints_Installables::get_installer( 'component', $slug )->install(
350
+			WordPoints_Installables::get_installer('component', $slug)->install(
351 351
 				is_wordpoints_network_active()
352 352
 			);
353 353
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 			 *
357 357
 			 * @since 1.0.0
358 358
 			 */
359
-			do_action( "wordpoints_component_activate-{$slug}" );
359
+			do_action("wordpoints_component_activate-{$slug}");
360 360
 		}
361 361
 
362 362
 		return true;
@@ -376,17 +376,17 @@  discard block
 block discarded – undo
376 376
 	 *
377 377
 	 * @return bool Whether the component was deactivated.
378 378
 	 */
379
-	public function deactivate( $slug ) {
379
+	public function deactivate($slug) {
380 380
 
381
-		if ( ! $this->is_registered( $slug ) ) {
381
+		if ( ! $this->is_registered($slug)) {
382 382
 			return false;
383 383
 		}
384 384
 
385
-		if ( $this->is_active( $slug ) ) {
385
+		if ($this->is_active($slug)) {
386 386
 
387
-			unset( $this->active[ $slug ] );
387
+			unset($this->active[$slug]);
388 388
 
389
-			if ( ! wordpoints_update_maybe_network_option( 'wordpoints_active_components', $this->active ) ) {
389
+			if ( ! wordpoints_update_maybe_network_option('wordpoints_active_components', $this->active)) {
390 390
 				return false;
391 391
 			}
392 392
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 			 *
396 396
 			 * @since 1.0.0
397 397
 			 */
398
-			do_action( "wordpoints_component_deactivate-{$slug}" );
398
+			do_action("wordpoints_component_deactivate-{$slug}");
399 399
 		}
400 400
 
401 401
 		return true;
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 	 *
414 414
 	 * @return bool Whether the component is active.
415 415
 	 */
416
-	public function is_active( $slug ) {
416
+	public function is_active($slug) {
417 417
 
418 418
 		$this->get_active();
419 419
 
420
-		$is_active = isset( $this->active[ $slug ] );
420
+		$is_active = isset($this->active[$slug]);
421 421
 
422 422
 		/**
423 423
 		 * Is a component active?
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 		 * @param bool   $is_active Whether the component is currently active.
428 428
 		 * @param string $slug      The component's slug.
429 429
 		 */
430
-		return apply_filters( 'wordpoints_component_active', $is_active, $slug );
430
+		return apply_filters('wordpoints_component_active', $is_active, $slug);
431 431
 	}
432 432
 
433 433
 	/**
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	 *
439 439
 	 * @param string $slug The component's slug.
440 440
 	 */
441
-	public function uninstall( $slug ) {
441
+	public function uninstall($slug) {
442 442
 
443 443
 		_deprecated_function(
444 444
 			__METHOD__
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 			, 'WordPoints_Installables::uninstall()'
447 447
 		);
448 448
 
449
-		WordPoints_Installables::uninstall( 'component', $slug );
449
+		WordPoints_Installables::uninstall('component', $slug);
450 450
 	}
451 451
 
452 452
 	/**
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	 *
494 494
 	 * @return WordPoints_Un_Installer_Base|false The installer for the component.
495 495
 	 */
496
-	public function get_installer( $slug ) {
496
+	public function get_installer($slug) {
497 497
 
498 498
 		_deprecated_function(
499 499
 			__METHOD__
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 			, 'WordPoints_Installables::get_installer()'
502 502
 		);
503 503
 
504
-		return WordPoints_Installables::get_installer( 'component', $slug );
504
+		return WordPoints_Installables::get_installer('component', $slug);
505 505
 	}
506 506
 }
507 507
 
Please login to merge, or discard this patch.
src/includes/modules.php 1 patch
Spacing   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @return bool Whether the module is active.
20 20
  */
21
-function is_wordpoints_module_active( $module ) {
21
+function is_wordpoints_module_active($module) {
22 22
 
23 23
 	return (
24
-		in_array( $module, wordpoints_get_array_option( 'wordpoints_active_modules' ) )
25
-		|| is_wordpoints_module_active_for_network( $module )
24
+		in_array($module, wordpoints_get_array_option('wordpoints_active_modules'))
25
+		|| is_wordpoints_module_active_for_network($module)
26 26
 	);
27 27
 }
28 28
 
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
  *
36 36
  * @return bool Whether the module is network active.
37 37
  */
38
-function is_wordpoints_module_active_for_network( $module ) {
38
+function is_wordpoints_module_active_for_network($module) {
39 39
 
40
-	if ( ! is_wordpoints_network_active() ) {
40
+	if ( ! is_wordpoints_network_active()) {
41 41
 		return false;
42 42
 	}
43 43
 
44
-	$modules = wordpoints_get_array_option( 'wordpoints_sitewide_active_modules', 'site' );
44
+	$modules = wordpoints_get_array_option('wordpoints_sitewide_active_modules', 'site');
45 45
 
46
-	if ( isset( $modules[ $module ] ) ) {
46
+	if (isset($modules[$module])) {
47 47
 		return true;
48 48
 	}
49 49
 
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
  *
66 66
  * @return bool True if the module is network only, false otherwise.
67 67
  */
68
-function is_network_only_wordpoints_module( $module ) {
68
+function is_network_only_wordpoints_module($module) {
69 69
 
70
-	$module_data = wordpoints_get_module_data( wordpoints_modules_dir() . '/' . $module );
70
+	$module_data = wordpoints_get_module_data(wordpoints_modules_dir() . '/' . $module);
71 71
 
72 72
 	return $module_data['network'];
73 73
 }
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
  *
82 82
  * @return bool True if the module has an uninstall script, false otherwise.
83 83
  */
84
-function is_uninstallable_wordpoints_module( $module ) {
84
+function is_uninstallable_wordpoints_module($module) {
85 85
 
86
-	return ( file_exists( wordpoints_modules_dir() . '/' . dirname( wordpoints_module_basename( $module ) ) . '/uninstall.php' ) );
86
+	return (file_exists(wordpoints_modules_dir() . '/' . dirname(wordpoints_module_basename($module)) . '/uninstall.php'));
87 87
 }
88 88
 
89 89
 /**
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 
108 108
 	static $modules_dir;
109 109
 
110
-	if ( ! $modules_dir ) {
110
+	if ( ! $modules_dir) {
111 111
 
112
-		if ( defined( 'WORDPOINTS_MODULES_DIR' ) ) {
112
+		if (defined('WORDPOINTS_MODULES_DIR')) {
113 113
 
114
-			$modules_dir = trailingslashit( WORDPOINTS_MODULES_DIR );
114
+			$modules_dir = trailingslashit(WORDPOINTS_MODULES_DIR);
115 115
 
116 116
 		} else {
117 117
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @param string $module_dir The full path to the modules folder.
129 129
 	 */
130
-	return apply_filters( 'wordpoints_modules_dir', $modules_dir );
130
+	return apply_filters('wordpoints_modules_dir', $modules_dir);
131 131
 }
132 132
 
133 133
 /**
@@ -140,30 +140,30 @@  discard block
 block discarded – undo
140 140
  *
141 141
  * @return string The URL for the path passed.
142 142
  */
143
-function wordpoints_modules_url( $path = '', $module = '' ) {
143
+function wordpoints_modules_url($path = '', $module = '') {
144 144
 
145
-	$path   = wp_normalize_path( $path );
146
-	$module = wp_normalize_path( $module );
145
+	$path   = wp_normalize_path($path);
146
+	$module = wp_normalize_path($module);
147 147
 
148
-	if ( defined( 'WORDPOINTS_MODULES_URL' ) ) {
148
+	if (defined('WORDPOINTS_MODULES_URL')) {
149 149
 		$url = WORDPOINTS_MODULES_URL;
150 150
 	} else {
151 151
 		$url = WP_CONTENT_URL . '/wordpoints-modules';
152 152
 	}
153 153
 
154
-	$url = set_url_scheme( $url );
154
+	$url = set_url_scheme($url);
155 155
 
156
-	if ( ! empty( $module ) && is_string( $module ) ) {
156
+	if ( ! empty($module) && is_string($module)) {
157 157
 
158
-		$folder = dirname( wordpoints_module_basename( $module ) );
158
+		$folder = dirname(wordpoints_module_basename($module));
159 159
 
160
-		if ( '.' !== $folder ) {
161
-			$url .= '/' . ltrim( $folder, '/' );
160
+		if ('.' !== $folder) {
161
+			$url .= '/' . ltrim($folder, '/');
162 162
 		}
163 163
 	}
164 164
 
165
-	if ( $path && is_string( $path ) ) {
166
-		$url .= '/' . ltrim( $path, '/' );
165
+	if ($path && is_string($path)) {
166
+		$url .= '/' . ltrim($path, '/');
167 167
 	}
168 168
 
169 169
 	/**
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * @param string $path   A relative path to a file or folder.
176 176
 	 * @param string $module A module file that the $path should be relative to.
177 177
 	 */
178
-	return apply_filters( 'wordpoints_modules_url', $url, $path, $module );
178
+	return apply_filters('wordpoints_modules_url', $url, $path, $module);
179 179
 }
180 180
 
181 181
 /**
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
  *
188 188
  * @return string The name of the module file.
189 189
  */
190
-function wordpoints_module_basename( $file ) {
190
+function wordpoints_module_basename($file) {
191 191
 
192 192
 	// Sanitize, and resolve possible symlink path from what is likely a real path.
193
-	$file = WordPoints_Module_Paths::resolve( $file );
193
+	$file = WordPoints_Module_Paths::resolve($file);
194 194
 
195 195
 	// Sanitize for Win32 installs and remove any duplicate slashes.
196
-	$modules_dir = wp_normalize_path( wordpoints_modules_dir() );
196
+	$modules_dir = wp_normalize_path(wordpoints_modules_dir());
197 197
 
198 198
 	// Get the relative path from the modules directory, and trim off the slashes.
199
-	$file = preg_replace( '#^' . preg_quote( $modules_dir, '#' ) . '#', '', $file );
200
-	$file = trim( $file, '/' );
199
+	$file = preg_replace('#^' . preg_quote($modules_dir, '#') . '#', '', $file);
200
+	$file = trim($file, '/');
201 201
 
202 202
 	return $file;
203 203
 }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
  *         @type string $namespace   The namespace for this module. Should be Title_Case, and omit "WordPoints" prefix.
238 238
  * }
239 239
  */
240
-function wordpoints_get_module_data( $module_file, $markup = true, $translate = true ) {
240
+function wordpoints_get_module_data($module_file, $markup = true, $translate = true) {
241 241
 
242 242
 	$default_headers = array(
243 243
 		'name'        => 'Module Name',
@@ -255,94 +255,94 @@  discard block
 block discarded – undo
255 255
 		'namespace'   => 'Namespace',
256 256
 	);
257 257
 
258
-	$module_data = WordPoints_Modules::get_data( $module_file );
258
+	$module_data = WordPoints_Modules::get_data($module_file);
259 259
 
260
-	if ( $module_data && wp_normalize_path( $module_file ) === $module_data['raw_file'] ) {
261
-		unset( $module_data['raw'], $module_data['raw_file'] );
260
+	if ($module_data && wp_normalize_path($module_file) === $module_data['raw_file']) {
261
+		unset($module_data['raw'], $module_data['raw_file']);
262 262
 	} else {
263
-		$module_data = get_file_data( $module_file, $default_headers, 'wordpoints_module' );
263
+		$module_data = get_file_data($module_file, $default_headers, 'wordpoints_module');
264 264
 	}
265 265
 
266
-	if ( ! empty( $module_data['update_api'] ) ) {
267
-		_deprecated_argument( __FUNCTION__, '1.10.0', 'The "Update API" module header has been deprecated in favor of "Channel".' );
266
+	if ( ! empty($module_data['update_api'])) {
267
+		_deprecated_argument(__FUNCTION__, '1.10.0', 'The "Update API" module header has been deprecated in favor of "Channel".');
268 268
 	}
269 269
 
270
-	$module_data['network'] = ( 'true' === strtolower( $module_data['network'] ) );
270
+	$module_data['network'] = ('true' === strtolower($module_data['network']));
271 271
 
272
-	if ( $markup || $translate ) {
272
+	if ($markup || $translate) {
273 273
 
274 274
 		// Sanitize the plugin filename to a WP_module_DIR relative path
275
-		$module_file = wordpoints_module_basename( $module_file );
275
+		$module_file = wordpoints_module_basename($module_file);
276 276
 
277 277
 		// Translate fields
278
-		if ( $translate ) {
278
+		if ($translate) {
279 279
 
280 280
 			$textdomain = $module_data['text_domain'];
281 281
 
282
-			if ( $textdomain ) {
282
+			if ($textdomain) {
283 283
 
284
-				if ( ! is_textdomain_loaded( $textdomain ) ) {
284
+				if ( ! is_textdomain_loaded($textdomain)) {
285 285
 
286
-					$domain_path = dirname( $module_file );
286
+					$domain_path = dirname($module_file);
287 287
 
288
-					if ( $module_data['domain_path'] ) {
288
+					if ($module_data['domain_path']) {
289 289
 						$domain_path .= $module_data['domain_path'];
290 290
 					}
291 291
 
292
-					wordpoints_load_module_textdomain( $textdomain, $domain_path );
292
+					wordpoints_load_module_textdomain($textdomain, $domain_path);
293 293
 				}
294 294
 
295
-				foreach ( array( 'name', 'module_uri', 'description', 'author', 'author_uri', 'version' ) as $field ) {
295
+				foreach (array('name', 'module_uri', 'description', 'author', 'author_uri', 'version') as $field) {
296 296
 
297
-					$module_data[ $field ] = translate( $module_data[ $field ], $textdomain ); // @codingStandardsIgnoreLine
297
+					$module_data[$field] = translate($module_data[$field], $textdomain); // @codingStandardsIgnoreLine
298 298
 				}
299 299
 			}
300 300
 		}
301 301
 
302 302
 		// Sanitize fields.
303 303
 		$allowed_tags_in_links = array(
304
-			'abbr'    => array( 'title' => true ),
305
-			'acronym' => array( 'title' => true ),
304
+			'abbr'    => array('title' => true),
305
+			'acronym' => array('title' => true),
306 306
 			'code'    => true,
307 307
 			'em'      => true,
308 308
 			'strong'  => true,
309 309
 		);
310 310
 
311 311
 		$allowed_tags = $allowed_tags_in_links;
312
-		$allowed_tags['a'] = array( 'href' => true, 'title' => true );
312
+		$allowed_tags['a'] = array('href' => true, 'title' => true);
313 313
 
314 314
 		// Name and author ar marked up inside <a> tags. Don't allow these.
315
-		$module_data['name']   = wp_kses( $module_data['name'],   $allowed_tags_in_links );
316
-		$module_data['author'] = wp_kses( $module_data['author'], $allowed_tags_in_links );
315
+		$module_data['name']   = wp_kses($module_data['name'], $allowed_tags_in_links);
316
+		$module_data['author'] = wp_kses($module_data['author'], $allowed_tags_in_links);
317 317
 
318
-		$module_data['description'] = wp_kses( $module_data['description'], $allowed_tags );
319
-		$module_data['version']     = wp_kses( $module_data['version'],     $allowed_tags );
318
+		$module_data['description'] = wp_kses($module_data['description'], $allowed_tags);
319
+		$module_data['version']     = wp_kses($module_data['version'], $allowed_tags);
320 320
 
321
-		$module_data['module_uri'] = esc_url( $module_data['module_uri'] );
322
-		$module_data['author_uri'] = esc_url( $module_data['author_uri'] );
321
+		$module_data['module_uri'] = esc_url($module_data['module_uri']);
322
+		$module_data['author_uri'] = esc_url($module_data['author_uri']);
323 323
 
324 324
 		$module_data['title']       = $module_data['name'];
325 325
 		$module_data['author_name'] = $module_data['author'];
326 326
 
327 327
 		// Apply markup.
328
-		if ( $markup ) {
328
+		if ($markup) {
329 329
 
330
-			if ( $module_data['module_uri'] && $module_data['name'] ) {
330
+			if ($module_data['module_uri'] && $module_data['name']) {
331 331
 				$module_data['title'] = '<a href="' . $module_data['module_uri']
332 332
 					. '">' . $module_data['name'] . '</a>';
333 333
 			}
334 334
 
335
-			if ( $module_data['author_uri'] && $module_data['author'] ) {
335
+			if ($module_data['author_uri'] && $module_data['author']) {
336 336
 				$module_data['author'] = '<a href="' . $module_data['author_uri']
337 337
 					. '">' . $module_data['author'] . '</a>';
338 338
 			}
339 339
 
340
-			$module_data['description'] = wptexturize( $module_data['description'] );
340
+			$module_data['description'] = wptexturize($module_data['description']);
341 341
 
342
-			if ( $module_data['author'] ) {
342
+			if ($module_data['author']) {
343 343
 				$module_data['description'] .= ' <cite>'
344 344
 					// translators: Author name.
345
-					. sprintf( __( 'By %s.', 'wordpoints' ), $module_data['author'] )
345
+					. sprintf(__('By %s.', 'wordpoints'), $module_data['author'])
346 346
 					. '</cite>';
347 347
 			}
348 348
 		}
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
  *
369 369
  * @return bool Whether the textdoamin was loaded successfully.
370 370
  */
371
-function wordpoints_load_module_textdomain( $domain, $module_rel_path = false ) {
371
+function wordpoints_load_module_textdomain($domain, $module_rel_path = false) {
372 372
 
373 373
 	$locale = get_locale();
374 374
 
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
 	 * @param string $locale The module's current locale.
381 381
 	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
382 382
 	 */
383
-	$locale = apply_filters( 'wordpoints_module_locale', $locale, $domain );
383
+	$locale = apply_filters('wordpoints_module_locale', $locale, $domain);
384 384
 
385
-	if ( false !== $module_rel_path	) {
385
+	if (false !== $module_rel_path) {
386 386
 
387
-		$path = wordpoints_modules_dir() . '/' . trim( $module_rel_path, '/' );
387
+		$path = wordpoints_modules_dir() . '/' . trim($module_rel_path, '/');
388 388
 
389 389
 	} else {
390 390
 
@@ -394,14 +394,14 @@  discard block
 block discarded – undo
394 394
 	// Load the textdomain according to the module first.
395 395
 	$mofile = $domain . '-' . $locale . '.mo';
396 396
 
397
-	if ( load_textdomain( $domain, $path . '/' . $mofile ) ) {
397
+	if (load_textdomain($domain, $path . '/' . $mofile)) {
398 398
 		return true;
399 399
 	}
400 400
 
401 401
 	// Otherwise, load from the languages directory.
402 402
 	$mofile = WP_LANG_DIR . '/wordpoints-modules/' . $mofile;
403 403
 
404
-	return load_textdomain( $domain, $mofile );
404
+	return load_textdomain($domain, $mofile);
405 405
 }
406 406
 
407 407
 /**
@@ -421,76 +421,76 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return array A list of the module files found (files with module headers).
423 423
  */
424
-function wordpoints_get_modules( $module_folder = '', $markup = false, $translate = false ) {
424
+function wordpoints_get_modules($module_folder = '', $markup = false, $translate = false) {
425 425
 
426
-	$cache_modules = wp_cache_get( 'wordpoints_modules', 'wordpoints_modules' );
426
+	$cache_modules = wp_cache_get('wordpoints_modules', 'wordpoints_modules');
427 427
 
428
-	if ( ! $cache_modules ) {
428
+	if ( ! $cache_modules) {
429 429
 		$cache_modules = array();
430 430
 	}
431 431
 
432
-	if ( isset( $cache_modules[ $module_folder ] ) ) {
433
-		return $cache_modules[ $module_folder ];
432
+	if (isset($cache_modules[$module_folder])) {
433
+		return $cache_modules[$module_folder];
434 434
 	}
435 435
 
436 436
 	$modules     = array();
437 437
 	$module_root = wordpoints_modules_dir();
438 438
 
439
-	if ( ! empty( $module_folder ) ) {
439
+	if ( ! empty($module_folder)) {
440 440
 		$module_root .= $module_folder;
441 441
 	}
442 442
 
443 443
 	// Escape pattern-matching characters in the path.
444
-	$module_escape_root = str_replace( array( '*', '?', '[' ), array( '[*]', '[?]', '[[]' ), $module_root );
444
+	$module_escape_root = str_replace(array('*', '?', '['), array('[*]', '[?]', '[[]'), $module_root);
445 445
 
446 446
 	// Get the top level files.
447
-	$module_files = glob( "{$module_escape_root}/*.php" );
447
+	$module_files = glob("{$module_escape_root}/*.php");
448 448
 
449
-	if ( false === $module_files ) {
449
+	if (false === $module_files) {
450 450
 		return $modules;
451 451
 	}
452 452
 
453 453
 	// Get the files of subfolders, if not already searching in a subfolder.
454
-	if ( empty( $module_folder ) ) {
454
+	if (empty($module_folder)) {
455 455
 
456
-		$subfolder_files = glob( "{$module_escape_root}/*/*.php" );
456
+		$subfolder_files = glob("{$module_escape_root}/*/*.php");
457 457
 
458
-		if ( false === $subfolder_files ) {
458
+		if (false === $subfolder_files) {
459 459
 			return $modules;
460 460
 		}
461 461
 
462
-		$module_files = array_merge( $module_files, $subfolder_files );
462
+		$module_files = array_merge($module_files, $subfolder_files);
463 463
 	}
464 464
 
465
-	if ( empty( $module_files ) ) {
465
+	if (empty($module_files)) {
466 466
 		return $modules;
467 467
 	}
468 468
 
469
-	foreach ( $module_files as $module_file ) {
469
+	foreach ($module_files as $module_file) {
470 470
 
471
-		if ( ! is_readable( $module_file ) ) {
471
+		if ( ! is_readable($module_file)) {
472 472
 			continue;
473 473
 		}
474 474
 
475
-		$module_data = wordpoints_get_module_data( $module_file, $markup, $translate );
475
+		$module_data = wordpoints_get_module_data($module_file, $markup, $translate);
476 476
 
477
-		if ( empty( $module_data['name'] ) ) {
477
+		if (empty($module_data['name'])) {
478 478
 			continue;
479 479
 		}
480 480
 
481
-		$module_file = wordpoints_module_basename( $module_file );
481
+		$module_file = wordpoints_module_basename($module_file);
482 482
 
483
-		if ( $module_folder ) {
484
-			$module_file = basename( $module_file );
483
+		if ($module_folder) {
484
+			$module_file = basename($module_file);
485 485
 		}
486 486
 
487
-		$modules[ $module_file ] = $module_data;
487
+		$modules[$module_file] = $module_data;
488 488
 	}
489 489
 
490
-	uasort( $modules, '_wordpoints_sort_uname_callback' );
490
+	uasort($modules, '_wordpoints_sort_uname_callback');
491 491
 
492
-	$cache_modules[ $module_folder ] = $modules;
493
-	wp_cache_set( 'wordpoints_modules', $cache_modules, 'wordpoints_modules' );
492
+	$cache_modules[$module_folder] = $modules;
493
+	wp_cache_set('wordpoints_modules', $cache_modules, 'wordpoints_modules');
494 494
 
495 495
 	return $modules;
496 496
 }
@@ -504,20 +504,20 @@  discard block
 block discarded – undo
504 504
  *
505 505
  * @return true|WP_Error True on success, a WP_Error on failure.
506 506
  */
507
-function wordpoints_validate_module( $module ) {
507
+function wordpoints_validate_module($module) {
508 508
 
509
-	if ( validate_file( $module ) ) {
510
-		return new WP_Error( 'module_invalid', __( 'Invalid module path.', 'wordpoints' ) );
509
+	if (validate_file($module)) {
510
+		return new WP_Error('module_invalid', __('Invalid module path.', 'wordpoints'));
511 511
 	}
512 512
 
513
-	if ( ! file_exists( wordpoints_modules_dir() . '/' . $module ) ) {
514
-		return new WP_Error( 'module_not_found', __( 'Module file does not exist.', 'wordpoints' ) );
513
+	if ( ! file_exists(wordpoints_modules_dir() . '/' . $module)) {
514
+		return new WP_Error('module_not_found', __('Module file does not exist.', 'wordpoints'));
515 515
 	}
516 516
 
517 517
 	$installed_modules = wordpoints_get_modules();
518 518
 
519
-	if ( ! isset( $installed_modules[ $module ] ) ) {
520
-		return new WP_Error( 'no_module_header', __( 'The module does not have a valid header.', 'wordpoints' ) );
519
+	if ( ! isset($installed_modules[$module])) {
520
+		return new WP_Error('no_module_header', __('The module does not have a valid header.', 'wordpoints'));
521 521
 	}
522 522
 
523 523
 	return true;
@@ -534,27 +534,27 @@  discard block
 block discarded – undo
534 534
  */
535 535
 function wordpoints_validate_active_modules() {
536 536
 
537
-	$modules = wordpoints_get_array_option( 'wordpoints_active_modules' );
537
+	$modules = wordpoints_get_array_option('wordpoints_active_modules');
538 538
 
539
-	if ( is_multisite() && current_user_can( 'manage_network_wordpoints_modules' ) ) {
539
+	if (is_multisite() && current_user_can('manage_network_wordpoints_modules')) {
540 540
 
541
-		$network_modules = wordpoints_get_array_option( 'wordpoints_sitewide_active_modules', 'site' );
542
-		$modules = array_merge( $modules, array_keys( $network_modules ) );
541
+		$network_modules = wordpoints_get_array_option('wordpoints_sitewide_active_modules', 'site');
542
+		$modules = array_merge($modules, array_keys($network_modules));
543 543
 	}
544 544
 
545
-	if ( empty( $modules ) ) {
545
+	if (empty($modules)) {
546 546
 		return null;
547 547
 	}
548 548
 
549 549
 	$invalid = array();
550 550
 
551
-	foreach ( $modules as $module ) {
551
+	foreach ($modules as $module) {
552 552
 
553
-		$result = wordpoints_validate_module( $module );
553
+		$result = wordpoints_validate_module($module);
554 554
 
555
-		if ( is_wp_error( $result ) ) {
556
-			$invalid[ $module ] = $result;
557
-			wordpoints_deactivate_modules( $module, true );
555
+		if (is_wp_error($result)) {
556
+			$invalid[$module] = $result;
557
+			wordpoints_deactivate_modules($module, true);
558 558
 		}
559 559
 	}
560 560
 
@@ -571,9 +571,9 @@  discard block
 block discarded – undo
571 571
  *
572 572
  * @return int {@see strnatcasecmp()}.
573 573
  */
574
-function _wordpoints_sort_uname_callback( $a, $b ) {
574
+function _wordpoints_sort_uname_callback($a, $b) {
575 575
 
576
-	return strnatcasecmp( $a['name'], $b['name'] );
576
+	return strnatcasecmp($a['name'], $b['name']);
577 577
 }
578 578
 
579 579
 /**
@@ -604,33 +604,33 @@  discard block
 block discarded – undo
604 604
  *
605 605
  * @return WP_Error|null An error object on failure, or null on success.
606 606
  */
607
-function wordpoints_activate_module( $module, $redirect = '', $network_wide = false, $silent = false ) {
607
+function wordpoints_activate_module($module, $redirect = '', $network_wide = false, $silent = false) {
608 608
 
609
-	$module = wordpoints_module_basename( $module );
609
+	$module = wordpoints_module_basename($module);
610 610
 
611
-	$valid = wordpoints_validate_module( $module );
611
+	$valid = wordpoints_validate_module($module);
612 612
 
613
-	if ( is_wp_error( $valid ) ) {
613
+	if (is_wp_error($valid)) {
614 614
 		return $valid;
615 615
 	}
616 616
 
617
-	if ( is_multisite() && ( $network_wide || is_network_only_wordpoints_module( $module ) ) ) {
617
+	if (is_multisite() && ($network_wide || is_network_only_wordpoints_module($module))) {
618 618
 
619 619
 		$network_wide = true;
620
-		$network_current = wordpoints_get_array_option( 'wordpoints_sitewide_active_modules', 'site' );
621
-		$current = array_keys( $network_current );
620
+		$network_current = wordpoints_get_array_option('wordpoints_sitewide_active_modules', 'site');
621
+		$current = array_keys($network_current);
622 622
 
623 623
 	} else {
624 624
 
625
-		$current = wordpoints_get_array_option( 'wordpoints_active_modules' );
625
+		$current = wordpoints_get_array_option('wordpoints_active_modules');
626 626
 	}
627 627
 
628 628
 	// If the module is already active, return.
629
-	if ( in_array( $module, $current ) ) {
629
+	if (in_array($module, $current)) {
630 630
 		return null;
631 631
 	}
632 632
 
633
-	if ( ! empty( $redirect ) ) {
633
+	if ( ! empty($redirect)) {
634 634
 
635 635
 		/*
636 636
 		 * Redirect. We'll override this later if the module can be included
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 		wp_safe_redirect(
640 640
 			add_query_arg(
641 641
 				'_error_nonce'
642
-				, wp_create_nonce( 'module-activation-error_' . $module )
642
+				, wp_create_nonce('module-activation-error_' . $module)
643 643
 				, $redirect
644 644
 			)
645 645
 		);
@@ -648,11 +648,11 @@  discard block
 block discarded – undo
648 648
 	ob_start();
649 649
 
650 650
 	$module_file = wordpoints_modules_dir() . '/' . $module;
651
-	WordPoints_Module_Paths::register( $module_file );
651
+	WordPoints_Module_Paths::register($module_file);
652 652
 
653 653
 	include_once $module_file;
654 654
 
655
-	if ( ! $silent ) {
655
+	if ( ! $silent) {
656 656
 
657 657
 		/**
658 658
 		 * Fires before a module is activated.
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 		 *                             all sites in the network or just the
665 665
 		 *                             current site.
666 666
 		 */
667
-		do_action( 'wordpoints_module_activate', $module, $network_wide );
667
+		do_action('wordpoints_module_activate', $module, $network_wide);
668 668
 
669 669
 		/**
670 670
 		 * Fires before a module is activated.
@@ -675,28 +675,28 @@  discard block
 block discarded – undo
675 675
 		 *                           all sites in the network or just the current
676 676
 		 *                           site.
677 677
 		 */
678
-		do_action( "wordpoints_module_activate-{$module}", $network_wide );
678
+		do_action("wordpoints_module_activate-{$module}", $network_wide);
679 679
 
680 680
 		WordPoints_Installables::install(
681 681
 			'module'
682
-			, WordPoints_Modules::get_slug( $module )
682
+			, WordPoints_Modules::get_slug($module)
683 683
 			, $network_wide
684 684
 		);
685 685
 	}
686 686
 
687
-	if ( $network_wide ) {
687
+	if ($network_wide) {
688 688
 
689
-		$network_current[ $module ] = time();
690
-		update_site_option( 'wordpoints_sitewide_active_modules', $network_current );
689
+		$network_current[$module] = time();
690
+		update_site_option('wordpoints_sitewide_active_modules', $network_current);
691 691
 
692 692
 	} else {
693 693
 
694 694
 		$current[] = $module;
695
-		sort( $current );
696
-		update_option( 'wordpoints_active_modules', $current );
695
+		sort($current);
696
+		update_option('wordpoints_active_modules', $current);
697 697
 	}
698 698
 
699
-	if ( ! $silent ) {
699
+	if ( ! $silent) {
700 700
 		/**
701 701
 		 * Fires after a module has been activated in activate_plugin() when the $silent parameter is false.
702 702
 		 *
@@ -707,14 +707,14 @@  discard block
 block discarded – undo
707 707
 		 *                             all sites in the network or just the
708 708
 		 *                             current site.
709 709
 		 */
710
-		do_action( 'wordpoints_activated_module', $module, $network_wide );
710
+		do_action('wordpoints_activated_module', $module, $network_wide);
711 711
 	}
712 712
 
713
-	if ( ob_get_length() > 0 ) {
713
+	if (ob_get_length() > 0) {
714 714
 
715 715
 		return new WP_Error(
716 716
 			'unexpected_output'
717
-			, __( 'The module generated unexpected output.', 'wordpoints' )
717
+			, __('The module generated unexpected output.', 'wordpoints')
718 718
 			, ob_get_contents()
719 719
 		);
720 720
 	}
@@ -734,29 +734,29 @@  discard block
 block discarded – undo
734 734
  *                                   Default is false.
735 735
  * @param bool         $network_wide Whether to apply the change network wide.
736 736
  */
737
-function wordpoints_deactivate_modules( $modules, $silent = false, $network_wide = null ) {
737
+function wordpoints_deactivate_modules($modules, $silent = false, $network_wide = null) {
738 738
 
739 739
 	$network_current = array();
740
-	if ( is_wordpoints_network_active() ) {
741
-		$network_current = wordpoints_get_array_option( 'wordpoints_sitewide_active_modules', 'site' );
740
+	if (is_wordpoints_network_active()) {
741
+		$network_current = wordpoints_get_array_option('wordpoints_sitewide_active_modules', 'site');
742 742
 	}
743 743
 
744
-	$current = wordpoints_get_array_option( 'wordpoints_active_modules' );
744
+	$current = wordpoints_get_array_option('wordpoints_active_modules');
745 745
 
746 746
 	$do_network = false;
747 747
 	$do_blog = false;
748 748
 
749
-	foreach ( (array) $modules as $module ) {
749
+	foreach ((array) $modules as $module) {
750 750
 
751
-		$module = wordpoints_module_basename( $module );
751
+		$module = wordpoints_module_basename($module);
752 752
 
753
-		if ( ! is_wordpoints_module_active( $module ) ) {
753
+		if ( ! is_wordpoints_module_active($module)) {
754 754
 			continue;
755 755
 		}
756 756
 
757
-		$network_deactivating = ( false !== $network_wide && is_wordpoints_module_active_for_network( $module ) );
757
+		$network_deactivating = (false !== $network_wide && is_wordpoints_module_active_for_network($module));
758 758
 
759
-		if ( ! $silent ) {
759
+		if ( ! $silent) {
760 760
 			/**
761 761
 			 * Fires for each module being deactivated in wordpoints_deactivate_modules(), before deactivation
762 762
 			 * and when the $silent parameter is false.
@@ -767,34 +767,34 @@  discard block
 block discarded – undo
767 767
 			 * @param bool   $network_deactivating Whether the module is deactivated for all sites in the network
768 768
 			 *                                     or just the current site. Multisite only. Default is false.
769 769
 			 */
770
-			do_action( 'wordpoints_deactivate_module', $module, $network_deactivating );
770
+			do_action('wordpoints_deactivate_module', $module, $network_deactivating);
771 771
 		}
772 772
 
773
-		if ( false !== $network_wide ) {
773
+		if (false !== $network_wide) {
774 774
 
775
-			if ( is_wordpoints_module_active_for_network( $module ) ) {
775
+			if (is_wordpoints_module_active_for_network($module)) {
776 776
 
777 777
 				$do_network = true;
778
-				unset( $network_current[ $module ] );
778
+				unset($network_current[$module]);
779 779
 
780
-			} elseif ( $network_wide ) {
780
+			} elseif ($network_wide) {
781 781
 
782 782
 				continue;
783 783
 			}
784 784
 		}
785 785
 
786
-		if ( true !== $network_wide ) {
786
+		if (true !== $network_wide) {
787 787
 
788
-			$key = array_search( $module, $current );
788
+			$key = array_search($module, $current);
789 789
 
790
-			if ( false !== $key ) {
790
+			if (false !== $key) {
791 791
 
792 792
 				$do_blog = true;
793
-				unset( $current[ $key ] );
793
+				unset($current[$key]);
794 794
 			}
795 795
 		}
796 796
 
797
-		if ( ! $silent ) {
797
+		if ( ! $silent) {
798 798
 			/**
799 799
 			 * Fires for each module being deactivated in wordpoints_deactivate_module(), after deactivation
800 800
 			 * and when the $silent parameter is false.
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 			 * @param bool $network_deactivating Whether the module is deactivated for all sites in the network
808 808
 			 *                                   or just the current site. Multisite only. Default is false.
809 809
 			 */
810
-			do_action( 'wordpoints_deactivate_module-' . $module, $network_deactivating );
810
+			do_action('wordpoints_deactivate_module-' . $module, $network_deactivating);
811 811
 
812 812
 			/**
813 813
 			 * Fires for each module being deactivated in deactivate_plugins(), after deactivation
@@ -819,17 +819,17 @@  discard block
 block discarded – undo
819 819
 			 * @param bool   $network_deactivating Whether the module is deactivated for all sites in the network
820 820
 			 *                                     or just the current site. Multisite only. Default is false.
821 821
 			 */
822
-			do_action( 'wordpoints_deactivated_module', $module, $network_deactivating );
822
+			do_action('wordpoints_deactivated_module', $module, $network_deactivating);
823 823
 		}
824 824
 
825 825
 	} // End foreach ( $modules ).
826 826
 
827
-	if ( $do_blog ) {
828
-		update_option( 'wordpoints_active_modules', $current );
827
+	if ($do_blog) {
828
+		update_option('wordpoints_active_modules', $current);
829 829
 	}
830 830
 
831
-	if ( $do_network ) {
832
-		update_site_option( 'wordpoints_sitewide_active_modules', $network_current );
831
+	if ($do_network) {
832
+		update_site_option('wordpoints_sitewide_active_modules', $network_current);
833 833
 	}
834 834
 }
835 835
 
@@ -846,31 +846,31 @@  discard block
 block discarded – undo
846 846
  * @return bool|WP_Error True if all modules deleted successfully, false or WP_Error
847 847
  *                       on failure.
848 848
  */
849
-function wordpoints_delete_modules( $modules ) {
849
+function wordpoints_delete_modules($modules) {
850 850
 
851 851
 	global $wp_filesystem;
852 852
 
853
-	if ( empty( $modules ) ) {
853
+	if (empty($modules)) {
854 854
 		return false;
855 855
 	}
856 856
 
857 857
 	$checked = array();
858 858
 
859
-	foreach ( $modules as $module ) {
859
+	foreach ($modules as $module) {
860 860
 		$checked[] = 'checked[]=' . $module;
861 861
 	}
862 862
 
863 863
 	ob_start();
864 864
 
865
-	$url = wp_nonce_url( self_admin_url( 'admin.php?page=wordpoints_modules&action=delete-selected&verify-delete=1&' . implode( '&', $checked ) ), 'bulk-modules' );
865
+	$url = wp_nonce_url(self_admin_url('admin.php?page=wordpoints_modules&action=delete-selected&verify-delete=1&' . implode('&', $checked)), 'bulk-modules');
866 866
 
867
-	$credentials = request_filesystem_credentials( $url );
867
+	$credentials = request_filesystem_credentials($url);
868 868
 
869
-	if ( false === $credentials ) {
869
+	if (false === $credentials) {
870 870
 
871 871
 		$data = ob_get_clean();
872 872
 
873
-		if ( ! empty( $data ) ) {
873
+		if ( ! empty($data)) {
874 874
 
875 875
 			include_once ABSPATH . 'wp-admin/admin-header.php';
876 876
 			echo $data; // XSS OK here, WPCS.
@@ -881,14 +881,14 @@  discard block
 block discarded – undo
881 881
 		return false;
882 882
 	}
883 883
 
884
-	if ( ! WP_Filesystem( $credentials ) ) {
884
+	if ( ! WP_Filesystem($credentials)) {
885 885
 
886 886
 		// Failed to connect, Error and request again
887
-		request_filesystem_credentials( $url, '', true );
887
+		request_filesystem_credentials($url, '', true);
888 888
 
889 889
 		$data = ob_get_clean();
890 890
 
891
-		if ( ! empty( $data ) ) {
891
+		if ( ! empty($data)) {
892 892
 
893 893
 			include_once ABSPATH . 'wp-admin/admin-header.php';
894 894
 			echo $data; // XSS OK here too, WPCS.
@@ -899,41 +899,41 @@  discard block
 block discarded – undo
899 899
 		return false;
900 900
 	}
901 901
 
902
-	if ( ! is_object( $wp_filesystem ) ) {
903
-		return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.', 'wordpoints' ) );
902
+	if ( ! is_object($wp_filesystem)) {
903
+		return new WP_Error('fs_unavailable', __('Could not access filesystem.', 'wordpoints'));
904 904
 	}
905 905
 
906
-	if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
907
-		return new WP_Error( 'fs_error', __( 'Filesystem error.', 'wordpoints' ), $wp_filesystem->errors );
906
+	if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
907
+		return new WP_Error('fs_error', __('Filesystem error.', 'wordpoints'), $wp_filesystem->errors);
908 908
 	}
909 909
 
910 910
 	// Get the base module folder.
911
-	$modules_dir = $wp_filesystem->find_folder( wordpoints_modules_dir() );
911
+	$modules_dir = $wp_filesystem->find_folder(wordpoints_modules_dir());
912 912
 
913
-	if ( empty( $modules_dir ) ) {
914
-		return new WP_Error( 'fs_no_modules_dir', __( 'Unable to locate WordPoints Module directory.', 'wordpoints' ) );
913
+	if (empty($modules_dir)) {
914
+		return new WP_Error('fs_no_modules_dir', __('Unable to locate WordPoints Module directory.', 'wordpoints'));
915 915
 	}
916 916
 
917
-	$modules_dir = trailingslashit( $modules_dir );
917
+	$modules_dir = trailingslashit($modules_dir);
918 918
 	$errors = array();
919 919
 
920
-	foreach ( $modules as $module_file ) {
920
+	foreach ($modules as $module_file) {
921 921
 
922 922
 		// Run uninstall hook.
923
-		if ( is_uninstallable_wordpoints_module( $module_file ) ) {
924
-			wordpoints_uninstall_module( $module_file );
923
+		if (is_uninstallable_wordpoints_module($module_file)) {
924
+			wordpoints_uninstall_module($module_file);
925 925
 		}
926 926
 
927
-		$this_module_dir = trailingslashit( dirname( $modules_dir . $module_file ) );
927
+		$this_module_dir = trailingslashit(dirname($modules_dir . $module_file));
928 928
 
929 929
 		// If module is in its own directory, recursively delete the directory.
930
-		if ( strpos( $module_file, '/' ) && $this_module_dir !== $modules_dir ) {
931
-			$deleted = $wp_filesystem->delete( $this_module_dir, true );
930
+		if (strpos($module_file, '/') && $this_module_dir !== $modules_dir) {
931
+			$deleted = $wp_filesystem->delete($this_module_dir, true);
932 932
 		} else {
933
-			$deleted = $wp_filesystem->delete( $modules_dir . $module_file );
933
+			$deleted = $wp_filesystem->delete($modules_dir . $module_file);
934 934
 		}
935 935
 
936
-		if ( ! $deleted ) {
936
+		if ( ! $deleted) {
937 937
 			$errors[] = $module_file;
938 938
 		}
939 939
 	}
@@ -950,9 +950,9 @@  discard block
 block discarded – undo
950 950
 	 * @param array $modules The modules that were to be deleted.
951 951
 	 * @param array $errors  The modules that failed to delete.
952 952
 	 */
953
-	do_action( 'wordpoints_deleted_modules', $modules, $errors );
953
+	do_action('wordpoints_deleted_modules', $modules, $errors);
954 954
 
955
-	if ( ! empty( $errors ) ) {
955
+	if ( ! empty($errors)) {
956 956
 		return new WP_Error(
957 957
 			'could_not_remove_module'
958 958
 			, sprintf(
@@ -960,10 +960,10 @@  discard block
 block discarded – undo
960 960
 				_n(
961 961
 					'Could not fully remove the module %s.'
962 962
 					, 'Could not fully remove the modules %s.'
963
-					, count( $errors )
963
+					, count($errors)
964 964
 					, 'wordpoints'
965 965
 				)
966
-				, implode( ', ', $errors )
966
+				, implode(', ', $errors)
967 967
 			)
968 968
 		);
969 969
 	}
@@ -982,16 +982,16 @@  discard block
 block discarded – undo
982 982
  *
983 983
  * @return bool Whether the module had an uninstall process.
984 984
  */
985
-function wordpoints_uninstall_module( $module ) {
985
+function wordpoints_uninstall_module($module) {
986 986
 
987
-	$file              = wordpoints_module_basename( $module );
988
-	$module_dir        = wordpoints_modules_dir() . '/' . dirname( $file );
987
+	$file              = wordpoints_module_basename($module);
988
+	$module_dir        = wordpoints_modules_dir() . '/' . dirname($file);
989 989
 	$uninstall_file    = $module_dir . '/uninstall.php';
990 990
 	$un_installer_file = $module_dir . '/includes/class-un-installer.php';
991 991
 
992
-	if ( file_exists( $uninstall_file ) ) {
992
+	if (file_exists($uninstall_file)) {
993 993
 
994
-		if ( ! defined( 'WORDPOINTS_UNINSTALL_MODULE' ) ) {
994
+		if ( ! defined('WORDPOINTS_UNINSTALL_MODULE')) {
995 995
 			/**
996 996
 			 * Uninstalling a module.
997 997
 			 *
@@ -1005,17 +1005,17 @@  discard block
 block discarded – undo
1005 1005
 			 *
1006 1006
 			 * @const WORDPOINTS_UNINSTALL_MODULE
1007 1007
 			 */
1008
-			define( 'WORDPOINTS_UNINSTALL_MODULE', true );
1008
+			define('WORDPOINTS_UNINSTALL_MODULE', true);
1009 1009
 		}
1010 1010
 
1011
-		WordPoints_Module_Paths::register( $uninstall_file );
1011
+		WordPoints_Module_Paths::register($uninstall_file);
1012 1012
 		include $uninstall_file;
1013 1013
 
1014 1014
 		return true;
1015 1015
 
1016
-	} elseif ( file_exists( $un_installer_file ) ) {
1016
+	} elseif (file_exists($un_installer_file)) {
1017 1017
 
1018
-		$slug = WordPoints_Modules::get_slug( $module );
1018
+		$slug = WordPoints_Modules::get_slug($module);
1019 1019
 
1020 1020
 		WordPoints_Installables::register(
1021 1021
 			'module'
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 			)
1028 1028
 		);
1029 1029
 
1030
-		return WordPoints_Installables::uninstall( 'module', $slug );
1030
+		return WordPoints_Installables::uninstall('module', $slug);
1031 1031
 
1032 1032
 	} else {
1033 1033
 
@@ -1053,34 +1053,34 @@  discard block
 block discarded – undo
1053 1053
  */
1054 1054
 function wordpoints_load_modules() {
1055 1055
 
1056
-	$active_modules = wordpoints_get_array_option( 'wordpoints_active_modules' );
1056
+	$active_modules = wordpoints_get_array_option('wordpoints_active_modules');
1057 1057
 
1058
-	if ( is_wordpoints_network_active() ) {
1058
+	if (is_wordpoints_network_active()) {
1059 1059
 
1060 1060
 		$network_active_modules = array_keys(
1061
-			wordpoints_get_array_option( 'wordpoints_sitewide_active_modules', 'site' )
1061
+			wordpoints_get_array_option('wordpoints_sitewide_active_modules', 'site')
1062 1062
 		);
1063 1063
 
1064 1064
 		// On the network admin screens we only load the network active modules.
1065
-		if ( is_network_admin() ) {
1065
+		if (is_network_admin()) {
1066 1066
 			$active_modules = $network_active_modules;
1067 1067
 		} else {
1068
-			$active_modules = array_merge( $active_modules, $network_active_modules );
1068
+			$active_modules = array_merge($active_modules, $network_active_modules);
1069 1069
 		}
1070 1070
 	}
1071 1071
 
1072
-	if ( ! empty( $active_modules ) ) {
1072
+	if ( ! empty($active_modules)) {
1073 1073
 
1074 1074
 		$modules_dir = wordpoints_modules_dir();
1075 1075
 
1076
-		foreach ( $active_modules as $module ) {
1076
+		foreach ($active_modules as $module) {
1077 1077
 
1078 1078
 			if (
1079
-				0 === validate_file( $module )
1080
-				&& '.php' === substr( $module, -4 )
1081
-				&& file_exists( $modules_dir . '/' . $module )
1079
+				0 === validate_file($module)
1080
+				&& '.php' === substr($module, -4)
1081
+				&& file_exists($modules_dir . '/' . $module)
1082 1082
 			) {
1083
-				WordPoints_Module_Paths::register( $modules_dir . '/' . $module );
1083
+				WordPoints_Module_Paths::register($modules_dir . '/' . $module);
1084 1084
 				include $modules_dir . '/' . $module;
1085 1085
 			}
1086 1086
 		}
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 	 *
1094 1094
 	 * @since 1.0.0
1095 1095
 	 */
1096
-	do_action( 'wordpoints_modules_loaded' );
1096
+	do_action('wordpoints_modules_loaded');
1097 1097
 }
1098 1098
 
1099 1099
 /**
@@ -1104,11 +1104,11 @@  discard block
 block discarded – undo
1104 1104
  * @param string $file     The main file of the module the hook is for.
1105 1105
  * @param string $function The callback function.
1106 1106
  */
1107
-function wordpoints_register_module_activation_hook( $file, $function ) {
1107
+function wordpoints_register_module_activation_hook($file, $function) {
1108 1108
 
1109
-	$module_file = wordpoints_module_basename( $file );
1109
+	$module_file = wordpoints_module_basename($file);
1110 1110
 
1111
-	add_action( "wordpoints_module_activate-{$module_file}", $function );
1111
+	add_action("wordpoints_module_activate-{$module_file}", $function);
1112 1112
 }
1113 1113
 
1114 1114
 /**
@@ -1119,11 +1119,11 @@  discard block
 block discarded – undo
1119 1119
  * @param string $file     The main file of the module the hook is for.
1120 1120
  * @param string $function The callback function.
1121 1121
  */
1122
-function wordpoints_register_module_deactivation_hook( $file, $function ) {
1122
+function wordpoints_register_module_deactivation_hook($file, $function) {
1123 1123
 
1124
-	$module_file = wordpoints_module_basename( $file );
1124
+	$module_file = wordpoints_module_basename($file);
1125 1125
 
1126
-	add_action( "wordpoints_deactivate_module-{$module_file}", $function );
1126
+	add_action("wordpoints_deactivate_module-{$module_file}", $function);
1127 1127
 }
1128 1128
 
1129 1129
 // EOF
Please login to merge, or discard this patch.
src/includes/functions.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
  *
40 40
  * @param bool $network_active Whether the plugin is being network activated.
41 41
  */
42
-function wordpoints_activate( $network_active ) {
42
+function wordpoints_activate($network_active) {
43 43
 
44 44
 	// The installer won't be registered yet.
45 45
 	wordpoints_register_installer();
46 46
 
47
-	WordPoints_Installables::install( 'plugin', 'wordpoints', $network_active );
47
+	WordPoints_Installables::install('plugin', 'wordpoints', $network_active);
48 48
 }
49 49
 
50 50
 /**
@@ -56,25 +56,25 @@  discard block
 block discarded – undo
56 56
  */
57 57
 function wordpoints_breaking_update() {
58 58
 
59
-	if ( is_wordpoints_network_active() ) {
60
-		$wordpoints_data = get_site_option( 'wordpoints_data' );
59
+	if (is_wordpoints_network_active()) {
60
+		$wordpoints_data = get_site_option('wordpoints_data');
61 61
 	} else {
62
-		$wordpoints_data = get_option( 'wordpoints_data' );
62
+		$wordpoints_data = get_option('wordpoints_data');
63 63
 	}
64 64
 
65 65
 	// Normally this should never happen, because the plugins_loaded action won't
66 66
 	// run until the next request after WordPoints is activated and installs itself.
67
-	if ( empty( $wordpoints_data['version'] ) ) {
67
+	if (empty($wordpoints_data['version'])) {
68 68
 		return;
69 69
 	}
70 70
 
71 71
 	// The major version is determined by the first number, so we can just cast to
72 72
 	// an integer. IF the major versions are equal, we don't need to do anything.
73
-	if ( (int) WORDPOINTS_VERSION === (int) $wordpoints_data['version'] ) {
73
+	if ((int) WORDPOINTS_VERSION === (int) $wordpoints_data['version']) {
74 74
 		return;
75 75
 	}
76 76
 
77
-	$updater = new WordPoints_Breaking_Updater( 'wordpoints_breaking', WORDPOINTS_VERSION );
77
+	$updater = new WordPoints_Breaking_Updater('wordpoints_breaking', WORDPOINTS_VERSION);
78 78
 	$updater->update();
79 79
 }
80 80
 
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
  */
89 89
 function wordpoints_maintenance_shutdown_print_rand_str() {
90 90
 
91
-	if ( ! isset( $_GET['wordpoints_module_check'] ) ) {
91
+	if ( ! isset($_GET['wordpoints_module_check'])) {
92 92
 		return;
93 93
 	}
94 94
 
95
-	if ( is_network_admin() ) {
96
-		$nonce = get_site_option( 'wordpoints_module_check_nonce' );
95
+	if (is_network_admin()) {
96
+		$nonce = get_site_option('wordpoints_module_check_nonce');
97 97
 	} else {
98
-		$nonce = get_option( 'wordpoints_module_check_nonce' );
98
+		$nonce = get_option('wordpoints_module_check_nonce');
99 99
 	}
100 100
 
101
-	if ( ! $nonce || ! hash_equals( $nonce, sanitize_key( $_GET['wordpoints_module_check'] ) ) ) {
101
+	if ( ! $nonce || ! hash_equals($nonce, sanitize_key($_GET['wordpoints_module_check']))) {
102 102
 		return;
103 103
 	}
104 104
 
105
-	if ( is_network_admin() ) {
106
-		$rand_str = get_site_option( 'wordpoints_module_check_rand_str' );
105
+	if (is_network_admin()) {
106
+		$rand_str = get_site_option('wordpoints_module_check_rand_str');
107 107
 	} else {
108
-		$rand_str = get_option( 'wordpoints_module_check_rand_str' );
108
+		$rand_str = get_option('wordpoints_module_check_rand_str');
109 109
 	}
110 110
 
111
-	echo esc_html( $rand_str );
111
+	echo esc_html($rand_str);
112 112
 }
113 113
 
114 114
 /**
@@ -126,29 +126,29 @@  discard block
 block discarded – undo
126 126
  *
127 127
  * @return array The modules whose compatibility is being checked.
128 128
  */
129
-function wordpoints_maintenance_filter_modules( $modules ) {
129
+function wordpoints_maintenance_filter_modules($modules) {
130 130
 
131
-	if ( ! isset( $_GET['check_module'], $_GET['wordpoints_module_check'] ) ) {
131
+	if ( ! isset($_GET['check_module'], $_GET['wordpoints_module_check'])) {
132 132
 		return $modules;
133 133
 	}
134 134
 
135
-	if ( is_network_admin() ) {
136
-		$nonce = get_site_option( 'wordpoints_module_check_nonce' );
135
+	if (is_network_admin()) {
136
+		$nonce = get_site_option('wordpoints_module_check_nonce');
137 137
 	} else {
138
-		$nonce = get_option( 'wordpoints_module_check_nonce' );
138
+		$nonce = get_option('wordpoints_module_check_nonce');
139 139
 	}
140 140
 
141
-	if ( ! $nonce || ! hash_equals( $nonce, sanitize_key( $_GET['wordpoints_module_check'] ) ) ) {
141
+	if ( ! $nonce || ! hash_equals($nonce, sanitize_key($_GET['wordpoints_module_check']))) {
142 142
 		return $modules;
143 143
 	}
144 144
 
145 145
 	$modules = explode(
146 146
 		','
147
-		, sanitize_text_field( wp_unslash( $_GET['check_module'] ) )
147
+		, sanitize_text_field(wp_unslash($_GET['check_module']))
148 148
 	);
149 149
 
150
-	if ( 'pre_site_option_wordpoints_sitewide_active_modules' === current_filter() ) {
151
-		$modules = array_flip( $modules );
150
+	if ('pre_site_option_wordpoints_sitewide_active_modules' === current_filter()) {
151
+		$modules = array_flip($modules);
152 152
 	}
153 153
 
154 154
 	return $modules;
@@ -175,16 +175,16 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return int|false False if $maybe_int couldn't reliably be converted to an integer.
177 177
  */
178
-function wordpoints_int( &$maybe_int ) {
178
+function wordpoints_int(&$maybe_int) {
179 179
 
180
-	$type = gettype( $maybe_int );
180
+	$type = gettype($maybe_int);
181 181
 
182
-	switch ( $type ) {
182
+	switch ($type) {
183 183
 
184 184
 		case 'integer': break;
185 185
 
186 186
 		case 'string':
187
-			if ( (string) (int) $maybe_int === $maybe_int ) {
187
+			if ((string) (int) $maybe_int === $maybe_int) {
188 188
 				$maybe_int = (int) $maybe_int;
189 189
 			} else {
190 190
 				$maybe_int = false;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		break;
193 193
 
194 194
 		case 'double':
195
-			if ( (float) (int) $maybe_int === $maybe_int ) {
195
+			if ((float) (int) $maybe_int === $maybe_int) {
196 196
 				$maybe_int = (int) $maybe_int;
197 197
 			} else {
198 198
 				$maybe_int = false;
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
  *
230 230
  * @return int
231 231
  */
232
-function wordpoints_posint( &$maybe_int ) {
232
+function wordpoints_posint(&$maybe_int) {
233 233
 
234
-	$maybe_int = ( wordpoints_int( $maybe_int ) > 0 ) ? $maybe_int : false;
234
+	$maybe_int = (wordpoints_int($maybe_int) > 0) ? $maybe_int : false;
235 235
 	return $maybe_int;
236 236
 }
237 237
 
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
  *
248 248
  * @return int
249 249
  */
250
-function wordpoints_negint( &$maybe_int ) {
250
+function wordpoints_negint(&$maybe_int) {
251 251
 
252
-	$maybe_int = ( wordpoints_int( $maybe_int ) < 0 ) ? $maybe_int : false;
252
+	$maybe_int = (wordpoints_int($maybe_int) < 0) ? $maybe_int : false;
253 253
 	return $maybe_int;
254 254
 }
255 255
 
@@ -284,38 +284,38 @@  discard block
 block discarded – undo
284 284
 	$request_type = 'get'
285 285
 ) {
286 286
 
287
-	if ( 'post' === $request_type ) {
287
+	if ('post' === $request_type) {
288 288
 		$request = $_POST; // WPCS: CSRF OK.
289 289
 	} else {
290 290
 		$request = $_GET;
291 291
 	}
292 292
 
293
-	if ( ! isset( $request[ $nonce_key ] ) ) {
293
+	if ( ! isset($request[$nonce_key])) {
294 294
 		return false;
295 295
 	}
296 296
 
297
-	if ( ! empty( $format_values ) ) {
297
+	if ( ! empty($format_values)) {
298 298
 
299 299
 		$values = array();
300 300
 
301
-		foreach ( (array) $format_values as $value ) {
301
+		foreach ((array) $format_values as $value) {
302 302
 
303
-			if ( ! isset( $request[ $value ] ) ) {
303
+			if ( ! isset($request[$value])) {
304 304
 				return false;
305 305
 			}
306 306
 
307
-			$values[] = $request[ $value ];
307
+			$values[] = $request[$value];
308 308
 		}
309 309
 
310
-		$action_format = vsprintf( $action_format, $values );
310
+		$action_format = vsprintf($action_format, $values);
311 311
 	}
312 312
 
313 313
 	$is_valid = wp_verify_nonce(
314
-		sanitize_key( $request[ $nonce_key ] )
315
-		, strip_tags( $action_format )
314
+		sanitize_key($request[$nonce_key])
315
+		, strip_tags($action_format)
316 316
 	);
317 317
 
318
-	if ( 1 === $is_valid || 2 === $is_valid ) {
318
+	if (1 === $is_valid || 2 === $is_valid) {
319 319
 		return $is_valid;
320 320
 	}
321 321
 
@@ -340,16 +340,16 @@  discard block
 block discarded – undo
340 340
  *
341 341
  * @return WP_Error The sanitized error.
342 342
  */
343
-function wordpoints_sanitize_wp_error( $error ) {
343
+function wordpoints_sanitize_wp_error($error) {
344 344
 
345 345
 	$code = $error->get_error_code();
346 346
 
347 347
 	$error_data = $error->error_data;
348 348
 
349
-	if ( isset( $error_data[ $code ]['title'] ) ) {
349
+	if (isset($error_data[$code]['title'])) {
350 350
 
351
-		$error_data[ $code ]['title'] = wp_kses(
352
-			$error->error_data[ $code ]['title']
351
+		$error_data[$code]['title'] = wp_kses(
352
+			$error->error_data[$code]['title']
353 353
 			, 'wordpoints_sanitize_wp_error_title'
354 354
 		);
355 355
 
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
 
359 359
 	$all_errors = $error->errors;
360 360
 
361
-	foreach ( $all_errors as $code => $errors ) {
361
+	foreach ($all_errors as $code => $errors) {
362 362
 
363
-		foreach ( $errors as $key => $message ) {
364
-			$all_errors[ $code ][ $key ] = wp_kses(
363
+		foreach ($errors as $key => $message) {
364
+			$all_errors[$code][$key] = wp_kses(
365 365
 				$message
366 366
 				, 'wordpoints_sanitize_wp_error_message'
367 367
 			);
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
  * @return string The escaped identifier. Already quoted, do not place within
389 389
  *                backticks.
390 390
  */
391
-function wordpoints_escape_mysql_identifier( $identifier ) {
392
-	return '`' . str_replace( '`', '``', $identifier ) . '`';
391
+function wordpoints_escape_mysql_identifier($identifier) {
392
+	return '`' . str_replace('`', '``', $identifier) . '`';
393 393
 }
394 394
 
395 395
 //
@@ -412,16 +412,16 @@  discard block
 block discarded – undo
412 412
  *
413 413
  * @return array The option value if it is an array, or an empty array if not.
414 414
  */
415
-function wordpoints_get_array_option( $option, $context = 'default' ) {
415
+function wordpoints_get_array_option($option, $context = 'default') {
416 416
 
417
-	switch ( $context ) {
417
+	switch ($context) {
418 418
 
419 419
 		case 'default':
420
-			$value = get_option( $option, array() );
420
+			$value = get_option($option, array());
421 421
 		break;
422 422
 
423 423
 		case 'site':
424
-			$value = get_site_option( $option, array() );
424
+			$value = get_site_option($option, array());
425 425
 		break;
426 426
 
427 427
 		case 'network':
@@ -431,15 +431,15 @@  discard block
 block discarded – undo
431 431
 				, 'Using "network" as the value of $context is deprecated, use wordpoints_get_maybe_network_array_option() instead.'
432 432
 			);
433 433
 
434
-			$value = wordpoints_get_maybe_network_option( $option, array() );
434
+			$value = wordpoints_get_maybe_network_option($option, array());
435 435
 		break;
436 436
 
437 437
 		default:
438
-			_doing_it_wrong( __FUNCTION__, sprintf( 'Unknown option context "%s"', esc_html( $context ) ), '1.2.0' );
438
+			_doing_it_wrong(__FUNCTION__, sprintf('Unknown option context "%s"', esc_html($context)), '1.2.0');
439 439
 			$value = array();
440 440
 	}
441 441
 
442
-	if ( ! is_array( $value ) ) {
442
+	if ( ! is_array($value)) {
443 443
 		$value = array();
444 444
 	}
445 445
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
  *
461 461
  * @return mixed The option value if it exists, or $default (false by default).
462 462
  */
463
-function wordpoints_get_network_option( $option, $default = false ) {
463
+function wordpoints_get_network_option($option, $default = false) {
464 464
 
465 465
 	_deprecated_function(
466 466
 		__FUNCTION__
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 		, 'wordpoints_get_maybe_network_option()'
469 469
 	);
470 470
 
471
-	return wordpoints_get_maybe_network_option( $option, null, $default );
471
+	return wordpoints_get_maybe_network_option($option, null, $default);
472 472
 }
473 473
 
474 474
 /**
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
  *
488 488
  * @return bool Whether the option was added successfully.
489 489
  */
490
-function wordpoints_add_network_option( $option, $value, $autoload = 'yes' ) {
490
+function wordpoints_add_network_option($option, $value, $autoload = 'yes') {
491 491
 
492 492
 	_deprecated_function(
493 493
 		__FUNCTION__
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 		, 'wordpoints_add_maybe_network_option()'
496 496
 	);
497 497
 
498
-	return wordpoints_add_maybe_network_option( $option, $value, null, $autoload );
498
+	return wordpoints_add_maybe_network_option($option, $value, null, $autoload);
499 499
 }
500 500
 
501 501
 /**
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
  *
513 513
  * @return bool Whether the option was updated successfully.
514 514
  */
515
-function wordpoints_update_network_option( $option, $value ) {
515
+function wordpoints_update_network_option($option, $value) {
516 516
 
517 517
 	_deprecated_function(
518 518
 		__FUNCTION__
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 		, 'wordpoints_update_maybe_network_option()'
521 521
 	);
522 522
 
523
-	return wordpoints_update_maybe_network_option( $option, $value );
523
+	return wordpoints_update_maybe_network_option($option, $value);
524 524
 }
525 525
 
526 526
 /**
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
  *
537 537
  * @return bool Whether the option was successfully deleted.
538 538
  */
539
-function wordpoints_delete_network_option( $option ) {
539
+function wordpoints_delete_network_option($option) {
540 540
 
541 541
 	_deprecated_function(
542 542
 		__FUNCTION__
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		, 'wordpoints_delete_maybe_network_option()'
545 545
 	);
546 546
 
547
-	return wordpoints_delete_maybe_network_option( $option );
547
+	return wordpoints_delete_maybe_network_option($option);
548 548
 }
549 549
 
550 550
 /**
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
  *
564 564
  * @return array The option value if it is an array, or an empty array if not.
565 565
  */
566
-function wordpoints_get_maybe_network_array_option( $option, $network = null ) {
566
+function wordpoints_get_maybe_network_array_option($option, $network = null) {
567 567
 
568
-	$value = wordpoints_get_maybe_network_option( $option, $network );
568
+	$value = wordpoints_get_maybe_network_option($option, $network);
569 569
 
570
-	if ( ! is_array( $value ) ) {
570
+	if ( ! is_array($value)) {
571 571
 		$value = array();
572 572
 	}
573 573
 
@@ -588,12 +588,12 @@  discard block
 block discarded – undo
588 588
  *
589 589
  * @return mixed The option value if it exists, or $default (false by default).
590 590
  */
591
-function wordpoints_get_maybe_network_option( $option, $network = null, $default = false ) {
591
+function wordpoints_get_maybe_network_option($option, $network = null, $default = false) {
592 592
 
593
-	if ( $network || ( null === $network && is_wordpoints_network_active() ) ) {
594
-		return get_site_option( $option, $default );
593
+	if ($network || (null === $network && is_wordpoints_network_active())) {
594
+		return get_site_option($option, $default);
595 595
 	} else {
596
-		return get_option( $option, $default );
596
+		return get_option($option, $default);
597 597
 	}
598 598
 }
599 599
 
@@ -613,12 +613,12 @@  discard block
 block discarded – undo
613 613
  *
614 614
  * @return bool Whether the option was added successfully.
615 615
  */
616
-function wordpoints_add_maybe_network_option( $option, $value, $network = null, $autoload = 'yes' ) {
616
+function wordpoints_add_maybe_network_option($option, $value, $network = null, $autoload = 'yes') {
617 617
 
618
-	if ( $network || ( null === $network && is_wordpoints_network_active() ) ) {
619
-		return add_site_option( $option, $value );
618
+	if ($network || (null === $network && is_wordpoints_network_active())) {
619
+		return add_site_option($option, $value);
620 620
 	} else {
621
-		return add_option( $option, $value, '', $autoload );
621
+		return add_option($option, $value, '', $autoload);
622 622
 	}
623 623
 }
624 624
 
@@ -636,12 +636,12 @@  discard block
 block discarded – undo
636 636
  *
637 637
  * @return bool Whether the option was updated successfully.
638 638
  */
639
-function wordpoints_update_maybe_network_option( $option, $value, $network = null ) {
639
+function wordpoints_update_maybe_network_option($option, $value, $network = null) {
640 640
 
641
-	if ( $network || ( null === $network && is_wordpoints_network_active() ) ) {
642
-		return update_site_option( $option, $value );
641
+	if ($network || (null === $network && is_wordpoints_network_active())) {
642
+		return update_site_option($option, $value);
643 643
 	} else {
644
-		return update_option( $option, $value );
644
+		return update_option($option, $value);
645 645
 	}
646 646
 }
647 647
 
@@ -658,12 +658,12 @@  discard block
 block discarded – undo
658 658
  *
659 659
  * @return bool Whether the option was successfully deleted.
660 660
  */
661
-function wordpoints_delete_maybe_network_option( $option, $network = null ) {
661
+function wordpoints_delete_maybe_network_option($option, $network = null) {
662 662
 
663
-	if ( $network || ( null === $network && is_wordpoints_network_active() ) ) {
664
-		return delete_site_option( $option );
663
+	if ($network || (null === $network && is_wordpoints_network_active())) {
664
+		return delete_site_option($option);
665 665
 	} else {
666
-		return delete_option( $option );
666
+		return delete_option($option);
667 667
 	}
668 668
 }
669 669
 
@@ -681,36 +681,36 @@  discard block
 block discarded – undo
681 681
  *
682 682
  * @return string|false The comma-delimited string of values. False on failure.
683 683
  */
684
-function wordpoints_prepare__in( $_in, $format = '%s' ) {
684
+function wordpoints_prepare__in($_in, $format = '%s') {
685 685
 
686 686
 	global $wpdb;
687 687
 
688 688
 	// Validate $format.
689
-	$formats = array( '%d', '%s', '%f' );
689
+	$formats = array('%d', '%s', '%f');
690 690
 
691
-	if ( ! in_array( $format, $formats ) ) {
691
+	if ( ! in_array($format, $formats)) {
692 692
 
693
-		$format = esc_html( $format );
694
-		_doing_it_wrong( __FUNCTION__, esc_html( "WordPoints Debug Error: invalid format '{$format}', allowed values are %s, %d, and %f" ), '1.0.0' );
693
+		$format = esc_html($format);
694
+		_doing_it_wrong(__FUNCTION__, esc_html("WordPoints Debug Error: invalid format '{$format}', allowed values are %s, %d, and %f"), '1.0.0');
695 695
 
696 696
 		$format = '%s';
697 697
 	}
698 698
 
699
-	$_in = array_unique( $_in );
699
+	$_in = array_unique($_in);
700 700
 
701
-	$count = count( $_in );
701
+	$count = count($_in);
702 702
 
703
-	if ( 0 === $count ) {
703
+	if (0 === $count) {
704 704
 
705
-		_doing_it_wrong( __FUNCTION__, 'WordPoints Debug Error: empty array passed as first parameter', '1.0.0' );
705
+		_doing_it_wrong(__FUNCTION__, 'WordPoints Debug Error: empty array passed as first parameter', '1.0.0');
706 706
 
707 707
 		return false;
708 708
 	}
709 709
 
710 710
 	// String a bunch of format signs together, one for each value in $_in.
711
-	$in = $format . str_repeat( ",{$format}", $count - 1 );
711
+	$in = $format . str_repeat(",{$format}", $count - 1);
712 712
 
713
-	return $wpdb->prepare( $in, $_in ); // WPCS: unprepared SQL OK
713
+	return $wpdb->prepare($in, $_in); // WPCS: unprepared SQL OK
714 714
 }
715 715
 
716 716
 //
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
  * }
739 739
  * @param array $args Arguments to pass to get_post_types(). Default is array().
740 740
  */
741
-function wordpoints_list_post_types( $options, $args = array() ) {
741
+function wordpoints_list_post_types($options, $args = array()) {
742 742
 
743 743
 	$defaults = array(
744 744
 		'name'     => '',
@@ -748,18 +748,18 @@  discard block
 block discarded – undo
748 748
 		'filter'   => null,
749 749
 	);
750 750
 
751
-	$options = array_merge( $defaults, $options );
751
+	$options = array_merge($defaults, $options);
752 752
 
753
-	echo '<select class="' . esc_attr( $options['class'] ) . '" name="' . esc_attr( $options['name'] ) . '" id="' . esc_attr( $options['id'] ) . '">';
754
-	echo '<option value="ALL"' . selected( $options['selected'], 'ALL', false ) . '>' . esc_html_x( 'Any', 'post type', 'wordpoints' ) . '</option>';
753
+	echo '<select class="' . esc_attr($options['class']) . '" name="' . esc_attr($options['name']) . '" id="' . esc_attr($options['id']) . '">';
754
+	echo '<option value="ALL"' . selected($options['selected'], 'ALL', false) . '>' . esc_html_x('Any', 'post type', 'wordpoints') . '</option>';
755 755
 
756
-	foreach ( get_post_types( $args, 'objects' ) as $post_type ) {
756
+	foreach (get_post_types($args, 'objects') as $post_type) {
757 757
 
758
-		if ( isset( $options['filter'] ) && ! call_user_func( $options['filter'], $post_type ) ) {
758
+		if (isset($options['filter']) && ! call_user_func($options['filter'], $post_type)) {
759 759
 			continue;
760 760
 		}
761 761
 
762
-		echo '<option value="' . esc_attr( $post_type->name ) . '"' . selected( $options['selected'], $post_type->name, false ) . '>' . esc_html( $post_type->label ) . '</option>';
762
+		echo '<option value="' . esc_attr($post_type->name) . '"' . selected($options['selected'], $post_type->name, false) . '>' . esc_html($post_type->label) . '</option>';
763 763
 	}
764 764
 
765 765
 	echo '</select>';
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 	require_once ABSPATH . '/wp-admin/includes/plugin.php';
782 782
 
783 783
 	$network_active = is_plugin_active_for_network(
784
-		plugin_basename( WORDPOINTS_DIR . 'wordpoints.php' )
784
+		plugin_basename(WORDPOINTS_DIR . 'wordpoints.php')
785 785
 	);
786 786
 
787 787
 	/**
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 	 *
795 795
 	 * @param bool $network_active Whether WordPoints is network activated.
796 796
 	 */
797
-	return apply_filters( 'is_wordpoints_network_active', $network_active );
797
+	return apply_filters('is_wordpoints_network_active', $network_active);
798 798
 }
799 799
 
800 800
 /**
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
  *
811 811
  * @return array An array of user IDs to exclude in the current $context.
812 812
  */
813
-function wordpoints_get_excluded_users( $context ) {
813
+function wordpoints_get_excluded_users($context) {
814 814
 
815 815
 	$user_ids = wordpoints_get_maybe_network_array_option(
816 816
 		'wordpoints_excluded_users'
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 	 * @param int[]  $user_ids The ids of the user's to be excluded.
827 827
 	 * @param string $context  The context in which the function is being called.
828 828
 	 */
829
-	return apply_filters( 'wordpoints_excluded_users', $user_ids, $context );
829
+	return apply_filters('wordpoints_excluded_users', $user_ids, $context);
830 830
 }
831 831
 
832 832
 /**
@@ -842,18 +842,18 @@  discard block
 block discarded – undo
842 842
  *
843 843
  * @return string The error message.
844 844
  */
845
-function wordpoints_shortcode_error( $message ) {
845
+function wordpoints_shortcode_error($message) {
846 846
 
847 847
 	if (
848
-		( get_post() && current_user_can( 'edit_post', get_the_ID() ) )
849
-		|| current_user_can( 'manage_options' )
848
+		(get_post() && current_user_can('edit_post', get_the_ID()))
849
+		|| current_user_can('manage_options')
850 850
 	) {
851 851
 
852
-		if ( is_wp_error( $message ) ) {
852
+		if (is_wp_error($message)) {
853 853
 			$message = $message->get_error_message();
854 854
 		}
855 855
 
856
-		return '<p class="wordpoints-shortcode-error">' . esc_html__( 'Shortcode error:', 'wordpoints' ) . ' ' . wp_kses( $message, 'wordpoints_shortcode_error' ) . '</p>';
856
+		return '<p class="wordpoints-shortcode-error">' . esc_html__('Shortcode error:', 'wordpoints') . ' ' . wp_kses($message, 'wordpoints_shortcode_error') . '</p>';
857 857
 	}
858 858
 
859 859
 	return '';
@@ -886,14 +886,14 @@  discard block
 block discarded – undo
886 886
  * @param array $capabilities The capabilities to add as keys, WP core counterparts
887 887
  *                            as values.
888 888
  */
889
-function wordpoints_add_custom_caps( $capabilities ) {
889
+function wordpoints_add_custom_caps($capabilities) {
890 890
 
891 891
 	/** @var WP_Role $role */
892
-	foreach ( wp_roles()->role_objects as $role ) {
892
+	foreach (wp_roles()->role_objects as $role) {
893 893
 
894
-		foreach ( $capabilities as $custom_cap => $core_cap ) {
895
-			if ( $role->has_cap( $core_cap ) ) {
896
-				$role->add_cap( $custom_cap );
894
+		foreach ($capabilities as $custom_cap => $core_cap) {
895
+			if ($role->has_cap($core_cap)) {
896
+				$role->add_cap($custom_cap);
897 897
 			}
898 898
 		}
899 899
 	}
@@ -908,12 +908,12 @@  discard block
 block discarded – undo
908 908
  *
909 909
  * @param string[] $capabilities The list of capabilities to remove.
910 910
  */
911
-function wordpoints_remove_custom_caps( $capabilities ) {
911
+function wordpoints_remove_custom_caps($capabilities) {
912 912
 
913 913
 	/** @var WP_Role $role */
914
-	foreach ( wp_roles()->role_objects as $role ) {
915
-		foreach ( $capabilities as $custom_cap ) {
916
-			$role->remove_cap( $custom_cap );
914
+	foreach (wp_roles()->role_objects as $role) {
915
+		foreach ($capabilities as $custom_cap) {
916
+			$role->remove_cap($custom_cap);
917 917
 		}
918 918
 	}
919 919
 }
@@ -931,13 +931,13 @@  discard block
 block discarded – undo
931 931
  *
932 932
  * @return array The user's capabilities.
933 933
  */
934
-function wordpoints_map_custom_meta_caps( $caps, $cap, $user_id ) {
934
+function wordpoints_map_custom_meta_caps($caps, $cap, $user_id) {
935 935
 
936
-	switch ( $cap ) {
936
+	switch ($cap) {
937 937
 		case 'install_wordpoints_modules':
938
-			if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
938
+			if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
939 939
 				$caps[] = 'do_not_allow';
940
-			} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
940
+			} elseif (is_multisite() && ! is_super_admin($user_id)) {
941 941
 				$caps[] = 'do_not_allow';
942 942
 			} else {
943 943
 				$caps[] = $cap;
@@ -959,9 +959,9 @@  discard block
 block discarded – undo
959 959
  *
960 960
  * @return bool Whether the component was registered.
961 961
  */
962
-function wordpoints_component_register( $args ) {
962
+function wordpoints_component_register($args) {
963 963
 
964
-	return WordPoints_Components::instance()->register( $args );
964
+	return WordPoints_Components::instance()->register($args);
965 965
 }
966 966
 
967 967
 /**
@@ -975,9 +975,9 @@  discard block
 block discarded – undo
975 975
  *
976 976
  * @return bool Whether the component is active.
977 977
  */
978
-function wordpoints_component_is_active( $slug ) {
978
+function wordpoints_component_is_active($slug) {
979 979
 
980
-	return WordPoints_Components::instance()->is_active( $slug );
980
+	return WordPoints_Components::instance()->is_active($slug);
981 981
 }
982 982
 
983 983
 /**
@@ -994,12 +994,12 @@  discard block
 block discarded – undo
994 994
 	wordpoints_component_register(
995 995
 		array(
996 996
 			'slug'          => 'points',
997
-			'name'          => _x( 'Points', 'component name', 'wordpoints' ),
997
+			'name'          => _x('Points', 'component name', 'wordpoints'),
998 998
 			'version'       => WORDPOINTS_VERSION,
999
-			'author'        => _x( 'WordPoints', 'component author', 'wordpoints' ),
999
+			'author'        => _x('WordPoints', 'component author', 'wordpoints'),
1000 1000
 			'author_uri'    => 'https://wordpoints.org/',
1001 1001
 			'component_uri' => 'https://wordpoints.org/',
1002
-			'description'   => __( 'Enables a points system for your site.', 'wordpoints' ),
1002
+			'description'   => __('Enables a points system for your site.', 'wordpoints'),
1003 1003
 			'file'          => WORDPOINTS_DIR . 'components/points/points.php',
1004 1004
 			'un_installer'  => WORDPOINTS_DIR . 'components/points/includes/class-un-installer.php',
1005 1005
 		)
@@ -1018,12 +1018,12 @@  discard block
 block discarded – undo
1018 1018
 	wordpoints_component_register(
1019 1019
 		array(
1020 1020
 			'slug'           => 'ranks',
1021
-			'name'           => _x( 'Ranks', 'component name', 'wordpoints' ),
1021
+			'name'           => _x('Ranks', 'component name', 'wordpoints'),
1022 1022
 			'version'        => WORDPOINTS_VERSION,
1023
-			'author'         => _x( 'WordPoints', 'component author', 'wordpoints' ),
1023
+			'author'         => _x('WordPoints', 'component author', 'wordpoints'),
1024 1024
 			'author_uri'     => 'https://wordpoints.org/',
1025 1025
 			'component_uri'  => 'https://wordpoints.org/',
1026
-			'description'    => __( 'Assign users ranks based on their points levels.', 'wordpoints' ),
1026
+			'description'    => __('Assign users ranks based on their points levels.', 'wordpoints'),
1027 1027
 			'file'           => WORDPOINTS_DIR . 'components/ranks/ranks.php',
1028 1028
 			'un_installer'   => WORDPOINTS_DIR . 'components/ranks/includes/class-un-installer.php',
1029 1029
 		)
@@ -1040,11 +1040,11 @@  discard block
 block discarded – undo
1040 1040
  */
1041 1041
 function wordpoints_init_cache_groups() {
1042 1042
 
1043
-	if ( function_exists( 'wp_cache_add_non_persistent_groups' ) ) {
1044
-		wp_cache_add_non_persistent_groups( array( 'wordpoints_modules' ) );
1043
+	if (function_exists('wp_cache_add_non_persistent_groups')) {
1044
+		wp_cache_add_non_persistent_groups(array('wordpoints_modules'));
1045 1045
 	}
1046 1046
 
1047
-	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
1047
+	if (function_exists('wp_cache_add_global_groups')) {
1048 1048
 
1049 1049
 		wp_cache_add_global_groups(
1050 1050
 			array(
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
  */
1079 1079
 function wordpoints_load_textdomain() {
1080 1080
 
1081
-	load_plugin_textdomain( 'wordpoints', false, plugin_basename( WORDPOINTS_DIR ) . '/languages/' );
1081
+	load_plugin_textdomain('wordpoints', false, plugin_basename(WORDPOINTS_DIR) . '/languages/');
1082 1082
 }
1083 1083
 
1084 1084
 /**
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
  *
1097 1097
  * @return string The hash.
1098 1098
  */
1099
-function wordpoints_hash( $data ) {
1100
-	return hash( 'sha256', $data );
1099
+function wordpoints_hash($data) {
1100
+	return hash('sha256', $data);
1101 1101
 }
1102 1102
 
1103 1103
 /**
@@ -1110,19 +1110,19 @@  discard block
 block discarded – undo
1110 1110
  *
1111 1111
  * @return object|false The constructed object, or false if to many args were passed.
1112 1112
  */
1113
-function wordpoints_construct_class_with_args( $class_name, array $args ) {
1113
+function wordpoints_construct_class_with_args($class_name, array $args) {
1114 1114
 
1115
-	switch ( count( $args ) ) {
1115
+	switch (count($args)) {
1116 1116
 		case 0:
1117 1117
 			return new $class_name();
1118 1118
 		case 1:
1119
-			return new $class_name( $args[0] );
1119
+			return new $class_name($args[0]);
1120 1120
 		case 2:
1121
-			return new $class_name( $args[0], $args[1] );
1121
+			return new $class_name($args[0], $args[1]);
1122 1122
 		case 3:
1123
-			return new $class_name( $args[0], $args[1], $args[2] );
1123
+			return new $class_name($args[0], $args[1], $args[2]);
1124 1124
 		case 4:
1125
-			return new $class_name( $args[0], $args[1], $args[2], $args[3] );
1125
+			return new $class_name($args[0], $args[1], $args[2], $args[3]);
1126 1126
 		default:
1127 1127
 			return false;
1128 1128
 	}
@@ -1137,13 +1137,13 @@  discard block
 block discarded – undo
1137 1137
  *
1138 1138
  * @return bool Whether the function is disabled.
1139 1139
  */
1140
-function wordpoints_is_function_disabled( $function ) {
1140
+function wordpoints_is_function_disabled($function) {
1141 1141
 
1142
-	if ( 'set_time_limit' === $function && ini_get( 'safe_mode' ) ) {
1142
+	if ('set_time_limit' === $function && ini_get('safe_mode')) {
1143 1143
 		return true;
1144 1144
 	}
1145 1145
 
1146
-	return in_array( $function, explode( ',', ini_get( 'disable_functions' ) ) );
1146
+	return in_array($function, explode(',', ini_get('disable_functions')));
1147 1147
 }
1148 1148
 
1149 1149
 // EOF
Please login to merge, or discard this patch.
src/includes/class-shortcode.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,6 +8,6 @@
 block discarded – undo
8 8
  * @deprecated 2.3.0
9 9
  */
10 10
 
11
-_deprecated_file( __FILE__, '2.3.0', 'classes/shortcode.php' );
11
+_deprecated_file(__FILE__, '2.3.0', 'classes/shortcode.php');
12 12
 
13 13
 // EOF
Please login to merge, or discard this patch.
src/classes/module/paths.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -64,30 +64,30 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return bool Whether the path was able to be registered.
66 66
 	 */
67
-	public static function register( $file ) {
67
+	public static function register($file) {
68 68
 
69
-		$file = wp_normalize_path( $file );
69
+		$file = wp_normalize_path($file);
70 70
 
71 71
 		// We store this so that we don't have to keep normalizing a constant value.
72
-		if ( ! isset( self::$modules_dir ) ) {
73
-			self::$modules_dir = wp_normalize_path( wordpoints_modules_dir() );
72
+		if ( ! isset(self::$modules_dir)) {
73
+			self::$modules_dir = wp_normalize_path(wordpoints_modules_dir());
74 74
 		}
75 75
 
76
-		$module_path = wp_normalize_path( dirname( $file ) );
76
+		$module_path = wp_normalize_path(dirname($file));
77 77
 
78 78
 		// It was a single-file module.
79
-		if ( $module_path . '/' === self::$modules_dir ) {
79
+		if ($module_path . '/' === self::$modules_dir) {
80 80
 			return false;
81 81
 		}
82 82
 
83
-		$module_realpath = wp_normalize_path( dirname( realpath( $file ) ) );
83
+		$module_realpath = wp_normalize_path(dirname(realpath($file)));
84 84
 
85
-		if ( $module_path !== $module_realpath ) {
85
+		if ($module_path !== $module_realpath) {
86 86
 
87
-			$realpath_length = strlen( $module_realpath );
87
+			$realpath_length = strlen($module_realpath);
88 88
 
89 89
 			// Use unique keys, but still easy to sort by realpath length.
90
-			self::$paths[ $realpath_length . '-' . $module_path ] = array(
90
+			self::$paths[$realpath_length . '-' . $module_path] = array(
91 91
 				'module_path'     => $module_path,
92 92
 				'module_realpath' => $module_realpath,
93 93
 				'realpath_length' => $realpath_length,
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return string The path to the symlink in the modules directory.
110 110
 	 */
111
-	public static function resolve( $file ) {
111
+	public static function resolve($file) {
112 112
 
113
-		$file = wp_normalize_path( $file );
113
+		$file = wp_normalize_path($file);
114 114
 
115 115
 		// Sort the paths by the realpath length, see https://core.trac.wordpress.org/ticket/28441.
116
-		if ( ! self::$paths_sorted ) {
117
-			krsort( self::$paths );
116
+		if ( ! self::$paths_sorted) {
117
+			krsort(self::$paths);
118 118
 			self::$paths_sorted = true;
119 119
 		}
120 120
 
121
-		foreach ( self::$paths as $path ) {
122
-			if ( 0 === strpos( $file, $path['module_realpath'] ) ) {
123
-				$file = $path['module_path'] . substr( $file, $path['realpath_length'] );
121
+		foreach (self::$paths as $path) {
122
+			if (0 === strpos($file, $path['module_realpath'])) {
123
+				$file = $path['module_path'] . substr($file, $path['realpath_length']);
124 124
 			}
125 125
 		}
126 126
 
Please login to merge, or discard this patch.
src/classes/shortcode.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 	 * @param string $content   The shortcode's content.
94 94
 	 * @param string $shortcode The shortcode's name.
95 95
 	 */
96
-	public function __construct( $atts, $content, $shortcode = null ) {
96
+	public function __construct($atts, $content, $shortcode = null) {
97 97
 
98 98
 		$this->atts = $atts;
99 99
 		$this->content = $content;
100 100
 
101
-		if ( isset( $shortcode ) ) {
101
+		if (isset($shortcode)) {
102 102
 			$this->shortcode = $shortcode;
103 103
 		}
104 104
 	}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function expand() {
118 118
 
119
-		$this->atts = shortcode_atts( $this->pairs, $this->atts, $this->shortcode );
119
+		$this->atts = shortcode_atts($this->pairs, $this->atts, $this->shortcode);
120 120
 
121 121
 		/**
122 122
 		 * Filter the shortcode attribute values supplied by the user.
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 
146 146
 		$error = $this->verify_atts();
147 147
 
148
-		if ( ! empty( $error ) ) {
149
-			return wordpoints_shortcode_error( $error );
148
+		if ( ! empty($error)) {
149
+			return wordpoints_shortcode_error($error);
150 150
 		}
151 151
 
152 152
 		return $this->generate();
@@ -171,16 +171,16 @@  discard block
 block discarded – undo
171 171
 	protected function verify_atts() {
172 172
 
173 173
 		// If this shortcode supports the user_id attribute, verify it.
174
-		if ( isset( $this->pairs['user_id'] ) ) {
174
+		if (isset($this->pairs['user_id'])) {
175 175
 
176
-			if ( 'post_author' === $this->atts['user_id'] ) {
176
+			if ('post_author' === $this->atts['user_id']) {
177 177
 
178 178
 				$post = get_post();
179 179
 
180
-				if ( ! $post ) {
180
+				if ( ! $post) {
181 181
 					return sprintf(
182 182
 						// translators: 1. Attribute name; 2. Shortcode name.
183
-						esc_html__( 'The &#8220;%1$s&#8221; attribute of the %2$s shortcode must be used inside of a Post, Page, or other post type.', 'wordpoints' )
183
+						esc_html__('The &#8220;%1$s&#8221; attribute of the %2$s shortcode must be used inside of a Post, Page, or other post type.', 'wordpoints')
184 184
 						, 'user_id="post_author"'
185 185
 						, "<code>[{$this->shortcode}]</code>"
186 186
 					);
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 
189 189
 				$this->atts['user_id'] = $post->post_author;
190 190
 
191
-			} elseif ( ! $this->atts['user_id'] ) {
191
+			} elseif ( ! $this->atts['user_id']) {
192 192
 
193 193
 				$this->atts['user_id'] = get_current_user_id();
194 194
 
195
-			} elseif ( ! wordpoints_posint( $this->atts['user_id'] ) ) {
195
+			} elseif ( ! wordpoints_posint($this->atts['user_id'])) {
196 196
 
197 197
 				return sprintf(
198 198
 					// translators: 1. Attribute name; 2. Shortcode name; 3. Expected value.
199
-					esc_html__( 'Unrecognized value for the %1$s attribute of the %2$s shortcode. Expected &#8220;%3$s&#8221; or a user ID.', 'wordpoints' )
199
+					esc_html__('Unrecognized value for the %1$s attribute of the %2$s shortcode. Expected &#8220;%3$s&#8221; or a user ID.', 'wordpoints')
200 200
 					, 'user_id'
201 201
 					, "<code>[{$this->shortcode}]</code>"
202 202
 					, 'post_author'
Please login to merge, or discard this patch.