Hooks::filter_date_escaping( mixed $value, string $optionName )
Ensures that date formats are escaped properly.
Contents
Converts "\" to "\" for escaped characters.
Parameters
- $value
-
(mixed) (Required) The current value of the option.
- $optionName
-
(string) (Required) The option "key"
Return
(mixed) $value The modified value of the option.
Source
File: src/Tribe/Views/V2/Hooks.php
public function filter_date_escaping( $value, $optionName ) {
// A list of date options we may need to unescape.
$date_options = [
'dateWithoutYearFormat',
'monthAndYearFormat',
];
if ( ! in_array( $optionName, $date_options ) ) {
return $value;
}
// Don't try to run string modification on an array or something.
if ( ! is_string( $value ) ) {
return $value;
}
// Note: backslash is hte escape character - so we need to escape it.
// This is the equivalent of replacing any occurrence of \\ with \
$value = str_replace( "\\\\", "\\", $value);
//$value = stripslashes( $value ); will strip out ones we want to keep!
return $value;
}
Changelog
| Version | Description |
|---|---|
| 5.16.4 | Introduced. |