-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathukmarrangementadmin.php
87 lines (74 loc) · 2.42 KB
/
ukmarrangementadmin.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
87
<?php
/*
Plugin Name: UKM Arrangement Admin
Plugin URI: http://www.ukm.no
Description: UKM Arrangement Admin side for å administrere arrangementet
Author: UKM Norge / Kushtrim Aliu
Version: 1.0
Author URI: http://www.ukm.no
*/
use UKMNorge\Wordpress\Modul;
require_once('UKM/Autoloader.php');
class UKMArrangementAdmin extends Modul
{
public static $action = 'placeholder';
public static $path_plugin = null;
/**
* Register hooks
*/
public static function hook() {
add_action('admin_menu', ['UKMArrangementAdmin', 'meny']);
add_action('wp_ajax_UKMArrangementAdmin_ajax', ['UKMArrangementAdmin', 'ajax']);
// self::scripts_and_styles(); // Attach scripts and styles hook
}
/**
* Håndterer alle ajax-kall
*
* @return void
*/
public static function ajax()
{
$reques_method = $_SERVER['REQUEST_METHOD'];
$subAction = $_REQUEST['controller'];
try {
require_once('ajax/' . $subAction . '.ajax.php');
// Noe gikk galt
} catch (Exception $e) {
static::addResponseData('success', false);
static::addResponseData('message', $e->getMessage());
static::addResponseData('code', $e->getCode());
}
$data = json_encode(static::getResponseData());
echo $data;
die();
}
/**
* Render menu
*/
public static function meny() {
// Placeholder for menu rendering
$page = add_submenu_page(
'index.php',
'Home Landsfestivalen',
'Home Landsfestivalen',
'editor',
'UKMArrangementAdmin',
['UKMArrangementAdmin', 'renderAdmin']
);
add_action(
'admin_print_styles-' . $page,
['UKMArrangementAdmin', 'scripts_and_styles']
);
}
/**
* Scripts and styles for admin pages
*/
public static function scripts_and_styles() {
// Remove empty submenu
wp_enqueue_style('UKMStatistikkVueMIDIcons', 'https://cdn.jsdelivr.net/npm/@mdi/font/css/materialdesignicons.min.css');
wp_enqueue_style('UKMArrangementAdminVueStyle', plugin_dir_url(__FILE__) . '/client/dist/assets/build.css', []);
wp_enqueue_script('UKMArrangementAdminVueJs', plugin_dir_url(__FILE__) . '/client/dist/assets/build.js', [], false, true);
}
}
UKMArrangementAdmin::init(__DIR__);
UKMArrangementAdmin::hook();