<?php
function wt_get_user_id(){
global $userdata;
get_currentuserinfo();
return $userdata->ID;
}
add_filter( 'show_admin_bar', '__return_false' );
require_once(TEMPLATEPATH . '/control.php');
//自定义域
$new_meta_boxes =
array(
"fmimg" => array(
"name" => "fmimg",
"std" => "",
"title" => "封面图片地址:"),
);
function new_meta_boxes() {
global $post, $new_meta_boxes;
foreach($new_meta_boxes as $meta_box) {
$meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);
if($meta_box_value == "")
$meta_box_value = $meta_box['std'];
echo'<style>.inside {overflow:hidden}</style><div style=" width:350px; float:left;"><input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';
// 自定义字段标题
echo'<h4>'.$meta_box['title'].'</h4>';
// 自定义字段输入框
echo '<textarea cols="45" rows="1" name="'.$meta_box['name'].'_value">'.$meta_box_value.'</textarea><br /></div>';
}
}
function create_meta_box() {
global $theme_name;
if ( function_exists('add_meta_box') ) {
add_meta_box( 'new-meta-boxes', '上边都690', '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));
}
}
add_action('admin_menu', 'create_meta_box');
add_action('save_post', 'save_postdata');
//分页工具
function par_pagenavi($range = 9){
// $paged - number of the current page
global $paged, $wp_query;
// How much pages do we have?
if ( !$max_page ) {
$max_page = $wp_query->max_num_pages;
}
// We need the pagination only if there are more than 1 page
if($max_page > 1){
if(!$paged){
$paged = 1;
}
echo '';
// On the first page, don't put the First page link
echo "<li><a href='" . get_pagenum_link(1) . "' class='extend' title='最前一页'>«</a></li>";
// To the previous page
echo "<li>";
previous_posts_link('‹');
echo "</li>";
// We need the sliding effect only if there are more pages than is the sliding range
if($max_page > $range){
// When closer to the beginning
if($paged < $range){
for($i = 1; $i <= ($range + 1); $i++){
if($i==$paged) echo "<li class='active'><a>$i</a></li>";
else echo "<li><a href='" . get_pagenum_link($i) ."'>$i</a></li>";
}
}
// When closer to the end
elseif($paged >= ($max_page - ceil(($range/2)))){
for($i = $max_page - $range; $i <= $max_page; $i++){
if($i==$paged) echo "<li class='active'><a>$i</a></li>";
else echo "<li><a href='" . get_pagenum_link($i) ."'>$i</a></li>";
}
}
// Somewhere in the middle
elseif($paged >= $range && $paged < ($max_page - ceil(($range/2)))){
for($i = ($paged - ceil($range/2)); $i <= ($paged + ceil(($range/2))); $i++){
if($i==$paged) echo "<li class='active'><a>$i</a></li>";
else echo "<li><a href='" . get_pagenum_link($i) ."'>$i</a></li>";
}
}
}
// Less pages than the range, no sliding effect needed
else{
for($i = 1; $i <= $max_page; $i++){
if($i==$paged) echo "<li class='active'><a>$i</a></li>";
else echo "<li><a href='" . get_pagenum_link($i) ."'>$i</a></li>";
}
}
// Next page
echo "<li>";
next_posts_link('›');
echo "</li>";
// On the last page, don't put the Last page link
echo "<li><a href='" . get_pagenum_link($max_page) . "' class='extend' title='最后一页'>»</a></li>";
}
}
register_nav_menus(
array(
'nav-menu' => __( '主导航' )
)
);
add_theme_support( 'post-thumbnails' );
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$popimg=get_option( 'mao10_popimg');
$first_img = "$popimg";
}
return $first_img;
}
function img() {
$fmimg = get_post_meta($post->ID, "fmimg_value", true);
$cti = catch_that_image();
if($fmimg) {
$showimg = $fmimg;
} else {
$showimg = $cti;
};
has_post_thumbnail();
if ( has_post_thumbnail() ) {
$thumbnail_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
$shareimg = $thumbnail_image_url[0];
} else {
$shareimg = $showimg;
};
return $shareimg;
}
//浏览统计
function getPostViews($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 setPostViews($postID) {
$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, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
//评论
function cleanr_theme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<div <?php comment_class('media'); ?> id="li-comment-<?php comment_ID() ?>">
<a class="pull-left" href="#">
<?php echo get_avatar($comment,$size='50',$default='' ); ?>
</a>
<div class="media-body">
<h5 class="media-heading">
<?php printf(__('%s'), get_comment_author_link()) ?>
<small class="pull-right"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></small>
</h5>
<?php comment_text() ?>
<?php comment_reply_link(array_merge( $args, array('reply_text' => '回复', 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
</div>
</div>
<?php } ?>
没有合适的资源?快使用搜索试试~ 我知道了~
基于PHP的wordpress 灰色主题.zip
共29个文件
php:11个
js:6个
css:5个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 132 浏览量
2023-07-23
00:34:27
上传
评论
收藏 348KB ZIP 举报
温馨提示
基于PHP的wordpress 灰色主题.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于PHP的wordpress 灰色主题.zip (29个子文件)
132676267007373890
Gray
style.css 6KB
page.php 48B
header.php 3KB
js
html5shiv.min.js 2KB
bootstrap.min.js 27KB
cat.js 2KB
respond.min.js 4KB
1.js 0B
jquery.min.js 91KB
control.php 6KB
footer.php 1KB
screenshot.png 7KB
img
logo.png 3KB
1.jpg 158KB
single.php 2KB
css
bootstrap.min.css 97KB
media.css 402B
bootstrap-old.css 120KB
bootstrap.css 125KB
index.php 2KB
archive.php 1KB
404.php 48B
search.php 1KB
comments.php 3KB
functions.php 7KB
fonts
glyphicons-halflings-regular.svg 61KB
glyphicons-halflings-regular.ttf 40KB
glyphicons-halflings-regular.woff 23KB
glyphicons-halflings-regular.eot 20KB
__MACOSX
Gray
js
img
css
fonts
共 29 条
- 1
资源评论
助力毕业
- 粉丝: 2177
- 资源: 5130
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功