Completed
Push — master ( 947d26...1e2c33 )
by J.D.
04:30
created
src/admin/includes/functions.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * @param WordPoints_App $app The main WordPoints app.
18 18
  */
19
-function wordpoints_hooks_register_admin_apps( $app ) {
19
+function wordpoints_hooks_register_admin_apps($app) {
20 20
 
21 21
 	$apps = $app->sub_apps;
22 22
 
23
-	$apps->register( 'admin', 'WordPoints_App' );
23
+	$apps->register('admin', 'WordPoints_App');
24 24
 
25 25
 	/** @var WordPoints_App $admin */
26
-	$admin = $apps->get( 'admin' );
26
+	$admin = $apps->get('admin');
27 27
 
28
-	$admin->sub_apps->register( 'screen', 'WordPoints_Admin_Screens' );
28
+	$admin->sub_apps->register('screen', 'WordPoints_Admin_Screens');
29 29
 }
30 30
 
31 31
 /**
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	// Hooks page.
47 47
 	$id = add_submenu_page(
48 48
 		$wordpoints_menu
49
-		, __( 'WordPoints — Points Types', 'wordpoints' )
50
-		, __( 'Points Types', 'wordpoints' )
49
+		, __('WordPoints — Points Types', 'wordpoints')
50
+		, __('Points Types', 'wordpoints')
51 51
 		, 'manage_options'
52 52
 		, 'wordpoints_points_types'
53
-		, array( $admin_screens, 'display' )
53
+		, array($admin_screens, 'display')
54 54
 	);
55 55
 
56
-	if ( $id ) {
57
-		$admin_screens->register( $id, 'WordPoints_Admin_Screen_Points_Types' );
56
+	if ($id) {
57
+		$admin_screens->register($id, 'WordPoints_Admin_Screen_Points_Types');
58 58
 	}
59 59
 }
60 60
 
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function wordpoints_hooks_admin_register_scripts() {
69 69
 
70
-	$assets_url = wordpoints_modules_url( '/assets', dirname( __FILE__ ) );
70
+	$assets_url = wordpoints_modules_url('/assets', dirname(__FILE__));
71 71
 
72 72
 	// CSS
73 73
 
74 74
 	wp_register_style(
75 75
 		'wordpoints-hooks-admin'
76
-		, $assets_url . '/css/hooks.css'
77
-		, array( 'dashicons', 'wp-jquery-ui-dialog' )
76
+		, $assets_url.'/css/hooks.css'
77
+		, array('dashicons', 'wp-jquery-ui-dialog')
78 78
 		, WORDPOINTS_VERSION
79 79
 	);
80 80
 
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 
83 83
 	wp_register_script(
84 84
 		'wordpoints-hooks-models'
85
-		, $assets_url . '/js/hooks/models.js'
86
-		, array( 'backbone', 'jquery-ui-dialog', 'wp-util' )
85
+		, $assets_url.'/js/hooks/models.js'
86
+		, array('backbone', 'jquery-ui-dialog', 'wp-util')
87 87
 		, WORDPOINTS_VERSION
88 88
 	);
89 89
 
90 90
 	wp_register_script(
91 91
 		'wordpoints-hooks-views'
92
-		, $assets_url . '/js/hooks/views.js'
93
-		, array( 'wordpoints-hooks-models' )
92
+		, $assets_url.'/js/hooks/views.js'
93
+		, array('wordpoints-hooks-models')
94 94
 		, WORDPOINTS_VERSION
95 95
 	);
96 96
 
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 		'wordpoints-hooks-views'
99 99
 		, 'WordPointsHooksAdminL10n'
100 100
 		, array(
101
-			'unexpectedError' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ),
102
-			'changesSaved'    => __( 'Your changes have been saved.', 'wordpoints' ),
101
+			'unexpectedError' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'),
102
+			'changesSaved'    => __('Your changes have been saved.', 'wordpoints'),
103 103
 			/* translators: the name of the field that cannot be empty */
104
-			'emptyField'      => sprintf( __( '%s cannot be empty.', 'wordpoints' ), '{{ data.label }}' ),
105
-			'confirmDelete'   => __( 'Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints' ),
106
-			'confirmTitle'    => __( 'Are you sure?', 'wordpoints' ),
107
-			'deleteText'      => __( 'Delete', 'wordpoints' ),
108
-			'cancelText'      => __( 'Cancel', 'wordpoints' ),
109
-			'separator'       => __( ' » ', 'wordpoints' ),
110
-			'target_label'    => __( 'Target', 'wordpoints' ),
104
+			'emptyField'      => sprintf(__('%s cannot be empty.', 'wordpoints'), '{{ data.label }}'),
105
+			'confirmDelete'   => __('Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints'),
106
+			'confirmTitle'    => __('Are you sure?', 'wordpoints'),
107
+			'deleteText'      => __('Delete', 'wordpoints'),
108
+			'cancelText'      => __('Cancel', 'wordpoints'),
109
+			'separator'       => __(' » ', 'wordpoints'),
110
+			'target_label'    => __('Target', 'wordpoints'),
111 111
 		)
112 112
 	);
113 113
 
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
 			<div class="view">
120 120
 				<div class="title"></div>
121 121
 				<button type="button" class="edit button-secondary">
122
-					' . esc_html__( 'Edit', 'wordpoints' ) . '
122
+					' . esc_html__('Edit', 'wordpoints').'
123 123
 				</button>
124 124
 				<button type="button" class="close button-secondary">
125
-					' . esc_html__( 'Close', 'wordpoints' ) . '
125
+					' . esc_html__('Close', 'wordpoints').'
126 126
 				</button>
127 127
 			</div>
128 128
 			<div class="form">
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
 						</div>
142 142
 						<div class="action-buttons">
143 143
 							<button type="button" class="save button-primary" disabled>
144
-								' . esc_html__( 'Save', 'wordpoints' ) . '
144
+								' . esc_html__('Save', 'wordpoints').'
145 145
 							</button>
146 146
 							<button type="button" class="cancel button-secondary">
147
-								' . esc_html__( 'Cancel', 'wordpoints' ) . '
147
+								' . esc_html__('Cancel', 'wordpoints').'
148 148
 							</button>
149 149
 							<button type="button" class="close button-secondary">
150
-								' . esc_html__( 'Close', 'wordpoints' ) . '
150
+								' . esc_html__('Close', 'wordpoints').'
151 151
 							</button>
152 152
 							<button type="button" class="delete button-secondary">
153
-								' . esc_html__( 'Delete', 'wordpoints' ) . '
153
+								' . esc_html__('Delete', 'wordpoints').'
154 154
 							</button>
155 155
 						</div>
156 156
 					</div>
@@ -198,15 +198,15 @@  discard block
 block discarded – undo
198 198
 
199 199
 	wp_register_script(
200 200
 		'wordpoints-hooks-reactor-points'
201
-		, $assets_url . '/js/hooks/reactors/points.js'
202
-		, array( 'wordpoints-hooks-views' )
201
+		, $assets_url.'/js/hooks/reactors/points.js'
202
+		, array('wordpoints-hooks-views')
203 203
 		, WORDPOINTS_VERSION
204 204
 	);
205 205
 
206 206
 	wp_register_script(
207 207
 		'wordpoints-hooks-extension-conditions'
208
-		, $assets_url . '/js/hooks/extensions/conditions.js'
209
-		, array( 'wordpoints-hooks-views' )
208
+		, $assets_url.'/js/hooks/extensions/conditions.js'
209
+		, array('wordpoints-hooks-views')
210 210
 		, WORDPOINTS_VERSION
211 211
 	);
212 212
 
@@ -216,25 +216,25 @@  discard block
 block discarded – undo
216 216
 		, '
217 217
 			<script type="text/template" id="tmpl-wordpoints-hook-condition-groups">
218 218
 				<div class="conditions-title section-title">
219
-					<h4>' . esc_html__( 'Conditions', 'wordpoints' ) . '</h4>
219
+					<h4>' . esc_html__('Conditions', 'wordpoints').'</h4>
220 220
 					<button type="button" class="add-new button-secondary button-link">
221
-						<span class="screen-reader-text">' . esc_html__( 'Add New Condition', 'wordpoints' ) . '</span>
221
+						<span class="screen-reader-text">' . esc_html__('Add New Condition', 'wordpoints').'</span>
222 222
 						<span class="dashicons dashicons-plus"></span>
223 223
 					</button>
224 224
 				</div>
225 225
 				<div class="add-condition-form hidden">
226 226
 					<div class="no-conditions hidden">
227
-						' . esc_html__( 'No conditions available.', 'wordpoints' ) . '
227
+						' . esc_html__('No conditions available.', 'wordpoints').'
228 228
 					</div>
229 229
 					<div class="condition-selectors">
230 230
 						<div class="arg-selectors"></div>
231 231
 						<div class="condition-selector"></div>
232 232
 					</div>
233
-					<button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__( 'Add Condition', 'wordpoints' ) . '">
234
-						' . esc_html_x( 'Add', 'reaction condition', 'wordpoints' ) . '
233
+					<button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__('Add Condition', 'wordpoints').'">
234
+						' . esc_html_x('Add', 'reaction condition', 'wordpoints').'
235 235
 					</button>
236
-					<button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__( 'Cancel Adding New Condition', 'wordpoints' ) . '">
237
-						' . esc_html_x( 'Cancel', 'reaction condition', 'wordpoints' ) . '
236
+					<button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__('Cancel Adding New Condition', 'wordpoints').'">
237
+						' . esc_html_x('Cancel', 'reaction condition', 'wordpoints').'
238 238
 					</button>
239 239
 				</div>
240 240
 				<div class="condition-groups section-content"></div>
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 				<div class="condition-controls">
249 249
 					<div class="condition-title"></div>
250 250
 					<button type="button" class="delete button-secondary button-link">
251
-						<span class="screen-reader-text">' . esc_html__( 'Remove Condition', 'wordpoints' ) . '</span>
251
+						<span class="screen-reader-text">' . esc_html__('Remove Condition', 'wordpoints').'</span>
252 252
 						<span class="dashicons dashicons-no"></span>
253 253
 					</button>
254 254
 				</div>
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 
267 267
 	wp_register_script(
268 268
 		'wordpoints-hooks-extension-periods'
269
-		, $assets_url . '/js/hooks/extensions/periods.js'
270
-		, array( 'wordpoints-hooks-views' )
269
+		, $assets_url.'/js/hooks/extensions/periods.js'
270
+		, array('wordpoints-hooks-views')
271 271
 		, WORDPOINTS_VERSION
272 272
 	);
273 273
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 		, '
278 278
 			<script type="text/template" id="tmpl-wordpoints-hook-periods">
279 279
 				<div class="periods-title section-title">
280
-					<h4>' . esc_html__( 'Rate Limit', 'wordpoints' ) . '</h4>
280
+					<h4>' . esc_html__('Rate Limit', 'wordpoints').'</h4>
281 281
 				</div>
282 282
 				<div class="periods section-content"></div>
283 283
 			</script>
@@ -296,27 +296,27 @@  discard block
 block discarded – undo
296 296
 
297 297
 	$extensions_data = array();
298 298
 
299
-	foreach ( $hooks->extensions->get_all() as $slug => $extension ) {
299
+	foreach ($hooks->extensions->get_all() as $slug => $extension) {
300 300
 
301
-		if ( $extension instanceof WordPoints_Hook_Extension ) {
302
-			$extensions_data[ $slug ] = $extension->get_ui_script_data();
301
+		if ($extension instanceof WordPoints_Hook_Extension) {
302
+			$extensions_data[$slug] = $extension->get_ui_script_data();
303 303
 		}
304 304
 
305
-		if ( wp_script_is( "wordpoints-hooks-extension-{$slug}", 'registered' ) ) {
306
-			wp_enqueue_script( "wordpoints-hooks-extension-{$slug}" );
305
+		if (wp_script_is("wordpoints-hooks-extension-{$slug}", 'registered')) {
306
+			wp_enqueue_script("wordpoints-hooks-extension-{$slug}");
307 307
 		}
308 308
 	}
309 309
 
310 310
 	$reactor_data = array();
311 311
 
312
-	foreach ( $hooks->reactors->get_all() as $slug => $reactor ) {
312
+	foreach ($hooks->reactors->get_all() as $slug => $reactor) {
313 313
 
314
-		if ( $reactor instanceof WordPoints_Hook_Reactor ) {
315
-			$reactor_data[ $slug ] = $reactor->get_ui_script_data();
314
+		if ($reactor instanceof WordPoints_Hook_Reactor) {
315
+			$reactor_data[$slug] = $reactor->get_ui_script_data();
316 316
 		}
317 317
 
318
-		if ( wp_script_is( "wordpoints-hooks-reactor-{$slug}", 'registered' ) ) {
319
-			wp_enqueue_script( "wordpoints-hooks-reactor-{$slug}" );
318
+		if (wp_script_is("wordpoints-hooks-reactor-{$slug}", 'registered')) {
319
+			wp_enqueue_script("wordpoints-hooks-reactor-{$slug}");
320 320
 		}
321 321
 	}
322 322
 
@@ -328,28 +328,28 @@  discard block
 block discarded – undo
328 328
 	$entity_children = $entities->children;
329 329
 
330 330
 	/** @var WordPoints_Entity $entity */
331
-	foreach ( $entities->get_all() as $slug => $entity ) {
331
+	foreach ($entities->get_all() as $slug => $entity) {
332 332
 
333 333
 		$child_data = array();
334 334
 
335 335
 		/** @var WordPoints_EntityishI $child */
336
-		foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) {
336
+		foreach ($entity_children->get_children($slug) as $child_slug => $child) {
337 337
 
338
-			$child_data[ $child_slug ] = array(
338
+			$child_data[$child_slug] = array(
339 339
 				'slug'  => $child_slug,
340 340
 				'title' => $child->get_title(),
341 341
 			);
342 342
 
343
-			if ( $child instanceof WordPoints_Entity_Attr ) {
343
+			if ($child instanceof WordPoints_Entity_Attr) {
344 344
 
345
-				$child_data[ $child_slug ]['_type'] = 'attr';
346
-				$child_data[ $child_slug ]['data_type']  = $child->get_data_type();
345
+				$child_data[$child_slug]['_type'] = 'attr';
346
+				$child_data[$child_slug]['data_type'] = $child->get_data_type();
347 347
 
348
-			} elseif ( $child instanceof WordPoints_Entity_Relationship ) {
348
+			} elseif ($child instanceof WordPoints_Entity_Relationship) {
349 349
 
350
-				$child_data[ $child_slug ]['_type']     = 'relationship';
351
-				$child_data[ $child_slug ]['primary']   = $child->get_primary_entity_slug();
352
-				$child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug();
350
+				$child_data[$child_slug]['_type']     = 'relationship';
351
+				$child_data[$child_slug]['primary']   = $child->get_primary_entity_slug();
352
+				$child_data[$child_slug]['secondary'] = $child->get_related_entity_slug();
353 353
 			}
354 354
 
355 355
 			/**
@@ -360,10 +360,10 @@  discard block
 block discarded – undo
360 360
 			 * @param array                $data  The data for the entity child.
361 361
 			 * @param WordPoints_Entityish $child The child's object.
362 362
 			 */
363
-			$child_data[ $child_slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity_child', $child_data[ $child_slug ], $child );
363
+			$child_data[$child_slug] = apply_filters('wordpoints_hooks_ui_data_entity_child', $child_data[$child_slug], $child);
364 364
 		}
365 365
 
366
-		$entities_data[ $slug ] = array(
366
+		$entities_data[$slug] = array(
367 367
 			'slug'     => $slug,
368 368
 			'title'    => $entity->get_title(),
369 369
 			'children' => $child_data,
@@ -371,12 +371,12 @@  discard block
 block discarded – undo
371 371
 			'_type'    => 'entity',
372 372
 		);
373 373
 
374
-		if ( $entity instanceof WordPoints_Entity_EnumerableI ) {
374
+		if ($entity instanceof WordPoints_Entity_EnumerableI) {
375 375
 
376 376
 			$values = array();
377 377
 
378
-			foreach ( $entity->get_enumerated_values() as $value ) {
379
-				if ( $entity->set_the_value( $value ) ) {
378
+			foreach ($entity->get_enumerated_values() as $value) {
379
+				if ($entity->set_the_value($value)) {
380 380
 					$values[] = array(
381 381
 						'value' => $entity->get_the_id(),
382 382
 						'label' => $entity->get_the_human_id(),
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 				}
385 385
 			}
386 386
 
387
-			$entities_data[ $slug ]['values'] = $values;
387
+			$entities_data[$slug]['values'] = $values;
388 388
 		}
389 389
 
390 390
 		/**
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 		 * @param array             $data   The data for the entity.
394 394
 		 * @param WordPoints_Entity $entity The entity object.
395 395
 		 */
396
-		$entities_data[ $slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity', $entities_data[ $slug ], $entity );
396
+		$entities_data[$slug] = apply_filters('wordpoints_hooks_ui_data_entity', $entities_data[$slug], $entity);
397 397
 	}
398 398
 
399 399
 	$data = array(
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 	 *
415 415
 	 * @param array $data The data.
416 416
 	 */
417
-	$data = apply_filters( 'wordpoints_hooks_ui_data', $data );
417
+	$data = apply_filters('wordpoints_hooks_ui_data', $data);
418 418
 
419 419
 	wp_localize_script(
420 420
 		'wordpoints-hooks-models'
@@ -439,13 +439,13 @@  discard block
 block discarded – undo
439 439
  *
440 440
  * @return string The HTML with templates appended.
441 441
  */
442
-function wordpoints_script_templates_filter( $html, $handle ) {
442
+function wordpoints_script_templates_filter($html, $handle) {
443 443
 
444 444
 	global $wp_scripts;
445 445
 
446
-	$templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' );
446
+	$templates = $wp_scripts->get_data($handle, 'wordpoints-templates');
447 447
 
448
-	if ( $templates ) {
448
+	if ($templates) {
449 449
 		$html .= $templates;
450 450
 	}
451 451
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
  */
462 462
 function wordpoints_hooks_admin_ajax() {
463 463
 
464
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
464
+	if (defined('DOING_AJAX') && DOING_AJAX) {
465 465
 		new WordPoints_Admin_Ajax_Hooks;
466 466
 	}
467 467
 }
Please login to merge, or discard this patch.
src/includes/actions.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@
 block discarded – undo
7 7
  * @since 1.0.0
8 8
  */
9 9
 
10
-add_action( 'wordpoints_init_app-apps', 'wordpoints_apps_init' );
11
-add_action( 'wordpoints_init_app-entities', 'wordpoints_entities_app_init' );
10
+add_action('wordpoints_init_app-apps', 'wordpoints_apps_init');
11
+add_action('wordpoints_init_app-entities', 'wordpoints_entities_app_init');
12 12
 
13
-add_action( 'wordpoints_init_app_registry-apps-entities', 'wordpoints_entities_init' );
14
-add_action( 'wordpoints_init_app_registry-entities-contexts', 'wordpoints_entity_contexts_init' );
13
+add_action('wordpoints_init_app_registry-apps-entities', 'wordpoints_entities_init');
14
+add_action('wordpoints_init_app_registry-entities-contexts', 'wordpoints_entity_contexts_init');
15 15
 
16
-add_action( 'wordpoints_init_app_registry-apps-data_types', 'wordpoints_data_types_init' );
16
+add_action('wordpoints_init_app_registry-apps-data_types', 'wordpoints_data_types_init');
17 17
 
18
-add_action( 'wordpoints_init_app_registry-hooks-firers', 'wordpoints_hook_firers_init' );
19
-add_action( 'wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init' );
20
-add_action( 'wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init' );
21
-add_action( 'wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init' );
22
-add_action( 'wordpoints_init_app_registry-hooks-reaction_groups', 'wordpoints_hook_reaction_groups_init' );
23
-add_action( 'wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init' );
24
-add_action( 'wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init' );
18
+add_action('wordpoints_init_app_registry-hooks-firers', 'wordpoints_hook_firers_init');
19
+add_action('wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init');
20
+add_action('wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init');
21
+add_action('wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init');
22
+add_action('wordpoints_init_app_registry-hooks-reaction_groups', 'wordpoints_hook_reaction_groups_init');
23
+add_action('wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init');
24
+add_action('wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init');
25 25
 
26
-add_action( 'wordpoints_modules_loaded', 'wordpoints_init_hooks' );
26
+add_action('wordpoints_modules_loaded', 'wordpoints_init_hooks');
27 27
 
28
-add_action( 'init', 'wordpoints_hooks_api_add_global_cache_groups', 5 );
28
+add_action('init', 'wordpoints_hooks_api_add_global_cache_groups', 5);
29 29
 
30
-add_filter( 'wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log' );
30
+add_filter('wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log');
31 31
 
32 32
 // EOF
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
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 	public function get_ui_script_data() {
26 26
 
27 27
 		$periods = array(
28
-			MINUTE_IN_SECONDS   => __( 'Minute', 'wordpoints' ),
29
-			HOUR_IN_SECONDS     => __( 'Hour',   'wordpoints' ),
30
-			DAY_IN_SECONDS      => __( 'Day',    'wordpoints' ),
31
-			WEEK_IN_SECONDS     => __( 'Week',   'wordpoints' ),
32
-			30 * DAY_IN_SECONDS => __( 'Month',  'wordpoints' ),
28
+			MINUTE_IN_SECONDS   => __('Minute', 'wordpoints'),
29
+			HOUR_IN_SECONDS     => __('Hour', 'wordpoints'),
30
+			DAY_IN_SECONDS      => __('Day', 'wordpoints'),
31
+			WEEK_IN_SECONDS     => __('Week', 'wordpoints'),
32
+			30 * DAY_IN_SECONDS => __('Month', 'wordpoints'),
33 33
 		);
34 34
 
35 35
 		/**
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 		 *
40 40
 		 * @param string[] $periods The period titles, indexed by length in seconds.
41 41
 		 */
42
-		$periods = apply_filters( 'wordpoints_hooks_ui_data_periods', $periods );
42
+		$periods = apply_filters('wordpoints_hooks_ui_data_periods', $periods);
43 43
 
44 44
 		return array(
45 45
 			'periods' => $periods,
46 46
 			'l10n' => array(
47
-				'label' => __( 'Trigger reaction no more than once per:', 'wordpoints' ),
47
+				'label' => __('Trigger reaction no more than once per:', 'wordpoints'),
48 48
 			),
49 49
 		);
50 50
 	}
@@ -58,25 +58,25 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return array The validated periods.
60 60
 	 */
61
-	protected function validate_periods( $periods ) {
61
+	protected function validate_periods($periods) {
62 62
 
63
-		if ( ! is_array( $periods ) ) {
63
+		if ( ! is_array($periods)) {
64 64
 
65 65
 			$this->validator->add_error(
66
-				__( 'Periods do not match expected format.', 'wordpoints' )
66
+				__('Periods do not match expected format.', 'wordpoints')
67 67
 			);
68 68
 
69 69
 			return array();
70 70
 		}
71 71
 
72
-		foreach ( $periods as $index => $period ) {
72
+		foreach ($periods as $index => $period) {
73 73
 
74
-			$this->validator->push_field( $index );
74
+			$this->validator->push_field($index);
75 75
 
76
-			$period = $this->validate_period( $period );
76
+			$period = $this->validate_period($period);
77 77
 
78
-			if ( $period ) {
79
-				$periods[ $index ] = $period;
78
+			if ($period) {
79
+				$periods[$index] = $period;
80 80
 			}
81 81
 
82 82
 			$this->validator->pop_field();
@@ -94,30 +94,30 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @return array|false The validated period, or false if invalid.
96 96
 	 */
97
-	protected function validate_period( $period ) {
97
+	protected function validate_period($period) {
98 98
 
99
-		if ( ! is_array( $period ) ) {
99
+		if ( ! is_array($period)) {
100 100
 			$this->validator->add_error(
101
-				__( 'Period does not match expected format.', 'wordpoints' )
101
+				__('Period does not match expected format.', 'wordpoints')
102 102
 			);
103 103
 
104 104
 			return false;
105 105
 		}
106 106
 
107
-		if ( isset( $period['args'] ) ) {
108
-			$this->validate_period_args( $period['args'] );
107
+		if (isset($period['args'])) {
108
+			$this->validate_period_args($period['args']);
109 109
 		}
110 110
 
111
-		if ( ! isset( $period['length'] ) ) {
111
+		if ( ! isset($period['length'])) {
112 112
 
113 113
 			$this->validator->add_error(
114
-				__( 'Period length setting is missing.', 'wordpoints' )
114
+				__('Period length setting is missing.', 'wordpoints')
115 115
 			);
116 116
 
117
-		} elseif ( false === wordpoints_posint( $period['length'] ) ) {
117
+		} elseif (false === wordpoints_posint($period['length'])) {
118 118
 
119 119
 			$this->validator->add_error(
120
-				__( 'Period length must be a positive integer.', 'wordpoints' )
120
+				__('Period length must be a positive integer.', 'wordpoints')
121 121
 				, 'length'
122 122
 			);
123 123
 
@@ -134,34 +134,34 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param mixed $args The args the period is related to.
136 136
 	 */
137
-	protected function validate_period_args( $args ) {
137
+	protected function validate_period_args($args) {
138 138
 
139
-		if ( ! is_array( $args ) ) {
139
+		if ( ! is_array($args)) {
140 140
 
141 141
 			$this->validator->add_error(
142
-				__( 'Period does not match expected format.', 'wordpoints' )
142
+				__('Period does not match expected format.', 'wordpoints')
143 143
 				, 'args'
144 144
 			);
145 145
 
146 146
 			return;
147 147
 		}
148 148
 
149
-		$this->validator->push_field( 'args' );
149
+		$this->validator->push_field('args');
150 150
 
151
-		foreach ( $args as $index => $hierarchy ) {
151
+		foreach ($args as $index => $hierarchy) {
152 152
 
153
-			$this->validator->push_field( $index );
153
+			$this->validator->push_field($index);
154 154
 
155
-			if ( ! is_array( $hierarchy ) ) {
155
+			if ( ! is_array($hierarchy)) {
156 156
 
157 157
 				$this->validator->add_error(
158
-					__( 'Period does not match expected format.', 'wordpoints' )
158
+					__('Period does not match expected format.', 'wordpoints')
159 159
 				);
160 160
 
161
-			} elseif ( ! $this->event_args->get_from_hierarchy( $hierarchy ) ) {
161
+			} elseif ( ! $this->event_args->get_from_hierarchy($hierarchy)) {
162 162
 
163 163
 				$this->validator->add_error(
164
-					__( 'Invalid period.', 'wordpoints' ) // TODO better error message
164
+					__('Invalid period.', 'wordpoints') // TODO better error message
165 165
 				);
166 166
 			}
167 167
 
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 	/**
175 175
 	 * @since 1.0.0
176 176
 	 */
177
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
177
+	public function should_hit(WordPoints_Hook_Fire $fire) {
178 178
 
179
-		$periods = $fire->reaction->get_meta( 'periods' );
179
+		$periods = $fire->reaction->get_meta('periods');
180 180
 
181
-		if ( empty( $periods ) ) {
181
+		if (empty($periods)) {
182 182
 			return true;
183 183
 		}
184 184
 
185 185
 		$this->event_args = $fire->event_args;
186 186
 
187
-		foreach ( $periods as $period ) {
188
-			if ( ! $this->has_period_ended( $period, $fire->reaction ) ) {
187
+		foreach ($periods as $period) {
188
+			if ( ! $this->has_period_ended($period, $fire->reaction)) {
189 189
 				return false;
190 190
 			}
191 191
 		}
@@ -209,24 +209,24 @@  discard block
 block discarded – undo
209 209
 	) {
210 210
 
211 211
 		$period = $this->get_period_by_reaction(
212
-			$this->get_period_signature( $settings, $reaction )
212
+			$this->get_period_signature($settings, $reaction)
213 213
 			, $reaction
214 214
 		);
215 215
 
216 216
 		// If the period isn't found, we know that we can still fire.
217
-		if ( ! $period ) {
217
+		if ( ! $period) {
218 218
 			return true;
219 219
 		}
220 220
 
221
-		$now = current_time( 'timestamp' );
222
-		$hit_time = strtotime( $period->date, $now );
221
+		$now = current_time('timestamp');
222
+		$hit_time = strtotime($period->date, $now);
223 223
 
224
-		if ( ! empty( $settings['relative'] ) ) {
225
-			return ( $hit_time < $now - $settings['length'] );
224
+		if ( ! empty($settings['relative'])) {
225
+			return ($hit_time < $now - $settings['length']);
226 226
 		} else {
227 227
 			return (
228
-				(int) ( $hit_time / $settings['length'] )
229
-				< (int) ( $now / $settings['length'] )
228
+				(int) ($hit_time / $settings['length'])
229
+				< (int) ($now / $settings['length'])
230 230
 			);
231 231
 		}
232 232
 	}
@@ -240,24 +240,24 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @return array The arg values.
242 242
 	 */
243
-	protected function get_arg_values( array $period_args ) {
243
+	protected function get_arg_values(array $period_args) {
244 244
 
245 245
 		$values = array();
246 246
 
247
-		foreach ( $period_args as $arg_hierarchy ) {
247
+		foreach ($period_args as $arg_hierarchy) {
248 248
 
249 249
 			$arg = $this->event_args->get_from_hierarchy(
250 250
 				$arg_hierarchy
251 251
 			);
252 252
 
253
-			if ( ! $arg instanceof WordPoints_EntityishI ) {
253
+			if ( ! $arg instanceof WordPoints_EntityishI) {
254 254
 				continue;
255 255
 			}
256 256
 
257
-			$values[ implode( '.', $arg_hierarchy ) ] = $arg->get_the_value();
257
+			$values[implode('.', $arg_hierarchy)] = $arg->get_the_value();
258 258
 		}
259 259
 
260
-		ksort( $values );
260
+		ksort($values);
261 261
 
262 262
 		return $values;
263 263
 	}
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @return object|false The period data, or false if not found.
273 273
 	 */
274
-	protected function get_period( $period_id ) {
274
+	protected function get_period($period_id) {
275 275
 
276
-		$period = wp_cache_get( $period_id, 'wordpoints_hook_periods' );
276
+		$period = wp_cache_get($period_id, 'wordpoints_hook_periods');
277 277
 
278
-		if ( ! $period ) {
278
+		if ( ! $period) {
279 279
 
280 280
 			global $wpdb;
281 281
 
@@ -292,11 +292,11 @@  discard block
 block discarded – undo
292 292
 				)
293 293
 			);
294 294
 
295
-			if ( ! $period ) {
295
+			if ( ! $period) {
296 296
 				return false;
297 297
 			}
298 298
 
299
-			wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
299
+			wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
300 300
 		}
301 301
 
302 302
 		return $period;
@@ -320,14 +320,14 @@  discard block
 block discarded – undo
320 320
 
321 321
 		$reaction_guid = $reaction->get_guid();
322 322
 
323
-		$cache_key = wp_json_encode( $reaction_guid ) . "-{$signature}";
323
+		$cache_key = wp_json_encode($reaction_guid)."-{$signature}";
324 324
 
325 325
 		// Before we run the query, we try to lookup the ID in the cache.
326
-		$period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids_by_reaction' );
326
+		$period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids_by_reaction');
327 327
 
328 328
 		// If we found it, we can retrieve the period by ID instead.
329
-		if ( $period_id ) {
330
-			return $this->get_period( $period_id );
329
+		if ($period_id) {
330
+			return $this->get_period($period_id);
331 331
 		}
332 332
 
333 333
 		global $wpdb;
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 				, $signature
352 352
 				, $reaction_guid['reactor']
353 353
 				, $reaction_guid['group']
354
-				, wp_json_encode( $reaction_guid['context_id'] )
354
+				, wp_json_encode($reaction_guid['context_id'])
355 355
 				, $reaction_guid['id']
356 356
 			)
357 357
 		);
358 358
 
359
-		if ( ! $period ) {
359
+		if ( ! $period) {
360 360
 			return false;
361 361
 		}
362 362
 
363
-		wp_cache_set( $cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction' );
364
-		wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
363
+		wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction');
364
+		wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
365 365
 
366 366
 		return $period;
367 367
 	}
@@ -369,20 +369,20 @@  discard block
 block discarded – undo
369 369
 	/**
370 370
 	 * @since 1.0.0
371 371
 	 */
372
-	public function after_hit( WordPoints_Hook_Fire $fire ) {
372
+	public function after_hit(WordPoints_Hook_Fire $fire) {
373 373
 
374
-		$periods = $fire->reaction->get_meta( 'periods' );
374
+		$periods = $fire->reaction->get_meta('periods');
375 375
 
376
-		if ( empty( $periods ) ) {
376
+		if (empty($periods)) {
377 377
 			return;
378 378
 		}
379 379
 
380 380
 		$this->event_args = $fire->event_args;
381 381
 
382
-		foreach ( $periods as $settings ) {
382
+		foreach ($periods as $settings) {
383 383
 
384 384
 			$this->add_period(
385
-				$this->get_period_signature( $settings, $fire->reaction )
385
+				$this->get_period_signature($settings, $fire->reaction)
386 386
 				, $fire
387 387
 			);
388 388
 		}
@@ -407,14 +407,14 @@  discard block
 block discarded – undo
407 407
 		WordPoints_Hook_ReactionI $reaction
408 408
 	) {
409 409
 
410
-		if ( isset( $settings['args'] ) ) {
410
+		if (isset($settings['args'])) {
411 411
 			$period_args = $settings['args'];
412 412
 		} else {
413
-			$period_args = array( $reaction->get_meta( 'target' ) );
413
+			$period_args = array($reaction->get_meta('target'));
414 414
 		}
415 415
 
416 416
 		return wordpoints_hash(
417
-			wp_json_encode( $this->get_arg_values( $period_args ) )
417
+			wp_json_encode($this->get_arg_values($period_args))
418 418
 		);
419 419
 	}
420 420
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 *
429 429
 	 * @return false|object The period data, or false if not found.
430 430
 	 */
431
-	protected function add_period( $signature, WordPoints_Hook_Fire $fire ) {
431
+	protected function add_period($signature, WordPoints_Hook_Fire $fire) {
432 432
 
433 433
 		global $wpdb;
434 434
 
@@ -438,17 +438,17 @@  discard block
 block discarded – undo
438 438
 				'hit_id' => $fire->hit_id,
439 439
 				'signature' => $signature,
440 440
 			)
441
-			, array( '%d', '%s' )
441
+			, array('%d', '%s')
442 442
 		);
443 443
 
444
-		if ( ! $inserted ) {
444
+		if ( ! $inserted) {
445 445
 			return false;
446 446
 		}
447 447
 
448 448
 		$period_id = $wpdb->insert_id;
449 449
 
450 450
 		wp_cache_set(
451
-			wp_json_encode( $fire->reaction->get_guid() ) . "-{$signature}"
451
+			wp_json_encode($fire->reaction->get_guid())."-{$signature}"
452 452
 			, $period_id
453 453
 			, 'wordpoints_hook_period_ids_by_reaction'
454 454
 		);
Please login to merge, or discard this patch.
src/includes/classes/hook/reactor/points.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function get_settings_fields() {
55 55
 
56
-		$this->settings_fields['points']['label'] = _x( 'Points', 'form label', 'wordpoints' );
57
-		$this->settings_fields['log_text']['label'] = _x( 'Log Text', 'form label', 'wordpoints' );
58
-		$this->settings_fields['description']['label'] = _x( 'Description', 'form label', 'wordpoints' );
56
+		$this->settings_fields['points']['label'] = _x('Points', 'form label', 'wordpoints');
57
+		$this->settings_fields['log_text']['label'] = _x('Log Text', 'form label', 'wordpoints');
58
+		$this->settings_fields['description']['label'] = _x('Description', 'form label', 'wordpoints');
59 59
 
60 60
 		return parent::get_settings_fields();
61 61
 	}
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 
68 68
 		$data = parent::get_ui_script_data();
69 69
 
70
-		$data['target_label'] = __( 'Award To', 'wordpoints' );
71
-		$data['periods_label'] = __( 'Award each user no more than once per:', 'wordpoints' );
70
+		$data['target_label'] = __('Award To', 'wordpoints');
71
+		$data['periods_label'] = __('Award each user no more than once per:', 'wordpoints');
72 72
 
73 73
 		return $data;
74 74
 	}
@@ -82,23 +82,23 @@  discard block
 block discarded – undo
82 82
 		WordPoints_Hook_Event_Args $event_args
83 83
 	) {
84 84
 
85
-		if ( ! isset( $settings['points'] ) || false === wordpoints_int( $settings['points'] ) ) {
86
-			$validator->add_error( __( 'Points must be an integer.', 'wordpoints' ), 'points' );
85
+		if ( ! isset($settings['points']) || false === wordpoints_int($settings['points'])) {
86
+			$validator->add_error(__('Points must be an integer.', 'wordpoints'), 'points');
87 87
 		}
88 88
 
89
-		if ( ! isset( $settings['points_type'] ) || ! wordpoints_is_points_type( $settings['points_type'] ) ) {
90
-			$validator->add_error( __( 'Invalid points type.', 'wordpoints' ), 'points_type' );
89
+		if ( ! isset($settings['points_type']) || ! wordpoints_is_points_type($settings['points_type'])) {
90
+			$validator->add_error(__('Invalid points type.', 'wordpoints'), 'points_type');
91 91
 		}
92 92
 
93
-		if ( ! isset( $settings['description'] ) ) {
94
-			$validator->add_error( __( 'Description is required.', 'wordpoints' ), 'description' );
93
+		if ( ! isset($settings['description'])) {
94
+			$validator->add_error(__('Description is required.', 'wordpoints'), 'description');
95 95
 		}
96 96
 
97
-		if ( ! isset( $settings['log_text'] ) ) {
98
-			$validator->add_error( __( 'Log Text is required.', 'wordpoints' ), 'log_text' );
97
+		if ( ! isset($settings['log_text'])) {
98
+			$validator->add_error(__('Log Text is required.', 'wordpoints'), 'log_text');
99 99
 		}
100 100
 
101
-		return parent::validate_settings( $settings, $validator, $event_args );
101
+		return parent::validate_settings($settings, $validator, $event_args);
102 102
 	}
103 103
 
104 104
 	/**
@@ -109,49 +109,49 @@  discard block
 block discarded – undo
109 109
 		array $settings
110 110
 	) {
111 111
 
112
-		parent::update_settings( $reaction, $settings );
112
+		parent::update_settings($reaction, $settings);
113 113
 
114
-		$reaction->update_meta( 'points', $settings['points'] );
115
-		$reaction->update_meta( 'points_type', $settings['points_type'] );
116
-		$reaction->update_meta( 'description', $settings['description'] );
117
-		$reaction->update_meta( 'log_text', $settings['log_text'] );
114
+		$reaction->update_meta('points', $settings['points']);
115
+		$reaction->update_meta('points_type', $settings['points_type']);
116
+		$reaction->update_meta('description', $settings['description']);
117
+		$reaction->update_meta('log_text', $settings['log_text']);
118 118
 	}
119 119
 
120 120
 	/**
121 121
 	 * @since 1.0.0
122 122
 	 */
123
-	public function hit( WordPoints_Hook_Fire $fire ) {
123
+	public function hit(WordPoints_Hook_Fire $fire) {
124 124
 
125 125
 		$reaction = $fire->reaction;
126 126
 
127 127
 		$target = $fire->event_args->get_from_hierarchy(
128
-			$reaction->get_meta( 'target' )
128
+			$reaction->get_meta('target')
129 129
 		);
130 130
 
131
-		if ( ! $target instanceof WordPoints_Entity ) {
131
+		if ( ! $target instanceof WordPoints_Entity) {
132 132
 			return;
133 133
 		}
134 134
 
135 135
 		$meta = array();
136 136
 
137
-		foreach ( $fire->event_args->get_entities() as $entity ) {
138
-			$meta[ $entity->get_slug() ] = $entity->get_the_id();
137
+		foreach ($fire->event_args->get_entities() as $entity) {
138
+			$meta[$entity->get_slug()] = $entity->get_the_id();
139 139
 		}
140 140
 
141 141
 		wordpoints_alter_points(
142 142
 			$target->get_the_id()
143
-			, $reaction->get_meta( 'points' )
144
-			, $reaction->get_meta( 'points_type' )
143
+			, $reaction->get_meta('points')
144
+			, $reaction->get_meta('points_type')
145 145
 			, $reaction->get_event_slug()
146 146
 			, $meta
147
-			, $reaction->get_meta( 'log_text' )
147
+			, $reaction->get_meta('log_text')
148 148
 		);
149 149
 	}
150 150
 
151 151
 	/**
152 152
 	 * @since 1.0.0
153 153
 	 */
154
-	public function reverse_hit( WordPoints_Hook_Fire $fire ) {
154
+	public function reverse_hit(WordPoints_Hook_Fire $fire) {
155 155
 
156 156
 		$meta_queries = array(
157 157
 			array(
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 			),
163 163
 		);
164 164
 
165
-		foreach ( $fire->event_args->get_entities() as $slug => $entity ) {
165
+		foreach ($fire->event_args->get_entities() as $slug => $entity) {
166 166
 
167 167
 			$meta_queries[] = array(
168 168
 				'key'   => $slug,
@@ -179,35 +179,35 @@  discard block
 block discarded – undo
179 179
 
180 180
 		$logs = $query->get();
181 181
 
182
-		if ( ! $logs ) {
182
+		if ( ! $logs) {
183 183
 			return;
184 184
 		}
185 185
 
186 186
 		global $wpdb;
187 187
 
188
-		add_filter( 'wordpoints_points_log', '__return_false' );
188
+		add_filter('wordpoints_points_log', '__return_false');
189 189
 
190
-		foreach ( $logs as $log ) {
190
+		foreach ($logs as $log) {
191 191
 
192 192
 			wordpoints_alter_points(
193 193
 				$log->user_id
194 194
 				, -$log->points
195 195
 				, $log->points_type
196 196
 				, "reverse-{$log->log_type}"
197
-				, array( 'original_log_id' => $log->id )
197
+				, array('original_log_id' => $log->id)
198 198
 			);
199 199
 
200
-			wordpoints_points_log_delete_all_metadata( $log->id );
200
+			wordpoints_points_log_delete_all_metadata($log->id);
201 201
 
202 202
 			// Now delete the log.
203 203
 			$wpdb->delete(
204 204
 				$wpdb->wordpoints_points_logs
205
-				, array( 'id' => $log->id )
205
+				, array('id' => $log->id)
206 206
 				, '%d'
207 207
 			); // WPCS: cache OK, cleaned by wordpoints_alter_points().
208 208
 		}
209 209
 
210
-		remove_filter( 'wordpoints_points_log', '__return_false' );
210
+		remove_filter('wordpoints_points_log', '__return_false');
211 211
 	}
212 212
 }
213 213
 
Please login to merge, or discard this patch.
src/includes/functions.php 1 patch
Spacing   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  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' );
38
+	$reactors->register('points', 'WordPoints_Hook_Reactor_Points');
39 39
 }
40 40
 
41 41
 /**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
  *
48 48
  * @param WordPoints_Class_Registry_Children $reaction_groups The group registry.
49 49
  */
50
-function wordpoints_hook_reaction_groups_init( $reaction_groups ) {
50
+function wordpoints_hook_reaction_groups_init($reaction_groups) {
51 51
 
52 52
 	$reaction_groups->register(
53 53
 		'points'
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		, 'WordPoints_Hook_Reaction_Storage_Options'
56 56
 	);
57 57
 
58
-	if ( is_wordpoints_network_active() ) {
58
+	if (is_wordpoints_network_active()) {
59 59
 		$reaction_groups->register(
60 60
 			'points'
61 61
 			, 'network'
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
  *
74 74
  * @param WordPoints_Class_Registry_Persistent $extensions The extension registry.
75 75
  */
76
-function wordpoints_hook_extension_init( $extensions ) {
76
+function wordpoints_hook_extension_init($extensions) {
77 77
 
78
-	$extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' );
79
-	$extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' );
78
+	$extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions');
79
+	$extensions->register('periods', 'WordPoints_Hook_Extension_Periods');
80 80
 }
81 81
 
82 82
 /**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
  *
89 89
  * @param WordPoints_Class_Registry_Children $conditions The conditions registry.
90 90
  */
91
-function wordpoints_hook_conditions_init( $conditions ) {
91
+function wordpoints_hook_conditions_init($conditions) {
92 92
 
93 93
 	$conditions->register(
94 94
 		'text'
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
  *
125 125
  * @param WordPoints_Hook_Actions $actions The action registry.
126 126
  */
127
-function wordpoints_hook_actions_init( $actions ) {
127
+function wordpoints_hook_actions_init($actions) {
128 128
 
129 129
 	$actions->register(
130 130
 		'comment_approve'
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 		, array(
133 133
 			'action' => 'transition_comment_status',
134 134
 			'data'   => array(
135
-				'arg_index'    => array( 'comment' => 2 ),
136
-				'requirements' => array( 0 => 'approved' ),
135
+				'arg_index'    => array('comment' => 2),
136
+				'requirements' => array(0 => 'approved'),
137 137
 			),
138 138
 		)
139 139
 	);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		, array(
145 145
 			'action' => 'wp_insert_comment',
146 146
 			'data'   => array(
147
-				'arg_index' => array( 'comment' => 1 ),
147
+				'arg_index' => array('comment' => 1),
148 148
 			),
149 149
 		)
150 150
 	);
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 		, array(
156 156
 			'action' => 'transition_comment_status',
157 157
 			'data'   => array(
158
-				'arg_index' => array( 'comment' => 2 ),
159
-				'requirements' => array( 1 => 'approved' ),
158
+				'arg_index' => array('comment' => 2),
159
+				'requirements' => array(1 => 'approved'),
160 160
 			),
161 161
 		)
162 162
 	);
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 		, array(
169 169
 			'action' => 'transition_post_status',
170 170
 			'data'   => array(
171
-				'arg_index' => array( 'post' => 2 ),
172
-				'requirements' => array( 0 => 'publish' ),
171
+				'arg_index' => array('post' => 2),
172
+				'requirements' => array(0 => 'publish'),
173 173
 			),
174 174
 		)
175 175
 	);
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		, array(
181 181
 			'action' => 'add_attachment',
182 182
 			'data'   => array(
183
-				'arg_index' => array( 'post\attachment' => 0 ),
183
+				'arg_index' => array('post\attachment' => 0),
184 184
 			),
185 185
 		)
186 186
 	);
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		, array(
192 192
 			'action' => 'post_delete',
193 193
 			'data'   => array(
194
-				'arg_index' => array( 'post' => 0 ),
194
+				'arg_index' => array('post' => 0),
195 195
 			),
196 196
 		)
197 197
 	);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		, array(
203 203
 			'action' => 'user_register',
204 204
 			'data'   => array(
205
-				'arg_index' => array( 'user' => 0 ),
205
+				'arg_index' => array('user' => 0),
206 206
 			),
207 207
 		)
208 208
 	);
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 		, array(
214 214
 			'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user',
215 215
 			'data'   => array(
216
-				'arg_index' => array( 'user' => 0 ),
216
+				'arg_index' => array('user' => 0),
217 217
 			),
218 218
 		)
219 219
 	);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
  *
237 237
  * @param WordPoints_Hook_Events $events The event registry.
238 238
  */
239
-function wordpoints_hook_events_init( $events ) {
239
+function wordpoints_hook_events_init($events) {
240 240
 
241 241
 	$events->register(
242 242
 		'user_register'
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	);
267 267
 
268 268
 	// Register events for all of the public post types.
269
-	$post_types = get_post_types( array( 'public' => true ) );
269
+	$post_types = get_post_types(array('public' => true));
270 270
 
271 271
 	/**
272 272
 	 * Filter which post types to register hook events for.
@@ -275,20 +275,20 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @param string[] The post type slugs ("names").
277 277
 	 */
278
-	$post_types = apply_filters( 'wordpoints_register_hook_events_for_post_types', $post_types );
278
+	$post_types = apply_filters('wordpoints_register_hook_events_for_post_types', $post_types);
279 279
 
280
-	foreach ( $post_types as $slug ) {
281
-		wordpoints_register_post_type_hook_events( $slug );
280
+	foreach ($post_types as $slug) {
281
+		wordpoints_register_post_type_hook_events($slug);
282 282
 	}
283 283
 
284
-	if ( is_multisite() ) {
284
+	if (is_multisite()) {
285 285
 
286 286
 		$event_slugs = array(
287 287
 			'user_visit',
288 288
 			'user_register',
289 289
 		);
290 290
 
291
-		foreach ( $event_slugs as $event_slug ) {
291
+		foreach ($event_slugs as $event_slug) {
292 292
 			// TODO network hooks
293 293
 			$events->args->register(
294 294
 				$event_slug
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
  *
309 309
  * @param WordPoints_Class_Registry_Persistent $firers The firer registry.
310 310
  */
311
-function wordpoints_hook_firers_init( $firers ) {
311
+function wordpoints_hook_firers_init($firers) {
312 312
 
313
-	$firers->register( 'fire', 'WordPoints_Hook_Firer' );
314
-	$firers->register( 'reverse', 'WordPoints_Hook_Firer_Reverse' );
313
+	$firers->register('fire', 'WordPoints_Hook_Firer');
314
+	$firers->register('reverse', 'WordPoints_Hook_Firer_Reverse');
315 315
 }
316 316
 
317 317
 /**
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
  *
324 324
  * @param WordPoints_App_Registry $entities The entities app.
325 325
  */
326
-function wordpoints_entities_app_init( $entities ) {
326
+function wordpoints_entities_app_init($entities) {
327 327
 
328
-	$entities->sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' );
329
-	$entities->sub_apps->register( 'contexts', 'WordPoints_Class_Registry' );
328
+	$entities->sub_apps->register('children', 'WordPoints_Class_Registry_Children');
329
+	$entities->sub_apps->register('contexts', 'WordPoints_Class_Registry');
330 330
 }
331 331
 
332 332
 /**
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
  *
339 339
  * @param WordPoints_Class_Registry $contexts The entity context registry.
340 340
  */
341
-function wordpoints_entity_contexts_init( $contexts ) {
341
+function wordpoints_entity_contexts_init($contexts) {
342 342
 
343
-	$contexts->register( 'network', 'WordPoints_Entity_Context_Network' );
344
-	$contexts->register( 'site', 'WordPoints_Entity_Context_Site' );
343
+	$contexts->register('network', 'WordPoints_Entity_Context_Network');
344
+	$contexts->register('site', 'WordPoints_Entity_Context_Site');
345 345
 }
346 346
 
347 347
 /**
@@ -353,18 +353,18 @@  discard block
 block discarded – undo
353 353
  *
354 354
  * @param WordPoints_App_Registry $entities The entities app.
355 355
  */
356
-function wordpoints_entities_init( $entities ) {
356
+function wordpoints_entities_init($entities) {
357 357
 
358 358
 	$children = $entities->children;
359 359
 
360
-	$entities->register( 'user', 'WordPoints_Entity_User' );
361
-	$children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' );
360
+	$entities->register('user', 'WordPoints_Entity_User');
361
+	$children->register('user', 'roles', 'WordPoints_Entity_User_Roles');
362 362
 
363
-	$entities->register( 'user_role', 'WordPoints_Entity_User_Role' );
364
-	$children->register( 'user_role', 'name', 'WordPoints_Entity_User_Role_Name' );
363
+	$entities->register('user_role', 'WordPoints_Entity_User_Role');
364
+	$children->register('user_role', 'name', 'WordPoints_Entity_User_Role_Name');
365 365
 
366 366
 	// Register entities for all of the public post types.
367
-	$post_types = get_post_types( array( 'public' => true ) );
367
+	$post_types = get_post_types(array('public' => true));
368 368
 
369 369
 	/**
370 370
 	 * Filter which post types to register entities for.
@@ -373,14 +373,14 @@  discard block
 block discarded – undo
373 373
 	 *
374 374
 	 * @param string[] The post type slugs ("names").
375 375
 	 */
376
-	$post_types = apply_filters( 'wordpoints_register_entities_for_post_types', $post_types );
376
+	$post_types = apply_filters('wordpoints_register_entities_for_post_types', $post_types);
377 377
 
378
-	foreach ( $post_types as $slug ) {
379
-		wordpoints_register_post_type_entities( $slug );
378
+	foreach ($post_types as $slug) {
379
+		wordpoints_register_post_type_entities($slug);
380 380
 	}
381 381
 
382 382
 	// Register entities for all of the public taxonomies.
383
-	$taxonomies = get_taxonomies( array( 'public' => true ) );
383
+	$taxonomies = get_taxonomies(array('public' => true));
384 384
 
385 385
 	/**
386 386
 	 * Filter which taxonomies to register entities for.
@@ -389,10 +389,10 @@  discard block
 block discarded – undo
389 389
 	 *
390 390
 	 * @param string[] The taxonomy slugs.
391 391
 	 */
392
-	$taxonomies = apply_filters( 'wordpoints_register_entities_for_taxonomies', $taxonomies );
392
+	$taxonomies = apply_filters('wordpoints_register_entities_for_taxonomies', $taxonomies);
393 393
 
394
-	foreach ( $taxonomies as $slug ) {
395
-		wordpoints_register_taxonomy_entities( $slug );
394
+	foreach ($taxonomies as $slug) {
395
+		wordpoints_register_taxonomy_entities($slug);
396 396
 	}
397 397
 }
398 398
 
@@ -403,28 +403,28 @@  discard block
 block discarded – undo
403 403
  *
404 404
  * @param string $slug The slug of the post type.
405 405
  */
406
-function wordpoints_register_post_type_entities( $slug ) {
406
+function wordpoints_register_post_type_entities($slug) {
407 407
 
408 408
 	$entities = wordpoints_entities();
409 409
 	$children = $entities->children;
410 410
 
411
-	$entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' );
412
-	$children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' );
411
+	$entities->register("post\\{$slug}", 'WordPoints_Entity_Post');
412
+	$children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author');
413 413
 
414
-	$supports = get_all_post_type_supports( $slug );
414
+	$supports = get_all_post_type_supports($slug);
415 415
 
416
-	if ( isset( $supports['editor'] ) ) {
417
-		$children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' );
416
+	if (isset($supports['editor'])) {
417
+		$children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content');
418 418
 	}
419 419
 
420
-	if ( isset( $supports['comments'] ) ) {
421
-		$entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' );
422
-		$children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' );
423
-		$children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' );
420
+	if (isset($supports['comments'])) {
421
+		$entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment');
422
+		$children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post');
423
+		$children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author');
424 424
 	}
425 425
 
426
-	foreach ( get_object_taxonomies( $slug ) as $taxonomy_slug ) {
427
-		$children->register( "post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms' );
426
+	foreach (get_object_taxonomies($slug) as $taxonomy_slug) {
427
+		$children->register("post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms');
428 428
 	}
429 429
 
430 430
 	/**
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	 *
435 435
 	 * @param string $slug The slug ("name") of the post type.
436 436
 	 */
437
-	do_action( 'wordpoints_register_post_type_entities', $slug );
437
+	do_action('wordpoints_register_post_type_entities', $slug);
438 438
 }
439 439
 
440 440
 /**
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
  *
445 445
  * @param string $slug The slug of the post type.
446 446
  */
447
-function wordpoints_register_post_type_hook_events( $slug ) {
447
+function wordpoints_register_post_type_hook_events($slug) {
448 448
 
449 449
 	$event_slugs = array();
450 450
 
451 451
 	$events = wordpoints_hooks()->events;
452 452
 
453
-	if ( 'attachment' === $slug ) {
453
+	if ('attachment' === $slug) {
454 454
 
455 455
 		$event_slugs[] = 'media_upload';
456 456
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 		);
488 488
 	}
489 489
 
490
-	if ( post_type_supports( $slug, 'comments' ) ) {
490
+	if (post_type_supports($slug, 'comments')) {
491 491
 
492 492
 		$event_slugs[] = "comment_leave\\{$slug}";
493 493
 
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 			, 'WordPoints_Hook_Event_Comment_Leave'
497 497
 			, array(
498 498
 				'actions' => array(
499
-					'fire' => array( 'comment_approve', 'comment_new' ),
499
+					'fire' => array('comment_approve', 'comment_new'),
500 500
 					'reverse' => 'comment_deapprove',
501 501
 				),
502 502
 				'args' => array(
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 		);
507 507
 	}
508 508
 
509
-	if ( is_multisite() ) {
510
-		foreach ( $event_slugs as $event_slug ) {
509
+	if (is_multisite()) {
510
+		foreach ($event_slugs as $event_slug) {
511 511
 			$events->args->register(
512 512
 				$event_slug
513 513
 				, 'current:site'
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 	 *
524 524
 	 * @param string $slug The slug ("name") of the post type.
525 525
 	 */
526
-	do_action( 'wordpoints_register_post_type_hook_events', $slug );
526
+	do_action('wordpoints_register_post_type_hook_events', $slug);
527 527
 }
528 528
 
529 529
 /**
@@ -533,13 +533,13 @@  discard block
 block discarded – undo
533 533
  *
534 534
  * @param string $slug The slug of the taxonomy.
535 535
  */
536
-function wordpoints_register_taxonomy_entities( $slug ) {
536
+function wordpoints_register_taxonomy_entities($slug) {
537 537
 
538 538
 	$entities = wordpoints_entities();
539 539
 	$children = $entities->children;
540 540
 
541
-	$entities->register( "term\\{$slug}", 'WordPoints_Entity_Term' );
542
-	$children->register( "term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id' );
541
+	$entities->register("term\\{$slug}", 'WordPoints_Entity_Term');
542
+	$children->register("term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id');
543 543
 
544 544
 	/**
545 545
 	 * Fired when registering the entities for a taxonomy.
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 	 *
549 549
 	 * @param string $slug The taxonomy's slug.
550 550
 	 */
551
-	do_action( 'wordpoints_register_taxonomy_entities', $slug );
551
+	do_action('wordpoints_register_taxonomy_entities', $slug);
552 552
 }
553 553
 
554 554
 /**
@@ -560,10 +560,10 @@  discard block
 block discarded – undo
560 560
  *
561 561
  * @param WordPoints_Class_RegistryI $data_types The data types registry.
562 562
  */
563
-function wordpoints_data_types_init( $data_types ) {
563
+function wordpoints_data_types_init($data_types) {
564 564
 
565
-	$data_types->register( 'integer', 'WordPoints_Data_Type_Integer' );
566
-	$data_types->register( 'text', 'WordPoints_Data_Type_Text' );
565
+	$data_types->register('integer', 'WordPoints_Data_Type_Integer');
566
+	$data_types->register('text', 'WordPoints_Data_Type_Text');
567 567
 }
568 568
 
569 569
 /**
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
  *
579 579
  * @return bool Whether the user can view the points log.
580 580
  */
581
-function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) {
581
+function wordpoints_hooks_user_can_view_points_log($can_view, $log) {
582 582
 
583
-	if ( ! $can_view ) {
583
+	if ( ! $can_view) {
584 584
 		return $can_view;
585 585
 	}
586 586
 
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
 	$event_slug = $log->log_type;
590 590
 
591 591
 	/** @var WordPoints_Hook_Arg $arg */
592
-	foreach ( wordpoints_hooks()->events->args->get_children( $event_slug ) as $slug => $arg ) {
592
+	foreach (wordpoints_hooks()->events->args->get_children($event_slug) as $slug => $arg) {
593 593
 
594
-		$value = wordpoints_get_points_log_meta( $log->id, $slug, true );
594
+		$value = wordpoints_get_points_log_meta($log->id, $slug, true);
595 595
 
596
-		if ( ! $value ) {
596
+		if ( ! $value) {
597 597
 			continue;
598 598
 		}
599 599
 
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 			, $value
604 604
 		);
605 605
 
606
-		if ( ! $can_view ) {
606
+		if ( ! $can_view) {
607 607
 			break;
608 608
 		}
609 609
 	}
@@ -622,20 +622,20 @@  discard block
 block discarded – undo
622 622
  *
623 623
  * @return bool Whether the user can view this entity.
624 624
  */
625
-function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) {
625
+function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) {
626 626
 
627
-	$entity = wordpoints_entities()->get( $entity_slug );
627
+	$entity = wordpoints_entities()->get($entity_slug);
628 628
 
629 629
 	// If this entity type is not found, we have no way of determining whether it is
630 630
 	// safe for the user to view it.
631
-	if ( ! ( $entity instanceof WordPoints_Entity ) ) {
631
+	if ( ! ($entity instanceof WordPoints_Entity)) {
632 632
 		return false;
633 633
 	}
634 634
 
635 635
 	$can_view = true;
636 636
 
637
-	if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) {
638
-		$can_view = $entity->user_can_view( $user_id, $entity_id );
637
+	if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) {
638
+		$can_view = $entity->user_can_view($user_id, $entity_id);
639 639
 	}
640 640
 
641 641
 	/**
@@ -666,8 +666,8 @@  discard block
 block discarded – undo
666 666
  */
667 667
 function wordpoints_apps() {
668 668
 
669
-	if ( ! isset( WordPoints_App::$main ) ) {
670
-		WordPoints_App::$main = new WordPoints_App( 'apps' );
669
+	if ( ! isset(WordPoints_App::$main)) {
670
+		WordPoints_App::$main = new WordPoints_App('apps');
671 671
 	}
672 672
 
673 673
 	return WordPoints_App::$main;
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
  */
683 683
 function wordpoints_hooks() {
684 684
 
685
-	if ( ! isset( WordPoints_App::$main ) ) {
685
+	if ( ! isset(WordPoints_App::$main)) {
686 686
 		wordpoints_apps();
687 687
 	}
688 688
 
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
  */
699 699
 function wordpoints_entities() {
700 700
 
701
-	if ( ! isset( WordPoints_App::$main ) ) {
701
+	if ( ! isset(WordPoints_App::$main)) {
702 702
 		wordpoints_apps();
703 703
 	}
704 704
 
@@ -714,13 +714,13 @@  discard block
 block discarded – undo
714 714
  *
715 715
  * @param WordPoints_App $app The main apps app.
716 716
  */
717
-function wordpoints_apps_init( $app ) {
717
+function wordpoints_apps_init($app) {
718 718
 
719 719
 	$apps = $app->sub_apps;
720 720
 
721
-	$apps->register( 'hooks', 'WordPoints_Hooks' );
722
-	$apps->register( 'entities', 'WordPoints_App_Registry' );
723
-	$apps->register( 'data_types', 'WordPoints_Class_Registry' );
721
+	$apps->register('hooks', 'WordPoints_Hooks');
722
+	$apps->register('entities', 'WordPoints_App_Registry');
723
+	$apps->register('data_types', 'WordPoints_Class_Registry');
724 724
 }
725 725
 
726 726
 /**
@@ -733,19 +733,19 @@  discard block
 block discarded – undo
733 733
  *
734 734
  * @return object|false The constructed object, or false if to many args were passed.
735 735
  */
736
-function wordpoints_construct_class_with_args( $class_name, array $args ) {
736
+function wordpoints_construct_class_with_args($class_name, array $args) {
737 737
 
738
-	switch ( count( $args ) ) {
738
+	switch (count($args)) {
739 739
 		case 0:
740 740
 			return new $class_name();
741 741
 		case 1:
742
-			return new $class_name( $args[0] );
742
+			return new $class_name($args[0]);
743 743
 		case 2:
744
-			return new $class_name( $args[0], $args[1] );
744
+			return new $class_name($args[0], $args[1]);
745 745
 		case 3:
746
-			return new $class_name( $args[0], $args[1], $args[2] );
746
+			return new $class_name($args[0], $args[1], $args[2]);
747 747
 		case 4:
748
-			return new $class_name( $args[0], $args[1], $args[2], $args[3] );
748
+			return new $class_name($args[0], $args[1], $args[2], $args[3]);
749 749
 		default:
750 750
 			return false;
751 751
 	}
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
  * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the
768 768
  *               slug is not dynamic, the value of each of those keys will be false.
769 769
  */
770
-function wordpoints_parse_dynamic_slug( $slug ) {
770
+function wordpoints_parse_dynamic_slug($slug) {
771 771
 
772
-	$parsed = array( 'dynamic' => false, 'generic' => false );
772
+	$parsed = array('dynamic' => false, 'generic' => false);
773 773
 
774
-	$parts = explode( '\\', $slug, 2 );
774
+	$parts = explode('\\', $slug, 2);
775 775
 
776
-	if ( isset( $parts[1] ) ) {
776
+	if (isset($parts[1])) {
777 777
 		$parsed['dynamic'] = $parts[1];
778 778
 		$parsed['generic'] = $parts[0];
779 779
 	}
@@ -812,28 +812,28 @@  discard block
 block discarded – undo
812 812
  *                     contexts, indexed by context slug, or false if any of the
813 813
  *                     contexts isn't current.
814 814
  */
815
-function wordpoints_entities_get_current_context_id( $slug ) {
815
+function wordpoints_entities_get_current_context_id($slug) {
816 816
 
817 817
 	$current_context = array();
818 818
 
819 819
 	/** @var WordPoints_Class_Registry $contexts */
820 820
 	$contexts = wordpoints_entities()->contexts;
821 821
 
822
-	while ( $slug ) {
822
+	while ($slug) {
823 823
 
824
-		$context = $contexts->get( $slug );
824
+		$context = $contexts->get($slug);
825 825
 
826
-		if ( ! $context instanceof WordPoints_Entity_Context ) {
826
+		if ( ! $context instanceof WordPoints_Entity_Context) {
827 827
 			return false;
828 828
 		}
829 829
 
830 830
 		$id = $context->get_current_id();
831 831
 
832
-		if ( false === $id ) {
832
+		if (false === $id) {
833 833
 			return false;
834 834
 		}
835 835
 
836
-		$current_context[ $slug ] = $id;
836
+		$current_context[$slug] = $id;
837 837
 
838 838
 		$slug = $context->get_parent_slug();
839 839
 	}
@@ -854,22 +854,22 @@  discard block
 block discarded – undo
854 854
  */
855 855
 function wordpoints_is_network_context() {
856 856
 
857
-	if ( ! is_multisite() ) {
857
+	if ( ! is_multisite()) {
858 858
 		return false;
859 859
 	}
860 860
 
861
-	if ( is_network_admin() ) {
861
+	if (is_network_admin()) {
862 862
 		return true;
863 863
 	}
864 864
 
865 865
 	// See https://core.trac.wordpress.org/ticket/22589
866 866
 	if (
867
-		defined( 'DOING_AJAX' )
867
+		defined('DOING_AJAX')
868 868
 		&& DOING_AJAX
869
-		&& isset( $_SERVER['HTTP_REFERER'] )
869
+		&& isset($_SERVER['HTTP_REFERER'])
870 870
 		&& preg_match(
871
-			'#^' . preg_quote( network_admin_url(), '#' ) . '#i'
872
-			, esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) )
871
+			'#^'.preg_quote(network_admin_url(), '#').'#i'
872
+			, esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER']))
873 873
 		)
874 874
 	) {
875 875
 		return true;
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 	 *
883 883
 	 * @param bool $in_network_context Whether we are in network context.
884 884
 	 */
885
-	return apply_filters( 'wordpoints_is_network_context', false );
885
+	return apply_filters('wordpoints_is_network_context', false);
886 886
 }
887 887
 
888 888
 /**
@@ -896,21 +896,21 @@  discard block
 block discarded – undo
896 896
  *
897 897
  * @return string The primary arg's GUID, JSON encoded.
898 898
  */
899
-function wordpoints_hooks_get_event_primary_arg_guid_json( WordPoints_Hook_Event_Args $event_args ) {
899
+function wordpoints_hooks_get_event_primary_arg_guid_json(WordPoints_Hook_Event_Args $event_args) {
900 900
 
901 901
 	$entity = $event_args->get_primary_arg();
902 902
 
903
-	if ( ! $entity ) {
903
+	if ( ! $entity) {
904 904
 		return '';
905 905
 	}
906 906
 
907 907
 	$the_guid = $entity->get_the_guid();
908 908
 
909
-	if ( ! $the_guid ) {
909
+	if ( ! $the_guid) {
910 910
 		return '';
911 911
 	}
912 912
 
913
-	return wp_json_encode( $the_guid );
913
+	return wp_json_encode($the_guid);
914 914
 }
915 915
 
916 916
 /**
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
  */
924 924
 function wordpoints_hooks_api_add_global_cache_groups() {
925 925
 
926
-	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
926
+	if (function_exists('wp_cache_add_global_groups')) {
927 927
 
928 928
 		wp_cache_add_global_groups(
929 929
 			array(
Please login to merge, or discard this patch.