更换主题-七彩之家BLUE2.0以及后续的修改

作者:matrix 被围观: 9,463 次 发布时间:2013-07-31 分类:Wordpress 兼容并蓄 零零星星 | 2 条评论 »

💡NOTICE:这是一个创建于 3011 天前的主题,其中的信息可能已经有所发展或是发生改变。

8.文章编辑后台添加表情功能

functions.php中添加:(只针对于此BLUE2.0的表情图标)

<?php

/*后台添加表情*/
add_action('admin_MEnu', 'aioseop_meta_box_add');
function aioseop_meta_box_add()
{
    if (function_exists('add_meta_box')) {
        if (function_exists('get_post_types')) {
            $mrt_aioseop_pts = get_post_types('', 'names');
            $aioseop_options = get_option('aioseop_options');
            $aioseop_mrt_cpt = $aioseop_options['aiosp_enablecpost'];
            foreach ($mrt_aioseop_pts as $mrt_aioseop_pt) {
                if ($mrt_aioseop_pt == 'post' || $mrt_aioseop_pt == 'page' || $aioseop_mrt_cpt) {
                    add_meta_box('smiley', __('表情'), 'aiosp_meta', $mrt_aioseop_pt);
                }
            }
        }
    }
}

function aiosp_meta()
{
    ?>
    <script type="text/javascript">
        function clinsertsmilies(keycode) {
            tinyMCE.execCommand('mceInsertContent', false, ' ' + keycode + ' ');
        }
    </script>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="<?php bloginfo('template_url'); ?>/images/smilies/icon_wink.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_neutral.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_mad.gif"
                                                      alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_twisted.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_smile.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_eek.gif"
                                                      alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_sad.gif"
                                                      alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_rolleyes.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_razz.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_redface.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_surprised.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies(' :mrgreen: ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_mrgreen.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_lol.gif"
                                                      alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_idea.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_biggrin.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_evil.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_cry.gif"
                                                      alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_cool.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies(' ➡ ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_arrow.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies('  ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_confused.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies(' ❓ ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_question.gif" alt=""/></a>
    <a href="javascript:clinsertsmilies(' ❗ ')"><img
                src="/wp-content/themes/blue2.0-3.5.1/images/smilies/icon_exclaim.gif" alt=""/></a>
    <?php
}

?>

9.去掉blue2.0右上角的主题下载、音乐导航图片

style.css以下代码中的height:58px值改为0px:

a.but_scupl,.but_scupl:hover,.but_scupl:visited,.but_buyl,.but_buyl:hover,.but_buyl:visited {  
    background:url(images/but_up.png) no-repeat;  
    display:block;  
    float:left;  
    width:298px;  
    height:0px;  
    text-indent:-9999px;  
}  

10.修改404页面

添加google自定义检索到404页面并完善按钮之类的东东。不过还是有些显示错位的,也无能为力。

添加右侧工具栏的悬浮

这个感觉很好看
jquery.js中添加:

//sidebar scroll悬浮  
jQuery(document).ready(function($) {  
    if (!isie6()) {  
        var rollStart = $('#001'),  
        rollSet = $('.widget,#newcomments');  
        rollStart.before('<div class="rollbox"></div>');  
        var offset = rollStart.offset(),  
        objWindow = $(window),  
        rollBox = rollStart.prev();  
        if (objWindow.width() > 960) {  
            objWindow.scroll(function() {  
                if (objWindow.scrollTop() > offset.top) {  
                    if (rollBox.html(null)) {  
                        rollSet.clone().prependTo('.rollbox')  
                    }  
                    rollBox.show().stop().animate({  
                        top: 0,  
                        paddingTop: 15  
                    },  
                    400)  
                } else {  
                    rollBox.hide().stop().animate({  
                        top: 0  
                    },  
                    400)  
                }  
            })  
        }  
    }  
    function isie6() {  
        if ($.browser.msie) {  
            if ($.browser.version == "6.0") return true;  
        }  
        return false;  
    }  
});  

参考:http://www.cmhello.com/sidebar-scroll.html

说明:#001为开始悬浮的位置标记

.widget,#newcomMEnts为要悬浮的东东

.rollbox就是悬浮的样式

sidebar.php中添加位置标记:<div id="001">

style.css中添加.rollbox悬浮样式:

.rollbox{position:fixed;background:none;width:275px;}  

###12.显示评论信息
添加显示评论者系统和浏览器(UA)信息以及IP地址(目前来说此功能有点鸡肋,纯真数据库还占我好几兆啊)
添加/ip2.dat纯真数据库(2013-7-15数据)

functions.php中添加代码:


//显示评论者地理位置 function convertip($ip) { $dat_path = TEMPLATEPATH . '/ip2.dat'; //*数据库路径*// if (!$fd = @fopen($dat_path, 'rb')) { return 'IP date file not exists or access denied'; } $ip = explode('.', $ip); $ipNum = $ip[0] * 16777216 + $ip[1] * 65536 + $ip[2] * 256 + $ip[3]; $DataBegin = fread($fd, 4); $DataEnd = fread($fd, 4); $ipbegin = implode('', unpack('L', $DataBegin)); if ($ipbegin < 0) $ipbegin += pow(2, 32); $ipend = implode('', unpack('L', $DataEnd)); if ($ipend < 0) $ipend += pow(2, 32); $ipAllNum = ($ipend - $ipbegin) / 7 + 1; $BeginNum = 0; $EndNum = $ipAllNum; $ip1num = $ip2num = 0; while ($ip1num > $ipNum || $ip2num < $ipNum) { $Middle = intval(($EndNum + $BeginNum) / 2); fseek($fd, $ipbegin + 7 * $Middle); $ipData1 = fread($fd, 4); if (strlen($ipData1) < 4) { fclose($fd); return 'System Error'; } $ip1num = implode('', unpack('L', $ipData1)); if ($ip1num < 0) $ip1num += pow(2, 32); if ($ip1num > $ipNum) { $EndNum = $Middle; continue; } $DataSeek = fread($fd, 3); if (strlen($DataSeek) < 3) { fclose($fd); return 'System Error'; } $DataSeek = implode('', unpack('L', $DataSeek . chr(0))); fseek($fd, $DataSeek); $ipData2 = fread($fd, 4); if (strlen($ipData2) < 4) { fclose($fd); return 'System Error'; } $ip2num = implode('', unpack('L', $ipData2)); if ($ip2num < 0) $ip2num += pow(2, 32); if ($ip2num < $ipNum) { if ($Middle == $BeginNum) { fclose($fd); return 'Unknown'; } $BeginNum = $Middle; } } $ipAddr2 = $ipAddr1 = ''; $ipFlag = fread($fd, 1); if ($ipFlag == chr(1)) { $ipSeek = fread($fd, 3); if (strlen($ipSeek) < 3) { fclose($fd); return 'System Error'; } $ipSeek = implode('', unpack('L', $ipSeek . chr(0))); fseek($fd, $ipSeek); $ipFlag = fread($fd, 1); } if ($ipFlag == chr(2)) { $AddrSeek = fread($fd, 3); if (strlen($AddrSeek) < 3) { fclose($fd); return 'System Error'; } $ipFlag = fread($fd, 1); if ($ipFlag == chr(2)) { $AddrSeek2 = fread($fd, 3); if (strlen($AddrSeek2) < 3) { fclose($fd); return 'System Error'; } $AddrSeek2 = implode('', unpack('L', $AddrSeek2 . chr(0))); fseek($fd, $AddrSeek2); } else { fseek($fd, -1, SEEK_CUR); } while (($char = fread($fd, 1)) != chr(0)) $ipAddr2 .= $char; $AddrSeek = implode('', unpack('L', $AddrSeek . chr(0))); fseek($fd, $AddrSeek); while (($char = fread($fd, 1)) != chr(0)) $ipAddr1 .= $char; } else { fseek($fd, -1, SEEK_CUR); while (($char = fread($fd, 1)) != chr(0)) $ipAddr1 .= $char; $ipFlag = fread($fd, 1); if ($ipFlag == chr(2)) { $AddrSeek2 = fread($fd, 3); if (strlen($AddrSeek2) < 3) { fclose($fd); return 'System Error'; } $AddrSeek2 = implode('', unpack('L', $AddrSeek2 . chr(0))); fseek($fd, $AddrSeek2); } else { fseek($fd, -1, SEEK_CUR); } while (($char = fread($fd, 1)) != chr(0)) { $ipAddr2 .= $char; } } fclose($fd); if (preg_match('/http/i', $ipAddr2)) { $ipAddr2 = ''; } $ipaddr = "$ipAddr1 $ipAddr2"; $ipaddr = preg_replace('/CZ88.Net/is', '', $ipaddr); $ipaddr = preg_replace('/^s*/is', '', $ipaddr); $ipaddr = preg_replace('/s*$/is', '', $ipaddr); if (preg_match('/http/i', $ipaddr) || $ipaddr == '') { $ipaddr = 'Unknown'; } $ipaddr = iconv('gbk', 'utf-8//IGNORE', $ipaddr); if ($ipaddr != ' ') return $ipaddr; else $ipaddr = '火星来客'; return $ipaddr; } //UA信息 function user_agent($ua) { //开始解析操作系统 $os = null; if (preg_match('/Windows 95/i', $ua) || preg_match('/Win95/', $ua)) { $os = "Windows 95"; } elseif (preg_match('/Windows NT 5.0/i', $ua) || preg_match('/Windows 2000/i', $ua)) { $os = "Windows 2000"; } elseif (preg_match('/Win 9x 4.90/i', $ua) || preg_match('/Windows ME/i', $ua)) { $os = "Windows ME"; } elseif (preg_match('/Windows.98/i', $ua) || preg_match('/Win98/i', $ua)) { $os = "Windows 98"; } elseif (preg_match('/Windows NT 6.0/i', $ua)) { $os = "Windows Vista"; } elseif (preg_match('/Windows NT 6.1/i', $ua)) { $os = "Windows 7"; } elseif (preg_match('/Windows NT 5.1/i', $ua)) { $os = "Windows XP"; } elseif (preg_match('/Windows NT 5.2/i', $ua) && preg_match('/Win64/i', $ua)) { $os = "Windows XP 64 bit"; } elseif (preg_match('/Windows NT 5.2/i', $ua)) { $os = "Windows Server 2003"; } elseif (preg_match('/Mac_PowerPC/i', $ua)) { $os = "Mac OS"; } elseif (preg_match('/Windows Phone/i', $ua)) { $os = "windows phone7"; } elseif (preg_match('/Windows NT 6.2/i', $ua)) { $os = "Windows 8"; } elseif (preg_match('/Windows NT 4.0/i', $ua) || preg_match('/WinNT4.0/i', $ua)) { $os = "Windows NT 4.0"; } elseif (preg_match('/Windows NT/i', $ua) || preg_match('/WinNT/i', $ua)) { $os = "Windows NT"; } elseif (preg_match('/Windows CE/i', $ua)) { $os = "Windows CE"; } elseif (preg_match('/ipad/i', $ua)) { $os = "iPad"; } elseif (preg_match('/Touch/i', $ua)) { $os = "Touchw"; } elseif (preg_match('/Symbian/i', $ua) || preg_match('/SymbOS/i', $ua)) { $os = "Symbian OS"; } elseif (preg_match('/iPhone/i', $ua)) { $os = "iPhone"; } elseif (preg_match('/PalmOS/i', $ua)) { $os = "Palm OS"; } elseif (preg_match('/QtEmbedded/i', $ua)) { $os = "Qtopia"; } elseif (preg_match('/Ubuntu/i', $ua)) { $os = "Ubuntu Linux"; } elseif (preg_match('/Gentoo/i', $ua)) { $os = "Gentoo Linux"; } elseif (preg_match('/Fedora/i', $ua)) { $os = "Fedora Linux"; } elseif (preg_match('/FreeBSD/i', $ua)) { $os = "FreeBSD"; } elseif (preg_match('/NetBSD/i', $ua)) { $os = "NetBSD"; } elseif (preg_match('/OpenBSD/i', $ua)) { $os = "OpenBSD"; } elseif (preg_match('/SunOS/i', $ua)) { $os = "SunOS"; } elseif (preg_match('/Linux/i', $ua)) { $os = "Linux"; } elseif (preg_match('/Mac OS X/i', $ua)) { $os = "Mac OS X"; } elseif (preg_match('/Macintosh/i', $ua)) { $os = "Mac OS"; } elseif (preg_match('/Unix/i', $ua)) { $os = "Unix"; } elseif (preg_match('#Nokia([a-zA-Z0-9.]+)#i', $ua, $matches)) { $os = "Nokia" . $matches[1]; } elseif (preg_match('/Mac OS X/i', $ua)) { $os = "Mac OS X"; } else { $os = '未知操作系统'; } //开始解析浏览器 if (preg_match('#(Camino|Chimera)[ /]([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Camino ' . $matches[2]; } elseif (preg_match('#SE 2([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = '搜狗浏览器 2' . $matches[1]; } elseif (preg_match('#360([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = '360浏览器 ' . $matches[1]; } elseif (preg_match('#Maxthon( |\/)([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Maxthon ' . $matches[2]; } elseif (preg_match('#Chrome/([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Chrome ' . $matches[1]; } elseif (preg_match('#Safari/([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Safari ' . $matches[1]; } elseif (preg_match('#opera mini#i', $ua)) { preg_match('#Opera/([a-zA-Z0-9.]+)#i', $ua, $matches); $browser = 'Opera Mini ' . $matches[1]; } elseif (preg_match('#Opera.([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Opera ' . $matches[1]; } elseif (preg_match('#(j2me|midp)#i', $ua)) { $browser = "J2ME/MIDP Browser"; } elseif (preg_match('/GreenBrowser/i', $ua)) { $browser = 'GreenBrowser'; } elseif (preg_match('#TencentTraveler ([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = '腾讯TT浏览器 ' . $matches[1]; } elseif (preg_match('#UCWEB([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'UCWEB ' . $matches[1]; } elseif (preg_match('#MSIE ([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Internet Explorer ' . $matches[1]; } elseif (preg_match('#avantbrowser.com#i', $ua)) { $browser = 'Avant Browser'; } elseif (preg_match('#PHP#', $ua, $matches)) { $browser = 'PHP'; } elseif (preg_match('#danger hiptop#i', $ua, $matches)) { $browser = 'Danger HipTop'; } elseif (preg_match('#Shiira[/]([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Shiira ' . $matches[1]; } elseif (preg_match('#Dillo[ /]([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Dillo ' . $matches[1]; } elseif (preg_match('#Epiphany/([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Epiphany ' . $matches[1]; } elseif (preg_match('#UP.Browser/([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Openwave UP.Browser ' . $matches[1]; } elseif (preg_match('#DoCoMo/([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'DoCoMo ' . $matches[1]; } elseif (preg_match('#(Firefox|Phoenix|Firebird|BonEcho|GranParadiso|Minefield|Iceweasel)/([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Firefox ' . $matches[2]; } elseif (preg_match('#(SeaMonkey)/([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Mozilla SeaMonkey ' . $matches[2]; } elseif (preg_match('#Kazehakase/([a-zA-Z0-9.]+)#i', $ua, $matches)) { $browser = 'Kazehakase ' . $matches[1]; } else { $browser = '未知浏览器'; } return $os . " | " . $browser; }

参考:http://yrwr.net/show-reviewed-by-WordPress-ua.html

http://yrwr.net/show-reviewed-by-WordPress-ip.html

13.感觉最有进步的修改

添加auto-highslide灯箱的功能。打开图片出现的效果蛮不错的。这可是我主题去插件化的第一个作品:整合auto-highslide插件  不错不错 😉
目前还有个小bug:貌似graphics的图片没有和auto-highslide功能整合,也就是不显示的啦~

打开插件的php文件,吧其中代码添加到functions.php中:

/* Add HighSlide灯箱非插件化 */
add_filter('the_content', 'addhighslideclass_replace');
function addhighslideclass_replace($content)
{
    global $post;
    $pattern = "/<a(.*?)href=('|\")([^>]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)<\/a>/i";
    $replacement = '<a$1href=$2$3.$4$5 class="highslide-image" onclick="return hs.expand(this);"$6>$7</a>';
    $content = preg_replace($pattern, $replacement, $content);
    return $content;
}

/* Add HighSlide */
function highslide_head()
{
    print('  
<link rel="stylesheet" href="' . get_bloginfo('wpurl') . '/wp-content/themes/blue2.0-3.5.1/highslide.css" type="text/css" />  
<script type="text/javascript" src="' . get_bloginfo('wpurl') . '/wp-content/themes/blue2.0-3.5.1/js/highslide-with-html.packed.js"></script>  
<script type="text/javascript">  
    hs.graphicsDir = "' . get_bloginfo('wpurl') . '/wp-content/themes/blue2.0-3.5.1/images/graphics/";  
    hs.outlineType = "rounded-white";  
    hs.outlineWhileAnimating = true;  
    hs.showCredits = false;  
</script>  
    ');
}

add_action('wp_head', 'highslide_head');

将插件内的css、js、图片文件放好:

/js/highslide-with-html.packed.js

/highslide.css

/images/graphics/

ok!

分页: 1 2 3 4
其他文章:
本文固定链接:https://www.hhtjim.com/change-the-theme-the-home-of-7-colour-blue2-0-and-subsequent-amendments.html
matrix
本文章由 matrix 于2013年07月31日发布在Wordpress, 兼容并蓄, 零零星星分类下,目前没有通告,你可以至底部留下评论。
转载请注明:更换主题-七彩之家BLUE2.0以及后续的修改-HHTjim'S 部落格
关键字:, , , , ,

有2 条评论 »

  1. [...] 更换主题-七彩之家BLUE2.0以及后续的修改 提过修改css中Blockquote样式来让引用样式更beautiful。 [...]

  2. [...] 以前在“ 更换主题-七彩之家BLUE2.0以及后续的修改 ”中的functions.php添加了很多内容,稍微有点差池就导致wordpress无法打开。 [...]

添加新评论 »

 🙈 😱 😂 😛 😭 😳 😀 😆 👿 😉 😯 😮 😕 😎 😐 😥 😡 😈 💡

插入图片

NOTICE: You should type some Chinese word (like “你好”) in your comment to pass the spam-check, thanks for your patience!