-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
52 lines (43 loc) · 1.1 KB
/
functions.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
<?php
function lioncub_file_get_contents( $file, $silent = 'no', $input = 'no' ) {
switch( $input ) {
// Returns input stream
case 'yes':
return file_get_contents( $file );
// Standard
default:
if ( @file_exists( $file ) ) {
return trim( file_get_contents( $file ) );
}
return ('no' === $silent ? $file . ' template is missing' : '' );
}
}
function lioncub_special_chars( $data ) {
$data = htmlspecialchars( $data );
$data = str_replace( '&#', '&#', $data );
return str_replace( '&amp;', '&', $data );
}
/**
* Return appropriate new line style
*
* @param int $br
* @return string
*/
function lioncub_new_line( $br = 1 ) {
if ( defined( 'PHP_EOL' ) ) {
if ( $br > 1 ) {
return str_repeat( PHP_EOL, $br );
}
return PHP_EOL;
}
$nl = "\n";
if ( isset( $_SERVER["HTTP_USER_AGENT"] ) && strstr( strtolower( $_SERVER["HTTP_USER_AGENT"] ), 'win' ) ) {
$nl = "\r\n";
} else if ( isset( $_SERVER["HTTP_USER_AGENT"] ) && strstr( strtolower( $_SERVER["HTTP_USER_AGENT"] ), 'mac' ) ) {
$nl = "\r";
}
if ( $br > 1 ) {
return str_repeat( $nl, $br );
}
return $nl;
}