Completed
Push — master ( aa04da...b6760c )
by J.D.
02:59
created
src/includes/classes/hierarchy.php 2 patches
Doc Comments   +44 added lines patch added patch discarded remove patch
@@ -9,17 +9,49 @@  discard block
 block discarded – undo
9 9
 
10 10
 interface WordPoints_HierarchyI {
11 11
 	public function get();
12
+
13
+	/**
14
+	 * @return void
15
+	 */
12 16
 	public function push( $field, $data );
17
+
18
+	/**
19
+	 * @return void
20
+	 */
13 21
 	public function pop();
14 22
 	public function set_field( $field, $value );
23
+
24
+	/**
25
+	 * @param string $field
26
+	 * @param string $sub
27
+	 * @param string $sub_2
28
+	 */
15 29
 	public function get_field( $field, $sub = null, $sub_2 = null );
16 30
 	public function get_id();
17 31
 	public function go_to( $id );
32
+
33
+	/**
34
+	 * @param string $field
35
+	 *
36
+	 * @return void
37
+	 */
18 38
 	public function push_to( $field, $value );
39
+
40
+	/**
41
+	 * @return boolean
42
+	 */
19 43
 	public function ascend();
44
+
45
+	/**
46
+	 * @return boolean
47
+	 */
20 48
 	public function descend( $to = null );
21 49
 	public function is_main();
22 50
 	public function next();
51
+
52
+	/**
53
+	 * @return void
54
+	 */
23 55
 	public function reset();
24 56
 }
25 57
 
@@ -134,6 +166,9 @@  discard block
 block discarded – undo
134 166
 	protected $current = 0;
135 167
 	protected $i = 0;
136 168
 
169
+	/**
170
+	 * @param string $descendant_index
171
+	 */
137 172
 	public function __construct( $descendant_index ) {
138 173
 		$this->descendant_index = $descendant_index;
139 174
 	}
@@ -196,10 +231,16 @@  discard block
 block discarded – undo
196 231
 		$this->current = 0;
197 232
 	}
198 233
 
234
+	/**
235
+	 * @param string $field
236
+	 */
199 237
 	public function set_field( $field, $value ) {
200 238
 		$this->hierarchy[ $this->current ][ $field ] = $value;
201 239
 	}
202 240
 
241
+	/**
242
+	 * @param string $field
243
+	 */
203 244
 	public function get_field( $field, $sub = null, $sub_2 = null ) {
204 245
 
205 246
 		if ( ! isset( $this->hierarchy[ $this->current ][ $field ] ) ) {
@@ -225,6 +266,9 @@  discard block
 block discarded – undo
225 266
 		return $this->hierarchy[ $this->current ][ $field ];
226 267
 	}
227 268
 
269
+	/**
270
+	 * @param string $field
271
+	 */
228 272
 	public function push_to( $field, $value ) {
229 273
 
230 274
 		if ( ! isset( $this->hierarchy[ $this->current ][ $field ] ) ) {
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
 
10 10
 interface WordPoints_HierarchyI {
11 11
 	public function get();
12
-	public function push( $field, $data );
12
+	public function push($field, $data);
13 13
 	public function pop();
14
-	public function set_field( $field, $value );
15
-	public function get_field( $field, $sub = null, $sub_2 = null );
14
+	public function set_field($field, $value);
15
+	public function get_field($field, $sub = null, $sub_2 = null);
16 16
 	public function get_id();
17
-	public function go_to( $id );
18
-	public function push_to( $field, $value );
17
+	public function go_to($id);
18
+	public function push_to($field, $value);
19 19
 	public function ascend();
20
-	public function descend( $to = null );
20
+	public function descend($to = null);
21 21
 	public function is_main();
22 22
 	public function next();
23 23
 	public function reset();
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
 	protected $descendant_index;
32 32
 
33 33
 	public function __construct() {
34
-		$this->current =& $this->hierarchy;
34
+		$this->current = & $this->hierarchy;
35 35
 	}
36 36
 
37 37
 	public function get() {
38 38
 		return $this->hierarchy;
39 39
 	}
40 40
 
41
-	public function push( $field, $data ) {
41
+	public function push($field, $data) {
42 42
 
43
-		if ( ! isset( $this->current['slug'] ) || $this->current['slug'] !== $field ) {
43
+		if ( ! isset($this->current['slug']) || $this->current['slug'] !== $field) {
44 44
 
45
-			if ( ! empty( $this->hierarchy ) ) {
46
-				$this->current[ $this->descendant_index ][ $field ] = $data;
47
-				$this->current =& $this->current[ $this->descendant_index ][ $field ];
45
+			if ( ! empty($this->hierarchy)) {
46
+				$this->current[$this->descendant_index][$field] = $data;
47
+				$this->current = & $this->current[$this->descendant_index][$field];
48 48
 			} else {
49 49
 				$this->current = $this->stack[0] = $data;
50 50
 			}
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 
58 58
 	public function pop() {
59 59
 
60
-		unset( $this->current );
60
+		unset($this->current);
61 61
 
62
-		$this->current = array_pop( $this->stack );
62
+		$this->current = array_pop($this->stack);
63 63
 	}
64 64
 
65 65
 	public function reset() {
66 66
 		//	unset( $this->current_arg );
67
-		$this->current =& $this->hierarchy;
67
+		$this->current = & $this->hierarchy;
68 68
 		$this->stack = array();
69 69
 	}
70 70
 
@@ -80,30 +80,30 @@  discard block
 block discarded – undo
80 80
 //		return $this->current[ $field ];
81 81
 //	}
82 82
 
83
-	public function push_to( $field, $value ) {
83
+	public function push_to($field, $value) {
84 84
 
85
-		if ( ! isset( $this->current[ $field ] ) ) {
85
+		if ( ! isset($this->current[$field])) {
86 86
 
87 87
 		}
88 88
 		//var_dump( $field, $value,$this->current[ $field ] );
89
-		$this->current[ $field ][] = $value;
89
+		$this->current[$field][] = $value;
90 90
 	}
91 91
 
92
-	public function set_sub_field( $slug, $field, $value ) {
93
-		$this->current[ $this->descendant_index ][ $slug ][ $field ] = $value;
92
+	public function set_sub_field($slug, $field, $value) {
93
+		$this->current[$this->descendant_index][$slug][$field] = $value;
94 94
 	}
95 95
 
96
-	public function get_sub_field( $slug, $field ) {
97
-		return $this->current[ $this->descendant_index ][ $slug ][ $field ];
96
+	public function get_sub_field($slug, $field) {
97
+		return $this->current[$this->descendant_index][$slug][$field];
98 98
 	}
99 99
 
100
-	public function get_sub_data( $slug ) {
101
-		return $this->current[ $this->descendant_index ][ $slug ];
100
+	public function get_sub_data($slug) {
101
+		return $this->current[$this->descendant_index][$slug];
102 102
 	}
103 103
 
104 104
 	public function ascend() {
105 105
 
106
-		if ( ! $this->stack ) {
106
+		if ( ! $this->stack) {
107 107
 			return false;
108 108
 		}
109 109
 
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 		return true;
113 113
 	}
114 114
 
115
-	public function descend( $to = null ) {
115
+	public function descend($to = null) {
116 116
 
117
-		if ( ! isset( $this->hierarchy[ $this->descendant_index ] ) ) {
117
+		if ( ! isset($this->hierarchy[$this->descendant_index])) {
118 118
 			return false;
119 119
 		}
120 120
 
121
-		reset( $this->current[ $this->descendant_index ] );
122
-		$field = key( $this->current[ $this->descendant_index ] );
123
-		$this->current =& $this->current[ $this->descendant_index ][ $field ];
121
+		reset($this->current[$this->descendant_index]);
122
+		$field = key($this->current[$this->descendant_index]);
123
+		$this->current = & $this->current[$this->descendant_index][$field];
124 124
 
125 125
 		$this->stack[] = $this->current;
126 126
 
@@ -134,52 +134,52 @@  discard block
 block discarded – undo
134 134
 	protected $current = 0;
135 135
 	protected $i = 0;
136 136
 
137
-	public function __construct( $descendant_index ) {
137
+	public function __construct($descendant_index) {
138 138
 		$this->descendant_index = $descendant_index;
139 139
 	}
140 140
 
141 141
 	public function get() {
142 142
 	//	var_dump( $this->hierarchy );
143 143
 
144
-		if ( empty( $this->hierarchy ) ) {
144
+		if (empty($this->hierarchy)) {
145 145
 			return array();
146 146
 		}
147 147
 
148
-		return $this->build_hierarchy( $this->hierarchy[0] );
148
+		return $this->build_hierarchy($this->hierarchy[0]);
149 149
 	}
150 150
 
151
-	protected function build_hierarchy( $arg ) {
151
+	protected function build_hierarchy($arg) {
152 152
 
153
-		if ( isset( $arg[ $this->descendant_index ] ) ) {
153
+		if (isset($arg[$this->descendant_index])) {
154 154
 
155
-			foreach ( $arg[ $this->descendant_index ] as $sub_arg => $i ) {
156
-				$arg[ $this->descendant_index ][ $sub_arg ] = $this->build_hierarchy( $this->hierarchy[ $i ] );
155
+			foreach ($arg[$this->descendant_index] as $sub_arg => $i) {
156
+				$arg[$this->descendant_index][$sub_arg] = $this->build_hierarchy($this->hierarchy[$i]);
157 157
 			}
158 158
 		}
159 159
 
160
-		if ( isset( $arg['_parent'] ) ) {
161
-			unset( $arg['_parent'] );
160
+		if (isset($arg['_parent'])) {
161
+			unset($arg['_parent']);
162 162
 		}
163 163
 
164
-		unset( $arg['_i'] );
164
+		unset($arg['_i']);
165 165
 
166 166
 		return $arg;
167 167
 	}
168 168
 
169
-	public function push( $field, $data ) {
169
+	public function push($field, $data) {
170 170
 
171
-		if ( ! isset( $this->hierarchy[ $this->current ]['slug'] ) || $this->hierarchy[ $this->current ]['slug'] !== $field ) {
171
+		if ( ! isset($this->hierarchy[$this->current]['slug']) || $this->hierarchy[$this->current]['slug'] !== $field) {
172 172
 
173 173
 			$i = $this->i++;
174 174
 
175
-			if ( ! empty( $this->hierarchy ) ) {
176
-				$this->hierarchy[ $this->current ][ $this->descendant_index ][ $field ] = $i;
175
+			if ( ! empty($this->hierarchy)) {
176
+				$this->hierarchy[$this->current][$this->descendant_index][$field] = $i;
177 177
 				$data['_parent'] = $this->current;
178 178
 			}
179 179
 
180
-			$this->hierarchy[ $i ] = $data;
181
-			$this->hierarchy[ $i ]['slug'] = $field;
182
-			$this->hierarchy[ $i ]['_i'] = $i;
180
+			$this->hierarchy[$i] = $data;
181
+			$this->hierarchy[$i]['slug'] = $field;
182
+			$this->hierarchy[$i]['_i'] = $i;
183 183
 
184 184
 			$this->current = $i;
185 185
 		}
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 
188 188
 	public function pop() {
189 189
 
190
-		$this->current = isset( $this->hierarchy[ $this->current ]['_parent'] )
191
-			?  $this->hierarchy[ $this->current ]['_parent']
190
+		$this->current = isset($this->hierarchy[$this->current]['_parent'])
191
+			? $this->hierarchy[$this->current]['_parent']
192 192
 			: 0;
193 193
 	}
194 194
 
@@ -196,95 +196,95 @@  discard block
 block discarded – undo
196 196
 		$this->current = 0;
197 197
 	}
198 198
 
199
-	public function set_field( $field, $value ) {
200
-		$this->hierarchy[ $this->current ][ $field ] = $value;
199
+	public function set_field($field, $value) {
200
+		$this->hierarchy[$this->current][$field] = $value;
201 201
 	}
202 202
 
203
-	public function get_field( $field, $sub = null, $sub_2 = null ) {
203
+	public function get_field($field, $sub = null, $sub_2 = null) {
204 204
 
205
-		if ( ! isset( $this->hierarchy[ $this->current ][ $field ] ) ) {
205
+		if ( ! isset($this->hierarchy[$this->current][$field])) {
206 206
 			return null;
207 207
 		}
208 208
 
209
-		if ( isset( $sub ) ) {
210
-			if ( ! isset( $this->hierarchy[ $this->current ][ $field ][ $sub ] ) ) {
209
+		if (isset($sub)) {
210
+			if ( ! isset($this->hierarchy[$this->current][$field][$sub])) {
211 211
 				return null;
212 212
 			}
213 213
 
214
-			if ( isset( $sub_2 ) ) {
215
-				if ( ! isset( $this->hierarchy[ $this->current ][ $field ][ $sub ][ $sub_2 ] ) ) {
214
+			if (isset($sub_2)) {
215
+				if ( ! isset($this->hierarchy[$this->current][$field][$sub][$sub_2])) {
216 216
 					return null;
217 217
 				} else {
218
-					return $this->hierarchy[ $this->current ][ $field ][ $sub ][ $sub_2 ];
218
+					return $this->hierarchy[$this->current][$field][$sub][$sub_2];
219 219
 				}
220 220
 			}
221 221
 
222
-			return $this->hierarchy[ $this->current ][ $field ][ $sub ];
222
+			return $this->hierarchy[$this->current][$field][$sub];
223 223
 		}
224 224
 
225
-		return $this->hierarchy[ $this->current ][ $field ];
225
+		return $this->hierarchy[$this->current][$field];
226 226
 	}
227 227
 
228
-	public function push_to( $field, $value ) {
228
+	public function push_to($field, $value) {
229 229
 
230
-		if ( ! isset( $this->hierarchy[ $this->current ][ $field ] ) ) {
230
+		if ( ! isset($this->hierarchy[$this->current][$field])) {
231 231
 
232 232
 		}
233 233
 		//var_dump( $field, $value,$this->current[ $field ] );
234
-		$this->hierarchy[ $this->current ][ $field ][] = $value;
234
+		$this->hierarchy[$this->current][$field][] = $value;
235 235
 	}
236 236
 
237
-	public function set_sub_field( $slug, $field, $value ) {
238
-		$this->hierarchy[ $this->current ][ $this->descendant_index ][ $slug ][ $field ] = $value;
237
+	public function set_sub_field($slug, $field, $value) {
238
+		$this->hierarchy[$this->current][$this->descendant_index][$slug][$field] = $value;
239 239
 	}
240 240
 
241
-	public function get_sub_field( $slug, $field ) {
241
+	public function get_sub_field($slug, $field) {
242 242
 
243
-		return $this->hierarchy[ $this->current ][ $this->descendant_index ][ $slug ][ $field ];
243
+		return $this->hierarchy[$this->current][$this->descendant_index][$slug][$field];
244 244
 	}
245 245
 
246
-	public function get_sub_data( $slug ) {
247
-		return $this->hierarchy[ $this->current ][ $this->descendant_index ][ $slug ];
246
+	public function get_sub_data($slug) {
247
+		return $this->hierarchy[$this->current][$this->descendant_index][$slug];
248 248
 	}
249 249
 
250
-	public function has_child( $slug ) {
251
-		return isset( $this->hierarchy[ $this->current ][ $this->descendant_index ][ $slug ] );
250
+	public function has_child($slug) {
251
+		return isset($this->hierarchy[$this->current][$this->descendant_index][$slug]);
252 252
 	}
253 253
 
254 254
 	public function get_children() {
255
-		return isset( $this->hierarchy[ $this->current ][ $this->descendant_index ][ $slug ] );
255
+		return isset($this->hierarchy[$this->current][$this->descendant_index][$slug]);
256 256
 
257 257
 	}
258 258
 
259 259
 	public function ascend() {
260 260
 
261
-		if ( ! isset( $this->hierarchy[ $this->current ]['_parent'] ) ) {
261
+		if ( ! isset($this->hierarchy[$this->current]['_parent'])) {
262 262
 			return false;
263 263
 		}
264 264
 
265
-		$this->current = $this->hierarchy[ $this->current ]['_parent'];
265
+		$this->current = $this->hierarchy[$this->current]['_parent'];
266 266
 
267 267
 		return true;
268 268
 	}
269 269
 
270
-	public function descend( $to = null ) {
270
+	public function descend($to = null) {
271 271
 
272
-		if ( ! isset( $this->hierarchy[ $this->current ][ $this->descendant_index ] ) ) {
272
+		if ( ! isset($this->hierarchy[$this->current][$this->descendant_index])) {
273 273
 			return false;
274 274
 		}
275 275
 
276
-		if ( isset( $to ) ) {
276
+		if (isset($to)) {
277 277
 
278
-			if ( ! isset( $this->hierarchy[ $this->current ][ $this->descendant_index ][ $to ] ) ) {
278
+			if ( ! isset($this->hierarchy[$this->current][$this->descendant_index][$to])) {
279 279
 				return false;
280 280
 			}
281 281
 
282
-			$this->current = $this->hierarchy[ $this->current ][ $this->descendant_index ][ $to ];
282
+			$this->current = $this->hierarchy[$this->current][$this->descendant_index][$to];
283 283
 
284 284
 		} else {
285 285
 
286 286
 			$this->current = reset(
287
-				$this->hierarchy[ $this->current ][ $this->descendant_index ]
287
+				$this->hierarchy[$this->current][$this->descendant_index]
288 288
 			);
289 289
 		}
290 290
 
@@ -293,29 +293,29 @@  discard block
 block discarded – undo
293 293
 
294 294
 	public function next() {
295 295
 
296
-		if ( ! isset( $this->hierarchy[ $this->current ]['_parent'] ) ) {
296
+		if ( ! isset($this->hierarchy[$this->current]['_parent'])) {
297 297
 			return false;
298 298
 		}
299 299
 
300
-		$parent = $this->hierarchy[ $this->current ]['_parent'];
300
+		$parent = $this->hierarchy[$this->current]['_parent'];
301 301
 
302
-		if ( ! isset( $this->hierarchy[ $parent ][ $this->descendant_index ] ) ) {
302
+		if ( ! isset($this->hierarchy[$parent][$this->descendant_index])) {
303 303
 			return false;
304 304
 		}
305 305
 
306
-		$sub_args = $this->hierarchy[ $parent ][ $this->descendant_index ];
306
+		$sub_args = $this->hierarchy[$parent][$this->descendant_index];
307 307
 
308
-		reset( $sub_args );
308
+		reset($sub_args);
309 309
 
310
-		while ( current( $sub_args ) !== $this->current ) {
311
-			next( $sub_args );
310
+		while (current($sub_args) !== $this->current) {
311
+			next($sub_args);
312 312
 		}
313 313
 
314
-		if ( ! next( $sub_args ) ) {
314
+		if ( ! next($sub_args)) {
315 315
 			return false;
316 316
 		}
317 317
 
318
-		$this->current = current( $sub_args );
318
+		$this->current = current($sub_args);
319 319
 
320 320
 		return true;
321 321
 	}
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 		return $this->current;
325 325
 	}
326 326
 
327
-	public function go_to( $id ) {
327
+	public function go_to($id) {
328 328
 
329
-		if ( false === wordpoints_posint( $id ) || $id < 0 ) {
329
+		if (false === wordpoints_posint($id) || $id < 0) {
330 330
 			return;
331 331
 		}
332 332
 
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction/storage.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@
 block discarded – undo
179 179
 	 *
180 180
 	 * @param string $event_slug The slug of the event this reaction is for.
181 181
 	 *
182
-	 * @return int|false The reaction ID, or false if not created.
182
+	 * @return integer The reaction ID, or false if not created.
183 183
 	 */
184 184
 	abstract protected function _create_reaction( $event_slug );
185 185
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	/**
59 59
 	 * @since 1.0.0
60 60
 	 */
61
-	public function __construct( $reactor_slug, $network_wide ) {
61
+	public function __construct($reactor_slug, $network_wide) {
62 62
 
63 63
 		$this->reactor_slug = $reactor_slug;
64 64
 		$this->network_wide = $network_wide;
@@ -82,27 +82,27 @@  discard block
 block discarded – undo
82 82
 	/**
83 83
 	 * @since 1.0.0
84 84
 	 */
85
-	public function get_reaction( $id ) {
85
+	public function get_reaction($id) {
86 86
 
87
-		if ( ! $this->reaction_exists( $id ) ) {
87
+		if ( ! $this->reaction_exists($id)) {
88 88
 			return false;
89 89
 		}
90 90
 
91
-		return new $this->reaction_class( $id, $this );
91
+		return new $this->reaction_class($id, $this);
92 92
 	}
93 93
 
94 94
 	/**
95 95
 	 * @since 1.0.0
96 96
 	 */
97
-	public function create_reaction( array $settings ) {
98
-		return $this->create_or_update_reaction( $settings );
97
+	public function create_reaction(array $settings) {
98
+		return $this->create_or_update_reaction($settings);
99 99
 	}
100 100
 
101 101
 	/**
102 102
 	 * @since 1.0.0
103 103
 	 */
104
-	public function update_reaction( $id, array $settings ) {
105
-		return $this->create_or_update_reaction( $settings, $id );
104
+	public function update_reaction($id, array $settings) {
105
+		return $this->create_or_update_reaction($settings, $id);
106 106
 	}
107 107
 
108 108
 	/**
@@ -117,44 +117,44 @@  discard block
 block discarded – undo
117 117
 	 *         The reaction object if created/updated successfully. False or a
118 118
 	 *         validator instance if not.
119 119
 	 */
120
-	protected function create_or_update_reaction( array $settings, $id = null ) {
120
+	protected function create_or_update_reaction(array $settings, $id = null) {
121 121
 
122
-		$is_new = ! isset( $id );
122
+		$is_new = ! isset($id);
123 123
 
124
-		if ( ! $is_new && ! $this->reaction_exists( $id ) ) {
124
+		if ( ! $is_new && ! $this->reaction_exists($id)) {
125 125
 			return false;
126 126
 		}
127 127
 
128 128
 		/** @var WordPoints_Hook_Reactor $reactor */
129
-		$reactor = $this->hooks->reactors->get( $this->reactor_slug );
129
+		$reactor = $this->hooks->reactors->get($this->reactor_slug);
130 130
 
131
-		$validator = new WordPoints_Hook_Reaction_Validator( $settings, $reactor );
131
+		$validator = new WordPoints_Hook_Reaction_Validator($settings, $reactor);
132 132
 		$settings = $validator->validate();
133 133
 
134
-		if ( $validator->had_errors() ) {
134
+		if ($validator->had_errors()) {
135 135
 			return $validator;
136 136
 		}
137 137
 
138
-		if ( $is_new ) {
138
+		if ($is_new) {
139 139
 
140
-			$id = $this->_create_reaction( $settings['event'] );
140
+			$id = $this->_create_reaction($settings['event']);
141 141
 
142
-			if ( ! $id ) {
142
+			if ( ! $id) {
143 143
 				return false;
144 144
 			}
145 145
 		}
146 146
 
147
-		$reaction = $this->get_reaction( $id );
147
+		$reaction = $this->get_reaction($id);
148 148
 
149
-		$reaction->update_event_slug( $settings['event'] );
149
+		$reaction->update_event_slug($settings['event']);
150 150
 
151
-		unset( $settings['event'] );
151
+		unset($settings['event']);
152 152
 
153
-		$reactor->update_settings( $reaction, $settings );
153
+		$reactor->update_settings($reaction, $settings);
154 154
 
155 155
 		/** @var WordPoints_Hook_Extension $extension */
156
-		foreach ( $this->hooks->extensions->get_all() as $extension ) {
157
-			$extension->update_settings( $reaction, $settings );
156
+		foreach ($this->hooks->extensions->get_all() as $extension) {
157
+			$extension->update_settings($reaction, $settings);
158 158
 		}
159 159
 
160 160
 		/**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		 * @param array                     $settings The new settings for the reaction.
165 165
 		 * @param bool                      $is_new   Whether the reaction was just now created.
166 166
 		 */
167
-		do_action( 'wordpoints_hook_reaction_save', $reaction, $settings, $is_new );
167
+		do_action('wordpoints_hook_reaction_save', $reaction, $settings, $is_new);
168 168
 
169 169
 		return $reaction;
170 170
 	}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return int|false The reaction ID, or false if not created.
183 183
 	 */
184
-	abstract protected function _create_reaction( $event_slug );
184
+	abstract protected function _create_reaction($event_slug);
185 185
 }
186 186
 
187 187
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/retroactive/query.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -73,6 +73,10 @@
 block discarded – undo
73 73
 
74 74
 
75 75
 interface WordPoints_Hook_Reactor_RetroactiveI extends WordPoints_Hook_Retroactive_Query_ModifierI {
76
+
77
+	/**
78
+	 * @return void
79
+	 */
76 80
 	public function retroactive_hit( $target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction );
77 81
 }
78 82
 
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 
74 74
 
75 75
 interface WordPoints_Hook_Reactor_RetroactiveI extends WordPoints_Hook_Retroactive_Query_ModifierI {
76
-	public function retroactive_hit( $target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction );
76
+	public function retroactive_hit($target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction);
77 77
 }
78 78
 
79 79
 abstract class WordPoints_Hook_Reactor_Retroactive implements WordPoints_Hook_Reactor_RetroactiveI {
80 80
 
81
-	public function modify_retroactive_query( WordPoints_Hook_Retroactive_QueryI $query ) {
81
+	public function modify_retroactive_query(WordPoints_Hook_Retroactive_QueryI $query) {
82 82
 
83
-		$query->set_target( $query->get_reaction()->get_meta( 'target' ) );
83
+		$query->set_target($query->get_reaction()->get_meta('target'));
84 84
 	}
85 85
 
86 86
 	public function spam_hits() {
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	/**
98 98
 	 * @since 1.0.0
99 99
 	 */
100
-	public function retroactive_hit( $target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction ) {
100
+	public function retroactive_hit($target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction) {
101 101
 
102
-		$count = count( $records );
102
+		$count = count($records);
103 103
 
104 104
 		wordpoints_alter_points(
105 105
 			$target
106
-			, $reaction->get_meta( 'points' ) * $count
107
-			, $reaction->get_meta( 'points_type' )
108
-			, 'retroactive_' . $reaction->get_event_slug()
109
-			, array( 'count' => $count )
110
-			, $event->get_retroactive_description( $reaction )
106
+			, $reaction->get_meta('points') * $count
107
+			, $reaction->get_meta('points_type')
108
+			, 'retroactive_'.$reaction->get_event_slug()
109
+			, array('count' => $count)
110
+			, $event->get_retroactive_description($reaction)
111 111
 		);
112 112
 	}
113 113
 
@@ -139,22 +139,22 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$logs = $query->get();
141 141
 
142
-		if ( ! $logs ) {
142
+		if ( ! $logs) {
143 143
 			return;
144 144
 		}
145 145
 
146
-		foreach ( $logs as $log ) {
146
+		foreach ($logs as $log) {
147 147
 
148 148
 			wordpoints_alter_points(
149 149
 				$log->user_id
150
-				, - ( $log->points / wordpoints_get_points_log_meta( $log->id, 'count', true ) )
150
+				, -($log->points / wordpoints_get_points_log_meta($log->id, 'count', true))
151 151
 				, $log->points_type
152 152
 				, "reverse_{$event}"
153
-				, array( 'original_log_id' => $log->id )
153
+				, array('original_log_id' => $log->id)
154 154
 				, $args->get_description()
155 155
 			);
156 156
 
157
-			wordpoints_add_points_log_meta( $log->id, 'auto_reversed', $args->get_entity_id() );
157
+			wordpoints_add_points_log_meta($log->id, 'auto_reversed', $args->get_entity_id());
158 158
 		}
159 159
 	}
160 160
 }
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 
197 197
 	protected $results;
198 198
 
199
-	public function __construct( WordPoints_Hook_ReactionI $reaction ) {
200
-		var_dump( __METHOD__ );
199
+	public function __construct(WordPoints_Hook_ReactionI $reaction) {
200
+		var_dump(__METHOD__);
201 201
 		$this->reaction = $reaction;
202
-		$this->arg_hierarchy = new WordPoints_Hierarchy( 'sub_args' );
202
+		$this->arg_hierarchy = new WordPoints_Hierarchy('sub_args');
203 203
 		$this->hooks = wordpoints_hooks();
204 204
 		$this->entities = wordpoints_entities();
205 205
 
206 206
 		$this->validator = new WordPoints_Hook_Reaction_Validator(
207 207
 			$reaction
208
-			, $this->hooks->reactors->get( $reaction->get_reactor_slug() )
208
+			, $this->hooks->reactors->get($reaction->get_reactor_slug())
209 209
 			, true
210 210
 		);
211 211
 	}
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
 	}
220 220
 
221 221
 	public function get_results() {
222
-		var_dump( __METHOD__ );
223
-		if ( ! isset( $this->results ) ) {
222
+		var_dump(__METHOD__);
223
+		if ( ! isset($this->results)) {
224 224
 
225 225
 			$this->execute();
226 226
 
227
-			if ( $this->validator->had_errors() ) {
227
+			if ($this->validator->had_errors()) {
228 228
 				$this->results = $this->validator;
229 229
 			}
230 230
 		}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	}
234 234
 
235 235
 	protected function execute() {
236
-		var_dump( __METHOD__ );
236
+		var_dump(__METHOD__);
237 237
 		try {
238 238
 
239 239
 			$this->prepare_query();
@@ -241,41 +241,41 @@  discard block
 block discarded – undo
241 241
 			$this->filter_results();
242 242
 			$this->group_results();
243 243
 
244
-		} catch ( WordPoints_Hook_Validator_Exception $e ) {
245
-			unset( $e );
244
+		} catch (WordPoints_Hook_Validator_Exception $e) {
245
+			unset($e);
246 246
 		}
247 247
 	}
248 248
 
249 249
 	protected function prepare_query() {
250
-		var_dump( __METHOD__ );
250
+		var_dump(__METHOD__);
251 251
 		$event_slug = $this->reaction->get_event_slug();
252 252
 
253
-		$event = $this->hooks->events->get( $event_slug );
253
+		$event = $this->hooks->events->get($event_slug);
254 254
 
255
-		if ( ! ( $event instanceof WordPoints_Hook_Event_RetroactiveI ) ) {
256
-			$this->validator->add_error( 'invalid hook' );
255
+		if ( ! ($event instanceof WordPoints_Hook_Event_RetroactiveI)) {
256
+			$this->validator->add_error('invalid hook');
257 257
 		}
258 258
 
259
-		foreach ( $this->hooks->events->args->get_children( $event_slug ) as $arg ) {
259
+		foreach ($this->hooks->events->args->get_children($event_slug) as $arg) {
260 260
 			$this->arg_hierarchy_push( // TODO
261 261
 				$arg
262 262
 			);
263 263
 		}
264 264
 
265
-		if ( $event instanceof WordPoints_Hook_Retroactive_Query_ModifierI ) {
266
-			$event->modify_retroactive_query( $this );
265
+		if ($event instanceof WordPoints_Hook_Retroactive_Query_ModifierI) {
266
+			$event->modify_retroactive_query($this);
267 267
 			$this->reset();
268 268
 		}
269 269
 
270
-		$reactor = $this->hooks->reactors->get( $this->reaction->get_reactor_slug() );
270
+		$reactor = $this->hooks->reactors->get($this->reaction->get_reactor_slug());
271 271
 
272
-		$reactor->modify_retroactive_query( $this );
272
+		$reactor->modify_retroactive_query($this);
273 273
 		$this->reset();
274 274
 
275
-		foreach ( $this->hooks->extensions->get_all() as $extension ) {
275
+		foreach ($this->hooks->extensions->get_all() as $extension) {
276 276
 
277
-			if ( $extension instanceof WordPoints_Hook_Retroactive_Query_ModifierI ) {
278
-				$extension->modify_retroactive_query( $this );
277
+			if ($extension instanceof WordPoints_Hook_Retroactive_Query_ModifierI) {
278
+				$extension->modify_retroactive_query($this);
279 279
 				$this->reset();
280 280
 			}
281 281
 		}
@@ -284,161 +284,161 @@  discard block
 block discarded – undo
284 284
 	protected function perform_query() {
285 285
 //		var_dump( __METHOD__,$this->arg_hierarchy->get() );exit;
286 286
 
287
-		$this->queries = new WordPoints_Hierarchy( 'sub_queries' );
288
-		$this->consolidate_queries( array( $this->arg_hierarchy->get() ) );
289
-		unset( $this->query );
287
+		$this->queries = new WordPoints_Hierarchy('sub_queries');
288
+		$this->consolidate_queries(array($this->arg_hierarchy->get()));
289
+		unset($this->query);
290 290
 
291 291
 		$this->queries->reset();
292 292
 //var_dump( $this->queries );exit;
293 293
 		// Find the tip of a query.
294
-		$this->results = $this->execute_queries( $this->queries->get() );
294
+		$this->results = $this->execute_queries($this->queries->get());
295 295
 
296
-		if ( is_wp_error( $this->results ) ) {
297
-			$this->validator->add_error( $this->results );
296
+		if (is_wp_error($this->results)) {
297
+			$this->validator->add_error($this->results);
298 298
 		}
299 299
 	}
300 300
 
301
-	protected function consolidate_queries( $arg_hierarchy, $storage_type = null ) {
302
-		var_dump( __METHOD__, wp_list_pluck( $arg_hierarchy, 'slug' ) );
303
-		foreach ( $arg_hierarchy as $data ) {
304
-			$this->consolidate_query( $data );
301
+	protected function consolidate_queries($arg_hierarchy, $storage_type = null) {
302
+		var_dump(__METHOD__, wp_list_pluck($arg_hierarchy, 'slug'));
303
+		foreach ($arg_hierarchy as $data) {
304
+			$this->consolidate_query($data);
305 305
 		}
306 306
 	}
307 307
 
308
-	protected function consolidate_query( $data ) {
309
-var_dump($data['slug']);var_dump($data['storage_info']['type'], $this->queries->get_field( 'slug' ) );
310
-		if ( $data['storage_info']['type'] !== $this->queries->get_field( 'slug' ) ) {
308
+	protected function consolidate_query($data) {
309
+var_dump($data['slug']); var_dump($data['storage_info']['type'], $this->queries->get_field('slug'));
310
+		if ($data['storage_info']['type'] !== $this->queries->get_field('slug')) {
311 311
 
312 312
 			$parent_id = null;
313
-			if ( isset( $this->query ) ) {
313
+			if (isset($this->query)) {
314 314
 				$parent_id = $this->query->get_id();
315 315
 			}
316
-			var_dump( $parent_id );
316
+			var_dump($parent_id);
317 317
 
318
-			$this->query = new WordPoints_Hierarchy( 'sub_args' );
318
+			$this->query = new WordPoints_Hierarchy('sub_args');
319 319
 
320 320
 			$this->queries->push(
321 321
 				$data['storage_info']['type']
322
-				, array( 'query' => $this->query, 'parent_id' => $parent_id )
322
+				, array('query' => $this->query, 'parent_id' => $parent_id)
323 323
 			);
324 324
 
325 325
 			$pushed_query = true;
326 326
 		}
327 327
 
328
-		if ( isset( $data['sub_args'] ) ) {
328
+		if (isset($data['sub_args'])) {
329 329
 			$sub_args = $data['sub_args'];
330
-			unset( $data['sub_args'] );
330
+			unset($data['sub_args']);
331 331
 		}
332 332
 
333
-		$this->query->push( $data['slug'], $data );
333
+		$this->query->push($data['slug'], $data);
334 334
 
335
-		if ( isset( $sub_args ) ) {
336
-			var_dump( '$sub_args',$data['slug'], wp_list_pluck($sub_args, 'slug') );
337
-			$this->consolidate_queries( $sub_args, $data['storage_info']['type'] );
335
+		if (isset($sub_args)) {
336
+			var_dump('$sub_args', $data['slug'], wp_list_pluck($sub_args, 'slug'));
337
+			$this->consolidate_queries($sub_args, $data['storage_info']['type']);
338 338
 		}
339 339
 
340 340
 		$this->query->pop();
341 341
 
342
-		if ( ! empty( $pushed_query ) ) {
342
+		if ( ! empty($pushed_query)) {
343 343
 			$this->queries->pop();
344
-			$this->query = $this->queries->get_field( 'query' );
344
+			$this->query = $this->queries->get_field('query');
345 345
 		}
346 346
 	}
347 347
 
348
-	protected function execute_queries( $queries ) {
349
-		var_dump( __METHOD__ );
348
+	protected function execute_queries($queries) {
349
+		var_dump(__METHOD__);
350 350
 //var_dump($queries);exit;
351 351
 		/** @var WordPoints_HierarchyI $query */
352 352
 		$query = $queries['query'];
353 353
 
354
-		if ( isset( $queries['sub_queries'] ) ) {
355
-			foreach ( $queries['sub_queries'] as $query_data ) {
354
+		if (isset($queries['sub_queries'])) {
355
+			foreach ($queries['sub_queries'] as $query_data) {
356 356
 
357
-				$results = $this->execute_queries( $query_data );
357
+				$results = $this->execute_queries($query_data);
358 358
 
359
-				if ( is_wp_error( $results ) ) {
359
+				if (is_wp_error($results)) {
360 360
 					return $results;
361 361
 				}
362 362
 
363
-				if ( empty( $results ) ) {
363
+				if (empty($results)) {
364 364
 					return array();
365 365
 				}
366 366
 
367 367
 				/** @var WordPoints_HierarchyI $child_query */
368 368
 				$child_query = $query_data['query'];
369
-				$query->go_to( $query_data['parent_id'] );
369
+				$query->go_to($query_data['parent_id']);
370 370
 //				var_dump( $query, $child_query );exit;
371 371
 				$condition = array(
372 372
 //					'field' => $child_query->get_field( 'slug' ),
373 373
 					'compare' => 'in',
374 374
 					'value' => wp_list_pluck(
375 375
 						$results
376
-						, $child_query->get_field( 'storage_info', 'meta', 'id_field' )
376
+						, $child_query->get_field('storage_info', 'meta', 'id_field')
377 377
 					),
378 378
 				);
379 379
 
380
-				$query->push_to( 'conditions', $condition );
380
+				$query->push_to('conditions', $condition);
381 381
 			}
382 382
 		}
383 383
 
384 384
 		$query->reset();
385
-		$storage_type = $query->get_field( 'storage_info', 'type' );
385
+		$storage_type = $query->get_field('storage_info', 'type');
386 386
 //var_dump( $query );exit;
387
-		$executor = $this->hooks->retroactive_query_executors->get( $storage_type );
387
+		$executor = $this->hooks->retroactive_query_executors->get($storage_type);
388 388
 
389
-		if ( ! $executor ) {
390
-			var_dump( $query );
389
+		if ( ! $executor) {
390
+			var_dump($query);
391 391
 			$this->validator->add_error(
392
-				sprintf( 'unknown storage type "%s".', $storage_type )
392
+				sprintf('unknown storage type "%s".', $storage_type)
393 393
 			);
394 394
 		}
395 395
 
396
-		return $executor->execute( array( $query->get() ) );
396
+		return $executor->execute(array($query->get()));
397 397
 	}
398 398
 
399 399
 	protected function filter_results() {
400
-		var_dump( __METHOD__ );
401
-		$reactor = $this->hooks->reactors->get( $this->reaction->get_reactor_slug() );
400
+		var_dump(__METHOD__);
401
+		$reactor = $this->hooks->reactors->get($this->reaction->get_reactor_slug());
402 402
 
403
-		if ( $reactor instanceof WordPoints_Hook_Retroactive_Query_FilterI ) {
404
-			$reactor->filter_retroactive_query( $this );
403
+		if ($reactor instanceof WordPoints_Hook_Retroactive_Query_FilterI) {
404
+			$reactor->filter_retroactive_query($this);
405 405
 		}
406 406
 
407
-		foreach ( $this->hooks->extensions->get_all() as $extension ) {
408
-			if ( $extension instanceof WordPoints_Hook_Retroactive_Query_FilterI ) {
409
-				$extension->filter_retroactive_query( $this );
407
+		foreach ($this->hooks->extensions->get_all() as $extension) {
408
+			if ($extension instanceof WordPoints_Hook_Retroactive_Query_FilterI) {
409
+				$extension->filter_retroactive_query($this);
410 410
 			}
411 411
 		}
412 412
 	}
413 413
 
414 414
 	protected function group_results() {
415
-		var_dump( __METHOD__ );
415
+		var_dump(__METHOD__);
416 416
 		$grouped_results = array();
417 417
 
418
-		foreach ( $this->results as $result ) {
419
-			$grouped_results[ $result->target ][] = $result;
418
+		foreach ($this->results as $result) {
419
+			$grouped_results[$result->target][] = $result;
420 420
 		}
421 421
 
422 422
 		$this->results = $grouped_results;
423 423
 	}
424 424
 
425
-	public function add_condition( array $condition ) {
426
-		var_dump( __METHOD__ );
425
+	public function add_condition(array $condition) {
426
+		var_dump(__METHOD__);
427 427
 
428
-		$this->arg_hierarchy->push_to( 'conditions', $condition );
428
+		$this->arg_hierarchy->push_to('conditions', $condition);
429 429
 	}
430 430
 
431
-	public function select_value( $data = array() ) {
432
-		var_dump( __METHOD__ );
431
+	public function select_value($data = array()) {
432
+		var_dump(__METHOD__);
433 433
 
434
-		$this->arg_hierarchy->set_field( 'select', $data );
434
+		$this->arg_hierarchy->set_field('select', $data);
435 435
 //	var_dump( $this->arg_hierarchy);exit;
436 436
 	}
437 437
 
438
-	public function set_target( $target_arg ) {
438
+	public function set_target($target_arg) {
439 439
 
440
-		foreach ( $target_arg as $arg_slug ) {
441
-			$this->arg_hierarchy_push( $arg_slug );
440
+		foreach ($target_arg as $arg_slug) {
441
+			$this->arg_hierarchy_push($arg_slug);
442 442
 		}
443 443
 
444 444
 //		$id = $this->arg_hierarchy->get_id();
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
 //			$field = $this->arg_hierarchy->get_field( 'storage_info', 'meta', 'field' );
449 449
 //			$this->arg_hierarchy->ascend();
450 450
 //		} else {
451
-			$field = $this->arg_hierarchy->get_field( 'storage_info', 'meta', 'id_field' );
451
+			$field = $this->arg_hierarchy->get_field('storage_info', 'meta', 'id_field');
452 452
 //		}
453 453
 
454
-		$this->select_value( array( 'field' => $field, 'as' => 'target' ) );
454
+		$this->select_value(array('field' => $field, 'as' => 'target'));
455 455
 
456 456
 //		$this->arg_hierarchy->go_to( $id );
457 457
 	}
@@ -463,41 +463,41 @@  discard block
 block discarded – undo
463 463
 	 * @return WordPoints_EntityishI
464 464
 	 */
465 465
 	public function get_arg() {
466
-		return $this->arg_hierarchy->get_field( 'arg' );
466
+		return $this->arg_hierarchy->get_field('arg');
467 467
 	}
468 468
 
469
-	public function arg_hierarchy_push( $slug ) {
470
-		var_dump( __METHOD__, $slug );
469
+	public function arg_hierarchy_push($slug) {
470
+		var_dump(__METHOD__, $slug);
471 471
 
472
-		$current_slug = $this->arg_hierarchy->get_field( 'slug' );
472
+		$current_slug = $this->arg_hierarchy->get_field('slug');
473 473
 
474
-		if ( $current_slug === $slug && $this->arg_hierarchy->is_main() ) {
474
+		if ($current_slug === $slug && $this->arg_hierarchy->is_main()) {
475 475
 			return;
476 476
 		}
477 477
 
478 478
 //		if ( $current_slug !== $slug ) {
479 479
 
480
-			if ( empty( $current_slug ) ) {
481
-				$arg = $this->entities->get( $slug );
480
+			if (empty($current_slug)) {
481
+				$arg = $this->entities->get($slug);
482 482
 			} else {
483 483
 
484 484
 				// If this child exists, don't overwrite it, just descend into it.
485
-				if ( $this->arg_hierarchy->has_child( $slug ) ) {
486
-					$this->arg_hierarchy->descend( $slug );
485
+				if ($this->arg_hierarchy->has_child($slug)) {
486
+					$this->arg_hierarchy->descend($slug);
487 487
 					return;
488 488
 				}
489 489
 
490
-				$parent_arg = $this->arg_hierarchy->get_field( 'arg' );
490
+				$parent_arg = $this->arg_hierarchy->get_field('arg');
491 491
 
492
-				if ( $parent_arg instanceof WordPoints_Entity_ParentI ) {
493
-					$arg = $parent_arg->get_child( $slug );
492
+				if ($parent_arg instanceof WordPoints_Entity_ParentI) {
493
+					$arg = $parent_arg->get_child($slug);
494 494
 				} else {
495 495
 					return; // TODO
496 496
 				}
497 497
 			}
498 498
 
499
-			if ( $arg instanceof WordPoints_Entity_Array ) {
500
-				$arg = $this->entities->get( $arg->get_entity_slug() );
499
+			if ($arg instanceof WordPoints_Entity_Array) {
500
+				$arg = $this->entities->get($arg->get_entity_slug());
501 501
 			}
502 502
 
503 503
 			$data['arg'] = $arg;
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 			// TODO check if storage type is recognized?
506 506
 			$data['storage_info'] = $arg->get_storage_info();
507 507
 
508
-			$this->arg_hierarchy->push( $slug, $data );
508
+			$this->arg_hierarchy->push($slug, $data);
509 509
 
510 510
 //		} else {
511 511
 //			$data = array();
@@ -513,22 +513,22 @@  discard block
 block discarded – undo
513 513
 	}
514 514
 
515 515
 	public function arg_hierarchy_pop() {
516
-		var_dump( __METHOD__ );
516
+		var_dump(__METHOD__);
517 517
 		$this->arg_hierarchy->pop();
518 518
 	}
519 519
 
520 520
 	public function reset() {
521
-		var_dump( __METHOD__ );
521
+		var_dump(__METHOD__);
522 522
 		$this->arg_hierarchy->reset();
523 523
 	}
524 524
 }
525 525
 
526 526
 interface WordPoints_Hook_Retroactive_Query_FilterI {
527
-	public function filter_retroactive_query( WordPoints_Hook_Retroactive_QueryI $query );
527
+	public function filter_retroactive_query(WordPoints_Hook_Retroactive_QueryI $query);
528 528
 }
529 529
 
530 530
 interface WordPoints_Hook_Retroactive_Query_ExecutorI {
531
-	public function execute( $query );
531
+	public function execute($query);
532 532
 }
533 533
 
534 534
 /*
@@ -557,49 +557,49 @@  discard block
 block discarded – undo
557 557
 	protected $array;
558 558
 	protected $results;
559 559
 
560
-	public function execute( $query ) {
560
+	public function execute($query) {
561 561
 //var_dump( __METHOD__, $query );//exit;
562
-		foreach ( $query as $arg_data ) {
562
+		foreach ($query as $arg_data) {
563 563
 
564 564
 			$meta = $arg_data['storage_info']['meta'];
565 565
 
566
-			if ( isset( $meta['getter'] ) ) {
566
+			if (isset($meta['getter'])) {
567 567
 				$this->array = $meta['getter']();
568 568
 			}
569 569
 //var_dump($this->array);
570 570
 //var_dump( $arg_data );exit;
571
-			if ( isset( $arg_data['conditions'] ) ) {
571
+			if (isset($arg_data['conditions'])) {
572 572
 //var_dump( $arg_data );
573
-				foreach ( $arg_data['conditions'] as $condition ) {
573
+				foreach ($arg_data['conditions'] as $condition) {
574 574
 
575
-					if ( ! isset( $condition['field'] ) ) {
576
-						if ( $arg_data['arg'] instanceof WordPoints_Entity_Attr ) {
575
+					if ( ! isset($condition['field'])) {
576
+						if ($arg_data['arg'] instanceof WordPoints_Entity_Attr) {
577 577
 							$condition['field'] = $meta['field'];
578 578
 						} else {
579 579
 							$condition['field'] = $meta['id_field'];
580 580
 						}
581 581
 					}
582 582
 
583
-					if ( ! isset( $condition['condition'] ) ) {
583
+					if ( ! isset($condition['condition'])) {
584 584
 						$condition['condition'] = '=';
585 585
 					}
586 586
 
587 587
 					$filter_args = array();
588 588
 
589
-					switch ( $condition['condition'] ) {
589
+					switch ($condition['condition']) {
590 590
 
591 591
 						case '=':
592
-							$filter_args[ $condition['field'] ] = $condition['value'];
592
+							$filter_args[$condition['field']] = $condition['value'];
593 593
 							break;
594 594
 
595 595
 						case 'in':
596 596
 							// TODO
597 597
 
598 598
 						default:
599
-							return new WP_Error( 'invalid condition type' );
599
+							return new WP_Error('invalid condition type');
600 600
 					}
601 601
 //var_dump( $filter_args );exit;
602
-					$this->array = wp_list_filter( $this->array, $filter_args );
602
+					$this->array = wp_list_filter($this->array, $filter_args);
603 603
 				}
604 604
 			}
605 605
 
@@ -607,9 +607,9 @@  discard block
 block discarded – undo
607 607
 //				$builder->add_field( $arg_data['select'] );
608 608
 //			}
609 609
 
610
-			if ( isset( $arg_data['sub_args'] ) ) {
610
+			if (isset($arg_data['sub_args'])) {
611 611
 				$this->parent_data = $arg_data;
612
-				$this->array = $this->execute( $arg_data['sub_args'] );
612
+				$this->array = $this->execute($arg_data['sub_args']);
613 613
 			}
614 614
 
615 615
 			$this->results = $this->array;
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	}
620 620
 }
621 621
 
622
-wordpoints_hooks()->retroactive_query_executors->register( 'array', 'WordPoints_Hook_Retroactive_Query_Executor_Array' );
622
+wordpoints_hooks()->retroactive_query_executors->register('array', 'WordPoints_Hook_Retroactive_Query_Executor_Array');
623 623
 
624 624
 class WordPoints_Hook_Retroactive_Query_Executor_MySQL
625 625
 	implements WordPoints_Hook_Retroactive_Query_ExecutorI {
@@ -638,86 +638,86 @@  discard block
 block discarded – undo
638 638
 
639 639
 	protected $entered_join;
640 640
 
641
-	public function execute( $query ) {
641
+	public function execute($query) {
642 642
 		// WE should be getting a hierarchy object here.
643 643
 		// This will let us loop over things easier.
644 644
 		// We'll also need to be marking the non-usable parts of the query.
645 645
 		// We'll need to test that as well.
646
-		var_dump( __METHOD__, $query );//exit;
646
+		var_dump(__METHOD__, $query); //exit;
647 647
 
648 648
 		global $wpdb;
649 649
 
650 650
 		$this->builder = new WordPoints_Query_Builder_DB_MySQL();
651 651
 
652
-		$this->build_query( $query );
652
+		$this->build_query($query);
653 653
 
654 654
 		$sql = $this->builder->get_query();
655 655
 
656
-		if ( is_wp_error( $sql ) ) {
656
+		if (is_wp_error($sql)) {
657 657
 			return $sql;
658 658
 		}
659
-var_dump( $sql );
660
-		return $wpdb->get_results( $sql );
659
+var_dump($sql);
660
+		return $wpdb->get_results($sql);
661 661
 	}
662 662
 
663
-	protected function build_query( $args ) {
664
-var_dump( __METHOD__, isset($this->grandparent_data['slug'])?$this->grandparent_data['slug']:null,  isset($this->parent_data['slug'])?$this->parent_data['slug']:null);
665
-		foreach ( $args as $arg_data ) {
666
-var_dump( $arg_data['slug'] );
663
+	protected function build_query($args) {
664
+var_dump(__METHOD__, isset($this->grandparent_data['slug']) ? $this->grandparent_data['slug'] : null, isset($this->parent_data['slug']) ? $this->parent_data['slug'] : null);
665
+		foreach ($args as $arg_data) {
666
+var_dump($arg_data['slug']);
667 667
 			$this->arg_data = $arg_data;
668 668
 
669
-			if ( isset( $arg_data['storage_info']['meta']['table_name'] ) ) {
670
-				$this->build_table_schema( $arg_data['storage_info']['meta'] );
669
+			if (isset($arg_data['storage_info']['meta']['table_name'])) {
670
+				$this->build_table_schema($arg_data['storage_info']['meta']);
671 671
 			}
672 672
 //var_dump(  $arg_data['conditions']  );
673
-			if ( isset( $arg_data['conditions'] ) ) {
674
-				$this->build_conditions( $arg_data['conditions'] );
673
+			if (isset($arg_data['conditions'])) {
674
+				$this->build_conditions($arg_data['conditions']);
675 675
 			}
676 676
 
677
-			if ( isset( $arg_data['select'] ) ) {
678
-				$this->builder->add_field( $arg_data['select'] );
677
+			if (isset($arg_data['select'])) {
678
+				$this->builder->add_field($arg_data['select']);
679 679
 			}
680 680
 
681
-			if ( isset( $arg_data['sub_args'] ) ) {
682
-var_dump( array_keys( $arg_data['sub_args']));
681
+			if (isset($arg_data['sub_args'])) {
682
+var_dump(array_keys($arg_data['sub_args']));
683 683
 				$this->grandparent_data = $this->parent_data;
684 684
 				$this->parent_data = $arg_data;
685 685
 
686
-				$this->build_query( $arg_data['sub_args'] );
686
+				$this->build_query($arg_data['sub_args']);
687 687
 
688 688
 				$this->parent_data = $this->grandparent_data;
689 689
 			}
690 690
 
691
-			if ( isset( $this->entered_join ) ) {
691
+			if (isset($this->entered_join)) {
692 692
 				$this->builder->exit_join();
693 693
 				$this->entered_join = null;
694
-				var_dump( '******** exit join *****' );
694
+				var_dump('******** exit join *****');
695 695
 			}
696 696
 		}
697 697
 	}
698 698
 
699
-	protected function build_table_schema( $db ) {
699
+	protected function build_table_schema($db) {
700 700
 
701
-		if ( $this->builder->get_table() ) {
701
+		if ($this->builder->get_table()) {
702 702
 
703
-			if ( $this->parent_data['arg'] instanceof WordPoints_Entity_Relationship ) {
703
+			if ($this->parent_data['arg'] instanceof WordPoints_Entity_Relationship) {
704 704
 				$primary_field = $this->parent_data['storage_info']['meta']['field'];
705 705
 				$join_field = $db['id_field'];
706 706
 				//$primary_field = $this->arg_data['arg']->get_secondary_field();
707
-			} elseif ( $this->arg_data['arg'] instanceof WordPoints_Entity_Relationship ) {
707
+			} elseif ($this->arg_data['arg'] instanceof WordPoints_Entity_Relationship) {
708 708
 				$join_field = $db['join_field'];
709 709
 				$primary_field = $this->parent_data['storage_info']['meta']['id_field'];
710 710
 			} else {
711
-				var_dump( $this->parent_data['arg'],$this->arg_data['arg'], $this->builder);
712
-				throw new WordPoints_Query_Builder_Exception( 'Houston, we have a problem.' );
711
+				var_dump($this->parent_data['arg'], $this->arg_data['arg'], $this->builder);
712
+				throw new WordPoints_Query_Builder_Exception('Houston, we have a problem.');
713 713
 			}
714 714
 
715
-			if ( is_array( $primary_field ) && isset( $primary_field['table_name'] ) ) {
716
-				$this->builder->enter_join( $primary_field );
715
+			if (is_array($primary_field) && isset($primary_field['table_name'])) {
716
+				$this->builder->enter_join($primary_field);
717 717
 				$primary_field = $primary_field['on']['join_field'];
718 718
 			}
719 719
 
720
-var_dump( __METHOD__, $db, $primary_field, $this->parent_data['arg'],$this->arg_data['arg'] );
720
+var_dump(__METHOD__, $db, $primary_field, $this->parent_data['arg'], $this->arg_data['arg']);
721 721
 
722 722
 			$join = array(
723 723
 				'table_name' => $db['table_name'],
@@ -727,28 +727,28 @@  discard block
 block discarded – undo
727 727
 				),
728 728
 			);
729 729
 
730
-			if ( isset( $db['join_where'] ) ) {
730
+			if (isset($db['join_where'])) {
731 731
 				$join['where'] = $db['join_where'];
732 732
 			}
733 733
 
734
-			$this->builder->enter_join( $join );
734
+			$this->builder->enter_join($join);
735 735
 
736 736
 			$this->entered_join = true;
737
-			var_dump( '******** enter join *****' );
737
+			var_dump('******** enter join *****');
738 738
 
739 739
 		} else {
740
-			$this->builder->set_table( $db['table_name'] );
741
-			$this->builder->add_field( $db['id_field'] );
740
+			$this->builder->set_table($db['table_name']);
741
+			$this->builder->add_field($db['id_field']);
742 742
 		}
743 743
 	}
744 744
 
745
-	protected function build_conditions( $conditions ) {
745
+	protected function build_conditions($conditions) {
746 746
 
747 747
 		// Join conditions should be pushed to the end.
748 748
 		$join_conditions = array();
749 749
 
750
-		foreach ( $conditions as $condition ) {
751
-			var_dump( __METHOD__, $condition);
750
+		foreach ($conditions as $condition) {
751
+			var_dump(__METHOD__, $condition);
752 752
 
753 753
 			// THis needs to be the identifier field for the type of arg that this
754 754
 			// field represents.
@@ -756,43 +756,43 @@  discard block
 block discarded – undo
756 756
 			// However, for a relationship it could be something else.
757 757
 			// Ultimately, this will have to be left up to the arg object to
758 758
 			// decide.
759
-			if ( ! isset( $condition['field'] ) ) {
760
-				if ( $this->arg_data['arg'] instanceof WordPoints_Entity_Relationship ) {
759
+			if ( ! isset($condition['field'])) {
760
+				if ($this->arg_data['arg'] instanceof WordPoints_Entity_Relationship) {
761 761
 //					$condition['field'] = $this->arg_data['arg']->get_secondary_field();
762 762
 					$condition['field'] = $this->arg_data['storage_info']['meta']['field'];
763 763
 
764
-					if ( is_array( $condition['field'] && isset( $condition['field']['table_name'] ) ) ) {
764
+					if (is_array($condition['field'] && isset($condition['field']['table_name']))) {
765 765
 						$join_conditions[] = $condition;
766 766
 						continue;
767 767
 					}
768
-				} elseif ( $this->arg_data['arg'] instanceof WordPoints_Entity_Attr ) {
768
+				} elseif ($this->arg_data['arg'] instanceof WordPoints_Entity_Attr) {
769 769
 					$condition['field'] = $this->arg_data['arg']->get_field();
770 770
 				} else {
771
-					var_dump($this->arg_data['arg']);exit;
771
+					var_dump($this->arg_data['arg']); exit;
772 772
 				}
773 773
 			}
774
-var_dump(  $condition);
775
-			$this->builder->where( $condition );
774
+var_dump($condition);
775
+			$this->builder->where($condition);
776 776
 		}
777 777
 
778
-		$join_count = count( $join_conditions );
778
+		$join_count = count($join_conditions);
779 779
 		$i = 0;
780 780
 
781
-		foreach ( $join_conditions as $condition ) {
781
+		foreach ($join_conditions as $condition) {
782 782
 
783 783
 			$i++;
784
-var_dump( $condition );
785
-			$this->builder->enter_join( $condition['field'] );
784
+var_dump($condition);
785
+			$this->builder->enter_join($condition['field']);
786 786
 
787 787
 			$condition['field'] = $condition['field']['on']['primary_field'];
788 788
 
789
-			$this->builder->where( $condition );
789
+			$this->builder->where($condition);
790 790
 
791 791
 			$this->builder->exit_join();
792 792
 
793 793
 			// If there are more join conditions, we need to leave a fresh, trailing
794 794
 			// join for the next one to join to.
795
-			if ( $i < $join_count ) {
795
+			if ($i < $join_count) {
796 796
 
797 797
 				// There is a current join, but it is already being used, so we
798 798
 				// need to exit it.
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 }
809 809
 
810 810
 
811
-wordpoints_hooks()->retroactive_query_executors->register( 'db', 'WordPoints_Hook_Retroactive_Query_Executor_MySQL' );
811
+wordpoints_hooks()->retroactive_query_executors->register('db', 'WordPoints_Hook_Retroactive_Query_Executor_MySQL');
812 812
 
813 813
 
814 814
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/settings.php 2 patches
Doc Comments   +20 added lines patch added patch discarded remove patch
@@ -8,12 +8,32 @@
 block discarded – undo
8 8
  */
9 9
 
10 10
 interface WordPoints_Hook_Reaction_SettingI {
11
+
12
+	/**
13
+	 * @return void
14
+	 */
11 15
 	public function __construct( $slug );
16
+
17
+	/**
18
+	 * @return string
19
+	 */
12 20
 	public function get_type();
21
+
22
+	/**
23
+	 * @return string
24
+	 */
13 25
 	public function get_label();
26
+
27
+	/**
28
+	 * @return boolean
29
+	 */
14 30
 	public function is_required();
15 31
 	public function get( WordPoints_Hook_ReactionI $reaction );
16 32
 	public function validate( $value, WordPoints_Hook_Reaction_Validator $validator );
33
+
34
+	/**
35
+	 * @return void
36
+	 */
17 37
 	public function save( $value, WordPoints_Hook_ReactionI $reaction, $is_new );
18 38
 }
19 39
 
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 interface WordPoints_Hook_Reaction_SettingI {
11
-	public function __construct( $slug );
11
+	public function __construct($slug);
12 12
 	public function get_type();
13 13
 	public function get_label();
14 14
 	public function is_required();
15
-	public function get( WordPoints_Hook_ReactionI $reaction );
16
-	public function validate( $value, WordPoints_Hook_Reaction_Validator $validator );
17
-	public function save( $value, WordPoints_Hook_ReactionI $reaction, $is_new );
15
+	public function get(WordPoints_Hook_ReactionI $reaction);
16
+	public function validate($value, WordPoints_Hook_Reaction_Validator $validator);
17
+	public function save($value, WordPoints_Hook_ReactionI $reaction, $is_new);
18 18
 }
19 19
 
20 20
 class WordPoints_Hook_Reaction_Setting implements WordPoints_Hook_Reaction_SettingI {
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	protected $type = 'hidden';
24 24
 	protected $required = true;
25 25
 
26
-	public function __construct( $slug ) {
26
+	public function __construct($slug) {
27 27
 		$this->slug = $slug;
28 28
 	}
29 29
 
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
 		return $this->required;
40 40
 	}
41 41
 
42
-	public function get( WordPoints_Hook_ReactionI $reaction ) {
43
-		return $reaction->get_meta( $this->slug );
42
+	public function get(WordPoints_Hook_ReactionI $reaction) {
43
+		return $reaction->get_meta($this->slug);
44 44
 	}
45 45
 
46
-	public function validate( $value, WordPoints_Hook_Reaction_Validator $validator ) {
46
+	public function validate($value, WordPoints_Hook_Reaction_Validator $validator) {
47 47
 
48
-		if ( $this->is_required() && '' === trim( $value ) ) {
48
+		if ($this->is_required() && '' === trim($value)) {
49 49
 
50 50
 			$validator->add_error(
51 51
 				sprintf(
52
-					__( '%s cannot be empty.', 'wordpoints' )
52
+					__('%s cannot be empty.', 'wordpoints')
53 53
 					, $this->get_label()
54 54
 				)
55 55
 				, $this->slug
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 		return $value;
60 60
 	}
61 61
 
62
-	public function save( $value, WordPoints_Hook_ReactionI $reaction, $is_new ) {
63
-		$reaction->update_meta( $this->slug, $value );
62
+	public function save($value, WordPoints_Hook_ReactionI $reaction, $is_new) {
63
+		$reaction->update_meta($this->slug, $value);
64 64
 	}
65 65
 }
66 66
 //
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 
83 83
 		$fields = array();
84 84
 
85
-		foreach ( $this->settings as $slug => $class ) {
85
+		foreach ($this->settings as $slug => $class) {
86 86
 
87 87
 			/** @var WordPoints_Hook_Reaction_SettingI $setting */
88
-			$setting = new $class( $slug );
88
+			$setting = new $class($slug);
89 89
 
90
-			$fields[ $slug ] = array(
90
+			$fields[$slug] = array(
91 91
 				'type' => $setting->get_type(),
92 92
 				'label' => $setting->get_label(),
93 93
 				'required' => $setting->is_required(),
@@ -97,29 +97,29 @@  discard block
 block discarded – undo
97 97
 		return $fields;
98 98
 	}
99 99
 
100
-	public function save_settings( $reaction, $settings, $is_new ) {
100
+	public function save_settings($reaction, $settings, $is_new) {
101 101
 
102
-		foreach ( $this->settings as $slug => $class ) {
102
+		foreach ($this->settings as $slug => $class) {
103 103
 
104 104
 			/** @var WordPoints_Hook_Reaction_SettingI $setting */
105
-			$setting = new $class( $slug );
105
+			$setting = new $class($slug);
106 106
 
107
-			$value = isset( $settings[ $slug ] ) ? $settings[ $slug ] : null;
107
+			$value = isset($settings[$slug]) ? $settings[$slug] : null;
108 108
 
109
-			$setting->save( $value, $reaction, $is_new );
109
+			$setting->save($value, $reaction, $is_new);
110 110
 		}
111 111
 	}
112 112
 
113
-	public function validate_settings( $settings, $validator ) {
113
+	public function validate_settings($settings, $validator) {
114 114
 
115
-		foreach ( $this->settings as $slug => $class ) {
115
+		foreach ($this->settings as $slug => $class) {
116 116
 
117 117
 			/** @var WordPoints_Hook_Reaction_SettingI $setting */
118
-			$setting = new $class( $slug );
118
+			$setting = new $class($slug);
119 119
 
120
-			$value = isset( $settings[ $slug ] ) ? $settings[ $slug ] : null;
120
+			$value = isset($settings[$slug]) ? $settings[$slug] : null;
121 121
 
122
-			$settings[ $slug ] = $setting->validate( $value, $validator );
122
+			$settings[$slug] = $setting->validate($value, $validator);
123 123
 		}
124 124
 
125 125
 		return $settings;
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
  *
134 134
  * @param WordPoints_Hooks $hooks
135 135
  */
136
-function wordpoints_hook_settings_app( $hooks ) {
137
-	$hooks->sub_apps->register( 'settings', 'WordPoints_Hook_Settings' );
136
+function wordpoints_hook_settings_app($hooks) {
137
+	$hooks->sub_apps->register('settings', 'WordPoints_Hook_Settings');
138 138
 }
139
-add_action( 'wordpoints_hooks_init', 'wordpoints_hook_settings_app' );
139
+add_action('wordpoints_hooks_init', 'wordpoints_hook_settings_app');
140 140
 
141 141
 /**
142 142
  *
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
  *
146 146
  * @param WordPoints_Hook_Settings $settings
147 147
  */
148
-function wordpoints_register_hook_settings( $settings ) {
148
+function wordpoints_register_hook_settings($settings) {
149 149
 
150
-	add_action( 'wordpoints_hook_reaction_save', array( $settings, 'save_settings' ), 10, 3 );
151
-	add_filter( 'wordpoints_hook_reaction_validate', array( $settings, 'validate_settings' ), 10, 2 );
150
+	add_action('wordpoints_hook_reaction_save', array($settings, 'save_settings'), 10, 3);
151
+	add_filter('wordpoints_hook_reaction_validate', array($settings, 'validate_settings'), 10, 2);
152 152
 
153
-	$settings->register( 'description', 'WordPoints_Hook_Reaction_Setting_Description' );
153
+	$settings->register('description', 'WordPoints_Hook_Reaction_Setting_Description');
154 154
 }
155
-add_action( 'wordpoints_hook_settings_init', 'wordpoints_register_hook_settings' );
155
+add_action('wordpoints_hook_settings_init', 'wordpoints_register_hook_settings');
156 156
 
157 157
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/query/builder/db/mysql.php 2 patches
Doc Comments   +24 added lines patch added patch discarded remove patch
@@ -9,12 +9,36 @@
 block discarded – undo
9 9
 
10 10
 
11 11
 interface WordPoints_Query_BuilderI {
12
+
13
+	/**
14
+	 * @return void
15
+	 */
12 16
 	public function set_fields( $fields );
17
+
18
+	/**
19
+	 * @return void
20
+	 */
13 21
 	public function add_field( $field );
22
+
23
+	/**
24
+	 * @return void
25
+	 */
14 26
 	public function set_table( $table_name );
15 27
 	public function get_table();
28
+
29
+	/**
30
+	 * @return void
31
+	 */
16 32
 	public function enter_join( $join );
33
+
34
+	/**
35
+	 * @return void
36
+	 */
17 37
 	public function exit_join();
38
+
39
+	/**
40
+	 * @return void
41
+	 */
18 42
 	public function where( $condition );
19 43
 	public function get_query();
20 44
 }
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
 
10 10
 
11 11
 interface WordPoints_Query_BuilderI {
12
-	public function set_fields( $fields );
13
-	public function add_field( $field );
14
-	public function set_table( $table_name );
12
+	public function set_fields($fields);
13
+	public function add_field($field);
14
+	public function set_table($table_name);
15 15
 	public function get_table();
16
-	public function enter_join( $join );
16
+	public function enter_join($join);
17 17
 	public function exit_join();
18
-	public function where( $condition );
18
+	public function where($condition);
19 19
 	public function get_query();
20 20
 }
21 21
 
@@ -33,55 +33,55 @@  discard block
 block discarded – undo
33 33
 	protected $aliases = array();
34 34
 
35 35
 	public function __construct() {
36
-		$this->query = new WordPoints_Hierarchy( 'joins' );
37
-		$this->query->push( '', array() );
36
+		$this->query = new WordPoints_Hierarchy('joins');
37
+		$this->query->push('', array());
38 38
 	}
39 39
 
40
-	public function set_fields( $fields ) {
41
-		$this->query->set_field( 'fields', $fields );
40
+	public function set_fields($fields) {
41
+		$this->query->set_field('fields', $fields);
42 42
 	}
43 43
 
44
-	public function add_field( $field ) {
45
-		$this->query->push_to( 'fields', $field );
44
+	public function add_field($field) {
45
+		$this->query->push_to('fields', $field);
46 46
 	}
47 47
 
48
-	public function set_table( $table_name ) {
49
-		$this->query->set_field( 'table_name',  $table_name );
48
+	public function set_table($table_name) {
49
+		$this->query->set_field('table_name', $table_name);
50 50
 	}
51 51
 
52 52
 	public function get_table() {
53
-		return $this->query->get_field( 'table_name' );
53
+		return $this->query->get_field('table_name');
54 54
 	}
55 55
 
56
-	protected function get_alias( $data ) {
56
+	protected function get_alias($data) {
57 57
 
58
-		if ( ! isset( $this->aliases[ $data['table_name'] ] ) ) {
59
-			$this->aliases[ $data['table_name'] ] = 0;
58
+		if ( ! isset($this->aliases[$data['table_name']])) {
59
+			$this->aliases[$data['table_name']] = 0;
60 60
 		}
61 61
 
62
-		return $data['table_name'] . '_' . ++$this->aliases[ $data['table_name'] ];
62
+		return $data['table_name'].'_'.++$this->aliases[$data['table_name']];
63 63
 	}
64 64
 
65
-	public function enter_join( $join ) {
66
-		$alias = $this->get_alias( $join );
67
-		$this->query->push( $alias, $join );
65
+	public function enter_join($join) {
66
+		$alias = $this->get_alias($join);
67
+		$this->query->push($alias, $join);
68 68
 	}
69 69
 
70 70
 	public function exit_join() {
71 71
 		$this->query->pop();
72 72
 	}
73 73
 
74
-	public function where( $condition ) {
74
+	public function where($condition) {
75 75
 
76
-		$where = $this->query->get_field( 'where' );
76
+		$where = $this->query->get_field('where');
77 77
 
78
-		if ( ! is_array( $where ) ) {
78
+		if ( ! is_array($where)) {
79 79
 			$where = array();
80 80
 		}
81 81
 
82 82
 		$where[] = $condition;
83 83
 
84
-		$this->query->set_field( 'where', $where );
84
+		$this->query->set_field('where', $where);
85 85
 	}
86 86
 }
87 87
 
@@ -101,64 +101,64 @@  discard block
 block discarded – undo
101 101
 
102 102
 		var_dump($this->query);
103 103
 		try {
104
-			$this->build_query( $this->query->get() );
105
-		} catch ( WordPoints_Query_Builder_Exception $e ) {
106
-			return new WP_Error( $e->getMessage(), $e->getTraceAsString() );
104
+			$this->build_query($this->query->get());
105
+		} catch (WordPoints_Query_Builder_Exception $e) {
106
+			return new WP_Error($e->getMessage(), $e->getTraceAsString());
107 107
 		}
108 108
 
109 109
 		return $this->sql;
110 110
 	}
111 111
 
112
-	protected function build_query( $query ) {
112
+	protected function build_query($query) {
113 113
 
114
-		var_dump( __METHOD__, $query );
114
+		var_dump(__METHOD__, $query);
115 115
 
116
-		$this->alias = $this->get_alias( $query );
116
+		$this->alias = $this->get_alias($query);
117 117
 
118
-		$this->build_fields( $query );
119
-		$this->build_from( $query );
120
-		$this->build_joins( $query );
121
-		$this->build_where( $query );
118
+		$this->build_fields($query);
119
+		$this->build_from($query);
120
+		$this->build_joins($query);
121
+		$this->build_where($query);
122 122
 		$this->build_select();
123 123
 	}
124 124
 
125 125
 	protected function build_select() {
126 126
 
127
-		if ( empty( $this->fields ) ) {
128
-			throw new WordPoints_Query_Builder_Exception( 'no fields' );
127
+		if (empty($this->fields)) {
128
+			throw new WordPoints_Query_Builder_Exception('no fields');
129 129
 		}
130 130
 
131
-		$this->sql = 'SELECT' . $this->fields . $this->sql;
131
+		$this->sql = 'SELECT'.$this->fields.$this->sql;
132 132
 	}
133 133
 
134
-	protected function build_fields( $query ) {
134
+	protected function build_fields($query) {
135 135
 
136
-		if ( empty( $query['fields'] ) ) {
136
+		if (empty($query['fields'])) {
137 137
 			return;
138 138
 		}
139 139
 
140
-		foreach ( $query['fields'] as $field ) {
140
+		foreach ($query['fields'] as $field) {
141 141
 
142
-			if ( ! is_array( $field ) ) {
143
-				$field = array( 'field' => $field );
142
+			if ( ! is_array($field)) {
143
+				$field = array('field' => $field);
144 144
 			}
145 145
 
146
-			if ( ! isset( $field['field'] ) ) {
147
-				throw new WordPoints_Query_Builder_Exception( 'invalid field' );
146
+			if ( ! isset($field['field'])) {
147
+				throw new WordPoints_Query_Builder_Exception('invalid field');
148 148
 			}
149 149
 
150
-			if ( ! empty( $this->fields ) ) {
150
+			if ( ! empty($this->fields)) {
151 151
 				$this->fields .= ',';
152 152
 			}
153 153
 
154
-			$this->fields .= ' ' . $this->build_field( $field['field'] );
154
+			$this->fields .= ' '.$this->build_field($field['field']);
155 155
 
156 156
 			$as = $field['field'];
157
-			if ( isset( $field['as'] ) ) {
157
+			if (isset($field['as'])) {
158 158
 				$as = $field['as'];
159 159
 			}
160 160
 
161
-			$this->fields .= ' AS `' . $this->escape_identifier( $as ) . '`';
161
+			$this->fields .= ' AS `'.$this->escape_identifier($as).'`';
162 162
 		}
163 163
 	}
164 164
 
@@ -171,118 +171,118 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @throws WordPoints_Query_Builder_Exception
173 173
 	 */
174
-	protected function build_field( $field ) {
174
+	protected function build_field($field) {
175 175
 
176
-		$field_name = $this->get_field_name( $field );
176
+		$field_name = $this->get_field_name($field);
177 177
 
178
-		$sql = '`' . $this->escape_identifier( $this->alias ) . '`';
179
-		$sql .= '.`' . $this->escape_identifier( $field_name ) . '`';
178
+		$sql = '`'.$this->escape_identifier($this->alias).'`';
179
+		$sql .= '.`'.$this->escape_identifier($field_name).'`';
180 180
 
181 181
 		return $sql;
182 182
 	}
183 183
 
184
-	protected function build_from( $query ) {
184
+	protected function build_from($query) {
185 185
 
186
-		if ( ! isset( $query['table_name'] ) ) {
187
-			throw new WordPoints_Query_Builder_Exception( 'table_name' );
186
+		if ( ! isset($query['table_name'])) {
187
+			throw new WordPoints_Query_Builder_Exception('table_name');
188 188
 		}
189 189
 
190 190
 		$this->sql .= "\n";
191
-		$this->sql .= 'FROM `' . $this->escape_identifier( $query['table_name'] ) . '`';
192
-		$this->sql .= ' AS `' . $this->escape_identifier( $this->alias ) . '`';
191
+		$this->sql .= 'FROM `'.$this->escape_identifier($query['table_name']).'`';
192
+		$this->sql .= ' AS `'.$this->escape_identifier($this->alias).'`';
193 193
 	}
194 194
 
195
-	protected function build_joins( $query ) {
195
+	protected function build_joins($query) {
196 196
 
197
-		if ( ! isset( $query['joins'] ) ) {
197
+		if ( ! isset($query['joins'])) {
198 198
 			return;
199 199
 		}
200 200
 
201
-		foreach ( $query['joins'] as $join ) {
202
-			$this->build_join( $join );
201
+		foreach ($query['joins'] as $join) {
202
+			$this->build_join($join);
203 203
 		}
204 204
 	}
205 205
 
206
-	protected function build_join( $join ) {
206
+	protected function build_join($join) {
207 207
 
208
-		if ( ! isset( $join['table_name'] ) ) {
209
-			throw new WordPoints_Query_Builder_Exception( 'join table_name' );
208
+		if ( ! isset($join['table_name'])) {
209
+			throw new WordPoints_Query_Builder_Exception('join table_name');
210 210
 		}
211 211
 
212
-		if ( ! isset( $join['on'] ) ) {
213
-			throw new WordPoints_Query_Builder_Exception( 'join on' );
212
+		if ( ! isset($join['on'])) {
213
+			throw new WordPoints_Query_Builder_Exception('join on');
214 214
 		}
215 215
 
216
-		if ( ! isset( $join['on']['join_field'] ) ) {
217
-			throw new WordPoints_Query_Builder_Exception( 'join on join_field' );
216
+		if ( ! isset($join['on']['join_field'])) {
217
+			throw new WordPoints_Query_Builder_Exception('join on join_field');
218 218
 		}
219 219
 
220
-		if ( ! isset( $join['on']['primary_field'] ) ) {
221
-			throw new WordPoints_Query_Builder_Exception( 'join on primary_field' );
220
+		if ( ! isset($join['on']['primary_field'])) {
221
+			throw new WordPoints_Query_Builder_Exception('join on primary_field');
222 222
 		}
223 223
 
224
-		$alias = $this->get_alias( $join );
224
+		$alias = $this->get_alias($join);
225 225
 
226 226
 		$this->sql .= "\n";
227
-		$this->sql .= 'INNER JOIN `' . $this->escape_identifier( $join['table_name'] ) . '`';
228
-		$this->sql .= ' AS `' . $this->escape_identifier( $alias ) . '`';
229
-		$this->sql .= "\n\t" . 'ON ' . $this->build_field( $join['on']['primary_field'] );
227
+		$this->sql .= 'INNER JOIN `'.$this->escape_identifier($join['table_name']).'`';
228
+		$this->sql .= ' AS `'.$this->escape_identifier($alias).'`';
229
+		$this->sql .= "\n\t".'ON '.$this->build_field($join['on']['primary_field']);
230 230
 
231 231
 		$old_alias = $this->alias;
232 232
 		$this->alias = $alias;
233 233
 
234
-		$this->sql .= ' = ' . $this->build_field( $join['on']['join_field'] );
234
+		$this->sql .= ' = '.$this->build_field($join['on']['join_field']);
235 235
 
236
-		$this->build_fields( $join );
236
+		$this->build_fields($join);
237 237
 
238
-		if ( isset( $join['where'] ) ) {
239
-			foreach ( $join['where'] as $condition ) {
240
-				$this->build_condition( $condition );
238
+		if (isset($join['where'])) {
239
+			foreach ($join['where'] as $condition) {
240
+				$this->build_condition($condition);
241 241
 			}
242 242
 		}
243 243
 
244
-		$this->build_joins( $join );
244
+		$this->build_joins($join);
245 245
 
246 246
 		$this->alias = $old_alias;
247 247
 	}
248 248
 
249
-	protected function build_where( $query ) {
249
+	protected function build_where($query) {
250 250
 
251
-		if ( empty( $query['where'] ) ) {
251
+		if (empty($query['where'])) {
252 252
 			return;
253 253
 		}
254 254
 
255 255
 		$this->sql .= "\n";
256 256
 		$this->sql .= 'WHERE 1=1';
257 257
 
258
-		foreach ( $query['where'] as $condition ) {
259
-			$this->build_condition( $condition );
258
+		foreach ($query['where'] as $condition) {
259
+			$this->build_condition($condition);
260 260
 		}
261 261
 	}
262 262
 
263
-	protected function build_condition( $condition ) {
263
+	protected function build_condition($condition) {
264 264
 
265 265
 		global $wpdb;
266 266
 
267
-		if ( ! isset( $condition['field'], $condition['value'] ) ) {
267
+		if ( ! isset($condition['field'], $condition['value'])) {
268 268
 			var_dump($condition);
269
-			throw new WordPoints_Query_Builder_Exception( 'bad condition' );
269
+			throw new WordPoints_Query_Builder_Exception('bad condition');
270 270
 		}
271 271
 
272
-		if ( ! isset( $condition['compare'] ) ) {
272
+		if ( ! isset($condition['compare'])) {
273 273
 			$condition['compare'] = '=';
274 274
 		}
275 275
 
276 276
 		$this->sql .= "\n\t";
277 277
 
278
-		$this->build_condition_type( $condition );
278
+		$this->build_condition_type($condition);
279 279
 
280
-		$field_type = $this->get_field_type( $condition['field'] );
281
-		if ( 'serialized_array' === $field_type ) {
282
-			if ( is_array( $condition['value'] ) ) {
283
-				if ( isset( $condition['compare'] ) && 'in' === $condition['compare'] ) {
280
+		$field_type = $this->get_field_type($condition['field']);
281
+		if ('serialized_array' === $field_type) {
282
+			if (is_array($condition['value'])) {
283
+				if (isset($condition['compare']) && 'in' === $condition['compare']) {
284 284
 					$this->sql .= '( 1=0 ';
285
-					foreach ( $condition['value'] as $index => $value ) {
285
+					foreach ($condition['value'] as $index => $value) {
286 286
 						$this->build_condition(
287 287
 							array(
288 288
 								'type' => 'or',
@@ -296,13 +296,13 @@  discard block
 block discarded – undo
296 296
 					return;
297 297
 				}
298 298
 			} else {
299
-				$condition['value'] = $this->serialize_value( $condition['value'] );
299
+				$condition['value'] = $this->serialize_value($condition['value']);
300 300
 			}
301 301
 		}
302 302
 
303
-		$this->sql .= $this->build_field( $condition['field'] );
303
+		$this->sql .= $this->build_field($condition['field']);
304 304
 
305
-		switch ( $condition['compare'] ) {
305
+		switch ($condition['compare']) {
306 306
 
307 307
 			case '=':
308 308
 				$this->sql .= ' = ';
@@ -313,18 +313,18 @@  discard block
 block discarded – undo
313 313
 				break;
314 314
 
315 315
 			case 'in':
316
-				$this->sql .= ' IN (' . wordpoints_prepare__in( $condition['value'] ) . ')';
316
+				$this->sql .= ' IN ('.wordpoints_prepare__in($condition['value']).')';
317 317
 				return;
318 318
 
319 319
 			default:
320
-				throw new WordPoints_Query_Builder_Exception( 'bad condition comparison' );
320
+				throw new WordPoints_Query_Builder_Exception('bad condition comparison');
321 321
 		}
322 322
 
323
-		if ( ! is_scalar( $condition['value'] ) ) {
324
-			throw new WordPoints_Query_Builder_Exception( 'bad condition value' );
323
+		if ( ! is_scalar($condition['value'])) {
324
+			throw new WordPoints_Query_Builder_Exception('bad condition value');
325 325
 		}
326 326
 
327
-		$this->sql .= $wpdb->prepare( '%s', $condition['value'] );
327
+		$this->sql .= $wpdb->prepare('%s', $condition['value']);
328 328
 	}
329 329
 
330 330
 	/**
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @throws WordPoints_Query_Builder_Exception
338 338
 	 */
339
-	protected function build_condition_type( $condition ) {
339
+	protected function build_condition_type($condition) {
340 340
 
341
-		if ( ! isset( $condition['type'] ) ) {
341
+		if ( ! isset($condition['type'])) {
342 342
 			$condition['type'] = 'and';
343 343
 		}
344 344
 
345
-		switch ( $condition['type'] ) {
345
+		switch ($condition['type']) {
346 346
 
347 347
 			case 'and':
348 348
 				$this->sql .= 'AND ';
@@ -353,21 +353,21 @@  discard block
 block discarded – undo
353 353
 				break;
354 354
 
355 355
 			default:
356
-				throw new WordPoints_Query_Builder_Exception( 'bad condition type' );
356
+				throw new WordPoints_Query_Builder_Exception('bad condition type');
357 357
 		}
358 358
 	}
359 359
 
360
-	protected function escape_identifier( $identifier ) {
360
+	protected function escape_identifier($identifier) {
361 361
 
362
-		return str_replace( '`', '``', $identifier );
362
+		return str_replace('`', '``', $identifier);
363 363
 	}
364 364
 
365
-	protected function get_field_name( $field ) {
365
+	protected function get_field_name($field) {
366 366
 
367
-		if ( is_array( $field ) ) {
367
+		if (is_array($field)) {
368 368
 
369
-			if ( ! isset( $field['name'] ) ) {
370
-				throw new WordPoints_Query_Builder_Exception( 'field name' );
369
+			if ( ! isset($field['name'])) {
370
+				throw new WordPoints_Query_Builder_Exception('field name');
371 371
 			}
372 372
 
373 373
 			$field = $field['name'];
@@ -376,22 +376,22 @@  discard block
 block discarded – undo
376 376
 		return $field;
377 377
 	}
378 378
 
379
-	protected function get_field_type( $field ) {
379
+	protected function get_field_type($field) {
380 380
 
381
-		if ( is_array( $field ) && isset( $field['type'] ) ) {
381
+		if (is_array($field) && isset($field['type'])) {
382 382
 			return $field['type'];
383 383
 		}
384 384
 
385 385
 		return 'string';
386 386
 	}
387 387
 
388
-	protected function serialize_value( $value ) {
388
+	protected function serialize_value($value) {
389 389
 
390
-		if ( is_string( $value ) ) {
391
-			$value = '"' . $value . '"';
390
+		if (is_string($value)) {
391
+			$value = '"'.$value.'"';
392 392
 		}
393 393
 
394
-		return '%:' . $value . ';%';
394
+		return '%:'.$value.';%';
395 395
 	}
396 396
 }
397 397
 
Please login to merge, or discard this patch.
src/includes/classes/spec.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -284,6 +284,9 @@
 block discarded – undo
284 284
 		return $entities;
285 285
 	}
286 286
 
287
+	/**
288
+	 * @param integer $count
289
+	 */
287 290
 	protected function check_count( $count ) {
288 291
 
289 292
 		if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) {
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 interface WordPoints_SpecI {
12 12
 	public function get_title();
13 13
 	public function get_settings_fields();
14
-	public function validate_settings( $settings );
14
+	public function validate_settings($settings);
15 15
 	public function is_met();
16
-	public function get_error( $name );
16
+	public function get_error($name);
17 17
 }
18 18
 
19 19
 abstract class WordPoints_Spec implements  WordPoints_SpecI {
@@ -25,38 +25,38 @@  discard block
 block discarded – undo
25 25
 	 * @param $value
26 26
 	 * @param $expected
27 27
 	 */
28
-	public function __construct( $value, $expected ) {
28
+	public function __construct($value, $expected) {
29 29
 		$this->value = $value;
30 30
 		$this->expected = $expected;
31 31
 	}
32 32
 
33
-	public function validate_settings( $settings ) {
33
+	public function validate_settings($settings) {
34 34
 
35 35
 		$data_types = wordpoints_apps()->data_types;
36 36
 
37
-		foreach ( $this->get_settings_fields() as $setting => $data ) {
37
+		foreach ($this->get_settings_fields() as $setting => $data) {
38 38
 
39
-			if ( ! isset( $settings[ $setting ] ) ) {
39
+			if ( ! isset($settings[$setting])) {
40 40
 
41
-				if ( ! empty( $data['required'] ) ) {
41
+				if ( ! empty($data['required'])) {
42 42
 					return 'error'; // TODO
43 43
 				}
44 44
 
45 45
 			} else {
46 46
 
47
-				$data_type = $data_types->get( $data['type'] );
47
+				$data_type = $data_types->get($data['type']);
48 48
 
49
-				if ( ! $data_type instanceof WordPoints_Data_TypeI ) {
49
+				if ( ! $data_type instanceof WordPoints_Data_TypeI) {
50 50
 					continue;
51 51
 				}
52 52
 
53
-				$value = $data_type->validate_value( $settings[ $setting ] );
53
+				$value = $data_type->validate_value($settings[$setting]);
54 54
 
55
-				if ( is_wp_error( $value ) ) {
55
+				if (is_wp_error($value)) {
56 56
 					return $value;
57 57
 				}
58 58
 
59
-				$settings[ $setting ] = $value;
59
+				$settings[$setting] = $value;
60 60
 			}
61 61
 		}
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 class WordPoints_Spec_Number_Max extends WordPoints_Spec {
68 68
 
69 69
 	public function get_title() {
70
-		return __( 'Maximum', 'wordpoints' );
70
+		return __('Maximum', 'wordpoints');
71 71
 	}
72 72
 
73 73
 	public function get_settings_fields() {
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 		return $this->value <= $this->expected;
86 86
 	}
87 87
 
88
-	public function get_error( $name ) {
88
+	public function get_error($name) {
89 89
 
90 90
 		return sprintf(
91
-			__( '%1$s must not be more than %2$s.', 'wordpoints' )
91
+			__('%1$s must not be more than %2$s.', 'wordpoints')
92 92
 			, $name
93 93
 			, $this->expected
94 94
 		);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 class WordPoints_Spec_String_Length_Max extends WordPoints_Spec {
99 99
 
100 100
 	public function get_title() {
101
-		return __( 'Maximum Length', 'wordpoints' );
101
+		return __('Maximum Length', 'wordpoints');
102 102
 	}
103 103
 
104 104
 	public function get_settings_fields() {
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 	}
113 113
 
114 114
 	public function is_met() {
115
-		return strlen( $this->value ) <= $this->expected;
115
+		return strlen($this->value) <= $this->expected;
116 116
 	}
117 117
 
118
-	public function get_error( $name ) {
118
+	public function get_error($name) {
119 119
 
120 120
 		return sprintf(
121
-			__( '%1$s must not be longer than %2$s characters.', 'wordpoints' )
121
+			__('%1$s must not be longer than %2$s characters.', 'wordpoints')
122 122
 			, $name
123 123
 			, $this->expected
124 124
 		);
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 class WordPoints_Spec_String_Contains extends WordPoints_Spec {
130 130
 
131 131
 	public function get_title() {
132
-		return __( 'Contains', 'wordpoints' );
132
+		return __('Contains', 'wordpoints');
133 133
 	}
134 134
 
135 135
 	public function get_settings_fields() {
136 136
 	}
137 137
 
138 138
 	public function is_met() {
139
-		return false !== strpos( $this->value, $this->expected );
139
+		return false !== strpos($this->value, $this->expected);
140 140
 	}
141 141
 
142
-	public function get_error( $name ) {
142
+	public function get_error($name) {
143 143
 
144 144
 		return sprintf(
145
-			__( '%1$s must contain "%2$s".', 'wordpoints' ) // TODO quotes
145
+			__('%1$s must contain "%2$s".', 'wordpoints') // TODO quotes
146 146
 			, $name
147 147
 			, $this->expected
148 148
 		);
@@ -165,19 +165,19 @@  discard block
 block discarded – undo
165 165
 	protected $validator;
166 166
 
167 167
 	public function get_title() {
168
-		return __( 'Contains', 'wordpoints' );
168
+		return __('Contains', 'wordpoints');
169 169
 	}
170 170
 
171 171
 	public function get_settings_fields() {
172 172
 		return array(
173 173
 			'min' => array(
174 174
 				'slug'  => 'min',
175
-				'label' => __( 'Minimum number of items', 'wordpoints' ),
175
+				'label' => __('Minimum number of items', 'wordpoints'),
176 176
 				'type'  => 'number',
177 177
 			),
178 178
 			'max' => array(
179 179
 				'slug'  => 'max',
180
-				'label' => __( 'Maximum number of items', 'wordpoints' ),
180
+				'label' => __('Maximum number of items', 'wordpoints'),
181 181
 				'type'  => 'number',
182 182
 			),
183 183
 		);
@@ -189,18 +189,18 @@  discard block
 block discarded – undo
189 189
 		WordPoints_Hook_Reaction_Validator $validator
190 190
 	) {
191 191
 
192
-		if ( ! $this->arg_type_supported( $arg, $validator ) ) {
192
+		if ( ! $this->arg_type_supported($arg, $validator)) {
193 193
 			return false;
194 194
 		}
195 195
 
196 196
 		$this->settings = $settings;
197 197
 		$this->validator = $validator;
198 198
 
199
-		if ( ! $this->validate_count() ) {
199
+		if ( ! $this->validate_count()) {
200 200
 			return false;
201 201
 		}
202 202
 
203
-		if ( isset( $settings['conditions'] ) ) {
203
+		if (isset($settings['conditions'])) {
204 204
 			$this->validate_conditions();
205 205
 		}
206 206
 
@@ -210,21 +210,21 @@  discard block
 block discarded – undo
210 210
 	protected function validate_count() {
211 211
 
212 212
 		if (
213
-			! empty( $this->settings['max'] )
214
-			&& ! wordpoints_posint( $this->settings['max'] )
213
+			! empty($this->settings['max'])
214
+			&& ! wordpoints_posint($this->settings['max'])
215 215
 		) {
216 216
 			$this->validator->add_error(
217
-				__( 'The maximum must be a positive integer.', 'wordpoints' )
217
+				__('The maximum must be a positive integer.', 'wordpoints')
218 218
 				, 'max'
219 219
 			);
220 220
 		}
221 221
 
222 222
 		if (
223
-			! empty( $this->settings['min'] )
224
-			&& ! wordpoints_posint( $this->settings['min'] )
223
+			! empty($this->settings['min'])
224
+			&& ! wordpoints_posint($this->settings['min'])
225 225
 		) {
226 226
 			$this->validator->add_error(
227
-				__( 'The minimum must be a positive integer.', 'wordpoints' )
227
+				__('The minimum must be a positive integer.', 'wordpoints')
228 228
 				, 'min'
229 229
 			);
230 230
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		);
240 240
 
241 241
 		$conditions = $conditions_extension->validate_settings(
242
-			array( 'conditions' => $this->settings['conditions'] )
242
+			array('conditions' => $this->settings['conditions'])
243 243
 			, $this->validator
244 244
 			, $this->validator->get_event_args()
245 245
 		);
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 
250 250
 	public function is_met() {
251 251
 
252
-		$entities = $this->filter_entities( $this->value );
252
+		$entities = $this->filter_entities($this->value);
253 253
 
254
-		return $this->check_count( count( $entities ) );
254
+		return $this->check_count(count($entities));
255 255
 	}
256 256
 
257 257
 	/**
@@ -263,41 +263,41 @@  discard block
 block discarded – undo
263 263
 	 *
264 264
 	 * @return WordPoints_Entity[]
265 265
 	 */
266
-	protected function filter_entities( $entities ) {
266
+	protected function filter_entities($entities) {
267 267
 
268 268
 		$conditions_extension = wordpoints_hooks()->extensions->get(
269 269
 			'conditions'
270 270
 		);
271 271
 
272
-		foreach ( $entities as $index => $entity ) {
272
+		foreach ($entities as $index => $entity) {
273 273
 
274 274
 			$matches = $conditions_extension->conditions_are_met(
275 275
 				$this->expected['conditions']
276
-				, new WordPoints_Hook_Event_Args( array( $entity ) )
276
+				, new WordPoints_Hook_Event_Args(array($entity))
277 277
 			);
278 278
 
279
-			if ( ! $matches ) {
280
-				unset( $entities[ $index ] );
279
+			if ( ! $matches) {
280
+				unset($entities[$index]);
281 281
 			}
282 282
 		}
283 283
 
284 284
 		return $entities;
285 285
 	}
286 286
 
287
-	protected function check_count( $count ) {
287
+	protected function check_count($count) {
288 288
 
289
-		if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) {
289
+		if (isset($this->settings['max']) && $count > $this->settings['max']) {
290 290
 			return false;
291 291
 		}
292 292
 
293
-		if ( isset( $this->settings['min'] ) && $count < $this->settings['min'] ) {
293
+		if (isset($this->settings['min']) && $count < $this->settings['min']) {
294 294
 			return false;
295 295
 		}
296 296
 
297 297
 		return true;
298 298
 	}
299 299
 
300
-	public function get_error( $name ) {
300
+	public function get_error($name) {
301 301
 		// TODO: Implement get_error() method.
302 302
 	}
303 303
 }
Please login to merge, or discard this patch.
src/admin/includes/classes/screen.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	public function hooks() {
63 63
 
64 64
 		/* Load the JavaScript needed for the settings screen. */
65
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
66
-		add_action( "admin_footer-{$this->id}", array( $this, 'footer_scripts' ) );
65
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
66
+		add_action("admin_footer-{$this->id}", array($this, 'footer_scripts'));
67 67
 	}
68 68
 
69 69
 	/**
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 
99 99
 		<div class="wrap">
100 100
 
101
-			<h1><?php echo esc_html( $this->get_title() ); ?></h1>
101
+			<h1><?php echo esc_html($this->get_title()); ?></h1>
102 102
 
103 103
 			<?php settings_errors(); ?>
104 104
 
105
-			<?php wordpoints_admin_show_tabs( $this->tabs, false ); ?>
105
+			<?php wordpoints_admin_show_tabs($this->tabs, false); ?>
106 106
 
107 107
 			<?php $this->display_content(); ?>
108 108
 
Please login to merge, or discard this patch.
src/admin/includes/classes/screen/points/types.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @since 1.0.0
57 57
 	 */
58 58
 	protected function get_title() {
59
-		return _x( 'Points Types', 'page title', 'wordpoints' );
59
+		return _x('Points Types', 'page title', 'wordpoints');
60 60
 	}
61 61
 
62 62
 	/**
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 
67 67
 		parent::hooks();
68 68
 
69
-		add_action( 'add_meta_boxes', array( $this, 'add_points_settings_meta_box' ) );
70
-		add_action( 'add_meta_boxes', array( $this, 'add_event_meta_boxes' ) );
69
+		add_action('add_meta_boxes', array($this, 'add_points_settings_meta_box'));
70
+		add_action('add_meta_boxes', array($this, 'add_event_meta_boxes'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function enqueue_scripts() {
77 77
 
78
-		wp_enqueue_style( 'wordpoints-hooks-admin' );
78
+		wp_enqueue_style('wordpoints-hooks-admin');
79 79
 
80
-		wp_enqueue_script( 'postbox' );
80
+		wp_enqueue_script('postbox');
81 81
 
82 82
 		wordpoints_hooks_ui_setup_script_data();
83 83
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 					.addClass( 'closed' );
98 98
 
99 99
 				postboxes.add_postbox_toggles(
100
-					<?php echo wp_json_encode( $this->id ); ?>
100
+					<?php echo wp_json_encode($this->id); ?>
101 101
 				);
102 102
 			} );
103 103
 		</script>
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function add_points_settings_meta_box() {
114 114
 
115
-		if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) {
115
+		if ( ! current_user_can('manage_wordpoints_points_types')) {
116 116
 			return;
117 117
 		}
118 118
 
119 119
 		add_meta_box(
120 120
 			'settings'
121
-			, __( 'Settings', 'wordpoints' )
122
-			, array( $this, 'display_points_settings_meta_box' )
121
+			, __('Settings', 'wordpoints')
122
+			, array($this, 'display_points_settings_meta_box')
123 123
 			, $this->id
124 124
 			, 'side'
125 125
 			, 'default'
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public function display_points_settings_meta_box() {
135 135
 
136
-		if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) {
136
+		if ( ! current_user_can('manage_wordpoints_points_types')) {
137 137
 			return;
138 138
 		}
139 139
 
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
 
142 142
 		$add_new = 0;
143 143
 
144
-		$points_type = wordpoints_get_points_type( $slug );
144
+		$points_type = wordpoints_get_points_type($slug);
145 145
 
146
-		if ( ! $points_type ) {
146
+		if ( ! $points_type) {
147 147
 
148 148
 			$points_type = array();
149
-			$add_new     = wp_create_nonce( 'wordpoints_add_new_points_type' );
149
+			$add_new     = wp_create_nonce('wordpoints_add_new_points_type');
150 150
 		}
151 151
 
152 152
 		$points_type = array_merge(
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 		?>
162 162
 
163 163
 		<form method="post">
164
-			<?php if ( $slug ) : ?>
164
+			<?php if ($slug) : ?>
165 165
 				<p>
166 166
 					<span class="wordpoints-points-slug">
167 167
 						<em>
168
-							<?php echo esc_html( sprintf( __( 'Slug: %s', 'wordpoints' ), $slug ) ); ?>
168
+							<?php echo esc_html(sprintf(__('Slug: %s', 'wordpoints'), $slug)); ?>
169 169
 						</em>
170 170
 					</span>
171 171
 				</p>
172
-				<?php wp_nonce_field( "wordpoints_update_points_type-$slug", 'update_points_type' ); ?>
172
+				<?php wp_nonce_field("wordpoints_update_points_type-$slug", 'update_points_type'); ?>
173 173
 			<?php endif; ?>
174 174
 
175 175
 			<?php
@@ -183,45 +183,45 @@  discard block
 block discarded – undo
183 183
 			 *
184 184
 			 * @param string $points_type The slug of the points type.
185 185
 			 */
186
-			do_action( 'wordpoints_points_type_form_top', $slug );
186
+			do_action('wordpoints_points_type_form_top', $slug);
187 187
 
188
-			if ( $add_new ) {
188
+			if ($add_new) {
189 189
 
190 190
 				// Mark the prefix and suffix optional on the add new form.
191
-				$prefix = _x( 'Prefix (optional):', 'points type', 'wordpoints' );
192
-				$suffix = _x( 'Suffix (optional):', 'points type', 'wordpoints' );
191
+				$prefix = _x('Prefix (optional):', 'points type', 'wordpoints');
192
+				$suffix = _x('Suffix (optional):', 'points type', 'wordpoints');
193 193
 
194 194
 			} else {
195 195
 
196
-				$prefix = _x( 'Prefix:', 'points type', 'wordpoints' );
197
-				$suffix = _x( 'Suffix:', 'points type', 'wordpoints' );
196
+				$prefix = _x('Prefix:', 'points type', 'wordpoints');
197
+				$suffix = _x('Suffix:', 'points type', 'wordpoints');
198 198
 			}
199 199
 
200 200
 			?>
201 201
 
202 202
 			<p>
203 203
 				<label
204
-					for="points-name-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html_x( 'Name:', 'points type', 'wordpoints' ); ?></label>
204
+					for="points-name-<?php echo esc_attr($slug); ?>"><?php echo esc_html_x('Name:', 'points type', 'wordpoints'); ?></label>
205 205
 				<input class="widefat" type="text"
206
-				       id="points-name-<?php echo esc_attr( $slug ); ?>"
206
+				       id="points-name-<?php echo esc_attr($slug); ?>"
207 207
 				       name="points-name"
208
-				       value="<?php echo esc_attr( $points_type['name'] ); ?>"/>
208
+				       value="<?php echo esc_attr($points_type['name']); ?>"/>
209 209
 			</p>
210 210
 			<p>
211 211
 				<label
212
-					for="points-prefix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $prefix ); ?></label>
212
+					for="points-prefix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($prefix); ?></label>
213 213
 				<input class="widefat" type="text"
214
-				       id="points-prefix-<?php echo esc_attr( $slug ); ?>"
214
+				       id="points-prefix-<?php echo esc_attr($slug); ?>"
215 215
 				       name="points-prefix"
216
-				       value="<?php echo esc_attr( $points_type['prefix'] ); ?>"/>
216
+				       value="<?php echo esc_attr($points_type['prefix']); ?>"/>
217 217
 			</p>
218 218
 			<p>
219 219
 				<label
220
-					for="points-suffix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $suffix ); ?></label>
220
+					for="points-suffix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($suffix); ?></label>
221 221
 				<input class="widefat" type="text"
222
-				       id="points-suffix-<?php echo esc_attr( $slug ); ?>"
222
+				       id="points-suffix-<?php echo esc_attr($slug); ?>"
223 223
 				       name="points-suffix"
224
-				       value="<?php echo esc_attr( $points_type['suffix'] ); ?>"/>
224
+				       value="<?php echo esc_attr($points_type['suffix']); ?>"/>
225 225
 			</p>
226 226
 
227 227
 			<?php
@@ -235,28 +235,28 @@  discard block
 block discarded – undo
235 235
 			 *
236 236
 			 * @param string $points_type The slug of the points type.
237 237
 			 */
238
-			do_action( 'wordpoints_points_type_form_bottom', $slug );
238
+			do_action('wordpoints_points_type_form_bottom', $slug);
239 239
 
240 240
 			?>
241 241
 
242 242
 			<input type="hidden" name="points-slug"
243
-			       value="<?php echo esc_attr( $slug ); ?>"/>
243
+			       value="<?php echo esc_attr($slug); ?>"/>
244 244
 			<input type="hidden" name="add_new" class="add_new"
245
-			       value="<?php echo esc_attr( $add_new ); ?>"/>
245
+			       value="<?php echo esc_attr($add_new); ?>"/>
246 246
 
247 247
 			<div class="hook-control-actions">
248 248
 				<div class="alignleft">
249 249
 					<?php
250 250
 
251
-					if ( ! $add_new ) {
252
-						wp_nonce_field( "wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce' );
253
-						submit_button( _x( 'Delete', 'points type', 'wordpoints' ), 'delete', 'delete-points-type', false, array( 'id' => "delete_points_type-{$slug}" ) );
251
+					if ( ! $add_new) {
252
+						wp_nonce_field("wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce');
253
+						submit_button(_x('Delete', 'points type', 'wordpoints'), 'delete', 'delete-points-type', false, array('id' => "delete_points_type-{$slug}"));
254 254
 					}
255 255
 
256 256
 					?>
257 257
 				</div>
258 258
 				<div class="alignright">
259
-					<?php submit_button( _x( 'Save', 'points type', 'wordpoints' ), 'button-primary hook-control-save right', 'save-points-type', false, array( 'id' => "points-{$slug}-save" ) ); ?>
259
+					<?php submit_button(_x('Save', 'points type', 'wordpoints'), 'button-primary hook-control-save right', 'save-points-type', false, array('id' => "points-{$slug}-save")); ?>
260 260
 					<span class="spinner"></span>
261 261
 				</div>
262 262
 				<br class="clear"/>
@@ -273,17 +273,17 @@  discard block
 block discarded – undo
273 273
 	 */
274 274
 	public function add_event_meta_boxes() {
275 275
 
276
-		if ( ! $this->current_points_type ) {
276
+		if ( ! $this->current_points_type) {
277 277
 			return;
278 278
 		}
279 279
 
280 280
 		/** @var WordPoints_Hook_EventI $event */
281
-		foreach ( $this->hooks->events->get_all() as $slug => $event ) {
281
+		foreach ($this->hooks->events->get_all() as $slug => $event) {
282 282
 
283 283
 			add_meta_box(
284 284
 				"{$this->current_points_type}-{$slug}"
285 285
 				, $event->get_title()
286
-				, array( $this, 'display_event_meta_box' )
286
+				, array($this, 'display_event_meta_box')
287 287
 				, $this->id
288 288
 				, 'events'
289 289
 				, 'default'
@@ -303,50 +303,50 @@  discard block
 block discarded – undo
303 303
 	 * @param array $points_type The points type this meta-box relates to.
304 304
 	 * @param array $meta_box    The data the meta-box was created with.
305 305
 	 */
306
-	public function display_event_meta_box( $points_type, $meta_box ) {
306
+	public function display_event_meta_box($points_type, $meta_box) {
307 307
 
308 308
 		$event_slug = $meta_box['args']['slug'];
309 309
 
310 310
 		/** @var WordPoints_Hook_Reactor $points_reactor */
311
-		$points_reactor = $this->hooks->reactors->get( 'points' );
311
+		$points_reactor = $this->hooks->reactors->get('points');
312 312
 
313 313
 		$data = array();
314 314
 
315
-		foreach ( $points_reactor->reactions->get_reactions_to_event( $event_slug ) as $id => $reaction ) {
316
-			if ( $reaction->get_meta( 'points_type' ) === $this->current_points_type ) {
315
+		foreach ($points_reactor->reactions->get_reactions_to_event($event_slug) as $id => $reaction) {
316
+			if ($reaction->get_meta('points_type') === $this->current_points_type) {
317 317
 				$data[] = WordPoints_Admin_Ajax_Hooks::prepare_hook_reaction(
318 318
 					$reaction
319 319
 				);
320 320
 			}
321 321
 		}
322 322
 
323
-		$args = $this->hooks->events->args->get_children( $event_slug );
323
+		$args = $this->hooks->events->args->get_children($event_slug);
324 324
 
325
-		$event_data = array( 'args' => array() );
325
+		$event_data = array('args' => array());
326 326
 
327
-		foreach ( $args as $slug => $arg ) {
327
+		foreach ($args as $slug => $arg) {
328 328
 
329
-			$event_data['args'][ $slug ] = array(
329
+			$event_data['args'][$slug] = array(
330 330
 				'slug' => $slug,
331 331
 			);
332 332
 
333
-			if ( $arg instanceof WordPoints_Hook_Arg ) {
334
-				$event_data['args'][ $slug ]['title'] = $arg->get_title();
333
+			if ($arg instanceof WordPoints_Hook_Arg) {
334
+				$event_data['args'][$slug]['title'] = $arg->get_title();
335 335
 			}
336 336
 		}
337 337
 
338 338
 		?>
339 339
 
340 340
 		<script>
341
-			WordPointsHooksAdminData.events[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $event_data ); ?>;
342
-			WordPointsHooksAdminData.reactions[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $data ); ?>;
341
+			WordPointsHooksAdminData.events[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($event_data); ?>;
342
+			WordPointsHooksAdminData.reactions[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($data); ?>;
343 343
 		</script>
344 344
 
345 345
 		<div class="wordpoints-hook-reaction-group-container">
346 346
 			<div class="wordpoints-hook-reaction-group"
347
-				data-wordpoints-hooks-hook-event="<?php echo esc_attr( $event_slug ); ?>"
348
-				data-wordpoints-hooks-points-type="<?php echo esc_attr( $this->current_points_type ); ?>"
349
-				data-wordpoints-hooks-create-nonce="<?php echo esc_attr( wp_create_nonce( 'wordpoints_create_hook_reaction|points' ) ); ?>"
347
+				data-wordpoints-hooks-hook-event="<?php echo esc_attr($event_slug); ?>"
348
+				data-wordpoints-hooks-points-type="<?php echo esc_attr($this->current_points_type); ?>"
349
+				data-wordpoints-hooks-create-nonce="<?php echo esc_attr(wp_create_nonce('wordpoints_create_hook_reaction|points')); ?>"
350 350
 				data-wordpoints-hooks-reactor="points">
351 351
 			</div>
352 352
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
 			<div class="controls">
362 362
 				<button type="button" class="button-primary add-reaction">
363
-					<?php esc_html_e( 'Add New', 'wordpoints' ); ?>
363
+					<?php esc_html_e('Add New', 'wordpoints'); ?>
364 364
 				</button>
365 365
 			</div>
366 366
 		</div>
@@ -380,19 +380,19 @@  discard block
 block discarded – undo
380 380
 		// Show a tab for each points type.
381 381
 		$tabs = array();
382 382
 
383
-		foreach ( $points_types as $slug => $settings ) {
384
-			$tabs[ $slug ] = $settings['name'];
383
+		foreach ($points_types as $slug => $settings) {
384
+			$tabs[$slug] = $settings['name'];
385 385
 		}
386 386
 
387
-		$tabs['add-new'] = __( 'Add New', 'wordpoints' );
387
+		$tabs['add-new'] = __('Add New', 'wordpoints');
388 388
 
389
-		$tab = wordpoints_admin_get_current_tab( $tabs );
389
+		$tab = wordpoints_admin_get_current_tab($tabs);
390 390
 
391
-		if ( 'add-new' !== $tab ) {
391
+		if ('add-new' !== $tab) {
392 392
 			$this->current_points_type = $tab;
393 393
 		}
394 394
 
395
-		do_action( 'add_meta_boxes', $this->id );
395
+		do_action('add_meta_boxes', $this->id);
396 396
 
397 397
 		$this->tabs = $tabs;
398 398
 	}
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	 */
405 405
 	public function save_points_type() {
406 406
 
407
-		if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) {
407
+		if ( ! current_user_can('manage_wordpoints_points_types')) {
408 408
 			return;
409 409
 		}
410 410
 
@@ -419,43 +419,43 @@  discard block
 block discarded – undo
419 419
 
420 420
 			$settings = array();
421 421
 
422
-			$settings['name']   = trim( sanitize_text_field( wp_unslash( $_POST['points-name'] ) ) ); // WPCS: CSRF OK
423
-			$settings['prefix'] = ltrim( sanitize_text_field( wp_unslash( $_POST['points-prefix'] ) ) ); // WPCS: CSRF OK
424
-			$settings['suffix'] = rtrim( sanitize_text_field( wp_unslash( $_POST['points-suffix'] ) ) ); // WPCS: CSRF OK
422
+			$settings['name']   = trim(sanitize_text_field(wp_unslash($_POST['points-name']))); // WPCS: CSRF OK
423
+			$settings['prefix'] = ltrim(sanitize_text_field(wp_unslash($_POST['points-prefix']))); // WPCS: CSRF OK
424
+			$settings['suffix'] = rtrim(sanitize_text_field(wp_unslash($_POST['points-suffix']))); // WPCS: CSRF OK
425 425
 
426 426
 			if (
427
-				isset( $_POST['points-slug'] )
428
-				&& wordpoints_verify_nonce( 'update_points_type', 'wordpoints_update_points_type-%s', array( 'points-slug' ), 'post' )
427
+				isset($_POST['points-slug'])
428
+				&& wordpoints_verify_nonce('update_points_type', 'wordpoints_update_points_type-%s', array('points-slug'), 'post')
429 429
 			) {
430 430
 
431 431
 				// - We are updating an existing points type.
432 432
 
433
-				$points_type = sanitize_key( $_POST['points-slug'] );
433
+				$points_type = sanitize_key($_POST['points-slug']);
434 434
 
435
-				$old_settings = wordpoints_get_points_type( $points_type );
435
+				$old_settings = wordpoints_get_points_type($points_type);
436 436
 
437
-				if ( false === $old_settings ) {
437
+				if (false === $old_settings) {
438 438
 
439 439
 					add_settings_error(
440 440
 						''
441 441
 						, 'wordpoints_points_type_update'
442
-						, __( 'Error: failed updating points type.', 'wordpoints' )
442
+						, __('Error: failed updating points type.', 'wordpoints')
443 443
 						, 'updated'
444 444
 					);
445 445
 
446 446
 					return;
447 447
 				}
448 448
 
449
-				if ( is_array( $old_settings ) ) {
450
-					$settings = array_merge( $old_settings, $settings );
449
+				if (is_array($old_settings)) {
450
+					$settings = array_merge($old_settings, $settings);
451 451
 				}
452 452
 
453
-				if ( ! wordpoints_update_points_type( $points_type, $settings ) ) {
453
+				if ( ! wordpoints_update_points_type($points_type, $settings)) {
454 454
 
455 455
 					add_settings_error(
456 456
 						''
457 457
 						, 'wordpoints_points_type_update'
458
-						, __( 'Error: failed updating points type.', 'wordpoints' )
458
+						, __('Error: failed updating points type.', 'wordpoints')
459 459
 						, 'updated'
460 460
 					);
461 461
 
@@ -464,23 +464,23 @@  discard block
 block discarded – undo
464 464
 					add_settings_error(
465 465
 						''
466 466
 						, 'wordpoints_points_type_update'
467
-						, __( 'Points type updated.', 'wordpoints' )
467
+						, __('Points type updated.', 'wordpoints')
468 468
 						, 'updated'
469 469
 					);
470 470
 				}
471 471
 
472
-			} elseif ( wordpoints_verify_nonce( 'add_new', 'wordpoints_add_new_points_type', null, 'post' ) ) {
472
+			} elseif (wordpoints_verify_nonce('add_new', 'wordpoints_add_new_points_type', null, 'post')) {
473 473
 
474 474
 				// - We are creating a new points type.
475 475
 
476
-				$slug = wordpoints_add_points_type( $settings );
476
+				$slug = wordpoints_add_points_type($settings);
477 477
 
478
-				if ( ! $slug ) {
478
+				if ( ! $slug) {
479 479
 
480 480
 					add_settings_error(
481 481
 						''
482 482
 						, 'wordpoints_points_type_create'
483
-						, __( 'Please choose a unique name for this points type.', 'wordpoints' )
483
+						, __('Please choose a unique name for this points type.', 'wordpoints')
484 484
 					);
485 485
 
486 486
 				} else {
@@ -490,26 +490,26 @@  discard block
 block discarded – undo
490 490
 					add_settings_error(
491 491
 						''
492 492
 						, 'wordpoints_points_type_create'
493
-						, __( 'Points type created.', 'wordpoints' )
493
+						, __('Points type created.', 'wordpoints')
494 494
 						, 'updated'
495 495
 					);
496 496
 				}
497 497
 			}
498 498
 
499 499
 		} elseif (
500
-			! empty( $_POST['delete-points-type'] )
501
-			&& isset( $_POST['points-slug'] )
502
-			&& wordpoints_verify_nonce( 'delete-points-type-nonce', 'wordpoints_delete_points_type-%s', array( 'points-slug' ), 'post' )
500
+			! empty($_POST['delete-points-type'])
501
+			&& isset($_POST['points-slug'])
502
+			&& wordpoints_verify_nonce('delete-points-type-nonce', 'wordpoints_delete_points_type-%s', array('points-slug'), 'post')
503 503
 		) {
504 504
 
505 505
 			// - We are deleting a points type.
506 506
 
507
-			if ( wordpoints_delete_points_type( sanitize_key( $_POST['points-slug'] ) ) ) {
507
+			if (wordpoints_delete_points_type(sanitize_key($_POST['points-slug']))) {
508 508
 
509 509
 				add_settings_error(
510 510
 					''
511 511
 					, 'wordpoints_points_type_delete'
512
-					, __( 'Points type deleted.', 'wordpoints' )
512
+					, __('Points type deleted.', 'wordpoints')
513 513
 					, 'updated'
514 514
 				);
515 515
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 				add_settings_error(
519 519
 					''
520 520
 					, 'wordpoints_points_type_delete'
521
-					, __( 'Error while deleting.', 'wordpoints' )
521
+					, __('Error while deleting.', 'wordpoints')
522 522
 				);
523 523
 			}
524 524
 		}
@@ -534,25 +534,25 @@  discard block
 block discarded – undo
534 534
 		 *
535 535
 		 * @since 1.0.0
536 536
 		 */
537
-		do_action( 'wordpoints_admin_points_events_head' );
537
+		do_action('wordpoints_admin_points_events_head');
538 538
 
539
-		if ( is_network_admin() ) {
540
-			$title = __( 'Network Events', 'wordpoints' );
541
-			$description = __( 'Award points when various events happen on this network.', 'wordpoints' );
539
+		if (is_network_admin()) {
540
+			$title = __('Network Events', 'wordpoints');
541
+			$description = __('Award points when various events happen on this network.', 'wordpoints');
542 542
 		} else {
543
-			$title = __( 'Events', 'wordpoints' );
544
-			$description = __( 'Award points when various events happen on this site.', 'wordpoints' );
543
+			$title = __('Events', 'wordpoints');
544
+			$description = __('Award points when various events happen on this site.', 'wordpoints');
545 545
 		}
546 546
 
547
-		$points_type = wordpoints_get_points_type( $this->current_points_type );
547
+		$points_type = wordpoints_get_points_type($this->current_points_type);
548 548
 
549 549
 		?>
550 550
 
551 551
 		<div class="wordpoints-points-type-meta-box-wrap">
552 552
 
553 553
 				<form>
554
-					<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
555
-					<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
554
+					<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
555
+					<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
556 556
 				</form>
557 557
 
558 558
 				<div id="poststuff">
@@ -560,17 +560,17 @@  discard block
 block discarded – undo
560 560
 					<div id="post-body" class="metabox-holder columns-<?php echo 1 === (int) get_current_screen()->get_columns() ? '1' : '2'; ?>">
561 561
 
562 562
 						<div id="postbox-container-1" class="postbox-container">
563
-							<?php do_meta_boxes( $this->id, 'side', $points_type ); ?>
563
+							<?php do_meta_boxes($this->id, 'side', $points_type); ?>
564 564
 						</div>
565 565
 
566
-						<?php if ( isset( $this->current_points_type ) ) : ?>
566
+						<?php if (isset($this->current_points_type)) : ?>
567 567
 							<div class="wordpoints-hook-events-heading">
568
-								<h2><?php echo esc_html( $title ); ?></h2>
569
-								<p class="description"><?php echo esc_html( $description ); ?></p>
568
+								<h2><?php echo esc_html($title); ?></h2>
569
+								<p class="description"><?php echo esc_html($description); ?></p>
570 570
 							</div>
571 571
 
572 572
 							<div id="postbox-container-2" class="postbox-container">
573
-								<?php do_meta_boxes( $this->id, 'events', $points_type ); ?>
573
+								<?php do_meta_boxes($this->id, 'events', $points_type); ?>
574 574
 							</div>
575 575
 						<?php endif; ?>
576 576
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 		 *
590 590
 		 * @since 1.0.0
591 591
 		 */
592
-		do_action( 'wordpoints_admin_points_events_foot' );
592
+		do_action('wordpoints_admin_points_events_foot');
593 593
 	}
594 594
 }
595 595
 
Please login to merge, or discard this patch.
src/admin/includes/classes/screens.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @since 1.0.0
28 28
 	 */
29 29
 	public function __construct() {
30
-		add_action( 'current_screen', array( $this, 'set_current_screen' ) );
30
+		add_action('current_screen', array($this, 'set_current_screen'));
31 31
 	}
32 32
 
33 33
 	/**
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param WP_Screen $current_screen The WP_Screen object for the current screen.
39 39
 	 */
40
-	public function set_current_screen( $current_screen ) {
40
+	public function set_current_screen($current_screen) {
41 41
 
42
-		$screen = $this->get( $current_screen->id );
42
+		$screen = $this->get($current_screen->id);
43 43
 
44
-		if ( ! ( $screen instanceof WordPoints_Admin_Screen ) ) {
44
+		if ( ! ($screen instanceof WordPoints_Admin_Screen)) {
45 45
 			return;
46 46
 		}
47 47
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 		add_action(
51 51
 			"load-{$current_screen->id}"
52
-			, array( $this->current_screen, 'load' )
52
+			, array($this->current_screen, 'load')
53 53
 		);
54 54
 	}
55 55
 
Please login to merge, or discard this patch.