@@ -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. |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $this->firer = $firer; |
74 | 74 | $this->event_args = $event_args; |
75 | 75 | $this->reaction = $reaction; |
76 | - $this->hit_logger = new WordPoints_Hook_Hit_Logger( $this ); |
|
76 | + $this->hit_logger = new WordPoints_Hook_Hit_Logger($this); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function hit() { |
87 | 87 | |
88 | - if ( ! $this->hit_id ) { |
|
88 | + if ( ! $this->hit_id) { |
|
89 | 89 | |
90 | 90 | $this->hit_id = $this->hit_logger->log_hit(); |
91 | 91 | |
92 | - if ( ! $this->hit_id ) { |
|
92 | + if ( ! $this->hit_id) { |
|
93 | 93 | return false; |
94 | 94 | } |
95 | 95 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param WordPoints_Hook_Fire $fire The fire that might be logged as a hit. |
30 | 30 | */ |
31 | - public function __construct( WordPoints_Hook_Fire $fire ) { |
|
31 | + public function __construct(WordPoints_Hook_Fire $fire) { |
|
32 | 32 | |
33 | 33 | $this->fire = $fire; |
34 | 34 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | global $wpdb; |
46 | 46 | |
47 | - $signature = wordpoints_hooks_get_event_primary_arg_guid_json( $this->fire->event_args ); |
|
47 | + $signature = wordpoints_hooks_get_event_primary_arg_guid_json($this->fire->event_args); |
|
48 | 48 | |
49 | 49 | $inserted = $wpdb->insert( |
50 | 50 | $wpdb->wordpoints_hook_hits |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | 'event' => $this->fire->reaction->get_event_slug(), |
55 | 55 | 'reactor' => $this->fire->reaction->get_reactor_slug(), |
56 | 56 | 'reaction_store' => $this->fire->reaction->get_store_slug(), |
57 | - 'reaction_context_id' => wp_json_encode( $this->fire->reaction->get_context_id() ), |
|
57 | + 'reaction_context_id' => wp_json_encode($this->fire->reaction->get_context_id()), |
|
58 | 58 | 'reaction_id' => $this->fire->reaction->ID, |
59 | - 'date' => current_time( 'mysql' ), |
|
59 | + 'date' => current_time('mysql'), |
|
60 | 60 | ) |
61 | 61 | ); |
62 | 62 | |
63 | - if ( ! $inserted ) { |
|
63 | + if ( ! $inserted) { |
|
64 | 64 | return false; |
65 | 65 | } |
66 | 66 |
@@ -9,8 +9,8 @@ |
||
9 | 9 | |
10 | 10 | global $wpdb; |
11 | 11 | |
12 | -$wpdb->wordpoints_hook_hits = $wpdb->base_prefix . 'wordpoints_hook_hits'; |
|
13 | -$wpdb->wordpoints_hook_hitmeta = $wpdb->base_prefix . 'wordpoints_hook_hitmeta'; |
|
14 | -$wpdb->wordpoints_hook_periods = $wpdb->base_prefix . 'wordpoints_hook_periods'; |
|
12 | +$wpdb->wordpoints_hook_hits = $wpdb->base_prefix.'wordpoints_hook_hits'; |
|
13 | +$wpdb->wordpoints_hook_hitmeta = $wpdb->base_prefix.'wordpoints_hook_hitmeta'; |
|
14 | +$wpdb->wordpoints_hook_periods = $wpdb->base_prefix.'wordpoints_hook_periods'; |
|
15 | 15 | |
16 | 16 | // EOF |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | * @type array $meta_query See WP_Meta_Query. |
215 | 215 | * } |
216 | 216 | */ |
217 | - public function __construct( $args = array() ) { |
|
218 | - $this->args = array_merge( $this->defaults, $args ); |
|
217 | + public function __construct($args = array()) { |
|
218 | + $this->args = array_merge($this->defaults, $args); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return mixed|null The query arg's value, or null if it isn't set. |
229 | 229 | */ |
230 | - public function get_arg( $arg ) { |
|
230 | + public function get_arg($arg) { |
|
231 | 231 | |
232 | - if ( isset( $this->args[ $arg ] ) ) { |
|
233 | - return $this->args[ $arg ]; |
|
232 | + if (isset($this->args[$arg])) { |
|
233 | + return $this->args[$arg]; |
|
234 | 234 | } else { |
235 | 235 | return null; |
236 | 236 | } |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @param array $args A list of arguments to set and their values. |
248 | 248 | */ |
249 | - public function set_args( array $args ) { |
|
249 | + public function set_args(array $args) { |
|
250 | 250 | |
251 | - $this->args = array_merge( $this->args, $args ); |
|
251 | + $this->args = array_merge($this->args, $args); |
|
252 | 252 | |
253 | 253 | $this->is_query_ready = false; |
254 | 254 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | global $wpdb; |
271 | 271 | |
272 | - $count = (int) $wpdb->get_var( $this->get_sql( 'SELECT COUNT' ) ); // WPCS: unprepared SQL, cache OK |
|
272 | + $count = (int) $wpdb->get_var($this->get_sql('SELECT COUNT')); // WPCS: unprepared SQL, cache OK |
|
273 | 273 | |
274 | 274 | return $count; |
275 | 275 | } |
@@ -284,20 +284,20 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return mixed The results of the query, or false on failure. |
286 | 286 | */ |
287 | - public function get( $method = 'results' ) { |
|
287 | + public function get($method = 'results') { |
|
288 | 288 | |
289 | 289 | global $wpdb; |
290 | 290 | |
291 | - $methods = array( 'results', 'row', 'col', 'var' ); |
|
291 | + $methods = array('results', 'row', 'col', 'var'); |
|
292 | 292 | |
293 | - if ( ! in_array( $method, $methods ) ) { |
|
293 | + if ( ! in_array($method, $methods)) { |
|
294 | 294 | |
295 | - _doing_it_wrong( __METHOD__, esc_html( sprintf( 'WordPoints Debug Error: invalid get method %s, possible values are %s', $method, implode( ', ', $methods ) ) ), '1.0.0' ); |
|
295 | + _doing_it_wrong(__METHOD__, esc_html(sprintf('WordPoints Debug Error: invalid get method %s, possible values are %s', $method, implode(', ', $methods))), '1.0.0'); |
|
296 | 296 | |
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
300 | - $result = $wpdb->{"get_{$method}"}( $this->get_sql() ); |
|
300 | + $result = $wpdb->{"get_{$method}"}($this->get_sql()); |
|
301 | 301 | |
302 | 302 | return $result; |
303 | 303 | } |
@@ -317,11 +317,11 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return string The SQL for the query. |
319 | 319 | */ |
320 | - public function get_sql( $select_type = 'SELECT' ) { |
|
320 | + public function get_sql($select_type = 'SELECT') { |
|
321 | 321 | |
322 | 322 | $this->prepare_query(); |
323 | 323 | |
324 | - $select = ( 'SELECT COUNT' === $select_type ) |
|
324 | + $select = ('SELECT COUNT' === $select_type) |
|
325 | 325 | ? $this->select_count |
326 | 326 | : $this->select; |
327 | 327 | |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return string[] The valid columns. |
351 | 351 | */ |
352 | - public function date_query_valid_columns_filter( $valid_columns ) { |
|
352 | + public function date_query_valid_columns_filter($valid_columns) { |
|
353 | 353 | |
354 | 354 | $valid_columns = array_merge( |
355 | 355 | $valid_columns |
356 | 356 | , array_keys( |
357 | - wp_list_filter( $this->columns, array( 'is_date' => true ) ) |
|
357 | + wp_list_filter($this->columns, array('is_date' => true)) |
|
358 | 358 | ) |
359 | 359 | ); |
360 | 360 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | */ |
373 | 373 | protected function prepare_query() { |
374 | 374 | |
375 | - if ( ! $this->is_query_ready ) { |
|
375 | + if ( ! $this->is_query_ready) { |
|
376 | 376 | |
377 | 377 | $this->prepare_select(); |
378 | 378 | $this->prepare_where(); |
@@ -390,26 +390,26 @@ discard block |
||
390 | 390 | */ |
391 | 391 | protected function prepare_select() { |
392 | 392 | |
393 | - $all_fields = array_keys( $this->columns ); |
|
393 | + $all_fields = array_keys($this->columns); |
|
394 | 394 | $fields = array(); |
395 | 395 | |
396 | - if ( ! empty( $this->args['fields'] ) ) { |
|
396 | + if ( ! empty($this->args['fields'])) { |
|
397 | 397 | |
398 | 398 | $fields = (array) $this->args['fields']; |
399 | - $diff = array_diff( $fields, $all_fields ); |
|
400 | - $fields = array_intersect( $all_fields, $fields ); |
|
399 | + $diff = array_diff($fields, $all_fields); |
|
400 | + $fields = array_intersect($all_fields, $fields); |
|
401 | 401 | |
402 | - if ( ! empty( $diff ) ) { |
|
403 | - _doing_it_wrong( __METHOD__, esc_html( 'WordPoints Debug Error: invalid field(s) "' . implode( '", "', $diff ) . '" given' ), '1.0.0' ); |
|
402 | + if ( ! empty($diff)) { |
|
403 | + _doing_it_wrong(__METHOD__, esc_html('WordPoints Debug Error: invalid field(s) "'.implode('", "', $diff).'" given'), '1.0.0'); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | 407 | // Pull all fields by default. |
408 | - if ( empty( $fields ) ) { |
|
408 | + if (empty($fields)) { |
|
409 | 409 | $fields = $all_fields; |
410 | 410 | } |
411 | 411 | |
412 | - $fields = implode( ', ', array_map( 'wordpoints_escape_mysql_identifier', $fields ) ); |
|
412 | + $fields = implode(', ', array_map('wordpoints_escape_mysql_identifier', $fields)); |
|
413 | 413 | |
414 | 414 | $this->select = "SELECT {$fields}"; |
415 | 415 | } |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | * |
425 | 425 | * @return mixed The validated value, or false if invalid. |
426 | 426 | */ |
427 | - protected function validate_value( $value, $validators ) { |
|
427 | + protected function validate_value($value, $validators) { |
|
428 | 428 | |
429 | - foreach ( $validators as $validator ) { |
|
429 | + foreach ($validators as $validator) { |
|
430 | 430 | |
431 | - $value = call_user_func_array( $validator, array( &$value ) ); |
|
431 | + $value = call_user_func_array($validator, array(&$value)); |
|
432 | 432 | |
433 | - if ( false === $value ) { |
|
433 | + if (false === $value) { |
|
434 | 434 | break; |
435 | 435 | } |
436 | 436 | } |
@@ -448,14 +448,14 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return array The validated values, with any invalid ones removed. |
450 | 450 | */ |
451 | - protected function validate_values( $values, $validators ) { |
|
451 | + protected function validate_values($values, $validators) { |
|
452 | 452 | |
453 | - foreach ( $values as $index => $value ) { |
|
453 | + foreach ($values as $index => $value) { |
|
454 | 454 | |
455 | - $value = $this->validate_value( $value, $validators ); |
|
455 | + $value = $this->validate_value($value, $validators); |
|
456 | 456 | |
457 | - if ( false === $value ) { |
|
458 | - unset( $values[ $index ] ); |
|
457 | + if (false === $value) { |
|
458 | + unset($values[$index]); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @return int|false The validated value or false. |
476 | 476 | */ |
477 | - protected function validate_unsigned_column( $value ) { |
|
477 | + protected function validate_unsigned_column($value) { |
|
478 | 478 | |
479 | - if ( false !== wordpoints_int( $value ) && $value >= 0 ) { |
|
479 | + if (false !== wordpoints_int($value) && $value >= 0) { |
|
480 | 480 | return $value; |
481 | 481 | } |
482 | 482 | |
@@ -492,14 +492,14 @@ discard block |
||
492 | 492 | * |
493 | 493 | * @return callable[] The validation functions. |
494 | 494 | */ |
495 | - protected function get_validators_for_column( $data ) { |
|
495 | + protected function get_validators_for_column($data) { |
|
496 | 496 | |
497 | 497 | $validators = array(); |
498 | 498 | |
499 | 499 | // Default validators for integer columns. |
500 | - if ( '%d' === $data['format'] ) { |
|
501 | - if ( ! empty( $data['unsigned'] ) ) { |
|
502 | - $validators[] = array( $this, 'validate_unsigned_column' ); |
|
500 | + if ('%d' === $data['format']) { |
|
501 | + if ( ! empty($data['unsigned'])) { |
|
502 | + $validators[] = array($this, 'validate_unsigned_column'); |
|
503 | 503 | } else { |
504 | 504 | $validators[] = 'wordpoints_int'; |
505 | 505 | } |
@@ -516,15 +516,15 @@ discard block |
||
516 | 516 | * @param string $column The column name. |
517 | 517 | * @param array $data The column data. |
518 | 518 | */ |
519 | - protected function prepare_column_where( $column, $data ) { |
|
519 | + protected function prepare_column_where($column, $data) { |
|
520 | 520 | |
521 | 521 | // If a single value has been supplied for the column, it takes precedence. |
522 | - if ( isset( $this->args[ $column ] ) ) { |
|
523 | - $this->prepare_column( $column, $data ); |
|
524 | - } elseif ( isset( $this->args[ "{$column}__in" ] ) ) { |
|
525 | - $this->prepare_column__in( $column, $data ); |
|
526 | - } elseif ( isset( $this->args[ "{$column}__not_in" ] ) ) { |
|
527 | - $this->prepare_column__in( $column, $data, 'NOT IN' ); |
|
522 | + if (isset($this->args[$column])) { |
|
523 | + $this->prepare_column($column, $data); |
|
524 | + } elseif (isset($this->args["{$column}__in"])) { |
|
525 | + $this->prepare_column__in($column, $data); |
|
526 | + } elseif (isset($this->args["{$column}__not_in"])) { |
|
527 | + $this->prepare_column__in($column, $data, 'NOT IN'); |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
@@ -536,29 +536,29 @@ discard block |
||
536 | 536 | * @param string $column The name of the column |
537 | 537 | * @param array $data The column data. |
538 | 538 | */ |
539 | - protected function prepare_column( $column, $data ) { |
|
539 | + protected function prepare_column($column, $data) { |
|
540 | 540 | |
541 | 541 | global $wpdb; |
542 | 542 | |
543 | 543 | if ( |
544 | - isset( $data['values'] ) |
|
545 | - && ! in_array( $this->args[ $column ], $data['values'], true ) |
|
544 | + isset($data['values']) |
|
545 | + && ! in_array($this->args[$column], $data['values'], true) |
|
546 | 546 | ) { |
547 | 547 | return; |
548 | 548 | } |
549 | 549 | |
550 | 550 | $value = $this->validate_value( |
551 | - $this->args[ $column ] |
|
552 | - , $this->get_validators_for_column( $data ) |
|
551 | + $this->args[$column] |
|
552 | + , $this->get_validators_for_column($data) |
|
553 | 553 | ); |
554 | 554 | |
555 | - if ( false === $value ) { |
|
555 | + if (false === $value) { |
|
556 | 556 | return; |
557 | 557 | } |
558 | 558 | |
559 | - $compare = $this->get_comparator_for_column( $column, $data ); |
|
559 | + $compare = $this->get_comparator_for_column($column, $data); |
|
560 | 560 | |
561 | - $column = wordpoints_escape_mysql_identifier( $column ); |
|
561 | + $column = wordpoints_escape_mysql_identifier($column); |
|
562 | 562 | |
563 | 563 | $this->wheres[] = $wpdb->prepare( // WPCS: unprepared SQL OK. |
564 | 564 | "{$column} {$compare} {$data['format']}" |
@@ -576,23 +576,23 @@ discard block |
||
576 | 576 | * |
577 | 577 | * @return string The comparator for the column. |
578 | 578 | */ |
579 | - protected function get_comparator_for_column( $column, $data ) { |
|
579 | + protected function get_comparator_for_column($column, $data) { |
|
580 | 580 | |
581 | - $comparisons = array( '=', '<', '>', '<>', '!=', '<=', '>=' ); |
|
581 | + $comparisons = array('=', '<', '>', '<>', '!=', '<=', '>='); |
|
582 | 582 | |
583 | 583 | // MySQL doesn't support LIKE and NOT LIKE for int columns. |
584 | 584 | // See http://stackoverflow.com/q/8422455/1924128 |
585 | - if ( '%s' === $data['format'] ) { |
|
586 | - $comparisons = array_merge( $comparisons, array( 'LIKE', 'NOT LIKE' ) ); |
|
585 | + if ('%s' === $data['format']) { |
|
586 | + $comparisons = array_merge($comparisons, array('LIKE', 'NOT LIKE')); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | $comparator = '='; |
590 | 590 | |
591 | 591 | if ( |
592 | - isset( $this->args[ "{$column}__compare" ] ) |
|
593 | - && in_array( $this->args[ "{$column}__compare" ], $comparisons, true ) |
|
592 | + isset($this->args["{$column}__compare"]) |
|
593 | + && in_array($this->args["{$column}__compare"], $comparisons, true) |
|
594 | 594 | ) { |
595 | - $comparator = $this->args[ "{$column}__compare" ]; |
|
595 | + $comparator = $this->args["{$column}__compare"]; |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | return $comparator; |
@@ -607,36 +607,36 @@ discard block |
||
607 | 607 | * @param array $data The column data. |
608 | 608 | * @param string $type The type of IN clause, IN or NOT IN. |
609 | 609 | */ |
610 | - protected function prepare_column__in( $column, $data, $type = 'IN' ) { |
|
610 | + protected function prepare_column__in($column, $data, $type = 'IN') { |
|
611 | 611 | |
612 | - $key = "{$column}__" . strtolower( str_replace( ' ', '_', $type ) ); |
|
612 | + $key = "{$column}__".strtolower(str_replace(' ', '_', $type)); |
|
613 | 613 | |
614 | - if ( empty( $this->args[ $key ] ) || ! is_array( $this->args[ $key ] ) ) { |
|
614 | + if (empty($this->args[$key]) || ! is_array($this->args[$key])) { |
|
615 | 615 | return; |
616 | 616 | } |
617 | 617 | |
618 | - $values = $this->args[ $key ]; |
|
618 | + $values = $this->args[$key]; |
|
619 | 619 | |
620 | - if ( isset( $data['values'] ) ) { |
|
621 | - $values = array_intersect( $values, $data['values'] ); |
|
620 | + if (isset($data['values'])) { |
|
621 | + $values = array_intersect($values, $data['values']); |
|
622 | 622 | } else { |
623 | 623 | $values = $this->validate_values( |
624 | 624 | $values |
625 | - , $this->get_validators_for_column( $data ) |
|
625 | + , $this->get_validators_for_column($data) |
|
626 | 626 | ); |
627 | 627 | } |
628 | 628 | |
629 | - if ( empty( $values ) ) { |
|
629 | + if (empty($values)) { |
|
630 | 630 | return; |
631 | 631 | } |
632 | 632 | |
633 | - $in = wordpoints_prepare__in( $values, $data['format'] ); |
|
633 | + $in = wordpoints_prepare__in($values, $data['format']); |
|
634 | 634 | |
635 | - if ( false === $in ) { |
|
635 | + if (false === $in) { |
|
636 | 636 | return; |
637 | 637 | } |
638 | 638 | |
639 | - $column = wordpoints_escape_mysql_identifier( $column ); |
|
639 | + $column = wordpoints_escape_mysql_identifier($column); |
|
640 | 640 | |
641 | 641 | $this->wheres[] = "{$column} {$type} ({$in})"; |
642 | 642 | } |
@@ -650,19 +650,19 @@ discard block |
||
650 | 650 | |
651 | 651 | $this->wheres = array(); |
652 | 652 | |
653 | - foreach ( $this->columns as $column => $data ) { |
|
653 | + foreach ($this->columns as $column => $data) { |
|
654 | 654 | |
655 | - if ( ! empty( $data['is_date'] ) ) { |
|
656 | - $this->prepare_date_where( $column ); |
|
655 | + if ( ! empty($data['is_date'])) { |
|
656 | + $this->prepare_date_where($column); |
|
657 | 657 | } else { |
658 | - $this->prepare_column_where( $column, $data ); |
|
658 | + $this->prepare_column_where($column, $data); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
662 | 662 | $this->prepare_meta_where(); |
663 | 663 | |
664 | - if ( ! empty( $this->wheres ) ) { |
|
665 | - $this->where = 'WHERE ' . implode( ' AND ', $this->wheres ) . "\n"; |
|
664 | + if ( ! empty($this->wheres)) { |
|
665 | + $this->where = 'WHERE '.implode(' AND ', $this->wheres)."\n"; |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | |
@@ -675,32 +675,32 @@ discard block |
||
675 | 675 | |
676 | 676 | // MySQL doesn't allow for the offset without a limit, so if no limit is set |
677 | 677 | // we can ignore the start arg. See http://stackoverflow.com/a/271650/1924128 |
678 | - if ( ! isset( $this->args['limit'] ) ) { |
|
678 | + if ( ! isset($this->args['limit'])) { |
|
679 | 679 | return; |
680 | 680 | } |
681 | 681 | |
682 | - foreach ( array( 'limit', 'start' ) as $key ) { |
|
682 | + foreach (array('limit', 'start') as $key) { |
|
683 | 683 | |
684 | 684 | // Save a backup of the arg value since wordpoints_int() is by reference. |
685 | - $arg = $this->args[ $key ]; |
|
685 | + $arg = $this->args[$key]; |
|
686 | 686 | |
687 | - if ( false === wordpoints_int( $this->args[ $key ] ) ) { |
|
687 | + if (false === wordpoints_int($this->args[$key])) { |
|
688 | 688 | |
689 | 689 | _doing_it_wrong( |
690 | 690 | __METHOD__ |
691 | 691 | , sprintf( |
692 | 692 | "WordPoints Debug Error: '%s' must be a positive integer, %s given" |
693 | - , esc_html( $key ) |
|
694 | - , esc_html( strval( $arg ) ? $arg : gettype( $arg ) ) |
|
693 | + , esc_html($key) |
|
694 | + , esc_html(strval($arg) ? $arg : gettype($arg)) |
|
695 | 695 | ) |
696 | 696 | , '1.0.0' |
697 | 697 | ); |
698 | 698 | |
699 | - $this->args[ $key ] = 0; |
|
699 | + $this->args[$key] = 0; |
|
700 | 700 | } |
701 | 701 | } |
702 | 702 | |
703 | - if ( $this->args['limit'] > 0 && $this->args['start'] >= 0 ) { |
|
703 | + if ($this->args['limit'] > 0 && $this->args['start'] >= 0) { |
|
704 | 704 | $this->limit = "LIMIT {$this->args['start']}, {$this->args['limit']}"; |
705 | 705 | } |
706 | 706 | } |
@@ -712,20 +712,20 @@ discard block |
||
712 | 712 | */ |
713 | 713 | protected function prepare_order_by() { |
714 | 714 | |
715 | - if ( empty( $this->args['order_by'] ) ) { |
|
715 | + if (empty($this->args['order_by'])) { |
|
716 | 716 | return; |
717 | 717 | } |
718 | 718 | |
719 | 719 | $order = $this->args['order']; |
720 | 720 | $order_by = $this->args['order_by']; |
721 | 721 | |
722 | - if ( ! in_array( $order, array( 'DESC', 'ASC' ) ) ) { |
|
722 | + if ( ! in_array($order, array('DESC', 'ASC'))) { |
|
723 | 723 | |
724 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: invalid 'order' \"{$order}\", possible values are DESC and ASC" ), '1.0.0' ); |
|
724 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: invalid 'order' \"{$order}\", possible values are DESC and ASC"), '1.0.0'); |
|
725 | 725 | $order = 'DESC'; |
726 | 726 | } |
727 | 727 | |
728 | - if ( 'meta_value' === $order_by ) { |
|
728 | + if ('meta_value' === $order_by) { |
|
729 | 729 | |
730 | 730 | global $wpdb; |
731 | 731 | |
@@ -733,9 +733,9 @@ discard block |
||
733 | 733 | $wpdb->{"{$this->meta_type}meta"} |
734 | 734 | ); |
735 | 735 | |
736 | - if ( isset( $this->args['meta_type'] ) ) { |
|
736 | + if (isset($this->args['meta_type'])) { |
|
737 | 737 | |
738 | - $meta_type = $this->meta_query->get_cast_for_type( $this->args['meta_type'] ); |
|
738 | + $meta_type = $this->meta_query->get_cast_for_type($this->args['meta_type']); |
|
739 | 739 | $order_by = "CAST({$meta_table_name}.meta_value AS {$meta_type})"; |
740 | 740 | |
741 | 741 | } else { |
@@ -743,13 +743,13 @@ discard block |
||
743 | 743 | $order_by = "{$meta_table_name}.meta_value"; |
744 | 744 | } |
745 | 745 | |
746 | - } elseif ( isset( $this->columns[ $order_by ] ) ) { |
|
746 | + } elseif (isset($this->columns[$order_by])) { |
|
747 | 747 | |
748 | - $order_by = wordpoints_escape_mysql_identifier( $order_by ); |
|
748 | + $order_by = wordpoints_escape_mysql_identifier($order_by); |
|
749 | 749 | |
750 | 750 | } else { |
751 | 751 | |
752 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: invalid 'order_by' \"{$order_by}\", possible values are " . implode( ', ', array_keys( $this->columns ) ) ), '1.0.0' ); |
|
752 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: invalid 'order_by' \"{$order_by}\", possible values are ".implode(', ', array_keys($this->columns))), '1.0.0'); |
|
753 | 753 | return; |
754 | 754 | } |
755 | 755 | |
@@ -763,25 +763,25 @@ discard block |
||
763 | 763 | * |
764 | 764 | * @param string $column The name of the column. |
765 | 765 | */ |
766 | - protected function prepare_date_where( $column ) { |
|
766 | + protected function prepare_date_where($column) { |
|
767 | 767 | |
768 | 768 | if ( |
769 | - empty( $this->args[ "{$column}_query" ] ) |
|
770 | - || ! is_array( $this->args[ "{$column}_query" ] ) |
|
769 | + empty($this->args["{$column}_query"]) |
|
770 | + || ! is_array($this->args["{$column}_query"]) |
|
771 | 771 | ) { |
772 | 772 | return; |
773 | 773 | } |
774 | 774 | |
775 | - add_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
|
775 | + add_filter('date_query_valid_columns', array($this, 'date_query_valid_columns_filter')); |
|
776 | 776 | |
777 | - $date_query = new WP_Date_Query( $this->args[ "{$column}_query" ], $column ); |
|
777 | + $date_query = new WP_Date_Query($this->args["{$column}_query"], $column); |
|
778 | 778 | $date_query = $date_query->get_sql(); |
779 | 779 | |
780 | - if ( ! empty( $date_query ) ) { |
|
781 | - $this->wheres[] = ltrim( $date_query, ' AND' ); |
|
780 | + if ( ! empty($date_query)) { |
|
781 | + $this->wheres[] = ltrim($date_query, ' AND'); |
|
782 | 782 | } |
783 | 783 | |
784 | - remove_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
|
784 | + remove_filter('date_query_valid_columns', array($this, 'date_query_valid_columns_filter')); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | /** |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | */ |
792 | 792 | protected function prepare_meta_where() { |
793 | 793 | |
794 | - if ( empty( $this->meta_type ) ) { |
|
794 | + if (empty($this->meta_type)) { |
|
795 | 795 | return; |
796 | 796 | } |
797 | 797 | |
@@ -806,12 +806,12 @@ discard block |
||
806 | 806 | ) |
807 | 807 | ); |
808 | 808 | |
809 | - if ( empty( $meta_args ) ) { |
|
809 | + if (empty($meta_args)) { |
|
810 | 810 | return; |
811 | 811 | } |
812 | 812 | |
813 | 813 | $this->meta_query = new WP_Meta_Query(); |
814 | - $this->meta_query->parse_query_vars( $meta_args ); |
|
814 | + $this->meta_query->parse_query_vars($meta_args); |
|
815 | 815 | |
816 | 816 | $meta_query = $this->meta_query->get_sql( |
817 | 817 | $this->meta_type |
@@ -820,11 +820,11 @@ discard block |
||
820 | 820 | , $this |
821 | 821 | ); |
822 | 822 | |
823 | - if ( ! empty( $meta_query['where'] ) ) { |
|
824 | - $this->wheres[] = ltrim( $meta_query['where'], ' AND' ); |
|
823 | + if ( ! empty($meta_query['where'])) { |
|
824 | + $this->wheres[] = ltrim($meta_query['where'], ' AND'); |
|
825 | 825 | } |
826 | 826 | |
827 | - $this->meta_join = $meta_query['join'] . "\n"; |
|
827 | + $this->meta_join = $meta_query['join']."\n"; |
|
828 | 828 | } |
829 | 829 | } |
830 | 830 |