@@ -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 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * the modules screen should be the main one (the configure menu is only for the |
49 | 49 | * network admin when network active). |
50 | 50 | */ |
51 | - if ( is_wordpoints_network_active() && 'admin_menu' === current_filter() ) { |
|
51 | + if (is_wordpoints_network_active() && 'admin_menu' === current_filter()) { |
|
52 | 52 | $slug = 'wordpoints_modules'; |
53 | 53 | } |
54 | 54 | |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | function wordpoints_admin_menu() { |
67 | 67 | |
68 | 68 | $main_menu = wordpoints_get_main_admin_menu(); |
69 | - $wordpoints = __( 'WordPoints', 'wordpoints' ); |
|
69 | + $wordpoints = __('WordPoints', 'wordpoints'); |
|
70 | 70 | |
71 | 71 | /* |
72 | 72 | * The settings page is always the main menu, except when the plugin is network |
73 | 73 | * active on multisite. Then it is only the main menu when in the network admin. |
74 | 74 | */ |
75 | - if ( 'wordpoints_configure' === $main_menu ) { |
|
75 | + if ('wordpoints_configure' === $main_menu) { |
|
76 | 76 | |
77 | 77 | // Main page. |
78 | 78 | add_menu_page( |
79 | 79 | $wordpoints |
80 | - ,esc_html( $wordpoints ) |
|
80 | + ,esc_html($wordpoints) |
|
81 | 81 | ,'manage_options' |
82 | 82 | ,'wordpoints_configure' |
83 | 83 | ,'wordpoints_admin_screen_configure' |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | // Settings page. |
87 | 87 | add_submenu_page( |
88 | 88 | 'wordpoints_configure' |
89 | - ,__( 'WordPoints — Configure', 'wordpoints' ) |
|
90 | - ,esc_html__( 'Configure', 'wordpoints' ) |
|
89 | + ,__('WordPoints — Configure', 'wordpoints') |
|
90 | + ,esc_html__('Configure', 'wordpoints') |
|
91 | 91 | ,'manage_options' |
92 | 92 | ,'wordpoints_configure' |
93 | 93 | ,'wordpoints_admin_screen_configure' |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | // Main page. |
104 | 104 | add_menu_page( |
105 | 105 | $wordpoints |
106 | - ,esc_html( $wordpoints ) |
|
106 | + ,esc_html($wordpoints) |
|
107 | 107 | ,'activate_wordpoints_modules' |
108 | 108 | ,'wordpoints_modules' |
109 | 109 | ,'wordpoints_admin_screen_modules' |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | // Modules page. |
115 | 115 | add_submenu_page( |
116 | 116 | $main_menu |
117 | - ,__( 'WordPoints — Modules', 'wordpoints' ) |
|
118 | - ,esc_html__( 'Modules', 'wordpoints' ) |
|
117 | + ,__('WordPoints — Modules', 'wordpoints') |
|
118 | + ,esc_html__('Modules', 'wordpoints') |
|
119 | 119 | ,'activate_wordpoints_modules' |
120 | 120 | ,'wordpoints_modules' |
121 | 121 | ,'wordpoints_admin_screen_modules' |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | // Module install page. |
125 | 125 | add_submenu_page( |
126 | 126 | '_wordpoints_modules' // Fake menu. |
127 | - ,__( 'WordPoints — Install Modules', 'wordpoints' ) |
|
128 | - ,esc_html__( 'Install Modules', 'wordpoints' ) |
|
127 | + ,__('WordPoints — Install Modules', 'wordpoints') |
|
128 | + ,esc_html__('Install Modules', 'wordpoints') |
|
129 | 129 | ,'install_wordpoints_modules' |
130 | 130 | ,'wordpoints_install_modules' |
131 | 131 | ,'wordpoints_admin_screen_install_modules' |
@@ -253,15 +253,15 @@ discard block |
||
253 | 253 | wp_register_style( |
254 | 254 | 'wordpoints-hooks-admin' |
255 | 255 | , "{$assets_url}/css/hooks{$suffix}.css" |
256 | - , array( 'dashicons', 'wp-jquery-ui-dialog' ) |
|
256 | + , array('dashicons', 'wp-jquery-ui-dialog') |
|
257 | 257 | , WORDPOINTS_VERSION |
258 | 258 | ); |
259 | 259 | |
260 | 260 | $styles = wp_styles(); |
261 | - $styles->add_data( 'wordpoints-hooks-admin', 'rtl', 'replace' ); |
|
261 | + $styles->add_data('wordpoints-hooks-admin', 'rtl', 'replace'); |
|
262 | 262 | |
263 | - if ( $suffix ) { |
|
264 | - $styles->add_data( 'wordpoints-hooks-admin', 'suffix', $suffix ); |
|
263 | + if ($suffix) { |
|
264 | + $styles->add_data('wordpoints-hooks-admin', 'suffix', $suffix); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // JS |
@@ -269,21 +269,21 @@ discard block |
||
269 | 269 | wp_register_script( |
270 | 270 | 'wordpoints-admin-dismiss-notice' |
271 | 271 | , "{$assets_url}/js/dismiss-notice{$suffix}.js" |
272 | - , array( 'jquery', 'wp-util' ) |
|
272 | + , array('jquery', 'wp-util') |
|
273 | 273 | , WORDPOINTS_VERSION |
274 | 274 | ); |
275 | 275 | |
276 | 276 | wp_register_script( |
277 | 277 | 'wordpoints-hooks-models' |
278 | 278 | , "{$assets_url}/js/hooks/models{$manifested_suffix}.js" |
279 | - , array( 'backbone', 'jquery-ui-dialog', 'wp-util' ) |
|
279 | + , array('backbone', 'jquery-ui-dialog', 'wp-util') |
|
280 | 280 | , WORDPOINTS_VERSION |
281 | 281 | ); |
282 | 282 | |
283 | 283 | wp_register_script( |
284 | 284 | 'wordpoints-hooks-views' |
285 | 285 | , "{$assets_url}/js/hooks/views{$manifested_suffix}.js" |
286 | - , array( 'wordpoints-hooks-models' ) |
|
286 | + , array('wordpoints-hooks-models') |
|
287 | 287 | , WORDPOINTS_VERSION |
288 | 288 | ); |
289 | 289 | |
@@ -291,19 +291,19 @@ discard block |
||
291 | 291 | 'wordpoints-hooks-views' |
292 | 292 | , 'WordPointsHooksAdminL10n' |
293 | 293 | , array( |
294 | - 'unexpectedError' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
295 | - 'changesSaved' => __( 'Your changes have been saved.', 'wordpoints' ), |
|
294 | + 'unexpectedError' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
295 | + 'changesSaved' => __('Your changes have been saved.', 'wordpoints'), |
|
296 | 296 | // translators: Form field name. |
297 | - 'emptyField' => sprintf( __( '%s cannot be empty.', 'wordpoints' ), '{{ data.label }}' ), |
|
298 | - 'confirmDelete' => __( 'Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints' ), |
|
299 | - 'confirmTitle' => __( 'Are you sure?', 'wordpoints' ), |
|
300 | - 'deleteText' => __( 'Delete', 'wordpoints' ), |
|
301 | - 'cancelText' => __( 'Cancel', 'wordpoints' ), |
|
297 | + 'emptyField' => sprintf(__('%s cannot be empty.', 'wordpoints'), '{{ data.label }}'), |
|
298 | + 'confirmDelete' => __('Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints'), |
|
299 | + 'confirmTitle' => __('Are you sure?', 'wordpoints'), |
|
300 | + 'deleteText' => __('Delete', 'wordpoints'), |
|
301 | + 'cancelText' => __('Cancel', 'wordpoints'), |
|
302 | 302 | 'separator' => is_rtl() ? ' « ' : ' » ', |
303 | - 'target_label' => __( 'Target', 'wordpoints' ), |
|
303 | + 'target_label' => __('Target', 'wordpoints'), |
|
304 | 304 | // translators: Form field. |
305 | - 'cannotBeChanged' => __( '(cannot be changed)', 'wordpoints' ), |
|
306 | - 'fieldsInvalid' => __( 'Error: the values of some fields are invalid. Please correct these and then try again.', 'wordpoints' ), |
|
305 | + 'cannotBeChanged' => __('(cannot be changed)', 'wordpoints'), |
|
306 | + 'fieldsInvalid' => __('Error: the values of some fields are invalid. Please correct these and then try again.', 'wordpoints'), |
|
307 | 307 | ) |
308 | 308 | ); |
309 | 309 | |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | <div class="view"> |
316 | 316 | <div class="title"></div> |
317 | 317 | <button type="button" class="edit button-secondary"> |
318 | - ' . esc_html__( 'Edit', 'wordpoints' ) . ' |
|
318 | + ' . esc_html__('Edit', 'wordpoints') . ' |
|
319 | 319 | </button> |
320 | 320 | <button type="button" class="close button-secondary"> |
321 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
321 | + ' . esc_html__('Close', 'wordpoints') . ' |
|
322 | 322 | </button> |
323 | 323 | </div> |
324 | 324 | <div class="form"> |
@@ -337,16 +337,16 @@ discard block |
||
337 | 337 | </div> |
338 | 338 | <div class="action-buttons"> |
339 | 339 | <button type="button" class="save button-primary" disabled> |
340 | - ' . esc_html__( 'Save', 'wordpoints' ) . ' |
|
340 | + ' . esc_html__('Save', 'wordpoints') . ' |
|
341 | 341 | </button> |
342 | 342 | <button type="button" class="cancel button-secondary"> |
343 | - ' . esc_html__( 'Cancel', 'wordpoints' ) . ' |
|
343 | + ' . esc_html__('Cancel', 'wordpoints') . ' |
|
344 | 344 | </button> |
345 | 345 | <button type="button" class="close button-secondary"> |
346 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
346 | + ' . esc_html__('Close', 'wordpoints') . ' |
|
347 | 347 | </button> |
348 | 348 | <button type="button" class="delete button-secondary"> |
349 | - ' . esc_html__( 'Delete', 'wordpoints' ) . ' |
|
349 | + ' . esc_html__('Delete', 'wordpoints') . ' |
|
350 | 350 | </button> |
351 | 351 | </div> |
352 | 352 | </div> |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | wp_register_script( |
396 | 396 | 'wordpoints-hooks-extension-conditions' |
397 | 397 | , "{$assets_url}/js/hooks/extensions/conditions{$manifested_suffix}.js" |
398 | - , array( 'wordpoints-hooks-views' ) |
|
398 | + , array('wordpoints-hooks-views') |
|
399 | 399 | , WORDPOINTS_VERSION |
400 | 400 | ); |
401 | 401 | |
@@ -405,25 +405,25 @@ discard block |
||
405 | 405 | , ' |
406 | 406 | <script type="text/template" id="tmpl-wordpoints-hook-condition-groups"> |
407 | 407 | <div class="conditions-title section-title"> |
408 | - <h4>' . esc_html__( 'Conditions', 'wordpoints' ) . '</h4> |
|
408 | + <h4>' . esc_html__('Conditions', 'wordpoints') . '</h4> |
|
409 | 409 | <button type="button" class="add-new button-secondary button-link"> |
410 | - <span class="screen-reader-text">' . esc_html__( 'Add New Condition', 'wordpoints' ) . '</span> |
|
410 | + <span class="screen-reader-text">' . esc_html__('Add New Condition', 'wordpoints') . '</span> |
|
411 | 411 | <span class="dashicons dashicons-plus"></span> |
412 | 412 | </button> |
413 | 413 | </div> |
414 | 414 | <div class="add-condition-form hidden"> |
415 | 415 | <div class="no-conditions hidden"> |
416 | - ' . esc_html__( 'No conditions available.', 'wordpoints' ) . ' |
|
416 | + ' . esc_html__('No conditions available.', 'wordpoints') . ' |
|
417 | 417 | </div> |
418 | 418 | <div class="condition-selectors"> |
419 | 419 | <div class="arg-selectors"></div> |
420 | 420 | <div class="condition-selector"></div> |
421 | 421 | </div> |
422 | - <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__( 'Add Condition', 'wordpoints' ) . '"> |
|
423 | - ' . esc_html_x( 'Add', 'reaction condition', 'wordpoints' ) . ' |
|
422 | + <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__('Add Condition', 'wordpoints') . '"> |
|
423 | + ' . esc_html_x('Add', 'reaction condition', 'wordpoints') . ' |
|
424 | 424 | </button> |
425 | - <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__( 'Cancel Adding New Condition', 'wordpoints' ) . '"> |
|
426 | - ' . esc_html_x( 'Cancel', 'reaction condition', 'wordpoints' ) . ' |
|
425 | + <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__('Cancel Adding New Condition', 'wordpoints') . '"> |
|
426 | + ' . esc_html_x('Cancel', 'reaction condition', 'wordpoints') . ' |
|
427 | 427 | </button> |
428 | 428 | </div> |
429 | 429 | <div class="condition-groups section-content"></div> |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | <div class="condition-controls"> |
438 | 438 | <div class="condition-title"></div> |
439 | 439 | <button type="button" class="delete button-secondary button-link"> |
440 | - <span class="screen-reader-text">' . esc_html__( 'Remove Condition', 'wordpoints' ) . '</span> |
|
440 | + <span class="screen-reader-text">' . esc_html__('Remove Condition', 'wordpoints') . '</span> |
|
441 | 441 | <span class="dashicons dashicons-no"></span> |
442 | 442 | </button> |
443 | 443 | </div> |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | wp_register_script( |
457 | 457 | 'wordpoints-hooks-extension-periods' |
458 | 458 | , "{$assets_url}/js/hooks/extensions/periods{$manifested_suffix}.js" |
459 | - , array( 'wordpoints-hooks-views' ) |
|
459 | + , array('wordpoints-hooks-views') |
|
460 | 460 | , WORDPOINTS_VERSION |
461 | 461 | ); |
462 | 462 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | <script type="text/template" id="tmpl-wordpoints-hook-periods"> |
468 | 468 | <div class="wordpoints-hook-periods"> |
469 | 469 | <div class="periods-title section-title"> |
470 | - <h4>' . esc_html__( 'Rate Limit', 'wordpoints' ) . '</h4> |
|
470 | + <h4>' . esc_html__('Rate Limit', 'wordpoints') . '</h4> |
|
471 | 471 | </div> |
472 | 472 | <div class="periods section-content"></div> |
473 | 473 | </div> |
@@ -480,11 +480,11 @@ discard block |
||
480 | 480 | <p class="description description-thin"> |
481 | 481 | <legend>{{ data.length_in_units_label }}</legend> |
482 | 482 | <label> |
483 | - <span class="screen-reader-text">' . esc_html__( 'Time Units:', 'wordpoints' ) . '</span> |
|
483 | + <span class="screen-reader-text">' . esc_html__('Time Units:', 'wordpoints') . '</span> |
|
484 | 484 | <select class="widefat wordpoints-hook-period-sync wordpoints-hook-period-units"></select> |
485 | 485 | </label> |
486 | 486 | <label> |
487 | - <span class="screen-reader-text">' . esc_html__( 'Number:', 'wordpoints' ) . '</span> |
|
487 | + <span class="screen-reader-text">' . esc_html__('Number:', 'wordpoints') . '</span> |
|
488 | 488 | <input type="number" value="{{ data.length_in_units }}" class="widefat wordpoints-hook-period-sync wordpoints-hook-period-length-in-units" /> |
489 | 489 | </label> |
490 | 490 | </p> |
@@ -505,12 +505,12 @@ discard block |
||
505 | 505 | $hooks = wordpoints_hooks(); |
506 | 506 | |
507 | 507 | $extensions_data = wordpoints_hooks_ui_get_script_data_from_objects( |
508 | - $hooks->get_sub_app( 'extensions' )->get_all() |
|
508 | + $hooks->get_sub_app('extensions')->get_all() |
|
509 | 509 | , 'extension' |
510 | 510 | ); |
511 | 511 | |
512 | 512 | $reactor_data = wordpoints_hooks_ui_get_script_data_from_objects( |
513 | - $hooks->get_sub_app( 'reactors' )->get_all() |
|
513 | + $hooks->get_sub_app('reactors')->get_all() |
|
514 | 514 | , 'reactor' |
515 | 515 | ); |
516 | 516 | |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @param array $data The data. |
538 | 538 | */ |
539 | - $data = apply_filters( 'wordpoints_hooks_ui_data', $data ); |
|
539 | + $data = apply_filters('wordpoints_hooks_ui_data', $data); |
|
540 | 540 | |
541 | 541 | wp_localize_script( |
542 | 542 | 'wordpoints-hooks-models' |
@@ -556,18 +556,18 @@ discard block |
||
556 | 556 | * |
557 | 557 | * @return array The data extracted from the objects. |
558 | 558 | */ |
559 | -function wordpoints_hooks_ui_get_script_data_from_objects( $objects, $type ) { |
|
559 | +function wordpoints_hooks_ui_get_script_data_from_objects($objects, $type) { |
|
560 | 560 | |
561 | 561 | $data = array(); |
562 | 562 | |
563 | - foreach ( $objects as $slug => $object ) { |
|
563 | + foreach ($objects as $slug => $object) { |
|
564 | 564 | |
565 | - if ( $object instanceof WordPoints_Hook_UI_Script_Data_ProviderI ) { |
|
566 | - $data[ $slug ] = $object->get_ui_script_data(); |
|
565 | + if ($object instanceof WordPoints_Hook_UI_Script_Data_ProviderI) { |
|
566 | + $data[$slug] = $object->get_ui_script_data(); |
|
567 | 567 | } |
568 | 568 | |
569 | - if ( wp_script_is( "wordpoints-hooks-{$type}-{$slug}", 'registered' ) ) { |
|
570 | - wp_enqueue_script( "wordpoints-hooks-{$type}-{$slug}" ); |
|
569 | + if (wp_script_is("wordpoints-hooks-{$type}-{$slug}", 'registered')) { |
|
570 | + wp_enqueue_script("wordpoints-hooks-{$type}-{$slug}"); |
|
571 | 571 | } |
572 | 572 | } |
573 | 573 | |
@@ -588,31 +588,31 @@ discard block |
||
588 | 588 | $entities_data = array(); |
589 | 589 | |
590 | 590 | /** @var WordPoints_Class_Registry_Children $entity_children */ |
591 | - $entity_children = $entities->get_sub_app( 'children' ); |
|
591 | + $entity_children = $entities->get_sub_app('children'); |
|
592 | 592 | |
593 | 593 | /** @var WordPoints_Entity $entity */ |
594 | - foreach ( $entities->get_all() as $slug => $entity ) { |
|
594 | + foreach ($entities->get_all() as $slug => $entity) { |
|
595 | 595 | |
596 | 596 | $child_data = array(); |
597 | 597 | |
598 | 598 | /** @var WordPoints_EntityishI $child */ |
599 | - foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) { |
|
599 | + foreach ($entity_children->get_children($slug) as $child_slug => $child) { |
|
600 | 600 | |
601 | - $child_data[ $child_slug ] = array( |
|
601 | + $child_data[$child_slug] = array( |
|
602 | 602 | 'slug' => $child_slug, |
603 | 603 | 'title' => $child->get_title(), |
604 | 604 | ); |
605 | 605 | |
606 | - if ( $child instanceof WordPoints_Entity_Attr ) { |
|
606 | + if ($child instanceof WordPoints_Entity_Attr) { |
|
607 | 607 | |
608 | - $child_data[ $child_slug ]['_type'] = 'attr'; |
|
609 | - $child_data[ $child_slug ]['data_type'] = $child->get_data_type(); |
|
608 | + $child_data[$child_slug]['_type'] = 'attr'; |
|
609 | + $child_data[$child_slug]['data_type'] = $child->get_data_type(); |
|
610 | 610 | |
611 | - } elseif ( $child instanceof WordPoints_Entity_Relationship ) { |
|
611 | + } elseif ($child instanceof WordPoints_Entity_Relationship) { |
|
612 | 612 | |
613 | - $child_data[ $child_slug ]['_type'] = 'relationship'; |
|
614 | - $child_data[ $child_slug ]['primary'] = $child->get_primary_entity_slug(); |
|
615 | - $child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug(); |
|
613 | + $child_data[$child_slug]['_type'] = 'relationship'; |
|
614 | + $child_data[$child_slug]['primary'] = $child->get_primary_entity_slug(); |
|
615 | + $child_data[$child_slug]['secondary'] = $child->get_related_entity_slug(); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
@@ -623,14 +623,14 @@ discard block |
||
623 | 623 | * @param array $data The data for the entity child. |
624 | 624 | * @param WordPoints_Entityish $child The child's object. |
625 | 625 | */ |
626 | - $child_data[ $child_slug ] = apply_filters( |
|
626 | + $child_data[$child_slug] = apply_filters( |
|
627 | 627 | 'wordpoints_hooks_ui_data_entity_child' |
628 | - , $child_data[ $child_slug ] |
|
628 | + , $child_data[$child_slug] |
|
629 | 629 | , $child |
630 | 630 | ); |
631 | 631 | } |
632 | 632 | |
633 | - $entities_data[ $slug ] = array( |
|
633 | + $entities_data[$slug] = array( |
|
634 | 634 | 'slug' => $slug, |
635 | 635 | 'title' => $entity->get_title(), |
636 | 636 | 'children' => $child_data, |
@@ -638,12 +638,12 @@ discard block |
||
638 | 638 | '_type' => 'entity', |
639 | 639 | ); |
640 | 640 | |
641 | - if ( $entity instanceof WordPoints_Entity_EnumerableI ) { |
|
641 | + if ($entity instanceof WordPoints_Entity_EnumerableI) { |
|
642 | 642 | |
643 | 643 | $values = array(); |
644 | 644 | |
645 | - foreach ( $entity->get_enumerated_values() as $value ) { |
|
646 | - if ( $entity->set_the_value( $value ) ) { |
|
645 | + foreach ($entity->get_enumerated_values() as $value) { |
|
646 | + if ($entity->set_the_value($value)) { |
|
647 | 647 | $values[] = array( |
648 | 648 | 'value' => $entity->get_the_id(), |
649 | 649 | 'label' => $entity->get_the_human_id(), |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | } |
652 | 652 | } |
653 | 653 | |
654 | - $entities_data[ $slug ]['values'] = $values; |
|
654 | + $entities_data[$slug]['values'] = $values; |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | /** |
@@ -660,9 +660,9 @@ discard block |
||
660 | 660 | * @param array $data The data for the entity. |
661 | 661 | * @param WordPoints_Entity $entity The entity object. |
662 | 662 | */ |
663 | - $entities_data[ $slug ] = apply_filters( |
|
663 | + $entities_data[$slug] = apply_filters( |
|
664 | 664 | 'wordpoints_hooks_ui_data_entity' |
665 | - , $entities_data[ $slug ] |
|
665 | + , $entities_data[$slug] |
|
666 | 666 | , $entity |
667 | 667 | ); |
668 | 668 | |
@@ -683,19 +683,19 @@ discard block |
||
683 | 683 | // We want a list of the action types for each event. We can start with this list |
684 | 684 | // but it is indexed by action slug and then action type and then event slug, so |
685 | 685 | // we ned to do some processing. |
686 | - $event_index = wordpoints_hooks()->get_sub_app( 'router' )->get_event_index(); |
|
686 | + $event_index = wordpoints_hooks()->get_sub_app('router')->get_event_index(); |
|
687 | 687 | |
688 | 688 | // We don't care about the action slugs, so first we get rid of that bottom level |
689 | 689 | // of the array. |
690 | - $event_index = call_user_func_array( 'array_merge_recursive', $event_index ); |
|
690 | + $event_index = call_user_func_array('array_merge_recursive', $event_index); |
|
691 | 691 | |
692 | 692 | $event_action_types = array(); |
693 | 693 | |
694 | 694 | // This leaves us the event indexed by action type. But we actually need to flip |
695 | 695 | // this, so that we have the action types indexed by event slug. |
696 | - foreach ( $event_index as $action_type => $events ) { |
|
697 | - foreach ( $events as $event => $unused ) { |
|
698 | - $event_action_types[ $event ][ $action_type ] = true; |
|
696 | + foreach ($event_index as $action_type => $events) { |
|
697 | + foreach ($events as $event => $unused) { |
|
698 | + $event_action_types[$event][$action_type] = true; |
|
699 | 699 | } |
700 | 700 | } |
701 | 701 | |
@@ -718,13 +718,13 @@ discard block |
||
718 | 718 | * |
719 | 719 | * @return string The HTML with templates appended. |
720 | 720 | */ |
721 | -function wordpoints_script_templates_filter( $html, $handle ) { |
|
721 | +function wordpoints_script_templates_filter($html, $handle) { |
|
722 | 722 | |
723 | 723 | global $wp_scripts; |
724 | 724 | |
725 | - $templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' ); |
|
725 | + $templates = $wp_scripts->get_data($handle, 'wordpoints-templates'); |
|
726 | 726 | |
727 | - if ( $templates ) { |
|
727 | + if ($templates) { |
|
728 | 728 | $html .= $templates; |
729 | 729 | } |
730 | 730 | |
@@ -742,9 +742,9 @@ discard block |
||
742 | 742 | * @param string $message The text for the error message. |
743 | 743 | * @param array $args Other optional arguments. |
744 | 744 | */ |
745 | -function wordpoints_show_admin_error( $message, array $args = array() ) { |
|
745 | +function wordpoints_show_admin_error($message, array $args = array()) { |
|
746 | 746 | |
747 | - wordpoints_show_admin_message( $message, 'error', $args ); |
|
747 | + wordpoints_show_admin_message($message, 'error', $args); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | /** |
@@ -774,16 +774,16 @@ discard block |
||
774 | 774 | * Required when $dismissible is true. |
775 | 775 | * } |
776 | 776 | */ |
777 | -function wordpoints_show_admin_message( $message, $type = 'success', array $args = array() ) { |
|
777 | +function wordpoints_show_admin_message($message, $type = 'success', array $args = array()) { |
|
778 | 778 | |
779 | 779 | $defaults = array( |
780 | 780 | 'dismissible' => false, |
781 | 781 | 'option' => '', |
782 | 782 | ); |
783 | 783 | |
784 | - $args = array_merge( $defaults, $args ); |
|
784 | + $args = array_merge($defaults, $args); |
|
785 | 785 | |
786 | - if ( isset( $args['dismissable'] ) ) { |
|
786 | + if (isset($args['dismissable'])) { |
|
787 | 787 | |
788 | 788 | $args['dismissible'] = $args['dismissable']; |
789 | 789 | |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | ); |
795 | 795 | } |
796 | 796 | |
797 | - if ( 'updated' === $type ) { |
|
797 | + if ('updated' === $type) { |
|
798 | 798 | |
799 | 799 | $type = 'success'; |
800 | 800 | |
@@ -805,27 +805,27 @@ discard block |
||
805 | 805 | ); |
806 | 806 | } |
807 | 807 | |
808 | - if ( $args['dismissible'] && $args['option'] ) { |
|
809 | - wp_enqueue_script( 'wordpoints-admin-dismiss-notice' ); |
|
808 | + if ($args['dismissible'] && $args['option']) { |
|
809 | + wp_enqueue_script('wordpoints-admin-dismiss-notice'); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | ?> |
813 | 813 | |
814 | 814 | <div |
815 | - class="notice notice-<?php echo sanitize_html_class( $type, 'success' ); ?><?php echo ( $args['dismissible'] ) ? ' is-dismissible' : ''; ?>" |
|
816 | - <?php if ( $args['dismissible'] && $args['option'] ) : ?> |
|
817 | - data-nonce="<?php echo esc_attr( wp_create_nonce( "wordpoints_dismiss_notice-{$args['option']}" ) ); ?>" |
|
818 | - data-option="<?php echo esc_attr( $args['option'] ); ?>" |
|
815 | + class="notice notice-<?php echo sanitize_html_class($type, 'success'); ?><?php echo ($args['dismissible']) ? ' is-dismissible' : ''; ?>" |
|
816 | + <?php if ($args['dismissible'] && $args['option']) : ?> |
|
817 | + data-nonce="<?php echo esc_attr(wp_create_nonce("wordpoints_dismiss_notice-{$args['option']}")); ?>" |
|
818 | + data-option="<?php echo esc_attr($args['option']); ?>" |
|
819 | 819 | <?php endif; ?> |
820 | 820 | > |
821 | 821 | <p> |
822 | - <?php echo wp_kses( $message, 'wordpoints_admin_message' ); ?> |
|
822 | + <?php echo wp_kses($message, 'wordpoints_admin_message'); ?> |
|
823 | 823 | </p> |
824 | - <?php if ( $args['dismissible'] && $args['option'] ) : ?> |
|
824 | + <?php if ($args['dismissible'] && $args['option']) : ?> |
|
825 | 825 | <form method="post" class="wordpoints-notice-dismiss-form" style="padding-bottom: 5px;"> |
826 | - <input type="hidden" name="wordpoints_notice" value="<?php echo esc_html( $args['option'] ); ?>" /> |
|
827 | - <?php wp_nonce_field( "wordpoints_dismiss_notice-{$args['option']}" ); ?> |
|
828 | - <?php submit_button( __( 'Hide This Notice', 'wordpoints' ), 'secondary', 'wordpoints_dismiss_notice', false ); ?> |
|
826 | + <input type="hidden" name="wordpoints_notice" value="<?php echo esc_html($args['option']); ?>" /> |
|
827 | + <?php wp_nonce_field("wordpoints_dismiss_notice-{$args['option']}"); ?> |
|
828 | + <?php submit_button(__('Hide This Notice', 'wordpoints'), 'secondary', 'wordpoints_dismiss_notice', false); ?> |
|
829 | 829 | </form> |
830 | 830 | <?php endif; ?> |
831 | 831 | </div> |
@@ -843,19 +843,19 @@ discard block |
||
843 | 843 | * |
844 | 844 | * @return string |
845 | 845 | */ |
846 | -function wordpoints_admin_get_current_tab( array $tabs = null ) { |
|
846 | +function wordpoints_admin_get_current_tab(array $tabs = null) { |
|
847 | 847 | |
848 | 848 | $tab = ''; |
849 | 849 | |
850 | - if ( isset( $_GET['tab'] ) ) { |
|
850 | + if (isset($_GET['tab'])) { |
|
851 | 851 | |
852 | - $tab = sanitize_key( $_GET['tab'] ); |
|
852 | + $tab = sanitize_key($_GET['tab']); |
|
853 | 853 | } |
854 | 854 | |
855 | - if ( isset( $tabs ) && ! isset( $tabs[ $tab ] ) ) { |
|
855 | + if (isset($tabs) && ! isset($tabs[$tab])) { |
|
856 | 856 | |
857 | - reset( $tabs ); |
|
858 | - $tab = key( $tabs ); |
|
857 | + reset($tabs); |
|
858 | + $tab = key($tabs); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | return $tab; |
@@ -872,29 +872,29 @@ discard block |
||
872 | 872 | * @param bool $show_heading Whether to show an <h1> element using the current |
873 | 873 | * tab. Default is true. |
874 | 874 | */ |
875 | -function wordpoints_admin_show_tabs( $tabs, $show_heading = true ) { |
|
875 | +function wordpoints_admin_show_tabs($tabs, $show_heading = true) { |
|
876 | 876 | |
877 | - $current = wordpoints_admin_get_current_tab( $tabs ); |
|
877 | + $current = wordpoints_admin_get_current_tab($tabs); |
|
878 | 878 | |
879 | - if ( $show_heading ) { |
|
879 | + if ($show_heading) { |
|
880 | 880 | |
881 | 881 | // translators: Current tab name. |
882 | - echo '<h1>', esc_html( sprintf( __( 'WordPoints — %s', 'wordpoints' ), $tabs[ $current ] ) ), '</h1>'; |
|
882 | + echo '<h1>', esc_html(sprintf(__('WordPoints — %s', 'wordpoints'), $tabs[$current])), '</h1>'; |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | echo '<h2 class="nav-tab-wrapper">'; |
886 | 886 | |
887 | 887 | $page = ''; |
888 | 888 | |
889 | - if ( isset( $_GET['page'] ) ) { |
|
890 | - $page = sanitize_key( $_GET['page'] ); |
|
889 | + if (isset($_GET['page'])) { |
|
890 | + $page = sanitize_key($_GET['page']); |
|
891 | 891 | } |
892 | 892 | |
893 | - foreach ( $tabs as $tab => $name ) { |
|
893 | + foreach ($tabs as $tab => $name) { |
|
894 | 894 | |
895 | - $class = ( $tab === $current ) ? ' nav-tab-active' : ''; |
|
895 | + $class = ($tab === $current) ? ' nav-tab-active' : ''; |
|
896 | 896 | |
897 | - echo '<a class="nav-tab ', sanitize_html_class( $class ), '" href="?page=', rawurlencode( $page ), '&tab=', rawurlencode( $tab ), '">', esc_html( $name ), '</a>'; |
|
897 | + echo '<a class="nav-tab ', sanitize_html_class($class), '" href="?page=', rawurlencode($page), '&tab=', rawurlencode($tab), '">', esc_html($name), '</a>'; |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | echo '</h2>'; |
@@ -918,12 +918,12 @@ discard block |
||
918 | 918 | </style> |
919 | 919 | |
920 | 920 | <div class="upload-plugin wordpoints-upload-module"> |
921 | - <p class="install-help"><?php esc_html_e( 'If you have a module in a .zip format, you may install it by uploading it here.', 'wordpoints' ); ?></p> |
|
922 | - <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo esc_url( self_admin_url( 'update.php?action=upload-wordpoints-module' ) ); ?>"> |
|
923 | - <?php wp_nonce_field( 'wordpoints-module-upload' ); ?> |
|
924 | - <label class="screen-reader-text" for="modulezip"><?php esc_html_e( 'Module zip file', 'wordpoints' ); ?></label> |
|
921 | + <p class="install-help"><?php esc_html_e('If you have a module in a .zip format, you may install it by uploading it here.', 'wordpoints'); ?></p> |
|
922 | + <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo esc_url(self_admin_url('update.php?action=upload-wordpoints-module')); ?>"> |
|
923 | + <?php wp_nonce_field('wordpoints-module-upload'); ?> |
|
924 | + <label class="screen-reader-text" for="modulezip"><?php esc_html_e('Module zip file', 'wordpoints'); ?></label> |
|
925 | 925 | <input type="file" id="modulezip" name="modulezip" /> |
926 | - <?php submit_button( __( 'Install Now', 'wordpoints' ), 'button', 'install-module-submit', false ); ?> |
|
926 | + <?php submit_button(__('Install Now', 'wordpoints'), 'button', 'install-module-submit', false); ?> |
|
927 | 927 | </form> |
928 | 928 | </div> |
929 | 929 | |
@@ -941,15 +941,15 @@ discard block |
||
941 | 941 | |
942 | 942 | global $title, $parent_file, $submenu_file; |
943 | 943 | |
944 | - if ( ! current_user_can( 'install_wordpoints_modules' ) ) { |
|
945 | - wp_die( esc_html__( 'Sorry, you are not allowed to install WordPoints modules on this site.', 'wordpoints' ), '', array( 'response' => 403 ) ); |
|
944 | + if ( ! current_user_can('install_wordpoints_modules')) { |
|
945 | + wp_die(esc_html__('Sorry, you are not allowed to install WordPoints modules on this site.', 'wordpoints'), '', array('response' => 403)); |
|
946 | 946 | } |
947 | 947 | |
948 | - check_admin_referer( 'wordpoints-module-upload' ); |
|
948 | + check_admin_referer('wordpoints-module-upload'); |
|
949 | 949 | |
950 | - $file_upload = new File_Upload_Upgrader( 'modulezip', 'package' ); |
|
950 | + $file_upload = new File_Upload_Upgrader('modulezip', 'package'); |
|
951 | 951 | |
952 | - $title = esc_html__( 'Upload WordPoints Module', 'wordpoints' ); |
|
952 | + $title = esc_html__('Upload WordPoints Module', 'wordpoints'); |
|
953 | 953 | $parent_file = 'admin.php'; |
954 | 954 | $submenu_file = 'admin.php'; |
955 | 955 | |
@@ -959,17 +959,17 @@ discard block |
||
959 | 959 | new WordPoints_Module_Installer_Skin( |
960 | 960 | array( |
961 | 961 | // translators: File name. |
962 | - 'title' => sprintf( esc_html__( 'Installing Module from uploaded file: %s', 'wordpoints' ), esc_html( basename( $file_upload->filename ) ) ), |
|
962 | + 'title' => sprintf(esc_html__('Installing Module from uploaded file: %s', 'wordpoints'), esc_html(basename($file_upload->filename))), |
|
963 | 963 | 'nonce' => 'wordpoints-module-upload', |
964 | - 'url' => add_query_arg( array( 'package' => $file_upload->id ), self_admin_url( 'update.php?action=upload-wordpoints-module' ) ), |
|
964 | + 'url' => add_query_arg(array('package' => $file_upload->id), self_admin_url('update.php?action=upload-wordpoints-module')), |
|
965 | 965 | 'type' => 'upload', |
966 | 966 | ) |
967 | 967 | ) |
968 | 968 | ); |
969 | 969 | |
970 | - $result = $upgrader->install( $file_upload->package ); |
|
970 | + $result = $upgrader->install($file_upload->package); |
|
971 | 971 | |
972 | - if ( $result || is_wp_error( $result ) ) { |
|
972 | + if ($result || is_wp_error($result)) { |
|
973 | 973 | $file_upload->cleanup(); |
974 | 974 | } |
975 | 975 | |
@@ -993,11 +993,11 @@ discard block |
||
993 | 993 | * |
994 | 994 | * @return string|WP_Error The filtered module source. |
995 | 995 | */ |
996 | -function wordpoints_plugin_upload_error_filter( $source ) { |
|
996 | +function wordpoints_plugin_upload_error_filter($source) { |
|
997 | 997 | |
998 | 998 | static $_source; |
999 | 999 | |
1000 | - if ( ! isset( $_source ) ) { |
|
1000 | + if ( ! isset($_source)) { |
|
1001 | 1001 | |
1002 | 1002 | $_source = $source; |
1003 | 1003 | |
@@ -1006,33 +1006,33 @@ discard block |
||
1006 | 1006 | global $wp_filesystem; |
1007 | 1007 | |
1008 | 1008 | if ( |
1009 | - ! is_wp_error( $_source ) |
|
1010 | - && is_wp_error( $source ) |
|
1009 | + ! is_wp_error($_source) |
|
1010 | + && is_wp_error($source) |
|
1011 | 1011 | && 'incompatible_archive_no_plugins' === $source->get_error_code() |
1012 | 1012 | ) { |
1013 | 1013 | |
1014 | 1014 | $working_directory = str_replace( |
1015 | 1015 | $wp_filesystem->wp_content_dir() |
1016 | - , trailingslashit( WP_CONTENT_DIR ) |
|
1016 | + , trailingslashit(WP_CONTENT_DIR) |
|
1017 | 1017 | , $_source |
1018 | 1018 | ); |
1019 | 1019 | |
1020 | - if ( is_dir( $working_directory ) ) { |
|
1020 | + if (is_dir($working_directory)) { |
|
1021 | 1021 | |
1022 | - $files = glob( $working_directory . '*.php' ); |
|
1022 | + $files = glob($working_directory . '*.php'); |
|
1023 | 1023 | |
1024 | - if ( is_array( $files ) ) { |
|
1024 | + if (is_array($files)) { |
|
1025 | 1025 | |
1026 | 1026 | // Check if the folder contains a module. |
1027 | - foreach ( $files as $file ) { |
|
1027 | + foreach ($files as $file) { |
|
1028 | 1028 | |
1029 | - $info = wordpoints_get_module_data( $file, false, false ); |
|
1029 | + $info = wordpoints_get_module_data($file, false, false); |
|
1030 | 1030 | |
1031 | - if ( ! empty( $info['name'] ) ) { |
|
1031 | + if ( ! empty($info['name'])) { |
|
1032 | 1032 | $source = new WP_Error( |
1033 | 1033 | 'wordpoints_module_archive_not_plugin' |
1034 | 1034 | , $source->get_error_message() |
1035 | - , __( 'This appears to be a WordPoints module archive. Try installing it on the WordPoints module install screen instead.', 'wordpoints' ) |
|
1035 | + , __('This appears to be a WordPoints module archive. Try installing it on the WordPoints module install screen instead.', 'wordpoints') |
|
1036 | 1036 | ); |
1037 | 1037 | |
1038 | 1038 | break; |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - unset( $_source ); |
|
1045 | + unset($_source); |
|
1046 | 1046 | |
1047 | 1047 | } // End if ( ! isset( $_source ) ) else. |
1048 | 1048 | |
@@ -1062,16 +1062,16 @@ discard block |
||
1062 | 1062 | |
1063 | 1063 | <div style="height: 120px;border: none;padding: 1px 12px;background-color: #fff;border-left: 4px solid rgb(122, 208, 58);box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);margin-top: 50px;"> |
1064 | 1064 | <div style="width:48%;float:left;"> |
1065 | - <h3><?php esc_html_e( 'Like this plugin?', 'wordpoints' ); ?></h3> |
|
1065 | + <h3><?php esc_html_e('Like this plugin?', 'wordpoints'); ?></h3> |
|
1066 | 1066 | <?php // translators: URL for leaving a review of WordPoints on WordPress.org. ?> |
1067 | - <p><?php echo wp_kses( sprintf( __( 'If you think WordPoints is great, let everyone know by giving it a <a href="%s">5 star rating</a>.', 'wordpoints' ), 'https://wordpress.org/support/view/plugin-reviews/wordpoints?rate=5#postform' ), array( 'a' => array( 'href' => true ) ) ); ?></p> |
|
1068 | - <p><?php esc_html_e( 'If you don’t think this plugin deserves 5 stars, please let us know how we can improve it.', 'wordpoints' ); ?></p> |
|
1067 | + <p><?php echo wp_kses(sprintf(__('If you think WordPoints is great, let everyone know by giving it a <a href="%s">5 star rating</a>.', 'wordpoints'), 'https://wordpress.org/support/view/plugin-reviews/wordpoints?rate=5#postform'), array('a' => array('href' => true))); ?></p> |
|
1068 | + <p><?php esc_html_e('If you don’t think this plugin deserves 5 stars, please let us know how we can improve it.', 'wordpoints'); ?></p> |
|
1069 | 1069 | </div> |
1070 | 1070 | <div style="width:48%;float:left;"> |
1071 | - <h3><?php esc_html_e( 'Need help?', 'wordpoints' ); ?></h3> |
|
1071 | + <h3><?php esc_html_e('Need help?', 'wordpoints'); ?></h3> |
|
1072 | 1072 | <?php // translators: URL of WordPoints plugin support forums WordPress.org. ?> |
1073 | - <p><?php echo wp_kses( sprintf( __( 'Post your feature request or support question in the <a href="%s">support forums</a>', 'wordpoints' ), 'https://wordpress.org/support/plugin/wordpoints' ), array( 'a' => array( 'href' => true ) ) ); ?></p> |
|
1074 | - <p><em><?php esc_html_e( 'Thank you for using WordPoints!', 'wordpoints' ); ?></em></p> |
|
1073 | + <p><?php echo wp_kses(sprintf(__('Post your feature request or support question in the <a href="%s">support forums</a>', 'wordpoints'), 'https://wordpress.org/support/plugin/wordpoints'), array('a' => array('href' => true))); ?></p> |
|
1074 | + <p><em><?php esc_html_e('Thank you for using WordPoints!', 'wordpoints'); ?></em></p> |
|
1075 | 1075 | </div> |
1076 | 1076 | </div> |
1077 | 1077 | |
@@ -1089,19 +1089,19 @@ discard block |
||
1089 | 1089 | |
1090 | 1090 | wordpoints_delete_admin_notice_option(); |
1091 | 1091 | |
1092 | - if ( current_user_can( 'activate_wordpoints_modules' ) ) { |
|
1092 | + if (current_user_can('activate_wordpoints_modules')) { |
|
1093 | 1093 | |
1094 | - if ( is_network_admin() ) { |
|
1094 | + if (is_network_admin()) { |
|
1095 | 1095 | |
1096 | - $deactivated_modules = get_site_option( 'wordpoints_breaking_deactivated_modules' ); |
|
1096 | + $deactivated_modules = get_site_option('wordpoints_breaking_deactivated_modules'); |
|
1097 | 1097 | |
1098 | - if ( is_array( $deactivated_modules ) ) { |
|
1098 | + if (is_array($deactivated_modules)) { |
|
1099 | 1099 | wordpoints_show_admin_error( |
1100 | 1100 | sprintf( |
1101 | 1101 | // translators: 1. Plugin version; 2. List of modules. |
1102 | - __( 'WordPoints has deactivated the following modules because of incompatibilities with WordPoints %1$s: %2$s', 'wordpoints' ) |
|
1102 | + __('WordPoints has deactivated the following modules because of incompatibilities with WordPoints %1$s: %2$s', 'wordpoints') |
|
1103 | 1103 | , WORDPOINTS_VERSION |
1104 | - , implode( ', ', $deactivated_modules ) |
|
1104 | + , implode(', ', $deactivated_modules) |
|
1105 | 1105 | ) |
1106 | 1106 | , array( |
1107 | 1107 | 'dismissible' => true, |
@@ -1110,15 +1110,15 @@ discard block |
||
1110 | 1110 | ); |
1111 | 1111 | } |
1112 | 1112 | |
1113 | - $incompatible_modules = get_site_option( 'wordpoints_incompatible_modules' ); |
|
1113 | + $incompatible_modules = get_site_option('wordpoints_incompatible_modules'); |
|
1114 | 1114 | |
1115 | - if ( is_array( $incompatible_modules ) ) { |
|
1115 | + if (is_array($incompatible_modules)) { |
|
1116 | 1116 | wordpoints_show_admin_error( |
1117 | 1117 | sprintf( |
1118 | 1118 | // translators: 1. Plugin version; 2. List of modules. |
1119 | - __( 'WordPoints has deactivated the following network-active modules because of incompatibilities with WordPoints %1$s: %2$s', 'wordpoints' ) |
|
1119 | + __('WordPoints has deactivated the following network-active modules because of incompatibilities with WordPoints %1$s: %2$s', 'wordpoints') |
|
1120 | 1120 | , WORDPOINTS_VERSION |
1121 | - , implode( ', ', $incompatible_modules ) |
|
1121 | + , implode(', ', $incompatible_modules) |
|
1122 | 1122 | ) |
1123 | 1123 | , array( |
1124 | 1124 | 'dismissible' => true, |
@@ -1129,15 +1129,15 @@ discard block |
||
1129 | 1129 | |
1130 | 1130 | } else { |
1131 | 1131 | |
1132 | - $incompatible_modules = get_option( 'wordpoints_incompatible_modules' ); |
|
1132 | + $incompatible_modules = get_option('wordpoints_incompatible_modules'); |
|
1133 | 1133 | |
1134 | - if ( is_array( $incompatible_modules ) ) { |
|
1134 | + if (is_array($incompatible_modules)) { |
|
1135 | 1135 | wordpoints_show_admin_error( |
1136 | 1136 | sprintf( |
1137 | 1137 | // translators: 1. Plugin version; 2. List of modules. |
1138 | - __( 'WordPoints has deactivated the following modules on this site because of incompatibilities with WordPoints %1$s: %2$s', 'wordpoints' ) |
|
1138 | + __('WordPoints has deactivated the following modules on this site because of incompatibilities with WordPoints %1$s: %2$s', 'wordpoints') |
|
1139 | 1139 | , WORDPOINTS_VERSION |
1140 | - , implode( ', ', $incompatible_modules ) |
|
1140 | + , implode(', ', $incompatible_modules) |
|
1141 | 1141 | ) |
1142 | 1142 | , array( |
1143 | 1143 | 'dismissible' => true, |
@@ -1164,23 +1164,23 @@ discard block |
||
1164 | 1164 | $is_notice_dismissed = wordpoints_verify_nonce( |
1165 | 1165 | '_wpnonce' |
1166 | 1166 | , 'wordpoints_dismiss_notice-%s' |
1167 | - , array( 'wordpoints_notice' ) |
|
1167 | + , array('wordpoints_notice') |
|
1168 | 1168 | , 'post' |
1169 | 1169 | ); |
1170 | 1170 | |
1171 | - if ( $is_notice_dismissed && isset( $_POST['wordpoints_notice'] ) ) { |
|
1171 | + if ($is_notice_dismissed && isset($_POST['wordpoints_notice'])) { |
|
1172 | 1172 | |
1173 | - $option = sanitize_key( $_POST['wordpoints_notice'] ); |
|
1173 | + $option = sanitize_key($_POST['wordpoints_notice']); |
|
1174 | 1174 | |
1175 | - if ( ! is_network_admin() && 'wordpoints_incompatible_modules' === $option ) { |
|
1176 | - delete_option( $option ); |
|
1175 | + if ( ! is_network_admin() && 'wordpoints_incompatible_modules' === $option) { |
|
1176 | + delete_option($option); |
|
1177 | 1177 | } else { |
1178 | - wordpoints_delete_maybe_network_option( $option ); |
|
1178 | + wordpoints_delete_maybe_network_option($option); |
|
1179 | 1179 | } |
1180 | 1180 | } |
1181 | 1181 | |
1182 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
1183 | - wp_die( '', 200 ); |
|
1182 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
1183 | + wp_die('', 200); |
|
1184 | 1184 | } |
1185 | 1185 | } |
1186 | 1186 | |
@@ -1197,14 +1197,14 @@ discard block |
||
1197 | 1197 | * |
1198 | 1198 | * @return mixed The option value, sanitized if it is for one of the plugin's screens. |
1199 | 1199 | */ |
1200 | -function wordpoints_admin_set_screen_option( $sanitized, $option, $value ) { |
|
1200 | +function wordpoints_admin_set_screen_option($sanitized, $option, $value) { |
|
1201 | 1201 | |
1202 | - switch ( $option ) { |
|
1202 | + switch ($option) { |
|
1203 | 1203 | |
1204 | 1204 | case 'wordpoints_page_wordpoints_modules_per_page': |
1205 | 1205 | case 'wordpoints_page_wordpoints_modules_network_per_page': |
1206 | 1206 | case 'toplevel_page_wordpoints_modules_per_page': |
1207 | - $sanitized = wordpoints_posint( $value ); |
|
1207 | + $sanitized = wordpoints_posint($value); |
|
1208 | 1208 | break; |
1209 | 1209 | } |
1210 | 1210 | |
@@ -1225,18 +1225,18 @@ discard block |
||
1225 | 1225 | */ |
1226 | 1226 | function wordpoints_admin_ajax_breaking_module_check() { |
1227 | 1227 | |
1228 | - if ( ! isset( $_GET['wordpoints_module_check'] ) ) { |
|
1229 | - wp_die( '', 400 ); |
|
1228 | + if ( ! isset($_GET['wordpoints_module_check'])) { |
|
1229 | + wp_die('', 400); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | - if ( is_network_admin() ) { |
|
1233 | - $nonce = get_site_option( 'wordpoints_module_check_nonce' ); |
|
1232 | + if (is_network_admin()) { |
|
1233 | + $nonce = get_site_option('wordpoints_module_check_nonce'); |
|
1234 | 1234 | } else { |
1235 | - $nonce = get_option( 'wordpoints_module_check_nonce' ); |
|
1235 | + $nonce = get_option('wordpoints_module_check_nonce'); |
|
1236 | 1236 | } |
1237 | 1237 | |
1238 | - if ( ! $nonce || ! hash_equals( $nonce, sanitize_key( $_GET['wordpoints_module_check'] ) ) ) { |
|
1239 | - wp_die( '', 403 ); |
|
1238 | + if ( ! $nonce || ! hash_equals($nonce, sanitize_key($_GET['wordpoints_module_check']))) { |
|
1239 | + wp_die('', 403); |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | // The list table constructor calls WP_Screen::get(), which expects this. |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | |
1245 | 1245 | wordpoints_admin_screen_modules(); |
1246 | 1246 | |
1247 | - wp_die( '', 200 ); |
|
1247 | + wp_die('', 200); |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | /** |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | */ |
1257 | 1257 | function wordpoints_hooks_admin_ajax() { |
1258 | 1258 | |
1259 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
1259 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
1260 | 1260 | new WordPoints_Admin_Ajax_Hooks; |
1261 | 1261 | } |
1262 | 1262 | } |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @since 1.7.0 |
40 | 40 | */ |
41 | - public function __construct( array $args ) { |
|
41 | + public function __construct(array $args) { |
|
42 | 42 | |
43 | - parent::__construct( $args ); |
|
43 | + parent::__construct($args); |
|
44 | 44 | |
45 | - $this->name = _x( 'Points', 'rank type', 'wordpoints' ); |
|
45 | + $this->name = _x('Points', 'rank type', 'wordpoints'); |
|
46 | 46 | |
47 | - if ( ! isset( $args['points_type'] ) ) { |
|
47 | + if ( ! isset($args['points_type'])) { |
|
48 | 48 | _doing_it_wrong( |
49 | 49 | __METHOD__ |
50 | 50 | , 'WordPoints Error: The "points_type" argument is required.' |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - $this->meta_fields['points']['label'] = _x( 'Points', 'form label', 'wordpoints' ); |
|
56 | + $this->meta_fields['points']['label'] = _x('Points', 'form label', 'wordpoints'); |
|
57 | 57 | $this->meta_fields['points_type']['default'] = $args['points_type']; |
58 | 58 | |
59 | - add_action( 'wordpoints_points_altered', array( $this, 'hook' ), 10, 3 ); |
|
59 | + add_action('wordpoints_points_altered', array($this, 'hook'), 10, 3); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function destruct() { |
68 | 68 | |
69 | - remove_action( 'wordpoints_points_altered', array( $this, 'hook' ), 10 ); |
|
69 | + remove_action('wordpoints_points_altered', array($this, 'hook'), 10); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -78,47 +78,47 @@ discard block |
||
78 | 78 | * @param int $points The number of points. |
79 | 79 | * @param string $points_type The type of points. |
80 | 80 | */ |
81 | - public function hook( $user_id, $points, $points_type ) { |
|
81 | + public function hook($user_id, $points, $points_type) { |
|
82 | 82 | |
83 | - if ( $points_type !== $this->meta_fields['points_type']['default'] ) { |
|
83 | + if ($points_type !== $this->meta_fields['points_type']['default']) { |
|
84 | 84 | return; |
85 | 85 | } |
86 | 86 | |
87 | - $this->maybe_transition_user_ranks( $user_id, $points > 0 ); |
|
87 | + $this->maybe_transition_user_ranks($user_id, $points > 0); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @since 1.7.0 |
92 | 92 | */ |
93 | - public function validate_rank_meta( array $meta ) { |
|
93 | + public function validate_rank_meta(array $meta) { |
|
94 | 94 | |
95 | - if ( ! isset( $meta['points'] ) || false === wordpoints_int( $meta['points'] ) ) { |
|
95 | + if ( ! isset($meta['points']) || false === wordpoints_int($meta['points'])) { |
|
96 | 96 | return new WP_Error( |
97 | 97 | 'wordpoints_points_rank_type_invalid_points' |
98 | - , __( 'The amount of points is required, and must be a valid number.', 'wordpoints' ) |
|
99 | - , array( 'field' => 'points' ) |
|
98 | + , __('The amount of points is required, and must be a valid number.', 'wordpoints') |
|
99 | + , array('field' => 'points') |
|
100 | 100 | ); |
101 | 101 | } |
102 | 102 | |
103 | 103 | if ( |
104 | - ! isset( $meta['points_type'] ) |
|
105 | - || ! wordpoints_is_points_type( $meta['points_type'] ) |
|
104 | + ! isset($meta['points_type']) |
|
105 | + || ! wordpoints_is_points_type($meta['points_type']) |
|
106 | 106 | ) { |
107 | 107 | return false; |
108 | 108 | } |
109 | 109 | |
110 | - $minimum = wordpoints_get_points_minimum( $meta['points_type'] ); |
|
110 | + $minimum = wordpoints_get_points_minimum($meta['points_type']); |
|
111 | 111 | |
112 | - if ( $meta['points'] < $minimum ) { |
|
112 | + if ($meta['points'] < $minimum) { |
|
113 | 113 | |
114 | 114 | return new WP_Error( |
115 | 115 | 'wordpoints_points_rank_type_points_less_than_minimum' |
116 | 116 | , sprintf( |
117 | 117 | // translators: Minimum number of points. |
118 | - __( 'The number of points must be more than the minimum (%s).', 'wordpoints' ) |
|
119 | - , wordpoints_format_points( $minimum, $meta['points_type'], 'points_rank_error' ) |
|
118 | + __('The number of points must be more than the minimum (%s).', 'wordpoints') |
|
119 | + , wordpoints_format_points($minimum, $meta['points_type'], 'points_rank_error') |
|
120 | 120 | ) |
121 | - , array( 'field' => 'points' ) |
|
121 | + , array('field' => 'points') |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
@@ -141,15 +141,15 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return bool Whether the user meets the requirements for this rank. |
143 | 143 | */ |
144 | - protected function can_transition_user_rank( $user_id, $rank, array $args ) { |
|
144 | + protected function can_transition_user_rank($user_id, $rank, array $args) { |
|
145 | 145 | |
146 | - if ( $rank->points_type !== $this->meta_fields['points_type']['default'] ) { |
|
146 | + if ($rank->points_type !== $this->meta_fields['points_type']['default']) { |
|
147 | 147 | return false; |
148 | 148 | } |
149 | 149 | |
150 | - $user_points = wordpoints_get_points( $user_id, $rank->points_type ); |
|
150 | + $user_points = wordpoints_get_points($user_id, $rank->points_type); |
|
151 | 151 | |
152 | - if ( $rank->points > $user_points ) { |
|
152 | + if ($rank->points > $user_points) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @WordPress\filter wordpoints_points_widget_text 30 After esc_html(). |
16 | 16 | */ |
17 | -function wordpoints_ranks_points_widget_text_filter( $text, $instance ) { |
|
17 | +function wordpoints_ranks_points_widget_text_filter($text, $instance) { |
|
18 | 18 | |
19 | - if ( is_user_logged_in() ) { |
|
19 | + if (is_user_logged_in()) { |
|
20 | 20 | |
21 | 21 | $rank = wordpoints_get_formatted_user_rank( |
22 | 22 | get_current_user_id() |
23 | 23 | , "points_type-{$instance['points_type']}" |
24 | 24 | , 'my-points-widget' |
25 | - , array( 'widget_settings' => $instance ) |
|
25 | + , array('widget_settings' => $instance) |
|
26 | 26 | ); |
27 | 27 | |
28 | - $text = str_replace( '%rank%', $rank, $text ); |
|
28 | + $text = str_replace('%rank%', $rank, $text); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | return $text; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ?> |
44 | 44 | <br /> |
45 | 45 | <?php // translators: Placeholder name. ?> |
46 | - <small><i><?php echo esc_html( sprintf( __( '%s will be replaced with the rank of the logged in user', 'wordpoints' ), '%rank%' ) ); ?></i></small> |
|
46 | + <small><i><?php echo esc_html(sprintf(__('%s will be replaced with the rank of the logged in user', 'wordpoints'), '%rank%')); ?></i></small> |
|
47 | 47 | <?php |
48 | 48 | } |
49 | 49 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @WordPress\filter wordpoints_points_top_users_username |
56 | 56 | */ |
57 | -function wordpoints_ranks_points_top_users_username_filter( $name, $user_id, $points_type, $context ) { |
|
57 | +function wordpoints_ranks_points_top_users_username_filter($name, $user_id, $points_type, $context) { |
|
58 | 58 | |
59 | 59 | $rank = wordpoints_get_formatted_user_rank( |
60 | 60 | $user_id |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @WordPress\filter shortcode_atts_wordpoints_user_rank |
76 | 76 | */ |
77 | -function wordpoints_user_rank_shortcode_points_type_attr( $out, $pairs, $atts ) { |
|
77 | +function wordpoints_user_rank_shortcode_points_type_attr($out, $pairs, $atts) { |
|
78 | 78 | |
79 | - if ( empty( $out['rank_group'] ) ) { |
|
79 | + if (empty($out['rank_group'])) { |
|
80 | 80 | |
81 | - if ( isset( $atts['points_type'] ) ) { |
|
81 | + if (isset($atts['points_type'])) { |
|
82 | 82 | |
83 | 83 | $out['rank_group'] = "points_type-{$atts['points_type']}"; |
84 | 84 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | $points_type = wordpoints_get_default_points_type(); |
88 | 88 | |
89 | - if ( $points_type ) { |
|
89 | + if ($points_type) { |
|
90 | 90 | $out['rank_group'] = "points_type-{$points_type}"; |
91 | 91 | } |
92 | 92 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | function wordpoints_register_points_ranks() { |
106 | 106 | |
107 | - foreach ( wordpoints_get_points_types() as $slug => $points_type ) { |
|
107 | + foreach (wordpoints_get_points_types() as $slug => $points_type) { |
|
108 | 108 | |
109 | 109 | WordPoints_Rank_Groups::register_group( |
110 | 110 | "points_type-{$slug}" |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | 'name' => $points_type['name'], |
113 | 113 | 'description' => sprintf( |
114 | 114 | // translators: Points type name. |
115 | - __( 'This rank group is associated with the “%s” points type.', 'wordpoints' ) |
|
115 | + __('This rank group is associated with the “%s” points type.', 'wordpoints') |
|
116 | 116 | , $points_type['name'] |
117 | 117 | ), |
118 | 118 | ) |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | WordPoints_Rank_Types::register_type( |
122 | 122 | "points-{$slug}" |
123 | 123 | , 'WordPoints_Points_Rank_Type' |
124 | - , array( 'points_type' => $slug ) |
|
124 | + , array('points_type' => $slug) |
|
125 | 125 | ); |
126 | 126 | |
127 | 127 | WordPoints_Rank_Groups::register_type_for_group( |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | |
146 | 146 | $tab = wordpoints_admin_get_current_tab(); |
147 | 147 | |
148 | - if ( 'add-new' === $tab ) { |
|
148 | + if ('add-new' === $tab) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | 152 | add_meta_box( |
153 | 153 | 'ranks' |
154 | - , _x( 'Ranks', 'Points Types screen meta box title', 'wordpoints' ) |
|
154 | + , _x('Ranks', 'Points Types screen meta box title', 'wordpoints') |
|
155 | 155 | , 'wordpoints_ranks_display_points_types_meta_box_ranks' |
156 | 156 | , 'wordpoints_page_wordpoints_points_types' |
157 | 157 | , 'side' |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @param array $points_type The data for the points type being edited. |
168 | 168 | */ |
169 | -function wordpoints_ranks_display_points_types_meta_box_ranks( $points_type ) { |
|
169 | +function wordpoints_ranks_display_points_types_meta_box_ranks($points_type) { |
|
170 | 170 | |
171 | 171 | ?> |
172 | 172 | |
173 | - <a href="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_ranks&tab=points_type-' . $points_type['slug'] ) ); ?>"> |
|
174 | - <?php esc_html_e( 'Go to the ranks for this points type.', 'wordpoints' ); ?> |
|
173 | + <a href="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_ranks&tab=points_type-' . $points_type['slug'])); ?>"> |
|
174 | + <?php esc_html_e('Go to the ranks for this points type.', 'wordpoints'); ?> |
|
175 | 175 | </a> |
176 | 176 | |
177 | 177 | <?php |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | |
10 | 10 | $rank_groups = WordPoints_Rank_Groups::get(); |
11 | 11 | |
12 | -if ( empty( $rank_groups ) ) { |
|
12 | +if (empty($rank_groups)) { |
|
13 | 13 | |
14 | 14 | ?> |
15 | 15 | <div class="wrap"> |
16 | - <?php wordpoints_show_admin_error( esc_html__( 'No rank groups are currently available.', 'wordpoints' ) ); ?> |
|
16 | + <?php wordpoints_show_admin_error(esc_html__('No rank groups are currently available.', 'wordpoints')); ?> |
|
17 | 17 | </div> |
18 | 18 | <?php |
19 | 19 | |
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | -$rank_group = $rank_groups[ wordpoints_admin_get_current_tab( $rank_groups ) ]; |
|
23 | +$rank_group = $rank_groups[wordpoints_admin_get_current_tab($rank_groups)]; |
|
24 | 24 | |
25 | 25 | ?> |
26 | 26 | |
27 | 27 | <div class="wrap"> |
28 | - <h1><?php esc_html_e( 'Ranks', 'wordpoints' ); ?></h1> |
|
28 | + <h1><?php esc_html_e('Ranks', 'wordpoints'); ?></h1> |
|
29 | 29 | |
30 | - <?php wordpoints_admin_show_tabs( wp_list_pluck( $rank_groups, 'name' ), false ) ?> |
|
30 | + <?php wordpoints_admin_show_tabs(wp_list_pluck($rank_groups, 'name'), false) ?> |
|
31 | 31 | |
32 | 32 | <div id="ranks-error-message" class="notice notice-error hidden"> |
33 | 33 | <p></p> |
@@ -42,34 +42,34 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param WordPoints_Rank_Group $rank_group The rank group being displayed. |
44 | 44 | */ |
45 | - do_action( 'wordpoints_ranks_admin_screen_top', $rank_group ); |
|
45 | + do_action('wordpoints_ranks_admin_screen_top', $rank_group); |
|
46 | 46 | |
47 | 47 | ?> |
48 | 48 | |
49 | 49 | <div class="wordpoints-rank-group-container"> |
50 | - <p class="description group-description"><?php echo esc_html( $rank_group->description ); ?></p> |
|
50 | + <p class="description group-description"><?php echo esc_html($rank_group->description); ?></p> |
|
51 | 51 | <ul |
52 | - id="wordpoints-rank-group_<?php echo esc_attr( $rank_group->slug ); ?>" |
|
52 | + id="wordpoints-rank-group_<?php echo esc_attr($rank_group->slug); ?>" |
|
53 | 53 | class="wordpoints-rank-group" |
54 | - data-slug="<?php echo esc_attr( $rank_group->slug ); ?>" |
|
55 | - data-nonce="<?php echo esc_attr( wp_create_nonce( "wordpoints_get_ranks-{$rank_group->slug}" ) ); ?>" |
|
54 | + data-slug="<?php echo esc_attr($rank_group->slug); ?>" |
|
55 | + data-nonce="<?php echo esc_attr(wp_create_nonce("wordpoints_get_ranks-{$rank_group->slug}")); ?>" |
|
56 | 56 | > |
57 | 57 | </ul> |
58 | 58 | <div class="spinner-overlay" style="display: block;"> |
59 | 59 | <span class="spinner is-active"></span> |
60 | 60 | </div> |
61 | 61 | <div class="controls"> |
62 | - <button class="add-rank button-primary"><?php esc_html_e( 'Add Rank', 'wordpoints' ); ?></button> |
|
62 | + <button class="add-rank button-primary"><?php esc_html_e('Add Rank', 'wordpoints'); ?></button> |
|
63 | 63 | <label class="wordpoints-rank-types"> |
64 | - <?php esc_html_e( 'Rank Type:', 'wordpoints' ); ?> |
|
64 | + <?php esc_html_e('Rank Type:', 'wordpoints'); ?> |
|
65 | 65 | <select> |
66 | - <?php foreach ( $rank_group->get_types() as $rank_type ) : ?> |
|
67 | - <?php if ( 'base' !== $rank_type ) : ?> |
|
66 | + <?php foreach ($rank_group->get_types() as $rank_type) : ?> |
|
67 | + <?php if ('base' !== $rank_type) : ?> |
|
68 | 68 | <option |
69 | - value="<?php echo esc_attr( $rank_type ); ?>" |
|
70 | - data-nonce="<?php echo esc_attr( wp_create_nonce( "wordpoints_create_rank|{$rank_group->slug}|{$rank_type}" ) ); ?>" |
|
69 | + value="<?php echo esc_attr($rank_type); ?>" |
|
70 | + data-nonce="<?php echo esc_attr(wp_create_nonce("wordpoints_create_rank|{$rank_group->slug}|{$rank_type}")); ?>" |
|
71 | 71 | > |
72 | - <?php echo esc_html( WordPoints_Rank_Types::get_type( $rank_type )->get_name() ); ?> |
|
72 | + <?php echo esc_html(WordPoints_Rank_Types::get_type($rank_type)->get_name()); ?> |
|
73 | 73 | </option> |
74 | 74 | <?php endif; ?> |
75 | 75 | <?php endforeach; ?> |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param WordPoints_Rank_Group $rank_group The rank group being displayed. |
88 | 88 | */ |
89 | - do_action( 'wordpoints_ranks_admin_screen_bottom', $rank_group ); |
|
89 | + do_action('wordpoints_ranks_admin_screen_bottom', $rank_group); |
|
90 | 90 | |
91 | 91 | ?> |
92 | 92 | </div> |
93 | 93 | |
94 | -<?php foreach ( $rank_group->get_types() as $rank_type ) : ?> |
|
95 | - <script type="text/template" class="rank-template_<?php echo sanitize_html_class( $rank_type ); ?>"> |
|
94 | +<?php foreach ($rank_group->get_types() as $rank_type) : ?> |
|
95 | + <script type="text/template" class="rank-template_<?php echo sanitize_html_class($rank_type); ?>"> |
|
96 | 96 | <div class="view"> |
97 | 97 | <div> |
98 | 98 | <%- name %> |
@@ -100,31 +100,31 @@ discard block |
||
100 | 100 | |
101 | 101 | $field = key( |
102 | 102 | wp_list_filter( |
103 | - WordPoints_Rank_Types::get_type( $rank_type )->get_meta_fields() |
|
104 | - , array( 'in_title' => true ) |
|
103 | + WordPoints_Rank_Types::get_type($rank_type)->get_meta_fields() |
|
104 | + , array('in_title' => true) |
|
105 | 105 | ) |
106 | 106 | ); |
107 | 107 | |
108 | 108 | ?> |
109 | - <?php if ( $field ) : ?> |
|
110 | - <span><% if ( typeof <?php echo preg_replace( '/[^a-z0-9_]/i', '', $field ); // WPCS: XSS OK ?> !== "undefined" ) { print( <?php echo preg_replace( '/[^a-z0-9_]/i', '', $field ); // WPCS: XSS OK ?> ); } %></span> |
|
109 | + <?php if ($field) : ?> |
|
110 | + <span><% if ( typeof <?php echo preg_replace('/[^a-z0-9_]/i', '', $field); // WPCS: XSS OK ?> !== "undefined" ) { print( <?php echo preg_replace('/[^a-z0-9_]/i', '', $field); // WPCS: XSS OK ?> ); } %></span> |
|
111 | 111 | <?php endif; ?> |
112 | 112 | </div> |
113 | - <a class="edit"><?php echo esc_html_x( 'Edit', 'rank', 'wordpoints' ); ?></a> |
|
114 | - <a class="close"><?php esc_html_e( 'Close', 'wordpoints' ); ?></a> |
|
113 | + <a class="edit"><?php echo esc_html_x('Edit', 'rank', 'wordpoints'); ?></a> |
|
114 | + <a class="close"><?php esc_html_e('Close', 'wordpoints'); ?></a> |
|
115 | 115 | </div> |
116 | 116 | <form> |
117 | 117 | <div class="fields"> |
118 | 118 | <p class="description description-thin"> |
119 | 119 | <label> |
120 | - <?php echo esc_html_x( 'Title', 'rank', 'wordpoints' ); ?> |
|
120 | + <?php echo esc_html_x('Title', 'rank', 'wordpoints'); ?> |
|
121 | 121 | <input class="widefat" type="text" value="<%- name %>" name="name" /> |
122 | 122 | </label> |
123 | 123 | </p> |
124 | - <input type="hidden" name="type" value="<?php echo esc_attr( $rank_type ); ?>" /> |
|
124 | + <input type="hidden" name="type" value="<?php echo esc_attr($rank_type); ?>" /> |
|
125 | 125 | <input type="hidden" name="order" value="<%- order %>" /> |
126 | 126 | <input type="hidden" name="nonce" value="<%- nonce %>" /> |
127 | - <?php WordPoints_Rank_Types::get_type( $rank_type )->display_rank_meta_form_fields( array(), array( 'placeholders' => true ) ); ?> |
|
127 | + <?php WordPoints_Rank_Types::get_type($rank_type)->display_rank_meta_form_fields(array(), array('placeholders' => true)); ?> |
|
128 | 128 | </div> |
129 | 129 | <div class="messages"> |
130 | 130 | <div class="success"></div> |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | <span class="spinner is-active"></span> |
136 | 136 | </div> |
137 | 137 | <div class="action-buttons"> |
138 | - <button class="save button-primary" disabled><?php esc_html_e( 'Save', 'wordpoints' ); ?></button> |
|
139 | - <button class="cancel button-secondary"><?php esc_html_e( 'Cancel', 'wordpoints' ); ?></button> |
|
140 | - <button class="close button-secondary"><?php esc_html_e( 'Close', 'wordpoints' ); ?></button> |
|
141 | - <?php if ( 'base' !== $rank_type ) : ?> |
|
142 | - <button class="delete button-secondary"><?php esc_html_e( 'Delete', 'wordpoints' ); ?></button> |
|
138 | + <button class="save button-primary" disabled><?php esc_html_e('Save', 'wordpoints'); ?></button> |
|
139 | + <button class="cancel button-secondary"><?php esc_html_e('Cancel', 'wordpoints'); ?></button> |
|
140 | + <button class="close button-secondary"><?php esc_html_e('Close', 'wordpoints'); ?></button> |
|
141 | + <?php if ('base' !== $rank_type) : ?> |
|
142 | + <button class="delete button-secondary"><?php esc_html_e('Delete', 'wordpoints'); ?></button> |
|
143 | 143 | <?php endif; ?> |
144 | 144 | </div> |
145 | 145 | </div> |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | $rank_groups = WordPoints_Rank_Groups::get(); |
67 | 67 | $ranks = array(); |
68 | 68 | |
69 | - foreach ( $rank_groups as $group ) { |
|
70 | - $ranks[ $group->slug ] = self::prepare_group_ranks( $group ); |
|
69 | + foreach ($rank_groups as $group) { |
|
70 | + $ranks[$group->slug] = self::prepare_group_ranks($group); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $ranks; |
@@ -82,20 +82,20 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return array The ranks of this group, prepared for sending to the JS. |
84 | 84 | */ |
85 | - public static function prepare_group_ranks( $group ) { |
|
85 | + public static function prepare_group_ranks($group) { |
|
86 | 86 | |
87 | 87 | $rank_ids = $group->get_ranks(); |
88 | 88 | $ranks = array(); |
89 | 89 | |
90 | - foreach ( $rank_ids as $order => $rank_id ) { |
|
90 | + foreach ($rank_ids as $order => $rank_id) { |
|
91 | 91 | |
92 | - $rank = wordpoints_get_rank( $rank_id ); |
|
92 | + $rank = wordpoints_get_rank($rank_id); |
|
93 | 93 | |
94 | - if ( ! $rank ) { |
|
94 | + if ( ! $rank) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | |
98 | - $ranks[] = self::_prepare_rank( $rank ); |
|
98 | + $ranks[] = self::_prepare_rank($rank); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return $ranks; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function __construct() { |
114 | 114 | |
115 | - if ( isset( self::$instance ) ) { |
|
116 | - _doing_it_wrong( __METHOD__, 'Class should only be constructed once.', '1.7.0' ); |
|
115 | + if (isset(self::$instance)) { |
|
116 | + _doing_it_wrong(__METHOD__, 'Class should only be constructed once.', '1.7.0'); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | self::$instance = $this; |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function hooks() { |
130 | 130 | |
131 | - add_action( 'wp_ajax_wordpoints_admin_get_ranks', array( $this, 'get_ranks' ) ); |
|
132 | - add_action( 'wp_ajax_wordpoints_admin_create_rank', array( $this, 'create_rank' ) ); |
|
133 | - add_action( 'wp_ajax_wordpoints_admin_update_rank', array( $this, 'update_rank' ) ); |
|
134 | - add_action( 'wp_ajax_wordpoints_admin_delete_rank', array( $this, 'delete_rank' ) ); |
|
131 | + add_action('wp_ajax_wordpoints_admin_get_ranks', array($this, 'get_ranks')); |
|
132 | + add_action('wp_ajax_wordpoints_admin_create_rank', array($this, 'create_rank')); |
|
133 | + add_action('wp_ajax_wordpoints_admin_update_rank', array($this, 'update_rank')); |
|
134 | + add_action('wp_ajax_wordpoints_admin_delete_rank', array($this, 'delete_rank')); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | |
146 | 146 | $group = $this->_get_group(); |
147 | 147 | |
148 | - $this->_verify_request( "wordpoints_get_ranks-{$group->slug}" ); |
|
148 | + $this->_verify_request("wordpoints_get_ranks-{$group->slug}"); |
|
149 | 149 | |
150 | - wp_send_json_success( self::prepare_group_ranks( $group ) ); |
|
150 | + wp_send_json_success(self::prepare_group_ranks($group)); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $group = $this->_get_group(); |
163 | 163 | $type = $this->_get_rank_type()->get_slug(); |
164 | 164 | |
165 | - $this->_verify_request( "wordpoints_create_rank|{$group->slug}|{$type}" ); |
|
165 | + $this->_verify_request("wordpoints_create_rank|{$group->slug}|{$type}"); |
|
166 | 166 | |
167 | 167 | // Attempt to save the rank. |
168 | 168 | $result = wordpoints_add_rank( |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | , $this->_get_rank_meta() |
174 | 174 | ); |
175 | 175 | |
176 | - $this->_send_json_result( $result, 'create' ); |
|
176 | + $this->_send_json_result($result, 'create'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | |
195 | 195 | $type = $this->_get_rank_type()->get_slug(); |
196 | 196 | |
197 | - if ( $type !== $rank->type ) { |
|
198 | - wp_send_json_error( array( 'message' => __( 'This rank does not match any rank in the database, perhaps it was deleted. Refresh the page to update the list of ranks.', 'wordpoints' ) ) ); |
|
197 | + if ($type !== $rank->type) { |
|
198 | + wp_send_json_error(array('message' => __('This rank does not match any rank in the database, perhaps it was deleted. Refresh the page to update the list of ranks.', 'wordpoints'))); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | $result = wordpoints_update_rank( |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | , $this->_get_rank_meta() |
208 | 208 | ); |
209 | 209 | |
210 | - $this->_send_json_result( $result, 'update' ); |
|
210 | + $this->_send_json_result($result, 'update'); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | "wordpoints_delete_rank|{$group->slug}|{$rank->ID}" |
227 | 227 | ); |
228 | 228 | |
229 | - $result = wordpoints_delete_rank( $rank->ID ); |
|
229 | + $result = wordpoints_delete_rank($rank->ID); |
|
230 | 230 | |
231 | - if ( ! $result ) { |
|
232 | - wp_send_json_error( array( 'message' => __( 'There was an error deleting the rank. Please try again.', 'wordpoints' ) ) ); |
|
231 | + if ( ! $result) { |
|
232 | + wp_send_json_error(array('message' => __('There was an error deleting the rank. Please try again.', 'wordpoints'))); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | wp_send_json_success(); |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @param string $debug_context Context sent with the message (for debugging). |
252 | 252 | */ |
253 | - private function _unexpected_error( $debug_context ) { |
|
253 | + private function _unexpected_error($debug_context) { |
|
254 | 254 | |
255 | 255 | wp_send_json_error( |
256 | 256 | array( |
257 | - 'message' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
257 | + 'message' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
258 | 258 | 'debug' => $debug_context, |
259 | 259 | ) |
260 | 260 | ); |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | */ |
271 | 271 | private function _verify_user_can() { |
272 | 272 | |
273 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
274 | - wp_send_json_error( array( 'message' => __( 'Sorry, you are not allowed to perform this action. Maybe you have been logged out?', 'wordpoints' ) ) ); |
|
273 | + if ( ! current_user_can('manage_options')) { |
|
274 | + wp_send_json_error(array('message' => __('Sorry, you are not allowed to perform this action. Maybe you have been logged out?', 'wordpoints'))); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
@@ -284,14 +284,14 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @param string $action The action the nonce should be for. |
286 | 286 | */ |
287 | - private function _verify_request( $action ) { |
|
287 | + private function _verify_request($action) { |
|
288 | 288 | |
289 | 289 | if ( |
290 | - empty( $_POST['nonce'] ) |
|
291 | - || ! wordpoints_verify_nonce( 'nonce', $action, null, 'post' ) |
|
290 | + empty($_POST['nonce']) |
|
291 | + || ! wordpoints_verify_nonce('nonce', $action, null, 'post') |
|
292 | 292 | ) { |
293 | 293 | wp_send_json_error( |
294 | - array( 'message' => __( 'Your security token for this action has expired. Refresh the page and try again.', 'wordpoints' ) ) |
|
294 | + array('message' => __('Your security token for this action has expired. Refresh the page and try again.', 'wordpoints')) |
|
295 | 295 | ); |
296 | 296 | } |
297 | 297 | } |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | */ |
306 | 306 | private function _get_group() { |
307 | 307 | |
308 | - if ( ! isset( $_POST['group'] ) ) { // WPCS: CSRF OK. |
|
309 | - $this->_unexpected_error( 'group' ); |
|
308 | + if ( ! isset($_POST['group'])) { // WPCS: CSRF OK. |
|
309 | + $this->_unexpected_error('group'); |
|
310 | 310 | } |
311 | 311 | |
312 | - $group = WordPoints_Rank_Groups::get_group( sanitize_key( $_POST['group'] ) ); // WPCS: CSRF OK. |
|
312 | + $group = WordPoints_Rank_Groups::get_group(sanitize_key($_POST['group'])); // WPCS: CSRF OK. |
|
313 | 313 | |
314 | - if ( ! $group ) { |
|
315 | - wp_send_json_error( array( 'message' => __( 'The rank group passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints' ) ) ); |
|
314 | + if ( ! $group) { |
|
315 | + wp_send_json_error(array('message' => __('The rank group passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints'))); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | return $group; |
@@ -327,14 +327,14 @@ discard block |
||
327 | 327 | */ |
328 | 328 | private function _get_rank() { |
329 | 329 | |
330 | - if ( ! isset( $_POST['id'] ) ) { // WPCS: CSRF OK. |
|
331 | - $this->_unexpected_error( 'id' ); |
|
330 | + if ( ! isset($_POST['id'])) { // WPCS: CSRF OK. |
|
331 | + $this->_unexpected_error('id'); |
|
332 | 332 | } |
333 | 333 | |
334 | - $rank = wordpoints_get_rank( wordpoints_int( $_POST['id'] ) ); // WPCS: CSRF OK. |
|
334 | + $rank = wordpoints_get_rank(wordpoints_int($_POST['id'])); // WPCS: CSRF OK. |
|
335 | 335 | |
336 | - if ( ! $rank ) { |
|
337 | - wp_send_json_error( array( 'message' => __( 'The rank ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints' ) ) ); |
|
336 | + if ( ! $rank) { |
|
337 | + wp_send_json_error(array('message' => __('The rank ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints'))); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $rank; |
@@ -351,14 +351,14 @@ discard block |
||
351 | 351 | |
352 | 352 | $name = ''; |
353 | 353 | |
354 | - if ( ! empty( $_POST['name'] ) ) { // WPCS: CSRF OK. |
|
355 | - $name = sanitize_text_field( wp_unslash( $_POST['name'] ) ); // WPCS: CSRF OK. |
|
354 | + if ( ! empty($_POST['name'])) { // WPCS: CSRF OK. |
|
355 | + $name = sanitize_text_field(wp_unslash($_POST['name'])); // WPCS: CSRF OK. |
|
356 | 356 | } |
357 | 357 | |
358 | - if ( ! $name ) { |
|
358 | + if ( ! $name) { |
|
359 | 359 | wp_send_json_error( |
360 | 360 | array( |
361 | - 'message' => __( 'Please enter a name for this rank.', 'wordpoints' ), |
|
361 | + 'message' => __('Please enter a name for this rank.', 'wordpoints'), |
|
362 | 362 | 'field' => 'name', |
363 | 363 | ) |
364 | 364 | ); |
@@ -376,17 +376,17 @@ discard block |
||
376 | 376 | */ |
377 | 377 | private function _get_rank_type() { |
378 | 378 | |
379 | - if ( empty( $_POST['type'] ) ) { // WPCS: CSRF OK. |
|
380 | - $this->_unexpected_error( 'type' ); |
|
379 | + if (empty($_POST['type'])) { // WPCS: CSRF OK. |
|
380 | + $this->_unexpected_error('type'); |
|
381 | 381 | } |
382 | 382 | |
383 | - $type = sanitize_text_field( wp_unslash( $_POST['type'] ) ); // WPCS: CSRF OK. |
|
383 | + $type = sanitize_text_field(wp_unslash($_POST['type'])); // WPCS: CSRF OK. |
|
384 | 384 | |
385 | - if ( ! WordPoints_Rank_Types::is_type_registered( $type ) ) { |
|
386 | - wp_send_json_error( array( 'message' => __( 'That rank type was not recognized. It may no longer be available. Try reloading the page.', 'wordpoints' ) ) ); |
|
385 | + if ( ! WordPoints_Rank_Types::is_type_registered($type)) { |
|
386 | + wp_send_json_error(array('message' => __('That rank type was not recognized. It may no longer be available. Try reloading the page.', 'wordpoints'))); |
|
387 | 387 | } |
388 | 388 | |
389 | - $this->rank_type = WordPoints_Rank_Types::get_type( $type ); |
|
389 | + $this->rank_type = WordPoints_Rank_Types::get_type($type); |
|
390 | 390 | |
391 | 391 | return $this->rank_type; |
392 | 392 | } |
@@ -401,10 +401,10 @@ discard block |
||
401 | 401 | private function _get_rank_position() { |
402 | 402 | |
403 | 403 | if ( |
404 | - ! isset( $_POST['order'] ) // WPCS: CSRF OK. |
|
405 | - || false === wordpoints_int( $_POST['order'] ) // WPCS: CSRF OK. |
|
404 | + ! isset($_POST['order']) // WPCS: CSRF OK. |
|
405 | + || false === wordpoints_int($_POST['order']) // WPCS: CSRF OK. |
|
406 | 406 | ) { |
407 | - $this->_unexpected_error( 'order' ); |
|
407 | + $this->_unexpected_error('order'); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | return (int) $_POST['order']; |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | private function _get_rank_meta() { |
421 | 421 | |
422 | 422 | return array_intersect_key( |
423 | - wp_unslash( $_POST ) // WPCS: CSRF OK. |
|
423 | + wp_unslash($_POST) // WPCS: CSRF OK. |
|
424 | 424 | , $this->rank_type->get_meta_fields() |
425 | 425 | ); |
426 | 426 | } |
@@ -433,19 +433,19 @@ discard block |
||
433 | 433 | * @param mixed $result The result of the action. |
434 | 434 | * @param string $action The action being performed: 'create' or 'update'. |
435 | 435 | */ |
436 | - private function _send_json_result( $result, $action ) { |
|
436 | + private function _send_json_result($result, $action) { |
|
437 | 437 | |
438 | - if ( ! $result ) { |
|
438 | + if ( ! $result) { |
|
439 | 439 | |
440 | - if ( 'create' === $action ) { |
|
441 | - $message = __( 'There was an error adding the rank. Please try again.', 'wordpoints' ); |
|
440 | + if ('create' === $action) { |
|
441 | + $message = __('There was an error adding the rank. Please try again.', 'wordpoints'); |
|
442 | 442 | } else { |
443 | - $message = __( 'There was an error updating the rank. Please try again.', 'wordpoints' ); |
|
443 | + $message = __('There was an error updating the rank. Please try again.', 'wordpoints'); |
|
444 | 444 | } |
445 | 445 | |
446 | - wp_send_json_error( array( 'message' => $message ) ); |
|
446 | + wp_send_json_error(array('message' => $message)); |
|
447 | 447 | |
448 | - } elseif ( is_wp_error( $result ) ) { |
|
448 | + } elseif (is_wp_error($result)) { |
|
449 | 449 | |
450 | 450 | wp_send_json_error( |
451 | 451 | array( |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | |
458 | 458 | $data = null; |
459 | 459 | |
460 | - if ( 'create' === $action ) { |
|
461 | - $data = self::_prepare_rank( wordpoints_get_rank( $result ) ); |
|
460 | + if ('create' === $action) { |
|
461 | + $data = self::_prepare_rank(wordpoints_get_rank($result)); |
|
462 | 462 | } |
463 | 463 | |
464 | - wp_send_json_success( $data ); |
|
464 | + wp_send_json_success($data); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | // |
@@ -477,15 +477,15 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return array The rank data extracted into an array. |
479 | 479 | */ |
480 | - private static function _prepare_rank( $rank ) { |
|
480 | + private static function _prepare_rank($rank) { |
|
481 | 481 | |
482 | 482 | $name = $rank->name; |
483 | - if ( empty( $name ) ) { |
|
484 | - $name = __( '(no title)', 'wordpoints' ); |
|
483 | + if (empty($name)) { |
|
484 | + $name = __('(no title)', 'wordpoints'); |
|
485 | 485 | } |
486 | 486 | |
487 | - $order = WordPoints_Rank_Groups::get_group( $rank->rank_group ) |
|
488 | - ->get_rank_position( $rank->ID ); |
|
487 | + $order = WordPoints_Rank_Groups::get_group($rank->rank_group) |
|
488 | + ->get_rank_position($rank->ID); |
|
489 | 489 | |
490 | 490 | $prepared_rank = array( |
491 | 491 | 'id' => $rank->ID, |
@@ -500,10 +500,10 @@ discard block |
||
500 | 500 | ), |
501 | 501 | ); |
502 | 502 | |
503 | - $rank_type = WordPoints_Rank_Types::get_type( $rank->type ); |
|
503 | + $rank_type = WordPoints_Rank_Types::get_type($rank->type); |
|
504 | 504 | |
505 | - foreach ( $rank_type->get_meta_fields() as $field => $data ) { |
|
506 | - $prepared_rank[ $field ] = $rank->{$field}; |
|
505 | + foreach ($rank_type->get_meta_fields() as $field => $data) { |
|
506 | + $prepared_rank[$field] = $rank->{$field}; |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | return $prepared_rank; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @deprecated 2.1.0 |
99 | 99 | */ |
100 | 100 | public static function init() { |
101 | - _deprecated_function( __METHOD__, '2.1.0' ); |
|
101 | + _deprecated_function(__METHOD__, '2.1.0'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param string $class_name A 'WordPoints_Points_Hook' class name. |
110 | 110 | */ |
111 | - public static function register( $class_name ) { |
|
111 | + public static function register($class_name) { |
|
112 | 112 | |
113 | 113 | self::$classes[] = $class_name; |
114 | 114 | } |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @since 1.4.0 |
129 | 129 | */ |
130 | - do_action( 'wordpoints_points_hooks_register' ); |
|
130 | + do_action('wordpoints_points_hooks_register'); |
|
131 | 131 | |
132 | - $classes = array_unique( self::$classes ); |
|
132 | + $classes = array_unique(self::$classes); |
|
133 | 133 | |
134 | - foreach ( $classes as $class_name ) { |
|
134 | + foreach ($classes as $class_name) { |
|
135 | 135 | |
136 | 136 | $hook_type = new $class_name(); |
137 | - self::$hook_types[ $hook_type->get_id_base() ] = $hook_type; |
|
137 | + self::$hook_types[$hook_type->get_id_base()] = $hook_type; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.0.0 |
144 | 144 | */ |
145 | - do_action( 'wordpoints_points_hooks_registered' ); |
|
145 | + do_action('wordpoints_points_hooks_registered'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -166,25 +166,25 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return WordPoints_Points_Hook|false The hook object, or false for invalid ID. |
168 | 168 | */ |
169 | - public static function get_handler( $hook_id ) { |
|
169 | + public static function get_handler($hook_id) { |
|
170 | 170 | |
171 | - list( $hook_type, $id_number ) = explode( '-', $hook_id ); |
|
171 | + list($hook_type, $id_number) = explode('-', $hook_id); |
|
172 | 172 | |
173 | - $hook_type = self::get_handler_by_id_base( $hook_type ); |
|
173 | + $hook_type = self::get_handler_by_id_base($hook_type); |
|
174 | 174 | |
175 | - if ( false === $hook_type ) { |
|
175 | + if (false === $hook_type) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
179 | - $type = ( self::$network_mode ) ? 'network' : 'standard'; |
|
179 | + $type = (self::$network_mode) ? 'network' : 'standard'; |
|
180 | 180 | |
181 | - $instances = $hook_type->get_instances( $type ); |
|
181 | + $instances = $hook_type->get_instances($type); |
|
182 | 182 | |
183 | - if ( ! isset( $instances[ $id_number ] ) ) { |
|
183 | + if ( ! isset($instances[$id_number])) { |
|
184 | 184 | return false; |
185 | 185 | } |
186 | 186 | |
187 | - $hook_type->set_number( $id_number ); |
|
187 | + $hook_type->set_number($id_number); |
|
188 | 188 | |
189 | 189 | return $hook_type; |
190 | 190 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return WordPoints_Points_Hook|false False if no handler found. |
203 | 203 | */ |
204 | - public static function get_handler_by_id_base( $id_base ) { |
|
204 | + public static function get_handler_by_id_base($id_base) { |
|
205 | 205 | |
206 | - if ( ! isset( self::$hook_types[ $id_base ] ) ) { |
|
206 | + if ( ! isset(self::$hook_types[$id_base])) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - return self::$hook_types[ $id_base ]; |
|
210 | + return self::$hook_types[$id_base]; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -221,35 +221,35 @@ discard block |
||
221 | 221 | * installed. Only needed if on multisite. If |
222 | 222 | * omitted, the current site ID is used. |
223 | 223 | */ |
224 | - public static function uninstall_hook_types( $hook_types, array $site_ids = null ) { |
|
224 | + public static function uninstall_hook_types($hook_types, array $site_ids = null) { |
|
225 | 225 | |
226 | - _deprecated_function( __METHOD__, '2.0.0', 'WordPoints_Un_Installer_Base::$uninstall' ); |
|
226 | + _deprecated_function(__METHOD__, '2.0.0', 'WordPoints_Un_Installer_Base::$uninstall'); |
|
227 | 227 | |
228 | 228 | $hook_types = (array) $hook_types; |
229 | 229 | |
230 | - if ( is_multisite() ) { |
|
230 | + if (is_multisite()) { |
|
231 | 231 | |
232 | - foreach ( $hook_types as $hook_type ) { |
|
233 | - delete_site_option( "wordpoints_hook-{$hook_type}" ); |
|
232 | + foreach ($hook_types as $hook_type) { |
|
233 | + delete_site_option("wordpoints_hook-{$hook_type}"); |
|
234 | 234 | } |
235 | 235 | |
236 | - if ( ! isset( $site_ids ) ) { |
|
237 | - $site_ids = array( get_current_blog_id() ); |
|
236 | + if ( ! isset($site_ids)) { |
|
237 | + $site_ids = array(get_current_blog_id()); |
|
238 | 238 | } |
239 | 239 | |
240 | - foreach ( $site_ids as $site_id ) { |
|
240 | + foreach ($site_ids as $site_id) { |
|
241 | 241 | |
242 | - switch_to_blog( $site_id ); |
|
243 | - foreach ( $hook_types as $hook_type ) { |
|
244 | - delete_option( "wordpoints_hook-{$hook_type}" ); |
|
242 | + switch_to_blog($site_id); |
|
243 | + foreach ($hook_types as $hook_type) { |
|
244 | + delete_option("wordpoints_hook-{$hook_type}"); |
|
245 | 245 | } |
246 | 246 | restore_current_blog(); |
247 | 247 | } |
248 | 248 | |
249 | 249 | } else { |
250 | 250 | |
251 | - foreach ( $hook_types as $hook_type ) { |
|
252 | - delete_option( "wordpoints_hook-{$hook_type}" ); |
|
251 | + foreach ($hook_types as $hook_type) { |
|
252 | + delete_option("wordpoints_hook-{$hook_type}"); |
|
253 | 253 | } |
254 | 254 | } |
255 | 255 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | // Sort the hooks by name. |
268 | 268 | $hook_types = self::$hook_types; |
269 | - uasort( $hook_types, array( __CLASS__, '_sort_name_callback' ) ); |
|
269 | + uasort($hook_types, array(__CLASS__, '_sort_name_callback')); |
|
270 | 270 | |
271 | 271 | $disabled_hooks = wordpoints_get_maybe_network_array_option( |
272 | 272 | 'wordpoints_legacy_points_hooks_disabled' |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | $i = 0; |
277 | 277 | |
278 | 278 | // Display a representative for each hook type. |
279 | - foreach ( $hook_types as $id_base => $hook_type ) { |
|
279 | + foreach ($hook_types as $id_base => $hook_type) { |
|
280 | 280 | |
281 | - if ( isset( $disabled_hooks[ $id_base ] ) ) { |
|
281 | + if (isset($disabled_hooks[$id_base])) { |
|
282 | 282 | continue; |
283 | 283 | } |
284 | 284 | |
@@ -291,16 +291,16 @@ discard block |
||
291 | 291 | $args['_multi_num'] = $hook_type->next_hook_id_number(); |
292 | 292 | $args['_id_slug'] = $i; |
293 | 293 | |
294 | - $hook_type->set_options( $args ); |
|
294 | + $hook_type->set_options($args); |
|
295 | 295 | |
296 | - self::_list_hook( $hook_type->get_id( 0 ), $hook_type ); |
|
296 | + self::_list_hook($hook_type->get_id(0), $hook_type); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | // If there were none, give the user a message. |
300 | - if ( empty( $hook_types ) ) { |
|
300 | + if (empty($hook_types)) { |
|
301 | 301 | |
302 | 302 | echo '<div class="wordpoints-no-hooks">' |
303 | - . esc_html__( 'There are no points hooks currently available.', 'wordpoints' ) |
|
303 | + . esc_html__('There are no points hooks currently available.', 'wordpoints') |
|
304 | 304 | . '</div>'; |
305 | 305 | } |
306 | 306 | } |
@@ -318,21 +318,21 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return void |
320 | 320 | */ |
321 | - public static function list_by_points_type( $slug ) { |
|
321 | + public static function list_by_points_type($slug) { |
|
322 | 322 | |
323 | - if ( '_inactive_hooks' !== $slug && ! wordpoints_is_points_type( $slug ) ) { |
|
323 | + if ('_inactive_hooks' !== $slug && ! wordpoints_is_points_type($slug)) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - $points_type_hooks = self::get_points_type_hooks( $slug ); |
|
327 | + $points_type_hooks = self::get_points_type_hooks($slug); |
|
328 | 328 | |
329 | - foreach ( $points_type_hooks as $hook_id ) { |
|
329 | + foreach ($points_type_hooks as $hook_id) { |
|
330 | 330 | |
331 | - list( $hook_type ) = explode( '-', $hook_id ); |
|
331 | + list($hook_type) = explode('-', $hook_id); |
|
332 | 332 | |
333 | - $hook_type = self::get_handler_by_id_base( $hook_type ); |
|
333 | + $hook_type = self::get_handler_by_id_base($hook_type); |
|
334 | 334 | |
335 | - if ( false === $hook_type ) { |
|
335 | + if (false === $hook_type) { |
|
336 | 336 | continue; |
337 | 337 | } |
338 | 338 | |
@@ -340,13 +340,13 @@ discard block |
||
340 | 340 | |
341 | 341 | $options['_display'] = 'instance'; |
342 | 342 | |
343 | - unset( $options['_add'] ); |
|
343 | + unset($options['_add']); |
|
344 | 344 | |
345 | 345 | $options['_id_slug'] = $slug; |
346 | 346 | |
347 | - $hook_type->set_options( $options ); |
|
347 | + $hook_type->set_options($options); |
|
348 | 348 | |
349 | - self::_list_hook( $hook_id, $hook_type, $slug ); |
|
349 | + self::_list_hook($hook_id, $hook_type, $slug); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
@@ -362,9 +362,9 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @param bool $on Whether to turn network mode on or off. |
364 | 364 | */ |
365 | - public static function set_network_mode( $on ) { |
|
365 | + public static function set_network_mode($on) { |
|
366 | 366 | |
367 | - if ( $on !== self::$network_mode ) { |
|
367 | + if ($on !== self::$network_mode) { |
|
368 | 368 | self::$network_mode = (bool) $on; |
369 | 369 | } |
370 | 370 | } |
@@ -408,12 +408,12 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @return array |
410 | 410 | */ |
411 | - public static function get_points_type_hooks( $slug ) { |
|
411 | + public static function get_points_type_hooks($slug) { |
|
412 | 412 | |
413 | 413 | $points_types_hooks = self::get_points_types_hooks(); |
414 | 414 | |
415 | - if ( isset( $points_types_hooks[ $slug ] ) && is_array( $points_types_hooks[ $slug ] ) ) { |
|
416 | - $points_type_hooks = $points_types_hooks[ $slug ]; |
|
415 | + if (isset($points_types_hooks[$slug]) && is_array($points_types_hooks[$slug])) { |
|
416 | + $points_type_hooks = $points_types_hooks[$slug]; |
|
417 | 417 | } else { |
418 | 418 | $points_type_hooks = array(); |
419 | 419 | } |
@@ -428,12 +428,12 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @param array $points_types_hooks The list of points types and their hooks. |
430 | 430 | */ |
431 | - public static function save_points_types_hooks( array $points_types_hooks ) { |
|
431 | + public static function save_points_types_hooks(array $points_types_hooks) { |
|
432 | 432 | |
433 | - if ( self::$network_mode ) { |
|
434 | - update_site_option( 'wordpoints_points_types_hooks', $points_types_hooks ); |
|
433 | + if (self::$network_mode) { |
|
434 | + update_site_option('wordpoints_points_types_hooks', $points_types_hooks); |
|
435 | 435 | } else { |
436 | - update_option( 'wordpoints_points_types_hooks', $points_types_hooks ); |
|
436 | + update_option('wordpoints_points_types_hooks', $points_types_hooks); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
@@ -446,11 +446,11 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @return string|false The points type for the hook. False if not found. |
448 | 448 | */ |
449 | - public static function get_points_type( $hook_id ) { |
|
449 | + public static function get_points_type($hook_id) { |
|
450 | 450 | |
451 | - foreach ( self::get_points_types_hooks() as $points_type => $hooks ) { |
|
451 | + foreach (self::get_points_types_hooks() as $points_type => $hooks) { |
|
452 | 452 | |
453 | - if ( in_array( $hook_id, $hooks ) ) { |
|
453 | + if (in_array($hook_id, $hooks)) { |
|
454 | 454 | return $points_type; |
455 | 455 | } |
456 | 456 | } |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | |
470 | 470 | $defaults = array(); |
471 | 471 | |
472 | - foreach ( wordpoints_get_points_types() as $slug => $settings ) { |
|
472 | + foreach (wordpoints_get_points_types() as $slug => $settings) { |
|
473 | 473 | |
474 | - $defaults[ $slug ] = array(); |
|
474 | + $defaults[$slug] = array(); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | return $defaults; |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | * @param string $slug The slug for this type of points. |
497 | 497 | * @param string $wrap Whether to wrap the form inputs in a "widget" or not. |
498 | 498 | */ |
499 | - public static function points_type_form( $slug = null, $wrap = 'hook' ) { |
|
499 | + public static function points_type_form($slug = null, $wrap = 'hook') { |
|
500 | 500 | |
501 | 501 | _deprecated_function( |
502 | 502 | __METHOD__ |
@@ -506,12 +506,12 @@ discard block |
||
506 | 506 | |
507 | 507 | $add_new = 0; |
508 | 508 | |
509 | - $points_type = wordpoints_get_points_type( $slug ); |
|
509 | + $points_type = wordpoints_get_points_type($slug); |
|
510 | 510 | |
511 | - if ( ! $points_type ) { |
|
511 | + if ( ! $points_type) { |
|
512 | 512 | |
513 | 513 | $points_type = array(); |
514 | - $add_new = wp_create_nonce( 'wordpoints_add_new_points_type' ); |
|
514 | + $add_new = wp_create_nonce('wordpoints_add_new_points_type'); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | $points_type = array_merge( |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | ,$points_type |
524 | 524 | ); |
525 | 525 | |
526 | - if ( ! isset( $slug ) && 'hook' === $wrap ) { |
|
526 | + if ( ! isset($slug) && 'hook' === $wrap) { |
|
527 | 527 | $wrap = 'hook-content'; |
528 | 528 | } |
529 | 529 | |
530 | - switch ( $wrap ) { |
|
530 | + switch ($wrap) { |
|
531 | 531 | |
532 | 532 | case 'hook': |
533 | 533 | $hook_wrap = true; |
@@ -546,25 +546,25 @@ discard block |
||
546 | 546 | |
547 | 547 | ?> |
548 | 548 | |
549 | - <?php if ( $hook_wrap ) : ?> |
|
549 | + <?php if ($hook_wrap) : ?> |
|
550 | 550 | <div class="hook points-settings"> |
551 | 551 | <div class="hook-top"> |
552 | 552 | <div class="hook-title-action"> |
553 | 553 | <a class="hook-action hide-if-no-js" href="#available-hooks"></a> |
554 | 554 | </div> |
555 | - <div class="hook-title"><h3><?php esc_html_e( 'Settings', 'wordpoints' ); ?><span class="in-hook-title"></span></h3></div> |
|
555 | + <div class="hook-title"><h3><?php esc_html_e('Settings', 'wordpoints'); ?><span class="in-hook-title"></span></h3></div> |
|
556 | 556 | </div> |
557 | 557 | |
558 | 558 | <div class="hook-inside"> |
559 | 559 | <?php endif; ?> |
560 | 560 | |
561 | - <?php if ( $hook_content_wrap ) : ?> |
|
561 | + <?php if ($hook_content_wrap) : ?> |
|
562 | 562 | <form method="post"> |
563 | 563 | <div class="hook-content"> |
564 | 564 | <?php endif; ?> |
565 | 565 | |
566 | - <?php if ( $slug ) : ?> |
|
567 | - <p><span class="wordpoints-points-slug"><em><?php esc_html_e( 'Slug', 'wordpoints' ); ?>: <?php echo esc_html( $slug ); ?></em></span></p> |
|
566 | + <?php if ($slug) : ?> |
|
567 | + <p><span class="wordpoints-points-slug"><em><?php esc_html_e('Slug', 'wordpoints'); ?>: <?php echo esc_html($slug); ?></em></span></p> |
|
568 | 568 | <?php endif; ?> |
569 | 569 | |
570 | 570 | <?php |
@@ -578,33 +578,33 @@ discard block |
||
578 | 578 | * |
579 | 579 | * @param string $points_type The slug of the points type. |
580 | 580 | */ |
581 | - do_action( 'wordpoints_points_type_form_top', $slug ); |
|
581 | + do_action('wordpoints_points_type_form_top', $slug); |
|
582 | 582 | |
583 | - if ( 'hook-content' === $wrap ) { |
|
583 | + if ('hook-content' === $wrap) { |
|
584 | 584 | |
585 | 585 | // Mark the prefix and suffix optional on the add new form. |
586 | - $prefix = _x( 'Prefix (optional):', 'points type', 'wordpoints' ); |
|
587 | - $suffix = _x( 'Suffix (optional):', 'points type', 'wordpoints' ); |
|
586 | + $prefix = _x('Prefix (optional):', 'points type', 'wordpoints'); |
|
587 | + $suffix = _x('Suffix (optional):', 'points type', 'wordpoints'); |
|
588 | 588 | |
589 | 589 | } else { |
590 | 590 | |
591 | - $prefix = _x( 'Prefix:', 'points type', 'wordpoints' ); |
|
592 | - $suffix = _x( 'Suffix:', 'points type', 'wordpoints' ); |
|
591 | + $prefix = _x('Prefix:', 'points type', 'wordpoints'); |
|
592 | + $suffix = _x('Suffix:', 'points type', 'wordpoints'); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | ?> |
596 | 596 | |
597 | 597 | <p> |
598 | - <label for="points-name-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html_x( 'Name:', 'points type', 'wordpoints' ); ?></label> |
|
599 | - <input class="widefat" type="text" id="points-name-<?php echo esc_attr( $slug ); ?>" name="points-name" value="<?php echo esc_attr( $points_type['name'] ); ?>" /> |
|
598 | + <label for="points-name-<?php echo esc_attr($slug); ?>"><?php echo esc_html_x('Name:', 'points type', 'wordpoints'); ?></label> |
|
599 | + <input class="widefat" type="text" id="points-name-<?php echo esc_attr($slug); ?>" name="points-name" value="<?php echo esc_attr($points_type['name']); ?>" /> |
|
600 | 600 | </p> |
601 | 601 | <p> |
602 | - <label for="points-prefix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $prefix ); ?></label> |
|
603 | - <input class="widefat" type="text" id="points-prefix-<?php echo esc_attr( $slug ); ?>" name="points-prefix" value="<?php echo esc_attr( $points_type['prefix'] ); ?>" /> |
|
602 | + <label for="points-prefix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($prefix); ?></label> |
|
603 | + <input class="widefat" type="text" id="points-prefix-<?php echo esc_attr($slug); ?>" name="points-prefix" value="<?php echo esc_attr($points_type['prefix']); ?>" /> |
|
604 | 604 | </p> |
605 | 605 | <p> |
606 | - <label for="points-suffix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $suffix ); ?></label> |
|
607 | - <input class="widefat" type="text" id="points-suffix-<?php echo esc_attr( $slug ); ?>" name="points-suffix" value="<?php echo esc_attr( $points_type['suffix'] ); ?>" /> |
|
606 | + <label for="points-suffix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($suffix); ?></label> |
|
607 | + <input class="widefat" type="text" id="points-suffix-<?php echo esc_attr($slug); ?>" name="points-suffix" value="<?php echo esc_attr($points_type['suffix']); ?>" /> |
|
608 | 608 | </p> |
609 | 609 | |
610 | 610 | <?php |
@@ -618,30 +618,30 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @param string $points_type The slug of the points type. |
620 | 620 | */ |
621 | - do_action( 'wordpoints_points_type_form_bottom', $slug ); |
|
621 | + do_action('wordpoints_points_type_form_bottom', $slug); |
|
622 | 622 | |
623 | 623 | ?> |
624 | 624 | |
625 | - <?php if ( $hook_content_wrap ) : ?> |
|
625 | + <?php if ($hook_content_wrap) : ?> |
|
626 | 626 | </div> |
627 | 627 | |
628 | - <input type="hidden" name="points-slug" value="<?php echo esc_attr( $slug ); ?>" /> |
|
629 | - <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr( $add_new ); ?>" /> |
|
628 | + <input type="hidden" name="points-slug" value="<?php echo esc_attr($slug); ?>" /> |
|
629 | + <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" /> |
|
630 | 630 | |
631 | 631 | <div class="hook-control-actions"> |
632 | 632 | <div class="alignleft"> |
633 | 633 | <?php |
634 | 634 | |
635 | - if ( ! $add_new ) { |
|
636 | - wp_nonce_field( "wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce' ); |
|
637 | - submit_button( _x( 'Delete', 'points type', 'wordpoints' ), 'delete', 'delete-points-type', false, array( 'id' => "delete_points_type-{$slug}" ) ); |
|
635 | + if ( ! $add_new) { |
|
636 | + wp_nonce_field("wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce'); |
|
637 | + submit_button(_x('Delete', 'points type', 'wordpoints'), 'delete', 'delete-points-type', false, array('id' => "delete_points_type-{$slug}")); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | ?> |
641 | - <a class="hook-control-close" href="#close"><?php esc_html_e( 'Close', 'wordpoints' ); ?></a> |
|
641 | + <a class="hook-control-close" href="#close"><?php esc_html_e('Close', 'wordpoints'); ?></a> |
|
642 | 642 | </div> |
643 | 643 | <div class="alignright"> |
644 | - <?php submit_button( _x( 'Save', 'points type', 'wordpoints' ), 'button-primary hook-control-save right', 'save-points-type', false, array( 'id' => "points-{$slug}-save" ) ); ?> |
|
644 | + <?php submit_button(_x('Save', 'points type', 'wordpoints'), 'button-primary hook-control-save right', 'save-points-type', false, array('id' => "points-{$slug}-save")); ?> |
|
645 | 645 | <span class="spinner"></span> |
646 | 646 | </div> |
647 | 647 | <br class="clear" /> |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | </form> |
650 | 650 | <?php endif; ?> |
651 | 651 | |
652 | - <?php if ( $hook_wrap ) : ?> |
|
652 | + <?php if ($hook_wrap) : ?> |
|
653 | 653 | </div> |
654 | 654 | </div> |
655 | 655 | |
@@ -669,25 +669,25 @@ discard block |
||
669 | 669 | * @param WordPoints_Points_Hook $hook A points hook object. |
670 | 670 | * @param string $points_type The slug for a points type. |
671 | 671 | */ |
672 | - private static function _list_hook( $hook_id, $hook, $points_type = null ) { |
|
672 | + private static function _list_hook($hook_id, $hook, $points_type = null) { |
|
673 | 673 | |
674 | - $number = $hook->get_number_by_id( $hook_id ); |
|
674 | + $number = $hook->get_number_by_id($hook_id); |
|
675 | 675 | $id_base = $hook->get_id_base(); |
676 | 676 | $options = $hook->get_options(); |
677 | 677 | |
678 | 678 | $id_format = $hook_id; |
679 | 679 | |
680 | - $multi_number = ( isset( $options['_multi_num'] ) ) ? $options['_multi_num'] : ''; |
|
681 | - $add_new = ( isset( $options['_add'] ) ) ? $options['_add'] : ''; |
|
680 | + $multi_number = (isset($options['_multi_num'])) ? $options['_multi_num'] : ''; |
|
681 | + $add_new = (isset($options['_add'])) ? $options['_add'] : ''; |
|
682 | 682 | |
683 | 683 | // Prepare the URL query string. |
684 | - $query_arg = array( 'edithook' => $id_format ); |
|
684 | + $query_arg = array('edithook' => $id_format); |
|
685 | 685 | |
686 | - if ( $add_new ) { |
|
686 | + if ($add_new) { |
|
687 | 687 | |
688 | 688 | $query_arg['addnew'] = 1; |
689 | 689 | |
690 | - if ( $multi_number ) { |
|
690 | + if ($multi_number) { |
|
691 | 691 | |
692 | 692 | $query_arg['num'] = $multi_number; |
693 | 693 | $query_arg['base'] = $id_base; |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | $query_arg['points_type'] = $points_type; |
699 | 699 | } |
700 | 700 | |
701 | - if ( isset( $options['_display'] ) && 'template' === $options['_display'] ) { |
|
701 | + if (isset($options['_display']) && 'template' === $options['_display']) { |
|
702 | 702 | |
703 | 703 | /* |
704 | 704 | * We aren't outputting the form for a hook, but a template form for this |
@@ -714,17 +714,17 @@ discard block |
||
714 | 714 | |
715 | 715 | ?> |
716 | 716 | |
717 | - <div id="hook-<?php echo esc_html( $options['_id_slug'] ); ?>_<?php echo esc_attr( $id_format ); ?>" class="hook <?php echo esc_attr( $options['_classname'] ); ?>"> |
|
717 | + <div id="hook-<?php echo esc_html($options['_id_slug']); ?>_<?php echo esc_attr($id_format); ?>" class="hook <?php echo esc_attr($options['_classname']); ?>"> |
|
718 | 718 | <div class="hook-top"> |
719 | 719 | <div class="hook-title-action"> |
720 | 720 | <a class="hook-action hide-if-no-js" href="#available-hooks"></a> |
721 | - <a class="hook-control-edit hide-if-js" href="<?php echo esc_url( add_query_arg( $query_arg ) ); ?>"> |
|
722 | - <span class="edit"><?php echo esc_html_x( 'Edit', 'hook', 'wordpoints' ); ?></span> |
|
723 | - <span class="add"><?php echo esc_html_x( 'Add', 'hook', 'wordpoints' ); ?></span> |
|
724 | - <span class="screen-reader-text"><?php echo esc_html( strip_tags( $hook->get_name() ) ); ?></span> |
|
721 | + <a class="hook-control-edit hide-if-js" href="<?php echo esc_url(add_query_arg($query_arg)); ?>"> |
|
722 | + <span class="edit"><?php echo esc_html_x('Edit', 'hook', 'wordpoints'); ?></span> |
|
723 | + <span class="add"><?php echo esc_html_x('Add', 'hook', 'wordpoints'); ?></span> |
|
724 | + <span class="screen-reader-text"><?php echo esc_html(strip_tags($hook->get_name())); ?></span> |
|
725 | 725 | </a> |
726 | 726 | </div> |
727 | - <div class="hook-title"><h3><?php echo esc_html( strip_tags( $hook->get_name() ) ) ?><span class="in-hook-title"></span></h3></div> |
|
727 | + <div class="hook-title"><h3><?php echo esc_html(strip_tags($hook->get_name())) ?><span class="in-hook-title"></span></h3></div> |
|
728 | 728 | </div> |
729 | 729 | |
730 | 730 | <div class="hook-inside"> |
@@ -732,26 +732,26 @@ discard block |
||
732 | 732 | <div class="hook-content"> |
733 | 733 | <?php |
734 | 734 | |
735 | - $has_form = $hook->form_callback( $number ); |
|
735 | + $has_form = $hook->form_callback($number); |
|
736 | 736 | |
737 | 737 | ?> |
738 | 738 | </div> |
739 | 739 | |
740 | - <input type="hidden" name="hook-id" class="hook-id" value="<?php echo esc_attr( $id_format ); ?>" /> |
|
741 | - <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr( $id_base ); ?>" /> |
|
742 | - <input type="hidden" name="hook-width" class="hook-width" value="<?php echo isset( $options['width'] ) ? esc_attr( $options['width'] ) : ''; ?>" /> |
|
743 | - <input type="hidden" name="hook-height" class="hook-height" value="<?php echo isset( $options['height'] ) ? esc_attr( $options['height'] ) : ''; ?>" /> |
|
744 | - <input type="hidden" name="hook_number" class="hook_number" value="<?php echo esc_attr( $number ); ?>" /> |
|
745 | - <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr( $multi_number ); ?>" /> |
|
746 | - <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr( $add_new ); ?>" /> |
|
740 | + <input type="hidden" name="hook-id" class="hook-id" value="<?php echo esc_attr($id_format); ?>" /> |
|
741 | + <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" /> |
|
742 | + <input type="hidden" name="hook-width" class="hook-width" value="<?php echo isset($options['width']) ? esc_attr($options['width']) : ''; ?>" /> |
|
743 | + <input type="hidden" name="hook-height" class="hook-height" value="<?php echo isset($options['height']) ? esc_attr($options['height']) : ''; ?>" /> |
|
744 | + <input type="hidden" name="hook_number" class="hook_number" value="<?php echo esc_attr($number); ?>" /> |
|
745 | + <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" /> |
|
746 | + <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" /> |
|
747 | 747 | |
748 | 748 | <div class="hook-control-actions"> |
749 | 749 | <div class="alignleft"> |
750 | - <a class="hook-control-remove" href="#remove"><?php esc_html_e( 'Delete', 'wordpoints' ); ?></a> | |
|
751 | - <a class="hook-control-close" href="#close"><?php esc_html_e( 'Close', 'wordpoints' ); ?></a> |
|
750 | + <a class="hook-control-remove" href="#remove"><?php esc_html_e('Delete', 'wordpoints'); ?></a> | |
|
751 | + <a class="hook-control-close" href="#close"><?php esc_html_e('Close', 'wordpoints'); ?></a> |
|
752 | 752 | </div> |
753 | - <div class="alignright<?php echo ( false === $has_form ) ? ' hook-control-noform' : ''; ?>"> |
|
754 | - <?php submit_button( __( 'Save', 'wordpoints' ), 'button-primary hook-control-save right', 'savehook', false, array( 'id' => "hook-{$id_format}-savehook" ) ); ?> |
|
753 | + <div class="alignright<?php echo (false === $has_form) ? ' hook-control-noform' : ''; ?>"> |
|
754 | + <?php submit_button(__('Save', 'wordpoints'), 'button-primary hook-control-save right', 'savehook', false, array('id' => "hook-{$id_format}-savehook")); ?> |
|
755 | 755 | <span class="spinner"></span> |
756 | 756 | </div> |
757 | 757 | <br class="clear" /> |
@@ -760,8 +760,8 @@ discard block |
||
760 | 760 | </div> |
761 | 761 | |
762 | 762 | <div class="hook-description"> |
763 | - <?php if ( ! empty( $options['description'] ) ) : ?> |
|
764 | - <?php echo esc_html( $options['description'] ); ?> |
|
763 | + <?php if ( ! empty($options['description'])) : ?> |
|
764 | + <?php echo esc_html($options['description']); ?> |
|
765 | 765 | <?php endif; ?> |
766 | 766 | </div> |
767 | 767 | </div> |
@@ -781,9 +781,9 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return int |
783 | 783 | */ |
784 | - private static function _sort_name_callback( $a, $b ) { |
|
784 | + private static function _sort_name_callback($a, $b) { |
|
785 | 785 | |
786 | - return strnatcasecmp( $a->get_name(), $b->get_name() ); |
|
786 | + return strnatcasecmp($a->get_name(), $b->get_name()); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | } // class WordPoints_Points_Hooks |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | * @since 2.3.0 |
28 | 28 | */ |
29 | 29 | protected $columns = array( |
30 | - 'id' => array( 'format' => '%d', 'unsigned' => true ), |
|
31 | - 'user_id' => array( 'format' => '%d', 'unsigned' => true ), |
|
32 | - 'log_type' => array( 'format' => '%s' ), |
|
33 | - 'points' => array( 'format' => '%d' ), |
|
34 | - 'points_type' => array( 'format' => '%s' ), |
|
35 | - 'text' => array( 'format' => '%s' ), |
|
36 | - 'blog_id' => array( 'format' => '%d', 'unsigned' => true ), |
|
37 | - 'site_id' => array( 'format' => '%d', 'unsigned' => true ), |
|
38 | - 'date' => array( 'format' => '%s', 'is_date' => true ), |
|
30 | + 'id' => array('format' => '%d', 'unsigned' => true), |
|
31 | + 'user_id' => array('format' => '%d', 'unsigned' => true), |
|
32 | + 'log_type' => array('format' => '%s'), |
|
33 | + 'points' => array('format' => '%d'), |
|
34 | + 'points_type' => array('format' => '%s'), |
|
35 | + 'text' => array('format' => '%s'), |
|
36 | + 'blog_id' => array('format' => '%d', 'unsigned' => true), |
|
37 | + 'site_id' => array('format' => '%d', 'unsigned' => true), |
|
38 | + 'date' => array('format' => '%s', 'is_date' => true), |
|
39 | 39 | ); |
40 | 40 | |
41 | 41 | /** |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @since 2.3.0 |
48 | 48 | */ |
49 | 49 | protected $deprecated_args = array( |
50 | - 'orderby' => array( 'replacement' => 'order_by', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
51 | - 'user__in' => array( 'replacement' => 'user_id__in', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
52 | - 'user__not_in' => array( 'replacement' => 'user_id__not_in', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
53 | - 'blog__in' => array( 'replacement' => 'blog_id__in', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
54 | - 'blog__not_in' => array( 'replacement' => 'blog_id__not_in', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
50 | + 'orderby' => array('replacement' => 'order_by', 'version' => '2.3.0', 'class' => __CLASS__), |
|
51 | + 'user__in' => array('replacement' => 'user_id__in', 'version' => '2.3.0', 'class' => __CLASS__), |
|
52 | + 'user__not_in' => array('replacement' => 'user_id__not_in', 'version' => '2.3.0', 'class' => __CLASS__), |
|
53 | + 'blog__in' => array('replacement' => 'blog_id__in', 'version' => '2.3.0', 'class' => __CLASS__), |
|
54 | + 'blog__not_in' => array('replacement' => 'blog_id__not_in', 'version' => '2.3.0', 'class' => __CLASS__), |
|
55 | 55 | ); |
56 | 56 | |
57 | 57 | // |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @type array $meta_query See WP_Meta_Query. |
178 | 178 | * } |
179 | 179 | */ |
180 | - public function __construct( $args = array() ) { |
|
180 | + public function __construct($args = array()) { |
|
181 | 181 | |
182 | 182 | global $wpdb; |
183 | 183 | |
@@ -191,21 +191,21 @@ discard block |
||
191 | 191 | $this->defaults['text__compare'] = 'LIKE'; |
192 | 192 | |
193 | 193 | // Back-compat for pre-2.3.0, in case an object or string is passed. |
194 | - $args = wp_parse_args( $args ); |
|
195 | - $args = $this->convert_deprecated_arg_values( $args ); |
|
194 | + $args = wp_parse_args($args); |
|
195 | + $args = $this->convert_deprecated_arg_values($args); |
|
196 | 196 | |
197 | - parent::__construct( $args ); |
|
197 | + parent::__construct($args); |
|
198 | 198 | |
199 | - if ( is_multisite() ) { |
|
200 | - foreach ( array( 'blog', 'site' ) as $arg ) { |
|
199 | + if (is_multisite()) { |
|
200 | + foreach (array('blog', 'site') as $arg) { |
|
201 | 201 | |
202 | 202 | if ( |
203 | 203 | // Support passing these as null to override the defaults. |
204 | - ! array_key_exists( "{$arg}_id", $this->args ) |
|
205 | - && ! isset( $this->args[ "{$arg}_id__in" ] ) |
|
206 | - && ! isset( $this->args[ "{$arg}_id__not_in" ] ) |
|
204 | + ! array_key_exists("{$arg}_id", $this->args) |
|
205 | + && ! isset($this->args["{$arg}_id__in"]) |
|
206 | + && ! isset($this->args["{$arg}_id__not_in"]) |
|
207 | 207 | ) { |
208 | - $this->args[ "{$arg}_id" ] = $wpdb->{"{$arg}id"}; |
|
208 | + $this->args["{$arg}_id"] = $wpdb->{"{$arg}id"}; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -220,31 +220,31 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return array $args The args, with any values converted as needed. |
222 | 222 | */ |
223 | - protected function convert_deprecated_arg_values( $args ) { |
|
223 | + protected function convert_deprecated_arg_values($args) { |
|
224 | 224 | |
225 | 225 | // Back-compat for pre-2.3.0, when the fields arg supported 'all'. |
226 | - if ( isset( $args['fields'] ) && 'all' === $args['fields'] ) { |
|
226 | + if (isset($args['fields']) && 'all' === $args['fields']) { |
|
227 | 227 | |
228 | 228 | _deprecated_argument( |
229 | 229 | __METHOD__ |
230 | 230 | , '2.3.0' |
231 | - , esc_html( "Passing 'fields' => 'all' is deprecated, just omit the 'fields' arg instead, since all fields returned by default." ) |
|
231 | + , esc_html("Passing 'fields' => 'all' is deprecated, just omit the 'fields' arg instead, since all fields returned by default.") |
|
232 | 232 | ); |
233 | 233 | |
234 | - unset( $args['fields'] ); |
|
234 | + unset($args['fields']); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // Back-compat for pre-2.3.0, when the orderby arg supported 'none'. |
238 | - if ( isset( $args['orderby'] ) && 'none' === $args['orderby'] ) { |
|
238 | + if (isset($args['orderby']) && 'none' === $args['orderby']) { |
|
239 | 239 | |
240 | 240 | _deprecated_argument( |
241 | 241 | __METHOD__ |
242 | 242 | , '2.3.0' |
243 | - , esc_html( "Passing 'orderby' => 'none' is deprecated, pass 'order_by' => null instead." ) |
|
243 | + , esc_html("Passing 'orderby' => 'none' is deprecated, pass 'order_by' => null instead.") |
|
244 | 244 | ); |
245 | 245 | |
246 | 246 | $args['order_by'] = null; |
247 | - unset( $args['orderby'] ); |
|
247 | + unset($args['orderby']); |
|
248 | 248 | |
249 | 249 | return $args; |
250 | 250 | } |
@@ -256,11 +256,11 @@ discard block |
||
256 | 256 | * @since 1.6.0 |
257 | 257 | * @since 2.3.0 Now returns $this. |
258 | 258 | */ |
259 | - public function set_args( array $args ) { |
|
259 | + public function set_args(array $args) { |
|
260 | 260 | |
261 | 261 | $this->_cache_query_hash = null; |
262 | 262 | |
263 | - return parent::set_args( $this->convert_deprecated_arg_values( $args ) ); |
|
263 | + return parent::set_args($this->convert_deprecated_arg_values($args)); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -279,18 +279,18 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function count() { |
281 | 281 | |
282 | - if ( $this->_is_cached_query ) { |
|
283 | - $cache = $this->_cache_get( 'count' ); |
|
282 | + if ($this->_is_cached_query) { |
|
283 | + $cache = $this->_cache_get('count'); |
|
284 | 284 | |
285 | - if ( false !== $cache ) { |
|
285 | + if (false !== $cache) { |
|
286 | 286 | return $cache; |
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | 290 | $count = parent::count(); |
291 | 291 | |
292 | - if ( $this->_is_cached_query ) { |
|
293 | - $this->_cache_set( $count, 'count' ); |
|
292 | + if ($this->_is_cached_query) { |
|
293 | + $this->_cache_set($count, 'count'); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | return $count; |
@@ -308,23 +308,23 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return mixed The results of the query, or false on failure. |
310 | 310 | */ |
311 | - public function get( $method = 'results' ) { |
|
311 | + public function get($method = 'results') { |
|
312 | 312 | |
313 | - if ( $this->_is_cached_query ) { |
|
314 | - $cache = $this->_cache_get( "get_{$method}" ); |
|
313 | + if ($this->_is_cached_query) { |
|
314 | + $cache = $this->_cache_get("get_{$method}"); |
|
315 | 315 | |
316 | - if ( false !== $cache ) { |
|
316 | + if (false !== $cache) { |
|
317 | 317 | return $cache; |
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | - $result = parent::get( $method ); |
|
321 | + $result = parent::get($method); |
|
322 | 322 | |
323 | - if ( $this->_is_cached_query ) { |
|
324 | - $this->_cache_set( $result, "get_{$method}" ); |
|
323 | + if ($this->_is_cached_query) { |
|
324 | + $this->_cache_set($result, "get_{$method}"); |
|
325 | 325 | |
326 | - if ( 'results' === $method || 'col' === $method ) { |
|
327 | - $this->_cache_set( count( $result ), 'count' ); |
|
326 | + if ('results' === $method || 'col' === $method) { |
|
327 | + $this->_cache_set(count($result), 'count'); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
@@ -351,20 +351,20 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return object[]|false The logs for this page, or false if $page or $per_page is invalid. |
353 | 353 | */ |
354 | - public function get_page( $page, $per_page = 25 ) { |
|
354 | + public function get_page($page, $per_page = 25) { |
|
355 | 355 | |
356 | - if ( ! wordpoints_posint( $page ) || ! wordpoints_posint( $per_page ) ) { |
|
356 | + if ( ! wordpoints_posint($page) || ! wordpoints_posint($per_page)) { |
|
357 | 357 | return false; |
358 | 358 | } |
359 | 359 | |
360 | - $start = ( $page - 1 ) * $per_page; |
|
360 | + $start = ($page - 1) * $per_page; |
|
361 | 361 | |
362 | 362 | // First try the main cache. |
363 | - if ( $this->_is_cached_query ) { |
|
363 | + if ($this->_is_cached_query) { |
|
364 | 364 | |
365 | - $cache = $this->_cache_get( 'get_results' ); |
|
365 | + $cache = $this->_cache_get('get_results'); |
|
366 | 366 | |
367 | - if ( false !== $cache ) { |
|
367 | + if (false !== $cache) { |
|
368 | 368 | return array_slice( |
369 | 369 | $cache |
370 | 370 | , $start - $this->args['start'] |
@@ -378,18 +378,18 @@ discard block |
||
378 | 378 | |
379 | 379 | $this->args['start'] += $start; |
380 | 380 | |
381 | - if ( ! empty( $this->args['limit'] ) ) { |
|
381 | + if ( ! empty($this->args['limit'])) { |
|
382 | 382 | $this->args['limit'] -= $start; |
383 | 383 | } |
384 | 384 | |
385 | - if ( empty( $this->args['limit'] ) || $this->args['limit'] > $per_page ) { |
|
385 | + if (empty($this->args['limit']) || $this->args['limit'] > $per_page) { |
|
386 | 386 | $this->args['limit'] = $per_page; |
387 | 387 | } |
388 | 388 | |
389 | 389 | // Regenerate the query limit after changing the start and limit args. |
390 | 390 | $this->prepare_limit(); |
391 | 391 | |
392 | - unset( $this->_cache_query_hash ); |
|
392 | + unset($this->_cache_query_hash); |
|
393 | 393 | |
394 | 394 | $results = $this->get(); |
395 | 395 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | $this->limit = ''; |
401 | 401 | $this->prepare_limit(); |
402 | 402 | |
403 | - unset( $this->_cache_query_hash ); |
|
403 | + unset($this->_cache_query_hash); |
|
404 | 404 | |
405 | 405 | return $results; |
406 | 406 | } |
@@ -448,9 +448,9 @@ discard block |
||
448 | 448 | * @param string $deprecated Deprecated; no longer used. |
449 | 449 | * @param bool $network Whether this is a network-wide query. |
450 | 450 | */ |
451 | - public function prime_cache( $key = 'default:%points_type%', $deprecated = null, $network = false ) { |
|
451 | + public function prime_cache($key = 'default:%points_type%', $deprecated = null, $network = false) { |
|
452 | 452 | |
453 | - if ( ! is_null( $deprecated ) ) { |
|
453 | + if ( ! is_null($deprecated)) { |
|
454 | 454 | _deprecated_argument( |
455 | 455 | __METHOD__ |
456 | 456 | , '1.9.0' |
@@ -466,13 +466,13 @@ discard block |
||
466 | 466 | '%user_id%', |
467 | 467 | ) |
468 | 468 | , array( |
469 | - isset( $this->args['points_type'] ) ? $this->args['points_type'] : '', |
|
470 | - isset( $this->args['user_id'] ) ? $this->args['user_id'] : 0, |
|
469 | + isset($this->args['points_type']) ? $this->args['points_type'] : '', |
|
470 | + isset($this->args['user_id']) ? $this->args['user_id'] : 0, |
|
471 | 471 | ) |
472 | 472 | , $key |
473 | 473 | ); |
474 | 474 | |
475 | - if ( $network ) { |
|
475 | + if ($network) { |
|
476 | 476 | $this->_cache_group = 'wordpoints_network_points_logs_query'; |
477 | 477 | } else { |
478 | 478 | $this->_cache_group = 'wordpoints_points_logs_query'; |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | * |
489 | 489 | * @return string The correct meta table ID column, if the key is wordpoints_points_log_. |
490 | 490 | */ |
491 | - public function meta_query_meta_table_id_filter( $key ) { |
|
491 | + public function meta_query_meta_table_id_filter($key) { |
|
492 | 492 | |
493 | - if ( 'wordpoints_points_log__id' === $key ) { |
|
493 | + if ('wordpoints_points_log__id' === $key) { |
|
494 | 494 | $key = 'log_id'; |
495 | 495 | } |
496 | 496 | |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | */ |
507 | 507 | protected function prepare_meta_where() { |
508 | 508 | |
509 | - add_filter( 'sanitize_key', array( $this, 'meta_query_meta_table_id_filter' ) ); |
|
509 | + add_filter('sanitize_key', array($this, 'meta_query_meta_table_id_filter')); |
|
510 | 510 | parent::prepare_meta_where(); |
511 | - remove_filter( 'sanitize_key', array( $this, 'meta_query_meta_table_id_filter' ) ); |
|
511 | + remove_filter('sanitize_key', array($this, 'meta_query_meta_table_id_filter')); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | // |
@@ -525,29 +525,29 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @return mixed Cached value, or false if none. |
527 | 527 | */ |
528 | - private function _cache_get( $type = null ) { |
|
528 | + private function _cache_get($type = null) { |
|
529 | 529 | |
530 | - $cache = wp_cache_get( $this->_cache_key, $this->_cache_group ); |
|
530 | + $cache = wp_cache_get($this->_cache_key, $this->_cache_group); |
|
531 | 531 | |
532 | - if ( ! is_array( $cache ) ) { |
|
532 | + if ( ! is_array($cache)) { |
|
533 | 533 | return false; |
534 | 534 | } |
535 | 535 | |
536 | 536 | $this->_calc_cache_query_hash(); |
537 | 537 | |
538 | - if ( ! isset( $cache[ $this->_cache_query_hash ] ) ) { |
|
538 | + if ( ! isset($cache[$this->_cache_query_hash])) { |
|
539 | 539 | return false; |
540 | 540 | } |
541 | 541 | |
542 | - if ( isset( $type ) ) { |
|
543 | - if ( isset( $cache[ $this->_cache_query_hash ][ $type ] ) ) { |
|
544 | - return $cache[ $this->_cache_query_hash ][ $type ]; |
|
542 | + if (isset($type)) { |
|
543 | + if (isset($cache[$this->_cache_query_hash][$type])) { |
|
544 | + return $cache[$this->_cache_query_hash][$type]; |
|
545 | 545 | } else { |
546 | 546 | return false; |
547 | 547 | } |
548 | 548 | } |
549 | 549 | |
550 | - return $cache[ $this->_cache_query_hash ]; |
|
550 | + return $cache[$this->_cache_query_hash]; |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -559,26 +559,26 @@ discard block |
||
559 | 559 | * @param string $type Optionally specify a results type to cache. Default is |
560 | 560 | * null, or all types. |
561 | 561 | */ |
562 | - private function _cache_set( $value, $type = null ) { |
|
562 | + private function _cache_set($value, $type = null) { |
|
563 | 563 | |
564 | - $cache = wp_cache_get( $this->_cache_key, $this->_cache_group ); |
|
564 | + $cache = wp_cache_get($this->_cache_key, $this->_cache_group); |
|
565 | 565 | |
566 | 566 | $this->_calc_cache_query_hash(); |
567 | 567 | |
568 | 568 | if ( |
569 | - ! isset( $cache[ $this->_cache_query_hash ] ) |
|
570 | - || ! is_array( $cache[ $this->_cache_query_hash ] ) |
|
569 | + ! isset($cache[$this->_cache_query_hash]) |
|
570 | + || ! is_array($cache[$this->_cache_query_hash]) |
|
571 | 571 | ) { |
572 | - $cache[ $this->_cache_query_hash ] = array(); |
|
572 | + $cache[$this->_cache_query_hash] = array(); |
|
573 | 573 | } |
574 | 574 | |
575 | - if ( isset( $type ) ) { |
|
576 | - $cache[ $this->_cache_query_hash ][ $type ] = $value; |
|
575 | + if (isset($type)) { |
|
576 | + $cache[$this->_cache_query_hash][$type] = $value; |
|
577 | 577 | } else { |
578 | - $cache[ $this->_cache_query_hash ] = $value; |
|
578 | + $cache[$this->_cache_query_hash] = $value; |
|
579 | 579 | } |
580 | 580 | |
581 | - wp_cache_set( $this->_cache_key, $cache, $this->_cache_group ); |
|
581 | + wp_cache_set($this->_cache_key, $cache, $this->_cache_group); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | */ |
589 | 589 | private function _calc_cache_query_hash() { |
590 | 590 | |
591 | - if ( ! isset( $this->_cache_query_hash ) ) { |
|
592 | - $this->_cache_query_hash = wordpoints_hash( $this->get_sql() ); |
|
591 | + if ( ! isset($this->_cache_query_hash)) { |
|
592 | + $this->_cache_query_hash = wordpoints_hash($this->get_sql()); |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @since 2.2.0 |
20 | 20 | */ |
21 | 21 | public function get_description() { |
22 | - return __( 'This log entry is only visible to users who can view the post that the comment is on.', 'wordpoints' ); |
|
22 | + return __('This log entry is only visible to users who can view the post that the comment is on.', 'wordpoints'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | , true |
34 | 34 | ); |
35 | 35 | |
36 | - if ( $comment_id ) { |
|
37 | - $comment = get_comment( $comment_id ); |
|
36 | + if ($comment_id) { |
|
37 | + $comment = get_comment($comment_id); |
|
38 | 38 | |
39 | - if ( $comment ) { |
|
39 | + if ($comment) { |
|
40 | 40 | return $comment->comment_post_ID; |
41 | 41 | } |
42 | 42 | } |
@@ -12,57 +12,57 @@ discard block |
||
12 | 12 | |
13 | 13 | // These messages/errors are used upon redirection from the non-JS version. |
14 | 14 | $messages = array( |
15 | - __( 'Changes saved.', 'wordpoints' ), |
|
15 | + __('Changes saved.', 'wordpoints'), |
|
16 | 16 | ); |
17 | 17 | |
18 | 18 | $errors = array( |
19 | - __( 'Error while saving.', 'wordpoints' ), |
|
20 | - __( 'Error in displaying the hooks settings form.', 'wordpoints' ), |
|
19 | + __('Error while saving.', 'wordpoints'), |
|
20 | + __('Error in displaying the hooks settings form.', 'wordpoints'), |
|
21 | 21 | '', // Back-compat for pre-2.1.0. |
22 | - __( 'Error while deleting.', 'wordpoints' ), |
|
22 | + __('Error while deleting.', 'wordpoints'), |
|
23 | 23 | ); |
24 | 24 | |
25 | -if ( is_network_admin() ) { |
|
26 | - $title = _x( 'Network Points Hooks', 'page title', 'wordpoints' ); |
|
25 | +if (is_network_admin()) { |
|
26 | + $title = _x('Network Points Hooks', 'page title', 'wordpoints'); |
|
27 | 27 | } else { |
28 | - $title = _x( 'Points Hooks', 'page title', 'wordpoints' ); |
|
28 | + $title = _x('Points Hooks', 'page title', 'wordpoints'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | ?> |
32 | 32 | |
33 | 33 | <div class="wrap"> |
34 | - <h1><?php echo esc_html( $title ); ?></h1> |
|
34 | + <h1><?php echo esc_html($title); ?></h1> |
|
35 | 35 | |
36 | 36 | <?php |
37 | 37 | |
38 | - if ( empty( $points_types ) && ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
38 | + if (empty($points_types) && ! current_user_can('manage_wordpoints_points_types')) { |
|
39 | 39 | |
40 | - wordpoints_show_admin_error( esc_html__( 'No points types have been created yet. Only network administrators can create points types.', 'wordpoints' ) ); |
|
40 | + wordpoints_show_admin_error(esc_html__('No points types have been created yet. Only network administrators can create points types.', 'wordpoints')); |
|
41 | 41 | |
42 | 42 | echo '</div>'; |
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | - if ( isset( $_GET['message'] ) && isset( $messages[ (int) $_GET['message'] ] ) ) { |
|
46 | + if (isset($_GET['message']) && isset($messages[(int) $_GET['message']])) { |
|
47 | 47 | |
48 | 48 | wordpoints_show_admin_message( |
49 | - esc_html( $messages[ (int) $_GET['message'] ] ) |
|
49 | + esc_html($messages[(int) $_GET['message']]) |
|
50 | 50 | , 'success' |
51 | - , array( 'dismissible' => true ) |
|
51 | + , array('dismissible' => true) |
|
52 | 52 | ); |
53 | 53 | |
54 | - } elseif ( isset( $_GET['error'] ) && isset( $errors[ (int) $_GET['error'] ] ) ) { |
|
54 | + } elseif (isset($_GET['error']) && isset($errors[(int) $_GET['error']])) { |
|
55 | 55 | |
56 | 56 | wordpoints_show_admin_error( |
57 | - esc_html( $errors[ (int) $_GET['error'] ] ) |
|
58 | - , array( 'dismissible' => true ) |
|
57 | + esc_html($errors[(int) $_GET['error']]) |
|
58 | + , array('dismissible' => true) |
|
59 | 59 | ); |
60 | 60 | } |
61 | 61 | |
62 | - if ( is_network_admin() && current_user_can( 'manage_network_wordpoints_points_hooks' ) ) { |
|
62 | + if (is_network_admin() && current_user_can('manage_network_wordpoints_points_hooks')) { |
|
63 | 63 | |
64 | 64 | // Display network wide hooks. |
65 | - WordPoints_Points_Hooks::set_network_mode( true ); |
|
65 | + WordPoints_Points_Hooks::set_network_mode(true); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @since 1.0.0 |
72 | 72 | */ |
73 | - do_action( 'wordpoints_admin_points_hooks_head' ); |
|
73 | + do_action('wordpoints_admin_points_hooks_head'); |
|
74 | 74 | |
75 | 75 | ?> |
76 | 76 | |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | <div id="available-hooks" class="hooks-holder-wrap hooks-holder-wrap"> |
80 | 80 | <div class="points-type-name"> |
81 | 81 | <div class="points-type-name-arrow"><br /></div> |
82 | - <h2><?php esc_html_e( 'Available Hooks', 'wordpoints' ); ?> <span id="removing-hook"><?php echo esc_html_x( 'Deactivate', 'removing-hook', 'wordpoints' ); ?> <span></span></span></h2> |
|
82 | + <h2><?php esc_html_e('Available Hooks', 'wordpoints'); ?> <span id="removing-hook"><?php echo esc_html_x('Deactivate', 'removing-hook', 'wordpoints'); ?> <span></span></span></h2> |
|
83 | 83 | </div> |
84 | 84 | <div class="hook-holder hook-holder"> |
85 | - <p class="description"><?php esc_html_e( 'Drag hooks from here to a points type on the right to activate them. Drag hooks back here to deactivate them and delete their settings.', 'wordpoints' ); ?></p> |
|
85 | + <p class="description"><?php esc_html_e('Drag hooks from here to a points type on the right to activate them. Drag hooks back here to deactivate them and delete their settings.', 'wordpoints'); ?></p> |
|
86 | 86 | <div id="hook-list"> |
87 | 87 | <?php WordPoints_Points_Hooks::list_hooks(); ?> |
88 | 88 | </div> |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | <div class="hooks-holder-wrap inactive-points-type"> |
95 | 95 | <div class="points-type-name"> |
96 | 96 | <div class="points-type-name-arrow"><br /></div> |
97 | - <h2><?php esc_html_e( 'Inactive Hooks', 'wordpoints' ); ?> |
|
97 | + <h2><?php esc_html_e('Inactive Hooks', 'wordpoints'); ?> |
|
98 | 98 | <span class="spinner"></span> |
99 | 99 | </h2> |
100 | 100 | </div> |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | <div id="_inactive_hooks" class="hooks-sortables"> |
103 | 103 | <div class="points-type-description"> |
104 | 104 | <p class="description"> |
105 | - <?php esc_html_e( 'Drag hooks here to remove them from the points type but keep their settings.', 'wordpoints' ); ?> |
|
105 | + <?php esc_html_e('Drag hooks here to remove them from the points type but keep their settings.', 'wordpoints'); ?> |
|
106 | 106 | </p> |
107 | 107 | </div> |
108 | - <?php WordPoints_Points_Hooks::list_by_points_type( '_inactive_hooks' ); ?> |
|
108 | + <?php WordPoints_Points_Hooks::list_by_points_type('_inactive_hooks'); ?> |
|
109 | 109 | </div> |
110 | 110 | <div class="clear"></div> |
111 | 111 | </div> |
@@ -121,31 +121,31 @@ discard block |
||
121 | 121 | |
122 | 122 | $i = 0; |
123 | 123 | |
124 | - foreach ( $points_types as $slug => $points_type ) { |
|
124 | + foreach ($points_types as $slug => $points_type) { |
|
125 | 125 | |
126 | 126 | $wrap_class = 'hooks-holder-wrap'; |
127 | - if ( ! empty( $points_type['class'] ) ) { |
|
127 | + if ( ! empty($points_type['class'])) { |
|
128 | 128 | $wrap_class .= ' points-type-' . $points_type['class']; |
129 | 129 | } |
130 | 130 | |
131 | - if ( $i ) { |
|
131 | + if ($i) { |
|
132 | 132 | $wrap_class .= ' closed'; |
133 | 133 | } |
134 | 134 | |
135 | 135 | ?> |
136 | 136 | |
137 | - <div class="<?php echo esc_attr( $wrap_class ); ?>"> |
|
137 | + <div class="<?php echo esc_attr($wrap_class); ?>"> |
|
138 | 138 | <div class="points-type-name"> |
139 | 139 | <div class="points-type-name-arrow"><br /></div> |
140 | - <h2><?php echo esc_html( $points_type['name'] ); ?><span class="spinner"></span></h2> |
|
140 | + <h2><?php echo esc_html($points_type['name']); ?><span class="spinner"></span></h2> |
|
141 | 141 | </div> |
142 | - <div id="<?php echo esc_attr( $slug ); ?>" class="hooks-sortables"> |
|
142 | + <div id="<?php echo esc_attr($slug); ?>" class="hooks-sortables"> |
|
143 | 143 | |
144 | 144 | <?php |
145 | 145 | |
146 | 146 | if ( |
147 | - get_site_option( 'wordpoints_disabled_points_hooks_edit_points_types' ) |
|
148 | - && current_user_can( 'manage_wordpoints_points_types' ) |
|
147 | + get_site_option('wordpoints_disabled_points_hooks_edit_points_types') |
|
148 | + && current_user_can('manage_wordpoints_points_types') |
|
149 | 149 | ) { |
150 | 150 | ?> |
151 | 151 | <div class="notice notice-info inline notice-alt"> |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | echo wp_kses_data( |
156 | 156 | sprintf( |
157 | 157 | // translators: URL of Points Types admin screen. |
158 | - __( 'You can edit this points type‛s settings on the <a href="%s">Points Types screen</a>.', 'wordpoints' ) |
|
158 | + __('You can edit this points type‛s settings on the <a href="%s">Points Types screen</a>.', 'wordpoints') |
|
159 | 159 | , esc_attr( |
160 | 160 | esc_url( |
161 | 161 | self_admin_url( |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | <?php |
174 | 174 | } |
175 | 175 | |
176 | - WordPoints_Points_Hooks::list_by_points_type( $slug ); |
|
176 | + WordPoints_Points_Hooks::list_by_points_type($slug); |
|
177 | 177 | |
178 | 178 | ?> |
179 | 179 | |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | } // End foreach ( $points_types ). |
188 | 188 | |
189 | 189 | if ( |
190 | - get_site_option( 'wordpoints_disabled_points_hooks_edit_points_types' ) |
|
191 | - && current_user_can( 'manage_wordpoints_points_types' ) |
|
190 | + get_site_option('wordpoints_disabled_points_hooks_edit_points_types') |
|
191 | + && current_user_can('manage_wordpoints_points_types') |
|
192 | 192 | ) { |
193 | 193 | |
194 | 194 | ?> |
195 | 195 | |
196 | - <div class="hooks-holder-wrap new-points-type <?php echo ( $i > 0 ) ? 'closed' : ''; ?>"> |
|
196 | + <div class="hooks-holder-wrap new-points-type <?php echo ($i > 0) ? 'closed' : ''; ?>"> |
|
197 | 197 | <div class="points-type-name"> |
198 | 198 | <div class="points-type-name-arrow"><br /></div> |
199 | - <h2><?php esc_html_e( 'Add New Points Type', 'wordpoints' ); ?><span class="spinner"></span></h2> |
|
199 | + <h2><?php esc_html_e('Add New Points Type', 'wordpoints'); ?><span class="spinner"></span></h2> |
|
200 | 200 | </div> |
201 | 201 | <div class="wordpoints-points-add-new hooks-sortables hook"> |
202 | 202 | <div class="notice notice-info inline notice-alt"> |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | echo wp_kses_data( |
207 | 207 | sprintf( |
208 | 208 | // translators: URL of Points Types admin screen. |
209 | - __( 'You can create new points types on the <a href="%s">Points Types screen</a>.', 'wordpoints' ) |
|
209 | + __('You can create new points types on the <a href="%s">Points Types screen</a>.', 'wordpoints') |
|
210 | 210 | , esc_attr( |
211 | 211 | esc_url( |
212 | 212 | self_admin_url( |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | <form method="post"> |
235 | 235 | <?php |
236 | 236 | |
237 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
237 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
238 | 238 | $field = 'save-network-wordpoints-points-hooks'; |
239 | 239 | } else { |
240 | 240 | $field = 'save-wordpoints-points-hooks'; |
241 | 241 | } |
242 | 242 | |
243 | - wp_nonce_field( $field, '_wpnonce_hooks', false ); |
|
243 | + wp_nonce_field($field, '_wpnonce_hooks', false); |
|
244 | 244 | |
245 | 245 | ?> |
246 | 246 | </form> |
@@ -252,18 +252,18 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @since 1.0.0 |
254 | 254 | */ |
255 | - do_action( 'wordpoints_admin_points_hooks_foot' ); |
|
255 | + do_action('wordpoints_admin_points_hooks_foot'); |
|
256 | 256 | |
257 | 257 | ?> |
258 | 258 | |
259 | 259 | <br class="clear" /> |
260 | 260 | |
261 | 261 | <div class="hooks-chooser"> |
262 | - <h3><?php esc_html_e( 'Choose a points type:', 'wordpoints' ); ?></h3> |
|
262 | + <h3><?php esc_html_e('Choose a points type:', 'wordpoints'); ?></h3> |
|
263 | 263 | <ul class="hooks-chooser-points-types"></ul> |
264 | 264 | <div class="hooks-chooser-actions"> |
265 | - <button class="button-secondary"><?php esc_html_e( 'Cancel', 'wordpoints' ); ?></button> |
|
266 | - <button class="button-primary"><?php esc_html_e( 'Add Hook', 'wordpoints' ); ?></button> |
|
265 | + <button class="button-secondary"><?php esc_html_e('Cancel', 'wordpoints'); ?></button> |
|
266 | + <button class="button-primary"><?php esc_html_e('Add Hook', 'wordpoints'); ?></button> |
|
267 | 267 | </div> |
268 | 268 | </div> |
269 | 269 | </div> |