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
- Why doesn’t remove_action work in my plugin?
- Using a filter to modify Genesis wp_nav_menu
- How to wrap all titles generated by Gutenberg “Heading” block with tag
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- Filters on Login Page
- How can I change the email that is inside the default email texts of wordpress?
- the_excerpt filter doesn’t work as expected
- How to filter link?
- Conditional does not work with add_filter
- What is the earliest hook to modify post content?
- How to modify only part of a function through the filter
- Modify message displayed on post save
- Something is filtering my shortcodes… Can’t figure out what
- How can I apply filters in my class that extends Walker_Nav_Menu?
- Pass debug_backtrace() in WordPress filter
- How should I be using filters and is_single together?
- Remove actions/filters that are set with create_function()
- How to edit embed filter for youtube video to allow responsive full width layout
- Remove get_template_part() from custom theme
- How to access page variable inside action hook
- Use has_filter on comment_post
- Shorten the title length
- Problem with Class, Filters and Callbacks
- Renaming wordpress login and get new password button
- Hook in a sidebar widget and add some markup
- preg_match() not working with post content
- Search a title word through query_posts (not the exact match)
- Parse a shortcode differently based on on what it’s nested in
- return get_the_tag_list with whitespace removed
- Elementor Image Hover + Filter Grid [closed]
- How to redirect template_directory to subdomain relativ url?
- ‘manage_users_custom_column’ is a filter, but ‘manage_posts_custom_column’ is an action. Why?
- comment_notification_text filter not working
- Line Breaks are stripped off when direction property is found
- Scanning for custom embed and prefetching
- Modify author url display in edit-comments.php
- WordPress remove_filter not working
- How to exclude or include categories in wp rest API without query parameters?
- Remove and replace woocommerce add to cart button [closed]
- add_filter( ‘the_title’ gets through this if statement twice
- Changing the category for existing Gutenberg blocks
- Filter Post Title without affecting screen-reader-text
- Hook to change the site URL
- Replace a specific URL on all apperances on the Website (Maybe a filter?)
- Modify WordPress Page Title ()
- How to add lazy field in content endpoint using Gutenberg blocks
- Strange behaviour of REGEX in a WordPress filter (trying to suppress emtpy paragraphs)
- Modify Contextual Help
- how to use apply filter for Class?
- How can I see exactly what arguments are being passed through a filter so that I may modify them?
- Widget image reorganize layout
- WordPress set featured image to first image of the post
- Modify WordPress search behaviour in backend?
- Re-order search results with posts_orderby filter and post meta value
- Set Microsoft Word links to open in new window/tab
- WordPress get_avatar filter to match logins
- Modify category listing API response
- Auto-generated excerpt with shortcode and read more button/text link
- ‘the_content’ Filter delivers empty string with lengh (608)
- Testing requested query in pre_get_posts
- Output dynamic_sidebar_params in wp_head
- How to sort posts according to meta value?
- Converting restricted html in comments to bbcode
- What is the proper/best way to have multiple add_filter for wp-job-manager-resume
- Modify WooCommerce email shipping text value
- How do I add a class to all sidebars to let a Google Custom Search Engine know not to index the content?
- How to replace all images in all posts and pages with a different size?
- Using Filters To Change Page Title
- How to add a class to Buddypress avatars in the Activity stream? [closed]
- using posts_where for meta data on pre_get_posts
- can’t output gray scaled image I’ve created using add_image_size
- remove_filter excerpt_more from a plugin class
- How properly write function to filter content in a template for plugin “multiple content blocks”
- ACF Load Field Groups Programmatically [closed]