@@ -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,22 +82,22 @@ discard block |
||
82 | 82 | |
83 | 83 | wp_register_script( |
84 | 84 | 'wordpoints-admin-points-types' |
85 | - , $assets_url . '/js/points-types.js' |
|
86 | - , array( 'backbone', 'jquery-ui-dialog', 'wp-util' ) |
|
85 | + , $assets_url.'/js/points-types.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-models' |
92 | - , $assets_url . '/js/hooks/models.js' |
|
93 | - , array( 'backbone', 'jquery-ui-dialog', 'wp-util' ) |
|
92 | + , $assets_url.'/js/hooks/models.js' |
|
93 | + , array('backbone', 'jquery-ui-dialog', 'wp-util') |
|
94 | 94 | , WORDPOINTS_VERSION |
95 | 95 | ); |
96 | 96 | |
97 | 97 | wp_register_script( |
98 | 98 | 'wordpoints-hooks-views' |
99 | - , $assets_url . '/js/hooks/views.js' |
|
100 | - , array( 'wordpoints-hooks-models' ) |
|
99 | + , $assets_url.'/js/hooks/views.js' |
|
100 | + , array('wordpoints-hooks-models') |
|
101 | 101 | , WORDPOINTS_VERSION |
102 | 102 | ); |
103 | 103 | |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | 'wordpoints-admin-points-types' |
106 | 106 | , 'WordPointsPointsTypesL10n' |
107 | 107 | , array( |
108 | - 'confirmDelete' => esc_html__( 'Are you sure that you want to delete this points type? This will delete all related logs and event hooks.', 'wordpoints' ) |
|
109 | - . ' ' . esc_html__( 'Once a points type has been deleted, you cannot bring it back.', 'wordpoints' ), |
|
110 | - 'confirmTitle' => esc_html__( 'Are you sure?', 'wordpoints' ), |
|
111 | - 'deleteText' => esc_html__( 'Delete', 'wordpoints' ), |
|
112 | - 'cancelText' => esc_html__( 'Cancel', 'wordpoints' ), |
|
108 | + 'confirmDelete' => esc_html__('Are you sure that you want to delete this points type? This will delete all related logs and event hooks.', 'wordpoints') |
|
109 | + . ' '.esc_html__('Once a points type has been deleted, you cannot bring it back.', 'wordpoints'), |
|
110 | + 'confirmTitle' => esc_html__('Are you sure?', 'wordpoints'), |
|
111 | + 'deleteText' => esc_html__('Delete', 'wordpoints'), |
|
112 | + 'cancelText' => esc_html__('Cancel', 'wordpoints'), |
|
113 | 113 | ) |
114 | 114 | ); |
115 | 115 | |
@@ -117,19 +117,19 @@ discard block |
||
117 | 117 | 'wordpoints-hooks-views' |
118 | 118 | , 'WordPointsHooksAdminL10n' |
119 | 119 | , array( |
120 | - 'unexpectedError' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
121 | - 'changesSaved' => __( 'Your changes have been saved.', 'wordpoints' ), |
|
120 | + 'unexpectedError' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
121 | + 'changesSaved' => __('Your changes have been saved.', 'wordpoints'), |
|
122 | 122 | /* translators: the name of the field that cannot be empty */ |
123 | - 'emptyField' => sprintf( __( '%s cannot be empty.', 'wordpoints' ), '{{ data.label }}' ), |
|
124 | - 'confirmDelete' => __( 'Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints' ), |
|
125 | - 'confirmTitle' => __( 'Are you sure?', 'wordpoints' ), |
|
126 | - 'deleteText' => __( 'Delete', 'wordpoints' ), |
|
127 | - 'cancelText' => __( 'Cancel', 'wordpoints' ), |
|
128 | - 'separator' => __( ' » ', 'wordpoints' ), |
|
129 | - 'target_label' => __( 'Target', 'wordpoints' ), |
|
123 | + 'emptyField' => sprintf(__('%s cannot be empty.', 'wordpoints'), '{{ data.label }}'), |
|
124 | + 'confirmDelete' => __('Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints'), |
|
125 | + 'confirmTitle' => __('Are you sure?', 'wordpoints'), |
|
126 | + 'deleteText' => __('Delete', 'wordpoints'), |
|
127 | + 'cancelText' => __('Cancel', 'wordpoints'), |
|
128 | + 'separator' => __(' » ', 'wordpoints'), |
|
129 | + 'target_label' => __('Target', 'wordpoints'), |
|
130 | 130 | // translators: form field |
131 | - 'cannotBeChanged' => __( '(cannot be changed)', 'wordpoints' ), |
|
132 | - 'fieldsInvalid' => __( 'Error: the values of some fields are invalid. Please correct these and then try again.', 'wordpoints' ), |
|
131 | + 'cannotBeChanged' => __('(cannot be changed)', 'wordpoints'), |
|
132 | + 'fieldsInvalid' => __('Error: the values of some fields are invalid. Please correct these and then try again.', 'wordpoints'), |
|
133 | 133 | ) |
134 | 134 | ); |
135 | 135 | |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | <div class="view"> |
142 | 142 | <div class="title"></div> |
143 | 143 | <button type="button" class="edit button-secondary"> |
144 | - ' . esc_html__( 'Edit', 'wordpoints' ) . ' |
|
144 | + ' . esc_html__('Edit', 'wordpoints').' |
|
145 | 145 | </button> |
146 | 146 | <button type="button" class="close button-secondary"> |
147 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
147 | + ' . esc_html__('Close', 'wordpoints').' |
|
148 | 148 | </button> |
149 | 149 | </div> |
150 | 150 | <div class="form"> |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | </div> |
164 | 164 | <div class="action-buttons"> |
165 | 165 | <button type="button" class="save button-primary" disabled> |
166 | - ' . esc_html__( 'Save', 'wordpoints' ) . ' |
|
166 | + ' . esc_html__('Save', 'wordpoints').' |
|
167 | 167 | </button> |
168 | 168 | <button type="button" class="cancel button-secondary"> |
169 | - ' . esc_html__( 'Cancel', 'wordpoints' ) . ' |
|
169 | + ' . esc_html__('Cancel', 'wordpoints').' |
|
170 | 170 | </button> |
171 | 171 | <button type="button" class="close button-secondary"> |
172 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
172 | + ' . esc_html__('Close', 'wordpoints').' |
|
173 | 173 | </button> |
174 | 174 | <button type="button" class="delete button-secondary"> |
175 | - ' . esc_html__( 'Delete', 'wordpoints' ) . ' |
|
175 | + ' . esc_html__('Delete', 'wordpoints').' |
|
176 | 176 | </button> |
177 | 177 | </div> |
178 | 178 | </div> |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | |
221 | 221 | wp_register_script( |
222 | 222 | 'wordpoints-hooks-reactor-points' |
223 | - , $assets_url . '/js/hooks/reactors/points.js' |
|
224 | - , array( 'wordpoints-hooks-views' ) |
|
223 | + , $assets_url.'/js/hooks/reactors/points.js' |
|
224 | + , array('wordpoints-hooks-views') |
|
225 | 225 | , WORDPOINTS_VERSION |
226 | 226 | ); |
227 | 227 | |
228 | 228 | wp_register_script( |
229 | 229 | 'wordpoints-hooks-extension-conditions' |
230 | - , $assets_url . '/js/hooks/extensions/conditions.js' |
|
231 | - , array( 'wordpoints-hooks-views' ) |
|
230 | + , $assets_url.'/js/hooks/extensions/conditions.js' |
|
231 | + , array('wordpoints-hooks-views') |
|
232 | 232 | , WORDPOINTS_VERSION |
233 | 233 | ); |
234 | 234 | |
@@ -238,25 +238,25 @@ discard block |
||
238 | 238 | , ' |
239 | 239 | <script type="text/template" id="tmpl-wordpoints-hook-condition-groups"> |
240 | 240 | <div class="conditions-title section-title"> |
241 | - <h4>' . esc_html__( 'Conditions', 'wordpoints' ) . '</h4> |
|
241 | + <h4>' . esc_html__('Conditions', 'wordpoints').'</h4> |
|
242 | 242 | <button type="button" class="add-new button-secondary button-link"> |
243 | - <span class="screen-reader-text">' . esc_html__( 'Add New Condition', 'wordpoints' ) . '</span> |
|
243 | + <span class="screen-reader-text">' . esc_html__('Add New Condition', 'wordpoints').'</span> |
|
244 | 244 | <span class="dashicons dashicons-plus"></span> |
245 | 245 | </button> |
246 | 246 | </div> |
247 | 247 | <div class="add-condition-form hidden"> |
248 | 248 | <div class="no-conditions hidden"> |
249 | - ' . esc_html__( 'No conditions available.', 'wordpoints' ) . ' |
|
249 | + ' . esc_html__('No conditions available.', 'wordpoints').' |
|
250 | 250 | </div> |
251 | 251 | <div class="condition-selectors"> |
252 | 252 | <div class="arg-selectors"></div> |
253 | 253 | <div class="condition-selector"></div> |
254 | 254 | </div> |
255 | - <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__( 'Add Condition', 'wordpoints' ) . '"> |
|
256 | - ' . esc_html_x( 'Add', 'reaction condition', 'wordpoints' ) . ' |
|
255 | + <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__('Add Condition', 'wordpoints').'"> |
|
256 | + ' . esc_html_x('Add', 'reaction condition', 'wordpoints').' |
|
257 | 257 | </button> |
258 | - <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__( 'Cancel Adding New Condition', 'wordpoints' ) . '"> |
|
259 | - ' . esc_html_x( 'Cancel', 'reaction condition', 'wordpoints' ) . ' |
|
258 | + <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__('Cancel Adding New Condition', 'wordpoints').'"> |
|
259 | + ' . esc_html_x('Cancel', 'reaction condition', 'wordpoints').' |
|
260 | 260 | </button> |
261 | 261 | </div> |
262 | 262 | <div class="condition-groups section-content"></div> |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | <div class="condition-controls"> |
271 | 271 | <div class="condition-title"></div> |
272 | 272 | <button type="button" class="delete button-secondary button-link"> |
273 | - <span class="screen-reader-text">' . esc_html__( 'Remove Condition', 'wordpoints' ) . '</span> |
|
273 | + <span class="screen-reader-text">' . esc_html__('Remove Condition', 'wordpoints').'</span> |
|
274 | 274 | <span class="dashicons dashicons-no"></span> |
275 | 275 | </button> |
276 | 276 | </div> |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | |
289 | 289 | wp_register_script( |
290 | 290 | 'wordpoints-hooks-extension-periods' |
291 | - , $assets_url . '/js/hooks/extensions/periods.js' |
|
292 | - , array( 'wordpoints-hooks-views' ) |
|
291 | + , $assets_url.'/js/hooks/extensions/periods.js' |
|
292 | + , array('wordpoints-hooks-views') |
|
293 | 293 | , WORDPOINTS_VERSION |
294 | 294 | ); |
295 | 295 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | , ' |
300 | 300 | <script type="text/template" id="tmpl-wordpoints-hook-periods"> |
301 | 301 | <div class="periods-title section-title"> |
302 | - <h4>' . esc_html__( 'Rate Limit', 'wordpoints' ) . '</h4> |
|
302 | + <h4>' . esc_html__('Rate Limit', 'wordpoints').'</h4> |
|
303 | 303 | </div> |
304 | 304 | <div class="periods section-content"></div> |
305 | 305 | </script> |
@@ -318,33 +318,33 @@ discard block |
||
318 | 318 | |
319 | 319 | $extensions_data = array(); |
320 | 320 | |
321 | - foreach ( $hooks->extensions->get_all() as $slug => $extension ) { |
|
321 | + foreach ($hooks->extensions->get_all() as $slug => $extension) { |
|
322 | 322 | |
323 | - if ( $extension instanceof WordPoints_Hook_Extension ) { |
|
324 | - $extensions_data[ $slug ] = $extension->get_ui_script_data(); |
|
323 | + if ($extension instanceof WordPoints_Hook_Extension) { |
|
324 | + $extensions_data[$slug] = $extension->get_ui_script_data(); |
|
325 | 325 | } |
326 | 326 | |
327 | - if ( wp_script_is( "wordpoints-hooks-extension-{$slug}", 'registered' ) ) { |
|
328 | - wp_enqueue_script( "wordpoints-hooks-extension-{$slug}" ); |
|
327 | + if (wp_script_is("wordpoints-hooks-extension-{$slug}", 'registered')) { |
|
328 | + wp_enqueue_script("wordpoints-hooks-extension-{$slug}"); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - unset( $extension, $slug ); |
|
332 | + unset($extension, $slug); |
|
333 | 333 | |
334 | 334 | $reactor_data = array(); |
335 | 335 | |
336 | - foreach ( $hooks->reactors->get_all() as $slug => $reactor ) { |
|
336 | + foreach ($hooks->reactors->get_all() as $slug => $reactor) { |
|
337 | 337 | |
338 | - if ( $reactor instanceof WordPoints_Hook_Reactor ) { |
|
339 | - $reactor_data[ $slug ] = $reactor->get_ui_script_data(); |
|
338 | + if ($reactor instanceof WordPoints_Hook_Reactor) { |
|
339 | + $reactor_data[$slug] = $reactor->get_ui_script_data(); |
|
340 | 340 | } |
341 | 341 | |
342 | - if ( wp_script_is( "wordpoints-hooks-reactor-{$slug}", 'registered' ) ) { |
|
343 | - wp_enqueue_script( "wordpoints-hooks-reactor-{$slug}" ); |
|
342 | + if (wp_script_is("wordpoints-hooks-reactor-{$slug}", 'registered')) { |
|
343 | + wp_enqueue_script("wordpoints-hooks-reactor-{$slug}"); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | - unset( $reactor, $slug ); |
|
347 | + unset($reactor, $slug); |
|
348 | 348 | |
349 | 349 | $event_action_types = wordpoints_hooks_ui_get_script_data_event_action_types(); |
350 | 350 | $entities_data = wordpoints_hooks_ui_get_script_data_entities(); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @param array $data The data. |
370 | 370 | */ |
371 | - $data = apply_filters( 'wordpoints_hooks_ui_data', $data ); |
|
371 | + $data = apply_filters('wordpoints_hooks_ui_data', $data); |
|
372 | 372 | |
373 | 373 | wp_localize_script( |
374 | 374 | 'wordpoints-hooks-models' |
@@ -394,28 +394,28 @@ discard block |
||
394 | 394 | $entity_children = $entities->children; |
395 | 395 | |
396 | 396 | /** @var WordPoints_Entity $entity */ |
397 | - foreach ( $entities->get_all() as $slug => $entity ) { |
|
397 | + foreach ($entities->get_all() as $slug => $entity) { |
|
398 | 398 | |
399 | 399 | $child_data = array(); |
400 | 400 | |
401 | 401 | /** @var WordPoints_EntityishI $child */ |
402 | - foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) { |
|
402 | + foreach ($entity_children->get_children($slug) as $child_slug => $child) { |
|
403 | 403 | |
404 | - $child_data[ $child_slug ] = array( |
|
404 | + $child_data[$child_slug] = array( |
|
405 | 405 | 'slug' => $child_slug, |
406 | 406 | 'title' => $child->get_title(), |
407 | 407 | ); |
408 | 408 | |
409 | - if ( $child instanceof WordPoints_Entity_Attr ) { |
|
409 | + if ($child instanceof WordPoints_Entity_Attr) { |
|
410 | 410 | |
411 | - $child_data[ $child_slug ]['_type'] = 'attr'; |
|
412 | - $child_data[ $child_slug ]['data_type'] = $child->get_data_type(); |
|
411 | + $child_data[$child_slug]['_type'] = 'attr'; |
|
412 | + $child_data[$child_slug]['data_type'] = $child->get_data_type(); |
|
413 | 413 | |
414 | - } elseif ( $child instanceof WordPoints_Entity_Relationship ) { |
|
414 | + } elseif ($child instanceof WordPoints_Entity_Relationship) { |
|
415 | 415 | |
416 | - $child_data[ $child_slug ]['_type'] = 'relationship'; |
|
417 | - $child_data[ $child_slug ]['primary'] = $child->get_primary_entity_slug(); |
|
418 | - $child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug(); |
|
416 | + $child_data[$child_slug]['_type'] = 'relationship'; |
|
417 | + $child_data[$child_slug]['primary'] = $child->get_primary_entity_slug(); |
|
418 | + $child_data[$child_slug]['secondary'] = $child->get_related_entity_slug(); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -426,14 +426,14 @@ discard block |
||
426 | 426 | * @param array $data The data for the entity child. |
427 | 427 | * @param WordPoints_Entityish $child The child's object. |
428 | 428 | */ |
429 | - $child_data[ $child_slug ] = apply_filters( |
|
429 | + $child_data[$child_slug] = apply_filters( |
|
430 | 430 | 'wordpoints_hooks_ui_data_entity_child' |
431 | - , $child_data[ $child_slug ] |
|
431 | + , $child_data[$child_slug] |
|
432 | 432 | , $child |
433 | 433 | ); |
434 | 434 | } |
435 | 435 | |
436 | - $entities_data[ $slug ] = array( |
|
436 | + $entities_data[$slug] = array( |
|
437 | 437 | 'slug' => $slug, |
438 | 438 | 'title' => $entity->get_title(), |
439 | 439 | 'children' => $child_data, |
@@ -441,12 +441,12 @@ discard block |
||
441 | 441 | '_type' => 'entity', |
442 | 442 | ); |
443 | 443 | |
444 | - if ( $entity instanceof WordPoints_Entity_EnumerableI ) { |
|
444 | + if ($entity instanceof WordPoints_Entity_EnumerableI) { |
|
445 | 445 | |
446 | 446 | $values = array(); |
447 | 447 | |
448 | - foreach ( $entity->get_enumerated_values() as $value ) { |
|
449 | - if ( $entity->set_the_value( $value ) ) { |
|
448 | + foreach ($entity->get_enumerated_values() as $value) { |
|
449 | + if ($entity->set_the_value($value)) { |
|
450 | 450 | $values[] = array( |
451 | 451 | 'value' => $entity->get_the_id(), |
452 | 452 | 'label' => $entity->get_the_human_id(), |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
457 | - $entities_data[ $slug ]['values'] = $values; |
|
457 | + $entities_data[$slug]['values'] = $values; |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | * @param array $data The data for the entity. |
464 | 464 | * @param WordPoints_Entity $entity The entity object. |
465 | 465 | */ |
466 | - $entities_data[ $slug ] = apply_filters( |
|
466 | + $entities_data[$slug] = apply_filters( |
|
467 | 467 | 'wordpoints_hooks_ui_data_entity' |
468 | - , $entities_data[ $slug ] |
|
468 | + , $entities_data[$slug] |
|
469 | 469 | , $entity |
470 | 470 | ); |
471 | 471 | } |
@@ -489,15 +489,15 @@ discard block |
||
489 | 489 | |
490 | 490 | // We don't care about the action slugs, so first we get rid of that bottom level |
491 | 491 | // of the array. |
492 | - $event_index = call_user_func_array( 'array_merge_recursive', $event_index ); |
|
492 | + $event_index = call_user_func_array('array_merge_recursive', $event_index); |
|
493 | 493 | |
494 | 494 | $event_action_types = array(); |
495 | 495 | |
496 | 496 | // This leaves us the event indexed by action type. But we actually need to flip |
497 | 497 | // this, so that we have the action types indexed by event slug. |
498 | - foreach ( $event_index as $action_type => $events ) { |
|
499 | - foreach ( $events as $event => $unused ) { |
|
500 | - $event_action_types[ $event ][ $action_type ] = true; |
|
498 | + foreach ($event_index as $action_type => $events) { |
|
499 | + foreach ($events as $event => $unused) { |
|
500 | + $event_action_types[$event][$action_type] = true; |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
@@ -520,13 +520,13 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @return string The HTML with templates appended. |
522 | 522 | */ |
523 | -function wordpoints_script_templates_filter( $html, $handle ) { |
|
523 | +function wordpoints_script_templates_filter($html, $handle) { |
|
524 | 524 | |
525 | 525 | global $wp_scripts; |
526 | 526 | |
527 | - $templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' ); |
|
527 | + $templates = $wp_scripts->get_data($handle, 'wordpoints-templates'); |
|
528 | 528 | |
529 | - if ( $templates ) { |
|
529 | + if ($templates) { |
|
530 | 530 | $html .= $templates; |
531 | 531 | } |
532 | 532 | |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | */ |
543 | 543 | function wordpoints_hooks_admin_ajax() { |
544 | 544 | |
545 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
545 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
546 | 546 | new WordPoints_Admin_Ajax_Hooks; |
547 | 547 | } |
548 | 548 | } |
@@ -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,10 +75,10 @@ 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' ); |
|
81 | - wp_enqueue_script( 'wordpoints-admin-points-types' ); |
|
80 | + wp_enqueue_script('postbox'); |
|
81 | + wp_enqueue_script('wordpoints-admin-points-types'); |
|
82 | 82 | |
83 | 83 | wordpoints_hooks_ui_setup_script_data(); |
84 | 84 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | .addClass( 'closed' ); |
99 | 99 | |
100 | 100 | postboxes.add_postbox_toggles( |
101 | - <?php echo wp_json_encode( $this->id ); ?> |
|
101 | + <?php echo wp_json_encode($this->id); ?> |
|
102 | 102 | ); |
103 | 103 | } ); |
104 | 104 | </script> |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function add_points_settings_meta_box() { |
115 | 115 | |
116 | - if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
116 | + if ( ! current_user_can('manage_wordpoints_points_types')) { |
|
117 | 117 | return; |
118 | 118 | } |
119 | 119 | |
120 | 120 | add_meta_box( |
121 | 121 | 'settings' |
122 | - , __( 'Settings', 'wordpoints' ) |
|
123 | - , array( $this, 'display_points_settings_meta_box' ) |
|
122 | + , __('Settings', 'wordpoints') |
|
123 | + , array($this, 'display_points_settings_meta_box') |
|
124 | 124 | , $this->id |
125 | 125 | , 'side' |
126 | 126 | , 'default' |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function display_points_settings_meta_box() { |
136 | 136 | |
137 | - if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
137 | + if ( ! current_user_can('manage_wordpoints_points_types')) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | |
143 | 143 | $add_new = 0; |
144 | 144 | |
145 | - $points_type = wordpoints_get_points_type( $slug ); |
|
145 | + $points_type = wordpoints_get_points_type($slug); |
|
146 | 146 | |
147 | - if ( ! $points_type ) { |
|
147 | + if ( ! $points_type) { |
|
148 | 148 | |
149 | 149 | $points_type = array(); |
150 | - $add_new = wp_create_nonce( 'wordpoints_add_new_points_type' ); |
|
150 | + $add_new = wp_create_nonce('wordpoints_add_new_points_type'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $points_type = array_merge( |
@@ -162,15 +162,15 @@ discard block |
||
162 | 162 | ?> |
163 | 163 | |
164 | 164 | <form method="post"> |
165 | - <?php if ( $slug ) : ?> |
|
165 | + <?php if ($slug) : ?> |
|
166 | 166 | <p> |
167 | 167 | <span class="wordpoints-points-slug"> |
168 | 168 | <em> |
169 | - <?php echo esc_html( sprintf( __( 'Slug: %s', 'wordpoints' ), $slug ) ); ?> |
|
169 | + <?php echo esc_html(sprintf(__('Slug: %s', 'wordpoints'), $slug)); ?> |
|
170 | 170 | </em> |
171 | 171 | </span> |
172 | 172 | </p> |
173 | - <?php wp_nonce_field( "wordpoints_update_points_type-$slug", 'update_points_type' ); ?> |
|
173 | + <?php wp_nonce_field("wordpoints_update_points_type-$slug", 'update_points_type'); ?> |
|
174 | 174 | <?php endif; ?> |
175 | 175 | |
176 | 176 | <?php |
@@ -184,45 +184,45 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @param string $points_type The slug of the points type. |
186 | 186 | */ |
187 | - do_action( 'wordpoints_points_type_form_top', $slug ); |
|
187 | + do_action('wordpoints_points_type_form_top', $slug); |
|
188 | 188 | |
189 | - if ( $add_new ) { |
|
189 | + if ($add_new) { |
|
190 | 190 | |
191 | 191 | // Mark the prefix and suffix optional on the add new form. |
192 | - $prefix = _x( 'Prefix (optional):', 'points type', 'wordpoints' ); |
|
193 | - $suffix = _x( 'Suffix (optional):', 'points type', 'wordpoints' ); |
|
192 | + $prefix = _x('Prefix (optional):', 'points type', 'wordpoints'); |
|
193 | + $suffix = _x('Suffix (optional):', 'points type', 'wordpoints'); |
|
194 | 194 | |
195 | 195 | } else { |
196 | 196 | |
197 | - $prefix = _x( 'Prefix:', 'points type', 'wordpoints' ); |
|
198 | - $suffix = _x( 'Suffix:', 'points type', 'wordpoints' ); |
|
197 | + $prefix = _x('Prefix:', 'points type', 'wordpoints'); |
|
198 | + $suffix = _x('Suffix:', 'points type', 'wordpoints'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | ?> |
202 | 202 | |
203 | 203 | <p> |
204 | 204 | <label |
205 | - for="points-name-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html_x( 'Name:', 'points type', 'wordpoints' ); ?></label> |
|
205 | + for="points-name-<?php echo esc_attr($slug); ?>"><?php echo esc_html_x('Name:', 'points type', 'wordpoints'); ?></label> |
|
206 | 206 | <input class="widefat" type="text" |
207 | - id="points-name-<?php echo esc_attr( $slug ); ?>" |
|
207 | + id="points-name-<?php echo esc_attr($slug); ?>" |
|
208 | 208 | name="points-name" |
209 | - value="<?php echo esc_attr( $points_type['name'] ); ?>"/> |
|
209 | + value="<?php echo esc_attr($points_type['name']); ?>"/> |
|
210 | 210 | </p> |
211 | 211 | <p> |
212 | 212 | <label |
213 | - for="points-prefix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $prefix ); ?></label> |
|
213 | + for="points-prefix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($prefix); ?></label> |
|
214 | 214 | <input class="widefat" type="text" |
215 | - id="points-prefix-<?php echo esc_attr( $slug ); ?>" |
|
215 | + id="points-prefix-<?php echo esc_attr($slug); ?>" |
|
216 | 216 | name="points-prefix" |
217 | - value="<?php echo esc_attr( $points_type['prefix'] ); ?>"/> |
|
217 | + value="<?php echo esc_attr($points_type['prefix']); ?>"/> |
|
218 | 218 | </p> |
219 | 219 | <p> |
220 | 220 | <label |
221 | - for="points-suffix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $suffix ); ?></label> |
|
221 | + for="points-suffix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($suffix); ?></label> |
|
222 | 222 | <input class="widefat" type="text" |
223 | - id="points-suffix-<?php echo esc_attr( $slug ); ?>" |
|
223 | + id="points-suffix-<?php echo esc_attr($slug); ?>" |
|
224 | 224 | name="points-suffix" |
225 | - value="<?php echo esc_attr( $points_type['suffix'] ); ?>"/> |
|
225 | + value="<?php echo esc_attr($points_type['suffix']); ?>"/> |
|
226 | 226 | </p> |
227 | 227 | |
228 | 228 | <?php |
@@ -236,28 +236,28 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @param string $points_type The slug of the points type. |
238 | 238 | */ |
239 | - do_action( 'wordpoints_points_type_form_bottom', $slug ); |
|
239 | + do_action('wordpoints_points_type_form_bottom', $slug); |
|
240 | 240 | |
241 | 241 | ?> |
242 | 242 | |
243 | 243 | <input type="hidden" name="points-slug" |
244 | - value="<?php echo esc_attr( $slug ); ?>"/> |
|
244 | + value="<?php echo esc_attr($slug); ?>"/> |
|
245 | 245 | <input type="hidden" name="add_new" class="add_new" |
246 | - value="<?php echo esc_attr( $add_new ); ?>"/> |
|
246 | + value="<?php echo esc_attr($add_new); ?>"/> |
|
247 | 247 | |
248 | 248 | <div class="hook-control-actions"> |
249 | 249 | <div class="alignleft"> |
250 | 250 | <?php |
251 | 251 | |
252 | - if ( ! $add_new ) { |
|
253 | - wp_nonce_field( "wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce' ); |
|
254 | - submit_button( _x( 'Delete', 'points type', 'wordpoints' ), 'delete', 'delete-points-type', false, array( 'id' => "delete_points_type-{$slug}" ) ); |
|
252 | + if ( ! $add_new) { |
|
253 | + wp_nonce_field("wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce'); |
|
254 | + submit_button(_x('Delete', 'points type', 'wordpoints'), 'delete', 'delete-points-type', false, array('id' => "delete_points_type-{$slug}")); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | ?> |
258 | 258 | </div> |
259 | 259 | <div class="alignright"> |
260 | - <?php submit_button( _x( 'Save', 'points type', 'wordpoints' ), 'button-primary hook-control-save right', 'save-points-type', false, array( 'id' => "points-{$slug}-save" ) ); ?> |
|
260 | + <?php submit_button(_x('Save', 'points type', 'wordpoints'), 'button-primary hook-control-save right', 'save-points-type', false, array('id' => "points-{$slug}-save")); ?> |
|
261 | 261 | <span class="spinner"></span> |
262 | 262 | </div> |
263 | 263 | <br class="clear"/> |
@@ -274,13 +274,13 @@ discard block |
||
274 | 274 | */ |
275 | 275 | public function add_event_meta_boxes() { |
276 | 276 | |
277 | - if ( ! $this->current_points_type ) { |
|
277 | + if ( ! $this->current_points_type) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | 281 | /** @var WordPoints_Hook_Reactor $reactor */ |
282 | - $reactor = $this->hooks->reactors->get( 'points' ); |
|
283 | - $reactor_action_types = array_fill_keys( $reactor->get_action_types(), true ); |
|
282 | + $reactor = $this->hooks->reactors->get('points'); |
|
283 | + $reactor_action_types = array_fill_keys($reactor->get_action_types(), true); |
|
284 | 284 | |
285 | 285 | $event_action_types = wordpoints_hooks_ui_get_script_data_event_action_types(); |
286 | 286 | |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | , $this->current_points_type |
306 | 306 | ); |
307 | 307 | |
308 | - foreach ( $events as $slug => $event ) { |
|
308 | + foreach ($events as $slug => $event) { |
|
309 | 309 | |
310 | 310 | if ( |
311 | 311 | ! array_intersect_key( |
312 | - $event_action_types[ $slug ] |
|
312 | + $event_action_types[$slug] |
|
313 | 313 | , $reactor_action_types |
314 | 314 | ) |
315 | 315 | ) { |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | add_meta_box( |
320 | 320 | "{$this->current_points_type}-{$slug}" |
321 | 321 | , $event->get_title() |
322 | - , array( $this, 'display_event_meta_box' ) |
|
322 | + , array($this, 'display_event_meta_box') |
|
323 | 323 | , $this->id |
324 | 324 | , 'events' |
325 | 325 | , 'default' |
@@ -340,54 +340,54 @@ discard block |
||
340 | 340 | * @param array $points_type The points type this meta-box relates to. |
341 | 341 | * @param array $meta_box The data the meta-box was created with. |
342 | 342 | */ |
343 | - public function display_event_meta_box( $points_type, $meta_box ) { |
|
343 | + public function display_event_meta_box($points_type, $meta_box) { |
|
344 | 344 | |
345 | 345 | $event_slug = $meta_box['args']['slug']; |
346 | 346 | |
347 | 347 | $data = array(); |
348 | 348 | |
349 | - $reaction_store = wordpoints_hooks()->get_reaction_store( 'points' ); |
|
349 | + $reaction_store = wordpoints_hooks()->get_reaction_store('points'); |
|
350 | 350 | |
351 | - foreach ( $reaction_store->get_reactions_to_event( $event_slug ) as $id => $reaction ) { |
|
352 | - if ( $reaction->get_meta( 'points_type' ) === $this->current_points_type ) { |
|
351 | + foreach ($reaction_store->get_reactions_to_event($event_slug) as $id => $reaction) { |
|
352 | + if ($reaction->get_meta('points_type') === $this->current_points_type) { |
|
353 | 353 | $data[] = WordPoints_Admin_Ajax_Hooks::prepare_hook_reaction( |
354 | 354 | $reaction |
355 | 355 | ); |
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | - $args = $this->hooks->events->args->get_children( $event_slug ); |
|
359 | + $args = $this->hooks->events->args->get_children($event_slug); |
|
360 | 360 | |
361 | - $event_data = array( 'args' => array() ); |
|
361 | + $event_data = array('args' => array()); |
|
362 | 362 | |
363 | - foreach ( $args as $slug => $arg ) { |
|
363 | + foreach ($args as $slug => $arg) { |
|
364 | 364 | |
365 | - $event_data['args'][ $slug ] = array( |
|
365 | + $event_data['args'][$slug] = array( |
|
366 | 366 | 'slug' => $slug, |
367 | 367 | ); |
368 | 368 | |
369 | - if ( $arg instanceof WordPoints_Hook_Arg ) { |
|
370 | - $event_data['args'][ $slug ]['title'] = $arg->get_title(); |
|
371 | - $event_data['args'][ $slug ]['is_stateful'] = $arg->is_stateful(); |
|
369 | + if ($arg instanceof WordPoints_Hook_Arg) { |
|
370 | + $event_data['args'][$slug]['title'] = $arg->get_title(); |
|
371 | + $event_data['args'][$slug]['is_stateful'] = $arg->is_stateful(); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | 375 | ?> |
376 | 376 | |
377 | 377 | <script> |
378 | - WordPointsHooksAdminData.events[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $event_data ); ?>; |
|
379 | - WordPointsHooksAdminData.reactions[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $data ); ?>; |
|
378 | + WordPointsHooksAdminData.events[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($event_data); ?>; |
|
379 | + WordPointsHooksAdminData.reactions[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($data); ?>; |
|
380 | 380 | </script> |
381 | 381 | |
382 | 382 | <div class="wordpoints-hook-reaction-group-container"> |
383 | 383 | <p class="description wordpoints-hook-reaction-group-description"> |
384 | - <?php echo esc_html( $meta_box['args']['event']->get_description() ); ?> |
|
384 | + <?php echo esc_html($meta_box['args']['event']->get_description()); ?> |
|
385 | 385 | </p> |
386 | 386 | |
387 | 387 | <div class="wordpoints-hook-reaction-group" |
388 | - data-wordpoints-hooks-hook-event="<?php echo esc_attr( $event_slug ); ?>" |
|
389 | - data-wordpoints-hooks-points-type="<?php echo esc_attr( $this->current_points_type ); ?>" |
|
390 | - data-wordpoints-hooks-create-nonce="<?php echo esc_attr( WordPoints_Admin_Ajax_Hooks::get_create_nonce( $reaction_store ) ); ?>" |
|
388 | + data-wordpoints-hooks-hook-event="<?php echo esc_attr($event_slug); ?>" |
|
389 | + data-wordpoints-hooks-points-type="<?php echo esc_attr($this->current_points_type); ?>" |
|
390 | + data-wordpoints-hooks-create-nonce="<?php echo esc_attr(WordPoints_Admin_Ajax_Hooks::get_create_nonce($reaction_store)); ?>" |
|
391 | 391 | data-wordpoints-hooks-reaction-store="points" |
392 | 392 | data-wordpoints-hooks-reactor="points"> |
393 | 393 | </div> |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | |
403 | 403 | <div class="controls"> |
404 | 404 | <button type="button" class="button-primary add-reaction"> |
405 | - <?php esc_html_e( 'Add New', 'wordpoints' ); ?> |
|
405 | + <?php esc_html_e('Add New', 'wordpoints'); ?> |
|
406 | 406 | </button> |
407 | 407 | </div> |
408 | 408 | </div> |
@@ -422,19 +422,19 @@ discard block |
||
422 | 422 | // Show a tab for each points type. |
423 | 423 | $tabs = array(); |
424 | 424 | |
425 | - foreach ( $points_types as $slug => $settings ) { |
|
426 | - $tabs[ $slug ] = $settings['name']; |
|
425 | + foreach ($points_types as $slug => $settings) { |
|
426 | + $tabs[$slug] = $settings['name']; |
|
427 | 427 | } |
428 | 428 | |
429 | - $tabs['add-new'] = __( 'Add New', 'wordpoints' ); |
|
429 | + $tabs['add-new'] = __('Add New', 'wordpoints'); |
|
430 | 430 | |
431 | - $tab = wordpoints_admin_get_current_tab( $tabs ); |
|
431 | + $tab = wordpoints_admin_get_current_tab($tabs); |
|
432 | 432 | |
433 | - if ( 'add-new' !== $tab ) { |
|
433 | + if ('add-new' !== $tab) { |
|
434 | 434 | $this->current_points_type = $tab; |
435 | 435 | } |
436 | 436 | |
437 | - do_action( 'add_meta_boxes', $this->id ); |
|
437 | + do_action('add_meta_boxes', $this->id); |
|
438 | 438 | |
439 | 439 | $this->tabs = $tabs; |
440 | 440 | } |
@@ -446,19 +446,19 @@ discard block |
||
446 | 446 | */ |
447 | 447 | public function save_points_type() { |
448 | 448 | |
449 | - if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
449 | + if ( ! current_user_can('manage_wordpoints_points_types')) { |
|
450 | 450 | return; |
451 | 451 | } |
452 | 452 | |
453 | - if ( isset( $_POST['save-points-type'] ) ) { // WPCS: CSRF OK |
|
453 | + if (isset($_POST['save-points-type'])) { // WPCS: CSRF OK |
|
454 | 454 | |
455 | - if ( isset( $_POST['points-slug'] ) ) { // WPCS: CSRF OK |
|
455 | + if (isset($_POST['points-slug'])) { // WPCS: CSRF OK |
|
456 | 456 | $this->update_points_type(); |
457 | 457 | } else { |
458 | 458 | $this->add_points_type(); |
459 | 459 | } |
460 | 460 | |
461 | - } elseif ( ! empty( $_POST['delete-points-type'] ) ) { // WPCS: CSRF OK |
|
461 | + } elseif ( ! empty($_POST['delete-points-type'])) { // WPCS: CSRF OK |
|
462 | 462 | |
463 | 463 | $this->delete_points_type(); |
464 | 464 | } |
@@ -475,21 +475,21 @@ discard block |
||
475 | 475 | |
476 | 476 | $settings = array(); |
477 | 477 | |
478 | - if ( isset( $_POST['points-name'] ) ) { // WPCS: CSRF OK |
|
478 | + if (isset($_POST['points-name'])) { // WPCS: CSRF OK |
|
479 | 479 | $settings['name'] = trim( |
480 | - sanitize_text_field( wp_unslash( $_POST['points-name'] ) ) // WPCS: CSRF OK |
|
480 | + sanitize_text_field(wp_unslash($_POST['points-name'])) // WPCS: CSRF OK |
|
481 | 481 | ); |
482 | 482 | } |
483 | 483 | |
484 | - if ( isset( $_POST['points-prefix'] ) ) { // WPCS: CSRF OK |
|
484 | + if (isset($_POST['points-prefix'])) { // WPCS: CSRF OK |
|
485 | 485 | $settings['prefix'] = ltrim( |
486 | - sanitize_text_field( wp_unslash( $_POST['points-prefix'] ) ) // WPCS: CSRF OK |
|
486 | + sanitize_text_field(wp_unslash($_POST['points-prefix'])) // WPCS: CSRF OK |
|
487 | 487 | ); |
488 | 488 | } |
489 | 489 | |
490 | - if ( isset( $_POST['points-suffix'] ) ) { // WPCS: CSRF OK |
|
490 | + if (isset($_POST['points-suffix'])) { // WPCS: CSRF OK |
|
491 | 491 | $settings['suffix'] = rtrim( |
492 | - sanitize_text_field( wp_unslash( $_POST['points-suffix'] ) ) // WPCS: CSRF OK |
|
492 | + sanitize_text_field(wp_unslash($_POST['points-suffix'])) // WPCS: CSRF OK |
|
493 | 493 | ); |
494 | 494 | } |
495 | 495 | |
@@ -507,52 +507,52 @@ discard block |
||
507 | 507 | ! wordpoints_verify_nonce( |
508 | 508 | 'update_points_type' |
509 | 509 | , 'wordpoints_update_points_type-%s' |
510 | - , array( 'points-slug' ) |
|
510 | + , array('points-slug') |
|
511 | 511 | , 'post' |
512 | 512 | ) |
513 | - || ! isset( $_POST['points-slug'] ) |
|
513 | + || ! isset($_POST['points-slug']) |
|
514 | 514 | ) { |
515 | 515 | return; |
516 | 516 | } |
517 | 517 | |
518 | 518 | $settings = $this->get_points_type_settings(); |
519 | 519 | |
520 | - if ( empty( $settings['name'] ) ) { |
|
520 | + if (empty($settings['name'])) { |
|
521 | 521 | |
522 | 522 | add_settings_error( |
523 | 523 | 'points-name' |
524 | 524 | , 'wordpoints_points_type_update' |
525 | - , __( 'Error: points type name cannot be empty.', 'wordpoints' ) |
|
525 | + , __('Error: points type name cannot be empty.', 'wordpoints') |
|
526 | 526 | ); |
527 | 527 | |
528 | 528 | return; |
529 | 529 | } |
530 | 530 | |
531 | - $points_type = sanitize_key( $_POST['points-slug'] ); |
|
531 | + $points_type = sanitize_key($_POST['points-slug']); |
|
532 | 532 | |
533 | - $old_settings = wordpoints_get_points_type( $points_type ); |
|
533 | + $old_settings = wordpoints_get_points_type($points_type); |
|
534 | 534 | |
535 | - if ( false === $old_settings ) { |
|
535 | + if (false === $old_settings) { |
|
536 | 536 | |
537 | 537 | add_settings_error( |
538 | 538 | '' |
539 | 539 | , 'wordpoints_points_type_update' |
540 | - , __( 'Error: failed updating points type.', 'wordpoints' ) |
|
540 | + , __('Error: failed updating points type.', 'wordpoints') |
|
541 | 541 | ); |
542 | 542 | |
543 | 543 | return; |
544 | 544 | } |
545 | 545 | |
546 | - if ( is_array( $old_settings ) ) { |
|
547 | - $settings = array_merge( $old_settings, $settings ); |
|
546 | + if (is_array($old_settings)) { |
|
547 | + $settings = array_merge($old_settings, $settings); |
|
548 | 548 | } |
549 | 549 | |
550 | - if ( ! wordpoints_update_points_type( $points_type, $settings ) ) { |
|
550 | + if ( ! wordpoints_update_points_type($points_type, $settings)) { |
|
551 | 551 | |
552 | 552 | add_settings_error( |
553 | 553 | '' |
554 | 554 | , 'wordpoints_points_type_update' |
555 | - , __( 'Error: failed updating points type.', 'wordpoints' ) |
|
555 | + , __('Error: failed updating points type.', 'wordpoints') |
|
556 | 556 | ); |
557 | 557 | |
558 | 558 | } else { |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | add_settings_error( |
561 | 561 | '' |
562 | 562 | , 'wordpoints_points_type_update' |
563 | - , __( 'Points type updated.', 'wordpoints' ) |
|
563 | + , __('Points type updated.', 'wordpoints') |
|
564 | 564 | , 'updated' |
565 | 565 | ); |
566 | 566 | } |
@@ -586,14 +586,14 @@ discard block |
||
586 | 586 | |
587 | 587 | $settings = $this->get_points_type_settings(); |
588 | 588 | |
589 | - $slug = wordpoints_add_points_type( $settings ); |
|
589 | + $slug = wordpoints_add_points_type($settings); |
|
590 | 590 | |
591 | - if ( ! $slug ) { |
|
591 | + if ( ! $slug) { |
|
592 | 592 | |
593 | 593 | add_settings_error( |
594 | 594 | '' |
595 | 595 | , 'wordpoints_points_type_create' |
596 | - , __( 'Please choose a unique name for this points type.', 'wordpoints' ) |
|
596 | + , __('Please choose a unique name for this points type.', 'wordpoints') |
|
597 | 597 | ); |
598 | 598 | |
599 | 599 | } else { |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | add_settings_error( |
604 | 604 | '' |
605 | 605 | , 'wordpoints_points_type_create' |
606 | - , __( 'Points type created.', 'wordpoints' ) |
|
606 | + , __('Points type created.', 'wordpoints') |
|
607 | 607 | , 'updated' |
608 | 608 | ); |
609 | 609 | } |
@@ -620,22 +620,22 @@ discard block |
||
620 | 620 | wordpoints_verify_nonce( |
621 | 621 | 'delete-points-type-nonce' |
622 | 622 | , 'wordpoints_delete_points_type-%s' |
623 | - , array( 'points-slug' ) |
|
623 | + , array('points-slug') |
|
624 | 624 | , 'post' |
625 | 625 | ) |
626 | - && isset( $_POST['points-slug'] ) |
|
626 | + && isset($_POST['points-slug']) |
|
627 | 627 | ) { |
628 | 628 | |
629 | 629 | if ( |
630 | 630 | wordpoints_delete_points_type( |
631 | - sanitize_key( $_POST['points-slug'] ) |
|
631 | + sanitize_key($_POST['points-slug']) |
|
632 | 632 | ) |
633 | 633 | ) { |
634 | 634 | |
635 | 635 | add_settings_error( |
636 | 636 | '' |
637 | 637 | , 'wordpoints_points_type_delete' |
638 | - , __( 'Points type deleted.', 'wordpoints' ) |
|
638 | + , __('Points type deleted.', 'wordpoints') |
|
639 | 639 | , 'updated' |
640 | 640 | ); |
641 | 641 | |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | add_settings_error( |
645 | 645 | '' |
646 | 646 | , 'wordpoints_points_type_delete' |
647 | - , __( 'Error while deleting.', 'wordpoints' ) |
|
647 | + , __('Error while deleting.', 'wordpoints') |
|
648 | 648 | ); |
649 | 649 | } |
650 | 650 | } |
@@ -660,25 +660,25 @@ discard block |
||
660 | 660 | * |
661 | 661 | * @since 1.0.0 |
662 | 662 | */ |
663 | - do_action( 'wordpoints_admin_points_events_head' ); |
|
663 | + do_action('wordpoints_admin_points_events_head'); |
|
664 | 664 | |
665 | - if ( is_network_admin() ) { |
|
666 | - $title = __( 'Network Events', 'wordpoints' ); |
|
667 | - $description = __( 'Award points when various events happen on this network.', 'wordpoints' ); |
|
665 | + if (is_network_admin()) { |
|
666 | + $title = __('Network Events', 'wordpoints'); |
|
667 | + $description = __('Award points when various events happen on this network.', 'wordpoints'); |
|
668 | 668 | } else { |
669 | - $title = __( 'Events', 'wordpoints' ); |
|
670 | - $description = __( 'Award points when various events happen on this site.', 'wordpoints' ); |
|
669 | + $title = __('Events', 'wordpoints'); |
|
670 | + $description = __('Award points when various events happen on this site.', 'wordpoints'); |
|
671 | 671 | } |
672 | 672 | |
673 | - $points_type = wordpoints_get_points_type( $this->current_points_type ); |
|
673 | + $points_type = wordpoints_get_points_type($this->current_points_type); |
|
674 | 674 | |
675 | 675 | ?> |
676 | 676 | |
677 | 677 | <div class="wordpoints-points-type-meta-box-wrap"> |
678 | 678 | |
679 | 679 | <form> |
680 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
681 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
680 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
681 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
682 | 682 | </form> |
683 | 683 | |
684 | 684 | <div id="poststuff"> |
@@ -686,17 +686,17 @@ discard block |
||
686 | 686 | <div id="post-body" class="metabox-holder columns-<?php echo 1 === (int) get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
687 | 687 | |
688 | 688 | <div id="postbox-container-1" class="postbox-container"> |
689 | - <?php do_meta_boxes( $this->id, 'side', $points_type ); ?> |
|
689 | + <?php do_meta_boxes($this->id, 'side', $points_type); ?> |
|
690 | 690 | </div> |
691 | 691 | |
692 | - <?php if ( isset( $this->current_points_type ) ) : ?> |
|
692 | + <?php if (isset($this->current_points_type)) : ?> |
|
693 | 693 | <div class="wordpoints-hook-events-heading"> |
694 | - <h2><?php echo esc_html( $title ); ?></h2> |
|
695 | - <p class="description"><?php echo esc_html( $description ); ?></p> |
|
694 | + <h2><?php echo esc_html($title); ?></h2> |
|
695 | + <p class="description"><?php echo esc_html($description); ?></p> |
|
696 | 696 | </div> |
697 | 697 | |
698 | 698 | <div id="postbox-container-2" class="postbox-container"> |
699 | - <?php do_meta_boxes( $this->id, 'events', $points_type ); ?> |
|
699 | + <?php do_meta_boxes($this->id, 'events', $points_type); ?> |
|
700 | 700 | </div> |
701 | 701 | <?php endif; ?> |
702 | 702 | |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | * |
716 | 716 | * @since 1.0.0 |
717 | 717 | */ |
718 | - do_action( 'wordpoints_admin_points_events_foot' ); |
|
718 | + do_action('wordpoints_admin_points_events_foot'); |
|
719 | 719 | } |
720 | 720 | } |
721 | 721 |