forked from owen0o0/WebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
single-sites.php
158 lines (142 loc) · 8.31 KB
/
single-sites.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
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
get_header(); ?>
<?php
$categories= get_categories(array(
'taxonomy' => 'favorites',
'meta_key' => '_term_order',
'orderby' => 'meta_value_num',
'order' => 'desc',
'hide_empty' => 0,
)
);
include( 'templates/header-nav.php' );
?>
<div class="main-content page">
<?php include( 'templates/header-banner.php' ); ?>
<div class="container">
<div class="row mt-5 mt-sm-0">
<div class="col-12 mx-auto">
<div class="panel panel-default">
<div class="panel-body my-4 ">
<?php while( have_posts() ): the_post();?>
<div class="row">
<div class="col-12 col-sm-4 col-lg-3">
<?php
$m_link_url = get_post_meta($post->ID, '_sites_link', true);
$m_thumbnail = get_post_meta(get_the_ID(), '_thumbnail', true);
if($m_thumbnail == '' && $m_link_url == '')
$imgurl = get_template_directory_uri() .'/images/favicon.png';
else
$imgurl = $m_thumbnail? $m_thumbnail : (io_get_option('ico_url') .format_url($m_link_url) . io_get_option('ico_png'));
$sitetitle = get_the_title();
?>
<div class="siteico">
<div class="blur blur-layer" style="background: transparent url(<?php echo $imgurl ?>) no-repeat center center;-webkit-background-size: cover;-moz-background-size: cover;-o-background-size: cover;background-size: cover;"></div>
<img class="img-cover" src="<?php echo $imgurl ?>" alt="<?php echo $sitetitle ?>" title="<?php echo $sitetitle ?>">
</div>
</div>
<div class="col-12 col-sm-8 col-lg-5 mt-4 mt-md-0">
<div class="site-body p-xl-4">
<?php
$terms = get_the_terms( get_the_ID(), 'favorites' );
if( !empty( $terms ) ){
foreach( $terms as $term ){
$name = $term->name;
$link = esc_url( get_term_link( $term, 'res_category' ) );
echo " <a class='btn-cat' href='$link'>".$name."</a>";
}
}
?>
<div class="site-name h3"><?php echo $sitetitle ?></div>
<div class="mt-2">
<p><?php echo get_post_meta(get_the_ID(), '_sites_sescribe', true) ?></p>
<?php
$m_post_link_url = $m_link_url ?: get_permalink($post->ID);
$qrname = "手机查看";
$qrurl = "https://api.pwmqr.com/qrcode/create/?url=".$m_post_link_url;
?>
<div class="site-go mt-3">
<?php if($m_link_url!=""): ?>
<a style="margin-right: 10px;" href="<?php echo io_get_option('is_go')? home_url().'/go/?url='.base64_encode($m_link_url) : $m_link_url ?>" title="<?php echo $sitetitle ?>" target="_blank" class="btn btn-arrow">
<span>链接直达<i class="fa fa-angle-right"></i>
</span>
</a>
<?php endif; ?>
<a style="margin-right: 10px;" href="javascript:" class="btn btn-arrow" data-toggle="tooltip" data-placement="bottom" title="" data-html="true" data-original-title="<img src='<?php echo $qrurl ?>' width='150'>">
<span><?php echo $qrname ?><i class="fa fa-qrcode"></i>
</span>
</a>
<a class="btn btn-arrow">
<span style="padding-right: 0px;"><?php the_views();?>
</span>
</a>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-12 col-lg-4 mt-4 mt-lg-0">
<?php if(io_get_option('ad_right_s')) echo '<div class="ad ad-right">' . stripslashes( io_get_option('ad_right') ) . '</div>'; ?>
</div>
</div>
<div class="mt-4 pt-4 border-top">
<?php
$contentinfo = get_the_content();
if( $contentinfo ){
the_content();
}else{
echo get_post_meta(get_the_ID(), '_sites_sescribe', true);
}
?>
</div>
<?php endwhile; ?>
</div>
<?php edit_post_link(__('编辑','i_owen'), '<span class="edit-link">', '</span>' ); ?>
</div>
<h4 class="text-gray mt-4"><i class="icon-io-tag" style="margin-right: 27px;" id="相关导航"></i>相关导航</h4>
<div class="row" style="margin-bottom: 8.5rem;">
<?php
$post_num = 6;
$i = 0;
if ($i < $post_num) {
$custom_taxterms = wp_get_object_terms( $post->ID,'favorites', array('fields' => 'ids') );
$args = array(
'post_type' => 'sites',// 文章类型
'post_status' => 'publish',
'posts_per_page' => 6, // 文章数量
'orderby' => 'rand', // 随机排序
'tax_query' => array(
array(
'taxonomy' => 'favorites', // 分类法
'field' => 'id',
'terms' => $custom_taxterms
)
),
'post__not_in' => array ($post->ID), // 排除当前文章
);
$related_items = new WP_Query( $args );
if ($related_items->have_posts()) :
while ( $related_items->have_posts() ) : $related_items->the_post();
$link_url = get_post_meta($post->ID, '_sites_link', true);
$default_ico = get_template_directory_uri() .'/images/favicon.png';
if(current_user_can('level_10') || get_post_meta($post->ID, '_visible', true)!="true"):
?>
<div class="xe-card col-sm-6 col-md-4 <?php echo get_post_meta($post->ID, '_wechat_qr', true)? 'wechat':''?>">
<?php include( 'templates/site-card.php' ); ?>
</div>
<?php endif; $i++; endwhile; endif; wp_reset_postdata();
}
if ($i == 0) echo '<div class="col-lg-12"><div class="nothing">没有相关内容!</div></div>';
?>
</div>
<?php
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
?>
<br />
</div>
<?php if(io_get_option('ad_footer_s')) echo '<div class="ad ad-footer">' . stripslashes( io_get_option('ad_footer') ) . '</div>'; ?>
</div>
</div>
<?php get_footer(); ?>