__('网站导航'), 'pagemenu' => __('页面导航') )); } } /* short code [] 短代码 1边栏,2评论,3摘要 */ add_filter('widget_text','do_shortcode'); add_filter('comment_text','do_shortcode'); add_filter('the_excerpt','do_shortcode'); if (function_exists('register_sidebar')){ register_sidebar(array( 'name' => '全站侧栏', 'id' => 'widget_sitesidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); register_sidebar(array( 'name' => '首页侧栏', 'id' => 'widget_sidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); register_sidebar(array( 'name' => '分类/标签/搜索页侧栏', 'id' => 'widget_othersidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); register_sidebar(array( 'name' => '文章页侧栏', 'id' => 'widget_postsidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); register_sidebar(array( 'name' => '页面侧栏', 'id' => 'widget_pagesidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } //修改默认发信地址 function f_res_from_email($email) { $wp_from_email = get_option('admin_email'); return $wp_from_email; } function f_res_from_name($email){ $wp_from_name = get_option('blogname'); return $wp_from_name; } //邮件回复 function comment_mail_notify($comment_id) { $admin_notify = '1'; $admin_email = get_bloginfo ('admin_email'); $comment = get_comment($comment_id); $comment_author_email = trim($comment->comment_author_email); $parent_id = $comment->comment_parent ? $comment->comment_parent : ''; global $wpdb; if ($wpdb->query("Describe {$wpdb->comments} comment_mail_notify") == '') $wpdb->query("ALTER TABLE {$wpdb->comments} ADD COLUMN comment_mail_notify TINYINT NOT NULL DEFAULT 0;"); if (($comment_author_email != $admin_email && isset($_POST['comment_mail_notify'])) || ($comment_author_email == $admin_email && $admin_notify == '1')) $wpdb->query("UPDATE {$wpdb->comments} SET comment_mail_notify='1' WHERE comment_ID='$comment_id'"); $notify = $parent_id ? '1' : '0'; $spam_confirmed = $comment->comment_approved; if ($parent_id != '' && $spam_confirmed != 'spam' && $notify == '1') { $wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); $to = trim(get_comment($parent_id)->comment_author_email); $subject = '你在' . get_option("blogname") . '被关注啦~'; $message = '
你在⌈ '. get_the_title($comment->comment_post_ID) .' ⌋的评论有了回复:
'. trim(get_comment($parent_id)->comment_author) .':'. trim(get_comment($parent_id)->comment_content) .'
'. trim($comment->comment_author) .':'. trim($comment->comment_content) .'

点击查看完整内容

(此邮件由系统发出,无需回复.)

'; $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 ); } } add_action('comment_post', 'comment_mail_notify'); //分页 if ( !function_exists('pagenavi') ) { function pagenavi( $p = 2 ) { // 取当前页前后各 2 页 if ( is_singular() ) return; // 文章与插页不用 global $wp_query, $paged; $max_page = $wp_query->max_num_pages; if ( $max_page == 1 ) return; // 只有一页不用 if ( empty( $paged ) ) $paged = 1; echo '' . $paged . '/' . $max_page . ' '; // 显示页数 if ( $paged > $p + 1 ) p_link( 1, '最前页', '«'); if ( $paged > 1 ) p_link( $paged - 1, '上一页', '‹' );/* 如果当前页大于1就显示上一页链接 */ if ( $paged > $p + 2 ) echo '... '; for( $i = $paged - $p; $i <= $paged + $p; $i++ ) { // 中间页 if ( $i > 0 && $i <= $max_page ) $i == $paged ? print "{$i} " : p_link( $i ); } if ( $paged < $max_page - $p - 1 ) echo '...'; if ( $paged < $max_page ) p_link( $paged + 1,'下一页', '›' );/* 如果当前页不是最后一页显示下一页链接 */ if ( $paged < $max_page - $p ) p_link( $max_page, '最后页', '»' ); } function p_link( $i, $title = '', $linktype = '' ) { if ( $title == '' ) $title = "第 {$i} 页"; if ( $linktype == '' ) { $linktext = $i; } else { $linktext = $linktype; } echo "{$linktext} "; } } //时间显示方式'xx以前' function timeago( $ptime ) { $ptime = strtotime($ptime); $etime = time() - $ptime; if ($etime < 1) return '刚刚'; $interval = array ( 12 * 30 * 24 * 60 * 60 => '年前 ('.date('Y-m-d', $ptime).')', 30 * 24 * 60 * 60 => '个月前 ('.date('m-d', $ptime).')', 7 * 24 * 60 * 60 => '周前 ('.date('m-d', $ptime).')', 24 * 60 * 60 => '天前', 60 * 60 => '小时前', 60 => '分钟前', 1 => '秒前' ); foreach ($interval as $secs => $str) { $d = $etime / $secs; if ($d >= 1) { $r = round($d); return $r . $str; } }; } add_action('wp_ajax_nopriv_bigfa_like', 'bigfa_like'); add_action('wp_ajax_bigfa_like', 'bigfa_like'); function bigfa_like(){ global $wpdb,$post; $id = $_POST["um_id"]; $action = $_POST["um_action"]; if ( $action == 'ding'){ $bigfa_raters = get_post_meta($id,'bigfa_ding',true); $expire = time() + 99999999; $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; // make cookies work with localhost setcookie('bigfa_ding_'.$id,$id,$expire,'/',$domain,false); if (!$bigfa_raters || !is_numeric($bigfa_raters)) { update_post_meta($id, 'bigfa_ding', 1); } else { update_post_meta($id, 'bigfa_ding', ($bigfa_raters + 1)); } echo get_post_meta($id,'bigfa_ding',true); } die; } //禁用Googlefont class Disable_Google_Fonts { public function __construct() { add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 888, 4 ); } public function disable_open_sans( $translations, $text, $context, $domain ) { if ( 'Open Sans font: on or off' == $context && 'on' == $text ) { $translations = 'off'; } return $translations; } } $disable_google_fonts = new Disable_Google_Fonts; //密码保护提示 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 = "
\r\n

这篇文章是受保护的文章,请输入密码继续阅读:

\r\n
\r\n\r\n\r\n
\r\n
"; return $out; } else { return $c; } } add_filter('the_content', 'password_hint'); //冒充评论检验 function CheckEmailAndName(){ global $wpdb; $comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null; $comment_author_email = ( isset($_POST['email']) ) ? trim($_POST['email']) : null; if(!$comment_author || !$comment_author_email){ return; } $result_set = $wpdb->get_results("SELECT display_name, user_email FROM $wpdb->users WHERE display_name = '" . $comment_author . "' OR user_email = '" . $comment_author_email . "'"); if ($result_set) { if ($result_set[0]->display_name == $comment_author){ err(__('警告: 您不能使用博主的昵称!')); }else{ err(__('警告: 您不能使用博主的邮箱!')); } fail($errorMessage); } } //评论列表 function commentlist($comment,$args,$depth){ $GLOBALS['comment']=$comment; ?>
  • id="li-comment-">
    comment_date_gmt ); ?>
    '回复','depth' =>$depth,'max_depth'=>$args['max_depth']))) ?>
    comment_approved=='0'): ?>
    is_singular = true; // base url of page links $baseLink = ''; if ($wp_rewrite->using_permalinks()) { $baseLink = '&base=' . user_trailingslashit(get_permalink($postid) . 'comment-page-%#%', 'commentpaged'); } // response 注意修改callback为你自己的,没有就去掉callback wp_list_comments('callback=commentlist&type=comment&page=' . $pageid . '&per_page=' . get_option('comments_per_page'), $comments); echo ''; echo ''; paginate_comments_links('current=' . $pageid . $baseLink); die; } } add_action('init', 'AjaxCommentsPage'); ?>