<?php
header("Content-type: text/html; charset=utf-8");
// 定义目录常量
define('THEME_FUNCTIONS', TEMPLATEPATH . '/includes/functions');
define('THEME_IMAGES', get_template_directory_uri() . '/images' );
//用户资料添加自定义用户头像功能
require_once(THEME_FUNCTIONS . '/simple-local-avatars.php');
// 去除头部不必要信息
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
// 后台登陆LOGO修改
function custom_login_logo() {
echo "<link rel='stylesheet' id='colors-fresh-css' href='".get_bloginfo("template_url")."/includes/admin_style.css' type='text/css' media='all' />";
//$ranum=rand(1,10);
//echo "<style>body.login{background:url(".get_bloginfo("template_url")."/images/login_bg".$ranum.".jpg) top center fixed;}</style>";
}
add_action('login_head', 'custom_login_logo');
//关闭前台显示管理工具条
show_admin_bar(false);
//友情链接
add_filter( 'pre_option_link_manager_enabled', '__return_true' );
//主题自定义菜单
register_nav_menus(
array(
'lefter-menu' => __( '左侧导航' )
)
);
//密码保护提示
function password_hint( $c ){
global $post, $user_ID, $user_identity;
if ( empty($post->post_password) )
return $c;
if ( isset($_COOKIE['wp-postpass_'.COOKIEHASH]) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) == $post->post_password )
return $c;
if($hint = get_post_meta($post->ID, 'password_hint', true)){
$url = get_option('siteurl').'/wp-pass.php';
if($hint)
$hint = '密码提示:'.$hint;
else
$hint = "请输入您的密码";
if($user_ID)
$hint .= sprintf('欢迎进入,您的密码是:', $user_identity, $post->post_password);
$out = <<<END
<form method="post" action="$url">
<p>这篇文章是受保护的文章,请输入密码继续阅读:</p>
<div>
<label>$hint<br/>
<input type="password" name="post_password"/></label>
<input type="submit" value="Submit" name="Submit"/>
</div>
</form>
END;
return $out;
}else{
return $c;
}
}
add_filter('the_content', 'password_hint');
//文章归档页面
function shejiwo_archives_list() {
if( !$output = get_option('shejiwo_archives_list') ){
$output = '<div id="archives"><p>[<a id="al_expand_collapse" href="#">全部展开/收缩</a>] <em>(注: 点击月份可以展开)</em></p>';
$the_query = new WP_Query( 'posts_per_page=-1&ignore_sticky_posts=1' ); //update: 加上忽略置顶文章
$year=0; $mon=0; $i=0; $j=0;
while ( $the_query->have_posts() ) : $the_query->the_post();
$year_tmp = get_the_time('Y');
$mon_tmp = get_the_time('m');
$y=$year; $m=$mon;
if ($mon != $mon_tmp && $mon > 0) $output .= '</ul></li>';
if ($year != $year_tmp && $year > 0) $output .= '</ul>';
if ($year != $year_tmp) {
$year = $year_tmp;
$output .= '<h3 class="al_year">'. $year .' 年</h3><ul class="al_mon_list">'; //输出年份
}
if ($mon != $mon_tmp) {
$mon = $mon_tmp;
$output .= '<li><span class="al_mon">'. $mon .' 月</span><ul class="al_post_list">'; //输出月份
}
$output .= '<li>'. get_the_time('d日: ') .'<a href="'. get_permalink() .'">'. get_the_title() .'</a> <em>('. get_comments_number('0', '1', '%') .')</em></li>'; //输出文章日期和标题
endwhile;
wp_reset_postdata();
$output .= '</ul></li></ul></div>';
update_option('shejiwo_archives_list', $output);
}
echo $output;
}
function clear_zal_cache() {
update_option('shejiwo_archives_list', ''); // 清空 zww_archives_list
}
add_action('save_post', 'clear_zal_cache'); // 新发表文章/修改文章时
//为WordPress添加自定义域可视化面板
//创建需要的字段信息
$new_meta_boxes =
array(
"keywords" => array(
"name" => "keywords",
"std" => "",
"title" => "关键字",
"style" => "textarea"),
"description" => array(
"name" => "description",
"std" => "",
"title" => "网页描述",
"style" => "textarea"
)
);
//创建自定义字段输入框
function new_meta_boxes() {
global $post, $new_meta_boxes;?><table width="100%" border="0" cellspacing="0" cellpadding="5" style="font-family: 微软雅黑; font-size:14px;"><style>.the_text{ line-height:20px;font-size:14px; padding-right:6px;}</style><?php foreach($new_meta_boxes as $meta_box) {
$meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);
echo "<tr>";if($meta_box_value == "")$meta_box_value = $meta_box['std'];
echo '<td width="150" align="right" valign="top">';
echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';
echo'<label for="'.$meta_box['name'].'_value"><h4 style="font-size:14px;font-weight:200;padding:2px 2px; margin:0;font-family: 微软雅黑;">'.$meta_box['title'].':</h4></label>';
echo '</td><td align="left" valign="top" style="padding:2px 2px;">';
if($meta_box['style']=='textarea'){
echo '<textarea cols="70" rows="3" name="'.$meta_box['name'].'_value" id="'.$meta_box['name'].'_value">'.$meta_box_value.'</textarea>';
}elseif($meta_box['style']=='input'){
echo '<input name="'.$meta_box['name'].'_value" id="'.$meta_box['name'].'_value" type="text" value="'.$meta_box_value.'" size="70" placeholder="'.$meta_box['placeholder'].'" class="the_text">';
}elseif($meta_box['style']=='input2'){
echo '<input name="'.$meta_box['name'].'_value" id="'.$meta_box['name'].'_value" type="text" value="'.$meta_box_value.'" size="50" placeholder="'.$meta_box['placeholder'].'" class="the_text">';
}elseif($meta_box['style']=='input3'){
echo '<input name="'.$meta_box['name'].'_value" id="'.$meta_box['name'].'_value" type="text" value="'.$meta_box_value.'" size="20" placeholder="'.$meta_box['placeholder'].'" class="the_text">';
}elseif($meta_box['style']=='checkbox'){
?><input name="<?php echo $meta_box['name'].'_value';?>" id="<?php echo $meta_box['name'].'_value';?>" type="checkbox" <?php if($meta_box_value){echo 'checked';}?> style="height:26px;line-height:26px;"><?php
}if($meta_box['points']){echo '<span style="font-size:12px; color:#999;display:block;padding:2px 0px;">'.$meta_box['points'].'</span>';}echo '</td>';} echo '</tr></table>';}
//创建自定义字段模块
function create_meta_box() {
global $theme_name;
if ( function_exists('add_meta_box') ) {
add_meta_box( 'new-meta-boxes', '文章参数设置', 'new_meta_boxes', 'post', 'normal', 'high' );
}
}
//保存文章数据
function save_postdata( $post_id ){
global $post, $new_meta_boxes;
foreach($new_meta_boxes as $meta_box) {
if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) {
return $post_id;
}
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ))
return $post_id;
}
else {
if ( !current_user_can( 'edit_post', $post_id ))
return $post_id;
}
$data = $_POST[$meta_box['name'].'_value'];
if(get_post_meta($post_id, $meta_box['name'].'_value') == "")
add_post_meta($post_id, $meta_box['name'].'_value', $data, true);
elseif($data != get_post_meta($post_id, $meta_box['name'].'_value', true))
update_post_meta($post_id, $meta_box['name'].'_value', $data);
elseif($data == "")
delete_post_meta($post_id, $meta_box['name'].'_value', get_post_meta($post_id, $meta_box['name'].'_value', true));
没有合适的资源?快使用搜索试试~ 我知道了~
wp个人博客Personal2主题是一款简洁大方,质感十足,可用于个人图片展示,摄影等.rar
共38个文件
php:16个
js:6个
jpg:6个
需积分: 0 0 下载量 46 浏览量
2023-09-10
11:00:20
上传
评论
收藏 142KB RAR 举报
温馨提示
html
资源推荐
资源详情
资源评论
收起资源包目录
wp个人博客Personal2主题是一款简洁大方,质感十足,可用于个人图片展示,摄影等.rar (38个子文件)
style.css 9KB
simple-local-avatars.php 12KB
aout_cion01.gif 49B
clock.jpg 1KB
page.php 767B
header.php 3KB
page-nocomm.php 730B
login-logo.png 53KB
jquery-1.6.4.min.js 90KB
top_ico.jpg 13KB
top_ico2.jpg 13KB
ico.png 3KB
jquery.vegas.min.js 4KB
menu_ico1.jpg 13KB
page-book.php 812B
admin_style.css 1KB
footer.php 62B
button-search.png 64KB
reset.css 1KB
screenshot.png 4KB
single.php 2KB
page-archives.php 626B
post_mata_bg.jpg 1KB
index.php 592B
archive.php 1KB
404.php 552B
search.php 826B
m_post.php 1KB
personal2.js 2KB
the_head.php 1KB
functions.php 13KB
banner.js 2KB
nopic.gif 1KB
jquery.lazyload.js 6KB
page-link.php 698B
shejiwo.to.top.min.js 1KB
comment.gif 1KB
menu_ico2.jpg 13KB
共 38 条
- 1
资源评论
Q_97095639
- 粉丝: 373
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功