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]
- How to define and link full path to css located at a random folder on header.php
- What is the preferred way to add custom javascript files to the site?
- How to add custom css file in theme?
- CSS not updating in browser when I change it
- Do I actually need to link my theme’s style.css in the theme files
- CSS classes for theme
- Should `get_template_directory_uri()` be escaped?
- Splitting WordPress theme CSS into multiple files, good or bad?
- How to sanitize select box values in post meta?
- Google Maps not displaying in wordpress using Google Maps Javascript API
- When to use esc_url, esc_html, esc_attr, and friends?
- Suggestions for creative use of post format feature, or themes that use them well
- Add class to before_widget for all widgets with a dropdown and a counter
- What is the best practice for customizing a plugin’s JavaScript/jQuery?
- Add a preview to a WordPress Control Panel
- use add_action(‘wp_head’) in a widget for generating dynamic CSS styles
- How to Change CSS Variable value in Theme Customizer Live Preview
- CSS in child theme not overriding the parent theme [closed]
- How to add (css) classes to only one wp_nav_menu()?
- Adding dashicon fonts to the admin of pre 3.8 installs
- How to keep theme layout the same when admin gray bar is present?
- wp_head() not inserting the default stylesheet style.css
- Writing Clean WooCommerce Styles
- De-registering parent style sheet css recommended?
- WordPress Customizer Control with React
- Alterntives to BEM syntax that comply with WordPress coding standards? [closed]
- WordPress 5.8 update problem custom theme styles are overridden by core styles common.min.css
- WordPress default theme css units
- Where is definied the theme location for the main menu in a WordPress template?
- How to correctly add JQuery in a WP theme?
- current-menu-item class not working
- enqueue_style is not working
- Weekly background code not working
- How do the default themes reference style.css?
- JavaScript Change focus to password field login page being reset
- Is it possible to edit the styling of the admin panel from within a custom theme?
- Using esc_url with a hard coded url
- What are the Entry classes for?
- Single page site with history.js
- How to edit my theme for full width?
- How to add styles set by user in the customizer
- Use second time navigation.js in underscores [closed]
- How remove render blocking css from wordpress when you build a theme?
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- Following Web Performance Optimization techniques to output static and dynamic css
- Displaying icon image for WordPress post formats, is there a cleaner way to do this?
- Internal Stylesheet in WordPress Theme development
- Redirect to another page using contact form 7? [closed]
- My jQuery is enqueued properly. So why isn’t it working?
- How to rotate every letter in a title
- Theming Using Bootstrap Glyphicons and WordPress Dashicons
- Broken theme, template is missing
- wp_enqueue_script not working?
- Having issue with WordPress wp_enqueue_style
- Why would you use esc_attr() on internal functions?
- How to safely return the HTML?
- pass wordpress template directory into ajax url call
- Do I need to escape get_the_post_thumbnail function?
- Javascript development in Custom Themes
- CSS preprocessor file messed up after compiled
- add jquery file if a certain page is included
- Customize Option Framework
- Some doubts about WordPress handle the horizontal main menu visualization
- Can’t change theme name
- How to format the first line of a post differently?
- 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
- How to create a robust and logic class naming system in WordPress theme developing?
- echo cutom css code to WordPress page template file ? is this safe?
- 3 Level Menu Navigation (3rd Level not displaying)
- How to enqueue scripts properly with ES6 webpack?
- register dependency css and js inside a plugin class
- Correct form of escaping and localization – functions.php breadcrumbs
- wp_kses allow checkbox class and checked
- How to fix an issue with customizer live preview?
- How would I get this to work – send to post from thick box
- Custom CSS no getting applied
- editor style css and page template with and without sidebar
- Why the slideshow is not shown in my theme?
- Theme customizer live preview JS- Trying to bind to an html image url without luck
- Set start page depending on screen width [closed]
- wp_deregister_script was called incorrectly
- Custom link color or stylesheets
- How to highlight current menu bar base on the URL?
- How can i move my product name & price from below thumbnail to be the rollover content in Avada & Woocommerce?
- Should we escape the values of constants?
- WordPress search field won’t get wider
- When trying to run build script with gutenberg (with SVG import) – Error: Plugin name should be specified