Took me a bit to track this down, but I guess I should have heeded the 'it may behave unexpectedly in rare cases' waing ;)
It appears that when you add a custom oembed provider using wp_oembed_add_provider()
, with the 'Keep paragraph tags' option on, TinyMCE will still wrap a custom embed provider URL in paragraph tags, which means WordPress won't pick it up to do the embed. It works fine when this option is not selected.
There is (sortof) a way around it, although I've only got it working in some cases - it's to add the following function which sends URLs still wrapped in <p></p>
tags to WP's oembed callback:
add_filter("the_content", "mytheme_detect_wrapped_embeds", 11); // be sure it runs after wpautop on priority 10 function mytheme_detect_wrapped_embeds($content){ $content = preg_replace_callback( '|^<p>(s*)(https?://[^s"]+)(s*)</p>$|im', // URLs on their own line wrapped with <p></p> array($GLOBALS["wp_embed"], "autoembed_callback"), $content ); retu $content; }
I tracked down where the problem is - in this plugin under mcewptadvplugin.js
, the oembeds are manually defined (as they also are in WP core). So, I'm not sure of an easy way around this... but is it possible perhaps to have a way to hook new regexes into this file when a new oembed provider is added?
https://wordpress.org/plugins/tinymce-advanced/
WordPress ...
ما را در سایت WordPress دنبال می کنید
برچسب : نویسنده : استخدام کار wpss بازدید : 273 تاريخ : دوشنبه 27 ارديبهشت 1395 ساعت: 9:04