-
Notifications
You must be signed in to change notification settings - Fork 0
/
bacon-ipsum.php
executable file
·51 lines (42 loc) · 1.41 KB
/
bacon-ipsum.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
<?php
/**
* Fansoro Bacon Ipsum Plugin
*
* (c) Romanenko Sergey / Awilum <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
// Shortcode: {bacon}
Shortcode::add('bacon', 'bacon');
function bacon($attributes)
{
// Extract
extract($attributes);
if (isset($type) && in_array($type, ['all-meat', 'meat-and-filler'])) {
$type = '?type='.$type;
} else {
$type = '?type='.Config::get('plugins.bacon-ipsum.type');
}
if (isset($p)) {
$p = '¶s='.$p;
} else {
$p = '¶s='.Config::get('plugins.bacon-ipsum.p');
}
if (isset($sentences)) {
$sentences = '&sentences='.$sentences;
} else {
$sentences = '&sentences='.Config::get('plugins.bacon-ipsum.sentences');
}
if (isset($start_with_lorem) && in_array($start_with_lorem, ['0', '1'])) {
$start_with_lorem = '&start-with-lorem='.$start_with_lorem;
} else {
$start_with_lorem = '&start-with-lorem='.Config::get('plugins.bacon-ipsum.start_with_lorem');
}
if (isset($format) && in_array($format, ['json', 'text', 'html'])) {
$format = '&format='.$format;
} else {
$format = '&format='.Config::get('plugins.bacon-ipsum.format');
}
return file_get_contents("http://baconipsum.com/api/{$type}{$p}{$sentences}{$start_with_lorem}{$format}");
}