Completed
Push — master ( 760553...dce43d )
by J.D.
03:49
created
src/components/ranks/ranks.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 include_once WORDPOINTS_DIR . 'components/ranks/includes/deprecated.php';
41 41
 
42
-if ( wordpoints_component_is_active( 'points' ) ) {
42
+if (wordpoints_component_is_active('points')) {
43 43
 
44 44
 	/**
45 45
 	 * Ranks integration with the Points component.
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	include_once WORDPOINTS_DIR . 'components/ranks/includes/integration/points.php';
50 50
 }
51 51
 
52
-if ( is_admin() ) {
52
+if (is_admin()) {
53 53
 
54 54
 	/**
55 55
 	 * Administration-side rank code.
Please login to merge, or discard this patch.
src/components/ranks/includes/deprecated.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
  */
18 18
 function wordpoints_ranks_get_db_schema() {
19 19
 
20
-	_deprecated_function( __FUNCTION__, '2.0.0' );
20
+	_deprecated_function(__FUNCTION__, '2.0.0');
21 21
 
22 22
 	global $wpdb;
23 23
 
Please login to merge, or discard this patch.
src/components/ranks/includes/rank-types/base.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @return array|false The validated metadata or false if it should't be saved.
34 34
 	 */
35
-	public function validate_rank_meta( array $meta ) {
35
+	public function validate_rank_meta(array $meta) {
36 36
 		return $meta;
37 37
 	}
38 38
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return bool Whether the user meets the requirements for this rank.
54 54
 	 */
55
-	protected function can_transition_user_rank( $user_id, $rank, array $args ) {
55
+	protected function can_transition_user_rank($user_id, $rank, array $args) {
56 56
 		return true;
57 57
 	}
58 58
 }
Please login to merge, or discard this patch.
src/components/ranks/includes/class-wordpoints-rank.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -75,17 +75,17 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @param int|WordPoints_Rank $id The ID of a rank.
77 77
 	 */
78
-	public function __construct( $id ) {
78
+	public function __construct($id) {
79 79
 
80
-		if ( is_a( $id, __CLASS__ ) ) {
81
-			$this->init( $id->data );
80
+		if (is_a($id, __CLASS__)) {
81
+			$this->init($id->data);
82 82
 			return;
83 83
 		}
84 84
 
85
-		$id = wordpoints_int( $id );
85
+		$id = wordpoints_int($id);
86 86
 
87
-		if ( $id ) {
88
-			$this->init( self::get_data( $id ) );
87
+		if ($id) {
88
+			$this->init(self::get_data($id));
89 89
 		}
90 90
 	}
91 91
 
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @since 1.7.0
96 96
 	 */
97
-	public function __isset( $key ) {
97
+	public function __isset($key) {
98 98
 
99
-		if ( isset( $this->data->$key ) ) {
99
+		if (isset($this->data->$key)) {
100 100
 			return true;
101 101
 		}
102 102
 
103
-		return metadata_exists( 'wordpoints_rank', $this->ID, $key );
103
+		return metadata_exists('wordpoints_rank', $this->ID, $key);
104 104
 	}
105 105
 
106 106
 	/**
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @since 1.7.0
110 110
 	 */
111
-	public function __get( $key ) {
111
+	public function __get($key) {
112 112
 
113
-		if ( 'ID' === $key ) {
113
+		if ('ID' === $key) {
114 114
 			return $this->ID;
115
-		} elseif ( isset( $this->data->$key ) ) {
115
+		} elseif (isset($this->data->$key)) {
116 116
 			$value = $this->data->$key;
117 117
 		} else {
118
-			$value = wordpoints_get_rank_meta( $this->ID, $key, true );
118
+			$value = wordpoints_get_rank_meta($this->ID, $key, true);
119 119
 		}
120 120
 
121 121
 		return $value;
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @since 1.7.0
128 128
 	 */
129
-	public function __set( $key, $value ) {
129
+	public function __set($key, $value) {
130 130
 
131
-		if ( 'ID' !== $key && 'data' !== $key ) {
131
+		if ('ID' !== $key && 'data' !== $key) {
132 132
 
133 133
 			_doing_it_wrong(
134 134
 				__METHOD__
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param object $data The data for a rank.
147 147
 	 */
148
-	public function init( $data ) {
148
+	public function init($data) {
149 149
 
150
-		if ( ! isset( $data->id ) ) {
150
+		if ( ! isset($data->id)) {
151 151
 			return;
152 152
 		}
153 153
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public function exists() {
166 166
 
167
-		return ! empty( $this->ID );
167
+		return ! empty($this->ID);
168 168
 	}
169 169
 
170 170
 	/**
@@ -181,23 +181,23 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return WordPoints_Rank|false The adjacent rank, or false.
183 183
 	 */
184
-	public function get_adjacent( $relative_position ) {
184
+	public function get_adjacent($relative_position) {
185 185
 
186
-		if ( 0 === wordpoints_int( $relative_position ) ) {
186
+		if (0 === wordpoints_int($relative_position)) {
187 187
 			return $this;
188 188
 		}
189 189
 
190
-		$group = WordPoints_Rank_Groups::get_group( $this->rank_group );
190
+		$group = WordPoints_Rank_Groups::get_group($this->rank_group);
191 191
 
192
-		$position = $group->get_rank_position( $this->ID );
192
+		$position = $group->get_rank_position($this->ID);
193 193
 
194
-		$adjacent_rank_id = $group->get_rank( $position + $relative_position );
194
+		$adjacent_rank_id = $group->get_rank($position + $relative_position);
195 195
 
196
-		if ( ! $adjacent_rank_id ) {
196
+		if ( ! $adjacent_rank_id) {
197 197
 			return false;
198 198
 		}
199 199
 
200
-		return new WordPoints_Rank( $adjacent_rank_id );
200
+		return new WordPoints_Rank($adjacent_rank_id);
201 201
 	}
202 202
 
203 203
 	//
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @return object|false The rank's data, or false if not found.
215 215
 	 */
216
-	public static function get_data( $id ) {
216
+	public static function get_data($id) {
217 217
 
218
-		$rank_data = wp_cache_get( $id, 'wordpoints_ranks' );
218
+		$rank_data = wp_cache_get($id, 'wordpoints_ranks');
219 219
 
220
-		if ( false !== $rank_data ) {
220
+		if (false !== $rank_data) {
221 221
 			return $rank_data;
222 222
 		}
223 223
 
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 			)
235 235
 		);
236 236
 
237
-		if ( null === $rank_data ) {
237
+		if (null === $rank_data) {
238 238
 			return false;
239 239
 		}
240 240
 
241
-		wp_cache_add( $rank_data->id, $rank_data, 'wordpoints_ranks' );
241
+		wp_cache_add($rank_data->id, $rank_data, 'wordpoints_ranks');
242 242
 
243 243
 		return $rank_data;
244 244
 	}
Please login to merge, or discard this patch.
src/components/ranks/includes/class-un-installer.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	protected $updates = array(
30 30
 		'1.8.0' => array( /*      -      */ 'site' => true, /*      -      */ ),
31
-		'2.0.0' => array( 'single' => true, /*     -     */ 'network' => true ),
31
+		'2.0.0' => array('single' => true, /*     -     */ 'network' => true),
32 32
 	);
33 33
 
34 34
 	/**
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	protected function before_update() {
81 81
 
82
-		if ( $this->network_wide ) {
83
-			unset( $this->updates['1_8_0'] );
82
+		if ($this->network_wide) {
83
+			unset($this->updates['1_8_0']);
84 84
 		}
85 85
 	}
86 86
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	protected function load_dependencies() {
98 98
 
99
-		include_once( WORDPOINTS_DIR . 'components/ranks/includes/constants.php' );
99
+		include_once(WORDPOINTS_DIR . 'components/ranks/includes/constants.php');
100 100
 	}
101 101
 
102 102
 	/**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 			"
128 128
 		); // WPCS: cache pass.
129 129
 
130
-		$this->maybe_update_tables_to_utf8mb4( 'global' );
130
+		$this->maybe_update_tables_to_utf8mb4('global');
131 131
 	}
132 132
 
133 133
 	/**
Please login to merge, or discard this patch.
src/components/ranks/includes/class-wordpoints-rank-type.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -218,8 +218,11 @@
 block discarded – undo
218 218
 						name="<?php echo esc_attr( $name ); ?>"
219 219
 						<?php if ( $args['placeholders'] && 'hidden' !== $field['type'] ) : ?>
220 220
 						value="<% if ( typeof <?php echo preg_replace( '/[^a-z0-9_]/i', '', $name ); // WPCS: XSS OK ?> !== "undefined" ) { print( <?php echo preg_replace( '/[^a-z0-9_]/i', '', $name ); // WPCS: XSS OK ?> ); } %>"
221
-						<?php else : ?>
222
-						value="<?php echo esc_attr( $value ); ?>"
221
+						<?php else {
222
+	: ?>
223
+						value="<?php echo esc_attr( $value );
224
+}
225
+?>"
223 226
 						<?php endif; ?>
224 227
 						class="widefat"
225 228
 					/>
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 *        @type string $slug The slug of this rank type.
76 76
 	 * }
77 77
 	 */
78
-	public function __construct( array $args ) {
78
+	public function __construct(array $args) {
79 79
 
80 80
 		$this->slug = $args['slug'];
81 81
 	}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return array|WP_Error|false The validated metadata, or false or a WP_Error
110 110
 	 *                              if it should't be saved.
111 111
 	 */
112
-	abstract public function validate_rank_meta( array $meta );
112
+	abstract public function validate_rank_meta(array $meta);
113 113
 
114 114
 	/**
115 115
 	 * Determine if a user meets the requirements for a rank of this type.
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return bool Whether the user meets the requirements for this rank.
128 128
 	 */
129
-	abstract protected function can_transition_user_rank( $user_id, $rank, array $args );
129
+	abstract protected function can_transition_user_rank($user_id, $rank, array $args);
130 130
 
131 131
 	//
132 132
 	// Final Public Methods.
@@ -185,49 +185,49 @@  discard block
 block discarded – undo
185 185
 		array $args = array()
186 186
 	) {
187 187
 
188
-		$args = array_merge( array( 'placeholders' => false ), $args );
188
+		$args = array_merge(array('placeholders' => false), $args);
189 189
 
190
-		foreach ( $this->meta_fields as $name => $field ) {
190
+		foreach ($this->meta_fields as $name => $field) {
191 191
 
192 192
 			$value = null;
193 193
 
194 194
 			// If we aren't using placeholders, calculate the value. Hidden fields
195 195
 			// never use placeholders.
196
-			if ( ! $args['placeholders'] || 'hidden' === $field['type'] ) {
196
+			if ( ! $args['placeholders'] || 'hidden' === $field['type']) {
197 197
 
198 198
 				// Default to the default value.
199 199
 				$value = $field['default'];
200 200
 
201 201
 				// If the value is set use that instead.
202
-				if ( isset( $meta[ $name ] ) ) {
203
-					$value = $meta[ $name ];
202
+				if (isset($meta[$name])) {
203
+					$value = $meta[$name];
204 204
 				}
205 205
 			}
206 206
 
207
-			switch ( $field['type'] ) {
207
+			switch ($field['type']) {
208 208
 
209 209
 				case 'hidden':
210 210
 				case 'number':
211 211
 				case 'text':
212
-					if ( isset( $field['label'] ) ) {
212
+					if (isset($field['label'])) {
213 213
 						?><p class="description description-thin"><label><?php
214
-						echo esc_html( $field['label'] );
214
+						echo esc_html($field['label']);
215 215
 					}
216 216
 
217 217
 					?>
218 218
 					<input
219
-						type="<?php echo esc_attr( $field['type'] ); ?>"
220
-						name="<?php echo esc_attr( $name ); ?>"
221
-						<?php if ( $args['placeholders'] && 'hidden' !== $field['type'] ) : ?>
222
-						value="<% if ( typeof <?php echo preg_replace( '/[^a-z0-9_]/i', '', $name ); // WPCS: XSS OK ?> !== "undefined" ) { print( <?php echo preg_replace( '/[^a-z0-9_]/i', '', $name ); // WPCS: XSS OK ?> ); } %>"
219
+						type="<?php echo esc_attr($field['type']); ?>"
220
+						name="<?php echo esc_attr($name); ?>"
221
+						<?php if ($args['placeholders'] && 'hidden' !== $field['type']) : ?>
222
+						value="<% if ( typeof <?php echo preg_replace('/[^a-z0-9_]/i', '', $name); // WPCS: XSS OK ?> !== "undefined" ) { print( <?php echo preg_replace('/[^a-z0-9_]/i', '', $name); // WPCS: XSS OK ?> ); } %>"
223 223
 						<?php else : ?>
224
-						value="<?php echo esc_attr( $value ); ?>"
224
+						value="<?php echo esc_attr($value); ?>"
225 225
 						<?php endif; ?>
226 226
 						class="widefat"
227 227
 					/>
228 228
 					<?php
229 229
 
230
-					if ( isset( $field['label'] ) ) {
230
+					if (isset($field['label'])) {
231 231
 						?></label></p><?php
232 232
 					}
233 233
 				break;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 						__METHOD__
238 238
 						, sprintf(
239 239
 							'WordPoints Error: Unknown field type "%s".'
240
-							, esc_html( $field['type'] )
240
+							, esc_html($field['type'])
241 241
 						)
242 242
 						, '1.7.0'
243 243
 					);
@@ -258,21 +258,21 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @return WordPoints_Rank The highest rank that the user can be increased to.
260 260
 	 */
261
-	final public function maybe_increase_user_rank( $user_id, $rank, array $args = array() ) {
261
+	final public function maybe_increase_user_rank($user_id, $rank, array $args = array()) {
262 262
 
263
-		$next_rank = $rank->get_adjacent( 1 );
263
+		$next_rank = $rank->get_adjacent(1);
264 264
 
265
-		if ( ! $next_rank ) {
265
+		if ( ! $next_rank) {
266 266
 			return $rank;
267 267
 		}
268 268
 
269
-		$rank_type = WordPoints_Rank_Types::get_type( $next_rank->type );
269
+		$rank_type = WordPoints_Rank_Types::get_type($next_rank->type);
270 270
 
271
-		if ( ! $rank_type->can_transition_user_rank( $user_id, $next_rank, $args ) ) {
271
+		if ( ! $rank_type->can_transition_user_rank($user_id, $next_rank, $args)) {
272 272
 			return $rank;
273 273
 		}
274 274
 
275
-		return $this->maybe_increase_user_rank( $user_id, $next_rank, $args );
275
+		return $this->maybe_increase_user_rank($user_id, $next_rank, $args);
276 276
 	}
277 277
 
278 278
 	/**
@@ -286,21 +286,21 @@  discard block
 block discarded – undo
286 286
 	 *
287 287
 	 * @return WordPoints_Rank The highest rank that the user can have.
288 288
 	 */
289
-	final public function maybe_decrease_user_rank( $user_id, $rank, array $args = array() ) {
289
+	final public function maybe_decrease_user_rank($user_id, $rank, array $args = array()) {
290 290
 
291
-		$rank_type = WordPoints_Rank_Types::get_type( $rank->type );
291
+		$rank_type = WordPoints_Rank_Types::get_type($rank->type);
292 292
 
293
-		if ( $rank_type->can_transition_user_rank( $user_id, $rank, $args ) ) {
293
+		if ($rank_type->can_transition_user_rank($user_id, $rank, $args)) {
294 294
 			return $rank;
295 295
 		}
296 296
 
297 297
 		$previous_rank = $rank->get_adjacent( -1 );
298 298
 
299
-		if ( ! $previous_rank ) {
299
+		if ( ! $previous_rank) {
300 300
 			return $rank;
301 301
 		}
302 302
 
303
-		return $this->maybe_decrease_user_rank( $user_id, $previous_rank, $args );
303
+		return $this->maybe_decrease_user_rank($user_id, $previous_rank, $args);
304 304
 	}
305 305
 
306 306
 	//
@@ -324,28 +324,28 @@  discard block
 block discarded – undo
324 324
 
325 325
 		$groups = WordPoints_Rank_Groups::get();
326 326
 
327
-		foreach ( $groups as $group_slug => $group ) {
327
+		foreach ($groups as $group_slug => $group) {
328 328
 
329
-			if ( ! WordPoints_Rank_Groups::is_type_registered_for_group( $this->slug, $group_slug ) ) {
329
+			if ( ! WordPoints_Rank_Groups::is_type_registered_for_group($this->slug, $group_slug)) {
330 330
 				continue;
331 331
 			}
332 332
 
333
-			$rank_id = wordpoints_get_user_rank( $user_id, $group_slug );
333
+			$rank_id = wordpoints_get_user_rank($user_id, $group_slug);
334 334
 
335
-			$rank = wordpoints_get_rank( $rank_id );
335
+			$rank = wordpoints_get_rank($rank_id);
336 336
 
337
-			if ( ! $rank ) {
337
+			if ( ! $rank) {
338 338
 				continue;
339 339
 			}
340 340
 
341
-			if ( $increase ) {
342
-				$new_rank = $this->maybe_increase_user_rank( $user_id, $rank, $args );
341
+			if ($increase) {
342
+				$new_rank = $this->maybe_increase_user_rank($user_id, $rank, $args);
343 343
 			} else {
344
-				$new_rank = $this->maybe_decrease_user_rank( $user_id, $rank, $args );
344
+				$new_rank = $this->maybe_decrease_user_rank($user_id, $rank, $args);
345 345
 			}
346 346
 
347
-			if ( $new_rank !== $rank ) {
348
-				wordpoints_update_user_rank( $user_id, $new_rank->ID );
347
+			if ($new_rank !== $rank) {
348
+				wordpoints_update_user_rank($user_id, $new_rank->ID);
349 349
 			}
350 350
 		}
351 351
 	}
Please login to merge, or discard this patch.
src/components/ranks/includes/integration/points.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@
 block discarded – undo
12 12
  *
13 13
  * @since 2.1.0
14 14
  */
15
-include_once( WORDPOINTS_DIR . '/components/ranks/includes/integration/points/functions.php' );
15
+include_once(WORDPOINTS_DIR . '/components/ranks/includes/integration/points/functions.php');
16 16
 
17 17
 /**
18 18
  * Actions and filters to integrate with the points component.
19 19
  *
20 20
  * @since 2.1.0
21 21
  */
22
-include_once( WORDPOINTS_DIR . '/components/ranks/includes/integration/points/filters.php' );
22
+include_once(WORDPOINTS_DIR . '/components/ranks/includes/integration/points/filters.php');
23 23
 
24 24
 // EOF
Please login to merge, or discard this patch.
src/components/ranks/includes/integration/points/filters.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
  * @since 2.1.0
8 8
  */
9 9
 
10
-add_filter( 'wordpoints_points_widget_text', 'wordpoints_ranks_points_widget_text_filter', 30, 2 );
11
-add_action( 'wordpoints_my_points_widget_below_text_field', 'wordpoints_ranks_my_points_widget_below_text_field' );
10
+add_filter('wordpoints_points_widget_text', 'wordpoints_ranks_points_widget_text_filter', 30, 2);
11
+add_action('wordpoints_my_points_widget_below_text_field', 'wordpoints_ranks_my_points_widget_below_text_field');
12 12
 
13
-add_filter( 'wordpoints_points_top_users_username', 'wordpoints_ranks_points_top_users_username_filter', 10, 4 );
13
+add_filter('wordpoints_points_top_users_username', 'wordpoints_ranks_points_top_users_username_filter', 10, 4);
14 14
 
15
-add_filter( 'shortcode_atts_wordpoints_user_rank', 'wordpoints_user_rank_shortcode_points_type_attr', 10, 3 );
15
+add_filter('shortcode_atts_wordpoints_user_rank', 'wordpoints_user_rank_shortcode_points_type_attr', 10, 3);
16 16
 
17
-add_action( 'wordpoints_ranks_register', 'wordpoints_register_points_ranks' );
17
+add_action('wordpoints_ranks_register', 'wordpoints_register_points_ranks');
18 18
 
19
-add_action( 'add_meta_boxes', 'wordpoints_ranks_add_points_types_meta_box_ranks', 20 );
19
+add_action('add_meta_boxes', 'wordpoints_ranks_add_points_types_meta_box_ranks', 20);
20 20
 
21 21
 // EOF
Please login to merge, or discard this patch.
src/components/ranks/includes/rank-types.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@
 block discarded – undo
8 8
  * @deprecated 2.2.0
9 9
  */
10 10
 
11
-_deprecated_file( __FILE__, '2.2.0' );
11
+_deprecated_file(__FILE__, '2.2.0');
12 12
 
13 13
 /**
14 14
  * The base rank type class.
15 15
  *
16 16
  * @since 1.7.0
17 17
  */
18
-include_once( WORDPOINTS_DIR . '/components/ranks/includes/rank-types/base.php' );
18
+include_once(WORDPOINTS_DIR . '/components/ranks/includes/rank-types/base.php');
19 19
 
20 20
 // EOF
Please login to merge, or discard this patch.