Support

Account

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.