forked from bangbay/wp-user-avatar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpua-options-page.php
208 lines (205 loc) · 9.6 KB
/
wpua-options-page.php
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
/**
* Admin page to change plugin options.
*
* @package WP User Avatar
* @version 1.9.13
*/
/**
* @since 1.4
* @uses bool $show_avatars
* @uses string $upload_size_limit_with_units
* @uses object $wpua_admin
* @uses bool $wpua_allow_upload
* @uses bool $wpua_disable_gravatar
* @uses bool $wpua_edit_avatar
* @uses bool $wpua_resize_crop
* @uses int int $wpua_resize_h
* @uses bool $wpua_resize_upload
* @uses int $wpua_resize_w
* @uses object $wpua_subscriber
* @uses bool $wpua_tinymce
* @uses int $wpua_upload_size_limit
* @uses string $wpua_upload_size_limit_with_units
* @uses admin_url()
* @uses apply_filters()
* @uses checked()
* @uses do_action()
* @uses do_settings_fields()
* @uses get_option()
* @uses settings_fields()
* @uses submit_button()
* @uses wpua_add_default_avatar()
*/
global $show_avatars, $upload_size_limit_with_units, $wpua_admin, $wpua_allow_upload, $wpua_disable_gravatar, $wpua_edit_avatar, $wpua_resize_crop, $wpua_resize_h, $wpua_resize_upload, $wpua_resize_w, $wpua_subscriber, $wpua_tinymce, $wpua_upload_size_limit, $wpua_upload_size_limit_with_units;
$updated = false;
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true') {
$updated = true;
}
$hide_size = (bool) $wpua_allow_upload != 1 ? ' style="display:none;"' : "";
$hide_resize = (bool) $wpua_resize_upload != 1 ? ' style="display:none;"' : "";
$wpua_options_page_title = __('WP User Avatar', 'wp-user-avatar');
/**
* Filter admin page title
* @since 1.9
* @param string $wpua_options_page_title
*/
$wpua_options_page_title = apply_filters('wpua_options_page_title', $wpua_options_page_title);
?>
<div class="wrap">
<h2><?php echo $wpua_options_page_title; ?></h2>
<form method="post" action="<?php echo admin_url('options.php'); ?>">
<?php settings_fields('wpua-settings-group'); ?>
<?php do_settings_fields('wpua-settings-group', ""); ?>
<?php do_action('wpua_donation_message'); ?>
<table class="form-table">
<?php
// Format settings in table rows
$wpua_before_settings = array();
/**
* Filter settings at beginning of table
* @since 1.9
* @param array $wpua_before_settings
*/
$wpua_before_settings = apply_filters('wpua_before_settings', $wpua_before_settings);
echo implode("", $wpua_before_settings);
?>
<tr valign="top">
<th scope="row"><?php _e('Settings'); ?></th>
<td>
<?php
// Format settings in fieldsets
$wpua_settings = array();
$wpua_settings['tinymce'] = '<fieldset>
<label for="wp_user_avatar_tinymce">
<input name="wp_user_avatar_tinymce" type="checkbox" id="wp_user_avatar_tinymce" value="1" '.checked($wpua_tinymce, 1, 0).' />'
.__('Add avatar button to Visual Editor', 'wp-user-avatar').'
</label>
</fieldset>';
$wpua_settings['upload'] ='<fieldset>
<label for="wp_user_avatar_allow_upload">
<input name="wp_user_avatar_allow_upload" type="checkbox" id="wp_user_avatar_allow_upload" value="1" '.checked($wpua_allow_upload, 1, 0).' />'
.__('Allow Contributors & Subscribers to upload avatars', 'wp-user-avatar').'
</label>
</fieldset>';
$wpua_settings['gravatar'] ='<fieldset>
<label for="wp_user_avatar_disable_gravatar">
<input name="wp_user_avatar_disable_gravatar" type="checkbox" id="wp_user_avatar_disable_gravatar" value="1" '.checked($wpua_disable_gravatar, 1, 0).' />'
.__('Disable Gravatar and use only local avatars', 'wp-user-avatar').'
</label>
</fieldset>';
/**
* Filter main settings
* @since 1.9
* @param array $wpua_settings
*/
$wpua_settings = apply_filters('wpua_settings', $wpua_settings);
echo implode("", $wpua_settings);
?>
</td>
</tr>
</table>
<?php
// Format settings in table
$wpua_subscriber_settings = array();
$wpua_subscriber_settings['subscriber-settings'] = '<div id="wpua-contributors-subscribers"'.$hide_size.'>
<table class="form-table">
<tr valign="top">
<th scope="row">
<label for="wp_user_avatar_upload_size_limit">'
.__('Upload Size Limit', 'wp-user-avatar').' '.__('(only for Contributors & Subscribers)', 'wp-user-avatar').'
</label>
</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>'.__('Upload Size Limit', 'wp-user-avatar').' '. __('(only for Contributors & Subscribers)', 'wp-user-avatar').'</span></legend>
<input name="wp_user_avatar_upload_size_limit" type="text" id="wp_user_avatar_upload_size_limit" value="'.$wpua_upload_size_limit.'" class="regular-text" />
<span id="wpua-readable-size">'.$wpua_upload_size_limit_with_units.'</span>
<span id="wpua-readable-size-error">'.sprintf(__('%s exceeds the maximum upload size for this site.'), "").'</span>
<div id="wpua-slider"></div>
<span class="description">'.sprintf(__('Maximum upload file size: %d%s.'), esc_html(wp_max_upload_size()), esc_html(' bytes ('.$upload_size_limit_with_units.')')).'</span>
</fieldset>
<fieldset>
<label for="wp_user_avatar_edit_avatar">
<input name="wp_user_avatar_edit_avatar" type="checkbox" id="wp_user_avatar_edit_avatar" value="1" '.checked($wpua_edit_avatar, 1, 0).' />'
.__('Allow users to edit avatars', 'wp-user-avatar').'
</label>
</fieldset>
<fieldset>
<label for="wp_user_avatar_resize_upload">
<input name="wp_user_avatar_resize_upload" type="checkbox" id="wp_user_avatar_resize_upload" value="1" '.checked($wpua_resize_upload, 1, 0).' />'
.__('Resize avatars on upload', 'wp-user-avatar').'
</label>
</fieldset>
<fieldset id="wpua-resize-sizes"'.$hide_resize.'>
<label for="wp_user_avatar_resize_w">'.__('Width').'</label>
<input name="wp_user_avatar_resize_w" type="number" step="1" min="0" id="wp_user_avatar_resize_w" value="'.get_option('wp_user_avatar_resize_w').'" class="small-text" />
<label for="wp_user_avatar_resize_h">'.__('Height').'</label>
<input name="wp_user_avatar_resize_h" type="number" step="1" min="0" id="wp_user_avatar_resize_h" value="'.get_option('wp_user_avatar_resize_h').'" class="small-text" />
<br />
<input name="wp_user_avatar_resize_crop" type="checkbox" id="wp_user_avatar_resize_crop" value="1" '.checked('1', $wpua_resize_crop, 0).' />
<label for="wp_user_avatar_resize_crop">'.__('Crop avatars to exact dimensions', 'wp-user-avatar').'</label>
</fieldset>
</td>
</tr>
</table>
</div>';
/**
* Filter Subscriber settings
* @since 1.9
* @param array $wpua_subscriber_settings
*/
$wpua_subscriber_settings = apply_filters('wpua_subscriber_settings', $wpua_subscriber_settings);
echo implode("", $wpua_subscriber_settings);
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Avatar Display'); ?></th>
<td>
<fieldset>
<legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend>
<label for="show_avatars">
<input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked($show_avatars, 1); ?> />
<?php _e('Show Avatars'); ?>
</label>
</fieldset>
</td>
</tr>
<?php if((bool) $wpua_disable_gravatar != 1) : ?>
<tr valign="top" id="avatar-rating">
<th scope="row"><?php _e('Maximum Rating'); ?></th>
<td>
<fieldset>
<legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
<?php
$ratings = array(
'G' => __('G — Suitable for all audiences'),
'PG' => __('PG — Possibly offensive, usually for audiences 13 and above'),
'R' => __('R — Intended for adult audiences above 17'),
'X' => __('X — Even more mature than above')
);
foreach ($ratings as $key => $rating) :
$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : "";
echo "\n\t<label><input type='radio' name='avatar_rating' value='".esc_attr($key)."' $selected/> $rating</label><br />";
endforeach;
?>
</fieldset>
</td>
</tr>
<?php else : ?>
<input type="hidden" id="avatar_rating" name="avatar_rating" value="<?php echo get_option('avatar_rating'); ?>" />
<?php endif; ?>
<tr valign="top">
<th scope="row"><?php _e('Default Avatar') ?></th>
<td class="defaultavatarpicker">
<fieldset>
<legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
<?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.'); ?><br />
<?php echo $wpua_admin->wpua_add_default_avatar(); ?>
</fieldset>
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>