<?php
//禁止自动保存草稿和修订版本 [开始]
remove_action('pre_post_update', 'wp_save_post_revision' );
add_action( 'wp_print_scripts', 'disable_autosave' );
function disable_autosave() {
wp_deregister_script('autosave');
}
//禁止自动保存草稿和修订版本 [结束]
function tangstyle_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'tangstyle_page_menu_args' );
function tangstyle_widgets_init() {
register_sidebar(array(
'name' => '首页侧栏',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => '分类页侧栏',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => '内容页侧栏',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
}
add_action( 'widgets_init', 'tangstyle_widgets_init' );
if ( ! function_exists( 'tangstyle_content_nav' ) ) :
register_nav_menus(array('header-menu' => __( 'TangStyle导航菜单' ),));
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 200, 150 );
//评论模板
function tangstyle_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
<p><?php _e( 'Pingback:', 'tangstyle' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'tangstyle' ), '<span class="edit-link">', '</span>' ); ?></p>
<?php
break;
default :
// Proceed with normal comments.
global $post;
?>
<li id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="avatar"><?php echo get_avatar( $comment, 40 );?></div>
<div class="comment">
<div class="comment_meta">
<?php printf(__('<cite>%s</cite>'), get_comment_author_link()) ?>
<span class="time"><?php printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></span>
<span class="reply"><?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( '回复', 'tangstyle' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?></span>
<?php edit_comment_link( __( '编辑', 'tangstyle' ), '<span class="edit_link">', '</span>' ); ?>
</div>
<?php comment_text(); ?>
<?php if ( '0' == $comment->comment_approved ) : ?><p style="color:#F00;"><?php _e( '您的评论正在等待审核。', 'tangstyle' ); ?></p><?php endif; ?>
</div>
</div>
<?php
break;
endswitch; // end comment_type check
}
endif;
// 获得热评文章
function tangstyle_get_most_viewed($posts_num=10, $days=180){
global $wpdb;
$sql = "SELECT ID , post_title , comment_count FROM $wpdb->posts WHERE post_type = 'post' AND TO_DAYS(now()) - TO_DAYS(post_date) < $days AND ($wpdb->posts.`post_status` = 'publish' OR $wpdb->posts.`post_status` = 'inherit') ORDER BY comment_count DESC LIMIT 0 , $posts_num ";
$posts = $wpdb->get_results($sql);
$output = "";
foreach ($posts as $post){
$output .= "\n<li><a href= \"".get_permalink($post->ID)."\" title=\"".$post->post_title."\" >".$post->post_title."</a></li>";
}
echo $output;
}
//分页
function pagination($query_string){
global $posts_per_page, $paged;
$my_query = new WP_Query($query_string ."&posts_per_page=-1");
$total_posts = $my_query->post_count;
if(empty($paged))$paged = 1;
$prev = $paged - 1;
$next = $paged + 1;
$range = 5; // 分页数设置
$showitems = ($range * 2)+1;
$pages = ceil($total_posts/$posts_per_page);
if(1 != $pages){
echo "<div class='pagination'>";
echo ($paged > 2 && $paged+$range+1 > $pages && $showitems < $pages)? "<a href='".get_pagenum_link(1)."' class='fir_las'>最前</a>":"";
echo ($paged > 1 && $showitems < $pages)? "<a href='".get_pagenum_link($prev)."' class='page_previous'>« 上一页</a>":"";
for ($i=1; $i <= $pages; $i++){
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )){
echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
}
}
echo ($paged < $pages && $showitems < $pages) ? "<a href='".get_pagenum_link($next)."' class='page_next'>下一页 »</a>" :"";
echo ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) ? "<a href='".get_pagenum_link($pages)."' class='fir_las'>最后</a>":"";
echo "</div>\n";
}
}
//彩色标签云
function colorCloud($text) {
$text = preg_replace_callback('|<a (.+?)>|i', 'colorCloudCallback', $text);
return $text;
}
function colorCloudCallback($matches) {
$text = $matches[1];
$color = dechex(rand(0,16777215));
$pattern = '/style=(\'|\")(.*)(\'|\")/i';
$text = preg_replace($pattern, "style=\"color:#{$color};$2;\"", $text);
return "<a $text>";
}
add_filter('wp_tag_cloud', 'colorCloud', 1);
//新窗口打开评论里的链接
function remove_comment_links() {
global $comment;
$url = get_comment_author_url();
$author = get_comment_author();
if ( empty( $url ) || 'http://' == $url )
$return = $author;
else
$return = "<a href='$url' rel='external nofollow' target='_blank'>$author</a>";
return $return;
}
add_filter('get_comment_author_link', 'remove_comment_links');
remove_filter('comment_text', 'make_clickable', 9);
//移除WordPress版本号
function wpbeginner_remove_version() {
return '';
}
add_filter('the_generator', 'wpbeginner_remove_version');
// 评论回应邮件通知
function comment_mail_notify($comment_id) {
$admin_email = get_bloginfo ('admin_email'); // $admin_email 可改为你指定的 e-mail.
$comment = get_comment($comment_id);
$comment_author_email = trim($comment->comment_author_email);
$parent_id = $comment->comment_parent ? $comment->comment_parent : '';
$to = $parent_id ? trim(get_comment($parent_id)->comment_author_email) : '';
$spam_confirmed = $comment->comment_approved;
if (($parent_id != '') && ($spam_confirmed != 'spam') && ($to != $admin_email) && ($comment_author_email == $admin_email)) {
$wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); // no-reply 可改为可用的 e-mail.
$subject = '您在 [' . get_option("blogname") . '] 的评论有新的回复';
$message = '
<div style="background-color:#eef2fa; border:1px solid #d8e3e8; color:#111; padding:0 15px; -moz-border-radius:5px; -webkit-border-radius:5px; -khtml-border-radius:5px; border-radius:5px;">
<p>' . trim(get_comment($parent_id)->comment_author) . ', 您好!</p>
<p>您曾在 [' . get_option("blogname") . '] 的文章 《' . get_the_title($comment->comment_post_ID) . '》 上发表评论:<br />'
. nl2br(get_comment($parent_id)->comment_content) . '</p>
<p>' . trim($comment->comment_author) . ' 给您的回复如下:<br />'
. nl2br($comment->comment_content) . '<br /></p>
<p>您可以点击 <a href="' . htmlspecialchars(get_comment_link($parent_id)) . '">查看回复的完整內容</a></p>
<p>欢迎再次光临 <a href="' . get_option('home') . '">' . get_option('blogname') . '</a></p>
<p>(此邮件由系统自动发出,请勿直接回复.)</p>
</div>';
$message = convert_smilies($message);
$from = "From: \"" . get_option('blogname') . "\" <$wp_email>";
$headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n";
wp_mail( $to, $subject, $message, $headers );
//echo 'mail to ', $to, '<br/> ' , $subject, $message; // for testing
}
}
add_action('comment_post', 'comment_mail_notify');
?>
<?php
$themename = "TangStyle";
$shortname = "tang";
$options = a
没有合适的资源?快使用搜索试试~ 我知道了~
完美支持自适应电脑、平板电脑、移动设备,图标字体库,自适应各种终端设备,保证图形图标清晰无锯齿,支持Retina.rar
共31个文件
php:14个
png:5个
woff:2个
需积分: 0 0 下载量 10 浏览量
2023-09-10
11:00:21
上传
评论
收藏 258KB RAR 举报
温馨提示
html
资源推荐
资源详情
资源评论
收起资源包目录
wp简洁tangstyle主题是一款适合做SEO博客,设计简洁,完美支持自适应电脑、平板电脑、移动设备,图标字体库,自适应各种终端设备,保证图形图标清晰无锯齿,支持Retina.rar (31个子文件)
tang.ttf 8KB
style.css 12KB
page.php 423B
404.png 73KB
header.php 5KB
sidebar.php 3KB
tang.eot 8KB
tang.svg 8KB
._tang.ttf 4KB
theme.js 3KB
footer.php 1KB
._tang.woff 4KB
screenshot.png 49KB
single.php 2KB
._favicon.ico 4KB
category.php 1KB
index.php 2KB
archive.php 2KB
bg.png 66KB
._tang.eot 4KB
404.php 181B
search.php 990B
._404.png 4KB
comments.php 909B
functions.php 15KB
tang.woff 5KB
sidebar-single.php 2KB
._bg.png 4KB
._tang.svg 4KB
jquery.min.js 92KB
sidebar-category.php 1KB
共 31 条
- 1
资源评论
Q_97095639
- 粉丝: 377
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功