测试 coolcode 源代码语法高亮插件
七月 20th, 2007
这是我的首字下沉插件,呵呵。
- /*
- Plugin Name: 首字下沉
- Plugin URI: http://yanfeng.org/blog/wordpress/dropcap
- Description: 把文章的第一段设置class,然後用CSS first-letter 把首字做处理。你可以通过修改插件中包含的css来获得你所需要的样式。
- Version: 2.1
- Author: 桑葚
- Author URI: http://yanfeng.org/blog
- */
- function drop_cap ($content) {
- $newContent = explode("</p>", $content);
- $newContent1 = explode("<p>", $newContent[0]);
- // Piece the output back together.
- $bufContent = "<p class='fp'>".$newContent1[1]."</p>";
- for($i = 1; $i < count($newContent); $i ++){
- $bufContent .= $newContent[$i] . '</p>';
- }
- // Return the updated markup
- return $bufContent;
- }
- function dropcap_head() {
- echo "
- .fp:first-letter {
- font-size : 350%;
- font-weight : bold;
- line-height: 1em;
- float : left;
- }
- ";
- }
- add_filter('the_content', 'drop_cap');
- add_action('wp_head', 'dropcap_head');