@@ -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,16 +98,16 @@ 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' ), |
|
110 | - 'target_label' => __( 'Target', '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 | + 'target_label' => __('Target', 'wordpoints'), |
|
111 | 111 | ) |
112 | 112 | ); |
113 | 113 | |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | <div class="view"> |
120 | 120 | <div class="title"></div> |
121 | 121 | <button type="button" class="edit button-secondary"> |
122 | - ' . esc_html__( 'Edit', 'wordpoints' ) . ' |
|
122 | + ' . esc_html__('Edit', 'wordpoints').' |
|
123 | 123 | </button> |
124 | 124 | <button type="button" class="close button-secondary"> |
125 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
125 | + ' . esc_html__('Close', 'wordpoints').' |
|
126 | 126 | </button> |
127 | 127 | </div> |
128 | 128 | <div class="form"> |
@@ -141,16 +141,16 @@ discard block |
||
141 | 141 | </div> |
142 | 142 | <div class="action-buttons"> |
143 | 143 | <button type="button" class="save button-primary" disabled> |
144 | - ' . esc_html__( 'Save', 'wordpoints' ) . ' |
|
144 | + ' . esc_html__('Save', 'wordpoints').' |
|
145 | 145 | </button> |
146 | 146 | <button type="button" class="cancel button-secondary"> |
147 | - ' . esc_html__( 'Cancel', 'wordpoints' ) . ' |
|
147 | + ' . esc_html__('Cancel', 'wordpoints').' |
|
148 | 148 | </button> |
149 | 149 | <button type="button" class="close button-secondary"> |
150 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
150 | + ' . esc_html__('Close', 'wordpoints').' |
|
151 | 151 | </button> |
152 | 152 | <button type="button" class="delete button-secondary"> |
153 | - ' . esc_html__( 'Delete', 'wordpoints' ) . ' |
|
153 | + ' . esc_html__('Delete', 'wordpoints').' |
|
154 | 154 | </button> |
155 | 155 | </div> |
156 | 156 | </div> |
@@ -198,15 +198,15 @@ discard block |
||
198 | 198 | |
199 | 199 | wp_register_script( |
200 | 200 | 'wordpoints-hooks-reactor-points' |
201 | - , $assets_url . '/js/hooks/reactors/points.js' |
|
202 | - , array( 'wordpoints-hooks-views' ) |
|
201 | + , $assets_url.'/js/hooks/reactors/points.js' |
|
202 | + , array('wordpoints-hooks-views') |
|
203 | 203 | , WORDPOINTS_VERSION |
204 | 204 | ); |
205 | 205 | |
206 | 206 | wp_register_script( |
207 | 207 | 'wordpoints-hooks-extension-conditions' |
208 | - , $assets_url . '/js/hooks/extensions/conditions.js' |
|
209 | - , array( 'wordpoints-hooks-views' ) |
|
208 | + , $assets_url.'/js/hooks/extensions/conditions.js' |
|
209 | + , array('wordpoints-hooks-views') |
|
210 | 210 | , WORDPOINTS_VERSION |
211 | 211 | ); |
212 | 212 | |
@@ -216,25 +216,25 @@ discard block |
||
216 | 216 | , ' |
217 | 217 | <script type="text/template" id="tmpl-wordpoints-hook-condition-groups"> |
218 | 218 | <div class="conditions-title section-title"> |
219 | - <h4>' . esc_html__( 'Conditions', 'wordpoints' ) . '</h4> |
|
219 | + <h4>' . esc_html__('Conditions', 'wordpoints').'</h4> |
|
220 | 220 | <button type="button" class="add-new button-secondary button-link"> |
221 | - <span class="screen-reader-text">' . esc_html__( 'Add New Condition', 'wordpoints' ) . '</span> |
|
221 | + <span class="screen-reader-text">' . esc_html__('Add New Condition', 'wordpoints').'</span> |
|
222 | 222 | <span class="dashicons dashicons-plus"></span> |
223 | 223 | </button> |
224 | 224 | </div> |
225 | 225 | <div class="add-condition-form hidden"> |
226 | 226 | <div class="no-conditions hidden"> |
227 | - ' . esc_html__( 'No conditions available.', 'wordpoints' ) . ' |
|
227 | + ' . esc_html__('No conditions available.', 'wordpoints').' |
|
228 | 228 | </div> |
229 | 229 | <div class="condition-selectors"> |
230 | 230 | <div class="arg-selectors"></div> |
231 | 231 | <div class="condition-selector"></div> |
232 | 232 | </div> |
233 | - <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__( 'Add Condition', 'wordpoints' ) . '"> |
|
234 | - ' . esc_html_x( 'Add', 'reaction condition', 'wordpoints' ) . ' |
|
233 | + <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__('Add Condition', 'wordpoints').'"> |
|
234 | + ' . esc_html_x('Add', 'reaction condition', 'wordpoints').' |
|
235 | 235 | </button> |
236 | - <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__( 'Cancel Adding New Condition', 'wordpoints' ) . '"> |
|
237 | - ' . esc_html_x( 'Cancel', 'reaction condition', 'wordpoints' ) . ' |
|
236 | + <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__('Cancel Adding New Condition', 'wordpoints').'"> |
|
237 | + ' . esc_html_x('Cancel', 'reaction condition', 'wordpoints').' |
|
238 | 238 | </button> |
239 | 239 | </div> |
240 | 240 | <div class="condition-groups section-content"></div> |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | <div class="condition-controls"> |
249 | 249 | <div class="condition-title"></div> |
250 | 250 | <button type="button" class="delete button-secondary button-link"> |
251 | - <span class="screen-reader-text">' . esc_html__( 'Remove Condition', 'wordpoints' ) . '</span> |
|
251 | + <span class="screen-reader-text">' . esc_html__('Remove Condition', 'wordpoints').'</span> |
|
252 | 252 | <span class="dashicons dashicons-no"></span> |
253 | 253 | </button> |
254 | 254 | </div> |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | |
267 | 267 | wp_register_script( |
268 | 268 | 'wordpoints-hooks-extension-periods' |
269 | - , $assets_url . '/js/hooks/extensions/periods.js' |
|
270 | - , array( 'wordpoints-hooks-views' ) |
|
269 | + , $assets_url.'/js/hooks/extensions/periods.js' |
|
270 | + , array('wordpoints-hooks-views') |
|
271 | 271 | , WORDPOINTS_VERSION |
272 | 272 | ); |
273 | 273 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | , ' |
278 | 278 | <script type="text/template" id="tmpl-wordpoints-hook-periods"> |
279 | 279 | <div class="periods-title section-title"> |
280 | - <h4>' . esc_html__( 'Rate Limit', 'wordpoints' ) . '</h4> |
|
280 | + <h4>' . esc_html__('Rate Limit', 'wordpoints').'</h4> |
|
281 | 281 | </div> |
282 | 282 | <div class="periods section-content"></div> |
283 | 283 | </script> |
@@ -295,27 +295,27 @@ discard block |
||
295 | 295 | $hooks = wordpoints_hooks(); |
296 | 296 | |
297 | 297 | $event_index = $hooks->router->get_event_index(); |
298 | - $event_index = call_user_func_array( 'array_merge_recursive', $event_index ); |
|
298 | + $event_index = call_user_func_array('array_merge_recursive', $event_index); |
|
299 | 299 | |
300 | 300 | $event_action_types = array(); |
301 | 301 | |
302 | - foreach ( $event_index as $action_type => $events ) { |
|
302 | + foreach ($event_index as $action_type => $events) { |
|
303 | 303 | $event_action_types = array_merge_recursive( |
304 | 304 | $event_action_types |
305 | - , array_fill_keys( array_keys( $events ), array( $action_type ) ) |
|
305 | + , array_fill_keys(array_keys($events), array($action_type)) |
|
306 | 306 | ); |
307 | 307 | } |
308 | 308 | |
309 | 309 | $extensions_data = array(); |
310 | 310 | |
311 | - foreach ( $hooks->extensions->get_all() as $slug => $extension ) { |
|
311 | + foreach ($hooks->extensions->get_all() as $slug => $extension) { |
|
312 | 312 | |
313 | - if ( $extension instanceof WordPoints_Hook_Extension ) { |
|
314 | - $extensions_data[ $slug ] = $extension->get_ui_script_data(); |
|
313 | + if ($extension instanceof WordPoints_Hook_Extension) { |
|
314 | + $extensions_data[$slug] = $extension->get_ui_script_data(); |
|
315 | 315 | } |
316 | 316 | |
317 | - if ( wp_script_is( "wordpoints-hooks-extension-{$slug}", 'registered' ) ) { |
|
318 | - wp_enqueue_script( "wordpoints-hooks-extension-{$slug}" ); |
|
317 | + if (wp_script_is("wordpoints-hooks-extension-{$slug}", 'registered')) { |
|
318 | + wp_enqueue_script("wordpoints-hooks-extension-{$slug}"); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -323,16 +323,16 @@ discard block |
||
323 | 323 | |
324 | 324 | $reactor_data = array(); |
325 | 325 | |
326 | - foreach ( $hooks->reactors->get_all() as $slug => $reactor ) { |
|
326 | + foreach ($hooks->reactors->get_all() as $slug => $reactor) { |
|
327 | 327 | |
328 | - if ( $reactor instanceof WordPoints_Hook_Reactor ) { |
|
329 | - $reactor_data[ $slug ] = $reactor->get_ui_script_data(); |
|
328 | + if ($reactor instanceof WordPoints_Hook_Reactor) { |
|
329 | + $reactor_data[$slug] = $reactor->get_ui_script_data(); |
|
330 | 330 | } |
331 | 331 | |
332 | - $reactor_data[ $slug ]['action_types'] = $action_types[ $slug ]; |
|
332 | + $reactor_data[$slug]['action_types'] = $action_types[$slug]; |
|
333 | 333 | |
334 | - if ( wp_script_is( "wordpoints-hooks-reactor-{$slug}", 'registered' ) ) { |
|
335 | - wp_enqueue_script( "wordpoints-hooks-reactor-{$slug}" ); |
|
334 | + if (wp_script_is("wordpoints-hooks-reactor-{$slug}", 'registered')) { |
|
335 | + wp_enqueue_script("wordpoints-hooks-reactor-{$slug}"); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -344,28 +344,28 @@ discard block |
||
344 | 344 | $entity_children = $entities->children; |
345 | 345 | |
346 | 346 | /** @var WordPoints_Entity $entity */ |
347 | - foreach ( $entities->get_all() as $slug => $entity ) { |
|
347 | + foreach ($entities->get_all() as $slug => $entity) { |
|
348 | 348 | |
349 | 349 | $child_data = array(); |
350 | 350 | |
351 | 351 | /** @var WordPoints_EntityishI $child */ |
352 | - foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) { |
|
352 | + foreach ($entity_children->get_children($slug) as $child_slug => $child) { |
|
353 | 353 | |
354 | - $child_data[ $child_slug ] = array( |
|
354 | + $child_data[$child_slug] = array( |
|
355 | 355 | 'slug' => $child_slug, |
356 | 356 | 'title' => $child->get_title(), |
357 | 357 | ); |
358 | 358 | |
359 | - if ( $child instanceof WordPoints_Entity_Attr ) { |
|
359 | + if ($child instanceof WordPoints_Entity_Attr) { |
|
360 | 360 | |
361 | - $child_data[ $child_slug ]['_type'] = 'attr'; |
|
362 | - $child_data[ $child_slug ]['data_type'] = $child->get_data_type(); |
|
361 | + $child_data[$child_slug]['_type'] = 'attr'; |
|
362 | + $child_data[$child_slug]['data_type'] = $child->get_data_type(); |
|
363 | 363 | |
364 | - } elseif ( $child instanceof WordPoints_Entity_Relationship ) { |
|
364 | + } elseif ($child instanceof WordPoints_Entity_Relationship) { |
|
365 | 365 | |
366 | - $child_data[ $child_slug ]['_type'] = 'relationship'; |
|
367 | - $child_data[ $child_slug ]['primary'] = $child->get_primary_entity_slug(); |
|
368 | - $child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug(); |
|
366 | + $child_data[$child_slug]['_type'] = 'relationship'; |
|
367 | + $child_data[$child_slug]['primary'] = $child->get_primary_entity_slug(); |
|
368 | + $child_data[$child_slug]['secondary'] = $child->get_related_entity_slug(); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
@@ -376,10 +376,10 @@ discard block |
||
376 | 376 | * @param array $data The data for the entity child. |
377 | 377 | * @param WordPoints_Entityish $child The child's object. |
378 | 378 | */ |
379 | - $child_data[ $child_slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity_child', $child_data[ $child_slug ], $child ); |
|
379 | + $child_data[$child_slug] = apply_filters('wordpoints_hooks_ui_data_entity_child', $child_data[$child_slug], $child); |
|
380 | 380 | } |
381 | 381 | |
382 | - $entities_data[ $slug ] = array( |
|
382 | + $entities_data[$slug] = array( |
|
383 | 383 | 'slug' => $slug, |
384 | 384 | 'title' => $entity->get_title(), |
385 | 385 | 'children' => $child_data, |
@@ -387,12 +387,12 @@ discard block |
||
387 | 387 | '_type' => 'entity', |
388 | 388 | ); |
389 | 389 | |
390 | - if ( $entity instanceof WordPoints_Entity_EnumerableI ) { |
|
390 | + if ($entity instanceof WordPoints_Entity_EnumerableI) { |
|
391 | 391 | |
392 | 392 | $values = array(); |
393 | 393 | |
394 | - foreach ( $entity->get_enumerated_values() as $value ) { |
|
395 | - if ( $entity->set_the_value( $value ) ) { |
|
394 | + foreach ($entity->get_enumerated_values() as $value) { |
|
395 | + if ($entity->set_the_value($value)) { |
|
396 | 396 | $values[] = array( |
397 | 397 | 'value' => $entity->get_the_id(), |
398 | 398 | 'label' => $entity->get_the_human_id(), |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
403 | - $entities_data[ $slug ]['values'] = $values; |
|
403 | + $entities_data[$slug]['values'] = $values; |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @param array $data The data for the entity. |
410 | 410 | * @param WordPoints_Entity $entity The entity object. |
411 | 411 | */ |
412 | - $entities_data[ $slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity', $entities_data[ $slug ], $entity ); |
|
412 | + $entities_data[$slug] = apply_filters('wordpoints_hooks_ui_data_entity', $entities_data[$slug], $entity); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | $data = array( |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @param array $data The data. |
433 | 433 | */ |
434 | - $data = apply_filters( 'wordpoints_hooks_ui_data', $data ); |
|
434 | + $data = apply_filters('wordpoints_hooks_ui_data', $data); |
|
435 | 435 | |
436 | 436 | wp_localize_script( |
437 | 437 | 'wordpoints-hooks-models' |
@@ -456,13 +456,13 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @return string The HTML with templates appended. |
458 | 458 | */ |
459 | -function wordpoints_script_templates_filter( $html, $handle ) { |
|
459 | +function wordpoints_script_templates_filter($html, $handle) { |
|
460 | 460 | |
461 | 461 | global $wp_scripts; |
462 | 462 | |
463 | - $templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' ); |
|
463 | + $templates = $wp_scripts->get_data($handle, 'wordpoints-templates'); |
|
464 | 464 | |
465 | - if ( $templates ) { |
|
465 | + if ($templates) { |
|
466 | 466 | $html .= $templates; |
467 | 467 | } |
468 | 468 | |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | */ |
479 | 479 | function wordpoints_hooks_admin_ajax() { |
480 | 480 | |
481 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
481 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
482 | 482 | new WordPoints_Admin_Ajax_Hooks; |
483 | 483 | } |
484 | 484 | } |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | ) { |
101 | 101 | |
102 | 102 | return 'wordpoints_create_hook_reaction|' . $reaction_store->get_slug() |
103 | - . '|' . wordpoints_hooks()->get_current_mode() |
|
104 | - . '|' . wp_json_encode( $reaction_store->get_context_id() ); |
|
103 | + . '|' . wordpoints_hooks()->get_current_mode() |
|
104 | + . '|' . wp_json_encode( $reaction_store->get_context_id() ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | WordPoints_Hook_ReactionI $reaction |
132 | 132 | ) { |
133 | 133 | return 'wordpoints_update_hook_reaction|' |
134 | - . wp_json_encode( $reaction->get_guid() ); |
|
134 | + . wp_json_encode( $reaction->get_guid() ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | WordPoints_Hook_ReactionI $reaction |
162 | 162 | ) { |
163 | 163 | return 'wordpoints_delete_hook_reaction|' |
164 | - . wp_json_encode( $reaction->get_guid() ); |
|
164 | + . wp_json_encode( $reaction->get_guid() ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array The hook reaction data extracted into an array. |
54 | 54 | */ |
55 | - public static function prepare_hook_reaction( WordPoints_Hook_ReactionI $reaction ) { |
|
55 | + public static function prepare_hook_reaction(WordPoints_Hook_ReactionI $reaction) { |
|
56 | 56 | |
57 | 57 | return array_merge( |
58 | 58 | $reaction->get_all_meta() |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | 'id' => $reaction->ID, |
61 | 61 | 'event' => $reaction->get_event_slug(), |
62 | 62 | 'reaction_store' => $reaction->get_store_slug(), |
63 | - 'nonce' => self::get_update_nonce( $reaction ), |
|
64 | - 'delete_nonce' => self::get_delete_nonce( $reaction ), |
|
63 | + 'nonce' => self::get_update_nonce($reaction), |
|
64 | + 'delete_nonce' => self::get_delete_nonce($reaction), |
|
65 | 65 | ) |
66 | 66 | ); |
67 | 67 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | WordPoints_Hook_Reaction_StoreI $reaction_store |
82 | 82 | ) { |
83 | 83 | |
84 | - return wp_create_nonce( self::get_create_nonce_action( $reaction_store ) ); |
|
84 | + return wp_create_nonce(self::get_create_nonce_action($reaction_store)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | WordPoints_Hook_Reaction_StoreI $reaction_store |
100 | 100 | ) { |
101 | 101 | |
102 | - return 'wordpoints_create_hook_reaction|' . $reaction_store->get_slug() |
|
103 | - . '|' . wordpoints_hooks()->get_current_mode() |
|
104 | - . '|' . wp_json_encode( $reaction_store->get_context_id() ); |
|
102 | + return 'wordpoints_create_hook_reaction|'.$reaction_store->get_slug() |
|
103 | + . '|'.wordpoints_hooks()->get_current_mode() |
|
104 | + . '|'.wp_json_encode($reaction_store->get_context_id()); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string A nonce for updating this reaction. |
115 | 115 | */ |
116 | - public static function get_update_nonce( WordPoints_Hook_ReactionI $reaction ) { |
|
116 | + public static function get_update_nonce(WordPoints_Hook_ReactionI $reaction) { |
|
117 | 117 | |
118 | - return wp_create_nonce( self::get_update_nonce_action( $reaction ) ); |
|
118 | + return wp_create_nonce(self::get_update_nonce_action($reaction)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | WordPoints_Hook_ReactionI $reaction |
132 | 132 | ) { |
133 | 133 | return 'wordpoints_update_hook_reaction|' |
134 | - . wp_json_encode( $reaction->get_guid() ); |
|
134 | + . wp_json_encode($reaction->get_guid()); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string A nonce for deleting this reaction. |
145 | 145 | */ |
146 | - public static function get_delete_nonce( WordPoints_Hook_ReactionI $reaction ) { |
|
146 | + public static function get_delete_nonce(WordPoints_Hook_ReactionI $reaction) { |
|
147 | 147 | |
148 | - return wp_create_nonce( self::get_delete_nonce_action( $reaction ) ); |
|
148 | + return wp_create_nonce(self::get_delete_nonce_action($reaction)); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | WordPoints_Hook_ReactionI $reaction |
162 | 162 | ) { |
163 | 163 | return 'wordpoints_delete_hook_reaction|' |
164 | - . wp_json_encode( $reaction->get_guid() ); |
|
164 | + . wp_json_encode($reaction->get_guid()); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // |
@@ -187,17 +187,17 @@ discard block |
||
187 | 187 | |
188 | 188 | add_action( |
189 | 189 | 'wp_ajax_wordpoints_admin_create_hook_reaction' |
190 | - , array( $this, 'create_hook_reaction' ) |
|
190 | + , array($this, 'create_hook_reaction') |
|
191 | 191 | ); |
192 | 192 | |
193 | 193 | add_action( |
194 | 194 | 'wp_ajax_wordpoints_admin_update_hook_reaction' |
195 | - , array( $this, 'update_hook_reaction' ) |
|
195 | + , array($this, 'update_hook_reaction') |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | add_action( |
199 | 199 | 'wp_ajax_wordpoints_admin_delete_hook_reaction' |
200 | - , array( $this, 'delete_hook_reaction' ) |
|
200 | + , array($this, 'delete_hook_reaction') |
|
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | |
213 | 213 | $reaction_store = $this->get_reaction_store(); |
214 | 214 | |
215 | - $this->verify_request( $this->get_create_nonce_action( $reaction_store ) ); |
|
215 | + $this->verify_request($this->get_create_nonce_action($reaction_store)); |
|
216 | 216 | |
217 | - $reaction = $reaction_store->create_reaction( $this->get_data() ); |
|
217 | + $reaction = $reaction_store->create_reaction($this->get_data()); |
|
218 | 218 | |
219 | - $this->send_json_result( $reaction, 'create' ); |
|
219 | + $this->send_json_result($reaction, 'create'); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -231,14 +231,14 @@ discard block |
||
231 | 231 | $reaction_store = $this->get_reaction_store(); |
232 | 232 | $reaction = $this->get_reaction(); |
233 | 233 | |
234 | - $this->verify_request( $this->get_update_nonce_action( $reaction ) ); |
|
234 | + $this->verify_request($this->get_update_nonce_action($reaction)); |
|
235 | 235 | |
236 | 236 | $reaction = $reaction_store->update_reaction( |
237 | 237 | $reaction->ID |
238 | 238 | , $this->get_data() |
239 | 239 | ); |
240 | 240 | |
241 | - $this->send_json_result( $reaction, 'update' ); |
|
241 | + $this->send_json_result($reaction, 'update'); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | $reaction_store = $this->get_reaction_store(); |
254 | 254 | $reaction = $this->get_reaction(); |
255 | 255 | |
256 | - $this->verify_request( $this->get_delete_nonce_action( $reaction ) ); |
|
256 | + $this->verify_request($this->get_delete_nonce_action($reaction)); |
|
257 | 257 | |
258 | - $result = $reaction_store->delete_reaction( $reaction->ID ); |
|
258 | + $result = $reaction_store->delete_reaction($reaction->ID); |
|
259 | 259 | |
260 | - if ( ! $result ) { |
|
261 | - wp_send_json_error( array( 'message' => __( 'There was an error deleting the reaction. Please try again.', 'wordpoints' ) ) ); |
|
260 | + if ( ! $result) { |
|
261 | + wp_send_json_error(array('message' => __('There was an error deleting the reaction. Please try again.', 'wordpoints'))); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | wp_send_json_success(); |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @param string $debug_context Context sent with the message (for debugging). |
281 | 281 | */ |
282 | - private function unexpected_error( $debug_context ) { |
|
282 | + private function unexpected_error($debug_context) { |
|
283 | 283 | |
284 | 284 | wp_send_json_error( |
285 | 285 | array( |
286 | - 'message' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
286 | + 'message' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
287 | 287 | 'debug' => $debug_context, |
288 | 288 | ) |
289 | 289 | ); |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | */ |
300 | 300 | private function verify_user_can() { |
301 | 301 | |
302 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
303 | - wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action. Maybe you have been logged out?', 'wordpoints' ) ) ); |
|
302 | + if ( ! current_user_can('manage_options')) { |
|
303 | + wp_send_json_error(array('message' => __('You do not have permission to perform this action. Maybe you have been logged out?', 'wordpoints'))); |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
@@ -313,14 +313,14 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param string $action The action the nonce should be for. |
315 | 315 | */ |
316 | - private function verify_request( $action ) { |
|
316 | + private function verify_request($action) { |
|
317 | 317 | |
318 | 318 | if ( |
319 | - empty( $_POST['nonce'] ) |
|
320 | - || ! wordpoints_verify_nonce( 'nonce', $action, null, 'post' ) |
|
319 | + empty($_POST['nonce']) |
|
320 | + || ! wordpoints_verify_nonce('nonce', $action, null, 'post') |
|
321 | 321 | ) { |
322 | 322 | wp_send_json_error( |
323 | - array( 'message' => __( 'Your security token for this action has expired. Refresh the page and try again.', 'wordpoints' ) ) |
|
323 | + array('message' => __('Your security token for this action has expired. Refresh the page and try again.', 'wordpoints')) |
|
324 | 324 | ); |
325 | 325 | } |
326 | 326 | } |
@@ -334,16 +334,16 @@ discard block |
||
334 | 334 | */ |
335 | 335 | protected function get_reaction_store() { |
336 | 336 | |
337 | - if ( ! isset( $_POST['reaction_store'] ) ) { // WPCS: CSRF OK. |
|
338 | - $this->unexpected_error( 'reaction_store' ); |
|
337 | + if ( ! isset($_POST['reaction_store'])) { // WPCS: CSRF OK. |
|
338 | + $this->unexpected_error('reaction_store'); |
|
339 | 339 | } |
340 | 340 | |
341 | - $reactor_slug = sanitize_key( $_POST['reaction_store'] ); // WPCS: CSRF OK. |
|
341 | + $reactor_slug = sanitize_key($_POST['reaction_store']); // WPCS: CSRF OK. |
|
342 | 342 | |
343 | - $reaction_store = wordpoints_hooks()->get_reaction_store( $reactor_slug ); |
|
343 | + $reaction_store = wordpoints_hooks()->get_reaction_store($reactor_slug); |
|
344 | 344 | |
345 | - if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) { |
|
346 | - $this->unexpected_error( 'reaction_store_invalid' ); |
|
345 | + if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) { |
|
346 | + $this->unexpected_error('reaction_store_invalid'); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | $this->reaction_store_slug = $reactor_slug; |
@@ -361,16 +361,16 @@ discard block |
||
361 | 361 | */ |
362 | 362 | protected function get_reaction() { |
363 | 363 | |
364 | - if ( ! isset( $_POST['id'] ) ) { // WPCS: CSRF OK. |
|
365 | - $this->unexpected_error( 'id' ); |
|
364 | + if ( ! isset($_POST['id'])) { // WPCS: CSRF OK. |
|
365 | + $this->unexpected_error('id'); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | $reaction = $this->reaction_store->get_reaction( |
369 | - wordpoints_int( $_POST['id'] ) // WPCS: CSRF OK. |
|
369 | + wordpoints_int($_POST['id']) // WPCS: CSRF OK. |
|
370 | 370 | ); |
371 | 371 | |
372 | - if ( ! $reaction ) { |
|
373 | - wp_send_json_error( array( 'message' => __( 'The reaction ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints' ) ) ); |
|
372 | + if ( ! $reaction) { |
|
373 | + wp_send_json_error(array('message' => __('The reaction ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints'))); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | return $reaction; |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | */ |
386 | 386 | protected function get_data() { |
387 | 387 | |
388 | - $data = wp_unslash( $_POST ); // WPCS: CSRF OK. |
|
388 | + $data = wp_unslash($_POST); // WPCS: CSRF OK. |
|
389 | 389 | |
390 | - unset( $data['id'], $data['action'], $data['nonce'], $data['reaction_store'] ); |
|
390 | + unset($data['id'], $data['action'], $data['nonce'], $data['reaction_store']); |
|
391 | 391 | |
392 | 392 | return $data; |
393 | 393 | } |
@@ -400,30 +400,30 @@ discard block |
||
400 | 400 | * @param mixed $result The result of the action. |
401 | 401 | * @param string $action The action being performed: 'create' or 'update'. |
402 | 402 | */ |
403 | - private function send_json_result( $result, $action ) { |
|
403 | + private function send_json_result($result, $action) { |
|
404 | 404 | |
405 | - if ( ! $result ) { |
|
405 | + if ( ! $result) { |
|
406 | 406 | |
407 | - if ( 'create' === $action ) { |
|
408 | - $message = __( 'There was an error adding the reaction. Please try again.', 'wordpoints' ); |
|
407 | + if ('create' === $action) { |
|
408 | + $message = __('There was an error adding the reaction. Please try again.', 'wordpoints'); |
|
409 | 409 | } else { |
410 | - $message = __( 'There was an error updating the reaction. Please try again.', 'wordpoints' ); |
|
410 | + $message = __('There was an error updating the reaction. Please try again.', 'wordpoints'); |
|
411 | 411 | } |
412 | 412 | |
413 | - wp_send_json_error( array( 'message' => $message ) ); |
|
413 | + wp_send_json_error(array('message' => $message)); |
|
414 | 414 | |
415 | - } elseif ( $result instanceof WordPoints_Hook_Reaction_Validator ) { |
|
415 | + } elseif ($result instanceof WordPoints_Hook_Reaction_Validator) { |
|
416 | 416 | |
417 | - wp_send_json_error( array( 'errors' => $result->get_errors() ) ); |
|
417 | + wp_send_json_error(array('errors' => $result->get_errors())); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | $data = null; |
421 | 421 | |
422 | - if ( 'create' === $action ) { |
|
423 | - $data = self::prepare_hook_reaction( $result ); |
|
422 | + if ('create' === $action) { |
|
423 | + $data = self::prepare_hook_reaction($result); |
|
424 | 424 | } |
425 | 425 | |
426 | - wp_send_json_success( $data ); |
|
426 | + wp_send_json_success($data); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 |
@@ -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,54 +304,54 @@ 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 | $data = array(); |
312 | 312 | |
313 | - $reaction_store = wordpoints_hooks()->get_reaction_store( 'points' ); |
|
313 | + $reaction_store = wordpoints_hooks()->get_reaction_store('points'); |
|
314 | 314 | |
315 | - foreach ( $reaction_store->get_reactions_to_event( $event_slug ) as $id => $reaction ) { |
|
316 | - if ( $reaction->get_meta( 'points_type' ) === $this->current_points_type ) { |
|
315 | + foreach ($reaction_store->get_reactions_to_event($event_slug) as $id => $reaction) { |
|
316 | + if ($reaction->get_meta('points_type') === $this->current_points_type) { |
|
317 | 317 | $data[] = WordPoints_Admin_Ajax_Hooks::prepare_hook_reaction( |
318 | 318 | $reaction |
319 | 319 | ); |
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - $args = $this->hooks->events->args->get_children( $event_slug ); |
|
323 | + $args = $this->hooks->events->args->get_children($event_slug); |
|
324 | 324 | |
325 | - $event_data = array( 'args' => array() ); |
|
325 | + $event_data = array('args' => array()); |
|
326 | 326 | |
327 | - foreach ( $args as $slug => $arg ) { |
|
327 | + foreach ($args as $slug => $arg) { |
|
328 | 328 | |
329 | - $event_data['args'][ $slug ] = array( |
|
329 | + $event_data['args'][$slug] = array( |
|
330 | 330 | 'slug' => $slug, |
331 | 331 | ); |
332 | 332 | |
333 | - if ( $arg instanceof WordPoints_Hook_Arg ) { |
|
334 | - $event_data['args'][ $slug ]['title'] = $arg->get_title(); |
|
335 | - $event_data['args'][ $slug ]['is_stateful'] = $arg->is_stateful(); |
|
333 | + if ($arg instanceof WordPoints_Hook_Arg) { |
|
334 | + $event_data['args'][$slug]['title'] = $arg->get_title(); |
|
335 | + $event_data['args'][$slug]['is_stateful'] = $arg->is_stateful(); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | 339 | ?> |
340 | 340 | |
341 | 341 | <script> |
342 | - WordPointsHooksAdminData.events[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $event_data ); ?>; |
|
343 | - WordPointsHooksAdminData.reactions[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $data ); ?>; |
|
342 | + WordPointsHooksAdminData.events[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($event_data); ?>; |
|
343 | + WordPointsHooksAdminData.reactions[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($data); ?>; |
|
344 | 344 | </script> |
345 | 345 | |
346 | 346 | <div class="wordpoints-hook-reaction-group-container"> |
347 | 347 | <p class="description wordpoints-hook-reaction-group-description"> |
348 | - <?php echo esc_html( $meta_box['args']['event']->get_description() ); ?> |
|
348 | + <?php echo esc_html($meta_box['args']['event']->get_description()); ?> |
|
349 | 349 | </p> |
350 | 350 | |
351 | 351 | <div class="wordpoints-hook-reaction-group" |
352 | - data-wordpoints-hooks-hook-event="<?php echo esc_attr( $event_slug ); ?>" |
|
353 | - data-wordpoints-hooks-points-type="<?php echo esc_attr( $this->current_points_type ); ?>" |
|
354 | - data-wordpoints-hooks-create-nonce="<?php echo esc_attr( WordPoints_Admin_Ajax_Hooks::get_create_nonce( $reaction_store ) ); ?>" |
|
352 | + data-wordpoints-hooks-hook-event="<?php echo esc_attr($event_slug); ?>" |
|
353 | + data-wordpoints-hooks-points-type="<?php echo esc_attr($this->current_points_type); ?>" |
|
354 | + data-wordpoints-hooks-create-nonce="<?php echo esc_attr(WordPoints_Admin_Ajax_Hooks::get_create_nonce($reaction_store)); ?>" |
|
355 | 355 | data-wordpoints-hooks-reaction-store="points" |
356 | 356 | data-wordpoints-hooks-reactor="points"> |
357 | 357 | </div> |
@@ -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 |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param WordPoints_Class_Registry_Persistent $reactors The reactors registry. |
35 | 35 | */ |
36 | -function wordpoints_hook_reactors_init( $reactors ) { |
|
36 | +function wordpoints_hook_reactors_init($reactors) { |
|
37 | 37 | |
38 | - $reactors->register( 'points', 'WordPoints_Hook_Reactor_Points' ); |
|
38 | + $reactors->register('points', 'WordPoints_Hook_Reactor_Points'); |
|
39 | 39 | |
40 | 40 | $router = wordpoints_hooks()->router; |
41 | 41 | |
42 | - $router->add_action_type_to_reactor( 'fire', 'points', 'award' ); |
|
43 | - $router->add_action_type_to_reactor( 'toggle_on', 'points', 'award' ); |
|
44 | - $router->add_action_type_to_reactor( 'toggle_off', 'points', 'reverse' ); |
|
42 | + $router->add_action_type_to_reactor('fire', 'points', 'award'); |
|
43 | + $router->add_action_type_to_reactor('toggle_on', 'points', 'award'); |
|
44 | + $router->add_action_type_to_reactor('toggle_off', 'points', 'reverse'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param WordPoints_Class_Registry_Children $reaction_stores The store registry. |
55 | 55 | */ |
56 | -function wordpoints_hook_reaction_stores_init( $reaction_stores ) { |
|
56 | +function wordpoints_hook_reaction_stores_init($reaction_stores) { |
|
57 | 57 | |
58 | 58 | $reaction_stores->register( |
59 | 59 | 'standard' |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | , 'WordPoints_Hook_Reaction_Store_Options' |
62 | 62 | ); |
63 | 63 | |
64 | - if ( is_wordpoints_network_active() ) { |
|
64 | + if (is_wordpoints_network_active()) { |
|
65 | 65 | $reaction_stores->register( |
66 | 66 | 'network' |
67 | 67 | , 'points' |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param WordPoints_Class_Registry_Persistent $extensions The extension registry. |
81 | 81 | */ |
82 | -function wordpoints_hook_extension_init( $extensions ) { |
|
82 | +function wordpoints_hook_extension_init($extensions) { |
|
83 | 83 | |
84 | - $extensions->register( 'blocker', 'WordPoints_Hook_Extension_Blocker' ); |
|
85 | - $extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' ); |
|
86 | - $extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' ); |
|
84 | + $extensions->register('blocker', 'WordPoints_Hook_Extension_Blocker'); |
|
85 | + $extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions'); |
|
86 | + $extensions->register('periods', 'WordPoints_Hook_Extension_Periods'); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param WordPoints_Class_Registry_Children $conditions The conditions registry. |
97 | 97 | */ |
98 | -function wordpoints_hook_conditions_init( $conditions ) { |
|
98 | +function wordpoints_hook_conditions_init($conditions) { |
|
99 | 99 | |
100 | 100 | $conditions->register( |
101 | 101 | 'text' |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @param WordPoints_Hook_Actions $actions The action registry. |
133 | 133 | */ |
134 | -function wordpoints_hook_actions_init( $actions ) { |
|
134 | +function wordpoints_hook_actions_init($actions) { |
|
135 | 135 | |
136 | 136 | $actions->register( |
137 | 137 | 'comment_approve' |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | , array( |
140 | 140 | 'action' => 'transition_comment_status', |
141 | 141 | 'data' => array( |
142 | - 'arg_index' => array( 'comment' => 2 ), |
|
143 | - 'requirements' => array( 0 => 'approved' ), |
|
142 | + 'arg_index' => array('comment' => 2), |
|
143 | + 'requirements' => array(0 => 'approved'), |
|
144 | 144 | ), |
145 | 145 | ) |
146 | 146 | ); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | , array( |
152 | 152 | 'action' => 'wp_insert_comment', |
153 | 153 | 'data' => array( |
154 | - 'arg_index' => array( 'comment' => 1 ), |
|
154 | + 'arg_index' => array('comment' => 1), |
|
155 | 155 | ), |
156 | 156 | ) |
157 | 157 | ); |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | , array( |
163 | 163 | 'action' => 'transition_comment_status', |
164 | 164 | 'data' => array( |
165 | - 'arg_index' => array( 'comment' => 2 ), |
|
166 | - 'requirements' => array( 1 => 'approved' ), |
|
165 | + 'arg_index' => array('comment' => 2), |
|
166 | + 'requirements' => array(1 => 'approved'), |
|
167 | 167 | ), |
168 | 168 | ) |
169 | 169 | ); |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | , array( |
176 | 176 | 'action' => 'transition_post_status', |
177 | 177 | 'data' => array( |
178 | - 'arg_index' => array( 'post' => 2 ), |
|
179 | - 'requirements' => array( 0 => 'publish' ), |
|
178 | + 'arg_index' => array('post' => 2), |
|
179 | + 'requirements' => array(0 => 'publish'), |
|
180 | 180 | ), |
181 | 181 | ) |
182 | 182 | ); |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | , array( |
188 | 188 | 'action' => 'transition_post_status', |
189 | 189 | 'data' => array( |
190 | - 'arg_index' => array( 'post' => 2 ), |
|
191 | - 'requirements' => array( 1 => 'publish' ), |
|
190 | + 'arg_index' => array('post' => 2), |
|
191 | + 'requirements' => array(1 => 'publish'), |
|
192 | 192 | ), |
193 | 193 | ) |
194 | 194 | ); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | , array( |
200 | 200 | 'action' => 'add_attachment', |
201 | 201 | 'data' => array( |
202 | - 'arg_index' => array( 'post\attachment' => 0 ), |
|
202 | + 'arg_index' => array('post\attachment' => 0), |
|
203 | 203 | ), |
204 | 204 | ) |
205 | 205 | ); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | , array( |
211 | 211 | 'action' => 'delete_post', |
212 | 212 | 'data' => array( |
213 | - 'arg_index' => array( 'post' => 0 ), |
|
213 | + 'arg_index' => array('post' => 0), |
|
214 | 214 | ), |
215 | 215 | ) |
216 | 216 | ); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | , array( |
222 | 222 | 'action' => 'user_register', |
223 | 223 | 'data' => array( |
224 | - 'arg_index' => array( 'user' => 0 ), |
|
224 | + 'arg_index' => array('user' => 0), |
|
225 | 225 | ), |
226 | 226 | ) |
227 | 227 | ); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | , array( |
233 | 233 | 'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user', |
234 | 234 | 'data' => array( |
235 | - 'arg_index' => array( 'user' => 0 ), |
|
235 | + 'arg_index' => array('user' => 0), |
|
236 | 236 | ), |
237 | 237 | ) |
238 | 238 | ); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @param WordPoints_Hook_Events $events The event registry. |
257 | 257 | */ |
258 | -function wordpoints_hook_events_init( $events ) { |
|
258 | +function wordpoints_hook_events_init($events) { |
|
259 | 259 | |
260 | 260 | $events->register( |
261 | 261 | 'user_register' |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | ); |
286 | 286 | |
287 | 287 | // Register events for all of the public post types. |
288 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
288 | + $post_types = get_post_types(array('public' => true)); |
|
289 | 289 | |
290 | 290 | /** |
291 | 291 | * Filter which post types to register hook events for. |
@@ -294,20 +294,20 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @param string[] The post type slugs ("names"). |
296 | 296 | */ |
297 | - $post_types = apply_filters( 'wordpoints_register_hook_events_for_post_types', $post_types ); |
|
297 | + $post_types = apply_filters('wordpoints_register_hook_events_for_post_types', $post_types); |
|
298 | 298 | |
299 | - foreach ( $post_types as $slug ) { |
|
300 | - wordpoints_register_post_type_hook_events( $slug ); |
|
299 | + foreach ($post_types as $slug) { |
|
300 | + wordpoints_register_post_type_hook_events($slug); |
|
301 | 301 | } |
302 | 302 | |
303 | - if ( is_multisite() ) { |
|
303 | + if (is_multisite()) { |
|
304 | 304 | |
305 | 305 | $event_slugs = array( |
306 | 306 | 'user_visit', |
307 | 307 | 'user_register', |
308 | 308 | ); |
309 | 309 | |
310 | - foreach ( $event_slugs as $event_slug ) { |
|
310 | + foreach ($event_slugs as $event_slug) { |
|
311 | 311 | // TODO network hooks |
312 | 312 | $events->args->register( |
313 | 313 | $event_slug |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @param WordPoints_App_Registry $entities The entities app. |
329 | 329 | */ |
330 | -function wordpoints_entities_app_init( $entities ) { |
|
330 | +function wordpoints_entities_app_init($entities) { |
|
331 | 331 | |
332 | - $entities->sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' ); |
|
333 | - $entities->sub_apps->register( 'contexts', 'WordPoints_Class_Registry' ); |
|
332 | + $entities->sub_apps->register('children', 'WordPoints_Class_Registry_Children'); |
|
333 | + $entities->sub_apps->register('contexts', 'WordPoints_Class_Registry'); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -342,10 +342,10 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @param WordPoints_Class_Registry $contexts The entity context registry. |
344 | 344 | */ |
345 | -function wordpoints_entity_contexts_init( $contexts ) { |
|
345 | +function wordpoints_entity_contexts_init($contexts) { |
|
346 | 346 | |
347 | - $contexts->register( 'network', 'WordPoints_Entity_Context_Network' ); |
|
348 | - $contexts->register( 'site', 'WordPoints_Entity_Context_Site' ); |
|
347 | + $contexts->register('network', 'WordPoints_Entity_Context_Network'); |
|
348 | + $contexts->register('site', 'WordPoints_Entity_Context_Site'); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
@@ -357,18 +357,18 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @param WordPoints_App_Registry $entities The entities app. |
359 | 359 | */ |
360 | -function wordpoints_entities_init( $entities ) { |
|
360 | +function wordpoints_entities_init($entities) { |
|
361 | 361 | |
362 | 362 | $children = $entities->children; |
363 | 363 | |
364 | - $entities->register( 'user', 'WordPoints_Entity_User' ); |
|
365 | - $children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' ); |
|
364 | + $entities->register('user', 'WordPoints_Entity_User'); |
|
365 | + $children->register('user', 'roles', 'WordPoints_Entity_User_Roles'); |
|
366 | 366 | |
367 | - $entities->register( 'user_role', 'WordPoints_Entity_User_Role' ); |
|
368 | - $children->register( 'user_role', 'name', 'WordPoints_Entity_User_Role_Name' ); |
|
367 | + $entities->register('user_role', 'WordPoints_Entity_User_Role'); |
|
368 | + $children->register('user_role', 'name', 'WordPoints_Entity_User_Role_Name'); |
|
369 | 369 | |
370 | 370 | // Register entities for all of the public post types. |
371 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
371 | + $post_types = get_post_types(array('public' => true)); |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Filter which post types to register entities for. |
@@ -377,14 +377,14 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @param string[] The post type slugs ("names"). |
379 | 379 | */ |
380 | - $post_types = apply_filters( 'wordpoints_register_entities_for_post_types', $post_types ); |
|
380 | + $post_types = apply_filters('wordpoints_register_entities_for_post_types', $post_types); |
|
381 | 381 | |
382 | - foreach ( $post_types as $slug ) { |
|
383 | - wordpoints_register_post_type_entities( $slug ); |
|
382 | + foreach ($post_types as $slug) { |
|
383 | + wordpoints_register_post_type_entities($slug); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | // Register entities for all of the public taxonomies. |
387 | - $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
387 | + $taxonomies = get_taxonomies(array('public' => true)); |
|
388 | 388 | |
389 | 389 | /** |
390 | 390 | * Filter which taxonomies to register entities for. |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @param string[] The taxonomy slugs. |
395 | 395 | */ |
396 | - $taxonomies = apply_filters( 'wordpoints_register_entities_for_taxonomies', $taxonomies ); |
|
396 | + $taxonomies = apply_filters('wordpoints_register_entities_for_taxonomies', $taxonomies); |
|
397 | 397 | |
398 | - foreach ( $taxonomies as $slug ) { |
|
399 | - wordpoints_register_taxonomy_entities( $slug ); |
|
398 | + foreach ($taxonomies as $slug) { |
|
399 | + wordpoints_register_taxonomy_entities($slug); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
@@ -407,28 +407,28 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @param string $slug The slug of the post type. |
409 | 409 | */ |
410 | -function wordpoints_register_post_type_entities( $slug ) { |
|
410 | +function wordpoints_register_post_type_entities($slug) { |
|
411 | 411 | |
412 | 412 | $entities = wordpoints_entities(); |
413 | 413 | $children = $entities->children; |
414 | 414 | |
415 | - $entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' ); |
|
416 | - $children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' ); |
|
415 | + $entities->register("post\\{$slug}", 'WordPoints_Entity_Post'); |
|
416 | + $children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author'); |
|
417 | 417 | |
418 | - $supports = get_all_post_type_supports( $slug ); |
|
418 | + $supports = get_all_post_type_supports($slug); |
|
419 | 419 | |
420 | - if ( isset( $supports['editor'] ) ) { |
|
421 | - $children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' ); |
|
420 | + if (isset($supports['editor'])) { |
|
421 | + $children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content'); |
|
422 | 422 | } |
423 | 423 | |
424 | - if ( isset( $supports['comments'] ) ) { |
|
425 | - $entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' ); |
|
426 | - $children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' ); |
|
427 | - $children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' ); |
|
424 | + if (isset($supports['comments'])) { |
|
425 | + $entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment'); |
|
426 | + $children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post'); |
|
427 | + $children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author'); |
|
428 | 428 | } |
429 | 429 | |
430 | - foreach ( get_object_taxonomies( $slug ) as $taxonomy_slug ) { |
|
431 | - $children->register( "post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms' ); |
|
430 | + foreach (get_object_taxonomies($slug) as $taxonomy_slug) { |
|
431 | + $children->register("post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * |
439 | 439 | * @param string $slug The slug ("name") of the post type. |
440 | 440 | */ |
441 | - do_action( 'wordpoints_register_post_type_entities', $slug ); |
|
441 | + do_action('wordpoints_register_post_type_entities', $slug); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -448,13 +448,13 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @param string $slug The slug of the post type. |
450 | 450 | */ |
451 | -function wordpoints_register_post_type_hook_events( $slug ) { |
|
451 | +function wordpoints_register_post_type_hook_events($slug) { |
|
452 | 452 | |
453 | 453 | $event_slugs = array(); |
454 | 454 | |
455 | 455 | $events = wordpoints_hooks()->events; |
456 | 456 | |
457 | - if ( 'attachment' === $slug ) { |
|
457 | + if ('attachment' === $slug) { |
|
458 | 458 | |
459 | 459 | $event_slugs[] = 'media_upload'; |
460 | 460 | |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | , array( |
483 | 483 | 'actions' => array( |
484 | 484 | 'toggle_on' => 'post_publish', |
485 | - 'toggle_off' => array( 'post_depublish', 'post_delete' ), |
|
485 | + 'toggle_off' => array('post_depublish', 'post_delete'), |
|
486 | 486 | ), |
487 | 487 | 'args' => array( |
488 | 488 | "post\\{$slug}" => 'WordPoints_Hook_Arg_Dynamic', |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | ); |
492 | 492 | } |
493 | 493 | |
494 | - if ( post_type_supports( $slug, 'comments' ) ) { |
|
494 | + if (post_type_supports($slug, 'comments')) { |
|
495 | 495 | |
496 | 496 | $event_slugs[] = "comment_leave\\{$slug}"; |
497 | 497 | |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | , 'WordPoints_Hook_Event_Comment_Leave' |
501 | 501 | , array( |
502 | 502 | 'actions' => array( |
503 | - 'toggle_on' => array( 'comment_approve', 'comment_new' ), |
|
503 | + 'toggle_on' => array('comment_approve', 'comment_new'), |
|
504 | 504 | 'toggle_off' => 'comment_deapprove', |
505 | 505 | ), |
506 | 506 | 'args' => array( |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | ); |
511 | 511 | } |
512 | 512 | |
513 | - if ( is_multisite() ) { |
|
514 | - foreach ( $event_slugs as $event_slug ) { |
|
513 | + if (is_multisite()) { |
|
514 | + foreach ($event_slugs as $event_slug) { |
|
515 | 515 | $events->args->register( |
516 | 516 | $event_slug |
517 | 517 | , 'current:site' |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @param string $slug The slug ("name") of the post type. |
529 | 529 | */ |
530 | - do_action( 'wordpoints_register_post_type_hook_events', $slug ); |
|
530 | + do_action('wordpoints_register_post_type_hook_events', $slug); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
@@ -537,13 +537,13 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @param string $slug The slug of the taxonomy. |
539 | 539 | */ |
540 | -function wordpoints_register_taxonomy_entities( $slug ) { |
|
540 | +function wordpoints_register_taxonomy_entities($slug) { |
|
541 | 541 | |
542 | 542 | $entities = wordpoints_entities(); |
543 | 543 | $children = $entities->children; |
544 | 544 | |
545 | - $entities->register( "term\\{$slug}", 'WordPoints_Entity_Term' ); |
|
546 | - $children->register( "term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id' ); |
|
545 | + $entities->register("term\\{$slug}", 'WordPoints_Entity_Term'); |
|
546 | + $children->register("term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id'); |
|
547 | 547 | |
548 | 548 | /** |
549 | 549 | * Fired when registering the entities for a taxonomy. |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @param string $slug The taxonomy's slug. |
554 | 554 | */ |
555 | - do_action( 'wordpoints_register_taxonomy_entities', $slug ); |
|
555 | + do_action('wordpoints_register_taxonomy_entities', $slug); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -564,10 +564,10 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @param WordPoints_Class_RegistryI $data_types The data types registry. |
566 | 566 | */ |
567 | -function wordpoints_data_types_init( $data_types ) { |
|
567 | +function wordpoints_data_types_init($data_types) { |
|
568 | 568 | |
569 | - $data_types->register( 'integer', 'WordPoints_Data_Type_Integer' ); |
|
570 | - $data_types->register( 'text', 'WordPoints_Data_Type_Text' ); |
|
569 | + $data_types->register('integer', 'WordPoints_Data_Type_Integer'); |
|
570 | + $data_types->register('text', 'WordPoints_Data_Type_Text'); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | /** |
@@ -582,9 +582,9 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @return bool Whether the user can view the points log. |
584 | 584 | */ |
585 | -function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) { |
|
585 | +function wordpoints_hooks_user_can_view_points_log($can_view, $log) { |
|
586 | 586 | |
587 | - if ( ! $can_view ) { |
|
587 | + if ( ! $can_view) { |
|
588 | 588 | return $can_view; |
589 | 589 | } |
590 | 590 | |
@@ -593,11 +593,11 @@ discard block |
||
593 | 593 | $event_slug = $log->log_type; |
594 | 594 | |
595 | 595 | /** @var WordPoints_Hook_Arg $arg */ |
596 | - foreach ( wordpoints_hooks()->events->args->get_children( $event_slug ) as $slug => $arg ) { |
|
596 | + foreach (wordpoints_hooks()->events->args->get_children($event_slug) as $slug => $arg) { |
|
597 | 597 | |
598 | - $value = wordpoints_get_points_log_meta( $log->id, $slug, true ); |
|
598 | + $value = wordpoints_get_points_log_meta($log->id, $slug, true); |
|
599 | 599 | |
600 | - if ( ! $value ) { |
|
600 | + if ( ! $value) { |
|
601 | 601 | continue; |
602 | 602 | } |
603 | 603 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | , $value |
608 | 608 | ); |
609 | 609 | |
610 | - if ( ! $can_view ) { |
|
610 | + if ( ! $can_view) { |
|
611 | 611 | break; |
612 | 612 | } |
613 | 613 | } |
@@ -626,20 +626,20 @@ discard block |
||
626 | 626 | * |
627 | 627 | * @return bool Whether the user can view this entity. |
628 | 628 | */ |
629 | -function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) { |
|
629 | +function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) { |
|
630 | 630 | |
631 | - $entity = wordpoints_entities()->get( $entity_slug ); |
|
631 | + $entity = wordpoints_entities()->get($entity_slug); |
|
632 | 632 | |
633 | 633 | // If this entity type is not found, we have no way of determining whether it is |
634 | 634 | // safe for the user to view it. |
635 | - if ( ! ( $entity instanceof WordPoints_Entity ) ) { |
|
635 | + if ( ! ($entity instanceof WordPoints_Entity)) { |
|
636 | 636 | return false; |
637 | 637 | } |
638 | 638 | |
639 | 639 | $can_view = true; |
640 | 640 | |
641 | - if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) { |
|
642 | - $can_view = $entity->user_can_view( $user_id, $entity_id ); |
|
641 | + if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) { |
|
642 | + $can_view = $entity->user_can_view($user_id, $entity_id); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -670,8 +670,8 @@ discard block |
||
670 | 670 | */ |
671 | 671 | function wordpoints_apps() { |
672 | 672 | |
673 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
674 | - WordPoints_App::$main = new WordPoints_App( 'apps' ); |
|
673 | + if ( ! isset(WordPoints_App::$main)) { |
|
674 | + WordPoints_App::$main = new WordPoints_App('apps'); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | return WordPoints_App::$main; |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | */ |
687 | 687 | function wordpoints_hooks() { |
688 | 688 | |
689 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
689 | + if ( ! isset(WordPoints_App::$main)) { |
|
690 | 690 | wordpoints_apps(); |
691 | 691 | } |
692 | 692 | |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | */ |
703 | 703 | function wordpoints_entities() { |
704 | 704 | |
705 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
705 | + if ( ! isset(WordPoints_App::$main)) { |
|
706 | 706 | wordpoints_apps(); |
707 | 707 | } |
708 | 708 | |
@@ -718,13 +718,13 @@ discard block |
||
718 | 718 | * |
719 | 719 | * @param WordPoints_App $app The main apps app. |
720 | 720 | */ |
721 | -function wordpoints_apps_init( $app ) { |
|
721 | +function wordpoints_apps_init($app) { |
|
722 | 722 | |
723 | 723 | $apps = $app->sub_apps; |
724 | 724 | |
725 | - $apps->register( 'hooks', 'WordPoints_Hooks' ); |
|
726 | - $apps->register( 'entities', 'WordPoints_App_Registry' ); |
|
727 | - $apps->register( 'data_types', 'WordPoints_Class_Registry' ); |
|
725 | + $apps->register('hooks', 'WordPoints_Hooks'); |
|
726 | + $apps->register('entities', 'WordPoints_App_Registry'); |
|
727 | + $apps->register('data_types', 'WordPoints_Class_Registry'); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
@@ -737,19 +737,19 @@ discard block |
||
737 | 737 | * |
738 | 738 | * @return object|false The constructed object, or false if to many args were passed. |
739 | 739 | */ |
740 | -function wordpoints_construct_class_with_args( $class_name, array $args ) { |
|
740 | +function wordpoints_construct_class_with_args($class_name, array $args) { |
|
741 | 741 | |
742 | - switch ( count( $args ) ) { |
|
742 | + switch (count($args)) { |
|
743 | 743 | case 0: |
744 | 744 | return new $class_name(); |
745 | 745 | case 1: |
746 | - return new $class_name( $args[0] ); |
|
746 | + return new $class_name($args[0]); |
|
747 | 747 | case 2: |
748 | - return new $class_name( $args[0], $args[1] ); |
|
748 | + return new $class_name($args[0], $args[1]); |
|
749 | 749 | case 3: |
750 | - return new $class_name( $args[0], $args[1], $args[2] ); |
|
750 | + return new $class_name($args[0], $args[1], $args[2]); |
|
751 | 751 | case 4: |
752 | - return new $class_name( $args[0], $args[1], $args[2], $args[3] ); |
|
752 | + return new $class_name($args[0], $args[1], $args[2], $args[3]); |
|
753 | 753 | default: |
754 | 754 | return false; |
755 | 755 | } |
@@ -771,13 +771,13 @@ discard block |
||
771 | 771 | * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the |
772 | 772 | * slug is not dynamic, the value of each of those keys will be false. |
773 | 773 | */ |
774 | -function wordpoints_parse_dynamic_slug( $slug ) { |
|
774 | +function wordpoints_parse_dynamic_slug($slug) { |
|
775 | 775 | |
776 | - $parsed = array( 'dynamic' => false, 'generic' => false ); |
|
776 | + $parsed = array('dynamic' => false, 'generic' => false); |
|
777 | 777 | |
778 | - $parts = explode( '\\', $slug, 2 ); |
|
778 | + $parts = explode('\\', $slug, 2); |
|
779 | 779 | |
780 | - if ( isset( $parts[1] ) ) { |
|
780 | + if (isset($parts[1])) { |
|
781 | 781 | $parsed['dynamic'] = $parts[1]; |
782 | 782 | $parsed['generic'] = $parts[0]; |
783 | 783 | } |
@@ -816,28 +816,28 @@ discard block |
||
816 | 816 | * contexts, indexed by context slug, or false if any of the |
817 | 817 | * contexts isn't current. |
818 | 818 | */ |
819 | -function wordpoints_entities_get_current_context_id( $slug ) { |
|
819 | +function wordpoints_entities_get_current_context_id($slug) { |
|
820 | 820 | |
821 | 821 | $current_context = array(); |
822 | 822 | |
823 | 823 | /** @var WordPoints_Class_Registry $contexts */ |
824 | 824 | $contexts = wordpoints_entities()->contexts; |
825 | 825 | |
826 | - while ( $slug ) { |
|
826 | + while ($slug) { |
|
827 | 827 | |
828 | - $context = $contexts->get( $slug ); |
|
828 | + $context = $contexts->get($slug); |
|
829 | 829 | |
830 | - if ( ! $context instanceof WordPoints_Entity_Context ) { |
|
830 | + if ( ! $context instanceof WordPoints_Entity_Context) { |
|
831 | 831 | return false; |
832 | 832 | } |
833 | 833 | |
834 | 834 | $id = $context->get_current_id(); |
835 | 835 | |
836 | - if ( false === $id ) { |
|
836 | + if (false === $id) { |
|
837 | 837 | return false; |
838 | 838 | } |
839 | 839 | |
840 | - $current_context[ $slug ] = $id; |
|
840 | + $current_context[$slug] = $id; |
|
841 | 841 | |
842 | 842 | $slug = $context->get_parent_slug(); |
843 | 843 | } |
@@ -858,22 +858,22 @@ discard block |
||
858 | 858 | */ |
859 | 859 | function wordpoints_is_network_context() { |
860 | 860 | |
861 | - if ( ! is_multisite() ) { |
|
861 | + if ( ! is_multisite()) { |
|
862 | 862 | return false; |
863 | 863 | } |
864 | 864 | |
865 | - if ( is_network_admin() ) { |
|
865 | + if (is_network_admin()) { |
|
866 | 866 | return true; |
867 | 867 | } |
868 | 868 | |
869 | 869 | // See https://core.trac.wordpress.org/ticket/22589 |
870 | 870 | if ( |
871 | - defined( 'DOING_AJAX' ) |
|
871 | + defined('DOING_AJAX') |
|
872 | 872 | && DOING_AJAX |
873 | - && isset( $_SERVER['HTTP_REFERER'] ) |
|
873 | + && isset($_SERVER['HTTP_REFERER']) |
|
874 | 874 | && preg_match( |
875 | - '#^' . preg_quote( network_admin_url(), '#' ) . '#i' |
|
876 | - , esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) |
|
875 | + '#^'.preg_quote(network_admin_url(), '#').'#i' |
|
876 | + , esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER'])) |
|
877 | 877 | ) |
878 | 878 | ) { |
879 | 879 | return true; |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @param bool $in_network_context Whether we are in network context. |
888 | 888 | */ |
889 | - return apply_filters( 'wordpoints_is_network_context', false ); |
|
889 | + return apply_filters('wordpoints_is_network_context', false); |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | /** |
@@ -900,21 +900,21 @@ discard block |
||
900 | 900 | * |
901 | 901 | * @return string The primary arg's GUID, JSON encoded. |
902 | 902 | */ |
903 | -function wordpoints_hooks_get_event_primary_arg_guid_json( WordPoints_Hook_Event_Args $event_args ) { |
|
903 | +function wordpoints_hooks_get_event_primary_arg_guid_json(WordPoints_Hook_Event_Args $event_args) { |
|
904 | 904 | |
905 | 905 | $entity = $event_args->get_primary_arg(); |
906 | 906 | |
907 | - if ( ! $entity ) { |
|
907 | + if ( ! $entity) { |
|
908 | 908 | return ''; |
909 | 909 | } |
910 | 910 | |
911 | 911 | $the_guid = $entity->get_the_guid(); |
912 | 912 | |
913 | - if ( ! $the_guid ) { |
|
913 | + if ( ! $the_guid) { |
|
914 | 914 | return ''; |
915 | 915 | } |
916 | 916 | |
917 | - return wp_json_encode( $the_guid ); |
|
917 | + return wp_json_encode($the_guid); |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | /** |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | */ |
928 | 928 | function wordpoints_hooks_api_add_global_cache_groups() { |
929 | 929 | |
930 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
930 | + if (function_exists('wp_cache_add_global_groups')) { |
|
931 | 931 | |
932 | 932 | wp_cache_add_global_groups( |
933 | 933 | array( |
@@ -953,8 +953,8 @@ discard block |
||
953 | 953 | * @return string The escaped identifier. Already quoted, do not place within |
954 | 954 | * backticks. |
955 | 955 | */ |
956 | -function wordpoints_escape_mysql_identifier( $identifier ) { |
|
957 | - return '`' . str_replace( '`', '``', $identifier ) . '`'; |
|
956 | +function wordpoints_escape_mysql_identifier($identifier) { |
|
957 | + return '`'.str_replace('`', '``', $identifier).'`'; |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | // EOF |
@@ -37,8 +37,8 @@ |
||
37 | 37 | /** |
38 | 38 | * @since 1.0.0 |
39 | 39 | */ |
40 | - protected function get_attr_value_from_entity( WordPoints_Entity $entity ) { |
|
41 | - return $entity->get_the_attr_value( $this->field ); |
|
40 | + protected function get_attr_value_from_entity(WordPoints_Entity $entity) { |
|
41 | + return $entity->get_the_attr_value($this->field); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -31,7 +31,7 @@ |
||
31 | 31 | public function get_storage_info() { |
32 | 32 | return array( |
33 | 33 | 'type' => 'array', |
34 | - 'info' => array( 'type' => 'method' ), |
|
34 | + 'info' => array('type' => 'method'), |
|
35 | 35 | ); |
36 | 36 | } |
37 | 37 | } |
@@ -34,8 +34,8 @@ |
||
34 | 34 | /** |
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | - protected function get_related_entity_ids( WordPoints_Entity $entity ) { |
|
38 | - return $entity->get_the_attr_value( $this->related_ids_field ); |
|
37 | + protected function get_related_entity_ids(WordPoints_Entity $entity) { |
|
38 | + return $entity->get_the_attr_value($this->related_ids_field); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -37,8 +37,8 @@ |
||
37 | 37 | /** |
38 | 38 | * @since 1.0.0 |
39 | 39 | */ |
40 | - protected function get_related_entity_ids( WordPoints_Entity $entity ) { |
|
41 | - return $entity->get_the_attr_value( $this->related_ids_field ); |
|
40 | + protected function get_related_entity_ids(WordPoints_Entity $entity) { |
|
41 | + return $entity->get_the_attr_value($this->related_ids_field); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return mixed The attribute value. |
41 | 41 | */ |
42 | - abstract protected function get_attr_value_from_entity( WordPoints_Entity $entity ); |
|
42 | + abstract protected function get_attr_value_from_entity(WordPoints_Entity $entity); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Get the data type of this attribute's values. |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return bool Whether the value was set correctly. |
68 | 68 | */ |
69 | - public function set_the_value_from_entity( WordPoints_Entity $entity ) { |
|
69 | + public function set_the_value_from_entity(WordPoints_Entity $entity) { |
|
70 | 70 | |
71 | - $this->the_value = $this->get_attr_value_from_entity( $entity ); |
|
71 | + $this->the_value = $this->get_attr_value_from_entity($entity); |
|
72 | 72 | |
73 | 73 | return true; |
74 | 74 | } |