-
Notifications
You must be signed in to change notification settings - Fork 0
/
lj-moods.php
232 lines (210 loc) · 6.14 KB
/
lj-moods.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?php
/*
Plugin Name: LJ-Moods
Plugin URI: https://codeberg.org/kvibber/lj-moods
Description: Display the current mood, music, and location on a blog imported from LiveJournal using the WordPress LiveJournal importer.
Version: 0.6.3
Requires at least: 3.0
Requires CP: 1.0
Requires PHP: 7.0
Author: Kelson Vibber
Author URI: https://kvibber.com
Text Domain: ktv-lj-moods
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
include( "lj-moods-options.php" );
// Display imported LiveJournal mood, music and location.
function lj_moods_metablock( $post_id ) {
load_plugin_textdomain('ktv-lj-moods');
$mood = get_post_meta( $post_id, 'lj_current_mood', true );
$location = get_post_meta( $post_id, 'lj_current_location', true );
$music = get_post_meta( $post_id, 'lj_current_music', true );
// If they're all empty, don't even return a placeholder div.
if ( empty($mood) && empty($location) && empty ($music) ) {
return '';
}
$return = "<div class='lj-moods-meta'>";
if ( !empty($mood) ) {
// Map moods to equivalent WordPress smilies
// TODO wrap in a class so this only needs to be instantiated once
$mood_map = array(
// Old-school WordPress smilies
'aggravated' => ':-x',
'amused' => ':-)',
'angry' => ':-x',
'annoyed' => ':-x',
'anxious' => '8-O',
'apathetic' => ':-|',
'bitchy' => ':-x',
'blah' => ':-|',
'blank' => ':-|',
'bored' => ':-(',
'calm' => ':-)',
'cheerful' => ':-)',
'chipper' => ':-)',
'cold' => ':-(',
'complacent' => ':-)',
'confused' => ':-?',
'content' => ':-)',
'cranky' => ':-x',
'crappy' => ':-(',
'crazy' => ';-)',
'crushed' => ':-(',
'curious' => ':-?',
'cynical' => ':-x',
'depressed' => ':-(',
'devious' => ':twisted:',
'dirty' => ':-(',
'disappointed' => ':-(',
'discontent' => ':-(',
'distressed' => '8-O',
'ditzy' => ';-)',
'drained' => ':-(',
'ecstatic' => ':-)',
'embarrassed' => ':oops:',
'enraged' => ':-x',
'envious' => ':-(',
'exanimate' => ':-|',
'excited' => ':-)',
'exhausted' => ':-(',
'flirty' => ';-)',
'frustrated' => ':-x',
'full' => ':-)',
'giddy' => ';-)',
'giggly' => ';-)',
'gloomy' => ':-(',
'good' => ':-)',
'grateful' => ':-)',
'grumpy' => ':-x',
'guilty' => ':-(',
'happy' => ':-)',
'high' => ':-)',
'hopeful' => ':-)',
'horny' => ':-)',
'hot' => ':-(',
'hungry' => ':-(',
'impressed' => ':-)',
'indifferent' => ':-)',
'infuriated' => ':-x',
'intimidated' => '8-O',
'irate' => ':-x',
'irritated' => ':-x',
'jealous' => ':-(',
'jubilant' => ':-)',
'lazy' => ':-|',
'lethargic' => ':-|',
'listless' => ':-|',
'lonely' => ':-(',
'loved' => ':-)',
'melancholy' => ':-(',
'mellow' => ':-)',
'mischievous' => ';-)',
'moody' => ':-x',
'morose' => ':-(',
'naughty' => ';-)',
'nervous' => '8-O',
'numb' => ':-(',
'okay' => ':-|',
'optimistic' => ':-)',
'peaceful' => ':-)',
'pessimistic' => ':-(',
'pissed off' => ':-x',
'pleased' => ':-)',
'quixotic' => ';-)',
'recumbent' => ':-)',
'refreshed' => ':-)',
'rejected' => ':-(',
'rejuvenated' => ':-)',
'relaxed' => ':-)',
'relieved' => ':-)',
'restless' => ':-(',
'rushed' => ':-x',
'sad' => ':-(',
'satisfied' => ':-)',
'scared' => '8-O',
'shocked' => '8-O',
'silly' => ';-)',
'sore' => ':-(',
'stressed' => ':-x',
'surprised' => ':-)',
'sympathetic' => ':-(',
'thankful' => ':-)',
'thirsty' => ':-(',
'touched' => ':-)',
'uncomfortable' => ':-(',
'weird' => ';-)',
'worried' => ':-(',
// Emoji. TODO How to handle these on older setups? Or make 4.2 required?
'groggy' => '😴', // sleeping face
'sleepy' => '😴',
'tired' => '😴',
'nauseated' => '🤒', // todo replace with actual nauseated face emoji at U+1F922 once supported widely
'sick' => '🤒', // face with thermometer.
'contemplative' => '🤔', // thinking face
'nostalgic' => '🤔',
'pensive' => '🤔',
'thoughtful' => '🤔',
'drunk' => '😵', // dizzy face. LJ default is closer to nauseated face
'bouncy' => '😄', // bouncing smiley isn't available, so let's use a smiling face with open mouth and smiling eyes.
'energetic' => '😄',
'hyper' => '😄'
/* TODO: Add remaining LJ moods that don't have default icons?
accomplished
artistic
awake
busy
creative
determined
dorky
enthralled
geeky
indescribable
nerdy
predatory
productive
working
*/
);
$return .= '<b>' . __('Current Mood', 'ktv-lj-moods') . ':</b> ' .
convert_smilies( $mood_map[sanitize_key( $mood )] ) .
esc_html( wptexturize ( $mood ) ) . '<br/>';
}
if ( !empty($music) ) {
$return .= '<b>' . __('Current Music', 'ktv-lj-moods') . ':</b> ' . esc_html( wptexturize ( $music ) ) . '<br/>';
}
if ( !empty($location) ) {
$return .= '<b>' . __('Current Location', 'ktv-lj-moods') . ':</b> ';
$locationFormatted = esc_html( wptexturize( $location ) );
$options = get_option('lj_moods_settings', array());
switch($options['link_to_map']) {
case 'google':
case 1:
$return .= "<a href='https://www.google.com/maps/search/" . rawurlencode(wp_strip_all_tags( $location)) . "'>" . $locationFormatted . "</a>";
break;
case 'openstreetmap':
$return .= "<a href='https://www.openstreetmap.org/search?query=" . rawurlencode(wp_strip_all_tags( $location)) . "'>" . $locationFormatted . "</a>";
break;
case 'bing':
$return .= "<a href='https://www.bing.com/maps?q=" . rawurlencode(wp_strip_all_tags( $location)) . "'>" . $locationFormatted . "</a>";
break;
case 'duckduckgo':
$return .= "<a href='https://duckduckgo.com/?ia=web&iaxm=places&q=" . rawurlencode(wp_strip_all_tags( $location)) . "'>" . $locationFormatted . "</a>";
break;
default:
$return .= $locationFormatted;
}
}
$return .= "</div>";
return $return;
}
// Add LiveJournal metadata to the content if it's not a password-protected post
// or if the password has been entered.
function lj_moods_add_metablock( $content ) {
if ( !post_password_required() ) {
$content .= lj_moods_metablock( get_the_ID() );
}
return $content;
}
add_filter( 'the_content', 'lj_moods_add_metablock' );
?>