使用WP内置的dashicons图标字体显示效果
中文字左侧的小图片就是用这个图标字体实现的,仔细观察,发现Wordpress是先调用一个php,再通过php调用图标字体的CSS的:
http://127.0.0.1/wp-admin/load-styles.php?c=1&dir=ltr&load=dashicons,admin-bar,wp-admin,buttons,media-views,wp-auth-check&ver=3.8
直接调用,是不行的,所以研究了两种方法:
一、方法1:
将这个链接打开后,复制里面的CSS代码到一个CSS文件,将这个CSS文件放在主题根目录下,先调整下这个CSS文件中的引用字体文件的相对URI,再正则替换下}替换为}\n,然后删除
.dashicons-smiley:before{content:"\f328"}
之前的内容,在主题的style.css中引入这个CSS:
@import urldashicons.css);
就可以调用了。
二、方法2:
在主题的functions.php中添加如下HOOK:
add_action( 'wp_enqueue_scripts', 'themename_scripts' );
function themename_scripts() {
wp_enqueue_style( 'themename-style', get_stylesheet_uri(), array( 'dashicons' ), '1.0' );
}
然后就可以调用了。
三、调用方法:
例如:
<div class="span3 ">Themed by <a href="http://coolwp.net" class="footer-links" target="_blank" alt="coolwp.net©酷维普计量泵" title="CoolWP.net©酷维普&Suoling.net"><span class="dashicons dashicons-wordpress" style="font-size:26px;margin-top:-3px;margin-right:10px"></span>CoolWP.net</a></div>
上面代码中的class="dashicons dashicons-wordpress" 就是调用方法,如果觉得位置不合适,可以另加个style调整下,实际测试计量泵截图:
dashicons
上面截图中的Wordpress标志就是这个调用这个图标字体文件生成的。
另外,在Wordpress自带的主题twentyfourteen的根目录下,还有一个叫genericons的图标字体,貌似是 Joen Asmussen的作品,图标少些,但是可以直接调用了。
Fix the width bug of meta fields of the textarea type on post/page editor page of wordpress
When you add a meta field of the textarea type below the post/page editor,you will find it can be resized anylagre,it's terrible,such as the screen shot below:
fixed meta fields of the textarea type on post/page editor page
(u can click the above image to look the big one)
Now,fix it,it's simple!http://mzj.nc.gov.cn/
add the below content to any css file which could be load on the post/page editor page:
textarea{
resize: vertical;
max-width:100%;
}
I think it's NOT a bug , just a little bug!
Nice WordPress!
Keywords:wordpress,fix,meta field,
很简单的一个事儿,在Wordpress中启用摘要功能或者自定义textarea类型的输入栏的时候,输入栏的宽度可以在X方向和Y方向被拖动放大,但是,好像没限制X方向的最大宽度,会导致如上文中插图那样不佳的效果,修复它很简单的,将上面的CSS添加到任何一个可以被编辑器页面载入的CSS文件即可。