diff --git a/plugin.php b/plugin.php
index c33b802..d5b264e 100644
--- a/plugin.php
+++ b/plugin.php
@@ -17,9 +17,10 @@ function h5pxapi_get_auth_settings() {
$settings=array(
"endpoint_url"=>get_option("h5pxapi_endpoint_url"),
"username"=>get_option("h5pxapi_username"),
- "password"=>get_option("h5pxapi_password")
+ "password"=>get_option("h5pxapi_password"),
+ "alerts" => get_option("h5pxapi_alerts"),
);
}
return $settings;
-}
\ No newline at end of file
+}
diff --git a/process-xapi-statement.php b/process-xapi-statement.php
index cfeada3..fa60747 100644
--- a/process-xapi-statement.php
+++ b/process-xapi-statement.php
@@ -21,7 +21,7 @@
&& !$statementObject["context"]["extensions"])
unset($statementObject["context"]["extensions"]);
-if (has_filter("h5p-xapi-pre-save")) {
+if ( has_filter("h5p-xapi-pre-save")) {
$statementObject=apply_filters("h5p-xapi-pre-save",$statementObject);
if (!$statementObject) {
diff --git a/src/template/settings.tpl.php b/src/template/settings.tpl.php
index 5af73a7..bd03e14 100644
--- a/src/template/settings.tpl.php
+++ b/src/template/settings.tpl.php
@@ -94,6 +94,14 @@ class="regular-text"/>
class="regular-text"/>
+
+ Alerts On (un-checking will make debug statements happen to console instead of alert) |
+
+ />
+
+ |
+
diff --git a/wp-h5p-xapi.js b/wp-h5p-xapi.js
index f8fce4f..a1bb2c6 100644
--- a/wp-h5p-xapi.js
+++ b/wp-h5p-xapi.js
@@ -25,8 +25,11 @@ jQuery(function($) {
*/
function showError(message, code) {
console.error("Unable to save xAPI statement");
-
- alert("Unable to save result data.\n\nMessage: " + message + "\n" + "Code: " + code);
+ if( xapi_settings.alerts == true ){
+ alert("Unable to save result data.\n\nMessage: " + message + "\n" + "Code: " + code);
+ } else {
+ console.log("Unable to save result data.\n\nMessage: " + message + "\n" + "Code: " + code);
+ }
}
/**
@@ -124,4 +127,4 @@ jQuery(function($) {
$("body").append("Saving...
");
$("#wp-h5p-xapi-spinner").hide();
});
-});
\ No newline at end of file
+});
diff --git a/wp-h5p-xapi.php b/wp-h5p-xapi.php
index 802492c..8f92a2d 100644
--- a/wp-h5p-xapi.php
+++ b/wp-h5p-xapi.php
@@ -16,6 +16,7 @@
/**
* Enqueue scripts and stylesheets.
*/
+
function h5pxapi_enqueue_scripts()
{
wp_register_script("wp-h5p-xapi", plugins_url() . "/wp-h5p-xapi/wp-h5p-xapi.js", array("jquery"));
@@ -45,6 +46,7 @@ function h5pxapi_enqueue_scripts()
}
wp_localize_script('wp-h5p-xapi', 'xapi_settings', $xapi_js_settings);
+
}
/**
@@ -68,11 +70,13 @@ function h5pxapi_admin_menu()
/**
* Admin init.
*/
-function h5pxapi_admin_init()
-{
- register_setting("h5pxapi", "h5pxapi_endpoint_url");
- register_setting("h5pxapi", "h5pxapi_username");
- register_setting("h5pxapi", "h5pxapi_password");
+
+function h5pxapi_admin_init() {
+ register_setting("h5pxapi","h5pxapi_endpoint_url");
+ register_setting("h5pxapi","h5pxapi_username");
+ register_setting("h5pxapi","h5pxapi_password");
+ register_setting("h5pxapi", "h5pxapi_alerts");
+
}
/**