@@ -16,16 +16,16 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @param WordPoints_App $app The main WordPoints app. |
18 | 18 | */ |
19 | -function wordpoints_hooks_register_admin_apps( $app ) { |
|
19 | +function wordpoints_hooks_register_admin_apps($app) { |
|
20 | 20 | |
21 | 21 | $apps = $app->sub_apps; |
22 | 22 | |
23 | - $apps->register( 'admin', 'WordPoints_App' ); |
|
23 | + $apps->register('admin', 'WordPoints_App'); |
|
24 | 24 | |
25 | 25 | /** @var WordPoints_App $admin */ |
26 | - $admin = $apps->get( 'admin' ); |
|
26 | + $admin = $apps->get('admin'); |
|
27 | 27 | |
28 | - $admin->sub_apps->register( 'screen', 'WordPoints_Admin_Screens' ); |
|
28 | + $admin->sub_apps->register('screen', 'WordPoints_Admin_Screens'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | // Hooks page. |
47 | 47 | $id = add_submenu_page( |
48 | 48 | $wordpoints_menu |
49 | - , __( 'WordPoints — Points Types', 'wordpoints' ) |
|
50 | - , __( 'Points Types', 'wordpoints' ) |
|
49 | + , __('WordPoints — Points Types', 'wordpoints') |
|
50 | + , __('Points Types', 'wordpoints') |
|
51 | 51 | , 'manage_options' |
52 | 52 | , 'wordpoints_points_types' |
53 | - , array( $admin_screens, 'display' ) |
|
53 | + , array($admin_screens, 'display') |
|
54 | 54 | ); |
55 | 55 | |
56 | - if ( $id ) { |
|
57 | - $admin_screens->register( $id, 'WordPoints_Admin_Screen_Points_Types' ); |
|
56 | + if ($id) { |
|
57 | + $admin_screens->register($id, 'WordPoints_Admin_Screen_Points_Types'); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | */ |
68 | 68 | function wordpoints_hooks_admin_register_scripts() { |
69 | 69 | |
70 | - $assets_url = wordpoints_modules_url( '/assets', dirname( __FILE__ ) ); |
|
70 | + $assets_url = wordpoints_modules_url('/assets', dirname(__FILE__)); |
|
71 | 71 | |
72 | 72 | // CSS |
73 | 73 | |
74 | 74 | wp_register_style( |
75 | 75 | 'wordpoints-hooks-admin' |
76 | - , $assets_url . '/css/hooks.css' |
|
77 | - , array( 'dashicons', 'wp-jquery-ui-dialog' ) |
|
76 | + , $assets_url.'/css/hooks.css' |
|
77 | + , array('dashicons', 'wp-jquery-ui-dialog') |
|
78 | 78 | , WORDPOINTS_VERSION |
79 | 79 | ); |
80 | 80 | |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | |
83 | 83 | wp_register_script( |
84 | 84 | 'wordpoints-hooks-models' |
85 | - , $assets_url . '/js/hooks/models.js' |
|
86 | - , array( 'backbone', 'jquery-ui-dialog', 'wp-util' ) |
|
85 | + , $assets_url.'/js/hooks/models.js' |
|
86 | + , array('backbone', 'jquery-ui-dialog', 'wp-util') |
|
87 | 87 | , WORDPOINTS_VERSION |
88 | 88 | ); |
89 | 89 | |
90 | 90 | wp_register_script( |
91 | 91 | 'wordpoints-hooks-views' |
92 | - , $assets_url . '/js/hooks/views.js' |
|
93 | - , array( 'wordpoints-hooks-models' ) |
|
92 | + , $assets_url.'/js/hooks/views.js' |
|
93 | + , array('wordpoints-hooks-models') |
|
94 | 94 | , WORDPOINTS_VERSION |
95 | 95 | ); |
96 | 96 | |
@@ -98,15 +98,15 @@ discard block |
||
98 | 98 | 'wordpoints-hooks-views' |
99 | 99 | , 'WordPointsHooksAdminL10n' |
100 | 100 | , array( |
101 | - 'unexpectedError' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
102 | - 'changesSaved' => __( 'Your changes have been saved.', 'wordpoints' ), |
|
101 | + 'unexpectedError' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
102 | + 'changesSaved' => __('Your changes have been saved.', 'wordpoints'), |
|
103 | 103 | /* translators: the name of the field that cannot be empty */ |
104 | - 'emptyField' => sprintf( __( '%s cannot be empty.', 'wordpoints' ), '{{ data.label }}' ), |
|
105 | - 'confirmDelete' => __( 'Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints' ), |
|
106 | - 'confirmTitle' => __( 'Are you sure?', 'wordpoints' ), |
|
107 | - 'deleteText' => __( 'Delete', 'wordpoints' ), |
|
108 | - 'cancelText' => __( 'Cancel', 'wordpoints' ), |
|
109 | - 'separator' => __( ' » ', 'wordpoints' ), |
|
104 | + 'emptyField' => sprintf(__('%s cannot be empty.', 'wordpoints'), '{{ data.label }}'), |
|
105 | + 'confirmDelete' => __('Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints'), |
|
106 | + 'confirmTitle' => __('Are you sure?', 'wordpoints'), |
|
107 | + 'deleteText' => __('Delete', 'wordpoints'), |
|
108 | + 'cancelText' => __('Cancel', 'wordpoints'), |
|
109 | + 'separator' => __(' » ', 'wordpoints'), |
|
110 | 110 | ) |
111 | 111 | ); |
112 | 112 | |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | <div class="view"> |
119 | 119 | <div class="title"></div> |
120 | 120 | <button type="button" class="edit button-secondary"> |
121 | - ' . esc_html__( 'Edit', 'wordpoints' ) . ' |
|
121 | + ' . esc_html__('Edit', 'wordpoints').' |
|
122 | 122 | </button> |
123 | 123 | <button type="button" class="close button-secondary"> |
124 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
124 | + ' . esc_html__('Close', 'wordpoints').' |
|
125 | 125 | </button> |
126 | 126 | </div> |
127 | 127 | <div class="form"> |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | </div> |
141 | 141 | <div class="action-buttons"> |
142 | 142 | <button type="button" class="save button-primary" disabled> |
143 | - ' . esc_html__( 'Save', 'wordpoints' ) . ' |
|
143 | + ' . esc_html__('Save', 'wordpoints').' |
|
144 | 144 | </button> |
145 | 145 | <button type="button" class="cancel button-secondary"> |
146 | - ' . esc_html__( 'Cancel', 'wordpoints' ) . ' |
|
146 | + ' . esc_html__('Cancel', 'wordpoints').' |
|
147 | 147 | </button> |
148 | 148 | <button type="button" class="close button-secondary"> |
149 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
149 | + ' . esc_html__('Close', 'wordpoints').' |
|
150 | 150 | </button> |
151 | 151 | <button type="button" class="delete button-secondary"> |
152 | - ' . esc_html__( 'Delete', 'wordpoints' ) . ' |
|
152 | + ' . esc_html__('Delete', 'wordpoints').' |
|
153 | 153 | </button> |
154 | 154 | </div> |
155 | 155 | </div> |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | |
198 | 198 | wp_register_script( |
199 | 199 | 'wordpoints-hooks-reactor-points' |
200 | - , $assets_url . '/js/hooks/reactors/points.js' |
|
201 | - , array( 'wordpoints-hooks-views' ) |
|
200 | + , $assets_url.'/js/hooks/reactors/points.js' |
|
201 | + , array('wordpoints-hooks-views') |
|
202 | 202 | , WORDPOINTS_VERSION |
203 | 203 | ); |
204 | 204 | |
205 | 205 | wp_register_script( |
206 | 206 | 'wordpoints-hooks-extension-conditions' |
207 | - , $assets_url . '/js/hooks/extensions/conditions.js' |
|
208 | - , array( 'wordpoints-hooks-views' ) |
|
207 | + , $assets_url.'/js/hooks/extensions/conditions.js' |
|
208 | + , array('wordpoints-hooks-views') |
|
209 | 209 | , WORDPOINTS_VERSION |
210 | 210 | ); |
211 | 211 | |
@@ -215,25 +215,25 @@ discard block |
||
215 | 215 | , ' |
216 | 216 | <script type="text/template" id="tmpl-wordpoints-hook-condition-groups"> |
217 | 217 | <div class="conditions-title section-title"> |
218 | - <h4>' . esc_html__( 'Conditions', 'wordpoints' ) . '</h4> |
|
218 | + <h4>' . esc_html__('Conditions', 'wordpoints').'</h4> |
|
219 | 219 | <button type="button" class="add-new button-secondary button-link"> |
220 | - <span class="screen-reader-text">' . esc_html__( 'Add New Condition', 'wordpoints' ) . '</span> |
|
220 | + <span class="screen-reader-text">' . esc_html__('Add New Condition', 'wordpoints').'</span> |
|
221 | 221 | <span class="dashicons dashicons-plus"></span> |
222 | 222 | </button> |
223 | 223 | </div> |
224 | 224 | <div class="add-condition-form hidden"> |
225 | 225 | <div class="no-conditions hidden"> |
226 | - ' . esc_html__( 'No conditions available.', 'wordpoints' ) . ' |
|
226 | + ' . esc_html__('No conditions available.', 'wordpoints').' |
|
227 | 227 | </div> |
228 | 228 | <div class="condition-selectors"> |
229 | 229 | <div class="arg-selectors"></div> |
230 | 230 | <div class="condition-selector"></div> |
231 | 231 | </div> |
232 | - <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__( 'Add Condition', 'wordpoints' ) . '"> |
|
233 | - ' . esc_html_x( 'Add', 'reaction condition', 'wordpoints' ) . ' |
|
232 | + <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__('Add Condition', 'wordpoints').'"> |
|
233 | + ' . esc_html_x('Add', 'reaction condition', 'wordpoints').' |
|
234 | 234 | </button> |
235 | - <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__( 'Cancel Adding New Condition', 'wordpoints' ) . '"> |
|
236 | - ' . esc_html_x( 'Cancel', 'reaction condition', 'wordpoints' ) . ' |
|
235 | + <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__('Cancel Adding New Condition', 'wordpoints').'"> |
|
236 | + ' . esc_html_x('Cancel', 'reaction condition', 'wordpoints').' |
|
237 | 237 | </button> |
238 | 238 | </div> |
239 | 239 | <div class="condition-groups section-content"></div> |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | <div class="condition-controls"> |
248 | 248 | <div class="condition-title"></div> |
249 | 249 | <button type="button" class="delete button-secondary button-link"> |
250 | - <span class="screen-reader-text">' . esc_html__( 'Remove Condition', 'wordpoints' ) . '</span> |
|
250 | + <span class="screen-reader-text">' . esc_html__('Remove Condition', 'wordpoints').'</span> |
|
251 | 251 | <span class="dashicons dashicons-no"></span> |
252 | 252 | </button> |
253 | 253 | </div> |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | |
266 | 266 | wp_register_script( |
267 | 267 | 'wordpoints-hooks-extension-periods' |
268 | - , $assets_url . '/js/hooks/extensions/periods.js' |
|
269 | - , array( 'wordpoints-hooks-views' ) |
|
268 | + , $assets_url.'/js/hooks/extensions/periods.js' |
|
269 | + , array('wordpoints-hooks-views') |
|
270 | 270 | , WORDPOINTS_VERSION |
271 | 271 | ); |
272 | 272 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | , ' |
277 | 277 | <script type="text/template" id="tmpl-wordpoints-hook-periods"> |
278 | 278 | <div class="periods-title section-title"> |
279 | - <h4>' . esc_html__( 'Rate Limit', 'wordpoints' ) . '</h4> |
|
279 | + <h4>' . esc_html__('Rate Limit', 'wordpoints').'</h4> |
|
280 | 280 | </div> |
281 | 281 | <div class="periods section-content"></div> |
282 | 282 | </script> |
@@ -295,32 +295,32 @@ discard block |
||
295 | 295 | |
296 | 296 | $extensions_data = array(); |
297 | 297 | |
298 | - foreach ( $hooks->extensions->get_all() as $slug => $extension ) { |
|
298 | + foreach ($hooks->extensions->get_all() as $slug => $extension) { |
|
299 | 299 | |
300 | - if ( $extension instanceof WordPoints_Hook_Extension ) { |
|
301 | - $extensions_data[ $slug ] = $extension->get_ui_script_data(); |
|
300 | + if ($extension instanceof WordPoints_Hook_Extension) { |
|
301 | + $extensions_data[$slug] = $extension->get_ui_script_data(); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( wp_script_is( "wordpoints-hooks-extension-{$slug}", 'registered' ) ) { |
|
305 | - wp_enqueue_script( "wordpoints-hooks-extension-{$slug}" ); |
|
304 | + if (wp_script_is("wordpoints-hooks-extension-{$slug}", 'registered')) { |
|
305 | + wp_enqueue_script("wordpoints-hooks-extension-{$slug}"); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | 309 | $reactor_data = array(); |
310 | 310 | |
311 | - foreach ( $hooks->reactors->get_all() as $slug => $reactor ) { |
|
311 | + foreach ($hooks->reactors->get_all() as $slug => $reactor) { |
|
312 | 312 | |
313 | - if ( $reactor instanceof WordPoints_Hook_Reactor ) { |
|
314 | - $reactor_data[ $slug ] = array( |
|
313 | + if ($reactor instanceof WordPoints_Hook_Reactor) { |
|
314 | + $reactor_data[$slug] = array( |
|
315 | 315 | 'slug' => $reactor->get_slug(), |
316 | 316 | 'fields' => $reactor->get_settings_fields(), |
317 | 317 | 'arg_types' => $reactor->get_arg_types(), |
318 | - 'target_label' => __( 'Award To', 'wordpoints' ), |
|
318 | + 'target_label' => __('Award To', 'wordpoints'), |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | |
322 | - if ( wp_script_is( "wordpoints-hooks-reactor-{$slug}", 'registered' ) ) { |
|
323 | - wp_enqueue_script( "wordpoints-hooks-reactor-{$slug}" ); |
|
322 | + if (wp_script_is("wordpoints-hooks-reactor-{$slug}", 'registered')) { |
|
323 | + wp_enqueue_script("wordpoints-hooks-reactor-{$slug}"); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -332,28 +332,28 @@ discard block |
||
332 | 332 | $entity_children = $entities->children; |
333 | 333 | |
334 | 334 | /** @var WordPoints_Entity $entity */ |
335 | - foreach ( $entities->get_all() as $slug => $entity ) { |
|
335 | + foreach ($entities->get_all() as $slug => $entity) { |
|
336 | 336 | |
337 | 337 | $child_data = array(); |
338 | 338 | |
339 | 339 | /** @var WordPoints_EntityishI $child */ |
340 | - foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) { |
|
340 | + foreach ($entity_children->get_children($slug) as $child_slug => $child) { |
|
341 | 341 | |
342 | - $child_data[ $child_slug ] = array( |
|
342 | + $child_data[$child_slug] = array( |
|
343 | 343 | 'slug' => $child_slug, |
344 | 344 | 'title' => $child->get_title(), |
345 | 345 | ); |
346 | 346 | |
347 | - if ( $child instanceof WordPoints_Entity_Attr ) { |
|
347 | + if ($child instanceof WordPoints_Entity_Attr) { |
|
348 | 348 | |
349 | - $child_data[ $child_slug ]['_type'] = 'attr'; |
|
350 | - $child_data[ $child_slug ]['data_type'] = $child->get_data_type(); |
|
349 | + $child_data[$child_slug]['_type'] = 'attr'; |
|
350 | + $child_data[$child_slug]['data_type'] = $child->get_data_type(); |
|
351 | 351 | |
352 | - } elseif ( $child instanceof WordPoints_Entity_Relationship ) { |
|
352 | + } elseif ($child instanceof WordPoints_Entity_Relationship) { |
|
353 | 353 | |
354 | - $child_data[ $child_slug ]['_type'] = 'relationship'; |
|
355 | - $child_data[ $child_slug ]['primary'] = $child->get_primary_entity_slug(); |
|
356 | - $child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug(); |
|
354 | + $child_data[$child_slug]['_type'] = 'relationship'; |
|
355 | + $child_data[$child_slug]['primary'] = $child->get_primary_entity_slug(); |
|
356 | + $child_data[$child_slug]['secondary'] = $child->get_related_entity_slug(); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -364,10 +364,10 @@ discard block |
||
364 | 364 | * @param array $data The data for the entity child. |
365 | 365 | * @param WordPoints_Entityish $child The child's object. |
366 | 366 | */ |
367 | - $child_data[ $child_slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity_child', $child_data[ $child_slug ], $child ); |
|
367 | + $child_data[$child_slug] = apply_filters('wordpoints_hooks_ui_data_entity_child', $child_data[$child_slug], $child); |
|
368 | 368 | } |
369 | 369 | |
370 | - $entities_data[ $slug ] = array( |
|
370 | + $entities_data[$slug] = array( |
|
371 | 371 | 'slug' => $slug, |
372 | 372 | 'title' => $entity->get_title(), |
373 | 373 | 'children' => $child_data, |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | '_type' => 'entity', |
376 | 376 | ); |
377 | 377 | |
378 | - if ( $entity instanceof WordPoints_Entity_EnumerableI ) { |
|
378 | + if ($entity instanceof WordPoints_Entity_EnumerableI) { |
|
379 | 379 | |
380 | 380 | $values = array(); |
381 | 381 | |
382 | - foreach ( $entity->get_enumerated_values() as $value ) { |
|
383 | - if ( $entity->set_the_value( $value ) ) { |
|
382 | + foreach ($entity->get_enumerated_values() as $value) { |
|
383 | + if ($entity->set_the_value($value)) { |
|
384 | 384 | $values[] = array( |
385 | 385 | 'value' => $entity->get_the_id(), |
386 | 386 | 'label' => $entity->get_the_human_id(), |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | - $entities_data[ $slug ]['values'] = $values; |
|
391 | + $entities_data[$slug]['values'] = $values; |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * @param array $data The data for the entity. |
398 | 398 | * @param WordPoints_Entity $entity The entity object. |
399 | 399 | */ |
400 | - $entities_data[ $slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity', $entities_data[ $slug ], $entity ); |
|
400 | + $entities_data[$slug] = apply_filters('wordpoints_hooks_ui_data_entity', $entities_data[$slug], $entity); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | $data = array( |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param array $data The data. |
420 | 420 | */ |
421 | - $data = apply_filters( 'wordpoints_hooks_ui_data', $data ); |
|
421 | + $data = apply_filters('wordpoints_hooks_ui_data', $data); |
|
422 | 422 | |
423 | 423 | wp_localize_script( |
424 | 424 | 'wordpoints-hooks-models' |
@@ -443,13 +443,13 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return string The HTML with templates appended. |
445 | 445 | */ |
446 | -function wordpoints_script_templates_filter( $html, $handle ) { |
|
446 | +function wordpoints_script_templates_filter($html, $handle) { |
|
447 | 447 | |
448 | 448 | global $wp_scripts; |
449 | 449 | |
450 | - $templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' ); |
|
450 | + $templates = $wp_scripts->get_data($handle, 'wordpoints-templates'); |
|
451 | 451 | |
452 | - if ( $templates ) { |
|
452 | + if ($templates) { |
|
453 | 453 | $html .= $templates; |
454 | 454 | } |
455 | 455 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | */ |
466 | 466 | function wordpoints_hooks_admin_ajax() { |
467 | 467 | |
468 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
468 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
469 | 469 | new WordPoints_Admin_Ajax_Hooks; |
470 | 470 | } |
471 | 471 | } |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | * @param bool $fail_fast Whether to fail as soon as |
105 | 105 | * the first error is found. |
106 | 106 | */ |
107 | - public function __construct( $settings, WordPoints_Hook_Reactor $reactor, $fail_fast = false ) { |
|
107 | + public function __construct($settings, WordPoints_Hook_Reactor $reactor, $fail_fast = false) { |
|
108 | 108 | |
109 | 109 | $this->reactor = $reactor; |
110 | 110 | $this->fail_fast = $fail_fast; |
111 | 111 | $this->hooks = wordpoints_hooks(); |
112 | 112 | |
113 | - if ( $settings instanceof WordPoints_Hook_ReactionI ) { |
|
113 | + if ($settings instanceof WordPoints_Hook_ReactionI) { |
|
114 | 114 | |
115 | 115 | $this->reaction = $settings; |
116 | 116 | $this->settings = $this->reaction->get_all_meta(); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | $this->settings = $settings; |
122 | 122 | |
123 | - if ( isset( $this->settings['event'] ) ) { |
|
123 | + if (isset($this->settings['event'])) { |
|
124 | 124 | $this->event_slug = $this->settings['event']; |
125 | 125 | } |
126 | 126 | } |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | $fail_fast = $this->fail_fast; |
145 | 145 | $this->fail_fast = true; |
146 | 146 | |
147 | - if ( ! isset( $this->event_slug ) ) { |
|
148 | - $this->add_error( __( 'Event is missing.', 'wordpoints' ), 'event' ); |
|
149 | - } elseif ( ! $this->hooks->events->is_registered( $this->event_slug ) ) { |
|
150 | - $this->add_error( __( 'Event is invalid.', 'wordpoints' ), 'event' ); |
|
147 | + if ( ! isset($this->event_slug)) { |
|
148 | + $this->add_error(__('Event is missing.', 'wordpoints'), 'event'); |
|
149 | + } elseif ( ! $this->hooks->events->is_registered($this->event_slug)) { |
|
150 | + $this->add_error(__('Event is invalid.', 'wordpoints'), 'event'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // From here on out we can collect errors as they come (unless we are |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | $this->event_slug |
159 | 159 | ); |
160 | 160 | |
161 | - $this->event_args = new WordPoints_Hook_Event_Args( $event_args ); |
|
162 | - $this->event_args->set_validator( $this ); |
|
161 | + $this->event_args = new WordPoints_Hook_Event_Args($event_args); |
|
162 | + $this->event_args->set_validator($this); |
|
163 | 163 | |
164 | - $this->settings = $this->reactor->validate_settings( $this->settings, $this, $this->event_args ); |
|
164 | + $this->settings = $this->reactor->validate_settings($this->settings, $this, $this->event_args); |
|
165 | 165 | |
166 | 166 | /** @var WordPoints_Hook_Extension $extension */ |
167 | - foreach ( $this->hooks->extensions->get_all() as $extension ) { |
|
168 | - $this->settings = $extension->validate_settings( $this->settings, $this, $this->event_args ); |
|
167 | + foreach ($this->hooks->extensions->get_all() as $extension) { |
|
168 | + $this->settings = $extension->validate_settings($this->settings, $this, $this->event_args); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * @param WordPoints_Hook_Reaction_Validator $validator The validator object. |
176 | 176 | * @param WordPoints_Hook_Event_Args $args The event args object. |
177 | 177 | */ |
178 | - $this->settings = apply_filters( 'wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args ); |
|
178 | + $this->settings = apply_filters('wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args); |
|
179 | 179 | |
180 | - } catch ( WordPoints_Hook_Validator_Exception $e ) { |
|
180 | + } catch (WordPoints_Hook_Validator_Exception $e) { |
|
181 | 181 | |
182 | 182 | // Do nothing. |
183 | - unset( $e ); |
|
183 | + unset($e); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | return $this->settings; |
@@ -208,17 +208,17 @@ discard block |
||
208 | 208 | * @throws WordPoints_Hook_Validator_Exception If the validator is configured to |
209 | 209 | * fail as soon as an error is found. |
210 | 210 | */ |
211 | - public function add_error( $message, $field = null ) { |
|
211 | + public function add_error($message, $field = null) { |
|
212 | 212 | |
213 | 213 | $field_stack = $this->field_stack; |
214 | 214 | |
215 | - if ( null !== $field ) { |
|
215 | + if (null !== $field) { |
|
216 | 216 | $field_stack[] = $field; |
217 | 217 | } |
218 | 218 | |
219 | - $this->errors[] = array( 'message' => $message, 'field' => $field_stack ); |
|
219 | + $this->errors[] = array('message' => $message, 'field' => $field_stack); |
|
220 | 220 | |
221 | - if ( $this->fail_fast ) { |
|
221 | + if ($this->fail_fast) { |
|
222 | 222 | throw new WordPoints_Hook_Validator_Exception; |
223 | 223 | } |
224 | 224 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @return bool Whether the validator found any errors. |
232 | 232 | */ |
233 | 233 | public function had_errors() { |
234 | - return ! empty( $this->errors ); |
|
234 | + return ! empty($this->errors); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @param string $field The field. |
254 | 254 | */ |
255 | - public function push_field( $field ) { |
|
255 | + public function push_field($field) { |
|
256 | 256 | $this->field_stack[] = $field; |
257 | 257 | } |
258 | 258 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @since 1.0.0 |
263 | 263 | */ |
264 | 264 | public function pop_field() { |
265 | - array_pop( $this->field_stack ); |
|
265 | + array_pop($this->field_stack); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public function get_id() { |
309 | 309 | |
310 | - if ( ! $this->reaction ) { |
|
310 | + if ( ! $this->reaction) { |
|
311 | 311 | return false; |
312 | 312 | } |
313 | 313 | |
@@ -345,13 +345,13 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return mixed The meta value. |
347 | 347 | */ |
348 | - public function get_meta( $key ) { |
|
348 | + public function get_meta($key) { |
|
349 | 349 | |
350 | - if ( ! isset( $this->settings[ $key ] ) ) { |
|
350 | + if ( ! isset($this->settings[$key])) { |
|
351 | 351 | return null; |
352 | 352 | } |
353 | 353 | |
354 | - return $this->settings[ $key ]; |
|
354 | + return $this->settings[$key]; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -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 |
@@ -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 |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | public function get_current_id() { |
23 | 23 | |
24 | - if ( ! is_multisite() ) { |
|
24 | + if ( ! is_multisite()) { |
|
25 | 25 | return 1; |
26 | 26 | } |
27 | 27 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | /** |
27 | 27 | * @since 1.0.0 |
28 | 28 | */ |
29 | - public function __construct( $slug ) { |
|
29 | + public function __construct($slug) { |
|
30 | 30 | |
31 | 31 | $this->slug = $slug; |
32 | 32 | } |
@@ -35,18 +35,18 @@ |
||
35 | 35 | /** |
36 | 36 | * @since 1.0.0 |
37 | 37 | */ |
38 | - public function __construct( $id, WordPoints_Hook_Reaction_StorageI $storage ) { |
|
38 | + public function __construct($id, WordPoints_Hook_Reaction_StorageI $storage) { |
|
39 | 39 | |
40 | - $this->ID = wordpoints_int( $id ); |
|
40 | + $this->ID = wordpoints_int($id); |
|
41 | 41 | $this->storage = $storage; |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @since 1.0.0 |
46 | 46 | */ |
47 | - public function __get( $var ) { |
|
47 | + public function __get($var) { |
|
48 | 48 | |
49 | - if ( 'ID' === $var ) { |
|
49 | + if ('ID' === $var) { |
|
50 | 50 | return $this->ID; |
51 | 51 | } |
52 | 52 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param string $slug The slug of this storage group. |
26 | 26 | * @param WordPoints_Hook_Reactor $reactor The reactor the reactions belong to. |
27 | 27 | */ |
28 | - public function __construct( $slug, WordPoints_Hook_Reactor $reactor ); |
|
28 | + public function __construct($slug, WordPoints_Hook_Reactor $reactor); |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Get the slug of this reaction storage group. |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return bool Whether the reaction exists. |
71 | 71 | */ |
72 | - public function reaction_exists( $id ); |
|
72 | + public function reaction_exists($id); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Get an reaction object. |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return WordPoints_Hook_ReactionI|false The reaction, or false if nonexistent. |
82 | 82 | */ |
83 | - public function get_reaction( $id ); |
|
83 | + public function get_reaction($id); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Create an reaction. |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * The reaction object if created successfully. False or a validator |
94 | 94 | * instance if not. |
95 | 95 | */ |
96 | - public function create_reaction( array $settings ); |
|
96 | + public function create_reaction(array $settings); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Update an reaction. |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * The reaction object if updated successfully. False or a validator |
108 | 108 | * instance if not. |
109 | 109 | */ |
110 | - public function update_reaction( $id, array $settings ); |
|
110 | + public function update_reaction($id, array $settings); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Delete an reaction. |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return bool Whether the reaction was deleted successfully. |
120 | 120 | */ |
121 | - public function delete_reaction( $id ); |
|
121 | + public function delete_reaction($id); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Get all hook reactions for the reactor. |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return WordPoints_Hook_ReactionI[] |
143 | 143 | */ |
144 | - public function get_reactions_to_event( $event_slug ); |
|
144 | + public function get_reactions_to_event($event_slug); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | // EOF |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @since 1.0.0 |
19 | 19 | */ |
20 | - public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args ) { |
|
20 | + public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args) { |
|
21 | 21 | |
22 | 22 | $hooks = wordpoints_hooks(); |
23 | 23 | |
24 | 24 | /** @var WordPoints_Hook_Reactor $reactor */ |
25 | - foreach ( $hooks->reactors->get_all() as $reactor ) { |
|
25 | + foreach ($hooks->reactors->get_all() as $reactor) { |
|
26 | 26 | |
27 | - foreach ( $reactor->get_all_reactions_to_event( $event_slug ) as $reaction ) { |
|
27 | + foreach ($reactor->get_all_reactions_to_event($event_slug) as $reaction) { |
|
28 | 28 | |
29 | 29 | $validator = new WordPoints_Hook_Reaction_Validator( |
30 | 30 | $reaction |
@@ -34,25 +34,25 @@ discard block |
||
34 | 34 | |
35 | 35 | $validator->validate(); |
36 | 36 | |
37 | - if ( $validator->had_errors() ) { |
|
37 | + if ($validator->had_errors()) { |
|
38 | 38 | continue; |
39 | 39 | } |
40 | 40 | |
41 | - unset( $validator ); |
|
41 | + unset($validator); |
|
42 | 42 | |
43 | 43 | /** @var WordPoints_Hook_Extension[] $extensions */ |
44 | 44 | $extensions = $hooks->extensions->get_all(); |
45 | 45 | |
46 | - foreach ( $extensions as $extension ) { |
|
47 | - if ( ! $extension->should_hit( $reaction, $event_args ) ) { |
|
46 | + foreach ($extensions as $extension) { |
|
47 | + if ( ! $extension->should_hit($reaction, $event_args)) { |
|
48 | 48 | continue 2; |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - $reactor->hit( $event_args, $reaction ); |
|
52 | + $reactor->hit($event_args, $reaction); |
|
53 | 53 | |
54 | - foreach ( $extensions as $extension ) { |
|
55 | - $extension->after_hit( $reaction, $event_args ); |
|
54 | + foreach ($extensions as $extension) { |
|
55 | + $extension->after_hit($reaction, $event_args); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |