init blog
This commit is contained in:
1 parent
5acc46db8e
commit
843783ce9a
1820 files changed
+539344
No files matched your search
@@ -0,0 +1,92 @@
|
||||
<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
|
||||
<h2 class="title"><a class="slow" href="<?php the_permalink() ?>" title="详细阅读 <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
|
||||
<?php preg_match_all( '/\<img.+?src="(.+?)".*?\/>/',$post->post_content,$matches ,PREG_SET_ORDER); ?>
|
||||
<?php if ( has_post_thumbnail() ) : //特色图片?>
|
||||
<div class="text indextext">
|
||||
<a href="<?php the_permalink(); ?>" class="thumbnail">
|
||||
<?php if ( has_post_thumbnail() ) : //特色图片?>
|
||||
<?php the_post_thumbnail(); ?>
|
||||
<?php else: //无特色图片?>
|
||||
<?php if ( $matches[0][1] ) ://文章内有图片 ?>
|
||||
<img src="<?php echo $matches [0][1];?>" />
|
||||
<?php else : //文章内没有图片?>
|
||||
|
||||
<?php endif;//文章内有图片结束 ?>
|
||||
<?php endif;//特色图片结束 ?>
|
||||
</a>
|
||||
<p>
|
||||
<span><time datetime="<?php the_time('Y/m/d') ?>"><?php the_time('Y/m/d') ?></time></span> |
|
||||
<span>围观:<?php echo guimeng_get_post_views(get_the_ID()); ?>人</span> |
|
||||
<span href="<?php the_permalink() ?>#comment">评论<?php comments_number('', '1人', '%人' );?></span>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
<?php
|
||||
if (has_excerpt()) {
|
||||
the_excerpt();
|
||||
} else {
|
||||
if (!post_password_required()) {
|
||||
echo f_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 100, '...');
|
||||
} else {
|
||||
echo '密码保护文章,暂无摘要!';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php elseif ( $matches[0][1] ) ://文章内有图片 ?>
|
||||
<div class="text indextext">
|
||||
<a href="<?php the_permalink(); ?>" class="thumbnail">
|
||||
<?php if ( has_post_thumbnail() ) : //特色图片?>
|
||||
<?php the_post_thumbnail(); ?>
|
||||
<?php else: //无特色图片?>
|
||||
<?php if ( $matches[0][1] ) ://文章内有图片 ?>
|
||||
<img src="<?php echo $matches [0][1];?>" />
|
||||
<?php else : //文章内没有图片?>
|
||||
|
||||
<?php endif;//文章内有图片结束 ?>
|
||||
<?php endif;//特色图片结束 ?>
|
||||
</a>
|
||||
<p>
|
||||
<span><time datetime="<?php the_time('Y/m/d') ?>"><?php the_time('Y/m/d') ?></time></span> |
|
||||
<span>围观:<?php echo guimeng_get_post_views(get_the_ID()); ?>人</span> |
|
||||
<span href="<?php the_permalink() ?>#comment">评论<?php comments_number('', '1人', '%人' );?></span>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
<?php
|
||||
if (has_excerpt()) {
|
||||
the_excerpt();
|
||||
} else {
|
||||
if (!post_password_required()) {
|
||||
echo f_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 100, '...');
|
||||
} else {
|
||||
echo '密码保护文章,暂无摘要!';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php else: //无特色图片?>
|
||||
<div class="text">
|
||||
<p>
|
||||
<span><time datetime="<?php the_time('Y/m/d') ?>"><?php the_time('Y/m/d') ?></time></span> |
|
||||
<span>围观:<?php echo guimeng_get_post_views(get_the_ID()); ?>人</span> |
|
||||
<span href="<?php the_permalink() ?>#comment">评论<?php comments_number('', '1人', '%人' );?></span>
|
||||
</p>
|
||||
<p>
|
||||
<?php
|
||||
if (has_excerpt()) {
|
||||
the_excerpt();
|
||||
} else {
|
||||
if (!post_password_required()) {
|
||||
echo f_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 100, '...');
|
||||
} else {
|
||||
echo '密码保护文章,暂无摘要!';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif;//特色图片结束 ?>
|
||||
</article>
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* post views
|
||||
*
|
||||
* 浏览量统计
|
||||
*
|
||||
* @since gm_record 1.0.0
|
||||
*
|
||||
* @return views.
|
||||
*/
|
||||
|
||||
function guimeng_set_post_views($postID) {
|
||||
$the_ID = "arc".$postID;
|
||||
if(isset($_SESSION[$the_ID]) || $_SESSION[$the_ID] == 1)
|
||||
return;
|
||||
$_SESSION[$the_ID] = 1;
|
||||
$count_key = 'post_views_count';
|
||||
$count = get_post_meta($postID, $count_key, true);
|
||||
if($count==''){
|
||||
$count = 0;
|
||||
delete_post_meta($postID, $count_key);
|
||||
add_post_meta($postID, $count_key, '1');
|
||||
}else{
|
||||
//administrator的浏览量不统计
|
||||
if(!current_user_can("administrator")){
|
||||
$count++;
|
||||
update_post_meta($postID, $count_key, $count);
|
||||
}
|
||||
}
|
||||
}
|
||||
function guimeng_get_post_views($postID){
|
||||
$count_key = 'post_views_count';
|
||||
$count = get_post_meta($postID, $count_key, true);
|
||||
if($count==''){
|
||||
delete_post_meta($postID, $count_key);
|
||||
add_post_meta($postID, $count_key, '0');
|
||||
return "0";
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
//评论可见
|
||||
function reply($content){
|
||||
if (preg_match_all('/<!--reply start-->([\s\S]*?)<!--reply end-->/i', $content, $hide_words)){
|
||||
$stats = 'hide';
|
||||
global $current_user;
|
||||
get_currentuserinfo();
|
||||
|
||||
if ($current_user->ID) {
|
||||
$email = $current_user->user_email;
|
||||
} else if (isset($_COOKIE['comment_author_email_'.COOKIEHASH])) {
|
||||
$email = $_COOKIE['comment_author_email_'.COOKIEHASH];
|
||||
}
|
||||
|
||||
$ereg = "^[_\.a-z0-9]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,5}$";
|
||||
if (eregi($ereg, $email)) {
|
||||
global $wpdb;
|
||||
global $id;
|
||||
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_author_email = '".$email."' and comment_post_id='".$id."'and comment_approved = '1'");
|
||||
if ($comments) {
|
||||
$stats = 'show';
|
||||
}
|
||||
}
|
||||
|
||||
$admin_email = ""; //博主Email,博主直接查看
|
||||
if ($email == $admin_email) {
|
||||
$stats = 'show';
|
||||
}
|
||||
|
||||
$hide_notice = '<div style="text-align:center;border:1px dashed #FF9A9A;padding:8px;margin:10px auto;color:#FF6666;">温馨提示:此处内容需要<a href="'. get_permalink().'#respond" title="评论本文">评论本文</a>后,<a href="javascript:window.location.reload();" title="刷新">刷新本页</a>才能查看。</div>';
|
||||
if( $stats == 'show' ){
|
||||
$content = str_replace($hide_words[0], $hide_words[1], $content);
|
||||
}else{
|
||||
$content = str_replace($hide_words[0], $hide_notice, $content);
|
||||
}
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
add_filter('the_content', 'reply');
|
||||
|
||||
//音乐播放器
|
||||
function mp3player3($atts, $content=null){
|
||||
extract(shortcode_atts(array("name"=>''),$atts));
|
||||
return '<div class="lrcplay"><div class="statusinfo"><span id="lrcicon-play" class="lrcicon-play"></span>'.$name.'</div><audio id="'.$id.'" src="'.$content.'" name="playerd" class="playerd"></audio></div>';
|
||||
}
|
||||
add_shortcode('mp3','mp3player3'); //mp3可以改成你想设置的其他短代码,只要不冲突即可
|
||||
|
||||
function appthemes_add_quicktags() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//快捷输入一个hr横线,点一下即可 QTags.addButton( 'h3', 'h3', '\n<h3>', '</h3>\n' ); //快捷输入h3标签 QTags.addButton( '[php]', '[php]', '\n[php]', '[/php]\n' ); //快捷输入[php]标签
|
||||
QTags.addButton('音乐播放器','音乐播放器','[mp3][/mp3]','','');
|
||||
QTags.addButton('回复可见','回复可见','<!--reply start--><!--reply end-->','','');
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action('admin_print_footer_scripts', 'appthemes_add_quicktags' );
|
||||
?>
|
||||
<?php
|
||||
if ( !function_exists('wp_new_user_notification') ) {
|
||||
function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
|
||||
$user = new WP_User($user_id);
|
||||
//获取用户名和邮箱
|
||||
$user_login = stripslashes($user->user_login);
|
||||
$user_email = stripslashes($user->user_email);
|
||||
//获取管理员邮箱和博客名称
|
||||
$admin_email = stripslashes(get_option('admin_email'));
|
||||
$blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
||||
//自定义管理员邮件
|
||||
$headers = 'From: '.$blog_name.' <'.$admin_email.'>';
|
||||
$headers .= 'MIME-Version: 1.0';
|
||||
$headers .= 'Content-type: text/html; charset=uft-8';
|
||||
$headers .= 'Content-Transfer-Encoding: 8bit';
|
||||
|
||||
$message = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div>';
|
||||
$message .= '<p>'.sprintf(__('你的网站[%s] 有新用户注册:'), $blog_name ) . '</p>';
|
||||
$message .= '<p>'.sprintf(__('Username: %s'), $user_login) . '</p>';
|
||||
$message .= '<p>'.sprintf(__('E-mail: %s'), $user_email) . '</p></div></body></html>';
|
||||
|
||||
@wp_mail($admin_email, sprintf(__('[%s] New User Registration'), $blog_name), $message, $headers);
|
||||
//判断新用户密码是否为空
|
||||
if ( empty($plaintext_pass) )
|
||||
return;
|
||||
//自定义新用户欢迎邮件
|
||||
$headers = 'From: '.$blog_name.' <'.$admin_email.'>';
|
||||
$headers .= 'MIME-Version: 1.0';
|
||||
$headers .= 'Content-type: text/html; charset=uft-8';
|
||||
$headers .= 'Content-Transfer-Encoding: 8bit';
|
||||
|
||||
$message = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div>';
|
||||
$message .= '<p>'.__('亲爱的:') .$user_login. '</p>';
|
||||
$message .= '<p>恭喜您今天正式成为教室的一员,我们已经展开热情的怀抱欢迎你。</p>';
|
||||
$message .= '<p>您的账号信息如下:</p>';
|
||||
$message .= '<p>'.sprintf(__('Username: %s'), $user_login) . '</p>';
|
||||
$message .= '<p>'.sprintf(__('Password: %s'), $plaintext_pass) . '</p>';
|
||||
$message .= '<p>请妥善保存好自己的账户信息,如果您忘记密码,可以通过登录窗口的密码找回功能找回密码。</p>';
|
||||
$message .= '</div></body></html>';
|
||||
|
||||
@wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blog_name), $message , $headers);
|
||||
|
||||
}
|
||||
//让邮件支持html
|
||||
add_filter( 'wp_mail_content_type', 'wpdx_set_html_content_type' );
|
||||
function wpdx_set_html_content_type() {
|
||||
return 'text/html';
|
||||
}
|
||||
}
|
||||
//官方Gravatar头像调用
|
||||
function mytheme_get_avatar($avatar) {
|
||||
$avatar = str_replace(array("www.gravatar.com","0.gravatar.com","1.gravatar.com","2.gravatar.com"),"secure.gravatar.com",$avatar);
|
||||
return $avatar;
|
||||
}
|
||||
add_filter( 'get_avatar', 'mytheme_get_avatar', 10, 3 );
|
||||
|
||||
function f_strimwidth($str ,$start , $width ,$trimmarker ){
|
||||
$output = preg_replace('/^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$start.'}((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$width.'}).*/s','\1',$str);
|
||||
return $output.$trimmarker;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php guimeng_set_post_views(get_the_ID()); ?>
|
||||
<div class="content">
|
||||
<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
|
||||
<h2 class="title"><a class="slow" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a><span class="edit"><?php edit_post_link();?></span></h2>
|
||||
<ul class="text">
|
||||
<?php the_content(); ?>
|
||||
<?php if(is_single){ ?><p class="zhuanzai">转载请注明:<a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a> » <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></p><?php } ?>
|
||||
<div class="post-like">
|
||||
<a href="javascript:;" data-action="ding" data-id="<?php the_ID(); ?>" class="favorite<?php if(isset($_COOKIE['bigfa_ding_'.$post->ID])) echo ' done';?>">喜欢 <span class="count">
|
||||
<?php if( get_post_meta($post->ID,'bigfa_ding',true) ){
|
||||
echo get_post_meta($post->ID,'bigfa_ding',true);
|
||||
} else {
|
||||
echo '0';
|
||||
}?></span>
|
||||
</a>
|
||||
</div>
|
||||
</ul>
|
||||
<div class="textfoot">
|
||||
<span><?php the_tags('标签:', ', ', ''); ?></span><span>分类:<?php the_category(', ');?></span>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
Reference in new issue
Block a user