@@ -26,7 +26,7 @@ |
||
26 | 26 | /** |
27 | 27 | * @since 1.0.0 |
28 | 28 | */ |
29 | - public function __construct( $slug ) { |
|
29 | + public function __construct($slug) { |
|
30 | 30 | |
31 | 31 | $this->slug = $slug; |
32 | 32 | } |
@@ -21,11 +21,11 @@ |
||
21 | 21 | */ |
22 | 22 | public function get_current_id() { |
23 | 23 | |
24 | - if ( ! is_multisite() ) { |
|
24 | + if ( ! is_multisite()) { |
|
25 | 25 | return 1; |
26 | 26 | } |
27 | 27 | |
28 | - if ( wordpoints_is_network_context() ) { |
|
28 | + if (wordpoints_is_network_context()) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return object[] The child objects, indexed by slug. |
48 | 48 | */ |
49 | - public function get_children( $parent_slug ); |
|
49 | + public function get_children($parent_slug); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Get the slugs of all of the classes that are children of a certain parent. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return string[] The child slugs. |
59 | 59 | */ |
60 | - public function get_children_slugs( $parent_slug ); |
|
60 | + public function get_children_slugs($parent_slug); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Get an object by its slug. |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return object|false The object or false on failure. |
71 | 71 | */ |
72 | - public function get( $parent_slug, $slug ); |
|
72 | + public function get($parent_slug, $slug); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Register a type of object. |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return bool Whether the class was registered successfully. |
85 | 85 | */ |
86 | - public function register( $parent_slug, $slug, $class, array $args = array() ); |
|
86 | + public function register($parent_slug, $slug, $class, array $args = array()); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Deregister a type of object. |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $parent_slug The group slug. |
94 | 94 | * @param string $slug The slug of the class to deregister. |
95 | 95 | */ |
96 | - public function deregister( $parent_slug, $slug ); |
|
96 | + public function deregister($parent_slug, $slug); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Deregister all children of a particular parent. |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @param string $parent_slug The group slug. |
104 | 104 | */ |
105 | - public function deregister_children( $parent_slug ); |
|
105 | + public function deregister_children($parent_slug); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Check if a type of object is registered by its slug. |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return bool Whether the class is registered. |
119 | 119 | */ |
120 | - public function is_registered( $parent_slug, $slug = null ); |
|
120 | + public function is_registered($parent_slug, $slug = null); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // EOF |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @since 1.0.0 |
35 | 35 | */ |
36 | - public function get_all( array $args = array() ) { |
|
36 | + public function get_all(array $args = array()) { |
|
37 | 37 | |
38 | 38 | $items = array(); |
39 | 39 | |
40 | - foreach ( $this->classes as $parent_slug => $classes ) { |
|
41 | - $items[ $parent_slug ] = WordPoints_Class_Registry::construct_with_args( |
|
40 | + foreach ($this->classes as $parent_slug => $classes) { |
|
41 | + $items[$parent_slug] = WordPoints_Class_Registry::construct_with_args( |
|
42 | 42 | $classes |
43 | 43 | , $args |
44 | 44 | ); |
@@ -51,20 +51,20 @@ discard block |
||
51 | 51 | * @since 1.0.0 |
52 | 52 | */ |
53 | 53 | public function get_all_slugs() { |
54 | - return array_map( 'array_keys', $this->classes ); |
|
54 | + return array_map('array_keys', $this->classes); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @since 1.0.0 |
59 | 59 | */ |
60 | - public function get_children( $parent_slug, array $args = array() ) { |
|
60 | + public function get_children($parent_slug, array $args = array()) { |
|
61 | 61 | |
62 | 62 | $items = array(); |
63 | 63 | |
64 | - if ( isset( $this->classes[ $parent_slug ] ) ) { |
|
64 | + if (isset($this->classes[$parent_slug])) { |
|
65 | 65 | |
66 | 66 | $items = WordPoints_Class_Registry::construct_with_args( |
67 | - $this->classes[ $parent_slug ] |
|
67 | + $this->classes[$parent_slug] |
|
68 | 68 | , $args |
69 | 69 | ); |
70 | 70 | } |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | /** |
76 | 76 | * @since 1.0.0 |
77 | 77 | */ |
78 | - public function get_children_slugs( $parent_slug ) { |
|
78 | + public function get_children_slugs($parent_slug) { |
|
79 | 79 | |
80 | 80 | $slugs = array(); |
81 | 81 | |
82 | - if ( isset( $this->classes[ $parent_slug ] ) ) { |
|
83 | - $slugs = array_keys( $this->classes[ $parent_slug ] ); |
|
82 | + if (isset($this->classes[$parent_slug])) { |
|
83 | + $slugs = array_keys($this->classes[$parent_slug]); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $slugs; |
@@ -89,29 +89,29 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * @since 1.0.0 |
91 | 91 | */ |
92 | - public function get( $parent_slug, $slug, array $args = array() ) { |
|
92 | + public function get($parent_slug, $slug, array $args = array()) { |
|
93 | 93 | |
94 | - if ( ! isset( $this->classes[ $parent_slug ][ $slug ] ) ) { |
|
94 | + if ( ! isset($this->classes[$parent_slug][$slug])) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | - $class = $this->classes[ $parent_slug ][ $slug ]; |
|
98 | + $class = $this->classes[$parent_slug][$slug]; |
|
99 | 99 | |
100 | - if ( empty( $args ) ) { |
|
101 | - return new $class( $slug ); |
|
100 | + if (empty($args)) { |
|
101 | + return new $class($slug); |
|
102 | 102 | } else { |
103 | - array_unshift( $args, $slug ); |
|
103 | + array_unshift($args, $slug); |
|
104 | 104 | |
105 | - return wordpoints_construct_class_with_args( $class, $args ); |
|
105 | + return wordpoints_construct_class_with_args($class, $args); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @since 1.0.0 |
111 | 111 | */ |
112 | - public function register( $parent_slug, $slug, $class, array $args = array() ) { |
|
112 | + public function register($parent_slug, $slug, $class, array $args = array()) { |
|
113 | 113 | |
114 | - $this->classes[ $parent_slug ][ $slug ] = $class; |
|
114 | + $this->classes[$parent_slug][$slug] = $class; |
|
115 | 115 | |
116 | 116 | return true; |
117 | 117 | } |
@@ -119,26 +119,26 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @since 1.0.0 |
121 | 121 | */ |
122 | - public function deregister( $parent_slug, $slug ) { |
|
123 | - unset( $this->classes[ $parent_slug ][ $slug ] ); |
|
122 | + public function deregister($parent_slug, $slug) { |
|
123 | + unset($this->classes[$parent_slug][$slug]); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | 127 | * @since 1.0.0 |
128 | 128 | */ |
129 | - public function deregister_children( $parent_slug ) { |
|
130 | - unset( $this->classes[ $parent_slug ] ); |
|
129 | + public function deregister_children($parent_slug) { |
|
130 | + unset($this->classes[$parent_slug]); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
134 | 134 | * @since 1.0.0 |
135 | 135 | */ |
136 | - public function is_registered( $parent_slug, $slug = null ) { |
|
136 | + public function is_registered($parent_slug, $slug = null) { |
|
137 | 137 | |
138 | - if ( isset( $slug ) ) { |
|
139 | - return isset( $this->classes[ $parent_slug ][ $slug ] ); |
|
138 | + if (isset($slug)) { |
|
139 | + return isset($this->classes[$parent_slug][$slug]); |
|
140 | 140 | } else { |
141 | - return isset( $this->classes[ $parent_slug ] ); |
|
141 | + return isset($this->classes[$parent_slug]); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
@@ -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 | } |
@@ -265,7 +265,7 @@ |
||
265 | 265 | * |
266 | 266 | * @param string $child_slug The slug of the child. |
267 | 267 | * |
268 | - * @return WordPoints_Entityish|false The child's object, or false if not found. |
|
268 | + * @return WordPoints_EntityishI The child's object, or false if not found. |
|
269 | 269 | */ |
270 | 270 | public function get_child( $child_slug ) { |
271 | 271 |
@@ -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 |