@@ -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( wp_create_nonce( 'wordpoints_create_hook_reaction|points' ) ); ?>" |
|
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(wp_create_nonce('wordpoints_create_hook_reaction|points')); ?>" |
|
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 |
@@ -54,20 +54,20 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @param WordPoints_Hook_Arg[] $args The hook args. |
56 | 56 | */ |
57 | - public function __construct( array $args ) { |
|
57 | + public function __construct(array $args) { |
|
58 | 58 | |
59 | 59 | parent::__construct(); |
60 | 60 | |
61 | - foreach ( $args as $arg ) { |
|
61 | + foreach ($args as $arg) { |
|
62 | 62 | |
63 | 63 | $entity = $arg->get_entity(); |
64 | 64 | |
65 | - if ( $entity instanceof WordPoints_Entity ) { |
|
66 | - $this->entities[ $arg->get_slug() ] = $entity; |
|
65 | + if ($entity instanceof WordPoints_Entity) { |
|
66 | + $this->entities[$arg->get_slug()] = $entity; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // If any of the args aren't stateful the event isn't repeatable. |
70 | - if ( $this->is_repeatable && ! $arg->is_stateful() ) { |
|
70 | + if ($this->is_repeatable && ! $arg->is_stateful()) { |
|
71 | 71 | $this->is_repeatable = false; |
72 | 72 | } |
73 | 73 | } |
@@ -99,54 +99,54 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param WordPoints_Hook_Reaction_Validator $validator The validator. |
101 | 101 | */ |
102 | - public function set_validator( WordPoints_Hook_Reaction_Validator $validator ) { |
|
102 | + public function set_validator(WordPoints_Hook_Reaction_Validator $validator) { |
|
103 | 103 | $this->validator = $validator; |
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @since 1.0.0 |
108 | 108 | */ |
109 | - public function descend( $child_slug ) { |
|
109 | + public function descend($child_slug) { |
|
110 | 110 | |
111 | - $result = parent::descend( $child_slug ); |
|
111 | + $result = parent::descend($child_slug); |
|
112 | 112 | |
113 | 113 | // Just in case no validator has been set. |
114 | - if ( ! $this->validator ) { |
|
114 | + if ( ! $this->validator) { |
|
115 | 115 | return $result; |
116 | 116 | } |
117 | 117 | |
118 | - if ( ! $result ) { |
|
118 | + if ( ! $result) { |
|
119 | 119 | |
120 | - if ( ! isset( $this->current ) ) { |
|
120 | + if ( ! isset($this->current)) { |
|
121 | 121 | |
122 | 122 | $this->validator->add_error( |
123 | 123 | sprintf( |
124 | - __( 'The %s arg is not registered for this event.', 'wordpoints' ) // TODO message |
|
124 | + __('The %s arg is not registered for this event.', 'wordpoints') // TODO message |
|
125 | 125 | , $child_slug |
126 | 126 | ) |
127 | 127 | ); |
128 | 128 | |
129 | - } elseif ( ! ( $this->current instanceof WordPoints_Entity_ParentI ) ) { |
|
129 | + } elseif ( ! ($this->current instanceof WordPoints_Entity_ParentI)) { |
|
130 | 130 | |
131 | 131 | $this->validator->add_error( |
132 | - __( 'Cannot get descendant of %s: not a parent.', 'wordpoints' ) // TODO message |
|
132 | + __('Cannot get descendant of %s: not a parent.', 'wordpoints') // TODO message |
|
133 | 133 | ); |
134 | 134 | |
135 | 135 | } else { |
136 | 136 | |
137 | - $child_arg = $this->current->get_child( $child_slug ); |
|
137 | + $child_arg = $this->current->get_child($child_slug); |
|
138 | 138 | |
139 | - if ( ! $child_arg ) { |
|
139 | + if ( ! $child_arg) { |
|
140 | 140 | $this->validator->add_error( |
141 | - __( '%s does not have a child "%s".', 'wordpoints' ) // TODO message |
|
141 | + __('%s does not have a child "%s".', 'wordpoints') // TODO message |
|
142 | 142 | , $this->push_on_descend ? $child_slug : null |
143 | 143 | ); |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - } elseif ( $this->push_on_descend ) { |
|
147 | + } elseif ($this->push_on_descend) { |
|
148 | 148 | |
149 | - $this->validator->push_field( $child_slug ); |
|
149 | + $this->validator->push_field($child_slug); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $result; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | $ascended = parent::ascend(); |
161 | 161 | |
162 | - if ( $ascended && $this->validator ) { |
|
162 | + if ($ascended && $this->validator) { |
|
163 | 163 | $this->validator->pop_field(); |
164 | 164 | } |
165 | 165 | |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | /** |
170 | 170 | * @since 1.0.0 |
171 | 171 | */ |
172 | - public function get_from_hierarchy( array $hierarchy ) { |
|
172 | + public function get_from_hierarchy(array $hierarchy) { |
|
173 | 173 | |
174 | 174 | $this->push_on_descend = false; |
175 | - $entityish = parent::get_from_hierarchy( $hierarchy ); |
|
175 | + $entityish = parent::get_from_hierarchy($hierarchy); |
|
176 | 176 | $this->push_on_descend = true; |
177 | 177 | |
178 | 178 | return $entityish; |
@@ -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,13 +39,13 @@ 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 | 47 | // TODO this should be supplied per-reactor |
48 | - 'label' => __( 'Award each user no more than once per:', 'wordpoints' ), |
|
48 | + 'label' => __('Award each user no more than once per:', 'wordpoints'), |
|
49 | 49 | ), |
50 | 50 | ); |
51 | 51 | } |
@@ -59,25 +59,25 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return array The validated periods. |
61 | 61 | */ |
62 | - protected function validate_periods( $periods ) { |
|
62 | + protected function validate_periods($periods) { |
|
63 | 63 | |
64 | - if ( ! is_array( $periods ) ) { |
|
64 | + if ( ! is_array($periods)) { |
|
65 | 65 | |
66 | 66 | $this->validator->add_error( |
67 | - __( 'Periods do not match expected format.', 'wordpoints' ) |
|
67 | + __('Periods do not match expected format.', 'wordpoints') |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | return array(); |
71 | 71 | } |
72 | 72 | |
73 | - foreach ( $periods as $index => $period ) { |
|
73 | + foreach ($periods as $index => $period) { |
|
74 | 74 | |
75 | - $this->validator->push_field( $index ); |
|
75 | + $this->validator->push_field($index); |
|
76 | 76 | |
77 | - $period = $this->validate_period( $period ); |
|
77 | + $period = $this->validate_period($period); |
|
78 | 78 | |
79 | - if ( $period ) { |
|
80 | - $periods[ $index ] = $period; |
|
79 | + if ($period) { |
|
80 | + $periods[$index] = $period; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $this->validator->pop_field(); |
@@ -95,30 +95,30 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return array|false The validated period, or false if invalid. |
97 | 97 | */ |
98 | - protected function validate_period( $period ) { |
|
98 | + protected function validate_period($period) { |
|
99 | 99 | |
100 | - if ( ! is_array( $period ) ) { |
|
100 | + if ( ! is_array($period)) { |
|
101 | 101 | $this->validator->add_error( |
102 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
102 | + __('Period does not match expected format.', 'wordpoints') |
|
103 | 103 | ); |
104 | 104 | |
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
108 | - if ( isset( $period['args'] ) ) { |
|
109 | - $this->validate_period_args( $period['args'] ); |
|
108 | + if (isset($period['args'])) { |
|
109 | + $this->validate_period_args($period['args']); |
|
110 | 110 | } |
111 | 111 | |
112 | - if ( ! isset( $period['length'] ) ) { |
|
112 | + if ( ! isset($period['length'])) { |
|
113 | 113 | |
114 | 114 | $this->validator->add_error( |
115 | - __( 'Period length setting is missing.', 'wordpoints' ) |
|
115 | + __('Period length setting is missing.', 'wordpoints') |
|
116 | 116 | ); |
117 | 117 | |
118 | - } elseif ( false === wordpoints_posint( $period['length'] ) ) { |
|
118 | + } elseif (false === wordpoints_posint($period['length'])) { |
|
119 | 119 | |
120 | 120 | $this->validator->add_error( |
121 | - __( 'Period length must be a positive integer.', 'wordpoints' ) |
|
121 | + __('Period length must be a positive integer.', 'wordpoints') |
|
122 | 122 | , 'length' |
123 | 123 | ); |
124 | 124 | |
@@ -135,34 +135,34 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param mixed $args The args the period is related to. |
137 | 137 | */ |
138 | - protected function validate_period_args( $args ) { |
|
138 | + protected function validate_period_args($args) { |
|
139 | 139 | |
140 | - if ( ! is_array( $args ) ) { |
|
140 | + if ( ! is_array($args)) { |
|
141 | 141 | |
142 | 142 | $this->validator->add_error( |
143 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
143 | + __('Period does not match expected format.', 'wordpoints') |
|
144 | 144 | , 'args' |
145 | 145 | ); |
146 | 146 | |
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | - $this->validator->push_field( 'args' ); |
|
150 | + $this->validator->push_field('args'); |
|
151 | 151 | |
152 | - foreach ( $args as $index => $hierarchy ) { |
|
152 | + foreach ($args as $index => $hierarchy) { |
|
153 | 153 | |
154 | - $this->validator->push_field( $index ); |
|
154 | + $this->validator->push_field($index); |
|
155 | 155 | |
156 | - if ( ! is_array( $hierarchy ) ) { |
|
156 | + if ( ! is_array($hierarchy)) { |
|
157 | 157 | |
158 | 158 | $this->validator->add_error( |
159 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
159 | + __('Period does not match expected format.', 'wordpoints') |
|
160 | 160 | ); |
161 | 161 | |
162 | - } elseif ( ! $this->event_args->get_from_hierarchy( $hierarchy ) ) { |
|
162 | + } elseif ( ! $this->event_args->get_from_hierarchy($hierarchy)) { |
|
163 | 163 | |
164 | 164 | $this->validator->add_error( |
165 | - __( 'Invalid period.', 'wordpoints' ) // TODO better error message |
|
165 | + __('Invalid period.', 'wordpoints') // TODO better error message |
|
166 | 166 | ); |
167 | 167 | } |
168 | 168 | |
@@ -180,16 +180,16 @@ discard block |
||
180 | 180 | WordPoints_Hook_Event_Args $event_args |
181 | 181 | ) { |
182 | 182 | |
183 | - $periods = $reaction->get_meta( 'periods' ); |
|
183 | + $periods = $reaction->get_meta('periods'); |
|
184 | 184 | |
185 | - if ( empty( $periods ) ) { |
|
185 | + if (empty($periods)) { |
|
186 | 186 | return true; |
187 | 187 | } |
188 | 188 | |
189 | 189 | $this->event_args = $event_args; |
190 | 190 | |
191 | - foreach ( $periods as $period ) { |
|
192 | - if ( ! $this->has_period_ended( $period, $reaction ) ) { |
|
191 | + foreach ($periods as $period) { |
|
192 | + if ( ! $this->has_period_ended($period, $reaction)) { |
|
193 | 193 | return false; |
194 | 194 | } |
195 | 195 | } |
@@ -213,24 +213,24 @@ discard block |
||
213 | 213 | ) { |
214 | 214 | |
215 | 215 | $period = $this->get_period_by_reaction( |
216 | - $this->get_period_signature( $settings, $reaction ) |
|
216 | + $this->get_period_signature($settings, $reaction) |
|
217 | 217 | , $reaction |
218 | 218 | ); |
219 | 219 | |
220 | 220 | // If the period isn't found, we know that we can still fire. |
221 | - if ( ! $period ) { |
|
221 | + if ( ! $period) { |
|
222 | 222 | return true; |
223 | 223 | } |
224 | 224 | |
225 | - $now = current_time( 'timestamp' ); |
|
226 | - $hit_time = strtotime( $period->hit_time, $now ); |
|
225 | + $now = current_time('timestamp'); |
|
226 | + $hit_time = strtotime($period->hit_time, $now); |
|
227 | 227 | |
228 | - if ( ! empty( $settings['relative'] ) ) { |
|
229 | - return ( $hit_time < $now - $settings['length'] ); |
|
228 | + if ( ! empty($settings['relative'])) { |
|
229 | + return ($hit_time < $now - $settings['length']); |
|
230 | 230 | } else { |
231 | 231 | return ( |
232 | - (int) ( $hit_time / $settings['length'] ) |
|
233 | - < (int) ( $now / $settings['length'] ) |
|
232 | + (int) ($hit_time / $settings['length']) |
|
233 | + < (int) ($now / $settings['length']) |
|
234 | 234 | ); |
235 | 235 | } |
236 | 236 | } |
@@ -244,24 +244,24 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return array The arg values. |
246 | 246 | */ |
247 | - protected function get_arg_values( array $period_args ) { |
|
247 | + protected function get_arg_values(array $period_args) { |
|
248 | 248 | |
249 | 249 | $values = array(); |
250 | 250 | |
251 | - foreach ( $period_args as $arg_hierarchy ) { |
|
251 | + foreach ($period_args as $arg_hierarchy) { |
|
252 | 252 | |
253 | 253 | $arg = $this->event_args->get_from_hierarchy( |
254 | 254 | $arg_hierarchy |
255 | 255 | ); |
256 | 256 | |
257 | - if ( ! $arg instanceof WordPoints_EntityishI ) { |
|
257 | + if ( ! $arg instanceof WordPoints_EntityishI) { |
|
258 | 258 | continue; |
259 | 259 | } |
260 | 260 | |
261 | - $values[ implode( '.', $arg_hierarchy ) ] = $arg->get_the_value(); |
|
261 | + $values[implode('.', $arg_hierarchy)] = $arg->get_the_value(); |
|
262 | 262 | } |
263 | 263 | |
264 | - ksort( $values ); |
|
264 | + ksort($values); |
|
265 | 265 | |
266 | 266 | return $values; |
267 | 267 | } |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return object|false The period data, or false if not found. |
277 | 277 | */ |
278 | - protected function get_period( $period_id ) { |
|
278 | + protected function get_period($period_id) { |
|
279 | 279 | |
280 | - $period = wp_cache_get( $period_id, 'wordpoints_hook_period' ); |
|
280 | + $period = wp_cache_get($period_id, 'wordpoints_hook_period'); |
|
281 | 281 | |
282 | - if ( ! $period ) { |
|
282 | + if ( ! $period) { |
|
283 | 283 | |
284 | 284 | global $wpdb; |
285 | 285 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | ) |
295 | 295 | ); |
296 | 296 | |
297 | - if ( ! $period ) { |
|
297 | + if ( ! $period) { |
|
298 | 298 | return false; |
299 | 299 | } |
300 | 300 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | , 'wordpoints_hook_period_ids' |
305 | 305 | ); |
306 | 306 | |
307 | - wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' ); |
|
307 | + wp_cache_set($period->id, $period, 'wordpoints_hook_periods'); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | return $period; |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | $cache_key = "{$reaction_id}-{$signature}"; |
332 | 332 | |
333 | 333 | // Before we run the query, we try to lookup the ID in the cache. |
334 | - $period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids' ); |
|
334 | + $period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids'); |
|
335 | 335 | |
336 | 336 | // If we found it, we can retrieve the period by ID instead. |
337 | - if ( $period_id ) { |
|
338 | - return $this->get_period( $period_id ); |
|
337 | + if ($period_id) { |
|
338 | + return $this->get_period($period_id); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | global $wpdb; |
@@ -356,12 +356,12 @@ discard block |
||
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' ); |
|
364 | - wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' ); |
|
363 | + wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids'); |
|
364 | + wp_cache_set($period->id, $period, 'wordpoints_hook_periods'); |
|
365 | 365 | |
366 | 366 | return $period; |
367 | 367 | } |
@@ -374,18 +374,18 @@ discard block |
||
374 | 374 | WordPoints_Hook_Event_Args $event_args |
375 | 375 | ) { |
376 | 376 | |
377 | - $periods = $reaction->get_meta( 'periods' ); |
|
377 | + $periods = $reaction->get_meta('periods'); |
|
378 | 378 | |
379 | - if ( empty( $periods ) ) { |
|
379 | + if (empty($periods)) { |
|
380 | 380 | return; |
381 | 381 | } |
382 | 382 | |
383 | 383 | $this->event_args = $event_args; |
384 | 384 | |
385 | - foreach ( $periods as $settings ) { |
|
385 | + foreach ($periods as $settings) { |
|
386 | 386 | |
387 | 387 | $this->add_period( |
388 | - $this->get_period_signature( $settings, $reaction ) |
|
388 | + $this->get_period_signature($settings, $reaction) |
|
389 | 389 | , $reaction |
390 | 390 | ); |
391 | 391 | } |
@@ -410,14 +410,14 @@ discard block |
||
410 | 410 | WordPoints_Hook_Reaction_Validator $reaction |
411 | 411 | ) { |
412 | 412 | |
413 | - if ( isset( $settings['args'] ) ) { |
|
413 | + if (isset($settings['args'])) { |
|
414 | 414 | $period_args = $settings['args']; |
415 | 415 | } else { |
416 | - $period_args = array( $reaction->get_meta( 'target' ) ); |
|
416 | + $period_args = array($reaction->get_meta('target')); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | return wordpoints_hash( |
420 | - wp_json_encode( $this->get_arg_values( $period_args ) ) |
|
420 | + wp_json_encode($this->get_arg_values($period_args)) |
|
421 | 421 | ); |
422 | 422 | } |
423 | 423 | |
@@ -445,12 +445,12 @@ discard block |
||
445 | 445 | , array( |
446 | 446 | 'reaction_id' => $reaction_id, |
447 | 447 | 'signature' => $signature, |
448 | - 'hit_time' => current_time( 'mysql' ), |
|
448 | + 'hit_time' => current_time('mysql'), |
|
449 | 449 | ) |
450 | - , array( '%d', '%s', '%s' ) |
|
450 | + , array('%d', '%s', '%s') |
|
451 | 451 | ); |
452 | 452 | |
453 | - if ( ! $inserted ) { |
|
453 | + if ( ! $inserted) { |
|
454 | 454 | return false; |
455 | 455 | } |
456 | 456 |