Completed
Push — master ( 4e57eb...947d26 )
by J.D.
02:55
created
src/includes/classes/entity.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return mixed The entity, or false if not found.
108 108
 	 */
109
-	protected function get_entity( $id ) {
109
+	protected function get_entity($id) {
110 110
 
111
-		$entity = call_user_func( $this->getter, $id );
111
+		$entity = call_user_func($this->getter, $id);
112 112
 
113
-		if ( ! $this->is_entity( $entity ) ) {
113
+		if ( ! $this->is_entity($entity)) {
114 114
 			return false;
115 115
 		}
116 116
 
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return bool Whether the passed value is an entity.
128 128
 	 */
129
-	protected function is_entity( $entity ) {
129
+	protected function is_entity($entity) {
130 130
 
131
-		if ( ! is_object( $entity ) && ! is_array( $entity ) ) {
131
+		if ( ! is_object($entity) && ! is_array($entity)) {
132 132
 			return false;
133 133
 		}
134 134
 
135
-		return (bool) $this->get_entity_id( $entity );
135
+		return (bool) $this->get_entity_id($entity);
136 136
 	}
137 137
 
138 138
 	/**
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @return mixed The value of the attribute of the entity.
147 147
 	 */
148
-	protected function get_attr_value( $entity, $attr ) {
148
+	protected function get_attr_value($entity, $attr) {
149 149
 
150
-		if ( is_array( $entity ) ) {
151
-			if ( isset( $entity[ $attr ] ) ) {
152
-				return $entity[ $attr ];
150
+		if (is_array($entity)) {
151
+			if (isset($entity[$attr])) {
152
+				return $entity[$attr];
153 153
 			}
154 154
 		} else {
155
-			if ( isset( $entity->{$attr} ) ) {
155
+			if (isset($entity->{$attr} )) {
156 156
 				return $entity->{$attr};
157 157
 			}
158 158
 		}
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @return mixed The ID of the entity.
171 171
 	 */
172
-	protected function get_entity_id( $entity ) {
173
-		return $this->get_attr_value( $entity, $this->get_id_field() );
172
+	protected function get_entity_id($entity) {
173
+		return $this->get_attr_value($entity, $this->get_id_field());
174 174
 	}
175 175
 
176 176
 	/**
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return mixed The human ID of the entity.
188 188
 	 */
189
-	protected function get_entity_human_id( $entity ) {
190
-		return $this->get_attr_value( $entity, $this->human_id_field );
189
+	protected function get_entity_human_id($entity) {
190
+		return $this->get_attr_value($entity, $this->human_id_field);
191 191
 	}
192 192
 
193 193
 	//
@@ -231,15 +231,15 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return string|int|float|false The human identifier for the entity, or false.
233 233
 	 */
234
-	public function get_human_id( $id ) {
234
+	public function get_human_id($id) {
235 235
 
236
-		$entity = $this->get_entity( $id );
236
+		$entity = $this->get_entity($id);
237 237
 
238
-		if ( ! $entity ) {
238
+		if ( ! $entity) {
239 239
 			return false;
240 240
 		}
241 241
 
242
-		return $this->get_entity_human_id( $entity );
242
+		return $this->get_entity_human_id($entity);
243 243
 	}
244 244
 
245 245
 	/**
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return bool Whether or not an entity with that ID exists.
253 253
 	 */
254
-	public function exists( $id ) {
255
-		return (bool) $this->get_entity( $id );
254
+	public function exists($id) {
255
+		return (bool) $this->get_entity($id);
256 256
 	}
257 257
 
258 258
 	/**
@@ -267,17 +267,17 @@  discard block
 block discarded – undo
267 267
 	 *
268 268
 	 * @return WordPoints_Entityish|false The child's object, or false if not found.
269 269
 	 */
270
-	public function get_child( $child_slug ) {
270
+	public function get_child($child_slug) {
271 271
 
272 272
 		$children = wordpoints_entities()->children;
273 273
 
274
-		$child = $children->get( $this->slug, $child_slug );
274
+		$child = $children->get($this->slug, $child_slug);
275 275
 
276 276
 		if (
277
-			isset( $this->the_value )
277
+			isset($this->the_value)
278 278
 			&& $child instanceof WordPoints_Entity_ChildI
279 279
 		) {
280
-			$child->set_the_value_from_entity( $this );
280
+			$child->set_the_value_from_entity($this);
281 281
 		}
282 282
 
283 283
 		return $child;
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return bool Whether the value was set.
301 301
 	 */
302
-	public function set_the_value( $value ) {
302
+	public function set_the_value($value) {
303 303
 
304 304
 		$this->the_value = $this->the_entity = $this->the_context = null;
305 305
 
306
-		if ( $this->is_entity( $value ) ) {
306
+		if ($this->is_entity($value)) {
307 307
 
308 308
 			$entity = $value;
309
-			$value = $this->get_entity_id( $value );
309
+			$value = $this->get_entity_id($value);
310 310
 
311 311
 		} else {
312 312
 
313
-			$entity = $this->get_entity( $value );
313
+			$entity = $this->get_entity($value);
314 314
 
315
-			if ( ! $entity ) {
315
+			if ( ! $entity) {
316 316
 				return false;
317 317
 			}
318 318
 		}
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
 	 *
336 336
 	 * @return mixed The value of the attribute.
337 337
 	 */
338
-	public function get_the_attr_value( $attr ) {
339
-		return $this->get_attr_value( $this->the_entity, $attr );
338
+	public function get_the_attr_value($attr) {
339
+		return $this->get_attr_value($this->the_entity, $attr);
340 340
 	}
341 341
 
342 342
 	/**
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * @return string|int|float|null The human identifier for the entity, or null.
361 361
 	 */
362 362
 	public function get_the_human_id() {
363
-		return $this->get_entity_human_id( $this->the_entity );
363
+		return $this->get_entity_human_id($this->the_entity);
364 364
 	}
365 365
 
366 366
 	/**
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
 
395 395
 		$guid = $this->get_the_context();
396 396
 
397
-		if ( ! is_array( $guid ) ) {
397
+		if ( ! is_array($guid)) {
398 398
 			return $guid;
399 399
 		}
400 400
 
401
-		$guid = array( $this->slug => $this->get_the_id() ) + $guid;
401
+		$guid = array($this->slug => $this->get_the_id()) + $guid;
402 402
 
403 403
 		return $guid;
404 404
 	}
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,13 +39,13 @@  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 47
 				// TODO this should be supplied per-reactor
48
-				'label' => __( 'Award each user no more than once per:', 'wordpoints' ),
48
+				'label' => __('Award each user no more than once per:', 'wordpoints'),
49 49
 			),
50 50
 		);
51 51
 	}
@@ -59,25 +59,25 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return array The validated periods.
61 61
 	 */
62
-	protected function validate_periods( $periods ) {
62
+	protected function validate_periods($periods) {
63 63
 
64
-		if ( ! is_array( $periods ) ) {
64
+		if ( ! is_array($periods)) {
65 65
 
66 66
 			$this->validator->add_error(
67
-				__( 'Periods do not match expected format.', 'wordpoints' )
67
+				__('Periods do not match expected format.', 'wordpoints')
68 68
 			);
69 69
 
70 70
 			return array();
71 71
 		}
72 72
 
73
-		foreach ( $periods as $index => $period ) {
73
+		foreach ($periods as $index => $period) {
74 74
 
75
-			$this->validator->push_field( $index );
75
+			$this->validator->push_field($index);
76 76
 
77
-			$period = $this->validate_period( $period );
77
+			$period = $this->validate_period($period);
78 78
 
79
-			if ( $period ) {
80
-				$periods[ $index ] = $period;
79
+			if ($period) {
80
+				$periods[$index] = $period;
81 81
 			}
82 82
 
83 83
 			$this->validator->pop_field();
@@ -95,30 +95,30 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @return array|false The validated period, or false if invalid.
97 97
 	 */
98
-	protected function validate_period( $period ) {
98
+	protected function validate_period($period) {
99 99
 
100
-		if ( ! is_array( $period ) ) {
100
+		if ( ! is_array($period)) {
101 101
 			$this->validator->add_error(
102
-				__( 'Period does not match expected format.', 'wordpoints' )
102
+				__('Period does not match expected format.', 'wordpoints')
103 103
 			);
104 104
 
105 105
 			return false;
106 106
 		}
107 107
 
108
-		if ( isset( $period['args'] ) ) {
109
-			$this->validate_period_args( $period['args'] );
108
+		if (isset($period['args'])) {
109
+			$this->validate_period_args($period['args']);
110 110
 		}
111 111
 
112
-		if ( ! isset( $period['length'] ) ) {
112
+		if ( ! isset($period['length'])) {
113 113
 
114 114
 			$this->validator->add_error(
115
-				__( 'Period length setting is missing.', 'wordpoints' )
115
+				__('Period length setting is missing.', 'wordpoints')
116 116
 			);
117 117
 
118
-		} elseif ( false === wordpoints_posint( $period['length'] ) ) {
118
+		} elseif (false === wordpoints_posint($period['length'])) {
119 119
 
120 120
 			$this->validator->add_error(
121
-				__( 'Period length must be a positive integer.', 'wordpoints' )
121
+				__('Period length must be a positive integer.', 'wordpoints')
122 122
 				, 'length'
123 123
 			);
124 124
 
@@ -135,34 +135,34 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param mixed $args The args the period is related to.
137 137
 	 */
138
-	protected function validate_period_args( $args ) {
138
+	protected function validate_period_args($args) {
139 139
 
140
-		if ( ! is_array( $args ) ) {
140
+		if ( ! is_array($args)) {
141 141
 
142 142
 			$this->validator->add_error(
143
-				__( 'Period does not match expected format.', 'wordpoints' )
143
+				__('Period does not match expected format.', 'wordpoints')
144 144
 				, 'args'
145 145
 			);
146 146
 
147 147
 			return;
148 148
 		}
149 149
 
150
-		$this->validator->push_field( 'args' );
150
+		$this->validator->push_field('args');
151 151
 
152
-		foreach ( $args as $index => $hierarchy ) {
152
+		foreach ($args as $index => $hierarchy) {
153 153
 
154
-			$this->validator->push_field( $index );
154
+			$this->validator->push_field($index);
155 155
 
156
-			if ( ! is_array( $hierarchy ) ) {
156
+			if ( ! is_array($hierarchy)) {
157 157
 
158 158
 				$this->validator->add_error(
159
-					__( 'Period does not match expected format.', 'wordpoints' )
159
+					__('Period does not match expected format.', 'wordpoints')
160 160
 				);
161 161
 
162
-			} elseif ( ! $this->event_args->get_from_hierarchy( $hierarchy ) ) {
162
+			} elseif ( ! $this->event_args->get_from_hierarchy($hierarchy)) {
163 163
 
164 164
 				$this->validator->add_error(
165
-					__( 'Invalid period.', 'wordpoints' ) // TODO better error message
165
+					__('Invalid period.', 'wordpoints') // TODO better error message
166 166
 				);
167 167
 			}
168 168
 
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
 	/**
176 176
 	 * @since 1.0.0
177 177
 	 */
178
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
178
+	public function should_hit(WordPoints_Hook_Fire $fire) {
179 179
 
180
-		$periods = $fire->reaction->get_meta( 'periods' );
180
+		$periods = $fire->reaction->get_meta('periods');
181 181
 
182
-		if ( empty( $periods ) ) {
182
+		if (empty($periods)) {
183 183
 			return true;
184 184
 		}
185 185
 
186 186
 		$this->event_args = $fire->event_args;
187 187
 
188
-		foreach ( $periods as $period ) {
189
-			if ( ! $this->has_period_ended( $period, $fire->reaction ) ) {
188
+		foreach ($periods as $period) {
189
+			if ( ! $this->has_period_ended($period, $fire->reaction)) {
190 190
 				return false;
191 191
 			}
192 192
 		}
@@ -210,24 +210,24 @@  discard block
 block discarded – undo
210 210
 	) {
211 211
 
212 212
 		$period = $this->get_period_by_reaction(
213
-			$this->get_period_signature( $settings, $reaction )
213
+			$this->get_period_signature($settings, $reaction)
214 214
 			, $reaction
215 215
 		);
216 216
 
217 217
 		// If the period isn't found, we know that we can still fire.
218
-		if ( ! $period ) {
218
+		if ( ! $period) {
219 219
 			return true;
220 220
 		}
221 221
 
222
-		$now = current_time( 'timestamp' );
223
-		$hit_time = strtotime( $period->date, $now );
222
+		$now = current_time('timestamp');
223
+		$hit_time = strtotime($period->date, $now);
224 224
 
225
-		if ( ! empty( $settings['relative'] ) ) {
226
-			return ( $hit_time < $now - $settings['length'] );
225
+		if ( ! empty($settings['relative'])) {
226
+			return ($hit_time < $now - $settings['length']);
227 227
 		} else {
228 228
 			return (
229
-				(int) ( $hit_time / $settings['length'] )
230
-				< (int) ( $now / $settings['length'] )
229
+				(int) ($hit_time / $settings['length'])
230
+				< (int) ($now / $settings['length'])
231 231
 			);
232 232
 		}
233 233
 	}
@@ -241,24 +241,24 @@  discard block
 block discarded – undo
241 241
 	 *
242 242
 	 * @return array The arg values.
243 243
 	 */
244
-	protected function get_arg_values( array $period_args ) {
244
+	protected function get_arg_values(array $period_args) {
245 245
 
246 246
 		$values = array();
247 247
 
248
-		foreach ( $period_args as $arg_hierarchy ) {
248
+		foreach ($period_args as $arg_hierarchy) {
249 249
 
250 250
 			$arg = $this->event_args->get_from_hierarchy(
251 251
 				$arg_hierarchy
252 252
 			);
253 253
 
254
-			if ( ! $arg instanceof WordPoints_EntityishI ) {
254
+			if ( ! $arg instanceof WordPoints_EntityishI) {
255 255
 				continue;
256 256
 			}
257 257
 
258
-			$values[ implode( '.', $arg_hierarchy ) ] = $arg->get_the_value();
258
+			$values[implode('.', $arg_hierarchy)] = $arg->get_the_value();
259 259
 		}
260 260
 
261
-		ksort( $values );
261
+		ksort($values);
262 262
 
263 263
 		return $values;
264 264
 	}
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @return object|false The period data, or false if not found.
274 274
 	 */
275
-	protected function get_period( $period_id ) {
275
+	protected function get_period($period_id) {
276 276
 
277
-		$period = wp_cache_get( $period_id, 'wordpoints_hook_period' );
277
+		$period = wp_cache_get($period_id, 'wordpoints_hook_period');
278 278
 
279
-		if ( ! $period ) {
279
+		if ( ! $period) {
280 280
 
281 281
 			global $wpdb;
282 282
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 				)
294 294
 			);
295 295
 
296
-			if ( ! $period ) {
296
+			if ( ! $period) {
297 297
 				return false;
298 298
 			}
299 299
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 				, 'wordpoints_hook_period_ids'
304 304
 			);
305 305
 
306
-			wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
306
+			wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
307 307
 		}
308 308
 
309 309
 		return $period;
@@ -327,14 +327,14 @@  discard block
 block discarded – undo
327 327
 
328 328
 		$reaction_guid = $reaction->get_guid();
329 329
 
330
-		$cache_key = wp_json_encode( $reaction_guid ) . "-{$signature}";
330
+		$cache_key = wp_json_encode($reaction_guid)."-{$signature}";
331 331
 
332 332
 		// Before we run the query, we try to lookup the ID in the cache.
333
-		$period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids' );
333
+		$period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids');
334 334
 
335 335
 		// If we found it, we can retrieve the period by ID instead.
336
-		if ( $period_id ) {
337
-			return $this->get_period( $period_id );
336
+		if ($period_id) {
337
+			return $this->get_period($period_id);
338 338
 		}
339 339
 
340 340
 		global $wpdb;
@@ -358,17 +358,17 @@  discard block
 block discarded – undo
358 358
 				, $signature
359 359
 				, $reaction_guid['reactor']
360 360
 				, $reaction_guid['group']
361
-				, wp_json_encode( $reaction_guid['context_id'] )
361
+				, wp_json_encode($reaction_guid['context_id'])
362 362
 				, $reaction_guid['id']
363 363
 			)
364 364
 		);
365 365
 
366
-		if ( ! $period ) {
366
+		if ( ! $period) {
367 367
 			return false;
368 368
 		}
369 369
 
370
-		wp_cache_set( $cache_key, $period->id, 'wordpoints_hook_period_ids' );
371
-		wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
370
+		wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids');
371
+		wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
372 372
 
373 373
 		return $period;
374 374
 	}
@@ -376,20 +376,20 @@  discard block
 block discarded – undo
376 376
 	/**
377 377
 	 * @since 1.0.0
378 378
 	 */
379
-	public function after_hit( WordPoints_Hook_Fire $fire ) {
379
+	public function after_hit(WordPoints_Hook_Fire $fire) {
380 380
 
381
-		$periods = $fire->reaction->get_meta( 'periods' );
381
+		$periods = $fire->reaction->get_meta('periods');
382 382
 
383
-		if ( empty( $periods ) ) {
383
+		if (empty($periods)) {
384 384
 			return;
385 385
 		}
386 386
 
387 387
 		$this->event_args = $fire->event_args;
388 388
 
389
-		foreach ( $periods as $settings ) {
389
+		foreach ($periods as $settings) {
390 390
 
391 391
 			$this->add_period(
392
-				$this->get_period_signature( $settings, $fire->reaction )
392
+				$this->get_period_signature($settings, $fire->reaction)
393 393
 				, $fire
394 394
 			);
395 395
 		}
@@ -414,14 +414,14 @@  discard block
 block discarded – undo
414 414
 		WordPoints_Hook_ReactionI $reaction
415 415
 	) {
416 416
 
417
-		if ( isset( $settings['args'] ) ) {
417
+		if (isset($settings['args'])) {
418 418
 			$period_args = $settings['args'];
419 419
 		} else {
420
-			$period_args = array( $reaction->get_meta( 'target' ) );
420
+			$period_args = array($reaction->get_meta('target'));
421 421
 		}
422 422
 
423 423
 		return wordpoints_hash(
424
-			wp_json_encode( $this->get_arg_values( $period_args ) )
424
+			wp_json_encode($this->get_arg_values($period_args))
425 425
 		);
426 426
 	}
427 427
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	 *
436 436
 	 * @return false|object The period data, or false if not found.
437 437
 	 */
438
-	protected function add_period( $signature, WordPoints_Hook_Fire $fire ) {
438
+	protected function add_period($signature, WordPoints_Hook_Fire $fire) {
439 439
 
440 440
 		global $wpdb;
441 441
 
@@ -445,17 +445,17 @@  discard block
 block discarded – undo
445 445
 				'hit_id' => $fire->hit_id,
446 446
 				'signature' => $signature,
447 447
 			)
448
-			, array( '%d', '%s' )
448
+			, array('%d', '%s')
449 449
 		);
450 450
 
451
-		if ( ! $inserted ) {
451
+		if ( ! $inserted) {
452 452
 			return false;
453 453
 		}
454 454
 
455 455
 		$period_id = $wpdb->insert_id;
456 456
 
457 457
 		wp_cache_set(
458
-			wp_json_encode( $fire->reaction->get_guid() ) . "-{$signature}"
458
+			wp_json_encode($fire->reaction->get_guid())."-{$signature}"
459 459
 			, $period_id
460 460
 			, 'wordpoints_hook_period_ids'
461 461
 		);
Please login to merge, or discard this patch.
src/includes/classes/hook/fire.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		$this->firer      = $firer;
85 85
 		$this->event_args = $event_args;
86 86
 		$this->reaction   = $reaction;
87
-		$this->hit_logger = new WordPoints_Hook_Hit_Logger( $this );
87
+		$this->hit_logger = new WordPoints_Hook_Hit_Logger($this);
88 88
 		$this->supersedes = $supersedes;
89 89
 	}
90 90
 
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function hit() {
99 99
 
100
-		if ( ! $this->hit_id ) {
100
+		if ( ! $this->hit_id) {
101 101
 
102 102
 			$this->hit_id = $this->hit_logger->log_hit();
103 103
 
104
-			if ( ! $this->hit_id ) {
104
+			if ( ! $this->hit_id) {
105 105
 				return false;
106 106
 			}
107 107
 		}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function get_superseded_hit() {
122 122
 
123
-		if ( isset( $this->supersedes ) ) {
123
+		if (isset($this->supersedes)) {
124 124
 			return $this->supersedes;
125 125
 		}
126 126
 
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
 					AND `superseded_by` IS NULL
142 142
 				"
143 143
 				, $this->firer->get_slug()
144
-				, wordpoints_hooks_get_event_primary_arg_guid_json( $this->event_args )
144
+				, wordpoints_hooks_get_event_primary_arg_guid_json($this->event_args)
145 145
 				, $this->reaction->get_event_slug()
146 146
 				, $this->reaction->get_reactor_slug()
147 147
 				, $this->reaction->get_storage_group_slug()
148
-				, wp_json_encode( $this->reaction->get_context_id() )
148
+				, wp_json_encode($this->reaction->get_context_id())
149 149
 				, $this->reaction->ID
150 150
 			)
151 151
 		);
152 152
 
153
-		$this->supersedes = ( $hit ) ? $hit : false;
153
+		$this->supersedes = ($hit) ? $hit : false;
154 154
 
155 155
 		return $this->supersedes;
156 156
 	}
Please login to merge, or discard this patch.
src/includes/classes/hook/firer/reverse.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,42 +17,42 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @since 1.0.0
19 19
 	 */
20
-	public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args ) {
20
+	public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args) {
21 21
 
22 22
 		$hooks = wordpoints_hooks();
23 23
 
24
-		foreach ( $this->get_hits( $event_slug, $event_args ) as $hit ) {
24
+		foreach ($this->get_hits($event_slug, $event_args) as $hit) {
25 25
 
26
-			$reactor = $hooks->reactors->get( $hit->reactor );
26
+			$reactor = $hooks->reactors->get($hit->reactor);
27 27
 
28
-			if ( ! $reactor instanceof WordPoints_Hook_Reactor ) {
28
+			if ( ! $reactor instanceof WordPoints_Hook_Reactor) {
29 29
 				continue;
30 30
 			}
31 31
 
32
-			$reactions = $reactor->get_reaction_group( $hit->reaction_type );
32
+			$reactions = $reactor->get_reaction_group($hit->reaction_type);
33 33
 
34 34
 			if (
35 35
 				! $reactions
36
-				|| wp_json_encode( $reactions->get_context_id() ) !== $hit->reaction_context_id
36
+				|| wp_json_encode($reactions->get_context_id()) !== $hit->reaction_context_id
37 37
 			) {
38 38
 				continue;
39 39
 			}
40 40
 
41
-			$reaction = $reactions->get_reaction( $hit->reaction_id );
41
+			$reaction = $reactions->get_reaction($hit->reaction_id);
42 42
 
43
-			if ( ! $reaction ) {
43
+			if ( ! $reaction) {
44 44
 				continue;
45 45
 			}
46 46
 
47
-			$fire = new WordPoints_Hook_Fire( $this, $event_args, $reaction, $hit );
47
+			$fire = new WordPoints_Hook_Fire($this, $event_args, $reaction, $hit);
48 48
 
49 49
 			$fire->hit();
50 50
 
51
-			$reactor->reverse_hit( $fire );
51
+			$reactor->reverse_hit($fire);
52 52
 
53 53
 			/** @var WordPoints_Hook_Extension $extension */
54
-			foreach ( $hooks->extensions->get_all() as $extension ) {
55
-				$extension->after_reverse( $fire );
54
+			foreach ($hooks->extensions->get_all() as $extension) {
55
+				$extension->after_reverse($fire);
56 56
 			}
57 57
 		}
58 58
 	}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return object[] The data for each hit from the hit logs database table.
69 69
 	 */
70
-	protected function get_hits( $event_slug, WordPoints_Hook_Event_Args $event_args ) {
70
+	protected function get_hits($event_slug, WordPoints_Hook_Event_Args $event_args) {
71 71
 
72 72
 		global $wpdb;
73 73
 
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 					AND `event` = %s
82 82
 					AND `superseded_by` IS NULL
83 83
 				"
84
-				, wordpoints_hooks_get_event_primary_arg_guid_json( $event_args )
84
+				, wordpoints_hooks_get_event_primary_arg_guid_json($event_args)
85 85
 				, $event_slug
86 86
 			)
87 87
 		);
88 88
 
89
-		if ( ! is_array( $hits ) ) {
89
+		if ( ! is_array($hits)) {
90 90
 			return array();
91 91
 		}
92 92
 
Please login to merge, or discard this patch.
src/includes/classes/hook/hit/logger.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	/**
27 27
 	 * @param WordPoints_Hook_Fire $fire The fire that might be logged as a hit.
28 28
 	 */
29
-	public function __construct( WordPoints_Hook_Fire $fire ) {
29
+	public function __construct(WordPoints_Hook_Fire $fire) {
30 30
 
31 31
 		$this->fire = $fire;
32 32
 	}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 		global $wpdb;
44 44
 
45
-		$signature = wordpoints_hooks_get_event_primary_arg_guid_json( $this->fire->event_args );
45
+		$signature = wordpoints_hooks_get_event_primary_arg_guid_json($this->fire->event_args);
46 46
 
47 47
 		$inserted = $wpdb->insert(
48 48
 			$wpdb->wordpoints_hook_hits
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
 				'event' => $this->fire->reaction->get_event_slug(),
53 53
 				'reactor' => $this->fire->reaction->get_reactor_slug(),
54 54
 				'reaction_type' => $this->fire->reaction->get_storage_group_slug(),
55
-				'reaction_context_id' => wp_json_encode( $this->fire->reaction->get_context_id() ),
55
+				'reaction_context_id' => wp_json_encode($this->fire->reaction->get_context_id()),
56 56
 				'reaction_id' => $this->fire->reaction->ID,
57
-				'date' => current_time( 'mysql' ),
57
+				'date' => current_time('mysql'),
58 58
 			)
59 59
 		);
60 60
 
61
-		if ( ! $inserted ) {
61
+		if ( ! $inserted) {
62 62
 			return false;
63 63
 		}
64 64
 
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 
67 67
 		$supersedes = $this->fire->get_superseded_hit();
68 68
 
69
-		if ( $supersedes ) {
69
+		if ($supersedes) {
70 70
 			$wpdb->update(
71 71
 				$wpdb->wordpoints_hook_hits
72
-				, array( 'superseded_by' => $hit_id )
73
-				, array( 'id' => $supersedes->id )
74
-				, array( '%d' )
75
-				, array( '%d' )
72
+				, array('superseded_by' => $hit_id)
73
+				, array('id' => $supersedes->id)
74
+				, array('%d')
75
+				, array('%d')
76 76
 			);
77 77
 		}
78 78
 
Please login to merge, or discard this patch.
src/includes/functions.php 1 patch
Spacing   +121 added lines, -121 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,18 +854,18 @@  discard block
 block discarded – undo
854 854
  */
855 855
 function wordpoints_is_network_context() {
856 856
 
857
-	if ( is_network_admin() ) {
857
+	if (is_network_admin()) {
858 858
 		return true;
859 859
 	}
860 860
 
861 861
 	// See https://core.trac.wordpress.org/ticket/22589
862 862
 	if (
863
-		defined( 'DOING_AJAX' )
863
+		defined('DOING_AJAX')
864 864
 		&& DOING_AJAX
865
-		&& isset( $_SERVER['HTTP_REFERER'] )
865
+		&& isset($_SERVER['HTTP_REFERER'])
866 866
 		&& preg_match(
867
-			'#^' . preg_quote( network_admin_url(), '#' ) . '#i'
868
-			, esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) )
867
+			'#^'.preg_quote(network_admin_url(), '#').'#i'
868
+			, esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER']))
869 869
 		)
870 870
 	) {
871 871
 		return true;
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 	 *
879 879
 	 * @param bool $in_network_context Whether we are in network context.
880 880
 	 */
881
-	return apply_filters( 'wordpoints_is_network_context', false );
881
+	return apply_filters('wordpoints_is_network_context', false);
882 882
 }
883 883
 
884 884
 /**
@@ -892,21 +892,21 @@  discard block
 block discarded – undo
892 892
  *
893 893
  * @return string The primary arg's GUID, JSON encoded.
894 894
  */
895
-function wordpoints_hooks_get_event_primary_arg_guid_json( WordPoints_Hook_Event_Args $event_args ) {
895
+function wordpoints_hooks_get_event_primary_arg_guid_json(WordPoints_Hook_Event_Args $event_args) {
896 896
 
897 897
 	$entity = $event_args->get_primary_arg();
898 898
 
899
-	if ( ! $entity ) {
899
+	if ( ! $entity) {
900 900
 		return '';
901 901
 	}
902 902
 
903 903
 	$the_guid = $entity->get_the_guid();
904 904
 
905
-	if ( ! $the_guid ) {
905
+	if ( ! $the_guid) {
906 906
 		return '';
907 907
 	}
908 908
 
909
-	return wp_json_encode( $the_guid );
909
+	return wp_json_encode($the_guid);
910 910
 }
911 911
 
912 912
 // EOF
Please login to merge, or discard this patch.