forked from wp-plugins/hello-dolly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello.php
54 lines (54 loc) · 1.62 KB
/
hello.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @package Haywyre_Restraint
* @version 1.6
*/
/*
Plugin Name: Haywyre Restraint
Plugin URI: https://genius.com/Haywyre-restraint-lyrics
Description: This is a custom plugin based from Hello Dolly, the lyrics came from Haywyre's Two Fold, Pt. 2 Album: Restraint.
Author: JM Crisostomo
Version: 1.6
Author URI: https://jmcrisostomo.github.io/
*/
function restraint_get_lyric() {
/** These are the lyrics to Restraint */
$lyrics = "Every concept, every notion has a counterpart
Yet, every idea's opposite
Is just the absence of the idea itself
Absence is the absence of presence
But presence is the absence of absence
Any perceived difference is, in fact, also a deep connection
In this way, opposing forces are unified
And the world becomes a cooperative web
Of interdependent pieces";
// Here we split it into lines
$lyrics = explode( "\n", $lyrics );
// And then randomly choose a line
return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
}
// This just echoes the chosen line, we'll position it later
function restraint() {
$chosen = restraint_get_lyric();
echo "<p id='restraint'>$chosen</p>";
}
// Now we set that function up to execute when the admin_notices action is called
add_action( 'admin_notices', 'restraint' );
// We need some CSS to position the paragraph
function restraint_css() {
// This makes sure that the positioning is also good for right-to-left languages
$x = is_rtl() ? 'left' : 'right';
echo "
<style type='text/css'>
#restraint {
float: $x;
padding-$x: 15px;
padding-top: 5px;
margin: 0;
font-size: 11px;
}
</style>
";
}
add_action( 'admin_head', 'restraint_css' );
?>