summaryrefslogtreecommitdiffstats
path: root/includes/class-giglogadmin-icalexport.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2023-01-22 14:49:26 +0100
committerHarald Eilertsen <haraldei@anduin.net>2023-01-22 14:49:26 +0100
commit3df0ecfd3c008d348b735bc0989b1082cc6bfd37 (patch)
tree2408309bbd7024d9161eaad19ae37b42a1a42a4e /includes/class-giglogadmin-icalexport.php
parentd6cd1c1c0dea7b625b7601d6bd97ff2f84cb67d2 (diff)
downloadgigologadmin-3df0ecfd3c008d348b735bc0989b1082cc6bfd37.tar.gz
gigologadmin-3df0ecfd3c008d348b735bc0989b1082cc6bfd37.tar.bz2
gigologadmin-3df0ecfd3c008d348b735bc0989b1082cc6bfd37.zip
Replace homegrown file name sanitization with WP function.
Diffstat (limited to 'includes/class-giglogadmin-icalexport.php')
-rw-r--r--includes/class-giglogadmin-icalexport.php14
1 files changed, 6 insertions, 8 deletions
diff --git a/includes/class-giglogadmin-icalexport.php b/includes/class-giglogadmin-icalexport.php
index ba1d7f0..d12db13 100644
--- a/includes/class-giglogadmin-icalexport.php
+++ b/includes/class-giglogadmin-icalexport.php
@@ -18,12 +18,6 @@ if ( ! class_exists( 'GiglogAdmin_IcalExport' ) ) {
*/
class Giglogadmin_IcalExport {
- static function textclean( string $txt ) : string {
- $cleantext = preg_replace( '/[^A-Za-z0-9 ]/', '', $txt );
- $cleantext = str_replace( ' ', '_', $cleantext );
- return( $cleantext );
- }
-
public static function export_ical() {
$evid = $_GET['evid'];
@@ -32,8 +26,12 @@ if ( ! class_exists( 'GiglogAdmin_IcalExport' ) ) {
$cshortname = substr( $cfullname, 0, 20 );
$fdate = strtotime( $concert->cdate() );
$newformat = date( 'Ymd', $fdate );
- $filename = 'Concert ' . $concert->venue()->name() . ' ' . $newformat . ' ' . substr( $concert->cname(), 0, 30 );
- $filename = self::textclean( $filename );
+
+ $filename = sanitize_file_name(
+ "Concert-{$concert->venue()->name()}-{$newformat}-"
+ . substr( $concert->cname(), 0, 30 )
+ );
+
// create a new calendar
$vcalendar = Vcalendar::factory( array( Vcalendar::UNIQUE_ID => 'kigkonsult.se' ) )
// with calendaring info