这是我的首字下沉插件,呵呵。

  1. /*
  2. Plugin Name: 首字下沉
  3. Plugin URI: http://yanfeng.org/blog/wordpress/dropcap
  4. Description: 把文章的第一段设置class,然後用CSS first-letter 把首字做处理。你可以通过修改插件中包含的css来获得你所需要的样式。
  5. Version: 2.1
  6. Author: 桑葚
  7. Author URI: http://yanfeng.org/blog
  8. */ 
  9.  
  10. function drop_cap ($content) { 
  11. $newContent = explode("</p>", $content);
  12. $newContent1 = explode("<p>", $newContent[0]);
  13. // Piece the output back together.
  14. $bufContent = "<p class='fp'>".$newContent1[1]."</p>";
  15. for($i = 1; $i &lt; count($newContent); $i ++){ 
  16. $bufContent .= $newContent[$i] . '</p>';
  17. } 
  18.  
  19. // Return the updated markup
  20. return $bufContent;
  21.  
  22. } 
  23.  
  24. function dropcap_head() {
  25.     echo "
  26. .fp:first-letter {
  27. font-size : 350%;
  28. font-weight : bold;
  29. line-height: 1em;
  30. float : left;
  31. }
  32. ";
  33. }
  34.  
  35. add_filter('the_content', 'drop_cap');
  36. add_action('wp_head', 'dropcap_head');

Hello world!

六月 10th, 2007

Welcome to 赛族. This is your first post. Edit or delete it, then start blogging!