The problem is not that the plugin adds a p tag. It actually may remove content which may leave empty lines. And those empty lines may result in orphan parargraphs or even single orphan p tags.
However, with the latest WordPress versions I could not find an example where this happens. Do you have an example how to reproduce this?
Hi Arno,
thank you very much for coming back to us.
One way to reproduce the problem is to just use a blank, new WordPress 4.9.8 and set up a new page with the following content…
<a href="https://www.ww.wp.xz.cn">Test</a>[timed-content-server hide="2019-SEP-12 16:00:00 Europe/Berlin"]<a href="https://www.ww.wp.xz.cn">ww.wp.xz.cn</a>[/timed-content-server]<a href="https://www.ww.wp.xz.cn">Test2</a>
You will see a p around all three links. One could guess now that all p tags are produced by WordPress p adding automatic. But when you install a plugin like “Toggle wpautop”, “Disable WPautop”, “Remove Wpautop” or “Manage WPAutoP” and disable auto p, the p around first and third link disappears, but not the p around timed-content-link.
Thanks for the example.
To explain the result:
WordPress passes the whole content inside the shortcode to the registered shortcode handler and the result of the shortcode handler will be used without without applying any filters at all.
Therefore Timed Content needs to apply a number of filters on the content. Otherwise it would not be possible to embed other shortcodes or more complex content as content (galleries etc.).
These filters are:
- wptexturize
- convert_smilies
- convert_chars
- wpautop
- prepend_attachment
- do_shortcode
The result is, that you can show or hide whole page sections with Timed Content even if these sections other shortcodes like Galleries – but on the other hand it is not possible to show or hide just simple text inside a line or paragraph.
I tried to remove the wpautop filter inside Timed Content and so far it looks OK, but I have to do further testing.
If you want to try this out – comment out line 1502 in timed-content.php:
Before:
add_filter('timed_content_filter', 'wpautop');
After:
// add_filter('timed_content_filter', 'wpautop');
This will remove the wpautop filter from the Timed Content handler and you should not get any extra p elements where you don’t expect them.
Even though the results looks promising, I still have to do more tests before I’ll publish an update.
According to https://codex.ww.wp.xz.cn/Shortcode_API WordPress indeed applies wpautop and wptexturize before executing shortcodes – therefore applying these filters inside the shortcode handler of Timed Content should not be needed at all. I’ll fix this with the next update.
Hello Arno,
well, this is perfect! Thank you for your versed reply… we are looking forward to the update. Until then we just passivated the p via additional CSS “display: inline”.
Thanks again and many greetings!
I just pushed an update (version 2.10) which should fix this problem.
Hi Arno,
perfect – now it works without any additional ps. Thanks for your quick fix!