forked from tunapanda/wp-h5p-xapi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wp-h5p-xapi.php
86 lines (68 loc) · 1.76 KB
/
wp-h5p-xapi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
require_once __DIR__."/src/utils/Template.php";
use h5pxapi\Template;
/*
Plugin Name: H5P xAPI
Plugin URI: http://github.com/tunapanda/wp-h5p-xapi
Description: Send H5P achievements to an xAPI repo.
Version: 0.0.4
*/
/**
* 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"));
wp_enqueue_script("wp-h5p-xapi");
wp_register_style("wp-h5p-xapi",plugins_url()."/wp-h5p-xapi/wp-h5p-xapi.css");
wp_enqueue_style("wp-h5p-xapi");
$s.="<script>\n";
if (get_option("h5pxapi_endpoint_url"))
$s.="WP_H5P_XAPI_STATEMENT_URL='".plugins_url()."/wp-h5p-xapi/process-xapi-statement.php';";
else
$s.="WP_H5P_XAPI_STATEMENT_URL=null;";
$s.="\n";
$s.="WP_H5P_XAPI_CONTEXTACTIVITY= {
'id': '".get_permalink()."',
'definition': {
'type': 'http://activitystrea.ms/schema/1.0/page',
'name': {
'en': '".wp_title("|",FALSE)."'
},
'moreInfo': '".get_permalink()."'
}
};";
$s.="\n";
$s.="</script>";
echo $s;
}
/**
* Create the admin menu.
*/
function h5pxapi_admin_menu() {
add_options_page(
'H5P xAPI',
'H5P xAPI',
'manage_options',
'h5pxapi_settings',
'h5pxapi_create_settings_page'
);
}
/**
* Admin init.
*/
function h5pxapi_admin_init() {
register_setting("h5pxapi","h5pxapi_endpoint_url");
register_setting("h5pxapi","h5pxapi_username");
register_setting("h5pxapi","h5pxapi_password");
}
/**
* Create settings page.
*/
function h5pxapi_create_settings_page() {
$template=new Template(__DIR__."/src/template/settings.tpl.php");
$template->show();
// echo "hello world";
}
add_action('wp_enqueue_scripts','h5pxapi_enqueue_scripts');
add_action('admin_menu','h5pxapi_admin_menu');
add_action('admin_init','h5pxapi_admin_init');