其实zAlive主题一直都是开源的并且在WordPress官方主题目录提供下载,最近将其放在Github上面,原因有二
- 使用Git版本控制,这样妈妈再也不用担心文件丢失之类的问题了
- 装装逼
自由人博客
其实zAlive主题一直都是开源的并且在WordPress官方主题目录提供下载,最近将其放在Github上面,原因有二
最近经常会收到WP Super Cache发送的邮件(从9月23号开始收到第一封,然后10月多开始频率增加,不过最多也就1天1封,但是现在1天竟然收到了5封)。
邮件如下:
最近在WordPress论坛里有朋友在反馈zAlive主题 的幻灯片设置有问题,具体表现为设置了幻灯片为只在首页显示,但是在博客页面还是会显示(WordPress可以将首页设置为一个静态页面,用另外一个页面显示博客,详见>>Creating a Static Front Page)。
Subscribe to Comments Reloaded是一款WordPress评论订阅通知及管理插件,用户可以通过邮件接收文章的评论更新通知,当然也可以通过设置取消所有通知。
关于Chrome插件想必用Chrome浏览器的童鞋都很清楚,不过这标题写的说实话有点让人晕,要解释清楚标题,首先要了解一下Chrome插件的安装机制。
目前据我的了解,你可以用这3种方法安装Chrome插件
然而本文所介绍的插件安装方法并不属于上述任意一种,这就是下面要说的第4种安装方法
这内联安装我用一句话概括就是:你制作了一个插件并且已经在Chrome Web Store上发布,同时你还想让你网站内的用户也能够直接在你的网站上安装插件而不用再跑到Chrome Web Store那里。
如果还是不太明白的话可以看看下面人家官方的原文吧
Once you’ve published your app or extension, you may be wondering how users will find and install your app. For users who browse the Chrome Web Store and find your item, its a very easy one-click process to install it. However, if a user is already on your site, it can be cumbersome for them to complete the installation – they would need to navigate away from your site to the store, complete the install process, and then return.
As of Google Chrome 15, you can initiate app and extensions installations “inline” from your site. These apps and extensions are still hosted in the Chrome Web Store, but users no longer have to leave your site to install them.
When users install the app, they will see an installation confirmation dialog similar to the one pictured on right. Just like the dialog displayed when installing directly from the Chrome Web Store, it lists all of the permissions that your app or extension is requesting. Additionally, this dialog includes the average Chrome Web Store rating and the number of users, giving users extra confidence about what they are about to install.
1、在页面的head内插入一个Chrome Web Store link
即将下面的代码插入页面<head></head>之间
<link rel=”chrome-webstore-item” href=”https://chrome.google.com/webstore/detail/itemID“>
itemID可以在打开一个插件的Chrome Web Store链接后找到,下面是我的查看源码Chrome插件的link
<link rel=”chrome-webstore-item” href=”https://chrome.google.com/webstore/detail/ggkbiakmiljlbbfhjajlpjgckcjanbab“>
2、触发内联安装
原文里面写的比较多,按照我的理解其实很简单也就是用JS写些判断代码,增强用户体验,下面是我个人的一些逻辑步骤
说了那么多,其实就是这段JS代码(需jQuery,另外上面所说的button已经在页面内插入,并且button的id为install-button)
(function($){ var e = $('#install-button') ,originalText = e.html() ,itemURL = $('link[rel=chrome-webstore-item]').attr('href') ,isChrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase()); checkAndSetButton(); e.click(function(){ e.html('正在安装...').attr('disabled',true); chrome.webstore.install(
前一段在制作zAlive主题的时候需要一个带头像最新评论widget,网上Google了一大圈发现用的最多的是SQL,我也就直接拿来用了,而且神奇的是通过了WP的主题审核,但是后来在更新主题的时候怕不给通过,就索性找别的方法,也就是今天的主角,get_comments()
其实用get_comments()
实现WordPress带头像最新评论zww很早就有一篇文章介绍,但是从2010年到现在WP已经升级了N多个版本,原来的参数有的已经失效,于是我就重新翻阅文档,用新版的get_comments实现WordPress带头像最新评论。
我写的这个可以指定获取的评论数,头像尺寸,评论字符数
function zAlive_recentComments($count,$avatarSize,$excerptLength){ $comments; if( $count != 0 ){ //新版的get_comments()不能直接获取指定类型的评论(比如会获取到pingback/trackback),+30是为了多获取一些评论,从而减少获取不到指定数量的评论的机会 $comments = get_comments(
其实我很早就知道最近WordPress要升级了,因为前几天在提交zAlive主题的时候在WordPress主题目录里面看到了Twenty Thirteen主题的ticket,当时还在纳闷这货是咋回事,等到第二天WordPress发布3.6更新后才恍然大悟(够迟钝,不过话说我当时也没多想嘛~