h5p / h5p-wordpress-plugin

Adds support for H5P Content in WordPress.
https://wordpress.org/plugins/h5p/
71 stars 74 forks source link

[RESOLVED] Unable to load Editor on Windows based Virtual Machines on Windows Azure #65

Open fifthsegment opened 6 years ago

fifthsegment commented 6 years ago

I was unable to load the editor at all. When I checked the console; it seemed like the editor was constantly trying to load it's resources again and again but had the incorrect url : http://wp-content/xxxx . When I viewed source of my editor page, I realized the H5PIntegration object had an incorrect URL; all resource URL's were starting with a double slash instead of a single slash.

I think the regex used for doing preg_replace for generating URLs fails to generate a correct URL on Azure IIS based setups.

FIX: After spending a lot of time going through the source code, I finally found a simple fix (2 files):

FYI, I'm using version : 1.10.0.

1- h5p/admin/class-h5p-content-admin.php::add_editor_assets(). (Line # 945) After that line I added the following code: $url = str_replace('//', '/', $url);

2- h5p/public/class-h5p-plugin.php::add_core_assets(). (Line # 1114) After that line I added the following code: $rel_path = str_replace("//", "/", $rel_path );

Could you guys, please test out my fix and add it to the source code if it doesn't break anything else?

Thanks!

fifthsegment commented 6 years ago

Also, to get the embeds to work, I had to add the following:

3- h5p/h5p-php-library/h5p.classes.php::getAssetsUrls() (Line # 2065) After that line I added the following code: $url = str_replace('//', '/', $url);

icc commented 6 years ago

Could you check your WP_HOME and WP_SITEURL variables on the /wp-admin/options-general.php page or in the wp-config.php file? It sounds like one of these URLs may be ending with an extra slash. Though, it would probably be good if the code could handle such cases.