Discussion:
Ignore filtered_html
Dobri
2013-07-03 14:37:40 UTC
Permalink
Hi,

I'm working on a plugin for WordPress that adds Code Snippets. Brief overview: admin people create/edit the code snippets and then when an editor wants to include them on a page, they use a shortcode. However, I want to make sure that when the code snippet(which is just a post type) is being saved, no html filtering is done. My guess is it will be done with kses_remove_filters(). I'm having trouble hooking to the right place though. So, what would be a good hook to check that WP is currently saving, check it's my custom post type and be early enough to run kses_remove_filters()? Is content_save_pre with priority < 10 a good choice. I do get the content and I guess it's early enough to run kses... but can I check the post_type? Any other ideas? Thanks!

Dobromir Yordanov (Dobri)
Web Developer & WordPress Support Specialist
Ramapo College Web Team
Phone: (201) 684-6657

~Dobri
Nicholas Ciske
2013-07-03 15:39:05 UTC
Permalink
Use a meta box/custom field (i.e. turn off post_content in your CPT) and you can control how it's saved.

As it's a code snippet I imagine a true code editor like code mirror would be preferable over the standard html editor in WP?

If you want to use the content editor, this may be what you're looking for:
http://wordpress.stackexchange.com/questions/75568/wp-insert-post-disable-html-filter

Also note that there is a capability called unfiltered_html that has a bearing on whether or not HTML is filtered by default.

_________________________
Nick Ciske
http://thoughtrefinery.com/
@nciske
Post by Dobri
I'm working on a plugin for WordPress that adds Code Snippets. Brief overview: admin people create/edit the code snippets and then when an editor wants to include them on a page, they use a shortcode. However, I want to make sure that when the code snippet(which is just a post type) is being saved, no html filtering is done.
~Dobri
Loading...