@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | ) { |
97 | 97 | |
98 | 98 | return 'wordpoints_create_hook_reaction' |
99 | - . '|' . $reactor->get_slug() |
|
100 | - . '|' . wordpoints_hooks()->get_current_mode() |
|
101 | - . '|' . wp_json_encode( $reactor->reactions->get_context_id() ); |
|
99 | + . '|' . $reactor->get_slug() |
|
100 | + . '|' . wordpoints_hooks()->get_current_mode() |
|
101 | + . '|' . wp_json_encode( $reactor->reactions->get_context_id() ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | WordPoints_Hook_ReactionI $reaction |
129 | 129 | ) { |
130 | 130 | return 'wordpoints_update_hook_reaction|' |
131 | - . wp_json_encode( $reaction->get_guid() ); |
|
131 | + . wp_json_encode( $reaction->get_guid() ); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | WordPoints_Hook_ReactionI $reaction |
159 | 159 | ) { |
160 | 160 | return 'wordpoints_delete_hook_reaction|' |
161 | - . wp_json_encode( $reaction->get_guid() ); |
|
161 | + . wp_json_encode( $reaction->get_guid() ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // |
@@ -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( WordPoints_Hook_ReactionI $reaction ) { |
|
55 | + public static function prepare_hook_reaction(WordPoints_Hook_ReactionI $reaction) { |
|
56 | 56 | |
57 | 57 | return array_merge( |
58 | 58 | $reaction->get_all_meta() |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | 'id' => $reaction->ID, |
61 | 61 | 'event' => $reaction->get_event_slug(), |
62 | 62 | 'reactor' => $reaction->get_reactor_slug(), |
63 | - 'nonce' => self::get_update_nonce( $reaction ), |
|
64 | - 'delete_nonce' => self::get_delete_nonce( $reaction ), |
|
63 | + 'nonce' => self::get_update_nonce($reaction), |
|
64 | + 'delete_nonce' => self::get_delete_nonce($reaction), |
|
65 | 65 | ) |
66 | 66 | ); |
67 | 67 | } |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return string A nonce for creating a new reaction to this reactor. |
78 | 78 | */ |
79 | - public static function get_create_nonce( WordPoints_Hook_Reactor $reactor ) { |
|
79 | + public static function get_create_nonce(WordPoints_Hook_Reactor $reactor) { |
|
80 | 80 | |
81 | - return wp_create_nonce( self::get_create_nonce_action( $reactor ) ); |
|
81 | + return wp_create_nonce(self::get_create_nonce_action($reactor)); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | ) { |
97 | 97 | |
98 | 98 | return 'wordpoints_create_hook_reaction' |
99 | - . '|' . $reactor->get_slug() |
|
100 | - . '|' . wordpoints_hooks()->get_current_mode() |
|
101 | - . '|' . wp_json_encode( $reactor->reactions->get_context_id() ); |
|
99 | + . '|'.$reactor->get_slug() |
|
100 | + . '|'.wordpoints_hooks()->get_current_mode() |
|
101 | + . '|'.wp_json_encode($reactor->reactions->get_context_id()); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string A nonce for updating this reaction. |
112 | 112 | */ |
113 | - public static function get_update_nonce( WordPoints_Hook_ReactionI $reaction ) { |
|
113 | + public static function get_update_nonce(WordPoints_Hook_ReactionI $reaction) { |
|
114 | 114 | |
115 | - return wp_create_nonce( self::get_update_nonce_action( $reaction ) ); |
|
115 | + return wp_create_nonce(self::get_update_nonce_action($reaction)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | WordPoints_Hook_ReactionI $reaction |
129 | 129 | ) { |
130 | 130 | return 'wordpoints_update_hook_reaction|' |
131 | - . wp_json_encode( $reaction->get_guid() ); |
|
131 | + . wp_json_encode($reaction->get_guid()); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return string A nonce for deleting this reaction. |
142 | 142 | */ |
143 | - public static function get_delete_nonce( WordPoints_Hook_ReactionI $reaction ) { |
|
143 | + public static function get_delete_nonce(WordPoints_Hook_ReactionI $reaction) { |
|
144 | 144 | |
145 | - return wp_create_nonce( self::get_delete_nonce_action( $reaction ) ); |
|
145 | + return wp_create_nonce(self::get_delete_nonce_action($reaction)); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | WordPoints_Hook_ReactionI $reaction |
159 | 159 | ) { |
160 | 160 | return 'wordpoints_delete_hook_reaction|' |
161 | - . wp_json_encode( $reaction->get_guid() ); |
|
161 | + . wp_json_encode($reaction->get_guid()); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // |
@@ -184,17 +184,17 @@ discard block |
||
184 | 184 | |
185 | 185 | add_action( |
186 | 186 | 'wp_ajax_wordpoints_admin_create_hook_reaction' |
187 | - , array( $this, 'create_hook_reaction' ) |
|
187 | + , array($this, 'create_hook_reaction') |
|
188 | 188 | ); |
189 | 189 | |
190 | 190 | add_action( |
191 | 191 | 'wp_ajax_wordpoints_admin_update_hook_reaction' |
192 | - , array( $this, 'update_hook_reaction' ) |
|
192 | + , array($this, 'update_hook_reaction') |
|
193 | 193 | ); |
194 | 194 | |
195 | 195 | add_action( |
196 | 196 | 'wp_ajax_wordpoints_admin_delete_hook_reaction' |
197 | - , array( $this, 'delete_hook_reaction' ) |
|
197 | + , array($this, 'delete_hook_reaction') |
|
198 | 198 | ); |
199 | 199 | } |
200 | 200 | |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | |
210 | 210 | $reactor = $this->get_reactor(); |
211 | 211 | |
212 | - $this->verify_request( $this->get_create_nonce_action( $reactor ) ); |
|
212 | + $this->verify_request($this->get_create_nonce_action($reactor)); |
|
213 | 213 | |
214 | - $reaction = $reactor->reactions->create_reaction( $this->get_data() ); |
|
214 | + $reaction = $reactor->reactions->create_reaction($this->get_data()); |
|
215 | 215 | |
216 | - $this->send_json_result( $reaction, 'create' ); |
|
216 | + $this->send_json_result($reaction, 'create'); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | $reactor = $this->get_reactor(); |
229 | 229 | $reaction = $this->get_reaction(); |
230 | 230 | |
231 | - $this->verify_request( $this->get_update_nonce_action( $reaction ) ); |
|
231 | + $this->verify_request($this->get_update_nonce_action($reaction)); |
|
232 | 232 | |
233 | 233 | $reaction = $reactor->reactions->update_reaction( |
234 | 234 | $reaction->ID |
235 | 235 | , $this->get_data() |
236 | 236 | ); |
237 | 237 | |
238 | - $this->send_json_result( $reaction, 'update' ); |
|
238 | + $this->send_json_result($reaction, 'update'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -250,12 +250,12 @@ discard block |
||
250 | 250 | $reactor = $this->get_reactor(); |
251 | 251 | $reaction = $this->get_reaction(); |
252 | 252 | |
253 | - $this->verify_request( $this->get_delete_nonce_action( $reaction ) ); |
|
253 | + $this->verify_request($this->get_delete_nonce_action($reaction)); |
|
254 | 254 | |
255 | - $result = $reactor->reactions->delete_reaction( $reaction->ID ); |
|
255 | + $result = $reactor->reactions->delete_reaction($reaction->ID); |
|
256 | 256 | |
257 | - if ( ! $result ) { |
|
258 | - wp_send_json_error( array( 'message' => __( 'There was an error deleting the reaction. Please try again.', 'wordpoints' ) ) ); |
|
257 | + if ( ! $result) { |
|
258 | + wp_send_json_error(array('message' => __('There was an error deleting the reaction. Please try again.', 'wordpoints'))); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | wp_send_json_success(); |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param string $debug_context Context sent with the message (for debugging). |
278 | 278 | */ |
279 | - private function unexpected_error( $debug_context ) { |
|
279 | + private function unexpected_error($debug_context) { |
|
280 | 280 | |
281 | 281 | wp_send_json_error( |
282 | 282 | array( |
283 | - 'message' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
283 | + 'message' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
284 | 284 | 'debug' => $debug_context, |
285 | 285 | ) |
286 | 286 | ); |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | */ |
297 | 297 | private function verify_user_can() { |
298 | 298 | |
299 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
300 | - wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action. Maybe you have been logged out?', 'wordpoints' ) ) ); |
|
299 | + if ( ! current_user_can('manage_options')) { |
|
300 | + wp_send_json_error(array('message' => __('You do not have permission to perform this action. Maybe you have been logged out?', 'wordpoints'))); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @param string $action The action the nonce should be for. |
312 | 312 | */ |
313 | - private function verify_request( $action ) { |
|
313 | + private function verify_request($action) { |
|
314 | 314 | |
315 | 315 | if ( |
316 | - empty( $_POST['nonce'] ) |
|
317 | - || ! wordpoints_verify_nonce( 'nonce', $action, null, 'post' ) |
|
316 | + empty($_POST['nonce']) |
|
317 | + || ! wordpoints_verify_nonce('nonce', $action, null, 'post') |
|
318 | 318 | ) { |
319 | 319 | wp_send_json_error( |
320 | - array( 'message' => __( 'Your security token for this action has expired. Refresh the page and try again.', 'wordpoints' ) ) |
|
320 | + array('message' => __('Your security token for this action has expired. Refresh the page and try again.', 'wordpoints')) |
|
321 | 321 | ); |
322 | 322 | } |
323 | 323 | } |
@@ -331,16 +331,16 @@ discard block |
||
331 | 331 | */ |
332 | 332 | protected function get_reactor() { |
333 | 333 | |
334 | - if ( ! isset( $_POST['reactor'] ) ) { // WPCS: CSRF OK. |
|
335 | - $this->unexpected_error( 'reactor' ); |
|
334 | + if ( ! isset($_POST['reactor'])) { // WPCS: CSRF OK. |
|
335 | + $this->unexpected_error('reactor'); |
|
336 | 336 | } |
337 | 337 | |
338 | - $reactor_slug = sanitize_key( $_POST['reactor'] ); // WPCS: CSRF OK. |
|
338 | + $reactor_slug = sanitize_key($_POST['reactor']); // WPCS: CSRF OK. |
|
339 | 339 | |
340 | - $reactor = wordpoints_hooks()->reactors->get( $reactor_slug ); |
|
340 | + $reactor = wordpoints_hooks()->reactors->get($reactor_slug); |
|
341 | 341 | |
342 | - if ( ! $reactor instanceof WordPoints_Hook_Reactor ) { |
|
343 | - $this->unexpected_error( 'reactor_invalid' ); |
|
342 | + if ( ! $reactor instanceof WordPoints_Hook_Reactor) { |
|
343 | + $this->unexpected_error('reactor_invalid'); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | $this->reactor_slug = $reactor_slug; |
@@ -358,16 +358,16 @@ discard block |
||
358 | 358 | */ |
359 | 359 | protected function get_reaction() { |
360 | 360 | |
361 | - if ( ! isset( $_POST['id'] ) ) { // WPCS: CSRF OK. |
|
362 | - $this->unexpected_error( 'id' ); |
|
361 | + if ( ! isset($_POST['id'])) { // WPCS: CSRF OK. |
|
362 | + $this->unexpected_error('id'); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | $reaction = $this->reactor->reactions->get_reaction( |
366 | - wordpoints_int( $_POST['id'] ) // WPCS: CSRF OK. |
|
366 | + wordpoints_int($_POST['id']) // WPCS: CSRF OK. |
|
367 | 367 | ); |
368 | 368 | |
369 | - if ( ! $reaction ) { |
|
370 | - 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' ) ) ); |
|
369 | + if ( ! $reaction) { |
|
370 | + 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'))); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | return $reaction; |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | */ |
383 | 383 | protected function get_data() { |
384 | 384 | |
385 | - $data = wp_unslash( $_POST ); // WPCS: CSRF OK. |
|
385 | + $data = wp_unslash($_POST); // WPCS: CSRF OK. |
|
386 | 386 | |
387 | - unset( $data['id'], $data['action'], $data['nonce'], $data['reactor'] ); |
|
387 | + unset($data['id'], $data['action'], $data['nonce'], $data['reactor']); |
|
388 | 388 | |
389 | 389 | return $data; |
390 | 390 | } |
@@ -397,30 +397,30 @@ discard block |
||
397 | 397 | * @param mixed $result The result of the action. |
398 | 398 | * @param string $action The action being performed: 'create' or 'update'. |
399 | 399 | */ |
400 | - private function send_json_result( $result, $action ) { |
|
400 | + private function send_json_result($result, $action) { |
|
401 | 401 | |
402 | - if ( ! $result ) { |
|
402 | + if ( ! $result) { |
|
403 | 403 | |
404 | - if ( 'create' === $action ) { |
|
405 | - $message = __( 'There was an error adding the reaction. Please try again.', 'wordpoints' ); |
|
404 | + if ('create' === $action) { |
|
405 | + $message = __('There was an error adding the reaction. Please try again.', 'wordpoints'); |
|
406 | 406 | } else { |
407 | - $message = __( 'There was an error updating the reaction. Please try again.', 'wordpoints' ); |
|
407 | + $message = __('There was an error updating the reaction. Please try again.', 'wordpoints'); |
|
408 | 408 | } |
409 | 409 | |
410 | - wp_send_json_error( array( 'message' => $message ) ); |
|
410 | + wp_send_json_error(array('message' => $message)); |
|
411 | 411 | |
412 | - } elseif ( $result instanceof WordPoints_Hook_Reaction_Validator ) { |
|
412 | + } elseif ($result instanceof WordPoints_Hook_Reaction_Validator) { |
|
413 | 413 | |
414 | - wp_send_json_error( array( 'errors' => $result->get_errors() ) ); |
|
414 | + wp_send_json_error(array('errors' => $result->get_errors())); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | $data = null; |
418 | 418 | |
419 | - if ( 'create' === $action ) { |
|
420 | - $data = self::prepare_hook_reaction( $result ); |
|
419 | + if ('create' === $action) { |
|
420 | + $data = self::prepare_hook_reaction($result); |
|
421 | 421 | } |
422 | 422 | |
423 | - wp_send_json_success( $data ); |
|
423 | + wp_send_json_success($data); |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @since 1.0.0 |
57 | 57 | */ |
58 | 58 | protected function get_title() { |
59 | - return _x( 'Points Types', 'page title', 'wordpoints' ); |
|
59 | + return _x('Points Types', 'page title', 'wordpoints'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | |
67 | 67 | parent::hooks(); |
68 | 68 | |
69 | - add_action( 'add_meta_boxes', array( $this, 'add_points_settings_meta_box' ) ); |
|
70 | - add_action( 'add_meta_boxes', array( $this, 'add_event_meta_boxes' ) ); |
|
69 | + add_action('add_meta_boxes', array($this, 'add_points_settings_meta_box')); |
|
70 | + add_action('add_meta_boxes', array($this, 'add_event_meta_boxes')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function enqueue_scripts() { |
77 | 77 | |
78 | - wp_enqueue_style( 'wordpoints-hooks-admin' ); |
|
78 | + wp_enqueue_style('wordpoints-hooks-admin'); |
|
79 | 79 | |
80 | - wp_enqueue_script( 'postbox' ); |
|
80 | + wp_enqueue_script('postbox'); |
|
81 | 81 | |
82 | 82 | wordpoints_hooks_ui_setup_script_data(); |
83 | 83 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | .addClass( 'closed' ); |
98 | 98 | |
99 | 99 | postboxes.add_postbox_toggles( |
100 | - <?php echo wp_json_encode( $this->id ); ?> |
|
100 | + <?php echo wp_json_encode($this->id); ?> |
|
101 | 101 | ); |
102 | 102 | } ); |
103 | 103 | </script> |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function add_points_settings_meta_box() { |
114 | 114 | |
115 | - if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
115 | + if ( ! current_user_can('manage_wordpoints_points_types')) { |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | |
119 | 119 | add_meta_box( |
120 | 120 | 'settings' |
121 | - , __( 'Settings', 'wordpoints' ) |
|
122 | - , array( $this, 'display_points_settings_meta_box' ) |
|
121 | + , __('Settings', 'wordpoints') |
|
122 | + , array($this, 'display_points_settings_meta_box') |
|
123 | 123 | , $this->id |
124 | 124 | , 'side' |
125 | 125 | , 'default' |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function display_points_settings_meta_box() { |
135 | 135 | |
136 | - if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
136 | + if ( ! current_user_can('manage_wordpoints_points_types')) { |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | |
142 | 142 | $add_new = 0; |
143 | 143 | |
144 | - $points_type = wordpoints_get_points_type( $slug ); |
|
144 | + $points_type = wordpoints_get_points_type($slug); |
|
145 | 145 | |
146 | - if ( ! $points_type ) { |
|
146 | + if ( ! $points_type) { |
|
147 | 147 | |
148 | 148 | $points_type = array(); |
149 | - $add_new = wp_create_nonce( 'wordpoints_add_new_points_type' ); |
|
149 | + $add_new = wp_create_nonce('wordpoints_add_new_points_type'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | $points_type = array_merge( |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | ?> |
162 | 162 | |
163 | 163 | <form method="post"> |
164 | - <?php if ( $slug ) : ?> |
|
164 | + <?php if ($slug) : ?> |
|
165 | 165 | <p> |
166 | 166 | <span class="wordpoints-points-slug"> |
167 | 167 | <em> |
168 | - <?php echo esc_html( sprintf( __( 'Slug: %s', 'wordpoints' ), $slug ) ); ?> |
|
168 | + <?php echo esc_html(sprintf(__('Slug: %s', 'wordpoints'), $slug)); ?> |
|
169 | 169 | </em> |
170 | 170 | </span> |
171 | 171 | </p> |
172 | - <?php wp_nonce_field( "wordpoints_update_points_type-$slug", 'update_points_type' ); ?> |
|
172 | + <?php wp_nonce_field("wordpoints_update_points_type-$slug", 'update_points_type'); ?> |
|
173 | 173 | <?php endif; ?> |
174 | 174 | |
175 | 175 | <?php |
@@ -183,45 +183,45 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param string $points_type The slug of the points type. |
185 | 185 | */ |
186 | - do_action( 'wordpoints_points_type_form_top', $slug ); |
|
186 | + do_action('wordpoints_points_type_form_top', $slug); |
|
187 | 187 | |
188 | - if ( $add_new ) { |
|
188 | + if ($add_new) { |
|
189 | 189 | |
190 | 190 | // Mark the prefix and suffix optional on the add new form. |
191 | - $prefix = _x( 'Prefix (optional):', 'points type', 'wordpoints' ); |
|
192 | - $suffix = _x( 'Suffix (optional):', 'points type', 'wordpoints' ); |
|
191 | + $prefix = _x('Prefix (optional):', 'points type', 'wordpoints'); |
|
192 | + $suffix = _x('Suffix (optional):', 'points type', 'wordpoints'); |
|
193 | 193 | |
194 | 194 | } else { |
195 | 195 | |
196 | - $prefix = _x( 'Prefix:', 'points type', 'wordpoints' ); |
|
197 | - $suffix = _x( 'Suffix:', 'points type', 'wordpoints' ); |
|
196 | + $prefix = _x('Prefix:', 'points type', 'wordpoints'); |
|
197 | + $suffix = _x('Suffix:', 'points type', 'wordpoints'); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | ?> |
201 | 201 | |
202 | 202 | <p> |
203 | 203 | <label |
204 | - for="points-name-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html_x( 'Name:', 'points type', 'wordpoints' ); ?></label> |
|
204 | + for="points-name-<?php echo esc_attr($slug); ?>"><?php echo esc_html_x('Name:', 'points type', 'wordpoints'); ?></label> |
|
205 | 205 | <input class="widefat" type="text" |
206 | - id="points-name-<?php echo esc_attr( $slug ); ?>" |
|
206 | + id="points-name-<?php echo esc_attr($slug); ?>" |
|
207 | 207 | name="points-name" |
208 | - value="<?php echo esc_attr( $points_type['name'] ); ?>"/> |
|
208 | + value="<?php echo esc_attr($points_type['name']); ?>"/> |
|
209 | 209 | </p> |
210 | 210 | <p> |
211 | 211 | <label |
212 | - for="points-prefix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $prefix ); ?></label> |
|
212 | + for="points-prefix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($prefix); ?></label> |
|
213 | 213 | <input class="widefat" type="text" |
214 | - id="points-prefix-<?php echo esc_attr( $slug ); ?>" |
|
214 | + id="points-prefix-<?php echo esc_attr($slug); ?>" |
|
215 | 215 | name="points-prefix" |
216 | - value="<?php echo esc_attr( $points_type['prefix'] ); ?>"/> |
|
216 | + value="<?php echo esc_attr($points_type['prefix']); ?>"/> |
|
217 | 217 | </p> |
218 | 218 | <p> |
219 | 219 | <label |
220 | - for="points-suffix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $suffix ); ?></label> |
|
220 | + for="points-suffix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($suffix); ?></label> |
|
221 | 221 | <input class="widefat" type="text" |
222 | - id="points-suffix-<?php echo esc_attr( $slug ); ?>" |
|
222 | + id="points-suffix-<?php echo esc_attr($slug); ?>" |
|
223 | 223 | name="points-suffix" |
224 | - value="<?php echo esc_attr( $points_type['suffix'] ); ?>"/> |
|
224 | + value="<?php echo esc_attr($points_type['suffix']); ?>"/> |
|
225 | 225 | </p> |
226 | 226 | |
227 | 227 | <?php |
@@ -235,28 +235,28 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @param string $points_type The slug of the points type. |
237 | 237 | */ |
238 | - do_action( 'wordpoints_points_type_form_bottom', $slug ); |
|
238 | + do_action('wordpoints_points_type_form_bottom', $slug); |
|
239 | 239 | |
240 | 240 | ?> |
241 | 241 | |
242 | 242 | <input type="hidden" name="points-slug" |
243 | - value="<?php echo esc_attr( $slug ); ?>"/> |
|
243 | + value="<?php echo esc_attr($slug); ?>"/> |
|
244 | 244 | <input type="hidden" name="add_new" class="add_new" |
245 | - value="<?php echo esc_attr( $add_new ); ?>"/> |
|
245 | + value="<?php echo esc_attr($add_new); ?>"/> |
|
246 | 246 | |
247 | 247 | <div class="hook-control-actions"> |
248 | 248 | <div class="alignleft"> |
249 | 249 | <?php |
250 | 250 | |
251 | - if ( ! $add_new ) { |
|
252 | - wp_nonce_field( "wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce' ); |
|
253 | - submit_button( _x( 'Delete', 'points type', 'wordpoints' ), 'delete', 'delete-points-type', false, array( 'id' => "delete_points_type-{$slug}" ) ); |
|
251 | + if ( ! $add_new) { |
|
252 | + wp_nonce_field("wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce'); |
|
253 | + submit_button(_x('Delete', 'points type', 'wordpoints'), 'delete', 'delete-points-type', false, array('id' => "delete_points_type-{$slug}")); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | ?> |
257 | 257 | </div> |
258 | 258 | <div class="alignright"> |
259 | - <?php submit_button( _x( 'Save', 'points type', 'wordpoints' ), 'button-primary hook-control-save right', 'save-points-type', false, array( 'id' => "points-{$slug}-save" ) ); ?> |
|
259 | + <?php submit_button(_x('Save', 'points type', 'wordpoints'), 'button-primary hook-control-save right', 'save-points-type', false, array('id' => "points-{$slug}-save")); ?> |
|
260 | 260 | <span class="spinner"></span> |
261 | 261 | </div> |
262 | 262 | <br class="clear"/> |
@@ -273,17 +273,17 @@ discard block |
||
273 | 273 | */ |
274 | 274 | public function add_event_meta_boxes() { |
275 | 275 | |
276 | - if ( ! $this->current_points_type ) { |
|
276 | + if ( ! $this->current_points_type) { |
|
277 | 277 | return; |
278 | 278 | } |
279 | 279 | |
280 | 280 | /** @var WordPoints_Hook_EventI $event */ |
281 | - foreach ( $this->hooks->events->get_all() as $slug => $event ) { |
|
281 | + foreach ($this->hooks->events->get_all() as $slug => $event) { |
|
282 | 282 | |
283 | 283 | add_meta_box( |
284 | 284 | "{$this->current_points_type}-{$slug}" |
285 | 285 | , $event->get_title() |
286 | - , array( $this, 'display_event_meta_box' ) |
|
286 | + , array($this, 'display_event_meta_box') |
|
287 | 287 | , $this->id |
288 | 288 | , 'events' |
289 | 289 | , 'default' |
@@ -304,55 +304,55 @@ discard block |
||
304 | 304 | * @param array $points_type The points type this meta-box relates to. |
305 | 305 | * @param array $meta_box The data the meta-box was created with. |
306 | 306 | */ |
307 | - public function display_event_meta_box( $points_type, $meta_box ) { |
|
307 | + public function display_event_meta_box($points_type, $meta_box) { |
|
308 | 308 | |
309 | 309 | $event_slug = $meta_box['args']['slug']; |
310 | 310 | |
311 | 311 | /** @var WordPoints_Hook_Reactor $points_reactor */ |
312 | - $points_reactor = $this->hooks->reactors->get( 'points' ); |
|
312 | + $points_reactor = $this->hooks->reactors->get('points'); |
|
313 | 313 | |
314 | 314 | $data = array(); |
315 | 315 | |
316 | - foreach ( $points_reactor->reactions->get_reactions_to_event( $event_slug ) as $id => $reaction ) { |
|
317 | - if ( $reaction->get_meta( 'points_type' ) === $this->current_points_type ) { |
|
316 | + foreach ($points_reactor->reactions->get_reactions_to_event($event_slug) as $id => $reaction) { |
|
317 | + if ($reaction->get_meta('points_type') === $this->current_points_type) { |
|
318 | 318 | $data[] = WordPoints_Admin_Ajax_Hooks::prepare_hook_reaction( |
319 | 319 | $reaction |
320 | 320 | ); |
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | - $args = $this->hooks->events->args->get_children( $event_slug ); |
|
324 | + $args = $this->hooks->events->args->get_children($event_slug); |
|
325 | 325 | |
326 | - $event_data = array( 'args' => array() ); |
|
326 | + $event_data = array('args' => array()); |
|
327 | 327 | |
328 | - foreach ( $args as $slug => $arg ) { |
|
328 | + foreach ($args as $slug => $arg) { |
|
329 | 329 | |
330 | - $event_data['args'][ $slug ] = array( |
|
330 | + $event_data['args'][$slug] = array( |
|
331 | 331 | 'slug' => $slug, |
332 | 332 | ); |
333 | 333 | |
334 | - if ( $arg instanceof WordPoints_Hook_Arg ) { |
|
335 | - $event_data['args'][ $slug ]['title'] = $arg->get_title(); |
|
336 | - $event_data['args'][ $slug ]['is_stateful'] = $arg->is_stateful(); |
|
334 | + if ($arg instanceof WordPoints_Hook_Arg) { |
|
335 | + $event_data['args'][$slug]['title'] = $arg->get_title(); |
|
336 | + $event_data['args'][$slug]['is_stateful'] = $arg->is_stateful(); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | ?> |
341 | 341 | |
342 | 342 | <script> |
343 | - WordPointsHooksAdminData.events[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $event_data ); ?>; |
|
344 | - WordPointsHooksAdminData.reactions[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $data ); ?>; |
|
343 | + WordPointsHooksAdminData.events[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($event_data); ?>; |
|
344 | + WordPointsHooksAdminData.reactions[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($data); ?>; |
|
345 | 345 | </script> |
346 | 346 | |
347 | 347 | <div class="wordpoints-hook-reaction-group-container"> |
348 | 348 | <p class="description wordpoints-hook-reaction-group-description"> |
349 | - <?php echo esc_html( $meta_box['args']['event']->get_description() ); ?> |
|
349 | + <?php echo esc_html($meta_box['args']['event']->get_description()); ?> |
|
350 | 350 | </p> |
351 | 351 | |
352 | 352 | <div class="wordpoints-hook-reaction-group" |
353 | - data-wordpoints-hooks-hook-event="<?php echo esc_attr( $event_slug ); ?>" |
|
354 | - data-wordpoints-hooks-points-type="<?php echo esc_attr( $this->current_points_type ); ?>" |
|
355 | - data-wordpoints-hooks-create-nonce="<?php echo esc_attr( WordPoints_Admin_Ajax_Hooks::get_create_nonce( $points_reactor ) ); ?>" |
|
353 | + data-wordpoints-hooks-hook-event="<?php echo esc_attr($event_slug); ?>" |
|
354 | + data-wordpoints-hooks-points-type="<?php echo esc_attr($this->current_points_type); ?>" |
|
355 | + data-wordpoints-hooks-create-nonce="<?php echo esc_attr(WordPoints_Admin_Ajax_Hooks::get_create_nonce($points_reactor)); ?>" |
|
356 | 356 | data-wordpoints-hooks-reactor="points"> |
357 | 357 | </div> |
358 | 358 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | <div class="controls"> |
368 | 368 | <button type="button" class="button-primary add-reaction"> |
369 | - <?php esc_html_e( 'Add New', 'wordpoints' ); ?> |
|
369 | + <?php esc_html_e('Add New', 'wordpoints'); ?> |
|
370 | 370 | </button> |
371 | 371 | </div> |
372 | 372 | </div> |
@@ -386,19 +386,19 @@ discard block |
||
386 | 386 | // Show a tab for each points type. |
387 | 387 | $tabs = array(); |
388 | 388 | |
389 | - foreach ( $points_types as $slug => $settings ) { |
|
390 | - $tabs[ $slug ] = $settings['name']; |
|
389 | + foreach ($points_types as $slug => $settings) { |
|
390 | + $tabs[$slug] = $settings['name']; |
|
391 | 391 | } |
392 | 392 | |
393 | - $tabs['add-new'] = __( 'Add New', 'wordpoints' ); |
|
393 | + $tabs['add-new'] = __('Add New', 'wordpoints'); |
|
394 | 394 | |
395 | - $tab = wordpoints_admin_get_current_tab( $tabs ); |
|
395 | + $tab = wordpoints_admin_get_current_tab($tabs); |
|
396 | 396 | |
397 | - if ( 'add-new' !== $tab ) { |
|
397 | + if ('add-new' !== $tab) { |
|
398 | 398 | $this->current_points_type = $tab; |
399 | 399 | } |
400 | 400 | |
401 | - do_action( 'add_meta_boxes', $this->id ); |
|
401 | + do_action('add_meta_boxes', $this->id); |
|
402 | 402 | |
403 | 403 | $this->tabs = $tabs; |
404 | 404 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | public function save_points_type() { |
412 | 412 | |
413 | - if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
413 | + if ( ! current_user_can('manage_wordpoints_points_types')) { |
|
414 | 414 | return; |
415 | 415 | } |
416 | 416 | |
@@ -425,43 +425,43 @@ discard block |
||
425 | 425 | |
426 | 426 | $settings = array(); |
427 | 427 | |
428 | - $settings['name'] = trim( sanitize_text_field( wp_unslash( $_POST['points-name'] ) ) ); // WPCS: CSRF OK |
|
429 | - $settings['prefix'] = ltrim( sanitize_text_field( wp_unslash( $_POST['points-prefix'] ) ) ); // WPCS: CSRF OK |
|
430 | - $settings['suffix'] = rtrim( sanitize_text_field( wp_unslash( $_POST['points-suffix'] ) ) ); // WPCS: CSRF OK |
|
428 | + $settings['name'] = trim(sanitize_text_field(wp_unslash($_POST['points-name']))); // WPCS: CSRF OK |
|
429 | + $settings['prefix'] = ltrim(sanitize_text_field(wp_unslash($_POST['points-prefix']))); // WPCS: CSRF OK |
|
430 | + $settings['suffix'] = rtrim(sanitize_text_field(wp_unslash($_POST['points-suffix']))); // WPCS: CSRF OK |
|
431 | 431 | |
432 | 432 | if ( |
433 | - isset( $_POST['points-slug'] ) |
|
434 | - && wordpoints_verify_nonce( 'update_points_type', 'wordpoints_update_points_type-%s', array( 'points-slug' ), 'post' ) |
|
433 | + isset($_POST['points-slug']) |
|
434 | + && wordpoints_verify_nonce('update_points_type', 'wordpoints_update_points_type-%s', array('points-slug'), 'post') |
|
435 | 435 | ) { |
436 | 436 | |
437 | 437 | // - We are updating an existing points type. |
438 | 438 | |
439 | - $points_type = sanitize_key( $_POST['points-slug'] ); |
|
439 | + $points_type = sanitize_key($_POST['points-slug']); |
|
440 | 440 | |
441 | - $old_settings = wordpoints_get_points_type( $points_type ); |
|
441 | + $old_settings = wordpoints_get_points_type($points_type); |
|
442 | 442 | |
443 | - if ( false === $old_settings ) { |
|
443 | + if (false === $old_settings) { |
|
444 | 444 | |
445 | 445 | add_settings_error( |
446 | 446 | '' |
447 | 447 | , 'wordpoints_points_type_update' |
448 | - , __( 'Error: failed updating points type.', 'wordpoints' ) |
|
448 | + , __('Error: failed updating points type.', 'wordpoints') |
|
449 | 449 | , 'updated' |
450 | 450 | ); |
451 | 451 | |
452 | 452 | return; |
453 | 453 | } |
454 | 454 | |
455 | - if ( is_array( $old_settings ) ) { |
|
456 | - $settings = array_merge( $old_settings, $settings ); |
|
455 | + if (is_array($old_settings)) { |
|
456 | + $settings = array_merge($old_settings, $settings); |
|
457 | 457 | } |
458 | 458 | |
459 | - if ( ! wordpoints_update_points_type( $points_type, $settings ) ) { |
|
459 | + if ( ! wordpoints_update_points_type($points_type, $settings)) { |
|
460 | 460 | |
461 | 461 | add_settings_error( |
462 | 462 | '' |
463 | 463 | , 'wordpoints_points_type_update' |
464 | - , __( 'Error: failed updating points type.', 'wordpoints' ) |
|
464 | + , __('Error: failed updating points type.', 'wordpoints') |
|
465 | 465 | , 'updated' |
466 | 466 | ); |
467 | 467 | |
@@ -470,23 +470,23 @@ discard block |
||
470 | 470 | add_settings_error( |
471 | 471 | '' |
472 | 472 | , 'wordpoints_points_type_update' |
473 | - , __( 'Points type updated.', 'wordpoints' ) |
|
473 | + , __('Points type updated.', 'wordpoints') |
|
474 | 474 | , 'updated' |
475 | 475 | ); |
476 | 476 | } |
477 | 477 | |
478 | - } elseif ( wordpoints_verify_nonce( 'add_new', 'wordpoints_add_new_points_type', null, 'post' ) ) { |
|
478 | + } elseif (wordpoints_verify_nonce('add_new', 'wordpoints_add_new_points_type', null, 'post')) { |
|
479 | 479 | |
480 | 480 | // - We are creating a new points type. |
481 | 481 | |
482 | - $slug = wordpoints_add_points_type( $settings ); |
|
482 | + $slug = wordpoints_add_points_type($settings); |
|
483 | 483 | |
484 | - if ( ! $slug ) { |
|
484 | + if ( ! $slug) { |
|
485 | 485 | |
486 | 486 | add_settings_error( |
487 | 487 | '' |
488 | 488 | , 'wordpoints_points_type_create' |
489 | - , __( 'Please choose a unique name for this points type.', 'wordpoints' ) |
|
489 | + , __('Please choose a unique name for this points type.', 'wordpoints') |
|
490 | 490 | ); |
491 | 491 | |
492 | 492 | } else { |
@@ -496,26 +496,26 @@ discard block |
||
496 | 496 | add_settings_error( |
497 | 497 | '' |
498 | 498 | , 'wordpoints_points_type_create' |
499 | - , __( 'Points type created.', 'wordpoints' ) |
|
499 | + , __('Points type created.', 'wordpoints') |
|
500 | 500 | , 'updated' |
501 | 501 | ); |
502 | 502 | } |
503 | 503 | } |
504 | 504 | |
505 | 505 | } elseif ( |
506 | - ! empty( $_POST['delete-points-type'] ) |
|
507 | - && isset( $_POST['points-slug'] ) |
|
508 | - && wordpoints_verify_nonce( 'delete-points-type-nonce', 'wordpoints_delete_points_type-%s', array( 'points-slug' ), 'post' ) |
|
506 | + ! empty($_POST['delete-points-type']) |
|
507 | + && isset($_POST['points-slug']) |
|
508 | + && wordpoints_verify_nonce('delete-points-type-nonce', 'wordpoints_delete_points_type-%s', array('points-slug'), 'post') |
|
509 | 509 | ) { |
510 | 510 | |
511 | 511 | // - We are deleting a points type. |
512 | 512 | |
513 | - if ( wordpoints_delete_points_type( sanitize_key( $_POST['points-slug'] ) ) ) { |
|
513 | + if (wordpoints_delete_points_type(sanitize_key($_POST['points-slug']))) { |
|
514 | 514 | |
515 | 515 | add_settings_error( |
516 | 516 | '' |
517 | 517 | , 'wordpoints_points_type_delete' |
518 | - , __( 'Points type deleted.', 'wordpoints' ) |
|
518 | + , __('Points type deleted.', 'wordpoints') |
|
519 | 519 | , 'updated' |
520 | 520 | ); |
521 | 521 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | add_settings_error( |
525 | 525 | '' |
526 | 526 | , 'wordpoints_points_type_delete' |
527 | - , __( 'Error while deleting.', 'wordpoints' ) |
|
527 | + , __('Error while deleting.', 'wordpoints') |
|
528 | 528 | ); |
529 | 529 | } |
530 | 530 | } |
@@ -540,25 +540,25 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @since 1.0.0 |
542 | 542 | */ |
543 | - do_action( 'wordpoints_admin_points_events_head' ); |
|
543 | + do_action('wordpoints_admin_points_events_head'); |
|
544 | 544 | |
545 | - if ( is_network_admin() ) { |
|
546 | - $title = __( 'Network Events', 'wordpoints' ); |
|
547 | - $description = __( 'Award points when various events happen on this network.', 'wordpoints' ); |
|
545 | + if (is_network_admin()) { |
|
546 | + $title = __('Network Events', 'wordpoints'); |
|
547 | + $description = __('Award points when various events happen on this network.', 'wordpoints'); |
|
548 | 548 | } else { |
549 | - $title = __( 'Events', 'wordpoints' ); |
|
550 | - $description = __( 'Award points when various events happen on this site.', 'wordpoints' ); |
|
549 | + $title = __('Events', 'wordpoints'); |
|
550 | + $description = __('Award points when various events happen on this site.', 'wordpoints'); |
|
551 | 551 | } |
552 | 552 | |
553 | - $points_type = wordpoints_get_points_type( $this->current_points_type ); |
|
553 | + $points_type = wordpoints_get_points_type($this->current_points_type); |
|
554 | 554 | |
555 | 555 | ?> |
556 | 556 | |
557 | 557 | <div class="wordpoints-points-type-meta-box-wrap"> |
558 | 558 | |
559 | 559 | <form> |
560 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
561 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
560 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
561 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
562 | 562 | </form> |
563 | 563 | |
564 | 564 | <div id="poststuff"> |
@@ -566,17 +566,17 @@ discard block |
||
566 | 566 | <div id="post-body" class="metabox-holder columns-<?php echo 1 === (int) get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
567 | 567 | |
568 | 568 | <div id="postbox-container-1" class="postbox-container"> |
569 | - <?php do_meta_boxes( $this->id, 'side', $points_type ); ?> |
|
569 | + <?php do_meta_boxes($this->id, 'side', $points_type); ?> |
|
570 | 570 | </div> |
571 | 571 | |
572 | - <?php if ( isset( $this->current_points_type ) ) : ?> |
|
572 | + <?php if (isset($this->current_points_type)) : ?> |
|
573 | 573 | <div class="wordpoints-hook-events-heading"> |
574 | - <h2><?php echo esc_html( $title ); ?></h2> |
|
575 | - <p class="description"><?php echo esc_html( $description ); ?></p> |
|
574 | + <h2><?php echo esc_html($title); ?></h2> |
|
575 | + <p class="description"><?php echo esc_html($description); ?></p> |
|
576 | 576 | </div> |
577 | 577 | |
578 | 578 | <div id="postbox-container-2" class="postbox-container"> |
579 | - <?php do_meta_boxes( $this->id, 'events', $points_type ); ?> |
|
579 | + <?php do_meta_boxes($this->id, 'events', $points_type); ?> |
|
580 | 580 | </div> |
581 | 581 | <?php endif; ?> |
582 | 582 | |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | * |
596 | 596 | * @since 1.0.0 |
597 | 597 | */ |
598 | - do_action( 'wordpoints_admin_points_events_foot' ); |
|
598 | + do_action('wordpoints_admin_points_events_foot'); |
|
599 | 599 | } |
600 | 600 | } |
601 | 601 |