Thanks to naththedeveloper from StackOverflow. His answer worked for me.
Well, this was a nightmare to find, but I think I’ve resolved it after digging through the WordPress code which hooks in through
wp_insert_post
. Please add this to yourfunctions.php
file and check it works:
add_filter('kses_allowed_protocols', function ($protocols) {
$protocols[] = 'data';
return $protocols;
});
Essentially internally in WordPress, there’s a filter that checks the protocol of any URL’s in the content and strips any which it doesn’t like. By default, the supported list doesn’t support the data protocol. The above function just adds it to the list of supported protocols.
This filter does not run if you’re an administrator, which is probably why you’re seeing this issue only when logged out.
Thank you for your research.
Related Posts:
- Faster way to wp_insert_post & add_post_meta in bulk
- Is there a downside of using wp_defer_term_counting?
- wp_insert_post extremely slow on big table, direct query very fast
- wp_insert_post add meta_input
- tax_input not working wp_insert_post
- wp set object terms vs wp set post terms
- See error message from wp_insert_post function?
- Adding post thumbnail in programatically inserted post
- can’t edit post_modified in wp_insert_post (bug?)
- wp_insert_post incorrectly escapes HTML comments when they include tags
- What is considered the post’s creation date for wp_insert_post?
- Insert new term during new post creation
- wp_insert_post() getting slower the more posts
- tax_input argument for wp_insert_post()
- XMLRPC Avoid duplicate content
- wp_insert_post does not write my post_name
- Is there a way to fire other functions from wp_insert_post
- Change allowed HTML tags for comments
- Programmatically add terms to custom post types
- Organizing uploaded media with wp_insert_post() and wp_handle_upload according to time parameter
- wp_insert_post() Callback?
- Get data from wp_editor()
- wp_insert post doesn’t work
- Replace string with post_name on sidebar
- Visual Editor – Colorize Shortcodes
- wp_insert_post insert a post but return 0
- How to update post parent?
- wp_insert_post returns int(0)
- Contact Form 7 to featured image
- Conditionally set post_content in wp_insert_post
- How to use wp_insert_post to update meta box?
- after wp_insert_post need to get the post id
- Is wp_insert_post exactly the same as publishing a post through the core UI?
- Could not get post ID from wp_insert_post()
- Creating New Page with WP_INSERT_POST Issue
- wp_insert_post is not creating revision in database
- wp_insert_post issue
- Inserting post, thumnail and custom fields with wp_insert_post
- add_menu_page Callback Function: Skip page content?
- WPML – Set language of inserted post
- using wp_insert_post inside of custom meta box
- wp_insert_post or wp_set_post_terms do not save taxonomy, but wp_set_post_terms does
- Make WordPress process admin group comments using $allowedtags
- update_post_meta, xml parser
- wp_insert_post if page doesn’t exist under current page
- Check if post is added manually or through wp_insert_post()
- When User Meta amended update Title and Slug of Post programatically
- keep wp_insert_post from adding duplicates
- Add file while inserting post
- Combining wp_insert_post() and update_post_meta()
- Inline style HTML attribute is being stripped from all elements of a post
- Programmatically create a post once a day
- wp_insert_post custom type and custom taxonomies
- Where to call wp_insert_user() and wp_insert_post() from?
- Add action to create new post after wp_insert_post fires? Think it’s creating an infitnite loop
- wp_insert_post alternatives for faster process
- WP-CLI –meta-input error: Warning: Invalid argument supplied for foreach()
- tax_input in wp_insert_post partly not working
- Issue with wp_insert_post() when post_content contains links?
- $user_id = wp_insert_user( $userdata ) Not working no errors
- $wpdb->insert() does not insert fields
- oEmbded with wp_insert_post() [embedly]
- wp_insert_post Only creates draft
- Save the Post ID from wp_insert_post($post); into a text file?
- wp_insert_post removes information when updating
- Problem with wp_insert_post
- Bug in wp_insert_post script and form, probably something simple I am not seeing
- Setting Post Date Returning “Notice: A non well formed numeric value encountered”
- Custom terms inserting as single string with commas, not separated
- wp_insert_post creating duplicate post with Safari
- Inserting post_id into guid before wp_insert_post
- “transition_post_status” action creating two post with wp_insert_post
- wp_insert_post fails at return statement (nothing is returned to the caller, the error displayed is: The Link You Followed Has Expired)
- wp_insert_post always returns 0 on one site, extensive testing done, can’t get to the bottom
- wp_insert_post order problem
- wp_insert_post limit 25
- wp_insert_post() crashing website
- XML FOLDER – wp_insert_post – how to assign XML variables to post
- Cannot insert HTML content even removing kses filters
- get_page_by_title() not working as expected
- How can I automatically add a post with Latin characters?
- 500 error after wp_insert_post
- insert category from form in a post
- How to insert post from external php file?
- How to Create Content Remotely
- Get original post ID after wp_insert_post
- Update post_meta post_name with the post ID from wp_insert_post after user register
- Bulk insert posts is really slow and skips entries
- Insert post programmatically and decide to tweet or not to tweet
- Changing wp_insert_post() location
- wp_insert_post questions
- wp_insert_post does not insert string with apostrophes correctly
- Automatically add another subpost of the same parent when a subpost is saved
- Setting a featured image while creating the post
- Issues with post_content when using wp_insert_post
- foreach $FILES create post how to
- wp_insert_post and title not utf8 inserts with empty title?
- Cant get front end form to post to wordpress
- The reverse of wp_insert_post
- Set post_parent from URL params in post-new.php