@@ -18,15 +18,15 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -7,25 +7,25 @@ |
||
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 |
@@ -100,8 +100,8 @@ discard block |
||
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 |
||
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 |
||
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 | // |
@@ -52,7 +52,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -37,8 +37,8 @@ |
||
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 | /** |
@@ -31,7 +31,7 @@ |
||
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 | } |
@@ -37,8 +37,8 @@ |
||
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 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return mixed The attribute value. |
41 | 41 | */ |
42 | - abstract protected function get_attr_value_from_entity( WordPoints_Entity $entity ); |
|
42 | + abstract protected function get_attr_value_from_entity(WordPoints_Entity $entity); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Get the data type of this attribute's values. |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return bool Whether the value was set correctly. |
68 | 68 | */ |
69 | - public function set_the_value_from_entity( WordPoints_Entity $entity ) { |
|
69 | + public function set_the_value_from_entity(WordPoints_Entity $entity) { |
|
70 | 70 | |
71 | - $this->the_value = $this->get_attr_value_from_entity( $entity ); |
|
71 | + $this->the_value = $this->get_attr_value_from_entity($entity); |
|
72 | 72 | |
73 | 73 | return true; |
74 | 74 | } |
@@ -34,15 +34,15 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | - protected function get_related_entity_ids( WordPoints_Entity $entity ) { |
|
38 | - return $entity->get_the_attr_value( $this->related_ids_field ); |
|
37 | + protected function get_related_entity_ids(WordPoints_Entity $entity) { |
|
38 | + return $entity->get_the_attr_value($this->related_ids_field); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @since 1.0.0 |
43 | 43 | */ |
44 | 44 | public function get_title() { |
45 | - return __( 'Roles', 'wordpoints' ); |
|
45 | + return __('Roles', 'wordpoints'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | 'conditions' => array( |
63 | 63 | array( |
64 | 64 | 'field' => 'meta_key', |
65 | - 'value' => $GLOBALS['wpdb']->get_blog_prefix() . 'capabilities', |
|
65 | + 'value' => $GLOBALS['wpdb']->get_blog_prefix().'capabilities', |
|
66 | 66 | ), |
67 | 67 | ), |
68 | 68 | ), |
@@ -103,12 +103,12 @@ discard block |
||
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 |
||
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,16 +146,16 @@ discard block |
||
146 | 146 | $fail_fast = $this->fail_fast; |
147 | 147 | $this->fail_fast = true; |
148 | 148 | |
149 | - if ( ! isset( $this->event_slug ) ) { |
|
150 | - $this->add_error( __( 'Event is missing.', 'wordpoints' ), 'event' ); |
|
151 | - } elseif ( ! $this->hooks->events->is_registered( $this->event_slug ) ) { |
|
152 | - $this->add_error( __( 'Event is invalid.', 'wordpoints' ), 'event' ); |
|
149 | + if ( ! isset($this->event_slug)) { |
|
150 | + $this->add_error(__('Event is missing.', 'wordpoints'), 'event'); |
|
151 | + } elseif ( ! $this->hooks->events->is_registered($this->event_slug)) { |
|
152 | + $this->add_error(__('Event is invalid.', 'wordpoints'), 'event'); |
|
153 | 153 | } |
154 | 154 | |
155 | - if ( ! isset( $this->reactor_slug ) ) { |
|
156 | - $this->add_error( __( 'Reactor is missing.', 'wordpoints' ), 'reactor' ); |
|
157 | - } elseif ( ! $this->hooks->reactors->is_registered( $this->reactor_slug ) ) { |
|
158 | - $this->add_error( __( 'Reactor is invalid.', 'wordpoints' ), 'reactor' ); |
|
155 | + if ( ! isset($this->reactor_slug)) { |
|
156 | + $this->add_error(__('Reactor is missing.', 'wordpoints'), 'reactor'); |
|
157 | + } elseif ( ! $this->hooks->reactors->is_registered($this->reactor_slug)) { |
|
158 | + $this->add_error(__('Reactor is invalid.', 'wordpoints'), 'reactor'); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | // From here on out we can collect errors as they come (unless we are |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | $this->event_slug |
167 | 167 | ); |
168 | 168 | |
169 | - $this->event_args = new WordPoints_Hook_Event_Args( $event_args ); |
|
170 | - $this->event_args->set_validator( $this ); |
|
169 | + $this->event_args = new WordPoints_Hook_Event_Args($event_args); |
|
170 | + $this->event_args->set_validator($this); |
|
171 | 171 | |
172 | - $reactor = $this->hooks->reactors->get( $this->reactor_slug ); |
|
172 | + $reactor = $this->hooks->reactors->get($this->reactor_slug); |
|
173 | 173 | |
174 | - $this->settings = $reactor->validate_settings( $this->settings, $this, $this->event_args ); |
|
174 | + $this->settings = $reactor->validate_settings($this->settings, $this, $this->event_args); |
|
175 | 175 | |
176 | 176 | /** @var WordPoints_Hook_Extension $extension */ |
177 | - foreach ( $this->hooks->extensions->get_all() as $extension ) { |
|
178 | - $this->settings = $extension->validate_settings( $this->settings, $this, $this->event_args ); |
|
177 | + foreach ($this->hooks->extensions->get_all() as $extension) { |
|
178 | + $this->settings = $extension->validate_settings($this->settings, $this, $this->event_args); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | * @param WordPoints_Hook_Reaction_Validator $validator The validator object. |
186 | 186 | * @param WordPoints_Hook_Event_Args $args The event args object. |
187 | 187 | */ |
188 | - $this->settings = apply_filters( 'wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args ); |
|
188 | + $this->settings = apply_filters('wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args); |
|
189 | 189 | |
190 | - } catch ( WordPoints_Hook_Validator_Exception $e ) { |
|
190 | + } catch (WordPoints_Hook_Validator_Exception $e) { |
|
191 | 191 | |
192 | 192 | // Do nothing. |
193 | - unset( $e ); |
|
193 | + unset($e); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | return $this->settings; |
@@ -218,17 +218,17 @@ discard block |
||
218 | 218 | * @throws WordPoints_Hook_Validator_Exception If the validator is configured to |
219 | 219 | * fail as soon as an error is found. |
220 | 220 | */ |
221 | - public function add_error( $message, $field = null ) { |
|
221 | + public function add_error($message, $field = null) { |
|
222 | 222 | |
223 | 223 | $field_stack = $this->field_stack; |
224 | 224 | |
225 | - if ( null !== $field ) { |
|
225 | + if (null !== $field) { |
|
226 | 226 | $field_stack[] = $field; |
227 | 227 | } |
228 | 228 | |
229 | - $this->errors[] = array( 'message' => $message, 'field' => $field_stack ); |
|
229 | + $this->errors[] = array('message' => $message, 'field' => $field_stack); |
|
230 | 230 | |
231 | - if ( $this->fail_fast ) { |
|
231 | + if ($this->fail_fast) { |
|
232 | 232 | throw new WordPoints_Hook_Validator_Exception; |
233 | 233 | } |
234 | 234 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return bool Whether the validator found any errors. |
242 | 242 | */ |
243 | 243 | public function had_errors() { |
244 | - return ! empty( $this->errors ); |
|
244 | + return ! empty($this->errors); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @param string $field The field. |
264 | 264 | */ |
265 | - public function push_field( $field ) { |
|
265 | + public function push_field($field) { |
|
266 | 266 | $this->field_stack[] = $field; |
267 | 267 | } |
268 | 268 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @since 1.0.0 |
273 | 273 | */ |
274 | 274 | public function pop_field() { |
275 | - array_pop( $this->field_stack ); |
|
275 | + array_pop($this->field_stack); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function get_id() { |
319 | 319 | |
320 | - if ( ! $this->reaction ) { |
|
320 | + if ( ! $this->reaction) { |
|
321 | 321 | return false; |
322 | 322 | } |
323 | 323 | |
@@ -355,13 +355,13 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return mixed The meta value. |
357 | 357 | */ |
358 | - public function get_meta( $key ) { |
|
358 | + public function get_meta($key) { |
|
359 | 359 | |
360 | - if ( ! isset( $this->settings[ $key ] ) ) { |
|
360 | + if ( ! isset($this->settings[$key])) { |
|
361 | 361 | return null; |
362 | 362 | } |
363 | 363 | |
364 | - return $this->settings[ $key ]; |
|
364 | + return $this->settings[$key]; |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |