Completed
Push — master ( 274f34...8ff377 )
by J.D.
04:05
created
src/includes/classes/hook/extension/blocker.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 	/**
25 25
 	 * @since 1.0.0
26 26
 	 */
27
-	public function validate_action_type_settings( $settings ) {
27
+	public function validate_action_type_settings($settings) {
28 28
 		return (bool) $settings;
29 29
 	}
30 30
 
31 31
 	/**
32 32
 	 * @since 1.0.0
33 33
 	 */
34
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
35
-		return ! $this->get_settings_from_fire( $fire );
34
+	public function should_hit(WordPoints_Hook_Fire $fire) {
35
+		return ! $this->get_settings_from_fire($fire);
36 36
 	}
37 37
 }
38 38
 
Please login to merge, or discard this patch.
src/includes/classes/hook/extension/conditions.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 
43 43
 		$conditions_data = array();
44 44
 
45
-		foreach ( $this->conditions->get_all() as $data_type => $conditions ) {
46
-			foreach ( $conditions as $slug => $condition ) {
45
+		foreach ($this->conditions->get_all() as $data_type => $conditions) {
46
+			foreach ($conditions as $slug => $condition) {
47 47
 
48
-				if ( ! ( $condition instanceof WordPoints_Hook_Condition ) ) {
48
+				if ( ! ($condition instanceof WordPoints_Hook_Condition)) {
49 49
 					continue;
50 50
 				}
51 51
 
52
-				$conditions_data[ $data_type ][ $slug ] = array(
52
+				$conditions_data[$data_type][$slug] = array(
53 53
 					'slug'      => $slug,
54 54
 					'data_type' => $data_type,
55 55
 					'title'     => $condition->get_title(),
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
 			}
59 59
 		}
60 60
 
61
-		return array( 'conditions' => $conditions_data );
61
+		return array('conditions' => $conditions_data);
62 62
 	}
63 63
 
64 64
 	/**
65 65
 	 * @since 1.0.0
66 66
 	 */
67
-	protected function validate_action_type_settings( $settings ) {
68
-		return $this->validate_conditions( $settings );
67
+	protected function validate_action_type_settings($settings) {
68
+		return $this->validate_conditions($settings);
69 69
 	}
70 70
 
71 71
 	/**
@@ -78,36 +78,36 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return array The validated settings.
80 80
 	 */
81
-	public function validate_conditions( $conditions, WordPoints_Hook_Event_Args $event_args = null ) {
81
+	public function validate_conditions($conditions, WordPoints_Hook_Event_Args $event_args = null) {
82 82
 
83
-		if ( $event_args ) {
83
+		if ($event_args) {
84 84
 			$this->event_args = $event_args;
85 85
 			$this->validator = $event_args->get_validator();
86 86
 		}
87 87
 
88
-		if ( ! is_array( $conditions ) ) {
88
+		if ( ! is_array($conditions)) {
89 89
 
90 90
 			$this->validator->add_error(
91
-				__( 'Conditions do not match expected format.', 'wordpoints' )
91
+				__('Conditions do not match expected format.', 'wordpoints')
92 92
 			);
93 93
 
94 94
 			return array();
95 95
 		}
96 96
 
97
-		foreach ( $conditions as $arg_slug => $sub_args ) {
97
+		foreach ($conditions as $arg_slug => $sub_args) {
98 98
 
99
-			if ( '_conditions' === $arg_slug ) {
99
+			if ('_conditions' === $arg_slug) {
100 100
 
101
-				$this->validator->push_field( $arg_slug );
101
+				$this->validator->push_field($arg_slug);
102 102
 
103
-				foreach ( $sub_args as $index => $settings ) {
103
+				foreach ($sub_args as $index => $settings) {
104 104
 
105
-					$this->validator->push_field( $index );
105
+					$this->validator->push_field($index);
106 106
 
107
-					$condition = $this->validate_condition( $settings );
107
+					$condition = $this->validate_condition($settings);
108 108
 
109
-					if ( $condition ) {
110
-						$sub_args[ $index ] = $condition;
109
+					if ($condition) {
110
+						$sub_args[$index] = $condition;
111 111
 					}
112 112
 
113 113
 					$this->validator->pop_field();
@@ -117,18 +117,18 @@  discard block
 block discarded – undo
117 117
 
118 118
 			} else {
119 119
 
120
-				if ( ! $this->event_args->descend( $arg_slug ) ) {
120
+				if ( ! $this->event_args->descend($arg_slug)) {
121 121
 					continue;
122 122
 				}
123 123
 
124
-				$sub_args = $this->validate_action_type_settings( $sub_args );
124
+				$sub_args = $this->validate_action_type_settings($sub_args);
125 125
 
126
-				$conditions[ $arg_slug ] = $sub_args;
126
+				$conditions[$arg_slug] = $sub_args;
127 127
 
128 128
 				$this->event_args->ascend();
129 129
 			}
130 130
 
131
-			$conditions[ $arg_slug ] = $sub_args;
131
+			$conditions[$arg_slug] = $sub_args;
132 132
 		}
133 133
 
134 134
 		return $conditions;
@@ -144,32 +144,32 @@  discard block
 block discarded – undo
144 144
 	 * @return array|false The validated conditions settings, or false if unable to
145 145
 	 *                     validate.
146 146
 	 */
147
-	protected function validate_condition( $settings ) {
147
+	protected function validate_condition($settings) {
148 148
 
149
-		if ( ! isset( $settings['type'] ) ) {
150
-			$this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) );
149
+		if ( ! isset($settings['type'])) {
150
+			$this->validator->add_error(__('Condition type is missing.', 'wordpoints'));
151 151
 			return false;
152 152
 		}
153 153
 
154 154
 		$arg = $this->event_args->get_current();
155 155
 
156
-		$data_type = $this->get_data_type( $arg );
156
+		$data_type = $this->get_data_type($arg);
157 157
 
158
-		if ( ! $data_type ) {
158
+		if ( ! $data_type) {
159 159
 			$this->validator->add_error(
160
-				__( 'This type of condition does not work for the selected attribute.', 'wordpoints' )
160
+				__('This type of condition does not work for the selected attribute.', 'wordpoints')
161 161
 			);
162 162
 
163 163
 			return false;
164 164
 		}
165 165
 
166
-		$condition = wordpoints_hooks()->conditions->get( $data_type, $settings['type'] );
166
+		$condition = wordpoints_hooks()->conditions->get($data_type, $settings['type']);
167 167
 
168
-		if ( ! $condition ) {
168
+		if ( ! $condition) {
169 169
 
170 170
 			$this->validator->add_error(
171 171
 				sprintf(
172
-					__( 'Unknown condition type “%s”.', 'wordpoints' )
172
+					__('Unknown condition type “%s”.', 'wordpoints')
173 173
 					, $settings['type']
174 174
 				)
175 175
 				, 'type'
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 			return false;
179 179
 		}
180 180
 
181
-		if ( ! isset( $settings['settings'] ) ) {
182
-			$this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) );
181
+		if ( ! isset($settings['settings'])) {
182
+			$this->validator->add_error(__('Condition settings are missing.', 'wordpoints'));
183 183
 			return false;
184 184
 		}
185 185
 
186
-		$this->validator->push_field( 'settings' );
186
+		$this->validator->push_field('settings');
187 187
 
188 188
 		// The condition may call this object's validate_settings() method to
189 189
 		// validate some sub-conditions. When that happens, these properties will be
190 190
 		// reset, so we need to back up their values and then restore them below.
191
-		$backup = array( $this->validator, $this->event_args );
191
+		$backup = array($this->validator, $this->event_args);
192 192
 
193 193
 		$settings['settings'] = $condition->validate_settings(
194 194
 			$arg
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 			, $this->validator
197 197
 		);
198 198
 
199
-		list( $this->validator, $this->event_args ) = $backup;
199
+		list($this->validator, $this->event_args) = $backup;
200 200
 
201 201
 		$this->validator->pop_field();
202 202
 
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
 	/**
207 207
 	 * @since 1.0.0
208 208
 	 */
209
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
209
+	public function should_hit(WordPoints_Hook_Fire $fire) {
210 210
 
211
-		$conditions = $this->get_settings_from_fire( $fire );
211
+		$conditions = $this->get_settings_from_fire($fire);
212 212
 
213
-		if ( $conditions && ! $this->conditions_are_met( $conditions, $fire->event_args ) ) {
213
+		if ($conditions && ! $this->conditions_are_met($conditions, $fire->event_args)) {
214 214
 			return false;
215 215
 		}
216 216
 
@@ -232,35 +232,35 @@  discard block
 block discarded – undo
232 232
 		WordPoints_Hook_Event_Args $event_args
233 233
 	) {
234 234
 
235
-		foreach ( $conditions as $arg_slug => $sub_args ) {
235
+		foreach ($conditions as $arg_slug => $sub_args) {
236 236
 
237
-			$event_args->descend( $arg_slug );
237
+			$event_args->descend($arg_slug);
238 238
 
239
-			if ( isset( $sub_args['_conditions'] ) ) {
239
+			if (isset($sub_args['_conditions'])) {
240 240
 
241
-				foreach ( $sub_args['_conditions'] as $settings ) {
241
+				foreach ($sub_args['_conditions'] as $settings) {
242 242
 
243 243
 					$condition = $this->conditions->get(
244
-						$this->get_data_type( $event_args->get_current() )
244
+						$this->get_data_type($event_args->get_current())
245 245
 						, $settings['type']
246 246
 					);
247 247
 
248
-					$is_met = $condition->is_met( $settings['settings'], $event_args );
248
+					$is_met = $condition->is_met($settings['settings'], $event_args);
249 249
 
250
-					if ( ! $is_met ) {
250
+					if ( ! $is_met) {
251 251
 						$event_args->ascend();
252 252
 						return false;
253 253
 					}
254 254
 				}
255 255
 
256
-				unset( $sub_args['_conditions'] );
256
+				unset($sub_args['_conditions']);
257 257
 			}
258 258
 
259
-			$are_met = $this->conditions_are_met( $sub_args, $event_args );
259
+			$are_met = $this->conditions_are_met($sub_args, $event_args);
260 260
 
261 261
 			$event_args->ascend();
262 262
 
263
-			if ( ! $are_met ) {
263
+			if ( ! $are_met) {
264 264
 				return false;
265 265
 			}
266 266
 		}
@@ -277,13 +277,13 @@  discard block
 block discarded – undo
277 277
 	 *
278 278
 	 * @return string|false The data type, or false.
279 279
 	 */
280
-	protected function get_data_type( $arg ) {
280
+	protected function get_data_type($arg) {
281 281
 
282
-		if ( $arg instanceof WordPoints_Entity_Attr ) {
282
+		if ($arg instanceof WordPoints_Entity_Attr) {
283 283
 			$data_type = $arg->get_data_type();
284
-		} elseif ( $arg instanceof WordPoints_Entity_Array ) {
284
+		} elseif ($arg instanceof WordPoints_Entity_Array) {
285 285
 			$data_type = 'entity_array';
286
-		} elseif ( $arg instanceof WordPoints_Entity ) {
286
+		} elseif ($arg instanceof WordPoints_Entity) {
287 287
 			$data_type = 'entity';
288 288
 		} else {
289 289
 			$data_type = false;
Please login to merge, or discard this patch.
src/includes/classes/hook/condition/entity/array/contains.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @since 1.0.0
57 57
 	 */
58 58
 	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/hit/query.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
 	 * @since 1.0.0
19 19
 	 */
20 20
 	protected $columns = array(
21
-		'id' => array( 'format' => '%d', 'unsigned' => true ),
22
-		'action_type' => array( 'format' => '%s' ),
23
-		'primary_arg_guid' => array( 'format' => '%s' ),
24
-		'event' => array( 'format' => '%s' ),
25
-		'reactor' => array( 'format' => '%s' ),
26
-		'reaction_store' => array( 'format' => '%s' ),
27
-		'reaction_context_id' => array( 'format' => '%s' ),
28
-		'reaction_id' => array( 'format' => '%d', 'unsigned' => true ),
29
-		'date' => array( 'format' => '%s', 'is_date' => true ),
21
+		'id' => array('format' => '%d', 'unsigned' => true),
22
+		'action_type' => array('format' => '%s'),
23
+		'primary_arg_guid' => array('format' => '%s'),
24
+		'event' => array('format' => '%s'),
25
+		'reactor' => array('format' => '%s'),
26
+		'reaction_store' => array('format' => '%s'),
27
+		'reaction_context_id' => array('format' => '%s'),
28
+		'reaction_id' => array('format' => '%d', 'unsigned' => true),
29
+		'date' => array('format' => '%s', 'is_date' => true),
30 30
 	);
31 31
 
32 32
 	/**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 *        @type array        $meta_query                   See WP_Meta_Query.
103 103
 	 * }
104 104
 	 */
105
-	public function __construct( $args = array() ) {
105
+	public function __construct($args = array()) {
106 106
 
107 107
 		global $wpdb;
108 108
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 		$this->defaults['order_by'] = 'date';
112 112
 
113
-		parent::__construct( $args );
113
+		parent::__construct($args);
114 114
 	}
115 115
 }
116 116
 
Please login to merge, or discard this patch.
src/includes/actions.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,25 +7,25 @@
 block discarded – undo
7 7
  * @since 1.0.0
8 8
  */
9 9
 
10
-add_action( 'wordpoints_init_app-apps', 'wordpoints_apps_init' );
11
-add_action( 'wordpoints_init_app-entities', 'wordpoints_entities_app_init' );
10
+add_action('wordpoints_init_app-apps', 'wordpoints_apps_init');
11
+add_action('wordpoints_init_app-entities', 'wordpoints_entities_app_init');
12 12
 
13
-add_action( 'wordpoints_init_app_registry-apps-entities', 'wordpoints_entities_init' );
14
-add_action( 'wordpoints_init_app_registry-entities-contexts', 'wordpoints_entity_contexts_init' );
13
+add_action('wordpoints_init_app_registry-apps-entities', 'wordpoints_entities_init');
14
+add_action('wordpoints_init_app_registry-entities-contexts', 'wordpoints_entity_contexts_init');
15 15
 
16
-add_action( 'wordpoints_init_app_registry-apps-data_types', 'wordpoints_data_types_init' );
16
+add_action('wordpoints_init_app_registry-apps-data_types', 'wordpoints_data_types_init');
17 17
 
18
-add_action( 'wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init' );
19
-add_action( 'wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init' );
20
-add_action( 'wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init' );
21
-add_action( 'wordpoints_init_app_registry-hooks-reaction_stores', 'wordpoints_hook_reaction_stores_init' );
22
-add_action( 'wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init' );
23
-add_action( 'wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init' );
18
+add_action('wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init');
19
+add_action('wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init');
20
+add_action('wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init');
21
+add_action('wordpoints_init_app_registry-hooks-reaction_stores', 'wordpoints_hook_reaction_stores_init');
22
+add_action('wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init');
23
+add_action('wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init');
24 24
 
25
-add_action( 'wordpoints_modules_loaded', 'wordpoints_init_hooks' );
25
+add_action('wordpoints_modules_loaded', 'wordpoints_init_hooks');
26 26
 
27
-add_action( 'init', 'wordpoints_hooks_api_add_global_cache_groups', 5 );
27
+add_action('init', 'wordpoints_hooks_api_add_global_cache_groups', 5);
28 28
 
29
-add_filter( 'wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log' );
29
+add_filter('wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log');
30 30
 
31 31
 // EOF
Please login to merge, or discard this patch.
src/admin/includes/classes/ajax/hooks.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	) {
101 101
 
102 102
 		return 'wordpoints_create_hook_reaction|' . $reaction_store->get_slug()
103
-		       . '|' . wordpoints_hooks()->get_current_mode()
104
-		       . '|' . wp_json_encode( $reaction_store->get_context_id() );
103
+			   . '|' . wordpoints_hooks()->get_current_mode()
104
+			   . '|' . wp_json_encode( $reaction_store->get_context_id() );
105 105
 	}
106 106
 
107 107
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		WordPoints_Hook_ReactionI $reaction
132 132
 	) {
133 133
 		return 'wordpoints_update_hook_reaction|'
134
-		       . wp_json_encode( $reaction->get_guid() );
134
+			   . wp_json_encode( $reaction->get_guid() );
135 135
 	}
136 136
 
137 137
 	/**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		WordPoints_Hook_ReactionI $reaction
162 162
 	) {
163 163
 		return 'wordpoints_delete_hook_reaction|'
164
-		       . wp_json_encode( $reaction->get_guid() );
164
+			   . wp_json_encode( $reaction->get_guid() );
165 165
 	}
166 166
 
167 167
 	//
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return array The hook reaction data extracted into an array.
54 54
 	 */
55
-	public static function prepare_hook_reaction( WordPoints_Hook_ReactionI $reaction ) {
55
+	public static function prepare_hook_reaction(WordPoints_Hook_ReactionI $reaction) {
56 56
 
57 57
 		return array_merge(
58 58
 			$reaction->get_all_meta()
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 				'id' => $reaction->ID,
61 61
 				'event' => $reaction->get_event_slug(),
62 62
 				'reaction_store' => $reaction->get_store_slug(),
63
-				'nonce' => self::get_update_nonce( $reaction ),
64
-				'delete_nonce' => self::get_delete_nonce( $reaction ),
63
+				'nonce' => self::get_update_nonce($reaction),
64
+				'delete_nonce' => self::get_delete_nonce($reaction),
65 65
 			)
66 66
 		);
67 67
 	}
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		WordPoints_Hook_Reaction_StoreI $reaction_store
82 82
 	) {
83 83
 
84
-		return wp_create_nonce( self::get_create_nonce_action( $reaction_store ) );
84
+		return wp_create_nonce(self::get_create_nonce_action($reaction_store));
85 85
 	}
86 86
 
87 87
 	/**
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 		WordPoints_Hook_Reaction_StoreI $reaction_store
100 100
 	) {
101 101
 
102
-		return 'wordpoints_create_hook_reaction|' . $reaction_store->get_slug()
103
-		       . '|' . wordpoints_hooks()->get_current_mode()
104
-		       . '|' . wp_json_encode( $reaction_store->get_context_id() );
102
+		return 'wordpoints_create_hook_reaction|'.$reaction_store->get_slug()
103
+		       . '|'.wordpoints_hooks()->get_current_mode()
104
+		       . '|'.wp_json_encode($reaction_store->get_context_id());
105 105
 	}
106 106
 
107 107
 	/**
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return string A nonce for updating this reaction.
115 115
 	 */
116
-	public static function get_update_nonce( WordPoints_Hook_ReactionI $reaction ) {
116
+	public static function get_update_nonce(WordPoints_Hook_ReactionI $reaction) {
117 117
 
118
-		return wp_create_nonce( self::get_update_nonce_action( $reaction ) );
118
+		return wp_create_nonce(self::get_update_nonce_action($reaction));
119 119
 	}
120 120
 
121 121
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		WordPoints_Hook_ReactionI $reaction
132 132
 	) {
133 133
 		return 'wordpoints_update_hook_reaction|'
134
-		       . wp_json_encode( $reaction->get_guid() );
134
+		       . wp_json_encode($reaction->get_guid());
135 135
 	}
136 136
 
137 137
 	/**
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @return string A nonce for deleting this reaction.
145 145
 	 */
146
-	public static function get_delete_nonce( WordPoints_Hook_ReactionI $reaction ) {
146
+	public static function get_delete_nonce(WordPoints_Hook_ReactionI $reaction) {
147 147
 
148
-		return wp_create_nonce( self::get_delete_nonce_action( $reaction ) );
148
+		return wp_create_nonce(self::get_delete_nonce_action($reaction));
149 149
 	}
150 150
 
151 151
 	/**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		WordPoints_Hook_ReactionI $reaction
162 162
 	) {
163 163
 		return 'wordpoints_delete_hook_reaction|'
164
-		       . wp_json_encode( $reaction->get_guid() );
164
+		       . wp_json_encode($reaction->get_guid());
165 165
 	}
166 166
 
167 167
 	//
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
 
188 188
 		add_action(
189 189
 			'wp_ajax_wordpoints_admin_create_hook_reaction'
190
-			, array( $this, 'create_hook_reaction' )
190
+			, array($this, 'create_hook_reaction')
191 191
 		);
192 192
 
193 193
 		add_action(
194 194
 			'wp_ajax_wordpoints_admin_update_hook_reaction'
195
-			, array( $this, 'update_hook_reaction' )
195
+			, array($this, 'update_hook_reaction')
196 196
 		);
197 197
 
198 198
 		add_action(
199 199
 			'wp_ajax_wordpoints_admin_delete_hook_reaction'
200
-			, array( $this, 'delete_hook_reaction' )
200
+			, array($this, 'delete_hook_reaction')
201 201
 		);
202 202
 	}
203 203
 
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 
213 213
 		$reaction_store = $this->get_reaction_store();
214 214
 
215
-		$this->verify_request( $this->get_create_nonce_action( $reaction_store ) );
215
+		$this->verify_request($this->get_create_nonce_action($reaction_store));
216 216
 
217
-		$reaction = $reaction_store->create_reaction( $this->get_data() );
217
+		$reaction = $reaction_store->create_reaction($this->get_data());
218 218
 
219
-		$this->send_json_result( $reaction, 'create' );
219
+		$this->send_json_result($reaction, 'create');
220 220
 	}
221 221
 
222 222
 	/**
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 		$reaction_store = $this->get_reaction_store();
232 232
 		$reaction = $this->get_reaction();
233 233
 
234
-		$this->verify_request( $this->get_update_nonce_action( $reaction ) );
234
+		$this->verify_request($this->get_update_nonce_action($reaction));
235 235
 
236 236
 		$reaction = $reaction_store->update_reaction(
237 237
 			$reaction->ID
238 238
 			, $this->get_data()
239 239
 		);
240 240
 
241
-		$this->send_json_result( $reaction, 'update' );
241
+		$this->send_json_result($reaction, 'update');
242 242
 	}
243 243
 
244 244
 	/**
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
 		$reaction_store = $this->get_reaction_store();
254 254
 		$reaction = $this->get_reaction();
255 255
 
256
-		$this->verify_request( $this->get_delete_nonce_action( $reaction ) );
256
+		$this->verify_request($this->get_delete_nonce_action($reaction));
257 257
 
258
-		$result = $reaction_store->delete_reaction( $reaction->ID );
258
+		$result = $reaction_store->delete_reaction($reaction->ID);
259 259
 
260
-		if ( ! $result ) {
261
-			wp_send_json_error( array( 'message' => __( 'There was an error deleting the reaction. Please try again.', 'wordpoints' ) ) );
260
+		if ( ! $result) {
261
+			wp_send_json_error(array('message' => __('There was an error deleting the reaction. Please try again.', 'wordpoints')));
262 262
 		}
263 263
 
264 264
 		wp_send_json_success();
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @param string $debug_context Context sent with the message (for debugging).
281 281
 	 */
282
-	private function unexpected_error( $debug_context ) {
282
+	private function unexpected_error($debug_context) {
283 283
 
284 284
 		wp_send_json_error(
285 285
 			array(
286
-				'message' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ),
286
+				'message' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'),
287 287
 				'debug'   => $debug_context,
288 288
 			)
289 289
 		);
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	private function verify_user_can() {
301 301
 
302
-		if ( ! current_user_can( 'manage_options' ) ) {
303
-			wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action. Maybe you have been logged out?', 'wordpoints' ) ) );
302
+		if ( ! current_user_can('manage_options')) {
303
+			wp_send_json_error(array('message' => __('You do not have permission to perform this action. Maybe you have been logged out?', 'wordpoints')));
304 304
 		}
305 305
 	}
306 306
 
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @param string $action The action the nonce should be for.
315 315
 	 */
316
-	private function verify_request( $action ) {
316
+	private function verify_request($action) {
317 317
 
318 318
 		if (
319
-			empty( $_POST['nonce'] )
320
-			|| ! wordpoints_verify_nonce( 'nonce', $action, null, 'post' )
319
+			empty($_POST['nonce'])
320
+			|| ! wordpoints_verify_nonce('nonce', $action, null, 'post')
321 321
 		) {
322 322
 			wp_send_json_error(
323
-				array( 'message' => __( 'Your security token for this action has expired. Refresh the page and try again.', 'wordpoints' ) )
323
+				array('message' => __('Your security token for this action has expired. Refresh the page and try again.', 'wordpoints'))
324 324
 			);
325 325
 		}
326 326
 	}
@@ -334,16 +334,16 @@  discard block
 block discarded – undo
334 334
 	 */
335 335
 	protected function get_reaction_store() {
336 336
 
337
-		if ( ! isset( $_POST['reaction_store'] ) ) { // WPCS: CSRF OK.
338
-			$this->unexpected_error( 'reaction_store' );
337
+		if ( ! isset($_POST['reaction_store'])) { // WPCS: CSRF OK.
338
+			$this->unexpected_error('reaction_store');
339 339
 		}
340 340
 
341
-		$reactor_slug = sanitize_key( $_POST['reaction_store'] ); // WPCS: CSRF OK.
341
+		$reactor_slug = sanitize_key($_POST['reaction_store']); // WPCS: CSRF OK.
342 342
 
343
-		$reaction_store = wordpoints_hooks()->get_reaction_store( $reactor_slug );
343
+		$reaction_store = wordpoints_hooks()->get_reaction_store($reactor_slug);
344 344
 
345
-		if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) {
346
-			$this->unexpected_error( 'reaction_store_invalid' );
345
+		if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) {
346
+			$this->unexpected_error('reaction_store_invalid');
347 347
 		}
348 348
 
349 349
 		$this->reaction_store_slug = $reactor_slug;
@@ -361,16 +361,16 @@  discard block
 block discarded – undo
361 361
 	 */
362 362
 	protected function get_reaction() {
363 363
 
364
-		if ( ! isset( $_POST['id'] ) ) { // WPCS: CSRF OK.
365
-			$this->unexpected_error( 'id' );
364
+		if ( ! isset($_POST['id'])) { // WPCS: CSRF OK.
365
+			$this->unexpected_error('id');
366 366
 		}
367 367
 
368 368
 		$reaction = $this->reaction_store->get_reaction(
369
-			wordpoints_int( $_POST['id'] ) // WPCS: CSRF OK.
369
+			wordpoints_int($_POST['id']) // WPCS: CSRF OK.
370 370
 		);
371 371
 
372
-		if ( ! $reaction ) {
373
-			wp_send_json_error( array( 'message' => __( 'The reaction ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints' ) ) );
372
+		if ( ! $reaction) {
373
+			wp_send_json_error(array('message' => __('The reaction ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints')));
374 374
 		}
375 375
 
376 376
 		return $reaction;
@@ -385,9 +385,9 @@  discard block
 block discarded – undo
385 385
 	 */
386 386
 	protected function get_data() {
387 387
 
388
-		$data = wp_unslash( $_POST ); // WPCS: CSRF OK.
388
+		$data = wp_unslash($_POST); // WPCS: CSRF OK.
389 389
 
390
-		unset( $data['id'], $data['action'], $data['nonce'], $data['reaction_store'] );
390
+		unset($data['id'], $data['action'], $data['nonce'], $data['reaction_store']);
391 391
 
392 392
 		return $data;
393 393
 	}
@@ -400,30 +400,30 @@  discard block
 block discarded – undo
400 400
 	 * @param mixed  $result The result of the action.
401 401
 	 * @param string $action The action being performed: 'create' or 'update'.
402 402
 	 */
403
-	private function send_json_result( $result, $action ) {
403
+	private function send_json_result($result, $action) {
404 404
 
405
-		if ( ! $result ) {
405
+		if ( ! $result) {
406 406
 
407
-			if ( 'create' === $action ) {
408
-				$message = __( 'There was an error adding the reaction. Please try again.', 'wordpoints' );
407
+			if ('create' === $action) {
408
+				$message = __('There was an error adding the reaction. Please try again.', 'wordpoints');
409 409
 			} else {
410
-				$message = __( 'There was an error updating the reaction. Please try again.', 'wordpoints' );
410
+				$message = __('There was an error updating the reaction. Please try again.', 'wordpoints');
411 411
 			}
412 412
 
413
-			wp_send_json_error( array( 'message' => $message ) );
413
+			wp_send_json_error(array('message' => $message));
414 414
 
415
-		} elseif ( $result instanceof WordPoints_Hook_Reaction_Validator ) {
415
+		} elseif ($result instanceof WordPoints_Hook_Reaction_Validator) {
416 416
 
417
-			wp_send_json_error( array( 'errors' => $result->get_errors() ) );
417
+			wp_send_json_error(array('errors' => $result->get_errors()));
418 418
 		}
419 419
 
420 420
 		$data = null;
421 421
 
422
-		if ( 'create' === $action ) {
423
-			$data = self::prepare_hook_reaction( $result );
422
+		if ('create' === $action) {
423
+			$data = self::prepare_hook_reaction($result);
424 424
 		}
425 425
 
426
-		wp_send_json_success( $data );
426
+		wp_send_json_success($data);
427 427
 	}
428 428
 }
429 429
 
Please login to merge, or discard this patch.
src/includes/classes/entity/attr/field.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@
 block discarded – undo
37 37
 	/**
38 38
 	 * @since 1.0.0
39 39
 	 */
40
-	protected function get_attr_value_from_entity( WordPoints_Entity $entity ) {
41
-		return $entity->get_the_attr_value( $this->field );
40
+	protected function get_attr_value_from_entity(WordPoints_Entity $entity) {
41
+		return $entity->get_the_attr_value($this->field);
42 42
 	}
43 43
 	
44 44
 	/**
Please login to merge, or discard this patch.
src/includes/classes/entity/stored/array.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 	public function get_storage_info() {
32 32
 		return array(
33 33
 			'type' => 'array',
34
-			'info' => array( 'type' => 'method' ),
34
+			'info' => array('type' => 'method'),
35 35
 		);
36 36
 	}
37 37
 }
Please login to merge, or discard this patch.
src/includes/classes/entity/relationship/stored/field.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@
 block discarded – undo
37 37
 	/**
38 38
 	 * @since 1.0.0
39 39
 	 */
40
-	protected function get_related_entity_ids( WordPoints_Entity $entity ) {
41
-		return $entity->get_the_attr_value( $this->related_ids_field );
40
+	protected function get_related_entity_ids(WordPoints_Entity $entity) {
41
+		return $entity->get_the_attr_value($this->related_ids_field);
42 42
 	}
43 43
 	
44 44
 	/**
Please login to merge, or discard this patch.