WordPress

WordPress前台版你好多莉(Hello_Dolly)插件

gyue2345·2017-08-05·714 次阅读··

   2017-08-05 0:09 LJY2345    抢沙发   714 
   评分 1 次,平均分 5.0    抢沙发

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(); ?>

 

赞赏

历史上的文章

博 主作者: 关注:6    粉丝:1最后编辑于:2022年8月30日
LJY IT BLOG的站长。

扫一扫打赏

支付宝扫一扫打赏

微信扫一扫打赏

view comments - NOTHING

切换注册
忘记密码 ?

×

您也可以使用第三方帐号快捷登录

切换登录

×
扫一扫二维码分享
下载海报
  切换主题 | SCHEME TOOL