forked from darkrain/woo-export-yml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WooExportYmlFunctions.php
executable file
·62 lines (39 loc) · 1.08 KB
/
WooExportYmlFunctions.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
<?php
class WooExportYmlFunctions
{
public static function substr( $text, $max, $removelastword = true ){
$text = mb_substr($text, 0, $max );
if( $removelastword ){
$text = explode('. ', $text );
unset( $text[ count( $text ) -1 ] );
$text = implode('. ', $text );
}
return $text;
}
public static function sanitize( $url ){
if( empty( $url ) )
return false;
$_p = explode('/', str_replace(home_url('/'), "", $url ));
$_a = array();
foreach($_p as $v_ulr) {
$_a[] = rawurlencode($v_ulr);
}
$_u = home_url('/').implode('/', $_a );
return $_u;
}
public static function del_symvol($str){
$tr = array(
";"=>" ",":"=>" ",">"=>" ","«"=>" ",
"»"=>" ","\""=>" ","@"=>" ","#"=>" ","$"=>" ",
"*" => " ", "%" => " ", "&" => " "
);
return strtr($str,$tr);
}
public function print_gzencode_output( $filename ){
$contents = ob_get_clean();
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Encoding: gzip');
$contents = gzencode($contents, 9);
print($contents);
}
}