$url = esc_url ( str_replace(' ' , '-', $url ) );
Replace the spaces to – chars before activating esc_url function, and your problem is solved.
Related Posts:
- Should I sanitize an email address before passing it to the is_email() function?
- Escaping and sanitizing SVGs in metabox textarea
- What is the difference between wp_strip_all_tags and wp_filter_nohtml_kses?
- Reason for Lowercase usernames
- What is the best way to sanitize data?
- Should nonce be sanitized?
- WP Coding standards – escaping the inescapable?
- Sanitatizing when using the posts_where hook
- Escape hexadecimals/rgba values
- Must I serialize/sanitize/escape array data before using set_transient?
- Echo JavaScript Safely
- wp_kses ignore allowed and allow everything
- Sanitize array callback for the WordPress Settings API
- How to escape $_GET and check if isset?
- What’s a safe / good way to output HTML safely within WordPress templates?
- Do Not Understand → Rule No. 4: Making Data Safe Is About Context [closed]
- Sanitizing output that contains quotes?
- WP_Customize_Manager: How to get control ID
- How to use wp_filter_oembed_result?
- Sanitization html output itself
- Post text sanitization after publishing/editing – changes are not saved
- wp_set_object_terms() without accents
- Escaping data from database (users table) is necessary?
- Properly sanitize an input field “Name “
- What is the proper way to sanitize $_POST and $_GET vars?
- Why is sanitize_text_field() selectively trimming data?
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- wordpress sanitize array?
- Should HTML output be passed through esc_html() AND wp_kses()?
- Sanitize content from wp_editor
- What’s the difference between esc_* functions?
- Sanitizing integer input for update_post_meta
- Sanitize User Entered CSS
- Which KSES should be used and when?
- Is sanitize_text_field() is enough to save to DB?
- How to sanitize select box values in post meta?
- WP doesn’t show Array Custom Fields?
- Shortcode putting html such as
- How to properly sanitize strings without $wpdb->prepare?
- how to sanitize checkbox input?
- Sanitizing post content for use in an email
- Is there an equivalent of the PHP function sanitize_key in Gutenberg?
- How to get input_attrs in the sanitize function?
- What is the difference between sanitize_text_field() and wp_filter_nohtml_kses()?
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- Sanitizing search data for use with WP_Query
- How to sanitize post meta field value?
- where to apply “apply filters” and other Sanitization Functions
- How to save html and text in the database?
- Data Validation: Always escape late / escape HTML Code
- Multiple register settings, with same option name – issue
- Filter string like a slug
- Sanitize textarea instead of input
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- vs WordPress Security
- Cannot get ‘sanitize_callback’ to work for rest parameters
- How to sanitize user input?
- Change filename during upload
- wpdb get_results() and prepare when to use prepare?
- Preserve old values on error in setting API
- WP_Editor – Saving Value into Plugin Option – Stripping HTML
- CSS from textarea in options page to frontend what to do
- How to get rid of shortcodes in post content once and for all
- What is the safe way to print tracking code / pixel code before tag or tag
- Unable to sanitize in customizer and escape in theme without removing ability for user to use “< br >” to insert a line break
- sanitize_text_field and apostrophe problem
- What data sanitzation function should be used to store entire source code of webpage?
- What functions does WordPress use for filtering / sanitizing comments?
- Why the WP Core team does not allow filter_* functions? [closed]
- data-type=”” … needed post tags stripped of characters
- wordpress is adding a second backslash when I use addslashes
- confused about sanitize_email after is_email [duplicate]
- Trouble creating custom sanitization function for user list dropdown
- Invalidate username if it contains @ symbol
- Contact Form Security
- How to allow certain PHP functions when using sanitize_callback in the word press customizer
- Display the line breaks in user bio without using html
- Change user nicename without sanitize
- HTML in category name
- How can I apply custom sanitization to new usernames?
- How do I sanitize the str_replace function in javascript variables
- Sanitizing textarea for wp_insert_post with TinyMCE enabled or disabled
- Safely store code(html/js..) into database
- Do I need to sanitize $_POST[‘keyword’] before send to ‘s’ parameter?
- Can non-latin characters appear in slugs?
- Data Validation & Sanitization for Big HTML Blocks
- Where is the HTML-handler part in the wpdb class?
- I need to get the control choices to sanitize_callback
- Can we validate data from jquery
- Escaping WP_Query tax_query when term has special character(s)
- Trouble creating custom sanitization function when uploading video files
- Custom-Metaboxes-and-Fields text_url field prepending http://
- Data validation for inline javascript
- Sanitize and Save metabox values
- esc_url, esc_url_raw or sanitize_url?
- Does it make sense to sanitize the output of an SVG file?
- Sanitization of register_setting()
- How to sanitize settings API value
- WooCommerce custom SVG coloring tool [closed]
- sanitize meta input