Skip to content

Commit df13491

Browse files
committed
240730
分类增加”可查看用户“ 仅管理员可见、登陆可见、所有人 网址”仅管理员可见”修改为 ”可查看用户“ 仅管理员可见、登陆可见、所有人 更换天气api 网址详情页根据“可查看用户”权限显示,权限不够则跳转到首页 增加“文章列表”页面模版 分离文章和网址分类页模版 优化搜索页面布局 优化部分布局 优化wp6.6支持 支持php8+
1 parent e509c80 commit df13491

28 files changed

+1095
-265
lines changed

archive.php

+43-36
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,62 @@
66
* @Author URI: https://www.iowen.cn/
77
* @Date: 2020-02-22 21:26:05
88
* @LastEditors: iowen
9-
* @LastEditTime: 2023-02-20 20:52:23
10-
* @FilePath: \WebStack\archive.php
9+
* @LastEditTime: 2024-07-30 18:25:17
10+
* @FilePath: /WebStack/archive.php
1111
* @Description:
1212
*/
1313
if ( ! defined( 'ABSPATH' ) ) { exit; }
1414
get_header(); ?>
1515

1616

1717
<?php
18-
$categories= get_categories(array(
19-
'taxonomy' => 'favorites',
20-
'meta_key' => '_term_order',
21-
'orderby' => 'meta_value_num',
22-
'order' => 'desc',
23-
'hide_empty' => 0,
24-
)
25-
);
2618
include( 'templates/header-nav.php' );
2719
?>
2820
<div class="main-content">
2921

3022
<?php include( 'templates/header-banner.php' ); ?>
3123

32-
<?php
33-
if(io_get_option('is_search')){include('search-tool.php'); }
34-
else{?>
35-
<div class="no-search"></div>
36-
<?php } ?>
37-
<h4 class="text-gray"><i class="icon-io-tag" style="margin-right: 27px;" id="<?php single_cat_title() ?>"></i><?php single_cat_title() ?></h4>
38-
<div class="row">
39-
<?php if ( have_posts() ) : ?>
40-
<?php while ( have_posts() ) : the_post();
41-
$link_url = get_post_meta($post->ID, '_sites_link', true);
42-
$default_ico = get_theme_file_uri('/images/favicon.png');
43-
if(current_user_can('level_10') || get_post_meta($post->ID, '_visible', true)==""):
44-
?>
45-
<div class="xe-card <?php echo io_get_option('columns') ?> <?php echo get_post_meta($post->ID, '_wechat_qr', true)? 'wechat':''?>">
46-
<?php include( 'templates/site-card.php' ); ?>
47-
</div>
48-
<?php endif; endwhile; endif;?>
49-
</div>
50-
<br />
5124

52-
<div class="posts-nav">
53-
<?php echo paginate_links(array(
54-
'prev_next' => 0,
55-
'before_page_number' => '',
56-
'mid_size' => 2,
57-
));?>
58-
</div>
25+
<div class="container">
26+
<div class="row mt-5 mt-sm-0">
27+
<div class="col-12 mx-auto">
28+
<h1 class="text-gray"><i class="icon-io-tag" style="margin-right: 27px;" id="<?php single_cat_title() ?>"></i><?php single_cat_title() ?></h1>
29+
<div class="panel panel-default">
30+
<div class="cat_list">
31+
<?php if ( have_posts() ) : ?>
32+
<?php while ( have_posts() ) : the_post();?>
33+
<div class="list-content my-3 pb-4">
34+
<h2 class="post-title">
35+
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="list-title text-lg overflowClip_2"><?php the_title(); ?></a>
36+
</h2>
37+
<div class="post-meta d-flex align-items-center text-muted text-xs">
38+
<?php
39+
$category = get_the_category();
40+
if($category[0]){ ?>
41+
<span><i class="fa fa-folder mr-1"></i>
42+
<a href="<?php echo get_category_link($category[0]->term_id ) ?>"><?php echo $category[0]->cat_name ?></a>
43+
</span>
44+
<?php } ?>
45+
<span class="ml-auto"><i class="fa fa-calendar mr-1"></i>
46+
<time class="mx-1"><?php echo get_the_time('Y-m-d G:i') ?></time>
47+
</span>
48+
</div>
49+
<div class="list-desc text-sm text-secondary my-4">
50+
<div class="overflowClip_2 "><?php echo io_get_excerpt(150) ?></div>
51+
</div>
52+
</div>
53+
<?php endwhile; endif;?>
54+
</div>
55+
<div class="posts-nav">
56+
<?php echo paginate_links(array(
57+
'prev_next' => 0,
58+
'before_page_number' => '',
59+
'mid_size' => 2,
60+
));?>
61+
</div>
62+
</div>
63+
</div>
64+
</div>
65+
</div>
5966

6067
<?php get_footer(); ?>

css/nav.css

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

header.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @Author URI: https://www.iowen.cn/
55
* @Date: 2021-02-21 21:26:02
66
* @LastEditors: iowen
7-
* @LastEditTime: 2023-02-20 20:53:39
8-
* @FilePath: \WebStack\header.php
7+
* @LastEditTime: 2024-07-30 19:49:22
8+
* @FilePath: /WebStack/header.php
99
* @Description:
1010
*/
1111
if ( ! defined( 'ABSPATH' ) ) { exit; }
@@ -33,6 +33,6 @@
3333
<link rel="apple-touch-icon" href="<?php echo io_get_option('apple_icon') ?>">
3434
<?php wp_head(); ?>
3535
</head>
36-
<body class="page-body <?php echo io_get_option('theme_mode')?>">
36+
<body <?php body_class('page-body '.io_get_option('theme_mode')) ?>>
3737
<div class="page-container">
3838

inc/fav-content.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
* @Author URI: https://www.iowen.cn/
77
* @Date: 2020-02-22 21:26:05
88
* @LastEditors: iowen
9-
* @LastEditTime: 2023-02-20 20:55:06
10-
* @FilePath: \WebStack\inc\fav-content.php
9+
* @LastEditTime: 2024-07-30 21:51:29
10+
* @FilePath: /WebStack/inc/fav-content.php
1111
* @Description:
1212
*/
1313
if ( ! defined( 'ABSPATH' ) ) { exit; }
14-
function fav_con($mid) { ?>
14+
function fav_con($mid, $visible) { ?>
1515
<h4 class="text-gray" style="display: inline-block;"><i class="icon-io-tag" style="margin-right: 27px;" id="term-<?php echo $mid->term_id; ?>"></i><?php echo $mid->name; ?></h4>
1616
<?php
17+
if($visible == 2){
18+
echo '<div class="login-notice">'.__('此分类需登陆后查看','i_theme').'</div>';
19+
return;
20+
}
1721
$site_n = io_get_option('site_n');
1822
$category_count = $mid->category_count;
1923
$count = $site_n;
@@ -51,7 +55,7 @@ function fav_con($mid) { ?>
5155
elseif ($myposts->have_posts()): while ($myposts->have_posts()): $myposts->the_post();
5256
$link_url = get_post_meta($post->ID, '_sites_link', true);
5357
$default_ico = get_theme_file_uri('/images/favicon.png');
54-
if(current_user_can('level_10') || get_post_meta($post->ID, '_visible', true)==""):
58+
if(io_is_visible( get_post_meta($post->ID, '_visible', true))):
5559
?>
5660
<div class="xe-card <?php echo io_get_option('columns') ?> <?php echo get_post_meta($post->ID, '_wechat_qr', true)? 'wechat':''?>">
5761
<?php include( get_theme_file_path() .'/templates/site-card.php' ); ?>

inc/frame/classes/abstract.class.php

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @version 1.0.0
99
*
1010
*/
11+
#[AllowDynamicProperties]
1112
abstract class CSFramework_Abstract {
1213

1314
public function __construct() {}

inc/frame/config/framework.config.php

+2-9
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* @Author URI: https://www.iowen.cn/
77
* @Date: 2019-02-22 21:26:02
88
* @LastEditors: iowen
9-
* @LastEditTime: 2023-04-24 00:37:18
10-
* @FilePath: \WebStack\inc\frame\config\framework.config.php
9+
* @LastEditTime: 2024-07-30 18:22:23
10+
* @FilePath: /WebStack/inc/frame/config/framework.config.php
1111
* @Description:
1212
*/
1313
if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
@@ -28,13 +28,6 @@
2828
//'framework_title' => '主题设置',
2929
);
3030

31-
// 所有分类ID
32-
$cats_id = '';
33-
$categories = get_categories(array('hide_empty' => 0));
34-
foreach ($categories as $cat) {
35-
$cats_id .= '<span style="margin-right: 15px;">'.$cat->cat_name.' [ '.$cat->cat_ID.' ]</span>';
36-
}
37-
$blog_name = trim(get_bloginfo('name'));
3831

3932
// ---------------------------------------
4033
// 图标 --------------------------------

inc/frame/config/metabox.config.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* @Author URI: https://www.iowen.cn/
77
* @Date: 2021-08-22 19:00:30
88
* @LastEditors: iowen
9-
* @LastEditTime: 2021-08-22 22:27:34
10-
* @FilePath: \WebStack\inc\frame\config\metabox.config.php
9+
* @LastEditTime: 2024-07-30 18:14:07
10+
* @FilePath: /WebStack/inc/frame/config/metabox.config.php
1111
* @Description:
1212
*/
1313
if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
@@ -24,10 +24,16 @@
2424
'name' => 'section_4',
2525
'fields' => array(
2626
array(
27-
'id' => '_visible',
28-
'type' => 'switcher',
29-
'title' => '管理员可见',
30-
'label' => '如果开启,将只有登录管理员账号后才会显示',
27+
'id' => '_visible',
28+
'type' => 'radio',
29+
'title' => '可查看用户',
30+
'class' => 'horizontal',
31+
'options' => array(
32+
'1' => '仅管理员可见',
33+
'2' => '登陆可见',
34+
'0' => '所有人',
35+
),
36+
'default' => '0',
3137
),
3238
array(
3339
"id" => "_sites_link",

inc/frame/config/taxonomy.config.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* @Author URI: https://www.iowen.cn/
77
* @Date: 2021-08-22 19:00:30
88
* @LastEditors: iowen
9-
* @LastEditTime: 2023-02-20 19:24:47
10-
* @FilePath: \WebStack\inc\frame\config\taxonomy.config.php
9+
* @LastEditTime: 2024-07-30 19:27:48
10+
* @FilePath: /WebStack/inc/frame/config/taxonomy.config.php
1111
* @Description:
1212
*/
1313
if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
@@ -23,6 +23,19 @@
2323
'content' => '<h2 style="color: red;">'.__('注意,最多2级,且父级不应有内容','i_theme').'</h2>',
2424
'class' => 'info',
2525
),
26+
array(
27+
'id' => '_view_user',
28+
'type' => 'radio',
29+
'title' => '可查看用户',
30+
'class' => 'horizontal',
31+
'options' => array(
32+
'1' => '仅管理员可见',
33+
'2' => '登陆可见',
34+
'0' => '所有人',
35+
),
36+
'default' => '0',
37+
'after' => '注意:分类下的网址不受此值影响<br />权限跟随父级,如果父级设置为“仅管理员可见”,则子级也只有管理员可见',
38+
),
2639
array(
2740
'id' => '_term_ico',
2841
'type' => 'icon',

inc/inc.php

+107-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* @Author URI: https://www.iowen.cn/
77
* @Date: 2019-02-22 21:26:02
88
* @LastEditors: iowen
9-
* @LastEditTime: 2023-02-20 21:38:08
10-
* @FilePath: \WebStack\inc\inc.php
9+
* @LastEditTime: 2024-07-30 22:06:04
10+
* @FilePath: /WebStack/inc/inc.php
1111
* @Description:
1212
*/
1313
if ( ! defined( 'ABSPATH' ) ) { exit; }
@@ -700,7 +700,112 @@ function io_login_footer(){
700700
</div>';
701701
}
702702

703+
/**
704+
* 获取当前用户的等级
705+
* @return int
706+
*/
707+
function io_get_user_level() {
708+
// 判断有没有登陆
709+
if (is_user_logged_in()) {
710+
// 判断是不是管理员
711+
if (current_user_can('manage_options')) {
712+
return 10;
713+
} else {
714+
return 2;
715+
}
716+
} else {
717+
return 0;
718+
}
719+
}
720+
/**
721+
* 判断是否可见
722+
* @param $val 0所有人 2登录可见 10管理员可见
723+
* @return bool
724+
*/
725+
function io_is_visible($val) {
726+
if (empty($val)) {
727+
$val = 0;
728+
}
729+
if($val == '1'){
730+
$val = 10;
731+
}
732+
$val = intval($val);
733+
$level = io_get_user_level();
734+
735+
if( $level >= $val){
736+
return 1;
737+
}else{
738+
if($level ===0 && $val === 2){
739+
return 2;
740+
}
741+
return 0;
742+
}
743+
}
703744

745+
746+
/**
747+
* 获取简介
748+
* @param int $count
749+
* @param string $meta_key
750+
* @param string $trimmarker
751+
* @return string
752+
*/
753+
function io_get_excerpt($count = 90,$meta_key = '_seo_desc', $trimmarker = '...', $post=''){
754+
if(''===$post){
755+
global $post;
756+
}
757+
$excerpt = '';
758+
if (!($excerpt = get_post_meta($post->ID, $meta_key, true))) {
759+
if (!empty($post->post_excerpt)) {
760+
$excerpt = $post->post_excerpt;
761+
} else {
762+
$excerpt = $post->post_content;
763+
}
764+
}
765+
$excerpt = trim(str_replace(array("\r\n", "\r", "\n", " ", " "), " ", str_replace("\"", "'", strip_tags(strip_shortcodes($excerpt)))));
766+
$excerpt = mb_strimwidth(strip_tags($excerpt), 0, $count, $trimmarker);
767+
return $excerpt;
768+
}
769+
/**
770+
* 获取特色图地址
771+
*/
772+
function io_theme_get_thumb($post = null){
773+
if( $post === null ){
774+
global $post;
775+
}
776+
$post_thumbnail_src = get_post_meta($post->ID, '_thumbnail', true);
777+
if(!empty($post_thumbnail_src)){
778+
return $post_thumbnail_src;
779+
}
780+
if( has_post_thumbnail() ){ //如果有特色缩略图,则输出缩略图地址
781+
$thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'full');
782+
$post_thumbnail_src = $thumbnail_src [0];
783+
} else {
784+
$post_thumbnail_src = '';
785+
$strResult = io_get_post_first_img(true);
786+
if(!empty($strResult[1][0])){
787+
$post_thumbnail_src = $strResult[1][0]; //获取该图片 src
788+
}
789+
}
790+
return $post_thumbnail_src;
791+
}
792+
793+
/**
794+
* 获取/输出缩略图地址
795+
*/
796+
function io_get_post_first_img($is_array = false){
797+
global $post;
798+
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $strResult);
799+
if($is_array)
800+
return $strResult;
801+
else{
802+
if(!empty($strResult[1][0])){
803+
return $strResult[1][0];
804+
}else{
805+
return null;
806+
}
807+
}
808+
}
704809
/**
705810
* 美化Wordpress登录页 By 一为
706811
* 原文地址:https://www.iowen.cn/chundaimameihuawordpressmorendengluye/

0 commit comments

Comments
 (0)