Skip to content

Commit

Permalink
✨ 增加用户中心基础框架和展示
Browse files Browse the repository at this point in the history
  • Loading branch information
Licoy committed Jan 27, 2023
1 parent dfc733c commit 3640fb6
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 64 deletions.
22 changes: 11 additions & 11 deletions 404.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
<a class="a-link" href="<?php echo home_url() ?>"><i class="fa fa-home"></i>&nbsp;<?php _e('返回首页', PUOCK) ?></a>
</div>
</div>
<script>
var timeCountDownS = 3;
var timeCountDownVal = 3;
timeCountDownVal = setInterval(function () {
$("#time-count-down").text(--timeCountDownS);
},1000);
setTimeout(function () {
window.clearInterval(timeCountDownVal);
window.location = '/';
},3000);
</script>
<!-- <script>-->
<!-- var timeCountDownS = 3;-->
<!-- var timeCountDownVal = 3;-->
<!-- timeCountDownVal = setInterval(function () {-->
<!-- $("#time-count-down").text(--timeCountDownS);-->
<!-- },1000);-->
<!-- setTimeout(function () {-->
<!-- window.clearInterval(timeCountDownVal);-->
<!-- window.location = '/';-->
<!-- },3000);-->
<!-- </script>-->
</div>


Expand Down
27 changes: 13 additions & 14 deletions assets/dist/js/libs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/dist/style/common.min.css

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions assets/dist/style/libs.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/dist/style/screen.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/dist/style/style.min.css

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions assets/style/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ a {
}
}

.list-group{
--bs-list-group-bg:var(--pk-bg-box);
--bs-list-group-color:var(--pk-c-font);
--bs-list-group-border-color:var(--pk-c-border);
}

.mtb10 {
margin-top: 10px;
margin-bottom: 10px;
Expand Down
6 changes: 6 additions & 0 deletions assets/style/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,12 @@ a:hover {
}
}

#user-center{
.form-control{
.fs14;
}
}

//企业风格
#index-company {
.bgimg {
Expand Down
2 changes: 2 additions & 0 deletions fun-custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ function cn_nf_url_parse( $content ) {
}
}
add_filter( 'the_content', 'cn_nf_url_parse');


32 changes: 18 additions & 14 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function pk_get_post_date()
$c_time = time() - $time;
$day = 86400;
switch ($c_time) {
//todo 本地化翻译
//todo 本地化翻译
case $c_time < $day:
$res = '近一天内';
break;
Expand Down Expand Up @@ -368,7 +368,8 @@ function page_link($i, $title = '')
//获取面包屑导航
function pk_breadcrumbs()
{
global $cat, $other_page_title;
global $cat;
$custom_seo_title = pk_get_custom_seo()['title'] ?? '';
$out = '<div id="breadcrumb" class="' . (pk_open_box_animated('animated fadeInUp', false)) . '">';
$out .= '<nav aria-label="breadcrumb">';
$out .= '<ol class="breadcrumb">';
Expand Down Expand Up @@ -409,8 +410,8 @@ function pk_breadcrumbs()
$tag_name = single_tag_title('', false);
$out .= '<li class="breadcrumb-item active " aria-current="page">' . __('标签', PUOCK) . '</li>';
$out .= '<li class="breadcrumb-item active " aria-current="page">' . ($tag_name) . '</li>';
} else if (isset($other_page_title)) {
$out .= '<li class="breadcrumb-item active " aria-current="page">' . $other_page_title . '</li>';
} else if (!empty($custom_seo_title)) {
$out .= '<li class="breadcrumb-item active " aria-current="page">' . $custom_seo_title . '</li>';
} else if (is_404()) {
$out .= '<li class="breadcrumb-item active " aria-current="page">' . __('你访问的资源不存在', PUOCK) . '</li>';
}
Expand Down Expand Up @@ -505,7 +506,8 @@ function pk_update()
$current_theme_dir_name = basename(dirname(__FILE__));
include('update-checker/update-checker.php');
switch ($update_server) {
case 'github': {
case 'github':
{
$pkUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'https://github.com/Licoy/wordpress-theme-puock',
__FILE__,
Expand All @@ -514,7 +516,8 @@ function pk_update()
);
}
break;
case 'fastgit': {
case 'fastgit':
{
$pkUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'https://licoy.cn/go/puock-update.php?r=fastgit',
__FILE__,
Expand All @@ -523,14 +526,15 @@ function pk_update()
);
}
break;
default: {
$pkUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'https://licoy.cn/go/puock-update.php?r=worker',
__FILE__,
$current_theme_dir_name,
$check_period
);
}
default:
{
$pkUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'https://licoy.cn/go/puock-update.php?r=worker',
__FILE__,
$current_theme_dir_name,
$check_period
);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions inc/fun/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function pk_ajax_update_theme_options()
$body = pk_ajax_get_req_body();
update_option(PUOCK_OPT, $body);
do_action('pk_option_updated', $body);
flush_rewrite_rules();
wp_send_json_success();
} else {
wp_send_json_error('权限不足');
Expand Down
56 changes: 50 additions & 6 deletions inc/fun/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ function pk_content_img_lazy($content)
add_filter('the_content', 'pk_content_img_lazy');
}
//获取图片缩略图链接
function pk_get_img_thumbnail_src($src, $width, $height,$args=array())
function pk_get_img_thumbnail_src($src, $width, $height, $args = array())
{
if ($width == null || $height == null) {
return $src;
}
if(pk_is_checked('thumbnail_rewrite_open')){
return home_url() . "/timthumb/w_{$width}/h_{$height}/q_90/zc_1/a_c/".str_replace("=","",base64_encode($src)).".png";
if (pk_is_checked('thumbnail_rewrite_open')) {
return home_url() . "/timthumb/w_{$width}/h_{$height}/q_90/zc_1/a_c/" . str_replace("=", "", base64_encode($src)) . ".png";
}
return PUOCK_ABS_URI . "/timthumb.php?w={$width}&h={$height}&a=c&zc=1&q=90&src=" . $src;
}
Expand Down Expand Up @@ -417,7 +417,7 @@ function pk_comment_author_url($comment_ID = 0)
$attr = "target='_blank' rel='external nofollow'";
}
$author = get_comment_author($comment_ID);
echo empty($url) ? $author : "<a ".$attr." href='" . pk_go_link($url) . "' class='url'>$author</a>";
echo empty($url) ? $author : "<a " . $attr . " href='" . pk_go_link($url) . "' class='url'>$author</a>";
}

//评论回复通知
Expand Down Expand Up @@ -657,7 +657,7 @@ function pk_get_main_menu($mobile = false)
if (is_user_logged_in()) {
$user = wp_get_current_user();
$avatar = get_avatar_url($user->user_email);
$out .= '<li><a data-no-instant data-bs-toggle="tooltip" title="用户中心" href="' . get_edit_profile_url() . '"><img alt="用户中心" src="' . $avatar . '" class="min-avatar"></a></li>';
$out .= '<li><a data-no-instant data-bs-toggle="tooltip" title="用户中心" href="' . pk_user_center_url() . '"><img alt="用户中心" src="' . $avatar . '" class="min-avatar"></a></li>';
} else {
if (pk_is_checked('open_quick_login')) {
$url = pk_ajax_url('pk_font_login_page', ['redirect' => home_url($wp->request)]);
Expand Down Expand Up @@ -766,7 +766,7 @@ function pk_pre_post_set($query)
{
if ($query->is_home() && $query->is_main_query()) {
if (pk_get_option('index_mode', '') == 'cms') {
$query->set('posts_per_page', pk_get_option('cms_show_new_num', 5));
$query->set('posts_per_page', pk_get_option('cms_show_new_num', 6));
}
}
}
Expand Down Expand Up @@ -941,3 +941,47 @@ function pk_vd_gt_validate(array $args = null)
}
return true;
}

function pk_user_center_url(): string
{
if(pk_is_checked('user_center')){
return home_url().'/uc';
}
return get_edit_profile_url();
}

function pk_rewrite_rule()
{
if(pk_is_checked('user_center')){
add_rewrite_rule("^uc/?", 'index.php?pagename=user-center', "top");
}
}

add_action('init', 'pk_rewrite_rule');

function pk_template_redirect()
{
global $wp_query;
$page_name = $wp_query->get('pagename');
if (!empty($page_name)) {
$template = '';
switch ($page_name) {
case 'user-center':
$template = PUOCK_ABS_DIR.'/inc/page/user-center.php';
break;
default:
break;
}
if (!empty($template)) {
pk_load_template($template);
exit;
}
}
}

add_action('template_redirect', 'pk_template_redirect');

function pk_load_template($_template_file, $require_once = true, $args = array()){
status_header(200);
load_template($_template_file, $require_once, $args);
}
14 changes: 14 additions & 0 deletions inc/fun/opt.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,17 @@ function pk_read_time_tip(): string
$read_time = ceil($words_count / 400);
return sprintf(__('共计 %d 个字符,预计需要花费 %d 分钟才能阅读完成。'), $words_count, $read_time);
}

function pk_set_custom_seo($title, $keywords = '', $description = '')
{
$GLOBALS['pk-seo'] = array(
'title' => $title,
'keywords' => $keywords,
'description' => $description
);
}

function pk_get_custom_seo()
{
return $GLOBALS['pk-seo'] ?? array();
}
4 changes: 1 addition & 3 deletions inc/go.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php

$other_page_title = "链接跳转";

include '../../../../wp-blog-header.php';

pk_set_custom_seo("链接跳转");
$url = @$_GET['to'];
$name = @$_GET['name'];
if (!empty($name)) {
Expand Down
71 changes: 71 additions & 0 deletions inc/page/user-center.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
if (!is_user_logged_in()) {
wp_redirect(home_url());
exit;
}
pk_set_custom_seo('用户中心');
$userinfo = get_userdata(get_current_user_id());
get_header();
?>

<div id="content" class="mt20 container min-height-container">
<?php echo pk_breadcrumbs() ?>
<div class="p-block" id="user-center">
<div class="row row-cols-1">
<div class="col-lg-3 col-md-12">
<div class="list-group">
<a href="#" class="ta3 list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div>基本信息</div>
<span class="c-sub fs12">基本信息</span>
</div>
</a>
<!-- <a href="#" class="ta3 list-group-item d-flex justify-content-between align-items-start">-->
<!-- <div class="ms-2 me-auto">-->
<!-- <div>社交账号</div>-->
<!-- <span class="c-sub fs12">第三方社交账号绑定</span>-->
<!-- </div>-->
<!-- </a>-->
</div>
</div>
<div class="col-lg-9 col-md-12 fs14">
<form action="">
<div class="mb-3 row">
<label class="col-sm-2 col-form-label">ID</label>
<div class="col-sm-10">
<input type="text" readonly class="form-control" value="<?php echo $userinfo->ID ?>">
</div>
</div>
<div class="mb-3 row">
<label class="col-sm-2 col-form-label">用户名</label>
<div class="col-sm-10">
<input type="text" readonly class="form-control" value="<?php echo $userinfo->user_nicename ?>">
<small class="c-sub">用户名不可更改</small>
</div>
</div>
<div class="mb-3 row">
<label class="col-sm-2 col-form-label">昵称</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="<?php echo $userinfo->nickname ?>">
</div>
</div>
<div class="mb-3 row">
<label class="col-sm-2 col-form-label">网站地址</label>
<div class="col-sm-10">
<input type="url" class="form-control" value="<?php echo $userinfo->user_url ?>">
</div>
</div>
<div class="mb-3 row">
<label class="col-sm-2 col-form-label">个人说明</label>
<div class="col-sm-10">
<textarea class="form-control" rows="4"><?php echo $userinfo->description ?></textarea>
</div>
</div>
</form>
</div>
</div>
</div>
</div>


<?php get_footer(); ?>
8 changes: 5 additions & 3 deletions inc/seo.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php $titleConn = " " . pk_get_option("title_conn") . " " ?>
<?php $blog_name = pk_get_web_title();
$pkSeoPageInfo = ''; ?>
<?php global $other_page_title;
<?php
$custom_seo = pk_get_custom_seo();
$custom_seo_title = $custom_seo['title'] ?? '';
if (get_query_var('paged')) {
$pkSeoPageInfo = $titleConn . '' . get_query_var('paged') . '';
}
if (isset($other_page_title)) { ?>
<title><?php echo $other_page_title . $pkSeoPageInfo . $titleConn . $blog_name; ?></title>
if (!empty($custom_seo_title)) { ?>
<title><?php echo $custom_seo['title'] . $pkSeoPageInfo . $titleConn . $blog_name; ?></title>
<?php } else if (is_home()) { ?>
<title><?php echo $blog_name . $pkSeoPageInfo . (pk_get_option('web_title_2') ? $titleConn . pk_get_option('web_title_2') : ''); ?></title>
<?php } else if (is_search()) { ?><title>搜索"<?php echo $_REQUEST['s'] ?>
Expand Down
8 changes: 8 additions & 0 deletions inc/setting/options/OptionExtend.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ function get_fields(): array
'disabled' => true,
'badge' => ['value' => '🔥 ' . __('热门 & 推荐', PUOCK)]
],
[
'id' => 'user_center',
'label' => __('用户中心', PUOCK),
'type' => 'switch',
'sdt' => false,
'badge' => ['value' => 'New'],
'tips' => __('使用前请先配置wordpress伪静态规则:<code>try_files $uri $uri/ /index.php?$args</code>', PUOCK)
],
[
'id' => 'strawberry_icon',
'label' => __('Strawberry图标库', PUOCK),
Expand Down

0 comments on commit 3640fb6

Please sign in to comment.