-
Notifications
You must be signed in to change notification settings - Fork 1
/
option.php
218 lines (191 loc) · 10.3 KB
/
option.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
209
210
211
212
213
214
215
216
217
218
<?php
defined('ABSPATH') or exit;
function Go_login_menu() {
$icon_url = plugins_url('/assets/img/favicon.ico', __FILE__);
add_menu_page(
'Gologin第三方登录登录设置',
'Gologin登录设置',
'administrator',
'GO_login_setting_page',
'display_Go_login_setting',
$icon_url
);
}
add_action('admin_menu','Go_login_menu');
function display_Go_login_setting() {
echo "<h1>设置页面</h1>";
?>
<div class="wpmm-wrapper">
<div class="content" class="wrapper-cell">
<form method="post" action="options.php">
<?php
settings_fields('GO_login_setting_field');
do_settings_sections('GO_login_setting_page');
submit_button();
?>
</form>
</div>
<?php
include_once "sidebar.php";
echo "</div>";
}
//添加设置表单
function add_Go_login_setting_field() {
//Go_login_options_qq_appid
add_settings_field(
'Go_login_options_qq_appid', // ID used to identify the field throughout the theme
'QQAppID', // The label to the left of the option interface element
'Go_login_text_field_callback', // The name of the function responsible for rendering the option interface
'GO_login_setting_page', // The page on which this option will be displayed
'GO_login_setting_section',
array(
'field' => 'Go_login_options_qq_appid',//传送给数组
'desc' => '<p class="description">填入<a href="http://connect.qq.com" target="_blank">QQ互联</a>里申请到的APPID。</p>'
)
);
//Go_login_options_qq_appkey
add_settings_field(
'Go_login_options_qq_appkey', // ID used to identify the field throughout the theme
'QQAppKEY', // The label to the left of the option interface element
'Go_login_text_field_callback', // The name of the function responsible for rendering the option interface
'GO_login_setting_page', // The page on which this option will be displayed
'GO_login_setting_section',
array(
'field' => 'Go_login_options_qq_appkey',//传送给数组
'desc' => '<p class="description">填入<a href="http://connect.qq.com" target="_blank">QQ互联</a>里申请到的APPKEY。</p>'
)
);
//Go_login_options_sina_appkey
add_settings_field(
'Go_login_options_sina_appkey', // ID used to identify the field throughout the theme
'Sina Appkey', // The label to the left of the option interface element
'Go_login_text_field_callback', // The name of the function responsible for rendering the option interface
'GO_login_setting_page', // The page on which this option will be displayed
'GO_login_setting_section',
array(
'field' => 'Go_login_options_sina_appkey',//传送给数组
'desc' => '<p class="description">填入<a href="http://open.weibo.com" target="_blank">新浪微博开放平台</a>里申请到的APPKEY。</p>'
)
);
//Go_login_options_sina_appsecret
add_settings_field(
'Go_login_options_sina_appsecret', // ID used to identify the field throughout the theme
'新浪App Secret:', // The label to the left of the option interface element
'Go_login_text_field_callback', // The name of the function responsible for rendering the option interface
'GO_login_setting_page', // The page on which this option will be displayed
'GO_login_setting_section',
array(
'field' => 'Go_login_options_sina_appsecret',//传送给数组
'desc' => '<p class="description">填入<a href="http://open.weibo.com" target="_blank">新浪微博开放平台</a>里申请到的App Secret。</p>'
)
);
//Go_login_options_bd_apikey
add_settings_field(
'Go_login_options_bd_apikey', // ID used to identify the field throughout the theme
'百度API Key:', // The label to the left of the option interface element
'Go_login_text_field_callback', // The name of the function responsible for rendering the option interface
'GO_login_setting_page', // The page on which this option will be displayed
'GO_login_setting_section',
array(
'field' => 'Go_login_options_bd_apikey',//传送给数组
'desc' => '<p class="description">填入<a href="http://dev.baidu.com" target="_blank">百度开放平台</a>里申请到的Api Key。</p>'
)
);
//Go_login_options_bd_secretkey
add_settings_field(
'Go_login_options_bd_secretkey', // ID used to identify the field throughout the theme
'百度Secret Key:', // The label to the left of the option interface element
'Go_login_text_field_callback', // The name of the function responsible for rendering the option interface
'GO_login_setting_page', // The page on which this option will be displayed
'GO_login_setting_section',
array(
'field' => 'Go_login_options_bd_secretkey',//传送给数组
'desc' => '<p class="description">填入<a href="http://dev.baidu.com" target="_blank">百度开放平台</a>里申请到的Secret Key。</p>'
)
);
//Go_login_options_gh_ClientID
add_settings_field(
'Go_login_options_gh_ClientID', // ID used to identify the field throughout the theme
'Github Client ID:', // The label to the left of the option interface element
'Go_login_text_field_callback', // The name of the function responsible for rendering the option interface
'GO_login_setting_page', // The page on which this option will be displayed
'GO_login_setting_section',
array(
'field' => 'Go_login_options_gh_ClientID',//传送给数组
'desc' => '<p class="description">填入<a href="https://github.com/settings/developers" target="_blank">Github开放平台</a>里申请到的Client ID。</p>'
)
);
//Go_login_options_gh_ClientSecret
add_settings_field(
'Go_login_options_gh_ClientSecret', // ID used to identify the field throughout the theme
'Github Client Secret:', // The label to the left of the option interface element
'Go_login_text_field_callback', // The name of the function responsible for rendering the option interface
'GO_login_setting_page', // The page on which this option will be displayed
'GO_login_setting_section',
array(
'field' => 'Go_login_options_gh_ClientSecret',//传送给数组
'desc' => '<p class="description">填入<a href="https://github.com/settings/developers" target="_blank">Github开放平台</a>里申请到的Client Secret。</p>'
)
);
//WeChat
add_settings_field(
'Go_login_options_wechat_switch', // ID used to identify the field throughout the theme
'启用微信登录:', // The label to the left of the option interface element
'Go_login_checkbox_field_callback', // The name of the function responsible for rendering the option interface
'GO_login_setting_page', // The page on which this option will be displayed
'GO_login_setting_section',
array(
'field' => 'Go_login_options_wechat_switch',//传送给数组
'desc' => '启用微信登录'
)
);
}
add_action('admin_init', 'add_Go_login_setting_field');
//注册设置菜单
function register_Go_login_setting_field() {
register_setting('GO_login_setting_field', 'Go_login_options_qq_appid');
register_setting('GO_login_setting_field', 'Go_login_options_qq_appkey');
register_setting('GO_login_setting_field', 'Go_login_options_sina_appkey');
register_setting('GO_login_setting_field', 'Go_login_options_sina_appsecret');
register_setting('GO_login_setting_field', 'Go_login_options_bd_apikey');
register_setting('GO_login_setting_field', 'Go_login_options_bd_secretkey');
register_setting('GO_login_setting_field', 'Go_login_options_gh_ClientID');
register_setting('GO_login_setting_field', 'Go_login_options_gh_ClientSecret');
register_setting('GO_login_setting_field', 'Go_login_options_wechat_switch');
}
add_action('admin_init', 'register_Go_login_setting_field');
//add section
function add_Go_login_setting_section()
{
//setting
add_settings_section(
'GO_login_setting_section', // ID used to identify this section and with which to register options
'GoLogin设置', // Title to be displayed on the administration page
'GO_login_setting_section_callback', // Callback used to render the description of the section
'GO_login_setting_page' // Page on which to add this section of options
);
}
add_action("admin_init", "add_Go_login_setting_section");
///////////////////////Callback///////////////////////////////
function GO_login_setting_section_callback()
{
echo "这是GoLogin设置部分";
}
/**
* $args array(
* 'field' => '???',
* 'desc' => '???'
* )
*/
function Go_login_text_field_callback($args)
{
$html = "<input type=\"text\" id=\"{$args['field']}\" name=\"{$args['field']}\" value=\"" . get_option($args['field']) . "\" />";
$html .= "<label for=\"{$args['field']}\">{$args['desc']}</label>";
echo $html;
}
function Go_login_checkbox_field_callback($args)
{
$html = "<input type=\"checkbox\" id=\"{$args['field']}\" name=\"{$args['field']}\" " . (get_option($args['field'])?'checked':'') . " />";
$html .= "<label for=\"{$args['field']}\">{$args['desc']}</label>";
echo $html;
}