forked from otacke/h5p-sharing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-admin.php
67 lines (54 loc) · 2.04 KB
/
class-admin.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
<?php
namespace H5PSHARING;
/**
* Admin
*
* @package H5PSHARING
* @since 0.1
*/
class Admin {
public function __construct() {
// Identify what action the H5P plugin is up to
$uri = parse_url( $_SERVER['REQUEST_URI'] );
$path = explode( '/', $uri['path'] ); // array_pop needs reference
$destination = array_pop( $path );
if ( 'admin.php' !== $destination ) {
return; // Not relevant
}
parse_str( $uri['query'], $queries );
if ( 'h5p' === $queries['page'] && isset( $queries['task'] ) && 'show' === $queries['task'] ) {
// View content type $queries['id'] as admin
$this->inject_sharing_info( $queries['id'] );
}
}
/**
* Inject data tables
*/
private function inject_sharing_info( $content_id ) {
// Set up localization
$l10n = array(
'clickToEnlarge' => __( 'Click to enlarge', 'H5PSHARING' ),
'clickToShrink' => __( 'Click to shrink', 'H5PSHARING' ),
'copied' => __( 'Copied!', 'H5PSHARING' ),
'copy' => __( 'Copy', 'H5PSHARING' ),
'directLink' => __( 'Direct link', 'H5PSHARING' ),
'embeddingNotAllowed' => __( 'Embedding / linking to this content has been disabled in the settings.', 'H5PSHARING' ),
'embedLinkUnretrievable' => __( 'The link to the content can\'t be retrieved.', 'H5PSHARING' ),
'embedSnippet' => __( 'HTML embed code snippet', 'H5PSHARING' ),
'qrcode' => __( 'QR Code', 'H5PSHARING' ),
'title' => __( 'H5P Sharing', 'H5PSHARING' ),
);
// Include scripts and styles
wp_enqueue_script( 'QRCode', plugins_url( '/js/qrcode.js', __FILE__ ), array(), H5PSHARING_VERSION );
wp_enqueue_script( 'InjectSharingInfo', plugins_url( '/js/inject-sharing-info.js', __FILE__ ), array(), H5PSHARING_VERSION );
// Pass variables to JavaScript
wp_localize_script( 'InjectSharingInfo', 'contentId', [ $content_id ] );
wp_localize_script( 'InjectSharingInfo', 'l10n', $l10n );
}
/**
* Initialize class variables/constants
*/
static function init() {
}
}
Admin::init();