@rpetitto, thanks for the updated code. Just wanted to let you and anyone reading this in the future, I got the following error message when using your code.
( ! ) Strict standards: Declaration of myCRED_Hook_H5P::sanitise_preferences() should be compatible with myCRED_Hook::sanitise_preferences($data) in E:\wordpress-development\localhost\devdomain.dev\wp-content\plugins\mycred-h5p-master\mycredh5p.php on line 49
To fix the issue, I replaced your code between lines 120 – 122 with the following:
/**
* Sanitize Preferences
*/
public function sanitise_preferences( $data ) {
$new_data = $data;
// Apply defaults if any field is left empty
$new_data['creds'] = ( !empty( $data['creds'] ) ) ? $data['creds'] : $this->defaults['creds'];
$new_data['log'] = ( !empty( $data['log'] ) ) ? sanitize_text_field( $data['log'] ) : $this->defaults['log'];
return $new_data;
}
If we can confirm that the code is bug free, you or @icc0rz should submit it to myCred for listing on their website. Gabriel is a good guy with a very useful plugin and I think this could be helpful to many others in the future.