@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | WordPoints_Hook_Event_Args $event_args |
66 | 66 | ) { |
67 | 67 | |
68 | - if ( ! isset( $settings[ $this->slug ] ) ) { |
|
68 | + if ( ! isset($settings[$this->slug])) { |
|
69 | 69 | return $settings; |
70 | 70 | } |
71 | 71 | |
72 | - if ( ! is_array( $settings[ $this->slug ] ) ) { |
|
72 | + if ( ! is_array($settings[$this->slug])) { |
|
73 | 73 | |
74 | 74 | $validator->add_error( |
75 | - __( 'Invalid settings format.', 'wordpoints' ) |
|
75 | + __('Invalid settings format.', 'wordpoints') |
|
76 | 76 | , $this->slug |
77 | 77 | ); |
78 | 78 | |
@@ -82,18 +82,18 @@ discard block |
||
82 | 82 | $this->validator = $validator; |
83 | 83 | $this->event_args = $event_args; |
84 | 84 | |
85 | - $this->validator->push_field( $this->slug ); |
|
85 | + $this->validator->push_field($this->slug); |
|
86 | 86 | |
87 | - foreach ( $settings[ $this->slug ] as $firer => $firer_settings ) { |
|
87 | + foreach ($settings[$this->slug] as $firer => $firer_settings) { |
|
88 | 88 | |
89 | - if ( ! wordpoints_hooks()->firers->is_registered( $firer ) ) { |
|
90 | - $this->validator->add_error( __( 'Unknown hook firer.', 'wordpoints' ), $firer ); |
|
89 | + if ( ! wordpoints_hooks()->firers->is_registered($firer)) { |
|
90 | + $this->validator->add_error(__('Unknown hook firer.', 'wordpoints'), $firer); |
|
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | |
94 | - $this->validator->push_field( $firer ); |
|
94 | + $this->validator->push_field($firer); |
|
95 | 95 | |
96 | - $settings[ $this->slug ][ $firer ] = $this->validate_firer_settings( |
|
96 | + $settings[$this->slug][$firer] = $this->validate_firer_settings( |
|
97 | 97 | $firer_settings |
98 | 98 | ); |
99 | 99 | |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @since 1.0.0 |
110 | 110 | */ |
111 | - public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) { |
|
111 | + public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) { |
|
112 | 112 | |
113 | - if ( isset( $settings[ $this->slug ] ) ) { |
|
114 | - $reaction->update_meta( $this->slug, $settings[ $this->slug ] ); |
|
113 | + if (isset($settings[$this->slug])) { |
|
114 | + $reaction->update_meta($this->slug, $settings[$this->slug]); |
|
115 | 115 | } else { |
116 | - $reaction->delete_meta( $this->slug ); |
|
116 | + $reaction->delete_meta($this->slug); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return mixed The validated settings. |
128 | 128 | */ |
129 | - protected function validate_firer_settings( $settings ) {} |
|
129 | + protected function validate_firer_settings($settings) {} |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * Get the extension settings from the fire object. |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return mixed The settings for the extension, or false if none. |
143 | 143 | */ |
144 | - protected function get_settings_from_fire( WordPoints_Hook_Fire $fire ) { |
|
144 | + protected function get_settings_from_fire(WordPoints_Hook_Fire $fire) { |
|
145 | 145 | |
146 | 146 | $firer_slug = $fire->firer->get_slug(); |
147 | - $settings = $fire->reaction->get_meta( $this->slug ); |
|
147 | + $settings = $fire->reaction->get_meta($this->slug); |
|
148 | 148 | |
149 | - if ( ! is_array( $settings ) ) { |
|
149 | + if ( ! is_array($settings)) { |
|
150 | 150 | return $settings; |
151 | 151 | } |
152 | 152 | |
153 | - if ( isset( $settings[ $firer_slug ] ) ) { |
|
154 | - return $settings[ $firer_slug ]; |
|
153 | + if (isset($settings[$firer_slug])) { |
|
154 | + return $settings[$firer_slug]; |
|
155 | 155 | } else { |
156 | 156 | return false; |
157 | 157 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return bool Whether the target should be hit by this hook firing. |
168 | 168 | */ |
169 | - abstract public function should_hit( WordPoints_Hook_Fire $fire ); |
|
169 | + abstract public function should_hit(WordPoints_Hook_Fire $fire); |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * After a reaction has hit the target. |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @param WordPoints_Hook_Fire $fire The hook fire object. |
177 | 177 | */ |
178 | - public function after_hit( WordPoints_Hook_Fire $fire ) {} |
|
178 | + public function after_hit(WordPoints_Hook_Fire $fire) {} |
|
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Get the data the scripts need for the UI. |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | |
43 | 43 | $conditions_data = array(); |
44 | 44 | |
45 | - foreach ( $this->conditions->get_all() as $data_type => $conditions ) { |
|
46 | - foreach ( $conditions as $slug => $condition ) { |
|
45 | + foreach ($this->conditions->get_all() as $data_type => $conditions) { |
|
46 | + foreach ($conditions as $slug => $condition) { |
|
47 | 47 | |
48 | - if ( ! ( $condition instanceof WordPoints_Hook_Condition ) ) { |
|
48 | + if ( ! ($condition instanceof WordPoints_Hook_Condition)) { |
|
49 | 49 | continue; |
50 | 50 | } |
51 | 51 | |
52 | - $conditions_data[ $data_type ][ $slug ] = array( |
|
52 | + $conditions_data[$data_type][$slug] = array( |
|
53 | 53 | 'slug' => $slug, |
54 | 54 | 'data_type' => $data_type, |
55 | 55 | 'title' => $condition->get_title(), |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - return array( 'conditions' => $conditions_data ); |
|
61 | + return array('conditions' => $conditions_data); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @since 1.0.0 |
66 | 66 | */ |
67 | - protected function validate_firer_settings( $settings ) { |
|
68 | - return $this->validate_conditions( $settings ); |
|
67 | + protected function validate_firer_settings($settings) { |
|
68 | + return $this->validate_conditions($settings); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -77,31 +77,31 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return array The validated settings. |
79 | 79 | */ |
80 | - protected function validate_conditions( $args ) { |
|
80 | + protected function validate_conditions($args) { |
|
81 | 81 | |
82 | - if ( ! is_array( $args ) ) { |
|
82 | + if ( ! is_array($args)) { |
|
83 | 83 | |
84 | 84 | $this->validator->add_error( |
85 | - __( 'Conditions do not match expected format.', 'wordpoints' ) |
|
85 | + __('Conditions do not match expected format.', 'wordpoints') |
|
86 | 86 | ); |
87 | 87 | |
88 | 88 | return array(); |
89 | 89 | } |
90 | 90 | |
91 | - foreach ( $args as $arg_slug => $sub_args ) { |
|
91 | + foreach ($args as $arg_slug => $sub_args) { |
|
92 | 92 | |
93 | - if ( '_conditions' === $arg_slug ) { |
|
93 | + if ('_conditions' === $arg_slug) { |
|
94 | 94 | |
95 | - $this->validator->push_field( $arg_slug ); |
|
95 | + $this->validator->push_field($arg_slug); |
|
96 | 96 | |
97 | - foreach ( $sub_args as $index => $settings ) { |
|
97 | + foreach ($sub_args as $index => $settings) { |
|
98 | 98 | |
99 | - $this->validator->push_field( $index ); |
|
99 | + $this->validator->push_field($index); |
|
100 | 100 | |
101 | - $condition = $this->validate_condition( $settings ); |
|
101 | + $condition = $this->validate_condition($settings); |
|
102 | 102 | |
103 | - if ( $condition ) { |
|
104 | - $sub_args[ $index ] = $condition; |
|
103 | + if ($condition) { |
|
104 | + $sub_args[$index] = $condition; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $this->validator->pop_field(); |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | |
112 | 112 | } else { |
113 | 113 | |
114 | - if ( ! $this->event_args->descend( $arg_slug ) ) { |
|
114 | + if ( ! $this->event_args->descend($arg_slug)) { |
|
115 | 115 | continue; |
116 | 116 | } |
117 | 117 | |
118 | - $sub_args = $this->validate_firer_settings( $sub_args ); |
|
118 | + $sub_args = $this->validate_firer_settings($sub_args); |
|
119 | 119 | |
120 | - $args[ $arg_slug ] = $sub_args; |
|
120 | + $args[$arg_slug] = $sub_args; |
|
121 | 121 | |
122 | 122 | $this->event_args->ascend(); |
123 | 123 | } |
124 | 124 | |
125 | - $args[ $arg_slug ] = $sub_args; |
|
125 | + $args[$arg_slug] = $sub_args; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | return $args; |
@@ -138,32 +138,32 @@ discard block |
||
138 | 138 | * @return array|false The validated conditions settings, or false if unable to |
139 | 139 | * validate. |
140 | 140 | */ |
141 | - protected function validate_condition( $settings ) { |
|
141 | + protected function validate_condition($settings) { |
|
142 | 142 | |
143 | - if ( ! isset( $settings['type'] ) ) { |
|
144 | - $this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) ); |
|
143 | + if ( ! isset($settings['type'])) { |
|
144 | + $this->validator->add_error(__('Condition type is missing.', 'wordpoints')); |
|
145 | 145 | return false; |
146 | 146 | } |
147 | 147 | |
148 | 148 | $arg = $this->event_args->get_current(); |
149 | 149 | |
150 | - $data_type = $this->get_data_type( $arg ); |
|
150 | + $data_type = $this->get_data_type($arg); |
|
151 | 151 | |
152 | - if ( ! $data_type ) { |
|
152 | + if ( ! $data_type) { |
|
153 | 153 | $this->validator->add_error( |
154 | - __( 'This type of condition does not work for the selected attribute.', 'wordpoints' ) |
|
154 | + __('This type of condition does not work for the selected attribute.', 'wordpoints') |
|
155 | 155 | ); |
156 | 156 | |
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | |
160 | - $condition = wordpoints_hooks()->conditions->get( $data_type, $settings['type'] ); |
|
160 | + $condition = wordpoints_hooks()->conditions->get($data_type, $settings['type']); |
|
161 | 161 | |
162 | - if ( ! $condition ) { |
|
162 | + if ( ! $condition) { |
|
163 | 163 | |
164 | 164 | $this->validator->add_error( |
165 | 165 | sprintf( |
166 | - __( 'Unknown condition type “%s”.', 'wordpoints' ) |
|
166 | + __('Unknown condition type “%s”.', 'wordpoints') |
|
167 | 167 | , $settings['type'] |
168 | 168 | ) |
169 | 169 | , 'type' |
@@ -172,17 +172,17 @@ discard block |
||
172 | 172 | return false; |
173 | 173 | } |
174 | 174 | |
175 | - if ( ! isset( $settings['settings'] ) ) { |
|
176 | - $this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) ); |
|
175 | + if ( ! isset($settings['settings'])) { |
|
176 | + $this->validator->add_error(__('Condition settings are missing.', 'wordpoints')); |
|
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | |
180 | - $this->validator->push_field( 'settings' ); |
|
180 | + $this->validator->push_field('settings'); |
|
181 | 181 | |
182 | 182 | // The condition may call this object's validate_settings() method to |
183 | 183 | // validate some sub-conditions. When that happens, these properties will be |
184 | 184 | // reset, so we need to back up their values and then restore them below. |
185 | - $backup = array( $this->validator, $this->event_args ); |
|
185 | + $backup = array($this->validator, $this->event_args); |
|
186 | 186 | |
187 | 187 | $settings['settings'] = $condition->validate_settings( |
188 | 188 | $arg |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | , $this->validator |
191 | 191 | ); |
192 | 192 | |
193 | - list( $this->validator, $this->event_args ) = $backup; |
|
193 | + list($this->validator, $this->event_args) = $backup; |
|
194 | 194 | |
195 | 195 | $this->validator->pop_field(); |
196 | 196 | |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | /** |
201 | 201 | * @since 1.0.0 |
202 | 202 | */ |
203 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
203 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
204 | 204 | |
205 | - $conditions = $this->get_settings_from_fire( $fire ); |
|
205 | + $conditions = $this->get_settings_from_fire($fire); |
|
206 | 206 | |
207 | - if ( $conditions && ! $this->conditions_are_met( $conditions, $fire->event_args ) ) { |
|
207 | + if ($conditions && ! $this->conditions_are_met($conditions, $fire->event_args)) { |
|
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | |
@@ -226,35 +226,35 @@ discard block |
||
226 | 226 | WordPoints_Hook_Event_Args $event_args |
227 | 227 | ) { |
228 | 228 | |
229 | - foreach ( $conditions as $arg_slug => $sub_args ) { |
|
229 | + foreach ($conditions as $arg_slug => $sub_args) { |
|
230 | 230 | |
231 | - $event_args->descend( $arg_slug ); |
|
231 | + $event_args->descend($arg_slug); |
|
232 | 232 | |
233 | - if ( isset( $sub_args['_conditions'] ) ) { |
|
233 | + if (isset($sub_args['_conditions'])) { |
|
234 | 234 | |
235 | - foreach ( $sub_args['_conditions'] as $settings ) { |
|
235 | + foreach ($sub_args['_conditions'] as $settings) { |
|
236 | 236 | |
237 | 237 | $condition = $this->conditions->get( |
238 | - $this->get_data_type( $event_args->get_current() ) |
|
238 | + $this->get_data_type($event_args->get_current()) |
|
239 | 239 | , $settings['type'] |
240 | 240 | ); |
241 | 241 | |
242 | - $is_met = $condition->is_met( $settings['settings'], $event_args ); |
|
242 | + $is_met = $condition->is_met($settings['settings'], $event_args); |
|
243 | 243 | |
244 | - if ( ! $is_met ) { |
|
244 | + if ( ! $is_met) { |
|
245 | 245 | $event_args->ascend(); |
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | - unset( $sub_args['_conditions'] ); |
|
250 | + unset($sub_args['_conditions']); |
|
251 | 251 | } |
252 | 252 | |
253 | - $are_met = $this->conditions_are_met( $sub_args, $event_args ); |
|
253 | + $are_met = $this->conditions_are_met($sub_args, $event_args); |
|
254 | 254 | |
255 | 255 | $event_args->ascend(); |
256 | 256 | |
257 | - if ( ! $are_met ) { |
|
257 | + if ( ! $are_met) { |
|
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | } |
@@ -271,13 +271,13 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return string|false The data type, or false. |
273 | 273 | */ |
274 | - protected function get_data_type( $arg ) { |
|
274 | + protected function get_data_type($arg) { |
|
275 | 275 | |
276 | - if ( $arg instanceof WordPoints_Entity_Attr ) { |
|
276 | + if ($arg instanceof WordPoints_Entity_Attr) { |
|
277 | 277 | $data_type = $arg->get_data_type(); |
278 | - } elseif ( $arg instanceof WordPoints_Entity_Array ) { |
|
278 | + } elseif ($arg instanceof WordPoints_Entity_Array) { |
|
279 | 279 | $data_type = 'entity_array'; |
280 | - } elseif ( $arg instanceof WordPoints_Entity ) { |
|
280 | + } elseif ($arg instanceof WordPoints_Entity) { |
|
281 | 281 | $data_type = 'entity'; |
282 | 282 | } else { |
283 | 283 | $data_type = false; |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | public function get_ui_script_data() { |
26 | 26 | |
27 | 27 | $periods = array( |
28 | - MINUTE_IN_SECONDS => __( 'Minute', 'wordpoints' ), |
|
29 | - HOUR_IN_SECONDS => __( 'Hour', 'wordpoints' ), |
|
30 | - DAY_IN_SECONDS => __( 'Day', 'wordpoints' ), |
|
31 | - WEEK_IN_SECONDS => __( 'Week', 'wordpoints' ), |
|
32 | - 30 * DAY_IN_SECONDS => __( 'Month', 'wordpoints' ), |
|
28 | + MINUTE_IN_SECONDS => __('Minute', 'wordpoints'), |
|
29 | + HOUR_IN_SECONDS => __('Hour', 'wordpoints'), |
|
30 | + DAY_IN_SECONDS => __('Day', 'wordpoints'), |
|
31 | + WEEK_IN_SECONDS => __('Week', 'wordpoints'), |
|
32 | + 30 * DAY_IN_SECONDS => __('Month', 'wordpoints'), |
|
33 | 33 | ); |
34 | 34 | |
35 | 35 | /** |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param string[] $periods The period titles, indexed by length in seconds. |
41 | 41 | */ |
42 | - $periods = apply_filters( 'wordpoints_hooks_ui_data_periods', $periods ); |
|
42 | + $periods = apply_filters('wordpoints_hooks_ui_data_periods', $periods); |
|
43 | 43 | |
44 | 44 | return array( |
45 | 45 | 'periods' => $periods, |
46 | 46 | 'l10n' => array( |
47 | - 'label' => __( 'Trigger reaction no more than once per:', 'wordpoints' ), |
|
47 | + 'label' => __('Trigger reaction no more than once per:', 'wordpoints'), |
|
48 | 48 | ), |
49 | 49 | ); |
50 | 50 | } |
@@ -58,25 +58,25 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return array The validated periods. |
60 | 60 | */ |
61 | - protected function validate_firer_settings( $periods ) { |
|
61 | + protected function validate_firer_settings($periods) { |
|
62 | 62 | |
63 | - if ( ! is_array( $periods ) ) { |
|
63 | + if ( ! is_array($periods)) { |
|
64 | 64 | |
65 | 65 | $this->validator->add_error( |
66 | - __( 'Periods do not match expected format.', 'wordpoints' ) |
|
66 | + __('Periods do not match expected format.', 'wordpoints') |
|
67 | 67 | ); |
68 | 68 | |
69 | 69 | return array(); |
70 | 70 | } |
71 | 71 | |
72 | - foreach ( $periods as $index => $period ) { |
|
72 | + foreach ($periods as $index => $period) { |
|
73 | 73 | |
74 | - $this->validator->push_field( $index ); |
|
74 | + $this->validator->push_field($index); |
|
75 | 75 | |
76 | - $period = $this->validate_period( $period ); |
|
76 | + $period = $this->validate_period($period); |
|
77 | 77 | |
78 | - if ( $period ) { |
|
79 | - $periods[ $index ] = $period; |
|
78 | + if ($period) { |
|
79 | + $periods[$index] = $period; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $this->validator->pop_field(); |
@@ -94,30 +94,30 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @return array|false The validated period, or false if invalid. |
96 | 96 | */ |
97 | - protected function validate_period( $period ) { |
|
97 | + protected function validate_period($period) { |
|
98 | 98 | |
99 | - if ( ! is_array( $period ) ) { |
|
99 | + if ( ! is_array($period)) { |
|
100 | 100 | $this->validator->add_error( |
101 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
101 | + __('Period does not match expected format.', 'wordpoints') |
|
102 | 102 | ); |
103 | 103 | |
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | |
107 | - if ( isset( $period['args'] ) ) { |
|
108 | - $this->validate_period_args( $period['args'] ); |
|
107 | + if (isset($period['args'])) { |
|
108 | + $this->validate_period_args($period['args']); |
|
109 | 109 | } |
110 | 110 | |
111 | - if ( ! isset( $period['length'] ) ) { |
|
111 | + if ( ! isset($period['length'])) { |
|
112 | 112 | |
113 | 113 | $this->validator->add_error( |
114 | - __( 'Period length setting is missing.', 'wordpoints' ) |
|
114 | + __('Period length setting is missing.', 'wordpoints') |
|
115 | 115 | ); |
116 | 116 | |
117 | - } elseif ( false === wordpoints_posint( $period['length'] ) ) { |
|
117 | + } elseif (false === wordpoints_posint($period['length'])) { |
|
118 | 118 | |
119 | 119 | $this->validator->add_error( |
120 | - __( 'Period length must be a positive integer.', 'wordpoints' ) |
|
120 | + __('Period length must be a positive integer.', 'wordpoints') |
|
121 | 121 | , 'length' |
122 | 122 | ); |
123 | 123 | |
@@ -134,34 +134,34 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param mixed $args The args the period is related to. |
136 | 136 | */ |
137 | - protected function validate_period_args( $args ) { |
|
137 | + protected function validate_period_args($args) { |
|
138 | 138 | |
139 | - if ( ! is_array( $args ) ) { |
|
139 | + if ( ! is_array($args)) { |
|
140 | 140 | |
141 | 141 | $this->validator->add_error( |
142 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
142 | + __('Period does not match expected format.', 'wordpoints') |
|
143 | 143 | , 'args' |
144 | 144 | ); |
145 | 145 | |
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
149 | - $this->validator->push_field( 'args' ); |
|
149 | + $this->validator->push_field('args'); |
|
150 | 150 | |
151 | - foreach ( $args as $index => $hierarchy ) { |
|
151 | + foreach ($args as $index => $hierarchy) { |
|
152 | 152 | |
153 | - $this->validator->push_field( $index ); |
|
153 | + $this->validator->push_field($index); |
|
154 | 154 | |
155 | - if ( ! is_array( $hierarchy ) ) { |
|
155 | + if ( ! is_array($hierarchy)) { |
|
156 | 156 | |
157 | 157 | $this->validator->add_error( |
158 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
158 | + __('Period does not match expected format.', 'wordpoints') |
|
159 | 159 | ); |
160 | 160 | |
161 | - } elseif ( ! $this->event_args->get_from_hierarchy( $hierarchy ) ) { |
|
161 | + } elseif ( ! $this->event_args->get_from_hierarchy($hierarchy)) { |
|
162 | 162 | |
163 | 163 | $this->validator->add_error( |
164 | - __( 'Invalid period.', 'wordpoints' ) // TODO better error message |
|
164 | + __('Invalid period.', 'wordpoints') // TODO better error message |
|
165 | 165 | ); |
166 | 166 | } |
167 | 167 | |
@@ -174,18 +174,18 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @since 1.0.0 |
176 | 176 | */ |
177 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
177 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
178 | 178 | |
179 | - $periods = $this->get_settings_from_fire( $fire ); |
|
179 | + $periods = $this->get_settings_from_fire($fire); |
|
180 | 180 | |
181 | - if ( empty( $periods ) ) { |
|
181 | + if (empty($periods)) { |
|
182 | 182 | return true; |
183 | 183 | } |
184 | 184 | |
185 | 185 | $this->event_args = $fire->event_args; |
186 | 186 | |
187 | - foreach ( $periods as $period ) { |
|
188 | - if ( ! $this->has_period_ended( $period, $fire->reaction ) ) { |
|
187 | + foreach ($periods as $period) { |
|
188 | + if ( ! $this->has_period_ended($period, $fire->reaction)) { |
|
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | } |
@@ -209,24 +209,24 @@ discard block |
||
209 | 209 | ) { |
210 | 210 | |
211 | 211 | $period = $this->get_period_by_reaction( |
212 | - $this->get_period_signature( $settings, $reaction ) |
|
212 | + $this->get_period_signature($settings, $reaction) |
|
213 | 213 | , $reaction |
214 | 214 | ); |
215 | 215 | |
216 | 216 | // If the period isn't found, we know that we can still fire. |
217 | - if ( ! $period ) { |
|
217 | + if ( ! $period) { |
|
218 | 218 | return true; |
219 | 219 | } |
220 | 220 | |
221 | - $now = current_time( 'timestamp' ); |
|
222 | - $hit_time = strtotime( $period->date, $now ); |
|
221 | + $now = current_time('timestamp'); |
|
222 | + $hit_time = strtotime($period->date, $now); |
|
223 | 223 | |
224 | - if ( ! empty( $settings['relative'] ) ) { |
|
225 | - return ( $hit_time < $now - $settings['length'] ); |
|
224 | + if ( ! empty($settings['relative'])) { |
|
225 | + return ($hit_time < $now - $settings['length']); |
|
226 | 226 | } else { |
227 | 227 | return ( |
228 | - (int) ( $hit_time / $settings['length'] ) |
|
229 | - < (int) ( $now / $settings['length'] ) |
|
228 | + (int) ($hit_time / $settings['length']) |
|
229 | + < (int) ($now / $settings['length']) |
|
230 | 230 | ); |
231 | 231 | } |
232 | 232 | } |
@@ -240,24 +240,24 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return array The arg values. |
242 | 242 | */ |
243 | - protected function get_arg_values( array $period_args ) { |
|
243 | + protected function get_arg_values(array $period_args) { |
|
244 | 244 | |
245 | 245 | $values = array(); |
246 | 246 | |
247 | - foreach ( $period_args as $arg_hierarchy ) { |
|
247 | + foreach ($period_args as $arg_hierarchy) { |
|
248 | 248 | |
249 | 249 | $arg = $this->event_args->get_from_hierarchy( |
250 | 250 | $arg_hierarchy |
251 | 251 | ); |
252 | 252 | |
253 | - if ( ! $arg instanceof WordPoints_EntityishI ) { |
|
253 | + if ( ! $arg instanceof WordPoints_EntityishI) { |
|
254 | 254 | continue; |
255 | 255 | } |
256 | 256 | |
257 | - $values[ implode( '.', $arg_hierarchy ) ] = $arg->get_the_value(); |
|
257 | + $values[implode('.', $arg_hierarchy)] = $arg->get_the_value(); |
|
258 | 258 | } |
259 | 259 | |
260 | - ksort( $values ); |
|
260 | + ksort($values); |
|
261 | 261 | |
262 | 262 | return $values; |
263 | 263 | } |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return object|false The period data, or false if not found. |
273 | 273 | */ |
274 | - protected function get_period( $period_id ) { |
|
274 | + protected function get_period($period_id) { |
|
275 | 275 | |
276 | - $period = wp_cache_get( $period_id, 'wordpoints_hook_periods' ); |
|
276 | + $period = wp_cache_get($period_id, 'wordpoints_hook_periods'); |
|
277 | 277 | |
278 | - if ( ! $period ) { |
|
278 | + if ( ! $period) { |
|
279 | 279 | |
280 | 280 | global $wpdb; |
281 | 281 | |
@@ -292,11 +292,11 @@ discard block |
||
292 | 292 | ) |
293 | 293 | ); |
294 | 294 | |
295 | - if ( ! $period ) { |
|
295 | + if ( ! $period) { |
|
296 | 296 | return false; |
297 | 297 | } |
298 | 298 | |
299 | - wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' ); |
|
299 | + wp_cache_set($period->id, $period, 'wordpoints_hook_periods'); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | return $period; |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | |
321 | 321 | $reaction_guid = $reaction->get_guid(); |
322 | 322 | |
323 | - $cache_key = wp_json_encode( $reaction_guid ) . "-{$signature}"; |
|
323 | + $cache_key = wp_json_encode($reaction_guid)."-{$signature}"; |
|
324 | 324 | |
325 | 325 | // Before we run the query, we try to lookup the ID in the cache. |
326 | - $period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids_by_reaction' ); |
|
326 | + $period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids_by_reaction'); |
|
327 | 327 | |
328 | 328 | // If we found it, we can retrieve the period by ID instead. |
329 | - if ( $period_id ) { |
|
330 | - return $this->get_period( $period_id ); |
|
329 | + if ($period_id) { |
|
330 | + return $this->get_period($period_id); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | global $wpdb; |
@@ -351,17 +351,17 @@ discard block |
||
351 | 351 | , $signature |
352 | 352 | , $reaction_guid['reactor'] |
353 | 353 | , $reaction_guid['store'] |
354 | - , wp_json_encode( $reaction_guid['context_id'] ) |
|
354 | + , wp_json_encode($reaction_guid['context_id']) |
|
355 | 355 | , $reaction_guid['id'] |
356 | 356 | ) |
357 | 357 | ); |
358 | 358 | |
359 | - if ( ! $period ) { |
|
359 | + if ( ! $period) { |
|
360 | 360 | return false; |
361 | 361 | } |
362 | 362 | |
363 | - wp_cache_set( $cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction' ); |
|
364 | - wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' ); |
|
363 | + wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction'); |
|
364 | + wp_cache_set($period->id, $period, 'wordpoints_hook_periods'); |
|
365 | 365 | |
366 | 366 | return $period; |
367 | 367 | } |
@@ -369,20 +369,20 @@ discard block |
||
369 | 369 | /** |
370 | 370 | * @since 1.0.0 |
371 | 371 | */ |
372 | - public function after_hit( WordPoints_Hook_Fire $fire ) { |
|
372 | + public function after_hit(WordPoints_Hook_Fire $fire) { |
|
373 | 373 | |
374 | - $periods = $this->get_settings_from_fire( $fire ); |
|
374 | + $periods = $this->get_settings_from_fire($fire); |
|
375 | 375 | |
376 | - if ( empty( $periods ) ) { |
|
376 | + if (empty($periods)) { |
|
377 | 377 | return; |
378 | 378 | } |
379 | 379 | |
380 | 380 | $this->event_args = $fire->event_args; |
381 | 381 | |
382 | - foreach ( $periods as $settings ) { |
|
382 | + foreach ($periods as $settings) { |
|
383 | 383 | |
384 | 384 | $this->add_period( |
385 | - $this->get_period_signature( $settings, $fire->reaction ) |
|
385 | + $this->get_period_signature($settings, $fire->reaction) |
|
386 | 386 | , $fire |
387 | 387 | ); |
388 | 388 | } |
@@ -407,14 +407,14 @@ discard block |
||
407 | 407 | WordPoints_Hook_ReactionI $reaction |
408 | 408 | ) { |
409 | 409 | |
410 | - if ( isset( $settings['args'] ) ) { |
|
410 | + if (isset($settings['args'])) { |
|
411 | 411 | $period_args = $settings['args']; |
412 | 412 | } else { |
413 | - $period_args = array( $reaction->get_meta( 'target' ) ); |
|
413 | + $period_args = array($reaction->get_meta('target')); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | return wordpoints_hash( |
417 | - wp_json_encode( $this->get_arg_values( $period_args ) ) |
|
417 | + wp_json_encode($this->get_arg_values($period_args)) |
|
418 | 418 | ); |
419 | 419 | } |
420 | 420 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @return false|object The period data, or false if not found. |
430 | 430 | */ |
431 | - protected function add_period( $signature, WordPoints_Hook_Fire $fire ) { |
|
431 | + protected function add_period($signature, WordPoints_Hook_Fire $fire) { |
|
432 | 432 | |
433 | 433 | global $wpdb; |
434 | 434 | |
@@ -438,17 +438,17 @@ discard block |
||
438 | 438 | 'hit_id' => $fire->hit_id, |
439 | 439 | 'signature' => $signature, |
440 | 440 | ) |
441 | - , array( '%d', '%s' ) |
|
441 | + , array('%d', '%s') |
|
442 | 442 | ); |
443 | 443 | |
444 | - if ( ! $inserted ) { |
|
444 | + if ( ! $inserted) { |
|
445 | 445 | return false; |
446 | 446 | } |
447 | 447 | |
448 | 448 | $period_id = $wpdb->insert_id; |
449 | 449 | |
450 | 450 | wp_cache_set( |
451 | - wp_json_encode( $fire->reaction->get_guid() ) . "-{$signature}" |
|
451 | + wp_json_encode($fire->reaction->get_guid())."-{$signature}" |
|
452 | 452 | , $period_id |
453 | 453 | , 'wordpoints_hook_period_ids_by_reaction' |
454 | 454 | ); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool Whether the hit should be reversed or not. |
25 | 25 | */ |
26 | - public function should_reverse( WordPoints_Hook_Fire $fire ); |
|
26 | + public function should_reverse(WordPoints_Hook_Fire $fire); |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Called after a reverse action is called. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @param WordPoints_Hook_Fire $fire The reverse fire object. |
34 | 34 | */ |
35 | - public function after_reverse( WordPoints_Hook_Fire $fire ); |
|
35 | + public function after_reverse(WordPoints_Hook_Fire $fire); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // EOF |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @since 1.0.0 |
55 | 55 | */ |
56 | - public function __get( $var ) { |
|
56 | + public function __get($var) { |
|
57 | 57 | |
58 | - if ( 'reactions' !== $var ) { |
|
58 | + if ('reactions' !== $var) { |
|
59 | 59 | return null; |
60 | 60 | } |
61 | 61 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | wordpoints_hooks()->get_current_mode() |
64 | 64 | ); |
65 | 65 | |
66 | - if ( ! $reaction_store ) { |
|
66 | + if ( ! $reaction_store) { |
|
67 | 67 | return null; |
68 | 68 | } |
69 | 69 | |
@@ -79,20 +79,20 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return WordPoints_Hook_Reaction_StoreI|false The reaction storage object. |
81 | 81 | */ |
82 | - public function get_reaction_store( $slug ) { |
|
82 | + public function get_reaction_store($slug) { |
|
83 | 83 | |
84 | 84 | $reaction_store = wordpoints_hooks()->reaction_stores->get( |
85 | 85 | $this->slug |
86 | 86 | , $slug |
87 | - , array( $this ) |
|
87 | + , array($this) |
|
88 | 88 | ); |
89 | 89 | |
90 | - if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) { |
|
90 | + if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Allowing access to stores out-of-context would lead to strange behavior. |
95 | - if ( false === $reaction_store->get_context_id() ) { |
|
95 | + if (false === $reaction_store->get_context_id()) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'slug' => $this->get_slug(), |
146 | 146 | 'fields' => $this->get_settings_fields(), |
147 | 147 | 'arg_types' => $this->get_arg_types(), |
148 | - 'firers' => array( 'fire' ), |
|
148 | + 'firers' => array('fire'), |
|
149 | 149 | ); |
150 | 150 | } |
151 | 151 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return WordPoints_Hook_ReactionI[] All of the reaction objects. |
185 | 185 | */ |
186 | - public function get_all_reactions_to_event( $event_slug ) { |
|
186 | + public function get_all_reactions_to_event($event_slug) { |
|
187 | 187 | |
188 | 188 | $reactions = array(); |
189 | 189 | |
@@ -191,17 +191,17 @@ discard block |
||
191 | 191 | $this->slug |
192 | 192 | ); |
193 | 193 | |
194 | - foreach ( $slugs as $slug ) { |
|
194 | + foreach ($slugs as $slug) { |
|
195 | 195 | |
196 | - $store = $this->get_reaction_store( $slug ); |
|
196 | + $store = $this->get_reaction_store($slug); |
|
197 | 197 | |
198 | - if ( ! $store ) { |
|
198 | + if ( ! $store) { |
|
199 | 199 | continue; |
200 | 200 | } |
201 | 201 | |
202 | 202 | $reactions = array_merge( |
203 | 203 | $reactions |
204 | - , $store->get_reactions_to_event( $event_slug ) |
|
204 | + , $store->get_reactions_to_event($event_slug) |
|
205 | 205 | ); |
206 | 206 | } |
207 | 207 | |
@@ -230,15 +230,15 @@ discard block |
||
230 | 230 | $this->slug |
231 | 231 | ); |
232 | 232 | |
233 | - foreach ( $slugs as $slug ) { |
|
233 | + foreach ($slugs as $slug) { |
|
234 | 234 | |
235 | - $store = $this->get_reaction_store( $slug ); |
|
235 | + $store = $this->get_reaction_store($slug); |
|
236 | 236 | |
237 | - if ( ! $store ) { |
|
237 | + if ( ! $store) { |
|
238 | 238 | continue; |
239 | 239 | } |
240 | 240 | |
241 | - $reactions = array_merge( $reactions, $store->get_reactions() ); |
|
241 | + $reactions = array_merge($reactions, $store->get_reactions()); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | return $reactions; |
@@ -254,21 +254,21 @@ discard block |
||
254 | 254 | ) { |
255 | 255 | |
256 | 256 | if ( |
257 | - empty( $settings['target'] ) |
|
258 | - || ! is_array( $settings['target'] ) |
|
257 | + empty($settings['target']) |
|
258 | + || ! is_array($settings['target']) |
|
259 | 259 | ) { |
260 | 260 | |
261 | - $validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' ); |
|
261 | + $validator->add_error(__('Invalid target.', 'wordpoints'), 'target'); |
|
262 | 262 | |
263 | 263 | } else { |
264 | 264 | |
265 | - $target = $event_args->get_from_hierarchy( $settings['target'] ); |
|
265 | + $target = $event_args->get_from_hierarchy($settings['target']); |
|
266 | 266 | |
267 | 267 | if ( |
268 | 268 | ! $target instanceof WordPoints_Entity |
269 | - || ! in_array( $target->get_slug(), (array) $this->arg_types ) |
|
269 | + || ! in_array($target->get_slug(), (array) $this->arg_types) |
|
270 | 270 | ) { |
271 | - $validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' ); |
|
271 | + $validator->add_error(__('Invalid target.', 'wordpoints'), 'target'); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | /** |
279 | 279 | * @since 1.0.0 |
280 | 280 | */ |
281 | - public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) { |
|
282 | - $reaction->update_meta( 'target', $settings['target'] ); |
|
281 | + public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) { |
|
282 | + $reaction->update_meta('target', $settings['target']); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @param WordPoints_Hook_Fire $fire The hook fire object. |
291 | 291 | */ |
292 | - abstract public function hit( WordPoints_Hook_Fire $fire ); |
|
292 | + abstract public function hit(WordPoints_Hook_Fire $fire); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // EOF |
@@ -17,67 +17,67 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @since 1.0.0 |
19 | 19 | */ |
20 | - public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args ) { |
|
20 | + public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args) { |
|
21 | 21 | |
22 | 22 | $hooks = wordpoints_hooks(); |
23 | 23 | |
24 | - $hits = $this->get_hits( $event_slug, $event_args ); |
|
24 | + $hits = $this->get_hits($event_slug, $event_args); |
|
25 | 25 | $reverse_hit_ids = array(); |
26 | 26 | |
27 | - foreach ( $hits as $hit ) { |
|
27 | + foreach ($hits as $hit) { |
|
28 | 28 | |
29 | 29 | /** @var WordPoints_Hook_Reactor $reactor */ |
30 | - $reactor = $hooks->reactors->get( $hit->reactor ); |
|
30 | + $reactor = $hooks->reactors->get($hit->reactor); |
|
31 | 31 | |
32 | - if ( ! $reactor instanceof WordPoints_Hook_Reactor_ReverseI ) { |
|
32 | + if ( ! $reactor instanceof WordPoints_Hook_Reactor_ReverseI) { |
|
33 | 33 | continue; |
34 | 34 | } |
35 | 35 | |
36 | - $reactions = $reactor->get_reaction_store( $hit->reaction_store ); |
|
36 | + $reactions = $reactor->get_reaction_store($hit->reaction_store); |
|
37 | 37 | |
38 | 38 | if ( |
39 | 39 | ! $reactions |
40 | - || wp_json_encode( $reactions->get_context_id() ) !== $hit->reaction_context_id |
|
40 | + || wp_json_encode($reactions->get_context_id()) !== $hit->reaction_context_id |
|
41 | 41 | ) { |
42 | 42 | continue; |
43 | 43 | } |
44 | 44 | |
45 | - $reaction = $reactions->get_reaction( $hit->reaction_id ); |
|
45 | + $reaction = $reactions->get_reaction($hit->reaction_id); |
|
46 | 46 | |
47 | - if ( ! $reaction ) { |
|
47 | + if ( ! $reaction) { |
|
48 | 48 | continue; |
49 | 49 | } |
50 | 50 | |
51 | - $fire = new WordPoints_Hook_Fire( $this, $event_args, $reaction ); |
|
51 | + $fire = new WordPoints_Hook_Fire($this, $event_args, $reaction); |
|
52 | 52 | |
53 | - foreach ( $hooks->extensions->get_all() as $extension ) { |
|
53 | + foreach ($hooks->extensions->get_all() as $extension) { |
|
54 | 54 | |
55 | - if ( ! $extension instanceof WordPoints_Hook_Extension_ReverseI ) { |
|
55 | + if ( ! $extension instanceof WordPoints_Hook_Extension_ReverseI) { |
|
56 | 56 | continue; |
57 | 57 | } |
58 | 58 | |
59 | - if ( ! $extension->should_reverse( $fire ) ) { |
|
59 | + if ( ! $extension->should_reverse($fire)) { |
|
60 | 60 | continue 2; |
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | - $reverse_hit_ids[ $hit->id ] = $fire->hit(); |
|
64 | + $reverse_hit_ids[$hit->id] = $fire->hit(); |
|
65 | 65 | |
66 | - $reactor->reverse_hit( $fire ); |
|
66 | + $reactor->reverse_hit($fire); |
|
67 | 67 | |
68 | - foreach ( $hooks->extensions->get_all() as $extension ) { |
|
69 | - if ( $extension instanceof WordPoints_Hook_Extension_ReverseI ) { |
|
70 | - $extension->after_reverse( $fire ); |
|
68 | + foreach ($hooks->extensions->get_all() as $extension) { |
|
69 | + if ($extension instanceof WordPoints_Hook_Extension_ReverseI) { |
|
70 | + $extension->after_reverse($fire); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | 75 | // Set the reversed_by meta key for all hits so that we know that they have |
76 | 76 | // been reverse fired, even if they didn't hit. |
77 | - foreach ( $hits as $hit ) { |
|
77 | + foreach ($hits as $hit) { |
|
78 | 78 | |
79 | - if ( isset( $reverse_hit_ids[ $hit->id ] ) ) { |
|
80 | - $reversed_by = $reverse_hit_ids[ $hit->id ]; |
|
79 | + if (isset($reverse_hit_ids[$hit->id])) { |
|
80 | + $reversed_by = $reverse_hit_ids[$hit->id]; |
|
81 | 81 | } else { |
82 | 82 | $reversed_by = 0; |
83 | 83 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return object[] The data for each hit from the hit logs database table. |
104 | 104 | */ |
105 | - protected function get_hits( $event_slug, WordPoints_Hook_Event_Args $event_args ) { |
|
105 | + protected function get_hits($event_slug, WordPoints_Hook_Event_Args $event_args) { |
|
106 | 106 | |
107 | 107 | $query = new WordPoints_Hook_Hit_Query( |
108 | 108 | array( |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | $hits = $query->get(); |
120 | 120 | |
121 | - if ( ! is_array( $hits ) ) { |
|
121 | + if ( ! is_array($hits)) { |
|
122 | 122 | return array(); |
123 | 123 | } |
124 | 124 |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @since 1.0.0 |
57 | 57 | */ |
58 | 58 | public function get_title() { |
59 | - return __( 'Contains', 'wordpoints' ); |
|
59 | + return __('Contains', 'wordpoints'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | return array( |
67 | 67 | 'min' => array( |
68 | 68 | 'slug' => 'min', |
69 | - 'label' => __( 'Minimum number of items', 'wordpoints' ), |
|
69 | + 'label' => __('Minimum number of items', 'wordpoints'), |
|
70 | 70 | 'type' => 'number', |
71 | 71 | 'default' => 1, |
72 | 72 | ), |
73 | 73 | 'max' => array( |
74 | 74 | 'slug' => 'max', |
75 | - 'label' => __( 'Maximum number of items', 'wordpoints' ), |
|
75 | + 'label' => __('Maximum number of items', 'wordpoints'), |
|
76 | 76 | 'type' => 'number', |
77 | 77 | ), |
78 | 78 | ); |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | |
93 | 93 | $this->validate_count(); |
94 | 94 | |
95 | - if ( isset( $settings['conditions'] ) ) { |
|
96 | - $this->validate_conditions( $arg ); |
|
95 | + if (isset($settings['conditions'])) { |
|
96 | + $this->validate_conditions($arg); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return $this->settings; |
@@ -107,31 +107,31 @@ discard block |
||
107 | 107 | protected function validate_count() { |
108 | 108 | |
109 | 109 | if ( |
110 | - ! empty( $this->settings['max'] ) |
|
111 | - && ! wordpoints_posint( $this->settings['max'] ) |
|
110 | + ! empty($this->settings['max']) |
|
111 | + && ! wordpoints_posint($this->settings['max']) |
|
112 | 112 | ) { |
113 | 113 | $this->validator->add_error( |
114 | - __( 'The maximum must be a positive integer.', 'wordpoints' ) |
|
114 | + __('The maximum must be a positive integer.', 'wordpoints') |
|
115 | 115 | , 'max' |
116 | 116 | ); |
117 | 117 | } |
118 | 118 | |
119 | - if ( ! empty( $this->settings['min'] ) ) { |
|
119 | + if ( ! empty($this->settings['min'])) { |
|
120 | 120 | |
121 | - if ( ! wordpoints_posint( $this->settings['min'] ) ) { |
|
121 | + if ( ! wordpoints_posint($this->settings['min'])) { |
|
122 | 122 | |
123 | 123 | $this->validator->add_error( |
124 | - __( 'The minimum must be a positive integer.', 'wordpoints' ) |
|
124 | + __('The minimum must be a positive integer.', 'wordpoints') |
|
125 | 125 | , 'min' |
126 | 126 | ); |
127 | 127 | |
128 | 128 | } elseif ( |
129 | - ! empty( $this->settings['max'] ) |
|
129 | + ! empty($this->settings['max']) |
|
130 | 130 | && $this->settings['max'] < $this->settings['min'] |
131 | 131 | ) { |
132 | 132 | |
133 | 133 | $this->validator->add_error( |
134 | - __( 'The minimum must be less than the maximum.', 'wordpoints' ) |
|
134 | + __('The minimum must be less than the maximum.', 'wordpoints') |
|
135 | 135 | , 'min' |
136 | 136 | ); |
137 | 137 | } |
@@ -145,39 +145,39 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param WordPoints_EntityishI $current_arg The current arg. |
147 | 147 | */ |
148 | - protected function validate_conditions( $current_arg ) { |
|
148 | + protected function validate_conditions($current_arg) { |
|
149 | 149 | |
150 | - $args = new WordPoints_Hook_Event_Args( array() ); |
|
150 | + $args = new WordPoints_Hook_Event_Args(array()); |
|
151 | 151 | |
152 | - if ( $current_arg instanceof WordPoints_Entity_Array ) { |
|
152 | + if ($current_arg instanceof WordPoints_Entity_Array) { |
|
153 | 153 | |
154 | 154 | $entity = wordpoints_entities()->get( |
155 | 155 | $current_arg->get_entity_slug() |
156 | 156 | ); |
157 | 157 | |
158 | - if ( $entity instanceof WordPoints_Entity ) { |
|
159 | - $args->add_entity( $entity ); |
|
158 | + if ($entity instanceof WordPoints_Entity) { |
|
159 | + $args->add_entity($entity); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - $args->set_validator( $this->validator ); |
|
163 | + $args->set_validator($this->validator); |
|
164 | 164 | |
165 | 165 | $firer_slugs = wordpoints_hooks()->firers->get_all_slugs(); |
166 | - $firer_slug = array_shift( $firer_slugs ); |
|
166 | + $firer_slug = array_shift($firer_slugs); |
|
167 | 167 | |
168 | 168 | $conditions = $this->conditions_extension->validate_settings( |
169 | - array( 'conditions' => array( $firer_slug => $this->settings['conditions'] ) ) |
|
169 | + array('conditions' => array($firer_slug => $this->settings['conditions'])) |
|
170 | 170 | , $this->validator |
171 | 171 | , $args |
172 | 172 | ); |
173 | 173 | |
174 | - $this->settings['conditions'] = $conditions['conditions'][ $firer_slug ]; |
|
174 | + $this->settings['conditions'] = $conditions['conditions'][$firer_slug]; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | 178 | * @since 1.0.0 |
179 | 179 | */ |
180 | - public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) { |
|
180 | + public function is_met(array $settings, WordPoints_Hook_Event_Args $args) { |
|
181 | 181 | |
182 | 182 | $this->settings = $settings; |
183 | 183 | |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | |
186 | 186 | $entities = array(); |
187 | 187 | |
188 | - if ( $arg instanceof WordPoints_Entity_Array ) { |
|
188 | + if ($arg instanceof WordPoints_Entity_Array) { |
|
189 | 189 | |
190 | 190 | $entities = $arg->get_the_entities(); |
191 | 191 | |
192 | - if ( isset( $this->settings['conditions'] ) ) { |
|
193 | - $entities = $this->filter_entities( $entities ); |
|
192 | + if (isset($this->settings['conditions'])) { |
|
193 | + $entities = $this->filter_entities($entities); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | - return $this->check_count( count( $entities ) ); |
|
197 | + return $this->check_count(count($entities)); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -206,20 +206,20 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return WordPoints_Entity[] The entities that matched the sub-conditions. |
208 | 208 | */ |
209 | - protected function filter_entities( $entities ) { |
|
209 | + protected function filter_entities($entities) { |
|
210 | 210 | |
211 | - foreach ( $entities as $index => $entity ) { |
|
211 | + foreach ($entities as $index => $entity) { |
|
212 | 212 | |
213 | - $event_args = new WordPoints_Hook_Event_Args( array() ); |
|
214 | - $event_args->add_entity( $entity ); |
|
213 | + $event_args = new WordPoints_Hook_Event_Args(array()); |
|
214 | + $event_args->add_entity($entity); |
|
215 | 215 | |
216 | 216 | $matches = $this->conditions_extension->conditions_are_met( |
217 | 217 | $this->settings['conditions'] |
218 | 218 | , $event_args |
219 | 219 | ); |
220 | 220 | |
221 | - if ( ! $matches ) { |
|
222 | - unset( $entities[ $index ] ); |
|
221 | + if ( ! $matches) { |
|
222 | + unset($entities[$index]); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return bool Whether the count met the requirements. |
237 | 237 | */ |
238 | - protected function check_count( $count ) { |
|
238 | + protected function check_count($count) { |
|
239 | 239 | |
240 | - if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) { |
|
240 | + if (isset($this->settings['max']) && $count > $this->settings['max']) { |
|
241 | 241 | return false; |
242 | 242 | } |
243 | 243 | |
244 | - if ( isset( $this->settings['min'] ) && $count < $this->settings['min'] ) { |
|
244 | + if (isset($this->settings['min']) && $count < $this->settings['min']) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 |
@@ -10,112 +10,112 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // auto-generated { |
13 | -require_once( dirname( __FILE__ ) . 'app.php' ); |
|
14 | -require_once( dirname( __FILE__ ) . 'app/registry.php' ); |
|
15 | -require_once( dirname( __FILE__ ) . 'class/autoloader.php' ); |
|
16 | -require_once( dirname( __FILE__ ) . 'class/registry.php' ); |
|
17 | -require_once( dirname( __FILE__ ) . 'class/registry/children.php' ); |
|
18 | -require_once( dirname( __FILE__ ) . 'class/registry/childreni.php' ); |
|
19 | -require_once( dirname( __FILE__ ) . 'class/registry/persistent.php' ); |
|
20 | -require_once( dirname( __FILE__ ) . 'class/registryi.php' ); |
|
21 | -require_once( dirname( __FILE__ ) . 'data/type.php' ); |
|
22 | -require_once( dirname( __FILE__ ) . 'data/type/integer.php' ); |
|
23 | -require_once( dirname( __FILE__ ) . 'data/type/text.php' ); |
|
24 | -require_once( dirname( __FILE__ ) . 'data/typei.php' ); |
|
25 | -require_once( dirname( __FILE__ ) . 'db/query.php' ); |
|
26 | -require_once( dirname( __FILE__ ) . 'entity.php' ); |
|
27 | -require_once( dirname( __FILE__ ) . 'entity/array.php' ); |
|
28 | -require_once( dirname( __FILE__ ) . 'entity/attr.php' ); |
|
29 | -require_once( dirname( __FILE__ ) . 'entity/childi.php' ); |
|
30 | -require_once( dirname( __FILE__ ) . 'entity/comment.php' ); |
|
31 | -require_once( dirname( __FILE__ ) . 'entity/comment/author.php' ); |
|
32 | -require_once( dirname( __FILE__ ) . 'entity/comment/post.php' ); |
|
33 | -require_once( dirname( __FILE__ ) . 'entity/context.php' ); |
|
34 | -require_once( dirname( __FILE__ ) . 'entity/context/network.php' ); |
|
35 | -require_once( dirname( __FILE__ ) . 'entity/context/site.php' ); |
|
36 | -require_once( dirname( __FILE__ ) . 'entity/enumerablei.php' ); |
|
37 | -require_once( dirname( __FILE__ ) . 'entity/hierarchy.php' ); |
|
38 | -require_once( dirname( __FILE__ ) . 'entity/hierarchyi.php' ); |
|
39 | -require_once( dirname( __FILE__ ) . 'entity/parenti.php' ); |
|
40 | -require_once( dirname( __FILE__ ) . 'entity/post.php' ); |
|
41 | -require_once( dirname( __FILE__ ) . 'entity/post/author.php' ); |
|
42 | -require_once( dirname( __FILE__ ) . 'entity/post/content.php' ); |
|
43 | -require_once( dirname( __FILE__ ) . 'entity/post/terms.php' ); |
|
44 | -require_once( dirname( __FILE__ ) . 'entity/post/type.php' ); |
|
45 | -require_once( dirname( __FILE__ ) . 'entity/post/type/name.php' ); |
|
46 | -require_once( dirname( __FILE__ ) . 'entity/post/type/relationship.php' ); |
|
47 | -require_once( dirname( __FILE__ ) . 'entity/relationship.php' ); |
|
48 | -require_once( dirname( __FILE__ ) . 'entity/relationship/dynamic.php' ); |
|
49 | -require_once( dirname( __FILE__ ) . 'entity/restricted/visibilityi.php' ); |
|
50 | -require_once( dirname( __FILE__ ) . 'entity/site.php' ); |
|
51 | -require_once( dirname( __FILE__ ) . 'entity/term.php' ); |
|
52 | -require_once( dirname( __FILE__ ) . 'entity/term/id.php' ); |
|
53 | -require_once( dirname( __FILE__ ) . 'entity/user.php' ); |
|
54 | -require_once( dirname( __FILE__ ) . 'entity/user/role.php' ); |
|
55 | -require_once( dirname( __FILE__ ) . 'entity/user/role/name.php' ); |
|
56 | -require_once( dirname( __FILE__ ) . 'entity/user/roles.php' ); |
|
57 | -require_once( dirname( __FILE__ ) . 'entityish.php' ); |
|
58 | -require_once( dirname( __FILE__ ) . 'entityishi.php' ); |
|
59 | -require_once( dirname( __FILE__ ) . 'hierarchy.php' ); |
|
60 | -require_once( dirname( __FILE__ ) . 'hook/action.php' ); |
|
61 | -require_once( dirname( __FILE__ ) . 'hook/action/comment/new.php' ); |
|
62 | -require_once( dirname( __FILE__ ) . 'hook/action/post/publish.php' ); |
|
63 | -require_once( dirname( __FILE__ ) . 'hook/actioni.php' ); |
|
64 | -require_once( dirname( __FILE__ ) . 'hook/actions.php' ); |
|
65 | -require_once( dirname( __FILE__ ) . 'hook/arg.php' ); |
|
66 | -require_once( dirname( __FILE__ ) . 'hook/arg/current/post.php' ); |
|
67 | -require_once( dirname( __FILE__ ) . 'hook/arg/current/site.php' ); |
|
68 | -require_once( dirname( __FILE__ ) . 'hook/arg/current/user.php' ); |
|
69 | -require_once( dirname( __FILE__ ) . 'hook/arg/dynamic.php' ); |
|
70 | -require_once( dirname( __FILE__ ) . 'hook/condition.php' ); |
|
71 | -require_once( dirname( __FILE__ ) . 'hook/condition/entity/array/contains.php' ); |
|
72 | -require_once( dirname( __FILE__ ) . 'hook/condition/equals.php' ); |
|
73 | -require_once( dirname( __FILE__ ) . 'hook/condition/string/contains.php' ); |
|
74 | -require_once( dirname( __FILE__ ) . 'hook/conditioni.php' ); |
|
75 | -require_once( dirname( __FILE__ ) . 'hook/event.php' ); |
|
76 | -require_once( dirname( __FILE__ ) . 'hook/event/args.php' ); |
|
77 | -require_once( dirname( __FILE__ ) . 'hook/event/comment/leave.php' ); |
|
78 | -require_once( dirname( __FILE__ ) . 'hook/event/dynamic.php' ); |
|
79 | -require_once( dirname( __FILE__ ) . 'hook/event/media/upload.php' ); |
|
80 | -require_once( dirname( __FILE__ ) . 'hook/event/post/publish.php' ); |
|
81 | -require_once( dirname( __FILE__ ) . 'hook/event/user/register.php' ); |
|
82 | -require_once( dirname( __FILE__ ) . 'hook/event/user/visit.php' ); |
|
83 | -require_once( dirname( __FILE__ ) . 'hook/eventi.php' ); |
|
84 | -require_once( dirname( __FILE__ ) . 'hook/events.php' ); |
|
85 | -require_once( dirname( __FILE__ ) . 'hook/extension.php' ); |
|
86 | -require_once( dirname( __FILE__ ) . 'hook/extension/conditions.php' ); |
|
87 | -require_once( dirname( __FILE__ ) . 'hook/extension/periods.php' ); |
|
88 | -require_once( dirname( __FILE__ ) . 'hook/extension/reversei.php' ); |
|
89 | -require_once( dirname( __FILE__ ) . 'hook/fire.php' ); |
|
90 | -require_once( dirname( __FILE__ ) . 'hook/firer.php' ); |
|
91 | -require_once( dirname( __FILE__ ) . 'hook/firer/reverse.php' ); |
|
92 | -require_once( dirname( __FILE__ ) . 'hook/fireri.php' ); |
|
93 | -require_once( dirname( __FILE__ ) . 'hook/hit/logger.php' ); |
|
94 | -require_once( dirname( __FILE__ ) . 'hook/hit/query.php' ); |
|
95 | -require_once( dirname( __FILE__ ) . 'hook/reaction.php' ); |
|
96 | -require_once( dirname( __FILE__ ) . 'hook/reaction/options.php' ); |
|
97 | -require_once( dirname( __FILE__ ) . 'hook/reaction/store.php' ); |
|
98 | -require_once( dirname( __FILE__ ) . 'hook/reaction/store/options.php' ); |
|
99 | -require_once( dirname( __FILE__ ) . 'hook/reaction/store/options/network.php' ); |
|
100 | -require_once( dirname( __FILE__ ) . 'hook/reaction/storei.php' ); |
|
101 | -require_once( dirname( __FILE__ ) . 'hook/reaction/validator.php' ); |
|
102 | -require_once( dirname( __FILE__ ) . 'hook/reactioni.php' ); |
|
103 | -require_once( dirname( __FILE__ ) . 'hook/reactor.php' ); |
|
104 | -require_once( dirname( __FILE__ ) . 'hook/reactor/points.php' ); |
|
105 | -require_once( dirname( __FILE__ ) . 'hook/reactor/reversei.php' ); |
|
106 | -require_once( dirname( __FILE__ ) . 'hook/retroactive/conditions.php' ); |
|
107 | -require_once( dirname( __FILE__ ) . 'hook/retroactive/query.php' ); |
|
108 | -require_once( dirname( __FILE__ ) . 'hook/retroactive/query/modifieri.php' ); |
|
109 | -require_once( dirname( __FILE__ ) . 'hook/retroactive/queryable.php' ); |
|
110 | -require_once( dirname( __FILE__ ) . 'hook/retroactive/queryi.php' ); |
|
111 | -require_once( dirname( __FILE__ ) . 'hook/router.php' ); |
|
112 | -require_once( dirname( __FILE__ ) . 'hook/settings.php' ); |
|
113 | -require_once( dirname( __FILE__ ) . 'hook/settingsi.php' ); |
|
114 | -require_once( dirname( __FILE__ ) . 'hook/validator/exception.php' ); |
|
115 | -require_once( dirname( __FILE__ ) . 'hooks.php' ); |
|
116 | -require_once( dirname( __FILE__ ) . 'query/builder/db/mysql.php' ); |
|
117 | -require_once( dirname( __FILE__ ) . 'spec.php' ); |
|
118 | -require_once( dirname( __FILE__ ) . 'specedi.php' ); |
|
13 | +require_once(dirname(__FILE__).'app.php'); |
|
14 | +require_once(dirname(__FILE__).'app/registry.php'); |
|
15 | +require_once(dirname(__FILE__).'class/autoloader.php'); |
|
16 | +require_once(dirname(__FILE__).'class/registry.php'); |
|
17 | +require_once(dirname(__FILE__).'class/registry/children.php'); |
|
18 | +require_once(dirname(__FILE__).'class/registry/childreni.php'); |
|
19 | +require_once(dirname(__FILE__).'class/registry/persistent.php'); |
|
20 | +require_once(dirname(__FILE__).'class/registryi.php'); |
|
21 | +require_once(dirname(__FILE__).'data/type.php'); |
|
22 | +require_once(dirname(__FILE__).'data/type/integer.php'); |
|
23 | +require_once(dirname(__FILE__).'data/type/text.php'); |
|
24 | +require_once(dirname(__FILE__).'data/typei.php'); |
|
25 | +require_once(dirname(__FILE__).'db/query.php'); |
|
26 | +require_once(dirname(__FILE__).'entity.php'); |
|
27 | +require_once(dirname(__FILE__).'entity/array.php'); |
|
28 | +require_once(dirname(__FILE__).'entity/attr.php'); |
|
29 | +require_once(dirname(__FILE__).'entity/childi.php'); |
|
30 | +require_once(dirname(__FILE__).'entity/comment.php'); |
|
31 | +require_once(dirname(__FILE__).'entity/comment/author.php'); |
|
32 | +require_once(dirname(__FILE__).'entity/comment/post.php'); |
|
33 | +require_once(dirname(__FILE__).'entity/context.php'); |
|
34 | +require_once(dirname(__FILE__).'entity/context/network.php'); |
|
35 | +require_once(dirname(__FILE__).'entity/context/site.php'); |
|
36 | +require_once(dirname(__FILE__).'entity/enumerablei.php'); |
|
37 | +require_once(dirname(__FILE__).'entity/hierarchy.php'); |
|
38 | +require_once(dirname(__FILE__).'entity/hierarchyi.php'); |
|
39 | +require_once(dirname(__FILE__).'entity/parenti.php'); |
|
40 | +require_once(dirname(__FILE__).'entity/post.php'); |
|
41 | +require_once(dirname(__FILE__).'entity/post/author.php'); |
|
42 | +require_once(dirname(__FILE__).'entity/post/content.php'); |
|
43 | +require_once(dirname(__FILE__).'entity/post/terms.php'); |
|
44 | +require_once(dirname(__FILE__).'entity/post/type.php'); |
|
45 | +require_once(dirname(__FILE__).'entity/post/type/name.php'); |
|
46 | +require_once(dirname(__FILE__).'entity/post/type/relationship.php'); |
|
47 | +require_once(dirname(__FILE__).'entity/relationship.php'); |
|
48 | +require_once(dirname(__FILE__).'entity/relationship/dynamic.php'); |
|
49 | +require_once(dirname(__FILE__).'entity/restricted/visibilityi.php'); |
|
50 | +require_once(dirname(__FILE__).'entity/site.php'); |
|
51 | +require_once(dirname(__FILE__).'entity/term.php'); |
|
52 | +require_once(dirname(__FILE__).'entity/term/id.php'); |
|
53 | +require_once(dirname(__FILE__).'entity/user.php'); |
|
54 | +require_once(dirname(__FILE__).'entity/user/role.php'); |
|
55 | +require_once(dirname(__FILE__).'entity/user/role/name.php'); |
|
56 | +require_once(dirname(__FILE__).'entity/user/roles.php'); |
|
57 | +require_once(dirname(__FILE__).'entityish.php'); |
|
58 | +require_once(dirname(__FILE__).'entityishi.php'); |
|
59 | +require_once(dirname(__FILE__).'hierarchy.php'); |
|
60 | +require_once(dirname(__FILE__).'hook/action.php'); |
|
61 | +require_once(dirname(__FILE__).'hook/action/comment/new.php'); |
|
62 | +require_once(dirname(__FILE__).'hook/action/post/publish.php'); |
|
63 | +require_once(dirname(__FILE__).'hook/actioni.php'); |
|
64 | +require_once(dirname(__FILE__).'hook/actions.php'); |
|
65 | +require_once(dirname(__FILE__).'hook/arg.php'); |
|
66 | +require_once(dirname(__FILE__).'hook/arg/current/post.php'); |
|
67 | +require_once(dirname(__FILE__).'hook/arg/current/site.php'); |
|
68 | +require_once(dirname(__FILE__).'hook/arg/current/user.php'); |
|
69 | +require_once(dirname(__FILE__).'hook/arg/dynamic.php'); |
|
70 | +require_once(dirname(__FILE__).'hook/condition.php'); |
|
71 | +require_once(dirname(__FILE__).'hook/condition/entity/array/contains.php'); |
|
72 | +require_once(dirname(__FILE__).'hook/condition/equals.php'); |
|
73 | +require_once(dirname(__FILE__).'hook/condition/string/contains.php'); |
|
74 | +require_once(dirname(__FILE__).'hook/conditioni.php'); |
|
75 | +require_once(dirname(__FILE__).'hook/event.php'); |
|
76 | +require_once(dirname(__FILE__).'hook/event/args.php'); |
|
77 | +require_once(dirname(__FILE__).'hook/event/comment/leave.php'); |
|
78 | +require_once(dirname(__FILE__).'hook/event/dynamic.php'); |
|
79 | +require_once(dirname(__FILE__).'hook/event/media/upload.php'); |
|
80 | +require_once(dirname(__FILE__).'hook/event/post/publish.php'); |
|
81 | +require_once(dirname(__FILE__).'hook/event/user/register.php'); |
|
82 | +require_once(dirname(__FILE__).'hook/event/user/visit.php'); |
|
83 | +require_once(dirname(__FILE__).'hook/eventi.php'); |
|
84 | +require_once(dirname(__FILE__).'hook/events.php'); |
|
85 | +require_once(dirname(__FILE__).'hook/extension.php'); |
|
86 | +require_once(dirname(__FILE__).'hook/extension/conditions.php'); |
|
87 | +require_once(dirname(__FILE__).'hook/extension/periods.php'); |
|
88 | +require_once(dirname(__FILE__).'hook/extension/reversei.php'); |
|
89 | +require_once(dirname(__FILE__).'hook/fire.php'); |
|
90 | +require_once(dirname(__FILE__).'hook/firer.php'); |
|
91 | +require_once(dirname(__FILE__).'hook/firer/reverse.php'); |
|
92 | +require_once(dirname(__FILE__).'hook/fireri.php'); |
|
93 | +require_once(dirname(__FILE__).'hook/hit/logger.php'); |
|
94 | +require_once(dirname(__FILE__).'hook/hit/query.php'); |
|
95 | +require_once(dirname(__FILE__).'hook/reaction.php'); |
|
96 | +require_once(dirname(__FILE__).'hook/reaction/options.php'); |
|
97 | +require_once(dirname(__FILE__).'hook/reaction/store.php'); |
|
98 | +require_once(dirname(__FILE__).'hook/reaction/store/options.php'); |
|
99 | +require_once(dirname(__FILE__).'hook/reaction/store/options/network.php'); |
|
100 | +require_once(dirname(__FILE__).'hook/reaction/storei.php'); |
|
101 | +require_once(dirname(__FILE__).'hook/reaction/validator.php'); |
|
102 | +require_once(dirname(__FILE__).'hook/reactioni.php'); |
|
103 | +require_once(dirname(__FILE__).'hook/reactor.php'); |
|
104 | +require_once(dirname(__FILE__).'hook/reactor/points.php'); |
|
105 | +require_once(dirname(__FILE__).'hook/reactor/reversei.php'); |
|
106 | +require_once(dirname(__FILE__).'hook/retroactive/conditions.php'); |
|
107 | +require_once(dirname(__FILE__).'hook/retroactive/query.php'); |
|
108 | +require_once(dirname(__FILE__).'hook/retroactive/query/modifieri.php'); |
|
109 | +require_once(dirname(__FILE__).'hook/retroactive/queryable.php'); |
|
110 | +require_once(dirname(__FILE__).'hook/retroactive/queryi.php'); |
|
111 | +require_once(dirname(__FILE__).'hook/router.php'); |
|
112 | +require_once(dirname(__FILE__).'hook/settings.php'); |
|
113 | +require_once(dirname(__FILE__).'hook/settingsi.php'); |
|
114 | +require_once(dirname(__FILE__).'hook/validator/exception.php'); |
|
115 | +require_once(dirname(__FILE__).'hooks.php'); |
|
116 | +require_once(dirname(__FILE__).'query/builder/db/mysql.php'); |
|
117 | +require_once(dirname(__FILE__).'spec.php'); |
|
118 | +require_once(dirname(__FILE__).'specedi.php'); |
|
119 | 119 | // } |
120 | 120 | |
121 | 121 | // 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 |