WordPress插件1.0.2版本更新
This commit is contained in:
parent
02ef0bcd99
commit
82342c7025
|
@ -18,7 +18,7 @@
|
|||
|
||||
### 插件详情
|
||||
|
||||
- [Typecho版本QuanPro](/WordPress/README.md)
|
||||
- [Typecho版本QuanPro](/Typecho/README.md)
|
||||
|
||||
### 安装配置教程
|
||||
|
||||
|
|
|
@ -6,6 +6,35 @@
|
|||
|
||||
## 更新记录
|
||||
|
||||
### v1.0.2 2023-06-17
|
||||
|
||||
1. 登录组件新增ShortCode调用方式,调用代码为 `[qualpro_login]`
|
||||
2. 新增启用中文用户名选项,自动注册用户名允许为中文(启用前请确保网站已经修改支持中文用户名)
|
||||
3. BUG修复及优化
|
||||
|
||||
修改主题functions.php文件以支持中文用户名
|
||||
|
||||
添加以下代码
|
||||
|
||||
```php
|
||||
/*---------------------------------*/
|
||||
/* wordpress支持中文名注册!
|
||||
/*---------------------------------*/
|
||||
function loper_sanitize_user($username, $raw_username, $strict) {
|
||||
$username = wp_strip_all_tags($raw_username);
|
||||
$username = remove_accents($username);
|
||||
$username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username);
|
||||
$username = preg_replace('/&.+?;/', '', $username); // Kill entities
|
||||
if ($strict) {
|
||||
$username = preg_replace('|[^a-z\p{Han}0-9 _.\-@]|iu', '', $username);
|
||||
}
|
||||
$username = trim($username);
|
||||
$username = preg_replace('|\s+|', ' ', $username);
|
||||
return $username;
|
||||
}
|
||||
add_filter('sanitize_user', 'loper_sanitize_user', 10, 3);
|
||||
```
|
||||
|
||||
### v1.0.1 2023-05-12
|
||||
|
||||
1. 新增state验证配置功能,用户可以在配置界面取消state验证功能
|
||||
|
|
|
@ -18,6 +18,7 @@ function qauth_init() {
|
|||
update_option('qauth_api', 'https://api.qauth.cn');
|
||||
update_option('qauth_auto_register', '1');
|
||||
update_option('qauth_state_check', '1');
|
||||
update_option('qauth_support_cn_name', '0');
|
||||
update_option('qualpro_redirect_type', '1');
|
||||
update_option('qualpro_redirect_url', '/');
|
||||
}
|
||||
|
@ -36,6 +37,7 @@ function qauth_deactivation() {
|
|||
|
||||
// 登录界面新增第三方按钮
|
||||
function qualpro_login_button(){
|
||||
|
||||
$qauth_api = get_option('qauth_api');
|
||||
$qauth_appkey = get_option('qauth_appkey');
|
||||
$qauth_user_secret = get_option('qauth_user_secret');
|
||||
|
@ -81,6 +83,10 @@ function qualpro_login_button(){
|
|||
|
||||
function qualpro_login($turn_to_current_page = false)
|
||||
{
|
||||
if(is_user_logged_in()){
|
||||
return;
|
||||
}
|
||||
|
||||
$redirect = "";
|
||||
if($turn_to_current_page == true){
|
||||
$redirect = '&redirect='.home_url(add_query_arg(array()));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Plugin Name: QualPro
|
||||
Plugin URI: https://github.com/mr-wixy/QualPro
|
||||
Description: QualPro是基于QuickAuth平台的集成登录插件
|
||||
Version: 1.0.1
|
||||
Version: 1.0.2
|
||||
Author: wixy
|
||||
Author URI: https://blog.wixy.cn/
|
||||
*/
|
||||
|
@ -14,6 +14,8 @@ include_once('core.php');
|
|||
|
||||
add_filter('login_form', 'qualpro_login_button');
|
||||
|
||||
add_shortcode('qualpro_login', 'qualpro_login');
|
||||
|
||||
add_action('admin_menu', 'qualpro_menu');
|
||||
|
||||
register_activation_hook( __FILE__, 'qauth_install' );
|
||||
|
|
|
@ -9,6 +9,7 @@ $qauth_appkey = get_option('qauth_appkey');
|
|||
$qauth_user_secret = get_option('qauth_user_secret');
|
||||
$qauth_auto_register = get_option('qauth_auto_register');
|
||||
$qauth_state_check = get_option('qauth_state_check');
|
||||
$qauth_support_cn_name = get_option('qauth_support_cn_name');
|
||||
$qualpro_redirect_url = get_option('qualpro_redirect_url');
|
||||
|
||||
if(isset($_GET['code']) && isset($_GET['state'])){
|
||||
|
@ -19,7 +20,7 @@ if(isset($_GET['code']) && isset($_GET['state'])){
|
|||
wp_die("请求state无效!");
|
||||
}
|
||||
}
|
||||
$response = wp_remote_get($qauth_api.'/authinfo?code='.$code.'&appkey='.$qauth_appkey.'&secret='.$qauth_user_secret);
|
||||
$response = wp_remote_get($qauth_api.'/authinfov2?code='.$code.'&appkey='.$qauth_appkey.'&secret='.$qauth_user_secret);
|
||||
$body = wp_remote_retrieve_body( $response );
|
||||
$content_obj = json_decode($body);
|
||||
if($content_obj->code === 0){
|
||||
|
@ -120,7 +121,10 @@ if(isset($_GET['code']) && isset($_GET['state'])){
|
|||
else{
|
||||
//未绑定用户
|
||||
if($qauth_auto_register == '1'){
|
||||
$newUserName = $user_obj->nickName;
|
||||
$newUserName = $user_obj->randomName;
|
||||
if($qauth_support_cn_name){
|
||||
$newUserName = $user_obj->nickName;
|
||||
}
|
||||
$user_id = username_exists($newUserName);
|
||||
if($user_id){
|
||||
$newUserName = $newUserName.'_'.substr(md5(uniqid(microtime())), 0, 4);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
header("Content-Type: application/json;charset=utf-8");
|
||||
include_once('../../../../wp-load.php');
|
||||
define("plugin_version",'1.0.0');
|
||||
define("plugin_version",'1.0.2');
|
||||
|
||||
$enable = get_option('qualpro_plugin_enable') == "1";
|
||||
$data = [
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
$qauth_api = isset($_POST['qauth_api'])?trim($_POST['qauth_api']):null;
|
||||
$qauth_auto_register = isset($_POST['qauth_auto_register'])?trim($_POST['qauth_auto_register']):null;
|
||||
$qauth_state_check = isset($_POST['qauth_state_check'])?trim($_POST['qauth_state_check']):null;
|
||||
$qauth_support_cn_name = isset($_POST['qauth_support_cn_name'])?trim($_POST['qauth_support_cn_name']):null;
|
||||
$qualpro_redirect_type = isset($_POST['qualpro_redirect_type'])?trim($_POST['qualpro_redirect_type']):null;
|
||||
$qualpro_redirect_url = isset($_POST['qualpro_redirect_url'])?trim($_POST['qualpro_redirect_url']):null;
|
||||
|
||||
|
@ -28,6 +29,7 @@
|
|||
update_option('qauth_api', $qauth_api);
|
||||
update_option('qauth_auto_register', $qauth_auto_register);
|
||||
update_option('qauth_state_check', $qauth_state_check);
|
||||
update_option('qauth_support_cn_name', $qauth_support_cn_name);
|
||||
update_option('qualpro_redirect_type', $qualpro_redirect_type);
|
||||
update_option('qualpro_redirect_url', $qualpro_redirect_url);
|
||||
echo '<div class="updated settings-error"><p>保存成功</p></div>';
|
||||
|
@ -37,6 +39,7 @@
|
|||
$qauth_api = get_option('qauth_api');
|
||||
$qauth_auto_register = get_option('qauth_auto_register');
|
||||
$qauth_state_check = get_option('qauth_state_check');
|
||||
$qauth_support_cn_name = get_option('qauth_support_cn_name');
|
||||
$qualpro_redirect_type = get_option('qualpro_redirect_type');
|
||||
$qualpro_redirect_url = get_option('qualpro_redirect_url');
|
||||
|
||||
|
@ -156,6 +159,13 @@
|
|||
<td><input type="checkbox" id="qauth_state_check" name="qauth_state_check" value="1" <?php if($qauth_state_check) echo 'checked'; ?>/>开启
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th valign="top">
|
||||
<p style="margin: 0;">允许使用中文用户名</p>
|
||||
<small style="color: orangered;">请确保网站已经支持中文用户名</small></th>
|
||||
<td><input type="checkbox" id="qauth_support_cn_name" name="qauth_support_cn_name" value="1" <?php if($qauth_support_cn_name) echo 'checked'; ?>/>开启
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th valign="top"><strong>成功登录后跳转地址</strong>
|
||||
</th>
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
.iconfont {
|
||||
font-family: "iconfont" !important;
|
||||
font-size: 35px;
|
||||
font-style: normal;
|
||||
font-size: 35px !important;
|
||||
color: inherit !important;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue