Azure Hosted Wordpress not showing Content Hub

I have a Wordpress site which is hosted in an Azure app service (so runs using IIS).

I have installed and activated the H5P Plugin and it all went through fine, but when I go to the H5P menu and click the button to Add Content, the Hub does not show up. It allows me to enter a name in the Add New box, but then when I click the 'Create' button it says 'Invalid Library'.

I uploaderd a few libraries for Memory Game, Personality Quiz and Questionnaire, but this has still not helped.

I checked the documentation which said to check my PHP extensions (mbstring, openssl and zip are all enabled) and it also mentioned to test connectivity to h5p.org - I successfully pinged the address from the Azure App console.

I have the same issue with Chrome, IE and Firefox.

I'm on Wordpress v4.9.4, PHP v7.0.27, H5P v1.10.1 

I am getting console errors in Chrome (see attached) for Get requests, but I'm not sure what's causing it.

Can anybody help please?

Many thanks

Attachments: 

I have the same problem (and posted it yesterday but cannot find it in the forum)... hope for an answer

Does anyone else have suggestions on how I can get this resolved please?

icc's picture

There appears to be some sort of domain URL issue. Are you sure the WP Setting page have the correct address for the page?

Also, double check you PHP Error Log for any messages.

Hi all,

we had the same problem. It is the combination of WordPress and Azure. In the wp-config.php there are settings for relative URLs which are needed for the deployment slots. I changed the settings and everything exploded :) But I found a solution, at least for us.

We use a child theme and in the functions.php I had to hook into two WordPress functions: plugins_url and upload_dir and change the relative urls to absolute. See code below.

Now we can update the plugin without issues.

function h5p_filter_plugins_url( $url ) {
  if (strpos($url, 'h5p/') !== false) {
    return get_site_url() . $url;
  }
  return $url;
}
add_filter( 'plugins_url', 'h5p_filter_plugins_url' );

function h5p_upload_dir_override( $param ) {
  $url = $param['baseurl'];
  $param['baseurl'] = get_site_url() . $param['baseurl'];
  return $param;
}
add_filter( 'upload_dir', 'h5p_upload_dir_override' );
icc's picture

That is great, thank you for sharing the solution!

There seems to be a bug in the Azure Template for WordPress as an AppService.

Changing the wp-config.php from:

//Relative URLs for swapping across app service deployment slots 
define('WP_HOME', 'http://'. filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING));
define('WP_SITEURL', 'http://'. filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING));
define('WP_CONTENT_URL', '/wp-content');
define('DOMAIN_CURRENT_SITE', filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING));

To:

//Relative URLs for swapping across app service deployment slots 
define('WP_HOME', 'http://'. filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING));
define('WP_SITEURL', 'http://'. filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING));
define('WP_CONTENT_URL', 'http://'. filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING).'/wp-content');
define('DOMAIN_CURRENT_SITE', filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING));

solved the problem on our side.