Completed
Push — master ( 8ff377...a97d75 )
by J.D.
04:02
created
src/includes/functions.php 1 patch
Spacing   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
  *
34 34
  * @param WordPoints_Class_Registry_Persistent $reactors The reactors registry.
35 35
  */
36
-function wordpoints_hook_reactors_init( $reactors ) {
36
+function wordpoints_hook_reactors_init($reactors) {
37 37
 
38
-	$reactors->register( 'points', 'WordPoints_Hook_Reactor_Points' );
39
-	$reactors->register( 'points_legacy', 'WordPoints_Hook_Reactor_Points_Legacy' );
38
+	$reactors->register('points', 'WordPoints_Hook_Reactor_Points');
39
+	$reactors->register('points_legacy', 'WordPoints_Hook_Reactor_Points_Legacy');
40 40
 }
41 41
 
42 42
 /**
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  *
49 49
  * @param WordPoints_Class_Registry_Children $reaction_stores The store registry.
50 50
  */
51
-function wordpoints_hook_reaction_stores_init( $reaction_stores ) {
51
+function wordpoints_hook_reaction_stores_init($reaction_stores) {
52 52
 
53 53
 	$reaction_stores->register(
54 54
 		'standard'
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		, 'WordPoints_Hook_Reaction_Store_Options'
57 57
 	);
58 58
 
59
-	if ( is_wordpoints_network_active() ) {
59
+	if (is_wordpoints_network_active()) {
60 60
 		$reaction_stores->register(
61 61
 			'network'
62 62
 			, 'points'
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
  *
75 75
  * @param WordPoints_Class_Registry_Persistent $extensions The extension registry.
76 76
  */
77
-function wordpoints_hook_extension_init( $extensions ) {
78
-
79
-	$extensions->register( 'blocker', 'WordPoints_Hook_Extension_Blocker' );
80
-	$extensions->register( 'repeat_blocker', 'WordPoints_Hook_Extension_Repeat_Blocker' );
81
-	$extensions->register( 'reversals', 'WordPoints_Hook_Extension_Reversals' );
82
-	$extensions->register( 'reversals_legacy_points', 'WordPoints_Hook_Extension_Reversals_Legacy_Points' );
83
-	$extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' );
84
-	$extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' );
77
+function wordpoints_hook_extension_init($extensions) {
78
+
79
+	$extensions->register('blocker', 'WordPoints_Hook_Extension_Blocker');
80
+	$extensions->register('repeat_blocker', 'WordPoints_Hook_Extension_Repeat_Blocker');
81
+	$extensions->register('reversals', 'WordPoints_Hook_Extension_Reversals');
82
+	$extensions->register('reversals_legacy_points', 'WordPoints_Hook_Extension_Reversals_Legacy_Points');
83
+	$extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions');
84
+	$extensions->register('periods', 'WordPoints_Hook_Extension_Periods');
85 85
 }
86 86
 
87 87
 /**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
  *
94 94
  * @param WordPoints_Class_Registry_Children $conditions The conditions registry.
95 95
  */
96
-function wordpoints_hook_conditions_init( $conditions ) {
96
+function wordpoints_hook_conditions_init($conditions) {
97 97
 
98 98
 	$conditions->register(
99 99
 		'text'
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
  *
130 130
  * @param WordPoints_Hook_Actions $actions The action registry.
131 131
  */
132
-function wordpoints_hook_actions_init( $actions ) {
132
+function wordpoints_hook_actions_init($actions) {
133 133
 
134 134
 	$actions->register(
135 135
 		'comment_approve'
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 		, array(
138 138
 			'action' => 'transition_comment_status',
139 139
 			'data'   => array(
140
-				'arg_index'    => array( 'comment' => 2 ),
141
-				'requirements' => array( 0 => 'approved' ),
140
+				'arg_index'    => array('comment' => 2),
141
+				'requirements' => array(0 => 'approved'),
142 142
 			),
143 143
 		)
144 144
 	);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		, array(
150 150
 			'action' => 'wp_insert_comment',
151 151
 			'data'   => array(
152
-				'arg_index' => array( 'comment' => 1 ),
152
+				'arg_index' => array('comment' => 1),
153 153
 			),
154 154
 		)
155 155
 	);
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 		, array(
161 161
 			'action' => 'transition_comment_status',
162 162
 			'data'   => array(
163
-				'arg_index' => array( 'comment' => 2 ),
164
-				'requirements' => array( 1 => 'approved' ),
163
+				'arg_index' => array('comment' => 2),
164
+				'requirements' => array(1 => 'approved'),
165 165
 			),
166 166
 		)
167 167
 	);
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 		, array(
174 174
 			'action' => 'transition_post_status',
175 175
 			'data'   => array(
176
-				'arg_index' => array( 'post' => 2 ),
177
-				'requirements' => array( 0 => 'publish' ),
176
+				'arg_index' => array('post' => 2),
177
+				'requirements' => array(0 => 'publish'),
178 178
 			),
179 179
 		)
180 180
 	);
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 		, array(
186 186
 			'action' => 'transition_post_status',
187 187
 			'data'   => array(
188
-				'arg_index' => array( 'post' => 2 ),
189
-				'requirements' => array( 1 => 'publish' ),
188
+				'arg_index' => array('post' => 2),
189
+				'requirements' => array(1 => 'publish'),
190 190
 			),
191 191
 		)
192 192
 	);
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		, array(
198 198
 			'action' => 'delete_post',
199 199
 			'data'   => array(
200
-				'arg_index' => array( 'post' => 0 ),
200
+				'arg_index' => array('post' => 0),
201 201
 			),
202 202
 		)
203 203
 	);
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		, array(
209 209
 			'action' => 'add_attachment',
210 210
 			'data'   => array(
211
-				'arg_index' => array( 'post\attachment' => 0 ),
211
+				'arg_index' => array('post\attachment' => 0),
212 212
 			),
213 213
 		)
214 214
 	);
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		, array(
220 220
 			'action' => 'delete_post',
221 221
 			'data'   => array(
222
-				'arg_index' => array( 'post' => 0 ),
222
+				'arg_index' => array('post' => 0),
223 223
 			),
224 224
 		)
225 225
 	);
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		, array(
231 231
 			'action' => 'user_register',
232 232
 			'data'   => array(
233
-				'arg_index' => array( 'user' => 0 ),
233
+				'arg_index' => array('user' => 0),
234 234
 			),
235 235
 		)
236 236
 	);
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		, array(
242 242
 			'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user',
243 243
 			'data'   => array(
244
-				'arg_index' => array( 'user' => 0 ),
244
+				'arg_index' => array('user' => 0),
245 245
 			),
246 246
 		)
247 247
 	);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
  *
265 265
  * @param WordPoints_Hook_Events $events The event registry.
266 266
  */
267
-function wordpoints_hook_events_init( $events ) {
267
+function wordpoints_hook_events_init($events) {
268 268
 
269 269
 	$events->register(
270 270
 		'user_register'
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	);
295 295
 
296 296
 	// Register events for all of the public post types.
297
-	$post_types = get_post_types( array( 'public' => true ) );
297
+	$post_types = get_post_types(array('public' => true));
298 298
 
299 299
 	/**
300 300
 	 * Filter which post types to register hook events for.
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @param string[] The post type slugs ("names").
305 305
 	 */
306
-	$post_types = apply_filters( 'wordpoints_register_hook_events_for_post_types', $post_types );
306
+	$post_types = apply_filters('wordpoints_register_hook_events_for_post_types', $post_types);
307 307
 
308
-	foreach ( $post_types as $slug ) {
309
-		wordpoints_register_post_type_hook_events( $slug );
308
+	foreach ($post_types as $slug) {
309
+		wordpoints_register_post_type_hook_events($slug);
310 310
 	}
311 311
 }
312 312
 
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
  *
320 320
  * @param WordPoints_App_Registry $entities The entities app.
321 321
  */
322
-function wordpoints_entities_app_init( $entities ) {
322
+function wordpoints_entities_app_init($entities) {
323 323
 
324
-	$entities->sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' );
325
-	$entities->sub_apps->register( 'contexts', 'WordPoints_Class_Registry' );
324
+	$entities->sub_apps->register('children', 'WordPoints_Class_Registry_Children');
325
+	$entities->sub_apps->register('contexts', 'WordPoints_Class_Registry');
326 326
 }
327 327
 
328 328
 /**
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
  *
335 335
  * @param WordPoints_Class_Registry $contexts The entity context registry.
336 336
  */
337
-function wordpoints_entity_contexts_init( $contexts ) {
337
+function wordpoints_entity_contexts_init($contexts) {
338 338
 
339
-	$contexts->register( 'network', 'WordPoints_Entity_Context_Network' );
340
-	$contexts->register( 'site', 'WordPoints_Entity_Context_Site' );
339
+	$contexts->register('network', 'WordPoints_Entity_Context_Network');
340
+	$contexts->register('site', 'WordPoints_Entity_Context_Site');
341 341
 }
342 342
 
343 343
 /**
@@ -349,17 +349,17 @@  discard block
 block discarded – undo
349 349
  *
350 350
  * @param WordPoints_App_Registry $entities The entities app.
351 351
  */
352
-function wordpoints_entities_init( $entities ) {
352
+function wordpoints_entities_init($entities) {
353 353
 
354 354
 	$children = $entities->children;
355 355
 
356
-	$entities->register( 'user', 'WordPoints_Entity_User' );
357
-	$children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' );
356
+	$entities->register('user', 'WordPoints_Entity_User');
357
+	$children->register('user', 'roles', 'WordPoints_Entity_User_Roles');
358 358
 
359
-	$entities->register( 'user_role', 'WordPoints_Entity_User_Role' );
359
+	$entities->register('user_role', 'WordPoints_Entity_User_Role');
360 360
 
361 361
 	// Register entities for all of the public post types.
362
-	$post_types = get_post_types( array( 'public' => true ) );
362
+	$post_types = get_post_types(array('public' => true));
363 363
 
364 364
 	/**
365 365
 	 * Filter which post types to register entities for.
@@ -368,14 +368,14 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @param string[] The post type slugs ("names").
370 370
 	 */
371
-	$post_types = apply_filters( 'wordpoints_register_entities_for_post_types', $post_types );
371
+	$post_types = apply_filters('wordpoints_register_entities_for_post_types', $post_types);
372 372
 
373
-	foreach ( $post_types as $slug ) {
374
-		wordpoints_register_post_type_entities( $slug );
373
+	foreach ($post_types as $slug) {
374
+		wordpoints_register_post_type_entities($slug);
375 375
 	}
376 376
 
377 377
 	// Register entities for all of the public taxonomies.
378
-	$taxonomies = get_taxonomies( array( 'public' => true ) );
378
+	$taxonomies = get_taxonomies(array('public' => true));
379 379
 
380 380
 	/**
381 381
 	 * Filter which taxonomies to register entities for.
@@ -384,10 +384,10 @@  discard block
 block discarded – undo
384 384
 	 *
385 385
 	 * @param string[] The taxonomy slugs.
386 386
 	 */
387
-	$taxonomies = apply_filters( 'wordpoints_register_entities_for_taxonomies', $taxonomies );
387
+	$taxonomies = apply_filters('wordpoints_register_entities_for_taxonomies', $taxonomies);
388 388
 
389
-	foreach ( $taxonomies as $slug ) {
390
-		wordpoints_register_taxonomy_entities( $slug );
389
+	foreach ($taxonomies as $slug) {
390
+		wordpoints_register_taxonomy_entities($slug);
391 391
 	}
392 392
 }
393 393
 
@@ -398,28 +398,28 @@  discard block
 block discarded – undo
398 398
  *
399 399
  * @param string $slug The slug of the post type.
400 400
  */
401
-function wordpoints_register_post_type_entities( $slug ) {
401
+function wordpoints_register_post_type_entities($slug) {
402 402
 
403 403
 	$entities = wordpoints_entities();
404 404
 	$children = $entities->children;
405 405
 
406
-	$entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' );
407
-	$children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' );
406
+	$entities->register("post\\{$slug}", 'WordPoints_Entity_Post');
407
+	$children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author');
408 408
 
409
-	$supports = get_all_post_type_supports( $slug );
409
+	$supports = get_all_post_type_supports($slug);
410 410
 
411
-	if ( isset( $supports['editor'] ) ) {
412
-		$children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' );
411
+	if (isset($supports['editor'])) {
412
+		$children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content');
413 413
 	}
414 414
 
415
-	if ( isset( $supports['comments'] ) ) {
416
-		$entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' );
417
-		$children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' );
418
-		$children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' );
415
+	if (isset($supports['comments'])) {
416
+		$entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment');
417
+		$children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post');
418
+		$children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author');
419 419
 	}
420 420
 
421
-	foreach ( get_object_taxonomies( $slug ) as $taxonomy_slug ) {
422
-		$children->register( "post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms' );
421
+	foreach (get_object_taxonomies($slug) as $taxonomy_slug) {
422
+		$children->register("post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms');
423 423
 	}
424 424
 
425 425
 	/**
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 *
430 430
 	 * @param string $slug The slug ("name") of the post type.
431 431
 	 */
432
-	do_action( 'wordpoints_register_post_type_entities', $slug );
432
+	do_action('wordpoints_register_post_type_entities', $slug);
433 433
 }
434 434
 
435 435
 /**
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
  *
440 440
  * @param string $slug The slug of the post type.
441 441
  */
442
-function wordpoints_register_post_type_hook_events( $slug ) {
442
+function wordpoints_register_post_type_hook_events($slug) {
443 443
 
444 444
 	$events = wordpoints_hooks()->events;
445 445
 
446
-	if ( 'attachment' === $slug ) {
446
+	if ('attachment' === $slug) {
447 447
 
448 448
 		$events->register(
449 449
 			'media_upload'
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 			, array(
468 468
 				'actions' => array(
469 469
 					'toggle_on'  => 'post_publish',
470
-					'toggle_off' => array( 'post_depublish', 'post_depublish_delete' ),
470
+					'toggle_off' => array('post_depublish', 'post_depublish_delete'),
471 471
 				),
472 472
 				'args'    => array(
473 473
 					"post\\{$slug}" => 'WordPoints_Hook_Arg_Dynamic',
@@ -476,14 +476,14 @@  discard block
 block discarded – undo
476 476
 		);
477 477
 	}
478 478
 
479
-	if ( post_type_supports( $slug, 'comments' ) ) {
479
+	if (post_type_supports($slug, 'comments')) {
480 480
 
481 481
 		$events->register(
482 482
 			"comment_leave\\{$slug}"
483 483
 			, 'WordPoints_Hook_Event_Comment_Leave'
484 484
 			, array(
485 485
 				'actions' => array(
486
-					'toggle_on'  => array( 'comment_approve', 'comment_new' ),
486
+					'toggle_on'  => array('comment_approve', 'comment_new'),
487 487
 					'toggle_off' => 'comment_deapprove',
488 488
 				),
489 489
 				'args' => array(
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	 *
501 501
 	 * @param string $slug The slug ("name") of the post type.
502 502
 	 */
503
-	do_action( 'wordpoints_register_post_type_hook_events', $slug );
503
+	do_action('wordpoints_register_post_type_hook_events', $slug);
504 504
 }
505 505
 
506 506
 /**
@@ -510,13 +510,13 @@  discard block
 block discarded – undo
510 510
  *
511 511
  * @param string $slug The slug of the taxonomy.
512 512
  */
513
-function wordpoints_register_taxonomy_entities( $slug ) {
513
+function wordpoints_register_taxonomy_entities($slug) {
514 514
 
515 515
 	$entities = wordpoints_entities();
516 516
 	$children = $entities->children;
517 517
 
518
-	$entities->register( "term\\{$slug}", 'WordPoints_Entity_Term' );
519
-	$children->register( "term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id' );
518
+	$entities->register("term\\{$slug}", 'WordPoints_Entity_Term');
519
+	$children->register("term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id');
520 520
 
521 521
 	/**
522 522
 	 * Fired when registering the entities for a taxonomy.
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 	 *
526 526
 	 * @param string $slug The taxonomy's slug.
527 527
 	 */
528
-	do_action( 'wordpoints_register_taxonomy_entities', $slug );
528
+	do_action('wordpoints_register_taxonomy_entities', $slug);
529 529
 }
530 530
 
531 531
 /**
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
  *
538 538
  * @param WordPoints_Class_RegistryI $data_types The data types registry.
539 539
  */
540
-function wordpoints_data_types_init( $data_types ) {
540
+function wordpoints_data_types_init($data_types) {
541 541
 
542
-	$data_types->register( 'integer', 'WordPoints_Data_Type_Integer' );
543
-	$data_types->register( 'text', 'WordPoints_Data_Type_Text' );
542
+	$data_types->register('integer', 'WordPoints_Data_Type_Integer');
543
+	$data_types->register('text', 'WordPoints_Data_Type_Text');
544 544
 }
545 545
 
546 546
 /**
@@ -555,9 +555,9 @@  discard block
 block discarded – undo
555 555
  *
556 556
  * @return bool Whether the user can view the points log.
557 557
  */
558
-function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) {
558
+function wordpoints_hooks_user_can_view_points_log($can_view, $log) {
559 559
 
560
-	if ( ! $can_view ) {
560
+	if ( ! $can_view) {
561 561
 		return $can_view;
562 562
 	}
563 563
 
@@ -566,11 +566,11 @@  discard block
 block discarded – undo
566 566
 	$event_slug = $log->log_type;
567 567
 
568 568
 	/** @var WordPoints_Hook_Arg $arg */
569
-	foreach ( wordpoints_hooks()->events->args->get_children( $event_slug ) as $slug => $arg ) {
569
+	foreach (wordpoints_hooks()->events->args->get_children($event_slug) as $slug => $arg) {
570 570
 
571
-		$value = wordpoints_get_points_log_meta( $log->id, $slug, true );
571
+		$value = wordpoints_get_points_log_meta($log->id, $slug, true);
572 572
 
573
-		if ( ! $value ) {
573
+		if ( ! $value) {
574 574
 			continue;
575 575
 		}
576 576
 
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 			, $value
581 581
 		);
582 582
 
583
-		if ( ! $can_view ) {
583
+		if ( ! $can_view) {
584 584
 			break;
585 585
 		}
586 586
 	}
@@ -599,20 +599,20 @@  discard block
 block discarded – undo
599 599
  *
600 600
  * @return bool Whether the user can view this entity.
601 601
  */
602
-function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) {
602
+function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) {
603 603
 
604
-	$entity = wordpoints_entities()->get( $entity_slug );
604
+	$entity = wordpoints_entities()->get($entity_slug);
605 605
 
606 606
 	// If this entity type is not found, we have no way of determining whether it is
607 607
 	// safe for the user to view it.
608
-	if ( ! ( $entity instanceof WordPoints_Entity ) ) {
608
+	if ( ! ($entity instanceof WordPoints_Entity)) {
609 609
 		return false;
610 610
 	}
611 611
 
612 612
 	$can_view = true;
613 613
 
614
-	if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) {
615
-		$can_view = $entity->user_can_view( $user_id, $entity_id );
614
+	if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) {
615
+		$can_view = $entity->user_can_view($user_id, $entity_id);
616 616
 	}
617 617
 
618 618
 	/**
@@ -643,8 +643,8 @@  discard block
 block discarded – undo
643 643
  */
644 644
 function wordpoints_apps() {
645 645
 
646
-	if ( ! isset( WordPoints_App::$main ) ) {
647
-		WordPoints_App::$main = new WordPoints_App( 'apps' );
646
+	if ( ! isset(WordPoints_App::$main)) {
647
+		WordPoints_App::$main = new WordPoints_App('apps');
648 648
 	}
649 649
 
650 650
 	return WordPoints_App::$main;
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
  */
660 660
 function wordpoints_hooks() {
661 661
 
662
-	if ( ! isset( WordPoints_App::$main ) ) {
662
+	if ( ! isset(WordPoints_App::$main)) {
663 663
 		wordpoints_apps();
664 664
 	}
665 665
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
  */
676 676
 function wordpoints_entities() {
677 677
 
678
-	if ( ! isset( WordPoints_App::$main ) ) {
678
+	if ( ! isset(WordPoints_App::$main)) {
679 679
 		wordpoints_apps();
680 680
 	}
681 681
 
@@ -691,13 +691,13 @@  discard block
 block discarded – undo
691 691
  *
692 692
  * @param WordPoints_App $app The main apps app.
693 693
  */
694
-function wordpoints_apps_init( $app ) {
694
+function wordpoints_apps_init($app) {
695 695
 
696 696
 	$apps = $app->sub_apps;
697 697
 
698
-	$apps->register( 'hooks', 'WordPoints_Hooks' );
699
-	$apps->register( 'entities', 'WordPoints_App_Registry' );
700
-	$apps->register( 'data_types', 'WordPoints_Class_Registry' );
698
+	$apps->register('hooks', 'WordPoints_Hooks');
699
+	$apps->register('entities', 'WordPoints_App_Registry');
700
+	$apps->register('data_types', 'WordPoints_Class_Registry');
701 701
 }
702 702
 
703 703
 /**
@@ -710,19 +710,19 @@  discard block
 block discarded – undo
710 710
  *
711 711
  * @return object|false The constructed object, or false if to many args were passed.
712 712
  */
713
-function wordpoints_construct_class_with_args( $class_name, array $args ) {
713
+function wordpoints_construct_class_with_args($class_name, array $args) {
714 714
 
715
-	switch ( count( $args ) ) {
715
+	switch (count($args)) {
716 716
 		case 0:
717 717
 			return new $class_name();
718 718
 		case 1:
719
-			return new $class_name( $args[0] );
719
+			return new $class_name($args[0]);
720 720
 		case 2:
721
-			return new $class_name( $args[0], $args[1] );
721
+			return new $class_name($args[0], $args[1]);
722 722
 		case 3:
723
-			return new $class_name( $args[0], $args[1], $args[2] );
723
+			return new $class_name($args[0], $args[1], $args[2]);
724 724
 		case 4:
725
-			return new $class_name( $args[0], $args[1], $args[2], $args[3] );
725
+			return new $class_name($args[0], $args[1], $args[2], $args[3]);
726 726
 		default:
727 727
 			return false;
728 728
 	}
@@ -744,13 +744,13 @@  discard block
 block discarded – undo
744 744
  * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the
745 745
  *               slug is not dynamic, the value of each of those keys will be false.
746 746
  */
747
-function wordpoints_parse_dynamic_slug( $slug ) {
747
+function wordpoints_parse_dynamic_slug($slug) {
748 748
 
749
-	$parsed = array( 'dynamic' => false, 'generic' => false );
749
+	$parsed = array('dynamic' => false, 'generic' => false);
750 750
 
751
-	$parts = explode( '\\', $slug, 2 );
751
+	$parts = explode('\\', $slug, 2);
752 752
 
753
-	if ( isset( $parts[1] ) ) {
753
+	if (isset($parts[1])) {
754 754
 		$parsed['dynamic'] = $parts[1];
755 755
 		$parsed['generic'] = $parts[0];
756 756
 	}
@@ -789,28 +789,28 @@  discard block
 block discarded – undo
789 789
  *                     contexts, indexed by context slug, or false if any of the
790 790
  *                     contexts isn't current.
791 791
  */
792
-function wordpoints_entities_get_current_context_id( $slug ) {
792
+function wordpoints_entities_get_current_context_id($slug) {
793 793
 
794 794
 	$current_context = array();
795 795
 
796 796
 	/** @var WordPoints_Class_Registry $contexts */
797 797
 	$contexts = wordpoints_entities()->contexts;
798 798
 
799
-	while ( $slug ) {
799
+	while ($slug) {
800 800
 
801
-		$context = $contexts->get( $slug );
801
+		$context = $contexts->get($slug);
802 802
 
803
-		if ( ! $context instanceof WordPoints_Entity_Context ) {
803
+		if ( ! $context instanceof WordPoints_Entity_Context) {
804 804
 			return false;
805 805
 		}
806 806
 
807 807
 		$id = $context->get_current_id();
808 808
 
809
-		if ( false === $id ) {
809
+		if (false === $id) {
810 810
 			return false;
811 811
 		}
812 812
 
813
-		$current_context[ $slug ] = $id;
813
+		$current_context[$slug] = $id;
814 814
 
815 815
 		$slug = $context->get_parent_slug();
816 816
 	}
@@ -831,22 +831,22 @@  discard block
 block discarded – undo
831 831
  */
832 832
 function wordpoints_is_network_context() {
833 833
 
834
-	if ( ! is_multisite() ) {
834
+	if ( ! is_multisite()) {
835 835
 		return false;
836 836
 	}
837 837
 
838
-	if ( is_network_admin() ) {
838
+	if (is_network_admin()) {
839 839
 		return true;
840 840
 	}
841 841
 
842 842
 	// See https://core.trac.wordpress.org/ticket/22589
843 843
 	if (
844
-		defined( 'DOING_AJAX' )
844
+		defined('DOING_AJAX')
845 845
 		&& DOING_AJAX
846
-		&& isset( $_SERVER['HTTP_REFERER'] )
846
+		&& isset($_SERVER['HTTP_REFERER'])
847 847
 		&& preg_match(
848
-			'#^' . preg_quote( network_admin_url(), '#' ) . '#i'
849
-			, esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) )
848
+			'#^'.preg_quote(network_admin_url(), '#').'#i'
849
+			, esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER']))
850 850
 		)
851 851
 	) {
852 852
 		return true;
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 	 *
860 860
 	 * @param bool $in_network_context Whether we are in network context.
861 861
 	 */
862
-	return apply_filters( 'wordpoints_is_network_context', false );
862
+	return apply_filters('wordpoints_is_network_context', false);
863 863
 }
864 864
 
865 865
 /**
@@ -873,21 +873,21 @@  discard block
 block discarded – undo
873 873
  *
874 874
  * @return string The primary arg's GUID, JSON encoded.
875 875
  */
876
-function wordpoints_hooks_get_event_primary_arg_guid_json( WordPoints_Hook_Event_Args $event_args ) {
876
+function wordpoints_hooks_get_event_primary_arg_guid_json(WordPoints_Hook_Event_Args $event_args) {
877 877
 
878 878
 	$entity = $event_args->get_primary_arg();
879 879
 
880
-	if ( ! $entity ) {
880
+	if ( ! $entity) {
881 881
 		return '';
882 882
 	}
883 883
 
884 884
 	$the_guid = $entity->get_the_guid();
885 885
 
886
-	if ( ! $the_guid ) {
886
+	if ( ! $the_guid) {
887 887
 		return '';
888 888
 	}
889 889
 
890
-	return wp_json_encode( $the_guid );
890
+	return wp_json_encode($the_guid);
891 891
 }
892 892
 
893 893
 /**
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
  */
901 901
 function wordpoints_hooks_api_add_global_cache_groups() {
902 902
 
903
-	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
903
+	if (function_exists('wp_cache_add_global_groups')) {
904 904
 
905 905
 		wp_cache_add_global_groups(
906 906
 			array(
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
  * @return string The escaped identifier. Already quoted, do not place within
927 927
  *                backticks.
928 928
  */
929
-function wordpoints_escape_mysql_identifier( $identifier ) {
930
-	return '`' . str_replace( '`', '``', $identifier ) . '`';
929
+function wordpoints_escape_mysql_identifier($identifier) {
930
+	return '`'.str_replace('`', '``', $identifier).'`';
931 931
 }
932 932
 
933 933
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/action/post/depublish/delete.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@
 block discarded – undo
19 19
 	 */
20 20
 	public function should_fire() {
21 21
 
22
-		$post = $this->get_arg_value( 'post' );
22
+		$post = $this->get_arg_value('post');
23 23
 
24
-		if ( ! $post ) {
24
+		if ( ! $post) {
25 25
 			return false;
26 26
 		}
27 27
 
28
-		if ( 'publish' !== get_post_status( $post ) ) {
28
+		if ('publish' !== get_post_status($post)) {
29 29
 			return false;
30 30
 		}
31 31
 
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,18 +35,18 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @since 1.0.0
37 37
 	 */
38
-	public function __construct( $id, WordPoints_Hook_Reaction_StoreI $store ) {
38
+	public function __construct($id, WordPoints_Hook_Reaction_StoreI $store) {
39 39
 
40
-		$this->ID    = wordpoints_int( $id );
40
+		$this->ID    = wordpoints_int($id);
41 41
 		$this->store = $store;
42 42
 	}
43 43
 
44 44
 	/**
45 45
 	 * @since 1.0.0
46 46
 	 */
47
-	public function __get( $var ) {
47
+	public function __get($var) {
48 48
 
49
-		if ( 'ID' === $var ) {
49
+		if ('ID' === $var) {
50 50
 			return $this->ID;
51 51
 		}
52 52
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @since 1.0.0
70 70
 	 */
71 71
 	public function get_reactor_slug() {
72
-		return $this->get_meta( 'reactor' );
72
+		return $this->get_meta('reactor');
73 73
 	}
74 74
 
75 75
 	/**
Please login to merge, or discard this patch.
src/includes/classes/hook/extension/periods.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 	public function get_ui_script_data() {
39 39
 
40 40
 		$periods = array(
41
-			MINUTE_IN_SECONDS   => __( 'Minute', 'wordpoints' ),
42
-			HOUR_IN_SECONDS     => __( 'Hour',   'wordpoints' ),
43
-			DAY_IN_SECONDS      => __( 'Day',    'wordpoints' ),
44
-			WEEK_IN_SECONDS     => __( 'Week',   'wordpoints' ),
45
-			30 * DAY_IN_SECONDS => __( 'Month',  'wordpoints' ),
41
+			MINUTE_IN_SECONDS   => __('Minute', 'wordpoints'),
42
+			HOUR_IN_SECONDS     => __('Hour', 'wordpoints'),
43
+			DAY_IN_SECONDS      => __('Day', 'wordpoints'),
44
+			WEEK_IN_SECONDS     => __('Week', 'wordpoints'),
45
+			30 * DAY_IN_SECONDS => __('Month', 'wordpoints'),
46 46
 		);
47 47
 
48 48
 		/**
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 		 *
53 53
 		 * @param string[] $periods The period titles, indexed by length in seconds.
54 54
 		 */
55
-		$periods = apply_filters( 'wordpoints_hooks_ui_data_periods', $periods );
55
+		$periods = apply_filters('wordpoints_hooks_ui_data_periods', $periods);
56 56
 
57 57
 		return array(
58 58
 			'periods' => $periods,
59 59
 			'l10n' => array(
60
-				'label' => __( 'Trigger reaction no more than once per:', 'wordpoints' ),
60
+				'label' => __('Trigger reaction no more than once per:', 'wordpoints'),
61 61
 			),
62 62
 		);
63 63
 	}
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return array The validated periods.
73 73
 	 */
74
-	protected function validate_action_type_settings( $periods ) {
74
+	protected function validate_action_type_settings($periods) {
75 75
 
76
-		if ( ! is_array( $periods ) ) {
76
+		if ( ! is_array($periods)) {
77 77
 
78 78
 			$this->validator->add_error(
79
-				__( 'Periods do not match expected format.', 'wordpoints' )
79
+				__('Periods do not match expected format.', 'wordpoints')
80 80
 			);
81 81
 
82 82
 			return array();
83 83
 		}
84 84
 
85
-		foreach ( $periods as $index => $period ) {
85
+		foreach ($periods as $index => $period) {
86 86
 
87
-			$this->validator->push_field( $index );
87
+			$this->validator->push_field($index);
88 88
 
89
-			$period = $this->validate_period( $period );
89
+			$period = $this->validate_period($period);
90 90
 
91
-			if ( $period ) {
92
-				$periods[ $index ] = $period;
91
+			if ($period) {
92
+				$periods[$index] = $period;
93 93
 			}
94 94
 
95 95
 			$this->validator->pop_field();
@@ -107,30 +107,30 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return array|false The validated period, or false if invalid.
109 109
 	 */
110
-	protected function validate_period( $period ) {
110
+	protected function validate_period($period) {
111 111
 
112
-		if ( ! is_array( $period ) ) {
112
+		if ( ! is_array($period)) {
113 113
 			$this->validator->add_error(
114
-				__( 'Period does not match expected format.', 'wordpoints' )
114
+				__('Period does not match expected format.', 'wordpoints')
115 115
 			);
116 116
 
117 117
 			return false;
118 118
 		}
119 119
 
120
-		if ( isset( $period['args'] ) ) {
121
-			$this->validate_period_args( $period['args'] );
120
+		if (isset($period['args'])) {
121
+			$this->validate_period_args($period['args']);
122 122
 		}
123 123
 
124
-		if ( ! isset( $period['length'] ) ) {
124
+		if ( ! isset($period['length'])) {
125 125
 
126 126
 			$this->validator->add_error(
127
-				__( 'Period length setting is missing.', 'wordpoints' )
127
+				__('Period length setting is missing.', 'wordpoints')
128 128
 			);
129 129
 
130
-		} elseif ( false === wordpoints_posint( $period['length'] ) ) {
130
+		} elseif (false === wordpoints_posint($period['length'])) {
131 131
 
132 132
 			$this->validator->add_error(
133
-				__( 'Period length must be a positive integer.', 'wordpoints' )
133
+				__('Period length must be a positive integer.', 'wordpoints')
134 134
 				, 'length'
135 135
 			);
136 136
 
@@ -147,34 +147,34 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @param mixed $args The args the period is related to.
149 149
 	 */
150
-	protected function validate_period_args( $args ) {
150
+	protected function validate_period_args($args) {
151 151
 
152
-		if ( ! is_array( $args ) ) {
152
+		if ( ! is_array($args)) {
153 153
 
154 154
 			$this->validator->add_error(
155
-				__( 'Period does not match expected format.', 'wordpoints' )
155
+				__('Period does not match expected format.', 'wordpoints')
156 156
 				, 'args'
157 157
 			);
158 158
 
159 159
 			return;
160 160
 		}
161 161
 
162
-		$this->validator->push_field( 'args' );
162
+		$this->validator->push_field('args');
163 163
 
164
-		foreach ( $args as $index => $hierarchy ) {
164
+		foreach ($args as $index => $hierarchy) {
165 165
 
166
-			$this->validator->push_field( $index );
166
+			$this->validator->push_field($index);
167 167
 
168
-			if ( ! is_array( $hierarchy ) ) {
168
+			if ( ! is_array($hierarchy)) {
169 169
 
170 170
 				$this->validator->add_error(
171
-					__( 'Period does not match expected format.', 'wordpoints' )
171
+					__('Period does not match expected format.', 'wordpoints')
172 172
 				);
173 173
 
174
-			} elseif ( ! $this->event_args->get_from_hierarchy( $hierarchy ) ) {
174
+			} elseif ( ! $this->event_args->get_from_hierarchy($hierarchy)) {
175 175
 
176 176
 				$this->validator->add_error(
177
-					__( 'Invalid arg hierarchy for period.', 'wordpoints' )
177
+					__('Invalid arg hierarchy for period.', 'wordpoints')
178 178
 				);
179 179
 			}
180 180
 
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
 	/**
188 188
 	 * @since 1.0.0
189 189
 	 */
190
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
190
+	public function should_hit(WordPoints_Hook_Fire $fire) {
191 191
 
192
-		$periods = $this->get_settings_from_fire( $fire );
192
+		$periods = $this->get_settings_from_fire($fire);
193 193
 
194
-		if ( empty( $periods ) ) {
194
+		if (empty($periods)) {
195 195
 			return true;
196 196
 		}
197 197
 
198 198
 		$this->event_args = $fire->event_args;
199 199
 		$this->action_type = $fire->action_type;
200 200
 
201
-		foreach ( $periods as $period ) {
202
-			if ( ! $this->has_period_ended( $period, $fire->reaction ) ) {
201
+		foreach ($periods as $period) {
202
+			if ( ! $this->has_period_ended($period, $fire->reaction)) {
203 203
 				return false;
204 204
 			}
205 205
 		}
@@ -223,24 +223,24 @@  discard block
 block discarded – undo
223 223
 	) {
224 224
 
225 225
 		$period = $this->get_period_by_reaction(
226
-			$this->get_period_signature( $settings, $reaction )
226
+			$this->get_period_signature($settings, $reaction)
227 227
 			, $reaction
228 228
 		);
229 229
 
230 230
 		// If the period isn't found, we know that we can still fire.
231
-		if ( ! $period ) {
231
+		if ( ! $period) {
232 232
 			return true;
233 233
 		}
234 234
 
235
-		$now = current_time( 'timestamp' );
236
-		$hit_time = strtotime( $period->date, $now );
235
+		$now = current_time('timestamp');
236
+		$hit_time = strtotime($period->date, $now);
237 237
 
238
-		if ( ! empty( $settings['relative'] ) ) {
239
-			return ( $hit_time < $now - $settings['length'] );
238
+		if ( ! empty($settings['relative'])) {
239
+			return ($hit_time < $now - $settings['length']);
240 240
 		} else {
241 241
 			return (
242
-				(int) ( $hit_time / $settings['length'] )
243
-				< (int) ( $now / $settings['length'] )
242
+				(int) ($hit_time / $settings['length'])
243
+				< (int) ($now / $settings['length'])
244 244
 			);
245 245
 		}
246 246
 	}
@@ -254,24 +254,24 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @return array The arg values.
256 256
 	 */
257
-	protected function get_arg_values( array $period_args ) {
257
+	protected function get_arg_values(array $period_args) {
258 258
 
259 259
 		$values = array();
260 260
 
261
-		foreach ( $period_args as $arg_hierarchy ) {
261
+		foreach ($period_args as $arg_hierarchy) {
262 262
 
263 263
 			$arg = $this->event_args->get_from_hierarchy(
264 264
 				$arg_hierarchy
265 265
 			);
266 266
 
267
-			if ( ! $arg instanceof WordPoints_EntityishI ) {
267
+			if ( ! $arg instanceof WordPoints_EntityishI) {
268 268
 				continue;
269 269
 			}
270 270
 
271
-			$values[ implode( '.', $arg_hierarchy ) ] = $arg->get_the_value();
271
+			$values[implode('.', $arg_hierarchy)] = $arg->get_the_value();
272 272
 		}
273 273
 
274
-		ksort( $values );
274
+		ksort($values);
275 275
 
276 276
 		return $values;
277 277
 	}
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @return object|false The period data, or false if not found.
287 287
 	 */
288
-	protected function get_period( $period_id ) {
288
+	protected function get_period($period_id) {
289 289
 
290
-		$period = wp_cache_get( $period_id, 'wordpoints_hook_periods' );
290
+		$period = wp_cache_get($period_id, 'wordpoints_hook_periods');
291 291
 
292
-		if ( ! $period ) {
292
+		if ( ! $period) {
293 293
 
294 294
 			global $wpdb;
295 295
 
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 				)
307 307
 			);
308 308
 
309
-			if ( ! $period ) {
309
+			if ( ! $period) {
310 310
 				return false;
311 311
 			}
312 312
 
313
-			wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
313
+			wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
314 314
 		}
315 315
 
316 316
 		return $period;
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 
335 335
 		$reaction_guid = $reaction->get_guid();
336 336
 
337
-		$cache_key = wp_json_encode( $reaction_guid ) . "-{$signature}-{$this->action_type}";
337
+		$cache_key = wp_json_encode($reaction_guid)."-{$signature}-{$this->action_type}";
338 338
 
339 339
 		// Before we run the query, we try to lookup the ID in the cache.
340
-		$period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids_by_reaction' );
340
+		$period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids_by_reaction');
341 341
 
342 342
 		// If we found it, we can retrieve the period by ID instead.
343
-		if ( $period_id ) {
344
-			return $this->get_period( $period_id );
343
+		if ($period_id) {
344
+			return $this->get_period($period_id);
345 345
 		}
346 346
 
347 347
 		global $wpdb;
@@ -364,18 +364,18 @@  discard block
 block discarded – undo
364 364
 				"
365 365
 				, $signature
366 366
 				, $reaction_guid['store']
367
-				, wp_json_encode( $reaction_guid['context_id'] )
367
+				, wp_json_encode($reaction_guid['context_id'])
368 368
 				, $reaction_guid['id']
369 369
 				, $this->action_type
370 370
 			)
371 371
 		);
372 372
 
373
-		if ( ! $period ) {
373
+		if ( ! $period) {
374 374
 			return false;
375 375
 		}
376 376
 
377
-		wp_cache_set( $cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction' );
378
-		wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
377
+		wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction');
378
+		wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
379 379
 
380 380
 		return $period;
381 381
 	}
@@ -383,21 +383,21 @@  discard block
 block discarded – undo
383 383
 	/**
384 384
 	 * @since 1.0.0
385 385
 	 */
386
-	public function after_hit( WordPoints_Hook_Fire $fire ) {
386
+	public function after_hit(WordPoints_Hook_Fire $fire) {
387 387
 
388
-		$periods = $this->get_settings_from_fire( $fire );
388
+		$periods = $this->get_settings_from_fire($fire);
389 389
 
390
-		if ( empty( $periods ) ) {
390
+		if (empty($periods)) {
391 391
 			return;
392 392
 		}
393 393
 
394 394
 		$this->event_args = $fire->event_args;
395 395
 		$this->action_type = $fire->action_type;
396 396
 
397
-		foreach ( $periods as $settings ) {
397
+		foreach ($periods as $settings) {
398 398
 
399 399
 			$this->add_period(
400
-				$this->get_period_signature( $settings, $fire->reaction )
400
+				$this->get_period_signature($settings, $fire->reaction)
401 401
 				, $fire
402 402
 			);
403 403
 		}
@@ -422,14 +422,14 @@  discard block
 block discarded – undo
422 422
 		WordPoints_Hook_ReactionI $reaction
423 423
 	) {
424 424
 
425
-		if ( isset( $settings['args'] ) ) {
425
+		if (isset($settings['args'])) {
426 426
 			$period_args = $settings['args'];
427 427
 		} else {
428
-			$period_args = array( $reaction->get_meta( 'target' ) );
428
+			$period_args = array($reaction->get_meta('target'));
429 429
 		}
430 430
 
431 431
 		return wordpoints_hash(
432
-			wp_json_encode( $this->get_arg_values( $period_args ) )
432
+			wp_json_encode($this->get_arg_values($period_args))
433 433
 		);
434 434
 	}
435 435
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @return false|object The period data, or false if not found.
445 445
 	 */
446
-	protected function add_period( $signature, WordPoints_Hook_Fire $fire ) {
446
+	protected function add_period($signature, WordPoints_Hook_Fire $fire) {
447 447
 
448 448
 		global $wpdb;
449 449
 
@@ -453,17 +453,17 @@  discard block
 block discarded – undo
453 453
 				'hit_id' => $fire->hit_id,
454 454
 				'signature' => $signature,
455 455
 			)
456
-			, array( '%d', '%s' )
456
+			, array('%d', '%s')
457 457
 		);
458 458
 
459
-		if ( ! $inserted ) {
459
+		if ( ! $inserted) {
460 460
 			return false;
461 461
 		}
462 462
 
463 463
 		$period_id = $wpdb->insert_id;
464 464
 
465 465
 		wp_cache_set(
466
-			wp_json_encode( $fire->reaction->get_guid() ) . "-{$signature}-{$this->action_type}"
466
+			wp_json_encode($fire->reaction->get_guid())."-{$signature}-{$this->action_type}"
467 467
 			, $period_id
468 468
 			, 'wordpoints_hook_period_ids_by_reaction'
469 469
 		);
Please login to merge, or discard this patch.
src/includes/classes/hook/event/args.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -63,22 +63,22 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @param WordPoints_Hook_Arg[] $args The hook args.
65 65
 	 */
66
-	public function __construct( array $args ) {
66
+	public function __construct(array $args) {
67 67
 
68 68
 		parent::__construct();
69 69
 
70
-		foreach ( $args as $arg ) {
70
+		foreach ($args as $arg) {
71 71
 
72 72
 			$entity = $arg->get_entity();
73 73
 			$slug = $arg->get_slug();
74 74
 
75
-			if ( ! $entity instanceof WordPoints_Entity ) {
75
+			if ( ! $entity instanceof WordPoints_Entity) {
76 76
 				continue;
77 77
 			}
78 78
 
79
-			$this->entities[ $slug ] = $entity;
79
+			$this->entities[$slug] = $entity;
80 80
 
81
-			if ( ! $arg->is_stateful() ) {
81
+			if ( ! $arg->is_stateful()) {
82 82
 				// If any of the args aren't stateful the event isn't repeatable.
83 83
 				$this->is_repeatable = false;
84 84
 				$this->primary_arg_slug = $slug;
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function get_primary_arg() {
116 116
 
117
-		if ( ! $this->primary_arg_slug ) {
117
+		if ( ! $this->primary_arg_slug) {
118 118
 			return false;
119 119
 		}
120 120
 
121
-		return $this->entities[ $this->primary_arg_slug ];
121
+		return $this->entities[$this->primary_arg_slug];
122 122
 	}
123 123
 
124 124
 	/**
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 
133 133
 		$stateful = $this->entities;
134 134
 
135
-		if ( $this->primary_arg_slug ) {
136
-			unset( $stateful[ $this->primary_arg_slug ] );
135
+		if ($this->primary_arg_slug) {
136
+			unset($stateful[$this->primary_arg_slug]);
137 137
 		}
138 138
 
139 139
 		return $stateful;
@@ -157,50 +157,50 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @param WordPoints_Hook_Reaction_Validator $validator The validator.
159 159
 	 */
160
-	public function set_validator( WordPoints_Hook_Reaction_Validator $validator ) {
160
+	public function set_validator(WordPoints_Hook_Reaction_Validator $validator) {
161 161
 		$this->validator = $validator;
162 162
 	}
163 163
 
164 164
 	/**
165 165
 	 * @since 1.0.0
166 166
 	 */
167
-	public function descend( $child_slug ) {
167
+	public function descend($child_slug) {
168 168
 
169
-		$result = parent::descend( $child_slug );
169
+		$result = parent::descend($child_slug);
170 170
 
171 171
 		// Just in case no validator has been set.
172
-		if ( ! $this->validator ) {
172
+		if ( ! $this->validator) {
173 173
 			return $result;
174 174
 		}
175 175
 
176
-		if ( ! $result ) {
176
+		if ( ! $result) {
177 177
 
178
-			if ( ! isset( $this->current ) ) {
178
+			if ( ! isset($this->current)) {
179 179
 
180 180
 				$this->validator->add_error(
181 181
 					sprintf(
182
-						__( 'The &#8220;%s&#8221; arg is not registered for this event.', 'wordpoints' )
182
+						__('The &#8220;%s&#8221; arg is not registered for this event.', 'wordpoints')
183 183
 						, $child_slug
184 184
 					)
185 185
 				);
186 186
 
187
-			} elseif ( ! ( $this->current instanceof WordPoints_Entity_ParentI ) ) {
187
+			} elseif ( ! ($this->current instanceof WordPoints_Entity_ParentI)) {
188 188
 
189 189
 				$this->validator->add_error(
190 190
 					sprintf(
191
-						__( 'Cannot get descendant of %s: not a parent.', 'wordpoints' )
191
+						__('Cannot get descendant of %s: not a parent.', 'wordpoints')
192 192
 						, $this->current->get_title()
193 193
 					)
194 194
 				);
195 195
 
196 196
 			} else {
197 197
 
198
-				$child_arg = $this->current->get_child( $child_slug );
198
+				$child_arg = $this->current->get_child($child_slug);
199 199
 
200
-				if ( ! $child_arg ) {
200
+				if ( ! $child_arg) {
201 201
 					$this->validator->add_error(
202 202
 						sprintf(
203
-							__( '%s does not have a child &#8220;%s&#8221;.', 'wordpoints' )
203
+							__('%s does not have a child &#8220;%s&#8221;.', 'wordpoints')
204 204
 							, $this->current->get_slug()
205 205
 							, $child_slug
206 206
 						)
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
 				}
210 210
 			}
211 211
 
212
-		} elseif ( $this->push_on_descend ) {
212
+		} elseif ($this->push_on_descend) {
213 213
 
214
-			$this->validator->push_field( $child_slug );
214
+			$this->validator->push_field($child_slug);
215 215
 		}
216 216
 
217 217
 		return $result;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 		$ascended = parent::ascend();
226 226
 
227
-		if ( $ascended && $this->validator ) {
227
+		if ($ascended && $this->validator) {
228 228
 			$this->validator->pop_field();
229 229
 		}
230 230
 
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 	/**
235 235
 	 * @since 1.0.0
236 236
 	 */
237
-	public function get_from_hierarchy( array $hierarchy ) {
237
+	public function get_from_hierarchy(array $hierarchy) {
238 238
 
239 239
 		$this->push_on_descend = false;
240
-		$entityish = parent::get_from_hierarchy( $hierarchy );
240
+		$entityish = parent::get_from_hierarchy($hierarchy);
241 241
 		$this->push_on_descend = true;
242 242
 
243 243
 		return $entityish;
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction/store/options.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -22,25 +22,25 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * @since 1.0.0
24 24
 	 */
25
-	public function reaction_exists( $id ) {
26
-		return (bool) $this->get_option( $this->get_settings_option_name( $id ) );
25
+	public function reaction_exists($id) {
26
+		return (bool) $this->get_option($this->get_settings_option_name($id));
27 27
 	}
28 28
 
29 29
 	/**
30 30
 	 * @since 1.0.0
31 31
 	 */
32 32
 	public function get_reactions() {
33
-		return $this->create_reaction_objects( $this->get_reaction_index() );
33
+		return $this->create_reaction_objects($this->get_reaction_index());
34 34
 	}
35 35
 
36 36
 	/**
37 37
 	 * @since 1.0.0
38 38
 	 */
39
-	public function get_reactions_to_event( $event_slug ) {
39
+	public function get_reactions_to_event($event_slug) {
40 40
 
41 41
 		$index = $this->get_reaction_index();
42
-		$index = wp_list_filter( $index, array( 'event' => $event_slug ) );
43
-		return $this->create_reaction_objects( $index );
42
+		$index = wp_list_filter($index, array('event' => $event_slug));
43
+		return $this->create_reaction_objects($index);
44 44
 	}
45 45
 
46 46
 	/**
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	protected function get_reaction_index() {
61 61
 
62
-		$index = $this->get_option( $this->get_reaction_index_option_name() );
62
+		$index = $this->get_option($this->get_reaction_index_option_name());
63 63
 
64
-		if ( ! is_array( $index ) ) {
64
+		if ( ! is_array($index)) {
65 65
 			$index = array();
66 66
 		}
67 67
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return bool Whether the index was updated successfully.
79 79
 	 */
80
-	protected function update_reaction_index( $index ) {
80
+	protected function update_reaction_index($index) {
81 81
 
82 82
 		return $this->update_option(
83 83
 			$this->get_reaction_index_option_name()
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return string|false The event slug, or false if not found.
98 98
 	 */
99
-	public function get_reaction_event_from_index( $id ) {
99
+	public function get_reaction_event_from_index($id) {
100 100
 
101 101
 		$index = $this->get_reaction_index();
102 102
 
103
-		if ( ! isset( $index[ $id ]['event'] ) ) {
103
+		if ( ! isset($index[$id]['event'])) {
104 104
 			return false;
105 105
 		}
106 106
 
107
-		return $index[ $id ]['event'];
107
+		return $index[$id]['event'];
108 108
 	}
109 109
 
110 110
 	/**
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return bool Whether the event was updated successfully.
121 121
 	 */
122
-	public function update_reaction_event_in_index( $id, $event ) {
122
+	public function update_reaction_event_in_index($id, $event) {
123 123
 
124 124
 		$index = $this->get_reaction_index();
125 125
 
126
-		if ( ! isset( $index[ $id ] ) ) {
126
+		if ( ! isset($index[$id])) {
127 127
 			return false;
128 128
 		}
129 129
 
130
-		$index[ $id ]['event'] = $event;
130
+		$index[$id]['event'] = $event;
131 131
 
132
-		return $this->update_reaction_index( $index );
132
+		return $this->update_reaction_index($index);
133 133
 	}
134 134
 
135 135
 	/**
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @return WordPoints_Hook_Reaction_Options[] The objects for the reactions.
143 143
 	 */
144
-	protected function create_reaction_objects( $index ) {
144
+	protected function create_reaction_objects($index) {
145 145
 
146 146
 		$reactions = array();
147 147
 
148
-		foreach ( $index as $reaction ) {
148
+		foreach ($index as $reaction) {
149 149
 
150
-			$object = $this->get_reaction( $reaction['id'] );
150
+			$object = $this->get_reaction($reaction['id']);
151 151
 
152
-			if ( ! $object ) {
152
+			if ( ! $object) {
153 153
 				continue;
154 154
 			}
155 155
 
@@ -162,52 +162,52 @@  discard block
 block discarded – undo
162 162
 	/**
163 163
 	 * @since 1.0.0
164 164
 	 */
165
-	public function delete_reaction( $id ) {
165
+	public function delete_reaction($id) {
166 166
 
167
-		if ( ! $this->reaction_exists( $id ) ) {
167
+		if ( ! $this->reaction_exists($id)) {
168 168
 			return false;
169 169
 		}
170 170
 
171
-		$result = $this->delete_option( $this->get_settings_option_name( $id ) );
171
+		$result = $this->delete_option($this->get_settings_option_name($id));
172 172
 
173
-		if ( ! $result ) {
173
+		if ( ! $result) {
174 174
 			return false;
175 175
 		}
176 176
 
177 177
 		$index = $this->get_reaction_index();
178 178
 
179
-		unset( $index[ $id ] );
179
+		unset($index[$id]);
180 180
 
181
-		return $this->update_reaction_index( $index );
181
+		return $this->update_reaction_index($index);
182 182
 	}
183 183
 
184 184
 	/**
185 185
 	 * @since 1.0.0
186 186
 	 */
187
-	protected function _create_reaction( $event_slug ) {
187
+	protected function _create_reaction($event_slug) {
188 188
 
189 189
 		$index = $this->get_reaction_index();
190 190
 
191
-		$id = $this->get_next_id( $index );
191
+		$id = $this->get_next_id($index);
192 192
 
193
-		$settings = array( 'event' => $event_slug );
193
+		$settings = array('event' => $event_slug);
194 194
 
195 195
 		$result = $this->add_option(
196
-			$this->get_settings_option_name( $id )
196
+			$this->get_settings_option_name($id)
197 197
 			, $settings
198 198
 		);
199 199
 
200
-		if ( ! $result ) {
200
+		if ( ! $result) {
201 201
 			return false;
202 202
 		}
203 203
 
204
-		$index[ $id ] = array( 'event' => $event_slug, 'id' => $id );
204
+		$index[$id] = array('event' => $event_slug, 'id' => $id);
205 205
 
206
-		if ( ! $this->update_reaction_index( $index ) ) {
206
+		if ( ! $this->update_reaction_index($index)) {
207 207
 			return false;
208 208
 		}
209 209
 
210
-		$this->update_option( $this->get_last_reaction_id_option_name(), $id );
210
+		$this->update_option($this->get_last_reaction_id_option_name(), $id);
211 211
 
212 212
 		return $id;
213 213
 	}
@@ -221,23 +221,23 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return int The ID to use for the next reaction.
223 223
 	 */
224
-	protected function get_next_id( $index ) {
224
+	protected function get_next_id($index) {
225 225
 
226 226
 		$id = 1;
227 227
 
228
-		$last_id = $this->get_option( $this->get_last_reaction_id_option_name() );
228
+		$last_id = $this->get_option($this->get_last_reaction_id_option_name());
229 229
 
230
-		if ( wordpoints_posint( $last_id ) ) {
230
+		if (wordpoints_posint($last_id)) {
231 231
 			$id = $last_id + 1;
232 232
 		}
233 233
 
234 234
 		// Double-check this against the index. This should avoid some issues from
235 235
 		// race conditions.
236
-		if ( ! empty( $index ) ) {
236
+		if ( ! empty($index)) {
237 237
 
238
-			$max = max( array_keys( $index ) );
238
+			$max = max(array_keys($index));
239 239
 
240
-			if ( $max >= $id ) {
240
+			if ($max >= $id) {
241 241
 				$id = $max + 1;
242 242
 			}
243 243
 		}
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return mixed The option value, or false.
258 258
 	 */
259
-	public function get_option( $name ) {
260
-		return get_option( $name );
259
+	public function get_option($name) {
260
+		return get_option($name);
261 261
 	}
262 262
 
263 263
 	/**
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return bool Whether the option was added successfully.
272 272
 	 */
273
-	protected function add_option( $name, $value ) {
274
-		return add_option( $name, $value );
273
+	protected function add_option($name, $value) {
274
+		return add_option($name, $value);
275 275
 	}
276 276
 
277 277
 	/**
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 	 *
287 287
 	 * @return bool Whether the option was updated successfully.
288 288
 	 */
289
-	public function update_option( $name, $value ) {
290
-		return update_option( $name, $value );
289
+	public function update_option($name, $value) {
290
+		return update_option($name, $value);
291 291
 	}
292 292
 
293 293
 	/**
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return bool Whether the option was deleted successfully.
301 301
 	 */
302
-	protected function delete_option( $name ) {
303
-		return delete_option( $name );
302
+	protected function delete_option($name) {
303
+		return delete_option($name);
304 304
 	}
305 305
 
306 306
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @return string The name of the option where the settings are stored.
316 316
 	 */
317
-	public function get_settings_option_name( $id ) {
317
+	public function get_settings_option_name($id) {
318 318
 
319 319
 		$current_mode = wordpoints_hooks()->get_current_mode();
320 320
 
Please login to merge, or discard this patch.
src/includes/classes/hook/condition/string/contains.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @since 1.0.0
19 19
 	 */
20 20
 	public function get_title() {
21
-		return __( 'Contains', 'wordpoints' );
21
+		return __('Contains', 'wordpoints');
22 22
 	}
23 23
 
24 24
 	/**
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		return array(
29 29
 			'value' => array(
30 30
 				'type'     => 'text',
31
-				'label'    => __( 'Word or phrase (case sensitive)', 'wordpoints' ),
31
+				'label'    => __('Word or phrase (case sensitive)', 'wordpoints'),
32 32
 				'required' => true,
33 33
 			),
34 34
 		);
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @since 1.0.0
39 39
 	 */
40
-	public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) {
40
+	public function is_met(array $settings, WordPoints_Hook_Event_Args $args) {
41 41
 
42 42
 		return false !== strpos(
43 43
 			$args->get_current()->get_the_value()
Please login to merge, or discard this patch.
src/includes/classes/entity/user/role/name.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * @since 1.0.0
34 34
 	 */
35 35
 	public function get_title() {
36
-		return _x( 'Name', 'user role', 'wordpoints' );
36
+		return _x('Name', 'user role', 'wordpoints');
37 37
 	}
38 38
 }
39 39
 
Please login to merge, or discard this patch.
src/includes/classes/entity/term/id.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * @since 1.0.0
34 34
 	 */
35 35
 	public function get_title() {
36
-		return _x( 'ID', 'taxonomy term', 'wordpoints' );
36
+		return _x('ID', 'taxonomy term', 'wordpoints');
37 37
 	}
38 38
 }
39 39
 // EOF
Please login to merge, or discard this patch.