@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function get_value() { |
26 | 26 | |
27 | - if ( wordpoints_is_network_context() ) { |
|
27 | + if (wordpoints_is_network_context()) { |
|
28 | 28 | return false; |
29 | 29 | } |
30 | 30 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | 37 | public function get_title() { |
38 | - return __( 'Site', 'wordpoints' ); |
|
38 | + return __('Site', 'wordpoints'); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | protected function init() { |
48 | 48 | |
49 | 49 | $sub_apps = $this->sub_apps; |
50 | - $sub_apps->register( 'router', 'WordPoints_Hook_Router' ); |
|
51 | - $sub_apps->register( 'actions', 'WordPoints_Hook_Actions' ); |
|
52 | - $sub_apps->register( 'events', 'WordPoints_Hook_Events' ); |
|
53 | - $sub_apps->register( 'firers', 'WordPoints_Class_Registry_Persistent' ); |
|
54 | - $sub_apps->register( 'reactors', 'WordPoints_Class_Registry_Persistent' ); |
|
55 | - $sub_apps->register( 'reaction_groups', 'WordPoints_Class_Registry_Children' ); |
|
56 | - $sub_apps->register( 'extensions', 'WordPoints_Class_Registry_Persistent' ); |
|
57 | - $sub_apps->register( 'conditions', 'WordPoints_Class_Registry_Children' ); |
|
50 | + $sub_apps->register('router', 'WordPoints_Hook_Router'); |
|
51 | + $sub_apps->register('actions', 'WordPoints_Hook_Actions'); |
|
52 | + $sub_apps->register('events', 'WordPoints_Hook_Events'); |
|
53 | + $sub_apps->register('firers', 'WordPoints_Class_Registry_Persistent'); |
|
54 | + $sub_apps->register('reactors', 'WordPoints_Class_Registry_Persistent'); |
|
55 | + $sub_apps->register('reaction_groups', 'WordPoints_Class_Registry_Children'); |
|
56 | + $sub_apps->register('extensions', 'WordPoints_Class_Registry_Persistent'); |
|
57 | + $sub_apps->register('conditions', 'WordPoints_Class_Registry_Children'); |
|
58 | 58 | |
59 | 59 | parent::init(); |
60 | 60 | } |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function get_current_mode() { |
79 | 79 | |
80 | - if ( ! isset( $this->current_mode ) ) { |
|
81 | - $this->current_mode = ( wordpoints_is_network_context() ? 'network' : 'standard' ); |
|
80 | + if ( ! isset($this->current_mode)) { |
|
81 | + $this->current_mode = (wordpoints_is_network_context() ? 'network' : 'standard'); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $this->current_mode; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param string $mode The slug of the mode to set as the current mode. |
98 | 98 | */ |
99 | - public function set_current_mode( $mode ) { |
|
99 | + public function set_current_mode($mode) { |
|
100 | 100 | $this->current_mode = $mode; |
101 | 101 | } |
102 | 102 | } |
@@ -7,24 +7,24 @@ |
||
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-firers', 'wordpoints_hook_firers_init' ); |
|
19 | -add_action( 'wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init' ); |
|
20 | -add_action( 'wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init' ); |
|
21 | -add_action( 'wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init' ); |
|
22 | -add_action( 'wordpoints_init_app_registry-hooks-reaction_groups', 'wordpoints_hook_reaction_groups_init' ); |
|
23 | -add_action( 'wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init' ); |
|
24 | -add_action( 'wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init' ); |
|
18 | +add_action('wordpoints_init_app_registry-hooks-firers', 'wordpoints_hook_firers_init'); |
|
19 | +add_action('wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init'); |
|
20 | +add_action('wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init'); |
|
21 | +add_action('wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init'); |
|
22 | +add_action('wordpoints_init_app_registry-hooks-reaction_groups', 'wordpoints_hook_reaction_groups_init'); |
|
23 | +add_action('wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init'); |
|
24 | +add_action('wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init'); |
|
25 | 25 | |
26 | -add_action( 'wordpoints_modules_loaded', 'wordpoints_init_hooks' ); |
|
26 | +add_action('wordpoints_modules_loaded', 'wordpoints_init_hooks'); |
|
27 | 27 | |
28 | -add_filter( 'wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log' ); |
|
28 | +add_filter('wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log'); |
|
29 | 29 | |
30 | 30 | // EOF |
@@ -106,11 +106,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | // |
@@ -231,15 +231,15 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return string|int|float|false The human identifier for the entity, or false. |
233 | 233 | */ |
234 | - public function get_human_id( $id ) { |
|
234 | + public function get_human_id($id) { |
|
235 | 235 | |
236 | - $entity = $this->get_entity( $id ); |
|
236 | + $entity = $this->get_entity($id); |
|
237 | 237 | |
238 | - if ( ! $entity ) { |
|
238 | + if ( ! $entity) { |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
242 | - return $this->get_entity_human_id( $entity ); |
|
242 | + return $this->get_entity_human_id($entity); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return bool Whether or not an entity with that ID exists. |
253 | 253 | */ |
254 | - public function exists( $id ) { |
|
255 | - return (bool) $this->get_entity( $id ); |
|
254 | + public function exists($id) { |
|
255 | + return (bool) $this->get_entity($id); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -267,17 +267,17 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return WordPoints_Entityish|false The child's object, or false if not found. |
269 | 269 | */ |
270 | - public function get_child( $child_slug ) { |
|
270 | + public function get_child($child_slug) { |
|
271 | 271 | |
272 | 272 | $children = wordpoints_entities()->children; |
273 | 273 | |
274 | - $child = $children->get( $this->slug, $child_slug ); |
|
274 | + $child = $children->get($this->slug, $child_slug); |
|
275 | 275 | |
276 | 276 | if ( |
277 | - isset( $this->the_value ) |
|
277 | + isset($this->the_value) |
|
278 | 278 | && $child instanceof WordPoints_Entity_ChildI |
279 | 279 | ) { |
280 | - $child->set_the_value_from_entity( $this ); |
|
280 | + $child->set_the_value_from_entity($this); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | return $child; |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return bool Whether the value was set. |
301 | 301 | */ |
302 | - public function set_the_value( $value ) { |
|
302 | + public function set_the_value($value) { |
|
303 | 303 | |
304 | 304 | $this->the_value = $this->the_entity = $this->the_context = null; |
305 | 305 | |
306 | - if ( $this->is_entity( $value ) ) { |
|
306 | + if ($this->is_entity($value)) { |
|
307 | 307 | |
308 | 308 | $entity = $value; |
309 | - $value = $this->get_entity_id( $value ); |
|
309 | + $value = $this->get_entity_id($value); |
|
310 | 310 | |
311 | 311 | } else { |
312 | 312 | |
313 | - $entity = $this->get_entity( $value ); |
|
313 | + $entity = $this->get_entity($value); |
|
314 | 314 | |
315 | - if ( ! $entity ) { |
|
315 | + if ( ! $entity) { |
|
316 | 316 | return false; |
317 | 317 | } |
318 | 318 | } |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return mixed The value of the attribute. |
337 | 337 | */ |
338 | - public function get_the_attr_value( $attr ) { |
|
339 | - return $this->get_attr_value( $this->the_entity, $attr ); |
|
338 | + public function get_the_attr_value($attr) { |
|
339 | + return $this->get_attr_value($this->the_entity, $attr); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return string|int|float|null The human identifier for the entity, or null. |
361 | 361 | */ |
362 | 362 | public function get_the_human_id() { |
363 | - return $this->get_entity_human_id( $this->the_entity ); |
|
363 | + return $this->get_entity_human_id($this->the_entity); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | |
392 | 392 | $guid = $this->get_the_context(); |
393 | 393 | |
394 | - if ( ! is_array( $guid ) ) { |
|
394 | + if ( ! is_array($guid)) { |
|
395 | 395 | return $guid; |
396 | 396 | } |
397 | 397 | |
398 | - $guid[ $this->slug ] = $this->get_the_id(); |
|
398 | + $guid[$this->slug] = $this->get_the_id(); |
|
399 | 399 | |
400 | 400 | return $guid; |
401 | 401 | } |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | WordPoints_Hook_Event_Args $event_args |
66 | 66 | ) { |
67 | 67 | |
68 | - if ( ! isset( $settings[ $this->slug ] ) ) { |
|
68 | + if ( ! isset($settings[$this->slug])) { |
|
69 | 69 | return $settings; |
70 | 70 | } |
71 | 71 | |
72 | 72 | $this->validator = $validator; |
73 | 73 | $this->event_args = $event_args; |
74 | 74 | |
75 | - $this->validator->push_field( $this->slug ); |
|
76 | - $settings[ $this->slug ] = $this->{"validate_{$this->slug}"}( $settings[ $this->slug ] ); |
|
75 | + $this->validator->push_field($this->slug); |
|
76 | + $settings[$this->slug] = $this->{"validate_{$this->slug}"}($settings[$this->slug]); |
|
77 | 77 | $this->validator->pop_field(); |
78 | 78 | |
79 | 79 | return $settings; |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * @since 1.0.0 |
84 | 84 | */ |
85 | - public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) { |
|
85 | + public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) { |
|
86 | 86 | |
87 | - if ( isset( $settings[ $this->slug ] ) ) { |
|
88 | - $reaction->update_meta( $this->slug, $settings[ $this->slug ] ); |
|
87 | + if (isset($settings[$this->slug])) { |
|
88 | + $reaction->update_meta($this->slug, $settings[$this->slug]); |
|
89 | 89 | } else { |
90 | - $reaction->delete_meta( $this->slug ); |
|
90 | + $reaction->delete_meta($this->slug); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return bool Whether the target should be hit by this hook firing. |
102 | 102 | */ |
103 | - abstract public function should_hit( WordPoints_Hook_Fire $fire ); |
|
103 | + abstract public function should_hit(WordPoints_Hook_Fire $fire); |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * After a reaction has hit the target. |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @param WordPoints_Hook_Fire $fire The hook fire object. |
111 | 111 | */ |
112 | - public function after_hit( WordPoints_Hook_Fire $fire ) {} |
|
112 | + public function after_hit(WordPoints_Hook_Fire $fire) {} |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * Called after a reverse action is called. |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @param WordPoints_Hook_Fire $fire The reverse fire object. |
120 | 120 | */ |
121 | - public function after_reverse( WordPoints_Hook_Fire $fire ) {} |
|
121 | + public function after_reverse(WordPoints_Hook_Fire $fire) {} |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Get the data the scripts need for the UI. |
@@ -42,14 +42,14 @@ discard block |
||
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,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - return array( 'conditions' => $conditions_data ); |
|
61 | + return array('conditions' => $conditions_data); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -70,31 +70,31 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return array The validated settings. |
72 | 72 | */ |
73 | - protected function validate_conditions( $args ) { |
|
73 | + protected function validate_conditions($args) { |
|
74 | 74 | |
75 | - if ( ! is_array( $args ) ) { |
|
75 | + if ( ! is_array($args)) { |
|
76 | 76 | |
77 | 77 | $this->validator->add_error( |
78 | - __( 'Conditions do not match expected format.', 'wordpoints' ) |
|
78 | + __('Conditions do not match expected format.', 'wordpoints') |
|
79 | 79 | ); |
80 | 80 | |
81 | 81 | return array(); |
82 | 82 | } |
83 | 83 | |
84 | - foreach ( $args as $arg_slug => $sub_args ) { |
|
84 | + foreach ($args as $arg_slug => $sub_args) { |
|
85 | 85 | |
86 | - if ( '_conditions' === $arg_slug ) { |
|
86 | + if ('_conditions' === $arg_slug) { |
|
87 | 87 | |
88 | - $this->validator->push_field( $arg_slug ); |
|
88 | + $this->validator->push_field($arg_slug); |
|
89 | 89 | |
90 | - foreach ( $sub_args as $index => $settings ) { |
|
90 | + foreach ($sub_args as $index => $settings) { |
|
91 | 91 | |
92 | - $this->validator->push_field( $index ); |
|
92 | + $this->validator->push_field($index); |
|
93 | 93 | |
94 | - $condition = $this->validate_condition( $settings ); |
|
94 | + $condition = $this->validate_condition($settings); |
|
95 | 95 | |
96 | - if ( $condition ) { |
|
97 | - $sub_args[ $index ] = $condition; |
|
96 | + if ($condition) { |
|
97 | + $sub_args[$index] = $condition; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $this->validator->pop_field(); |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | |
105 | 105 | } else { |
106 | 106 | |
107 | - if ( ! $this->event_args->descend( $arg_slug ) ) { |
|
107 | + if ( ! $this->event_args->descend($arg_slug)) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | - $sub_args = $this->validate_conditions( $sub_args ); |
|
111 | + $sub_args = $this->validate_conditions($sub_args); |
|
112 | 112 | |
113 | - $args[ $arg_slug ] = $sub_args; |
|
113 | + $args[$arg_slug] = $sub_args; |
|
114 | 114 | |
115 | 115 | $this->event_args->ascend(); |
116 | 116 | } |
117 | 117 | |
118 | - $args[ $arg_slug ] = $sub_args; |
|
118 | + $args[$arg_slug] = $sub_args; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | return $args; |
@@ -131,32 +131,32 @@ discard block |
||
131 | 131 | * @return array|false The validated conditions settings, or false if unable to |
132 | 132 | * validate. |
133 | 133 | */ |
134 | - protected function validate_condition( $settings ) { |
|
134 | + protected function validate_condition($settings) { |
|
135 | 135 | |
136 | - if ( ! isset( $settings['type'] ) ) { |
|
137 | - $this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) ); |
|
136 | + if ( ! isset($settings['type'])) { |
|
137 | + $this->validator->add_error(__('Condition type is missing.', 'wordpoints')); |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $arg = $this->event_args->get_current(); |
142 | 142 | |
143 | - $data_type = $this->get_data_type( $arg ); |
|
143 | + $data_type = $this->get_data_type($arg); |
|
144 | 144 | |
145 | - if ( ! $data_type ) { |
|
145 | + if ( ! $data_type) { |
|
146 | 146 | $this->validator->add_error( |
147 | - __( 'This type of condition does not work for the selected attribute.', 'wordpoints' ) |
|
147 | + __('This type of condition does not work for the selected attribute.', 'wordpoints') |
|
148 | 148 | ); |
149 | 149 | |
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
153 | - $condition = wordpoints_hooks()->conditions->get( $data_type, $settings['type'] ); |
|
153 | + $condition = wordpoints_hooks()->conditions->get($data_type, $settings['type']); |
|
154 | 154 | |
155 | - if ( ! $condition ) { |
|
155 | + if ( ! $condition) { |
|
156 | 156 | |
157 | 157 | $this->validator->add_error( |
158 | 158 | sprintf( |
159 | - __( 'Unknown condition type “%s”.', 'wordpoints' ) |
|
159 | + __('Unknown condition type “%s”.', 'wordpoints') |
|
160 | 160 | , $settings['type'] |
161 | 161 | ) |
162 | 162 | , 'type' |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | - if ( ! isset( $settings['settings'] ) ) { |
|
169 | - $this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) ); |
|
168 | + if ( ! isset($settings['settings'])) { |
|
169 | + $this->validator->add_error(__('Condition settings are missing.', 'wordpoints')); |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | - $this->validator->push_field( 'settings' ); |
|
173 | + $this->validator->push_field('settings'); |
|
174 | 174 | |
175 | 175 | // The condition may call this object's validate_settings() method to |
176 | 176 | // validate some sub-conditions. When that happens, these properties will be |
177 | 177 | // reset, so we need to back up their values and then restore them below. |
178 | - $backup = array( $this->validator, $this->event_args ); |
|
178 | + $backup = array($this->validator, $this->event_args); |
|
179 | 179 | |
180 | 180 | $settings['settings'] = $condition->validate_settings( |
181 | 181 | $arg |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | , $this->validator |
184 | 184 | ); |
185 | 185 | |
186 | - list( $this->validator, $this->event_args ) = $backup; |
|
186 | + list($this->validator, $this->event_args) = $backup; |
|
187 | 187 | |
188 | 188 | $this->validator->pop_field(); |
189 | 189 | |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | /** |
194 | 194 | * @since 1.0.0 |
195 | 195 | */ |
196 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
196 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
197 | 197 | |
198 | - $conditions = $fire->reaction->get_meta( 'conditions' ); |
|
198 | + $conditions = $fire->reaction->get_meta('conditions'); |
|
199 | 199 | |
200 | - if ( $conditions && ! $this->conditions_are_met( $conditions, $fire->event_args ) ) { |
|
200 | + if ($conditions && ! $this->conditions_are_met($conditions, $fire->event_args)) { |
|
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
@@ -219,35 +219,35 @@ discard block |
||
219 | 219 | WordPoints_Hook_Event_Args $event_args |
220 | 220 | ) { |
221 | 221 | |
222 | - foreach ( $conditions as $arg_slug => $sub_args ) { |
|
222 | + foreach ($conditions as $arg_slug => $sub_args) { |
|
223 | 223 | |
224 | - $event_args->descend( $arg_slug ); |
|
224 | + $event_args->descend($arg_slug); |
|
225 | 225 | |
226 | - if ( isset( $sub_args['_conditions'] ) ) { |
|
226 | + if (isset($sub_args['_conditions'])) { |
|
227 | 227 | |
228 | - foreach ( $sub_args['_conditions'] as $settings ) { |
|
228 | + foreach ($sub_args['_conditions'] as $settings) { |
|
229 | 229 | |
230 | 230 | $condition = $this->conditions->get( |
231 | - $this->get_data_type( $event_args->get_current() ) |
|
231 | + $this->get_data_type($event_args->get_current()) |
|
232 | 232 | , $settings['type'] |
233 | 233 | ); |
234 | 234 | |
235 | - $is_met = $condition->is_met( $settings['settings'], $event_args ); |
|
235 | + $is_met = $condition->is_met($settings['settings'], $event_args); |
|
236 | 236 | |
237 | - if ( ! $is_met ) { |
|
237 | + if ( ! $is_met) { |
|
238 | 238 | $event_args->ascend(); |
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | - unset( $sub_args['_conditions'] ); |
|
243 | + unset($sub_args['_conditions']); |
|
244 | 244 | } |
245 | 245 | |
246 | - $are_met = $this->conditions_are_met( $sub_args, $event_args ); |
|
246 | + $are_met = $this->conditions_are_met($sub_args, $event_args); |
|
247 | 247 | |
248 | 248 | $event_args->ascend(); |
249 | 249 | |
250 | - if ( ! $are_met ) { |
|
250 | + if ( ! $are_met) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | } |
@@ -264,13 +264,13 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string|false The data type, or false. |
266 | 266 | */ |
267 | - protected function get_data_type( $arg ) { |
|
267 | + protected function get_data_type($arg) { |
|
268 | 268 | |
269 | - if ( $arg instanceof WordPoints_Entity_Attr ) { |
|
269 | + if ($arg instanceof WordPoints_Entity_Attr) { |
|
270 | 270 | $data_type = $arg->get_data_type(); |
271 | - } elseif ( $arg instanceof WordPoints_Entity_Array ) { |
|
271 | + } elseif ($arg instanceof WordPoints_Entity_Array) { |
|
272 | 272 | $data_type = 'entity_array'; |
273 | - } elseif ( $arg instanceof WordPoints_Entity ) { |
|
273 | + } elseif ($arg instanceof WordPoints_Entity) { |
|
274 | 274 | $data_type = 'entity'; |
275 | 275 | } else { |
276 | 276 | $data_type = false; |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | public function get_ui_script_data() { |
26 | 26 | |
27 | 27 | $periods = array( |
28 | - MINUTE_IN_SECONDS => __( 'Minute', 'wordpoints' ), |
|
29 | - HOUR_IN_SECONDS => __( 'Hour', 'wordpoints' ), |
|
30 | - DAY_IN_SECONDS => __( 'Day', 'wordpoints' ), |
|
31 | - WEEK_IN_SECONDS => __( 'Week', 'wordpoints' ), |
|
32 | - 30 * DAY_IN_SECONDS => __( 'Month', 'wordpoints' ), |
|
28 | + MINUTE_IN_SECONDS => __('Minute', 'wordpoints'), |
|
29 | + HOUR_IN_SECONDS => __('Hour', 'wordpoints'), |
|
30 | + DAY_IN_SECONDS => __('Day', 'wordpoints'), |
|
31 | + WEEK_IN_SECONDS => __('Week', 'wordpoints'), |
|
32 | + 30 * DAY_IN_SECONDS => __('Month', 'wordpoints'), |
|
33 | 33 | ); |
34 | 34 | |
35 | 35 | /** |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param string[] $periods The period titles, indexed by length in seconds. |
41 | 41 | */ |
42 | - $periods = apply_filters( 'wordpoints_hooks_ui_data_periods', $periods ); |
|
42 | + $periods = apply_filters('wordpoints_hooks_ui_data_periods', $periods); |
|
43 | 43 | |
44 | 44 | return array( |
45 | 45 | 'periods' => $periods, |
46 | 46 | 'l10n' => array( |
47 | 47 | // TODO this should be supplied per-reactor |
48 | - 'label' => __( 'Award each user no more than once per:', 'wordpoints' ), |
|
48 | + 'label' => __('Award each user no more than once per:', 'wordpoints'), |
|
49 | 49 | ), |
50 | 50 | ); |
51 | 51 | } |
@@ -59,25 +59,25 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return array The validated periods. |
61 | 61 | */ |
62 | - protected function validate_periods( $periods ) { |
|
62 | + protected function validate_periods($periods) { |
|
63 | 63 | |
64 | - if ( ! is_array( $periods ) ) { |
|
64 | + if ( ! is_array($periods)) { |
|
65 | 65 | |
66 | 66 | $this->validator->add_error( |
67 | - __( 'Periods do not match expected format.', 'wordpoints' ) |
|
67 | + __('Periods do not match expected format.', 'wordpoints') |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | return array(); |
71 | 71 | } |
72 | 72 | |
73 | - foreach ( $periods as $index => $period ) { |
|
73 | + foreach ($periods as $index => $period) { |
|
74 | 74 | |
75 | - $this->validator->push_field( $index ); |
|
75 | + $this->validator->push_field($index); |
|
76 | 76 | |
77 | - $period = $this->validate_period( $period ); |
|
77 | + $period = $this->validate_period($period); |
|
78 | 78 | |
79 | - if ( $period ) { |
|
80 | - $periods[ $index ] = $period; |
|
79 | + if ($period) { |
|
80 | + $periods[$index] = $period; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $this->validator->pop_field(); |
@@ -95,30 +95,30 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return array|false The validated period, or false if invalid. |
97 | 97 | */ |
98 | - protected function validate_period( $period ) { |
|
98 | + protected function validate_period($period) { |
|
99 | 99 | |
100 | - if ( ! is_array( $period ) ) { |
|
100 | + if ( ! is_array($period)) { |
|
101 | 101 | $this->validator->add_error( |
102 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
102 | + __('Period does not match expected format.', 'wordpoints') |
|
103 | 103 | ); |
104 | 104 | |
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
108 | - if ( isset( $period['args'] ) ) { |
|
109 | - $this->validate_period_args( $period['args'] ); |
|
108 | + if (isset($period['args'])) { |
|
109 | + $this->validate_period_args($period['args']); |
|
110 | 110 | } |
111 | 111 | |
112 | - if ( ! isset( $period['length'] ) ) { |
|
112 | + if ( ! isset($period['length'])) { |
|
113 | 113 | |
114 | 114 | $this->validator->add_error( |
115 | - __( 'Period length setting is missing.', 'wordpoints' ) |
|
115 | + __('Period length setting is missing.', 'wordpoints') |
|
116 | 116 | ); |
117 | 117 | |
118 | - } elseif ( false === wordpoints_posint( $period['length'] ) ) { |
|
118 | + } elseif (false === wordpoints_posint($period['length'])) { |
|
119 | 119 | |
120 | 120 | $this->validator->add_error( |
121 | - __( 'Period length must be a positive integer.', 'wordpoints' ) |
|
121 | + __('Period length must be a positive integer.', 'wordpoints') |
|
122 | 122 | , 'length' |
123 | 123 | ); |
124 | 124 | |
@@ -135,34 +135,34 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param mixed $args The args the period is related to. |
137 | 137 | */ |
138 | - protected function validate_period_args( $args ) { |
|
138 | + protected function validate_period_args($args) { |
|
139 | 139 | |
140 | - if ( ! is_array( $args ) ) { |
|
140 | + if ( ! is_array($args)) { |
|
141 | 141 | |
142 | 142 | $this->validator->add_error( |
143 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
143 | + __('Period does not match expected format.', 'wordpoints') |
|
144 | 144 | , 'args' |
145 | 145 | ); |
146 | 146 | |
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | - $this->validator->push_field( 'args' ); |
|
150 | + $this->validator->push_field('args'); |
|
151 | 151 | |
152 | - foreach ( $args as $index => $hierarchy ) { |
|
152 | + foreach ($args as $index => $hierarchy) { |
|
153 | 153 | |
154 | - $this->validator->push_field( $index ); |
|
154 | + $this->validator->push_field($index); |
|
155 | 155 | |
156 | - if ( ! is_array( $hierarchy ) ) { |
|
156 | + if ( ! is_array($hierarchy)) { |
|
157 | 157 | |
158 | 158 | $this->validator->add_error( |
159 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
159 | + __('Period does not match expected format.', 'wordpoints') |
|
160 | 160 | ); |
161 | 161 | |
162 | - } elseif ( ! $this->event_args->get_from_hierarchy( $hierarchy ) ) { |
|
162 | + } elseif ( ! $this->event_args->get_from_hierarchy($hierarchy)) { |
|
163 | 163 | |
164 | 164 | $this->validator->add_error( |
165 | - __( 'Invalid period.', 'wordpoints' ) // TODO better error message |
|
165 | + __('Invalid period.', 'wordpoints') // TODO better error message |
|
166 | 166 | ); |
167 | 167 | } |
168 | 168 | |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | /** |
176 | 176 | * @since 1.0.0 |
177 | 177 | */ |
178 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
178 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
179 | 179 | |
180 | - $periods = $fire->reaction->get_meta( 'periods' ); |
|
180 | + $periods = $fire->reaction->get_meta('periods'); |
|
181 | 181 | |
182 | - if ( empty( $periods ) ) { |
|
182 | + if (empty($periods)) { |
|
183 | 183 | return true; |
184 | 184 | } |
185 | 185 | |
186 | 186 | $this->event_args = $fire->event_args; |
187 | 187 | |
188 | - foreach ( $periods as $period ) { |
|
189 | - if ( ! $this->has_period_ended( $period, $fire->reaction ) ) { |
|
188 | + foreach ($periods as $period) { |
|
189 | + if ( ! $this->has_period_ended($period, $fire->reaction)) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | } |
@@ -210,24 +210,24 @@ discard block |
||
210 | 210 | ) { |
211 | 211 | |
212 | 212 | $period = $this->get_period_by_reaction( |
213 | - $this->get_period_signature( $settings, $reaction ) |
|
213 | + $this->get_period_signature($settings, $reaction) |
|
214 | 214 | , $reaction |
215 | 215 | ); |
216 | 216 | |
217 | 217 | // If the period isn't found, we know that we can still fire. |
218 | - if ( ! $period ) { |
|
218 | + if ( ! $period) { |
|
219 | 219 | return true; |
220 | 220 | } |
221 | 221 | |
222 | - $now = current_time( 'timestamp' ); |
|
223 | - $hit_time = strtotime( $period->hit_time, $now ); |
|
222 | + $now = current_time('timestamp'); |
|
223 | + $hit_time = strtotime($period->hit_time, $now); |
|
224 | 224 | |
225 | - if ( ! empty( $settings['relative'] ) ) { |
|
226 | - return ( $hit_time < $now - $settings['length'] ); |
|
225 | + if ( ! empty($settings['relative'])) { |
|
226 | + return ($hit_time < $now - $settings['length']); |
|
227 | 227 | } else { |
228 | 228 | return ( |
229 | - (int) ( $hit_time / $settings['length'] ) |
|
230 | - < (int) ( $now / $settings['length'] ) |
|
229 | + (int) ($hit_time / $settings['length']) |
|
230 | + < (int) ($now / $settings['length']) |
|
231 | 231 | ); |
232 | 232 | } |
233 | 233 | } |
@@ -241,24 +241,24 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return array The arg values. |
243 | 243 | */ |
244 | - protected function get_arg_values( array $period_args ) { |
|
244 | + protected function get_arg_values(array $period_args) { |
|
245 | 245 | |
246 | 246 | $values = array(); |
247 | 247 | |
248 | - foreach ( $period_args as $arg_hierarchy ) { |
|
248 | + foreach ($period_args as $arg_hierarchy) { |
|
249 | 249 | |
250 | 250 | $arg = $this->event_args->get_from_hierarchy( |
251 | 251 | $arg_hierarchy |
252 | 252 | ); |
253 | 253 | |
254 | - if ( ! $arg instanceof WordPoints_EntityishI ) { |
|
254 | + if ( ! $arg instanceof WordPoints_EntityishI) { |
|
255 | 255 | continue; |
256 | 256 | } |
257 | 257 | |
258 | - $values[ implode( '.', $arg_hierarchy ) ] = $arg->get_the_value(); |
|
258 | + $values[implode('.', $arg_hierarchy)] = $arg->get_the_value(); |
|
259 | 259 | } |
260 | 260 | |
261 | - ksort( $values ); |
|
261 | + ksort($values); |
|
262 | 262 | |
263 | 263 | return $values; |
264 | 264 | } |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return object|false The period data, or false if not found. |
274 | 274 | */ |
275 | - protected function get_period( $period_id ) { |
|
275 | + protected function get_period($period_id) { |
|
276 | 276 | |
277 | - $period = wp_cache_get( $period_id, 'wordpoints_hook_period' ); |
|
277 | + $period = wp_cache_get($period_id, 'wordpoints_hook_period'); |
|
278 | 278 | |
279 | - if ( ! $period ) { |
|
279 | + if ( ! $period) { |
|
280 | 280 | |
281 | 281 | global $wpdb; |
282 | 282 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ) |
292 | 292 | ); |
293 | 293 | |
294 | - if ( ! $period ) { |
|
294 | + if ( ! $period) { |
|
295 | 295 | return false; |
296 | 296 | } |
297 | 297 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | , 'wordpoints_hook_period_ids' |
302 | 302 | ); |
303 | 303 | |
304 | - wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' ); |
|
304 | + wp_cache_set($period->id, $period, 'wordpoints_hook_periods'); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | return $period; |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | $cache_key = "{$reaction_id}-{$signature}"; |
329 | 329 | |
330 | 330 | // Before we run the query, we try to lookup the ID in the cache. |
331 | - $period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids' ); |
|
331 | + $period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids'); |
|
332 | 332 | |
333 | 333 | // If we found it, we can retrieve the period by ID instead. |
334 | - if ( $period_id ) { |
|
335 | - return $this->get_period( $period_id ); |
|
334 | + if ($period_id) { |
|
335 | + return $this->get_period($period_id); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | global $wpdb; |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | ) |
354 | 354 | ); |
355 | 355 | |
356 | - if ( ! $period ) { |
|
356 | + if ( ! $period) { |
|
357 | 357 | return false; |
358 | 358 | } |
359 | 359 | |
360 | - wp_cache_set( $cache_key, $period->id, 'wordpoints_hook_period_ids' ); |
|
361 | - wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' ); |
|
360 | + wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids'); |
|
361 | + wp_cache_set($period->id, $period, 'wordpoints_hook_periods'); |
|
362 | 362 | |
363 | 363 | return $period; |
364 | 364 | } |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | /** |
367 | 367 | * @since 1.0.0 |
368 | 368 | */ |
369 | - public function after_hit( WordPoints_Hook_Fire $fire ) { |
|
369 | + public function after_hit(WordPoints_Hook_Fire $fire) { |
|
370 | 370 | |
371 | - $periods = $fire->reaction->get_meta( 'periods' ); |
|
371 | + $periods = $fire->reaction->get_meta('periods'); |
|
372 | 372 | |
373 | - if ( empty( $periods ) ) { |
|
373 | + if (empty($periods)) { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | $this->event_args = $fire->event_args; |
378 | 378 | |
379 | - foreach ( $periods as $settings ) { |
|
379 | + foreach ($periods as $settings) { |
|
380 | 380 | |
381 | 381 | $this->add_period( |
382 | - $this->get_period_signature( $settings, $fire->reaction ) |
|
382 | + $this->get_period_signature($settings, $fire->reaction) |
|
383 | 383 | , $fire->reaction |
384 | 384 | ); |
385 | 385 | } |
@@ -404,14 +404,14 @@ discard block |
||
404 | 404 | WordPoints_Hook_ReactionI $reaction |
405 | 405 | ) { |
406 | 406 | |
407 | - if ( isset( $settings['args'] ) ) { |
|
407 | + if (isset($settings['args'])) { |
|
408 | 408 | $period_args = $settings['args']; |
409 | 409 | } else { |
410 | - $period_args = array( $reaction->get_meta( 'target' ) ); |
|
410 | + $period_args = array($reaction->get_meta('target')); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | return wordpoints_hash( |
414 | - wp_json_encode( $this->get_arg_values( $period_args ) ) |
|
414 | + wp_json_encode($this->get_arg_values($period_args)) |
|
415 | 415 | ); |
416 | 416 | } |
417 | 417 | |
@@ -439,12 +439,12 @@ discard block |
||
439 | 439 | , array( |
440 | 440 | 'reaction_id' => $reaction_id, |
441 | 441 | 'signature' => $signature, |
442 | - 'hit_time' => current_time( 'mysql' ), |
|
442 | + 'hit_time' => current_time('mysql'), |
|
443 | 443 | ) |
444 | - , array( '%d', '%s', '%s' ) |
|
444 | + , array('%d', '%s', '%s') |
|
445 | 445 | ); |
446 | 446 | |
447 | - if ( ! $inserted ) { |
|
447 | + if ( ! $inserted) { |
|
448 | 448 | return false; |
449 | 449 | } |
450 | 450 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @since 1.0.0 |
28 | 28 | */ |
29 | - public function __construct( $slug ) { |
|
29 | + public function __construct($slug) { |
|
30 | 30 | $this->slug = $slug; |
31 | 31 | } |
32 | 32 | |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @since 1.0.0 |
42 | 42 | */ |
43 | - public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args ) { |
|
43 | + public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args) { |
|
44 | 44 | |
45 | 45 | $hooks = wordpoints_hooks(); |
46 | 46 | |
47 | 47 | /** @var WordPoints_Hook_Reactor $reactor */ |
48 | - foreach ( $hooks->reactors->get_all() as $reactor ) { |
|
48 | + foreach ($hooks->reactors->get_all() as $reactor) { |
|
49 | 49 | |
50 | - foreach ( $reactor->get_all_reactions_to_event( $event_slug ) as $reaction ) { |
|
50 | + foreach ($reactor->get_all_reactions_to_event($event_slug) as $reaction) { |
|
51 | 51 | |
52 | 52 | $validator = new WordPoints_Hook_Reaction_Validator( |
53 | 53 | $reaction |
@@ -57,29 +57,29 @@ discard block |
||
57 | 57 | |
58 | 58 | $validator->validate(); |
59 | 59 | |
60 | - if ( $validator->had_errors() ) { |
|
60 | + if ($validator->had_errors()) { |
|
61 | 61 | continue; |
62 | 62 | } |
63 | 63 | |
64 | - unset( $validator ); |
|
64 | + unset($validator); |
|
65 | 65 | |
66 | - $fire = new WordPoints_Hook_Fire( $this, $event_args, $reaction ); |
|
66 | + $fire = new WordPoints_Hook_Fire($this, $event_args, $reaction); |
|
67 | 67 | |
68 | 68 | /** @var WordPoints_Hook_Extension[] $extensions */ |
69 | 69 | $extensions = $hooks->extensions->get_all(); |
70 | 70 | |
71 | - foreach ( $extensions as $extension ) { |
|
72 | - if ( ! $extension->should_hit( $fire ) ) { |
|
71 | + foreach ($extensions as $extension) { |
|
72 | + if ( ! $extension->should_hit($fire)) { |
|
73 | 73 | continue 2; |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | $fire->hit(); |
78 | 78 | |
79 | - $reactor->hit( $fire ); |
|
79 | + $reactor->hit($fire); |
|
80 | 80 | |
81 | - foreach ( $extensions as $extension ) { |
|
82 | - $extension->after_hit( $fire ); |
|
81 | + foreach ($extensions as $extension) { |
|
82 | + $extension->after_hit($fire); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @since 1.0.0 |
55 | 55 | */ |
56 | - public function __get( $var ) { |
|
56 | + public function __get($var) { |
|
57 | 57 | |
58 | - if ( 'reactions' !== $var ) { |
|
58 | + if ('reactions' !== $var) { |
|
59 | 59 | return null; |
60 | 60 | } |
61 | 61 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | wordpoints_hooks()->get_current_mode() |
64 | 64 | ); |
65 | 65 | |
66 | - if ( ! $reaction_group ) { |
|
66 | + if ( ! $reaction_group) { |
|
67 | 67 | return null; |
68 | 68 | } |
69 | 69 | |
@@ -79,20 +79,20 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return WordPoints_Hook_Reaction_StorageI|false The reaction storage object. |
81 | 81 | */ |
82 | - public function get_reaction_group( $slug ) { |
|
82 | + public function get_reaction_group($slug) { |
|
83 | 83 | |
84 | 84 | $reaction_group = wordpoints_hooks()->reaction_groups->get( |
85 | 85 | $this->slug |
86 | 86 | , $slug |
87 | - , array( $this ) |
|
87 | + , array($this) |
|
88 | 88 | ); |
89 | 89 | |
90 | - if ( ! $reaction_group instanceof WordPoints_Hook_Reaction_StorageI ) { |
|
90 | + if ( ! $reaction_group instanceof WordPoints_Hook_Reaction_StorageI) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Allowing access to groups out-of-context would lead to strange behavior. |
95 | - if ( false === $reaction_group->get_context_id() ) { |
|
95 | + if (false === $reaction_group->get_context_id()) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return WordPoints_Hook_ReactionI[] All of the reaction objects. |
168 | 168 | */ |
169 | - public function get_all_reactions_to_event( $event_slug ) { |
|
169 | + public function get_all_reactions_to_event($event_slug) { |
|
170 | 170 | |
171 | 171 | $reactions = array(); |
172 | 172 | |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | $this->slug |
175 | 175 | ); |
176 | 176 | |
177 | - foreach ( $slugs as $slug ) { |
|
177 | + foreach ($slugs as $slug) { |
|
178 | 178 | |
179 | - $storage = $this->get_reaction_group( $slug ); |
|
179 | + $storage = $this->get_reaction_group($slug); |
|
180 | 180 | |
181 | - if ( ! $storage ) { |
|
181 | + if ( ! $storage) { |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | |
185 | 185 | $reactions = array_merge( |
186 | 186 | $reactions |
187 | - , $storage->get_reactions_to_event( $event_slug ) |
|
187 | + , $storage->get_reactions_to_event($event_slug) |
|
188 | 188 | ); |
189 | 189 | } |
190 | 190 | |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | $this->slug |
214 | 214 | ); |
215 | 215 | |
216 | - foreach ( $slugs as $slug ) { |
|
216 | + foreach ($slugs as $slug) { |
|
217 | 217 | |
218 | - $storage = $this->get_reaction_group( $slug ); |
|
218 | + $storage = $this->get_reaction_group($slug); |
|
219 | 219 | |
220 | - if ( ! $storage ) { |
|
220 | + if ( ! $storage) { |
|
221 | 221 | continue; |
222 | 222 | } |
223 | 223 | |
224 | - $reactions = array_merge( $reactions, $storage->get_reactions() ); |
|
224 | + $reactions = array_merge($reactions, $storage->get_reactions()); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $reactions; |
@@ -237,21 +237,21 @@ discard block |
||
237 | 237 | ) { |
238 | 238 | |
239 | 239 | if ( |
240 | - empty( $settings['target'] ) |
|
241 | - || ! is_array( $settings['target'] ) |
|
240 | + empty($settings['target']) |
|
241 | + || ! is_array($settings['target']) |
|
242 | 242 | ) { |
243 | 243 | |
244 | - $validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' ); |
|
244 | + $validator->add_error(__('Invalid target.', 'wordpoints'), 'target'); |
|
245 | 245 | |
246 | 246 | } else { |
247 | 247 | |
248 | - $target = $event_args->get_from_hierarchy( $settings['target'] ); |
|
248 | + $target = $event_args->get_from_hierarchy($settings['target']); |
|
249 | 249 | |
250 | 250 | if ( |
251 | 251 | ! $target instanceof WordPoints_Entity |
252 | - || ! in_array( $target->get_slug(), (array) $this->arg_types ) |
|
252 | + || ! in_array($target->get_slug(), (array) $this->arg_types) |
|
253 | 253 | ) { |
254 | - $validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' ); |
|
254 | + $validator->add_error(__('Invalid target.', 'wordpoints'), 'target'); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | /** |
262 | 262 | * @since 1.0.0 |
263 | 263 | */ |
264 | - public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) { |
|
265 | - $reaction->update_meta( 'target', $settings['target'] ); |
|
264 | + public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) { |
|
265 | + $reaction->update_meta('target', $settings['target']); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @param WordPoints_Hook_Fire $fire The hook fire object. |
274 | 274 | */ |
275 | - abstract public function hit( WordPoints_Hook_Fire $fire ); |
|
275 | + abstract public function hit(WordPoints_Hook_Fire $fire); |
|
276 | 276 | |
277 | 277 | /** |
278 | 278 | * Reverses all hits matching this event and args. |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @param WordPoints_Hook_Fire $fire The reverse fire object. |
283 | 283 | */ |
284 | - abstract public function reverse_hit( WordPoints_Hook_Fire $fire ); |
|
284 | + abstract public function reverse_hit(WordPoints_Hook_Fire $fire); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // EOF |