credit-tools.php
6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
/**
* Credit Tools
*
* @package badgeos
* @subpackage Tools
* @author LearningTimes, LLC
* @license http://www.gnu.org/licenses/agpl.txt GNU AGPL v3.0
* @link https://badgeos.org
*/
$credit_types = badgeos_get_point_types();
?>
<div id="credit-tabs">
<div class="tab-title"><?php esc_attr_e( 'Credit Tools', 'badgeos' ); ?></div>
<ul>
<li>
<a href="#credit_bulk_award">
<i class="fa fa-trophy" aria-hidden="true"></i>
<?php esc_attr_e( 'Award Credits In Bulk', 'badgeos' ); ?>
</a>
</li>
<li>
<a href="#credit_bulk_revoke">
<i class="fa fa-star-o" aria-hidden="true"></i>
<?php esc_attr_e( 'Revoke Credits In Bulk', 'badgeos' ); ?>
</a>
</li>
</ul>
<div id="credit_bulk_award">
<form method="POST" class="credit-bulk-award" action="">
<table cellspacing="0">
<tbody>
<tr>
<th scope="row"><label for="credit_types"><?php esc_attr_e( 'Select Credit Type', 'badgeos' ); ?></label></th>
<td>
<select id="credit_types_to_award" data-placeholder="Select Credit Type" name="badgeos_tools[award_credit_type]" class="badgeos-select">
<option value=""><?php esc_attr_e( 'Select Credit Type' ); ?></option>
<?php
if ( is_array( $credit_types ) && ! empty( $credit_types ) ) {
foreach ( $credit_types as $credit_type ) {
echo '<option value="' . esc_attr( $credit_type->ID ) . '">' . esc_attr( $credit_type->post_title ) . '</option>';
}
}
?>
</select>
<span class="tool-hint"><?php esc_attr_e( 'Choose the credit type to award', 'badgeos' ); ?></span>
</td>
</tr>
<tr>
<th scope="row"><label for="credit_amount"><?php esc_attr_e( 'Credit Amount', 'badgeos' ); ?></label></th>
<td>
<input type="number" class="credit-amount" placeholder="Credit Amount" name="badgeos_tools[credit_amount]">
<span class="tool-hint"><?php esc_attr_e( 'Amount of credit to award', 'badgeos' ); ?></span>
</td>
</tr>
<tr>
<th scope="row"><label for="all_users"><?php esc_attr_e( 'Award to All Users', 'badgeos' ); ?></label></th>
<td>
<div class="form-switcher form-switcher-lg form-switcher-sm-phone">
<input type="checkbox" name="badgeos_tools[award_all_users]" id="award-credits" data-com.bitwarden.browser.user-edited="yes">
<label class="switcher" for="award-credits"></label>
</div>
<span class="tool-hint"><?php esc_attr_e( 'Check this point to award achievements to all users', 'badgeos' ); ?></span>
</td>
</tr>
<tr>
<th scope="row"><label for="users"><?php esc_attr_e( 'Users to Award', 'badgeos' ); ?></label></th>
<td>
<select id="badgeos-award-users" name="badgeos_tools[award_users][]" data-placeholder="Select a user" multiple="multiple" class="badgeos-select">
<?php
$args = array(
'role' => '',
'orderby' => 'nicename',
'order' => 'ASC',
'count_total' => false,
'fields' => array( 'ID', 'user_nicename' ),
);
$wp_users = get_users( $args );
foreach ( $wp_users as $user ) :
?>
<option value="<?php echo esc_attr( $user->ID ); ?>" <?php selected( esc_attr( $user->ID ), 'disabled' ); ?>>
<?php echo esc_html( $user->user_nicename ); ?>
</option>
<?php endforeach; ?>
</select>
<span class="tool-hint"><?php esc_attr_e( 'Choose users to award', 'badgeos' ); ?></span>
</td>
</tr>
</tbody>
</table>
<?php wp_nonce_field( 'credit_bulk_award', 'credit_bulk_award' ); ?>
<input type="hidden" name="action" value="award_credits_in_bulk">
<input type="submit" name="award_credits_in_bulk" class="button button-primary" value="<?php esc_attr_e( 'Award Credits', 'badgeos' ); ?>">
</form>
</div>
<div id="credit_bulk_revoke">
<form method="POST" class="credit_bulk_revoke" action="">
<table cellspacing="0">
<tbody>
<tr>
<th scope="row"><label for="credit_types"><?php esc_attr_e( 'Select Credit Type', 'badgeos' ); ?></label></th>
<td>
<select id="credit_types_to_revoke" data-placeholder="Select Credit Type" name="badgeos_tools[revoke_credit_type]" class="badgeos-select">
<option value=""><?php esc_attr_e( 'Select Credit Type' ); ?></option>
<?php
if ( is_array( $credit_types ) && ! empty( $credit_types ) ) {
foreach ( $credit_types as $credit_type ) {
echo '<option value="' . esc_attr( $credit_type->ID ) . '">' . esc_attr( $credit_type->post_title ) . '</option>';
}
}
?>
</select>
<span class="tool-hint"><?php esc_attr_e( 'Choose the credit type to revoke', 'badgeos' ); ?></span>
</td>
</tr>
<tr>
<th scope="row"><label for="credit_amount"><?php esc_attr_e( 'Credit Amount', 'badgeos' ); ?></label></th>
<td>
<input type="number" class="credit-amount" placeholder="Credit Amount" name="badgeos_tools[credit_amount]">
<span class="tool-hint"><?php esc_attr_e( 'Amount of credit to revoke', 'badgeos' ); ?></span>
</td>
</tr>
<tr>
<th scope="row"><label for="all_users"><?php esc_attr_e( 'Revoke to All Users', 'badgeos' ); ?></label></th>
<td>
<div class="form-switcher form-switcher-lg">
<input type="checkbox" name="badgeos_tools[revoke_all_users]" id="revoke-credits" data-com.bitwarden.browser.user-edited="yes">
<label class="switcher" for="revoke-credits"></label>
</div>
<span class="tool-hint"><?php esc_attr_e( 'Check this point to revoke achievements to all users', 'badgeos' ); ?></span>
</td>
</tr>
<tr>
<th scope="row"><label for="users"><?php esc_attr_e( 'Users to Revoke', 'badgeos' ); ?></label></th>
<td>
<select id="badgeos-revoke-users" name="badgeos_tools[revoke_users][]" data-placeholder="Select a user" multiple="multiple" class="badgeos-select">
<?php
$args = array(
'role' => '',
'orderby' => 'nicename',
'order' => 'ASC',
'count_total' => false,
'fields' => array( 'ID', 'user_nicename' ),
);
$wp_users = get_users( $args );
foreach ( $wp_users as $user ) :
?>
<option value="<?php echo esc_attr( $user->ID ); ?>" <?php selected( esc_attr( $user->ID ), 'disabled' ); ?>>
<?php echo esc_html( $user->user_nicename ); ?>
</option>
<?php endforeach; ?>
</select>
<span class="tool-hint"><?php esc_attr_e( 'Choose users to revoke', 'badgeos' ); ?></span>
</td>
</tr>
</tbody>
</table>
<?php wp_nonce_field( 'credit_bulk_revoke', 'credit_bulk_revoke' ); ?>
<input type="hidden" name="action" value="revoke_credits_in_bulk">
<input type="submit" name="revoke_credits_in_bulk" class="button button-primary" value="<?php esc_attr_e( 'Revoke Credits', 'badgeos' ); ?>">
</form>
</div>
</div>