Completed
Push — master ( 975fd1...3e68e7 )
by J.D.
03:16
created
src/includes/classes/hook/reaction/validator.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
 	 * @param bool                            $fail_fast Whether to fail as soon as
104 104
 	 *                                                   the first error is found.
105 105
 	 */
106
-	public function __construct( $settings, $fail_fast = false ) {
106
+	public function __construct($settings, $fail_fast = false) {
107 107
 
108 108
 		$this->fail_fast = $fail_fast;
109 109
 		$this->hooks = wordpoints_hooks();
110 110
 
111
-		if ( $settings instanceof WordPoints_Hook_ReactionI ) {
111
+		if ($settings instanceof WordPoints_Hook_ReactionI) {
112 112
 
113 113
 			$this->reaction     = $settings;
114 114
 			$this->settings     = $this->reaction->get_all_meta();
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 
120 120
 			$this->settings = $settings;
121 121
 
122
-			if ( isset( $this->settings['event'] ) ) {
122
+			if (isset($this->settings['event'])) {
123 123
 				$this->event_slug = $this->settings['event'];
124 124
 			}
125 125
 
126
-			if ( isset( $this->settings['reactor'] ) ) {
126
+			if (isset($this->settings['reactor'])) {
127 127
 				$this->reactor_slug = $this->settings['reactor'];
128 128
 			}
129 129
 		}
@@ -146,40 +146,40 @@  discard block
 block discarded – undo
146 146
 			$fail_fast = $this->fail_fast;
147 147
 			$this->fail_fast = true;
148 148
 
149
-			$events = $this->hooks->get_sub_app( 'events' );
149
+			$events = $this->hooks->get_sub_app('events');
150 150
 
151
-			if ( ! isset( $this->event_slug ) ) {
152
-				$this->add_error( __( 'Event is missing.', 'wordpoints' ), 'event' );
153
-			} elseif ( ! $events->is_registered( $this->event_slug ) ) {
154
-				$this->add_error( __( 'Event is invalid.', 'wordpoints' ), 'event' );
151
+			if ( ! isset($this->event_slug)) {
152
+				$this->add_error(__('Event is missing.', 'wordpoints'), 'event');
153
+			} elseif ( ! $events->is_registered($this->event_slug)) {
154
+				$this->add_error(__('Event is invalid.', 'wordpoints'), 'event');
155 155
 			}
156 156
 
157
-			$reactors = $this->hooks->get_sub_app( 'reactors' );
157
+			$reactors = $this->hooks->get_sub_app('reactors');
158 158
 
159
-			if ( ! isset( $this->reactor_slug ) ) {
160
-				$this->add_error( __( 'Reactor is missing.', 'wordpoints' ), 'reactor' );
161
-			} elseif ( ! $reactors->is_registered( $this->reactor_slug ) ) {
162
-				$this->add_error( __( 'Reactor is invalid.', 'wordpoints' ), 'reactor' );
159
+			if ( ! isset($this->reactor_slug)) {
160
+				$this->add_error(__('Reactor is missing.', 'wordpoints'), 'reactor');
161
+			} elseif ( ! $reactors->is_registered($this->reactor_slug)) {
162
+				$this->add_error(__('Reactor is invalid.', 'wordpoints'), 'reactor');
163 163
 			}
164 164
 
165 165
 			// From here on out we can collect errors as they come (unless we are
166 166
 			// supposed to fail fast).
167 167
 			$this->fail_fast = $fail_fast;
168 168
 
169
-			$event_args = $events->get_sub_app( 'args' )->get_children(
169
+			$event_args = $events->get_sub_app('args')->get_children(
170 170
 				$this->event_slug
171 171
 			);
172 172
 
173
-			$this->event_args = new WordPoints_Hook_Event_Args( $event_args );
174
-			$this->event_args->set_validator( $this );
173
+			$this->event_args = new WordPoints_Hook_Event_Args($event_args);
174
+			$this->event_args->set_validator($this);
175 175
 
176
-			$reactor = $reactors->get( $this->reactor_slug );
176
+			$reactor = $reactors->get($this->reactor_slug);
177 177
 
178
-			$this->settings = $reactor->validate_settings( $this->settings, $this, $this->event_args );
178
+			$this->settings = $reactor->validate_settings($this->settings, $this, $this->event_args);
179 179
 
180 180
 			/** @var WordPoints_Hook_ExtensionI $extension */
181
-			foreach ( $this->hooks->get_sub_app( 'extensions' )->get_all() as $extension ) {
182
-				$this->settings = $extension->validate_settings( $this->settings, $this, $this->event_args );
181
+			foreach ($this->hooks->get_sub_app('extensions')->get_all() as $extension) {
182
+				$this->settings = $extension->validate_settings($this->settings, $this, $this->event_args);
183 183
 			}
184 184
 
185 185
 			/**
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 			 * @param WordPoints_Hook_Reaction_Validator $validator The validator object.
190 190
 			 * @param WordPoints_Hook_Event_Args         $args      The event args object.
191 191
 			 */
192
-			$this->settings = apply_filters( 'wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args );
192
+			$this->settings = apply_filters('wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args);
193 193
 
194
-		} catch ( WordPoints_Hook_Validator_Exception $e ) {
194
+		} catch (WordPoints_Hook_Validator_Exception $e) {
195 195
 
196 196
 			// Do nothing.
197
-			unset( $e );
197
+			unset($e);
198 198
 		}
199 199
 
200 200
 		return $this->settings;
@@ -222,17 +222,17 @@  discard block
 block discarded – undo
222 222
 	 * @throws WordPoints_Hook_Validator_Exception If the validator is configured to
223 223
 	 *                                             fail as soon as an error is found.
224 224
 	 */
225
-	public function add_error( $message, $field = null ) {
225
+	public function add_error($message, $field = null) {
226 226
 
227 227
 		$field_stack = $this->field_stack;
228 228
 
229
-		if ( null !== $field ) {
229
+		if (null !== $field) {
230 230
 			$field_stack[] = $field;
231 231
 		}
232 232
 
233
-		$this->errors[] = array( 'message' => $message, 'field' => $field_stack );
233
+		$this->errors[] = array('message' => $message, 'field' => $field_stack);
234 234
 
235
-		if ( $this->fail_fast ) {
235
+		if ($this->fail_fast) {
236 236
 			throw new WordPoints_Hook_Validator_Exception;
237 237
 		}
238 238
 	}
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @return bool Whether the validator found any errors.
246 246
 	 */
247 247
 	public function had_errors() {
248
-		return ! empty( $this->errors );
248
+		return ! empty($this->errors);
249 249
 	}
250 250
 
251 251
 	/**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @param string $field The field.
268 268
 	 */
269
-	public function push_field( $field ) {
269
+	public function push_field($field) {
270 270
 		$this->field_stack[] = $field;
271 271
 	}
272 272
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @since 1.0.0
277 277
 	 */
278 278
 	public function pop_field() {
279
-		array_pop( $this->field_stack );
279
+		array_pop($this->field_stack);
280 280
 	}
281 281
 
282 282
 	/**
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	 */
322 322
 	public function get_id() {
323 323
 
324
-		if ( ! $this->reaction ) {
324
+		if ( ! $this->reaction) {
325 325
 			return false;
326 326
 		}
327 327
 
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
 	 *
360 360
 	 * @return mixed The meta value.
361 361
 	 */
362
-	public function get_meta( $key ) {
362
+	public function get_meta($key) {
363 363
 
364
-		if ( ! isset( $this->settings[ $key ] ) ) {
364
+		if ( ! isset($this->settings[$key])) {
365 365
 			return null;
366 366
 		}
367 367
 
368
-		return $this->settings[ $key ];
368
+		return $this->settings[$key];
369 369
 	}
370 370
 
371 371
 	/**
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction/store.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param string $slug The slug of this store.
57 57
 	 */
58
-	public function __construct( $slug ) {
58
+	public function __construct($slug) {
59 59
 		$this->slug = $slug;
60 60
 	}
61 61
 
@@ -70,33 +70,33 @@  discard block
 block discarded – undo
70 70
 	 * @since 1.0.0
71 71
 	 */
72 72
 	public function get_context_id() {
73
-		return wordpoints_entities_get_current_context_id( $this->context );
73
+		return wordpoints_entities_get_current_context_id($this->context);
74 74
 	}
75 75
 
76 76
 	/**
77 77
 	 * @since 1.0.0
78 78
 	 */
79
-	public function get_reaction( $id ) {
79
+	public function get_reaction($id) {
80 80
 
81
-		if ( ! $this->reaction_exists( $id ) ) {
81
+		if ( ! $this->reaction_exists($id)) {
82 82
 			return false;
83 83
 		}
84 84
 
85
-		return new $this->reaction_class( $id, $this );
85
+		return new $this->reaction_class($id, $this);
86 86
 	}
87 87
 
88 88
 	/**
89 89
 	 * @since 1.0.0
90 90
 	 */
91
-	public function create_reaction( array $settings ) {
92
-		return $this->create_or_update_reaction( $settings );
91
+	public function create_reaction(array $settings) {
92
+		return $this->create_or_update_reaction($settings);
93 93
 	}
94 94
 
95 95
 	/**
96 96
 	 * @since 1.0.0
97 97
 	 */
98
-	public function update_reaction( $id, array $settings ) {
99
-		return $this->create_or_update_reaction( $settings, $id );
98
+	public function update_reaction($id, array $settings) {
99
+		return $this->create_or_update_reaction($settings, $id);
100 100
 	}
101 101
 
102 102
 	/**
@@ -111,45 +111,45 @@  discard block
 block discarded – undo
111 111
 	 *         The reaction object if created/updated successfully. False or a
112 112
 	 *         validator instance if not.
113 113
 	 */
114
-	protected function create_or_update_reaction( array $settings, $id = null ) {
114
+	protected function create_or_update_reaction(array $settings, $id = null) {
115 115
 
116
-		$is_new = ! isset( $id );
116
+		$is_new = ! isset($id);
117 117
 
118
-		if ( ! $is_new && ! $this->reaction_exists( $id ) ) {
118
+		if ( ! $is_new && ! $this->reaction_exists($id)) {
119 119
 			return false;
120 120
 		}
121 121
 
122
-		$validator = new WordPoints_Hook_Reaction_Validator( $settings );
122
+		$validator = new WordPoints_Hook_Reaction_Validator($settings);
123 123
 		$settings = $validator->validate();
124 124
 
125
-		if ( $validator->had_errors() ) {
125
+		if ($validator->had_errors()) {
126 126
 			return $validator;
127 127
 		}
128 128
 
129
-		if ( $is_new ) {
129
+		if ($is_new) {
130 130
 
131
-			$id = $this->_create_reaction( $settings['event'] );
131
+			$id = $this->_create_reaction($settings['event']);
132 132
 
133
-			if ( ! $id ) {
133
+			if ( ! $id) {
134 134
 				return false;
135 135
 			}
136 136
 		}
137 137
 
138
-		$reaction = $this->get_reaction( $id );
138
+		$reaction = $this->get_reaction($id);
139 139
 
140
-		$reaction->update_event_slug( $settings['event'] );
140
+		$reaction->update_event_slug($settings['event']);
141 141
 
142
-		unset( $settings['event'] );
142
+		unset($settings['event']);
143 143
 
144
-		$reaction->update_meta( 'reactor', $settings['reactor'] );
144
+		$reaction->update_meta('reactor', $settings['reactor']);
145 145
 
146 146
 		/** @var WordPoints_Hook_ReactorI $reactor */
147
-		$reactor = wordpoints_hooks()->get_sub_app( 'reactors' )->get( $settings['reactor'] );
148
-		$reactor->update_settings( $reaction, $settings );
147
+		$reactor = wordpoints_hooks()->get_sub_app('reactors')->get($settings['reactor']);
148
+		$reactor->update_settings($reaction, $settings);
149 149
 
150 150
 		/** @var WordPoints_Hook_ExtensionI $extension */
151
-		foreach ( wordpoints_hooks()->get_sub_app( 'extensions' )->get_all() as $extension ) {
152
-			$extension->update_settings( $reaction, $settings );
151
+		foreach (wordpoints_hooks()->get_sub_app('extensions')->get_all() as $extension) {
152
+			$extension->update_settings($reaction, $settings);
153 153
 		}
154 154
 
155 155
 		/**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		 * @param array                     $settings The new settings for the reaction.
160 160
 		 * @param bool                      $is_new   Whether the reaction was just now created.
161 161
 		 */
162
-		do_action( 'wordpoints_hook_reaction_save', $reaction, $settings, $is_new );
162
+		do_action('wordpoints_hook_reaction_save', $reaction, $settings, $is_new);
163 163
 
164 164
 		return $reaction;
165 165
 	}
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return int|false The reaction ID, or false if not created.
178 178
 	 */
179
-	abstract protected function _create_reaction( $event_slug );
179
+	abstract protected function _create_reaction($event_slug);
180 180
 }
181 181
 
182 182
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/condition.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,33 +23,33 @@  discard block
 block discarded – undo
23 23
 		WordPoints_Hook_Reaction_Validator $validator
24 24
 	) {
25 25
 
26
-		if ( ! isset( $settings['value'] ) || '' === $settings['value'] ) {
26
+		if ( ! isset($settings['value']) || '' === $settings['value']) {
27 27
 
28 28
 			$settings_fields = $this->get_settings_fields();
29 29
 
30 30
 			$validator->add_error(
31 31
 				sprintf(
32
-					__( '%s is required.', 'wordpoints' )
32
+					__('%s is required.', 'wordpoints')
33 33
 					, $settings_fields['value']['label']
34 34
 				)
35 35
 				, 'value'
36 36
 			);
37 37
 
38
-		} elseif ( $arg instanceof WordPoints_Entity_Attr ) {
38
+		} elseif ($arg instanceof WordPoints_Entity_Attr) {
39 39
 
40
-			$data_types = wordpoints_apps()->get_sub_app( 'data_types' );
40
+			$data_types = wordpoints_apps()->get_sub_app('data_types');
41 41
 
42
-			$data_type = $data_types->get( $arg->get_data_type() );
42
+			$data_type = $data_types->get($arg->get_data_type());
43 43
 
44 44
 			// If this data type isn't recognized, that's probably OK. Validation is
45 45
 			// just to help the user know that they've made a mistake anyway.
46
-			if ( ! ( $data_type instanceof WordPoints_Data_TypeI ) ) {
46
+			if ( ! ($data_type instanceof WordPoints_Data_TypeI)) {
47 47
 				return $settings;
48 48
 			}
49 49
 
50
-			$validated_value = $data_type->validate_value( $settings['value'] );
50
+			$validated_value = $data_type->validate_value($settings['value']);
51 51
 
52
-			if ( is_wp_error( $validated_value ) ) {
52
+			if (is_wp_error($validated_value)) {
53 53
 
54 54
 				$settings_fields = $this->get_settings_fields();
55 55
 
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 
67 67
 			$settings['value'] = $validated_value;
68 68
 
69
-		} elseif ( $arg instanceof WordPoints_Entity ) {
69
+		} elseif ($arg instanceof WordPoints_Entity) {
70 70
 
71
-			if ( ! $arg->exists( $settings['value'] ) ) {
71
+			if ( ! $arg->exists($settings['value'])) {
72 72
 				$validator->add_error(
73 73
 					sprintf(
74 74
 						// translators: 1. item type, 2. item ID/slug.
75
-						__( '%1$s “%2$s” not found.', 'wordpoints' )
75
+						__('%1$s “%2$s” not found.', 'wordpoints')
76 76
 						, $arg->get_title()
77 77
 						, $settings['value']
78 78
 					)
Please login to merge, or discard this patch.
src/includes/classes/hook/settings.php 1 patch
Spacing   +31 added lines, -31 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,8 +133,8 @@  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 139
 //add_action( 'wordpoints_hooks_init', 'wordpoints_hook_settings_app' );
140 140
 
@@ -145,12 +145,12 @@  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 155
 //add_action( 'wordpoints_hook_settings_init', 'wordpoints_register_hook_settings' );
156 156
 
Please login to merge, or discard this patch.
src/includes/classes/hook/condition/entity/array/contains.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function __construct() {
49 49
 
50
-		$this->conditions_extension = wordpoints_hooks()->get_sub_app( 'extensions' )->get(
50
+		$this->conditions_extension = wordpoints_hooks()->get_sub_app('extensions')->get(
51 51
 			'conditions'
52 52
 		);
53 53
 	}
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @since 1.0.0
57 57
 	 */
58 58
 	public function get_title() {
59
-		return __( 'Contains', 'wordpoints' );
59
+		return __('Contains', 'wordpoints');
60 60
 	}
61 61
 
62 62
 	/**
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 		return array(
67 67
 			'min' => array(
68 68
 				'slug'    => 'min',
69
-				'label'   => __( 'Minimum number of items', 'wordpoints' ),
69
+				'label'   => __('Minimum number of items', 'wordpoints'),
70 70
 				'type'    => 'number',
71 71
 				'default' => 1,
72 72
 			),
73 73
 			'max' => array(
74 74
 				'slug'  => 'max',
75
-				'label' => __( 'Maximum number of items', 'wordpoints' ),
75
+				'label' => __('Maximum number of items', 'wordpoints'),
76 76
 				'type'  => 'number',
77 77
 			),
78 78
 		);
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 
93 93
 		$this->validate_count();
94 94
 
95
-		if ( isset( $settings['conditions'] ) ) {
96
-			$this->validate_conditions( $arg );
95
+		if (isset($settings['conditions'])) {
96
+			$this->validate_conditions($arg);
97 97
 		}
98 98
 
99 99
 		return $this->settings;
@@ -107,31 +107,31 @@  discard block
 block discarded – undo
107 107
 	protected function validate_count() {
108 108
 
109 109
 		if (
110
-			! empty( $this->settings['max'] )
111
-			&& ! wordpoints_posint( $this->settings['max'] )
110
+			! empty($this->settings['max'])
111
+			&& ! wordpoints_posint($this->settings['max'])
112 112
 		) {
113 113
 			$this->validator->add_error(
114
-				__( 'The maximum must be a positive integer.', 'wordpoints' )
114
+				__('The maximum must be a positive integer.', 'wordpoints')
115 115
 				, 'max'
116 116
 			);
117 117
 		}
118 118
 
119
-		if ( ! empty( $this->settings['min'] ) ) {
119
+		if ( ! empty($this->settings['min'])) {
120 120
 
121
-			if ( ! wordpoints_posint( $this->settings['min'] ) ) {
121
+			if ( ! wordpoints_posint($this->settings['min'])) {
122 122
 
123 123
 				$this->validator->add_error(
124
-					__( 'The minimum must be a positive integer.', 'wordpoints' )
124
+					__('The minimum must be a positive integer.', 'wordpoints')
125 125
 					, 'min'
126 126
 				);
127 127
 
128 128
 			} elseif (
129
-				! empty( $this->settings['max'] )
129
+				! empty($this->settings['max'])
130 130
 				&& $this->settings['max'] < $this->settings['min']
131 131
 			) {
132 132
 
133 133
 				$this->validator->add_error(
134
-					__( 'The minimum must be less than the maximum.', 'wordpoints' )
134
+					__('The minimum must be less than the maximum.', 'wordpoints')
135 135
 					, 'min'
136 136
 				);
137 137
 			}
@@ -145,24 +145,24 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param WordPoints_EntityishI $current_arg The current arg.
147 147
 	 */
148
-	protected function validate_conditions( $current_arg ) {
148
+	protected function validate_conditions($current_arg) {
149 149
 
150
-		$args = new WordPoints_Hook_Event_Args( array() );
150
+		$args = new WordPoints_Hook_Event_Args(array());
151 151
 
152
-		if ( $current_arg instanceof WordPoints_Entity_Array ) {
152
+		if ($current_arg instanceof WordPoints_Entity_Array) {
153 153
 
154 154
 			$entity = wordpoints_entities()->get(
155 155
 				$current_arg->get_entity_slug()
156 156
 			);
157 157
 
158
-			if ( $entity instanceof WordPoints_Entity ) {
159
-				$args->add_entity( $entity );
158
+			if ($entity instanceof WordPoints_Entity) {
159
+				$args->add_entity($entity);
160 160
 			}
161 161
 		}
162 162
 
163
-		$args->set_validator( $this->validator );
163
+		$args->set_validator($this->validator);
164 164
 
165
-		$this->validator->push_field( 'conditions' );
165
+		$this->validator->push_field('conditions');
166 166
 
167 167
 		$this->settings['conditions'] = $this->conditions_extension->validate_conditions(
168 168
 			$this->settings['conditions']
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	/**
176 176
 	 * @since 1.0.0
177 177
 	 */
178
-	public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) {
178
+	public function is_met(array $settings, WordPoints_Hook_Event_Args $args) {
179 179
 
180 180
 		$this->settings = $settings;
181 181
 
@@ -183,16 +183,16 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$entities = array();
185 185
 
186
-		if ( $arg instanceof WordPoints_Entity_Array ) {
186
+		if ($arg instanceof WordPoints_Entity_Array) {
187 187
 
188 188
 			$entities = $arg->get_the_entities();
189 189
 
190
-			if ( isset( $this->settings['conditions'] ) ) {
191
-				$entities = $this->filter_entities( $entities );
190
+			if (isset($this->settings['conditions'])) {
191
+				$entities = $this->filter_entities($entities);
192 192
 			}
193 193
 		}
194 194
 
195
-		return $this->check_count( count( $entities ) );
195
+		return $this->check_count(count($entities));
196 196
 	}
197 197
 
198 198
 	/**
@@ -204,20 +204,20 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return WordPoints_Entity[] The entities that matched the sub-conditions.
206 206
 	 */
207
-	protected function filter_entities( $entities ) {
207
+	protected function filter_entities($entities) {
208 208
 
209
-		foreach ( $entities as $index => $entity ) {
209
+		foreach ($entities as $index => $entity) {
210 210
 
211
-			$event_args = new WordPoints_Hook_Event_Args( array() );
212
-			$event_args->add_entity( $entity );
211
+			$event_args = new WordPoints_Hook_Event_Args(array());
212
+			$event_args->add_entity($entity);
213 213
 
214 214
 			$matches = $this->conditions_extension->conditions_are_met(
215 215
 				$this->settings['conditions']
216 216
 				, $event_args
217 217
 			);
218 218
 
219
-			if ( ! $matches ) {
220
-				unset( $entities[ $index ] );
219
+			if ( ! $matches) {
220
+				unset($entities[$index]);
221 221
 			}
222 222
 		}
223 223
 
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @return bool Whether the count met the requirements.
235 235
 	 */
236
-	protected function check_count( $count ) {
236
+	protected function check_count($count) {
237 237
 
238
-		if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) {
238
+		if (isset($this->settings['max']) && $count > $this->settings['max']) {
239 239
 			return false;
240 240
 		}
241 241
 
242
-		if ( isset( $this->settings['min'] ) && $count < $this->settings['min'] ) {
242
+		if (isset($this->settings['min']) && $count < $this->settings['min']) {
243 243
 			return false;
244 244
 		}
245 245
 
Please login to merge, or discard this patch.
src/includes/classes/hook/retroactive/query.php 1 patch
Spacing   +155 added lines, -155 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 reverse_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,13 +196,13 @@  discard block
 block discarded – undo
196 196
 
197 197
 	protected $results;
198 198
 
199
-	public function __construct( WordPoints_Hook_ReactionI $reaction ) {
199
+	public function __construct(WordPoints_Hook_ReactionI $reaction) {
200 200
 
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
-		$this->validator = new WordPoints_Hook_Reaction_Validator( $reaction, true );
205
+		$this->validator = new WordPoints_Hook_Reaction_Validator($reaction, true);
206 206
 	}
207 207
 
208 208
 	public function get_reaction() {
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 
216 216
 	public function get_results() {
217 217
 
218
-		if ( ! isset( $this->results ) ) {
218
+		if ( ! isset($this->results)) {
219 219
 
220 220
 			$this->execute();
221 221
 
222
-			if ( $this->validator->had_errors() ) {
222
+			if ($this->validator->had_errors()) {
223 223
 				$this->results = $this->validator;
224 224
 			}
225 225
 		}
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 			$this->filter_results();
237 237
 			$this->group_results();
238 238
 
239
-		} catch ( WordPoints_Hook_Validator_Exception $e ) {
240
-			unset( $e );
239
+		} catch (WordPoints_Hook_Validator_Exception $e) {
240
+			unset($e);
241 241
 		}
242 242
 	}
243 243
 
@@ -245,33 +245,33 @@  discard block
 block discarded – undo
245 245
 
246 246
 		$event_slug = $this->reaction->get_event_slug();
247 247
 
248
-		$events = $this->hooks->get_sub_app( 'events' );
249
-		$event  = $events->get( $event_slug );
248
+		$events = $this->hooks->get_sub_app('events');
249
+		$event  = $events->get($event_slug);
250 250
 
251
-		if ( ! ( $event instanceof WordPoints_Hook_Event_RetroactiveI ) ) {
252
-			$this->validator->add_error( 'invalid hook' );
251
+		if ( ! ($event instanceof WordPoints_Hook_Event_RetroactiveI)) {
252
+			$this->validator->add_error('invalid hook');
253 253
 		}
254 254
 
255
-		foreach ( $events->get_sub_app( 'args' )->get_children( $event_slug ) as $arg ) {
255
+		foreach ($events->get_sub_app('args')->get_children($event_slug) as $arg) {
256 256
 			$this->arg_hierarchy_push( // TODO
257 257
 				$arg
258 258
 			);
259 259
 		}
260 260
 
261
-		if ( $event instanceof WordPoints_Hook_Retroactive_Query_ModifierI ) {
262
-			$event->modify_retroactive_query( $this );
261
+		if ($event instanceof WordPoints_Hook_Retroactive_Query_ModifierI) {
262
+			$event->modify_retroactive_query($this);
263 263
 			$this->reset();
264 264
 		}
265 265
 
266
-		$reactor = $this->hooks->get_sub_app( 'reactors' )->get( $this->reaction->get_reactor_slug() );
266
+		$reactor = $this->hooks->get_sub_app('reactors')->get($this->reaction->get_reactor_slug());
267 267
 
268
-		$reactor->modify_retroactive_query( $this );
268
+		$reactor->modify_retroactive_query($this);
269 269
 		$this->reset();
270 270
 
271
-		foreach ( $this->hooks->get_sub_app( 'extensions' )->get_all() as $extension ) {
271
+		foreach ($this->hooks->get_sub_app('extensions')->get_all() as $extension) {
272 272
 
273
-			if ( $extension instanceof WordPoints_Hook_Retroactive_Query_ModifierI ) {
274
-				$extension->modify_retroactive_query( $this );
273
+			if ($extension instanceof WordPoints_Hook_Retroactive_Query_ModifierI) {
274
+				$extension->modify_retroactive_query($this);
275 275
 				$this->reset();
276 276
 			}
277 277
 		}
@@ -279,126 +279,126 @@  discard block
 block discarded – undo
279 279
 
280 280
 	protected function perform_query() {
281 281
 
282
-		$this->queries = new WordPoints_Hierarchy( 'sub_queries' );
283
-		$this->consolidate_queries( array( $this->arg_hierarchy->get() ) );
284
-		unset( $this->query );
282
+		$this->queries = new WordPoints_Hierarchy('sub_queries');
283
+		$this->consolidate_queries(array($this->arg_hierarchy->get()));
284
+		unset($this->query);
285 285
 
286 286
 		$this->queries->reset();
287 287
 
288 288
 		// Find the tip of a query.
289
-		$this->results = $this->execute_queries( $this->queries->get() );
289
+		$this->results = $this->execute_queries($this->queries->get());
290 290
 
291
-		if ( is_wp_error( $this->results ) ) {
292
-			$this->validator->add_error( $this->results );
291
+		if (is_wp_error($this->results)) {
292
+			$this->validator->add_error($this->results);
293 293
 		}
294 294
 	}
295 295
 
296
-	protected function consolidate_queries( $arg_hierarchy, $storage_type = null ) {
296
+	protected function consolidate_queries($arg_hierarchy, $storage_type = null) {
297 297
 
298
-		foreach ( $arg_hierarchy as $data ) {
299
-			$this->consolidate_query( $data );
298
+		foreach ($arg_hierarchy as $data) {
299
+			$this->consolidate_query($data);
300 300
 		}
301 301
 	}
302 302
 
303
-	protected function consolidate_query( $data ) {
303
+	protected function consolidate_query($data) {
304 304
 
305
-		if ( $data['storage_info']['type'] !== $this->queries->get_field( 'slug' ) ) {
305
+		if ($data['storage_info']['type'] !== $this->queries->get_field('slug')) {
306 306
 
307 307
 			$parent_id = null;
308
-			if ( isset( $this->query ) ) {
308
+			if (isset($this->query)) {
309 309
 				$parent_id = $this->query->get_id();
310 310
 			}
311 311
 
312
-			$this->query = new WordPoints_Hierarchy( 'sub_args' );
312
+			$this->query = new WordPoints_Hierarchy('sub_args');
313 313
 
314 314
 			$this->queries->push(
315 315
 				$data['storage_info']['type']
316
-				, array( 'query' => $this->query, 'parent_id' => $parent_id )
316
+				, array('query' => $this->query, 'parent_id' => $parent_id)
317 317
 			);
318 318
 
319 319
 			$pushed_query = true;
320 320
 		}
321 321
 
322
-		if ( isset( $data['sub_args'] ) ) {
322
+		if (isset($data['sub_args'])) {
323 323
 			$sub_args = $data['sub_args'];
324
-			unset( $data['sub_args'] );
324
+			unset($data['sub_args']);
325 325
 		}
326 326
 
327
-		$this->query->push( $data['slug'], $data );
327
+		$this->query->push($data['slug'], $data);
328 328
 
329
-		if ( isset( $sub_args ) ) {
330
-			$this->consolidate_queries( $sub_args, $data['storage_info']['type'] );
329
+		if (isset($sub_args)) {
330
+			$this->consolidate_queries($sub_args, $data['storage_info']['type']);
331 331
 		}
332 332
 
333 333
 		$this->query->pop();
334 334
 
335
-		if ( ! empty( $pushed_query ) ) {
335
+		if ( ! empty($pushed_query)) {
336 336
 			$this->queries->pop();
337
-			$this->query = $this->queries->get_field( 'query' );
337
+			$this->query = $this->queries->get_field('query');
338 338
 		}
339 339
 	}
340 340
 
341
-	protected function execute_queries( $queries ) {
341
+	protected function execute_queries($queries) {
342 342
 
343 343
 		/** @var WordPoints_HierarchyI $query */
344 344
 		$query = $queries['query'];
345 345
 
346
-		if ( isset( $queries['sub_queries'] ) ) {
347
-			foreach ( $queries['sub_queries'] as $query_data ) {
346
+		if (isset($queries['sub_queries'])) {
347
+			foreach ($queries['sub_queries'] as $query_data) {
348 348
 
349
-				$results = $this->execute_queries( $query_data );
349
+				$results = $this->execute_queries($query_data);
350 350
 
351
-				if ( is_wp_error( $results ) ) {
351
+				if (is_wp_error($results)) {
352 352
 					return $results;
353 353
 				}
354 354
 
355
-				if ( empty( $results ) ) {
355
+				if (empty($results)) {
356 356
 					return array();
357 357
 				}
358 358
 
359 359
 				/** @var WordPoints_HierarchyI $child_query */
360 360
 				$child_query = $query_data['query'];
361
-				$query->go_to( $query_data['parent_id'] );
361
+				$query->go_to($query_data['parent_id']);
362 362
 
363 363
 				$condition = array(
364 364
 //					'field' => $child_query->get_field( 'slug' ),
365 365
 					'compare' => 'in',
366 366
 					'value' => wp_list_pluck(
367 367
 						$results
368
-						, $child_query->get_field( 'storage_info', 'meta', 'id_field' )
368
+						, $child_query->get_field('storage_info', 'meta', 'id_field')
369 369
 					),
370 370
 				);
371 371
 
372
-				$query->push_to( 'conditions', $condition );
372
+				$query->push_to('conditions', $condition);
373 373
 			}
374 374
 		}
375 375
 
376 376
 		$query->reset();
377
-		$storage_type = $query->get_field( 'storage_info', 'type' );
377
+		$storage_type = $query->get_field('storage_info', 'type');
378 378
 
379 379
 		// it is pretty stupid to wait until now to figure this out.
380
-		$executor = $this->hooks->get_sub_app( 'retroactive_query_executors' )->get( $storage_type );
380
+		$executor = $this->hooks->get_sub_app('retroactive_query_executors')->get($storage_type);
381 381
 
382
-		if ( ! $executor ) {
382
+		if ( ! $executor) {
383 383
 			$this->validator->add_error(
384
-				sprintf( 'unknown storage type "%s".', $storage_type )
384
+				sprintf('unknown storage type "%s".', $storage_type)
385 385
 			);
386 386
 		}
387 387
 
388
-		return $executor->execute( array( $query->get() ) );
388
+		return $executor->execute(array($query->get()));
389 389
 	}
390 390
 
391 391
 	protected function filter_results() {
392 392
 
393
-		$reactor = $this->hooks->get_sub_app( 'reactors' )->get( $this->reaction->get_reactor_slug() );
393
+		$reactor = $this->hooks->get_sub_app('reactors')->get($this->reaction->get_reactor_slug());
394 394
 
395
-		if ( $reactor instanceof WordPoints_Hook_Retroactive_Query_FilterI ) {
396
-			$reactor->filter_retroactive_query( $this );
395
+		if ($reactor instanceof WordPoints_Hook_Retroactive_Query_FilterI) {
396
+			$reactor->filter_retroactive_query($this);
397 397
 		}
398 398
 
399
-		foreach ( $this->hooks->get_sub_app( 'extensions' )->get_all() as $extension ) {
400
-			if ( $extension instanceof WordPoints_Hook_Retroactive_Query_FilterI ) {
401
-				$extension->filter_retroactive_query( $this );
399
+		foreach ($this->hooks->get_sub_app('extensions')->get_all() as $extension) {
400
+			if ($extension instanceof WordPoints_Hook_Retroactive_Query_FilterI) {
401
+				$extension->filter_retroactive_query($this);
402 402
 			}
403 403
 		}
404 404
 	}
@@ -407,27 +407,27 @@  discard block
 block discarded – undo
407 407
 
408 408
 		$grouped_results = array();
409 409
 
410
-		foreach ( $this->results as $result ) {
411
-			$grouped_results[ $result->target ][] = $result;
410
+		foreach ($this->results as $result) {
411
+			$grouped_results[$result->target][] = $result;
412 412
 		}
413 413
 
414 414
 		$this->results = $grouped_results;
415 415
 	}
416 416
 
417
-	public function add_condition( array $condition ) {
417
+	public function add_condition(array $condition) {
418 418
 
419
-		$this->arg_hierarchy->push_to( 'conditions', $condition );
419
+		$this->arg_hierarchy->push_to('conditions', $condition);
420 420
 	}
421 421
 
422
-	public function select_value( $data = array() ) {
422
+	public function select_value($data = array()) {
423 423
 
424
-		$this->arg_hierarchy->set_field( 'select', $data );
424
+		$this->arg_hierarchy->set_field('select', $data);
425 425
 	}
426 426
 
427
-	public function set_target( $target_arg ) {
427
+	public function set_target($target_arg) {
428 428
 
429
-		foreach ( $target_arg as $arg_slug ) {
430
-			$this->arg_hierarchy_push( $arg_slug );
429
+		foreach ($target_arg as $arg_slug) {
430
+			$this->arg_hierarchy_push($arg_slug);
431 431
 		}
432 432
 
433 433
 //		$id = $this->arg_hierarchy->get_id();
@@ -437,10 +437,10 @@  discard block
 block discarded – undo
437 437
 //			$field = $this->arg_hierarchy->get_field( 'storage_info', 'meta', 'field' );
438 438
 //			$this->arg_hierarchy->ascend();
439 439
 //		} else {
440
-			$field = $this->arg_hierarchy->get_field( 'storage_info', 'meta', 'id_field' );
440
+			$field = $this->arg_hierarchy->get_field('storage_info', 'meta', 'id_field');
441 441
 //		}
442 442
 
443
-		$this->select_value( array( 'field' => $field, 'as' => 'target' ) );
443
+		$this->select_value(array('field' => $field, 'as' => 'target'));
444 444
 
445 445
 //		$this->arg_hierarchy->go_to( $id );
446 446
 	}
@@ -452,40 +452,40 @@  discard block
 block discarded – undo
452 452
 	 * @return WordPoints_EntityishI
453 453
 	 */
454 454
 	public function get_arg() {
455
-		return $this->arg_hierarchy->get_field( 'arg' );
455
+		return $this->arg_hierarchy->get_field('arg');
456 456
 	}
457 457
 
458
-	public function arg_hierarchy_push( $slug ) {
458
+	public function arg_hierarchy_push($slug) {
459 459
 
460
-		$current_slug = $this->arg_hierarchy->get_field( 'slug' );
460
+		$current_slug = $this->arg_hierarchy->get_field('slug');
461 461
 
462
-		if ( $current_slug === $slug && $this->arg_hierarchy->is_main() ) {
462
+		if ($current_slug === $slug && $this->arg_hierarchy->is_main()) {
463 463
 			return;
464 464
 		}
465 465
 
466 466
 //		if ( $current_slug !== $slug ) {
467 467
 
468
-			if ( empty( $current_slug ) ) {
469
-				$arg = $this->entities->get( $slug );
468
+			if (empty($current_slug)) {
469
+				$arg = $this->entities->get($slug);
470 470
 			} else {
471 471
 
472 472
 				// If this child exists, don't overwrite it, just descend into it.
473
-				if ( $this->arg_hierarchy->has_child( $slug ) ) {
474
-					$this->arg_hierarchy->descend( $slug );
473
+				if ($this->arg_hierarchy->has_child($slug)) {
474
+					$this->arg_hierarchy->descend($slug);
475 475
 					return;
476 476
 				}
477 477
 
478
-				$parent_arg = $this->arg_hierarchy->get_field( 'arg' );
478
+				$parent_arg = $this->arg_hierarchy->get_field('arg');
479 479
 
480
-				if ( $parent_arg instanceof WordPoints_Entity_ParentI ) {
481
-					$arg = $parent_arg->get_child( $slug );
480
+				if ($parent_arg instanceof WordPoints_Entity_ParentI) {
481
+					$arg = $parent_arg->get_child($slug);
482 482
 				} else {
483 483
 					return; // TODO
484 484
 				}
485 485
 			}
486 486
 
487
-			if ( $arg instanceof WordPoints_Entity_Array ) {
488
-				$arg = $this->entities->get( $arg->get_entity_slug() );
487
+			if ($arg instanceof WordPoints_Entity_Array) {
488
+				$arg = $this->entities->get($arg->get_entity_slug());
489 489
 			}
490 490
 
491 491
 			$data['arg'] = $arg;
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 			// TODO check if storage type is recognized?
494 494
 			$data['storage_info'] = $arg->get_storage_info();
495 495
 
496
-			$this->arg_hierarchy->push( $slug, $data );
496
+			$this->arg_hierarchy->push($slug, $data);
497 497
 
498 498
 //		} else {
499 499
 //			$data = array();
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 }
511 511
 
512 512
 interface WordPoints_Hook_Retroactive_Query_FilterI {
513
-	public function filter_retroactive_query( WordPoints_Hook_Retroactive_QueryI $query );
513
+	public function filter_retroactive_query(WordPoints_Hook_Retroactive_QueryI $query);
514 514
 }
515 515
 
516 516
 interface WordPoints_Hook_Retroactive_Query_ExecutorI {
517
-	public function execute( $query );
517
+	public function execute($query);
518 518
 }
519 519
 
520 520
 /*
@@ -543,48 +543,48 @@  discard block
 block discarded – undo
543 543
 	protected $array;
544 544
 	protected $results;
545 545
 
546
-	public function execute( $query ) {
546
+	public function execute($query) {
547 547
 
548
-		foreach ( $query as $arg_data ) {
548
+		foreach ($query as $arg_data) {
549 549
 
550 550
 			$meta = $arg_data['storage_info']['meta'];
551 551
 
552
-			if ( isset( $meta['getter'] ) ) {
552
+			if (isset($meta['getter'])) {
553 553
 				$this->array = $meta['getter']();
554 554
 			}
555 555
 
556
-			if ( isset( $arg_data['conditions'] ) ) {
556
+			if (isset($arg_data['conditions'])) {
557 557
 
558
-				foreach ( $arg_data['conditions'] as $condition ) {
558
+				foreach ($arg_data['conditions'] as $condition) {
559 559
 
560
-					if ( ! isset( $condition['field'] ) ) {
561
-						if ( $arg_data['arg'] instanceof WordPoints_Entity_Attr ) {
560
+					if ( ! isset($condition['field'])) {
561
+						if ($arg_data['arg'] instanceof WordPoints_Entity_Attr) {
562 562
 							$condition['field'] = $meta['field'];
563 563
 						} else {
564 564
 							$condition['field'] = $meta['id_field'];
565 565
 						}
566 566
 					}
567 567
 
568
-					if ( ! isset( $condition['condition'] ) ) {
568
+					if ( ! isset($condition['condition'])) {
569 569
 						$condition['condition'] = '=';
570 570
 					}
571 571
 
572 572
 					$filter_args = array();
573 573
 
574
-					switch ( $condition['condition'] ) {
574
+					switch ($condition['condition']) {
575 575
 
576 576
 						case '=':
577
-							$filter_args[ $condition['field'] ] = $condition['value'];
577
+							$filter_args[$condition['field']] = $condition['value'];
578 578
 							break;
579 579
 
580 580
 						case 'in':
581 581
 							// TODO
582 582
 
583 583
 						default:
584
-							return new WP_Error( 'invalid condition type' );
584
+							return new WP_Error('invalid condition type');
585 585
 					}
586 586
 
587
-					$this->array = wp_list_filter( $this->array, $filter_args );
587
+					$this->array = wp_list_filter($this->array, $filter_args);
588 588
 				}
589 589
 			}
590 590
 
@@ -592,9 +592,9 @@  discard block
 block discarded – undo
592 592
 //				$builder->add_field( $arg_data['select'] );
593 593
 //			}
594 594
 
595
-			if ( isset( $arg_data['sub_args'] ) ) {
595
+			if (isset($arg_data['sub_args'])) {
596 596
 				$this->parent_data = $arg_data;
597
-				$this->array = $this->execute( $arg_data['sub_args'] );
597
+				$this->array = $this->execute($arg_data['sub_args']);
598 598
 			}
599 599
 
600 600
 			$this->results = $this->array;
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 
624 624
 	protected $entered_join;
625 625
 
626
-	public function execute( $query ) {
626
+	public function execute($query) {
627 627
 		// WE should be getting a hierarchy object here.
628 628
 		// This will let us loop over things easier.
629 629
 		// We'll also need to be marking the non-usable parts of the query.
@@ -633,69 +633,69 @@  discard block
 block discarded – undo
633 633
 
634 634
 		$this->builder = new WordPoints_Query_Builder_DB_MySQL();
635 635
 
636
-		$this->build_query( $query );
636
+		$this->build_query($query);
637 637
 
638 638
 		$sql = $this->builder->get_query();
639 639
 
640
-		if ( is_wp_error( $sql ) ) {
640
+		if (is_wp_error($sql)) {
641 641
 			return $sql;
642 642
 		}
643 643
 
644
-		return $wpdb->get_results( $sql );
644
+		return $wpdb->get_results($sql);
645 645
 	}
646 646
 
647
-	protected function build_query( $args ) {
647
+	protected function build_query($args) {
648 648
 
649
-		foreach ( $args as $arg_data ) {
649
+		foreach ($args as $arg_data) {
650 650
 
651 651
 			$this->arg_data = $arg_data;
652 652
 
653
-			if ( isset( $arg_data['storage_info']['meta']['table_name'] ) ) {
654
-				$this->build_table_schema( $arg_data['storage_info']['meta'] );
653
+			if (isset($arg_data['storage_info']['meta']['table_name'])) {
654
+				$this->build_table_schema($arg_data['storage_info']['meta']);
655 655
 			}
656 656
 
657
-			if ( isset( $arg_data['conditions'] ) ) {
658
-				$this->build_conditions( $arg_data['conditions'] );
657
+			if (isset($arg_data['conditions'])) {
658
+				$this->build_conditions($arg_data['conditions']);
659 659
 			}
660 660
 
661
-			if ( isset( $arg_data['select'] ) ) {
662
-				$this->builder->add_field( $arg_data['select'] );
661
+			if (isset($arg_data['select'])) {
662
+				$this->builder->add_field($arg_data['select']);
663 663
 			}
664 664
 
665
-			if ( isset( $arg_data['sub_args'] ) ) {
665
+			if (isset($arg_data['sub_args'])) {
666 666
 
667 667
 				$this->grandparent_data = $this->parent_data;
668 668
 				$this->parent_data = $arg_data;
669 669
 
670
-				$this->build_query( $arg_data['sub_args'] );
670
+				$this->build_query($arg_data['sub_args']);
671 671
 
672 672
 				$this->parent_data = $this->grandparent_data;
673 673
 			}
674 674
 
675
-			if ( isset( $this->entered_join ) ) {
675
+			if (isset($this->entered_join)) {
676 676
 				$this->builder->exit_join();
677 677
 				$this->entered_join = null;
678 678
 			}
679 679
 		}
680 680
 	}
681 681
 
682
-	protected function build_table_schema( $db ) {
682
+	protected function build_table_schema($db) {
683 683
 
684
-		if ( $this->builder->get_table() ) {
684
+		if ($this->builder->get_table()) {
685 685
 
686
-			if ( $this->parent_data['arg'] instanceof WordPoints_Entity_Relationship ) {
686
+			if ($this->parent_data['arg'] instanceof WordPoints_Entity_Relationship) {
687 687
 				$primary_field = $this->parent_data['storage_info']['meta']['field'];
688 688
 				$join_field = $db['id_field'];
689 689
 				//$primary_field = $this->arg_data['arg']->get_secondary_field();
690
-			} elseif ( $this->arg_data['arg'] instanceof WordPoints_Entity_Relationship ) {
690
+			} elseif ($this->arg_data['arg'] instanceof WordPoints_Entity_Relationship) {
691 691
 				$join_field = $db['join_field'];
692 692
 				$primary_field = $this->parent_data['storage_info']['meta']['id_field'];
693 693
 			} else {
694
-				throw new WordPoints_Query_Builder_Exception( 'Houston, we have a problem.' );
694
+				throw new WordPoints_Query_Builder_Exception('Houston, we have a problem.');
695 695
 			}
696 696
 
697
-			if ( is_array( $primary_field ) && isset( $primary_field['table_name'] ) ) {
698
-				$this->builder->enter_join( $primary_field );
697
+			if (is_array($primary_field) && isset($primary_field['table_name'])) {
698
+				$this->builder->enter_join($primary_field);
699 699
 				$primary_field = $primary_field['on']['join_field'];
700 700
 			}
701 701
 
@@ -707,26 +707,26 @@  discard block
 block discarded – undo
707 707
 				),
708 708
 			);
709 709
 
710
-			if ( isset( $db['join_where'] ) ) {
710
+			if (isset($db['join_where'])) {
711 711
 				$join['where'] = $db['join_where'];
712 712
 			}
713 713
 
714
-			$this->builder->enter_join( $join );
714
+			$this->builder->enter_join($join);
715 715
 
716 716
 			$this->entered_join = true;
717 717
 
718 718
 		} else {
719
-			$this->builder->set_table( $db['table_name'] );
720
-			$this->builder->add_field( $db['id_field'] );
719
+			$this->builder->set_table($db['table_name']);
720
+			$this->builder->add_field($db['id_field']);
721 721
 		}
722 722
 	}
723 723
 
724
-	protected function build_conditions( $conditions ) {
724
+	protected function build_conditions($conditions) {
725 725
 
726 726
 		// Join conditions should be pushed to the end.
727 727
 		$join_conditions = array();
728 728
 
729
-		foreach ( $conditions as $condition ) {
729
+		foreach ($conditions as $condition) {
730 730
 
731 731
 			// THis needs to be the identifier field for the type of arg that this
732 732
 			// field represents.
@@ -734,43 +734,43 @@  discard block
 block discarded – undo
734 734
 			// However, for a relationship it could be something else.
735 735
 			// Ultimately, this will have to be left up to the arg object to
736 736
 			// decide.
737
-			if ( ! isset( $condition['field'] ) ) {
738
-				if ( $this->arg_data['arg'] instanceof WordPoints_Entity_Relationship ) {
737
+			if ( ! isset($condition['field'])) {
738
+				if ($this->arg_data['arg'] instanceof WordPoints_Entity_Relationship) {
739 739
 //					$condition['field'] = $this->arg_data['arg']->get_secondary_field();
740 740
 					$condition['field'] = $this->arg_data['storage_info']['meta']['field'];
741 741
 
742
-					if ( is_array( $condition['field'] && isset( $condition['field']['table_name'] ) ) ) {
742
+					if (is_array($condition['field'] && isset($condition['field']['table_name']))) {
743 743
 						$join_conditions[] = $condition;
744 744
 						continue;
745 745
 					}
746
-				} elseif ( $this->arg_data['arg'] instanceof WordPoints_Entity_Attr ) {
746
+				} elseif ($this->arg_data['arg'] instanceof WordPoints_Entity_Attr) {
747 747
 					$condition['field'] = $this->arg_data['arg']->get_field();
748 748
 				} else {
749
-					var_dump($this->arg_data['arg']);exit;
749
+					var_dump($this->arg_data['arg']); exit;
750 750
 				}
751 751
 			}
752 752
 
753
-			$this->builder->where( $condition );
753
+			$this->builder->where($condition);
754 754
 		}
755 755
 
756
-		$join_count = count( $join_conditions );
756
+		$join_count = count($join_conditions);
757 757
 		$i = 0;
758 758
 
759
-		foreach ( $join_conditions as $condition ) {
759
+		foreach ($join_conditions as $condition) {
760 760
 
761 761
 			$i++;
762 762
 
763
-			$this->builder->enter_join( $condition['field'] );
763
+			$this->builder->enter_join($condition['field']);
764 764
 
765 765
 			$condition['field'] = $condition['field']['on']['primary_field'];
766 766
 
767
-			$this->builder->where( $condition );
767
+			$this->builder->where($condition);
768 768
 
769 769
 			$this->builder->exit_join();
770 770
 
771 771
 			// If there are more join conditions, we need to leave a fresh, trailing
772 772
 			// join for the next one to join to.
773
-			if ( $i < $join_count ) {
773
+			if ($i < $join_count) {
774 774
 
775 775
 				// There is a current join, but it is already being used, so we
776 776
 				// need to exit it.
Please login to merge, or discard this patch.
src/includes/classes/hook/events.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @since 1.0.0
37 37
 	 */
38
-	public function __construct( $slug ) {
38
+	public function __construct($slug) {
39 39
 
40 40
 		$hooks = wordpoints_hooks();
41 41
 
42
-		$this->router = $hooks->get_sub_app( 'router' );
42
+		$this->router = $hooks->get_sub_app('router');
43 43
 
44
-		parent::__construct( $slug );
44
+		parent::__construct($slug);
45 45
 	}
46 46
 
47 47
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function init() {
51 51
 
52
-		$this->sub_apps()->register( 'args', 'WordPoints_Class_Registry_Children' );
52
+		$this->sub_apps()->register('args', 'WordPoints_Class_Registry_Children');
53 53
 
54 54
 		parent::init();
55 55
 	}
@@ -73,27 +73,27 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return bool Whether the event was registered.
75 75
 	 */
76
-	public function register( $slug, $class, array $args = array() ) {
76
+	public function register($slug, $class, array $args = array()) {
77 77
 
78
-		parent::register( $slug, $class, $args );
78
+		parent::register($slug, $class, $args);
79 79
 
80
-		if ( isset( $args['actions'] ) ) {
81
-			foreach ( $args['actions'] as $type => $actions ) {
82
-				foreach ( (array) $actions as $action_slug ) {
83
-					$this->router->add_event_to_action( $slug, $action_slug, $type );
80
+		if (isset($args['actions'])) {
81
+			foreach ($args['actions'] as $type => $actions) {
82
+				foreach ((array) $actions as $action_slug) {
83
+					$this->router->add_event_to_action($slug, $action_slug, $type);
84 84
 				}
85 85
 			}
86 86
 		}
87 87
 
88
-		if ( isset( $args['args'] ) ) {
89
-			$args_registry = $this->get_sub_app( 'args' );
88
+		if (isset($args['args'])) {
89
+			$args_registry = $this->get_sub_app('args');
90 90
 
91
-			foreach ( $args['args'] as $arg_slug => $class ) {
92
-				$args_registry->register( $slug, $arg_slug, $class );
91
+			foreach ($args['args'] as $arg_slug => $class) {
92
+				$args_registry->register($slug, $arg_slug, $class);
93 93
 			}
94 94
 		}
95 95
 
96
-		$this->event_data[ $slug ] = $args;
96
+		$this->event_data[$slug] = $args;
97 97
 
98 98
 		return true;
99 99
 	}
@@ -101,23 +101,23 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * @since 1.0.0
103 103
 	 */
104
-	public function deregister( $slug ) {
104
+	public function deregister($slug) {
105 105
 
106
-		if ( ! $this->is_registered( $slug ) ) {
106
+		if ( ! $this->is_registered($slug)) {
107 107
 			return;
108 108
 		}
109 109
 
110
-		parent::deregister( $slug );
110
+		parent::deregister($slug);
111 111
 
112
-		foreach ( (array) $this->event_data[ $slug ]['actions'] as $type => $actions ) {
113
-			foreach ( (array) $actions as $action_slug ) {
114
-				$this->router->remove_event_from_action( $slug, $action_slug, $type );
112
+		foreach ((array) $this->event_data[$slug]['actions'] as $type => $actions) {
113
+			foreach ((array) $actions as $action_slug) {
114
+				$this->router->remove_event_from_action($slug, $action_slug, $type);
115 115
 			}
116 116
 		}
117 117
 
118
-		$this->get_sub_app( 'args' )->deregister_children( $slug );
118
+		$this->get_sub_app('args')->deregister_children($slug);
119 119
 
120
-		unset( $this->event_data[ $slug ] );
120
+		unset($this->event_data[$slug]);
121 121
 	}
122 122
 }
123 123
 
Please login to merge, or discard this patch.
src/includes/classes/entity.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return mixed The entity, or false if not found.
108 108
 	 */
109
-	protected function get_entity( $id ) {
109
+	protected function get_entity($id) {
110 110
 
111
-		$entity = call_user_func( $this->getter, $id );
111
+		$entity = call_user_func($this->getter, $id);
112 112
 
113
-		if ( ! $this->is_entity( $entity ) ) {
113
+		if ( ! $this->is_entity($entity)) {
114 114
 			return false;
115 115
 		}
116 116
 
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return bool Whether the passed value is an entity.
128 128
 	 */
129
-	protected function is_entity( $entity ) {
129
+	protected function is_entity($entity) {
130 130
 
131
-		if ( ! is_object( $entity ) && ! is_array( $entity ) ) {
131
+		if ( ! is_object($entity) && ! is_array($entity)) {
132 132
 			return false;
133 133
 		}
134 134
 
135
-		return (bool) $this->get_entity_id( $entity );
135
+		return (bool) $this->get_entity_id($entity);
136 136
 	}
137 137
 
138 138
 	/**
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @return mixed The value of the attribute of the entity.
147 147
 	 */
148
-	protected function get_attr_value( $entity, $attr ) {
148
+	protected function get_attr_value($entity, $attr) {
149 149
 
150
-		if ( is_array( $entity ) ) {
151
-			if ( isset( $entity[ $attr ] ) ) {
152
-				return $entity[ $attr ];
150
+		if (is_array($entity)) {
151
+			if (isset($entity[$attr])) {
152
+				return $entity[$attr];
153 153
 			}
154 154
 		} else {
155
-			if ( isset( $entity->{$attr} ) ) {
155
+			if (isset($entity->{$attr} )) {
156 156
 				return $entity->{$attr};
157 157
 			}
158 158
 		}
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @return mixed The ID of the entity.
171 171
 	 */
172
-	protected function get_entity_id( $entity ) {
173
-		return $this->get_attr_value( $entity, $this->get_id_field() );
172
+	protected function get_entity_id($entity) {
173
+		return $this->get_attr_value($entity, $this->get_id_field());
174 174
 	}
175 175
 
176 176
 	/**
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return mixed The human ID of the entity.
188 188
 	 */
189
-	protected function get_entity_human_id( $entity ) {
190
-		return $this->get_attr_value( $entity, $this->human_id_field );
189
+	protected function get_entity_human_id($entity) {
190
+		return $this->get_attr_value($entity, $this->human_id_field);
191 191
 	}
192 192
 
193 193
 	//
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return string|int|float|false The human identifier for the entity, or false.
231 231
 	 */
232
-	public function get_human_id( $id ) {
232
+	public function get_human_id($id) {
233 233
 
234
-		$entity = $this->get_entity( $id );
234
+		$entity = $this->get_entity($id);
235 235
 
236
-		if ( ! $entity ) {
236
+		if ( ! $entity) {
237 237
 			return false;
238 238
 		}
239 239
 
240
-		return $this->get_entity_human_id( $entity );
240
+		return $this->get_entity_human_id($entity);
241 241
 	}
242 242
 
243 243
 	/**
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 	 *
250 250
 	 * @return bool Whether or not an entity with that ID exists.
251 251
 	 */
252
-	public function exists( $id ) {
253
-		return (bool) $this->get_entity( $id );
252
+	public function exists($id) {
253
+		return (bool) $this->get_entity($id);
254 254
 	}
255 255
 
256 256
 	/**
@@ -265,17 +265,17 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @return WordPoints_Entityish|false The child's object, or false if not found.
267 267
 	 */
268
-	public function get_child( $child_slug ) {
268
+	public function get_child($child_slug) {
269 269
 
270
-		$children = wordpoints_entities()->get_sub_app( 'children' );
270
+		$children = wordpoints_entities()->get_sub_app('children');
271 271
 
272
-		$child = $children->get( $this->slug, $child_slug );
272
+		$child = $children->get($this->slug, $child_slug);
273 273
 
274 274
 		if (
275
-			isset( $this->the_value )
275
+			isset($this->the_value)
276 276
 			&& $child instanceof WordPoints_Entity_ChildI
277 277
 		) {
278
-			$child->set_the_value_from_entity( $this );
278
+			$child->set_the_value_from_entity($this);
279 279
 		}
280 280
 
281 281
 		return $child;
@@ -297,20 +297,20 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return bool Whether the value was set.
299 299
 	 */
300
-	public function set_the_value( $value ) {
300
+	public function set_the_value($value) {
301 301
 
302 302
 		$this->the_value = $this->the_entity = $this->the_context = null;
303 303
 
304
-		if ( $this->is_entity( $value ) ) {
304
+		if ($this->is_entity($value)) {
305 305
 
306 306
 			$entity = $value;
307
-			$value = $this->get_entity_id( $value );
307
+			$value = $this->get_entity_id($value);
308 308
 
309 309
 		} else {
310 310
 
311
-			$entity = $this->get_entity( $value );
311
+			$entity = $this->get_entity($value);
312 312
 
313
-			if ( ! $entity ) {
313
+			if ( ! $entity) {
314 314
 				return false;
315 315
 			}
316 316
 		}
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 	 *
334 334
 	 * @return mixed The value of the attribute.
335 335
 	 */
336
-	public function get_the_attr_value( $attr ) {
337
-		return $this->get_attr_value( $this->the_entity, $attr );
336
+	public function get_the_attr_value($attr) {
337
+		return $this->get_attr_value($this->the_entity, $attr);
338 338
 	}
339 339
 
340 340
 	/**
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 * @return string|int|float|null The human identifier for the entity, or null.
359 359
 	 */
360 360
 	public function get_the_human_id() {
361
-		return $this->get_entity_human_id( $this->the_entity );
361
+		return $this->get_entity_human_id($this->the_entity);
362 362
 	}
363 363
 
364 364
 	/**
@@ -392,11 +392,11 @@  discard block
 block discarded – undo
392 392
 
393 393
 		$guid = $this->get_the_context();
394 394
 
395
-		if ( ! is_array( $guid ) ) {
395
+		if ( ! is_array($guid)) {
396 396
 			return $guid;
397 397
 		}
398 398
 
399
-		$guid = array( $this->slug => $this->get_the_id() ) + $guid;
399
+		$guid = array($this->slug => $this->get_the_id()) + $guid;
400 400
 
401 401
 		return $guid;
402 402
 	}
Please login to merge, or discard this patch.
src/includes/functions.php 1 patch
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	// Just accessing this causes it to be initialized. We need to do that so
22 22
 	// the actions will be registered and hooked up. The rest of the API can be
23 23
 	// lazy-loaded as it is needed.
24
-	$hooks->get_sub_app( 'actions' );
24
+	$hooks->get_sub_app('actions');
25 25
 }
26 26
 
27 27
 /**
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
  *
34 34
  * @param WordPoints_Class_Registry_Persistent $reactors The reactors registry.
35 35
  */
36
-function wordpoints_hook_reactors_init( $reactors ) {
36
+function wordpoints_hook_reactors_init($reactors) {
37 37
 
38
-	$reactors->register( 'points', 'WordPoints_Hook_Reactor_Points' );
39
-	$reactors->register( 'points_legacy', 'WordPoints_Hook_Reactor_Points_Legacy' );
38
+	$reactors->register('points', 'WordPoints_Hook_Reactor_Points');
39
+	$reactors->register('points_legacy', 'WordPoints_Hook_Reactor_Points_Legacy');
40 40
 }
41 41
 
42 42
 /**
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  *
49 49
  * @param WordPoints_Class_Registry_Children $reaction_stores The store registry.
50 50
  */
51
-function wordpoints_hook_reaction_stores_init( $reaction_stores ) {
51
+function wordpoints_hook_reaction_stores_init($reaction_stores) {
52 52
 
53 53
 	$reaction_stores->register(
54 54
 		'standard'
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		, 'WordPoints_Hook_Reaction_Store_Options'
57 57
 	);
58 58
 
59
-	if ( is_wordpoints_network_active() ) {
59
+	if (is_wordpoints_network_active()) {
60 60
 		$reaction_stores->register(
61 61
 			'network'
62 62
 			, 'points'
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
  *
75 75
  * @param WordPoints_Class_Registry_Persistent $extensions The extension registry.
76 76
  */
77
-function wordpoints_hook_extension_init( $extensions ) {
78
-
79
-	$extensions->register( 'blocker', 'WordPoints_Hook_Extension_Blocker' );
80
-	$extensions->register( 'repeat_blocker', 'WordPoints_Hook_Extension_Repeat_Blocker' );
81
-	$extensions->register( 'reversals', 'WordPoints_Hook_Extension_Reversals' );
82
-	$extensions->register( 'reversals_legacy_points', 'WordPoints_Hook_Extension_Reversals_Legacy_Points' );
83
-	$extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' );
84
-	$extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' );
77
+function wordpoints_hook_extension_init($extensions) {
78
+
79
+	$extensions->register('blocker', 'WordPoints_Hook_Extension_Blocker');
80
+	$extensions->register('repeat_blocker', 'WordPoints_Hook_Extension_Repeat_Blocker');
81
+	$extensions->register('reversals', 'WordPoints_Hook_Extension_Reversals');
82
+	$extensions->register('reversals_legacy_points', 'WordPoints_Hook_Extension_Reversals_Legacy_Points');
83
+	$extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions');
84
+	$extensions->register('periods', 'WordPoints_Hook_Extension_Periods');
85 85
 }
86 86
 
87 87
 /**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
  *
94 94
  * @param WordPoints_Class_Registry_Children $conditions The conditions registry.
95 95
  */
96
-function wordpoints_hook_conditions_init( $conditions ) {
96
+function wordpoints_hook_conditions_init($conditions) {
97 97
 
98 98
 	$conditions->register(
99 99
 		'text'
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
  *
130 130
  * @param WordPoints_Hook_Actions $actions The action registry.
131 131
  */
132
-function wordpoints_hook_actions_init( $actions ) {
132
+function wordpoints_hook_actions_init($actions) {
133 133
 
134 134
 	$actions->register(
135 135
 		'comment_approve'
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 		, array(
138 138
 			'action' => 'transition_comment_status',
139 139
 			'data'   => array(
140
-				'arg_index'    => array( 'comment' => 2 ),
141
-				'requirements' => array( 0 => 'approved' ),
140
+				'arg_index'    => array('comment' => 2),
141
+				'requirements' => array(0 => 'approved'),
142 142
 			),
143 143
 		)
144 144
 	);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		, array(
150 150
 			'action' => 'wp_insert_comment',
151 151
 			'data'   => array(
152
-				'arg_index' => array( 'comment' => 1 ),
152
+				'arg_index' => array('comment' => 1),
153 153
 			),
154 154
 		)
155 155
 	);
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 		, array(
161 161
 			'action' => 'transition_comment_status',
162 162
 			'data'   => array(
163
-				'arg_index' => array( 'comment' => 2 ),
164
-				'requirements' => array( 1 => 'approved' ),
163
+				'arg_index' => array('comment' => 2),
164
+				'requirements' => array(1 => 'approved'),
165 165
 			),
166 166
 		)
167 167
 	);
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 		, array(
174 174
 			'action' => 'transition_post_status',
175 175
 			'data'   => array(
176
-				'arg_index' => array( 'post' => 2 ),
177
-				'requirements' => array( 0 => 'publish' ),
176
+				'arg_index' => array('post' => 2),
177
+				'requirements' => array(0 => 'publish'),
178 178
 			),
179 179
 		)
180 180
 	);
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 		, array(
186 186
 			'action' => 'transition_post_status',
187 187
 			'data'   => array(
188
-				'arg_index' => array( 'post' => 2 ),
189
-				'requirements' => array( 1 => 'publish' ),
188
+				'arg_index' => array('post' => 2),
189
+				'requirements' => array(1 => 'publish'),
190 190
 			),
191 191
 		)
192 192
 	);
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		, array(
198 198
 			'action' => 'delete_post',
199 199
 			'data'   => array(
200
-				'arg_index' => array( 'post' => 0 ),
200
+				'arg_index' => array('post' => 0),
201 201
 			),
202 202
 		)
203 203
 	);
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		, array(
209 209
 			'action' => 'add_attachment',
210 210
 			'data'   => array(
211
-				'arg_index' => array( 'post\attachment' => 0 ),
211
+				'arg_index' => array('post\attachment' => 0),
212 212
 			),
213 213
 		)
214 214
 	);
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		, array(
220 220
 			'action' => 'delete_post',
221 221
 			'data'   => array(
222
-				'arg_index' => array( 'post' => 0 ),
222
+				'arg_index' => array('post' => 0),
223 223
 			),
224 224
 		)
225 225
 	);
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		, array(
231 231
 			'action' => 'user_register',
232 232
 			'data'   => array(
233
-				'arg_index' => array( 'user' => 0 ),
233
+				'arg_index' => array('user' => 0),
234 234
 			),
235 235
 		)
236 236
 	);
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		, array(
242 242
 			'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user',
243 243
 			'data'   => array(
244
-				'arg_index' => array( 'user' => 0 ),
244
+				'arg_index' => array('user' => 0),
245 245
 			),
246 246
 		)
247 247
 	);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
  *
265 265
  * @param WordPoints_Hook_Events $events The event registry.
266 266
  */
267
-function wordpoints_hook_events_init( $events ) {
267
+function wordpoints_hook_events_init($events) {
268 268
 
269 269
 	$events->register(
270 270
 		'user_register'
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	);
295 295
 
296 296
 	// Register events for all of the public post types.
297
-	$post_types = get_post_types( array( 'public' => true ) );
297
+	$post_types = get_post_types(array('public' => true));
298 298
 
299 299
 	/**
300 300
 	 * Filter which post types to register hook events for.
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @param string[] The post type slugs ("names").
305 305
 	 */
306
-	$post_types = apply_filters( 'wordpoints_register_hook_events_for_post_types', $post_types );
306
+	$post_types = apply_filters('wordpoints_register_hook_events_for_post_types', $post_types);
307 307
 
308
-	foreach ( $post_types as $slug ) {
309
-		wordpoints_register_post_type_hook_events( $slug );
308
+	foreach ($post_types as $slug) {
309
+		wordpoints_register_post_type_hook_events($slug);
310 310
 	}
311 311
 }
312 312
 
@@ -319,11 +319,11 @@  discard block
 block discarded – undo
319 319
  *
320 320
  * @param WordPoints_App_Registry $entities The entities app.
321 321
  */
322
-function wordpoints_entities_app_init( $entities ) {
322
+function wordpoints_entities_app_init($entities) {
323 323
 
324 324
 	$sub_apps = $entities->sub_apps();
325
-	$sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' );
326
-	$sub_apps->register( 'contexts', 'WordPoints_Class_Registry' );
325
+	$sub_apps->register('children', 'WordPoints_Class_Registry_Children');
326
+	$sub_apps->register('contexts', 'WordPoints_Class_Registry');
327 327
 }
328 328
 
329 329
 /**
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
  *
336 336
  * @param WordPoints_Class_RegistryI $contexts The entity context registry.
337 337
  */
338
-function wordpoints_entity_contexts_init( $contexts ) {
338
+function wordpoints_entity_contexts_init($contexts) {
339 339
 
340
-	$contexts->register( 'network', 'WordPoints_Entity_Context_Network' );
341
-	$contexts->register( 'site', 'WordPoints_Entity_Context_Site' );
340
+	$contexts->register('network', 'WordPoints_Entity_Context_Network');
341
+	$contexts->register('site', 'WordPoints_Entity_Context_Site');
342 342
 }
343 343
 
344 344
 /**
@@ -350,17 +350,17 @@  discard block
 block discarded – undo
350 350
  *
351 351
  * @param WordPoints_App_Registry $entities The entities app.
352 352
  */
353
-function wordpoints_entities_init( $entities ) {
353
+function wordpoints_entities_init($entities) {
354 354
 
355
-	$children = $entities->get_sub_app( 'children' );
355
+	$children = $entities->get_sub_app('children');
356 356
 
357
-	$entities->register( 'user', 'WordPoints_Entity_User' );
358
-	$children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' );
357
+	$entities->register('user', 'WordPoints_Entity_User');
358
+	$children->register('user', 'roles', 'WordPoints_Entity_User_Roles');
359 359
 
360
-	$entities->register( 'user_role', 'WordPoints_Entity_User_Role' );
360
+	$entities->register('user_role', 'WordPoints_Entity_User_Role');
361 361
 
362 362
 	// Register entities for all of the public post types.
363
-	$post_types = get_post_types( array( 'public' => true ) );
363
+	$post_types = get_post_types(array('public' => true));
364 364
 
365 365
 	/**
366 366
 	 * Filter which post types to register entities for.
@@ -369,14 +369,14 @@  discard block
 block discarded – undo
369 369
 	 *
370 370
 	 * @param string[] The post type slugs ("names").
371 371
 	 */
372
-	$post_types = apply_filters( 'wordpoints_register_entities_for_post_types', $post_types );
372
+	$post_types = apply_filters('wordpoints_register_entities_for_post_types', $post_types);
373 373
 
374
-	foreach ( $post_types as $slug ) {
375
-		wordpoints_register_post_type_entities( $slug );
374
+	foreach ($post_types as $slug) {
375
+		wordpoints_register_post_type_entities($slug);
376 376
 	}
377 377
 
378 378
 	// Register entities for all of the public taxonomies.
379
-	$taxonomies = get_taxonomies( array( 'public' => true ) );
379
+	$taxonomies = get_taxonomies(array('public' => true));
380 380
 
381 381
 	/**
382 382
 	 * Filter which taxonomies to register entities for.
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 	 *
386 386
 	 * @param string[] The taxonomy slugs.
387 387
 	 */
388
-	$taxonomies = apply_filters( 'wordpoints_register_entities_for_taxonomies', $taxonomies );
388
+	$taxonomies = apply_filters('wordpoints_register_entities_for_taxonomies', $taxonomies);
389 389
 
390
-	foreach ( $taxonomies as $slug ) {
391
-		wordpoints_register_taxonomy_entities( $slug );
390
+	foreach ($taxonomies as $slug) {
391
+		wordpoints_register_taxonomy_entities($slug);
392 392
 	}
393 393
 }
394 394
 
@@ -399,28 +399,28 @@  discard block
 block discarded – undo
399 399
  *
400 400
  * @param string $slug The slug of the post type.
401 401
  */
402
-function wordpoints_register_post_type_entities( $slug ) {
402
+function wordpoints_register_post_type_entities($slug) {
403 403
 
404 404
 	$entities = wordpoints_entities();
405
-	$children = $entities->get_sub_app( 'children' );
405
+	$children = $entities->get_sub_app('children');
406 406
 
407
-	$entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' );
408
-	$children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' );
407
+	$entities->register("post\\{$slug}", 'WordPoints_Entity_Post');
408
+	$children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author');
409 409
 
410
-	$supports = get_all_post_type_supports( $slug );
410
+	$supports = get_all_post_type_supports($slug);
411 411
 
412
-	if ( isset( $supports['editor'] ) ) {
413
-		$children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' );
412
+	if (isset($supports['editor'])) {
413
+		$children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content');
414 414
 	}
415 415
 
416
-	if ( isset( $supports['comments'] ) ) {
417
-		$entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' );
418
-		$children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' );
419
-		$children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' );
416
+	if (isset($supports['comments'])) {
417
+		$entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment');
418
+		$children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post');
419
+		$children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author');
420 420
 	}
421 421
 
422
-	foreach ( get_object_taxonomies( $slug ) as $taxonomy_slug ) {
423
-		$children->register( "post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms' );
422
+	foreach (get_object_taxonomies($slug) as $taxonomy_slug) {
423
+		$children->register("post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms');
424 424
 	}
425 425
 
426 426
 	/**
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 	 *
431 431
 	 * @param string $slug The slug ("name") of the post type.
432 432
 	 */
433
-	do_action( 'wordpoints_register_post_type_entities', $slug );
433
+	do_action('wordpoints_register_post_type_entities', $slug);
434 434
 }
435 435
 
436 436
 /**
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
  *
441 441
  * @param string $slug The slug of the post type.
442 442
  */
443
-function wordpoints_register_post_type_hook_events( $slug ) {
443
+function wordpoints_register_post_type_hook_events($slug) {
444 444
 
445
-	$events = wordpoints_hooks()->get_sub_app( 'events' );
445
+	$events = wordpoints_hooks()->get_sub_app('events');
446 446
 
447
-	if ( 'attachment' === $slug ) {
447
+	if ('attachment' === $slug) {
448 448
 
449 449
 		$events->register(
450 450
 			'media_upload'
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 			, array(
469 469
 				'actions' => array(
470 470
 					'toggle_on'  => 'post_publish',
471
-					'toggle_off' => array( 'post_depublish', 'post_depublish_delete' ),
471
+					'toggle_off' => array('post_depublish', 'post_depublish_delete'),
472 472
 				),
473 473
 				'args'    => array(
474 474
 					"post\\{$slug}" => 'WordPoints_Hook_Arg_Dynamic',
@@ -477,14 +477,14 @@  discard block
 block discarded – undo
477 477
 		);
478 478
 	}
479 479
 
480
-	if ( post_type_supports( $slug, 'comments' ) ) {
480
+	if (post_type_supports($slug, 'comments')) {
481 481
 
482 482
 		$events->register(
483 483
 			"comment_leave\\{$slug}"
484 484
 			, 'WordPoints_Hook_Event_Comment_Leave'
485 485
 			, array(
486 486
 				'actions' => array(
487
-					'toggle_on'  => array( 'comment_approve', 'comment_new' ),
487
+					'toggle_on'  => array('comment_approve', 'comment_new'),
488 488
 					'toggle_off' => 'comment_deapprove',
489 489
 				),
490 490
 				'args' => array(
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @param string $slug The slug ("name") of the post type.
503 503
 	 */
504
-	do_action( 'wordpoints_register_post_type_hook_events', $slug );
504
+	do_action('wordpoints_register_post_type_hook_events', $slug);
505 505
 }
506 506
 
507 507
 /**
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
  *
512 512
  * @param string $slug The slug of the taxonomy.
513 513
  */
514
-function wordpoints_register_taxonomy_entities( $slug ) {
514
+function wordpoints_register_taxonomy_entities($slug) {
515 515
 
516 516
 	$entities = wordpoints_entities();
517
-	$children = $entities->get_sub_app( 'children' );
517
+	$children = $entities->get_sub_app('children');
518 518
 
519
-	$entities->register( "term\\{$slug}", 'WordPoints_Entity_Term' );
520
-	$children->register( "term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id' );
519
+	$entities->register("term\\{$slug}", 'WordPoints_Entity_Term');
520
+	$children->register("term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id');
521 521
 
522 522
 	/**
523 523
 	 * Fired when registering the entities for a taxonomy.
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 	 *
527 527
 	 * @param string $slug The taxonomy's slug.
528 528
 	 */
529
-	do_action( 'wordpoints_register_taxonomy_entities', $slug );
529
+	do_action('wordpoints_register_taxonomy_entities', $slug);
530 530
 }
531 531
 
532 532
 /**
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
  *
539 539
  * @param WordPoints_Class_RegistryI $data_types The data types registry.
540 540
  */
541
-function wordpoints_data_types_init( $data_types ) {
541
+function wordpoints_data_types_init($data_types) {
542 542
 
543
-	$data_types->register( 'integer', 'WordPoints_Data_Type_Integer' );
544
-	$data_types->register( 'text', 'WordPoints_Data_Type_Text' );
543
+	$data_types->register('integer', 'WordPoints_Data_Type_Integer');
544
+	$data_types->register('text', 'WordPoints_Data_Type_Text');
545 545
 }
546 546
 
547 547
 /**
@@ -556,9 +556,9 @@  discard block
 block discarded – undo
556 556
  *
557 557
  * @return bool Whether the user can view the points log.
558 558
  */
559
-function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) {
559
+function wordpoints_hooks_user_can_view_points_log($can_view, $log) {
560 560
 
561
-	if ( ! $can_view ) {
561
+	if ( ! $can_view) {
562 562
 		return $can_view;
563 563
 	}
564 564
 
@@ -567,11 +567,11 @@  discard block
 block discarded – undo
567 567
 	$event_slug = $log->log_type;
568 568
 
569 569
 	/** @var WordPoints_Hook_ArgI $arg */
570
-	foreach ( wordpoints_hooks()->get_sub_app( 'events' )->get_sub_app( 'args' )->get_children( $event_slug ) as $slug => $arg ) {
570
+	foreach (wordpoints_hooks()->get_sub_app('events')->get_sub_app('args')->get_children($event_slug) as $slug => $arg) {
571 571
 
572
-		$value = wordpoints_get_points_log_meta( $log->id, $slug, true );
572
+		$value = wordpoints_get_points_log_meta($log->id, $slug, true);
573 573
 
574
-		if ( ! $value ) {
574
+		if ( ! $value) {
575 575
 			continue;
576 576
 		}
577 577
 
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 			, $value
582 582
 		);
583 583
 
584
-		if ( ! $can_view ) {
584
+		if ( ! $can_view) {
585 585
 			break;
586 586
 		}
587 587
 	}
@@ -600,20 +600,20 @@  discard block
 block discarded – undo
600 600
  *
601 601
  * @return bool Whether the user can view this entity.
602 602
  */
603
-function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) {
603
+function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) {
604 604
 
605
-	$entity = wordpoints_entities()->get( $entity_slug );
605
+	$entity = wordpoints_entities()->get($entity_slug);
606 606
 
607 607
 	// If this entity type is not found, we have no way of determining whether it is
608 608
 	// safe for the user to view it.
609
-	if ( ! ( $entity instanceof WordPoints_Entity ) ) {
609
+	if ( ! ($entity instanceof WordPoints_Entity)) {
610 610
 		return false;
611 611
 	}
612 612
 
613 613
 	$can_view = true;
614 614
 
615
-	if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) {
616
-		$can_view = $entity->user_can_view( $user_id, $entity_id );
615
+	if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) {
616
+		$can_view = $entity->user_can_view($user_id, $entity_id);
617 617
 	}
618 618
 
619 619
 	/**
@@ -644,8 +644,8 @@  discard block
 block discarded – undo
644 644
  */
645 645
 function wordpoints_apps() {
646 646
 
647
-	if ( ! isset( WordPoints_App::$main ) ) {
648
-		WordPoints_App::$main = new WordPoints_App( 'apps' );
647
+	if ( ! isset(WordPoints_App::$main)) {
648
+		WordPoints_App::$main = new WordPoints_App('apps');
649 649
 	}
650 650
 
651 651
 	return WordPoints_App::$main;
@@ -660,11 +660,11 @@  discard block
 block discarded – undo
660 660
  */
661 661
 function wordpoints_hooks() {
662 662
 
663
-	if ( ! isset( WordPoints_App::$main ) ) {
663
+	if ( ! isset(WordPoints_App::$main)) {
664 664
 		wordpoints_apps();
665 665
 	}
666 666
 
667
-	return WordPoints_App::$main->get_sub_app( 'hooks' );
667
+	return WordPoints_App::$main->get_sub_app('hooks');
668 668
 }
669 669
 
670 670
 /**
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
  */
677 677
 function wordpoints_entities() {
678 678
 
679
-	if ( ! isset( WordPoints_App::$main ) ) {
679
+	if ( ! isset(WordPoints_App::$main)) {
680 680
 		wordpoints_apps();
681 681
 	}
682 682
 
683
-	return WordPoints_App::$main->get_sub_app( 'entities' );
683
+	return WordPoints_App::$main->get_sub_app('entities');
684 684
 }
685 685
 
686 686
 /**
@@ -692,13 +692,13 @@  discard block
 block discarded – undo
692 692
  *
693 693
  * @param WordPoints_App $app The main apps app.
694 694
  */
695
-function wordpoints_apps_init( $app ) {
695
+function wordpoints_apps_init($app) {
696 696
 
697 697
 	$apps = $app->sub_apps();
698 698
 
699
-	$apps->register( 'hooks', 'WordPoints_Hooks' );
700
-	$apps->register( 'entities', 'WordPoints_App_Registry' );
701
-	$apps->register( 'data_types', 'WordPoints_Class_Registry' );
699
+	$apps->register('hooks', 'WordPoints_Hooks');
700
+	$apps->register('entities', 'WordPoints_App_Registry');
701
+	$apps->register('data_types', 'WordPoints_Class_Registry');
702 702
 }
703 703
 
704 704
 /**
@@ -711,19 +711,19 @@  discard block
 block discarded – undo
711 711
  *
712 712
  * @return object|false The constructed object, or false if to many args were passed.
713 713
  */
714
-function wordpoints_construct_class_with_args( $class_name, array $args ) {
714
+function wordpoints_construct_class_with_args($class_name, array $args) {
715 715
 
716
-	switch ( count( $args ) ) {
716
+	switch (count($args)) {
717 717
 		case 0:
718 718
 			return new $class_name();
719 719
 		case 1:
720
-			return new $class_name( $args[0] );
720
+			return new $class_name($args[0]);
721 721
 		case 2:
722
-			return new $class_name( $args[0], $args[1] );
722
+			return new $class_name($args[0], $args[1]);
723 723
 		case 3:
724
-			return new $class_name( $args[0], $args[1], $args[2] );
724
+			return new $class_name($args[0], $args[1], $args[2]);
725 725
 		case 4:
726
-			return new $class_name( $args[0], $args[1], $args[2], $args[3] );
726
+			return new $class_name($args[0], $args[1], $args[2], $args[3]);
727 727
 		default:
728 728
 			return false;
729 729
 	}
@@ -745,13 +745,13 @@  discard block
 block discarded – undo
745 745
  * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the
746 746
  *               slug is not dynamic, the value of each of those keys will be false.
747 747
  */
748
-function wordpoints_parse_dynamic_slug( $slug ) {
748
+function wordpoints_parse_dynamic_slug($slug) {
749 749
 
750
-	$parsed = array( 'dynamic' => false, 'generic' => false );
750
+	$parsed = array('dynamic' => false, 'generic' => false);
751 751
 
752
-	$parts = explode( '\\', $slug, 2 );
752
+	$parts = explode('\\', $slug, 2);
753 753
 
754
-	if ( isset( $parts[1] ) ) {
754
+	if (isset($parts[1])) {
755 755
 		$parsed['dynamic'] = $parts[1];
756 756
 		$parsed['generic'] = $parts[0];
757 757
 	}
@@ -790,28 +790,28 @@  discard block
 block discarded – undo
790 790
  *                     contexts, indexed by context slug, or false if any of the
791 791
  *                     contexts isn't current.
792 792
  */
793
-function wordpoints_entities_get_current_context_id( $slug ) {
793
+function wordpoints_entities_get_current_context_id($slug) {
794 794
 
795 795
 	$current_context = array();
796 796
 
797 797
 	/** @var WordPoints_Class_Registry $contexts */
798
-	$contexts = wordpoints_entities()->get_sub_app( 'contexts' );
798
+	$contexts = wordpoints_entities()->get_sub_app('contexts');
799 799
 
800
-	while ( $slug ) {
800
+	while ($slug) {
801 801
 
802
-		$context = $contexts->get( $slug );
802
+		$context = $contexts->get($slug);
803 803
 
804
-		if ( ! $context instanceof WordPoints_Entity_Context ) {
804
+		if ( ! $context instanceof WordPoints_Entity_Context) {
805 805
 			return false;
806 806
 		}
807 807
 
808 808
 		$id = $context->get_current_id();
809 809
 
810
-		if ( false === $id ) {
810
+		if (false === $id) {
811 811
 			return false;
812 812
 		}
813 813
 
814
-		$current_context[ $slug ] = $id;
814
+		$current_context[$slug] = $id;
815 815
 
816 816
 		$slug = $context->get_parent_slug();
817 817
 	}
@@ -832,22 +832,22 @@  discard block
 block discarded – undo
832 832
  */
833 833
 function wordpoints_is_network_context() {
834 834
 
835
-	if ( ! is_multisite() ) {
835
+	if ( ! is_multisite()) {
836 836
 		return false;
837 837
 	}
838 838
 
839
-	if ( is_network_admin() ) {
839
+	if (is_network_admin()) {
840 840
 		return true;
841 841
 	}
842 842
 
843 843
 	// See https://core.trac.wordpress.org/ticket/22589
844 844
 	if (
845
-		defined( 'DOING_AJAX' )
845
+		defined('DOING_AJAX')
846 846
 		&& DOING_AJAX
847
-		&& isset( $_SERVER['HTTP_REFERER'] )
847
+		&& isset($_SERVER['HTTP_REFERER'])
848 848
 		&& preg_match(
849
-			'#^' . preg_quote( network_admin_url(), '#' ) . '#i'
850
-			, esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) )
849
+			'#^'.preg_quote(network_admin_url(), '#').'#i'
850
+			, esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER']))
851 851
 		)
852 852
 	) {
853 853
 		return true;
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 	 *
861 861
 	 * @param bool $in_network_context Whether we are in network context.
862 862
 	 */
863
-	return apply_filters( 'wordpoints_is_network_context', false );
863
+	return apply_filters('wordpoints_is_network_context', false);
864 864
 }
865 865
 
866 866
 /**
@@ -874,21 +874,21 @@  discard block
 block discarded – undo
874 874
  *
875 875
  * @return string The primary arg's GUID, JSON encoded.
876 876
  */
877
-function wordpoints_hooks_get_event_primary_arg_guid_json( WordPoints_Hook_Event_Args $event_args ) {
877
+function wordpoints_hooks_get_event_primary_arg_guid_json(WordPoints_Hook_Event_Args $event_args) {
878 878
 
879 879
 	$entity = $event_args->get_primary_arg();
880 880
 
881
-	if ( ! $entity ) {
881
+	if ( ! $entity) {
882 882
 		return '';
883 883
 	}
884 884
 
885 885
 	$the_guid = $entity->get_the_guid();
886 886
 
887
-	if ( ! $the_guid ) {
887
+	if ( ! $the_guid) {
888 888
 		return '';
889 889
 	}
890 890
 
891
-	return wp_json_encode( $the_guid );
891
+	return wp_json_encode($the_guid);
892 892
 }
893 893
 
894 894
 /**
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
  */
902 902
 function wordpoints_hooks_api_add_global_cache_groups() {
903 903
 
904
-	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
904
+	if (function_exists('wp_cache_add_global_groups')) {
905 905
 
906 906
 		wp_cache_add_global_groups(
907 907
 			array(
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
  * @return string The escaped identifier. Already quoted, do not place within
928 928
  *                backticks.
929 929
  */
930
-function wordpoints_escape_mysql_identifier( $identifier ) {
931
-	return '`' . str_replace( '`', '``', $identifier ) . '`';
930
+function wordpoints_escape_mysql_identifier($identifier) {
931
+	return '`'.str_replace('`', '``', $identifier).'`';
932 932
 }
933 933
 
934 934
 // EOF
Please login to merge, or discard this patch.