@@ -12,17 +12,17 @@ |
||
12 | 12 | * |
13 | 13 | * @since 1.0.0 |
14 | 14 | */ |
15 | -require_once( dirname( __FILE__ ) . '/includes/functions.php' ); |
|
15 | +require_once(dirname(__FILE__).'/includes/functions.php'); |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * The admin-side actions and filters. |
19 | 19 | * |
20 | 20 | * @since 1.0.0 |
21 | 21 | */ |
22 | -require_once( dirname( __FILE__ ) . '/includes/actions.php' ); |
|
22 | +require_once(dirname(__FILE__).'/includes/actions.php'); |
|
23 | 23 | |
24 | 24 | WordPoints_Class_Autoloader::register_dir( |
25 | - dirname( __FILE__ ) . '/includes/classes' |
|
25 | + dirname(__FILE__).'/includes/classes' |
|
26 | 26 | , 'WordPoints_Admin_' |
27 | 27 | ); |
28 | 28 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array The hook reaction data extracted into an array. |
54 | 54 | */ |
55 | - public static function prepare_hook_reaction( $reaction ) { |
|
55 | + public static function prepare_hook_reaction($reaction) { |
|
56 | 56 | |
57 | 57 | $reactor = $reaction->get_reactor_slug(); |
58 | 58 | |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | |
96 | 96 | add_action( |
97 | 97 | 'wp_ajax_wordpoints_admin_create_hook_reaction' |
98 | - , array( $this, 'create_hook_reaction' ) |
|
98 | + , array($this, 'create_hook_reaction') |
|
99 | 99 | ); |
100 | 100 | |
101 | 101 | add_action( |
102 | 102 | 'wp_ajax_wordpoints_admin_update_hook_reaction' |
103 | - , array( $this, 'update_hook_reaction' ) |
|
103 | + , array($this, 'update_hook_reaction') |
|
104 | 104 | ); |
105 | 105 | |
106 | 106 | add_action( |
107 | 107 | 'wp_ajax_wordpoints_admin_delete_hook_reaction' |
108 | - , array( $this, 'delete_hook_reaction' ) |
|
108 | + , array($this, 'delete_hook_reaction') |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | "wordpoints_create_hook_reaction|{$this->reactor_slug}" |
125 | 125 | ); |
126 | 126 | |
127 | - $reaction = $reactor->reactions->create_reaction( $this->get_data() ); |
|
127 | + $reaction = $reactor->reactions->create_reaction($this->get_data()); |
|
128 | 128 | |
129 | - $this->send_json_result( $reaction, 'create' ); |
|
129 | + $this->send_json_result($reaction, 'create'); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | , $this->get_data() |
151 | 151 | ); |
152 | 152 | |
153 | - $this->send_json_result( $reaction, 'update' ); |
|
153 | + $this->send_json_result($reaction, 'update'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | "wordpoints_delete_hook_reaction|{$this->reactor_slug}|{$reaction->ID}" |
170 | 170 | ); |
171 | 171 | |
172 | - $result = $reactor->reactions->delete_reaction( $reaction->ID ); |
|
172 | + $result = $reactor->reactions->delete_reaction($reaction->ID); |
|
173 | 173 | |
174 | - if ( ! $result ) { |
|
175 | - wp_send_json_error( array( 'message' => __( 'There was an error deleting the reaction. Please try again.', 'wordpoints' ) ) ); |
|
174 | + if ( ! $result) { |
|
175 | + wp_send_json_error(array('message' => __('There was an error deleting the reaction. Please try again.', 'wordpoints'))); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | wp_send_json_success(); |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param string $debug_context Context sent with the message (for debugging). |
195 | 195 | */ |
196 | - private function unexpected_error( $debug_context ) { |
|
196 | + private function unexpected_error($debug_context) { |
|
197 | 197 | |
198 | 198 | wp_send_json_error( |
199 | 199 | array( |
200 | - 'message' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
200 | + 'message' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
201 | 201 | 'debug' => $debug_context, |
202 | 202 | ) |
203 | 203 | ); |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | */ |
214 | 214 | private function verify_user_can() { |
215 | 215 | |
216 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
217 | - wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action. Maybe you have been logged out?', 'wordpoints' ) ) ); |
|
216 | + if ( ! current_user_can('manage_options')) { |
|
217 | + wp_send_json_error(array('message' => __('You do not have permission to perform this action. Maybe you have been logged out?', 'wordpoints'))); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @param string $action The action the nonce should be for. |
229 | 229 | */ |
230 | - private function verify_request( $action ) { |
|
230 | + private function verify_request($action) { |
|
231 | 231 | |
232 | 232 | if ( |
233 | - empty( $_POST['nonce'] ) |
|
234 | - || ! wordpoints_verify_nonce( 'nonce', $action, null, 'post' ) |
|
233 | + empty($_POST['nonce']) |
|
234 | + || ! wordpoints_verify_nonce('nonce', $action, null, 'post') |
|
235 | 235 | ) { |
236 | 236 | wp_send_json_error( |
237 | - array( 'message' => __( 'Your security token for this action has expired. Refresh the page and try again.', 'wordpoints' ) ) |
|
237 | + array('message' => __('Your security token for this action has expired. Refresh the page and try again.', 'wordpoints')) |
|
238 | 238 | ); |
239 | 239 | } |
240 | 240 | } |
@@ -248,16 +248,16 @@ discard block |
||
248 | 248 | */ |
249 | 249 | protected function get_reactor() { |
250 | 250 | |
251 | - if ( ! isset( $_POST['reactor'] ) ) { // WPCS: CSRF OK. |
|
252 | - $this->unexpected_error( 'reactor' ); |
|
251 | + if ( ! isset($_POST['reactor'])) { // WPCS: CSRF OK. |
|
252 | + $this->unexpected_error('reactor'); |
|
253 | 253 | } |
254 | 254 | |
255 | - $reactor_slug = sanitize_key( $_POST['reactor'] ); // WPCS: CSRF OK. |
|
255 | + $reactor_slug = sanitize_key($_POST['reactor']); // WPCS: CSRF OK. |
|
256 | 256 | |
257 | - $reactor = wordpoints_hooks()->reactors->get( $reactor_slug ); |
|
257 | + $reactor = wordpoints_hooks()->reactors->get($reactor_slug); |
|
258 | 258 | |
259 | - if ( ! $reactor instanceof WordPoints_Hook_Reactor ) { |
|
260 | - $this->unexpected_error( 'reactor_invalid' ); |
|
259 | + if ( ! $reactor instanceof WordPoints_Hook_Reactor) { |
|
260 | + $this->unexpected_error('reactor_invalid'); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | $this->reactor_slug = $reactor_slug; |
@@ -275,16 +275,16 @@ discard block |
||
275 | 275 | */ |
276 | 276 | protected function get_reaction() { |
277 | 277 | |
278 | - if ( ! isset( $_POST['id'] ) ) { // WPCS: CSRF OK. |
|
279 | - $this->unexpected_error( 'id' ); |
|
278 | + if ( ! isset($_POST['id'])) { // WPCS: CSRF OK. |
|
279 | + $this->unexpected_error('id'); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | $reaction = $this->reactor->reactions->get_reaction( |
283 | - wordpoints_int( $_POST['id'] ) // WPCS: CSRF OK. |
|
283 | + wordpoints_int($_POST['id']) // WPCS: CSRF OK. |
|
284 | 284 | ); |
285 | 285 | |
286 | - if ( ! $reaction ) { |
|
287 | - wp_send_json_error( array( 'message' => __( 'The reaction ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints' ) ) ); |
|
286 | + if ( ! $reaction) { |
|
287 | + wp_send_json_error(array('message' => __('The reaction ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints'))); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | return $reaction; |
@@ -299,9 +299,9 @@ discard block |
||
299 | 299 | */ |
300 | 300 | protected function get_data() { |
301 | 301 | |
302 | - $data = wp_unslash( $_POST ); // WPCS: CSRF OK. |
|
302 | + $data = wp_unslash($_POST); // WPCS: CSRF OK. |
|
303 | 303 | |
304 | - unset( $data['id'], $data['action'], $data['nonce'], $data['reactor'] ); |
|
304 | + unset($data['id'], $data['action'], $data['nonce'], $data['reactor']); |
|
305 | 305 | |
306 | 306 | return $data; |
307 | 307 | } |
@@ -314,30 +314,30 @@ discard block |
||
314 | 314 | * @param mixed $result The result of the action. |
315 | 315 | * @param string $action The action being performed: 'create' or 'update'. |
316 | 316 | */ |
317 | - private function send_json_result( $result, $action ) { |
|
317 | + private function send_json_result($result, $action) { |
|
318 | 318 | |
319 | - if ( ! $result ) { |
|
319 | + if ( ! $result) { |
|
320 | 320 | |
321 | - if ( 'create' === $action ) { |
|
322 | - $message = __( 'There was an error adding the reaction. Please try again.', 'wordpoints' ); |
|
321 | + if ('create' === $action) { |
|
322 | + $message = __('There was an error adding the reaction. Please try again.', 'wordpoints'); |
|
323 | 323 | } else { |
324 | - $message = __( 'There was an error updating the reaction. Please try again.', 'wordpoints' ); |
|
324 | + $message = __('There was an error updating the reaction. Please try again.', 'wordpoints'); |
|
325 | 325 | } |
326 | 326 | |
327 | - wp_send_json_error( array( 'message' => $message ) ); |
|
327 | + wp_send_json_error(array('message' => $message)); |
|
328 | 328 | |
329 | - } elseif ( $result instanceof WordPoints_Hook_Reaction_Validator ) { |
|
329 | + } elseif ($result instanceof WordPoints_Hook_Reaction_Validator) { |
|
330 | 330 | |
331 | - wp_send_json_error( array( 'errors' => $result->get_errors() ) ); |
|
331 | + wp_send_json_error(array('errors' => $result->get_errors())); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | $data = null; |
335 | 335 | |
336 | - if ( 'create' === $action ) { |
|
337 | - $data = self::prepare_hook_reaction( $result ); |
|
336 | + if ('create' === $action) { |
|
337 | + $data = self::prepare_hook_reaction($result); |
|
338 | 338 | } |
339 | 339 | |
340 | - wp_send_json_success( $data ); |
|
340 | + wp_send_json_success($data); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | 37 | public function get_title() { |
38 | - return __( 'Site', 'wordpoints' ); |
|
38 | + return __('Site', 'wordpoints'); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 |
@@ -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,25 +145,25 @@ 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 | $conditions = $this->conditions_extension->validate_settings( |
166 | - array( 'conditions' => $this->settings['conditions'] ) |
|
166 | + array('conditions' => $this->settings['conditions']) |
|
167 | 167 | , $this->validator |
168 | 168 | , $args |
169 | 169 | ); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @since 1.0.0 |
176 | 176 | */ |
177 | - public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) { |
|
177 | + public function is_met(array $settings, WordPoints_Hook_Event_Args $args) { |
|
178 | 178 | |
179 | 179 | $this->settings = $settings; |
180 | 180 | |
@@ -182,16 +182,16 @@ discard block |
||
182 | 182 | |
183 | 183 | $entities = array(); |
184 | 184 | |
185 | - if ( $arg instanceof WordPoints_Entity_Array ) { |
|
185 | + if ($arg instanceof WordPoints_Entity_Array) { |
|
186 | 186 | |
187 | 187 | $entities = $arg->get_the_entities(); |
188 | 188 | |
189 | - if ( isset( $this->settings['conditions'] ) ) { |
|
190 | - $entities = $this->filter_entities( $entities ); |
|
189 | + if (isset($this->settings['conditions'])) { |
|
190 | + $entities = $this->filter_entities($entities); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | - return $this->check_count( count( $entities ) ); |
|
194 | + return $this->check_count(count($entities)); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -203,20 +203,20 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return WordPoints_Entity[] The entities that matched the sub-conditions. |
205 | 205 | */ |
206 | - protected function filter_entities( $entities ) { |
|
206 | + protected function filter_entities($entities) { |
|
207 | 207 | |
208 | - foreach ( $entities as $index => $entity ) { |
|
208 | + foreach ($entities as $index => $entity) { |
|
209 | 209 | |
210 | - $event_args = new WordPoints_Hook_Event_Args( array() ); |
|
211 | - $event_args->add_entity( $entity ); |
|
210 | + $event_args = new WordPoints_Hook_Event_Args(array()); |
|
211 | + $event_args->add_entity($entity); |
|
212 | 212 | |
213 | 213 | $matches = $this->conditions_extension->conditions_are_met( |
214 | 214 | $this->settings['conditions'] |
215 | 215 | , $event_args |
216 | 216 | ); |
217 | 217 | |
218 | - if ( ! $matches ) { |
|
219 | - unset( $entities[ $index ] ); |
|
218 | + if ( ! $matches) { |
|
219 | + unset($entities[$index]); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return bool Whether the count met the requirements. |
234 | 234 | */ |
235 | - protected function check_count( $count ) { |
|
235 | + protected function check_count($count) { |
|
236 | 236 | |
237 | - if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) { |
|
237 | + if (isset($this->settings['max']) && $count > $this->settings['max']) { |
|
238 | 238 | return false; |
239 | 239 | } |
240 | 240 | |
241 | - if ( isset( $this->settings['min'] ) && $count < $this->settings['min'] ) { |
|
241 | + if (isset($this->settings['min']) && $count < $this->settings['min']) { |
|
242 | 242 | return false; |
243 | 243 | } |
244 | 244 |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | |
43 | 43 | $conditions_data = array(); |
44 | 44 | |
45 | - foreach ( $this->conditions->get_all() as $data_type => $conditions ) { |
|
46 | - foreach ( $conditions as $slug => $condition ) { |
|
45 | + foreach ($this->conditions->get_all() as $data_type => $conditions) { |
|
46 | + foreach ($conditions as $slug => $condition) { |
|
47 | 47 | |
48 | - if ( ! ( $condition instanceof WordPoints_Hook_Condition ) ) { |
|
48 | + if ( ! ($condition instanceof WordPoints_Hook_Condition)) { |
|
49 | 49 | continue; |
50 | 50 | } |
51 | 51 | |
52 | - $conditions_data[ $data_type ][ $slug ] = array( |
|
52 | + $conditions_data[$data_type][$slug] = array( |
|
53 | 53 | 'slug' => $slug, |
54 | 54 | 'data_type' => $data_type, |
55 | 55 | 'title' => $condition->get_title(), |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - return array( 'conditions' => $conditions_data ); |
|
61 | + return array('conditions' => $conditions_data); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -70,31 +70,31 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return array The validated settings. |
72 | 72 | */ |
73 | - protected function validate_conditions( $args ) { |
|
73 | + protected function validate_conditions($args) { |
|
74 | 74 | |
75 | - if ( ! is_array( $args ) ) { |
|
75 | + if ( ! is_array($args)) { |
|
76 | 76 | |
77 | 77 | $this->validator->add_error( |
78 | - __( 'Conditions do not match expected format.', 'wordpoints' ) |
|
78 | + __('Conditions do not match expected format.', 'wordpoints') |
|
79 | 79 | ); |
80 | 80 | |
81 | 81 | return array(); |
82 | 82 | } |
83 | 83 | |
84 | - foreach ( $args as $arg_slug => $sub_args ) { |
|
84 | + foreach ($args as $arg_slug => $sub_args) { |
|
85 | 85 | |
86 | - if ( '_conditions' === $arg_slug ) { |
|
86 | + if ('_conditions' === $arg_slug) { |
|
87 | 87 | |
88 | - $this->validator->push_field( $arg_slug ); |
|
88 | + $this->validator->push_field($arg_slug); |
|
89 | 89 | |
90 | - foreach ( $sub_args as $index => $settings ) { |
|
90 | + foreach ($sub_args as $index => $settings) { |
|
91 | 91 | |
92 | - $this->validator->push_field( $index ); |
|
92 | + $this->validator->push_field($index); |
|
93 | 93 | |
94 | - $condition = $this->validate_condition( $settings ); |
|
94 | + $condition = $this->validate_condition($settings); |
|
95 | 95 | |
96 | - if ( $condition ) { |
|
97 | - $sub_args[ $index ] = $condition; |
|
96 | + if ($condition) { |
|
97 | + $sub_args[$index] = $condition; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $this->validator->pop_field(); |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | |
105 | 105 | } else { |
106 | 106 | |
107 | - if ( ! $this->event_args->descend( $arg_slug ) ) { |
|
107 | + if ( ! $this->event_args->descend($arg_slug)) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | - $sub_args = $this->validate_conditions( $sub_args ); |
|
111 | + $sub_args = $this->validate_conditions($sub_args); |
|
112 | 112 | |
113 | - $args[ $arg_slug ] = $sub_args; |
|
113 | + $args[$arg_slug] = $sub_args; |
|
114 | 114 | |
115 | 115 | $this->event_args->ascend(); |
116 | 116 | } |
117 | 117 | |
118 | - $args[ $arg_slug ] = $sub_args; |
|
118 | + $args[$arg_slug] = $sub_args; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | return $args; |
@@ -131,32 +131,32 @@ discard block |
||
131 | 131 | * @return array|false The validated conditions settings, or false if unable to |
132 | 132 | * validate. |
133 | 133 | */ |
134 | - protected function validate_condition( $settings ) { |
|
134 | + protected function validate_condition($settings) { |
|
135 | 135 | |
136 | - if ( ! isset( $settings['type'] ) ) { |
|
137 | - $this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) ); |
|
136 | + if ( ! isset($settings['type'])) { |
|
137 | + $this->validator->add_error(__('Condition type is missing.', 'wordpoints')); |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $arg = $this->event_args->get_current(); |
142 | 142 | |
143 | - $data_type = $this->get_data_type( $arg ); |
|
143 | + $data_type = $this->get_data_type($arg); |
|
144 | 144 | |
145 | - if ( ! $data_type ) { |
|
145 | + if ( ! $data_type) { |
|
146 | 146 | $this->validator->add_error( |
147 | - __( 'This type of condition does not work for the selected attribute.', 'wordpoints' ) |
|
147 | + __('This type of condition does not work for the selected attribute.', 'wordpoints') |
|
148 | 148 | ); |
149 | 149 | |
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
153 | - $condition = wordpoints_hooks()->conditions->get( $data_type, $settings['type'] ); |
|
153 | + $condition = wordpoints_hooks()->conditions->get($data_type, $settings['type']); |
|
154 | 154 | |
155 | - if ( ! $condition ) { |
|
155 | + if ( ! $condition) { |
|
156 | 156 | |
157 | 157 | $this->validator->add_error( |
158 | 158 | sprintf( |
159 | - __( 'Unknown condition type “%s”.', 'wordpoints' ) |
|
159 | + __('Unknown condition type “%s”.', 'wordpoints') |
|
160 | 160 | , $settings['type'] |
161 | 161 | ) |
162 | 162 | , 'type' |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | - if ( ! isset( $settings['settings'] ) ) { |
|
169 | - $this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) ); |
|
168 | + if ( ! isset($settings['settings'])) { |
|
169 | + $this->validator->add_error(__('Condition settings are missing.', 'wordpoints')); |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | - $this->validator->push_field( 'settings' ); |
|
173 | + $this->validator->push_field('settings'); |
|
174 | 174 | |
175 | 175 | // The condition may call this object's validate_settings() method to |
176 | 176 | // validate some sub-conditions. When that happens, these properties will be |
177 | 177 | // reset, so we need to back up their values and then restore them below. |
178 | - $backup = array( $this->validator, $this->event_args ); |
|
178 | + $backup = array($this->validator, $this->event_args); |
|
179 | 179 | |
180 | 180 | $settings['settings'] = $condition->validate_settings( |
181 | 181 | $arg |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | , $this->validator |
184 | 184 | ); |
185 | 185 | |
186 | - list( $this->validator, $this->event_args ) = $backup; |
|
186 | + list($this->validator, $this->event_args) = $backup; |
|
187 | 187 | |
188 | 188 | $this->validator->pop_field(); |
189 | 189 | |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | WordPoints_Hook_Event_Args $event_args |
199 | 199 | ) { |
200 | 200 | |
201 | - $conditions = $reaction->get_meta( 'conditions' ); |
|
201 | + $conditions = $reaction->get_meta('conditions'); |
|
202 | 202 | |
203 | - if ( $conditions && ! $this->conditions_are_met( $conditions, $event_args ) ) { |
|
203 | + if ($conditions && ! $this->conditions_are_met($conditions, $event_args)) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
@@ -222,35 +222,35 @@ discard block |
||
222 | 222 | WordPoints_Hook_Event_Args $event_args |
223 | 223 | ) { |
224 | 224 | |
225 | - foreach ( $conditions as $arg_slug => $sub_args ) { |
|
225 | + foreach ($conditions as $arg_slug => $sub_args) { |
|
226 | 226 | |
227 | - $event_args->descend( $arg_slug ); |
|
227 | + $event_args->descend($arg_slug); |
|
228 | 228 | |
229 | - if ( isset( $sub_args['_conditions'] ) ) { |
|
229 | + if (isset($sub_args['_conditions'])) { |
|
230 | 230 | |
231 | - foreach ( $sub_args['_conditions'] as $settings ) { |
|
231 | + foreach ($sub_args['_conditions'] as $settings) { |
|
232 | 232 | |
233 | 233 | $condition = $this->conditions->get( |
234 | - $this->get_data_type( $event_args->get_current() ) |
|
234 | + $this->get_data_type($event_args->get_current()) |
|
235 | 235 | , $settings['type'] |
236 | 236 | ); |
237 | 237 | |
238 | - $is_met = $condition->is_met( $settings['settings'], $event_args ); |
|
238 | + $is_met = $condition->is_met($settings['settings'], $event_args); |
|
239 | 239 | |
240 | - if ( ! $is_met ) { |
|
240 | + if ( ! $is_met) { |
|
241 | 241 | $event_args->ascend(); |
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | - unset( $sub_args['_conditions'] ); |
|
246 | + unset($sub_args['_conditions']); |
|
247 | 247 | } |
248 | 248 | |
249 | - $are_met = $this->conditions_are_met( $sub_args, $event_args ); |
|
249 | + $are_met = $this->conditions_are_met($sub_args, $event_args); |
|
250 | 250 | |
251 | 251 | $event_args->ascend(); |
252 | 252 | |
253 | - if ( ! $are_met ) { |
|
253 | + if ( ! $are_met) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | } |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return string|false The data type, or false. |
269 | 269 | */ |
270 | - protected function get_data_type( $arg ) { |
|
270 | + protected function get_data_type($arg) { |
|
271 | 271 | |
272 | - if ( $arg instanceof WordPoints_Entity_Attr ) { |
|
272 | + if ($arg instanceof WordPoints_Entity_Attr) { |
|
273 | 273 | $data_type = $arg->get_data_type(); |
274 | - } elseif ( $arg instanceof WordPoints_Entity_Array ) { |
|
274 | + } elseif ($arg instanceof WordPoints_Entity_Array) { |
|
275 | 275 | $data_type = 'entity_array'; |
276 | - } elseif ( $arg instanceof WordPoints_Entity ) { |
|
276 | + } elseif ($arg instanceof WordPoints_Entity) { |
|
277 | 277 | $data_type = 'entity'; |
278 | 278 | } else { |
279 | 279 | $data_type = false; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function get_title() { |
21 | 21 | |
22 | - return __( 'Upload Media', 'wordpoints' ); |
|
22 | + return __('Upload Media', 'wordpoints'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function get_description() { |
29 | 29 | |
30 | - return __( 'When a file is uploaded to the Media Library.', 'wordpoints' ); |
|
30 | + return __('When a file is uploaded to the Media Library.', 'wordpoints'); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function get_title() { |
38 | 38 | |
39 | - $post_type = get_post_type_object( substr( $this->slug, 5 /* post\ */ ) ); |
|
39 | + $post_type = get_post_type_object(substr($this->slug, 5 /* post\ */)); |
|
40 | 40 | |
41 | - if ( $post_type ) { |
|
41 | + if ($post_type) { |
|
42 | 42 | return $post_type->labels->singular_name; |
43 | 43 | } else { |
44 | 44 | return $this->slug; |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * @since 1.0.0 |
50 | 50 | */ |
51 | - public function user_can_view( $user_id, $id ) { |
|
52 | - return user_can( $user_id, 'read_post', $id ); |
|
51 | + public function user_can_view($user_id, $id) { |
|
52 | + return user_can($user_id, 'read_post', $id); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function get_title() { |
31 | 31 | |
32 | - $taxonomy = get_taxonomy( substr( $this->slug, 5 /* term\ */ ) ); |
|
32 | + $taxonomy = get_taxonomy(substr($this->slug, 5 /* term\ */)); |
|
33 | 33 | |
34 | - if ( $taxonomy ) { |
|
34 | + if ($taxonomy) { |
|
35 | 35 | return $taxonomy->labels->singular_name; |
36 | 36 | } else { |
37 | 37 | return $this->slug; |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * @since 1.0.0 |
43 | 43 | */ |
44 | - public function get_entity( $id ) { |
|
45 | - return get_term( $id, 'taxonomy' ); |
|
44 | + public function get_entity($id) { |
|
45 | + return get_term($id, 'taxonomy'); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function get_title() { |
31 | 31 | |
32 | - $taxonomy = get_taxonomy( substr( $this->slug, 6 /* terms\ */ ) ); |
|
32 | + $taxonomy = get_taxonomy(substr($this->slug, 6 /* terms\ */)); |
|
33 | 33 | |
34 | - if ( $taxonomy ) { |
|
34 | + if ($taxonomy) { |
|
35 | 35 | return $taxonomy->labels->name; |
36 | 36 | } else { |
37 | 37 | return parent::get_title(); |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * @since 1.0.0 |
43 | 43 | */ |
44 | - protected function get_related_entity_ids( WordPoints_Entity $entity ) { |
|
44 | + protected function get_related_entity_ids(WordPoints_Entity $entity) { |
|
45 | 45 | |
46 | 46 | $id = $entity->get_the_id(); |
47 | 47 | |
48 | - $taxonomies = get_object_taxonomies( get_post( $id ) ); |
|
48 | + $taxonomies = get_object_taxonomies(get_post($id)); |
|
49 | 49 | |
50 | - return wp_get_object_terms( $id, $taxonomies, array( 'fields' => 'ids' ) ); |
|
50 | + return wp_get_object_terms($id, $taxonomies, array('fields' => 'ids')); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 |