Hello_Dolly,启用后会在你的站点后台每个页面的右上角都可以看到一句来自《俏红娘》音乐剧的英文原版台词。
为什么只能在后台显示,在后台显示没人看见。现在它可以在主题的任何地方显示。
<?php /** * @package Hello_Dolly前台版 * @version 1.0 */ /* Plugin Name: Hello_Dolly前台版 Plugin URI: http://wordpress.org/plugins/hello-dolly/ Description: 可以在主题显示,This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page. Author: Matt Mullenweg Version: 1.0 Author URI: http://ma.tt/ */ /** These are the lyrics to Hello Dolly */ $quotes = <<< eot Hello, Dolly Well, hello, Dolly It's so nice to have you back where you belong You're lookin' swell, Dolly I can tell, Dolly You're still glowin', you're still crowin' You're still goin' strong We feel the room swayin' While the band's playin' One of your old favourite songs from way back when So, take her wrap, fellas Find her an empty lap, fellas Dolly'll never go away again Hello, Dolly Well, hello, Dolly It's so nice to have you back where you belong You're lookin' swell, Dolly I can tell, Dolly You're still glowin', you're still crowin' You're still goin' strong We feel the room swayin' While the band's playin' One of your old favourite songs from way back when Golly, gee, fellas Find her a vacant knee, fellas Dolly'll never go away Dolly'll never go away Dolly'll never go away again eot; // Here we split it into lines $quotes = explode("\n", $quotes); // 随机选择一行输出 $show_quotes = wptexturize( $quotes[ mt_rand(0, count($quotes)-1 ) ] ); // 在想要显示的地方加上 if(function_exists('show_quotes')) show_quotes(); 即可 function show_quotes() { global $show_quotes; echo "<div style=\"color: #ffffff;\" id=\"random\">".$show_quotes."</div>"; } ?>
使用方法:复制本段代码保存为hello2.php移动到word press插件目录下,打开后台启用插件
需要在主题哪里显示就把以下代码添加到哪里。OK
<?php if(function_exists('show_quotes')) show_quotes(); ?>
赞赏
历史上的文章
- 2016: 从DOS到Windows10,发生的变化!( 3)
- 2015: 博客夜间阅读模式的正确的使用方法&实现方法( 0)
- 2015: Dreamweaver/DW CS6 官方简体中文原版下载+破解文件(含32位+64位)( 0)
除特别注明外,本站文章均采用BY-NC-SA协议授权,转载请注明来自:https://www.ljy2345.com/2017/08/wordpress%e5%89%8d%e5%8f%b0%e7%89%88%e4%bd%a0%e5%a5%bd%e5%a4%9a%e8%8e%89%ef%bc%88hello_dolly%ef%bc%89%e6%8f%92%e4%bb%b6/
Comments | NOTHING