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

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

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

PhilNa2之自说ME话扩展版 v1.5.1  留个图。 强大的小墙、强大的功能、更是辛苦了的自说Me话

图片有点不科学,打开的时候要注意啦 同学~

PhilNa2之自说Me话扩展版 v1.5.1

无意中发现个好看的cms主题BLUE2.0之后就果断跟换,然后就一连串的修改调整。。。真是闲着蛋疼~

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

然后就开始记录修改主题的细节部分,方便以后的查找~

1.后台添加html按钮

toggle伸缩、mp3短代码、分隔符、文章分页样式

functions.php中上部添加 代码:

// 自定义HTML编辑器按钮  

add_action('admin_print_scripts', 'my_quicktags');

function my_quicktags() {

    wp_enqueue_script(

        'my_quicktags',

        get_stylesheet_directory_uri().'/my-quicktags.js',

        array('quicktags')

    );

}  

主题目录内添加my-quicktags.js文件:

QTags.addButton( '<', '<', '<', '' ); //快捷输入<的html代码  
QTags.addButton( '>', '>', '>', '' );  
QTags.addButton( 'hr', '分隔线', "\n<hr />\n", '' );  //快捷输入一个hr横线,点一下即可  
QTags.addButton( 'nextpage', '文章分页', "\n<!--nextpage-->\n", '' ); //添加文章分页按钮  
QTags.addButton( 'h1', 'h1', "\n<h1>", "</h1>\n" );  //快捷输入h1标签  
QTags.addButton( 'h2', 'h2', "\n<h2>", "</h2>\n" );  
QTags.addButton( 'h3', 'h3', "\n<h3>", "</h3>\n" );  
QTags.addButton( 'mp3', 'mp3 auto1自动播放', '\n[mp(占位符)3 auto=1]', '[/mp3]\n' ); //mp3按钮  
QTags.addButton( 'toggle', 'toggle伸缩', '\n[t(占位符)oggle]', '[/toggle]\n' ); //toggle伸缩按钮  

//QTags.addButton( 'my_id', 'my button', '\n</span>', '</span>\n' );  
//这儿共有四对引号,分别是按钮的ID、显示名、点一下输入内容、再点一下关闭内容(此为空则一次输入全部内容),\n表示换行。

 

2.functions.php中添加访问计数代码

//访问计数  
function record_visitors()
{
    if (is_singular()) {
        global $post;
        $post_ID = $post->ID;
        if ($post_ID) {
            $post_views = (int)get_post_MEta($post_ID, 'views', true);
            if (!update_post_MEta($post_ID, 'views', ($post_views + 1))) {
                add_post_meta($post_ID, 'views', 1, true);
            }
        }
    }
}

add_action('wp_head', 'record_visitors');
function post_views($before = '(点击 ', $after = ' 次)', $echo = 1)
{
    global $post;
    $post_ID = $post->ID;
    $views = (int)get_post_meta($post_ID, 'views', true);
    if ($echo) echo $before, number_format($views), $after;
    else return $views;
}

single.php、blog.php中添加被围观次数显示:

被围观: <?php post_views(' ', ' 次'); ?>

3.添加toggle伸缩功能

functions.php中添加toggle伸缩函数:

/* 
* 文章内容部分文字toggle伸缩,源代码取自林木木博客 
*自己稍加修改,添加后台编辑器按钮,方便朋友们添加 
*/

function single_toggle($atts, $content=null){

    extract(shortcode_atts(array("title"=>' 点击此处展开↑ '),$atts));

    return '<p class="tg_t">'.$title.' ↓ </p><p class="tg_c" style="display:none;">'.$content.'</p>';

}

add_shortcode('toggle','single_toggle');

参考:自说ME话 & http://immmmm.com/WordPress-shortcodes-toggle.html

\js\jquery.js中添加控制语句:

/*************************** Toggle伸缩 就少了”jQuery(document).ready(function(){“这句ready的话 TMD 给老子弄惨了 ***************************/  

jQuery(document).ready(function(){  

jQuery(".tg_t").click(function(){$(this).next('.tg_c').slideToggle(400)});  

});  

之前就少了ready的语句,害得我弄了大半天都没效果~  不懂代码真是恼火啊

4.添加播放mp3的功能

从自说Me话扩展版 v1.5.1拷贝\swf\player.swf
functions.php中添加mp3短代码:

/* 
* mp3短代码 
*/
function mp3player($atts, $content=null,$auto = false){
    extract(shortcode_atts(array("auto"=>'0'),$atts));
    $autostart=$auto?'yes':'no';
    return '<embed src="'.get_bloginfo('template_directory').'/swf/player.swf?soundFile='.$content.'&autostart='.$autostart.'&animation=yes&encode=no&initialvolume=80&remaining=yes&noinfo=no&buffer=5&checkpolicy=no&rtl=no&bg=E5E5E5&text=333333&leftbg=CCCCCC&lefticon=333333&volslider=666666&voltrack=FFFFFF&rightbg=B4B4B4&rightbghover=999999&righticon=333333&righticonhover=FFFFFF&track=FFFFFF&loader=009900&border=CCCCCC&tracker=DDDDDD&skip=666666" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="290" height="30">';
}
add_shortcode('mp3','mp3player');  

参考:http://isayme.com/2011/05/shortcode-enable-mp3player.html

分页: 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!