Completed
Push — master ( e7ef90...760553 )
by J.D.
03:28
created
src/components/ranks/includes/class-wordpoints-rank-types.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return bool Whether this rank type is registered.
37 37
 	 */
38
-	public static function is_type_registered( $type ) {
38
+	public static function is_type_registered($type) {
39 39
 
40
-		return isset( self::$types[ $type ] );
40
+		return isset(self::$types[$type]);
41 41
 	}
42 42
 
43 43
 	/**
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return bool Whether the rank type was registered.
56 56
 	 */
57
-	public static function register_type( $type, $class, array $args = array() ) {
57
+	public static function register_type($type, $class, array $args = array()) {
58 58
 
59
-		if ( self::is_type_registered( $type ) ) {
59
+		if (self::is_type_registered($type)) {
60 60
 			return false;
61 61
 		}
62 62
 
63 63
 		$args['slug'] = $type;
64 64
 
65
-		self::$types[ $type ] = new $class( $args );
65
+		self::$types[$type] = new $class($args);
66 66
 
67 67
 		return true;
68 68
 	}
@@ -78,23 +78,23 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return bool Whether the rank type was deregistered.
80 80
 	 */
81
-	public static function deregister_type( $type ) {
81
+	public static function deregister_type($type) {
82 82
 
83
-		if ( 'base' === $type ) {
83
+		if ('base' === $type) {
84 84
 			return false;
85 85
 		}
86 86
 
87
-		if ( ! self::is_type_registered( $type ) ) {
87
+		if ( ! self::is_type_registered($type)) {
88 88
 			return false;
89 89
 		}
90 90
 
91
-		self::$types[ $type ]->destruct();
91
+		self::$types[$type]->destruct();
92 92
 
93
-		foreach ( WordPoints_Rank_Groups::get() as $group ) {
94
-			$group->remove_type( $type );
93
+		foreach (WordPoints_Rank_Groups::get() as $group) {
94
+			$group->remove_type($type);
95 95
 		}
96 96
 
97
-		unset( self::$types[ $type ] );
97
+		unset(self::$types[$type]);
98 98
 
99 99
 		return true;
100 100
 	}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public static function get() {
110 110
 
111
-		if ( ! did_action( 'wordpoints_ranks_register' ) ) {
111
+		if ( ! did_action('wordpoints_ranks_register')) {
112 112
 			_doing_it_wrong(
113 113
 				__METHOD__
114 114
 				, 'Ranks should not be retreived until after they are all registered.'
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return WordPoints_Rank_Type|false The hander object, or false.
130 130
 	 */
131
-	public static function get_type( $type ) {
131
+	public static function get_type($type) {
132 132
 
133
-		if ( ! self::is_type_registered( $type ) ) {
133
+		if ( ! self::is_type_registered($type)) {
134 134
 			return false;
135 135
 		}
136 136
 
137
-		return self::$types[ $type ];
137
+		return self::$types[$type];
138 138
 	}
139 139
 
140 140
 	/**
@@ -146,21 +146,21 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public static function init() {
148 148
 
149
-		self::register_type( 'base', 'WordPoints_Base_Rank_Type' );
149
+		self::register_type('base', 'WordPoints_Base_Rank_Type');
150 150
 
151 151
 		/**
152 152
 		 * Ranks should not register later than this action.
153 153
 		 *
154 154
 		 * @since 1.7.0
155 155
 		 */
156
-		do_action( 'wordpoints_ranks_register' );
156
+		do_action('wordpoints_ranks_register');
157 157
 
158 158
 		/**
159 159
 		 * All ranks are registered.
160 160
 		 *
161 161
 		 * @since 1.7.0
162 162
 		 */
163
-		do_action( 'wordpoints_ranks_registered' );
163
+		do_action('wordpoints_ranks_registered');
164 164
 	}
165 165
 }
166 166
 
Please login to merge, or discard this patch.
src/components/ranks/includes/ranks.php 1 patch
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return int|false|WP_Error The ID of the inserted rank, or false or WP_Error on failure.
28 28
  */
29
-function wordpoints_add_rank( $name, $type, $group, $position, array $meta = array() ) {
29
+function wordpoints_add_rank($name, $type, $group, $position, array $meta = array()) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( ! WordPoints_Rank_Groups::is_type_registered_for_group( $type, $group ) ) {
33
+	if ( ! WordPoints_Rank_Groups::is_type_registered_for_group($type, $group)) {
34 34
 		return false;
35 35
 	}
36 36
 
37
-	$rank_type = WordPoints_Rank_Types::get_type( $type );
37
+	$rank_type = WordPoints_Rank_Types::get_type($type);
38 38
 
39
-	if ( ! $rank_type ) {
39
+	if ( ! $rank_type) {
40 40
 		return false;
41 41
 	}
42 42
 
43
-	$meta = $rank_type->validate_rank_meta( $meta );
44
-	if ( false === $meta || is_wp_error( $meta ) ) {
43
+	$meta = $rank_type->validate_rank_meta($meta);
44
+	if (false === $meta || is_wp_error($meta)) {
45 45
 		return $meta;
46 46
 	}
47 47
 
48
-	if ( 'utf8' === $wpdb->get_col_charset( $wpdb->wordpoints_ranks, 'name' ) ) {
49
-		$name = wp_encode_emoji( $name );
48
+	if ('utf8' === $wpdb->get_col_charset($wpdb->wordpoints_ranks, 'name')) {
49
+		$name = wp_encode_emoji($name);
50 50
 	}
51 51
 
52 52
 	$inserted = $wpdb->insert(
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
 		)
61 61
 	);
62 62
 
63
-	if ( ! $inserted ) {
63
+	if ( ! $inserted) {
64 64
 		return false;
65 65
 	}
66 66
 
67 67
 	$rank_id = (int) $wpdb->insert_id;
68 68
 
69
-	foreach ( $meta as $meta_key => $meta_value ) {
70
-		wordpoints_add_rank_meta( $rank_id, $meta_key, $meta_value );
69
+	foreach ($meta as $meta_key => $meta_value) {
70
+		wordpoints_add_rank_meta($rank_id, $meta_key, $meta_value);
71 71
 	}
72 72
 
73
-	WordPoints_Rank_Groups::get_group( $group )->add_rank( $rank_id, $position );
73
+	WordPoints_Rank_Groups::get_group($group)->add_rank($rank_id, $position);
74 74
 
75 75
 	/**
76 76
 	 * Perform actions when a rank is added.
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param int $rank_id The ID of the rank that was added.
81 81
 	 */
82
-	do_action( 'wordpoints_add_rank', $rank_id );
82
+	do_action('wordpoints_add_rank', $rank_id);
83 83
 
84 84
 	return $rank_id;
85 85
 }
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
  *
94 94
  * @return bool True if the rank was deleted, false otherwise.
95 95
  */
96
-function wordpoints_delete_rank( $id ) {
96
+function wordpoints_delete_rank($id) {
97 97
 
98 98
 	global $wpdb;
99 99
 
100
-	$rank = wordpoints_get_rank( $id );
100
+	$rank = wordpoints_get_rank($id);
101 101
 
102
-	if ( ! $rank ) {
102
+	if ( ! $rank) {
103 103
 		return false;
104 104
 	}
105 105
 
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @param WordPoints_Rank $rank The rank that is being deleted.
112 112
 	 */
113
-	do_action( 'wordpoints_pre_delete_rank', $rank );
113
+	do_action('wordpoints_pre_delete_rank', $rank);
114 114
 
115 115
 	$deleted = $wpdb->delete(
116 116
 		$wpdb->wordpoints_ranks
117
-		, array( 'id' => $id )
118
-		, array( '%d' )
117
+		, array('id' => $id)
118
+		, array('%d')
119 119
 	);
120 120
 
121
-	if ( ! $deleted ) {
121
+	if ( ! $deleted) {
122 122
 		return false;
123 123
 	}
124 124
 
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
 		)
134 134
 	); // WPCS: cache pass.
135 135
 
136
-	WordPoints_Rank_Groups::get_group( $rank->rank_group )->remove_rank( $id );
136
+	WordPoints_Rank_Groups::get_group($rank->rank_group)->remove_rank($id);
137 137
 
138
-	wp_cache_delete( $id, 'wordpoints_ranks' );
138
+	wp_cache_delete($id, 'wordpoints_ranks');
139 139
 
140
-	foreach ( $rank_meta_ids as $mid ) {
141
-		delete_metadata_by_mid( 'wordpoints_rank', $mid );
140
+	foreach ($rank_meta_ids as $mid) {
141
+		delete_metadata_by_mid('wordpoints_rank', $mid);
142 142
 	}
143 143
 
144 144
 	/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @param int $rank_id The ID of the rank that was deleted.
150 150
 	 */
151
-	do_action( 'wordpoints_delete_rank', $id );
151
+	do_action('wordpoints_delete_rank', $id);
152 152
 
153 153
 	return true;
154 154
 }
@@ -170,28 +170,28 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return bool|WP_Error True the rank was updated successfully, or false/WP_Error on failure.
172 172
  */
173
-function wordpoints_update_rank( $id, $name, $type, $group, $position, array $meta = array() ) {
173
+function wordpoints_update_rank($id, $name, $type, $group, $position, array $meta = array()) {
174 174
 
175 175
 	global $wpdb;
176 176
 
177
-	$rank = wordpoints_get_rank( $id );
177
+	$rank = wordpoints_get_rank($id);
178 178
 
179
-	if ( ! $rank ) {
179
+	if ( ! $rank) {
180 180
 		return false;
181 181
 	}
182 182
 
183
-	if ( ! WordPoints_Rank_Groups::is_type_registered_for_group( $type, $group ) ) {
183
+	if ( ! WordPoints_Rank_Groups::is_type_registered_for_group($type, $group)) {
184 184
 		return false;
185 185
 	}
186 186
 
187
-	$rank_type = WordPoints_Rank_Types::get_type( $type );
187
+	$rank_type = WordPoints_Rank_Types::get_type($type);
188 188
 
189
-	if ( ! $rank_type ) {
189
+	if ( ! $rank_type) {
190 190
 		return false;
191 191
 	}
192 192
 
193
-	$meta = $rank_type->validate_rank_meta( $meta );
194
-	if ( false === $meta || is_wp_error( $meta ) ) {
193
+	$meta = $rank_type->validate_rank_meta($meta);
194
+	if (false === $meta || is_wp_error($meta)) {
195 195
 		return $meta;
196 196
 	}
197 197
 
@@ -207,50 +207,50 @@  discard block
 block discarded – undo
207 207
 	 * @param int             $position The new position this rank should have in the group.
208 208
 	 * @param array           $meta     The new metadata for the rank.
209 209
 	 */
210
-	do_action( 'wordpoints_pre_update_rank', $rank, $name, $type, $group, $position, $meta );
210
+	do_action('wordpoints_pre_update_rank', $rank, $name, $type, $group, $position, $meta);
211 211
 
212
-	if ( 'utf8' === $wpdb->get_col_charset( $wpdb->wordpoints_ranks, 'name' ) ) {
213
-		$name = wp_encode_emoji( $name );
212
+	if ('utf8' === $wpdb->get_col_charset($wpdb->wordpoints_ranks, 'name')) {
213
+		$name = wp_encode_emoji($name);
214 214
 	}
215 215
 
216 216
 	$updated = $wpdb->update(
217 217
 		$wpdb->wordpoints_ranks
218
-		, array( 'name' => $name, 'type' => $type, 'rank_group' => $group )
219
-		, array( 'id' => $id )
218
+		, array('name' => $name, 'type' => $type, 'rank_group' => $group)
219
+		, array('id' => $id)
220 220
 		, '%s'
221 221
 		, '%d'
222 222
 	);
223 223
 
224
-	if ( false === $updated ) {
224
+	if (false === $updated) {
225 225
 		return false;
226 226
 	}
227 227
 
228
-	wp_cache_delete( $id, 'wordpoints_ranks' );
228
+	wp_cache_delete($id, 'wordpoints_ranks');
229 229
 
230
-	foreach ( $meta as $meta_key => $meta_value ) {
231
-		wordpoints_update_rank_meta( $id, $meta_key, $meta_value );
230
+	foreach ($meta as $meta_key => $meta_value) {
231
+		wordpoints_update_rank_meta($id, $meta_key, $meta_value);
232 232
 	}
233 233
 
234
-	$rank_group = WordPoints_Rank_Groups::get_group( $group );
234
+	$rank_group = WordPoints_Rank_Groups::get_group($group);
235 235
 
236
-	if ( $rank->rank_group !== $group ) {
236
+	if ($rank->rank_group !== $group) {
237 237
 
238
-		$previous_group = WordPoints_Rank_Groups::get_group( $rank->rank_group );
239
-		if ( $previous_group ) {
240
-			$previous_group->remove_rank( $rank->ID );
238
+		$previous_group = WordPoints_Rank_Groups::get_group($rank->rank_group);
239
+		if ($previous_group) {
240
+			$previous_group->remove_rank($rank->ID);
241 241
 		}
242 242
 
243
-		$rank_group->add_rank( $rank->ID, $position );
243
+		$rank_group->add_rank($rank->ID, $position);
244 244
 
245 245
 	} else {
246 246
 
247
-		if ( $position !== $rank_group->get_rank_position( $rank->ID ) ) {
248
-			$rank_group->move_rank( $rank->ID, $position );
247
+		if ($position !== $rank_group->get_rank_position($rank->ID)) {
248
+			$rank_group->move_rank($rank->ID, $position);
249 249
 		} else {
250 250
 			// If the position doesn't change, we still need refresh the ranks of
251 251
 			// users who have this rank, if the metadata or type has changed.
252
-			if ( $meta || $type !== $rank->type ) {
253
-				wordpoints_refresh_rank_users( $rank->ID );
252
+			if ($meta || $type !== $rank->type) {
253
+				wordpoints_refresh_rank_users($rank->ID);
254 254
 			}
255 255
 		}
256 256
 	}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 *
263 263
 	 * @param int $rank_id The ID of the rank that was updated.
264 264
 	 */
265
-	do_action( 'wordpoints_update_rank', $id );
265
+	do_action('wordpoints_update_rank', $id);
266 266
 
267 267
 	return true;
268 268
 }
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
  *
277 277
  * @return WordPoints_Rank|false The rank object, or false if it doesn't exist.
278 278
  */
279
-function wordpoints_get_rank( $id ) {
279
+function wordpoints_get_rank($id) {
280 280
 
281
-	$rank = new WordPoints_Rank( $id );
281
+	$rank = new WordPoints_Rank($id);
282 282
 
283
-	if ( ! $rank->exists() ) {
283
+	if ( ! $rank->exists()) {
284 284
 		return false;
285 285
 	}
286 286
 
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
  *
303 303
  * @return string The integer value of $points formatted for display.
304 304
  */
305
-function wordpoints_format_rank( $rank_id, $context, array $args = array() ) {
305
+function wordpoints_format_rank($rank_id, $context, array $args = array()) {
306 306
 
307
-	$rank = wordpoints_get_rank( $rank_id );
307
+	$rank = wordpoints_get_rank($rank_id);
308 308
 
309
-	if ( ! $rank ) {
309
+	if ( ! $rank) {
310 310
 		return false;
311 311
 	}
312 312
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 *        @type int $user_id The ID of the user the rank is being displayed with.
327 327
 	 * }
328 328
 	 */
329
-	return apply_filters( 'wordpoints_format_rank', $formatted, $rank, $context, $args );
329
+	return apply_filters('wordpoints_format_rank', $formatted, $rank, $context, $args);
330 330
 }
331 331
 
332 332
 //
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
  *
349 349
  * @return int|bool The meta ID on success, false on failure.
350 350
  */
351
-function wordpoints_add_rank_meta( $rank_id, $meta_key, $meta_value, $unique = false ) {
351
+function wordpoints_add_rank_meta($rank_id, $meta_key, $meta_value, $unique = false) {
352 352
 
353 353
 	return add_metadata(
354 354
 		'wordpoints_rank'
355 355
 		, $rank_id
356
-		, wp_slash( $meta_key )
357
-		, wp_slash( $meta_value )
356
+		, wp_slash($meta_key)
357
+		, wp_slash($meta_value)
358 358
 		, $unique
359 359
 	);
360 360
 }
@@ -375,13 +375,13 @@  discard block
 block discarded – undo
375 375
  * @return int|bool Meta ID if the key didn't exist, true on successful update,
376 376
  *                  false on failure.
377 377
  */
378
-function wordpoints_update_rank_meta( $rank_id, $meta_key, $meta_value, $prev_value = '' ) {
378
+function wordpoints_update_rank_meta($rank_id, $meta_key, $meta_value, $prev_value = '') {
379 379
 
380 380
 	return update_metadata(
381 381
 		'wordpoints_rank'
382 382
 		, $rank_id
383
-		, wp_slash( $meta_key )
384
-		, wp_slash( $meta_value )
383
+		, wp_slash($meta_key)
384
+		, wp_slash($meta_value)
385 385
 		, $prev_value
386 386
 	);
387 387
 }
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
  *
402 402
  * @return bool True on successful delete, false on failure.
403 403
  */
404
-function wordpoints_delete_rank_meta( $rank_id, $meta_key, $meta_value = '', $delete_all = false ) {
404
+function wordpoints_delete_rank_meta($rank_id, $meta_key, $meta_value = '', $delete_all = false) {
405 405
 
406 406
 	return delete_metadata(
407 407
 		'wordpoints_rank'
408 408
 		, $rank_id
409
-		, wp_slash( $meta_key )
410
-		, wp_slash( $meta_value )
409
+		, wp_slash($meta_key)
410
+		, wp_slash($meta_value)
411 411
 		, $delete_all
412 412
 	);
413 413
 }
@@ -425,9 +425,9 @@  discard block
 block discarded – undo
425 425
  *
426 426
  * @return string|array Single metadata value or array of metadata values.
427 427
  */
428
-function wordpoints_get_rank_meta( $rank_id, $meta_key = '', $single = false ) {
428
+function wordpoints_get_rank_meta($rank_id, $meta_key = '', $single = false) {
429 429
 
430
-	return get_metadata( 'wordpoints_rank', $rank_id, $meta_key, $single );
430
+	return get_metadata('wordpoints_rank', $rank_id, $meta_key, $single);
431 431
 }
432 432
 
433 433
 //
@@ -444,30 +444,30 @@  discard block
 block discarded – undo
444 444
  *
445 445
  * @return int|false The ID of the rank this user has, or false for invalid args.
446 446
  */
447
-function wordpoints_get_user_rank( $user_id, $group ) {
447
+function wordpoints_get_user_rank($user_id, $group) {
448 448
 
449 449
 	global $wpdb;
450 450
 
451
-	if ( ! wordpoints_posint( $user_id ) ) {
451
+	if ( ! wordpoints_posint($user_id)) {
452 452
 		return false;
453 453
 	}
454 454
 
455
-	$rank_group = WordPoints_Rank_Groups::get_group( $group );
455
+	$rank_group = WordPoints_Rank_Groups::get_group($group);
456 456
 
457
-	if ( ! $rank_group ) {
457
+	if ( ! $rank_group) {
458 458
 		return false;
459 459
 	}
460 460
 
461
-	$group_ranks = wp_cache_get( $group, 'wordpoints_user_ranks' );
461
+	$group_ranks = wp_cache_get($group, 'wordpoints_user_ranks');
462 462
 
463
-	foreach ( (array) $group_ranks as $_rank_id => $user_ids ) {
464
-		if ( isset( $user_ids[ $user_id ] ) ) {
463
+	foreach ((array) $group_ranks as $_rank_id => $user_ids) {
464
+		if (isset($user_ids[$user_id])) {
465 465
 			  $rank_id = $_rank_id;
466 466
 			  break;
467 467
 		}
468 468
 	}
469 469
 
470
-	if ( ! isset( $rank_id ) ) {
470
+	if ( ! isset($rank_id)) {
471 471
 
472 472
 		$rank_id = $wpdb->get_var(
473 473
 			$wpdb->prepare(
@@ -488,13 +488,13 @@  discard block
 block discarded – undo
488 488
 			)
489 489
 		);
490 490
 
491
-		if ( ! $rank_id ) {
491
+		if ( ! $rank_id) {
492 492
 			$rank_id = $rank_group->get_base_rank();
493 493
 		}
494 494
 
495
-		$group_ranks[ $rank_id ][ $user_id ] = $user_id;
495
+		$group_ranks[$rank_id][$user_id] = $user_id;
496 496
 
497
-		wp_cache_set( $group, $group_ranks, 'wordpoints_user_ranks' );
497
+		wp_cache_set($group, $group_ranks, 'wordpoints_user_ranks');
498 498
 	}
499 499
 
500 500
 	return (int) $rank_id;
@@ -512,17 +512,17 @@  discard block
 block discarded – undo
512 512
  *
513 513
  * @return string|false The rank of this user formatted for dispay, or false.
514 514
  */
515
-function wordpoints_get_formatted_user_rank( $user_id, $group, $context, array $args = array() ) {
515
+function wordpoints_get_formatted_user_rank($user_id, $group, $context, array $args = array()) {
516 516
 
517
-	$rank_id = wordpoints_get_user_rank( $user_id, $group );
517
+	$rank_id = wordpoints_get_user_rank($user_id, $group);
518 518
 
519
-	if ( ! $rank_id ) {
519
+	if ( ! $rank_id) {
520 520
 		return false;
521 521
 	}
522 522
 
523
-	$args = array_merge( $args, array( 'user_id' => $user_id ) );
523
+	$args = array_merge($args, array('user_id' => $user_id));
524 524
 
525
-	return wordpoints_format_rank( $rank_id, $context, $args );
525
+	return wordpoints_format_rank($rank_id, $context, $args);
526 526
 }
527 527
 
528 528
 /**
@@ -535,29 +535,29 @@  discard block
 block discarded – undo
535 535
  *
536 536
  * @return bool True if the update was successful. False otherwise.
537 537
  */
538
-function wordpoints_update_user_rank( $user_id, $rank_id ) {
538
+function wordpoints_update_user_rank($user_id, $rank_id) {
539 539
 
540 540
 	global $wpdb;
541 541
 
542
-	if ( ! wordpoints_posint( $rank_id ) || ! wordpoints_posint( $user_id ) ) {
542
+	if ( ! wordpoints_posint($rank_id) || ! wordpoints_posint($user_id)) {
543 543
 		return false;
544 544
 	}
545 545
 
546
-	$rank = wordpoints_get_rank( $rank_id );
546
+	$rank = wordpoints_get_rank($rank_id);
547 547
 
548
-	if ( ! $rank ) {
548
+	if ( ! $rank) {
549 549
 		return false;
550 550
 	}
551 551
 
552
-	$old_rank_id = wordpoints_get_user_rank( $user_id, $rank->rank_group );
552
+	$old_rank_id = wordpoints_get_user_rank($user_id, $rank->rank_group);
553 553
 
554
-	if ( $rank_id === $old_rank_id ) {
554
+	if ($rank_id === $old_rank_id) {
555 555
 		return true;
556 556
 	}
557 557
 
558
-	$old_rank = wordpoints_get_rank( $old_rank_id );
558
+	$old_rank = wordpoints_get_rank($old_rank_id);
559 559
 
560
-	switch ( $old_rank->type ) {
560
+	switch ($old_rank->type) {
561 561
 
562 562
 		case 'base':
563 563
 			// If this is a base rank, it's possible that the user will not have
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 
578 578
 			// If the user rank isn't in the database, we can't run an update query,
579 579
 			// and need to do this insert instead.
580
-			if ( ! $has_rank ) {
580
+			if ( ! $has_rank) {
581 581
 
582 582
 				// This user doesn't yet have a rank in this group.
583 583
 				$result = $wpdb->insert(
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 		default:
599 599
 			$result = $wpdb->update(
600 600
 				$wpdb->wordpoints_user_ranks
601
-				, array( 'rank_id' => $rank_id )
601
+				, array('rank_id' => $rank_id)
602 602
 				, array(
603 603
 					'user_id' => $user_id,
604 604
 					'rank_id' => $old_rank_id,
@@ -609,22 +609,22 @@  discard block
 block discarded – undo
609 609
 
610 610
 	} // End switch ( $old_rank->type ).
611 611
 
612
-	if ( false === $result ) {
612
+	if (false === $result) {
613 613
 		return false;
614 614
 	}
615 615
 
616
-	$group_ranks = wp_cache_get( $rank->rank_group, 'wordpoints_user_ranks' );
616
+	$group_ranks = wp_cache_get($rank->rank_group, 'wordpoints_user_ranks');
617 617
 
618
-	foreach ( $group_ranks as $_rank_id => $user_ids ) {
619
-		unset( $group_ranks[ $_rank_id ][ $user_id ] );
618
+	foreach ($group_ranks as $_rank_id => $user_ids) {
619
+		unset($group_ranks[$_rank_id][$user_id]);
620 620
 	}
621 621
 
622
-	wp_cache_set( $rank->rank_group, $group_ranks, 'wordpoints_user_ranks' );
622
+	wp_cache_set($rank->rank_group, $group_ranks, 'wordpoints_user_ranks');
623 623
 
624
-	unset( $group_ranks );
624
+	unset($group_ranks);
625 625
 
626
-	wp_cache_delete( $rank_id, 'wordpoints_users_with_rank' );
627
-	wp_cache_delete( $old_rank_id, 'wordpoints_users_with_rank' );
626
+	wp_cache_delete($rank_id, 'wordpoints_users_with_rank');
627
+	wp_cache_delete($old_rank_id, 'wordpoints_users_with_rank');
628 628
 
629 629
 	/**
630 630
 	 * Perform actions when a user rank is updated.
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	 * @param int $new_rank_id The ID of the new rank the user has.
636 636
 	 * @param int $old_rank_id The ID of the old rank the user used to have.
637 637
 	 */
638
-	do_action( 'wordpoints_update_user_rank', $user_id, $rank_id, $old_rank_id );
638
+	do_action('wordpoints_update_user_rank', $user_id, $rank_id, $old_rank_id);
639 639
 
640 640
 	return true;
641 641
 }
@@ -649,19 +649,19 @@  discard block
 block discarded – undo
649 649
  *
650 650
  * @return int[]|false Array of user IDs or false if the $rank_id is invalid.
651 651
  */
652
-function wordpoints_get_users_with_rank( $rank_id ) {
652
+function wordpoints_get_users_with_rank($rank_id) {
653 653
 
654 654
 	global $wpdb;
655 655
 
656
-	$rank = wordpoints_get_rank( $rank_id );
656
+	$rank = wordpoints_get_rank($rank_id);
657 657
 
658
-	if ( ! $rank ) {
658
+	if ( ! $rank) {
659 659
 		return false;
660 660
 	}
661 661
 
662
-	$user_ids = wp_cache_get( $rank_id, 'wordpoints_users_with_rank' );
662
+	$user_ids = wp_cache_get($rank_id, 'wordpoints_users_with_rank');
663 663
 
664
-	if ( false === $user_ids ) {
664
+	if (false === $user_ids) {
665 665
 
666 666
 		$user_ids = $wpdb->get_col(
667 667
 			$wpdb->prepare(
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 			)
675 675
 		);
676 676
 
677
-		if ( 'base' === $rank->type ) {
677
+		if ('base' === $rank->type) {
678 678
 
679 679
 			$other_user_ids = $wpdb->get_col(
680 680
 				$wpdb->prepare(
@@ -693,10 +693,10 @@  discard block
 block discarded – undo
693 693
 				)
694 694
 			);
695 695
 
696
-			$user_ids = array_merge( $user_ids, $other_user_ids );
696
+			$user_ids = array_merge($user_ids, $other_user_ids);
697 697
 		}
698 698
 
699
-		wp_cache_set( $rank_id, $user_ids, 'wordpoints_users_with_rank' );
699
+		wp_cache_set($rank_id, $user_ids, 'wordpoints_users_with_rank');
700 700
 
701 701
 	} // End if ( not cached ).
702 702
 
@@ -712,59 +712,59 @@  discard block
 block discarded – undo
712 712
  *
713 713
  * @param int $rank_id The ID of the rank to refresh.
714 714
  */
715
-function wordpoints_refresh_rank_users( $rank_id ) {
715
+function wordpoints_refresh_rank_users($rank_id) {
716 716
 
717
-	$rank = wordpoints_get_rank( $rank_id );
717
+	$rank = wordpoints_get_rank($rank_id);
718 718
 
719
-	if ( ! $rank || 'base' === $rank->type ) {
719
+	if ( ! $rank || 'base' === $rank->type) {
720 720
 		return;
721 721
 	}
722 722
 
723 723
 	$prev_rank = $rank->get_adjacent( -1 );
724 724
 
725
-	if ( ! $prev_rank ) {
725
+	if ( ! $prev_rank) {
726 726
 		return;
727 727
 	}
728 728
 
729 729
 	// Get a list of users who have this rank.
730
-	$users = wordpoints_get_users_with_rank( $rank->ID );
730
+	$users = wordpoints_get_users_with_rank($rank->ID);
731 731
 
732 732
 	// Also get users who have the previous rank.
733
-	$prev_rank_users = wordpoints_get_users_with_rank( $prev_rank->ID );
733
+	$prev_rank_users = wordpoints_get_users_with_rank($prev_rank->ID);
734 734
 
735 735
 	// If there are some users who have this rank, check if any of them need to
736 736
 	// decrease to that rank.
737
-	if ( ! empty( $users ) ) {
737
+	if ( ! empty($users)) {
738 738
 
739
-		$rank_type = WordPoints_Rank_Types::get_type( $rank->type );
739
+		$rank_type = WordPoints_Rank_Types::get_type($rank->type);
740 740
 
741
-		foreach ( $users as $user_id ) {
741
+		foreach ($users as $user_id) {
742 742
 
743
-			$new_rank = $rank_type->maybe_decrease_user_rank( $user_id, $rank );
743
+			$new_rank = $rank_type->maybe_decrease_user_rank($user_id, $rank);
744 744
 
745
-			if ( $new_rank->ID === $rank->ID ) {
745
+			if ($new_rank->ID === $rank->ID) {
746 746
 				continue;
747 747
 			}
748 748
 
749
-			wordpoints_update_user_rank( $user_id, $new_rank->ID );
749
+			wordpoints_update_user_rank($user_id, $new_rank->ID);
750 750
 		}
751 751
 	}
752 752
 
753 753
 	// If there were some users with the previous rank, check if any of them can now
754 754
 	// increase to this rank.
755
-	if ( ! empty( $prev_rank_users ) ) {
755
+	if ( ! empty($prev_rank_users)) {
756 756
 
757
-		$rank_type = WordPoints_Rank_Types::get_type( $rank->type );
757
+		$rank_type = WordPoints_Rank_Types::get_type($rank->type);
758 758
 
759
-		foreach ( $prev_rank_users as $user_id ) {
759
+		foreach ($prev_rank_users as $user_id) {
760 760
 
761
-			$new_rank = $rank_type->maybe_increase_user_rank( $user_id, $prev_rank );
761
+			$new_rank = $rank_type->maybe_increase_user_rank($user_id, $prev_rank);
762 762
 
763
-			if ( $new_rank->ID === $prev_rank->ID ) {
763
+			if ($new_rank->ID === $prev_rank->ID) {
764 764
 				continue;
765 765
 			}
766 766
 
767
-			wordpoints_update_user_rank( $user_id, $new_rank->ID );
767
+			wordpoints_update_user_rank($user_id, $new_rank->ID);
768 768
 		}
769 769
 	}
770 770
 }
Please login to merge, or discard this patch.
src/components/ranks/admin/admin.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@
 block discarded – undo
12 12
  *
13 13
  * @since 1.7.0
14 14
  */
15
-include_once( WORDPOINTS_DIR . 'components/ranks/admin/includes/ajax.php' );
15
+include_once(WORDPOINTS_DIR . 'components/ranks/admin/includes/ajax.php');
16 16
 
17 17
 /**
18 18
  * Admin-side functions of the ranks component.
19 19
  *
20 20
  * @since 2.1.0
21 21
  */
22
-include_once( WORDPOINTS_DIR . 'components/ranks/admin/includes/functions.php' );
22
+include_once(WORDPOINTS_DIR . 'components/ranks/admin/includes/functions.php');
23 23
 
24 24
 /**
25 25
  * Admin-side actin and filter hooks of the ranks component.
26 26
  *
27 27
  * @since 2.1.0
28 28
  */
29
-include_once( WORDPOINTS_DIR . 'components/ranks/admin/includes/filters.php' );
29
+include_once(WORDPOINTS_DIR . 'components/ranks/admin/includes/filters.php');
30 30
 
31 31
 // EOF
Please login to merge, or discard this patch.
src/components/ranks/admin/includes/filters.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
  * @since 2.1.0
8 8
  */
9 9
 
10
-add_action( 'init', 'wordpoints_ranks_admin_register_scripts' );
10
+add_action('init', 'wordpoints_ranks_admin_register_scripts');
11 11
 
12
-add_action( 'admin_menu', 'wordpoints_ranks_admin_menu' );
12
+add_action('admin_menu', 'wordpoints_ranks_admin_menu');
13 13
 
14
-add_action( 'load-wordpoints_page_wordpoints_ranks', 'wordpoints_ranks_admin_screen_load' );
14
+add_action('load-wordpoints_page_wordpoints_ranks', 'wordpoints_ranks_admin_screen_load');
15 15
 
16 16
 
17 17
 // EOF
Please login to merge, or discard this patch.
src/components/ranks/admin/includes/functions.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@  discard block
 block discarded – undo
24 24
 	wp_register_style(
25 25
 		'wordpoints-ranks-admin'
26 26
 		, "{$assets_url}/css/ranks-screen{$suffix}.css"
27
-		, array( 'dashicons', 'wp-jquery-ui-dialog' )
27
+		, array('dashicons', 'wp-jquery-ui-dialog')
28 28
 		, WORDPOINTS_VERSION
29 29
 	);
30 30
 
31 31
 	$styles = wp_styles();
32
-	$styles->add_data( 'wordpoints-ranks-admin', 'rtl', 'replace' );
32
+	$styles->add_data('wordpoints-ranks-admin', 'rtl', 'replace');
33 33
 
34
-	if ( $suffix ) {
35
-		$styles->add_data( 'wordpoints-ranks-admin', 'suffix', $suffix );
34
+	if ($suffix) {
35
+		$styles->add_data('wordpoints-ranks-admin', 'suffix', $suffix);
36 36
 	}
37 37
 
38 38
 	// JS
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	wp_register_script(
41 41
 		'wordpoints-ranks-admin'
42 42
 		, "{$assets_url}/js/ranks-screen{$suffix}.js"
43
-		, array( 'backbone', 'jquery-ui-dialog', 'wp-util' )
43
+		, array('backbone', 'jquery-ui-dialog', 'wp-util')
44 44
 		, WORDPOINTS_VERSION
45 45
 	);
46 46
 
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
 		'wordpoints-ranks-admin'
49 49
 		, 'WordPointsRanksAdminL10n'
50 50
 		, array(
51
-			'unexpectedError' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ),
52
-			'changesSaved'    => __( 'Your changes have been saved.', 'wordpoints' ),
53
-			'emptyName'       => __( 'A rank title cannot be empty.', 'wordpoints' ),
54
-			'confirmDelete'   => __( 'Are you sure that you want to delete this rank? This action cannot be undone.', 'wordpoints' ),
55
-			'confirmTitle'    => __( 'Are you sure?', 'wordpoints' ),
56
-			'deleteText'      => __( 'Delete', 'wordpoints' ),
57
-			'cancelText'      => __( 'Cancel', 'wordpoints' ),
51
+			'unexpectedError' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'),
52
+			'changesSaved'    => __('Your changes have been saved.', 'wordpoints'),
53
+			'emptyName'       => __('A rank title cannot be empty.', 'wordpoints'),
54
+			'confirmDelete'   => __('Are you sure that you want to delete this rank? This action cannot be undone.', 'wordpoints'),
55
+			'confirmTitle'    => __('Are you sure?', 'wordpoints'),
56
+			'deleteText'      => __('Delete', 'wordpoints'),
57
+			'cancelText'      => __('Cancel', 'wordpoints'),
58 58
 		)
59 59
 	);
60 60
 
61 61
 	wp_localize_script(
62 62
 		'wordpoints-ranks-admin'
63 63
 		, 'WordPointsRanksAdminData'
64
-		, array( 'ranks' => WordPoints_Ranks_Admin_Screen_Ajax::prepare_all_ranks() )
64
+		, array('ranks' => WordPoints_Ranks_Admin_Screen_Ajax::prepare_all_ranks())
65 65
 	);
66 66
 }
67 67
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	// Ranks screen.
80 80
 	add_submenu_page(
81 81
 		$wordpoints_menu
82
-		,__( 'WordPoints — Ranks', 'wordpoints' )
83
-		,esc_html__( 'Ranks', 'wordpoints' )
82
+		,__('WordPoints — Ranks', 'wordpoints')
83
+		,esc_html__('Ranks', 'wordpoints')
84 84
 		,'manage_options'
85 85
 		,'wordpoints_ranks'
86 86
 		,'wordpoints_ranks_admin_screen'
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
  */
97 97
 function wordpoints_ranks_admin_screen_load() {
98 98
 
99
-	wp_enqueue_style( 'wordpoints-ranks-admin' );
100
-	wp_enqueue_script( 'wordpoints-ranks-admin' );
99
+	wp_enqueue_style('wordpoints-ranks-admin');
100
+	wp_enqueue_script('wordpoints-ranks-admin');
101 101
 
102 102
 	// Add help and screen options tabs.
103 103
 	$screen = get_current_screen();
@@ -105,37 +105,37 @@  discard block
 block discarded – undo
105 105
 	$screen->add_help_tab(
106 106
 		array(
107 107
 			'id'      => 'overview',
108
-			'title'   => esc_html__( 'Overview', 'wordpoints' ),
108
+			'title'   => esc_html__('Overview', 'wordpoints'),
109 109
 			'content' =>
110
-				'<p>' . esc_html__( 'Ranks are titles assigned to users. A set of ranks are organized into a hierarchy. The user starts at the bottom, but can work his way up to higher ranks. Each rank has requirements that a user must meet before he can move up to that rank. For example, the user may need to have a certain number of points to reach a given rank.', 'wordpoints' ) . '</p>
111
-				<p>' . esc_html__( 'More than one rank hierarchy may be available. For example, if you have multiple types of points, you will have a group of ranks for each points type. Each rank group is managed separately, on a different tab on this screen.', 'wordpoints' ) . '</p>',
110
+				'<p>' . esc_html__('Ranks are titles assigned to users. A set of ranks are organized into a hierarchy. The user starts at the bottom, but can work his way up to higher ranks. Each rank has requirements that a user must meet before he can move up to that rank. For example, the user may need to have a certain number of points to reach a given rank.', 'wordpoints') . '</p>
111
+				<p>' . esc_html__('More than one rank hierarchy may be available. For example, if you have multiple types of points, you will have a group of ranks for each points type. Each rank group is managed separately, on a different tab on this screen.', 'wordpoints') . '</p>',
112 112
 		)
113 113
 	);
114 114
 
115 115
 	$screen->add_help_tab(
116 116
 		array(
117 117
 			'id'      => 'adding-editing',
118
-			'title'   => esc_html__( 'Adding and Editing', 'wordpoints' ),
118
+			'title'   => esc_html__('Adding and Editing', 'wordpoints'),
119 119
 			'content' =>
120
-				'<p>' . esc_html__( 'To add a new rank to the rank group, click the Add Rank button. A new rank will appear with its settings form open. Fill out its settings and click the save button. If you have changed your mind, you can remove the new rank without saving it by clicking the Cancel button.', 'wordpoints' ) . '</p>
121
-				<p>' . esc_html__( 'To edit an existing rank&#8217;s settings, click on the Edit link in its title bar. The settings form for that rank will open. You can close the settings form again by clicking the Close link.', 'wordpoints' ) . '</p>
122
-				<p>' . esc_html__( 'Once you have modified the rank&#8217;s settings as desired, you can save your changes by clicking the Save button. Keep in mind that your changes will take effect immediately, and it is wise to double check that you have all of the settings just as you want them. If you decide that you don&#8217;t want to save your changes, click the Cancel button instead, which will reset the form to the rank&#8217;s current settings.', 'wordpoints' ) . '</p>',
120
+				'<p>' . esc_html__('To add a new rank to the rank group, click the Add Rank button. A new rank will appear with its settings form open. Fill out its settings and click the save button. If you have changed your mind, you can remove the new rank without saving it by clicking the Cancel button.', 'wordpoints') . '</p>
121
+				<p>' . esc_html__('To edit an existing rank&#8217;s settings, click on the Edit link in its title bar. The settings form for that rank will open. You can close the settings form again by clicking the Close link.', 'wordpoints') . '</p>
122
+				<p>' . esc_html__('Once you have modified the rank&#8217;s settings as desired, you can save your changes by clicking the Save button. Keep in mind that your changes will take effect immediately, and it is wise to double check that you have all of the settings just as you want them. If you decide that you don&#8217;t want to save your changes, click the Cancel button instead, which will reset the form to the rank&#8217;s current settings.', 'wordpoints') . '</p>',
123 123
 		)
124 124
 	);
125 125
 
126 126
 	$screen->add_help_tab(
127 127
 		array(
128 128
 			'id'      => 'deleting',
129
-			'title'   => esc_html__( 'Deleting', 'wordpoints' ),
129
+			'title'   => esc_html__('Deleting', 'wordpoints'),
130 130
 			'content' =>
131
-				'<p>' . esc_html__( 'If you would like to delete a rank, open its settings form, then click the Delete button. You will be asked to confirm that you want to delete the rank. If you are not sure, click the Cancel button in the confirmation dialog. Once you delete the rank, it is gone!', 'wordpoints' ) . '</p>',
131
+				'<p>' . esc_html__('If you would like to delete a rank, open its settings form, then click the Delete button. You will be asked to confirm that you want to delete the rank. If you are not sure, click the Cancel button in the confirmation dialog. Once you delete the rank, it is gone!', 'wordpoints') . '</p>',
132 132
 		)
133 133
 	);
134 134
 
135 135
 	$screen->set_help_sidebar(
136
-		'<p><strong>' . esc_html__( 'For more information:', 'wordpoints' ) . '</strong></p>
137
-		<p><a href="https://wordpoints.org/user-guide/ranks/">' . esc_html__( 'Documentation on Ranks', 'wordpoints' ) . '</a></p>
138
-		<p><a href="https://wordpress.org/support/plugin/wordpoints">' . esc_html__( 'Support Forums', 'wordpoints' ) . '</a></p>'
136
+		'<p><strong>' . esc_html__('For more information:', 'wordpoints') . '</strong></p>
137
+		<p><a href="https://wordpoints.org/user-guide/ranks/">' . esc_html__('Documentation on Ranks', 'wordpoints') . '</a></p>
138
+		<p><a href="https://wordpress.org/support/plugin/wordpoints">' . esc_html__('Support Forums', 'wordpoints') . '</a></p>'
139 139
 	);
140 140
 }
141 141
 
Please login to merge, or discard this patch.
src/uninstall.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if we aren't being uninstalled.
13
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-require_once( dirname( __FILE__ ) . '/includes/constants.php' );
18
-require_once( WORDPOINTS_DIR . '/includes/functions.php' );
19
-require_once( WORDPOINTS_DIR . '/includes/class-installables.php' );
20
-require_once( WORDPOINTS_DIR . '/includes/class-un-installer-base.php' );
17
+require_once(dirname(__FILE__) . '/includes/constants.php');
18
+require_once(WORDPOINTS_DIR . '/includes/functions.php');
19
+require_once(WORDPOINTS_DIR . '/includes/class-installables.php');
20
+require_once(WORDPOINTS_DIR . '/includes/class-un-installer-base.php');
21 21
 
22 22
 wordpoints_register_installer();
23 23
 
24
-WordPoints_Installables::uninstall( 'plugin', 'wordpoints' );
24
+WordPoints_Installables::uninstall('plugin', 'wordpoints');
25 25
 
26 26
 // EOF
Please login to merge, or discard this patch.
src/classes/multisite/switched/state.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 
41 41
 		$this->backup['original_blog_id'] = get_current_blog_id();
42 42
 
43
-		if ( isset( $GLOBALS['_wp_switched_stack'] ) ) {
43
+		if (isset($GLOBALS['_wp_switched_stack'])) {
44 44
 			$this->backup['switched_stack'] = $GLOBALS['_wp_switched_stack'];
45 45
 		}
46 46
 
47
-		if ( isset( $GLOBALS['switched'] ) ) {
47
+		if (isset($GLOBALS['switched'])) {
48 48
 			$this->backup['switched'] = $GLOBALS['switched'];
49 49
 		}
50 50
 
@@ -62,18 +62,18 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function restore() {
64 64
 
65
-		switch_to_blog( $this->backup['original_blog_id'] );
65
+		switch_to_blog($this->backup['original_blog_id']);
66 66
 
67
-		if ( isset( $this->backup['switched_stack'] ) ) {
67
+		if (isset($this->backup['switched_stack'])) {
68 68
 			$GLOBALS['_wp_switched_stack'] = $this->backup['switched_stack'];
69 69
 		} else {
70
-			unset( $GLOBALS['_wp_switched_stack'] );
70
+			unset($GLOBALS['_wp_switched_stack']);
71 71
 		}
72 72
 
73
-		if ( isset( $this->backup['switched'] ) ) {
73
+		if (isset($this->backup['switched'])) {
74 74
 			$GLOBALS['switched'] = $this->backup['switched'];
75 75
 		} else {
76
-			unset( $GLOBALS['switched'] );
76
+			unset($GLOBALS['switched']);
77 77
 		}
78 78
 
79 79
 		return $this->backup['original_blog_id'];
Please login to merge, or discard this patch.
src/classes/app.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 	/**
95 95
 	 * @since 2.1.0
96 96
 	 */
97
-	public function __construct( $slug, $parent = null ) {
97
+	public function __construct($slug, $parent = null) {
98 98
 
99 99
 		$this->slug = $slug;
100 100
 		$this->full_slug = $slug;
101 101
 
102
-		if ( $parent instanceof WordPoints_App ) {
102
+		if ($parent instanceof WordPoints_App) {
103 103
 			$this->parent = $parent;
104 104
 
105
-			if ( 'apps' !== $this->parent->full_slug ) {
105
+			if ('apps' !== $this->parent->full_slug) {
106 106
 				$this->full_slug = $this->parent->full_slug . '-' . $this->full_slug;
107 107
 			}
108 108
 		}
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
 	 * @return null|object|WordPoints_App|WordPoints_Class_RegistryI|WordPoints_Class_Registry_ChildrenI|WordPoints_Class_Registry_DeepI
123 123
 	 *         The sub app, or null if not found.
124 124
 	 */
125
-	public function get_sub_app( $slug ) {
125
+	public function get_sub_app($slug) {
126 126
 
127
-		$sub_app = $this->sub_apps->get( $slug, array( $this ) );
127
+		$sub_app = $this->sub_apps->get($slug, array($this));
128 128
 
129
-		if ( ! $sub_app ) {
129
+		if ( ! $sub_app) {
130 130
 			return null;
131 131
 		}
132 132
 
133 133
 		if (
134
-			empty( $this->did_init[ $slug ] )
134
+			empty($this->did_init[$slug])
135 135
 			&& ! self::$main->silent
136
-			&& $this->should_do_registry_init( $sub_app )
136
+			&& $this->should_do_registry_init($sub_app)
137 137
 		) {
138 138
 
139
-			$this->did_init[ $slug ] = true;
139
+			$this->did_init[$slug] = true;
140 140
 
141 141
 			/**
142 142
 			 * Initialization of an app registry.
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			 * @param WordPoints_Class_RegistryI|WordPoints_Class_Registry_ChildrenI
147 147
 			 *        $registry The registry object.
148 148
 			 */
149
-			do_action( "wordpoints_init_app_registry-{$this->full_slug}-{$slug}", $sub_app );
149
+			do_action("wordpoints_init_app_registry-{$this->full_slug}-{$slug}", $sub_app);
150 150
 		}
151 151
 
152 152
 		return $sub_app;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return bool Whether to call the init action or not.
174 174
 	 */
175
-	protected function should_do_registry_init( $registry ) {
175
+	protected function should_do_registry_init($registry) {
176 176
 		return (
177 177
 		   $registry instanceof WordPoints_Class_RegistryI
178 178
 		   || $registry instanceof WordPoints_Class_Registry_ChildrenI
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		 *
198 198
 		 * @param WordPoints_App $app The app object.
199 199
 		 */
200
-		do_action( "wordpoints_init_app-{$this->full_slug}", $this );
200
+		do_action("wordpoints_init_app-{$this->full_slug}", $this);
201 201
 	}
202 202
 }
203 203
 
Please login to merge, or discard this patch.
src/classes/hooks.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
 	protected function init() {
41 41
 
42 42
 		$sub_apps = $this->sub_apps;
43
-		$sub_apps->register( 'router', 'WordPoints_Hook_Router' );
44
-		$sub_apps->register( 'actions', 'WordPoints_Hook_Actions' );
45
-		$sub_apps->register( 'events', 'WordPoints_Hook_Events' );
46
-		$sub_apps->register( 'reactors', 'WordPoints_Class_Registry_Persistent' );
47
-		$sub_apps->register( 'reaction_stores', 'WordPoints_Class_Registry_Children' );
48
-		$sub_apps->register( 'extensions', 'WordPoints_Class_Registry_Persistent' );
49
-		$sub_apps->register( 'conditions', 'WordPoints_Class_Registry_Children' );
43
+		$sub_apps->register('router', 'WordPoints_Hook_Router');
44
+		$sub_apps->register('actions', 'WordPoints_Hook_Actions');
45
+		$sub_apps->register('events', 'WordPoints_Hook_Events');
46
+		$sub_apps->register('reactors', 'WordPoints_Class_Registry_Persistent');
47
+		$sub_apps->register('reaction_stores', 'WordPoints_Class_Registry_Children');
48
+		$sub_apps->register('extensions', 'WordPoints_Class_Registry_Persistent');
49
+		$sub_apps->register('conditions', 'WordPoints_Class_Registry_Children');
50 50
 
51 51
 		parent::init();
52 52
 	}
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function get_current_mode() {
71 71
 
72
-		if ( ! isset( $this->current_mode ) ) {
73
-			$this->current_mode = ( wordpoints_is_network_context() ? 'network' : 'standard' );
72
+		if ( ! isset($this->current_mode)) {
73
+			$this->current_mode = (wordpoints_is_network_context() ? 'network' : 'standard');
74 74
 		}
75 75
 
76 76
 		return $this->current_mode;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @param string $mode The slug of the mode to set as the current mode.
90 90
 	 */
91
-	public function set_current_mode( $mode ) {
91
+	public function set_current_mode($mode) {
92 92
 		$this->current_mode = $mode;
93 93
 	}
94 94
 
@@ -101,19 +101,19 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return WordPoints_Hook_Reaction_StoreI|false The reaction storage object.
103 103
 	 */
104
-	public function get_reaction_store( $slug ) {
104
+	public function get_reaction_store($slug) {
105 105
 
106
-		$reaction_store = $this->get_sub_app( 'reaction_stores' )->get(
106
+		$reaction_store = $this->get_sub_app('reaction_stores')->get(
107 107
 			$this->get_current_mode()
108 108
 			, $slug
109 109
 		);
110 110
 
111
-		if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) {
111
+		if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) {
112 112
 			return false;
113 113
 		}
114 114
 
115 115
 		// Allowing access to stores out-of-context would lead to strange behavior.
116
-		if ( false === $reaction_store->get_context_id() ) {
116
+		if (false === $reaction_store->get_context_id()) {
117 117
 			return false;
118 118
 		}
119 119
 
@@ -129,30 +129,30 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return WordPoints_Hook_Reaction_StoreI[] The reaction stores with this slug.
131 131
 	 */
132
-	public function get_reaction_stores( $slug ) {
132
+	public function get_reaction_stores($slug) {
133 133
 
134
-		$reaction_stores = $this->get_sub_app( 'reaction_stores' );
134
+		$reaction_stores = $this->get_sub_app('reaction_stores');
135 135
 
136 136
 		$stores = array();
137 137
 
138
-		foreach ( $reaction_stores->get_all_slugs() as $mode => $slugs ) {
138
+		foreach ($reaction_stores->get_all_slugs() as $mode => $slugs) {
139 139
 
140
-			if ( ! in_array( $slug, $slugs ) ) {
140
+			if ( ! in_array($slug, $slugs)) {
141 141
 				continue;
142 142
 			}
143 143
 
144
-			$store = $reaction_stores->get( $mode, $slug, array( $mode ) );
144
+			$store = $reaction_stores->get($mode, $slug, array($mode));
145 145
 
146
-			if ( ! $store instanceof WordPoints_Hook_Reaction_StoreI ) {
146
+			if ( ! $store instanceof WordPoints_Hook_Reaction_StoreI) {
147 147
 				continue;
148 148
 			}
149 149
 
150 150
 			// Allowing access to stores out-of-context would lead to strange behavior.
151
-			if ( false === $store->get_context_id() ) {
151
+			if (false === $store->get_context_id()) {
152 152
 				continue;
153 153
 			}
154 154
 
155
-			$stores[ $mode ] = $store;
155
+			$stores[$mode] = $store;
156 156
 		}
157 157
 
158 158
 		return $stores;
@@ -174,19 +174,19 @@  discard block
 block discarded – undo
174 174
 		$action_type
175 175
 	) {
176 176
 
177
-		foreach ( $this->get_sub_app( 'reaction_stores' )->get_all() as $reaction_stores ) {
178
-			foreach ( $reaction_stores as $reaction_store ) {
177
+		foreach ($this->get_sub_app('reaction_stores')->get_all() as $reaction_stores) {
178
+			foreach ($reaction_stores as $reaction_store) {
179 179
 
180
-				if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) {
180
+				if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) {
181 181
 					continue;
182 182
 				}
183 183
 
184 184
 				// Allowing access to stores out-of-context would lead to strange behavior.
185
-				if ( false === $reaction_store->get_context_id() ) {
185
+				if (false === $reaction_store->get_context_id()) {
186 186
 					continue;
187 187
 				}
188 188
 
189
-				foreach ( $reaction_store->get_reactions_to_event( $event_slug ) as $reaction ) {
189
+				foreach ($reaction_store->get_reactions_to_event($event_slug) as $reaction) {
190 190
 
191 191
 					$fire = new WordPoints_Hook_Fire(
192 192
 						$event_args
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 						, $action_type
195 195
 					);
196 196
 
197
-					$this->fire_reaction( $fire );
197
+					$this->fire_reaction($fire);
198 198
 				}
199 199
 			}
200 200
 		}
@@ -207,32 +207,32 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @param WordPoints_Hook_Fire $fire The hook fire object.
209 209
 	 */
210
-	protected function fire_reaction( $fire ) {
210
+	protected function fire_reaction($fire) {
211 211
 
212 212
 		/** @var WordPoints_Hook_ReactorI $reactor */
213
-		$reactor = $this->get_sub_app( 'reactors' )->get( $fire->reaction->get_reactor_slug() );
213
+		$reactor = $this->get_sub_app('reactors')->get($fire->reaction->get_reactor_slug());
214 214
 
215
-		if ( ! in_array( $fire->action_type, $reactor->get_action_types(), true ) ) {
215
+		if ( ! in_array($fire->action_type, $reactor->get_action_types(), true)) {
216 216
 			return;
217 217
 		}
218 218
 
219
-		$validator = new WordPoints_Hook_Reaction_Validator( $fire->reaction, true );
219
+		$validator = new WordPoints_Hook_Reaction_Validator($fire->reaction, true);
220 220
 		$validator->validate();
221 221
 
222
-		if ( $validator->had_errors() ) {
222
+		if ($validator->had_errors()) {
223 223
 			return;
224 224
 		}
225 225
 
226
-		unset( $validator );
226
+		unset($validator);
227 227
 
228 228
 		/** @var WordPoints_Hook_ExtensionI[] $extensions */
229
-		$extensions = $this->get_sub_app( 'extensions' )->get_all();
229
+		$extensions = $this->get_sub_app('extensions')->get_all();
230 230
 
231
-		foreach ( $extensions as $extension ) {
232
-			if ( ! $extension->should_hit( $fire ) ) {
233
-				foreach ( $extensions as $ext ) {
234
-					if ( $ext instanceof WordPoints_Hook_Extension_Miss_ListenerI ) {
235
-						$ext->after_miss( $fire );
231
+		foreach ($extensions as $extension) {
232
+			if ( ! $extension->should_hit($fire)) {
233
+				foreach ($extensions as $ext) {
234
+					if ($ext instanceof WordPoints_Hook_Extension_Miss_ListenerI) {
235
+						$ext->after_miss($fire);
236 236
 					}
237 237
 				}
238 238
 
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 
243 243
 		$fire->hit();
244 244
 
245
-		$reactor->hit( $fire );
245
+		$reactor->hit($fire);
246 246
 
247
-		foreach ( $extensions as $extension ) {
248
-			if ( $extension instanceof WordPoints_Hook_Extension_Hit_ListenerI ) {
249
-				$extension->after_hit( $fire );
247
+		foreach ($extensions as $extension) {
248
+			if ($extension instanceof WordPoints_Hook_Extension_Hit_ListenerI) {
249
+				$extension->after_hit($fire);
250 250
 			}
251 251
 		}
252 252
 	}
Please login to merge, or discard this patch.