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
- How to remove a filter that is an anonymous object?
- How do filters and hooks really work in PHP
- Trouble understanding apply_filters()
- How would one modify the filtering Gutenberg applies to pasted content?
- No filter of code on switch from html to visual editor, how?
- How to modify posts_where filter only for the search query
- How to wrap oEmbed-embedded video in DIV tags inside the_content?
- How to add filter with 2 args?
- is it possible to add “extra” table nav to edit-tags.php screens?
- How to apply the “retrieve_password_message” filter?
- wp_mail – Remove sitename from email subject
- How to change/rewrite the lost password url?
- add_filter multiple times with different addon functions?
- WP Rest API – Upload media without saving attachment post
- Using variable from one filter in another filter
- add class to term_description
- How can I find out what an `apply_filter` call is actually doing?
- How to apply content filter permanently?
- Customize the “Registration complete. Please check your e-mail.” message on WP 4.0
- posts_groupby problem
- Remove classes from post_class()
- Replace a part of url generated by get_term_link
- Error when overriding only some audio shortcode HTML output
- Run oembed separately outside the_content()
- Hook Into the_content Filter For JSON API Only [closed]
- How to call a function or method that is Namespaced using another plugin
- apply_filters(‘the_content’) – make it ignore shortcodes?
- Replace a word with a word in the URL string
- Remove style `?ver=` from `/wp-admin/upgrade.php`
- theme_page_templates not working
- Filter custom post type using multiple taxonomy dropdowns
- Add new post with predefined / preset date
- Remove Actions added by SEO ultimate Plugin
- Building a request processor for multi-page forms, etc using $_GET requests
- Replace audio links with jplayer using the_content filter
- Sorting a specific taxonomy by archive date using URL
- Modify Redux Framework Options in Child Theme
- Contact Form 7 Custom Validation Doesn’t Get Called [closed]
- How to filter bbPress replies (content)?
- Trimming a custom field to a length
- How to add a filter to the get_body_class function?
- How to hide/remove GhostKit component panel in gutenberg block inspector
- Change user nicename without sanitize
- when use function the_content break
- Filter page title (displayed in browser tab) of wp-login
- Adding html banner to posts
- How can I get the default content of WordPress post?
- How do I hide tinymce within the edit screen of a particular page
- What would cause the gettext filter to not work for a given text domain?
- How does wordpress add ‘style’ attribute to element
- How do I safely force get_theme_mod() to use a defined get_option(“stylesheet”) value?
- Shortcode / plugin with custom (flexible) output
- Filter “Your latest posts”
- Is it better to use a constant or apply_filter?
- Hooked into wp_get_attachment_caption to add content to the default description; not working for jetpack slideshow. Why?
- Removing menus from users other than the administrator
- Remove image of srcset
- Add option to query string before get_posts() is called on archive.php
- Modify wp headers on specific page
- How can I add a prefix to titles displayed in sidebar using function.php?
- How to make the show as a button?
- List all image sizes still getting disabled sizes
- Why this remove empty paragraphs from the_content does not works?
- Take filter from multiple functions
- What problems could happen if I replaced add_filter and add_action with the function calling
- WP REST API v2. filters doesn’t work
- Adding to an array & passing it through do_action/apply_filters
- Custom excerpt_more filter not working when tag is present
- Taxonomy search filters
- NextGEN Gallery: Adding drop-down menu widget to gallery view without modifying plugin code [closed]
- Modify the third (context) parameter in a filter?
- WordPress wp_lazy_loading_enabled returns loading attribute set to lazy
- Deregister Custom the_title Filter for edit_post_link
- Is it possible to dynamically change the “page_for_posts” option?