Why is javascript allowed in my post content?
If you have the unfiltered_html capability then you can use JS. Admins and editors have this capability by default.
Personally I use a plugin for fine control of my users’ capabilities, but you can make this change easily in code:
$role = get_role( 'administrator' );
$role->remove_cap( 'unfiltered_html' );
$role = get_role( 'editor' );
$role->remove_cap( 'unfiltered_html' );
The capabilities are stored in the options db table, so technically you don’t need to execute this repeatedly. Maybe make yourself a small plugin and put this on the activation hook.
Don’t forget that admins could circumvent this by loading their own code and then directly editing the role options. I never let anyone have the admin role unless I’m happy for them to do anything.
Related Posts:
- How to add defer=”defer” tag in plugin javascripts?
- How to add a custom CSS class to core blocks in Gutenberg editor?
- How to pass/get data to/from the WooCommerce data-product_variations object?
- Insert Custom HTML After Shortcode
- AJAX filter posts on click based on category
- Remove left alignment option in core/image block
- remove other tabs in new wordpress media gallery
- Format content value from DB outside of WordPress filters
- How can I filter block registration based on post-type? (Block alignment settings)
- Add attribute to script loaded by the theme
- When to use add_action when registering/enqueuing scripts
- Remove CSS & JS files from WordPress Main Page For Increase Pagespeed?
- Where is the content cache when using apply_filters(‘the_content…?
- How to filter post content and force every link () made in blocks to return urldecode() with readable value?
- upload_files cap to not loggen in users – add_cap to not logged in users
- How to display the content HTML of a page without displaying the gallery code as well
- Can I override the content array using the_posts filter?
- Stripping URLs & Email from post submissions
- How do I add tags to entire comments, not just their text
- “The editor has encountered an unexpected error” After add defer tag to java script
- How to bridge the gap between dynamic back-end data and front-end output?
- Add class to all parent elements inside the_content
- How would I remove an inline googleAPI font script in the the parent theme header.php?
- This code works, but breaks the media uploader. How do I integrate it in a way that won’t?
- How to correctly override a filter?
- Limit total tags in the_content
- WordPress REST API and Backbone JS
- Modify Gutenberg blocks quick inserter defaults
- Disable emojicons introduced with WP 4.2
- How to remove a filter that is an anonymous object?
- WordPress hooks/filters insert before content or after title
- add_action(), add_filter() before or after function
- apply_filters(‘the_content’, $content) vs do_shortcode($content)
- How do filters and hooks really work in PHP
- Trouble understanding apply_filters()
- What is the very earliest action hook you can call?
- How would one modify the filtering Gutenberg applies to pasted content?
- How can I modify the WordPress default widget output?
- Add custom options to the wplink dialog
- Remove classes from body_class
- what is __return_false in filters
- Explanation for apply_filters function and its variables
- Gutenberg: Is there a way to know if current block is inside InnerBlocks?
- How to reorder billing fields in WooCommerce Checkout template? [closed]
- Insert HTML just after tag
- the_content and is_main_query
- Changing WooCommerce Display Price Based on User Role & Category [closed]
- How to show page content in feed?
- wp_headers vs send_headers. When to use each?
- Filter any HTTP request URI?
- How to Pass External Variables to Filters/Actions
- How to filter users on admin users page by custom meta field?
- Filter by one custom field, order by another?
- Not able to change wp_title using add_filter
- How to appending to the_content using add_filter with custom post type?
- Query WP REST API v2 by multiple meta keys
- No filter of code on switch from html to visual editor, how?
- Sanitize and data validation with apply_filters() function
- How to modify posts_where filter only for the search query
- How to hook a filter to catch get_post_meta when alternate a custom field output?
- How to get shortcode’s input values inside a filter?
- Removing Image and Caption Dimension Attributes
- How to wrap oEmbed-embedded video in DIV tags inside the_content?
- How to bulk delete all users with no posts?
- How many filter/action hooks are healthy?
- WordPress 3.9 – Trouble Editing TinyMCE 4.0
- Changing JPEG compression depending on image size
- How to add filter with 2 args?
- How to use update_{$meta_type}_metadata filter to modify meta value
- How to wrap an element around an iframe or embed in content automatically?
- Filter specific shortcode output?
- WordPress Internal @ Mentions
- How to add headers to outgoing email?
- Earliest hook to reliably get $post/$posts
- Insert new element to array with add_filter
- LESS CSS enqueue_style with add_filter to change rel attribute
- Is it possible to filter comments in a post so a user can only see the comments they have written?
- Remove Editor From Homepage
- How to modify Contact Form 7 Success/Error Response Output [closed]
- Where to hook into post content?
- What does (10, 2) mean when used with add_filter
- Filter translations (gettext strings) on specific admin pages
- Filter username field on registration for profanity and unwanted words
- Clarification on filters and hooks
- remove_filter( ‘the_content’, ‘wpautop’ ); only for certain post types
- At what priority does add_filter overwrite core functions?
- Valid characters for actions, hooks and filters
- is it possible to add “extra” table nav to edit-tags.php screens?
- Advanced Custom Fields and Yoast SEO keyword analysis [closed]
- Adding a filter to qTranslate to change display of language chooser
- Modify links when inserted by WYSIWYG editor
- Is there a way to add another row to the tinyMCE kitchen sink toggle?
- How to hook into unregistering a widget instance?
- How to check if a hook is hooked or not?
- Completely strip any hidden formatting when pasting into TinyMCE
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- How to add filter to __() and _e()?
- Remove description from on Home
- Editing ‘Password Reset’ E-mail
- Is it possible to use object in add_action?