@@ -30,46 +30,46 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @since 1.0.0 |
32 | 32 | */ |
33 | - public function get_all( array $args = array() ) { |
|
34 | - return self::construct_with_args( $this->classes, $args ); |
|
33 | + public function get_all(array $args = array()) { |
|
34 | + return self::construct_with_args($this->classes, $args); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @since 1.0.0 |
39 | 39 | */ |
40 | 40 | public function get_all_slugs() { |
41 | - return array_keys( $this->classes ); |
|
41 | + return array_keys($this->classes); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @since 1.0.0 |
46 | 46 | */ |
47 | - public function get( $slug, array $args = array() ) { |
|
47 | + public function get($slug, array $args = array()) { |
|
48 | 48 | |
49 | - if ( ! isset( $this->classes[ $slug ] ) ) { |
|
49 | + if ( ! isset($this->classes[$slug])) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - if ( ! empty( $args ) ) { |
|
53 | + if ( ! empty($args)) { |
|
54 | 54 | |
55 | - array_unshift( $args, $slug ); |
|
55 | + array_unshift($args, $slug); |
|
56 | 56 | |
57 | 57 | return wordpoints_construct_class_with_args( |
58 | - $this->classes[ $slug ] |
|
58 | + $this->classes[$slug] |
|
59 | 59 | , $args |
60 | 60 | ); |
61 | 61 | |
62 | 62 | } else { |
63 | - return new $this->classes[ $slug ]( $slug ); |
|
63 | + return new $this->classes[$slug]($slug); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @since 1.0.0 |
69 | 69 | */ |
70 | - public function register( $slug, $class, array $args = array() ) { |
|
70 | + public function register($slug, $class, array $args = array()) { |
|
71 | 71 | |
72 | - $this->classes[ $slug ] = $class; |
|
72 | + $this->classes[$slug] = $class; |
|
73 | 73 | |
74 | 74 | return true; |
75 | 75 | } |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * @since 1.0.0 |
79 | 79 | */ |
80 | - public function deregister( $slug ) { |
|
80 | + public function deregister($slug) { |
|
81 | 81 | |
82 | - unset( $this->classes[ $slug ] ); |
|
82 | + unset($this->classes[$slug]); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @since 1.0.0 |
87 | 87 | */ |
88 | - public function is_registered( $slug ) { |
|
88 | + public function is_registered($slug) { |
|
89 | 89 | |
90 | - return isset( $this->classes[ $slug ] ); |
|
90 | + return isset($this->classes[$slug]); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -101,24 +101,24 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return object[] An array of the constructed objects. |
103 | 103 | */ |
104 | - public static function construct_with_args( array $classes, array $args ) { |
|
104 | + public static function construct_with_args(array $classes, array $args) { |
|
105 | 105 | |
106 | 106 | $objects = array(); |
107 | 107 | |
108 | - if ( empty( $args ) ) { |
|
108 | + if (empty($args)) { |
|
109 | 109 | |
110 | - foreach ( $classes as $slug => $class ) { |
|
111 | - $objects[ $slug ] = new $class( $slug ); |
|
110 | + foreach ($classes as $slug => $class) { |
|
111 | + $objects[$slug] = new $class($slug); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | } else { |
115 | 115 | |
116 | - array_unshift( $args, null ); |
|
116 | + array_unshift($args, null); |
|
117 | 117 | |
118 | - foreach ( $classes as $slug => $class ) { |
|
119 | - $objects[ $slug ] = wordpoints_construct_class_with_args( |
|
118 | + foreach ($classes as $slug => $class) { |
|
119 | + $objects[$slug] = wordpoints_construct_class_with_args( |
|
120 | 120 | $class |
121 | - , array( $slug ) + $args |
|
121 | + , array($slug) + $args |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | } |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * @param string $slug The arg slug. |
71 | 71 | * @param WordPoints_Hook_ActionI $action The calling action's object. |
72 | 72 | */ |
73 | - public function __construct( $slug, WordPoints_Hook_ActionI $action = null ) { |
|
73 | + public function __construct($slug, WordPoints_Hook_ActionI $action = null) { |
|
74 | 74 | |
75 | 75 | $this->slug = $slug; |
76 | 76 | $this->action = $action; |
77 | 77 | |
78 | - $parts = explode( ':', $slug, 2 ); |
|
78 | + $parts = explode(':', $slug, 2); |
|
79 | 79 | |
80 | - if ( isset( $parts[1] ) ) { |
|
80 | + if (isset($parts[1])) { |
|
81 | 81 | $this->entity_slug = $parts[1]; |
82 | 82 | } else { |
83 | 83 | $this->entity_slug = $slug; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | $this->get_entity_slug() |
120 | 120 | ); |
121 | 121 | |
122 | - if ( $entity instanceof WordPoints_Entity ) { |
|
122 | + if ($entity instanceof WordPoints_Entity) { |
|
123 | 123 | $value = $this->get_value(); |
124 | 124 | |
125 | - if ( $value ) { |
|
126 | - $entity->set_the_value( $value ); |
|
125 | + if ($value) { |
|
126 | + $entity->set_the_value($value); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function get_value() { |
141 | 141 | |
142 | - if ( $this->action instanceof WordPoints_Hook_ActionI ) { |
|
143 | - return $this->action->get_arg_value( $this->slug ); |
|
142 | + if ($this->action instanceof WordPoints_Hook_ActionI) { |
|
143 | + return $this->action->get_arg_value($this->slug); |
|
144 | 144 | } else { |
145 | 145 | return null; |
146 | 146 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | $entity = $this->get_entity(); |
159 | 159 | |
160 | - if ( ! $entity ) { |
|
160 | + if ( ! $entity) { |
|
161 | 161 | return $this->slug; |
162 | 162 | } |
163 | 163 |
@@ -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 |
@@ -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 | /** |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | |
395 | 395 | $guid = $this->get_the_context(); |
396 | 396 | |
397 | - if ( ! is_array( $guid ) ) { |
|
397 | + if ( ! is_array($guid)) { |
|
398 | 398 | return $guid; |
399 | 399 | } |
400 | 400 | |
401 | - $guid = array( $this->slug => $this->get_the_id() ) + $guid; |
|
401 | + $guid = array($this->slug => $this->get_the_id()) + $guid; |
|
402 | 402 | |
403 | 403 | return $guid; |
404 | 404 | } |
@@ -179,7 +179,7 @@ |
||
179 | 179 | * |
180 | 180 | * @param string $event_slug The slug of the event this reaction is for. |
181 | 181 | * |
182 | - * @return int|false The reaction ID, or false if not created. |
|
182 | + * @return integer The reaction ID, or false if not created. |
|
183 | 183 | */ |
184 | 184 | abstract protected function _create_reaction( $event_slug ); |
185 | 185 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * @since 1.0.0 |
53 | 53 | */ |
54 | - public function __construct( $slug ) { |
|
54 | + public function __construct($slug) { |
|
55 | 55 | $this->slug = $slug; |
56 | 56 | } |
57 | 57 | |
@@ -66,33 +66,33 @@ discard block |
||
66 | 66 | * @since 1.0.0 |
67 | 67 | */ |
68 | 68 | public function get_context_id() { |
69 | - return wordpoints_entities_get_current_context_id( $this->context ); |
|
69 | + return wordpoints_entities_get_current_context_id($this->context); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @since 1.0.0 |
74 | 74 | */ |
75 | - public function get_reaction( $id ) { |
|
75 | + public function get_reaction($id) { |
|
76 | 76 | |
77 | - if ( ! $this->reaction_exists( $id ) ) { |
|
77 | + if ( ! $this->reaction_exists($id)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - return new $this->reaction_class( $id, $this ); |
|
81 | + return new $this->reaction_class($id, $this); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @since 1.0.0 |
86 | 86 | */ |
87 | - public function create_reaction( array $settings ) { |
|
88 | - return $this->create_or_update_reaction( $settings ); |
|
87 | + public function create_reaction(array $settings) { |
|
88 | + return $this->create_or_update_reaction($settings); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @since 1.0.0 |
93 | 93 | */ |
94 | - public function update_reaction( $id, array $settings ) { |
|
95 | - return $this->create_or_update_reaction( $settings, $id ); |
|
94 | + public function update_reaction($id, array $settings) { |
|
95 | + return $this->create_or_update_reaction($settings, $id); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -107,45 +107,45 @@ discard block |
||
107 | 107 | * The reaction object if created/updated successfully. False or a |
108 | 108 | * validator instance if not. |
109 | 109 | */ |
110 | - protected function create_or_update_reaction( array $settings, $id = null ) { |
|
110 | + protected function create_or_update_reaction(array $settings, $id = null) { |
|
111 | 111 | |
112 | - $is_new = ! isset( $id ); |
|
112 | + $is_new = ! isset($id); |
|
113 | 113 | |
114 | - if ( ! $is_new && ! $this->reaction_exists( $id ) ) { |
|
114 | + if ( ! $is_new && ! $this->reaction_exists($id)) { |
|
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | |
118 | - $validator = new WordPoints_Hook_Reaction_Validator( $settings ); |
|
118 | + $validator = new WordPoints_Hook_Reaction_Validator($settings); |
|
119 | 119 | $settings = $validator->validate(); |
120 | 120 | |
121 | - if ( $validator->had_errors() ) { |
|
121 | + if ($validator->had_errors()) { |
|
122 | 122 | return $validator; |
123 | 123 | } |
124 | 124 | |
125 | - if ( $is_new ) { |
|
125 | + if ($is_new) { |
|
126 | 126 | |
127 | - $id = $this->_create_reaction( $settings['event'] ); |
|
127 | + $id = $this->_create_reaction($settings['event']); |
|
128 | 128 | |
129 | - if ( ! $id ) { |
|
129 | + if ( ! $id) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - $reaction = $this->get_reaction( $id ); |
|
134 | + $reaction = $this->get_reaction($id); |
|
135 | 135 | |
136 | - $reaction->update_event_slug( $settings['event'] ); |
|
136 | + $reaction->update_event_slug($settings['event']); |
|
137 | 137 | |
138 | - unset( $settings['event'] ); |
|
138 | + unset($settings['event']); |
|
139 | 139 | |
140 | - $reaction->update_meta( 'reactor', $settings['reactor'] ); |
|
140 | + $reaction->update_meta('reactor', $settings['reactor']); |
|
141 | 141 | |
142 | 142 | /** @var WordPoints_Hook_Reactor $reactor */ |
143 | - $reactor = wordpoints_hooks()->reactors->get( $settings['reactor'] ); |
|
144 | - $reactor->update_settings( $reaction, $settings ); |
|
143 | + $reactor = wordpoints_hooks()->reactors->get($settings['reactor']); |
|
144 | + $reactor->update_settings($reaction, $settings); |
|
145 | 145 | |
146 | 146 | /** @var WordPoints_Hook_Extension $extension */ |
147 | - foreach ( wordpoints_hooks()->extensions->get_all() as $extension ) { |
|
148 | - $extension->update_settings( $reaction, $settings ); |
|
147 | + foreach (wordpoints_hooks()->extensions->get_all() as $extension) { |
|
148 | + $extension->update_settings($reaction, $settings); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param array $settings The new settings for the reaction. |
156 | 156 | * @param bool $is_new Whether the reaction was just now created. |
157 | 157 | */ |
158 | - do_action( 'wordpoints_hook_reaction_save', $reaction, $settings, $is_new ); |
|
158 | + do_action('wordpoints_hook_reaction_save', $reaction, $settings, $is_new); |
|
159 | 159 | |
160 | 160 | return $reaction; |
161 | 161 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return int|false The reaction ID, or false if not created. |
174 | 174 | */ |
175 | - abstract protected function _create_reaction( $event_slug ); |
|
175 | + abstract protected function _create_reaction($event_slug); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | // EOF |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * @since 1.0.0 |
26 | 26 | */ |
27 | 27 | public function get_event_slug() { |
28 | - return $this->store->get_reaction_event_from_index( $this->ID ); |
|
28 | + return $this->store->get_reaction_event_from_index($this->ID); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @since 1.0.0 |
33 | 33 | */ |
34 | - public function update_event_slug( $event_slug ) { |
|
34 | + public function update_event_slug($event_slug) { |
|
35 | 35 | return $this->store->update_reaction_event_in_index( |
36 | 36 | $this->ID |
37 | 37 | , $event_slug |
@@ -41,63 +41,63 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * @since 1.0.0 |
43 | 43 | */ |
44 | - public function get_meta( $key ) { |
|
44 | + public function get_meta($key) { |
|
45 | 45 | |
46 | 46 | $settings = $this->get_settings(); |
47 | 47 | |
48 | - if ( ! is_array( $settings ) || ! isset( $settings[ $key ] ) ) { |
|
48 | + if ( ! is_array($settings) || ! isset($settings[$key])) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | |
52 | - return $settings[ $key ]; |
|
52 | + return $settings[$key]; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @since 1.0.0 |
57 | 57 | */ |
58 | - public function add_meta( $key, $value ) { |
|
58 | + public function add_meta($key, $value) { |
|
59 | 59 | |
60 | 60 | $settings = $this->get_settings(); |
61 | 61 | |
62 | - if ( ! is_array( $settings ) || isset( $settings[ $key ] ) ) { |
|
62 | + if ( ! is_array($settings) || isset($settings[$key])) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
66 | - $settings[ $key ] = $value; |
|
66 | + $settings[$key] = $value; |
|
67 | 67 | |
68 | - return $this->update_settings( $settings ); |
|
68 | + return $this->update_settings($settings); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @since 1.0.0 |
73 | 73 | */ |
74 | - public function update_meta( $key, $value ) { |
|
74 | + public function update_meta($key, $value) { |
|
75 | 75 | |
76 | 76 | $settings = $this->get_settings(); |
77 | 77 | |
78 | - if ( ! is_array( $settings ) ) { |
|
78 | + if ( ! is_array($settings)) { |
|
79 | 79 | return false; |
80 | 80 | } |
81 | 81 | |
82 | - $settings[ $key ] = $value; |
|
82 | + $settings[$key] = $value; |
|
83 | 83 | |
84 | - return $this->update_settings( $settings ); |
|
84 | + return $this->update_settings($settings); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
88 | 88 | * @since 1.0.0 |
89 | 89 | */ |
90 | - public function delete_meta( $key ) { |
|
90 | + public function delete_meta($key) { |
|
91 | 91 | |
92 | 92 | $settings = $this->get_settings(); |
93 | 93 | |
94 | - if ( ! is_array( $settings ) || ! isset( $settings[ $key ] ) ) { |
|
94 | + if ( ! is_array($settings) || ! isset($settings[$key])) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | - unset( $settings[ $key ] ); |
|
98 | + unset($settings[$key]); |
|
99 | 99 | |
100 | - return $this->update_settings( $settings ); |
|
100 | + return $this->update_settings($settings); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | protected function get_settings() { |
118 | 118 | |
119 | 119 | return $this->store->get_option( |
120 | - $this->store->get_settings_option_name( $this->ID ) |
|
120 | + $this->store->get_settings_option_name($this->ID) |
|
121 | 121 | ); |
122 | 122 | } |
123 | 123 | |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return bool Whether the settings were updated successfully. |
132 | 132 | */ |
133 | - protected function update_settings( $settings ) { |
|
133 | + protected function update_settings($settings) { |
|
134 | 134 | |
135 | 135 | return $this->store->update_option( |
136 | - $this->store->get_settings_option_name( $this->ID ) |
|
136 | + $this->store->get_settings_option_name($this->ID) |
|
137 | 137 | , $settings |
138 | 138 | ); |
139 | 139 | } |
@@ -22,25 +22,25 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @since 1.0.0 |
24 | 24 | */ |
25 | - public function reaction_exists( $id ) { |
|
26 | - return (bool) $this->get_option( $this->get_settings_option_name( $id ) ); |
|
25 | + public function reaction_exists($id) { |
|
26 | + return (bool) $this->get_option($this->get_settings_option_name($id)); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @since 1.0.0 |
31 | 31 | */ |
32 | 32 | public function get_reactions() { |
33 | - return $this->create_reaction_objects( $this->get_reaction_index() ); |
|
33 | + return $this->create_reaction_objects($this->get_reaction_index()); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @since 1.0.0 |
38 | 38 | */ |
39 | - public function get_reactions_to_event( $event_slug ) { |
|
39 | + public function get_reactions_to_event($event_slug) { |
|
40 | 40 | |
41 | 41 | $index = $this->get_reaction_index(); |
42 | - $index = wp_list_filter( $index, array( 'event' => $event_slug ) ); |
|
43 | - return $this->create_reaction_objects( $index ); |
|
42 | + $index = wp_list_filter($index, array('event' => $event_slug)); |
|
43 | + return $this->create_reaction_objects($index); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | */ |
60 | 60 | protected function get_reaction_index() { |
61 | 61 | |
62 | - $index = $this->get_option( $this->get_reaction_index_option_name() ); |
|
62 | + $index = $this->get_option($this->get_reaction_index_option_name()); |
|
63 | 63 | |
64 | - if ( ! is_array( $index ) ) { |
|
64 | + if ( ! is_array($index)) { |
|
65 | 65 | $index = array(); |
66 | 66 | } |
67 | 67 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return bool Whether the index was updated successfully. |
79 | 79 | */ |
80 | - protected function update_reaction_index( $index ) { |
|
80 | + protected function update_reaction_index($index) { |
|
81 | 81 | |
82 | 82 | return $this->update_option( |
83 | 83 | $this->get_reaction_index_option_name() |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return string|false The event slug, or false if not found. |
98 | 98 | */ |
99 | - public function get_reaction_event_from_index( $id ) { |
|
99 | + public function get_reaction_event_from_index($id) { |
|
100 | 100 | |
101 | 101 | $index = $this->get_reaction_index(); |
102 | 102 | |
103 | - if ( ! isset( $index[ $id ]['event'] ) ) { |
|
103 | + if ( ! isset($index[$id]['event'])) { |
|
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | |
107 | - return $index[ $id ]['event']; |
|
107 | + return $index[$id]['event']; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -119,17 +119,17 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return bool Whether the event was updated successfully. |
121 | 121 | */ |
122 | - public function update_reaction_event_in_index( $id, $event ) { |
|
122 | + public function update_reaction_event_in_index($id, $event) { |
|
123 | 123 | |
124 | 124 | $index = $this->get_reaction_index(); |
125 | 125 | |
126 | - if ( ! isset( $index[ $id ] ) ) { |
|
126 | + if ( ! isset($index[$id])) { |
|
127 | 127 | return false; |
128 | 128 | } |
129 | 129 | |
130 | - $index[ $id ]['event'] = $event; |
|
130 | + $index[$id]['event'] = $event; |
|
131 | 131 | |
132 | - return $this->update_reaction_index( $index ); |
|
132 | + return $this->update_reaction_index($index); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -141,15 +141,15 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return WordPoints_Hook_Reaction_Options[] The objects for the reactions. |
143 | 143 | */ |
144 | - protected function create_reaction_objects( $index ) { |
|
144 | + protected function create_reaction_objects($index) { |
|
145 | 145 | |
146 | 146 | $reactions = array(); |
147 | 147 | |
148 | - foreach ( $index as $reaction ) { |
|
148 | + foreach ($index as $reaction) { |
|
149 | 149 | |
150 | - $object = $this->get_reaction( $reaction['id'] ); |
|
150 | + $object = $this->get_reaction($reaction['id']); |
|
151 | 151 | |
152 | - if ( ! $object ) { |
|
152 | + if ( ! $object) { |
|
153 | 153 | continue; |
154 | 154 | } |
155 | 155 | |
@@ -162,53 +162,53 @@ discard block |
||
162 | 162 | /** |
163 | 163 | * @since 1.0.0 |
164 | 164 | */ |
165 | - public function delete_reaction( $id ) { |
|
165 | + public function delete_reaction($id) { |
|
166 | 166 | |
167 | - if ( ! $this->reaction_exists( $id ) ) { |
|
167 | + if ( ! $this->reaction_exists($id)) { |
|
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | |
171 | - $result = $this->delete_option( $this->get_settings_option_name( $id ) ); |
|
171 | + $result = $this->delete_option($this->get_settings_option_name($id)); |
|
172 | 172 | |
173 | - if ( ! $result ) { |
|
173 | + if ( ! $result) { |
|
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | |
177 | 177 | $index = $this->get_reaction_index(); |
178 | 178 | |
179 | - unset( $index[ $id ] ); |
|
179 | + unset($index[$id]); |
|
180 | 180 | |
181 | - return $this->update_reaction_index( $index ); |
|
181 | + return $this->update_reaction_index($index); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | 185 | * @since 1.0.0 |
186 | 186 | */ |
187 | - protected function _create_reaction( $event_slug ) { |
|
187 | + protected function _create_reaction($event_slug) { |
|
188 | 188 | |
189 | 189 | $index = $this->get_reaction_index(); |
190 | 190 | |
191 | 191 | $id = 1; |
192 | 192 | |
193 | 193 | // TODO this is fragile when the newest reaction gets deleted. |
194 | - if ( ! empty( $index ) ) { |
|
195 | - $id = 1 + max( array_keys( $index ) ); |
|
194 | + if ( ! empty($index)) { |
|
195 | + $id = 1 + max(array_keys($index)); |
|
196 | 196 | } |
197 | 197 | |
198 | - $settings = array( 'event' => $event_slug ); |
|
198 | + $settings = array('event' => $event_slug); |
|
199 | 199 | |
200 | 200 | $result = $this->add_option( |
201 | - $this->get_settings_option_name( $id ) |
|
201 | + $this->get_settings_option_name($id) |
|
202 | 202 | , $settings |
203 | 203 | ); |
204 | 204 | |
205 | - if ( ! $result ) { |
|
205 | + if ( ! $result) { |
|
206 | 206 | return false; |
207 | 207 | } |
208 | 208 | |
209 | - $index[ $id ] = array( 'event' => $event_slug, 'id' => $id ); |
|
209 | + $index[$id] = array('event' => $event_slug, 'id' => $id); |
|
210 | 210 | |
211 | - if ( ! $this->update_reaction_index( $index ) ) { |
|
211 | + if ( ! $this->update_reaction_index($index)) { |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return mixed The option value, or false. |
228 | 228 | */ |
229 | - public function get_option( $name ) { |
|
230 | - return get_option( $name ); |
|
229 | + public function get_option($name) { |
|
230 | + return get_option($name); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return bool Whether the option was added successfully. |
242 | 242 | */ |
243 | - protected function add_option( $name, $value ) { |
|
244 | - return add_option( $name, $value ); |
|
243 | + protected function add_option($name, $value) { |
|
244 | + return add_option($name, $value); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return bool Whether the option was updated successfully. |
258 | 258 | */ |
259 | - public function update_option( $name, $value ) { |
|
260 | - return update_option( $name, $value ); |
|
259 | + public function update_option($name, $value) { |
|
260 | + return update_option($name, $value); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return bool Whether the option was deleted successfully. |
271 | 271 | */ |
272 | - protected function delete_option( $name ) { |
|
273 | - return delete_option( $name ); |
|
272 | + protected function delete_option($name) { |
|
273 | + return delete_option($name); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return string The name of the option where the settings are stored. |
284 | 284 | */ |
285 | - public function get_settings_option_name( $id ) { |
|
285 | + public function get_settings_option_name($id) { |
|
286 | 286 | return "wordpoints_{$this->reactor_slug}_hook_reaction-{$id}"; |
287 | 287 | } |
288 | 288 |
@@ -22,29 +22,29 @@ |
||
22 | 22 | /** |
23 | 23 | * @since 1.0.0 |
24 | 24 | */ |
25 | - public function get_option( $name ) { |
|
26 | - return get_site_option( $name ); |
|
25 | + public function get_option($name) { |
|
26 | + return get_site_option($name); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @since 1.0.0 |
31 | 31 | */ |
32 | - protected function add_option( $name, $value ) { |
|
33 | - return add_site_option( $name, $value ); |
|
32 | + protected function add_option($name, $value) { |
|
33 | + return add_site_option($name, $value); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @since 1.0.0 |
38 | 38 | */ |
39 | - public function update_option( $name, $value ) { |
|
40 | - return update_site_option( $name, $value ); |
|
39 | + public function update_option($name, $value) { |
|
40 | + return update_site_option($name, $value); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @since 1.0.0 |
45 | 45 | */ |
46 | - protected function delete_option( $name ) { |
|
47 | - return delete_site_option( $name ); |
|
46 | + protected function delete_option($name) { |
|
47 | + return delete_site_option($name); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param int $id The ID of a hook reaction. |
26 | 26 | * @param WordPoints_Hook_Reaction_StoreI $store The storage object. |
27 | 27 | */ |
28 | - public function __construct( $id, WordPoints_Hook_Reaction_StoreI $store ); |
|
28 | + public function __construct($id, WordPoints_Hook_Reaction_StoreI $store); |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Get a Globally Unique ID for this reaction. |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return bool Whether the event was updated successfully. |
69 | 69 | */ |
70 | - public function update_event_slug( $event_slug ); |
|
70 | + public function update_event_slug($event_slug); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Get the slug of the reactor this reaction is for. |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return mixed|false The meta value, or false if not found. |
102 | 102 | */ |
103 | - public function get_meta( $key ); |
|
103 | + public function get_meta($key); |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Add a piece of metadata for this reaction. |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return bool Whether the metadata was added successfully. |
116 | 116 | */ |
117 | - public function add_meta( $key, $value ); |
|
117 | + public function add_meta($key, $value); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Update a piece of metadata for this reaction. |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return bool Whether the metadata was updated successfully. |
128 | 128 | */ |
129 | - public function update_meta( $key, $value ); |
|
129 | + public function update_meta($key, $value); |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * Delete a piece of metadata for this reaction. |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return bool Whether the metadata was deleted successfully. |
139 | 139 | */ |
140 | - public function delete_meta( $key ); |
|
140 | + public function delete_meta($key); |
|
141 | 141 | |
142 | 142 | /** |
143 | 143 | * Get all of the metadata for this reaction. |