Bug in H5P in Wordpress

Hello, im using H5P with wordpress and im having a fatal bug, the content is not loading correctly, only its loaded the first time you see a page with H5P content, the rest of the times you display a page with H5P content it will not display.

I have found this differences in HTML with pages when it loads correctly and when it dont:

Correct display : <iframe id="h5p-iframe-2" class="h5p-iframe h5p-initialized" data-content-id="2" style="height: 474px;" src="about:blank" frameborder="0" scrolling="no"></iframe>

Wrong display: <iframe id="h5p-iframe-2" class="h5p-iframe" data-content-id="2" style="height:1px" src="about:blank" frameborder="0" scrolling="no"></iframe>

There are more differences, in the wrong one it looks like there is a wrong value returned by a funcion because in the corrct one you found this line :

"<script>H5PIntegration =  ...... "

But in the one that dont display the content this line is non existent.

If you need URLs of my site I can show them in private.

Thanks for your help



Hello, I reasearched more my problem and its related with another plugin I use that works in Ajax mode, so the H5P content is not reloaded in AJAX pages, is there a way to fix this??

Very Thanks.

I have found a fix for my problem, to insert the H5P content you should not use the shortcode but insert the HTML code to embed the H5P content.

BTW Thanks a lot for your plugin, is great I think.

icc's picture

Yes, unfortnuatly H5P doesn't work with AJAX straight out of the box. The problem is that the H5P Content need to be "started" after it's inserted into the page. That means that the script running the AJAX have to trigger H5P.init(newNode) to initialize the H5P content. 

Another way we could go about this is that we add a MutationObserver to the H5P plugin, it can listen for newly added content and then check if it contains any H5Ps. The problem is all structural changes we'd have to do to make room for the logic that loads the correct JavaScripts etc, as this is usually already inserted on a normal page load. However, this is a feature we're seriously considering for the next major version of H5P. 

Wether you can use the shortcode or you have to write the HTML, also depends on the plugin running the AJAX. It's the plugin's job to make sure any shortcodes are converted, but unfortnuatly not all plugins do support shortcodes in their AJAX content.
If shortcodes aren't supported I would try reporting this to the plugin author, or see if there are any issues 
concerning it.