Allowing user to control code is explicitly unsafe operation. As you note the purpose of sanitization is pretty much to not let user slip in anything executable and/or with malicious intent.
To “sanitize” executable code you would need programmatic understanding of it (code parser) and criteria engine to distinguish what is safe and what is not. For such requirements it is utopian.
Natively WordPress lets admin use JavaScript in post content. Now and then people report it as “horrible security vulnerability”, but really it’s just binary matter of trust — either you trust some user to input executable code or you don’t. There is essentially no middle ground or “but not that code” in this case.
Related Posts:
- Solutions for generating dynamic javascript / CSS
- Any alternate TinyMCE4 themes / subthemes?
- How to add material design css in wordpress and woocommerce
- What is the safe way to print tracking code / pixel code before tag or tag
- How to get javascript slider to work! [closed]
- How to escape multiple attribute at once in WordPress?
- How can I wrap all blog posts image with
- White screen when attaching css to function.php
- WordPress theme resource won’t load over VPN
- theme-independent CSS/JS files
- How to reuse parts of WordPress site e.g. header, footer, part of header for multiple WordPress sites?
- What is The Best Way to Make Parallax header effect for wordpress theme ?? pure CSS or using JavaScript? [closed]
- If necessary, how should wp_get_attachment_image() and its parameters be escaped?
- How to assess whether a WP core (or other) function is escaped already or not?
- jQuery not available to other scripts
- Using esc_url with a hard coded url
- How to make Isotope and WordPress work together?
- Theme Loading Into Dashboard
- What are the Entry classes for?
- Single page site with history.js
- Using PIE CSS in WordPress. “localizing” styles
- How to edit my theme for full width?
- How to check if a WordPress core block is active in sidebar
- Which html elements should be styled in wordpress theme
- How to override checkbox styles if these inputs have a unique id [closed]
- How to add styles set by user in the customizer
- Use second time navigation.js in underscores [closed]
- Font Awesome 5 Free – far working but fas is not? [closed]
- Theme Javascript.php Overwritten Nightly [closed]
- How remove render blocking css from wordpress when you build a theme?
- Why doesn’t my css work when I check my theme on mobile devices? [closed]
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- WordPress Unite Theme: Footer isn’t sticking [closed]
- Following Web Performance Optimization techniques to output static and dynamic css
- How to disable wordpress from overload my stylesheet styles with customizer styles
- Underscore Based Theme File Permissions in Git
- Theme Customizer not loading JS for live preview
- correct tags for validating input types
- How can I add custom text styles to the visual text editor?
- Displaying icon image for WordPress post formats, is there a cleaner way to do this?
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Internal Stylesheet in WordPress Theme development
- Combining CSS files into a single cached one
- Redirect to another page using contact form 7? [closed]
- How to i style the elements from the TinyMCE
- Using page-id-{ID} from body_class() in local dev, versus live staging
- My jQuery is enqueued properly. So why isn’t it working?
- Enqueued JavaScript is not working
- How to change footer or for different kinds of users in wordpress?
- How do I remove inline style in featured image markup?
- different way to achive stylesheet_url
- How do I use a color from theme options?
- Custom image size vs CSS sizing
- How to escape html generate by a loop
- Why is my CSS not loading?
- How to rotate every letter in a title
- Ideal inline dynamic CSS injection
- Theming Using Bootstrap Glyphicons and WordPress Dashicons
- How to register and enqueue JavaScript files without breaking plugin dependencies?
- Broken theme, template is missing
- wp_enqueue_script not working?
- JQuery undefined and Stylesheet loads in bottom along with js files
- Having issue with WordPress wp_enqueue_style
- Contact Form Security
- How do I use wp_nav_menu?
- Why would you use esc_attr() on internal functions?
- Is there any solution, ide/tool etc., for automatic escaping for WordPress?
- theme style is applied on the dhasboard rather than the website
- Assign custom classes to the divs inside the loop
- SVG in list-style-image breaks when adding fill
- How to safely return the HTML?
- pass wordpress template directory into ajax url call
- Do I need to escape get_the_post_thumbnail function?
- How to style bootstrap container in wordpress theme?
- CSS added through customizer neglects the need of a child theme?
- How to override template files in parent theme?
- Javascript development in Custom Themes
- LESS not working in WordPress [closed]
- Place title (in correct place) above image with opaque background [closed]
- A post with a clear:both in its css destroy the theme design, and the sidebar is moved to the bottom
- multiple html/css files for wordpress theme?
- CSS preprocessor file messed up after compiled
- add jquery file if a certain page is included
- Customize Option Framework
- Why I obtain different visualization when I run the website on my local machine and on remote server?
- Some doubts about WordPress handle the horizontal main menu visualization
- How to create a WP theme that use BootStrap? [closed]
- Can’t change theme name
- my single.php is mixup on some post for no reason
- How to use the _S framework
- header, stylesheet not being read
- Tiny MCE custom styles, and preview in the backend
- How to format the first line of a post differently?
- .current_page_ancestor broken in Twenty Eleven
- security concerns if using html data-* attribute for l10n?
- enqueuing external and internal js and css in wordpress did not work with owl.js animate.css
- WordPress Animation Adjustments
- Is there a list of default generated Gutenberg block CSS? Unable to align video blocks
- getBoundingClientRect() showing different values on load vs scroll
- style variations hurt the editing performance