Home › Forums › ACF PRO › Date Picker: Using escape-characters results in odd behaviour › Reply To: Date Picker: Using escape-characters results in odd behaviour
I was also able to correct this using a filter to avoid changing the ACF code directly, the preg_match()
will only do the replace if there is a single \
in the content, not a double \\
:
add_filter( 'content_save_pre', function( $content ){
global $post;
if ( get_post_type() == 'acf-field-group' ){
if ( preg_match( '~(?<!\\\\)\\\\(?!\\\\)~', $content ) ){
$content = str_replace('\\', '\\\\', $content);
}
}
return $content;
});
I’m including this filter in my Validated Field plugin since backslashes are pretty common in regular expressions which is one of the validations types I am supporting.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.