-
-
Save stephenharris/6078242 to your computer and use it in GitHub Desktop.
<?php | |
function myprefix_kses_allowed_tags($input){ | |
return array_merge( $input, array( | |
// paragraphs | |
'p' => array( | |
'style' => array() | |
), | |
'span' => array( | |
'style' => array() | |
), | |
// Links | |
'a' => array( | |
'href' => array(), | |
'title' => array(), | |
'rel' => array() | |
), | |
// Quotes | |
'blockquote' => array( | |
'cite' => array() | |
), | |
// Code | |
'code' => array(), | |
'pre' => array(), | |
// Formatting | |
'em' => array(), | |
'strong' => array(), | |
'del' => array( 'datetime' => true, ), | |
// Lists | |
'ul' => array(), | |
'ol' => array( 'start' => true, ), | |
'li' => array(), | |
// Images | |
'img' => array( | |
'src' => true, | |
'border' => true, | |
'alt' => true, | |
'height' => true, | |
'width' => true, | |
) | |
)); | |
} | |
add_filter( 'bbp_kses_allowed_tags', 'myprefix_kses_allowed_tags', 999, 1 ); | |
?> |
Sorry Chris, it seems like I suck at copy and pasting. The first gist was missing both a return
a array_merge
. (Also I used add_action
rather than add_filter
- but that doesn't really make a difference).
I'm surprised a load of errors didn't get thrown in your screencast...
I put the above snippet in my site's utility plug-in - but i'm sure your theme's functions.php or equivalent would work as well. I haven't got a test site with bbPress & MarkDown installed, but I'll give it a test later.
Ooooh that helped =). So the paragraph tags thing is solved, but other stuff is kinda out of whack.
Here's a series of steps:
- User authors some totally legit Markdown
- Some it it renders OK, and no paragraphs anymore, but a lot of it does not.
e.g. Three list items turned into to paragraphs, HTML stripped - If you edit the very same post, what you get in the edit textarea is very different from what was posted.
- If you save that it's extra whacky.
What's cool is that WP-Markdown in the normal blog comments area of WordPress works perfectly:
So it's possible!
If you have time to work on this, I'd be happy to pay your freelance rate if you do that kinda thing. And of course have it just go into the open source plugin.
Mmm.... For no.2 have you checked the actual HTML - it could be bullet points without the styling (At least, I recall having to tweak bbPress' css). On a test site everything rendered correctly (for admin / author ).
- Yup, can confirm an issue with editing posts - will need to look into it, but seems like the paragraph tags are stripped, before HTML is converted into markdown (?). At least lsits s So when you edit it you're not seeing the appropriate markdown - and hence re-saving (4) will save those errors to the database.
(Editing from the admin doesn't produce these errors, so maybe bbPress is doing something somewhere to the post content when editing it from the frontend.)
I'll try and take a proper look at this over the weekend. I do take on freelance work, but this is a plug-in I actively use and (try to) maintain. So if you want to buy me a beer, you can, but there's obligation :).
How can I add support for videos?
See:
https://bbpress.org/forums/topic/extra-tags-to-add-to-list-for-videos/#post-205701
I added:
'video' => array(
'controls' => true,
'width' => true,
'height' => true,
),
'source' => array(
'src' => true
)
But it is not right. The source
inner component gets stripped.
I gave this a shot and posted my results so far here: http://wordpress.org/support/topic/adding-extra-paragraph-tags-strange-editing?replies=4#post-4457309